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

compiler compatibility fixes (clang, GCC 5, Intel 2016)

This commit is contained in:
Antonin Portelli 2016-04-07 20:10:47 +01:00
parent 19de6290d1
commit d1666a1e75
13 changed files with 68 additions and 95 deletions

View File

@ -27,43 +27,34 @@ m4_ifdef([AM_PROG_AR],[AM_PROG_AR])
LT_INIT
# Options
AC_ARG_ENABLE([SSE],
[AS_HELP_STRING([--enable-SSE],
[compiles SSE version of ranlux random generator])],
[AC_DEFINE([HAVE_SSE],
[1],
[Define to 1 if your CPU support SSE instructions.])])
AC_ARG_WITH([gsl],
[AS_HELP_STRING([--with-gsl=prefix],
[try this for a non-standard install prefix of the GSL library])],
[AM_CFLAGS="$AM_CFLAGS -I$with_gsl/include"]
[AM_CXXFLAGS="$AM_CXXFLAGS -I$with_gsl/include"]
[AM_LDFLAGS="$AM_LDFLAGS -L$with_gsl/lib"])
AC_ARG_WITH([Minuit2],
[AS_HELP_STRING([--with-Minuit2=prefix],
AC_ARG_WITH([minuit],
[AS_HELP_STRING([--with-minuit=prefix],
[try this for a non-standard install prefix of the Minuit2 library])],
[AM_CFLAGS="$AM_CFLAGS -I$with_Minuit2/include"]
[AM_CXXFLAGS="$AM_CXXFLAGS -I$with_Minuit2/include"]
[AM_LDFLAGS="$AM_LDFLAGS -L$with_Minuit2/lib"])
[AM_CXXFLAGS="$AM_CXXFLAGS -I$with_minuit/include"]
[AM_LDFLAGS="$AM_LDFLAGS -L$with_minuit/lib"])
AC_ARG_WITH([nlopt],
[AS_HELP_STRING([--with-nlopt=prefix],
[try this for a non-standard install prefix of the nlopt library])],
[AM_CFLAGS="$AM_CFLAGS -I$with_nlopt/include"]
[try this for a non-standard install prefix of the NLopt library])],
[AM_CXXFLAGS="$AM_CXXFLAGS -I$with_nlopt/include"]
[AM_LDFLAGS="$AM_LDFLAGS -L$with_nlopt/lib"])
AC_ARG_WITH([LatCore],
[AS_HELP_STRING([--with-LatCore=prefix],
AC_ARG_WITH([hdf5],
[AS_HELP_STRING([--with-hdf5=prefix],
[try this for a non-standard install prefix of the HDF5 library])],
[AM_CXXFLAGS="$AM_CXXFLAGS -I$with_hdf5/include"]
[AM_LDFLAGS="$AM_LDFLAGS -L$with_hdf5/lib"])
AC_ARG_WITH([latcore],
[AS_HELP_STRING([--with-latcore=prefix],
[use this option for a non-standard install prefix of the LatCore library])],
[AM_CXXFLAGS="$AM_CXXFLAGS -I$with_LatCore/include"]
[AM_LDFLAGS="$AM_LDFLAGS -L$with_LatCore/lib"])
AX_LIB_HDF5()
if test x$with_hdf5 = xno; then
AC_MSG_ERROR([HDF5 library not found])
fi
CFLAGS="$AM_CFLAGS $HDF5_CFLAGS $CFLAGS"
CXXFLAGS="$AM_CXXFLAGS $HDF5_CPPFLAGS $CXXFLAGS"
LDFLAGS="$AM_LDFLAGS $HDF5_LDFLAGS $LDFLAGS"
LIBS="$LIBS $HDF5_LIBS -lhdf5_cpp"
[AM_CXXFLAGS="$AM_CXXFLAGS -I$with_latcore/include"]
[AM_LDFLAGS="$AM_LDFLAGS -L$with_latcore/lib"])
CFLAGS="$AM_CFLAGS $CFLAGS"
CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS"
LDFLAGS="$AM_LDFLAGS $LDFLAGS"
# Get compilers informations
AX_COMPILER_VENDOR
@ -97,6 +88,13 @@ AC_CHECK_LIB([nlopt_cxx],[nlopt_create],
[have_nlopt=true]
[LIBS="$LIBS -lnlopt_cxx"],[])
AM_CONDITIONAL([HAVE_NLOPT], [test x$have_nlopt = xtrue])
AC_CHECK_LIB([hdf5_cpp],[H5Fopen],
[AC_DEFINE([HAVE_HDF5],
[1],
[Define to 1 if you have the `HDF5' library (-lhdf5_cpp).])]
[have_hdf5=true]
[LIBS="$LIBS -lhdf5_cpp"],[],[-lhdf5])
AM_CONDITIONAL([HAVE_HDF5], [test x$have_hdf5 = xtrue])
AC_CHECK_LIB([LatCore],[_ZN7LatCore12testFunctionEv],[],
[AC_MSG_ERROR([LatCore library not found])])
SAVED_LDFLAGS=$LDFLAGS

View File

@ -1,8 +1,8 @@
if CXX_GNU
COM_CXXFLAGS = -Wall -W -pedantic
COM_CXXFLAGS = -Wall -W -pedantic -Wno-deprecated-declarations
else
if CXX_INTEL
COM_CXXFLAGS = -Wall
COM_CXXFLAGS = -wd1682 -Wall
endif
endif

View File

@ -27,17 +27,7 @@
%{
#include <LatAnalyze/AsciiFile.hpp>
#include "AsciiParser.hpp"
#if (defined __INTEL_COMPILER)
#pragma warning disable 1682 2259
#elif (defined __GNUC__)||(defined __clang__)
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wsign-conversion"
#pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wunused-function"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#endif
using namespace std;
using namespace Latan;

View File

@ -23,13 +23,6 @@
#include <LatAnalyze/Mat.hpp>
#include <LatAnalyze/MatSample.hpp>
#if (defined __INTEL_COMPILER)
#pragma warning disable 1682 2259
#elif (defined __GNUC__)||(defined __clang__)
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wsign-conversion"
#endif
using namespace std;
using namespace Latan;

View File

@ -23,6 +23,8 @@
using namespace std;
using namespace Latan;
PlaceHolder Latan::_;
const string Env::fullName = PACKAGE_STRING;
const string Env::name = PACKAGE_NAME;
const string Env::version = PACKAGE_VERSION;

View File

@ -1,9 +1,9 @@
COM_CXXFLAGS = -Wall
if CXX_GNU
COM_CXXFLAGS += -W -pedantic
COM_CXXFLAGS += -W -pedantic -Wno-deprecated-declarations
else
if CXX_INTEL
COM_CXXFLAGS +=
COM_CXXFLAGS += -wd1682
endif
endif
@ -12,12 +12,19 @@ AM_YFLAGS = -d
BUILT_SOURCES = AsciiParser.hpp MathParser.hpp
lib_LTLIBRARIES = libLatAnalyze.la
lib_LTLIBRARIES = libLatAnalyze.la
noinst_LTLIBRARIES = libLexers.la
libLexers_la_SOURCES = AsciiLexer.lpp MathLexer.lpp
if CXX_GNU
libLexers_la_CXXFLAGS = $(COM_CXXFLAGS) -Wno-unused-function
else
libLexers_la_CXXFLAGS = $(COM_CXXFLAGS)
endif
libLatAnalyze_la_SOURCES = \
AsciiFile.cpp \
AsciiParser.ypp \
AsciiLexer.lpp \
CompiledFunction.cpp \
CompiledModel.cpp \
Derivative.cpp \
@ -36,7 +43,6 @@ libLatAnalyze_la_SOURCES = \
Math.cpp \
MathInterpreter.cpp \
MathParser.ypp \
MathLexer.lpp \
Minimizer.cpp \
Model.cpp \
Plot.cpp \
@ -89,5 +95,6 @@ if HAVE_NLOPT
libLatAnalyze_la_HEADERS += NloptMinimizer.hpp
endif
libLatAnalyze_la_CXXFLAGS = $(COM_CXXFLAGS)
libLatAnalyze_la_LIBADD = libLexers.la
ACLOCAL_AMFLAGS = -I .buildutils/m4

View File

@ -411,7 +411,7 @@ void ExprNode::pushArg(ExprNode *node)
// ExprNode operators //////////////////////////////////////////////////////////
const ExprNode &ExprNode::operator[](const Index i) const
{
return *arg_[static_cast<unsigned int>(i)];
return *arg_[i];
}
ostream &Latan::operator<<(ostream &out, const ExprNode &n)
@ -451,7 +451,7 @@ try\
}\
catch (out_of_range)\
{\
address = static_cast<unsigned int>((table).size());\
address = (table).size();\
(table)[(name)] = address;\
}\
@ -582,7 +582,7 @@ MathInterpreter::MathInterpreter(const std::string &code)
// access //////////////////////////////////////////////////////////////////////
const Instruction * MathInterpreter::operator[](const Index i) const
{
return program_[static_cast<unsigned int>(i)].get();
return program_[i].get();
}
const ExprNode * MathInterpreter::getAST(void) const

View File

@ -27,17 +27,7 @@
%{
#include <LatAnalyze/MathInterpreter.hpp>
#include "MathParser.hpp"
#if (defined __INTEL_COMPILER)
#pragma warning disable 1682 2259
#elif (defined __GNUC__)||(defined __clang__)
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wsign-conversion"
#pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wunused-function"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#endif
using namespace std;
using namespace Latan;

View File

@ -21,13 +21,6 @@
#include <LatAnalyze/Global.hpp>
#include <LatAnalyze/MathInterpreter.hpp>
#if (defined __INTEL_COMPILER)
#pragma warning disable 1682 2259
#elif (defined __GNUC__)||(defined __clang__)
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wsign-conversion"
#endif
using namespace std;
using namespace Latan;
%}

View File

@ -54,9 +54,8 @@ const DVec & MinuitMinimizer::operator()(const DoubleFunction &f)
using namespace Minuit2;
DVec &x = getState();
int printLevel;
EMinimizerType minuitAlg;
unique_ptr<Math::Minimizer> min;
int printLevel = 0;
EMinimizerType minuitAlg = kCombined;
// convert Latan parameters to Minuit parameters
switch (getVerbosity())
@ -91,18 +90,19 @@ const DVec & MinuitMinimizer::operator()(const DoubleFunction &f)
}
// create and set minimizer
min.reset(new Minuit2Minimizer(minuitAlg));
min->SetStrategy(2);
min->SetMaxFunctionCalls(getMaxIteration());
min->SetTolerance(getPrecision());
min->SetPrintLevel(printLevel);
Minuit2Minimizer min(minuitAlg);
min.SetStrategy(2);
min.SetMaxFunctionCalls(getMaxIteration());
min.SetTolerance(getPrecision());
min.SetPrintLevel(printLevel);
// set function and variables
Math::Functor minuitF(f, x.size());
string name;
double val, step;
min->SetFunction(minuitF);
min.SetFunction(minuitF);
for (Index i = 0; i < x.size(); ++i)
{
name = f.varName().getName(i);
@ -110,20 +110,20 @@ const DVec & MinuitMinimizer::operator()(const DoubleFunction &f)
step = (fabs(x(i)) != 0.) ? initErr*fabs(x(i)) : 1.;
if (hasHighLimit(i) and !hasLowLimit(i))
{
min->SetUpperLimitedVariable(i, name, val, step, getHighLimit(i));
min.SetUpperLimitedVariable(i, name, val, step, getHighLimit(i));
}
else if (!hasHighLimit(i) and hasLowLimit(i))
{
min->SetLowerLimitedVariable(i, name, val, step, getLowLimit(i));
min.SetLowerLimitedVariable(i, name, val, step, getLowLimit(i));
}
else if (hasHighLimit(i) and hasLowLimit(i))
{
min->SetLimitedVariable(i, name, val, step, getLowLimit(i),
getHighLimit(i));
min.SetLimitedVariable(i, name, val, step, getLowLimit(i),
getHighLimit(i));
}
else
{
min->SetVariable(i, name, val, step);
min.SetVariable(i, name, val, step);
}
}
@ -138,8 +138,8 @@ const DVec & MinuitMinimizer::operator()(const DoubleFunction &f)
cout << "========== Minuit minimization, pass #" << n + 1;
cout << " =========" << endl;
}
min->Minimize();
status = min->Status();
min.Minimize();
status = min.Status();
n++;
} while (status and (n < getMaxPass()));
if (getVerbosity() >= Verbosity::Normal)
@ -165,7 +165,7 @@ const DVec & MinuitMinimizer::operator()(const DoubleFunction &f)
// save and return result
for (Index i = 0; i < x.size(); ++i)
{
x(i) = min->X()[i];
x(i) = min.X()[i];
}
return x;

View File

@ -65,14 +65,14 @@ double SampleFitResult::getPValue(const Index s) const
const DoubleFunction & SampleFitResult::getModel(const Index s,
const Index j) const
{
return model_[static_cast<unsigned int>(j)][s];
return model_[j][s];
}
const DoubleFunctionSample & SampleFitResult::getModel(
const PlaceHolder ph __dumb,
const Index j) const
{
return model_[static_cast<unsigned int>(j)];
return model_[j];
}
FitResult SampleFitResult::getFitResult(const Index s) const
@ -292,7 +292,7 @@ SampleFitResult XYSampleData::fit(std::vector<Minimizer *> &minimizer,
}
}
result.nPar_ = sampleResult.getNPar();
result.nDof_ = sampleResult.getNDof();
result.nDof_ = sampleResult.nDof_;
result.parName_ = sampleResult.parName_;
return result;

View File

@ -57,7 +57,7 @@ double FitResult::getPValue(void) const
const DoubleFunction & FitResult::getModel(const Index j) const
{
return model_[static_cast<unsigned int>(j)];
return model_[j];
}
// IO //////////////////////////////////////////////////////////////////////////

View File

@ -1,8 +1,8 @@
if CXX_GNU
COM_CXXFLAGS = -Wall -W -pedantic
COM_CXXFLAGS = -Wall -W -pedantic -Wno-deprecated-declarations
else
if CXX_INTEL
COM_CXXFLAGS = -Wall
COM_CXXFLAGS = -wd1682 -Wall
endif
endif