Defines a matrix-valued variable to be used for exporting code. More...
#include <export_variable_internal.hpp>
Public Member Functions | |
virtual ExportVariableInternal * | clone () const |
ExportVariableInternal () | |
ExportVariableInternal (const std::string &_name, const DMatrixPtr &_data, ExportType _type=REAL, ExportStruct _dataStruct=ACADO_LOCAL, bool _callItByValue=false, const std::string &_prefix=std::string()) | |
const std::string | get (const ExportIndex &rowIdx, const ExportIndex &colIdx) const |
ExportVariable | getCol (const ExportIndex &idx) const |
ExportVariable | getCols (const ExportIndex &idx1, const ExportIndex &idx2) const |
virtual uint | getDim () const |
const DMatrix & | getGivenMatrix () const |
virtual uint | getNumCols () const |
virtual uint | getNumRows () const |
ExportVariable | getRow (const ExportIndex &idx) const |
ExportVariable | getRows (const ExportIndex &idx1, const ExportIndex &idx2) const |
ExportVariable | getSubMatrix (const ExportIndex &_rowIdx1, const ExportIndex &_rowIdx2, const ExportIndex &_colIdx1, const ExportIndex &_colIdx2) const |
ExportVariable | getTranspose () const |
bool | isDiagonal () const |
bool | isGiven (const ExportIndex &rowIdx, const ExportIndex &colIdx) const |
virtual bool | isGiven () const |
bool | isOne (const ExportIndex &rowIdx, const ExportIndex &colIdx) const |
bool | isSubMatrix () const |
bool | isVector () const |
bool | isZero (const ExportIndex &rowIdx, const ExportIndex &colIdx) const |
ExportVariable | makeColVector () const |
ExportVariable | makeRowVector () const |
returnValue | print () const |
virtual | ~ExportVariableInternal () |
Protected Member Functions | |
virtual uint | getColDim () const |
virtual ExportIndex | getTotalIdx (const ExportIndex &rowIdx, const ExportIndex &colIdx) const |
bool | hasValue (const ExportIndex &_rowIdx, const ExportIndex &_colIdx, double _value) const |
returnValue | setSubmatrixOffsets (const ExportIndex &_rowOffset, const ExportIndex &_colOffset, unsigned _rowDim=0, unsigned _colDim=0, unsigned _nRows=0, unsigned _nCols=0) |
Protected Attributes | |
unsigned | colDim |
ExportIndex | colOffset |
bool | doAccessTransposed |
unsigned | nCols |
unsigned | nRows |
unsigned | rowDim |
ExportIndex | rowOffset |
Defines a matrix-valued variable to be used for exporting code.
The class ExportVariableInternal defines a matrix-valued variable to be used for exporting code. Instances of this class can be used similar to usual DMatrix objects but offer additional functionality, e.g. they allow to export arithmetic expressions and they can be passed as argument to exported functions. By default, all entries of a ExportVariableInternal are undefined, but each of its component can be set to a fixed value if known beforehand.
Definition at line 63 of file export_variable_internal.hpp.
Default constructor.
Definition at line 48 of file export_variable_internal.cpp.
ExportVariableInternal::ExportVariableInternal | ( | const std::string & | _name, |
const DMatrixPtr & | _data, | ||
ExportType | _type = REAL , |
||
ExportStruct | _dataStruct = ACADO_LOCAL , |
||
bool | _callItByValue = false , |
||
const std::string & | _prefix = std::string() |
||
) |
Constructor which takes the name and type string of the variable. Moreover, it initializes the variable with the dimensions and the values of the given matrix.
[in] | _name | Name of the argument. |
[in] | _data | DMatrix used for initialization. |
[in] | _type | Data type of the argument. |
[in] | _dataStruct | Global data struct to which the argument belongs to (if any). |
[in] | _callByValue | Flag indicating whether argument it to be called by value. |
Definition at line 61 of file export_variable_internal.cpp.
ExportVariableInternal::~ExportVariableInternal | ( | ) | [virtual] |
Destructor.
Definition at line 82 of file export_variable_internal.cpp.
ExportVariableInternal * ExportVariableInternal::clone | ( | ) | const [virtual] |
Clone constructor (deep copy).
Reimplemented from ExportArgumentInternal.
Definition at line 86 of file export_variable_internal.cpp.
const std::string ExportVariableInternal::get | ( | const ExportIndex & | rowIdx, |
const ExportIndex & | colIdx | ||
) | const |
Returns string containing the value of a given component. If its value is undefined, the string contains the address of the component.
[in] | rowIdx | Variable row index of the component. |
[in] | colIdx | Variable column index of the component. |
Definition at line 122 of file export_variable_internal.cpp.
ExportVariable ExportVariableInternal::getCol | ( | const ExportIndex & | idx | ) | const |
Returns a new variable containing only the given column of the variable.
[in] | idx | Variable column index. |
Definition at line 216 of file export_variable_internal.cpp.
uint ExportVariableInternal::getColDim | ( | ) | const [protected, virtual] |
Returns column dimension of the variable.
Reimplemented from ExportArgumentInternal.
Definition at line 409 of file export_variable_internal.cpp.
ExportVariable ExportVariableInternal::getCols | ( | const ExportIndex & | idx1, |
const ExportIndex & | idx2 | ||
) | const |
Returns a new variable containing only the given columns of the variable.
[in] | idx1 | Variable index of first column of new variable. |
[in] | idx2 | Variable index following last column of new variable. |
Definition at line 269 of file export_variable_internal.cpp.
uint ExportVariableInternal::getDim | ( | ) | const [virtual] |
Returns total dimension of the variable.
Reimplemented from ExportArgumentInternal.
Definition at line 176 of file export_variable_internal.cpp.
const DMatrix & ExportVariableInternal::getGivenMatrix | ( | ) | const |
Returns the internal data matrix.
Definition at line 389 of file export_variable_internal.cpp.
uint ExportVariableInternal::getNumCols | ( | ) | const [virtual] |
Returns number of columns of the variable.
Reimplemented from ExportArgumentInternal.
Definition at line 167 of file export_variable_internal.cpp.
uint ExportVariableInternal::getNumRows | ( | ) | const [virtual] |
Returns number of rows of the variable.
Reimplemented from ExportArgumentInternal.
Definition at line 158 of file export_variable_internal.cpp.
ExportVariable ExportVariableInternal::getRow | ( | const ExportIndex & | idx | ) | const |
Returns a new variable containing only the given row of the variable.
[in] | idx | Variable row index. |
Definition at line 194 of file export_variable_internal.cpp.
ExportVariable ExportVariableInternal::getRows | ( | const ExportIndex & | idx1, |
const ExportIndex & | idx2 | ||
) | const |
Returns a new variable containing only the given rows of the variable.
[in] | idx1 | Variable index of first row of new variable. |
[in] | idx2 | Variable index following last row of new variable. |
Definition at line 238 of file export_variable_internal.cpp.
ExportVariable ExportVariableInternal::getSubMatrix | ( | const ExportIndex & | _rowIdx1, |
const ExportIndex & | _rowIdx2, | ||
const ExportIndex & | _colIdx1, | ||
const ExportIndex & | _colIdx2 | ||
) | const |
Returns a new variable containing only the given rows and columns of the variable.
[in] | rowIdx1 | Variable index of first row of new variable. |
[in] | rowIdx2 | Variable index following last row of new variable. |
[in] | colIdx1 | Variable index of first column of new variable. |
[in] | colIdx2 | Variable index following last column of new variable. |
Definition at line 300 of file export_variable_internal.cpp.
ExportIndex ExportVariableInternal::getTotalIdx | ( | const ExportIndex & | rowIdx, |
const ExportIndex & | colIdx | ||
) | const [protected, virtual] |
Returns total index of given component within memory.
[in] | rowIdx | Row index of the component. |
[in] | colIdx | Column index of the component. |
Reimplemented from ExportArgumentInternal.
Definition at line 418 of file export_variable_internal.cpp.
Returns a copy of the variable with transposed components.
Definition at line 182 of file export_variable_internal.cpp.
bool ExportVariableInternal::hasValue | ( | const ExportIndex & | _rowIdx, |
const ExportIndex & | _colIdx, | ||
double | _value | ||
) | const [protected] |
Returns whether given component is set to given value.
[in] | rowIdx | Variable row index of the component. |
[in] | colIdx | Variable column index of the component. |
[in] | _value | Value used for comparison. |
Definition at line 462 of file export_variable_internal.cpp.
bool ExportVariableInternal::isDiagonal | ( | ) | const |
Check whether the matrix is diagonal.
Definition at line 487 of file export_variable_internal.cpp.
bool ExportVariableInternal::isGiven | ( | const ExportIndex & | rowIdx, |
const ExportIndex & | colIdx | ||
) | const |
Returns whether given component is set to a given value.
[in] | rowIdx | Variable row index of the component. |
[in] | colIdx | Variable column index of the component. |
Definition at line 106 of file export_variable_internal.cpp.
bool ExportVariableInternal::isGiven | ( | ) | const [virtual] |
Returns whether all components of the argument are given.
Reimplemented from ExportArgumentInternal.
Definition at line 116 of file export_variable_internal.cpp.
bool ExportVariableInternal::isOne | ( | const ExportIndex & | rowIdx, |
const ExportIndex & | colIdx | ||
) | const |
Returns whether given component is set to one.
[in] | rowIdx | Variable row index of the component. |
[in] | colIdx | Variable column index of the component. |
Definition at line 98 of file export_variable_internal.cpp.
bool ExportVariableInternal::isSubMatrix | ( | ) | const |
Check whether the matrix is actually a submatrix.
Definition at line 479 of file export_variable_internal.cpp.
bool ExportVariableInternal::isVector | ( | ) | const |
Returns whether variable is a vector.
Definition at line 380 of file export_variable_internal.cpp.
bool ExportVariableInternal::isZero | ( | const ExportIndex & | rowIdx, |
const ExportIndex & | colIdx | ||
) | const |
Returns whether given component is set to zero.
[in] | rowIdx | Variable row index of the component. |
[in] | colIdx | Variable column index of the component. |
Definition at line 91 of file export_variable_internal.cpp.
Returns a copy of the variable that is transformed to a column vector.
Definition at line 367 of file export_variable_internal.cpp.
Returns a copy of the variable that is transformed to a row vector.
Definition at line 354 of file export_variable_internal.cpp.
returnValue ExportVariableInternal::print | ( | ) | const |
Prints contents of variable to screen.
Definition at line 398 of file export_variable_internal.cpp.
returnValue ExportVariableInternal::setSubmatrixOffsets | ( | const ExportIndex & | _rowOffset, |
const ExportIndex & | _colOffset, | ||
unsigned | _rowDim = 0 , |
||
unsigned | _colDim = 0 , |
||
unsigned | _nRows = 0 , |
||
unsigned | _nCols = 0 |
||
) | [protected] |
Assigns offsets and dimensions of a sub-matrix. This function is used to access only a sub-matrix of the variable without copying its values to a new variable.
[in] | _rowOffset | Variable index of first row of sub-matrix. |
[in] | _colOffset | Variable index of first column of sub-matrix. |
[in] | _rowDim | Row dimension of variable (as only the submatrix data is stored). |
[in] | _colDim | Column dimension of variable (as only the submatrix data is stored). |
[in] | _nRows | Number of rows of sub-matrix. |
[in] | _nCols | Number of columns of sub-matrix. |
Definition at line 433 of file export_variable_internal.cpp.
unsigned ExportVariableInternal::colDim [protected] |
Column dimension of variable (as only the submatrix data is stored).
Definition at line 339 of file export_variable_internal.hpp.
ExportIndex ExportVariableInternal::colOffset [protected] |
Index of first column of a possible sub-matrix of the variable.
Definition at line 337 of file export_variable_internal.hpp.
bool ExportVariableInternal::doAccessTransposed [protected] |
Flag indicating whether variable is to be accessed in a transposed manner.
Definition at line 334 of file export_variable_internal.hpp.
unsigned ExportVariableInternal::nCols [protected] |
Number of columns of a possible sub-matrix of the variable.
Definition at line 341 of file export_variable_internal.hpp.
unsigned ExportVariableInternal::nRows [protected] |
Number of rows of a possible sub-matrix of the variable.
Definition at line 340 of file export_variable_internal.hpp.
unsigned ExportVariableInternal::rowDim [protected] |
Row dimension of variable (as only the submatrix data is stored).
Definition at line 338 of file export_variable_internal.hpp.
ExportIndex ExportVariableInternal::rowOffset [protected] |
Index of first row of a possible sub-matrix of the variable.
Definition at line 336 of file export_variable_internal.hpp.