9#include "CLHEP/Evaluator/Evaluator.h"
16 if(
status() !=
OK) v = std::numeric_limits<double>::quiet_NaN();
34 {
"0 - -z", 3.0, -30.0},
35 {
"10/-x", -10.0, -1.0},
36 {
"exp(-y)*exp(y)", 1.0, 1.0},
37 {
"exp(-y^2)*exp(y^2)", 1.0, 1.0},
38 {
"-5*x", -5.0, -50.0},
40 {
"5+(-x)", 4.0, -5.0},
41 {
"5*-x", -5.0, -50.0},
42 {
"5*(-x)", -5.0, -50.0},
43 {
"-z^2", -9.0, -900.0},
44 {
"0-z^2", -9.0, -900.0},
45 {
"exp(-0.2*z^2)*exp(0.2*z^2)", 1.0, 1.0},
46 {
"exp(0.2*-z^2)*exp(0.2*z^2)", 1.0, 1.0},
47 {
"exp(-z^2*0.2)*exp(0.2*z^2)", 1.0, 1.0},
48 {
"exp(0.2*-(z^2))*exp(0.2*z^2)", 1.0, 1.0},
49 {
"exp(-(z^2)*0.2)*exp(0.2*z^2)", 1.0, 1.0},
50 {
"exp(-0.2*z)*exp(0.2*z)", 1.0, 1.0},
51 {
"exp(0.2*-z)*exp(0.2*z)", 1.0, 1.0},
52 {
"exp(-z*0.2)*exp(0.2*z)", 1.0, 1.0},
63 for(
unsigned i=0; i<
sizeof(
tests)/
sizeof(
Test); ++i) {
65 if(std::isnan(v) || std::fabs(v-
tests[i].value1) > 1E-12 || !e.
isOK()) {
66 printf(
"%s = %.6f should be %.6f\n",
tests[i].expr,
76 for(
unsigned i=0; i<
sizeof(
tests)/
sizeof(
Test); ++i) {
78 if(std::isnan(v) || std::fabs(v-
tests[i].value2) > 1E-12 || !e.
isOK()) {
79 printf(
"%s = %.6f should be %.6f\n",
tests[i].expr,
86 if(!std::isnan(v) || e.
isOK()) {
87 printf(
"%s succeeded\n",
"unknown(0.0)");
92 if(!std::isnan(v) || e.
isOK()) {
93 printf(
"%s succeeded\n",
"unknown+0.0");
double evaluate(const char *e)