diff --git a/src/classes/PFunction.cpp b/src/classes/PFunction.cpp index b1f75b8f..c323d6dd 100644 --- a/src/classes/PFunction.cpp +++ b/src/classes/PFunction.cpp @@ -247,6 +247,8 @@ void PFunction::FillFuncEvalTree(iter_t const& i, PFuncTreeNode &node) node.fFunctionTag = FUN_LN; else if (!strcmp(str.c_str(), "EXP")) node.fFunctionTag = FUN_EXP; + else if (!strcmp(str.c_str(), "SQRT")) + node.fFunctionTag = FUN_SQRT; else { cerr << endl << "**PANIC ERROR**: function " << str << " doesn't exist, but you never should have reached this point!"; cerr << endl; @@ -442,11 +444,13 @@ Double_t PFunction::EvalNode(PFuncTreeNode &node) } else if (node.fFunctionTag == FUN_ATANH) { return atanh(EvalNode(node.children[0])); } else if (node.fFunctionTag == FUN_LOG) { - return log(EvalNode(node.children[0]))/log(10); + return log(EvalNode(node.children[0]))/log(10.0); } else if (node.fFunctionTag == FUN_LN) { return log(EvalNode(node.children[0])); } else if (node.fFunctionTag == FUN_EXP) { return exp(EvalNode(node.children[0])); + } else if (node.fFunctionTag == FUN_SQRT) { + return sqrt(EvalNode(node.children[0])); } else { cerr << endl << "**PANIC ERROR**: PFunction::EvalNode: node.fID == PFunctionGrammar::functionID: you never should have reached this point!"; cerr << endl; diff --git a/src/include/PFunction.h b/src/include/PFunction.h index 1a5ca973..900cd592 100644 --- a/src/include/PFunction.h +++ b/src/include/PFunction.h @@ -69,6 +69,7 @@ #define FUN_LOG 12 #define FUN_LN 13 #define FUN_EXP 14 +#define FUN_SQRT 15 //---------------------------------------------------------------------------- typedef struct func_tree_node { diff --git a/src/include/PFunctionGrammar.h b/src/include/PFunctionGrammar.h index 4dd752d5..cd4e2f46 100644 --- a/src/include/PFunctionGrammar.h +++ b/src/include/PFunctionGrammar.h @@ -105,6 +105,7 @@ struct PFunctionGrammar : public grammar | lexeme_d[ root_node_d[ str_p("LOG") ] >> ch_p('(') ] >> expression >> ch_p(')') | lexeme_d[ root_node_d[ str_p("LN") ] >> ch_p('(') ] >> expression >> ch_p(')') | lexeme_d[ root_node_d[ str_p("EXP") ] >> ch_p('(') ] >> expression >> ch_p(')') + | lexeme_d[ root_node_d[ str_p("SQRT") ] >> ch_p('(') ] >> expression >> ch_p(')') ; factor = real