diff --git a/eisgenerator/eistype.h b/eisgenerator/eistype.h index a3a2060d10e1a9235debcbe20d1fde7e27267747..ae87ff97dccf6da75095e9838e7254d9006ef86b 100644 --- a/eisgenerator/eistype.h +++ b/eisgenerator/eistype.h @@ -61,7 +61,7 @@ class Range public: fvalue start; fvalue end; - size_t count; + size_t count = 0; size_t step = 0; bool log = false; @@ -77,7 +77,7 @@ public: } fvalue at(size_t index) const { - assert(index < count); + assert(index < count || (index == 0 && count == 0)); if(count < 2) return start; return log ? pow(10, stepSize()*index+log10(start)) : stepSize()*index+start; @@ -107,6 +107,7 @@ public: void print(int level) const; std::string getString() const; bool isSane() const; + std::vector<fvalue> getRangeVector() const; static std::vector<Range> rangesFromParamString(const std::string& paramStr, size_t count); }; diff --git a/eistype.cpp b/eistype.cpp index af6998a461c24463b1348e2d2abebd9ede68ec0d..9fa86353b6da4796a87ce557957fe210bca57c36 100644 --- a/eistype.cpp +++ b/eistype.cpp @@ -65,6 +65,14 @@ void eis::Range::print(int level) const Log(static_cast<Log::Level>(level))<<"Range "<<start<<'-'<<end<<' '<<count<<" steps"<<(log ? " Log" : ""); } +std::vector<fvalue> eis::Range::getRangeVector() const +{ + std::vector<fvalue> out(count, 0); + for(size_t i = 0; i < count; ++i) + out[i] = at(i); + return out; +} + std::vector<Range> eis::Range::rangesFromParamString(const std::string& paramStr, size_t count) { std::vector<std::string> tokens = tokenize(paramStr, ',');