/home/coin/SVN-release/OS-1.0.0/OS/src/OSCommonInterfaces/OSExpressionTree.cpp

Go to the documentation of this file.
00001 
00018 #include "OSExpressionTree.h"
00019 #include<vector>
00020 
00021 using std::cout; 
00022 using std::endl;
00023 
00024 OSExpressionTree::OSExpressionTree():
00025         m_treeRoot( NULL),
00026         mapVarIdx( NULL),
00027         m_bIndexMapGenerated( false),
00028         bCppADMustReTape( false){
00029 }//end OSExpressionTree
00030 
00031  
00032 OSExpressionTree::~OSExpressionTree(){
00033         #ifdef DEBUG  
00034         cout << "Inside the OSExpressionTree Destructor" << endl;
00035         #endif
00036         if(m_treeRoot != NULL) delete m_treeRoot;
00037         m_treeRoot = NULL;
00038         if(mapVarIdx != NULL) delete mapVarIdx;
00039         mapVarIdx = NULL;
00040 }//end ~OSExpressionTree 
00041 
00042 
00043 std::vector<OSnLNode*> OSExpressionTree::getPostfixFromExpressionTree(){
00044         return m_treeRoot->getPostfixFromExpressionTree();
00045 }//getPostfixFromExpressionTree
00046 
00047 
00048 std::vector<OSnLNode*> OSExpressionTree::getPrefixFromExpressionTree(){
00049         return m_treeRoot->getPrefixFromExpressionTree();
00050 }//getPrefixFromExpressionTree
00051 
00052 
00053 
00054 double OSExpressionTree::calculateFunction( double *x, bool new_x){
00055         //calculateFunctionCppAD( x, functionEvaluated);
00056         if( new_x == false){
00057                 return m_dTreeRootValue; 
00058         }
00059         else{
00060                 m_dTreeRootValue = m_treeRoot->calculateFunction( x);
00061                 return  m_dTreeRootValue;
00062         }
00063 }//calculateFunction
00064 
00065 std::map<int, int> *OSExpressionTree::getVariableIndiciesMap(){
00066         if( m_bIndexMapGenerated == true) return mapVarIdx;
00067         mapVarIdx = new std::map<int, int>();
00068         m_treeRoot->getVariableIndexMap( mapVarIdx);
00069         //std::cout << "SIZE OF MAP =  "  << (*mapVarIdx).size() << std::endl;
00070         int kount = 0;
00071         for(m_mPosVarIdx = (*mapVarIdx).begin(); m_mPosVarIdx != (*mapVarIdx).end(); ++m_mPosVarIdx){
00072                 m_mPosVarIdx->second = kount++;
00073                 //std::cout <<  "POSITION FIRST =  "  << m_mPosVarIdx->first ;
00074                 //std::cout <<  "    POSITION SECOND = "  << m_mPosVarIdx->second << std::endl;
00075         }
00076         m_bIndexMapGenerated = true;
00077         return mapVarIdx;
00078 }//getVariableIndicies
00079 

Generated on Thu May 15 22:15:04 2008 by  doxygen 1.4.7