20#include "../utils/tools.hpp"
21#include "../../kernel.hpp"
52 getIndices(sCmd, _idx, _parser, _data, _option);
84 if (nClosingParens == string::npos)
87 sTableName = sCmd.
subview(0, nPos);
90 for (
size_t i = 0; i < sTableName.
length(); i++)
95 if (sTableName[i] ==
'_' || isalpha(sTableName[i]))
104 sIndices = sCmd.
subview(nPos+1, nClosingParens-1);
124 if (sCmd[nPos] ==
'(')
133#warning TODO (numere#3#08/15/21): Checking for string variables here is inefficient
140 for (std::string& index : idc)
145 bool isVector = index.front() ==
'{' && index.back() ==
'}';
149 index =
"{" + index +
"}";
184 vector<StringView> vLines;
185 vector<StringView> vCols;
195 if (vLines.size() == 1)
203 if (vCols.size() == 1)
210 if (vLines.size() > 1 || vCols.size() > 1)
243 bool openEnd = sLines.
back() ==
':';
251 vLines.push_back(sLines);
261 openEnd = sCols.
back() ==
':';
297 else if (sIndex ==
"#")
302 v = _parser.
Eval(nResults);
331 for (
size_t n = 0; n < vIndex.size(); n++)
333 if (!vIndex[n].length())
345 if (sIndexExpressions.length())
346 sIndexExpressions +=
",";
348 sIndexExpressions += vIndex[n].to_string();
350 vIndexNumbers.push_back(sign*(n + 1));
371 std::string sIndexExpression;
373 for (
size_t i = 0; i < vIndexNumbers.size(); i++)
377 if (vIndexNumbers[i-1] > 0 && vIndexNumbers[i] < 0)
378 sIndexExpression +=
", ";
380 sIndexExpression +=
':';
383 sIndexExpression +=
toString(v[i], 5);
386 return sIndexExpression;
406 string sIndexExpressions;
407 vector<int> vIndexNumbers;
420 if (sIndexExpressions.length())
422 _parser.
SetExpr(sIndexExpressions);
427 if ((
size_t)nResults != vIndexNumbers.size())
431 for (
int i = 0; i < nResults; i++)
439 if (vIndexNumbers.front() > 0 && vIndexNumbers.back() < 0)
441 else if (vIndexNumbers.front() > 0)
455 if (vIndexNumbers[i] > 0)
480 bool isCluster = sCmd[sCache.
length()] ==
'{';
494 if (sCache ==
"string")
void debug(const std::string &sMessage)
Convenience member function.
This class extends the std::vector for endlessness.
This class represents the central memory managing instance. It will handle all tables and clusters,...
bool isTable(const std::string &sTable) const
This member function returns, whether the passed table name corresponds to a known table.
bool updateDimensionVariables(StringView sTableName)
This member function updates the dimension variables for the selected table to be used in expressions...
bool containsTablesOrClusters(const std::string &sCmdLine)
This member function evaluates, whether the passed command line contains tables or clusters.
bool updateClusterSizeVariables(StringView sCluster)
This member function updates the dimension variable reserved for cluster accesses with the size of th...
StringParserRetVal evalAndFormat(std::string &sLine, std::string &sCache, bool bSilent=false, bool bCheckAssertions=false)
This public member function evaluates the passed string expression and formats the results for the co...
static NumeReKernel * getInstance()
This static member function returns a a pointer to the singleton instance of the kernel.
NumeRe::StringParser & getStringParser()
This class manages the setting values of the internal (kernel) settings of this application.
unsigned int getStringCols() const
unsigned int getStringElements(unsigned int nCol=std::string::npos) const
void strip()
This member function shrinks the viewed section to remove all leading or trailing whitespace characte...
void trim_front(size_t len)
This member function can be used to remove characters from the front of the viewed section.
size_t find_first_of(const std::string &findstr, size_t pos=0) const
Wrapper member function for std::string::find_first_of()
const char & back() const
This member function provides a const char reference to the last character in the viewed section.
std::string to_string() const
This member function returns a copy of the viewed section of the string (via std::string::substr)....
std::string::const_iterator end() const
This member function provides an iterator to the end of the viewed section of the internal string.
size_t length() const
This member function simply returns the length of the viewed section.
std::string::const_iterator begin() const
This member function provides an iterator to the beginning of the viewed section of the internal stri...
This class is the immutable (const) version of a string view. It can be constructed from a MutableStr...
StringView subview(size_t pos=0, size_t len=std::string::npos) const
This member function creates a new StringView class instance using the selected position and length a...
Common exception class for all exceptions thrown in NumeRe.
static size_t invalid_position
This class abstracts all the index logics, i.e. the logical differences between single indices and in...
bool isValid() const
This member function determines, whether the internal index set is valid.
bool isOpenEnd() const
This member function determines, whether the internal index set has an open end.
void setRange(int nMin, int nMax)
This member function can be used to force the indices stored internally to be in a defined interval....
std::string to_string() const
This member function converts the vector indexes contents into a human-readable string representation...
void setIndex(size_t nthIndex, int nVal)
This member function can be used to set the index at a special position. This will expand the interna...
int & front()
This member function returns a reference to the first index value stored internally.
size_t numberOfNodes() const
This member function returns the number of nodes describing the index set, which is stored internally...
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 ...
Indices getIndices(StringView sCmd, Parser &_parser, MemoryManager &_data, const Settings &_option)
Wrapper for the new getIndices function interface.
static void handleArgumentForIndices(Indices &_idx, Parser &_parser, MemoryManager &_data, StringView sArgument, StringView sCmd)
This static function is the main driver function for extracting the indices into VectorIndex represen...
static void handleSingleCasualIndex(VectorIndex &_vIdx, vector< StringView > &vIndex, string &sIndexExpressions, vector< int > &vIndexNumbers, int sign)
This static function is a helper function for handleCasualIndices(), which will be applied to row and...
static void handleCasualIndices(Parser &_parser, Indices &_idx, vector< StringView > &vLines, vector< StringView > &vCols, StringView sCmd)
This function will evaluate all indices, which are interpreted as casual indices, at once and store t...
static void handleIndexVectors(Parser &_parser, VectorIndex &_vIdx, StringView sIndex)
This static function will evaluate the indices and it tries to match it to a vector.
static void extractIndexList(StringView sCols, vector< StringView > &vLines, vector< StringView > &vCols)
This static function separates the argument into its row and column parts and returns them as vectors...
static void expandStringIndexVectors(Indices &_idx, MemoryManager &_data)
This static function expands the indices into vectors, if the current object is the string object.
static std::string convertToString(value_type *v, const vector< int > vIndexNumbers)
This static function is a simple helper to convert the numerical results into a string,...
static void expandIndexVectors(Indices &_idx, MemoryManager &_data, StringView sCmd)
This function will expand casual indices into vectors. Actually, it is only used for the special case...
unsigned int getMatchingParenthesis(const StringView &)
Returns the position of the closing parenthesis.
CONSTCD11 std::chrono::duration< Rep, Period > abs(std::chrono::duration< Rep, Period > d)
Namespace for mathematical applications.
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)
bool isinf(const value_type &v)
This structure is central for managing the indices of a table or cluster read or write data access....
std::string sCompiledAccessEquation
long long int intCast(const std::complex< double > &)
Casts the real part of the complex number to an integer and avoids rounding errors.
std::string toString(int)
Converts an integer to a string without the Settings bloat.