本文整理汇总了C++中CEvaluationNode::compile方法的典型用法代码示例。如果您正苦于以下问题:C++ CEvaluationNode::compile方法的具体用法?C++ CEvaluationNode::compile怎么用?C++ CEvaluationNode::compile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CEvaluationNode
的用法示例。
在下文中一共展示了CEvaluationNode::compile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
// static
CEvaluationNode * CEvaluationNodeDelay::fromAST(const ASTNode * pASTNode, const std::vector< CEvaluationNode * > & children)
{
assert(pASTNode->getNumChildren() == children.size());
size_t i = 0, iMax = children.size();
SubType subType = SubType::DELAY;
std::string data = "delay";
CEvaluationNode * pConvertedNode = new CEvaluationNodeDelay(subType, data);
for (i = 0; i < iMax; ++i)
{
pConvertedNode->addChild(children[i]);
}
pConvertedNode->compile(NULL);
return pConvertedNode;
}
示例2: deriveBranch
//TODO remove pModel
CEvaluationNode* CDerive::deriveBranch(const CEvaluationNode* node, const CCopasiObject * pObject,
std::vector<const CEvaluationNode*>& env,
//std::vector<const CCopasiObject*>& objenv,
const CEvaluationTree* pTree,
bool simplify)
{
CEvaluationNode * newNode = NULL;
const CEvaluationNodeOperator * pENO = dynamic_cast<const CEvaluationNodeOperator*>(node);
if (pENO)
{
if (!pENO->getLeft() || !pENO->getRight()) return NULL;
CEvaluationNode * pLeftDeriv = deriveBranch(pENO->getLeft(), pObject, env, pTree, simplify);
if (!pLeftDeriv) return NULL;
CEvaluationNode * pRightDeriv = deriveBranch(pENO->getRight(), pObject, env, pTree, simplify);
if (!pRightDeriv) {delete pLeftDeriv; return NULL;}
// we now know that derivations of the left and right branch exist
switch ((CEvaluationNodeOperator::SubType) CEvaluationNode::subType(pENO->getType()))
{
case CEvaluationNodeOperator::MULTIPLY:
{
CEvaluationNode * pLeftCopy = copyBranch_var2obj(pENO->getLeft(), env);
CEvaluationNode * pRightCopy = copyBranch_var2obj(pENO->getRight(), env);
CEvaluationNode * tmpNode1 = multiply(pRightCopy, pLeftDeriv, simplify);
CEvaluationNode * tmpNode2 = multiply(pRightDeriv, pLeftCopy, simplify);
return add(tmpNode1, tmpNode2, simplify);
}
break;
case CEvaluationNodeOperator::DIVIDE:
{
CEvaluationNode * pLeftCopy = copyBranch_var2obj(pENO->getLeft(), env);
CEvaluationNode * pRightCopy = copyBranch_var2obj(pENO->getRight(), env);
//numerator
CEvaluationNode * tmpNode1 = multiply(pRightCopy, pLeftDeriv, simplify);
CEvaluationNode * tmpNode2 = multiply(pRightDeriv, pLeftCopy, simplify);
CEvaluationNode * minusNode = subtract(tmpNode1, tmpNode2, simplify);
minusNode->compile(NULL);
//denominator
CEvaluationNode * powerNode = power(copyBranch_var2obj(pENO->getRight(), env),
new CEvaluationNodeNumber(CEvaluationNodeNumber::INTEGER, "2"),
simplify);
return divide(minusNode, powerNode, simplify);
}
break;
case CEvaluationNodeOperator::PLUS:
return add(pLeftDeriv, pRightDeriv, simplify);
break;
case CEvaluationNodeOperator::MINUS:
return subtract(pLeftDeriv, pRightDeriv, simplify);
break;
case CEvaluationNodeOperator::POWER:
{
// b-1
CEvaluationNode * tmpNode = subtract(copyBranch_var2obj(pENO->getRight(), env),
new CEvaluationNodeNumber(CEvaluationNodeNumber::INTEGER, "1"),
simplify);
// a^(b-1)
CEvaluationNode * powerNode = power(copyBranch_var2obj(pENO->getLeft(), env), tmpNode, simplify);
// b*a'
tmpNode = multiply(copyBranch_var2obj(pENO->getRight(), env),
pLeftDeriv, simplify);
// ln a
CEvaluationNodeFunction * funcNode = new CEvaluationNodeFunction(CEvaluationNodeFunction::LOG, "ln");
funcNode->addChild(copyBranch_var2obj(pENO->getLeft(), env)); // add a
// a * b' * ln a
CEvaluationNode * tmpNode2 = multiply(copyBranch_var2obj(pENO->getLeft(), env),
multiply(pRightDeriv, funcNode, simplify),
simplify);
// b*a + a*b * ln a
CEvaluationNode * plusNode = add(tmpNode, tmpNode2, simplify);
// a^(b-1)*(b*a + a*b * ln a)
return multiply(powerNode, plusNode, simplify);
}
//.........这里部分代码省略.........