aboutsummaryrefslogtreecommitdiffstats
path: root/vmodels
diff options
context:
space:
mode:
authorastrojhgu <astrojhgu@ed2142bd-67ad-457f-ba7c-d818d4011675>2010-02-08 09:23:14 +0000
committerastrojhgu <astrojhgu@ed2142bd-67ad-457f-ba7c-d818d4011675>2010-02-08 09:23:14 +0000
commitdb1d374b7a24b8f3f74e17d706704d93f1e66d90 (patch)
treef6043b9df2ebfca0b4fea721e14d861785e985a5 /vmodels
parent435b4484e00b1ac3b6ee5e87b81f5b8af4f1e653 (diff)
downloadopt-utilities-db1d374b7a24b8f3f74e17d706704d93f1e66d90.tar.bz2
git-svn-id: file:///home/svn/opt_utilities@110 ed2142bd-67ad-457f-ba7c-d818d4011675
Diffstat (limited to 'vmodels')
-rw-r--r--vmodels/beta1d.hpp64
-rw-r--r--vmodels/constant.hpp54
-rw-r--r--vmodels/poly1d.hpp78
3 files changed, 196 insertions, 0 deletions
diff --git a/vmodels/beta1d.hpp b/vmodels/beta1d.hpp
new file mode 100644
index 0000000..42be3fd
--- /dev/null
+++ b/vmodels/beta1d.hpp
@@ -0,0 +1,64 @@
+#ifndef VBETA_MODEL_H_
+#define VBETA_MODEL_H_
+#define OPT_HEADER
+#include <core/fitter.hpp>
+#include <misc/optvec.hpp>
+#include <cmath>
+
+namespace opt_utilities
+{
+ template <typename T>
+ class beta1d
+ :public model<optvec<T>,optvec<T>,optvec<T>,std::string>
+ {
+ typedef optvec<T> Tv;
+ private:
+ beta1d<T>* do_clone()const
+ {
+ return new beta1d<T>(*this);
+ }
+
+ const char* do_get_type_name()const
+ {
+ return "1d surface brightness beta model";
+ }
+ public:
+ beta1d()
+ {
+ this->push_param_info(param_info<Tv>("S0",1));
+ this->push_param_info(param_info<Tv>("rc",10));
+ this->push_param_info(param_info<Tv>("beta",2./3.));
+ this->push_param_info(param_info<Tv>("bkg",0));
+ }
+
+ public:
+ Tv do_eval(const Tv& x,const Tv& param)
+ {
+ Tv result(x.size());
+ T S0=get_element(param,0);
+ T r_c=get_element(param,1);
+ T beta=get_element(param,2);
+ T bkg=get_element(param,3);
+
+ //return x*get_element(param,0)+get_element(param,1);
+ for(size_t i=0;i!=x.size();++i)
+ {
+
+ result[i]=bkg+S0*pow(1+(x[i]*x[i])/(r_c*r_c),-3*beta+static_cast<T>(.5));
+
+ }
+ return result;
+ }
+
+ private:
+ std::string do_get_information()const
+ {
+ return "";
+ }
+ };
+}
+
+
+
+#endif
+//EOF
diff --git a/vmodels/constant.hpp b/vmodels/constant.hpp
new file mode 100644
index 0000000..c4044b0
--- /dev/null
+++ b/vmodels/constant.hpp
@@ -0,0 +1,54 @@
+#ifndef VCONSTANT_MODEL_H_
+#define VCONSTANT_MODEL_H_
+#define OPT_HEADER
+#include <core/fitter.hpp>
+#include <misc/optvec.hpp>
+#include <cmath>
+
+namespace opt_utilities
+{
+ template <typename T>
+ class constant
+ :public model<optvec<T>,optvec<T>,optvec<T>,std::string>
+ {
+ typedef optvec<T> Tv;
+ private:
+ constant<T>* do_clone()const
+ {
+ return new constant<T>(*this);
+ }
+ const char* do_get_type_name()const
+ {
+ return "constant";
+ }
+ public:
+ constant()
+ {
+ this->push_param_info(param_info<Tv>("c",1));
+ }
+
+ public:
+ Tv do_eval(const Tv& x,const Tv& param)
+ {
+ //return x*param[0]+param[1];
+ Tv result(x.size());
+ for(int i=0;i<result.size();++i)
+ {
+ result[i]=param[0];
+ }
+ return result;
+ }
+
+ private:
+ std::string do_get_information()const
+ {
+ return "Constant\n"
+ "y=C\n";
+ }
+ };
+}
+
+
+
+#endif
+//EOF
diff --git a/vmodels/poly1d.hpp b/vmodels/poly1d.hpp
new file mode 100644
index 0000000..adaf03b
--- /dev/null
+++ b/vmodels/poly1d.hpp
@@ -0,0 +1,78 @@
+#ifndef POLY_MODEL_H_
+#define POLY_MODEL_H_
+#define OPT_HEADER
+#include <core/fitter.hpp>
+#include <cmath>
+#include <sstream>
+#include <cassert>
+
+namespace opt_utilities
+{
+ template <typename T,int n>
+ class poly1d
+ :public model<optvec<T>,optvec<T>,optvec<T>,std::string>
+ {
+ typedef optvec<T> Tv;
+ private:
+ poly1d<T,n>* do_clone()const
+ {
+ return new poly1d<T,n>(*this);
+ }
+
+ const char* do_get_type_name()const
+ {
+ return "polynomial";
+ }
+ public:
+ poly1d()
+ {
+ assert(n>=0);
+ for(int i=0;i<=n;++i)
+ {
+ std::ostringstream ostr;
+ ostr<<"a"<<i;
+ this->push_param_info(param_info<Tv>(ostr.str().c_str(),1));
+ }
+
+ }
+
+ public:
+ Tv do_eval(const Tv& x,const Tv& param)
+ {
+ // return x*get_element(param,0)+get_element(param,1);
+ Tv result(x.size());
+ for(int m=0;m<result.size();++m)
+ {
+ result[m]=0;
+ for(int i=0;i<=n;++i)
+ {
+ typename Tv::value_type xn(1);
+ for(int j=0;j<i;++j)
+ {
+ xn*=x[m];
+ }
+ result[m]+=get_element(param,i)*xn;
+ }
+ }
+ return result;
+ }
+
+ private:
+ std::string do_get_information()const
+ {
+ std::ostringstream ostr;
+ ostr<<n<<"-order polynorminal model\n";
+ for(int i=0;i<n;++i)
+ {
+ ostr<<"a"<<i<<"*x^"<<i<<"+";
+ }
+ ostr<<"a"<<n<<"*x^"<<n;
+ return ostr.str();
+ }
+ };
+}
+
+
+
+#endif
+//EOF