23 #ifndef O2SCL_MM_FUNCT_H
24 #define O2SCL_MM_FUNCT_H
32 #include <boost/numeric/ublas/vector.hpp>
34 #include <o2scl/fparser.h>
36 #ifndef DOXYGEN_NO_O2NS
41 typedef std::function<
47 template<
class vec_t=boost::numeric::ublas::vector<
double> >
54 int np=0, std::string parms=
"") {
59 fpw[i].Parse(formulas[i],vars);
64 std::string all=vars+
","+parms;
66 fpw[i].Parse(formulas[i],all);
88 for(
int i=0;i<
st_np;i++) {
98 virtual int operator()(
size_t nv,
const vec_t &x, vec_t &y) {
101 for(i=0;i<
st_nv;i++) {
106 for(i=0;i<
st_nv;i++) all[i]=x[i];
110 for(i=0;i<
st_nv;i++) {
111 y[i]=
fpw[i].Eval(all);
120 int np=0, std::string parms=
"") {
128 fpw[i].Parse(formulas[i],vars);
133 std::string all=vars+
","+parms;
135 fpw[i].Parse(formulas[i],all);
139 arr=
new double[np+nv];
147 #ifndef DOXYGEN_INTERNAL
183 #ifdef O2SCL_NEVER_DEFINED
187 template<
class vec_t>
188 class mm_funct_gsl :
public gsl_multiroot_function {
192 typedef std::function<int(size_t,const vec_t &, vec_t &)> func_t;
197 static int funct_wrap(
const gsl_vector *x,
void *params,
199 func_t *fp=(func_t *)params;
200 vec_t
x2(x->size), f2(x->size);
201 o2scl::vector_copy<double *,vec_t>(x->size,x.data,
x2);
202 int ret=(*fp)(x->size,
x2,f2);
203 o2scl::vector_copy<vec_t,double *>(x->size,f2,f.data);
210 funct_gsl(func_t &f) {
211 function=&funct_wrap;
218 #ifndef DOXYGEN_NO_O2NS
Parse a mathematical function specified in a string.
virtual int operator()(size_t nv, const vec_t &x, vec_t &y)
Compute nv functions, y, of nv variables stored in x with parameter pa.
FunctionParser * fpw
The function parser.
std::function< int(size_t, const boost::numeric::ublas::vector< double > &, boost::numeric::ublas::vector< double > &) > mm_funct11
Array of multi-dimensional functions typedef.
std::string st_parms
The parameters.
int set_parms(const vec_t &p)
Set the values of the auxilliary parameters that were specified in 'parms' in the constructor...
double * arr
The arguments to the function parser.
mm_funct11_strings(int nv, std::string *formulas, std::string vars, int np=0, std::string parms="")
Specify the strings.
int set_function(int nv, std::string *formulas, std::string vars, int np=0, std::string parms="")
Set the functions.
Array of multi-dimensional functions in an array of strings.
int st_np
The number of parameters.
std::string * st_forms
The formulas.
int st_nv
The number of variables.
static const double x2[5]
std::string st_vars
The variables.