copasi API  0.1
Static Public Member Functions | Static Public Attributes | Static Protected Member Functions | Static Protected Attributes
CNormalTranslation Class Reference

#include <CNormalTranslation.h>

List of all members.

Static Public Member Functions

static CEvaluationNodesimplifyTree (const CEvaluationNode *node)
static CEvaluationNodesimplifyTreeReptdly (const CEvaluationNode *root0)
static CNormalFractionnormAndSimplify (const CEvaluationNode *root0)
static CNormalFractionnormAndSimplifyReptdly (const CEvaluationTree *tree0, unsigned int depth=0)
static CNormalFractionnormAndSimplifyReptdly (const CEvaluationNode *tree0, unsigned int depth=0)
static CEvaluationNodecreateChain (const CEvaluationNode *pLink, const CEvaluationNode *pNeutralElement, const std::vector< const CEvaluationNode * > &elements)
static CEvaluationNodecreateChain (const CEvaluationNode *pLink, const CEvaluationNode *pNeutralElement, const std::vector< CEvaluationNode * > &elements)
static CEvaluationNodecreateOperatorChain (CEvaluationNodeOperator::SubType type, const char *data, const std::vector< CEvaluationNode * > &nodes)
static CEvaluationNodecreateOperatorChain (CEvaluationNodeOperator::SubType type, const char *data, const std::vector< const CEvaluationNode * > &nodes)
static CEvaluationNodeexpandPowerBases (const CEvaluationNode *pRoot)
static CEvaluationNodeexpandPowerExponents (const CEvaluationNode *pRoot)
static void findSummands (const CEvaluationNode *pRoot, std::vector< const CEvaluationNode * > &summands)
static CEvaluationNodeexpandProducts (CEvaluationNode *pOrig)
static void splitProduct (const CEvaluationNode *pRoot, std::vector< const CEvaluationNode * > &multiplications, std::vector< const CEvaluationNode * > &divisions, bool division)
static void splitSum (const CEvaluationNode *pRoot, std::vector< CEvaluationNode * > &additions, std::vector< CEvaluationNode * > &substractions, bool minus)
static void splitSum (const CEvaluationNode *pRoot, std::vector< const CEvaluationNode * > &additions, std::vector< const CEvaluationNode * > &substractions, bool minus)
static CEvaluationNodeevaluateNumbers (CEvaluationNode *pOrig)

Static Public Attributes

static const CEvaluationNode NEUTRAL_ELEMENT_ADD = CEvaluationNodeNumber(CEvaluationNodeNumber::DOUBLE, "0.0")
static const CEvaluationNode NEUTRAL_ELEMENT_MULTIPLY = CEvaluationNodeNumber(CEvaluationNodeNumber::DOUBLE, "1.0")
static const CEvaluationNode NEUTRAL_ELEMENT_OR = CEvaluationNodeConstant(CEvaluationNodeConstant::FALSE, "FALSE")
static const CEvaluationNode NEUTRAL_ELEMENT_AND = CEvaluationNodeConstant(CEvaluationNodeConstant::TRUE, "TRUE")
static const CEvaluationNode ZERO_NODE = CNormalTranslation::NEUTRAL_ELEMENT_ADD
static const CEvaluationNode ONE_NODE = CNormalTranslation::NEUTRAL_ELEMENT_MULTIPLY
static const CEvaluationNode PLUS_NODE = CEvaluationNodeOperator(CEvaluationNodeOperator::PLUS, "+")
static const CEvaluationNode TIMES_NODE = CEvaluationNodeOperator(CEvaluationNodeOperator::MULTIPLY, "*")

Static Protected Member Functions

static void swapNegativeNumbers (std::vector< CEvaluationNode * > &v1, std::vector< CEvaluationNode * > &v2)
static CEvaluationNodesimplify (const CEvaluationNode *pOrig)
static CEvaluationNodeelementaryElimination (CEvaluationNode *pOrig)
static CEvaluationNodeelementaryEliminationFunction (CEvaluationNode *pFunctionNode)
static CEvaluationNodeelementaryEliminationPower (CEvaluationNode *pPowerNode)
static CEvaluationNodeelementaryEliminationModulus (CEvaluationNode *pModulusNode)
static CEvaluationNodeelementaryEliminationMultiply (CEvaluationNode *pMultiplyNode)
static CEvaluationNodeelementaryEliminationDivide (CEvaluationNode *pDivideNode)
static CEvaluationNodeelementaryEliminationPlus (CEvaluationNode *pPlusNode)
static CEvaluationNodeelementaryEliminationMinus (CEvaluationNode *pMinusNode)
static CEvaluationNodeeliminateNestedPowers (const CEvaluationNode *pOrig)
static CEvaluationNodeexpandPowerNodes (const CEvaluationNode *pOrig)
static std::vector< std::pair
< CEvaluationNode
*, CEvaluationNode * > > 
matchPowerBases (const std::vector< const CEvaluationNode * > &multiplications, const std::vector< const CEvaluationNode * > &divisions)
static std::vector< std::pair
< CEvaluationNode
*, CEvaluationNode * > > 
matchSummands (const std::vector< CEvaluationNode * > &additions, const std::vector< CEvaluationNode * > &subtractions)
static CEvaluationNodemultiply (const CEvaluationNode *pNode1, const CEvaluationNode *pNode2)
static CEvaluationNodecancel (const CEvaluationNode *pOrig)
static CEvaluationNodeeliminate (const CEvaluationNode *pOrig)
static CEvaluationNodeeliminateDirectlyNestedFractions (const CEvaluationNode *pOrig)
static CEvaluationNodeeliminatePowersOfFractions (const CEvaluationNode *pOrig)
static CEvaluationNodeproduct2fraction (const CEvaluationNode *pOrig)
static std::pair
< CEvaluationNode
*, CEvaluationNode * > 
factorize (const std::vector< CEvaluationNode * > &additions, const std::vector< CEvaluationNode * > &subtractions)

Static Protected Attributes

static const double ZERO = 1e-100
static const unsigned int RECURSION_LIMIT = 20

Detailed Description

The class for simplification and translation of trees into CNormal


Member Function Documentation

CEvaluationNode * CNormalTranslation::cancel ( const CEvaluationNode pOrig) [static, protected]

This method does all the canceling on a given node and its children.

CEvaluationNode * CNormalTranslation::createChain ( const CEvaluationNode pLink,
const CEvaluationNode pNeutralElement,
const std::vector< const CEvaluationNode * > &  elements 
) [static]

More general version of createOperatorChain. This method can also be used to combine logical item chains. Once I know this works, I will replace createOperatorChain with this method.

This version of create chain copies the given elements in the vector and then calls the createChain method which does not need copying.

CEvaluationNode * CNormalTranslation::createChain ( const CEvaluationNode pLink,
const CEvaluationNode pNeutralElement,
const std::vector< CEvaluationNode * > &  elements 
) [static]

More general version of createOperatorChain. This version does not copy the nodes in the given vector, but uses them directly. This method can also be used to combine logical item chains. method.

This method creates a chain of operations. The individual elements are linked with copies of pLink. NULL is returned if elements is empty. So if this method is used to create a chanin of OR linked elements which will be embedded in another and linked chain, the neutral element should be a TRUE node since AND combining something with true does not change the result. The neutral element is the element that does not change the result of the operation represented be pLink. So if pLink represents a multiplication, the neutral element is the number node 1.0. This method does not copy the elements in the given vector, but uses them in the chain directly.

CEvaluationNode * CNormalTranslation::createOperatorChain ( CEvaluationNodeOperator::SubType  type,
const char *  data,
const std::vector< CEvaluationNode * > &  nodes 
) [static]

Given a vector of nodes, this method creates a multiplication chain of all the nodes. The chain contains copies of the nodes passed in.

Given a vector of nodes, this method creates a multiplication chain of all the nodes. The chain contains the original nodes and not copies.

CEvaluationNode * CNormalTranslation::createOperatorChain ( CEvaluationNodeOperator::SubType  type,
const char *  data,
const std::vector< const CEvaluationNode * > &  nodes 
) [static]

Given a vector of nodes, this method creates a multiplication chain of all the nodes. The chain contains copies of the nodes passed in.

CEvaluationNode * CNormalTranslation::elementaryElimination ( CEvaluationNode pOrig) [static, protected]

This routine is responsible for all elementary eliminations, e.g. addition of 0. These steps can not lead to new simplifications in the children of the node being simplified, so it is not necessary to run this on the children again.

CEvaluationNode * CNormalTranslation::elementaryEliminationDivide ( CEvaluationNode pDivideNode) [static, protected]

This method makes the elementary elimination on a divide node.

CEvaluationNode * CNormalTranslation::elementaryEliminationFunction ( CEvaluationNode pFunctionNode) [static, protected]

This method makes elementary eliminations on function nodes

CEvaluationNode * CNormalTranslation::elementaryEliminationMinus ( CEvaluationNode pMinusNode) [static, protected]

This method makes the elementary elimination on a minus node.

CEvaluationNode * CNormalTranslation::elementaryEliminationModulus ( CEvaluationNode pModulusNode) [static, protected]

This method makes the elementary elimination on a modulus node.

CEvaluationNode * CNormalTranslation::elementaryEliminationMultiply ( CEvaluationNode pMultiplyNode) [static, protected]

This method makes the elementary elimination on a multiply node.

CEvaluationNode * CNormalTranslation::elementaryEliminationPlus ( CEvaluationNode pPlusNode) [static, protected]

This method makes the elementary elimination on a plus node.

CEvaluationNode * CNormalTranslation::elementaryEliminationPower ( CEvaluationNode pPowerNode) [static, protected]

This method makes the elementary elimination on a power node.

CEvaluationNode * CNormalTranslation::eliminate ( const CEvaluationNode pOrig) [static, protected]

This method elminates subexpressions from an expression

CEvaluationNode * CNormalTranslation::eliminateDirectlyNestedFractions ( const CEvaluationNode pOrig) [static, protected]

This method eliminates directly nested fractions. ((a/b)/(c/d)) -> (a*d)/(b*c)

This method eliminates directly nested fractions.

CEvaluationNode * CNormalTranslation::eliminateNestedPowers ( const CEvaluationNode pOrig) [static, protected]

This method removes nested power nodes, e.g. (a^b)^c -> a^(b*c)

CEvaluationNode * CNormalTranslation::eliminatePowersOfFractions ( const CEvaluationNode pOrig) [static, protected]

This method gets rid of fractions within a power construct. (a/b)^3 -> a^3 / b^3

CEvaluationNode * CNormalTranslation::evaluateNumbers ( CEvaluationNode pOrig) [static]

This method evaluates operators acting on two numbers

CEvaluationNode * CNormalTranslation::expandPowerBases ( const CEvaluationNode pRoot) [static]

Given a root node, this method traverses the tree and expands products in power bases to multiplications of power items. It is the responsibility of the caller to delete the returned node.

Given a root node, this method traverses the tree and expands produtcs in power bases to multiplications of power items. It is the responsibility of the caller to delete the returned node.

CEvaluationNode * CNormalTranslation::expandPowerExponents ( const CEvaluationNode pRoot) [static]

Given a root node, this method traverses the tree and expands sums in power exponents to multiplications of power items. It is the responsibility of the caller to delete the returned node.

CEvaluationNode * CNormalTranslation::expandPowerNodes ( const CEvaluationNode pOrig) [static, protected]

This method expands the exponents of power nodes, e.g. A^(x+y) -> A^x * A^y

This method splits a sum into the individual elements void CNormalTranslation::splitSum(const CEvaluationNode* pRoot, std::vector<CEvaluationNode*>& additions, std::vector<CEvaluationNode*>& subtractions, bool minus) { TODO this method might save some copy/delete cycles if the test for TODO negative number was done before making copies of children and TODO inserting them TODO this would also simplify the code since the test would be put TODO into a separate function if (CEvaluationNode::type(pRoot->getType()) == CEvaluationNode::OPERATOR && ((CEvaluationNodeOperator::SubType)CEvaluationNode::subType(pRoot->getType()) == CEvaluationNodeOperator::PLUS || (CEvaluationNodeOperator::SubType)CEvaluationNode::subType(pRoot->getType()) == CEvaluationNodeOperator::MINUS)) { const CEvaluationNode* pChild1 = dynamic_cast<const CEvaluationNode*>(pRoot->getChild()); assert(pChild1 != NULL); const CEvaluationNode* pChild2 = dynamic_cast<const CEvaluationNode*>(pChild1->getSibling()); assert(pChild2 != NULL); assert(pChild2->getSibling() == NULL); if (((CEvaluationNodeOperator::SubType)CEvaluationNode::subType(pRoot->getType())) == CEvaluationNodeOperator::PLUS) { if (CEvaluationNode::type(pChild1->getType()) == CEvaluationNode::OPERATOR && (((CEvaluationNodeOperator::SubType)CEvaluationNode::subType(pChild1->getType())) == CEvaluationNodeOperator::PLUS || ((CEvaluationNodeOperator::SubType)CEvaluationNode::subType(pChild1->getType())) == CEvaluationNodeOperator::MINUS)) { CNormalTranslation::splitSum(pChild1, additions, subtractions, minus); } else { if (minus == false) { additions.push_back(pChild1->copyBranch()); } else { subtractions.push_back(pChild1->copyBranch()); } } if (CEvaluationNode::type(pChild2->getType()) == CEvaluationNode::OPERATOR && (((CEvaluationNodeOperator::SubType)CEvaluationNode::subType(pChild2->getType())) == CEvaluationNodeOperator::PLUS || ((CEvaluationNodeOperator::SubType)CEvaluationNode::subType(pChild2->getType())) == CEvaluationNodeOperator::MINUS)) { CNormalTranslation::splitSum(pChild2, additions, subtractions, minus); } else { if (minus == false) { additions.push_back(pChild2->copyBranch()); } else { subtractions.push_back(pChild2->copyBranch()); } } } else if (((CEvaluationNodeOperator::SubType)CEvaluationNode::subType(pRoot->getType())) == CEvaluationNodeOperator::MINUS) { if (CEvaluationNode::type(pChild1->getType()) == CEvaluationNode::OPERATOR && (((CEvaluationNodeOperator::SubType)CEvaluationNode::subType(pChild1->getType())) == CEvaluationNodeOperator::PLUS || ((CEvaluationNodeOperator::SubType)CEvaluationNode::subType(pChild1->getType())) == CEvaluationNodeOperator::MINUS)) { CNormalTranslation::splitSum(pChild1, additions, subtractions, minus); } else { if (minus == false) { additions.push_back(pChild1->copyBranch()); } else { subtractions.push_back(pChild1->copyBranch()); } } if (CEvaluationNode::type(pChild2->getType()) == CEvaluationNode::OPERATOR && (((CEvaluationNodeOperator::SubType)CEvaluationNode::subType(pChild2->getType())) == CEvaluationNodeOperator::PLUS || ((CEvaluationNodeOperator::SubType)CEvaluationNode::subType(pChild2->getType())) == CEvaluationNodeOperator::MINUS)) { CNormalTranslation::splitSum(pChild2, additions, subtractions, !minus); } else { if (minus == false) { subtractions.push_back(pChild2->copyBranch()); } else { additions.push_back(pChild2->copyBranch()); } } } } else { additions.push_back(pRoot->copyBranch()); } check for negative numbers in additions and add them to subtractions likewise check for negative numbers in substractions and add them to additions do the same for multiplications with a negative number std::vector<CEvaluationNode*>::iterator it = additions.begin(); while (it != additions.end()) { if (CEvaluationNode::type((*it)->getType()) == CEvaluationNode::NUMBER && dynamic_cast<const CEvaluationNodeNumber*>(*it)->value() < 0.0) { std::ostringstream os; os.precision(18); os << static_cast<CEvaluationNodeNumber*>(*it)->value() * -1.0; CEvaluationNode* pTmpNumber = new CEvaluationNodeNumber(CEvaluationNodeNumber::DOUBLE, os.str().c_str()); subtractions.push_back(pTmpNumber); delete *it; it = additions.erase(it); } else if (CEvaluationNode::type((*it)->getType()) == CEvaluationNode::OPERATOR && (CEvaluationNodeOperator::SubType)CEvaluationNode::subType((*it)->getType()) == CEvaluationNodeOperator::MULTIPLY) { actually there should be code that tests if both are negative numbers if ((CEvaluationNode::type(dynamic_cast<const CEvaluationNode*>((*it)->getChild())->getType()) == CEvaluationNode::NUMBER && dynamic_cast<const CEvaluationNodeNumber*>((*it)->getChild())->value() < 0.0)) { if(fabs(dynamic_cast<const CEvaluationNodeNumber*>((*it)->getChild())->value()) - 1.0 < ZERO) { subtractions.push_back(dynamic_cast<const CEvaluationNode*>((*it)->getChild()->getSibling())->copyBranch()); delete *it; it = additions.erase(it); } else { CEvaluationNode* pTmp = new CEvaluationNodeOperator(CEvaluationNodeOperator::MULTIPLY, "*"); std::ostringstream os; os.precision(18); os << static_cast<const CEvaluationNodeNumber*>((*it)->getChild())->value() * -1.0; pTmp->addChild(new CEvaluationNodeNumber(CEvaluationNodeNumber::DOUBLE, os.str().c_str())); pTmp->addChild(dynamic_cast<const CEvaluationNode*>((*it)->getChild()->getSibling())->copyBranch()); subtractions.push_back(pTmp); delete *it; it = additions.erase(it); } } else if (CEvaluationNode::type(dynamic_cast<const CEvaluationNode*>((*it)->getChild()->getSibling())->getType()) == CEvaluationNode::NUMBER && dynamic_cast<const CEvaluationNodeNumber*>((*it)->getChild()->getSibling())->value() < 0.0) { if(fabs(dynamic_cast<const CEvaluationNodeNumber*>((*it)->getChild()->getSibling())->value()) - 1.0 < ZERO) { subtractions.push_back(dynamic_cast<const CEvaluationNode*>((*it)->getChild())->copyBranch()); delete *it; it = additions.erase(it); } else { CEvaluationNode* pTmp = new CEvaluationNodeOperator(CEvaluationNodeOperator::MULTIPLY, "*"); pTmp->addChild(dynamic_cast<const CEvaluationNode*>((*it)->getChild())->copyBranch()); std::ostringstream os; os.precision(18); os << static_cast<const CEvaluationNodeNumber*>((*it)->getChild()->getSibling())->value() * -1.0; pTmp->addChild(new CEvaluationNodeNumber(CEvaluationNodeNumber::DOUBLE, os.str().c_str())); subtractions.push_back(pTmp); delete *it; it = additions.erase(it); } } else { ++it; } } else { ++it; } } it = subtractions.begin(); while (it != subtractions.end()) { if (CEvaluationNode::type((*it)->getType()) == CEvaluationNode::NUMBER && dynamic_cast<const CEvaluationNodeNumber*>(*it)->value() < 0.0) { std::ostringstream os; os.precision(18); os << static_cast<CEvaluationNodeNumber*>(*it)->value() * -1.0; CEvaluationNode* pTmpNumber = new CEvaluationNodeNumber(CEvaluationNodeNumber::DOUBLE, os.str().c_str()); additions.push_back(pTmpNumber); delete *it; it = subtractions.erase(it); } else if (CEvaluationNode::type((*it)->getType()) == CEvaluationNode::OPERATOR && (CEvaluationNodeOperator::SubType)CEvaluationNode::subType((*it)->getType()) == CEvaluationNodeOperator::MULTIPLY) { actually there should be code that tests if both are negative numbers if ((CEvaluationNode::type(dynamic_cast<const CEvaluationNode*>((*it)->getChild())->getType()) == CEvaluationNode::NUMBER && dynamic_cast<const CEvaluationNodeNumber*>((*it)->getChild())->value() < 0.0)) { if(fabs(dynamic_cast<const CEvaluationNodeNumber*>((*it)->getChild())->value()) - 1.0 < ZERO) { additions.push_back(dynamic_cast<const CEvaluationNode*>((*it)->getChild()->getSibling())->copyBranch()); delete *it; it = subtractions.erase(it); } else { CEvaluationNode* pTmp = new CEvaluationNodeOperator(CEvaluationNodeOperator::MULTIPLY, "*"); std::ostringstream os; os.precision(18); os << static_cast<const CEvaluationNodeNumber*>((*it)->getChild())->value() * -1.0; pTmp->addChild(new CEvaluationNodeNumber(CEvaluationNodeNumber::DOUBLE, os.str().c_str())); pTmp->addChild(dynamic_cast<const CEvaluationNode*>((*it)->getChild()->getSibling())->copyBranch()); additions.push_back(pTmp); delete *it; it = subtractions.erase(it); } } else if (CEvaluationNode::type(dynamic_cast<const CEvaluationNode*>((*it)->getChild()->getSibling())->getType()) == CEvaluationNode::NUMBER && dynamic_cast<const CEvaluationNodeNumber*>((*it)->getChild()->getSibling())->value() < 0.0) { if(fabs(dynamic_cast<const CEvaluationNodeNumber*>((*it)->getChild()->getSibling())->value()) - 1.0 < ZERO) { additions.push_back(dynamic_cast<const CEvaluationNode*>((*it)->getChild())->copyBranch()); delete *it; it = subtractions.erase(it); } else { CEvaluationNode* pTmp = new CEvaluationNodeOperator(CEvaluationNodeOperator::MULTIPLY, "*"); pTmp->addChild(dynamic_cast<const CEvaluationNode*>((*it)->getChild())->copyBranch()); std::ostringstream os; os.precision(18); os << static_cast<const CEvaluationNodeNumber*>((*it)->getChild()->getSibling())->value() * -1.0; pTmp->addChild(new CEvaluationNodeNumber(CEvaluationNodeNumber::DOUBLE, os.str().c_str())); additions.push_back(pTmp); delete *it; it = subtractions.erase(it); } } else { ++it; } } else { ++it; } } } This method expands the exponents of power nodes, e.g. A^(x+y) -> A^x * A^y

CEvaluationNode * CNormalTranslation::expandProducts ( CEvaluationNode pOrig) [static]

This method expands products. (A+B)*(C+D) -> (A*C)+(A*D)+(B*C)+(B*D) This method should be replaced by the one below pretty soon.

This method expands products. (A+B)*(C+D) -> (A*C)+(A*D)+(B*C)+(B*D) CEvaluationNode* CNormalTranslation::expandProducts(const CEvaluationNode* pOrig) { CEvaluationNode* pResult = NULL; we have to create operation chains and do the mutliplication on the numerator and the denominator chain if the node is a multiplication or a division if (CEvaluationNode::type(pOrig->getType()) == CEvaluationNode::OPERATOR && ((CEvaluationNodeOperator::SubType)CEvaluationNode::subType(pOrig->getType()) == CEvaluationNodeOperator::MULTIPLY || (CEvaluationNodeOperator::SubType)CEvaluationNode::subType(pOrig->getType()) == CEvaluationNodeOperator::DIVIDE)) { std::vector<const CEvaluationNode*> multiplications, divisions; CNormalTranslation::splitProduct(pOrig, multiplications, divisions, false); unsigned int i, iMax = multiplications.size(); CEvaluationNode* pTmpResult; for (i = 0;i < iMax;++i) { if (pResult == NULL) { pResult = CNormalTranslation::expandProducts(multiplications[i]); } else { CEvaluationNode* pTmpNode = CNormalTranslation::expandProducts(multiplications[i]); pTmpResult = CNormalTranslation::multiply(pResult, pTmpNode); delete pResult; delete pTmpNode; pResult = pTmpResult; } } if (!divisions.empty()) { CEvaluationNode* pDenominator = NULL; iMax = divisions.size(); for (i = 0;i < iMax;++i) { if (pDenominator == NULL) { pDenominator = CNormalTranslation::expandProducts(divisions[i]); } else { CEvaluationNode* pTmpNode = CNormalTranslation::expandProducts(divisions[i]); pTmpResult = CNormalTranslation::multiply(pDenominator, pTmpNode); delete pDenominator; delete pTmpNode; pDenominator = pTmpResult; } delete divisions[i]; } pTmpResult = new CEvaluationNodeOperator(CEvaluationNodeOperator::DIVIDE, "/"); pTmpResult->addChild(pResult); pTmpResult->addChild(pDenominator); pResult = pTmpResult; } } else { const CEvaluationNode* pChild = dynamic_cast<const CEvaluationNode*>(pOrig->getChild()); std::vector<CEvaluationNode*> children; while (pChild != NULL) { children.push_back(CNormalTranslation::expandProducts(pChild)); pChild = dynamic_cast<const CEvaluationNode*>(pChild->getSibling()); } if (CEvaluationNode::type(pOrig->getType()) == CEvaluationNode::OPERATOR && ((CEvaluationNodeOperator::SubType)CEvaluationNode::subType(pOrig->getType())) == CEvaluationNodeOperator::MULTIPLY) { assert(children.size() == 2); pResult = CNormalTranslation::multiply(children[0], children[1]); delete the children delete children[0]; delete children[1]; } if (pResult == NULL) { pResult = pOrig->copyNode(children); } } return pResult; } This method expands products. (A+B)*(C+D) -> (A*C)+(A*D)+(B*C)+(B*D)

std::pair< CEvaluationNode *, CEvaluationNode * > CNormalTranslation::factorize ( const std::vector< CEvaluationNode * > &  additions,
const std::vector< CEvaluationNode * > &  subtractions 
) [static, protected]

This method takes two vectors. One with a list of nodes that are added and one with nodes that are subtracted. It tries to find common factors and divisors in those nodes and returns two result nodes. The first is the multiplication of all common factors and divisors, the other is the sum of the remaining additions and subtractions after removing the common factors and divisors. e.g. (A*B*D+A*C*D) -> returns (A*D) and (B+C)

This method takes two vectors and checks if the elements in the two vectors can be split into multiplications and divisions and if there a common factors in all resulting subgroups.

void CNormalTranslation::findSummands ( const CEvaluationNode pRoot,
std::vector< const CEvaluationNode * > &  summands 
) [static]

Given a node, the method check if the node is a PLUS node, if so, it calls itself recursively on the children. This way all summands of a summation chain are gathered. All items in the vector are children of pRoot.

std::vector< std::pair< CEvaluationNode *, CEvaluationNode * > > CNormalTranslation::matchPowerBases ( const std::vector< const CEvaluationNode * > &  multiplications,
const std::vector< const CEvaluationNode * > &  divisions 
) [static, protected]

The methods get a vector of multiplication elements and a vector of division elements and tries to find elements with the same power base in those two vectors.

std::vector< std::pair< CEvaluationNode *, CEvaluationNode * > > CNormalTranslation::matchSummands ( const std::vector< CEvaluationNode * > &  additions,
const std::vector< CEvaluationNode * > &  subtractions 
) [static, protected]

The methods get a vector of addition elements and a vector of subtractions elements and tries to find equal elements in those two vectors.

CEvaluationNode * CNormalTranslation::multiply ( const CEvaluationNode pNode1,
const CEvaluationNode pNode2 
) [static, protected]

Multiplies the two given nodes and returns the result.

CNormalFraction * CNormalTranslation::normAndSimplify ( const CEvaluationNode root0) [static]

Translate and simplify a tree given by the root node into CNormal structure

Returns:
CNormalFraction*
CNormalFraction * CNormalTranslation::normAndSimplifyReptdly ( const CEvaluationTree tree0,
unsigned int  depth = 0 
) [static]

Translate and simplify a tree by calling normAndSimplify repeatedly until it cannot be simplified further The second parameter is a depth value that is used to track the recursion. If a given limit (currently 20) is reached, the algorithm throws an exception.

Returns:
CNormalFraction*

Translate and simplify a tree by calling normAndSimplify repeatedly until it cannot be simplified further

Returns:
CNormalFraction*
CNormalFraction * CNormalTranslation::normAndSimplifyReptdly ( const CEvaluationNode root0,
unsigned int  depth = 0 
) [static]

Translate and simplify a tree by calling normAndSimplify repeatedly until it cannot be simplified further

Returns:
CNormalFraction*
CEvaluationNode * CNormalTranslation::product2fraction ( const CEvaluationNode pOrig) [static, protected]

This methods converts a product of fractions into a fraction of products.

CEvaluationNode * CNormalTranslation::simplify ( const CEvaluationNode pOrig) [static, protected]

This routine is responsible for recursively simplifying a given CEvaluationNode based tree.

CEvaluationNode * CNormalTranslation::simplifyTree ( const CEvaluationNode node) [static]

Simplify an evaluation tree given by the root node by creating a new simplified tree from the original one. The tree itself is actually not created!

Returns:
NodeClass*, pointer to root node of the newly created tree.

Simplify an evaluation tree given by the root node by creating a new simplified tree from the original one. The tree itself is actually not created!

Returns:
CEvaluationNode*, pointer to root node of the newly created tree.
CEvaluationNode * CNormalTranslation::simplifyTreeReptdly ( const CEvaluationNode root0) [static]

Creating a simplified tree by calling simplifyTree repeatedly until it cannot be simplified further. The tree itself is actually not created!

Returns:
NodeClass*, pointer to root node of the newly created tree.

Creating a simplified tree by calling simplifyTree repeatedly until it cannot be simplified further. The tree itself is actually not created!

Returns:
CEvaluationNode*, pointer to root node of the newly created tree.
void CNormalTranslation::splitProduct ( const CEvaluationNode pRoot,
std::vector< const CEvaluationNode * > &  multiplications,
std::vector< const CEvaluationNode * > &  divisions,
bool  division 
) [static]

This method expands products. (A+B)*(C+D) -> (A*C)+(A*D)+(B*C)+(B*D) This method splits a product into the individual elements

This method splits a product into the individual elements

void CNormalTranslation::splitSum ( const CEvaluationNode pRoot,
std::vector< CEvaluationNode * > &  additions,
std::vector< CEvaluationNode * > &  subtractions,
bool  minus 
) [static]

This method splits a sum into the individual elements. The returned nodes are copies of the original.

This method splits a sum into the individual elements The returned nodes are copies of the original.

void CNormalTranslation::splitSum ( const CEvaluationNode pRoot,
std::vector< const CEvaluationNode * > &  additions,
std::vector< const CEvaluationNode * > &  subtractions,
bool  minus 
) [static]

This method splits a sum into the individual elements. The returned nodes are part of the original node and not copies.

This method splits a sum into the individual elements The returned nodes are part of the original node and not copies.

void CNormalTranslation::swapNegativeNumbers ( std::vector< CEvaluationNode * > &  v1,
std::vector< CEvaluationNode * > &  v2 
) [static, protected]

This routine moves all negative numbers from vector v1 to v2 and changes the number to a positive number.


Member Data Documentation

const CEvaluationNode CNormalTranslation::NEUTRAL_ELEMENT_ADD = CEvaluationNodeNumber(CEvaluationNodeNumber::DOUBLE, "0.0") [static]

Neutral element for an addition chain.

const CEvaluationNode CNormalTranslation::NEUTRAL_ELEMENT_AND = CEvaluationNodeConstant(CEvaluationNodeConstant::TRUE, "TRUE") [static]

Neutral element for an and chain.

const CEvaluationNode CNormalTranslation::NEUTRAL_ELEMENT_MULTIPLY = CEvaluationNodeNumber(CEvaluationNodeNumber::DOUBLE, "1.0") [static]

Neutral element for a multiplication chain.

const CEvaluationNode CNormalTranslation::NEUTRAL_ELEMENT_OR = CEvaluationNodeConstant(CEvaluationNodeConstant::FALSE, "FALSE") [static]

Neutral element for an or chain.

Number node that represents 1.0

const CEvaluationNode CNormalTranslation::PLUS_NODE = CEvaluationNodeOperator(CEvaluationNodeOperator::PLUS, "+") [static]

Operator node that represents the PLUS operation.

const unsigned int CNormalTranslation::RECURSION_LIMIT = 20 [static, protected]
const CEvaluationNode CNormalTranslation::TIMES_NODE = CEvaluationNodeOperator(CEvaluationNodeOperator::MULTIPLY, "*") [static]

Operator node that represents the TIMES operation.

const double CNormalTranslation::ZERO = 1e-100 [static, protected]

Number node that represents 0.0


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines