From 1b839fd299c77624bc9522995bc0241de63eee8f Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Thu, 16 Feb 2017 23:41:11 +0800 Subject: Remove calc_distance (last used by the deleted 'calc_lx') --- mass_profile/Makefile | 8 +-- mass_profile/adapt_trapezoid.h | 124 ------------------------------------- mass_profile/calc_distance.cc | 61 ------------------ mass_profile/calc_distance.h | 8 --- mass_profile/calc_distance_main.cc | 52 ---------------- 5 files changed, 1 insertion(+), 252 deletions(-) delete mode 100644 mass_profile/adapt_trapezoid.h delete mode 100644 mass_profile/calc_distance.cc delete mode 100644 mass_profile/calc_distance.h delete mode 100644 mass_profile/calc_distance_main.cc (limited to 'mass_profile') diff --git a/mass_profile/Makefile b/mass_profile/Makefile index 4f037e6..1d7f48b 100644 --- a/mass_profile/Makefile +++ b/mass_profile/Makefile @@ -24,7 +24,7 @@ endif OPT_UTIL_INC ?= -I../opt_utilities TARGETS= fit_nfw_sbp fit_dbeta_sbp fit_beta_sbp \ - fit_direct_beta calc_distance fit_wang2012_model \ + fit_direct_beta fit_wang2012_model \ fit_nfw_mass fit_mt_pl fit_lt_pl fit_mt_bpl \ fit_lt_bpl cooling_time calc_lx_dbeta calc_lx_beta HEADERS= projector.hpp spline.hpp vchisq.hpp @@ -57,9 +57,6 @@ calc_lx_dbeta: calc_lx_dbeta.o beta_cfg.o report_error.o calc_lx_beta: calc_lx_beta.o beta_cfg.o dump_fit_qdp.o $(CXX) $(CXXFLAGS) $^ -o $@ $(OPT_UTIL_INC) -calc_distance: calc_distance_main.o calc_distance.o - $(CXX) $(CXXFLAGS) -o $@ $^ - fit_mt_pl: fit_mt_pl.cpp $(CXX) $(CXXFLAGS) $< -o $@ $(OPT_UTIL_INC) @@ -106,9 +103,6 @@ report_error.o: report_error.cpp report_error.hpp dump_fit_qdp.o: dump_fit_qdp.cpp dump_fit_qdp.hpp $(CXX) $(CXXFLAGS) -c $< $(OPT_UTIL_INC) -calc_distance.o: calc_distance.cc calc_distance.h adapt_trapezoid.h - $(CXX) $(CXXFLAGS) -c $< - %.o: %.cc $(CXX) $(CXXFLAGS) -c $< $(OPT_UTIL_INC) diff --git a/mass_profile/adapt_trapezoid.h b/mass_profile/adapt_trapezoid.h deleted file mode 100644 index 35d22b4..0000000 --- a/mass_profile/adapt_trapezoid.h +++ /dev/null @@ -1,124 +0,0 @@ -#ifndef ADAPT_TRAPEZOID_H -#define ADAPT_TRAPEZOID_H -#include -#include -#include -//#include - -//using namespace std; - -template -class triple -{ - public: - T1 first; - T2 second; - T3 third; - triple(T1 x1,T2 x2,T3 x3) - :first(x1),second(x2),third(x3) - { - } -}; - - -template -triple make_triple(T1 x1,T2 x2,T3 x3) -{ - return triple(x1,x2,x3); -} - -template -T trapezoid(T (*fun)(T),T x1,T x2,T err_limit) -{ - int n=256; - T result; - const int max_division=24; - T old_value=0; - for(int i=1;i -T adapt_trapezoid(T (*fun)(T),T x1,T x2,T err_limit) -{ - // const err_limit=.001; - typedef triple interval; - /*T for interval type, - bool for state trur for still to be updated, - false for do not need to be updated - */ - std::list interval_list; - T current_sum=((fun(x1)+fun(x2))/2.*(x2-x1)); - interval_list.push_back(make_triple(x1,current_sum,true)); - interval_list.push_back(make_triple(x2,(T)0.,true)); - bool int_state=1; - int n_intervals=1; - while(int_state) - { - //std::cout<::iterator i1=interval_list.begin(); - typename std::list::iterator i2=interval_list.begin(); - i2++; - for(;i2!=interval_list.end();i1++,i2=i1,i2++) - { - //cout<first<<"\t"<first<first>i1->first); - if(i1->third) - { - interval new_interval((i1->first+i2->first)/2,0,true); - - T sum1,sum2; - sum1=(fun(new_interval.first)+fun(i1->first))/2*(new_interval.first-i1->first); - sum2=(fun(new_interval.first)+fun(i2->first))/2*(i2->first-new_interval.first); - new_interval.second=sum2; - T err; - err=i1->second-sum1-sum2; - err=err<0?-err:err; - - if(err>err_limit/n_intervals) - { - i1->second=sum1; - interval_list.insert(i2,new_interval); - n_intervals++; - if(n_intervals>10e6) - { - - break; - } - } - else - { - i1->third=false; - } - int_state=1; - } - } - - } - T result=0; - for(typename std::list::iterator i=interval_list.begin();i!=interval_list.end();i++) - { - result+=i->second; - } - return result; -} - -#endif -//end of the file diff --git a/mass_profile/calc_distance.cc b/mass_profile/calc_distance.cc deleted file mode 100644 index 91f2ea3..0000000 --- a/mass_profile/calc_distance.cc +++ /dev/null @@ -1,61 +0,0 @@ -#include -#include -#include -#include -#include -#include "adapt_trapezoid.h" - -//calc_distance -//usage: -//calc_distance z - -using namespace std; - -static double cm=1; -static double s=1; -static double km=1000*100; -static double Mpc=3.08568e+24*cm; -//static double kpc=3.08568e+21*cm; -//static double yr=365.*24.*3600.; -//static double Gyr=1e9*yr; -static double H=71.*km/s/Mpc; -static const double c=299792458.*100.*cm; -//const double c=3e8*100*cm; -static const double omega_m=0.27; -static const double omega_l=0.73; -static const double arcsec2arc_ratio=1./60/60/180*3.1415926; - - -double E(double z) -{ - double omega_k=1-omega_m-omega_l; - return sqrt(omega_m*(1+z)*(1+z)*(1+z)+omega_k*(1+z)*(1+z)+omega_l); -} - -double f_dist(double z) -{ - return 1/E(z); -} - -double f_age(double z) -{ - return f_dist(1/z)/(z*z); -} - - - -double calc_angular_distance(double z) -{ - //return c/H*integer(f_dist,0,z)/(1+z); - //return c/H*adapt_trapezoid(f_dist,0.,z,1e-4)/(1+z); - return adapt_trapezoid(f_dist,0.,z,1e-4)/(1+z); -} - -double calc_luminosity_distance(double z) -{ - //return c/H*integer(f_dist,0,z)/(1+z); - return c/H*adapt_trapezoid(f_dist,0.,z,1e-4)*(1+z); -} - - -//EOF diff --git a/mass_profile/calc_distance.h b/mass_profile/calc_distance.h deleted file mode 100644 index ba01316..0000000 --- a/mass_profile/calc_distance.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef CALC_DISTANCE_H -#define CALC_DISTANCE_H -extern double calc_angular_distance(double z); -extern double calc_luminosity_distance(double z); -extern double E(double z); -#endif - -//EOF diff --git a/mass_profile/calc_distance_main.cc b/mass_profile/calc_distance_main.cc deleted file mode 100644 index 28bdb70..0000000 --- a/mass_profile/calc_distance_main.cc +++ /dev/null @@ -1,52 +0,0 @@ -#include "calc_distance.h" -#include -#include -#include -using namespace std; - -static double cm=1; -static double s=1; -static double km=1000*100; -static double Mpc=3.08568e+24*cm; -static double kpc=3.08568e+21*cm; -//static double yr=365.*24.*3600.; -//static double Gyr=1e9*yr; -static double H=71.*km/s/Mpc; -static const double c=299792458.*100.*cm; -//const double c=3e8*100*cm; -static const double pi=4*atan(1); -static const double omega_m=0.27; -static const double omega_l=0.73; -static const double arcsec2arc_ratio=1./60/60/180*pi; - - - - -int main(int argc,char* argv[]) -{ - if(argc<2) - { - cerr<<"Usage:"<