Commit 094ace42 authored by Xavier Garrido's avatar Xavier Garrido
Browse files

fix parsing of z value

The `substr` function was going a character too far making the `fail` function from istringstream
function failing.

`testKlass` is working again.
parent f242fcda
......@@ -94,39 +94,31 @@ Engine::writeCls(std::ostream &of){
double
Engine::get(const std::string& key)
{
string var=key;
double z=0.;
string::size_type index=key.find("(");
if (index !=string::npos){
planck_assert(key.substr(key.size()-1,1)==")",key+": keyword not finishing with )");
var=key.substr(0,index);
istringstream isNum(key.substr(index+1,key.size()-index-1));
isNum >> z;
planck_assert(isNum.good(),key+": Engine canot decode z value in keyword");
//SP: 5sep18 previuous lines fail (don't lnow why) so back to previous method
//planck_assert(isNum>>z,key+": Engine canot decode z value in keyword");
}
if (var=="z_drag") return z_drag();
else if (var=="rs_drag") return rs_drag();
else if (var=="f") return get_f(z);
else if (var=="Dv") return get_Dv(z);
else if (var=="Da") return get_Da(z);
else if (var=="sigma8") return get_sigma8(z);
else if (var=="H0") return get_H0();
else if (var=="theta") return theta();
else if (var=="tau_reio") return get_tau_reio();
else if (var=="z_reio") return get_z_reio();
else if (var=="H") return get_H(z);
else if (var=="com_distance") return com_distance(z);
else if (var=="growthD") return get_growthD(z);
else { planck_assert(false,("key="+key+" not found in Engine::get()")); return -1;}
Engine::get(const std::string& key){
string var=key;
double z=0.;
string::size_type index=key.find("(");
if (index != string::npos){
planck_assert(key.substr(key.size()-1,1)==")",key+": keyword not finishing with )");
var=key.substr(0,index);
istringstream isNum(key.substr(index+1,key.size()-index-2));
planck_assert(isNum >> z,key+": Engine cannot decode z value in keyword");
}
if (var=="z_drag") return z_drag();
else if (var=="rs_drag") return rs_drag();
else if (var=="f") return get_f(z);
else if (var=="Dv") return get_Dv(z);
else if (var=="Da") return get_Da(z);
else if (var=="sigma8") return get_sigma8(z);
else if (var=="H0") return get_H0();
else if (var=="theta") return theta();
else if (var=="tau_reio") return get_tau_reio();
else if (var=="z_reio") return get_z_reio();
else if (var=="H") return get_H(z);
else if (var=="com_distance") return com_distance(z);
else if (var=="growthD") return get_growthD(z);
else { planck_assert(false,("key="+key+" not found in Engine::get()")); return -1;}
}
double
Engine::undef(const char* param) const{
......
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