From 389a52374c619f2ca75dd8cf436dab32ad2cdc8b Mon Sep 17 00:00:00 2001 From: Antonin Portelli Date: Sat, 23 May 2015 14:44:43 +0100 Subject: [PATCH] portability fixes --- lib/AsciiLexer.lpp | 5 +++++ lib/AsciiParser.ypp | 4 ++++ lib/Chi2Function.cpp | 20 +++++++++++++------- lib/Dataset.hpp | 10 ---------- lib/File.hpp | 2 +- lib/MathLexer.lpp | 5 +++++ lib/MathParser.ypp | 4 ++++ 7 files changed, 32 insertions(+), 18 deletions(-) diff --git a/lib/AsciiLexer.lpp b/lib/AsciiLexer.lpp index 7d266a9..c679e56 100644 --- a/lib/AsciiLexer.lpp +++ b/lib/AsciiLexer.lpp @@ -28,6 +28,10 @@ #include #include #include "AsciiParser.hpp" + + #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" @@ -35,6 +39,7 @@ #pragma GCC diagnostic ignored "-Wdeprecated-register" #pragma GCC diagnostic ignored "-Wunused-function" #pragma GCC diagnostic ignored "-Wunused-parameter" + #endif using namespace std; using namespace Latan; diff --git a/lib/AsciiParser.ypp b/lib/AsciiParser.ypp index 4ef0fe0..886e880 100644 --- a/lib/AsciiParser.ypp +++ b/lib/AsciiParser.ypp @@ -28,9 +28,13 @@ #include #include + #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 using namespace std; using namespace Latan; diff --git a/lib/Chi2Function.cpp b/lib/Chi2Function.cpp index f21c8c4..20c7c73 100644 --- a/lib/Chi2Function.cpp +++ b/lib/Chi2Function.cpp @@ -75,9 +75,11 @@ Index Chi2Function::getNPar(void) const void Chi2Function::setModel(const DoubleModel &model, const Index j) { + typedef decltype(model_.size()) size_type; + if (static_cast(model_.size()) != data_.getYDim()) { - model_.resize(static_cast(data_.getYDim())); + model_.resize(static_cast(data_.getYDim())); } if (model.getNArg() != data_.getXDim()) { @@ -93,17 +95,19 @@ void Chi2Function::setModel(const DoubleModel &model, const Index j) } } } - model_[static_cast(j)] = &model; - nPar_ = model.getNPar(); + model_[static_cast(j)] = &model; + nPar_ = model.getNPar(); } void Chi2Function::setModel(const vector &modelVector) { + typedef decltype(model_.size()) size_type; + if (static_cast(model_.size()) != data_.getYDim()) { - model_.resize(static_cast(data_.getYDim())); + model_.resize(static_cast(data_.getYDim())); } - if (modelVector.size() != static_cast(data_.getYDim())) + if (modelVector.size() != static_cast(data_.getYDim())) { LATAN_ERROR(Size, "number of models and y-dimension mismatch"); } @@ -117,7 +121,7 @@ void Chi2Function::setModel(const vector &modelVector) { LATAN_ERROR(Size, "model number of arguments and x-dimension mismatch"); } - model_[static_cast(j)] = modelVector[j]; + model_[static_cast(j)] = modelVector[j]; if (modelVector[j]->getNPar() != modelVector[0]->getNPar()) { LATAN_ERROR(Size, "model number of parameter mismatch"); @@ -236,6 +240,8 @@ void Chi2Function::initBuffer(void) const // function call /////////////////////////////////////////////////////////////// double Chi2Function::operator()(const double *arg) const { + typedef decltype(model_.size()) size_type; + if (!model_[0]) { LATAN_ERROR(Memory, "null model"); @@ -259,7 +265,7 @@ double Chi2Function::operator()(const double *arg) const for (Index j = 0; j < yDim; ++j) FOR_VEC(buffer_->dInd, k) { - const DoubleModel *f = model_[static_cast(j)]; + const DoubleModel *f = model_[static_cast(j)]; double f_jk, y_jk = data_.y(j, buffer_->dInd(k)); if (!f) diff --git a/lib/Dataset.hpp b/lib/Dataset.hpp index 5b3b864..7b8dc09 100644 --- a/lib/Dataset.hpp +++ b/lib/Dataset.hpp @@ -39,8 +39,6 @@ public: // constructors Dataset(void) = default; Dataset(const Index size); - template - Dataset(const std::string &listFileName, const std::string &dataName); EIGEN_EXPR_CTOR(Dataset, Dataset, StatArray, ArrayExpr) // destructor virtual ~Dataset(void) = default; @@ -62,14 +60,6 @@ template Dataset::Dataset(const Index size) : StatArray(size) {} - -template -template -Dataset::Dataset(const std::string &listFileName, - const std::string &dataName) -{ - load(listFileName, dataName); -} // IO ////////////////////////////////////////////////////////////////////////// template diff --git a/lib/File.hpp b/lib/File.hpp index 4a34fd4..31b4e89 100644 --- a/lib/File.hpp +++ b/lib/File.hpp @@ -144,7 +144,7 @@ void Io::save(const IoT &data, const std::string &fileName, FileType file(fileName, mode); std::string realName = (name.empty()) ? fileName : name; - file.template save(data, realName); + file.save(data, realName); } END_LATAN_NAMESPACE diff --git a/lib/MathLexer.lpp b/lib/MathLexer.lpp index 2e09ae5..4666f4b 100644 --- a/lib/MathLexer.lpp +++ b/lib/MathLexer.lpp @@ -28,6 +28,10 @@ #include #include #include "MathParser.hpp" + + #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" @@ -35,6 +39,7 @@ #pragma GCC diagnostic ignored "-Wdeprecated-register" #pragma GCC diagnostic ignored "-Wunused-function" #pragma GCC diagnostic ignored "-Wunused-parameter" + #endif using namespace std; using namespace Latan; diff --git a/lib/MathParser.ypp b/lib/MathParser.ypp index 4ad3734..0ea639a 100644 --- a/lib/MathParser.ypp +++ b/lib/MathParser.ypp @@ -24,9 +24,13 @@ #include #include + #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 using namespace std; using namespace Latan;