diff options
Diffstat (limited to 'vmodel/gauss1d.hpp')
-rw-r--r-- | vmodel/gauss1d.hpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/vmodel/gauss1d.hpp b/vmodel/gauss1d.hpp new file mode 100644 index 0000000..5576c89 --- /dev/null +++ b/vmodel/gauss1d.hpp @@ -0,0 +1,53 @@ +#ifndef GAUSS_MODEL_H_ +#define GAUSS_MODEL_H_ +#define OPT_HEADER +#include <core/fitter.hpp> +#include <cmath> +#include <misc/optvec.hpp> + +namespace opt_utilities +{ + template <typename T> + class gauss1d + :public model<optvec<T>,optvec<T>,optvec<T>,std::string> + { + private: + gauss1d* do_clone()const + { + return new gauss1d<T>(*this); + } + + const char* do_get_type_name()const + { + return "1d gaussian"; + } + public: + gauss1d() + { + this->push_param_info(param_info<optvec<T> >("N",1)); + this->push_param_info(param_info<optvec<T> >("x0",0)); + this->push_param_info(param_info<optvec<T> >("sigma",1)); + } + + public: + optvec<T> do_eval(const optvec<T>& x,const optvec<T>& param) + { + T N=get_element(param,0); + T x0=get_element(param,1); + T sigma=get_element(param,2); + optvec<T> y=(x-x0)/2./sigma; + return N*exp(-y*y); + } + + private: + std::string do_get_information()const + { + return ""; + } + }; +} + + + +#endif +//EOF |