18#include "OSParameters.h"
31# error "don't have header file for math"
40using std::ostringstream;
157 inumberOfChildren( 0),
158 inumberOfMatrixChildren( 0),
160 m_mMatrixChildren(NULL)
170 std::ostringstream outStr;
171 outStr <<
"inside ExprNode destructor" << std::endl;
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;
387 int numMtxKids = nlNodeVec[kount]->inumberOfMatrixChildren;
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)
420 int numMtxKids = nlNodeVec[kount]->inumberOfMatrixChildren;
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");
1116 if( (numberNode->
value) ==
int( numberNode->
value))
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=\"";
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)
2442 int numkids = nlMNodeVec[kount]->inumberOfMatrixChildren;
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;
2484 int numkids = nlNodeVec[kount]->inumberOfChildren;
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)
2516 int numMtxKids = nlNodeVec[kount]->inumberOfMatrixChildren;
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);
2561 return *prefixVector;
2566 std::vector<ExprNode*> postfixVector;
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;
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)
2857 std::ostringstream outStr;
2859 outStr <<
"inside OSnLMNodeMatrixPlus destructor" << endl;
2866 return "matrixPlus";
2873 return nlMNodePoint;
2892 std::ostringstream outStr;
2894 outStr <<
"inside OSnLMNodeMatrixSum destructor" << endl;
2908 return nlMNodePoint;
2933 return "matrixProduct";
2937double OSnLMNodeMatrixProduct::calculateFunction(
double *x)
2940 m_dFunctionValue = 1.0;
2946 return m_dFunctionValue;
2950ADdouble OSnLMNodeMatrixProduct::constructADTape(std::map<int, int> *ADIdx,
ADvector *XAD)
2966 return nlMNodePoint;
2983 std::ostringstream outStr;
2985 outStr <<
"inside OSnLMNodeMatrixMinus destructor" << endl;
2992 return "matrixMinus";
2999 return nlMNodePoint;
3015 std::ostringstream outStr;
3017 outStr <<
"inside OSnLMNodeMatrixNegate destructor" << endl;
3024 return "matrixNegate";
3031 return nlMNodePoint;
3047 std::ostringstream outStr;
3049 outStr <<
"inside OSnLMNodeMatrixTimes destructor" << endl;
3056 return "matrixTimes";
3063 return nlMNodePoint;
3079 std::ostringstream outStr;
3081 outStr <<
"inside OSnLMNodeMatrixInverse destructor" << endl;
3088 return "matrixInverse";
3095 return nlMNodePoint;
3112 std::ostringstream outStr;
3114 outStr <<
"inside OSnLMNodeMatrixTranspose destructor" << endl;
3121 return "matrixTranspose";
3128 return nlMNodePoint;
3144 std::ostringstream outStr;
3146 outStr <<
"inside OSnLMNodeMatrixScalarTimes destructor" << endl;
3153 return "matrixScalarTimes";
3160 return nlMNodePoint;
3176 std::ostringstream outStr;
3178 outStr <<
"inside OSnLMNodeMatrixDotTimes destructor" << endl;
3185 return "matrixDotTimes";
3192 return nlMNodePoint;
3209 std::ostringstream outStr;
3211 outStr <<
"inside OSnLMNodeIdentityMatrix destructor" << endl;
3218 return "identityMatrix";
3225 return nlMNodePoint;
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;
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)
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;
3468 "First object is NULL, second is not");
3479 "Second object is NULL, first is not");
3485 if (this->inodeInt != that->
inodeInt)
3524 std::ostringstream outStr;
3526 outStr <<
"inside OSnLMNodeMatrixDiagonal destructor" << endl;
3533 return "matrixDiagonal";
3540 return nlMNodePoint;
3557 std::ostringstream outStr;
3559 outStr <<
"inside OSnLMNodeDiagonalMatrixFromVector destructor" << endl;
3566 return "diagonalMatrixFromVector";
3573 return nlMNodePoint;
3590 std::ostringstream outStr;
3592 outStr <<
"inside OSnLMNodeMatrixSubmatrixAt destructor" << endl;
3599 return "matrixSubmatrixAt";
3606 return nlMNodePoint;
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;
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)
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();
3806double OSnLMNodeMatrixVar::calculateFunction(
double *x)
3808 m_dFunctionValue = coef*x[
idx];
3809 return m_dFunctionValue;
3812ADdouble OSnLMNodeMatrixVar::constructADTape(std::map<int, int> *varIdx,
ADvector *XAD)
3815 m_ADTape = coef*(*XAD)[ (*varIdx)[
idx] ];
3820void 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;
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)
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();
3987double OSnLMNodeMatrixObj::calculateFunction(
double *x)
3989 m_dFunctionValue = coef*x[
idx];
3990 return m_dFunctionValue;
3993ADdouble OSnLMNodeMatrixObj::constructADTape(std::map<int, int> *varIdx,
ADvector *XAD)
3996 m_ADTape = coef*(*XAD)[ (*varIdx)[
idx] ];
4000void 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;
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)
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();
4166double OSnLMNodeMatrixCon::calculateFunction(
double *x)
4168 m_dFunctionValue = coef*x[
idx];
4169 return m_dFunctionValue;
4172ADdouble OSnLMNodeMatrixCon::constructADTape(std::map<int, int> *varIdx,
ADvector *XAD)
4175 m_ADTape = coef*(*XAD)[ (*varIdx)[
idx] ];
4180void 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;
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)
const OSSmartPtr< OSOutput > osoutput
std::string os_dtoa_format(double x)
double OSNaN()
returns the value for NaN used in OS
This file defines the OSnLNode class along with its derived classes.
std::vector< ADdouble > ADvector
used for throwing exceptions.
std::string errormsg
errormsg is the error that is causing the exception to be thrown
A generic class from which we derive both OSnLNode and OSnLMNode.
virtual std::vector< ExprNode * > getPrefixFromExpressionTree()
Get a vector of pointers to OSnLNodes and OSnLMNodes that correspond to the (scalar-valued or matrix-...
OSnLNode ** m_mChildren
m_mChildren holds all the operands, that is, nodes that the current node operates on.
int inodeType
inodeType essentially tracks whether the number of children are known or not.
int inodeInt
inodeInt is the unique integer assigned to the OSnLNode or OSnLMNode in OSParameters....
virtual std::vector< ExprNode * > getPostfixFromExpressionTree()
Get a vector of pointers to ExprNodes that correspond to the expression tree in postfix format.
virtual bool IsEqual(ExprNode *that)
A function to check for the equality of two objects.
virtual ~ExprNode()
default destructor.
virtual std::string getTokenNumber()
ExprNode()
default constructor.
unsigned int inumberOfMatrixChildren
inumberOfMatrixChildren is the number of OSnLMNode child elements If this number is not fixed,...
virtual std::vector< ExprNode * > preOrderOSnLNodeTraversal(std::vector< ExprNode * > *prefixVector)
Called by getPrefixFromExpressionTree().
unsigned int inumberOfChildren
inumberOfChildren is the number of OSnLNode child elements If this number is not fixed,...
virtual std::string getNonlinearExpressionInXML()
The following method writes an OSnLNode or OSnLMNode in OSiL format.
OSnLMNode ** m_mMatrixChildren
m_mMatrixChildren holds all the matrix-valued operands, if any.
virtual std::vector< ExprNode * > postOrderOSnLNodeTraversal(std::vector< ExprNode * > *postfixVector)
Called by getPostfixFromExpressionTree().
virtual ExprNode * cloneExprNode()=0
Create or clone a node of this type.
virtual std::string getTokenName()=0
~OSnLMNodeDiagonalMatrixFromVector()
default destructor.
virtual std::string getTokenName()
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
OSnLMNodeDiagonalMatrixFromVector()
default constructor.
The OSnLMNode Class for nonlinear expressions involving matrices.
std::vector< ExprNode * > postOrderOSnLNodeTraversal(std::vector< ExprNode * > *postfixVector)
Called by getPostfixFromExpressionTree().
std::vector< ExprNode * > getPrefixFromExpressionTree()
Get a vector of pointers to OSnLNodes and OSnLMNodes that correspond to the (matrix-valued) expressio...
OSnLMNode * createExpressionTreeFromPrefix(std::vector< ExprNode * > nlNodeVec)
Take a vector of ExprNodes (OSnLNodes and OSnLMNodes) in prefix format and create a matrix-valued OSE...
OSnLMNode * createExpressionTreeFromPostfix(std::vector< ExprNode * > nlNodeVec)
Take a vector of ExprNodes (OSnLNodes and OSnLMNodes) in postfix format and create a matrix-valued OS...
std::vector< ExprNode * > preOrderOSnLNodeTraversal(std::vector< ExprNode * > *prefixVector)
Called by getPrefixFromExpressionTree().
std::vector< ExprNode * > getPostfixFromExpressionTree()
Get a vector of pointers to ExprNodes that correspond to the expression tree in postfix format.
virtual OSnLMNode * copyNodeAndDescendants()
make a copy of this node and all its descendants
bool IsEqual(OSnLMNode *that)
A function to check for the equality of two objects.
virtual ~OSnLMNode()
default destructor.
OSnLMNode()
default constructor.
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
OSnLMNodeIdentityMatrix()
default constructor.
~OSnLMNodeIdentityMatrix()
default destructor.
virtual std::string getTokenName()
int idx
The index of the matrixCon.
virtual OSnLMNode * copyNodeAndDescendants()
make a copy of this node and all its descendants
~OSnLMNodeMatrixCon()
default destructor.
virtual std::string getNonlinearExpressionInXML()
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
virtual std::string getTokenNumber()
OSnLMNodeMatrixCon()
default constructor.
virtual bool IsEqual(OSnLMNodeMatrixCon *that)
A function to check for the equality of two objects.
virtual std::string getTokenName()
OSnLMNodeMatrixDiagonal()
default constructor.
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
~OSnLMNodeMatrixDiagonal()
default destructor.
virtual std::string getTokenName()
~OSnLMNodeMatrixDotTimes()
default destructor.
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
OSnLMNodeMatrixDotTimes()
default constructor.
virtual std::string getTokenName()
~OSnLMNodeMatrixInverse()
default destructor.
virtual std::string getTokenName()
OSnLMNodeMatrixInverse()
default constructor.
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
bool includeDiagonal
A boolean to express whether the diagonal is to be part of the upper triangle or not.
virtual std::string getNonlinearExpressionInXML()
virtual OSnLMNode * copyNodeAndDescendants()
make a copy of this node and all its descendants
virtual std::string getTokenName()
OSnLMNodeMatrixLowerTriangle()
default constructor.
~OSnLMNodeMatrixLowerTriangle()
default destructor.
virtual bool IsEqual(OSnLMNodeMatrixLowerTriangle *that)
A function to check for the equality of two objects.
~OSnLMNodeMatrixMinus()
default destructor.
virtual std::string getTokenName()
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
OSnLMNodeMatrixMinus()
default constructor.
OSnLMNodeMatrixNegate()
default constructor.
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
~OSnLMNodeMatrixNegate()
default destructor.
virtual std::string getTokenName()
OSnLMNodeMatrixObj()
default constructor.
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
virtual bool IsEqual(OSnLMNodeMatrixObj *that)
A function to check for the equality of two objects.
virtual std::string getNonlinearExpressionInXML()
~OSnLMNodeMatrixObj()
default destructor.
virtual OSnLMNode * copyNodeAndDescendants()
make a copy of this node and all its descendants
int idx
The index of the matrixObj.
virtual std::string getTokenNumber()
virtual std::string getTokenName()
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
OSnLMNodeMatrixPlus()
default constructor.
virtual std::string getTokenName()
~OSnLMNodeMatrixPlus()
default destructor.
virtual OSnLMNode * cloneExprNode()
The implementation of the virtual functions.
~OSnLMNodeMatrixProduct()
default destructor.
OSnLMNodeMatrixProduct()
default constructor.
virtual std::string getTokenName()
int idx
The index of the matrix.
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
virtual std::string getTokenName()
OSnLMNodeMatrixReference()
default constructor.
virtual std::string getTokenNumber()
virtual OSnLMNode * copyNodeAndDescendants()
make a copy of this node and all its descendants
virtual bool IsEqual(OSnLMNodeMatrixReference *that)
A function to check for the equality of two objects.
virtual std::string getNonlinearExpressionInXML()
~OSnLMNodeMatrixReference()
default destructor.
~OSnLMNodeMatrixScalarTimes()
default destructor.
virtual std::string getTokenName()
OSnLMNodeMatrixScalarTimes()
default constructor.
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
virtual std::string getTokenName()
~OSnLMNodeMatrixSubmatrixAt()
default destructor.
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
OSnLMNodeMatrixSubmatrixAt()
default constructor.
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
virtual std::string getTokenName()
~OSnLMNodeMatrixSum()
default destructor.
OSnLMNodeMatrixSum()
default constructor.
virtual std::string getTokenName()
~OSnLMNodeMatrixTimes()
default destructor.
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
OSnLMNodeMatrixTimes()
default constructor.
virtual std::string getTokenName()
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
OSnLMNodeMatrixTranspose()
default constructor.
~OSnLMNodeMatrixTranspose()
default destructor.
virtual std::string getTokenName()
bool includeDiagonal
A boolean to express whether the diagonal is to be part of the upper triangle or not.
virtual std::string getNonlinearExpressionInXML()
virtual OSnLMNode * copyNodeAndDescendants()
make a copy of this node and all its descendants
OSnLMNodeMatrixUpperTriangle()
default constructor.
virtual bool IsEqual(OSnLMNodeMatrixUpperTriangle *that)
A function to check for the equality of two objects.
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
~OSnLMNodeMatrixUpperTriangle()
default destructor.
virtual std::string getTokenName()
virtual std::string getTokenNumber()
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
~OSnLMNodeMatrixVar()
default destructor.
int idx
The index of the matrixVar.
virtual OSnLMNode * copyNodeAndDescendants()
make a copy of this node and all its descendants
virtual std::string getNonlinearExpressionInXML()
OSnLMNodeMatrixVar()
default constructor.
virtual bool IsEqual(OSnLMNodeMatrixVar *that)
A function to check for the equality of two objects.
~OSnLNodeAbs()
default destructor.
OSnLNodeAbs()
default constructor.
virtual std::string getTokenName()
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
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 std::string getTokenName()
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
~OSnLNodeAllDiff()
default destructor.
OSnLNodeAllDiff()
default constructor.
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 OSnLNode * cloneExprNode()
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 double calculateFunction(double *x)
Calculate the function value given the current variable values.
~OSnLNodeCos()
default destructor.
OSnLNodeCos()
default constructor.
~OSnLNodeDivide()
default destructor.
OSnLNodeDivide()
default constructor.
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 ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
~OSnLNodeE()
default destructor.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
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()
OSnLNodeE()
default constructor.
virtual std::string getTokenNumber()
virtual std::string getNonlinearExpressionInXML()
OSnLNodeErf()
default constructor.
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)
Create the AD tape to be evaluated by AD.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
~OSnLNodeErf()
default destructor.
OSnLNodeExp()
default constructor.
~OSnLNodeExp()
default destructor.
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 OSnLNode * cloneExprNode()
The implementation of the virtual functions.
The OSnLNode Class for nonlinear expressions.
virtual std::vector< ExprNode * > postOrderOSnLNodeTraversal(std::vector< ExprNode * > *postfixVector)
Called by getPostfixFromExpressionTree().
OSnLNode * createExpressionTreeFromPostfix(std::vector< ExprNode * > nlNodeVec)
Take a vector of ExprNodes (OSnLNodes and OSnLMNodes) in postfix format and create a scalar-valued OS...
OSnLNode()
default constructor.
bool IsEqual(OSnLNode *that)
A function to check for the equality of two objects.
virtual std::vector< ExprNode * > preOrderOSnLNodeTraversal(std::vector< ExprNode * > *prefixVector)
Called by getPrefixFromExpressionTree().
virtual OSnLNode * copyNodeAndDescendants()
make a copy of this node and all its descendants
virtual ~OSnLNode()
default destructor.
virtual std::vector< ExprNode * > getPostfixFromExpressionTree()
Get a vector of pointers to ExprNodes that correspond to the expression tree in postfix format.
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...
ADdouble m_ADTape
m_ADTape stores the expression tree for the this OSnLNode as an ADdouble.
virtual std::vector< ExprNode * > getPrefixFromExpressionTree()
Get a vector of pointers to OSnLNodes and OSnLMNodes that correspond to the (scalar-valued or matrix-...
OSnLNode * createExpressionTreeFromPrefix(std::vector< ExprNode * > nlNodeVec)
Take a vector of ExprNodes (OSnLNodes and OSnLMNodes) in prefix format and create a scalar-valued OSE...
virtual double calculateFunction(double *x)=0
Calculate the function value given the current variable values.
double m_dFunctionValue
m_dFunctionValue holds the function value given the current variable values.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)=0
Create the AD tape to be evaluated by AD.
~OSnLNodeIf()
default destructor.
OSnLNodeIf()
default constructor.
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
virtual std::string getTokenName()
virtual OSnLNode * cloneExprNode()
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.
~OSnLNodeLn()
default destructor.
virtual std::string getTokenName()
OSnLNodeLn()
default constructor.
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
~OSnLNodeMatrixDeterminant()
default destructor.
virtual OSnLNode * cloneExprNode()
Create or clone a node of this type.
virtual double calculateFunction(double *x)
The implementation of the virtual functions.
OSnLNodeMatrixDeterminant()
default constructor.
virtual std::string getTokenName()
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
~OSnLNodeMatrixToScalar()
default destructor.
OSnLNodeMatrixToScalar()
default constructor.
virtual std::string getTokenName()
virtual OSnLNode * cloneExprNode()
Create or clone a node of this type.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
Create the AD tape to be evaluated by AD.
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
virtual std::string getTokenName()
virtual double calculateFunction(double *x)
The implementation of the virtual functions.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
~OSnLNodeMatrixTrace()
default destructor.
OSnLNodeMatrixTrace()
default constructor.
virtual OSnLNode * cloneExprNode()
Create or clone a node of this type.
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
virtual std::string getTokenName()
~OSnLNodeMax()
default destructor.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
OSnLNodeMax()
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.
~OSnLNodeMin()
default destructor.
virtual std::string getTokenName()
OSnLNodeMin()
default constructor.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
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.
~OSnLNodeMinus()
default destructor.
OSnLNodeMinus()
default constructor.
virtual std::string getTokenName()
virtual std::string getTokenName()
OSnLNodeNegate()
default constructor.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
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.
~OSnLNodeNegate()
default destructor.
The OSnLNodeNumber Class.
double value
value is the value of the number
virtual std::string getTokenNumber()
virtual std::string getTokenName()
virtual std::string getNonlinearExpressionInXML()
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
~OSnLNodeNumber()
default destructor.
OSnLNodeNumber()
default constructor.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
std::string id
later, e.g.
virtual OSnLNode * copyNodeAndDescendants()
make a copy of this node and all its descendants
std::string type
in the C++ type is real
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.
virtual std::string getTokenName()
~OSnLNodePI()
default destructor.
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
virtual OSnLNode * cloneExprNode()
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 getTokenNumber()
virtual std::string getNonlinearExpressionInXML()
OSnLNodePI()
default constructor.
virtual double calculateFunction(double *x)
The implementation of the virtual functions.
virtual std::string getTokenName()
OSnLNodePlus()
default constructor.
~OSnLNodePlus()
default destructor.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
~OSnLNodePower()
default destructor.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual std::string getTokenName()
OSnLNodePower()
default constructor.
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 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.
OSnLNodeProduct()
default constructor.
~OSnLNodeProduct()
default destructor.
OSnLNodeSin()
default constructor.
~OSnLNodeSin()
default destructor.
virtual std::string getTokenName()
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
OSnLNodeSqrt()
default constructor.
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
~OSnLNodeSqrt()
default destructor.
virtual OSnLNode * cloneExprNode()
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 ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
OSnLNodeSquare()
default constructor.
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
~OSnLNodeSquare()
default destructor.
virtual std::string getTokenName()
OSnLNodeSum()
default constructor.
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 OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual std::string getTokenName()
~OSnLNodeSum()
default destructor.
OSnLNodeTimes()
default constructor.
virtual std::string getTokenName()
~OSnLNodeTimes()
default destructor.
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
Create the AD tape to be evaluated by AD.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
The OSnLNodeVariable Class.
~OSnLNodeVariable()
default destructor.
virtual std::string getTokenName()
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual OSnLNode * copyNodeAndDescendants()
make a copy of this node and all its descendants
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
virtual bool IsEqual(OSnLNodeVariable *that)
A function to check for the equality of two objects.
OSnLNodeVariable()
default constructor.
virtual std::string getNonlinearExpressionInXML()
int idx
idx is the index of the variable
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 std::string getTokenNumber()
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...
#define OS_MATRIX_UPPERTRIANGLE
#define OS_MATRIX_DOTTIMES
#define OS_MATRIX_INVERSE
#define OS_MATRIX_LOWERTRIANGLE
#define OS_IDENTITY_MATRIX
#define OS_MATRIX_DETERMINANT
#define OS_MATRIX_TO_SCALAR
#define OS_MATRIX_REFERENCE
@ ENUM_OUTPUT_LEVEL_detailed_trace
@ ENUM_OUTPUT_LEVEL_trace
@ ENUM_OUTPUT_LEVEL_warning
#define OS_DIAGONAL_MATRIX_FROM_VECTOR
#define OS_MATRIX_SCALARTIMES
#define OS_MATRIX_PRODUCT
#define OS_MATRIX_TRANSPOSE
@ ENUM_OUTPUT_AREA_OSInstance
#define OS_MATRIX_SUBMATRIX_AT
#define OS_MATRIX_DIAGONAL