aboutsummaryrefslogtreecommitdiffstats
path: root/models/strmodel1d.hpp
blob: 831e1c420d4e1fb552707ebb9f2ec9a0d11d70a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
   \file strmodel1d.hpp
   \brief evaluating model from string, by usig muparser
   \author Junhua Gu
 */


#ifndef STRMODEL1D_HPP
#define STRMODEL1D_HPP
#define OPT_HEADER
#include <core/fitter.hpp>
#include <cmath>
#include <sstream>
#include <cassert>
#include <muParser.h>
#include <vector>
#include <string>

class strmodel1d
  :public opt_utilities::model<double,double,std::vector<double>,std::string>
{
private:
  mu::Parser mp;
  strmodel1d* do_clone()const;
  std::vector<double> par_vec;
  std::vector<std::string> par_names;
  std::string expr;
  std::string var_name;
  double x;
  void set_buildin_fun();

  const char* do_get_type_name()const
  {
    return "parse a string as a model";
  }
public:
  double do_eval(const double& x,const std::vector<double>& p);
  strmodel1d();
  strmodel1d(const strmodel1d& rhs);
  strmodel1d& operator=(const strmodel1d& rhs);
  

  void set_expr(const std::string& _expr,
		const std::vector<std::string>& _par_names,
		const std::string& _var_name);

};



#endif
//EOF