#include <OSnLNode.h>
Public Member Functions | |
virtual std::string | getTokenNumber () |
virtual std::string | getTokenName ()=0 |
virtual std::string | getNonlinearExpressionInXML () |
OSnLNode * | createExpressionTreeFromPostfix (std::vector< OSnLNode * > nlNodeVec) |
OSnLNode * | createExpressionTreeFromPrefix (std::vector< OSnLNode * > nlNodeVec) |
std::vector< OSnLNode * > | getPrefixFromExpressionTree () |
std::vector< OSnLNode * > | preOrderOSnLNodeTraversal (std::vector< OSnLNode * > *prefixVector) |
std::vector< OSnLNode * > | getPostfixFromExpressionTree () |
std::vector< OSnLNode * > | postOrderOSnLNodeTraversal (std::vector< OSnLNode * > *postfixVector) |
virtual void | getVariableIndexMap (std::map< int, int > *varIdx) |
virtual double | calculateFunction (double *x)=0 |
virtual ADdouble | constructADTape (std::map< int, int > *ADIdx, ADvector *XAD)=0 |
OSnLNode * | copyNodeAndDescendants () |
make a copy of this node and all its descendants | |
virtual OSnLNode * | cloneOSnLNode ()=0 |
OSnLNode () | |
default constructor. | |
virtual | ~OSnLNode () |
default destructor. | |
bool | IsEqual (OSnLNode *that) |
A function to check for the equality of two objects. | |
Public Attributes | |
unsigned int | inumberOfChildren |
inumberOfChildren is the number of OSnLNode child elements set to -1 if the number is not fixed, e.g., for a sum node | |
int | inodeInt |
inodeInt is the unique integer assigned to the OSnLNode | |
int | inodeType |
inodeType is the number of children the node has, it is set to -1 if the number is not known a priori, e.g., a sum node | |
OSnLNode ** | m_mChildren |
m_mChildren holds all the operands, that is, nodes that the current node operates on. | |
double | m_dFunctionValue |
m_dFunctionValue holds the function value given the current variable values. | |
ADdouble | m_ADTape |
m_ADTape stores the expression tree for the this OSnLNode as an ADdouble. |
The OSnLNode Class.
Definition at line 50 of file OSnLNode.h.
OSnLNode::OSnLNode | ( | ) |
default constructor.
Definition at line 156 of file OSnLNode.cpp.
OSnLNode::~OSnLNode | ( | ) | [virtual] |
default destructor.
Definition at line 163 of file OSnLNode.cpp.
std::string OSnLNode::getTokenNumber | ( | ) | [virtual] |
Reimplemented in OSnLNodeNumber, OSnLNodeE, OSnLNodePI, and OSnLNodeVariable.
Definition at line 269 of file OSnLNode.cpp.
virtual std::string OSnLNode::getTokenName | ( | ) | [pure virtual] |
Implemented in OSnLNodePlus, OSnLNodeSum, OSnLNodeMax, OSnLNodeMin, OSnLNodeMinus, OSnLNodeNegate, OSnLNodeTimes, OSnLNodeDivide, OSnLNodePower, OSnLNodeProduct, OSnLNodeLn, OSnLNodeSqrt, OSnLNodeSquare, OSnLNodeCos, OSnLNodeSin, OSnLNodeExp, OSnLNodeAbs, OSnLNodeErf, OSnLNodeIf, OSnLNodeNumber, OSnLNodeE, OSnLNodePI, OSnLNodeVariable, and OSnLNodeAllDiff.
std::string OSnLNode::getNonlinearExpressionInXML | ( | ) | [virtual] |
the following method writes an OSnLNode in OSiL format, it is used by OSiLWriter to take an OSInstance and write the corresponding OSiL
Reimplemented in OSnLNodeNumber, OSnLNodeE, OSnLNodePI, and OSnLNodeVariable.
Definition at line 398 of file OSnLNode.cpp.
Take a vector of OSnLNodes in postfix format and create an OSExpressionTree root node
nlNodeVec | holds a vector of pointers to OSnLNodes in postfix format |
Definition at line 189 of file OSnLNode.cpp.
Take a vector of OSnLNodes in prefix format and create an OSExpressionTree root node
nlNodeVec | holds a vector of pointers to OSnLNodes in prefix format |
Definition at line 229 of file OSnLNode.cpp.
std::vector< OSnLNode * > OSnLNode::getPrefixFromExpressionTree | ( | ) |
Get a vector of pointers to OSnLNodes that correspond to the OSExpressionTree in prefix format
Definition at line 251 of file OSnLNode.cpp.
std::vector< OSnLNode * > OSnLNode::preOrderOSnLNodeTraversal | ( | std::vector< OSnLNode * > * | prefixVector | ) |
Called by getPrefixFromExpressionTree(). This method calls itself recursively and generates a vector of pointers to OSnLNodes in prefix
a | pointer prefixVector to a vector of pointers of OSnLNodes |
Definition at line 257 of file OSnLNode.cpp.
std::vector< OSnLNode * > OSnLNode::getPostfixFromExpressionTree | ( | ) |
Get a vector of pointers to OSnLNodes that correspond to the OSExpressionTree in postfix format
Definition at line 211 of file OSnLNode.cpp.
std::vector< OSnLNode * > OSnLNode::postOrderOSnLNodeTraversal | ( | std::vector< OSnLNode * > * | postfixVector | ) |
Called by getPostfixFromExpressionTree(). This method calls itself recursively and generates a vector of pointers to OSnLNodes in postfix
a | pointer postfixVector to a vector of pointers of OSnLNodes |
Definition at line 217 of file OSnLNode.cpp.
void OSnLNode::getVariableIndexMap | ( | std::map< int, int > * | varIdx | ) | [virtual] |
varIdx is a map where the key is the index of an OSnLNodeVariable and (*varIdx)[ idx] is the kth variable in the map, e.g. (*varIdx)[ 5] = 2 means that variable indexed by 5 is the second variable in the OSnLNode and all of its children
a | pointer to a map of the variables in the OSnLNode and its children |
Reimplemented in OSnLNodeVariable.
Definition at line 433 of file OSnLNode.cpp.
virtual double OSnLNode::calculateFunction | ( | double * | x | ) | [pure virtual] |
Calculate the function value given the current variable values. This is an abstract method which is required to be implemented by the concrete operator nodes that derive or extend from this OSnLNode class.
x | holds the values of the variables in a double array. |
Implemented in OSnLNodePlus, OSnLNodeSum, OSnLNodeMax, OSnLNodeMin, OSnLNodeMinus, OSnLNodeNegate, OSnLNodeTimes, OSnLNodeDivide, OSnLNodePower, OSnLNodeProduct, OSnLNodeLn, OSnLNodeSqrt, OSnLNodeSquare, OSnLNodeCos, OSnLNodeSin, OSnLNodeExp, OSnLNodeAbs, OSnLNodeErf, OSnLNodeIf, OSnLNodeNumber, OSnLNodeE, OSnLNodePI, OSnLNodeVariable, and OSnLNodeAllDiff.
virtual ADdouble OSnLNode::constructADTape | ( | std::map< int, int > * | ADIdx, | |
ADvector * | XAD | |||
) | [pure virtual] |
Create the AD tape to be evaluated by AD. This is an abstract method which is required to be implemented by the concrete operator nodes that derive or extend from this OSnLNode class.
Implemented in OSnLNodePlus, OSnLNodeSum, OSnLNodeMax, OSnLNodeMin, OSnLNodeMinus, OSnLNodeNegate, OSnLNodeTimes, OSnLNodeDivide, OSnLNodePower, OSnLNodeProduct, OSnLNodeLn, OSnLNodeSqrt, OSnLNodeSquare, OSnLNodeCos, OSnLNodeSin, OSnLNodeExp, OSnLNodeAbs, OSnLNodeErf, OSnLNodeIf, OSnLNodeNumber, OSnLNodeE, OSnLNodePI, OSnLNodeVariable, and OSnLNodeAllDiff.
OSnLNode * OSnLNode::copyNodeAndDescendants | ( | ) |
make a copy of this node and all its descendants
Definition at line 170 of file OSnLNode.cpp.
virtual OSnLNode* OSnLNode::cloneOSnLNode | ( | ) | [pure virtual] |
Create or clone a node of this type. This is an abstract method which is required to be implemented by the concrete operator nodes that derive or extend from this OSnLNode class.
x | holds the values of the variables in a double array. |
Implemented in OSnLNodePlus, OSnLNodeSum, OSnLNodeMax, OSnLNodeMin, OSnLNodeMinus, OSnLNodeNegate, OSnLNodeTimes, OSnLNodeDivide, OSnLNodePower, OSnLNodeProduct, OSnLNodeLn, OSnLNodeSqrt, OSnLNodeSquare, OSnLNodeCos, OSnLNodeSin, OSnLNodeExp, OSnLNodeAbs, OSnLNodeErf, OSnLNodeIf, OSnLNodeNumber, OSnLNodeE, OSnLNodePI, OSnLNodeVariable, and OSnLNodeAllDiff.
bool OSnLNode::IsEqual | ( | OSnLNode * | that | ) |
A function to check for the equality of two objects.
Definition at line 445 of file OSnLNode.cpp.
unsigned int OSnLNode::inumberOfChildren |
inumberOfChildren is the number of OSnLNode child elements set to -1 if the number is not fixed, e.g., for a sum node
Definition at line 57 of file OSnLNode.h.
inodeInt is the unique integer assigned to the OSnLNode
Definition at line 60 of file OSnLNode.h.
inodeType is the number of children the node has, it is set to -1 if the number is not known a priori, e.g., a sum node
Definition at line 65 of file OSnLNode.h.
m_mChildren holds all the operands, that is, nodes that the current node operates on.
Definition at line 70 of file OSnLNode.h.
double OSnLNode::m_dFunctionValue |
m_dFunctionValue holds the function value given the current variable values.
Definition at line 75 of file OSnLNode.h.
m_ADTape stores the expression tree for the this OSnLNode as an ADdouble.
Definition at line 80 of file OSnLNode.h.