24 #include "sbml/math/ASTNode.h"
35 const char * str =
mData.c_str();
44 std::istringstream in;
45 in.imbue(std::locale::classic());
69 std::ostringstream
Data;
71 Data.imbue(std::locale::classic());
88 assert(pASTNode->getNumChildren() == children.size());
92 std::string data =
"";
95 switch (pASTNode->getType())
100 if (pASTNode->getInteger() < 0)
104 ss <<
abs(pASTNode->getInteger());
110 ss << pASTNode->getInteger();
120 if (pASTNode->getReal() == (std::numeric_limits<C_FLOAT64>::infinity()))
124 else if (pASTNode->getReal() == (-std::numeric_limits<C_FLOAT64>::infinity()))
129 else if (isnan(pASTNode->getReal()))
133 else if (pASTNode->getReal() < 0.0)
137 ss << fabs(pASTNode->getReal());
143 ss << pASTNode->getReal();
153 if (pASTNode->getReal() == (std::numeric_limits<C_FLOAT64>::infinity()))
157 else if (pASTNode->getReal() == (-std::numeric_limits<C_FLOAT64>::infinity()))
162 else if (isnan(pASTNode->getReal()))
166 else if (pASTNode->getReal() < 0.0)
170 ss << fabs(pASTNode->getReal());
176 ss << pASTNode->getReal();
186 if (pASTNode->getReal() < 0.0)
190 ss <<
"(" <<
abs(pASTNode->getNumerator()) <<
"/" <<
abs(pASTNode->getDenominator()) <<
")";
196 ss <<
"(" << pASTNode->getNumerator() <<
"/" << pASTNode->getDenominator() <<
")";
214 ASTNode* node =
new ASTNode();
218 const char * str =
mData.c_str();
223 node->setType(AST_REAL);
228 node->setType(AST_INTEGER);
229 node->setValue((
long)this->
getValue());
233 node->setType(AST_REAL_E);
234 num2 = floor(log10(this->
getValue()));
235 num1 = pow(10.0, log10(this->
getValue()) - num2);
236 node->setValue(num1, (
long)num2);
240 node->setType(AST_RATIONAL);
245 node->setValue((
long)num1, (
long)num2);
260 const std::vector< std::vector< std::string > > & )
const
262 std::ostringstream out;
265 out <<
"<mn>" <<
mData <<
"</mn>" << std::endl;
272 std::ostringstream out;
273 out << std::setprecision(std::numeric_limits<double>::digits10 + 2) << std::fixed <<
getValue();
static CEvaluationNode * fromAST(const ASTNode *pASTNode, const std::vector< CEvaluationNode * > &children)
const C_FLOAT64 & getValue() const
const Type & getType() const
virtual bool addChild(CCopasiNode< Data > *pChild, CCopasiNode< Data > *pAfter=NULL)
virtual std::string getCCodeString(const std::vector< std::string > &children) const
static Type subType(const Type &type)
class CEvaluationNode::CPrecedence mPrecedence
double strToDouble(const char *str, char const **pTail)
virtual std::string getMMLString(const std::vector< std::string > &children, bool expand, const std::vector< std::vector< std::string > > &variables) const
ASTNode * toAST(const CCopasiDataModel *pDataModel) const
#define PRECEDENCE_NUMBER
virtual ~CEvaluationNodeNumber()