22 m_calc.setSystemOfUnits(1.
e+3, 1./1.60217733
e-25, 1.
e+9, 1./1.60217733
e-10,1.0, 1.0, 1.0);
37 if(
m_calc.status() != HepTool::Evaluator::OK )
39 std::cerr <<
"Expression evaluator:: Error registering constant " <<
c << std::endl;
41 std::cout << std::endl;
50 for(
unsigned int i=0;
i<
v.size();
i++)
91 if(strchr(
" ()|&=!><+-%*/^",
c) ||
c==9 ||
c==0 ||
c==
'\r' ||
c==
'\n' ||
c==
'\t' ||
c==
'\0' || isspace(
c))
return true;
97 std::string str_mod =
str;
98 const char* c_str_mod =
str.c_str();
99 std::vector<int> variable_ends;
100 int cur_variable_end = 0;
108 else if(isalpha(*c_str_mod))
122 std::string variable_to_check =
variable;
125 variable_ends.push_back(cur_variable_end);
133 std::string::size_type shift = 0;
135 for(
unsigned int i=0;
i<variable_ends.size();
i++)
152 std::string expr =
value;
159 if(
m_calc.status() != HepTool::Evaluator::OK )
161 std::cerr <<
"Expression evaluator:: Error registering quantity "
164 std::cout << std::endl;
174 std::string expr =
"(";
179 if(
m_calc.status() != HepTool::Evaluator::OK )
181 std::cerr <<
"Expression evaluator:: Error registering expression " <<
name << std::endl;
183 std::cout << std::endl;
193 return Eval( expr.c_str() );
199 std::string expr = expr_mod;
200 std::string::size_type start_index = 0;
201 std::string::size_type end_index = 0;
204 start_index = expr.find(
'[', start_index);
205 if(start_index == std::string::npos)
break;
206 std::string::size_type boundary_index = expr.find(
']', start_index);
207 expr.replace(start_index,1,1,
'_');
208 end_index = expr.find(
',', start_index);
209 if(end_index != std::string::npos && end_index < boundary_index)
212 std::string var1 = expr.substr(start_index, end_index-start_index);
214 std::stringstream ss1;
218 expr.replace(start_index, end_index-start_index, str1, 0, str1.size());
222 end_index = boundary_index;
223 if(end_index != std::string::npos)
226 std::string var1 = expr.substr(start_index, end_index-start_index);
228 std::stringstream ss1;
232 expr.replace(start_index, end_index-start_index, str1, 0, str1.size());
240 start_index = expr.find(
',', start_index);
241 if(start_index == std::string::npos)
break;
242 expr.replace(start_index,1,1,
'_');
243 end_index = expr.find(
']', start_index);
245 std::string var2 = expr.substr(start_index, end_index-start_index);
247 std::stringstream ss2;
251 expr.replace(start_index, end_index-start_index, str2, 0, str2.size());
257 start_index = expr.find(
']', start_index);
258 if(start_index == std::string::npos)
break;
259 expr.replace(start_index,1,1,
'_');
262 if(
m_calc.status() != HepTool::Evaluator::OK )
264 std::cerr << expr << std::endl;
265 for (
int i=0;
i<
m_calc.error_position();
i++)
269 std::cerr <<
"^\a" << std::endl;
271 std::cerr << std::endl;
279 if (
s.size () == 0)
return (
s);
280 std::string
temp =
s;
281 std::string::size_type
i;
282 i =
temp.find_first_not_of (
' ');
283 if (
i == std::string::npos)
return std::string();
289 i =
temp.find_last_not_of (
' ');
290 if (
i <
temp.size ())
299 std::vector<std::string> tempvect;
301 for (
unsigned int i=0;
i<
aa.size();
i++) tempvect.push_back(
trim(
aa[
i]));