18 #include "OSParameters.h"
31 # error "don't have header file for math"
40 using std::ostringstream;
157 inumberOfChildren( 0),
158 inumberOfMatrixChildren( 0),
160 m_mMatrixChildren(NULL)
170 std::ostringstream outStr;
171 outStr <<
"inside ExprNode destructor" << std::endl;
186 inumberOfChildren = 0;
201 inumberOfMatrixChildren = 0;
210 ostringstream outStr;
223 ostringstream outStr, logStr;
227 logStr <<
"nonlinear node " << this->
getTokenName() << endl;
261 std::vector<ExprNode*> prefixVector;
268 (*prefixVector).push_back(
this);
279 return *prefixVector;
284 std::vector<ExprNode*> postfixVector;
303 (*postfixVector).push_back(
this);
304 return *postfixVector;
321 "First object is NULL, second is not");
332 "Second object is NULL, first is not");
367 m_dFunctionValue(
OSNaN())
383 std::vector<ExprNode*> stackVec;
384 int kount = nlNodeVec.size() - 1;
388 int numkids = nlNodeVec[kount]->inumberOfChildren;
391 for(
int i = 0; i < numkids; i++)
393 nlNodeVec[kount]->m_mChildren[i] = (
OSnLNode*)stackVec.back();
400 for(
int i = 0; i < numMtxKids; i++)
402 nlNodeVec[kount]->m_mMatrixChildren[i] = (
OSnLMNode*)stackVec.back();
406 stackVec.push_back( nlNodeVec[kount]);
415 std::vector<ExprNode*> stackVec;
418 while(kount <= nlNodeVec.size() - 1)
423 for(
int i = numMtxKids - 1; i >= 0; i--)
425 nlNodeVec[kount]->m_mMatrixChildren[i] = (
OSnLMNode*)stackVec.back();
429 int numkids = nlNodeVec[kount]->inumberOfChildren;
432 for(
int i = numkids - 1; i >= 0; i--)
434 nlNodeVec[kount]->m_mChildren[i] = (
OSnLNode*)stackVec.back();
438 stackVec.push_back( nlNodeVec[kount]);
442 return (
OSnLNode*)nlNodeVec[ kount - 1];
448 std::vector<ExprNode*> prefixVector;
454 (*prefixVector).push_back( (
OSnLNode*)
this);
465 return *prefixVector;
470 std::vector<ExprNode*> postfixVector;
489 (*postfixVector).push_back( (
OSnLNode*)
this);
490 return *postfixVector;
508 ostringstream outStr;
509 outStr <<
"In copyNodeAndDescendants(), copy a node of type " <<
inodeInt;
510 outStr <<
" (" << this->
getTokenName() <<
")" << std::endl;
554 "First object is NULL, second is not");
565 "Second object is NULL, first is not");
609 std::ostringstream outStr;
611 outStr <<
"inside OSnLNodePlus destructor" << endl;
745 throw ErrorClass(
"AllDifferent operator not supported by current Algorithmic Differentiation implementation");
807 throw ErrorClass(
"Max operator not supported by current Algorithmic Differentiation implementation");
868 throw ErrorClass(
"Min operator not supported by current Algorithmic Differentiation implementation");
1550 const double a = (993./880.);
1551 const double b = (89./880.);
1569 const double a = (993./880.);
1570 const double b = (89./880.);
1626 throw ErrorClass(
"if operator not supported by current Algorithmic Differentiation implementation");
1670 ostringstream outStr;
1682 return outStr.str();
1694 ostringstream outStr;
1697 outStr <<
" value=\"";
1702 outStr <<
" type=\"";
1713 return outStr.str();
1740 ostringstream outStr;
1741 outStr <<
"In copyNodeAndDescendants(), copy a node of type " <<
inodeInt;
1742 outStr <<
" (" << this->
getTokenName() <<
")" << std::endl;
1789 "First object is NULL, second is not");
1800 "Second object is NULL, first is not");
1827 if (this->
id != that->
id)
1860 ostringstream outStr;
1862 return outStr.str();
1868 ostringstream outStr;
1870 return outStr.str();
1876 ostringstream outStr;
1880 return outStr.str();
1927 ostringstream outStr;
1929 return outStr.str();
1935 ostringstream outStr;
1937 return outStr.str();
1943 ostringstream outStr;
1947 return outStr.str();
1987 std::ostringstream outStr;
1989 outStr <<
"inside OSnLNodeVariable destructor" << endl;
1997 ostringstream outStr;
2007 outStr <<
":real:" ;
2008 return outStr.str();
2014 ostringstream outStr;
2016 outStr <<
"variable";
2024 outStr <<
":real:" ;
2025 return outStr.str();
2031 ostringstream outStr;
2033 outStr <<
"variable";
2034 outStr <<
" idx=\"";
2037 if (coef < 1 || coef > 1)
2039 outStr <<
" coef=\"";
2050 outStr <<
"</variable>";
2056 return outStr.str();
2075 if( (*varIdx).find(
idx) == (*varIdx).end() )
2079 (*varIdx)[
idx] = 1;
2081 ostringstream outStr;
2082 outStr <<
"add variable " <<
idx <<
" to the map" << std::endl;
2099 ostringstream outStr;
2100 outStr <<
"In copyNodeAndDescendants(), copy a node of type " <<
inodeInt;
2101 outStr <<
" (" << this->
getTokenName() <<
")" << std::endl;
2148 "First object is NULL, second is not");
2159 "Second object is NULL, first is not");
2184 if (this->
idx != that->
idx)
2230 return "matrixDeterminant";
2239 throw ErrorClass(
"Matrix determinant operator not supported by current Algorithmic Differentiation implementation");
2293 return "matrixTrace";
2302 throw ErrorClass(
"Matrix trace operator not supported by current Algorithmic Differentiation implementation");
2354 return "matrixToScalar";
2363 throw ErrorClass(
"Matrix-to-scalar conversion not supported by current Algorithmic Differentiation implementation");
2402 ostringstream outStr;
2403 outStr <<
"In copyNodeAndDescendants(), copy a node of type " <<
inodeInt;
2404 outStr <<
" (" << this->
getTokenName() <<
")" << std::endl;
2438 std::vector<OSnLMNode*> stackVec ;
2439 unsigned int kount = 0;
2440 while(kount <= nlMNodeVec.size() - 1)
2445 for(
int i = numkids - 1; i >= 0; i--)
2447 nlMNodeVec[kount]->m_mMatrixChildren[i] = stackVec.back() ;
2448 stackVec.pop_back();
2451 stackVec.push_back( nlMNodeVec[kount]);
2455 return nlMNodeVec[ kount - 1];
2473 (*postfixVector).push_back(
this);
2474 return *postfixVector;
2480 std::vector<ExprNode*> stackVec;
2481 int kount = nlNodeVec.size() - 1;
2487 for(
int i = 0; i < numkids; i++)
2489 nlNodeVec[kount]->m_mChildren[i] = (
OSnLNode*)stackVec.back();
2490 stackVec.pop_back();
2493 int mtxkids = nlNodeVec[kount]->inumberOfMatrixChildren;
2496 for(
int i = 0; i < mtxkids; i++)
2498 nlNodeVec[kount]->m_mMatrixChildren[i] = (
OSnLMNode*)stackVec.back();
2499 stackVec.pop_back();
2502 stackVec.push_back( nlNodeVec[kount]);
2511 std::vector<ExprNode*> stackVec;
2514 while(kount <= nlNodeVec.size() - 1)
2519 for(
int i = numMtxKids - 1; i >= 0; i--)
2521 nlNodeVec[kount]->m_mMatrixChildren[i] = (
OSnLMNode*)stackVec.back();
2522 stackVec.pop_back();
2525 int numkids = nlNodeVec[kount]->inumberOfChildren;
2528 for(
int i = numkids - 1; i >= 0; i--)
2530 nlNodeVec[kount]->m_mChildren[i] = (
OSnLNode*)stackVec.back();
2531 stackVec.pop_back();
2534 stackVec.push_back( nlNodeVec[kount]);
2538 return (
OSnLMNode*)nlNodeVec[ kount - 1];
2544 std::vector<ExprNode*> prefixVector;
2550 (*prefixVector).push_back( (
OSnLMNode*)
this);
2551 if(inumberOfChildren > 0)
2561 return *prefixVector;
2566 std::vector<ExprNode*> postfixVector;
2573 if(inumberOfChildren > 0)
2585 (*postfixVector).push_back( (
OSnLMNode*)
this);
2586 return *postfixVector;
2592 ostringstream outStr;
2601 return outStr.str();
2709 ostringstream outStr, logStr;
2713 logStr <<
"nonlinear node " << this->
getTokenName() << endl;
2716 if(inumberOfChildren > 0)
2726 if(inumberOfChildren > 0)
2733 if(inumberOfChildren > 0)
2740 return outStr.str();
2773 "First object is NULL, second is not");
2784 "Second object is NULL, first is not");
2794 if (this->inodeInt != that->
inodeInt)
2822 if (inumberOfChildren > 0)
2847 inumberOfChildren = 0;
2857 std::ostringstream outStr;
2859 outStr <<
"inside OSnLMNodeMatrixPlus destructor" << endl;
2866 return "matrixPlus";
2873 return nlMNodePoint;
2880 inumberOfChildren = 0;
2892 std::ostringstream outStr;
2894 outStr <<
"inside OSnLMNodeMatrixSum destructor" << endl;
2908 return nlMNodePoint;
2915 inumberOfChildren = 0;
2933 return "matrixProduct";
2937 double OSnLMNodeMatrixProduct::calculateFunction(
double *
x)
2940 m_dFunctionValue = 1.0;
2946 return m_dFunctionValue;
2950 ADdouble OSnLMNodeMatrixProduct::constructADTape(std::map<int, int> *ADIdx,
ADvector *XAD)
2966 return nlMNodePoint;
2973 inumberOfChildren = 0;
2983 std::ostringstream outStr;
2985 outStr <<
"inside OSnLMNodeMatrixMinus destructor" << endl;
2992 return "matrixMinus";
2999 return nlMNodePoint;
3005 inumberOfChildren = 0;
3015 std::ostringstream outStr;
3017 outStr <<
"inside OSnLMNodeMatrixNegate destructor" << endl;
3024 return "matrixNegate";
3031 return nlMNodePoint;
3037 inumberOfChildren = 0;
3047 std::ostringstream outStr;
3049 outStr <<
"inside OSnLMNodeMatrixTimes destructor" << endl;
3056 return "matrixTimes";
3063 return nlMNodePoint;
3069 inumberOfChildren = 0;
3079 std::ostringstream outStr;
3081 outStr <<
"inside OSnLMNodeMatrixInverse destructor" << endl;
3088 return "matrixInverse";
3095 return nlMNodePoint;
3102 inumberOfChildren = 0;
3112 std::ostringstream outStr;
3114 outStr <<
"inside OSnLMNodeMatrixTranspose destructor" << endl;
3121 return "matrixTranspose";
3128 return nlMNodePoint;
3134 inumberOfChildren = 1;
3144 std::ostringstream outStr;
3146 outStr <<
"inside OSnLMNodeMatrixScalarTimes destructor" << endl;
3153 return "matrixScalarTimes";
3160 return nlMNodePoint;
3166 inumberOfChildren = 0;
3176 std::ostringstream outStr;
3178 outStr <<
"inside OSnLMNodeMatrixDotTimes destructor" << endl;
3185 return "matrixDotTimes";
3192 return nlMNodePoint;
3199 inumberOfChildren = 1;
3209 std::ostringstream outStr;
3211 outStr <<
"inside OSnLMNodeIdentityMatrix destructor" << endl;
3218 return "identityMatrix";
3225 return nlMNodePoint;
3232 inumberOfChildren = 0;
3243 std::ostringstream outStr;
3245 outStr <<
"inside OSnLMNodeMatrixLowerTriangle destructor" << endl;
3252 return "matrixLowerTriangle";
3259 return nlMNodePoint;
3265 ostringstream outStr;
3266 outStr <<
"In copyNodeAndDescendants(), copy a node of type " <<
inodeInt;
3267 outStr <<
" (" << this->
getTokenName() <<
")" << std::endl;
3278 if (inumberOfChildren > 0)
3301 ostringstream outStr;
3302 outStr <<
"<matrixLowerTriangle";
3304 outStr <<
" includeDiagonal=\"false\"";
3305 outStr <<
">" << std::endl;
3309 outStr <<
"</matrixLowerTriangle>";
3310 return outStr.str();
3326 "First object is NULL, second is not");
3337 "Second object is NULL, first is not");
3343 if (this->inodeInt != that->
inodeInt)
3373 inumberOfChildren = 0;
3385 std::ostringstream outStr;
3387 outStr <<
"inside OSnLMNodeMatrixUpperTriangle destructor" << endl;
3394 ostringstream outStr;
3395 outStr <<
"<matrixUpperTriangle";
3397 outStr <<
" includeDiagonal=\"false\"";
3398 outStr <<
">" << std::endl;
3402 outStr <<
"</matrixUpperTriangle>";
3403 return outStr.str();
3408 return "matrixUpperTriangle";
3415 return nlMNodePoint;
3421 ostringstream outStr;
3422 outStr <<
"In copyNodeAndDescendants(), copy a node of type " <<
inodeInt;
3423 outStr <<
" (" << this->
getTokenName() <<
")" << std::endl;
3434 if (inumberOfChildren > 0)
3468 "First object is NULL, second is not");
3479 "Second object is NULL, first is not");
3485 if (this->inodeInt != that->
inodeInt)
3514 inumberOfChildren = 0;
3524 std::ostringstream outStr;
3526 outStr <<
"inside OSnLMNodeMatrixDiagonal destructor" << endl;
3533 return "matrixDiagonal";
3540 return nlMNodePoint;
3547 inumberOfChildren = 0;
3557 std::ostringstream outStr;
3559 outStr <<
"inside OSnLMNodeDiagonalMatrixFromVector destructor" << endl;
3566 return "diagonalMatrixFromVector";
3573 return nlMNodePoint;
3580 inumberOfChildren = 4;
3590 std::ostringstream outStr;
3592 outStr <<
"inside OSnLMNodeMatrixSubmatrixAt destructor" << endl;
3599 return "matrixSubmatrixAt";
3606 return nlMNodePoint;
3614 inumberOfChildren = 0;
3624 std::ostringstream outStr;
3626 outStr <<
"inside OSnLMNodeMatrixReference destructor" << endl;
3633 ostringstream outStr;
3641 return outStr.str();
3646 return "matrixReference";
3652 ostringstream outStr;
3653 outStr <<
"<matrixReference idx=\"" <<
idx <<
"\"/>" << std::endl;
3654 return outStr.str();
3661 return nlMNodePoint;
3667 ostringstream outStr;
3668 outStr <<
"In copyNodeAndDescendants(), copy a node of type " <<
inodeInt;
3669 outStr <<
" (" << this->
getTokenName() <<
")" << std::endl;
3680 if (inumberOfChildren > 0)
3714 "First object is NULL, second is not");
3725 "Second object is NULL, first is not");
3731 if (this->inodeInt != that->
inodeInt)
3740 if (this->
idx != that->
idx)
3761 inumberOfChildren = 0;
3771 std::ostringstream outStr;
3773 outStr <<
"inside OSnLMNodeMatrixVar destructor" << endl;
3780 ostringstream outStr;
3788 return outStr.str();
3799 ostringstream outStr;
3801 outStr <<
"<matrixVar idx=\"" <<
idx <<
"\"/>" << std::endl;
3802 return outStr.str();
3806 double OSnLMNodeMatrixVar::calculateFunction(
double *x)
3808 m_dFunctionValue = coef*x[
idx];
3809 return m_dFunctionValue;
3812 ADdouble OSnLMNodeMatrixVar::constructADTape(std::map<int, int> *varIdx,
ADvector *XAD)
3815 m_ADTape = coef*(*XAD)[ (*varIdx)[
idx] ];
3820 void OSnLMNodeMatrixVar::getVariableIndexMap(std::map<int, int> *varIdx)
3823 if( (*varIdx).find(
idx) != (*varIdx).end() )
3830 numVars = (*varIdx).size();
3832 (*varIdx)[
idx] = numVars;
3843 return nlMNodePoint;
3849 ostringstream outStr;
3850 outStr <<
"In copyNodeAndDescendants(), copy a node of type " <<
inodeInt;
3851 outStr <<
" (" << this->
getTokenName() <<
")" << std::endl;
3862 if (inumberOfChildren > 0)
3896 "First object is NULL, second is not");
3907 "Second object is NULL, first is not");
3913 if (this->inodeInt != that->
inodeInt)
3922 if (this->
idx != that->
idx)
3943 inumberOfChildren = 0;
3953 std::ostringstream outStr;
3955 outStr <<
"inside OSnLMNodeMatrixObj destructor" << endl;
3962 ostringstream outStr;
3970 return outStr.str();
3981 ostringstream outStr;
3982 outStr <<
"<matrixObj idx=\"" <<
idx <<
"\"/>" << std::endl;
3983 return outStr.str();
3987 double OSnLMNodeMatrixObj::calculateFunction(
double *x)
3989 m_dFunctionValue = coef*x[
idx];
3990 return m_dFunctionValue;
3993 ADdouble OSnLMNodeMatrixObj::constructADTape(std::map<int, int> *varIdx,
ADvector *XAD)
3996 m_ADTape = coef*(*XAD)[ (*varIdx)[
idx] ];
4000 void OSnLMNodeMatrixObj::getVariableIndexMap(std::map<int, int> *varIdx)
4003 if( (*varIdx).find(
idx) != (*varIdx).end() )
4010 numVars = (*varIdx).size();
4012 (*varIdx)[
idx] = numVars;
4022 return nlMNodePoint;
4028 ostringstream outStr;
4029 outStr <<
"In copyNodeAndDescendants(), copy a node of type " <<
inodeInt;
4030 outStr <<
" (" << this->
getTokenName() <<
")" << std::endl;
4041 if (inumberOfChildren > 0)
4075 "First object is NULL, second is not");
4086 "Second object is NULL, first is not");
4092 if (this->inodeInt != that->
inodeInt)
4101 if (this->
idx != that->
idx)
4122 inumberOfChildren = 0;
4132 std::ostringstream outStr;
4134 outStr <<
"inside OSnLMNodeMatrixCon destructor" << endl;
4141 ostringstream outStr;
4149 return outStr.str();
4160 ostringstream outStr;
4161 outStr <<
"<matrixCon idx=\"" <<
idx <<
"\"/>" << std::endl;
4162 return outStr.str();
4166 double OSnLMNodeMatrixCon::calculateFunction(
double *x)
4168 m_dFunctionValue = coef*x[
idx];
4169 return m_dFunctionValue;
4172 ADdouble OSnLMNodeMatrixCon::constructADTape(std::map<int, int> *varIdx,
ADvector *XAD)
4175 m_ADTape = coef*(*XAD)[ (*varIdx)[
idx] ];
4180 void OSnLMNodeMatrixCon::getVariableIndexMap(std::map<int, int> *varIdx)
4183 if( (*varIdx).find(
idx) != (*varIdx).end() )
4190 numVars = (*varIdx).size();
4192 (*varIdx)[
idx] = numVars;
4203 return nlMNodePoint;
4209 ostringstream outStr;
4210 outStr <<
"In copyNodeAndDescendants(), copy a node of type " <<
inodeInt;
4211 outStr <<
" (" << this->
getTokenName() <<
")" << std::endl;
4222 if (inumberOfChildren > 0)
4257 "First object is NULL, second is not");
4268 "Second object is NULL, first is not");
4274 if (this->inodeInt != that->
inodeInt)
4283 if (this->
idx != that->
idx)
virtual double calculateFunction(double *x)
The implementation of the virtual functions.
OSnLNodeE()
default constructor.
virtual std::string getNonlinearExpressionInXML()
virtual std::string getTokenName()
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
OSnLMNodeMatrixUpperTriangle()
default constructor.
~OSnLMNodeMatrixObj()
default destructor.
#define OS_IDENTITY_MATRIX
int idx
The index of the matrix.
std::vector< ExprNode * > preOrderOSnLNodeTraversal(std::vector< ExprNode * > *prefixVector)
Called by getPrefixFromExpressionTree().
CouExpr & cos(CouExpr &e)
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
~OSnLNodeMinus()
default destructor.
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
double coef
coef is an option coefficient on the variable, the default value is 1.0
virtual ~OSnLNode()
default destructor.
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
~OSnLMNodeMatrixVar()
default destructor.
~OSnLNodeCos()
default destructor.
OSnLMNodeIdentityMatrix()
default constructor.
~OSnLMNodeMatrixReference()
default destructor.
OSnLMNodeMatrixInverse()
default constructor.
OSnLMNodeDiagonalMatrixFromVector()
default constructor.
virtual std::string getTokenName()
~OSnLNodeLn()
default destructor.
virtual double calculateFunction(double *x)
The implementation of the virtual functions.
This file defines the OSnLNode class along with its derived classes.
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
~OSnLNodeIf()
default destructor.
OSnLNodeVariable()
default constructor.
virtual std::string getTokenName()
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
virtual std::string getTokenName()
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
virtual OSnLMNode * copyNodeAndDescendants()
make a copy of this node and all its descendants
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
const OSSmartPtr< OSOutput > osoutput
double m_dFunctionValue
m_dFunctionValue holds the function value given the current variable values.
virtual OSnLNode * cloneExprNode()
Create or clone a node of this type.
virtual OSnLNode * cloneExprNode()
Create or clone a node of this type.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual std::string getTokenName()
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
virtual OSnLNode * copyNodeAndDescendants()
make a copy of this node and all its descendants
OSnLMNodeMatrixReference()
default constructor.
OSnLMNodeMatrixTimes()
default constructor.
OSnLMNode * createExpressionTreeFromPrefix(std::vector< ExprNode * > nlNodeVec)
Take a vector of ExprNodes (OSnLNodes and OSnLMNodes) in prefix format and create a matrix-valued OSE...
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual std::string getTokenName()
virtual std::string getTokenName()
std::vector< ExprNode * > postOrderOSnLNodeTraversal(std::vector< ExprNode * > *postfixVector)
Called by getPostfixFromExpressionTree().
~OSnLNodeDivide()
default destructor.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
virtual std::string getTokenName()
#define OS_MATRIX_TO_SCALAR
virtual std::string getTokenName()
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
virtual bool IsEqual(OSnLMNodeMatrixReference *that)
A function to check for the equality of two objects.
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
virtual std::string getTokenName()
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
virtual std::string getTokenName()
~OSnLMNodeMatrixLowerTriangle()
default destructor.
virtual double calculateFunction(double *x)
The implementation of the virtual functions.
~OSnLNodeNegate()
default destructor.
unsigned int inumberOfChildren
inumberOfChildren is the number of OSnLNode child elements If this number is not fixed, e.g., for a sum node, it is temporarily set to 0
int idx
idx is the index of the variable
std::string errormsg
errormsg is the error that is causing the exception to be thrown
virtual std::string getNonlinearExpressionInXML()
virtual std::string getTokenName()
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
~OSnLMNodeMatrixScalarTimes()
default destructor.
virtual std::vector< ExprNode * > getPostfixFromExpressionTree()
Get a vector of pointers to ExprNodes that correspond to the expression tree in postfix format...
~OSnLMNodeMatrixSubmatrixAt()
default destructor.
OSnLMNodeMatrixPlus()
default constructor.
~OSnLMNodeIdentityMatrix()
default destructor.
OSnLMNodeMatrixLowerTriangle()
default constructor.
OSnLNodeSin()
default constructor.
CouExpr & sin(CouExpr &e)
OSnLMNode ** m_mMatrixChildren
m_mMatrixChildren holds all the matrix-valued operands, if any.
void fint fint fint real * a
virtual std::vector< ExprNode * > preOrderOSnLNodeTraversal(std::vector< ExprNode * > *prefixVector)
Called by getPrefixFromExpressionTree().
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
virtual std::string getTokenName()
virtual std::string getTokenName()
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual void getVariableIndexMap(std::map< int, int > *varIdx)
varIdx is a map where the key is the index of an OSnLNodeVariable and (*varIdx)[ idx] is the kth vari...
OSnLMNodeMatrixScalarTimes()
default constructor.
virtual std::string getTokenName()
virtual void getVariableIndexMap(std::map< int, int > *varIdx)
varIdx is a map where the key is the index of an OSnLNodeVariable and (*varIdx)[ idx] is the kth vari...
~OSnLNodeVariable()
default destructor.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
virtual std::string getTokenNumber()
virtual std::string getTokenNumber()
int idx
The index of the matrixCon.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
virtual OSnLMNode * copyNodeAndDescendants()
make a copy of this node and all its descendants
CouExpr & exp(CouExpr &e)
~OSnLMNodeMatrixInverse()
default destructor.
int idx
The index of the matrixObj.
~OSnLNodeAbs()
default destructor.
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
int idx
The index of the matrixVar.
virtual OSnLNode * copyNodeAndDescendants()
make a copy of this node and all its descendants
The OSnLMNode Class for nonlinear expressions involving matrices.
~OSnLNodeE()
default destructor.
virtual std::string getTokenNumber()
OSnLMNodeMatrixDiagonal()
default constructor.
virtual ~ExprNode()
default destructor.
OSnLNodeSum()
default constructor.
~OSnLNodeAllDiff()
default destructor.
OSnLMNodeMatrixSum()
default constructor.
virtual std::string getTokenName()
OSnLNodeSquare()
default constructor.
virtual std::string getTokenName()
virtual std::string getTokenName()
int inodeInt
inodeInt is the unique integer assigned to the OSnLNode or OSnLMNode in OSParameters.h.
virtual std::string getTokenNumber()
OSnLMNodeMatrixCon()
default constructor.
virtual std::string getTokenName()
~OSnLMNodeMatrixDotTimes()
default destructor.
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
~OSnLNodeTimes()
default destructor.
OSnLNodeDivide()
default constructor.
virtual std::string getTokenName()
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
virtual std::string getTokenName()
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
std::string id
later, e.g.
~OSnLNodeNumber()
default destructor.
#define OS_MATRIX_REFERENCE
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
unsigned int inumberOfMatrixChildren
inumberOfMatrixChildren is the number of OSnLMNode child elements If this number is not fixed...
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
OSnLNodeNegate()
default constructor.
virtual ExprNode * cloneExprNode()=0
Create or clone a node of this type.
virtual ~OSnLMNode()
default destructor.
OSnLNodeMatrixTrace()
default constructor.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
Create the AD tape to be evaluated by AD.
virtual std::string getNonlinearExpressionInXML()
~OSnLNodeSqrt()
default destructor.
double OSNaN()
returns the value for NaN used in OS
The OSnLNodeNumber Class.
OSnLMNodeMatrixMinus()
default constructor.
~OSnLMNodeMatrixNegate()
default destructor.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
OSnLMNode * createExpressionTreeFromPostfix(std::vector< ExprNode * > nlNodeVec)
Take a vector of ExprNodes (OSnLNodes and OSnLMNodes) in postfix format and create a matrix-valued OS...
OSnLNodeMinus()
default constructor.
OSnLNodePI()
default constructor.
virtual std::string getTokenName()
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
~OSnLMNodeMatrixUpperTriangle()
default destructor.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
virtual std::vector< ExprNode * > preOrderOSnLNodeTraversal(std::vector< ExprNode * > *prefixVector)
Called by getPrefixFromExpressionTree().
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual std::string getTokenName()
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
OSnLNodeIf()
default constructor.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)=0
Create the AD tape to be evaluated by AD.
virtual std::string getTokenName()
OSnLNodeErf()
default constructor.
virtual bool IsEqual(OSnLNodeNumber *that)
A function to check for the equality of two objects.
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
A generic class from which we derive both OSnLNode and OSnLMNode.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
virtual std::string getTokenName()
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
virtual std::vector< ExprNode * > postOrderOSnLNodeTraversal(std::vector< ExprNode * > *postfixVector)
Called by getPostfixFromExpressionTree().
#define OS_MATRIX_SCALARTIMES
bool includeDiagonal
A boolean to express whether the diagonal is to be part of the upper triangle or not.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
OSnLNode * createExpressionTreeFromPostfix(std::vector< ExprNode * > nlNodeVec)
Take a vector of ExprNodes (OSnLNodes and OSnLMNodes) in postfix format and create a scalar-valued OS...
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
virtual std::string getNonlinearExpressionInXML()
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
virtual std::string getTokenName()
~OSnLNodeMatrixTrace()
default destructor.
~OSnLMNodeMatrixCon()
default destructor.
The OSnLNodeVariable Class.
#define OS_MATRIX_TRANSPOSE
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual OSnLMNode * copyNodeAndDescendants()
make a copy of this node and all its descendants
OSnLNodeExp()
default constructor.
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
#define OS_MATRIX_DOTTIMES
~OSnLNodeSquare()
default destructor.
~OSnLNodeErf()
default destructor.
virtual OSnLNode * cloneExprNode()
Create or clone a node of this type.
~OSnLMNodeMatrixMinus()
default destructor.
virtual std::string getNonlinearExpressionInXML()
OSnLMNodeMatrixTranspose()
default constructor.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
OSnLMNodeMatrixNegate()
default constructor.
virtual bool IsEqual(OSnLNodeVariable *that)
A function to check for the equality of two objects.
~OSnLNodeSin()
default destructor.
OSnLMNode()
default constructor.
double value
value is the value of the number
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual std::string getNonlinearExpressionInXML()
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
virtual std::string getTokenName()
OSnLNode ** m_mChildren
m_mChildren holds all the operands, that is, nodes that the current node operates on...
~OSnLMNodeDiagonalMatrixFromVector()
default destructor.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual std::string getTokenName()
OSnLNodeCos()
default constructor.
virtual OSnLMNode * copyNodeAndDescendants()
make a copy of this node and all its descendants
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
virtual bool IsEqual(OSnLMNodeMatrixLowerTriangle *that)
A function to check for the equality of two objects.
virtual std::string getTokenName()
virtual std::string getNonlinearExpressionInXML()
~OSnLNodeMax()
default destructor.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
virtual std::string getTokenName()
virtual std::string getTokenName()
virtual std::string getTokenName()
virtual std::string getTokenName()
std::vector< ExprNode * > getPrefixFromExpressionTree()
Get a vector of pointers to OSnLNodes and OSnLMNodes that correspond to the (matrix-valued) expressio...
~OSnLNodeProduct()
default destructor.
#define OS_MATRIX_PRODUCT
virtual std::string getNonlinearExpressionInXML()
~OSnLNodeMin()
default destructor.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
#define OS_MATRIX_LOWERTRIANGLE
virtual OSnLMNode * copyNodeAndDescendants()
make a copy of this node and all its descendants
virtual std::string getTokenName()
virtual std::string getTokenName()
~OSnLMNodeMatrixDiagonal()
default destructor.
OSnLMNodeMatrixDotTimes()
default constructor.
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
virtual std::vector< ExprNode * > getPrefixFromExpressionTree()
Get a vector of pointers to OSnLNodes and OSnLMNodes that correspond to the (scalar-valued or matrix-...
OSnLNodeAbs()
default constructor.
#define OS_MATRIX_DETERMINANT
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
OSnLNodeMatrixDeterminant()
default constructor.
std::vector< ADdouble > ADvector
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
#define OS_MATRIX_DIAGONAL
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
bool IsEqual(OSnLMNode *that)
A function to check for the equality of two objects.
virtual std::string getTokenName()
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
virtual OSnLMNode * copyNodeAndDescendants()
make a copy of this node and all its descendants
~OSnLMNodeMatrixProduct()
default destructor.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
virtual std::string getTokenName()
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
Create the AD tape to be evaluated by AD.
virtual bool IsEqual(OSnLMNodeMatrixCon *that)
A function to check for the equality of two objects.
~OSnLNodeSum()
default destructor.
std::string os_dtoa_format(double x)
#define OS_MATRIX_INVERSE
~OSnLMNodeMatrixPlus()
default destructor.
virtual bool IsEqual(ExprNode *that)
A function to check for the equality of two objects.
virtual std::string getTokenNumber()
virtual std::string getTokenName()
virtual std::string getNonlinearExpressionInXML()
OSnLNodeAllDiff()
default constructor.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
Create the AD tape to be evaluated by AD.
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
virtual bool IsEqual(OSnLMNodeMatrixUpperTriangle *that)
A function to check for the equality of two objects.
virtual bool IsEqual(OSnLMNodeMatrixObj *that)
A function to check for the equality of two objects.
~OSnLMNodeMatrixSum()
default destructor.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
int inodeType
inodeType essentially tracks whether the number of children are known or not.
virtual OSnLMNode * copyNodeAndDescendants()
make a copy of this node and all its descendants
virtual std::string getTokenName()
virtual std::string getNonlinearExpressionInXML()
The following method writes an OSnLNode or OSnLMNode in OSiL format.
virtual OSnLMNode * cloneExprNode()
The implementation of the virtual functions.
virtual OSnLNode * copyNodeAndDescendants()
make a copy of this node and all its descendants
virtual std::string getTokenName()
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
OSnLNode()
default constructor.
std::string type
in the C++ type is real
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
~OSnLNodeMatrixDeterminant()
default destructor.
OSnLMNodeMatrixObj()
default constructor.
ADdouble m_ADTape
m_ADTape stores the expression tree for the this OSnLNode as an ADdouble.
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
~OSnLMNodeMatrixTranspose()
default destructor.
virtual std::string getTokenName()
OSnLMNodeMatrixProduct()
default constructor.
virtual std::string getTokenNumber()
bool IsEqual(OSnLNode *that)
A function to check for the equality of two objects.
std::vector< ExprNode * > getPostfixFromExpressionTree()
Get a vector of pointers to ExprNodes that correspond to the expression tree in postfix format...
virtual std::string getNonlinearExpressionInXML()
The OSnLNode Class for nonlinear expressions.
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
virtual std::string getTokenName()=0
OSnLNodeLn()
default constructor.
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
virtual std::vector< ExprNode * > getPostfixFromExpressionTree()
Get a vector of pointers to ExprNodes that correspond to the expression tree in postfix format...
virtual std::string getTokenName()
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
~OSnLNodePI()
default destructor.
~OSnLMNodeMatrixTimes()
default destructor.
virtual bool IsEqual(OSnLMNodeMatrixVar *that)
A function to check for the equality of two objects.
virtual std::string getTokenNumber()
virtual std::string getTokenName()
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
OSnLNode * createExpressionTreeFromPrefix(std::vector< ExprNode * > nlNodeVec)
Take a vector of ExprNodes (OSnLNodes and OSnLMNodes) in prefix format and create a scalar-valued OSE...
#define OS_DIAGONAL_MATRIX_FROM_VECTOR
OSnLNodeMatrixToScalar()
default constructor.
virtual std::string getTokenName()
OSnLNodeNumber()
default constructor.
~OSnLNodePlus()
default destructor.
OSnLNodeTimes()
default constructor.
OSnLNodePower()
default constructor.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
used for throwing exceptions.
virtual std::vector< ExprNode * > getPrefixFromExpressionTree()
Get a vector of pointers to OSnLNodes and OSnLMNodes that correspond to the (scalar-valued or matrix-...
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
virtual std::vector< ExprNode * > postOrderOSnLNodeTraversal(std::vector< ExprNode * > *postfixVector)
Called by getPostfixFromExpressionTree().
ExprNode()
default constructor.
virtual std::string getTokenNumber()
virtual std::string getTokenName()
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
OSnLNodeMin()
default constructor.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
virtual std::string getTokenName()
OSnLMNodeMatrixSubmatrixAt()
default constructor.
bool includeDiagonal
A boolean to express whether the diagonal is to be part of the upper triangle or not.
virtual std::string getTokenNumber()
OSnLNodeMax()
default constructor.
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
virtual double calculateFunction(double *x)=0
Calculate the function value given the current variable values.
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
OSnLNodeProduct()
default constructor.
OSnLNodePlus()
default constructor.
virtual std::string getTokenName()
~OSnLNodePower()
default destructor.
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
void fint fint fint real fint real * x
OSnLMNodeMatrixVar()
default constructor.
#define OS_MATRIX_UPPERTRIANGLE
#define OS_MATRIX_SUBMATRIX_AT
~OSnLNodeMatrixToScalar()
default destructor.
CouExpr & log(CouExpr &e)
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
~OSnLNodeExp()
default destructor.
OSnLNodeSqrt()
default constructor.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.