blob: 2234cc1b118c9fae841f72bc4a73c5fd7ba957c6 (
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
53
54
55
56
57
58
|
#ifndef FUNC_MODEL_H_
#define FUNC_MODEL_H_
#define OPT_HEADER
#include <core/fitter.hpp>
#include <cmath>
#include <iostream>
#include <string>
#include <sstream>
namespace opt_utilities
{
template <typename T>
class func_model
:public model<T,T,std::vector<T>,std::string>
{
private:
T (*func)(T x,const T* const& p);
int nparams;
private:
model<T,T,std::vector<T> >* do_clone()const
{
return new func_model<T>(*this);
}
// public:
private:
func_model()
{}
public:
func_model(T (*_func)(T x,const T* const& p),int n)
:func(_func),nparams(n)
{
for(int i=0;i!=n;++i)
{
std::ostringstream oss;
oss<<i;
this->push_param_info(param_info<std::vector<T> >(oss.str(),0));
}
}
T do_eval(const T& x,const std::vector<T>& param)
{
return func(x,&get_element(param,0));
}
private:
std::string do_to_string()const
{
return "Wrapper for necked C function\n";
}
};
}
#endif
//EOF
|