ACADO Toolkit  1.2.0beta
Toolkit for Automatic Control and Dynamic Optimization
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Friends

Allows to export code of different arithmetic statements. More...

#include <export_arithmetic_statement.hpp>

Inheritance diagram for ExportArithmeticStatement:
Inheritance graph
[legend]

List of all members.

Public Types

typedef std::tr1::shared_ptr
< ExportStatement
StatementPtr
 Shared pointer to a statement.
typedef std::vector< StatementPtrStatementPtrArray
 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.
ExportArithmeticStatementoperator= (const ExportArithmeticStatement &arg)
 Assignment operator (deep copy).
virtual ExportStatementclone () 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.
ExportArithmeticStatementallocate (MemoryAllocatorPtr allocator)
 Set a memory allocator.
virtual ExportStatementacquire (ExportIndex &)
 Acquire an index.
virtual ExportStatementrelease (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

Detailed Description

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 "-".

Author:
Hans Joachim Ferreau, Boris Houska

Member Typedef Documentation

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]

Constructor & Destructor Documentation

References ESO_UNDEFINED.

Referenced by clone().

Parameters:
[in]_lhsLeft-hand side expressions
[in]_op0Operator between left- and right-hand side expression.
[in]_rhs1First right-hand side expression.
[in]_op1Operator between first and second right-hand side expression.
[in]_rhs2Second right-hand side expression of arithmetic statement.
[in]_op2Operator between second and third right-hand side expression.
[in]_rhs3Third 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.

Parameters:
[in]argRight-hand side object.

References lhs, memAllocator, op0, op1, op2, rhs1, rhs2, and rhs3.


Member Function Documentation

virtual ExportStatement& ExportStatement::acquire ( ExportIndex ) [inline, virtual, inherited]

Reimplemented in ExportFunction.

Reimplemented from ExportStatement.

References memAllocator.

Returns:
Pointer to cloned object.

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.

Parameters:
[in]fileName of file to be used to export statement.
[in]_realStringString to be used to declare real variables.
[in]_intStringString to be used to declare integer variables.
[in]_precisionNumber of digits to be used for exporting real values.
Returns:
SUCCESSFUL_RETURN

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.

Parameters:
[in]fileName of file to be used to export statement.
[in]_signString of the operation ("+" or "-").
[in]_realStringString to be used to declare real variables.
[in]_intStringString to be used to declare integer variables.
[in]_precisionNumber of digits to be used for exporting real values.
Returns:
SUCCESSFUL_RETURN

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.

Parameters:
[in]fileName of file to be used to export statement.
[in]_opString of the assignment operation ("=", "+=" or "-=").
[in]_realStringString to be used to declare real variables.
[in]_intStringString to be used to declare integer variables.
[in]_precisionNumber of digits to be used for exporting real values.
Returns:
SUCCESSFUL_RETURN

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.

Parameters:
[in]fileName of file to be used to export statement.
[in]transposeRhs1Flag indicating whether rhs1 shall be transposed.
[in]_realStringString to be used to declare real variables.
[in]_intStringString to be used to declare integer variables.
[in]_precisionNumber of digits to be used for exporting real values.
Returns:
SUCCESSFUL_RETURN

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.

Parameters:
[in]fileName of file to be used to export statement.
[in]_realStringString to be used to declare real variables.
[in]_intStringString to be used to declare integer variables.
[in]_precisionNumber of digits to be used for exporting real values.
Returns:
SUCCESSFUL_RETURN

Reimplemented from ExportStatement.

References SUCCESSFUL_RETURN.

returnValue ExportArithmeticStatement::getAssignString ( String _assignString) const [protected]
Parameters:
[out]_assignStringString containing the assignment operation.
Returns:
SUCCESSFUL_RETURN,
RET_UNABLE_TO_EXPORT_STATEMENT

References ESO_ADD_ASSIGN, ESO_ASSIGN, ESO_SUBTRACT_ASSIGN, op0, RET_UNABLE_TO_EXPORT_STATEMENT, and SUCCESSFUL_RETURN.

Referenced by exportCodeAddSubtract(), and exportCodeMultiply().

Returns:
Number of columns of arithmetic statement

References ExportVariableInternal::getNumCols(), rhs1, and rhs2.

Referenced by exportCodeAddSubtract(), and exportCodeMultiply().

ExportArithmeticStatement & ExportArithmeticStatement::operator= ( const ExportArithmeticStatement arg)
Parameters:
[in]argRight-hand side object.

References lhs, memAllocator, op0, op1, op2, rhs1, rhs2, and rhs3.

virtual ExportStatement& ExportStatement::release ( const ExportIndex ) [inline, virtual, inherited]

Reimplemented in ExportFunction.


Friends And Related Function Documentation

friend class ExportVariable [friend]

Member Data Documentation


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines