diff --git a/basicmath.cpp b/basicmath.cpp index 1cf1b7dc0a6a4d3cc3abbf8600481cad9ef066ad..389c55d518d619708b0d1e17ce8ff60fe11b9666 100644 --- a/basicmath.cpp +++ b/basicmath.cpp @@ -121,10 +121,10 @@ std::vector<eis::DataPoint> eis::rescale(const std::vector<eis::DataPoint>& data std::vector<eis::DataPoint> output(outputSize); for(size_t i = 0; i < output.size(); ++i) { - double position = static_cast<double>(i) / (output.size()-1); - double sourcePosF = (data.size()-1)*position; + fvalue position = static_cast<double>(i) / (output.size()-1); + fvalue sourcePosF = (data.size()-1)*position; size_t sourcePos = (data.size()-1)*position; - double frac = sourcePosF - sourcePos; + fvalue frac = sourcePosF - sourcePos; output[i].im = data[sourcePos].im*(1-frac) + data[sourcePos+1].im*frac; output[i].omega = data[sourcePos].omega*(1-frac) + data[sourcePos+1].omega*frac; } diff --git a/eisgenerator/eistype.h b/eisgenerator/eistype.h index ae87ff97dccf6da75095e9838e7254d9006ef86b..161037061e6b1aefb09917f624e836fd548f003b 100644 --- a/eisgenerator/eistype.h +++ b/eisgenerator/eistype.h @@ -5,7 +5,7 @@ #include <cmath> #include <filesystem> -typedef double fvalue; +typedef float fvalue; namespace eis { diff --git a/eistype.cpp b/eistype.cpp index 9fa86353b6da4796a87ce557957fe210bca57c36..ea4f9a9fcf8d72a71c1d10900d1441e35115c45c 100644 --- a/eistype.cpp +++ b/eistype.cpp @@ -53,7 +53,14 @@ EisSpectra eis::loadFromDisk(const std::filesystem::path& path) tokens = tokenize(line, ','); if(tokens.size() != 3) throw file_error("invalid line in " + path.string() + ": " + line); - out.data.push_back(DataPoint({std::stod(tokens[1]), std::stod(tokens[2])}, std::stod(tokens[0]))); + + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wnarrowing" + if constexpr (std::is_same<fvalue, double>::value) + out.data.push_back(DataPoint({std::stod(tokens[1]), std::stod(tokens[2])}, std::stod(tokens[0]))); + else + out.data.push_back(DataPoint({std::stof(tokens[1]), std::stof(tokens[2])}, std::stof(tokens[0]))); + #pragma GCC diagnostic pop } file.close();