Public Member Functions | Private Member Functions | Friends | List of all members

Defines a matrix-valued variable to be used for exporting code. More...

#include <export_variable.hpp>

Inheritance diagram for ExportVariable:
Inheritance graph
[legend]

Public Member Functions

ExportVariable clone () const
 
 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 DMatrixgetGivenMatrix () 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
 
ExportVariableInternaloperator-> ()
 
const ExportVariableInternaloperator-> () const
 
ExportArithmeticStatement operator== (ExportArithmeticStatement arg) const
 
returnValue print () const
 
ExportVariablesetup (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())
 
ExportVariablesetup (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)
 
- Public Member Functions inherited from ExportArgument
returnValue callByValue ()
 
 ExportArgument ()
 
 ExportArgument (const std::string &_name, uint _nRows=1, uint _nCols=1, ExportType _type=REAL, ExportStruct _dataStruct=ACADO_LOCAL, bool _callByValue=false, const ExportIndex &_addressIdx=emptyConstExportIndex, const std::string &_prefix=std::string())
 
 ExportArgument (const std::string &_name, const DMatrixPtr &_data, ExportType _type=REAL, ExportStruct _dataStruct=ACADO_LOCAL, bool _callByValue=false, const ExportIndex &_addressIdx=emptyConstExportIndex, const std::string &_prefix=std::string())
 
 ExportArgument (const DMatrix &_data)
 
virtual returnValue exportDataDeclaration (std::ostream &stream, const std::string &_realString="real_t", const std::string &_intString="int", int _precision=16) const
 
ExportArgument getAddress (const ExportIndex &_rowIdx, const ExportIndex &_colIdx=emptyConstExportIndex) const
 
const std::string getAddressString (bool withDataStruct=true) const
 
bool isCalledByValue () const
 
ExportArgumentInternaloperator-> ()
 
const ExportArgumentInternaloperator-> () const
 
- Public Member Functions inherited from ExportData
 ExportData ()
 
ExportStruct getDataStruct () const
 
std::string getDataStructString () const
 
virtual std::string getDoc () const
 
std::string getFullName () const
 
std::string getName () const
 
std::string getPrefix () const
 
ExportType getType () const
 
std::string getTypeString (const std::string &_realString="real_t", const std::string &_intString="int") const
 
virtual bool isGiven ()
 
ExportDataInternaloperator-> ()
 
const ExportDataInternaloperator-> () const
 
returnValue setDataStruct (ExportStruct _dataStruct)
 
virtual returnValue setDoc (const std::string &_doc)
 
returnValue setName (const std::string &_name)
 
returnValue setPrefix (const std::string &_prefix)
 
returnValue setType (ExportType _type)
 
virtual ~ExportData ()
 
- Public Member Functions inherited from CasADi::SharedObject
void assertInit () const
 Assert that it is initialized. More...
 
void assignNode (SharedObjectNode *node)
 Assign the node to a node class pointer (or null) More...
 
void assignNodeNoCount (SharedObjectNode *node)
 Assign the node to a node class pointer without reference counting: inproper use will cause memory leaks! More...
 
virtual bool checkNode () const
 Assert that the node is pointing to the right type of object. More...
 
SharedObject clone () const
 Deep copy. More...
 
const SharedObjectNodeget () const
 Get a const pointer to the node. More...
 
SharedObjectNodeget ()
 Get a pointer to the node. More...
 
int getCount () const
 Get the reference count. More...
 
void init ()
 Initialize the object: more documentation in the node class (SharedObjectNode and derived classes) More...
 
bool isInit () const
 Is initialized? More...
 
bool isNull () const
 Is a null pointer? More...
 
SharedObjectNodeoperator-> ()
 Access a member function or object. More...
 
const SharedObjectNodeoperator-> () const
 Const access a member function or object. More...
 
SharedObjectoperator= (const SharedObject &ref)
 Assignment operator. More...
 
virtual void print (std::ostream &stream=std::cout) const
 Print a destription of the object. More...
 
virtual void repr (std::ostream &stream) const
 Print a representation of the object. More...
 
 SharedObject ()
 Default constructor. More...
 
 SharedObject (const SharedObject &ref)
 Copy constructor (shallow copy) More...
 
void swap (SharedObject &other)
 Swap content with another instance. More...
 
 ~SharedObject ()
 Destructor. More...
 
void makeUnique (bool clone_members=true)
 If there are other references to the object, then make a deep copy of it and point to this new object. More...
 
void makeUnique (std::map< SharedObjectNode *, SharedObject > &already_copied, bool clone_members=true)
 
- Public Member Functions inherited from CasADi::PrintableObject
std::string getDescription () const
 Return a string with a destription (for SWIG) More...
 
std::string getRepresentation () const
 Return a string with a representation (for SWIG) More...
 

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)
 

Detailed Description

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.

Authors
Hans Joachim Ferreau, Boris Houska, Milan Vukov

Definition at line 58 of file export_variable.hpp.

Constructor & Destructor Documentation

ExportVariable::ExportVariable ( )

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.

Parameters
[in]_nameName of the argument.
[in]_nRowsNumber of rows of the argument.
[in]_nColsNumber of columns of the argument.
[in]_typeData type of the argument.
[in]_dataStructGlobal data struct to which the argument belongs to (if any).
[in]_callByValueFlag 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.

Parameters
[in]_nameName of the argument.
[in]_dataDMatrix used for initialization.
[in]_typeData type of the argument.
[in]_dataStructGlobal data struct to which the argument belongs to (if any).
[in]_callByValueFlag 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.

Parameters
[in]_nameName of the argument.
[in]_dataShared pointer to DMatrix used for initialization.
[in]_typeData type of the argument.
[in]_dataStructGlobal data struct to which the argument belongs to (if any).
[in]_callByValueFlag 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.

Parameters
[in]_nRowsName of the argument.
[in]_nColsName of the argument.
[in]_typeData type of the argument.
[in]_dataStructGlobal data struct to which the argument belongs to (if any).
[in]_callByValueFlag indicating whether argument it to be called by value.

Definition at line 86 of file export_variable.cpp.

template<typename Derived >
ExportVariable::ExportVariable ( const Eigen::MatrixBase< Derived > &  _data)
inline

Definition at line 145 of file export_variable.hpp.

ExportVariable::ExportVariable ( const double  _data)
Parameters
_dataScalar 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.

Member Function Documentation

ExportVariable ExportVariable::clone ( ) const

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.

Parameters
[in]rowIdxVariable row index of the component.
[in]colIdxVariable column index of the component.
Returns
std::string containing the value of a given 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.

@param[in] idx                      Variable column index.

\return New variable containing only the given column of the variable

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.

@param[in] idx1                     Variable index of first column of new variable.
@param[in] idx2                     Variable index following last column of new variable.

\return New variable containing only the given columns of the variable

Definition at line 417 of file export_variable.cpp.

uint ExportVariable::getDim ( ) const
virtual

Returns total dimension of the variable.

\return 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).

@param[in] rowIdx           Variable row index of the component.
@param[in] colIdx           Variable column index of the component.

\return Element at position (rowIdx, colIdx)

Definition at line 434 of file export_variable.cpp.

const DMatrix & ExportVariable::getGivenMatrix ( ) const

Returns the internal data matrix.

\return Internal data matrix

Definition at line 460 of file export_variable.cpp.

uint ExportVariable::getNumCols ( ) const
virtual

Returns number of columns of the variable.

\return 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.

\return 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.

@param[in] idx                      Variable row index.

\return New variable containing only the given row of the variable

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.

@param[in] idx1                     Variable index of first row of new variable.
@param[in] idx2                     Variable index following last row of new variable.

\return New variable containing only the given rows of the 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.

@param[in] rowIdx1          Variable index of first row of new variable.
@param[in] rowIdx2          Variable index following last row of new variable.
@param[in] colIdx1          Variable index of first column of new variable.
@param[in] colIdx2          Variable index following last column of new variable.

\return New variable containing only the given sub-matrix of the variable

Definition at line 425 of file export_variable.cpp.

ExportVariable ExportVariable::getTranspose ( ) const

Returns a copy of the variable with transposed components.

\return 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.

@param[in] rowIdx           Variable row index of the component.
@param[in] colIdx           Variable column index of the component.

\return true  iff given component is set to a given value, \n
        false otherwise

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.

\return true  iff all components of the variable are set to a given value, \n
        false otherwise

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.

@param[in] rowIdx           Variable row index of the component.
@param[in] colIdx           Variable column index of the component.

\return true  iff given component is set to one, \n
        false otherwise

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.

\return true  iff variable is a vector, \n
        false otherwise

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.

@param[in] rowIdx           Variable row index of the component.
@param[in] colIdx           Variable column index of the component.

\return true  iff given component is set to zero, \n
        false otherwise

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.

\return 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.

\return Copy of the variable that is transformed to a row vector

Definition at line 442 of file export_variable.cpp.

double ExportVariable::operator() ( uint  rowIdx,
uint  colIdx 
) const

Returns value of given component.

@param[in] rowIdx           Row index of the component to be returned.
@param[in] colIdx           Column index of the component to be returned.

\return SUCCESSFUL_RETURN

Definition at line 182 of file export_variable.cpp.

double ExportVariable::operator() ( uint  totalIdx) const

Returns value of given component.

@param[in] totalIdx         Memory location of the component to be returned.

\return SUCCESSFUL_RETURN

Definition at line 190 of file export_variable.cpp.

ExportArithmeticStatement ExportVariable::operator+ ( ExportArithmeticStatement  arg) const

Operator for adding an arithmetic statement to an ExportVariable.

@param[in] arg              Arithmetic statement to be added.

\return Arithmetic statement containing the addition

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.

@param[in] arg              Arithmetic statement to be add-assigned.

\return Arithmetic statement containing the add-assignment

Definition at line 360 of file export_variable.cpp.

ExportArithmeticStatement ExportVariable::operator- ( ExportArithmeticStatement  arg) const

Operator for subtraction an arithmetic statement from an ExportVariable.

@param[in] arg              Arithmetic statement to be subtracted.

\return Arithmetic statement containing the subtraction

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.

@param[in] arg              Arithmetic statement to be subtract-assigned.

\return Arithmetic statement containing the subtract-assignment

Definition at line 375 of file export_variable.cpp.

ExportVariableInternal * ExportVariable::operator-> ( )

Definition at line 136 of file export_variable.cpp.

const ExportVariableInternal * ExportVariable::operator-> ( ) const

Definition at line 142 of file export_variable.cpp.

ExportArithmeticStatement ExportVariable::operator== ( ExportArithmeticStatement  arg) const

Operator for assigning an arithmetic statement to an ExportVariable.

@param[in] arg              Arithmetic statement to be assigned.

\return Arithmetic statement containing the assignment

Definition at line 326 of file export_variable.cpp.

returnValue ExportVariable::print ( ) const

Prints contents of variable to screen.

\return SUCCESSFUL_RETURN

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.

Parameters
[in]_nameName of the argument.
[in]_nRowsNumber of rows of the argument.
[in]_nColsNumber of columns of the argument.
[in]_typeData type of the argument.
[in]_dataStructGlobal data struct to which the argument belongs to (if any).
[in]_callByValueFlag indicating whether argument it to be called by value.
Returns
Reference to initialized object

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.

Parameters
[in]_nameName of the argument.
[in]_dataDMatrix used for initialization.
[in]_typeData type of the argument.
[in]_dataStructGlobal data struct to which the argument belongs to (if any).
[in]_callByValueFlag indicating whether argument it to be called by value.
Returns
Reference to initialized object

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.

Friends And Related Function Documentation

ExportArithmeticStatement operator* ( const ExportVariable arg1,
const ExportVariable arg2 
)
friend

Operator for multiplying two ExportVariables.

@param[in] arg              Variable to be multiplied from the right.

\return Arithmetic statement containing the multiplication

Definition at line 295 of file export_variable.cpp.

ExportArithmeticStatement operator+ ( const ExportVariable arg1,
const ExportVariable arg2 
)
friend

Operator for adding two ExportVariables.

@param[in] arg              Variable to be added.

\return Arithmetic statement containing the addition

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.

@param[in] arg              Variable to be add-assigned.

\return Arithmetic statement containing the add-assignment

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.

@param[in] arg              Variable to be subtracted.

\return Arithmetic statement containing the subtraction

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.

@param[in] arg              Variable to be subtract-assigned.

\return Arithmetic statement containing the subtract-assignment

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.

@param[in] arg              Variable to be assined.

\return Arithmetic statement containing the assignment

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.

@param[in] arg              Variable to be multiplied from the right.

\return Arithmetic statement containing the multiplication with left-hand side variable transposed

Definition at line 305 of file export_variable.cpp.


The documentation for this class was generated from the following files:


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Mon Jun 10 2019 12:35:24