Docker-in-Docker (DinD) capabilities of public runners deactivated. More info

Commit 8fe5fcb9 authored by Plaszczynski Stephane's avatar Plaszczynski Stephane
Browse files

clean Pkvec and use access with explicit z; looks OK

parent ab32cba3
......@@ -59,6 +59,10 @@ macro_append CAMEL_linkopts " -lcfitsio"
#macro_append cppflags ' -DPICODATA=\"$(PICO_DATA)\" '
#application testPico -group=test -s=$(CAMELROOT)/src/camel/pico/exec testPico.cc
#CLASS optional FastPk access
macro_append cppflags " -DFASTPK "
###FROM THERE YOU DONT NEED TO TOUCH
###########################################################################################
#CAMEL LIBRARIES
......
......@@ -722,19 +722,25 @@ double ClassEngine::get_DMod(double z){
#ifdef FASTPK
//fast access
void
/*
bool
ClassEngine::get_Pkvec(const std::vector<double>& knodes,
std::vector<double>& pks){
planck_assert(sp.ln_tau_size==1,name()+":get_Pkvec cannot proceed since several z values required-> remove z_max_pk/z_pk or use get_Pkvec(k,z,pk)" );
spectra_fast_pk_at_kvec(
return (spectra_fast_pk_at_kvec(
&ba,
&sp,
const_cast<double*>(&knodes[0]),
knodes.size(),
&pks[0]);
&pks[0])==_TRUE_);
}
*/
bool
ClassEngine::get_Pkvec(const std::vector<double>& knodes, const std::vector<double>& zvec, std::vector<double>& pks)
{
return ( _nonlin ? (spectra_fast_pk_nl_at_kvec_and_zvec(&ba,&sp,const_cast<double*>(&knodes[0]),knodes.size(),const_cast<double*>(&zvec[0]), zvec.size(),&pks[0])==_TRUE_) : (spectra_fast_pk_at_kvec_and_zvec(&ba,&sp,const_cast<double*>(&knodes[0]),knodes.size(),const_cast<double*>(&zvec[0]), zvec.size(),&pks[0])==_TRUE_) );
}
#endif
......@@ -157,10 +157,18 @@ public:
double get_PkNL(double k, double z);
#ifdef FASTPK
//should be used with care only for z=0 so no z_max_pk and z_pk should be given
//pks should be sized as knodes
void get_Pkvec(const std::vector<double>& knodes,
std::vector<double>& pks);
//fixed k and z values: output
bool get_Pkvec(const std::vector<double>& knodes, const std::vector<double>& z,std::vector<double>& pks);
inline bool get_Pkvec(const std::vector<double>& kvec,
const double& z,
std::vector<double>& pks){
std::vector<double> zvec(1,z);
return this->get_Pkvec(kvec,zvec,pks);
}
#endif
//combile distance
......
......@@ -95,9 +95,8 @@ public:
virtual double get_Pklin(double k, double z) { return klass->get_Pklin(k,z);}
virtual double get_PkNL(double k, double z) { return klass->get_PkNL(k,z);}
inline void get_Pkvec(const std::vector<double>& knodes,
std::vector<double>& pks)
{ return klass->get_Pkvec(knodes,pks);}
inline bool get_Pkvec(const std::vector<double>& knodes, const std::vector<double>& zvec, std::vector<double>& pks) {return klass->get_Pkvec(knodes,zvec,pks);}
void writeCls(std::ostream &o) {klass->writeCls(o);}
......
......@@ -93,15 +93,25 @@ public:
virtual double get_Pklin(double k, double z) { return undef("get_Pklin");}
virtual double get_PkNL(double k, double z) { return undef("get_Pknl");}
// P(k,z=0) access through vectors for given k values.
// output vector pks should be sized the same
//default implementation: calls P(k,z) -> override for better performances
inline virtual void get_Pkvec(const std::vector<double>& knodes,
std::vector<double>& pks){
for (size_t i=0;i<knodes.size();i++) pks[i]=get_Pk(knodes[i],0);
//compute Pk for fixed k and z values
//output Pks should be sized as zvec.size()*kvec.size
//default implementations calls P(k,z) function -> override for better performances
//most general form
inline virtual bool get_Pkvec(const std::vector<double>& kvec,
const std::vector<double>& zvec,
std::vector<double>& pks){
for (size_t j=0;j<zvec.size();j++)
for (size_t i=0;i<kvec.size();i++)
pks[j*zvec.size()+i]=get_Pk(kvec[i],zvec[j]);
return true;
}
inline virtual bool get_Pkvec(const std::vector<double>& kvec,
const double& z,
std::vector<double>& pks){
std::vector<double> zvec(1,z);
return get_Pkvec(kvec,zvec,pks);
}
//access thtought keyword: convention is that kw is name of previous methods without "get_"
......
......@@ -233,7 +233,7 @@ int main(int argc,char** argv){
cout <<"Pk timer test..." << endl;
vector<double> pkvec(kval.size());
for (size_t i=0;i<1000;i++)
e->get_Pkvec(kval,pkvec);
e->get_Pkvec(kval,z0,pkvec);
cout << "fast=" << timer.partial() <<endl;
for (size_t i=0;i<1000;i++){
......@@ -253,7 +253,7 @@ int main(int argc,char** argv){
//check fast
vector<double> pkfast(kval.size());
try{
e->get_Pkvec(kval,pkfast);
e->get_Pkvec(kval,z0,pkfast);
}
catch (Message_error &e){};
......
......@@ -110,7 +110,7 @@ int main(int argc,char** argv){
//spectra_fast_pk_at_kvec(&ba,&sp,const_cast<double*>(&kvec[0]),kvec.size(),&pkvec[0]);
engine->get_Pkvec(kvec,pkvec);
engine->get_Pkvec(kvec,0.,pkvec);
for (size_t i=0;i<kvec.size();i++) cout << "k=" << kvec[i] << "\t p(k)=" << pkvec[i] << endl;
//clean
delete engine;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment