diff options
author | astrojhgu <astrojhgu@ed2142bd-67ad-457f-ba7c-d818d4011675> | 2011-03-28 17:52:27 +0000 |
---|---|---|
committer | astrojhgu <astrojhgu@ed2142bd-67ad-457f-ba7c-d818d4011675> | 2011-03-28 17:52:27 +0000 |
commit | 83f8b6ea00b90959dacc2b61f263a54475a014bd (patch) | |
tree | 847d280fbce6b604d41d1bd878464bdc8a56c6a9 /vmodels | |
parent | 79e3d7e49be0a4c9f00d63cfa0e2cdd168410fef (diff) | |
download | opt-utilities-83f8b6ea00b90959dacc2b61f263a54475a014bd.tar.bz2 |
git-svn-id: file:///home/svn/opt_utilities@185 ed2142bd-67ad-457f-ba7c-d818d4011675
Diffstat (limited to 'vmodels')
-rw-r--r-- | vmodels/quad_pl.hpp | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/vmodels/quad_pl.hpp b/vmodels/quad_pl.hpp new file mode 100644 index 0000000..a6a1e57 --- /dev/null +++ b/vmodels/quad_pl.hpp @@ -0,0 +1,59 @@ +/** + \file quad_pl.hpp + \brief power law model + \author Junhua Gu + */ + + +#ifndef QUAD_PL_MODEL_H_ +#define QUAD_PL_MODEL_H_ +#define OPT_HEADER +#include <core/fitter.hpp> +#include <cmath> +#include <misc/optvec.hpp> + +namespace opt_utilities +{ + template <typename T> + class quad_pl + :public model<optvec<T>,optvec<T>,optvec<T>,std::string> + { + private: + quad_pl* do_clone()const + { + return new quad_pl<T>(*this); + } + + const char* do_get_type_name()const + { + return "quad power law"; + } + public: + quad_pl() + { + this->push_param_info(param_info<optvec<T> >("a",1)); + this->push_param_info(param_info<optvec<T> >("b",1)); + this->push_param_info(param_info<optvec<T> >("c",1)); + } + + optvec<T> do_eval(const optvec<T>& x,const optvec<T>& param) + { + T a=get_element(param,0); + T b=get_element(param,1); + T c=get_element(param,1); + return c*exp(a*log(x)*log(x)+b*log(x)); + } + + private: + std::string do_get_information()const + { + return "Simple power law model\n" + "y=A*x^gamma\n"; + } + }; +} + + + +#endif +//EOF |