5 #include "Evaluator/Evaluator.h"
6 #include "Evaluator/detail/Evaluator.h"
12 #include <condition_variable>
19 #include <unordered_map>
22 #if defined(__GNUC__) && !defined(__APPLE__) && !defined(__llvm__)
29 #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
34 #define EVAL dd4hep::tools::Evaluator
40 enum { UNKNOWN, VARIABLE, EXPRESSION, FUNCTION, STRING } what;
42 std::string expression;
45 explicit Item() : what(UNKNOWN), variable(0),expression(),
function(0) {}
46 explicit Item(
double x) : what(VARIABLE), variable(x),expression(),
function(0) {}
47 explicit Item(std::string x) : what(EXPRESSION),variable(0),expression(std::move(x)),
function(0) {}
48 explicit Item(
void *x) : what(FUNCTION), variable(0),expression(),
function(x) {}
56 double (*f2)(double,double);
57 double (*f3)(double,double,double);
58 double (*f4)(double,double,double,double);
59 double (*f5)(double,double,double,double,double);
60 FCN(
void* p) { ptr = p; }
61 FCN(
double (*f)()) { f0 = f; }
62 FCN(
double (*f)(
double)) { f1 = f; }
63 FCN(
double (*f)(
double,
double)) { f2 = f; }
64 FCN(
double (*f)(
double,
double,
double)) { f3 = f; }
65 FCN(
double (*f)(
double,
double,
double,
double)) { f4 = f; }
66 FCN(
double (*f)(
double,
double,
double,
double,
double)) { f5 = f; }
71 typedef std::unordered_map<std::string,Item>
dic_type;
91 std::unique_lock<std::mutex>
theLg;
119 #define REMOVE_BLANKS \
120 for(pointer=name;;pointer++) if (!isspace(*pointer)) break; \
121 for(n=strlen(pointer);n>0;n--) if (!isspace(*(pointer+n-1))) break
123 #define SKIP_BLANKS \
125 c = (pointer > end) ? '\0' : *pointer; \
126 if (!isspace(c)) break; \
129 #define EVAL_EXIT(STATUS,POSITION) endp = POSITION; return STATUS
132 static constexpr
char sss[
MAX_N_PAR+2] =
"012345";
134 enum {
ENDL,
LBRA,
OR,
AND,
EQ,
NE,
GE,
GT,
LE,
LT,
137 static int engine(
char const*,
char const*,
double &,
char const* &,
const dic_type &);
139 static int variable(
const std::string & name,
double & result,
156 dic_type::const_iterator iter = dictionary.find(name);
157 if (iter == dictionary.end())
158 return EVAL::ERROR_UNKNOWN_VARIABLE;
160 Item
const& item = iter->second;
163 result = item.variable;
165 case Item::EXPRESSION: {
166 char const* exp_begin = (item.expression.c_str());
167 char const* exp_end = exp_begin + strlen(exp_begin) - 1;
168 if (engine(exp_begin, exp_end, result, exp_end, dictionary) == EVAL::OK)
170 return EVAL::ERROR_CALCULATION_ERROR;
173 return EVAL::ERROR_CALCULATION_ERROR;
177 static int execute_function(
const std::string & name, std::stack<double> & par,
178 double & result,
const dic_type & dictionary)
195 int npar = par.size();
196 if (npar >
MAX_N_PAR)
return EVAL::ERROR_UNKNOWN_FUNCTION;
198 dic_type::const_iterator iter = dictionary.find(sss[npar]+name);
199 if (iter == dictionary.end())
return EVAL::ERROR_UNKNOWN_FUNCTION;
201 Item
const& item = iter->second;
204 for(
int i=0; i<npar; i++) { pp[i] = par.top(); par.pop(); }
206 if (item.function == 0)
return EVAL::ERROR_CALCULATION_ERROR;
207 FCN fcn(item.function);
210 result = (*fcn.f0)();
213 result = (*fcn.f1)(pp[0]);
216 result = (*fcn.f2)(pp[1], pp[0]);
219 result = (*fcn.f3)(pp[2],pp[1],pp[0]);
222 result = (*fcn.f4)(pp[3],pp[2],pp[1],pp[0]);
225 result = (*fcn.f5)(pp[4],pp[3],pp[2],pp[1],pp[0]);
228 return (errno == 0) ? EVAL::OK : EVAL::ERROR_CALCULATION_ERROR;
231 static int operand(
char const* begin,
char const* end,
double & result,
232 char const* & endp,
const dic_type & dictionary)
251 char const* pointer = begin;
257 if (!isalpha(*pointer)) {
260 if ( pointer[0] ==
'0' && pointer < end && (pointer[1] ==
'x' || pointer[1] ==
'X') )
261 result = strtol(pointer, (
char **)(&pointer), 0);
264 result = strtod(pointer, (
char **)(&pointer));
268 EVAL_EXIT( EVAL::ERROR_CALCULATION_ERROR, begin );
274 while(pointer <= end) {
276 if ( !(c ==
'_' || c ==
':') && !isalnum(c))
break;
279 std::string name(begin, pointer-begin);
286 EVAL_STATUS = variable(name, result, dictionary);
287 EVAL_EXIT( EVAL_STATUS, (EVAL_STATUS == EVAL::OK) ? --pointer : begin);
292 std::stack<char const*> pos;
293 std::stack<double> par;
295 char const* par_begin = pointer+1;
299 c = (pointer > end) ?
'\0' : *pointer;
302 EVAL_EXIT( EVAL::ERROR_UNPAIRED_PARENTHESIS, pos.top() );
304 pos.push(pointer);
break;
306 if (pos.size() == 1) {
308 EVAL_STATUS = engine(par_begin, par_end, value, par_end, dictionary);
309 if (EVAL_STATUS == EVAL::WARNING_BLANK_STRING)
310 {
EVAL_EXIT( EVAL::ERROR_EMPTY_PARAMETER, --par_end ); }
311 if (EVAL_STATUS != EVAL::OK)
314 par_begin = pointer + 1;
318 if (pos.size() > 1) {
323 EVAL_STATUS = engine(par_begin, par_end, value, par_end, dictionary);
324 switch (EVAL_STATUS) {
328 case EVAL::WARNING_BLANK_STRING:
330 {
EVAL_EXIT( EVAL::ERROR_EMPTY_PARAMETER, --par_end ); }
335 EVAL_STATUS = execute_function(name, par, result, dictionary);
336 EVAL_EXIT( EVAL_STATUS, (EVAL_STATUS == EVAL::OK) ? pointer : begin);
356 static int maker(
int op, std::stack<double> & val)
358 if (val.size() < 2)
return EVAL::ERROR_SYNTAX_ERROR;
359 double val2 = val.top(); val.pop();
360 double val1 = val.top();
363 val.top() = (val1 || val2) ? 1. : 0.;
366 val.top() = (val1 && val2) ? 1. : 0.;
369 val.top() = (val1 == val2) ? 1. : 0.;
372 val.top() = (val1 != val2) ? 1. : 0.;
375 val.top() = (val1 >= val2) ? 1. : 0.;
378 val.top() = (val1 > val2) ? 1. : 0.;
381 val.top() = (val1 <= val2) ? 1. : 0.;
384 val.top() = (val1 < val2) ? 1. : 0.;
387 val.top() = val1 + val2;
390 val.top() = val1 - val2;
393 val.top() = val1 * val2;
396 if (val2 == 0.0)
return EVAL::ERROR_CALCULATION_ERROR;
397 val.top() = val1 / val2;
401 val.top() = pow(val1,val2);
402 if (errno == 0)
return EVAL::OK;
405 return EVAL::ERROR_CALCULATION_ERROR;
425 static int engine(
char const* begin,
char const* end,
double & result,
426 char const*& endp,
const dic_type & dictionary)
428 static constexpr
int SyntaxTable[17][17] = {
430 { 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 1 },
431 { 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 1 },
432 { 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
433 { 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
434 { 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
435 { 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
436 { 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
437 { 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
438 { 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
439 { 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
440 { 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
441 { 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
442 { 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
443 { 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
444 { 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
445 { 3, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0 },
446 { 3, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0 }
448 static constexpr
int ActionTable[15][16] = {
450 { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,-1 },
451 {-1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3 },
452 { 4, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4 },
453 { 4, 1, 4, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4 },
454 { 4, 1, 4, 4, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4 },
455 { 4, 1, 4, 4, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4 },
456 { 4, 1, 4, 4, 4, 4, 2, 2, 2, 2, 1, 1, 1, 1, 1, 4 },
457 { 4, 1, 4, 4, 4, 4, 2, 2, 2, 2, 1, 1, 1, 1, 1, 4 },
458 { 4, 1, 4, 4, 4, 4, 2, 2, 2, 2, 1, 1, 1, 1, 1, 4 },
459 { 4, 1, 4, 4, 4, 4, 2, 2, 2, 2, 1, 1, 1, 1, 1, 4 },
460 { 4, 1, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 1, 1, 1, 4 },
461 { 4, 1, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 1, 1, 1, 4 },
462 { 4, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 1, 4 },
463 { 4, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 1, 4 },
464 { 4, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 }
468 std::stack<char const*> pos;
469 std::stack<double> val;
471 char const* pointer = begin;
472 int iWhat, iCur, iPrev = 0, iTop, EVAL_STATUS;
475 op.push(0); pos.push(pointer);
477 if (c ==
'\0') {
EVAL_EXIT( EVAL::WARNING_BLANK_STRING, begin ); }
482 c = (pointer > end) ?
'\0' : *pointer;
483 if (isspace(c))
continue;
485 case '\0': iCur =
ENDL;
break;
486 case '(': iCur =
LBRA;
break;
488 if (*(pointer+1) ==
'|') {
489 pointer++; iCur =
OR;
break;
491 EVAL_EXIT( EVAL::ERROR_UNEXPECTED_SYMBOL, pointer );
494 if (*(pointer+1) ==
'&') {
495 pointer++; iCur =
AND;
break;
497 EVAL_EXIT( EVAL::ERROR_UNEXPECTED_SYMBOL, pointer );
500 if (*(pointer+1) ==
'=') {
501 pointer++; iCur =
EQ;
break;
503 EVAL_EXIT( EVAL::ERROR_UNEXPECTED_SYMBOL, pointer );
506 if (*(pointer+1) ==
'=') {
507 pointer++; iCur =
NE;
break;
509 EVAL_EXIT( EVAL::ERROR_UNEXPECTED_SYMBOL, pointer );
512 if (*(pointer+1) ==
'=') { pointer++; iCur =
GE; }
else { iCur =
GT; }
515 if (*(pointer+1) ==
'=') { pointer++; iCur =
LE; }
else { iCur =
LT; }
517 case '+': iCur =
PLUS;
break;
518 case '-': iCur =
MINUS;
break;
520 if (*(pointer+1) ==
'*') { pointer++; iCur =
POW; }
else{ iCur =
MULT; }
522 case '/': iCur =
DIV;
break;
523 case '^': iCur =
POW;
break;
524 case ')': iCur =
RBRA;
break;
526 if (c ==
'.' || isalnum(c)) {
529 EVAL_EXIT( EVAL::ERROR_UNEXPECTED_SYMBOL, pointer );
535 iWhat = SyntaxTable[iPrev][iCur];
539 EVAL_EXIT( EVAL::ERROR_SYNTAX_ERROR, pointer );
541 EVAL_STATUS = operand(pointer, end, value, pointer, dictionary);
542 if (EVAL_STATUS != EVAL::OK) {
EVAL_EXIT( EVAL_STATUS, pointer ); }
554 if (op.size() == 0) {
EVAL_EXIT( EVAL::ERROR_SYNTAX_ERROR, pointer ); }
556 switch (ActionTable[iTop][iCur]) {
558 if (op.size() > 1) pointer = pos.top();
559 EVAL_EXIT( EVAL::ERROR_UNPAIRED_PARENTHESIS, pointer );
561 if (val.size() == 1) {
565 EVAL_EXIT( EVAL::ERROR_SYNTAX_ERROR, pointer );
568 op.push(iCur); pos.push(pointer);
571 EVAL_STATUS = maker(iTop, val);
572 if (EVAL_STATUS != EVAL::OK) {
575 op.top() = iCur; pos.top() = pointer;
581 EVAL_STATUS = maker(iTop, val);
582 if (EVAL_STATUS != EVAL::OK) {
594 static int setItem(
const char * prefix,
const char * name,
597 if (name == 0 || *name ==
'\0') {
598 return EVAL::ERROR_NOT_A_NAME;
608 return EVAL::ERROR_NOT_A_NAME;
610 for(
int i=0; i<n; i++) {
611 char c = *(pointer+i);
612 if ( !(c ==
'_' || c==
':') && !isalnum(c)) {
613 return EVAL::ERROR_NOT_A_NAME;
619 std::string item_name = prefix + std::string(pointer,n);
621 dic_type::iterator iter = imp->
theDictionary.find(item_name);
624 if (item_name == name) {
625 return EVAL::WARNING_EXISTING_VARIABLE;
627 return EVAL::WARNING_EXISTING_FUNCTION;
635 static void print_error_status(std::ostream& os,
int status,
char const* extra) {
636 static char prefix[] =
"Evaluator::Object : ";
637 const char* opt = (extra ? extra :
"");
639 case EVAL::WARNING_EXISTING_VARIABLE:
640 os << prefix <<
"existing variable";
642 case EVAL::WARNING_EXISTING_FUNCTION:
643 os << prefix <<
"existing function";
645 case EVAL::WARNING_BLANK_STRING:
646 os << prefix <<
"blank string detected";
648 case EVAL::ERROR_NOT_A_NAME:
649 os << prefix <<
"invalid name : " << opt;
651 case EVAL::ERROR_SYNTAX_ERROR:
652 os << prefix <<
"systax error" ;
654 case EVAL::ERROR_UNPAIRED_PARENTHESIS:
655 os << prefix <<
"unpaired parenthesis";
657 case EVAL::ERROR_UNEXPECTED_SYMBOL:
658 os << prefix <<
"unexpected symbol : " << opt;
660 case EVAL::ERROR_UNKNOWN_VARIABLE:
661 os << prefix <<
"unknown variable : " << opt;
663 case EVAL::ERROR_UNKNOWN_FUNCTION:
664 os << prefix <<
"unknown function : " << opt;
666 case EVAL::ERROR_EMPTY_PARAMETER:
667 os << prefix <<
"empty parameter in function call: " << opt;
669 case EVAL::ERROR_CALCULATION_ERROR:
670 os << prefix <<
"calculation error";
681 Evaluator::Object::Object(
double meter,
double kilogram,
double second,
double ampere,
double kelvin
682 ,
double mole,
double candela,
double radians) : imp( new Struct()) {
684 setSystemOfUnits(meter, kilogram, second, ampere, kelvin
685 , mole, candela, radians );
689 Evaluator::Object::~Object() {
694 Evaluator::Object::EvalStatus Evaluator::Object::evaluate(
const char * expression)
const {
696 if (expression != 0) {
697 Struct::ReadLock guard(imp);
698 s.theStatus = engine(expression,
699 expression+strlen(expression)-1,
708 int Evaluator::Object::EvalStatus::status()
const {
713 double Evaluator::Object::EvalStatus::result()
const {
718 int Evaluator::Object::EvalStatus::error_position(
const char* expression)
const {
719 return thePosition - expression;
723 void Evaluator::Object::EvalStatus::print_error()
const {
724 std::stringstream str;
726 if ( str.str().empty() )
return;
727 std::cerr << str.str() << std::endl;
731 void Evaluator::Object::EvalStatus::print_error(std::ostream& os)
const {
732 print_error_status(os, theStatus, thePosition);
736 int Evaluator::Object::setEnviron(
const char* name,
const char* value) {
737 std::string prefix =
"${";
738 std::string item_name = prefix + std::string(name) + std::string(
"}");
742 Struct::WriteLock guard(imp);
744 item.what = Item::STRING;
745 item.expression = value;
748 dic_type::iterator iter = imp->
theDictionary.find(item_name);
750 iter->second = std::move(item);
751 if (item_name == name) {
752 return EVAL::WARNING_EXISTING_VARIABLE;
754 return EVAL::WARNING_EXISTING_FUNCTION;
764 Struct::ReadLock guard(imp);
765 Struct
const* cImp = imp;
766 dic_type::const_iterator iter = cImp->
theDictionary.find(name);
767 if (iter != cImp->theDictionary.end()) {
768 return std::make_pair(iter->second.expression.c_str(), EVAL::OK);
770 if ( ::strlen(name) > 3 ) {
772 std::string env_name(name+2,::strlen(name)-3);
773 const char* env_str = ::getenv(env_name.c_str());
774 if ( 0 != env_str ) {
775 return std::make_pair(env_str, EVAL::OK);
778 return std::make_pair(
nullptr,EVAL::ERROR_UNKNOWN_VARIABLE);
782 int Evaluator::Object::setVariable(
const char * name,
double value) {
783 return setItem(
"", name, Item(value), imp);
786 int Evaluator::Object::setVariable(
const char * name,
const char * expression) {
787 Item item(expression);
788 auto returnValue = setItem(
"", name, item, imp);
792 Struct::WriteLock guard(imp);
793 item.expression =
"";
798 void Evaluator::Object::setVariableNoLock(
const char * name,
double value) {
799 std::string item_name = name;
803 int Evaluator::Object::setFunction(
const char * name,
double (*fun)()) {
804 return setItem(
"0", name, Item(FCN(fun).ptr), imp);
807 int Evaluator::Object::setFunction(
const char * name,
double (*fun)(
double)) {
808 return setItem(
"1", name, Item(FCN(fun).ptr), imp);
811 int Evaluator::Object::setFunction(
const char * name,
double (*fun)(
double,
double)) {
812 return setItem(
"2", name, Item(FCN(fun).ptr), imp);
815 int Evaluator::Object::setFunction(
const char * name,
double (*fun)(
double,
double,
double)) {
816 return setItem(
"3", name, Item(FCN(fun).ptr), imp);
819 int Evaluator::Object::setFunction(
const char * name,
double (*fun)(
double,
double,
double,
double)) {
820 return setItem(
"4", name, Item(FCN(fun).ptr), imp);
823 int Evaluator::Object::setFunction(
const char * name,
double (*fun)(
double,
double,
double,
double,
double)) {
824 return setItem(
"5", name, Item(FCN(fun).ptr), imp);
827 void Evaluator::Object::setFunctionNoLock(
const char * name,
double (*fun)(
double)) {
828 std::string item_name =
"1"+std::string(name);
832 void Evaluator::Object::setFunctionNoLock(
const char * name,
double (*fun)(
double,
double)) {
833 std::string item_name =
"2"+std::string(name);
839 bool Evaluator::Object::findVariable(
const char * name)
const {
840 if (name == 0 || *name ==
'\0')
return false;
842 if (n == 0)
return false;
843 Struct::ReadLock guard(imp);
850 bool Evaluator::Object::findFunction(
const char * name,
int npar)
const {
851 if (name == 0 || *name ==
'\0')
return false;
852 if (npar < 0 || npar >
MAX_N_PAR)
return false;
854 if (n == 0)
return false;
855 Struct::ReadLock guard(imp);
856 return (imp->
theDictionary.find(sss[npar]+std::string(pointer,n)) ==
861 void Evaluator::Object::removeVariable(
const char * name) {
862 if (name == 0 || *name ==
'\0')
return;
865 Struct::WriteLock guard(imp);
870 void Evaluator::Object::removeFunction(
const char * name,
int npar) {
871 if (name == 0 || *name ==
'\0')
return;
872 if (npar < 0 || npar >
MAX_N_PAR)
return;
875 Struct::WriteLock guard(imp);
880 Evaluator::Evaluator(
double meter,
double kilogram,
double second,
double ampere,
double kelvin
881 ,
double mole,
double candela,
double radians) {
882 object =
new Object(meter, kilogram, second, ampere, kelvin, mole, candela, radians);
886 Evaluator::Evaluator(Evaluator&& other):object(other.object) {
887 other.object=
nullptr;
891 Evaluator::~Evaluator() {
896 std::pair<int,double> Evaluator::evaluate(
const std::string& expression)
const {
897 auto result =
object->evaluate(expression.c_str());
898 return std::make_pair(result.status(),result.result());
902 std::pair<int,double> Evaluator::evaluate(
const std::string& expression, std::ostream& os)
const {
903 auto result =
object->evaluate(expression.c_str());
904 int status = result.status();
905 if ( status != OK ) {
906 result.print_error(os);
908 return std::make_pair(result.status(),result.result());
912 int Evaluator::setEnviron(
const std::string& name,
const std::string& value)
const {
913 int result =
object->setEnviron(name.c_str(), value.c_str());
919 std::pair<int,std::string> result;
920 auto env_status =
object->getEnviron(name.c_str());
921 result.first = env_status.second;
922 if( env_status.first ) result.second = env_status.first;
928 std::pair<int,std::string> result;
929 auto env_status =
object->getEnviron(name.c_str());
930 result.first = env_status.second;
931 if ( env_status.first ) {
932 result.second = env_status.first;
934 if ( result.first != OK ) {
935 print_error_status(os, result.first, name.c_str());
941 int Evaluator::setVariable(
const std::string& name,
double value)
const {
942 int result =
object->setVariable(name.c_str(), value);
947 int Evaluator::setVariable(
const std::string& name,
double value, std::ostream& os)
const {
948 int result =
object->setVariable(name.c_str(), value);
949 if ( result != OK ) {
950 print_error_status(os, result, name.c_str());
956 int Evaluator::setVariable(
const std::string& name,
const std::string& value)
const {
957 int result =
object->setVariable(name.c_str(), value.c_str());
962 int Evaluator::setVariable(
const std::string& name,
const std::string& value, std::ostream& os)
const {
963 int result =
object->setVariable(name.c_str(), value.c_str());
964 if ( result != OK ) {
965 print_error_status(os, result, name.c_str());
971 bool Evaluator::findVariable(
const std::string& name)
const {
973 ret =
object->findVariable(name.c_str());
978 int Evaluator::setFunction(
const std::string& name,
double (*fun)())
const {
979 int result =
object->setFunction(name.c_str(), fun);
984 int Evaluator::setFunction(
const std::string& name,
double (*fun)(
double))
const {
985 int result =
object->setFunction(name.c_str(), fun);
990 int Evaluator::setFunction(
const std::string& name,
double (*fun)(
double,
double))
const {
991 int result =
object->setFunction(name.c_str(), fun);
996 int Evaluator::setFunction(
const std::string& name,
double (*fun)(
double,
double,
double))
const {
997 int result =
object->setFunction(name.c_str(), fun);
1002 int Evaluator::setFunction(
const std::string& name,
double (*fun)(
double,
double,
double,
double))
const {
1003 int result =
object->setFunction(name.c_str(), fun);
1008 int Evaluator::setFunction(
const std::string& name,
double (*fun)(
double,
double,
double,
double,
double))
const {
1009 int result =
object->setFunction(name.c_str(), fun);
1014 bool Evaluator::findFunction(
const std::string& name,
int npar)
const {
1016 ret =
object->findFunction(name.c_str(), npar);