From 4170b13f464439ab97efadb210dab0d749fa4b42 Mon Sep 17 00:00:00 2001 From: astrojhgu Date: Thu, 17 Dec 2009 17:01:15 +0000 Subject: rename vmodel to vmodels git-svn-id: file:///home/svn/opt_utilities@103 ed2142bd-67ad-457f-ba7c-d818d4011675 --- vmodel/bl.hpp | 67 ---------------------------------------------------- vmodel/bpl.hpp | 67 ---------------------------------------------------- vmodel/bremss.hpp | 50 --------------------------------------- vmodel/gauss1d.hpp | 53 ----------------------------------------- vmodel/lin1d.hpp | 58 --------------------------------------------- vmodel/powerlaw.hpp | 50 --------------------------------------- vmodels/bl.hpp | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++ vmodels/bpl.hpp | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++ vmodels/bremss.hpp | 50 +++++++++++++++++++++++++++++++++++++++ vmodels/gauss1d.hpp | 53 +++++++++++++++++++++++++++++++++++++++++ vmodels/lin1d.hpp | 58 +++++++++++++++++++++++++++++++++++++++++++++ vmodels/powerlaw.hpp | 50 +++++++++++++++++++++++++++++++++++++++ 12 files changed, 345 insertions(+), 345 deletions(-) delete mode 100644 vmodel/bl.hpp delete mode 100644 vmodel/bpl.hpp delete mode 100644 vmodel/bremss.hpp delete mode 100644 vmodel/gauss1d.hpp delete mode 100644 vmodel/lin1d.hpp delete mode 100644 vmodel/powerlaw.hpp create mode 100644 vmodels/bl.hpp create mode 100644 vmodels/bpl.hpp create mode 100644 vmodels/bremss.hpp create mode 100644 vmodels/gauss1d.hpp create mode 100644 vmodels/lin1d.hpp create mode 100644 vmodels/powerlaw.hpp diff --git a/vmodel/bl.hpp b/vmodel/bl.hpp deleted file mode 100644 index 84d6ca5..0000000 --- a/vmodel/bl.hpp +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef BROKEN_LINE_MODEL_H_ -#define BROKEN_LINE_MODEL_H_ -#define OPT_HEADER -#include -#include -#include -namespace opt_utilities -{ - template - class bl - :public model,optvec,optvec,std::string> - { - private: - model,optvec,optvec,std::string >* do_clone()const - { - return new bl(*this); - } - - const char* do_get_type_name()const - { - return "broken linear model"; - } - public: - bl() - { - this->push_param_info(param_info >("break point y value",1)); - this->push_param_info(param_info >("break point x value",1)); - this->push_param_info(param_info >("slop 1",1)); - this->push_param_info(param_info >("slop 2",1)); - } - - public: - optvec do_eval(const optvec& x,const optvec& param) - { - T x_b=get_element(param,0); - T f_b=get_element(param,1); - T k1=get_element(param,2); - T k2=get_element(param,3); - optvec result(x.size()); - for(int i=0;i -#include -#include - -namespace opt_utilities -{ - template - class bpl1d - :public model,optvec,optvec,std::string> - { - private: - bpl1d* do_clone()const - { - return new bpl1d(*this); - } - - const char* do_get_type_name()const - { - return "broken power law"; - } - public: - bpl1d() - { - this->push_param_info(param_info >("bpx",1)); - this->push_param_info(param_info >("bpy",1)); - this->push_param_info(param_info >("gamma1",1)); - this->push_param_info(param_info >("gamma2",1)); - } - - optvec do_eval(const optvec& x,const optvec& param) - { - T x_b=get_element(param,0); - T f_b=get_element(param,1); - T gamma1=get_element(param,2); - T gamma2=get_element(param,3); - - optvec result(x.size()); - for(int i=0;i -#include -#include - -namespace opt_utilities -{ - template - class bremss - :public model,optvec,optvec,std::string> - { - private: - bremss* do_clone()const - { - return new bremss(*this); - } - - const char* do_get_type_name()const - { - return "Bremsstrahlung emission"; - } - public: - bremss() - { - this->push_param_info(param_info >("norm",1)); - this->push_param_info(param_info >("kT",1)); - } - - optvec do_eval(const optvec& x,const optvec& param) - { - T norm=get_element(param,0); - T kT=get_element(param,1); - - return norm*sqrt(kT)*exp(-x/kT); - } - - private: - std::string do_get_information()const - { - return ""; - } - }; -} - - - -#endif -//EOF diff --git a/vmodel/gauss1d.hpp b/vmodel/gauss1d.hpp deleted file mode 100644 index 5576c89..0000000 --- a/vmodel/gauss1d.hpp +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef GAUSS_MODEL_H_ -#define GAUSS_MODEL_H_ -#define OPT_HEADER -#include -#include -#include - -namespace opt_utilities -{ - template - class gauss1d - :public model,optvec,optvec,std::string> - { - private: - gauss1d* do_clone()const - { - return new gauss1d(*this); - } - - const char* do_get_type_name()const - { - return "1d gaussian"; - } - public: - gauss1d() - { - this->push_param_info(param_info >("N",1)); - this->push_param_info(param_info >("x0",0)); - this->push_param_info(param_info >("sigma",1)); - } - - public: - optvec do_eval(const optvec& x,const optvec& param) - { - T N=get_element(param,0); - T x0=get_element(param,1); - T sigma=get_element(param,2); - optvec y=(x-x0)/2./sigma; - return N*exp(-y*y); - } - - private: - std::string do_get_information()const - { - return ""; - } - }; -} - - - -#endif -//EOF diff --git a/vmodel/lin1d.hpp b/vmodel/lin1d.hpp deleted file mode 100644 index 8ca8074..0000000 --- a/vmodel/lin1d.hpp +++ /dev/null @@ -1,58 +0,0 @@ -#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 diff --git a/vmodel/powerlaw.hpp b/vmodel/powerlaw.hpp deleted file mode 100644 index 1f05301..0000000 --- a/vmodel/powerlaw.hpp +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef POWER_LAW_MODEL_H_ -#define POWER_LAW_MODEL_H_ -#define OPT_HEADER -#include -#include -#include - -namespace opt_utilities -{ - template - class powerlaw - :public model,optvec,optvec,std::string> - { - private: - powerlaw* do_clone()const - { - return new powerlaw(*this); - } - - const char* do_get_type_name()const - { - return "1d power law"; - } - public: - powerlaw() - { - this->push_param_info(param_info >("Ampl",1)); - this->push_param_info(param_info >("gamma",1)); - } - - optvec do_eval(const optvec& x,const optvec& 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 diff --git a/vmodels/bl.hpp b/vmodels/bl.hpp new file mode 100644 index 0000000..84d6ca5 --- /dev/null +++ b/vmodels/bl.hpp @@ -0,0 +1,67 @@ +#ifndef BROKEN_LINE_MODEL_H_ +#define BROKEN_LINE_MODEL_H_ +#define OPT_HEADER +#include +#include +#include +namespace opt_utilities +{ + template + class bl + :public model,optvec,optvec,std::string> + { + private: + model,optvec,optvec,std::string >* do_clone()const + { + return new bl(*this); + } + + const char* do_get_type_name()const + { + return "broken linear model"; + } + public: + bl() + { + this->push_param_info(param_info >("break point y value",1)); + this->push_param_info(param_info >("break point x value",1)); + this->push_param_info(param_info >("slop 1",1)); + this->push_param_info(param_info >("slop 2",1)); + } + + public: + optvec do_eval(const optvec& x,const optvec& param) + { + T x_b=get_element(param,0); + T f_b=get_element(param,1); + T k1=get_element(param,2); + T k2=get_element(param,3); + optvec result(x.size()); + for(int i=0;i +#include +#include + +namespace opt_utilities +{ + template + class bpl1d + :public model,optvec,optvec,std::string> + { + private: + bpl1d* do_clone()const + { + return new bpl1d(*this); + } + + const char* do_get_type_name()const + { + return "broken power law"; + } + public: + bpl1d() + { + this->push_param_info(param_info >("bpx",1)); + this->push_param_info(param_info >("bpy",1)); + this->push_param_info(param_info >("gamma1",1)); + this->push_param_info(param_info >("gamma2",1)); + } + + optvec do_eval(const optvec& x,const optvec& param) + { + T x_b=get_element(param,0); + T f_b=get_element(param,1); + T gamma1=get_element(param,2); + T gamma2=get_element(param,3); + + optvec result(x.size()); + for(int i=0;i +#include +#include + +namespace opt_utilities +{ + template + class bremss + :public model,optvec,optvec,std::string> + { + private: + bremss* do_clone()const + { + return new bremss(*this); + } + + const char* do_get_type_name()const + { + return "Bremsstrahlung emission"; + } + public: + bremss() + { + this->push_param_info(param_info >("norm",1)); + this->push_param_info(param_info >("kT",1)); + } + + optvec do_eval(const optvec& x,const optvec& param) + { + T norm=get_element(param,0); + T kT=get_element(param,1); + + return norm*sqrt(kT)*exp(-x/kT); + } + + private: + std::string do_get_information()const + { + return ""; + } + }; +} + + + +#endif +//EOF diff --git a/vmodels/gauss1d.hpp b/vmodels/gauss1d.hpp new file mode 100644 index 0000000..5576c89 --- /dev/null +++ b/vmodels/gauss1d.hpp @@ -0,0 +1,53 @@ +#ifndef GAUSS_MODEL_H_ +#define GAUSS_MODEL_H_ +#define OPT_HEADER +#include +#include +#include + +namespace opt_utilities +{ + template + class gauss1d + :public model,optvec,optvec,std::string> + { + private: + gauss1d* do_clone()const + { + return new gauss1d(*this); + } + + const char* do_get_type_name()const + { + return "1d gaussian"; + } + public: + gauss1d() + { + this->push_param_info(param_info >("N",1)); + this->push_param_info(param_info >("x0",0)); + this->push_param_info(param_info >("sigma",1)); + } + + public: + optvec do_eval(const optvec& x,const optvec& param) + { + T N=get_element(param,0); + T x0=get_element(param,1); + T sigma=get_element(param,2); + optvec y=(x-x0)/2./sigma; + return N*exp(-y*y); + } + + private: + std::string do_get_information()const + { + return ""; + } + }; +} + + + +#endif +//EOF diff --git a/vmodels/lin1d.hpp b/vmodels/lin1d.hpp new file mode 100644 index 0000000..8ca8074 --- /dev/null +++ b/vmodels/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 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 +#include +#include + +namespace opt_utilities +{ + template + class powerlaw + :public model,optvec,optvec,std::string> + { + private: + powerlaw* do_clone()const + { + return new powerlaw(*this); + } + + const char* do_get_type_name()const + { + return "1d power law"; + } + public: + powerlaw() + { + this->push_param_info(param_info >("Ampl",1)); + this->push_param_info(param_info >("gamma",1)); + } + + optvec do_eval(const optvec& x,const optvec& 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 -- cgit v1.2.2