mirror of
https://github.com/aportelli/LatAnalyze.git
synced 2025-04-11 03:20:46 +01:00
code cleaning and GCC compatibility
This commit is contained in:
parent
3e6b0edce1
commit
cb45b34ddc
@ -32,11 +32,9 @@
|
|||||||
#if (defined __INTEL_COMPILER)
|
#if (defined __INTEL_COMPILER)
|
||||||
#pragma warning disable 1682 2259
|
#pragma warning disable 1682 2259
|
||||||
#elif (defined __GNUC__)||(defined __clang__)
|
#elif (defined __GNUC__)||(defined __clang__)
|
||||||
#pragma GCC diagnostic ignored "-Wshorten-64-to-32"
|
|
||||||
#pragma GCC diagnostic ignored "-Wconversion"
|
#pragma GCC diagnostic ignored "-Wconversion"
|
||||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
||||||
#pragma GCC diagnostic ignored "-Wsign-compare"
|
#pragma GCC diagnostic ignored "-Wsign-compare"
|
||||||
#pragma GCC diagnostic ignored "-Wdeprecated-register"
|
|
||||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||||
#endif
|
#endif
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
#if (defined __INTEL_COMPILER)
|
#if (defined __INTEL_COMPILER)
|
||||||
#pragma warning disable 1682 2259
|
#pragma warning disable 1682 2259
|
||||||
#elif (defined __GNUC__)||(defined __clang__)
|
#elif (defined __GNUC__)||(defined __clang__)
|
||||||
#pragma GCC diagnostic ignored "-Wshorten-64-to-32"
|
|
||||||
#pragma GCC diagnostic ignored "-Wconversion"
|
#pragma GCC diagnostic ignored "-Wconversion"
|
||||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
||||||
#endif
|
#endif
|
||||||
@ -48,7 +47,7 @@
|
|||||||
%}
|
%}
|
||||||
|
|
||||||
%pure-parser
|
%pure-parser
|
||||||
%name-prefix "_Ascii_"
|
%name-prefix = "_Ascii_"
|
||||||
%locations
|
%locations
|
||||||
%defines
|
%defines
|
||||||
%error-verbose
|
%error-verbose
|
||||||
@ -117,12 +116,12 @@ data:
|
|||||||
mat:
|
mat:
|
||||||
OPEN MAT ID INT floats CLOSE 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;
|
Index i, j, r = 0;
|
||||||
|
|
||||||
if (state->doubleQueue.size() != nRow*nCol)
|
if (state->doubleQueue.size() != nRow*nCol)
|
||||||
{
|
{
|
||||||
LATAN_ERROR(Size, "matrix '" + *state->streamName + ":" + $ID +
|
LATAN_ERROR(Size, "matrix '" + *state->streamName + ":" + $3 +
|
||||||
"' has a wrong size");
|
"' has a wrong size");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,29 +134,29 @@ mat:
|
|||||||
state->doubleQueue.pop();
|
state->doubleQueue.pop();
|
||||||
r++;
|
r++;
|
||||||
}
|
}
|
||||||
strcpy($$, $ID);
|
strcpy($$, $3);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
sample:
|
sample:
|
||||||
OPEN SAMPLE ID INT mats CLOSE 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");
|
"' has a wrong size");
|
||||||
}
|
}
|
||||||
state->dMatSampleBuf.resize(nSample);
|
state->dMatSampleBuf.resize(nSample);
|
||||||
state->dMatSampleBuf[central] = state->dMatQueue.front();
|
state->dMatSampleBuf[central] = state->dMatQueue.front();
|
||||||
state->dMatQueue.pop();
|
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->dMatSampleBuf[i] = state->dMatQueue.front();
|
||||||
state->dMatQueue.pop();
|
state->dMatQueue.pop();
|
||||||
}
|
}
|
||||||
strcpy($$, $ID);
|
strcpy($$, $3);
|
||||||
}
|
}
|
||||||
|
|
||||||
rg_state:
|
rg_state:
|
||||||
@ -166,14 +165,14 @@ rg_state:
|
|||||||
if (state->intQueue.size() != RLXG_STATE_SIZE)
|
if (state->intQueue.size() != RLXG_STATE_SIZE)
|
||||||
{
|
{
|
||||||
LATAN_ERROR(Size, "random generator state '" + *state->streamName
|
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)
|
for (Index i = 0; i < RLXG_STATE_SIZE; ++i)
|
||||||
{
|
{
|
||||||
state->stateBuf[i] = state->intQueue.front();
|
state->stateBuf[i] = state->intQueue.front();
|
||||||
state->intQueue.pop();
|
state->intQueue.pop();
|
||||||
}
|
}
|
||||||
strcpy($$, $ID);
|
strcpy($$, $3);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -183,13 +182,13 @@ mats:
|
|||||||
;
|
;
|
||||||
|
|
||||||
floats:
|
floats:
|
||||||
floats FLOAT {state->doubleQueue.push($FLOAT);}
|
floats FLOAT {state->doubleQueue.push($2);}
|
||||||
| floats INT {state->doubleQueue.push(static_cast<double>($INT));}
|
| floats INT {state->doubleQueue.push(static_cast<double>($2));}
|
||||||
| FLOAT {state->doubleQueue.push($FLOAT);}
|
| FLOAT {state->doubleQueue.push($1);}
|
||||||
| INT {state->doubleQueue.push(static_cast<double>($INT));}
|
| INT {state->doubleQueue.push(static_cast<double>($1));}
|
||||||
;
|
;
|
||||||
|
|
||||||
ints:
|
ints:
|
||||||
ints INT {state->intQueue.push($INT);}
|
ints INT {state->intQueue.push($2);}
|
||||||
| INT {state->intQueue.push($INT);}
|
| INT {state->intQueue.push($1);}
|
||||||
;
|
;
|
||||||
|
@ -61,7 +61,7 @@ Index Chi2Function::getNDof(void) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
return data_.getYDim()*data_.getNFitPoint() - nPar_;
|
return data_.getYDim()*data_.getNFitPoint() - nPar_;
|
||||||
};
|
}
|
||||||
|
|
||||||
Index Chi2Function::getNPar(void) const
|
Index Chi2Function::getNPar(void) const
|
||||||
{
|
{
|
||||||
@ -71,7 +71,7 @@ Index Chi2Function::getNPar(void) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
return nPar_;
|
return nPar_;
|
||||||
};
|
}
|
||||||
|
|
||||||
void Chi2Function::setModel(const DoubleModel &model, const Index j)
|
void Chi2Function::setModel(const DoubleModel &model, const Index j)
|
||||||
{
|
{
|
||||||
|
10
lib/Mat.cpp
10
lib/Mat.cpp
@ -21,14 +21,16 @@
|
|||||||
#include <LatAnalyze/includes.hpp>
|
#include <LatAnalyze/includes.hpp>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Latan;
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* DMat implementation *
|
* DMat implementation *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
// IO //////////////////////////////////////////////////////////////////////////
|
// IO //////////////////////////////////////////////////////////////////////////
|
||||||
template <>
|
namespace Latan
|
||||||
IoObject::IoType Mat<double>::getType(void) const
|
|
||||||
{
|
{
|
||||||
return IoType::dMat;
|
template <>
|
||||||
|
IoObject::IoType Mat<double>::getType(void) const
|
||||||
|
{
|
||||||
|
return IoType::dMat;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,10 +21,12 @@
|
|||||||
#include <LatAnalyze/includes.hpp>
|
#include <LatAnalyze/includes.hpp>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Latan;
|
|
||||||
|
|
||||||
template <>
|
namespace Latan
|
||||||
IoObject::IoType MatSample<double>::getType(void) const
|
|
||||||
{
|
{
|
||||||
return IoType::dMatSample;
|
template <>
|
||||||
|
IoObject::IoType MatSample<double>::getType(void) const
|
||||||
|
{
|
||||||
|
return IoType::dMatSample;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,11 +32,9 @@
|
|||||||
#if (defined __INTEL_COMPILER)
|
#if (defined __INTEL_COMPILER)
|
||||||
#pragma warning disable 1682 2259
|
#pragma warning disable 1682 2259
|
||||||
#elif (defined __GNUC__)||(defined __clang__)
|
#elif (defined __GNUC__)||(defined __clang__)
|
||||||
#pragma GCC diagnostic ignored "-Wshorten-64-to-32"
|
|
||||||
#pragma GCC diagnostic ignored "-Wconversion"
|
#pragma GCC diagnostic ignored "-Wconversion"
|
||||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
||||||
#pragma GCC diagnostic ignored "-Wsign-compare"
|
#pragma GCC diagnostic ignored "-Wsign-compare"
|
||||||
#pragma GCC diagnostic ignored "-Wdeprecated-register"
|
|
||||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||||
#endif
|
#endif
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
#if (defined __INTEL_COMPILER)
|
#if (defined __INTEL_COMPILER)
|
||||||
#pragma warning disable 1682 2259
|
#pragma warning disable 1682 2259
|
||||||
#elif (defined __GNUC__)||(defined __clang__)
|
#elif (defined __GNUC__)||(defined __clang__)
|
||||||
#pragma GCC diagnostic ignored "-Wshorten-64-to-32"
|
|
||||||
#pragma GCC diagnostic ignored "-Wconversion"
|
#pragma GCC diagnostic ignored "-Wconversion"
|
||||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
||||||
#endif
|
#endif
|
||||||
@ -37,7 +36,7 @@
|
|||||||
%}
|
%}
|
||||||
|
|
||||||
%pure-parser
|
%pure-parser
|
||||||
%name-prefix "_math_"
|
%name-prefix = "_math_"
|
||||||
%locations
|
%locations
|
||||||
%defines
|
%defines
|
||||||
%error-verbose
|
%error-verbose
|
||||||
@ -105,7 +104,7 @@ stmt:
|
|||||||
| expr ';'
|
| expr ';'
|
||||||
{$$ = nullptr; _math_warning(&yylloc, state, "useless statement removed");}
|
{$$ = nullptr; _math_warning(&yylloc, state, "useless statement removed");}
|
||||||
| ID '=' expr ';'
|
| ID '=' expr ';'
|
||||||
{$$ = new AssignNode("="); $$->pushArg(new VarNode($ID)); $$->pushArg($3);}
|
{$$ = new AssignNode("="); $$->pushArg(new VarNode($1)); $$->pushArg($3);}
|
||||||
| RETURN expr ';'
|
| RETURN expr ';'
|
||||||
{$$ = new ReturnNode("return"); $$->pushArg($2);}
|
{$$ = new ReturnNode("return"); $$->pushArg($2);}
|
||||||
| '{' stmt_list '}'
|
| '{' stmt_list '}'
|
||||||
@ -121,9 +120,9 @@ stmt_list:
|
|||||||
|
|
||||||
expr:
|
expr:
|
||||||
FLOAT
|
FLOAT
|
||||||
{$$ = new CstNode($FLOAT);}
|
{$$ = new CstNode($1);}
|
||||||
| ID
|
| ID
|
||||||
{$$ = new VarNode($ID);}
|
{$$ = new VarNode($1);}
|
||||||
| '-' expr %prec UMINUS
|
| '-' expr %prec UMINUS
|
||||||
{$$ = new MathOpNode("-"); $$->pushArg($2);}
|
{$$ = new MathOpNode("-"); $$->pushArg($2);}
|
||||||
| expr '+' expr
|
| expr '+' expr
|
||||||
@ -139,7 +138,7 @@ expr:
|
|||||||
| '(' expr ')'
|
| '(' expr ')'
|
||||||
{$$ = $2;}
|
{$$ = $2;}
|
||||||
| ID '(' func_args ')'
|
| ID '(' func_args ')'
|
||||||
{$$ = $3; $$->setName($ID);}
|
{$$ = $3; $$->setName($1);}
|
||||||
;
|
;
|
||||||
|
|
||||||
func_args:
|
func_args:
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
#include <LatAnalyze/MinuitMinimizer.hpp>
|
#include <LatAnalyze/MinuitMinimizer.hpp>
|
||||||
#include <LatAnalyze/includes.hpp>
|
#include <LatAnalyze/includes.hpp>
|
||||||
|
|
||||||
#pragma GCC diagnostic ignored "-Wdeprecated-register"
|
|
||||||
#pragma GCC diagnostic ignored "-Wconversion"
|
#pragma GCC diagnostic ignored "-Wconversion"
|
||||||
|
|
||||||
#include <Minuit2/FCNBase.h>
|
#include <Minuit2/FCNBase.h>
|
||||||
@ -34,9 +33,6 @@
|
|||||||
#include <Minuit2/SimplexMinimizer.h>
|
#include <Minuit2/SimplexMinimizer.h>
|
||||||
#include <Minuit2/VariableMetricMinimizer.h>
|
#include <Minuit2/VariableMetricMinimizer.h>
|
||||||
|
|
||||||
#pragma GCC diagnostic warning "-Wdeprecated-register"
|
|
||||||
#pragma GCC diagnostic warning "-Wconversion"
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace ROOT;
|
using namespace ROOT;
|
||||||
using namespace Minuit2;
|
using namespace Minuit2;
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
#include <LatAnalyze/RandGen.hpp>
|
#include <LatAnalyze/RandGen.hpp>
|
||||||
#include <LatAnalyze/includes.hpp>
|
#include <LatAnalyze/includes.hpp>
|
||||||
|
|
||||||
|
#pragma GCC diagnostic ignored "-Wfloat-conversion"
|
||||||
|
|
||||||
#ifndef RLXD_LEVEL
|
#ifndef RLXD_LEVEL
|
||||||
#define RLXD_LEVEL 1
|
#define RLXD_LEVEL 1
|
||||||
#endif
|
#endif
|
||||||
|
@ -74,7 +74,6 @@ namespace ReducOp
|
|||||||
inline T tensProd(const T &v1, const T &v2);
|
inline T tensProd(const T &v1, const T &v2);
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline T sum(const T &a, const T &b);
|
inline T sum(const T &a, const T &b);
|
||||||
// matrix specializations
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sample types
|
// Sample types
|
||||||
@ -233,42 +232,45 @@ T StatArray<T, os>::correlationMatrix(const Index pos, const Index n) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// reduction operations ////////////////////////////////////////////////////////
|
// reduction operations ////////////////////////////////////////////////////////
|
||||||
template <typename T>
|
namespace ReducOp
|
||||||
inline T ReducOp::sum(const T &a, const T &b)
|
|
||||||
{
|
{
|
||||||
return a + b;
|
template <typename T>
|
||||||
}
|
inline T sum(const T &a, const T &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))
|
|
||||||
{
|
{
|
||||||
LATAN_ERROR(Size,
|
return a + b;
|
||||||
"tensorial product is only valid with column vectors");
|
}
|
||||||
|
|
||||||
|
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
|
END_LATAN_NAMESPACE
|
||||||
|
@ -215,7 +215,6 @@ SampleFitResult XYSampleData::fit(Minimizer &minimizer, const DVec &init,
|
|||||||
const Index nSample = x_.size();
|
const Index nSample = x_.size();
|
||||||
FitResult sampleResult;
|
FitResult sampleResult;
|
||||||
SampleFitResult result;
|
SampleFitResult result;
|
||||||
bool initChi2;
|
|
||||||
DVec initBuf = init;
|
DVec initBuf = init;
|
||||||
|
|
||||||
result.resize(nSample);
|
result.resize(nSample);
|
||||||
@ -235,9 +234,6 @@ SampleFitResult XYSampleData::fit(Minimizer &minimizer, const DVec &init,
|
|||||||
// set data
|
// set data
|
||||||
setDataToSample(s);
|
setDataToSample(s);
|
||||||
|
|
||||||
// initialize chi^2 only once
|
|
||||||
initChi2 = (s == central);
|
|
||||||
|
|
||||||
// fit
|
// fit
|
||||||
sampleResult = data_.fit(minimizer, initBuf, modelVector);
|
sampleResult = data_.fit(minimizer, initBuf, modelVector);
|
||||||
if (s == central)
|
if (s == central)
|
||||||
|
@ -85,7 +85,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
// data loading ////////////////////////////////////////////////////////////
|
// data loading ////////////////////////////////////////////////////////////
|
||||||
vector<DMatSample> sample(n);
|
vector<DMatSample> sample(n);
|
||||||
Index nSample;
|
Index nSample = 0;
|
||||||
|
|
||||||
cout << "-- loading data..." << endl;
|
cout << "-- loading data..." << endl;
|
||||||
for (unsigned int i = 0; i < n; ++i)
|
for (unsigned int i = 0; i < n; ++i)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user