aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorastrojhgu <astrojhgu@ed2142bd-67ad-457f-ba7c-d818d4011675>2009-10-13 03:08:47 +0000
committerastrojhgu <astrojhgu@ed2142bd-67ad-457f-ba7c-d818d4011675>2009-10-13 03:08:47 +0000
commit0c1f50351a0287252c4b0f7e9edbfb945481e6f7 (patch)
treee8e58b799cf192dd74569300c20e223c9923a916
parent896a67e280d41df613092279f76913f8372faba1 (diff)
downloadopt-utilities-0c1f50351a0287252c4b0f7e9edbfb945481e6f7.tar.bz2
git-svn-id: file:///home/svn/opt_utilities@80 ed2142bd-67ad-457f-ba7c-d818d4011675
-rw-r--r--misc/bootstrap.hpp13
-rw-r--r--misc/data_loaders.hpp6
-rw-r--r--models/polar_ellipse.hpp49
3 files changed, 61 insertions, 7 deletions
diff --git a/misc/bootstrap.hpp b/misc/bootstrap.hpp
index bd1f4a3..f2ba525 100644
--- a/misc/bootstrap.hpp
+++ b/misc/bootstrap.hpp
@@ -13,7 +13,7 @@
#include <utility>
#include <algorithm>
#include <data_sets/default_data_set.hpp>
-using std::cout;
+using std::cerr;
namespace opt_utilities
{
@@ -122,6 +122,11 @@ namespace opt_utilities
{
return param_pool.at(i);
}
+
+ int get_param_pool_size()const
+ {
+ return param_pool.size();
+ }
private:
Tp sample()
@@ -143,9 +148,9 @@ namespace opt_utilities
param_pool.push_back(p_fitter->fit());
for(size_t i=0;i<(param_pool.back()).size();++i)
{
- cout<<param_pool.back()[i]<<",";
+ cerr<<param_pool.back()[i]<<",";
}
- std::cout<<std::endl;
+ std::cerr<<std::endl;
return param_pool.back();
}
@@ -181,7 +186,7 @@ namespace opt_utilities
typename std::vector<typename element_type_trait<Tp>::element_type>::iterator>
itv=equal_range(_tmp.begin(),_tmp.end(),origin_param[order]);
int current_param_position=itv.second-_tmp.begin();
- std::cout<<_tmp.size()<<std::endl;
+ std::cerr<<_tmp.size()<<std::endl;
return std::pair<typename element_type_trait<Tp>::element_type,
typename element_type_trait<Tp>::element_type>(
_tmp.at((int)((1-level)*current_param_position)),
diff --git a/misc/data_loaders.hpp b/misc/data_loaders.hpp
index 20405b1..ad23db6 100644
--- a/misc/data_loaders.hpp
+++ b/misc/data_loaders.hpp
@@ -66,7 +66,7 @@ namespace opt_utilities
break;
}
data<Ty,Tx> d(x,y,y_err,y_err,x_err,x_err);
- ds.push_back(d);
+ ds.add_data(d);
}
//return ifs;
}
@@ -125,7 +125,7 @@ namespace opt_utilities
break;
}
data<Ty,Tx> d(x,y,y_err,y_err,x_err,x_err);
- ds.push_back(d);
+ ds.add_data(d);
}
}
@@ -186,7 +186,7 @@ namespace opt_utilities
break;
}
data<Ty,Tx> d(x,y,yl,yu,xl,xu);
- ds.push_back(d);
+ ds.add_data(d);
}
}
diff --git a/models/polar_ellipse.hpp b/models/polar_ellipse.hpp
new file mode 100644
index 0000000..0b574a4
--- /dev/null
+++ b/models/polar_ellipse.hpp
@@ -0,0 +1,49 @@
+#ifndef PELLIPSE_MODEL_H_
+#define PELLIPSE_MODEL_H_
+#define OPT_HEADER
+#include <core/fitter.hpp>
+#include <cmath>
+
+namespace opt_utilities
+{
+ template <typename T>
+ class polar_ellipse
+ :public model<T,T,std::vector<T>,std::string>
+ {
+ private:
+ model<T,T,std::vector<T> >* do_clone()const
+ {
+ return new polar_ellipse<T>(*this);
+ }
+ public:
+ polar_ellipse()
+ {
+ this->push_param_info(param_info<std::vector<T> >("a",1,0,10));
+ this->push_param_info(param_info<std::vector<T> >("e",0,0,1));
+ this->push_param_info(param_info<std::vector<T> >("theta0",0,0,360));
+ }
+
+ public:
+ T do_eval(const T& x,const std::vector<T>& param)
+ {
+ double a=param[0];
+ double e=param[1];
+ double t0=param[2];
+ double t=x-t0;
+ t=t/180.*3.14159265358979;
+ return a*(1-e*e)/(1-e*cos(t));
+ }
+
+ private:
+ std::string do_to_string()const
+ {
+ return "linear model\n"
+ "y=k*x+b\n";
+ }
+ };
+}
+
+
+
+#endif
+//EOF