diff options
author | astrojhgu <astrojhgu@ed2142bd-67ad-457f-ba7c-d818d4011675> | 2009-12-17 17:01:15 +0000 |
---|---|---|
committer | astrojhgu <astrojhgu@ed2142bd-67ad-457f-ba7c-d818d4011675> | 2009-12-17 17:01:15 +0000 |
commit | 4170b13f464439ab97efadb210dab0d749fa4b42 (patch) | |
tree | f6d31514c19a9a015c4d22477f5a3fb8bccd250b /vmodels/powerlaw.hpp | |
parent | eeafd6e502bc60da664de3cf0eb9251f349df228 (diff) | |
download | opt-utilities-4170b13f464439ab97efadb210dab0d749fa4b42.tar.bz2 |
rename vmodel to vmodels
git-svn-id: file:///home/svn/opt_utilities@103 ed2142bd-67ad-457f-ba7c-d818d4011675
Diffstat (limited to 'vmodels/powerlaw.hpp')
-rw-r--r-- | vmodels/powerlaw.hpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/vmodels/powerlaw.hpp b/vmodels/powerlaw.hpp new file mode 100644 index 0000000..1f05301 --- /dev/null +++ b/vmodels/powerlaw.hpp @@ -0,0 +1,50 @@ +#ifndef POWER_LAW_MODEL_H_ +#define POWER_LAW_MODEL_H_ +#define OPT_HEADER +#include <core/fitter.hpp> +#include <cmath> +#include <misc/optvec.hpp> + +namespace opt_utilities +{ + template <typename T> + class powerlaw + :public model<optvec<T>,optvec<T>,optvec<T>,std::string> + { + private: + powerlaw* do_clone()const + { + return new powerlaw<T>(*this); + } + + const char* do_get_type_name()const + { + return "1d power law"; + } + public: + powerlaw() + { + this->push_param_info(param_info<optvec<T> >("Ampl",1)); + this->push_param_info(param_info<optvec<T> >("gamma",1)); + } + + optvec<T> do_eval(const optvec<T>& x,const optvec<T>& param) + { + T A=get_element(param,0); + T gamma=get_element(param,1); + return A*pow(x,gamma); + } + + private: + std::string do_get_information()const + { + return "Simple power law model\n" + "y=A*x^gamma\n"; + } + }; +} + + + +#endif +//EOF |