aboutsummaryrefslogtreecommitdiffstats
path: root/mass_profile/constrained_dbeta.hpp
diff options
context:
space:
mode:
authorAaron LI <aaronly.me@gmail.com>2016-06-08 01:13:12 +0800
committerAaron LI <aaronly.me@gmail.com>2016-06-08 01:13:19 +0800
commitc380ede43a82a5b13bf5d93be5ddb6fe7a2b4b8c (patch)
treef9476573ff59fd795682333d6c91c1944a40b857 /mass_profile/constrained_dbeta.hpp
parent695c64ecce86f764758ee0169348a06677267208 (diff)
downloadchandra-acis-analysis-c380ede43a82a5b13bf5d93be5ddb6fe7a2b4b8c.tar.bz2
constrained_dbeta.hpp: add missing <iostream> and std::
Also some style adjustments
Diffstat (limited to 'mass_profile/constrained_dbeta.hpp')
-rw-r--r--mass_profile/constrained_dbeta.hpp73
1 files changed, 35 insertions, 38 deletions
diff --git a/mass_profile/constrained_dbeta.hpp b/mass_profile/constrained_dbeta.hpp
index 24a1ebb..31a4cd4 100644
--- a/mass_profile/constrained_dbeta.hpp
+++ b/mass_profile/constrained_dbeta.hpp
@@ -1,26 +1,26 @@
#ifndef CONSTRAINED_DBETA
#define CONSTRAINED_DBETA
#include "projector.hpp"
+#include <iostream>
namespace opt_utilities
{
- template <typename T>
- class constrained_dbeta
- :public model<std::vector<T>,std::vector<T>,std::vector<T> >
- {
- public:
- constrained_dbeta()
+ template <typename T>
+ class constrained_dbeta
+ :public model<std::vector<T>,std::vector<T>,std::vector<T> >
{
- this->push_param_info(param_info<std::vector<T>,std::string>("n01",1));
- this->push_param_info(param_info<std::vector<T>,std::string>("beta1",.66));
- this->push_param_info(param_info<std::vector<T>,std::string>("rc1",100));
+ public:
+ constrained_dbeta()
+ {
+ this->push_param_info(param_info<std::vector<T>,std::string>("n01",1));
+ this->push_param_info(param_info<std::vector<T>,std::string>("beta1",.66));
+ this->push_param_info(param_info<std::vector<T>,std::string>("rc1",100));
- this->push_param_info(param_info<std::vector<T>,std::string>("n02",1));
- this->push_param_info(param_info<std::vector<T>,std::string>("beta2",.67));
- this->push_param_info(param_info<std::vector<T>,std::string>("rc2",110));
-
- }
+ this->push_param_info(param_info<std::vector<T>,std::string>("n02",1));
+ this->push_param_info(param_info<std::vector<T>,std::string>("beta2",.67));
+ this->push_param_info(param_info<std::vector<T>,std::string>("rc2",110));
+ }
public:
constrained_dbeta<T>* do_clone()const
@@ -28,8 +28,7 @@ namespace opt_utilities
return new constrained_dbeta<T>(*this);
}
- std::vector<T> do_eval(const std::vector<T> & x,
- const std::vector<T>& p)
+ std::vector<T> do_eval(const std::vector<T> & x, const std::vector<T>& p)
{
T n01=std::abs(p[0]);
T beta1=p[1];
@@ -39,40 +38,38 @@ namespace opt_utilities
T beta2=p[4];
T rc2=p[5];
-
-
std::vector<T> result(x.size()-1);
for(int i=1;i<x.size();++i)
- {
- T xi=(x[i]+x[i-1])/2;
- T yi=0;
- yi=n01*pow(1+xi*xi/rc1/rc1,-3./2.*beta1)+n02*pow(1+xi*xi/rc2/rc2,-3./2.*beta2);
- result[i-1]=yi;
- }
+ {
+ T xi=(x[i]+x[i-1])/2;
+ T yi=0;
+ yi=n01*pow(1+xi*xi/rc1/rc1,-3./2.*beta1)+n02*pow(1+xi*xi/rc2/rc2,-3./2.*beta2);
+ result[i-1]=yi;
+ }
return result;
}
bool do_meets_constraint(const std::vector<T>& p)const
{
if(p.size()!=6)
- {
- cerr<<p.size()<<endl;
- cerr<<this->get_num_params()<<endl;
- assert(0);
- }
-
+ {
+ std::cerr<<p.size()<<std::endl;
+ std::cerr<<this->get_num_params()<<std::endl;
+ assert(0);
+ }
+
T rc1=p.at(2);
T rc2=p.at(5);
if(rc2>rc1)
- {
- return true;
- }
+ {
+ return true;
+ }
else
- {
- cerr<<rc2<<"\t"<<rc1<<endl;
- cerr<<"***"<<endl;
- return false;
- }
+ {
+ std::cerr<<rc2<<"\t"<<rc1<<std::endl;
+ std::cerr<<"***"<<std::endl;
+ return false;
+ }
}
};
}