Public Member Functions | Public Attributes | List of all members
OSnLNode Class Referenceabstract

The OSnLNode Class for nonlinear expressions. More...

#include <OSnLNode.h>

Inheritance diagram for OSnLNode:
Inheritance graph
[legend]
Collaboration diagram for OSnLNode:
Collaboration graph
[legend]

Public Member Functions

 OSnLNode ()
 default constructor. More...
 
virtual ~OSnLNode ()
 default destructor. More...
 
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 variable in the map, e.g. More...
 
virtual double calculateFunction (double *x)=0
 Calculate the function value given the current variable values. More...
 
virtual ADdouble constructADTape (std::map< int, int > *ADIdx, ADvector *XAD)=0
 Create the AD tape to be evaluated by AD. More...
 
OSnLNodecreateExpressionTreeFromPrefix (std::vector< ExprNode * > nlNodeVec)
 Take a vector of ExprNodes (OSnLNodes and OSnLMNodes) in prefix format and create a scalar-valued OSExpressionTree root node. More...
 
virtual std::vector< ExprNode * > getPrefixFromExpressionTree ()
 Get a vector of pointers to OSnLNodes and OSnLMNodes that correspond to the (scalar-valued or matrix-valued) expression tree in prefix format. More...
 
virtual std::vector< ExprNode * > preOrderOSnLNodeTraversal (std::vector< ExprNode * > *prefixVector)
 Called by getPrefixFromExpressionTree(). More...
 
OSnLNodecreateExpressionTreeFromPostfix (std::vector< ExprNode * > nlNodeVec)
 Take a vector of ExprNodes (OSnLNodes and OSnLMNodes) in postfix format and create a scalar-valued OSExpressionTree root node. More...
 
virtual std::vector< ExprNode * > getPostfixFromExpressionTree ()
 Get a vector of pointers to ExprNodes that correspond to the expression tree in postfix format. More...
 
virtual std::vector< ExprNode * > postOrderOSnLNodeTraversal (std::vector< ExprNode * > *postfixVector)
 Called by getPostfixFromExpressionTree(). More...
 
virtual OSnLNodecopyNodeAndDescendants ()
 make a copy of this node and all its descendants More...
 
bool IsEqual (OSnLNode *that)
 A function to check for the equality of two objects. More...
 
- Public Member Functions inherited from ExprNode
 ExprNode ()
 default constructor. More...
 
virtual ~ExprNode ()
 default destructor. More...
 
virtual std::string getTokenNumber ()
 
virtual std::string getTokenName ()=0
 
virtual std::string getNonlinearExpressionInXML ()
 The following method writes an OSnLNode or OSnLMNode in OSiL format. More...
 
virtual ExprNodecloneExprNode ()=0
 Create or clone a node of this type. More...
 
virtual bool IsEqual (ExprNode *that)
 A function to check for the equality of two objects. More...
 

Public Attributes

double m_dFunctionValue
 m_dFunctionValue holds the function value given the current variable values. More...
 
ADdouble m_ADTape
 m_ADTape stores the expression tree for the this OSnLNode as an ADdouble. More...
 
- Public Attributes inherited from ExprNode
int inodeInt
 inodeInt is the unique integer assigned to the OSnLNode or OSnLMNode in OSParameters.h. More...
 
int inodeType
 inodeType essentially tracks whether the number of children are known or not. More...
 
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 More...
 
unsigned int inumberOfMatrixChildren
 inumberOfMatrixChildren is the number of OSnLMNode child elements If this number is not fixed, e.g., for a matrixProduct node, it is temporarily set to 0 More...
 
OSnLNode ** m_mChildren
 m_mChildren holds all the operands, that is, nodes that the current node operates on. More...
 
OSnLMNode ** m_mMatrixChildren
 m_mMatrixChildren holds all the matrix-valued operands, if any. More...
 

Detailed Description

The OSnLNode Class for nonlinear expressions.

Author
Horand Gassmann, Jun Ma, Kipp Martin
Version
1.0, 10/05/2005
Since
OS1.0

Definition at line 179 of file OSnLNode.h.

Constructor & Destructor Documentation

OSnLNode::OSnLNode ( )

default constructor.

Definition at line 365 of file OSnLNode.cpp.

OSnLNode::~OSnLNode ( )
virtual

default destructor.

Definition at line 374 of file OSnLNode.cpp.

Member Function Documentation

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

Parameters
apointer to a map of the variables in the OSnLNode and its children

Reimplemented in OSnLNodeVariable.

Definition at line 493 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.

Parameters
xholds the values of the variables in a double array.
Returns
the function value given the current variable values.

Implemented in OSnLNodeMatrixToScalar, OSnLNodeMatrixTrace, OSnLNodeMatrixDeterminant, OSnLNodeAllDiff, OSnLNodeVariable, OSnLNodePI, OSnLNodeE, OSnLNodeNumber, OSnLNodeIf, OSnLNodeErf, OSnLNodeAbs, OSnLNodeExp, OSnLNodeSin, OSnLNodeCos, OSnLNodeSquare, OSnLNodeSqrt, OSnLNodeLn, OSnLNodeProduct, OSnLNodePower, OSnLNodeDivide, OSnLNodeTimes, OSnLNodeNegate, OSnLNodeMinus, OSnLNodeMin, OSnLNodeMax, OSnLNodeSum, and OSnLNodePlus.

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.

Returns
the expression tree.

Implemented in OSnLNodeMatrixToScalar, OSnLNodeMatrixTrace, OSnLNodeMatrixDeterminant, OSnLNodeAllDiff, OSnLNodeVariable, OSnLNodePI, OSnLNodeE, OSnLNodeNumber, OSnLNodeIf, OSnLNodeErf, OSnLNodeAbs, OSnLNodeExp, OSnLNodeSin, OSnLNodeCos, OSnLNodeSquare, OSnLNodeSqrt, OSnLNodeLn, OSnLNodeProduct, OSnLNodePower, OSnLNodeDivide, OSnLNodeTimes, OSnLNodeNegate, OSnLNodeMinus, OSnLNodeMin, OSnLNodeMax, OSnLNodeSum, and OSnLNodePlus.

OSnLNode * OSnLNode::createExpressionTreeFromPrefix ( std::vector< ExprNode * >  nlNodeVec)

Take a vector of ExprNodes (OSnLNodes and OSnLMNodes) in prefix format and create a scalar-valued OSExpressionTree root node.

Parameters
nlNodeVecholds a vector of pointers to OSnLNodes and OSnLMNodes in prefix format
Returns
a pointer to an OSnLNode which is the root of an OSExpressionTree.

Definition at line 381 of file OSnLNode.cpp.

std::vector< ExprNode * > OSnLNode::getPrefixFromExpressionTree ( )
virtual

Get a vector of pointers to OSnLNodes and OSnLMNodes that correspond to the (scalar-valued or matrix-valued) expression tree in prefix format.

Returns
the expression tree as a vector of ExprNodes in prefix.

Reimplemented from ExprNode.

Definition at line 446 of file OSnLNode.cpp.

std::vector< ExprNode * > OSnLNode::preOrderOSnLNodeTraversal ( std::vector< ExprNode * > *  prefixVector)
virtual

Called by getPrefixFromExpressionTree().

This method calls itself recursively and generates a vector of pointers to ExprNode in prefix

Parameters
apointer prefixVector to a vector of pointers of ExprNodes
Returns
a vector of pointers to ExprNode in prefix.

Reimplemented from ExprNode.

Definition at line 452 of file OSnLNode.cpp.

OSnLNode * OSnLNode::createExpressionTreeFromPostfix ( std::vector< ExprNode * >  nlNodeVec)

Take a vector of ExprNodes (OSnLNodes and OSnLMNodes) in postfix format and create a scalar-valued OSExpressionTree root node.

Parameters
nlNodeVecholds a vector of pointers to OSnLNodes in postfix format
Returns
a pointer to an OSnLNode which is the root of an OSExpressionTree.

Definition at line 413 of file OSnLNode.cpp.

std::vector< ExprNode * > OSnLNode::getPostfixFromExpressionTree ( )
virtual

Get a vector of pointers to ExprNodes that correspond to the expression tree in postfix format.

Returns
the expression tree as a vector of ExprNodes in postfix.

Reimplemented from ExprNode.

Definition at line 468 of file OSnLNode.cpp.

std::vector< ExprNode * > OSnLNode::postOrderOSnLNodeTraversal ( std::vector< ExprNode * > *  postfixVector)
virtual

Called by getPostfixFromExpressionTree().

This method calls itself recursively and generates a vector of pointers to ExprNodes in postfix.

Parameters
apointer postfixVector to a vector of pointers of ExprNodes
Returns
a vector of pointers to ExprNodes in postfix.

Reimplemented from ExprNode.

Definition at line 475 of file OSnLNode.cpp.

OSnLNode * OSnLNode::copyNodeAndDescendants ( )
virtual

make a copy of this node and all its descendants

Returns
a pointer to the duplicate node

Reimplemented in OSnLNodeVariable, and OSnLNodeNumber.

Definition at line 505 of file OSnLNode.cpp.

bool OSnLNode::IsEqual ( OSnLNode that)

A function to check for the equality of two objects.

Definition at line 541 of file OSnLNode.cpp.

Member Data Documentation

double OSnLNode::m_dFunctionValue

m_dFunctionValue holds the function value given the current variable values.

Definition at line 185 of file OSnLNode.h.

ADdouble OSnLNode::m_ADTape

m_ADTape stores the expression tree for the this OSnLNode as an ADdouble.

Definition at line 190 of file OSnLNode.h.


The documentation for this class was generated from the following files: