109 const std::string& _realString,
110 const std::string& _intString,
119 const std::string& _realString,
120 const std::string& _intString,
132 "expression is given." << endl;
179 const std::string& _sign,
180 const std::string& _realString,
181 const std::string& _intString
207 if (numberOfFlops < 4096 || optimizationsAllowed ==
false)
227 stream <<
" " <<
rhs1->
get(i, j);
229 stream <<
" " << _sign <<
" " <<
rhs2->
get(i, j) <<
";\n";
231 stream <<
";" << endl;
236 stream <<
" " << _sign <<
" " <<
rhs2->
get(i, j) <<
";\n";
242 else if ( numberOfFlops < 32768 )
247 stream <<
"for (" << ii.
getName() <<
" = 0; ";
249 stream <<
"++" << ii.
getName() <<
")\n{\n";
254 stream <<
" " << _sign <<
" " <<
rhs2->
get(ii, j) <<
";\n";
267 stream <<
"for (" << ii.
getName() <<
" = 0; " 269 <<
"++" << ii.
getName() <<
")\n{\n";
271 stream <<
"for (" << jj.
getName() <<
" = 0; " 273 <<
"++" << jj.
getName() <<
")\n{\n";
276 << _sign <<
" " <<
rhs2->
get(ii, jj) <<
";\n";
290 const std::string& _realString,
291 const std::string& _intString
297 if ( transposeRhs1 ==
false )
340 bool optimizationsAllowed =
348 if (numberOfFlops < 4096 || optimizationsAllowed ==
false)
364 for(
uint k = 0; k < nColsRhs1; ++k)
367 if ( transposeRhs1 ==
false )
378 if ( (
rhs1->
isZero(iiRhs1,kkRhs1) == false ) &&
383 if (
rhs1->
isOne(iiRhs1,kkRhs1) == false )
385 stream <<
" " << sign <<
" " <<
rhs1->
get(iiRhs1,kkRhs1);
388 stream <<
"*" <<
rhs2->
get(kk, j);
393 stream <<
" " << sign <<
rhs2->
get(kk,j);
395 stream <<
" " << sign <<
" 1.0";
401 stream <<
" + " <<
rhs3->
get(ii, j);
403 stream <<
" - " <<
rhs3->
get(ii, j);
490 stream <<
"for (" << ii.
getName() <<
" = 0; ";
492 stream <<
"++" << ii.
getName() <<
")\n{\n";
495 stream <<
"for (" << jj.
getName() <<
" = 0; ";
497 stream <<
"++" << jj.
getName() <<
")\n{\n";
499 stream << _realString <<
" t = 0.0;" << endl;
502 stream <<
"for (" << kk.
getName() <<
" = 0; ";
503 stream << kk.
getName() <<
" < " << nColsRhs1 <<
"; ";
504 stream <<
"++" << kk.
getName() <<
")\n{\n";
506 if ( transposeRhs1 ==
false )
516 stream <<
"t += " << sign <<
" " <<
rhs1->
get(iiRhs1, kkRhs1) <<
"*" <<
rhs2->
get(kk, jj) <<
";";
522 stream <<
lhs->
get(ii, jj);
528 stream <<
" + " <<
rhs3->
get(ii, jj);
532 stream <<
" - " <<
rhs3->
get(ii, jj);
549 const std::string& _op,
550 const std::string& _realString,
551 const std::string& _intString
570 stream <<
"{ int lCopy; for (lCopy = 0; lCopy < "<<
lhs.
getDim() <<
"; lCopy++) " 573 else if ((numOps < 128) || (
rhs1.
isGiven() ==
true))
577 if ( ( _op ==
"=" ) || (
rhs1.
isZero(i,j) == false ) )
579 stream <<
lhs->
get(i, j) <<
" " << _op <<
" ";
583 stream << scientific <<
rhs1(i, j);
585 stream << (int)
rhs1(i, j);
591 stream <<
rhs1->
get(i, j) <<
";\n";
603 stream <<
"for (" << ii.
get() <<
" = 0; " << ii.
get() <<
" < ";
609 <<
";" << endl << endl;
614 stream <<
lhs.
get(0, ii) <<
" " << _op <<
" " <<
rhs1.
get(0, ii)
615 <<
";" << endl << endl;
625 stream <<
"for (" << ii.
getName() <<
" = 0;" << ii.
getName() <<
" < " 628 stream <<
"for (" << jj.
getName() <<
" = 0;" << jj.
getName() <<
" < " 631 stream <<
lhs->
get(ii, jj) <<
" " << _op <<
" " <<
rhs1->
get(ii, jj) <<
";" << endl;
ExportStatementOperator op2
#define LOG(level)
Just define a handy macro for getting the logger.
Lowest level, the debug level.
ExportArithmeticStatement & allocate(MemoryAllocatorPtr allocator)
virtual uint getDim() const
bool isOne(const ExportIndex &rowIdx, const ExportIndex &colIdx) const
bool isGiven(const ExportIndex &rowIdx, const ExportIndex &colIdx) const
Allows to pass back messages to the calling function.
const std::string get(const ExportIndex &rowIdx, const ExportIndex &colIdx) const
bool isGiven(const ExportIndex &rowIdx, const ExportIndex &colIdx) const
BEGIN_NAMESPACE_ACADO typedef unsigned int uint
returnValue exportCodeAddSubtract(std::ostream &stream, const std::string &_sign="+", const std::string &_realString="real_t", const std::string &_intString="int") const
const DMatrix & getGivenMatrix() const
ExportStatementOperator op1
MemoryAllocatorPtr memAllocator
Returned value is a error.
#define CLOSE_NAMESPACE_ACADO
returnValue exportCodeAssign(std::ostream &stream, const std::string &_op="=", const std::string &_realString="real_t", const std::string &_intString="int") const
Defines a scalar-valued index variable to be used for exporting code.
virtual uint getNumCols() const
Allows to export code of different arithmetic statements.
bool isCalledByValue() const
bool isZero(const ExportIndex &rowIdx, const ExportIndex &colIdx) const
virtual returnValue exportCode(std::ostream &stream, const std::string &_realString="real_t", const std::string &_intString="int", int _precision=16) const
const std::string get(const ExportIndex &rowIdx, const ExportIndex &colIdx) const
std::string getAssignString() const
returnValue exportCodeMultiply(std::ostream &stream, bool transposeRhs1=false, const std::string &_realString="real_t", const std::string &_intString="int") const
virtual uint getNumRows() const
ExportType getType() const
virtual ~ExportArithmeticStatement()
Base class for all kind of statements to be exported by the code generation tool. ...
virtual uint getDim() const
bool isZero(const ExportIndex &rowIdx, const ExportIndex &colIdx) const
std::string getFullName() const
const std::string get() const
BooleanType acadoIsZero(double x, double TOL)
bool isNull() const
Is a null pointer?
virtual uint getNumCols() const
#define BEGIN_NAMESPACE_ACADO
virtual returnValue exportDataDeclaration(std::ostream &stream, const std::string &_realString="real_t", const std::string &_intString="int", int _precision=16) const
ExportStatementOperator op0
ExportArithmeticStatement()
virtual ExportStatement * clone() const
std::shared_ptr< MemoryAllocator > MemoryAllocatorPtr
#define ACADOERROR(retval)
Defines a matrix-valued variable to be used for exporting code.
#define ACADOERRORTEXT(retval, text)
std::string getName() const
virtual uint getNumRows() const