20#include "../utils/tools.hpp"
21#include "../../kernel.hpp"
49 size_t pos = string::npos;
59 for (
size_t i = 0; i < sCommand.
length(); i++)
63 if (pos == string::npos && (sCommand[i] ==
'_' || isalpha(sCommand[i])))
69 if (pos != string::npos && sCommand[i] !=
'_' && sCommand[i] !=
'~' && !isalnum(sCommand[i]))
75 if (sCommand[i] ==
'(')
92 else if (sCommand[i] ==
'{')
235static vector<mu::value_type>
MafDataAccess(
MemoryManager& _data,
const string& sMafname,
const string& sCache,
const string& sMafAccess);
244 size_t pos = sCmd.
find(
'=');
246 if (pos != std::string::npos
248 && sCmd[pos - 1] !=
'!'
249 && sCmd[pos - 1] !=
'<'
250 && sCmd[pos - 1] !=
'>'
251 && sCmd[pos + 1] !=
'='
252 && sCmd[pos - 1] !=
'=')
255 return std::string::npos;
288 size_t eq_pos = string::npos;
303 if (sLine[sLine.find_first_not_of(
' ')] !=
'-')
307 if (eq_pos != std::string::npos)
309 sCache = sLine.substr(0, eq_pos);
313 if (sCache.find(
'(') != std::string::npos
314 && sCache.substr(sCache.find(
'(')) ==
"()"
315 && sCache.find_first_of(
" +-*/?:!%&|<>=") == std::string::npos)
317 std::string source = sLine.substr(eq_pos+1);
321 if (source.find(
'(') != std::string::npos
322 && source.substr(source.find(
"(")) ==
"()"
323 && source.find_first_of(
" +-*/?:!%&|<>=") == std::string::npos
328 _data.
getCols(source.substr(0, source.find(
"(")))}));
334 if (eq_pos == string::npos
348 sCache = sLine.substr(0, eq_pos);
351 while (sCache[0] ==
'(')
357 sLine_Temp = sCache.substr(sCache.find_first_of(
"({") + 1);
359 sCache = sCache.substr(0, sCache.find_first_of(
"({") + 1) + sLine_Temp;
362 sLine_Temp = sLine.substr(eq_pos + 1);
401 if (sLine.find((iter->first) +
"(") != string::npos)
411 if (sLine.find((iter->first) +
"{") != string::npos)
438 string sEntityOccurence =
"";
439 string sEntityName = sEntity.substr(0, sEntity.length()-1);
440 unsigned int nPos = 0;
441 bool bWriteStrings =
false;
442 bool bWriteFileName =
false;
443 bool isCluster = sEntity.back() ==
'{';
444 vector<mu::value_type> vEntityContents;
445 string sEntityReplacement =
"";
446 string sEntityStringReplacement =
"";
451 while (!isCluster && (nPos = sLine.find(sEntity +
").", nPos)) != string::npos)
465 while (!isCluster && (nPos = sLine.find(sEntity +
")", nPos)) != string::npos)
473 sLine.replace(nPos, sEntity.length()+1, (_data.
getCols(sEntity.substr(0, sEntity.length()-1)) ?
"true" :
"false"));
476 if (sLine.find(sEntity) == string::npos)
491 sEntityOccurence = sLine.substr(sLine.find(sEntity, nPos));
492 nPos = sLine.find(sEntity, nPos);
502 vEntityContents.clear();
503 sEntityReplacement.clear();
504 sEntityStringReplacement.clear();
508 getIndices(sEntityOccurence, _idx, _parser, _data, _option);
531 bWriteStrings =
true;
534 bWriteFileName =
true;
537 if (!isCluster && bWriteFileName)
540 sEntityStringReplacement =
"\"" + _data.
getDataFileName(sEntityName) +
"\"";
542 else if (!isCluster && bWriteStrings)
544 vector<string> vStringContents;
547 for (
size_t j = 0; j < _idx.
col.
size(); j++)
556#warning NOTE (numere#1#08/17/21): Might be the source of some bytecode issues
577 for (
size_t i = 0; i < _idx.
row.
size(); i++)
578 vEntityContents.push_back(cluster.
getDouble(_idx.
row[i]));
593 vector<string> vStringContents;
597 for (
size_t i = 0; i < _idx.
row.
size(); i++)
611 if (sEntityStringReplacement.length())
624 _parser.
SetVectorVar(sEntityReplacement, vEntityContents);
631 replaceEntityOccurence(sLine, sEntityOccurence, sEntityName, sEntityReplacement, _idx, _data, _parser, _option, isCluster);
634 while (sLine.find(sEntity, nPos) != string::npos);
741 while ((nPos = sLine.find(sEntityOccurence)) != string::npos)
743 sLine.replace(nPos, sEntityOccurence.length(), sEntityStringReplacement);
767 sLine =
" " + sLine +
" ";
772 while ((nPos = sLine.find(sEntityOccurence, nPos)) != string::npos)
776 if (nPos && (isalnum(sLine[nPos-1]) || sLine[nPos-1] ==
'_'))
786 size_t nNextNonWhiteSpace = sLine.find_first_not_of(
" ", nPos + sEntityOccurence.length());
788 if (sLeft.length() < 3 || sLeft.back() !=
'(' || (sLine[nNextNonWhiteSpace] !=
')' && sLine[nNextNonWhiteSpace] !=
','))
791 sLine.replace(nPos, sEntityOccurence.length(), sEntityReplacement);
801 sLine = sLine.substr(0, sLine.rfind(
"std(", sLine.find(sEntityOccurence)))
803 + sLine.substr(sLine.find(
')', sLine.find(sEntityOccurence) + sEntityOccurence.length()) + 1);
805 else if (sLeft ==
"avg(")
808 sLine = sLine.substr(0, sLine.rfind(
"avg(", sLine.find(sEntityOccurence)))
810 + sLine.substr(sLine.find(
')', sLine.find(sEntityOccurence) + sEntityOccurence.length()) + 1);
812 else if (sLeft ==
"max(")
815 sLine = sLine.substr(0, sLine.rfind(
"max(", sLine.find(sEntityOccurence)))
817 + sLine.substr(sLine.find(
')', sLine.find(sEntityOccurence) + sEntityOccurence.length()) + 1);
819 else if (sLeft ==
"min(")
822 sLine = sLine.substr(0, sLine.rfind(
"min(", sLine.find(sEntityOccurence)))
824 + sLine.substr(sLine.find(
')', sLine.find(sEntityOccurence) + sEntityOccurence.length()) + 1);
826 else if (sLeft ==
"prd(")
829 sLine = sLine.substr(0, sLine.rfind(
"prd(", sLine.find(sEntityOccurence)))
831 + sLine.substr(sLine.find(
')', sLine.find(sEntityOccurence) + sEntityOccurence.length()) + 1);
833 else if (sLeft ==
"sum(")
836 sLine = sLine.substr(0, sLine.rfind(
"sum(", sLine.find(sEntityOccurence)))
838 + sLine.substr(sLine.find(
')', sLine.find(sEntityOccurence) + sEntityOccurence.length()) + 1);
840 else if (sLeft ==
"num(")
843 sLine = sLine.substr(0, sLine.rfind(
"num(", sLine.find(sEntityOccurence)))
845 + sLine.substr(sLine.find(
')', sLine.find(sEntityOccurence) + sEntityOccurence.length()) + 1);
847 else if (sLeft ==
"and(")
850 sLine = sLine.substr(0, sLine.rfind(
"and(", sLine.find(sEntityOccurence)))
852 + sLine.substr(sLine.find(
')', sLine.find(sEntityOccurence) + sEntityOccurence.length()) + 1);
854 else if (sLeft ==
"xor(")
857 sLine = sLine.substr(0, sLine.rfind(
"xor(", sLine.find(sEntityOccurence)))
859 + sLine.substr(sLine.find(
')', sLine.find(sEntityOccurence) + sEntityOccurence.length()) + 1);
861 else if (sLeft ==
"or(")
864 sLine = sLine.substr(0, sLine.rfind(
"or(", sLine.find(sEntityOccurence)))
866 + sLine.substr(sLine.find(
')', sLine.find(sEntityOccurence) + sEntityOccurence.length()) + 1);
868 else if (sLeft ==
"cnt(")
871 sLine = sLine.substr(0, sLine.rfind(
"cnt(", sLine.find(sEntityOccurence)))
873 + sLine.substr(sLine.find(
')', sLine.find(sEntityOccurence) + sEntityOccurence.length()) + 1);
875 else if (sLeft ==
"med(")
878 sLine = sLine.substr(0, sLine.rfind(
"med(", sLine.find(sEntityOccurence)))
880 + sLine.substr(sLine.find(
')', sLine.find(sEntityOccurence) + sEntityOccurence.length()) + 1);
882 else if (sLeft ==
"norm(")
885 sLine = sLine.substr(0, sLine.rfind(
"norm(", sLine.find(sEntityOccurence)))
887 + sLine.substr(sLine.find(
')', sLine.find(sEntityOccurence) + sEntityOccurence.length()) + 1);
889 else if (sLeft ==
"cmp(")
896 sLeft = sLine.substr(sLine.find(sLeft) + sLeft.length(),
getMatchingParenthesis(sLine.substr(sLine.find(sLeft) + sLeft.length() - 1)) - 1);
904 dRef = _parser.
Eval();
912 sLine = sLine.replace(sLine.rfind(
"cmp(", sLine.find(sEntityOccurence)),
916 else if (sLeft ==
"pct(")
922 sLeft = sLine.substr(sLine.find(sLeft) + sLeft.length(),
getMatchingParenthesis(sLine.substr(sLine.find(sLeft) + sLeft.length() - 1)) - 1);
930 dPct = _parser.
Eval();
931 sLine = sLine.replace(sLine.rfind(
"pct(", sLine.find(sEntityOccurence)),
936 sLine.replace(nPos, sEntityOccurence.length(), sEntityReplacement);
969 sMafAccess.substr(0, sMafAccess.find(
'(')),
975 sMafAccess.substr(0, sMafAccess.find(
'(')),
984 if (sMafVectorName.front() ==
'{')
991 while ((nPos = sLine.find(sMafAccess, nPos)) != string::npos)
999 sLine.replace(nPos, sMafAccess.length(), sMafVectorName);
1018 if (sAccessString.find(
".grid") != string::npos)
1021 if (sAccessString.find(
".cols") != string::npos)
1024 if (sAccessString.find(
".lines") != string::npos)
1025 sDataMaf +=
"lines";
1027 if (sAccessString.find(
".rows") != string::npos)
1028 sDataMaf +=
"lines";
1030 if (sAccessString.find(
".every(") != string::npos)
1048 static const int sMafListLength = 16;
1049 static std::string sMafList[sMafListLength] = {
"std",
"avg",
"prd",
"sum",
"min",
"max",
"norm",
"num",
"cnt",
"med",
"and",
"or",
"xor",
"size",
"maxpos",
"minpos"};
1052 for (
int i = 0; i < sMafListLength; i++)
1054 pos = sAccessString.find(
"." + sMafList[i]);
1056 if (pos != std::string::npos
1057 && (pos + sMafList[i].length() + 1 >= sAccessString.length() || sAccessString[pos+sMafList[i].length()+1] ==
'.' ||
isDelimiter(sAccessString[pos+sMafList[i].length()+1])))
1062 if ((pos = sAccessString.find(
".rows")) != std::string::npos)
1064 if (pos + 4 + 1 >= sAccessString.length()
1065 || sAccessString[pos+4+1] ==
'.'
1070 else if ((pos = sAccessString.find(
".cols")) != std::string::npos)
1072 if (pos + 4 + 1 >= sAccessString.length()
1073 || sAccessString[pos+4+1] ==
'.'
1095 static string sDelim =
"+-*/^%&| ,=<>!()[]{}";
1097 if ((nPos = sLine.find(sEntity +
").")) != string::npos)
1100 for (
size_t i = nPos; i < sLine.length(); i++)
1102 if (sLine[i] ==
'(' || sLine[i] ==
'[' || sLine[i] ==
'{')
1105 if (i >= sLine.length())
1106 return sLine.substr(nPos);
1108 if (sDelim.find(sLine[i]) != string::npos)
1109 return sLine.substr(nPos, i - nPos);
1111 if (i + 1 == sLine.length())
1112 return sLine.substr(nPos, i - nPos + 1);
1134 if (sMafname ==
"std")
1135 return _data.
std(sCache, sMafAccess);
1137 if (sMafname ==
"avg")
1138 return _data.
avg(sCache, sMafAccess);
1140 if (sMafname ==
"prd")
1141 return _data.
prd(sCache, sMafAccess);
1143 if (sMafname ==
"sum")
1144 return _data.
sum(sCache, sMafAccess);
1146 if (sMafname ==
"min")
1147 return _data.
min(sCache, sMafAccess);
1149 if (sMafname ==
"max")
1150 return _data.
max(sCache, sMafAccess);
1152 if (sMafname ==
"norm")
1153 return _data.
norm(sCache, sMafAccess);
1155 if (sMafname ==
"num")
1156 return _data.
num(sCache, sMafAccess);
1158 if (sMafname ==
"cnt")
1159 return _data.
cnt(sCache, sMafAccess);
1161 if (sMafname ==
"med")
1162 return _data.
med(sCache, sMafAccess);
1164 if (sMafname ==
"and")
1165 return _data.
and_func(sCache, sMafAccess);
1167 if (sMafname ==
"or")
1168 return _data.
or_func(sCache, sMafAccess);
1170 if (sMafname ==
"xor")
1171 return _data.
xor_func(sCache, sMafAccess);
1173 if (sMafname ==
"size")
1174 return _data.
size(sCache, sMafAccess);
1176 if (sMafname ==
"rows")
1177 return std::vector<mu::value_type>(1, _data.
size(sCache, sMafAccess.find(
"grid") != std::string::npos ?
"grid" :
"").front());
1179 if (sMafname ==
"cols")
1180 return std::vector<mu::value_type>(1, _data.
size(sCache, sMafAccess.find(
"grid") != std::string::npos ?
"grid" :
"").back());
1182 if (sMafname ==
"maxpos")
1183 return _data.
maxpos(sCache, sMafAccess);
1185 if (sMafname ==
"minpos")
1186 return _data.
minpos(sCache, sMafAccess);
1189 return vector<mu::value_type>(1, NAN);
1205 string sExpr = sLine.substr(sLine.find(
".every(") + 6);
1211 return "every=" + sExpr +
" ";
1237 sMethodArguments =
"\"\"";
1242 return sMethodArguments;
1267 sMethodArguments +=
" -nq";
1280 return "\"" + sMethodArguments +
"\"";
1309 for (
int i = 0; i < nResults; i++)
1320 if (sRet.find(
',') != std::string::npos)
1321 return "{" + sRet +
"}";
1354 if (!vCategories.size())
1359 for (
size_t i = 0; i < vCategories.size(); i+=2)
1364 sRet +=
"\"" + vCategories[i] +
"\"," + vCategories[i+1];
1367 return "{" + sRet +
"}";
1383 std::vector<std::string> vCategories;
1394 sMethodArguments +=
" -nq";
1412 if (!vCategories.size())
1417 for (
size_t i = 0; i < vCategories.size(); i+=2)
1422 sRet +=
"\"" + vCategories[i] +
"\"," + vCategories[i+1];
1425 return "{" + sRet +
"}";
1450 std::vector<std::string> vColNames;
1495 std::vector<mu::value_type> vResults;
1500 sMethodArguments +=
" -nq";
1509 std::vector<mu::value_type>(v, v+nResults),
1510 std::vector<std::string>());
1514 std::vector<mu::value_type>(),
1523 std::vector<mu::value_type>(v, v+nResults),
1524 std::vector<std::string>());
1555 std::vector<mu::value_type> vResults;
1560 sMethodArguments +=
" -nq";
1569 std::vector<mu::value_type>(v, v+nResults),
1570 std::vector<std::string>());
1574 std::vector<mu::value_type>(),
1583 std::vector<mu::value_type>(v, v+nResults),
1584 std::vector<std::string>());
1599static std::string
tableMethod_cov(
const std::string& sTableName, std::string sMethodArguments)
1619 size_t col1 =
intCast(v[0])-1;
1620 size_t col2 =
intCast(v[1])-1;
1622 std::vector<mu::value_type> vResults;
1626 if (sMethodArguments.length())
1638 if (sMethodArguments.length())
1681 size_t col1 =
intCast(v[0])-1;
1682 size_t col2 =
intCast(v[1])-1;
1684 std::vector<mu::value_type> vResults;
1688 if (sMethodArguments.length())
1700 if (sMethodArguments.length())
1743 size_t col1 =
intCast(v[0])-1;
1744 size_t col2 =
intCast(v[1])-1;
1746 std::vector<mu::value_type> vResults;
1750 if (sMethodArguments.length())
1762 if (sMethodArguments.length())
1802 std::vector<mu::value_type> vResults;
1805 if (sMethodArguments.length())
1852 size_t col1 =
intCast(v[0])-1;
1853 size_t col2 =
intCast(v[1])-1;
1856 double significance = 0.05;
1858 if (sMethodArguments.length())
1868 significance = v[0].real();
1870 if (sMethodArguments.length())
1886 std::string sRet =
"{";
1911 if (sMethodArguments.length())
1943static std::string
tableMethod_rank(
const std::string& sTableName, std::string sMethodArguments)
1960 std::vector<mu::value_type> vResults;
1964 if (sMethodArguments.length())
1981 else if (sStrat ==
"d")
1985 if (sMethodArguments.length())
2024 sMethodArguments +=
" -nq";
2032 return "\"" + sMethodArguments +
"\"";
2051 std::map<std::string, TableMethod> mTableMethods;
2070 return mTableMethods;
2086 std::string sTableName = sAccessString.substr(0, sAccessString.find(
"()."));
2088 for (
auto& method : mMethods)
2090 if (sAccessString.compare(0, sTableName.length()+method.first.length()+4, sTableName+
"()."+method.first+
"(") == 0)
2093 std::string sMethodArguments = sAccessString.substr(sTableName.length()+method.first.length()+3);
2095 sMethodArguments = sMethodArguments.substr(1, sMethodArguments.length()-2);
2097 return method.second(sTableName, sMethodArguments);
2101 if (sAccessString.find(
".name") != std::string::npos)
2102 return "\"" + sAccessString.substr(0, sAccessString.find(
"().")+2) +
"\"";
2104 if (sAccessString.find(
".description") != std::string::npos)
2107 sAccessString.replace(sAccessString.find(
"()"), 2,
"[");
2109 return sAccessString +
"]";
2124 string sToken = sLine;
2129 if (sToken.back() ==
'(')
2132 pos = sToken.find_last_of(
" !%&|<>=?:.,/*-+^(){}#", sToken.length() - 2);
2133 if (pos == string::npos)
2135 sToken.erase(0, pos + 1);
2140 pos = sToken.find_last_of(
" !%&|<>=?:.,/*-+^(){}#");
2141 if (pos == string::npos)
2143 sToken.erase(0, pos + 1);
2216 return _accessParser;
2239 sDataTable =
"data";
2277 if (!sExpr.length())
2279 return sExpr.find_first_not_of(
' ') != string::npos;
2308 for (
size_t i = 1; i < sLine.length(); i++)
2311 if (sLine[i] ==
'"' && (!i || sLine[i-1] !=
'\\'))
2317 if (!(nQuotes % 2) && sLine[i] ==
'{' && (sLine[i-1] ==
'_' || isalnum(sLine[i-1])))
2322 for (
int j = i-1; j >= 0; j--)
2324 if (!isalnum(sLine[j]) && sLine[j] !=
'_' && sLine[j] !=
'~')
2335 sLine.erase(start, sCluster.length());
2337 size_t nextCharPos = sLine.find_first_not_of(
' ');
2339 if (nextCharPos != string::npos && sLine[nextCharPos] ==
'=' && sLine[nextCharPos+1] !=
'=')
2340 sLine.erase(start, nextCharPos + 1);
2350 if (!_data.
isCluster(sCluster.substr(0, sCluster.find(
'{'))))
2358 if (!(nQuotes % 2) && sLine[i] !=
'~' && sLine[i] !=
'_' && sLine[i] !=
'[' && sLine[i] !=
']' && (sLine[i] ==
'(' || sLine[i] ==
'=' || ispunct(sLine[i])))
2419 std::vector<mu::value_type> vRes;
2421 for (
int i = 0; i < vRows.
size(); i++)
2449 if (sFunc.back() !=
'(')
2457 for (
unsigned int i = 0; i < sRight.length(); i++)
2459 if (sRight[i] !=
' ')
2461 if (sRight[i] ==
')')
2463 else if (sRight[i] ==
',')
2465 if (sRight.find(
')', i + 1) != string::npos)
2475 if (sFunc ==
"max(" && !bCMP)
2477 else if (sFunc ==
"min(" && !bCMP)
2479 else if (sFunc ==
"sum(" && !bCMP)
2481 else if (sFunc ==
"avg(" && !bCMP)
2483 else if (sFunc ==
"num(" && !bCMP)
2485 else if (sFunc ==
"cnt(" && !bCMP)
2487 else if (sFunc ==
"med(" && !bCMP)
2489 else if (sFunc ==
"pct(" && bCMP)
2491 else if (sFunc ==
"std(" && !bCMP)
2493 else if (sFunc ==
"prd(" && !bCMP)
2495 else if (sFunc ==
"and(" && !bCMP)
2497 else if (sFunc ==
"or(" && !bCMP)
2499 else if (sFunc ==
"xor(" && !bCMP)
2501 else if (sFunc ==
"cmp(" && bCMP)
2503 else if (sFunc ==
"norm(" && !bCMP)
2522 std::vector<size_t> sizes(2, 0);
2524 if (_manager.
isTable(sTableName))
2526 sizes[0] = _manager.
cnt(sTableName, _idx.
row, _idx.
col.
subidx(0, 1)).real();
2527 sizes[1] = _manager.
cnt(sTableName, _idx.
row, _idx.
col.
subidx(1, 1)).real();
This class is defined to abstrahize the determination of the correct data object and the calculation ...
Indices & getIndices()
Returns a reference to the stored indices.
void evalIndices()
Evaluates open end indices using the identified data object size.
bool isCluster() const
Determines, whether the data access references a cluster.
std::string & getDataObject()
Returns a reference to the data object identifier.
std::vector< size_t > getDataGridDimensions() const
Covenience wrapper method for the global function.
DataAccessParser()
DataAccessParser default constructor.
std::string getIndexString()
This member function returns the index definitions as a human-readable string.
This class represents a single table in memory, or a - so to say - single memory page to be handled b...
int getLines(bool _bFull=false) const
This member function will return the number of lines, which are currently available in this table.
int getCols(bool _bFull=false) const
This member function will return the number of columns, which are currently available in this table.
std::vector< int > sortElements(int i1, int i2, int j1=0, int j2=0, const std::string &sSortingExpression="")
This member function is the interface function for the Sorter class. It will pre- evaluate the passed...
Memory * extractRange(const VectorIndex &_vLine, const VectorIndex &_vCol) const
This member function extracts a range of this table and returns it as a new Memory instance.
This class represents the central memory managing instance. It will handle all tables and clusters,...
TableColumn::ColumnType getType(const VectorIndex &_vCol, const std::string &_sTable) const
std::vector< mu::value_type > med(const std::string &sTable, std::string sDir) const
std::vector< mu::value_type > xor_func(const std::string &sTable, std::string sDir) const
std::vector< mu::value_type > avg(const std::string &sTable, std::string sDir) const
mu::value_type getElement(int _nLine, int _nCol, const std::string &_sTable) const
std::string getComment(const std::string &_sTable) const
std::vector< mu::value_type > findCols(const std::string &sTable, const std::vector< std::string > &vCols) const
ValueVector getElementAsString(const VectorIndex &_vLine, const VectorIndex &_vCol, const std::string &_sTable) const
std::vector< mu::value_type > countIfEqual(const std::string &sTable, const VectorIndex &_vCols, const std::vector< mu::value_type > &vValues, const std::vector< std::string > &vStringValues) const
std::vector< mu::value_type > min(const std::string &sTable, std::string sDir) const
std::vector< mu::value_type > norm(const std::string &sTable, std::string sDir) const
std::vector< mu::value_type > pct(const std::string &sTable, std::string sDir, mu::value_type dPct=0.5) const
void copyTable(const std::string &source, const std::string &target)
Copy one table to another one (and create the missing table automatically, if needed).
int getLines(StringView sTable, bool _bFull=false) const
const std::map< std::string, std::pair< size_t, size_t > > & getTableMap() const
std::vector< mu::value_type > cmp(const std::string &sTable, std::string sDir, mu::value_type dRef=0.0, int nType=0) const
std::vector< mu::value_type > getRank(const std::string &sTable, size_t col, const VectorIndex &_vIndex, Memory::RankingStrategy _strat) const
bool isTable(const std::string &sTable) const
This member function returns, whether the passed table name corresponds to a known table.
mu::value_type getSpearmanCorr(const std::string &sTable, size_t col1, const VectorIndex &_vIndex1, size_t col2, const VectorIndex &_vIndex2) const
std::vector< mu::value_type > getBins(const std::string &sTable, size_t col, size_t nBins) const
std::vector< mu::value_type > and_func(const std::string &sTable, std::string sDir) const
void copyElementsInto(std::vector< mu::value_type > *vTarget, const VectorIndex &_vLine, const VectorIndex &_vCol, const std::string &_sTable) const
std::vector< mu::value_type > cnt(const std::string &sTable, std::string sDir) const
void writeComment(const std::string &_sTable, const std::string &_comment)
void addReference(const std::string &sTable, const std::string &sReference)
std::vector< mu::value_type > num(const std::string &sTable, std::string sDir) const
mu::value_type getPearsonCorr(const std::string &sTable, size_t col1, const VectorIndex &_vIndex1, size_t col2, const VectorIndex &_vIndex2) const
ValueVector getElementMixed(const VectorIndex &_vLine, const VectorIndex &_vCol, const std::string &_sTable) const
std::string getHeadLineElement(int _i, const std::string &_sTable) const
std::vector< mu::value_type > max(const std::string &sTable, std::string sDir) const
bool containsTables(const std::string &sExpression)
This member function detects, whether a table is used in the current expression.
std::vector< mu::value_type > sum(const std::string &sTable, std::string sDir) const
mu::value_type getCovariance(const std::string &sTable, size_t col1, const VectorIndex &_vIndex1, size_t col2, const VectorIndex &_vIndex2) const
std::vector< mu::value_type > std(const std::string &sTable, std::string sDir) const
std::vector< mu::value_type > getZScore(const std::string &sTable, size_t col, const VectorIndex &_vIndex) const
std::vector< mu::value_type > or_func(const std::string &sTable, std::string sDir) const
ValueVector getCategoryList(const VectorIndex &_vCol, const std::string &_sTable) const
bool updateDimensionVariables(StringView sTableName)
This member function updates the dimension variables for the selected table to be used in expressions...
Memory * getTable(const std::string &sTable)
This member function returns a pointer to an existing Memory instance representing the selected table...
AnovaResult getOneWayAnova(const std::string &sTable, size_t colCategories, size_t colValues, const VectorIndex &_vIndex, double significance) const
bool containsTablesOrClusters(const std::string &sCmdLine)
This member function evaluates, whether the passed command line contains tables or clusters.
std::vector< mu::value_type > getIndex(const std::string &sTable, size_t nCol, const std::vector< mu::value_type > &vValues, const std::vector< std::string > &vStringValues) const
std::vector< mu::value_type > minpos(const std::string &sTable, std::string sDir) const
std::vector< mu::value_type > maxpos(const std::string &sTable, std::string sDir) const
std::vector< mu::value_type > size(const std::string &sTable, std::string sDir) const
int getCols(StringView sTable, bool _bFull=false) const
int getColElements(const VectorIndex &cols, const std::string &_sTable) const
Returns the maximal number of elements in the selected column range.
std::vector< mu::value_type > prd(const std::string &sTable, std::string sDir) const
This class represents a whole cluster. The single items are stored as pointers to the abstract cluste...
size_t size() const
This member function returns the size of the internal memory buffer as items.
std::string getParserString(size_t i) const
This member function returns the data of the i-th cluster item in memory as a parser string.
void push_back(ClusterItem *item)
This member function appends an arbitrary cluster item at the back of the internal cluster array buff...
mu::value_type med(const VectorIndex &_vLine)
This member function calculates the median value of the data in memory. Cluster items,...
mu::value_type min(const VectorIndex &_vLine)
This member function calculates the minimal value of the data in memory. Cluster items,...
std::vector< std::string > getInternalStringArray() const
This member function returns the data of all cluster items memory as a value vector.
mu::value_type cnt(const VectorIndex &_vLine)
This member function counts the number of valid cluster items in memory. Cluster items of any type ar...
mu::value_type and_func(const VectorIndex &_vLine)
This member function applies an "AND" to the data in memory. Cluster items, which do not have the typ...
mu::value_type num(const VectorIndex &_vLine)
This member function counts the number of valid cluster items in memory. Cluster items of any type ar...
mu::value_type xor_func(const VectorIndex &_vLine)
This member function applies an "exclusive OR" to the data in memory. Cluster items,...
mu::value_type avg(const VectorIndex &_vLine)
This member function calculates the average of the data in memory. Cluster items, which do not have t...
void insertDataInArray(std::vector< mu::value_type > *vTarget, const VectorIndex &_vLine)
This member function inserts the data of all cluster items memory into the pointer passed to the func...
mu::value_type max(const VectorIndex &_vLine)
This member function calculates the maximal value of the data in memory. Cluster items,...
mu::value_type getDouble(size_t i) const
This member function returns the data of the i-th cluster item in memory as a value.
mu::value_type std(const VectorIndex &_vLine)
This member function calculates the standard deviation of the data in memory. Cluster items,...
mu::value_type pct(const VectorIndex &_vLine, mu::value_type dPct)
This member function calculates the p-th percentile of the data in memory. Cluster items,...
mu::value_type or_func(const VectorIndex &_vLine)
This member function applies an "OR" to the data in memory. Cluster items, which do not have the type...
mu::value_type norm(const VectorIndex &_vLine)
This member function calculates the euclidic vector norm of the data in memory. Cluster items,...
mu::value_type cmp(const VectorIndex &_vLine, mu::value_type dRef, int _nType)
This member function compares the values in memory with the referenced value and returns indices or v...
mu::value_type sum(const VectorIndex &_vLine)
This member function calculates the sum of the data in memory. Cluster items, which do not have the t...
mu::value_type prd(const VectorIndex &_vLine)
This member function calculates the product of the data in memory. Cluster items, which do not have t...
bool isDouble() const
This member function returns, whether the data in the cluster have only double as type.
unsigned short getType(size_t i) const
This member function returns the type of the i-th cluster item in the internal memory buffer.
bool containsClusters(const std::string &sCmdLine) const
This member function detects, whether any cluster is used in the current expression.
Cluster & getCluster(StringView sCluster)
This member function returns a reference to the cluster indicated by the passed cluster identifier.
Cluster & newCluster(const std::string &sCluster)
This member function creates a new cluster from the passed cluster identifier and returns a reference...
bool isCluster(StringView sCluster) const
This member function returns true, if the passed cluster identifier can be found in the internal map.
const std::map< std::string, Cluster > & getClusterMap() const
std::string getDataFileName(const std::string &sTable) const
This member function will return the file name of the selected table. Will default to the table name.
This class is the central string expression parser. It is designed as being a singleton with a persis...
virtual bool isStringExpression(const std::string &sExpression) override
Returns true, if the passed expression is an expression containing strings, string variables or strin...
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...
std::string createTempStringVectorVar(const std::vector< std::string > &vStringVector)
This member function is used to create a temporary string vector variable.
This class provides the interface to the core of NumeRe. It provides all functionalities,...
static NumeReKernel * getInstance()
This static member function returns a a pointer to the singleton instance of the kernel.
NumeRe::StringParser & getStringParser()
MemoryManager & getMemoryManager()
NumeRe::Cluster & getAns()
This class manages the setting values of the internal (kernel) settings of this application.
std::string to_string() const
This member function returns a copy of the viewed section of the string (via std::string::substr)....
size_t find(const std::string &findstr, size_t pos=0) const
Wrapper member function for std::string::find()
size_t length() const
This member function simply returns the length of the viewed section.
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.
@ TABLE_DOESNT_EXIST
INSERT HERE.
static size_t invalid_position
This class abstracts all the index logics, i.e. the logical differences between single indices and in...
VectorIndex subidx(size_t pos, size_t nLen=std::string::npos) const
This member function returns a subset of the internal stored index just like the std::string::substr(...
int last() const
This member function returns the last index value, which can be reached by the values stored internal...
size_t size() const
This member function returns the size of the indices stored in this class.
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...
bool isString() const
This member function determines, whether the internal index set referres to the table headlines.
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 CacheCurrentAccess(const CachedDataAccess &_access)
Store the passed data access for this position 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.
const CachedDataAccess & GetCachedAccess(size_t nthAccess)
Returns the cached data access for the passed position.
const std::string & GetCachedEquation() const
Returns the stored equation for this position.
const std::string & GetCachedTarget() const
Returns the stored target equation for this position.
std::vector< mu::value_type > * GetVectorVar(const std::string &sVarName)
This member function returns a pointer to the vector stored internally.
bool IsCompiling()
Returns true, if the parser is currently in compiling step.
string_type CreateTempVectorVar(const std::vector< mu::value_type > &vVar)
This member function copies the passed vector into the internal storage referencing it with a auto-ge...
void UpdateVectorVar(const std::string &sVarName)
This member function updates the corresponding variable of a vector with the previously newly assigne...
size_t HasCachedAccess()
Evaluate, whether there are any cached data accesses for this position.
void DisableAccessCaching()
Disable the data access caching for this position.
bool ContainsVectorVars(StringView sExpr, bool ignoreSingletons)
This member function checks, whether the passed expression contains a vector.
void SetVectorVar(const std::string &sVarName, const std::vector< mu::value_type > &vVar, bool bAddVectorType=false)
This member function copies the passed vector into the internal storage referencing it with the passe...
Mathematical expressions parser.
mu::value_type getDataFromObject(const std::string &sObject, long long int i, long long int j, bool isCluster)
This function returns the data from the selected object and switches automatically between tables and...
static std::map< std::string, TableMethod > getInplaceTableMethods()
Returns the declared list of table methods.
static std::string tableMethod_index(const std::string &sTableName, std::string sMethodArguments)
Realizes the "index()" table method.
static const string handleCachedDataAccess(string &sLine, Parser &_parser, MemoryManager &_data, const Settings &_option)
This function handles cached data access strings, which may be available in the parser.
static std::string tableMethod_pcorr(const std::string &sTableName, std::string sMethodArguments)
Realizes the "pcorr()" table method.
DataAccessParser getAccessParserForPlotAndFit(StringView sExpression)
This function will return the access parser instance for the current expression validate,...
static std::string tableMethod_categories(const std::string &sTableName, std::string sMethodArguments)
Realizes the "categories()" table method.
static std::string tableMethod_scorr(const std::string &sTableName, std::string sMethodArguments)
Realizes the "scorr()" table method.
static std::string tableMethod_convert(const std::string &sTableName, std::string sMethodArguments)
Realizes the "convert()" table method.
static std::string tableMethod_typeof(const std::string &sTableName, std::string sMethodArguments)
Realizes the "typeof()" table method.
static std::string tableMethod_anova(const std::string &sTableName, std::string sMethodArguments)
Realizes the "anova()" table method.
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 ...
static void replaceEntityStringOccurence(string &sLine, const string &sEntityOccurence, const string &sEntityStringReplacement)
This function simply replaces every occurences of the entity with its replacement.
static string createMafVectorName(string sAccessString)
This function simply returns the vector name obtained from the MAF method string.
size_t findAssignmentOperator(StringView sCmd)
static string getMafAccessString(const string &sLine, const string &sEntity)
This function returns the first MAF access in the passed sLine string.
Indices getIndicesForPlotAndFit(const string &sExpression, string &sDataTable, int &nColumns, bool &openEnd, bool &isCluster)
This function will calculate the indices from the passed data expression and return them optimized fo...
static string createEveryDefinition(const string &sLine, Parser &_parser)
This function creates an every definition from the methods, which the Datafile class is able to parse...
static void handleMafDataAccess(string &sLine, const string &sMafAccess, Parser &_parser, MemoryManager &_data)
This function handles the MAF data access using methods.
static void resolveTablesAndClusters(string &sLine, Parser &_parser, MemoryManager &_data, const Settings &_option, int options)
Resolves every call to a cluster or a table.
static void replaceEntityOccurence(string &sLine, const string &sEntityOccurence, const string &sEntityName, const string &sEntityReplacement, const Indices &_idx, MemoryManager &_data, Parser &_parser, const Settings &_option, bool isCluster)
This function replaces every occurence of the entity with either the vector name for the parser or wi...
bool isNotEmptyExpression(const string &sExpr)
This function checks, whether the passed expression is non-empty (i.e. it contains more than white sp...
static std::string tableMethod_aliasof(const std::string &sTableName, std::string sMethodArguments)
Realizes the "aliasof()" table method.
std::string(* TableMethod)(const std::string &, std::string)
Typedef for a table method.
static std::string tableMethod_categorize(const std::string &sTableName, std::string sMethodArguments)
Realizes the "categorize()" table method.
static string getLastToken(const string &sLine)
This function returns the last token of the current string, e.g. a function name, etc.
Memory * extractRange(const std::string &sCmd, DataAccessParser &_accessParser, int nDesiredCols, bool bSort)
This function extracts a portion of a table and returns it to the calling function....
static std::string tableMethod_findCols(const std::string &sTableName, std::string sMethodArguments)
Realizes the "fndcols()" table method.
bool isClusterCandidate(string &sLine, string &sCluster, bool doCut)
This function checks, whether the passed command line contains the syntax for a cluster candidate,...
static std::string tableMethod_annotate(const std::string &sTableName, std::string sMethodArguments)
Realizes the "describe()" method.
static vector< mu::value_type > MafDataAccess(MemoryManager &_data, const string &sMafname, const string &sCache, const string &sMafAccess)
This function simply performs the MAF access and returns the vector of the results.
void replaceDataEntities(string &sLine, const string &sEntity, MemoryManager &_data, Parser &_parser, const Settings &_option, int options)
This function replaces all calls to a single data entity with an internal vector or its value,...
static std::string tableMethod_counteq(const std::string &sTableName, std::string sMethodArguments)
Realizes the "countif()" table method.
static string createMafDataAccessString(const string &sAccessString, Parser &_parser)
This function returns the modifier list obtained from the method string.
static std::string tableMethod_zscore(const std::string &sTableName, std::string sMethodArguments)
Realizes the "zscore()" table method.
static std::string tableMethod_rank(const std::string &sTableName, std::string sMethodArguments)
Realizes the "rankof()" table method.
static string getMafFromAccessString(const string &sAccessString)
This function returns the name of the MAF.
static std::string tableMethod_cov(const std::string &sTableName, std::string sMethodArguments)
Realizes the "cov()" table method.
std::vector< size_t > getDataGridDimensions(const Indices &_idx, const std::string &sTableName)
Returns the accessed data grid dimensions.
static std::string tableMethod_binsof(const std::string &sTableName, std::string sMethodArguments)
Realizes the "binsof()" table method.
bool parser_CheckMultArgFunc(const string &sLeft, const string &sRight)
This function checks, whether the argument located between sLeft and sRight is part of a multi-argume...
Indices getIndices(StringView sCmd, mu::Parser &_parser, MemoryManager &_data, const Settings &_option)
Wrapper for the new getIndices function interface.
bool isValidIndexSet(const Indices &_idx)
std::vector< std::string > ValueVector
This type defines a generic value vector.
unsigned int getMatchingParenthesis(const StringView &)
Returns the position of the closing parenthesis.
Namespace for mathematical applications.
MUP_BASETYPE value_type
The numeric datatype used by the parser.
void StripSpaces(std::string &)
Removes leading and trailing white spaces and tabulator characters.
Contains the relevant results of the ANOVA F test.
mu::value_type m_significance
mu::value_type m_significanceVal
This structure is central for managing the indices of a table or cluster read or write data access....
std::string sCompiledAccessEquation
static std::string typeToString(ColumnType type)
Converts the passed ColumnType value to a string representation.
Describes an already evaluated data access, which can be reconstructed from the current parser state.
std::string sAccessEquation
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.