ACADO Toolkit
1.2.0beta
Toolkit for Automatic Control and Dynamic Optimization
|
Allows to export code of different arithmetic statements. More...
#include <export_arithmetic_statement.hpp>
Public Types | |
typedef std::tr1::shared_ptr < ExportStatement > | StatementPtr |
Shared pointer to a statement. | |
typedef std::vector< StatementPtr > | StatementPtrArray |
A vector of shared pointer statements. | |
typedef std::tr1::shared_ptr < MemoryAllocator > | MemoryAllocatorPtr |
Shared pointer to a memory allocator. | |
Public Member Functions | |
ExportArithmeticStatement () | |
Default constructor. | |
ExportArithmeticStatement (const ExportVariable &_lhs, ExportStatementOperator _op0, const ExportVariable &_rhs1, ExportStatementOperator _op1, const ExportVariable &_rhs2, ExportStatementOperator _op2=ESO_UNDEFINED, const ExportVariable &_rhs3=0) | |
Constructor which takes all expressions and operators of the arithmetic statement. | |
ExportArithmeticStatement (const ExportArithmeticStatement &arg) | |
Copy constructor (deep copy). | |
virtual | ~ExportArithmeticStatement () |
Destructor. | |
ExportArithmeticStatement & | operator= (const ExportArithmeticStatement &arg) |
Assignment operator (deep copy). | |
virtual ExportStatement * | clone () const |
Clone constructor (deep copy). | |
uint | getNumRows () const |
Returns number of rows of arithmetic statement. | |
uint | getNumCols () const |
Returns number of columns of arithmetic statement. | |
virtual returnValue | exportDataDeclaration (FILE *file, const String &_realString="real_t", const String &_intString="int", int _precision=16) const |
Exports data declaration of the statement into given file. | |
virtual returnValue | exportCode (FILE *file, const String &_realString="real_t", const String &_intString="int", int _precision=16) const |
Exports source code of the statement into given file. | |
ExportArithmeticStatement & | allocate (MemoryAllocatorPtr allocator) |
Set a memory allocator. | |
virtual ExportStatement & | acquire (ExportIndex &) |
Acquire an index. | |
virtual ExportStatement & | release (const ExportIndex &) |
Release an index. | |
Protected Member Functions | |
returnValue | exportCodeAddSubtract (FILE *file, const String &_sign="+", const String &_realString="real_t", const String &_intString="int", int _precision=16) const |
Exports source code for an addition or subtraction to given file. | |
returnValue | exportCodeMultiply (FILE *file, BooleanType transposeRhs1=BT_FALSE, const String &_realString="real_t", const String &_intString="int", int _precision=16) const |
Exports source code for a multiplication to given file. | |
returnValue | exportCodeAssign (FILE *file, const String &_op="=", const String &_realString="real_t", const String &_intString="int", int _precision=16) const |
Exports source code for an assignment to given file. | |
returnValue | getAssignString (String &_assignString) const |
Returns string containing the assignment operation. | |
Protected Attributes | |
ExportVariable | lhs |
Left-hand side expression of arithmetic statement. | |
ExportVariable | rhs1 |
First right-hand side expression of arithmetic statement. | |
ExportVariable | rhs2 |
Second right-hand side expression of arithmetic statement. | |
ExportVariable | rhs3 |
Third right-hand side expression of arithmetic statement. | |
ExportStatementOperator | op0 |
Operator between left- and right-hand side expression of arithmetic statement. | |
ExportStatementOperator | op1 |
Operator between first and second right-hand side expression of arithmetic statement. | |
ExportStatementOperator | op2 |
Operator between second and third right-hand side expression of arithmetic statement. | |
MemoryAllocatorPtr | memAllocator |
Friends | |
class | ExportVariable |
The class ExportArithmeticStatement allows to export code of different arithmetic statements of the form:
lhs <op0> rhs1 <op1> rhs2 <op2> rhs3,
where <op0> can be "=", "+=" or "-=", <op1> can be "+", "-" or "*" and <op2> can be "+" or "-".
typedef std::tr1::shared_ptr< MemoryAllocator > ExportStatement::MemoryAllocatorPtr [inherited] |
typedef std::tr1::shared_ptr< ExportStatement > ExportStatement::StatementPtr [inherited] |
typedef std::vector< StatementPtr > ExportStatement::StatementPtrArray [inherited] |
References ESO_UNDEFINED.
Referenced by clone().
ExportArithmeticStatement::ExportArithmeticStatement | ( | const ExportVariable & | _lhs, |
ExportStatementOperator | _op0, | ||
const ExportVariable & | _rhs1, | ||
ExportStatementOperator | _op1, | ||
const ExportVariable & | _rhs2, | ||
ExportStatementOperator | _op2 = ESO_UNDEFINED , |
||
const ExportVariable & | _rhs3 = 0 |
||
) |
[in] | _lhs | Left-hand side expressions |
[in] | _op0 | Operator between left- and right-hand side expression. |
[in] | _rhs1 | First right-hand side expression. |
[in] | _op1 | Operator between first and second right-hand side expression. |
[in] | _rhs2 | Second right-hand side expression of arithmetic statement. |
[in] | _op2 | Operator between second and third right-hand side expression. |
[in] | _rhs3 | Third right-hand side expression. |
References ASSERT, ESO_ADD, ESO_ADD_ASSIGN, ESO_ASSIGN, ESO_SUBTRACT, ESO_SUBTRACT_ASSIGN, ESO_UNDEFINED, lhs, op0, op1, op2, rhs1, rhs2, and rhs3.
ExportArithmeticStatement::~ExportArithmeticStatement | ( | ) | [virtual] |
virtual ExportStatement& ExportStatement::acquire | ( | ExportIndex & | ) | [inline, virtual, inherited] |
Reimplemented in ExportFunction.
Reimplemented from ExportStatement.
References memAllocator.
ExportStatement * ExportArithmeticStatement::clone | ( | ) | const [virtual] |
Implements ExportStatement.
References ExportArithmeticStatement().
returnValue ExportArithmeticStatement::exportCode | ( | FILE * | file, |
const String & | _realString = "real_t" , |
||
const String & | _intString = "int" , |
||
int | _precision = 16 |
||
) | const [virtual] |
Its appearance can can be adjusted by various options.
[in] | file | Name of file to be used to export statement. |
[in] | _realString | String to be used to declare real variables. |
[in] | _intString | String to be used to declare integer variables. |
[in] | _precision | Number of digits to be used for exporting real values. |
Implements ExportStatement.
References ACADOERROR, ACADOERRORTEXT, BT_FALSE, BT_TRUE, ESO_ADD, ESO_ADD_ASSIGN, ESO_ASSIGN, ESO_MULTIPLY, ESO_MULTIPLY_TRANSPOSE, ESO_SUBTRACT, ESO_SUBTRACT_ASSIGN, exportCodeAddSubtract(), exportCodeAssign(), exportCodeMultiply(), ExportVariableInternal::getDim(), ExportData::getFullName(), String::getName(), ExportVariableInternal::isGiven(), lhs, LOG, LVL_ERROR, memAllocator, op1, RET_INVALID_ARGUMENTS, and RET_UNKNOWN_BUG.
returnValue ExportArithmeticStatement::exportCodeAddSubtract | ( | FILE * | file, |
const String & | _sign = "+" , |
||
const String & | _realString = "real_t" , |
||
const String & | _intString = "int" , |
||
int | _precision = 16 |
||
) | const [protected] |
Its appearance can be adjusted by various options.
[in] | file | Name of file to be used to export statement. |
[in] | _sign | String of the operation ("+" or "-"). |
[in] | _realString | String to be used to declare real variables. |
[in] | _intString | String to be used to declare integer variables. |
[in] | _precision | Number of digits to be used for exporting real values. |
References ACADOERROR, acadoFPrintf(), acadoIsZero(), BT_FALSE, BT_TRUE, ESO_ADD, ESO_ASSIGN, ESO_SUBTRACT, ExportVariableInternal::get(), ExportVariable::get(), getAssignString(), ExportVariable::getDim(), ExportData::getName(), String::getName(), getNumCols(), ExportVariableInternal::getNumCols(), ExportVariable::getNumCols(), getNumRows(), ExportVariableInternal::getNumRows(), ExportVariable::getNumRows(), ExportVariableInternal::isGiven(), ExportVariableInternal::isZero(), lhs, memAllocator, op0, op1, RET_UNABLE_TO_EXPORT_STATEMENT, RET_VECTOR_DIMENSION_MISMATCH, rhs1, rhs2, SUCCESSFUL_RETURN, and uint.
Referenced by exportCode().
returnValue ExportArithmeticStatement::exportCodeAssign | ( | FILE * | file, |
const String & | _op = "=" , |
||
const String & | _realString = "real_t" , |
||
const String & | _intString = "int" , |
||
int | _precision = 16 |
||
) | const [protected] |
Its appearance can be adjusted by various options.
[in] | file | Name of file to be used to export statement. |
[in] | _op | String of the assignment operation ("=", "+=" or "-="). |
[in] | _realString | String to be used to declare real variables. |
[in] | _intString | String to be used to declare integer variables. |
[in] | _precision | Number of digits to be used for exporting real values. |
References ACADOERROR, acadoFPrintf(), BT_FALSE, BT_TRUE, ExportIndex::get(), ExportVariableInternal::get(), ExportVariable::get(), ExportVariable::getDim(), ExportData::getFullName(), ExportVariable::getGivenMatrix(), ExportData::getName(), String::getName(), ExportVariableInternal::getNumCols(), ExportVariable::getNumCols(), ExportVariableInternal::getNumRows(), ExportVariable::getNumRows(), ExportVariableInternal::isGiven(), ExportVariable::isGiven(), ExportVariable::isSubMatrix(), VectorspaceElement::isZero(), ExportVariable::isZero(), lhs, LOG, LVL_DEBUG, memAllocator, RET_VECTOR_DIMENSION_MISMATCH, rhs1, rhs2, and SUCCESSFUL_RETURN.
Referenced by exportCode().
returnValue ExportArithmeticStatement::exportCodeMultiply | ( | FILE * | file, |
BooleanType | transposeRhs1 = BT_FALSE , |
||
const String & | _realString = "real_t" , |
||
const String & | _intString = "int" , |
||
int | _precision = 16 |
||
) | const [protected] |
Its appearance can be adjusted by various options.
[in] | file | Name of file to be used to export statement. |
[in] | transposeRhs1 | Flag indicating whether rhs1 shall be transposed. |
[in] | _realString | String to be used to declare real variables. |
[in] | _intString | String to be used to declare integer variables. |
[in] | _precision | Number of digits to be used for exporting real values. |
References ACADOERROR, acadoFPrintf(), BT_FALSE, BT_TRUE, ESO_ADD, ESO_SUBTRACT, ESO_UNDEFINED, ExportVariableInternal::get(), getAssignString(), ExportVariable::getDim(), ExportData::getName(), String::getName(), getNumCols(), ExportVariableInternal::getNumCols(), getNumRows(), ExportVariableInternal::getNumRows(), ExportVariableInternal::isGiven(), ExportVariableInternal::isOne(), ExportVariableInternal::isZero(), lhs, memAllocator, op2, RET_UNABLE_TO_EXPORT_STATEMENT, RET_VECTOR_DIMENSION_MISMATCH, rhs1, rhs2, rhs3, sign(), SUCCESSFUL_RETURN, and uint.
Referenced by exportCode().
returnValue ExportArithmeticStatement::exportDataDeclaration | ( | FILE * | file, |
const String & | _realString = "real_t" , |
||
const String & | _intString = "int" , |
||
int | _precision = 16 |
||
) | const [virtual] |
Its appearance can can be adjusted by various options.
[in] | file | Name of file to be used to export statement. |
[in] | _realString | String to be used to declare real variables. |
[in] | _intString | String to be used to declare integer variables. |
[in] | _precision | Number of digits to be used for exporting real values. |
Reimplemented from ExportStatement.
References SUCCESSFUL_RETURN.
returnValue ExportArithmeticStatement::getAssignString | ( | String & | _assignString | ) | const [protected] |
[out] | _assignString | String containing the assignment operation. |
References ESO_ADD_ASSIGN, ESO_ASSIGN, ESO_SUBTRACT_ASSIGN, op0, RET_UNABLE_TO_EXPORT_STATEMENT, and SUCCESSFUL_RETURN.
Referenced by exportCodeAddSubtract(), and exportCodeMultiply().
uint ExportArithmeticStatement::getNumCols | ( | ) | const |
References ExportVariableInternal::getNumCols(), rhs1, and rhs2.
Referenced by exportCodeAddSubtract(), and exportCodeMultiply().
uint ExportArithmeticStatement::getNumRows | ( | ) | const |
References ESO_MULTIPLY_TRANSPOSE, ExportVariableInternal::getNumCols(), ExportVariableInternal::getNumRows(), op1, and rhs1.
Referenced by exportCodeAddSubtract(), and exportCodeMultiply().
ExportArithmeticStatement & ExportArithmeticStatement::operator= | ( | const ExportArithmeticStatement & | arg | ) |
virtual ExportStatement& ExportStatement::release | ( | const ExportIndex & | ) | [inline, virtual, inherited] |
Reimplemented in ExportFunction.
friend class ExportVariable [friend] |
ExportVariable ExportArithmeticStatement::lhs [protected] |
Referenced by ExportArithmeticStatement(), exportCode(), exportCodeAddSubtract(), exportCodeAssign(), exportCodeMultiply(), and operator=().
Referenced by allocate(), ExportArithmeticStatement(), exportCode(), exportCodeAddSubtract(), exportCodeAssign(), exportCodeMultiply(), and operator=().
Referenced by ExportArithmeticStatement(), exportCodeAddSubtract(), getAssignString(), and operator=().
ExportVariable ExportArithmeticStatement::rhs1 [protected] |
Referenced by ExportArithmeticStatement(), exportCodeAddSubtract(), exportCodeAssign(), exportCodeMultiply(), getNumCols(), getNumRows(), ExportVariable::operator+(), ExportVariable::operator+=(), ExportVariable::operator-(), ExportVariable::operator-=(), operator=(), and ExportVariable::operator==().
ExportVariable ExportArithmeticStatement::rhs2 [protected] |
ExportVariable ExportArithmeticStatement::rhs3 [protected] |