aboutsummaryrefslogtreecommitdiffstats
path: root/vmodels
diff options
context:
space:
mode:
authorastrojhgu <astrojhgu@ed2142bd-67ad-457f-ba7c-d818d4011675>2012-03-02 10:05:27 +0000
committerastrojhgu <astrojhgu@ed2142bd-67ad-457f-ba7c-d818d4011675>2012-03-02 10:05:27 +0000
commit61ccc92efe31b5cb72d8face87f9ce4eab120e62 (patch)
treec8eaa305f761408ad9e64429402c9bca56c12db9 /vmodels
parentb94e4583034625b6c4477a537d314283f04c8c80 (diff)
downloadopt-utilities-61ccc92efe31b5cb72d8face87f9ce4eab120e62.tar.bz2
git-svn-id: file:///home/svn/opt_utilities@227 ed2142bd-67ad-457f-ba7c-d818d4011675
Diffstat (limited to 'vmodels')
-rw-r--r--vmodels/gauss1d_bkg.hpp64
1 files changed, 64 insertions, 0 deletions
diff --git a/vmodels/gauss1d_bkg.hpp b/vmodels/gauss1d_bkg.hpp
new file mode 100644
index 0000000..71175b5
--- /dev/null
+++ b/vmodels/gauss1d_bkg.hpp
@@ -0,0 +1,64 @@
+/**
+ \file gauss1d.hpp
+ \brief Gauss model
+ \author Junhua Gu
+ */
+
+#ifndef GAUSS_MODEL_BKG_H_
+#define GAUSS_MODEL_BKG_H_
+#define OPT_HEADER
+#include <core/fitter.hpp>
+#include <cmath>
+#include <misc/optvec.hpp>
+
+namespace opt_utilities
+{
+ template <typename T>
+ class gauss1d_bkg
+ :public model<optvec<T>,optvec<T>,optvec<T>,std::string>
+ {
+ private:
+ gauss1d_bkg* do_clone()const
+ {
+ return new gauss1d_bkg<T>(*this);
+ }
+
+ const char* do_get_type_name()const
+ {
+ return "1d gaussian with bkg";
+ }
+ public:
+ gauss1d_bkg()
+ {
+ 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));
+ this->push_param_info(param_info<optvec<T> >("bkg",0));
+ }
+
+ 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);
+ T bkg=get_element(param,3);
+ optvec<T> y=(x-x0)/sigma;
+ return N*exp(-y*y/2.)+bkg;
+ }
+
+ private:
+ std::string do_get_information()const
+ {
+#ifdef WITH_OPT_DOC
+#include <model_doc/gauss1d_bkg.info>
+#endif
+ return "";
+ }
+ };
+}
+
+
+
+#endif
+//EOF