1
0
mirror of https://github.com/aportelli/LatAnalyze.git synced 2025-04-05 09:35:54 +01:00

code cleaning and GCC compatibility

This commit is contained in:
Antonin Portelli 2015-06-15 14:59:10 +02:00
parent 3e6b0edce1
commit cb45b34ddc
12 changed files with 75 additions and 81 deletions

View File

@ -32,11 +32,9 @@
#if (defined __INTEL_COMPILER)
#pragma warning disable 1682 2259
#elif (defined __GNUC__)||(defined __clang__)
#pragma GCC diagnostic ignored "-Wshorten-64-to-32"
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wsign-conversion"
#pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wdeprecated-register"
#pragma GCC diagnostic ignored "-Wunused-function"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#endif

View File

@ -31,7 +31,6 @@
#if (defined __INTEL_COMPILER)
#pragma warning disable 1682 2259
#elif (defined __GNUC__)||(defined __clang__)
#pragma GCC diagnostic ignored "-Wshorten-64-to-32"
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wsign-conversion"
#endif
@ -48,7 +47,7 @@
%}
%pure-parser
%name-prefix "_Ascii_"
%name-prefix = "_Ascii_"
%locations
%defines
%error-verbose
@ -117,12 +116,12 @@ data:
mat:
OPEN MAT ID INT floats CLOSE MAT
{
const unsigned int nRow = state->doubleQueue.size()/$INT, nCol = $INT;
const unsigned int nRow = state->doubleQueue.size()/$4, nCol = $4;
Index i, j, r = 0;
if (state->doubleQueue.size() != nRow*nCol)
{
LATAN_ERROR(Size, "matrix '" + *state->streamName + ":" + $ID +
LATAN_ERROR(Size, "matrix '" + *state->streamName + ":" + $3 +
"' has a wrong size");
}
@ -135,29 +134,29 @@ mat:
state->doubleQueue.pop();
r++;
}
strcpy($$, $ID);
strcpy($$, $3);
}
;
sample:
OPEN SAMPLE ID INT mats CLOSE SAMPLE
{
const unsigned int nSample = $INT;
const unsigned int nSample = $4, os = DMatSample::offset;
if (state->dMatQueue.size() != nSample + DMatSample::offset)
if (state->dMatQueue.size() != nSample + os)
{
LATAN_ERROR(Size, "sample '" + *state->streamName + ":" + $ID +
LATAN_ERROR(Size, "sample '" + *state->streamName + ":" + $3 +
"' has a wrong size");
}
state->dMatSampleBuf.resize(nSample);
state->dMatSampleBuf[central] = state->dMatQueue.front();
state->dMatQueue.pop();
for (int i = 0; i < $INT; ++i)
for (unsigned int i = 0; i < nSample; ++i)
{
state->dMatSampleBuf[i] = state->dMatQueue.front();
state->dMatQueue.pop();
}
strcpy($$, $ID);
strcpy($$, $3);
}
rg_state:
@ -166,14 +165,14 @@ rg_state:
if (state->intQueue.size() != RLXG_STATE_SIZE)
{
LATAN_ERROR(Size, "random generator state '" + *state->streamName
+ ":" + $ID + "' has a wrong size");
+ ":" + $3 + "' has a wrong size");
}
for (Index i = 0; i < RLXG_STATE_SIZE; ++i)
{
state->stateBuf[i] = state->intQueue.front();
state->intQueue.pop();
}
strcpy($$, $ID);
strcpy($$, $3);
}
;
@ -183,13 +182,13 @@ mats:
;
floats:
floats FLOAT {state->doubleQueue.push($FLOAT);}
| floats INT {state->doubleQueue.push(static_cast<double>($INT));}
| FLOAT {state->doubleQueue.push($FLOAT);}
| INT {state->doubleQueue.push(static_cast<double>($INT));}
floats FLOAT {state->doubleQueue.push($2);}
| floats INT {state->doubleQueue.push(static_cast<double>($2));}
| FLOAT {state->doubleQueue.push($1);}
| INT {state->doubleQueue.push(static_cast<double>($1));}
;
ints:
ints INT {state->intQueue.push($INT);}
| INT {state->intQueue.push($INT);}
ints INT {state->intQueue.push($2);}
| INT {state->intQueue.push($1);}
;

View File

@ -61,7 +61,7 @@ Index Chi2Function::getNDof(void) const
}
return data_.getYDim()*data_.getNFitPoint() - nPar_;
};
}
Index Chi2Function::getNPar(void) const
{
@ -71,7 +71,7 @@ Index Chi2Function::getNPar(void) const
}
return nPar_;
};
}
void Chi2Function::setModel(const DoubleModel &model, const Index j)
{

View File

@ -21,14 +21,16 @@
#include <LatAnalyze/includes.hpp>
using namespace std;
using namespace Latan;
/******************************************************************************
* DMat implementation *
******************************************************************************/
// IO //////////////////////////////////////////////////////////////////////////
template <>
IoObject::IoType Mat<double>::getType(void) const
namespace Latan
{
return IoType::dMat;
template <>
IoObject::IoType Mat<double>::getType(void) const
{
return IoType::dMat;
}
}

View File

@ -21,10 +21,12 @@
#include <LatAnalyze/includes.hpp>
using namespace std;
using namespace Latan;
template <>
IoObject::IoType MatSample<double>::getType(void) const
namespace Latan
{
return IoType::dMatSample;
template <>
IoObject::IoType MatSample<double>::getType(void) const
{
return IoType::dMatSample;
}
}

View File

@ -32,11 +32,9 @@
#if (defined __INTEL_COMPILER)
#pragma warning disable 1682 2259
#elif (defined __GNUC__)||(defined __clang__)
#pragma GCC diagnostic ignored "-Wshorten-64-to-32"
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wsign-conversion"
#pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wdeprecated-register"
#pragma GCC diagnostic ignored "-Wunused-function"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#endif

View File

@ -27,7 +27,6 @@
#if (defined __INTEL_COMPILER)
#pragma warning disable 1682 2259
#elif (defined __GNUC__)||(defined __clang__)
#pragma GCC diagnostic ignored "-Wshorten-64-to-32"
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wsign-conversion"
#endif
@ -37,7 +36,7 @@
%}
%pure-parser
%name-prefix "_math_"
%name-prefix = "_math_"
%locations
%defines
%error-verbose
@ -105,7 +104,7 @@ stmt:
| expr ';'
{$$ = nullptr; _math_warning(&yylloc, state, "useless statement removed");}
| ID '=' expr ';'
{$$ = new AssignNode("="); $$->pushArg(new VarNode($ID)); $$->pushArg($3);}
{$$ = new AssignNode("="); $$->pushArg(new VarNode($1)); $$->pushArg($3);}
| RETURN expr ';'
{$$ = new ReturnNode("return"); $$->pushArg($2);}
| '{' stmt_list '}'
@ -121,9 +120,9 @@ stmt_list:
expr:
FLOAT
{$$ = new CstNode($FLOAT);}
{$$ = new CstNode($1);}
| ID
{$$ = new VarNode($ID);}
{$$ = new VarNode($1);}
| '-' expr %prec UMINUS
{$$ = new MathOpNode("-"); $$->pushArg($2);}
| expr '+' expr
@ -139,7 +138,7 @@ expr:
| '(' expr ')'
{$$ = $2;}
| ID '(' func_args ')'
{$$ = $3; $$->setName($ID);}
{$$ = $3; $$->setName($1);}
;
func_args:

View File

@ -20,7 +20,6 @@
#include <LatAnalyze/MinuitMinimizer.hpp>
#include <LatAnalyze/includes.hpp>
#pragma GCC diagnostic ignored "-Wdeprecated-register"
#pragma GCC diagnostic ignored "-Wconversion"
#include <Minuit2/FCNBase.h>
@ -34,9 +33,6 @@
#include <Minuit2/SimplexMinimizer.h>
#include <Minuit2/VariableMetricMinimizer.h>
#pragma GCC diagnostic warning "-Wdeprecated-register"
#pragma GCC diagnostic warning "-Wconversion"
using namespace std;
using namespace ROOT;
using namespace Minuit2;

View File

@ -20,6 +20,8 @@
#include <LatAnalyze/RandGen.hpp>
#include <LatAnalyze/includes.hpp>
#pragma GCC diagnostic ignored "-Wfloat-conversion"
#ifndef RLXD_LEVEL
#define RLXD_LEVEL 1
#endif

View File

@ -74,7 +74,6 @@ namespace ReducOp
inline T tensProd(const T &v1, const T &v2);
template <typename T>
inline T sum(const T &a, const T &b);
// matrix specializations
}
// Sample types
@ -233,42 +232,45 @@ T StatArray<T, os>::correlationMatrix(const Index pos, const Index n) const
}
// reduction operations ////////////////////////////////////////////////////////
template <typename T>
inline T ReducOp::sum(const T &a, const T &b)
namespace ReducOp
{
return a + b;
}
template <typename T>
inline T ReducOp::prod(const T &a, const T &b)
{
return a*b;
}
template <typename T>
inline T ReducOp::tensProd(const T &v1 __unused, const T &v2 __unused)
{
LATAN_ERROR(Implementation,
"tensorial product not implemented for this type");
}
template <>
inline Mat<double> ReducOp::prod(const Mat<double> &a, const Mat<double> &b)
{
return a.cwiseProduct(b);
}
template <>
inline Mat<double> ReducOp::tensProd(const Mat<double> &v1,
const Mat<double> &v2)
{
if ((v1.cols() != 1)||(v2.cols() != 1))
template <typename T>
inline T sum(const T &a, const T &b)
{
LATAN_ERROR(Size,
"tensorial product is only valid with column vectors");
return a + b;
}
template <typename T>
inline T prod(const T &a, const T &b)
{
return a*b;
}
template <typename T>
inline T tensProd(const T &v1 __unused, const T &v2 __unused)
{
LATAN_ERROR(Implementation,
"tensorial product not implemented for this type");
}
template <>
inline Mat<double> prod(const Mat<double> &a, const Mat<double> &b)
{
return a.cwiseProduct(b);
}
template <>
inline Mat<double> tensProd(const Mat<double> &v1,
const Mat<double> &v2)
{
if ((v1.cols() != 1)||(v2.cols() != 1))
{
LATAN_ERROR(Size,
"tensorial product is only valid with column vectors");
}
return v1*v2.transpose();
}
return v1*v2.transpose();
}
END_LATAN_NAMESPACE

View File

@ -215,7 +215,6 @@ SampleFitResult XYSampleData::fit(Minimizer &minimizer, const DVec &init,
const Index nSample = x_.size();
FitResult sampleResult;
SampleFitResult result;
bool initChi2;
DVec initBuf = init;
result.resize(nSample);
@ -235,9 +234,6 @@ SampleFitResult XYSampleData::fit(Minimizer &minimizer, const DVec &init,
// set data
setDataToSample(s);
// initialize chi^2 only once
initChi2 = (s == central);
// fit
sampleResult = data_.fit(minimizer, initBuf, modelVector);
if (s == central)

View File

@ -85,7 +85,7 @@ int main(int argc, char *argv[])
// data loading ////////////////////////////////////////////////////////////
vector<DMatSample> sample(n);
Index nSample;
Index nSample = 0;
cout << "-- loading data..." << endl;
for (unsigned int i = 0; i < n; ++i)