Defines a matrix-valued variable to be used for exporting code. More...
#include <export_variable.hpp>
Public Member Functions | |
ExportVariable | clone () const |
Deep copy. | |
ExportVariable () | |
ExportVariable (const std::string &_name, uint _nRows, uint _nCols, ExportType _type=REAL, ExportStruct _dataStruct=ACADO_LOCAL, bool _callItByValue=false, const std::string &_prefix=std::string()) | |
ExportVariable (const std::string &_name, const DMatrix &_data, ExportType _type=REAL, ExportStruct _dataStruct=ACADO_LOCAL, bool _callItByValue=false, const std::string &_prefix=std::string(), bool _isGiven=true) | |
ExportVariable (const std::string &_name, const DMatrixPtr &_data, ExportType _type=REAL, ExportStruct _dataStruct=ACADO_LOCAL, bool _callItByValue=false, const std::string &_prefix=std::string()) | |
ExportVariable (unsigned _nRows, unsigned _nCols, 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 |
ExportVariable | getElement (const ExportIndex &rowIdx, const ExportIndex &colIdx) 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 |
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 |
double | operator() (uint rowIdx, uint colIdx) const |
double | operator() (uint totalIdx) const |
ExportArithmeticStatement | operator+ (ExportArithmeticStatement arg) const |
ExportArithmeticStatement | operator+= (ExportArithmeticStatement arg) const |
ExportArithmeticStatement | operator- (ExportArithmeticStatement arg) const |
ExportArithmeticStatement | operator-= (ExportArithmeticStatement arg) const |
ExportVariableInternal * | operator-> () |
const ExportVariableInternal * | operator-> () const |
ExportArithmeticStatement | operator== (ExportArithmeticStatement arg) const |
returnValue | print () const |
ExportVariable & | setup (const std::string &_name, uint _nRows=1, uint _nCols=1, ExportType _type=REAL, ExportStruct _dataStruct=ACADO_LOCAL, bool _callItByValue=false, const std::string &_prefix=std::string()) |
ExportVariable & | setup (const std::string &_name, const DMatrix &_data, ExportType _type=REAL, ExportStruct _dataStruct=ACADO_LOCAL, bool _callItByValue=false, const std::string &_prefix=std::string(), bool _isGiven=true) |
virtual | ~ExportVariable () |
Constructor which converts a given matrix/vector/scalar into an ExportVariable. | |
template<typename Derived > | |
ExportVariable (const Eigen::MatrixBase< Derived > &_data) | |
ExportVariable (const double _data) | |
Private Member Functions | |
void | simpleForward (const DMatrix &_value) |
Friends | |
ExportArithmeticStatement | operator* (const ExportVariable &arg1, const ExportVariable &arg2) |
ExportArithmeticStatement | operator+ (const ExportVariable &arg1, const ExportVariable &arg2) |
ExportArithmeticStatement | operator+= (const ExportVariable &arg1, const ExportVariable &arg2) |
ExportArithmeticStatement | operator- (const ExportVariable &arg1, const ExportVariable &arg2) |
ExportArithmeticStatement | operator-= (const ExportVariable &arg1, const ExportVariable &arg2) |
ExportArithmeticStatement | operator== (const ExportVariable &arg1, const ExportVariable &arg2) |
ExportArithmeticStatement | operator^ (const ExportVariable &arg1, const ExportVariable &arg2) |
Defines a matrix-valued variable to be used for exporting code.
The class ExportVariable 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 ExportVariable are undefined, but each of its component can be set to a fixed value if known beforehand.
Definition at line 58 of file export_variable.hpp.
Default constructor.
Definition at line 52 of file export_variable.cpp.
ExportVariable::ExportVariable | ( | const std::string & | _name, |
uint | _nRows, | ||
uint | _nCols, | ||
ExportType | _type = REAL , |
||
ExportStruct | _dataStruct = ACADO_LOCAL , |
||
bool | _callItByValue = false , |
||
const std::string & | _prefix = std::string() |
||
) |
Constructor which takes the name, type string and dimensions of the variable.
[in] | _name | Name of the argument. |
[in] | _nRows | Number of rows of the argument. |
[in] | _nCols | Number of columns of the argument. |
[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 57 of file export_variable.cpp.
ExportVariable::ExportVariable | ( | const std::string & | _name, |
const DMatrix & | _data, | ||
ExportType | _type = REAL , |
||
ExportStruct | _dataStruct = ACADO_LOCAL , |
||
bool | _callItByValue = false , |
||
const std::string & | _prefix = std::string() , |
||
bool | _isGiven = true |
||
) |
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 73 of file export_variable.cpp.
ExportVariable::ExportVariable | ( | 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 | Shared pointer to 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 100 of file export_variable.cpp.
ExportVariable::ExportVariable | ( | unsigned | _nRows, |
unsigned | _nCols, | ||
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 of the matrix.
[in] | _nRows | Name of the argument. |
[in] | _nCols | Name of the argument. |
[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 86 of file export_variable.cpp.
ExportVariable::ExportVariable | ( | const Eigen::MatrixBase< Derived > & | _data | ) | [inline] |
Definition at line 145 of file export_variable.hpp.
ExportVariable::ExportVariable | ( | const double | _data | ) |
_data | Scalar used for initialization |
Definition at line 117 of file export_variable.cpp.
ExportVariable::~ExportVariable | ( | ) | [virtual] |
Destructor.
Definition at line 123 of file export_variable.cpp.
ExportVariable ExportVariable::clone | ( | ) | const |
Deep copy.
Reimplemented from CasADi::SharedObject.
Definition at line 126 of file export_variable.cpp.
const std::string ExportVariable::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 227 of file export_variable.cpp.
ExportVariable ExportVariable::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 402 of file export_variable.cpp.
ExportVariable ExportVariable::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 417 of file export_variable.cpp.
uint ExportVariable::getDim | ( | ) | const [virtual] |
Returns total dimension of the variable.
Reimplemented from ExportArgument.
Definition at line 245 of file export_variable.cpp.
ExportVariable ExportVariable::getElement | ( | const ExportIndex & | rowIdx, |
const ExportIndex & | colIdx | ||
) | const |
Returns element at position (rowIdx, colIdx).
[in] | rowIdx | Variable row index of the component. |
[in] | colIdx | Variable column index of the component. |
Definition at line 434 of file export_variable.cpp.
const DMatrix & ExportVariable::getGivenMatrix | ( | ) | const |
Returns the internal data matrix.
Definition at line 460 of file export_variable.cpp.
uint ExportVariable::getNumCols | ( | ) | const [virtual] |
Returns number of columns of the variable.
Reimplemented from ExportArgument.
Definition at line 239 of file export_variable.cpp.
uint ExportVariable::getNumRows | ( | ) | const [virtual] |
Returns number of rows of the variable.
Reimplemented from ExportArgument.
Definition at line 234 of file export_variable.cpp.
ExportVariable ExportVariable::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 395 of file export_variable.cpp.
ExportVariable ExportVariable::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 409 of file export_variable.cpp.
ExportVariable ExportVariable::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 425 of file export_variable.cpp.
ExportVariable ExportVariable::getTranspose | ( | ) | const |
Returns a copy of the variable with transposed components.
Definition at line 390 of file export_variable.cpp.
bool ExportVariable::isDiagonal | ( | ) | const |
Check whether the matrix is diagonal.
Definition at line 476 of file export_variable.cpp.
bool ExportVariable::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 213 of file export_variable.cpp.
bool ExportVariable::isGiven | ( | ) | const [virtual] |
Returns whether all components of the variable are set to a given value.
Reimplemented from ExportArgument.
Definition at line 221 of file export_variable.cpp.
bool ExportVariable::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 205 of file export_variable.cpp.
bool ExportVariable::isSubMatrix | ( | ) | const |
Check whether the matrix is actually a submatrix.
Definition at line 471 of file export_variable.cpp.
bool ExportVariable::isVector | ( | ) | const |
Returns whether variable is a vector.
Definition at line 454 of file export_variable.cpp.
bool ExportVariable::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 197 of file export_variable.cpp.
ExportVariable ExportVariable::makeColVector | ( | ) | const |
Returns a copy of the variable that is transformed to a column vector.
Definition at line 448 of file export_variable.cpp.
ExportVariable ExportVariable::makeRowVector | ( | ) | const |
Returns a copy of the variable that is transformed to a row vector.
Definition at line 442 of file export_variable.cpp.
Returns value of given component.
[in] | rowIdx | Row index of the component to be returned. |
[in] | colIdx | Column index of the component to be returned. |
Definition at line 182 of file export_variable.cpp.
double ExportVariable::operator() | ( | uint | totalIdx | ) | const |
Returns value of given component.
[in] | totalIdx | Memory location of the component to be returned. |
Definition at line 190 of file export_variable.cpp.
ExportArithmeticStatement ExportVariable::operator+ | ( | ExportArithmeticStatement | arg | ) | const |
Operator for adding an arithmetic statement to an ExportVariable.
[in] | arg | Arithmetic statement to be added. |
Definition at line 336 of file export_variable.cpp.
ExportArithmeticStatement ExportVariable::operator+= | ( | ExportArithmeticStatement | arg | ) | const |
Operator for add-assigning an arithmetic statement to an ExportVariable.
[in] | arg | Arithmetic statement to be add-assigned. |
Definition at line 360 of file export_variable.cpp.
ExportArithmeticStatement ExportVariable::operator- | ( | ExportArithmeticStatement | arg | ) | const |
Operator for subtraction an arithmetic statement from an ExportVariable.
[in] | arg | Arithmetic statement to be subtracted. |
Definition at line 348 of file export_variable.cpp.
ExportArithmeticStatement ExportVariable::operator-= | ( | ExportArithmeticStatement | arg | ) | const |
Operator for subtract-assigning an arithmetic statement from an ExportVariable.
[in] | arg | Arithmetic statement to be subtract-assigned. |
Definition at line 375 of file export_variable.cpp.
ExportVariableInternal * ExportVariable::operator-> | ( | ) |
An operator for access to functions and members of the node
Reimplemented from ExportArgument.
Definition at line 136 of file export_variable.cpp.
const ExportVariableInternal * ExportVariable::operator-> | ( | ) | const |
An operator for const access to functions and members of the node
Reimplemented from ExportArgument.
Definition at line 142 of file export_variable.cpp.
ExportArithmeticStatement ExportVariable::operator== | ( | ExportArithmeticStatement | arg | ) | const |
Operator for assigning an arithmetic statement to an ExportVariable.
[in] | arg | Arithmetic statement to be assigned. |
Definition at line 326 of file export_variable.cpp.
returnValue ExportVariable::print | ( | ) | const |
Prints contents of variable to screen.
Definition at line 466 of file export_variable.cpp.
ExportVariable & ExportVariable::setup | ( | const std::string & | _name, |
uint | _nRows = 1 , |
||
uint | _nCols = 1 , |
||
ExportType | _type = REAL , |
||
ExportStruct | _dataStruct = ACADO_LOCAL , |
||
bool | _callItByValue = false , |
||
const std::string & | _prefix = std::string() |
||
) |
Initializes variable with given name, type string and dimensions of the variable.
[in] | _name | Name of the argument. |
[in] | _nRows | Number of rows of the argument. |
[in] | _nCols | Number of columns of the argument. |
[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 148 of file export_variable.cpp.
ExportVariable & ExportVariable::setup | ( | const std::string & | _name, |
const DMatrix & | _data, | ||
ExportType | _type = REAL , |
||
ExportStruct | _dataStruct = ACADO_LOCAL , |
||
bool | _callItByValue = false , |
||
const std::string & | _prefix = std::string() , |
||
bool | _isGiven = true |
||
) |
Initializes variable with given name and type string of the variable. Moreover, the variable is initialized 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 166 of file export_variable.cpp.
void ExportVariable::simpleForward | ( | const DMatrix & | _value | ) | [private] |
Definition at line 111 of file export_variable.cpp.
ExportArithmeticStatement operator* | ( | const ExportVariable & | arg1, |
const ExportVariable & | arg2 | ||
) | [friend] |
Operator for multiplying two ExportVariables.
[in] | arg | Variable to be multiplied from the right. |
Definition at line 295 of file export_variable.cpp.
ExportArithmeticStatement operator+ | ( | const ExportVariable & | arg1, |
const ExportVariable & | arg2 | ||
) | [friend] |
Operator for adding two ExportVariables.
[in] | arg | Variable to be added. |
Definition at line 251 of file export_variable.cpp.
ExportArithmeticStatement operator+= | ( | const ExportVariable & | arg1, |
const ExportVariable & | arg2 | ||
) | [friend] |
Operator for add-assigning an ExportVariable to another.
[in] | arg | Variable to be add-assigned. |
Definition at line 273 of file export_variable.cpp.
ExportArithmeticStatement operator- | ( | const ExportVariable & | arg1, |
const ExportVariable & | arg2 | ||
) | [friend] |
Operator for subtracting an ExportVariable from another.
[in] | arg | Variable to be subtracted. |
Definition at line 262 of file export_variable.cpp.
ExportArithmeticStatement operator-= | ( | const ExportVariable & | arg1, |
const ExportVariable & | arg2 | ||
) | [friend] |
Operator for subtract-assigning an ExportVariables from another.
[in] | arg | Variable to be subtract-assigned. |
Definition at line 284 of file export_variable.cpp.
ExportArithmeticStatement operator== | ( | const ExportVariable & | arg1, |
const ExportVariable & | arg2 | ||
) | [friend] |
Operator for assigning an ExportVariable to another.
[in] | arg | Variable to be assined. |
Definition at line 315 of file export_variable.cpp.
ExportArithmeticStatement operator^ | ( | const ExportVariable & | arg1, |
const ExportVariable & | arg2 | ||
) | [friend] |
Operator for multiplying an ExportVariable to the transposed on another.
[in] | arg | Variable to be multiplied from the right. |
Definition at line 305 of file export_variable.cpp.