diff options
Diffstat (limited to 'models/func_model.hpp')
-rw-r--r-- | models/func_model.hpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/models/func_model.hpp b/models/func_model.hpp new file mode 100644 index 0000000..4eda8d5 --- /dev/null +++ b/models/func_model.hpp @@ -0,0 +1,57 @@ +#ifndef FUNC_MODEL_H_ +#define FUNC_MODEL_H_ +#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 |