54 construct(variableType_, globalTypeID, nRows_, nCols_, name_);
64 construct(variableType_, globalTypeID, nRows_, nCols_,
"");
69 construct(variableType_, globalTypeID, nRows_, nCols_,
"");
100 for(
unsigned el = 0; el < rhs.
getDim(); el++ )
110 for(
unsigned run1 = 0; run1 < rhs.
getNumRows(); run1++ )
112 for(
unsigned run2 = 0; run2 < rhs.
getNumCols(); run2++ )
154 for( run1 = oldDim; run1 <
dim; run1++ )
191 for( run1 = oldDim; run1 <
dim; run1++ )
203 for (run1 = 0; run1 <
dim - 1; run1++)
204 stream << *
element[run1] <<
" , ";
215 return arg.
print(stream);
299 {
return arg1.
add(arg2);}
301 {
return arg1.
sub(arg2);}
303 {
return arg1.
mul(arg2);}
305 {
return arg1.
div(arg2);}
422 for( i = 0; i< arg.
getDim(); i++ ){
426 tmp.element[i] = prod->
clone();
438 for( i = 0; i<
getDim(); i++ ){
456 for( i=0; i<newNumRows; ++i ){
457 for( j=0; j<newNumCols; ++j ){
483 for( i = 0; i<
getDim(); i++ ){
499 for( i = 0; i <
M; i++ ){
500 for( j = 0; j < 2*
M; j++ ){
502 else tmp(i,j) = 0.0 ;
503 if( j == M+i ) tmp(i,j) = 1.0 ;
507 for( i = 0; i < M-1; i++ )
508 for( k = i+1; k <
M; k++ )
509 for( j = 2*M-1; j >= i; j-- )
510 tmp(k,j) -= ( tmp(i,j)*tmp(k,i) )/tmp(i,i);
512 for( i = M-1; i > 0; i-- )
513 for( k = i-1; k >= 0; k-- )
514 for( j = 2*M-1; j >= i; j-- )
515 tmp(k,j) -= (tmp(i,j)*tmp(k,i))/tmp(i,i);
517 for( i = 0; i <
M; i++ )
518 for( j = 2*M-1; j >= 0; j-- )
519 tmp(i,j) = tmp(i,j)/tmp(i,i);
522 for( i = 0; i <
M; i++ ){
523 for( j = 0; j <
M; j++ ){
550 uint run1, run2, _nRows;
553 _nRows = rowIdx2 - rowIdx1;
557 for( run1 = 0; run1 < _nRows; run1++ ){
584 uint run1, run2, _nCols;
587 _nCols = colIdx2 - colIdx1;
592 for( run2 = 0; run2 < _nCols; run2++ ){
593 delete tmp.
element[run1*_nCols+run2];
603 uint run1, run2, _nRows, _nCols;
606 _nCols = colIdx2 - colIdx1;
609 _nRows = rowIdx2 - rowIdx1;
613 for( run1 = 0; run1 < _nRows; run1++ ){
614 for( run2 = 0; run2 < _nCols; run2++ ){
615 delete tmp.
element[run1*_nCols+run2];
626 if( arg.
getDim() == 0 )
return tmp;
636 double *result =
new double[ f.
getDim() ];
642 x[run1] = 1.0 + (
double)rand() / RAND_MAX;
660 for (
unsigned el = 0; el <
getDim(); ++el)
678 for( run1 = 0; run1 <
dim; run1++ ){
690 for( run1 = 0; run1 <
dim; run1++ ){
702 for( run1 = 0; run1 <
dim; run1++ ){
714 for( run1 = 0; run1 <
dim; run1++ ){
726 for( run1 = 0; run1 <
dim; run1++ ){
738 for( run1 = 0; run1 <
dim; run1++ ){
750 for( run1 = 0; run1 <
dim; run1++ ){
762 for( run1 = 0; run1 <
dim; run1++ ){
774 for( run1 = 0; run1 <
dim; run1++ ){
789 for( run1 = 0; run1 <
dim; run1++ ){
790 delete tmp.element[run1];
802 for( run1 = 0; run1 <
dim; run1++ ){
837 for( run1 = 0; run1 <
getDim(); run1++ ){
865 result =
exp(
operator()(0) );
867 for( run1 = 1; run1 <
getDim(); run1++ )
868 result = result +
exp(
operator()(run1) );
870 result =
ln( result );
875 for( run1 = 0; run1 <
getDim(); run1++ ){
921 for( run1 = 0; run1 <
getDim(); run1++ ){
982 for( run1 = 0; run1 < arg.
getNumRows(); run1++ ){
989 delete seed.element[run1];
993 delete result.element[run2*arg.
getNumRows()+run1];
1012 for( run1 = 0; run1 < nV; run1++ ) seed(run1) = 0;
1014 for( run1 = 0; run1 < nV; run1++ ){
1022 for( run2 = 0; run2 < (int)
getNumRows(); run2++ ){
1023 delete result.
element[run2*nV+run1];
1043 for( run1 = 0; run1 <
getNumRows(); run1++ ){
1053 for( run2 = 0; run2 < arg.
getNumRows(); run2++ ){
1054 delete result.element[run1*arg.
getNumRows()+run2];
1066 const unsigned int n = arg.
getDim();
1072 int *Component =
new int[n];
1074 for( run1 = 0; run1 < n; run1++ ){
1091 for(
uint run1 = 0; run1 < seed.
getDim(); run1++ ) varType[run1] = varType_;
1102 unsigned int run1, run2;
1103 const unsigned int n = seed.
getDim();
1108 int *Component =
new int [n];
1111 for( run1 = 0; run1 < n; run1++ ){
1112 varType [run1] = varType_[run1];
1113 Component[run1] = arg[run1];
1117 for( run1 = 0; run1 <
getDim(); run1++ ){
1128 for( run2 = 0; (int) run2 < nIS; run2++ ){
1129 if( IS[run2] != 0 ){
1140 for( run1 = 0; run1 < n; run1++ )
1154 int *Comp =
new int [dim*(order+1)+1];
1167 Comp [i+1] = arg[i];
1168 seed [i+1] = coeff.
element[(order+2)*i+1];
1175 for(
int j=0; j<order; j++ ){
1178 der[dim*(j+1)+i] = der[dim*j+i]->AD_forward( (j+1)*dim+1, vType, Comp, seed, nIS, &IS );
1181 coeff(i,j+2) = *der[dim*(j+1)+i];
1184 seed [dim*(j+1)+i+1] = coeff.
element[(order+2)*i+j+2];
1188 for(
int run = 0; run < nIS; run++ ){
1190 if( IS[run] != 0 )
delete IS[run];
1192 if( IS != 0 ) free(IS);
1196 for(
uint i=0; i<dim*(order+1); i++ )
delete der[i];
1217 int *Component =
new int [Dim];
1220 for( run1 = 0; run1 < Dim; run1++ ){
1227 for( run1 = 0; run1 < (int)
getDim(); run1++ ){
1231 for( run2 = 0; run2 < Dim; run2++ )
1237 for( run2 = 0; run2 < Dim; run2++ ){
1239 delete result.element[run2];
1242 delete iresult[run2];
1247 for(
int run = 0; run < nIS; run++ ){
1249 if( IS[run] != 0 )
delete IS[run];
1251 if( IS != 0 ) free(IS);
1255 delete[] Component ;
1275 for( i=0; i<Dim; i++ )
1276 for( j=0; j<Dim; j++ ){
1277 for( k=0; k<=i; k++ ){
1278 sum(i,j) +=
H(i,k)*
S(k,j);
1280 for( k=i+1; k<Dim; k++ ){
1281 sum(i,j) +=
H(k,i)*
S(k,j);
1285 for( i=0; i<Dim; i++ )
1286 for( j=0; j<=i; j++ )
1287 for( k=0; k<Dim; k++ )
1288 sum2(i,j) +=
S(k,i)*sum(k,j);
1290 for( i=0; i<Dim; i++ )
1291 for( j=0; j<i; j++ )
1292 sum2(j,i) = sum2(i,j);
1320 int *Component =
new int [Dim];
1325 for( run1 = 0; run1 < Dim; run1++ ){
1339 for( run1 = 0; run1 < (int)
getDim(); run1++ ){
1344 for( run2 = 0; run2 < Dim*nS; run2++ )
1347 for( run2 = 0; run2 < nS; run2++ )
1350 for( run2 = 0; run2 < Dim; run2++ )
1353 for( run2 = 0; run2 < nS*nS; run2++ )
1357 element[run1]->
AD_symmetric( Dim, varType, Component, l1, S1, nS, dS, ld, H, nLIS, &LIS, nSIS, &SIS, nHIS, &HIS );
1361 for( run2 = 0; run2 < nS; run2++ ){
1362 for( run3 = 0; run3 < run2; run3++ ){
1364 delete result.element[run2*nS+run3];
1365 delete result.element[run3*nS+run2];
1366 result.element[run2*nS+run3] = sum->
myAdd( sum, H[run2*nS+run3] );
1367 result.element[run3*nS+run2] = sum->
myAdd( sum, H[run2*nS+run3] );
1371 delete result.element[run2*nS+run2];
1372 result.element[run2*nS+run2] = sum->
myAdd( sum, H[run2*nS+run2] );
1377 for( run2 = 0; run2 < nS; run2++ ){
1378 delete tmp.
element[run1*nS+run2];
1384 for( run2 = 0; run2 < nS; run2++ ){
1392 for( run2 = 0; run2 < Dim*nS; run2++ )
1395 for( run2 = 0; run2 < nS; run2++ )
1398 for( run2 = 0; run2 < Dim; run2++ )
1401 for( run2 = 0; run2 < nS*nS; run2++ )
1407 if( dfS != 0 ) *dfS = tmp ;
1408 if( ldf != 0 ) *ldf = tmp2;
1411 for(
int run = 0; run < nLIS; run++ ){
1412 if( LIS[run] != 0 )
delete LIS[run];
1414 if( LIS != 0 ) free(LIS);
1416 for(
int run = 0; run < nSIS; run++ ){
1417 if( SIS[run] != 0 )
delete SIS[run];
1419 if( SIS != 0 ) free(SIS);
1421 for(
int run = 0; run < nHIS; run++ ){
1422 if( HIS[run] != 0 )
delete HIS[run];
1424 if( HIS != 0 ) free(HIS);
1430 delete[] Component ;
1441 for( i = 0; i <
getDim(); i++ )
1453 for( run1 = 0; run1 <
getNumRows(); run1++ ){
1454 for( run2 = 0; run2 <
getNumCols(); run2++ ){
1483 for( i = 0; i <
dim; i++ ){
1490 default :
element[i] =
new Projection( variableType_, globalTypeID+i,
"" );
break;
1507 for (i = 0; i <
dim; i++)
1531 for (
uint i = 0; i <
dim; i++)
1538 std::stringstream tmpName;
1539 if (
name.empty() ==
false)
1542 tmpName <<
name <<
"[" << i <<
"]";
1547 tmp.operator=(*(arg.
element[i]));
1559 for( i = 0; i <
dim; i++ )
1573 for( run1 = 0; run1 <
getDim(); run1++ )
1595 if( tmp == 0 ) tmp =
element[idx];
1597 return tmp->
clone();
VariableType variableType
Operator * getOperatorClone(uint idx) const
virtual int getGlobalIndex() const
Expression getAtan() const
BooleanType isVariable() const
Expression & operator-=(const Expression &arg)
Allows to setup and evaluate a general function based on SymbolicExpressions.
Expression getEntropy() const
IntermediateState sqrt(const Expression &arg)
Expression getPow(const Expression &arg) const
friend Expression operator+(const Expression &arg1, const Expression &arg2)
Expression backwardDerivative(const Expression &arg1, const Expression &arg2)
returnValue substitute(int idx, const Expression &arg) const
Abstract base class for all scalar-valued symbolic operators.
Expression ADsymmetric(const Expression &arg, const Expression &S, const Expression &l, Expression *dfS=0, Expression *ldf=0) const
Expression getCol(const uint &colIdx) const
Implements the scalar sine operator within the symbolic operators family.
virtual NeutralElement isOneOrZero() const =0
Expression operator-() const
Expression getRow(const uint &rowIdx) const
BEGIN_NAMESPACE_ACADO const double EPS
Expression div(const Expression &arg) const
Allows to pass back messages to the calling function.
DVector evaluate(const EvaluationPoint &x, const int &number=0)
Implements the scalar power operator within the symbolic operators family.
virtual Operator * clone() const =0
virtual Operator * substitute(int index, const Operator *sub)=0
BEGIN_NAMESPACE_ACADO typedef unsigned int uint
Expression getCols(const uint &colIdx1, const uint &colIdx2) const
void copy(const Expression &rhs)
Expression operator()(uint idx) const
Expression getLogSumExp() const
Expression getDot() const
#define CLOSE_NAMESPACE_ACADO
Implements the scalar inverse tangens operator (arctan) within the symbolic operators family...
std::ostream & print(std::ostream &stream) const
Expression mul(const Expression &arg) const
GenericMatrix< double > DMatrix
Expression sub(const Expression &arg) const
Operator * product(const Operator *a, const Operator *b) const
Expression getSqrt() const
BooleanType isDependingOn(VariableType type) const
Expression & operator*=(const Expression &arg)
Base class for all variables within the symbolic expressions family.
Expression getPowInt(const int &arg) const
virtual Operator * AD_forward(int dim, VariableType *varType, int *component, Operator **seed, int &nNewIS, TreeProjection ***newIS)=0
Expression getInverse() const
Expression getExp() const
virtual Expression * clone() const
Expression getTan() const
Expression getSumSquare() const
Expression ADforward(const Expression &arg) const
void construct(VariableType variableType_, uint globalTypeID_, uint nRows_, uint nCols_, const std::string &name_)
Implements the scalar cosine operator within the symbolic operators family.
Expression getAsin() const
Implements the scalar tangens operator within the symbolic operators family.
Expression add(const Expression &arg) const
Expression & operator<<(const Expression &arg)
Implements the scalar power operator with integer exponent within the symbolic operators family...
Expression & operator=(const Expression &arg)
Implements the scalar exponential operator within the symbolic operators family.
DMatrix getDependencyPattern(const Expression &arg) const
virtual returnValue AD_backward(int dim, VariableType *varType, int *component, Operator *seed, Operator **df, int &nNewIS, TreeProjection ***newIS)=0
virtual returnValue initDerivative()
Expression & appendRows(const Expression &arg)
Implements the scalar addition operator within the symbolic expressions family.
Implements the scalar subtraction operator within the symbolic operators family.
virtual returnValue initDerivative()
DMatrix getSparsityPattern() const
virtual Operator * myAdd(Operator *a, Operator *b)
friend Expression operator*(const Expression &arg1, const Expression &arg2)
void rhs(const real_t *x, real_t *f)
Implements the projection operator within the symbolic operators family.
unsigned getNumRows() const
Expression transpose() const
Expression getNext() const
virtual BooleanType isVariable(VariableType &varType, int &component) const =0
Implements the scalar inverse sine operator (arcsin) within the symbolic operators family...
friend Expression operator/(const Expression &arg1, const Expression &arg2)
Implements the scalar quotient operator within the symbolic operators family.
unsigned getNumCols() const
virtual Operator * passArgument() const
Expression & assignmentSetup(const Expression &arg)
Expression getODEexpansion(const int &order, const int *arg) const
GenericVector< T > sumRow() const
Expression getAcos() const
IntermediateState ln(const Expression &arg)
virtual returnValue setCurvature(CurvatureType curvature_)=0
Implements the tree-projection operator within the family of SymbolicOperators.
Expression getSin() const
Implements the scalar inverse cosine operator (arccos) within the symbolic operators family...
#define ACADOWARNING(retval)
Expression getSubMatrix(const uint &rowIdx1, const uint &rowIdx2, const uint &colIdx1, const uint &colIdx2) const
#define BEGIN_NAMESPACE_ACADO
Implements the scalar logarithm operator within the symbolic operators family.
Expression getEuclideanNorm() const
virtual CurvatureType getCurvature()=0
IntermediateState exp(const Expression &arg)
Expression ADbackward(const Expression &arg) const
Expression & operator+=(const Expression &arg)
Expression & appendCols(const Expression &arg)
Expression getCos() const
Expression getRows(const uint &rowIdx1, const uint &rowIdx2) const
virtual returnValue AD_symmetric(int dim, VariableType *varType, int *component, Operator *l, Operator **S, int dimS, Operator **dfS, Operator **ldf, Operator **H, int &nNewLIS, TreeProjection ***newLIS, int &nNewSIS, TreeProjection ***newSIS, int &nNewHIS, TreeProjection ***newHIS)=0
int getNumberOfVariables() const
Implements a scalar constant within the symbolic operators family.
Expression & operator/=(const Expression &arg)
#define ACADOERROR(retval)
Implements the scalar product operator within the symbolic operators family.