21#include "../kernel.hpp"
83 double val = (
m_vInterval.size()-1) / (
double)(nSamples-1) * n;
84 size_t nIdx = (size_t)val;
122 reset(dFront, dBack);
176 return std::pow(10.0, std::log10(
front()) + (
double)n * (std::log10(
back()) - std::log10(
front())) / (
double)(nSamples - 1));
280 return 0.5 * (
max() +
min());
350 if (indices.size() == 1)
357 _parser.
SetExpr(indices.front());
362 v = _parser.
Eval(nResults);
372 for (
int i = 0; i < nResults; i++)
381 for (
size_t i = 0; i < indices.size(); i++)
440 if (r == 0.0 || r < 1e-4 * mi)
443 double mi2 = mi - r * (perc - 1.0) * 0.5;
444 ma += r * (perc - 1.0) * 0.5;
451 mi = dMin + r * (perc - 1.0) * 0.5;
516 if (sIntervalString.find(
'[') != std::string::npos &&
getMatchingParenthesis(sIntervalString.substr(sIntervalString.find(
'['))) != std::string::npos)
519 size_t nMatchingParens = 0;
520 size_t nPrevChar = 0;
525 nPos = sIntervalString.find(
'[', nPos);
527 if (nPos == std::string::npos || (nMatchingParens =
getMatchingParenthesis(sIntervalString.substr(nPos))) == std::string::npos)
530 nMatchingParens += nPos;
531 nPrevChar = sIntervalString.find_last_not_of(
" [", nPos);
534 while (
isInQuotes(sIntervalString, nPos) || (nPrevChar != std::string::npos && sIntervalString[nPrevChar] ==
'='));
537 if (nPos != std::string::npos && nMatchingParens != std::string::npos)
539 std::string sRanges = sIntervalString.substr(nPos, nMatchingParens - nPos);
543 static std::string sNames[4] = {
"x",
"y",
"z",
"t"};
545 for (
size_t i = 0; i < args.size(); i++)
624 for (
size_t i = 0; i <
intervals.size(); i++)
626 for (
size_t j = 0; j <
intervals.size(); j++)
658 std::vector<mu::value_type> vIntervals;
662 vIntervals.push_back(ivl.front());
663 vIntervals.push_back(ivl.back());
679 for (
size_t i = 0; i < vNames.size(); i++)
This class represents a single interval in code providing reading access functionality.
void expand(double perc, double dMin=-INFINITY)
Expand the interval by the corresponding percentage. The expansion is equally distributed to both end...
void assign(const Interval &ivl)
Assign a interval object to this instance.
Interval combine(const Interval &_ivl) const
Returns the (continous) interval, which contains this and the passed interval.
mu::value_type back() const
Return the last element in the interval.
void refresh()
Referesh the internal interval representation (e.g. after a dependency has been updated).
std::string m_sDefinition
size_t getSamples() const
Returns the number of internal samples. Will return zero, if the internal samples are only interval s...
double getSample(size_t n, size_t nSamples) const
Return the nth sample of the interval using the desired number of samples.
double range() const
Return the real inteval range of this interval.
void reset(const std::string &sDef)
Reset the interval with a new definition.
mu::value_type cmax() const
Return the componentwise maximal element in the interval.
double middle() const
Calculates the middle point of the interval.
bool isInside(mu::value_type val) const
Checks, whether the passed value is part of this interval.
mu::value_type front() const
Return the first element in the interval.
std::vector< double > m_vInterval
Interval & operator=(const Interval &ivl)
Assignment operator overload.
double max() const
Return the maximal element in the interval.
bool contains(const std::string &sVarName) const
Check, whether a variable is part of the interval definition string to detect a possible dependency.
mu::value_type log(size_t n, size_t nSamples=100) const
Return a sample in logarithmic scale.
mu::value_type operator()(size_t n, size_t nSamples=100) const
Parenthesis operator overload.
mu::value_type cmin() const
Return the componentwise minimal element in the interval.
double min() const
Return the minimal element in the interval.
This class represents the central memory managing instance. It will handle all tables and clusters,...
bool containsTablesOrClusters(const std::string &sCmdLine)
This member function evaluates, whether the passed command line contains tables or clusters.
static NumeReKernel * getInstance()
This static member function returns a a pointer to the singleton instance of the kernel.
MemoryManager & getMemoryManager()
Common exception class for all exceptions thrown in NumeRe.
static size_t invalid_position
void SetExpr(StringView a_sExpr)
Set the expression. Triggers first time calculation thus the creation of the bytecode and scanning of...
value_type Eval()
Single-value wrapper around the vectorized overload of this member function.
Mathematical expressions parser.
string getDataElements(string &sLine, Parser &_parser, MemoryManager &_data, const Settings &_option, int options)
Searches the passed string for calls to any table or cluster and replaces them with internal vectors ...
size_t findVariableInExpression(const std::string &sExpr, const std::string &sVarName, size_t nPosStart)
This function searches for the selected variable in the passed string and returns the position of the...
unsigned int getMatchingParenthesis(const StringView &)
Returns the position of the closing parenthesis.
MUP_BASETYPE value_type
The numeric datatype used by the parser.
bool isnan(const value_type &v)
std::vector< double > real(const std::vector< value_type > &vVec)
int findParameter(const std::string &sCmd, const std::string &sParam, const char cFollowing)
This function searches the passed parameter in the passed command string. If something is found,...
This class represents a set of intervals used together for calculations and simulations.
std::vector< mu::value_type > convert()
Convert the new interval data types to the old plain mu::value_type values.
size_t size() const
Return the number of intervals.
void setNames(const std::vector< std::string > &vNames)
Set the interval names.
bool hasDependentIntervals() const
Detect, whether there are intervals, which depend on each other.
std::vector< Interval > intervals
Interval & operator[](size_t n)
Access operator overload.
IntervalSet & operator=(const IntervalSet &ivSet)
Assignment operator overload.