Gitlab is now running v13.9.0 - More info -> here <-

Commit 57b8f7d1 authored by Matthieu Tristram's avatar Matthieu Tristram

Merge branch 'fix-warnings' into 'master'

Fix warnings

See merge request cosmotools/CAMEL!5
parents 2cef189c 28ed2caa
......@@ -26,7 +26,7 @@ using namespace std;
//---------------
// Constructors --
//----------------
OofNoise::OofNoise(AbsGauss* r,double slope,double fmin,double fknee,double fsample):AbsGauss(0.,1.),_r(r),_sigma(r->sigma())
OofNoise::OofNoise(AbsGauss* r,double slope,double fmin,double fknee,double fsample):AbsGauss(0.,1.),_r(r),_sigma(r->sigma())
{
//TW:
......@@ -73,10 +73,10 @@ using namespace std;
//_sigma*=sqrt(fsample);
}
OofNoise::~OofNoise(){
OofNoise::~OofNoise(){
for (unsigned i=0;i<ff.size();i++) delete ff[i];
if (_r) delete _r; _r=NULL;
};
}
double
OofNoise::normal(){
......@@ -84,5 +84,4 @@ OofNoise::normal(){
for (unsigned i=0;i<ff.size();i++) x2=ff[i]->filter(x2);
return x2*_sigma;
};
}
......@@ -954,8 +954,8 @@ void HiLLiPOP::computeResiduals( vector<double> ClCMB, vector<double>& nuisance,
unsigned int modeOffset = 0;
char tmpPar[32];
vector<double> Aps(_nXFreq);
double Asz, Acib, Aksz, Aszxcib;
double AdustTT, AdustTP, AdustPP;
double Asz = 0.0, Acib = 0.0, Aksz = 0.0, Aszxcib = 0.0;
double AdustTT = 0.0, AdustTP = 0.0, AdustPP = 0.0;
_residual.resize(5);
_instrumental.resize(5);
......@@ -1359,4 +1359,3 @@ void HiLLiPOP::WriteOutput(const vector<double>& ClCMB,const vector<double>& nui
of.close();
// End: output
}
......@@ -498,7 +498,7 @@ double HighEll::computeLikelihood(const vector<unsigned int>& l,vector<double>&
if (_verbose >2) cout << " high ell likelihood compute for"<< _name<<" nuisance size "<< nuisance.size()<<endl;
HandleNuisance( nuisance ); // fills calibs + fg params etc...
if (_verbose >2) cout << " handled nuisance params for "<< _name<<endl;
ofstream * fileout ;
ofstream * fileout = 0;
if (_verbose >2) {
string fname = "outLike_";
fname = fname + _name;
......@@ -572,10 +572,12 @@ double HighEll::computeLikelihood(const vector<unsigned int>& l,vector<double>&
mychi2 = _cov_matrix->similarity(clChi);
_chi2_prec = mychi2;
if (_verbose >1)cout << " High ell likelihood for "<< _name<<" chi2 " << mychi2 <<" ndof "<< _size <<endl;
if ( _verbose > 2 ) fileout->close();
if ( _verbose > 2 ) delete fileout;
if ( _verbose > 2 ) computeResiduals(l, cltt, clte, clee, clbb, nuisance);
if (_verbose >1) cout << " High ell likelihood for "<< _name<<" chi2 " << mychi2 <<" ndof "<< _size <<endl;
if (_verbose > 2) {
fileout->close();
delete fileout;
computeResiduals(l, cltt, clte, clee, clbb, nuisance);
}
_lnlkl= mychi2/2.;
......
......@@ -925,8 +925,8 @@ void Hillipop::computeResiduals( vector<double> ClCMB, vector<double>& nuisance,
double tmpBeamEigenmodes = 1.;
double foregrounds = 0;
unsigned int modeOffset = 0;
double ApsRadio, ApsDusty, Asz, Acib, Aksz, Aszxcib;
double AdustTT, AdustTP, AdustPP;
double ApsRadio = 0.0, ApsDusty = 0.0, Asz = 0.0, Acib = 0.0, Aksz = 0.0, Aszxcib = 0.0;
double AdustTT = 0.0, AdustTP = 0.0, AdustPP = 0.0;
_residual.resize(5);
_instrumental.resize(5);
......
......@@ -10,7 +10,9 @@
SPTpol::~SPTpol(){
cout << "Chi2 from SPTpol: " << SPTpolLnLike << endl;
delete _cov_data, _cov_sims, _windows;
delete _cov_data;
delete _cov_sims;
delete _windows;
}
......@@ -166,7 +168,7 @@ double SPTpol::computeLikelihood(const vector<unsigned int>& l,
const double kappa = nuisance[getIndex("SPTpol_kappa" )];
i=0;
double epsilon, calib;
double epsilon = 0.0, calib = 0.0;
HepVector deltacb(nall,0);
for( int j=0; j<nfreq; j++) {
for( int k=1; k<bands_per_freq; k++) {
......
......@@ -31,7 +31,7 @@ template<typename T> std::string str(const T &x){
std::ostringstream os;
os << x;
return os.str();
};
}
//specilization
template<> std::string str (const float &x){
std::ostringstream os;
......@@ -557,7 +557,7 @@ double ClassEngine::get_growthD(double z)
double ClassEngine::get_Pklin(double k, double z){
double tau;
int ret, index;
int index;
double * pk_ic = NULL;
......@@ -565,19 +565,19 @@ double ClassEngine::get_Pklin(double k, double z){
background_tau_of_z(&ba,z,&tau);
background_at_tau(&ba,tau,ba.long_info,ba.inter_normal, &index, pvecback);
ret=spectra_pk_at_k_and_z(&ba,&pm,&sp,k,z,&mypk,pk_ic);
spectra_pk_at_k_and_z(&ba,&pm,&sp,k,z,&mypk,pk_ic);
return mypk;
}
double ClassEngine::get_PkNL(double k, double z){
double tau;
int ret,index;
int index;
double mypk;
background_tau_of_z(&ba,z,&tau);
//cout << "pknl after bkg "<<tau<< endl;
background_at_tau(&ba,tau,ba.long_info,ba.inter_normal, &index, pvecback);
//cout << "pknl after bkg @tau "<<tau<< " z "<<z<< " k "<< k << endl;
ret = spectra_pk_nl_at_k_and_z(&ba,&pm,&sp,k,z,&mypk);
spectra_pk_nl_at_k_and_z(&ba,&pm,&sp,k,z,&mypk);
return mypk;
}
......@@ -685,7 +685,7 @@ double ClassEngine::com_distance(double z)
double ClassEngine::get_Da(double z)
{
double tau, H_z, D_ang;
double tau;
int index;
//transform redshift in conformal time
background_tau_of_z(&ba,z,&tau);
......@@ -693,10 +693,9 @@ double ClassEngine::get_Da(double z)
//call to fill pvecback
background_at_tau(&ba,tau,ba.long_info,ba.inter_normal, &index, pvecback);
H_z=pvecback[ba.index_bg_H];
D_ang=pvecback[ba.index_bg_ang_distance];
double D_ang=pvecback[ba.index_bg_ang_distance];
#ifdef DBUG
double H_z=pvecback[ba.index_bg_H];
cout << "H_z= "<< H_z <<endl;
cout << "D_ang= "<< D_ang <<endl;
#endif
......
......@@ -18,6 +18,7 @@
//CLASS
extern "C"{
#include"class.h"
}
#include"Engine.hh"
......@@ -259,4 +260,3 @@ protected:
};
#endif
......@@ -104,7 +104,8 @@ Engine::get(const std::string& key)
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));
planck_assert(isNum>>z,key+": Engine canot decode z value in keyword");
isNum >> z;
planck_assert(isNum.fail(),key+": Engine canot decode z value in keyword");
}
if (var=="z_drag") return z_drag();
else if (var=="rs_drag") return rs_drag();
......
......@@ -58,7 +58,7 @@ double JLA_chi2::chi2_eff(const std::vector<double>& par) const
// gets distance moduli from class
if (_verbosity>3)
cout << name() << " chi2_eff nuisance params : "<< _jla_nuisance[0] <<" "<< _jla_nuisance[1] <<" "<< _jla_nuisance[2] << " "<< _jla_nuisance[3]<<endl;
double mu[ _jlalike->size()];
std::vector<double> mu( _jlalike->size());
for (int i=0; i < _jlalike->size(); i++)
{
mu[i] = engine->get_DMod (_Z[i] );
......@@ -66,13 +66,13 @@ double JLA_chi2::chi2_eff(const std::vector<double>& par) const
// JLA likelihood evaluation
double retchi2 = _jlalike->computeLikelihood(mu,_jla_nuisance );
double retchi2 = _jlalike->computeLikelihood(&mu[0],_jla_nuisance );
if (_verbosity>4) {
// puts distance modulus and standardized residuals in an ascii file for later plotting
ofstream myfile;
double residuals[ _jlalike->size() ] ;
int ret = _jlalike->computeResiduals(mu, _jla_nuisance, residuals);
std::vector<double> residuals( _jlalike->size());
int ret = _jlalike->computeResiduals(&mu[0], _jla_nuisance, &residuals[0]);
if (ret !=0) cout<<" PROBLEM WITH COMPUTE RESIDUALS !!" <<endl;
myfile.open("SNIa_Std_Residuals.dat");
for (int i=0; i < _jlalike->size(); i++){
......
......@@ -218,9 +218,10 @@ void JLALikelihood::read(const char * datasetfile)
double JLALikelihood::computeLikelihood(double * distance_modulii,
double * nuisance_parameters)
{
double residuals[size()];
std::vector<double> residuals(size());
int status;
status = computeResiduals(distance_modulii, nuisance_parameters, residuals);
status = computeResiduals(distance_modulii, nuisance_parameters, &residuals[0]);
double chi2 = 0;
if (status == 0)
......@@ -275,13 +276,13 @@ int JLALikelihood::computeResiduals(double * distance_modulii, double * nuisance
// Covariance matrix computation
int nsq = n*n;
double cov[nsq];
cblas_dcopy(nsq, C00, incx, cov, incy);
cblas_daxpy(nsq, sq(alpha), C11, 1, cov, 1);
cblas_daxpy(nsq, sq(beta), C22, 1, cov, 1);
cblas_daxpy(nsq, 2.0 * alpha, C01, 1, cov, 1);
cblas_daxpy(nsq, -2.0 * beta, C02, 1, cov, 1);
cblas_daxpy(nsq, -2.0 * alpha * beta, C12, 1, cov, 1);
std::vector<double> cov(nsq);
cblas_dcopy(nsq, C00, incx, &cov[0], incy);
cblas_daxpy(nsq, sq(alpha), C11, 1, &cov[0], 1);
cblas_daxpy(nsq, sq(beta), C22, 1, &cov[0], 1);
cblas_daxpy(nsq, 2.0 * alpha, C01, 1, &cov[0], 1);
cblas_daxpy(nsq, -2.0 * beta, C02, 1, &cov[0], 1);
cblas_daxpy(nsq, -2.0 * alpha * beta, C12, 1, &cov[0], 1);
for (int i = 0; i < n; i++)
......@@ -301,14 +302,14 @@ int JLALikelihood::computeResiduals(double * distance_modulii, double * nuisance
// Whiten the residuals
int nhrs = 1, info = 0;
dpotrf("U", &n, cov, &n, &info);
dpotrf("U", &n, &cov[0], &n, &info);
if (info != 0){
if (verbosity > 0)
cerr << "Cholesky Error: " << info << endl;
return -1;
}
dtrtrs("U", "T", "N", &n, &nhrs, cov, &n, residuals, &n, &info);
dtrtrs("U", "T", "N", &n, &nhrs, &cov[0], &n, residuals, &n, &info);
if (info != 0){
if (verbosity > 0)
cerr << "Solve Error: " << info << endl;
......@@ -357,4 +358,3 @@ JLALikelihood::~JLALikelihood()
free(C12);
}
}
......@@ -230,13 +230,13 @@ int main(int argc, char *argv[])
//---autocorr----and acc rate-------------
vector<double > ar_vs_length;
int max_lag;
int min_lag;
// int max_lag;
// int min_lag;
vector<HepVector > autocorr_vs_length;
for(int step=100; step<=length; step+=100)
{
max_lag=50;
min_lag=max_lag;
// max_lag=50;
// min_lag=max_lag;
if((step<t0) && algo=="ada")
{ar_vs_length.push_back(chain->acc_rate(0,step)); }
else if(step>=t0 && algo=="ada" )
......@@ -265,4 +265,3 @@ int main(int argc, char *argv[])
delete chi2;
}
......@@ -41,8 +41,7 @@ void printVec(const vector<T>& v,unsigned n,const string & s){
if (v.size()<n) n=v.size();
copy(v.begin(),v.begin()+n,ostream_iterator<T>(cout,"\t"));
cout << "..." << endl;
}
;
}
/*********************/
/* global variables */
/*********************/
......@@ -190,7 +189,6 @@ int main(int argc,char** argv){
if (argc ==4){
ofstream of(argv[3]);
const MnUserCovariance& cov=min1.UserCovariance();
int pr = of.precision(6);
unsigned int n = cov.Nrow();
for (unsigned int i = 0; i < n; i++) {
for (unsigned int j = 0; j < n; j++) {
......
......@@ -238,7 +238,7 @@ int main(int argc,char** argv){
for (size_t i=0;i<100;i++){
for (int k =0; k<kval.size() ; k++){
double pk=e->get_Pklin(kval[k], 0);
e->get_Pklin(kval[k], 0);
}
}
cout << "std=" << timer.partial() <<endl;
......
......@@ -31,7 +31,7 @@ using namespace std;
bool file_present (const string &filename)
{
ifstream dummy(filename.c_str());
return dummy;
return dummy.good();
}
void assert_present (const string &filename)
......@@ -214,15 +214,6 @@ void IO_backend_status()
<< iohandle_current::Type() << " I/O." << endl;
}
void CVS_status()
{
#ifndef CVSTAG
cout << "CVS checkout status: unknown" << endl;
#else
cout << "CVS checkout tag: " CVSTAG " (" CVSSTATUS ")" << endl;
#endif
}
} //unnamed namespace
void announce (const string &name)
......
......@@ -18,54 +18,73 @@
// should not be used outside this file.
template <typename T, bool equalSize> struct sizeChooserHelper
{ typedef void TYPE; };
{ typedef void TYPE; };
template <typename T> struct sizeChooserHelper<T,true>
{ typedef T TYPE; };
{ typedef T TYPE; };
template <typename T1, typename T2, typename T3> struct sizeChooserHelper2
{ typedef T1 TYPE; };
{ typedef T1 TYPE; };
template <typename T2, typename T3> struct sizeChooserHelper2 <void, T2, T3>
{ typedef T2 TYPE; };
{ typedef T2 TYPE; };
template <typename T3> struct sizeChooserHelper2 <void, void, T3>
{ typedef T3 TYPE; };
{ typedef T3 TYPE; };
template <> struct sizeChooserHelper2 <void, void, void>
{ };
{ };
template <int sz, typename T1, typename T2=char, typename T3=char>
struct sizeChooser
{
struct sizeChooser
{
typedef typename sizeChooserHelper2
<typename sizeChooserHelper<T1,sizeof(T1)==sz>::TYPE,
typename sizeChooserHelper<T2,sizeof(T2)==sz>::TYPE,
typename sizeChooserHelper<T3,sizeof(T3)==sz>::TYPE >::TYPE TYPE;
};
};
#if (__cplusplus>=201103L)
#include <cstdint>
typedef int8_t int8;
typedef uint8_t uint8;
typedef int16_t int16;
typedef uint16_t uint16;
typedef int32_t int32;
typedef uint32_t uint32;
typedef int64_t int64;
typedef uint64_t uint64;
#else
typedef signed char int8;
typedef unsigned char uint8;
typedef sizeChooser<2, short, int>::TYPE
int16;
int16;
typedef sizeChooser<2, unsigned short, unsigned int>::TYPE
uint16;
uint16;
typedef sizeChooser<4, int, long, short>::TYPE
int32;
int32;
typedef sizeChooser<4, unsigned int, unsigned long, unsigned short>::TYPE
uint32;
uint32;
typedef sizeChooser<8, long, long long>::TYPE
int64;
int64;
typedef sizeChooser<8, unsigned long, unsigned long long>::TYPE
uint64;
uint64;
#endif
typedef sizeChooser<4, float, double>::TYPE
float32;
float32;
typedef sizeChooser<8, double, long double>::TYPE
float64;
float64;
//! unsigned integer type which should be used for array sizes
typedef std::size_t tsize;
......@@ -89,32 +108,32 @@ enum { PLANCK_INT8 = 0,
template<typename T> struct typehelper {};
template<> struct typehelper<int8>
{ enum { id=PLANCK_INT8 }; };
{ enum { id=PLANCK_INT8 }; };
template<> struct typehelper<uint8>
{ enum { id=PLANCK_UINT8 }; };
{ enum { id=PLANCK_UINT8 }; };
template<> struct typehelper<int16>
{ enum { id=PLANCK_INT16 }; };
{ enum { id=PLANCK_INT16 }; };
template<> struct typehelper<uint16>
{ enum { id=PLANCK_UINT16 }; };
{ enum { id=PLANCK_UINT16 }; };
template<> struct typehelper<int32>
{ enum { id=PLANCK_INT32 }; };
{ enum { id=PLANCK_INT32 }; };
template<> struct typehelper<uint32>
{ enum { id=PLANCK_UINT32 }; };
{ enum { id=PLANCK_UINT32 }; };
template<> struct typehelper<int64>
{ enum { id=PLANCK_INT64 }; };
{ enum { id=PLANCK_INT64 }; };
template<> struct typehelper<uint64>
{ enum { id=PLANCK_UINT64 }; };
{ enum { id=PLANCK_UINT64 }; };
template<> struct typehelper<float32>
{ enum { id=PLANCK_FLOAT32 }; };
{ enum { id=PLANCK_FLOAT32 }; };
template<> struct typehelper<float64>
{ enum { id=PLANCK_FLOAT64 }; };
{ enum { id=PLANCK_FLOAT64 }; };
template<> struct typehelper<bool>
{ enum { id=PLANCK_BOOL }; };
{ enum { id=PLANCK_BOOL }; };
template<> struct typehelper<std::string>
{ enum { id=PLANCK_STRING }; };
{ enum { id=PLANCK_STRING }; };
inline int type2size (int type)
{
{
switch (type)
{
case PLANCK_INT8 : return 1;
......@@ -132,10 +151,10 @@ inline int type2size (int type)
default:
planck_fail ("type2size: unsupported data type");
}
}
}
inline int string2type(const std::string &type)
{
{
if (type=="FLOAT64") return PLANCK_FLOAT64;
if (type=="FLOAT32") return PLANCK_FLOAT32;
if (type=="INT8") return PLANCK_INT8;
......@@ -149,10 +168,10 @@ inline int string2type(const std::string &type)
if (type=="BOOL") return PLANCK_BOOL;
if (type=="STRING") return PLANCK_STRING;
planck_fail ("string2type: unknown data type '"+type+"'");
}
}
inline const char *type2string (int type)
{
{
switch (type)
{
case PLANCK_INT8 : return "INT8";
......@@ -170,37 +189,37 @@ inline const char *type2string (int type)
default:
planck_fail ("type2string: unsupported data type");
}
}
}
template<typename T> inline const char *type2typename ()
{ return "unknown type"; }
{ return "unknown type"; }
template<> inline const char *type2typename<signed char> ()
{ return "signed char"; }
{ return "signed char"; }
template<> inline const char *type2typename<unsigned char> ()
{ return "unsigned char"; }
{ return "unsigned char"; }
template<> inline const char *type2typename<short> ()
{ return "short"; }
{ return "short"; }
template<> inline const char *type2typename<unsigned short> ()
{ return "unsigned short"; }
{ return "unsigned short"; }
template<> inline const char *type2typename<int> ()
{ return "int"; }
{ return "int"; }
template<> inline const char *type2typename<unsigned int> ()
{ return "unsigned int"; }
{ return "unsigned int"; }
template<> inline const char *type2typename<long> ()
{ return "long"; }
{ return "long"; }
template<> inline const char *type2typename<unsigned long> ()
{ return "unsigned long"; }
{ return "unsigned long"; }
template<> inline const char *type2typename<long long> ()
{ return "long long"; }
{ return "long long"; }
template<> inline const char *type2typename<unsigned long long> ()
{ return "unsigned long long"; }
{ return "unsigned long long"; }
template<> inline const char *type2typename<float> ()
{ return "float"; }
{ return "float"; }
template<> inline const char *type2typename<double> ()
{ return "double"; }
{ return "double"; }
template<> inline const char *type2typename<bool> ()
{ return "bool"; }
{ return "bool"; }
template<> inline const char *type2typename<std::string> ()
{ return "std::string"; }
{ return "std::string"; }
#endif
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