#include <matrix.hpp>
Public Types | |
typedef Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor|Eigen::AutoAlign > | Base |
Public Member Functions | |
GenericMatrix | absolute () const |
GenericMatrix & | appendCols (const GenericMatrix &_arg) |
GenericMatrix & | appendRows (const GenericMatrix &_arg) |
template<typename OtherDerived > | |
GenericMatrix (const Eigen::MatrixBase< OtherDerived > &other) | |
template<typename OtherDerived > | |
GenericMatrix (const Eigen::ReturnByValue< OtherDerived > &other) | |
template<typename OtherDerived > | |
GenericMatrix (const Eigen::EigenBase< OtherDerived > &other) | |
GenericMatrix< T > | getAbsolute () const |
GenericVector< T > | getCol (unsigned _idx) const |
GenericMatrix | getCols (unsigned _start, unsigned _end) const |
T | getConditionNumber () const |
GenericVector< T > | getDiag () const |
unsigned | getDim () const |
T | getMax () const |
T | getMean () const |
T | getMin () const |
T | getNorm () const |
unsigned | getNumCols () const |
unsigned | getNumRows () const |
GenericVector< T > | getRow (unsigned _idx) const |
GenericMatrix | getRows (unsigned _start, unsigned _end) const |
T | getTrace () const |
void | init (unsigned _nRows=0, unsigned _nCols=0) |
bool | isEmpty () const |
bool | isPositiveDefinite () const |
bool | isPositiveSemiDefinite () const |
bool | isSquare () const |
bool | isSymmetric () const |
GenericMatrix & | makeVector () |
GenericMatrix | negative () const |
bool | operator!= (const GenericMatrix &arg) const |
bool | operator== (const GenericMatrix &arg) const |
GenericMatrix | positive () const |
virtual returnValue | print (std::ostream &_stream=std::cout, const std::string &_name=DEFAULT_LABEL, const std::string &_startString=DEFAULT_START_STRING, const std::string &_endString=DEFAULT_END_STRING, uint _width=DEFAULT_WIDTH, uint _precision=DEFAULT_PRECISION, const std::string &_colSeparator=DEFAULT_COL_SEPARATOR, const std::string &_rowSeparator=DEFAULT_ROW_SEPARATOR) const |
virtual returnValue | print (std::ostream &stream, const std::string &name, PrintScheme printScheme) const |
virtual returnValue | print (const std::string &_filename, const std::string &_name=DEFAULT_LABEL, const std::string &_startString=DEFAULT_START_STRING, const std::string &_endString=DEFAULT_END_STRING, uint _width=DEFAULT_WIDTH, uint _precision=DEFAULT_PRECISION, const std::string &_colSeparator=DEFAULT_COL_SEPARATOR, const std::string &_rowSeparator=DEFAULT_ROW_SEPARATOR) const |
virtual returnValue | print (const std::string &_filename, const std::string &_name, PrintScheme _printScheme) const |
virtual returnValue | read (std::istream &_stream) |
virtual returnValue | read (const std::string &_filename) |
void | setAll (const T &_value) |
GenericMatrix & | setCol (unsigned _idx, const GenericVector< T > &_arg) |
GenericMatrix & | setRow (unsigned _idx, const GenericVector< T > &_values) |
GenericVector< T > | sumCol () const |
GenericVector< T > | sumRow () const |
returnValue | symmetrize () |
virtual | ~GenericMatrix () |
Constructors. | |
GenericMatrix () | |
GenericMatrix (const T &_value) | |
GenericMatrix (unsigned _nRows, unsigned _nCols) | |
GenericMatrix (unsigned _nRows, unsigned _nCols, const T *const _values) | |
GenericMatrix (unsigned _nRows, unsigned _nCols, std::vector< T > &_values) | |
GenericMatrix (unsigned _nRows, unsigned _nCols, std::vector< std::vector< T > > &_values) |
A generic matrix class based on Eigen's matrix class.
Definition at line 49 of file matrix.hpp.
typedef Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor | Eigen::AutoAlign> GenericMatrix< T >::Base |
Handy typedef for the base matrix class.
Reimplemented from Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor|Eigen::AutoAlign >.
Definition at line 59 of file matrix.hpp.
GenericMatrix< T >::GenericMatrix | ( | const Eigen::MatrixBase< OtherDerived > & | other | ) | [inline] |
Constructor from any other Eigen::MatrixBase derived class.
Definition at line 64 of file matrix.hpp.
GenericMatrix< T >::GenericMatrix | ( | const Eigen::ReturnByValue< OtherDerived > & | other | ) | [inline] |
Constructor from any other Eigen::ReturnByValue derived class.
Definition at line 68 of file matrix.hpp.
GenericMatrix< T >::GenericMatrix | ( | const Eigen::EigenBase< OtherDerived > & | other | ) | [inline] |
Constructor from any other Eigen::EigenBase derived class.
Definition at line 72 of file matrix.hpp.
GenericMatrix< T >::GenericMatrix | ( | ) | [inline] |
Default ctor
Definition at line 82 of file matrix.hpp.
GenericMatrix< T >::GenericMatrix | ( | const T & | _value | ) | [inline] |
Ctor with scalar initializtion.
Definition at line 85 of file matrix.hpp.
GenericMatrix< T >::GenericMatrix | ( | unsigned | _nRows, |
unsigned | _nCols | ||
) | [inline] |
Ctor that accepts matrix dimensions.
Definition at line 91 of file matrix.hpp.
GenericMatrix< T >::GenericMatrix | ( | unsigned | _nRows, |
unsigned | _nCols, | ||
const T *const | _values | ||
) | [inline] |
Ctor that accepts matrix dimensions and initialization data in C-like array.
Definition at line 98 of file matrix.hpp.
GenericMatrix< T >::GenericMatrix | ( | unsigned | _nRows, |
unsigned | _nCols, | ||
std::vector< T > & | _values | ||
) | [inline] |
Ctor that accepts matrix dimensions and initialization data in STL 1D vector.
Definition at line 106 of file matrix.hpp.
BEGIN_NAMESPACE_ACADO GenericMatrix< T >::GenericMatrix | ( | unsigned | _nRows, |
unsigned | _nCols, | ||
std::vector< std::vector< T > > & | _values | ||
) |
Ctor that accepts matrix dimensions and initialization data in STL 2D array.
Definition at line 42 of file matrix.cpp.
virtual GenericMatrix< T >::~GenericMatrix | ( | ) | [inline, virtual] |
Destructor.
Definition at line 121 of file matrix.hpp.
GenericMatrix< T > GenericMatrix< T >::absolute | ( | ) | const |
Returns the a matrix whose components are the absolute values of the components of this object.
Definition at line 193 of file matrix.cpp.
GenericMatrix< T > & GenericMatrix< T >::appendCols | ( | const GenericMatrix< T > & | _arg | ) |
Appends columns at the end of the matrix.
Definition at line 83 of file matrix.cpp.
GenericMatrix< T > & GenericMatrix< T >::appendRows | ( | const GenericMatrix< T > & | _arg | ) |
Appends rows at the end of the matrix.
Definition at line 62 of file matrix.cpp.
GenericMatrix< T > GenericMatrix< T >::getAbsolute | ( | ) | const [inline] |
Return a new vector with absolute elements.
Definition at line 309 of file matrix.hpp.
GenericVector< T > GenericMatrix< T >::getCol | ( | unsigned | _idx | ) | const [inline] |
Returns a given column of the matrix object.
Definition at line 209 of file matrix.hpp.
GenericMatrix GenericMatrix< T >::getCols | ( | unsigned | _start, |
unsigned | _end | ||
) | const [inline] |
Returns given columns of the matrix object.
Definition at line 250 of file matrix.hpp.
T GenericMatrix< T >::getConditionNumber | ( | ) | const |
Returns condition number of the square matrix based on SVD.
Definition at line 235 of file matrix.cpp.
GenericVector< T > GenericMatrix< T >::getDiag | ( | ) | const |
Returns a vector containing the diagonal elements of a square matrix.
Definition at line 131 of file matrix.cpp.
unsigned GenericMatrix< T >::getDim | ( | ) | const [inline] |
Returns total number of elements of the matrix object.
Definition at line 185 of file matrix.hpp.
T GenericMatrix< T >::getMax | ( | ) | const [inline] |
Returns maximum element.
Definition at line 297 of file matrix.hpp.
T GenericMatrix< T >::getMean | ( | ) | const [inline] |
Returns mean value of all elements.
Definition at line 305 of file matrix.hpp.
T GenericMatrix< T >::getMin | ( | ) | const [inline] |
Returns minimum element.
Definition at line 301 of file matrix.hpp.
T GenericMatrix< T >::getNorm | ( | ) | const |
Returns Frobenius norm of the matrix.
Definition at line 227 of file matrix.cpp.
unsigned GenericMatrix< T >::getNumCols | ( | ) | const [inline] |
Returns number of columns of the matrix object.
Definition at line 193 of file matrix.hpp.
unsigned GenericMatrix< T >::getNumRows | ( | ) | const [inline] |
Returns number of rows of the matrix object.
Definition at line 189 of file matrix.hpp.
GenericVector< T > GenericMatrix< T >::getRow | ( | unsigned | _idx | ) | const [inline] |
Returns a given row of the matrix object.
Definition at line 201 of file matrix.hpp.
GenericMatrix GenericMatrix< T >::getRows | ( | unsigned | _start, |
unsigned | _end | ||
) | const [inline] |
Returns given rows of the matrix object.
Definition at line 239 of file matrix.hpp.
T GenericMatrix< T >::getTrace | ( | ) | const |
Returns trace of the matrix.
Definition at line 231 of file matrix.cpp.
void GenericMatrix< T >::init | ( | unsigned | _nRows = 0 , |
unsigned | _nCols = 0 |
||
) | [inline] |
Initialization routine.
Definition at line 139 of file matrix.hpp.
bool GenericMatrix< T >::isEmpty | ( | ) | const [inline] |
Returns whether the vector is empty.
Definition at line 197 of file matrix.hpp.
bool GenericMatrix< T >::isPositiveDefinite | ( | ) | const |
Tests if object is a (strictly) positive definite matrix.
Definition at line 184 of file matrix.cpp.
bool GenericMatrix< T >::isPositiveSemiDefinite | ( | ) | const |
Tests if object is a positive semi-definite matrix.
Definition at line 173 of file matrix.cpp.
bool GenericMatrix< T >::isSquare | ( | ) | const |
Is the matrix square?
Definition at line 135 of file matrix.cpp.
bool GenericMatrix< T >::isSymmetric | ( | ) | const |
Tests if object is a symmetric matrix.
Definition at line 139 of file matrix.cpp.
GenericMatrix< T > & GenericMatrix< T >::makeVector | ( | ) |
Reshapes a matrix into a column vector.
Definition at line 124 of file matrix.cpp.
GenericMatrix< T > GenericMatrix< T >::negative | ( | ) | const |
Returns the a matrix whose components are equal to the components of this object, if they are negative or zero, but zero otherwise.
Definition at line 212 of file matrix.cpp.
bool GenericMatrix< T >::operator!= | ( | const GenericMatrix< T > & | arg | ) | const [inline] |
Inequality operator.
Definition at line 133 of file matrix.hpp.
bool GenericMatrix< T >::operator== | ( | const GenericMatrix< T > & | arg | ) | const [inline] |
Equality operator.
Definition at line 125 of file matrix.hpp.
GenericMatrix< T > GenericMatrix< T >::positive | ( | ) | const |
Returns the a matrix whose components are equal to the components of this object, if they are positive or zero, but zero otherwise.
Definition at line 197 of file matrix.cpp.
returnValue GenericMatrix< T >::print | ( | std::ostream & | _stream = std::cout , |
const std::string & | _name = DEFAULT_LABEL , |
||
const std::string & | _startString = DEFAULT_START_STRING , |
||
const std::string & | _endString = DEFAULT_END_STRING , |
||
uint | _width = DEFAULT_WIDTH , |
||
uint | _precision = DEFAULT_PRECISION , |
||
const std::string & | _colSeparator = DEFAULT_COL_SEPARATOR , |
||
const std::string & | _rowSeparator = DEFAULT_ROW_SEPARATOR |
||
) | const [virtual] |
Prints object to given file. Various settings can be specified defining its output format.
[in] | _stream | Output stream for printing. |
[in] | _name | Name label to be printed before the numerical values. |
[in] | _startString | Prefix before printing the numerical values. |
[in] | _endString | Suffix after printing the numerical values. |
[in] | _width | Total number of digits per single numerical value. |
[in] | _precision | Number of decimals per single numerical value. |
[in] | _colSeparator | Separator between the columns of the numerical values. |
[in] | _rowSeparator | Separator between the rows of the numerical values. |
Definition at line 254 of file matrix.cpp.
returnValue GenericMatrix< T >::print | ( | std::ostream & | stream, |
const std::string & | name, | ||
PrintScheme | printScheme | ||
) | const [virtual] |
Prints object to given file. Various settings can be specified defining its output format.
[in] | _stream | Output stream for printing. |
[in] | _name | Name label to be printed before the numerical values. |
[in] | _printScheme | Print scheme defining the output format of the information. |
Definition at line 332 of file matrix.cpp.
returnValue GenericMatrix< T >::print | ( | const std::string & | _filename, |
const std::string & | _name = DEFAULT_LABEL , |
||
const std::string & | _startString = DEFAULT_START_STRING , |
||
const std::string & | _endString = DEFAULT_END_STRING , |
||
uint | _width = DEFAULT_WIDTH , |
||
uint | _precision = DEFAULT_PRECISION , |
||
const std::string & | _colSeparator = DEFAULT_COL_SEPARATOR , |
||
const std::string & | _rowSeparator = DEFAULT_ROW_SEPARATOR |
||
) | const [virtual] |
Prints object to file with given name. Various settings can be specified defining its output format.
[in] | _filename | Filename for printing. |
[in] | _name | Name label to be printed before the numerical values. |
[in] | _startString | Prefix before printing the numerical values. |
[in] | _endString | Suffix after printing the numerical values. |
[in] | _width | Total number of digits per single numerical value. |
[in] | _precision | Number of decimals per single numerical value. |
[in] | _colSeparator | Separator between the columns of the numerical values. |
[in] | _rowSeparator | Separator between the rows of the numerical values. |
Definition at line 376 of file matrix.cpp.
returnValue GenericMatrix< T >::print | ( | const std::string & | _filename, |
const std::string & | _name, | ||
PrintScheme | _printScheme | ||
) | const [virtual] |
Prints object to given file. Various settings can be specified defining its output format.
[in] | _filename | Filename for printing. |
[in] | _name | Name label to be printed before the numerical values. |
[in] | _printScheme | Print scheme defining the output format of the information. |
Definition at line 400 of file matrix.cpp.
returnValue GenericMatrix< T >::read | ( | std::istream & | _stream | ) | [virtual] |
Read matrix data from an input stream.
Definition at line 419 of file matrix.cpp.
returnValue GenericMatrix< T >::read | ( | const std::string & | _filename | ) | [virtual] |
Read data from an input file.
Definition at line 443 of file matrix.cpp.
void GenericMatrix< T >::setAll | ( | const T & | _value | ) | [inline] |
Set all elements constant.
Definition at line 145 of file matrix.hpp.
GenericMatrix& GenericMatrix< T >::setCol | ( | unsigned | _idx, |
const GenericVector< T > & | _arg | ||
) | [inline] |
Assigns new values to a given column of the matrix object.
Definition at line 228 of file matrix.hpp.
GenericMatrix& GenericMatrix< T >::setRow | ( | unsigned | _idx, |
const GenericVector< T > & | _values | ||
) | [inline] |
Assigns new values to a given row of the matrix object.
Definition at line 217 of file matrix.hpp.
GenericVector< T > GenericMatrix< T >::sumCol | ( | ) | const |
Computes the column-wise sum the DMatrix
Example:
a | b c | d
returns [a+b;c+d]
Definition at line 104 of file matrix.cpp.
GenericVector< T > GenericMatrix< T >::sumRow | ( | ) | const |
Computes the row-wise sum the DMatrix
Example:
a | b c | d
returns [a+c|b+d]
Definition at line 114 of file matrix.cpp.
returnValue GenericMatrix< T >::symmetrize | ( | ) |
Make the matrix symmetric.
Definition at line 156 of file matrix.cpp.