From 36076e63361d7c3d010f673d267793797de122b8 Mon Sep 17 00:00:00 2001 From: astrojhgu Date: Tue, 17 Nov 2009 17:08:23 +0000 Subject: git-svn-id: file:///home/svn/opt_utilities@96 ed2142bd-67ad-457f-ba7c-d818d4011675 --- vmodel/lin1d.hpp | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 vmodel/lin1d.hpp (limited to 'vmodel') diff --git a/vmodel/lin1d.hpp b/vmodel/lin1d.hpp new file mode 100644 index 0000000..8ca8074 --- /dev/null +++ b/vmodel/lin1d.hpp @@ -0,0 +1,58 @@ +#ifndef VLINEAR_MODEL_H_ +#define VLINEAR_MODEL_H_ +#define OPT_HEADER +#include +#include +#include + +namespace opt_utilities +{ + template + class lin1d + :public model,optvec,optvec,std::string> + { + typedef optvec Tv; + private: + lin1d* do_clone()const + { + return new lin1d(*this); + } + + const char* do_get_type_name()const + { + return "1d linear model"; + } + public: + lin1d() + { + this->push_param_info(param_info("k",1)); + this->push_param_info(param_info("b",0)); + } + + public: + Tv do_eval(const Tv& x,const Tv& param) + { + Tv result(x.size()); + + //return x*get_element(param,0)+get_element(param,1); + for(size_t i=0;i!=x.size();++i) + { + result[i]=param[0]*x[i]+param[1]; + } + return result; + } + + private: + std::string do_get_information()const + { + return " f(x;k,b)=k x+b \ + \ +"; + } + }; +} + + + +#endif +//EOF -- cgit v1.2.2