33 #include <gsl/gsl_math.h> 35 #include <boost/numeric/ublas/vector.hpp> 37 #include <o2scl/shunting_yard.h> 38 #include <o2scl/err_hnd.h> 40 #ifndef DOXYGEN_NO_O2NS 45 typedef std::function<double(double)>
funct;
48 typedef std::function<long double(long double)>
funct_ld;
92 O2SCL_ERR2(
"A parameter cannot have the same name as ",
93 "the variable in funct_string::set_parm().",
107 #ifndef DOXYGEN_INTERNAL 115 mutable std::map<std::string,double>
vars;
125 #ifndef DOXYGEN_NO_O2NS 145 funct *fp=(funct *)params;
153 function=&funct_wrap;
193 if (name==st_var1 || name==st_var2) {
194 O2SCL_ERR2(
"A parameter cannot have the same name as ",
195 "a variable in funct_string::set_parm().",
210 #ifndef DOXYGEN_INTERNAL 218 mutable std::map<std::string,double>
vars;
230 #ifndef DOXYGEN_NO_O2NS 243 #ifndef DOXYGEN_NO_O2NS virtual double operator()(double x) const
Compute the function at point x and return the result.
calculator calc
The object for evaluating strings.
The main O<span style='position: relative; top: 0.3em; font-size: 0.8em'>2</span>scl O$_2$scl names...
funct_gsl(funct &f)
Create an object based on the specified function, f.
std::map< std::string, double > vars
Parameter map.
void compile(const char *expr, std::map< std::string, double > *vars=0, bool debug=false, std::map< std::string, int > opPrec=opPrecedence)
Compile expression expr using variables specified in vars.
static double funct_wrap(double x, void *params)
The function wrapper.
invalid argument supplied by user
std::function< long double(long double)> funct_ld
One-dimensional function typedef.
One-dimensional function from a string.
std::string st_var2
The variable.
funct_string(std::string expr, std::string var)
Specify the string and the parameters.
virtual double operator()(double x, double y) const
Compute the function at point x and return the result.
int set_function(std::string expr, std::string var)
Specify the string and the parameters.
A wrapper to specify o2scl::funct objects to GSL.
int set_parm(std::string name, double val)
Set the values of the auxilliary parameters that were specified in parms in the constructor.
int set_parm(std::string name, double val)
Set the values of the auxilliary parameters that were specified in parms in the constructor.
std::string st_var
The variable.
#define O2SCL_ERR2(d, d2, n)
Set an error, two-string version.
double eval(std::map< std::string, double > *vars=0)
Evalate the previously compiled expression using variables specified in vars.
std::string st_form
The expr.
funct2_string(std::string expr, std::string var1, std::string var2)
Specify the string and the parameters.
Evaluate a mathematical expression in a string.
std::function< double(double)> funct
One-dimensional function typedef.
int set_function(std::string expr, std::string var1, std::string var2)
Specify the string and the parameters.
std::string st_var1
The variable.
Two-dimensional function from a string.
calculator calc
The object for evaluating strings.
std::map< std::string, double > vars
Parameter map.
std::string st_form
The expr.