diff options
author | astrojhgu <astrojhgu@ed2142bd-67ad-457f-ba7c-d818d4011675> | 2010-11-14 17:15:48 +0000 |
---|---|---|
committer | astrojhgu <astrojhgu@ed2142bd-67ad-457f-ba7c-d818d4011675> | 2010-11-14 17:15:48 +0000 |
commit | d9f662d8857c1ae15d72d6212b616a10a5181f67 (patch) | |
tree | 5a5e64e12c553d85a251c992ea1cdcbd89503f4c /distributions | |
parent | cfcf2b9fc6b091c6db0997c2dea45b701955a696 (diff) | |
download | opt-utilities-d9f662d8857c1ae15d72d6212b616a10a5181f67.tar.bz2 |
git-svn-id: file:///home/svn/opt_utilities@143 ed2142bd-67ad-457f-ba7c-d818d4011675
Diffstat (limited to 'distributions')
-rw-r--r-- | distributions/uniformed.hpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/distributions/uniformed.hpp b/distributions/uniformed.hpp new file mode 100644 index 0000000..ccafd01 --- /dev/null +++ b/distributions/uniformed.hpp @@ -0,0 +1,58 @@ +#ifndef UNIFORMED_MODEL_H_ +#define UNIFORMED_MODEL_H_ +#define OPT_HEADER +#include <core/fitter.hpp> +#include <cmath> +#include <misc/optvec.hpp> + +namespace opt_utilities +{ + template <typename T> + class uniformed + :public model<optvec<T>,optvec<T>,optvec<T>,std::string> + { + private: + uniformed* do_clone()const + { + return new uniformed<T>(*this); + } + + const char* do_get_type_name()const + { + return "1d normed gaussian"; + } + public: + uniformed() + { + this->push_param_info(param_info<optvec<T> >("a",0.)); + this->push_param_info(param_info<optvec<T> >("b",1.)); + } + + + public: + optvec<T> do_eval(const optvec<T>& x,const optvec<T>& param) + { + T a=get_element(param,0); + T b=get_element(param,1); + optvec<T> y; + resize(y,get_size(x)); + for(int i=0;i<get_size(x);++i) + { + T v=get_element(x,i); + set_element(y,i,(v-a)*(v-b)<0?1/abs(b-a):0); + } + return y; + } + + private: + std::string do_get_information()const + { + return ""; + } + }; +} + + + +#endif +//EOF |