NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
memorymanager.hpp
Go to the documentation of this file.
1/*****************************************************************************
2 NumeRe: Framework fuer Numerische Rechnungen
3 Copyright (C) 2014 Erik Haenel et al.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17******************************************************************************/
18
19
20#include <fstream>
21#include <string>
22#include <vector>
23
24#include "../ui/error.hpp"
25#include "../settings.hpp"
26#include "../structures.hpp"
27#include "table.hpp"
28#include "memory.hpp"
29#include "stringmemory.hpp"
30#include "cluster.hpp"
31#include "fileadapter.hpp"
32
33
34#ifndef MEMORYMANAGER_HPP
35#define MEMORYMANAGER_HPP
36
37
45{
46 private:
47 std::vector<Memory*> vMemory;
48 std::map<std::string, std::pair<size_t, size_t>> mCachesMap;
50 std::fstream cache_file;
51 std::string sCache_file;
52 std::string sPredefinedFuncs;
53 std::string sUserdefinedFuncs;
55 std::string sPluginCommands;
56
57 void reorderColumn(size_t _nLayer, const std::vector<int>& vIndex, long long int i1, long long int i2, long long int j1 = 0);
60 VectorIndex parseEvery(std::string& sDir, const std::string& sTableName) const;
61 std::vector<mu::value_type> resolveMAF(const std::string& sTableName, std::string sDir, mu::value_type (MemoryManager::*MAF)(const std::string&, long long int, long long int, long long int, long long int) const) const;
62
63 virtual bool saveLayer(std::string _sFileName, const std::string& _sTable, unsigned short nPrecision) override
64 {
65 return vMemory[findTable(_sTable)]->save(ValidFileName(_sFileName, ".ndat"), _sTable, nPrecision);
66 }
67
68 inline bool exists(const std::string& sTable) const
69 {
70 return mCachesMap.find(sTable) != mCachesMap.end();
71 }
72
73 size_t mapStringViewFind(StringView view) const
74 {
75 for (auto iter = mCachesMap.begin(); iter != mCachesMap.end(); ++iter)
76 {
77 if (view == iter->first)
78 {
79 if (iter->second.first != iter->second.second)
80 return iter->second.second;
81
82 return iter->second.first;
83 }
84 else if (view < iter->first)
86 }
87
88 return -1;
89 }
90
91 size_t findTable(const std::string& sTable) const
92 {
93 auto iter = mCachesMap.find(sTable);
94
95 if (iter == mCachesMap.end())
96 throw SyntaxError(SyntaxError::TABLE_DOESNT_EXIST, sTable, sTable);
97
98 if (iter->second.first != iter->second.second)
99 return iter->second.second;
100
101 return iter->second.first;
102 }
103
104 public:
107
109
110 // Variables for the parser
113 bool updateDimensionVariables(StringView sTableName);
114
115
116 // OTHER METHODS
117 inline void setPredefinedFuncs(const std::string& sFuncs)
118 {
119 sPredefinedFuncs = sFuncs;
120 }
121
122 inline void setUserdefinedFuncs(const std::string& sUserFuncs)
123 {
124 sUserdefinedFuncs = sUserFuncs;
125 }
126
127 inline void setPluginCommands(const std::string& sPluginCmds)
128 {
129 sPluginCommands = sPluginCmds;
130 }
131
132 inline void setPredefinedCommands(const std::string& sCommands)
133 {
134 sPredefinedCommands = sCommands;
135 }
136
137
138
139 // VALIDATION METHODS
140 bool isValid() const;
141 bool isTable(const std::string& sTable) const;
142
143 bool isEmpty(const std::string& sTable) const
144 {
145 if (exists(sTable))
146 return !vMemory[findTable(sTable)]->getCols();
147
148 return true;
149 }
150
151 bool isValidElement(long long int _nLine, long long int _nCol, const std::string& _sTable) const
152 {
153 if (exists(_sTable))
154 return vMemory[findTable(_sTable)]->isValidElement(_nLine, _nCol);
155
156 return false;
157 }
158
159
160
161 // RECOGNITION METHODS
162 bool containsTables(const std::string& sExpression);
163 bool containsTablesOrClusters(const std::string& sCmdLine);
164
165 inline std::string matchTableAsParameter(const std::string& sExpression, char cFollowing = ' ')
166 {
167 for (auto iter = mCachesMap.begin(); iter != mCachesMap.end(); ++iter)
168 {
169 if (findParameter(sExpression, iter->first, cFollowing))
170 return iter->first;
171 }
172
173 return "";
174 }
175
176
177
178 // GLOBAL TABLE METHODS
179 // CREATION AND DELETION
180 bool addTable(const std::string& sCache, const Settings& _option);
181 bool deleteTable(const std::string& sCache);
182 void removeData(bool bAutoSave = false);
184
185 bool resizeTable(int _nCols, const std::string& _sTable)
186 {
187 return vMemory[findTable(_sTable)]->resizeMemory(1, _nCols);
188 }
189
190 void deleteEntry(int _nLine, int _nCol, const std::string& _sCache)
191 {
192 vMemory[findTable(_sCache)]->deleteEntry(_nLine, _nCol);
193 }
194
195 void deleteBulk(const std::string& _sCache, int i1, int i2, int j1 = 0, int j2 = 0)
196 {
197 vMemory[findTable(_sCache)]->deleteBulk(VectorIndex(i1, i2), VectorIndex(j1, j2));
198 }
199
200 void deleteBulk(const std::string& _sCache, const VectorIndex& _vLine, const VectorIndex& _vCol)
201 {
202 vMemory[findTable(_sCache)]->deleteBulk(_vLine, _vCol);
203 }
204
205 void shrink(const std::string& _sCache)
206 {
207 vMemory[findTable(_sCache)]->shrink();
208 }
209
210
211 // TABLE INFORMATION AND SAVING METHODS
212 bool getSaveStatus() const;
213 void setSaveStatus(bool _bIsSaved);
214 long long int getLastSaved() const;
215 void setCacheFileName(std::string _sFileName);
216 bool saveToCacheFile();
217 bool loadFromCacheFile();
218
219 inline unsigned int getNumberOfTables() const
220 {
221 return mCachesMap.size();
222 }
223
224 inline const std::map<std::string, std::pair<size_t, size_t>>& getTableMap() const
225 {
226 return mCachesMap;
227 }
228
229 inline std::string getTableNames() const
230 {
231 std::string sReturn = ";";
232
233 for (auto iter = mCachesMap.begin(); iter != mCachesMap.end(); ++iter)
234 {
235 sReturn += iter->first + ";";
236 }
237
238 return sReturn;
239 }
240
241
242 // GLOBAL TABLE ACCESS METHODS
243 Memory* getTable(const std::string& sTable);
244 virtual void melt(Memory* _mem, const std::string& sTable, bool overrideTarget = false) override;
245
246 inline void renameTable(const std::string& sCache, const std::string& sNewName, bool bForceRenaming = false)
247 {
248 if (isTable(sNewName))
250
251 if (!isTable(sCache))
253
254 if (sCache == "table" && !bForceRenaming)
256
257 mCachesMap[sNewName] = mCachesMap[sCache];
258 mCachesMap.erase(sCache);
259 setSaveStatus(false);
260 }
261
262 inline void swapTables(std::string sTable1, std::string sTable2)
263 {
264 if (!isTable(sTable1))
266
267 if (!isTable(sTable2))
269
270 size_t tab1 = mCachesMap[sTable1].second;
271 size_t tab2 = mCachesMap[sTable2].second;
272
273 for (auto& iter : mCachesMap)
274 {
275 if (iter.second.first == tab1)
276 iter.second.first = tab2;
277 else if (iter.second.first == tab2)
278 iter.second.first = tab1;
279
280 if (iter.second.second == tab1)
281 iter.second.second = tab2;
282 else if (iter.second.second == tab2)
283 iter.second.second = tab1;
284 }
285 }
286
287 void addReference(const std::string& sTable, const std::string& sReference)
288 {
289 if (!isTable(sTable))
291
292 if (!sReference.length())
293 {
294 mCachesMap[sTable].second = mCachesMap[sTable].first;
295 return;
296 }
297 else if (!isTable(sReference))
299
300 auto iter = mCachesMap.find(sReference.substr(0, sReference.find('(')));
301 mCachesMap[sTable].second = iter->second.first;
302 }
303
304 void copyTable(const std::string& source, const std::string& target);
305
306
307 // TABLE EXTRACTOR AND IMPORTER METHODS
308 inline NumeRe::Table extractTable(const std::string& _sTable, const VectorIndex& lines = VectorIndex(0, VectorIndex::OPEN_END), const VectorIndex& cols = VectorIndex(0, VectorIndex::OPEN_END))
309 {
310 return vMemory[findTable(_sTable)]->extractTable(_sTable, lines, cols);
311 }
312
313 inline NumeRe::Table extractTable(int _nLayer, const std::string& _sTable = "", const VectorIndex& lines = VectorIndex(0, VectorIndex::OPEN_END), const VectorIndex& cols = VectorIndex(0, VectorIndex::OPEN_END))
314 {
315 return vMemory[_nLayer]->extractTable(_sTable, lines, cols);
316 }
317
318 inline void importTable(NumeRe::Table _table, const std::string& _sTable, const VectorIndex& lines = VectorIndex(0, VectorIndex::OPEN_END), const VectorIndex& cols = VectorIndex(0, VectorIndex::OPEN_END))
319 {
320 return vMemory[findTable(_sTable)]->importTable(_table, lines, cols);
321 }
322
323 inline void importTable(NumeRe::Table _table, int _nLayer, const VectorIndex& lines = VectorIndex(0, VectorIndex::OPEN_END), const VectorIndex& cols = VectorIndex(0, VectorIndex::OPEN_END))
324 {
325 return vMemory[_nLayer]->importTable(_table, lines, cols);
326 }
327
328
329 // TABLE INPLACE MODIFICATION METHODS
330 std::vector<int> sortElements(const std::string& sLine);
331 std::vector<int> sortElements(const std::string& sCache, int i1, int i2, int j1 = 0, int j2 = 0, const std::string& sSortingExpression = "");
332
333 inline bool smooth(const std::string& _sCache, const VectorIndex& _vLine, const VectorIndex& _vCol, const NumeRe::FilterSettings& _settings, AppDir Direction = ALL)
334 {
335 return vMemory[findTable(_sCache)]->smooth(_vLine, _vCol, _settings, (Memory::AppDir)Direction);
336 }
337
338 inline bool retouch(const std::string& _sCache, const VectorIndex& _vLine, const VectorIndex& _vCol, AppDir Direction = ALL)
339 {
340 return vMemory[findTable(_sCache)]->retouch(_vLine, _vCol, (Memory::AppDir)Direction);
341 }
342
343 inline bool resample(const std::string& _sCache, const VectorIndex& _vLine, const VectorIndex& _vCol, std::pair<size_t,size_t> samples, AppDir Direction = ALL, std::string sFilter = "lanczos3")
344 {
345 return vMemory[findTable(_sCache)]->resample(_vLine, _vCol, samples, (Memory::AppDir)Direction, sFilter);
346 }
347
348 inline bool convertColumns(const std::string& _sTable, const VectorIndex& _vCol, const std::string& _sType)
349 {
350 return vMemory[findTable(_sTable)]->convertColumns(_vCol, _sType);
351 }
352
353 inline bool setCategories(const std::string& _sTable, const VectorIndex& _vCol, const std::vector<std::string>& vCategories)
354 {
355 return vMemory[findTable(_sTable)]->setCategories(_vCol, vCategories);
356 }
357
358 std::vector<mu::value_type> findCols(const std::string& sTable, const std::vector<std::string>& vCols) const
359 {
360 return vMemory[findTable(sTable)]->findCols(vCols);
361 }
362
363 std::vector<mu::value_type> countIfEqual(const std::string& sTable, const VectorIndex& _vCols,
364 const std::vector<mu::value_type>& vValues,
365 const std::vector<std::string>& vStringValues) const
366 {
367 return vMemory[findTable(sTable)]->countIfEqual(_vCols, vValues, vStringValues);
368 }
369
370 std::vector<mu::value_type> getIndex(const std::string& sTable, size_t nCol,
371 const std::vector<mu::value_type>& vValues,
372 const std::vector<std::string>& vStringValues) const
373 {
374 return vMemory[findTable(sTable)]->getIndex(nCol, vValues, vStringValues);
375 }
376
377 AnovaResult getOneWayAnova(const std::string& sTable,
378 size_t colCategories, size_t colValues, const VectorIndex& _vIndex, double significance) const
379 {
380 return vMemory[findTable(sTable)]->getOneWayAnova(colCategories, colValues, _vIndex, significance);
381 }
382
383 mu::value_type getCovariance(const std::string& sTable,
384 size_t col1, const VectorIndex& _vIndex1, size_t col2, const VectorIndex& _vIndex2) const
385 {
386 return vMemory[findTable(sTable)]->getCovariance(col1, _vIndex1, col2, _vIndex2);
387 }
388
389 mu::value_type getPearsonCorr(const std::string& sTable,
390 size_t col1, const VectorIndex& _vIndex1, size_t col2, const VectorIndex& _vIndex2) const
391 {
392 return vMemory[findTable(sTable)]->getPearsonCorr(col1, _vIndex1, col2, _vIndex2);
393 }
394
395 mu::value_type getSpearmanCorr(const std::string& sTable,
396 size_t col1, const VectorIndex& _vIndex1, size_t col2, const VectorIndex& _vIndex2) const
397 {
398 return vMemory[findTable(sTable)]->getSpearmanCorr(col1, _vIndex1, col2, _vIndex2);
399 }
400
401 std::vector<mu::value_type> getRank(const std::string& sTable,
402 size_t col, const VectorIndex& _vIndex, Memory::RankingStrategy _strat) const
403 {
404 return vMemory[findTable(sTable)]->getRank(col, _vIndex, _strat);
405 }
406
407 std::vector<mu::value_type> getZScore(const std::string& sTable,
408 size_t col, const VectorIndex& _vIndex) const
409 {
410 return vMemory[findTable(sTable)]->getZScore(col, _vIndex);
411 }
412
413 std::vector<mu::value_type> getBins(const std::string& sTable,
414 size_t col, size_t nBins) const
415 {
416 return vMemory[findTable(sTable)]->getBins(col, nBins);
417 }
418
419
420
421 // DIMENSION ACCESS METHODS
422 inline int getLines(StringView sTable, bool _bFull = false) const
423 {
424 size_t idx = mapStringViewFind(sTable);
425
426 if (idx != (size_t)-1)
427 return vMemory[idx]->getLines(_bFull);
428
429 return 0;
430 }
431
432 inline int getLines(const std::string& sTable, bool _bFull = false) const
433 {
434 auto iter = mCachesMap.find(sTable);
435
436 if (iter != mCachesMap.end())
437 return vMemory[findTable(sTable)]->getLines(_bFull);
438
439 return 0;
440 }
441
442 inline int getCols(StringView sTable, bool _bFull = false) const
443 {
444 size_t idx = mapStringViewFind(sTable);
445
446 if (idx != (size_t)-1)
447 return vMemory[idx]->getCols(_bFull);
448
449 return 0;
450 }
451
452 inline int getCols(const std::string& sTable, bool _bFull = false) const
453 {
454 auto iter = mCachesMap.find(sTable);
455
456 if (iter != mCachesMap.end())
457 return vMemory[findTable(sTable)]->getCols(_bFull);
458
459 return 0;
460 }
461
462 inline int getBytes(const std::string& sTable) const
463 {
464 return getSize(findTable(sTable));
465 }
466
467 inline int getSize(int _nLayer) const
468 {
469 if (vMemory.size() && _nLayer < (int)vMemory.size())
470 return vMemory[_nLayer]->getSize();
471
472 return 0;
473 }
474
475
476
477 // READ ACCESS METHODS
478 mu::value_type getElement(int _nLine, int _nCol, const std::string& _sTable) const
479 {
480 if (exists(_sTable))
481 return vMemory[findTable(_sTable)]->readMem(_nLine, _nCol);
482
483 return NAN;
484 }
485
486 std::vector<mu::value_type> getElement(const VectorIndex& _vLine, const VectorIndex& _vCol, const std::string& _sTable) const
487 {
488 if (exists(_sTable))
489 return vMemory[findTable(_sTable)]->readMem(_vLine, _vCol);
490
491 return std::vector<mu::value_type>();
492 }
493
494 ValueVector getElementMixed(const VectorIndex& _vLine, const VectorIndex& _vCol, const std::string& _sTable) const
495 {
496 if (exists(_sTable))
497 return vMemory[findTable(_sTable)]->readMixedMem(_vLine, _vCol);
498
499 return ValueVector();
500 }
501
502 ValueVector getElementAsString(const VectorIndex& _vLine, const VectorIndex& _vCol, const std::string& _sTable) const
503 {
504 if (exists(_sTable))
505 return vMemory[findTable(_sTable)]->readMemAsString(_vLine, _vCol);
506
507 return ValueVector();
508 }
509
510 TableColumn::ColumnType getType(const VectorIndex& _vCol, const std::string& _sTable) const
511 {
512 if (exists(_sTable))
513 return vMemory[findTable(_sTable)]->getType(_vCol);
514
516 }
517
518 ValueVector getCategoryList(const VectorIndex& _vCol, const std::string& _sTable) const
519 {
520 if (exists(_sTable))
521 return vMemory[findTable(_sTable)]->getCategoryList(_vCol);
522
523 return ValueVector();
524 }
525
526 void copyElementsInto(std::vector<mu::value_type>* vTarget, const VectorIndex& _vLine, const VectorIndex& _vCol, const std::string& _sTable) const
527 {
528 vMemory[findTable(_sTable)]->copyElementsInto(vTarget, _vLine, _vCol);
529 }
530
531 int getHeadlineCount(const std::string& _sTable) const
532 {
533 if (exists(_sTable))
534 return vMemory[findTable(_sTable)]->getHeadlineCount();
535
536 return 0;
537 }
538
539 std::string getHeadLineElement(int _i, const std::string& _sTable) const
540 {
541 if (exists(_sTable))
542 return vMemory[findTable(_sTable)]->getHeadLineElement(_i);
543
544 return "";
545 }
546
547 std::vector<std::string> getHeadLineElement(const VectorIndex& _vCol, const std::string& _sTable) const
548 {
549 if (exists(_sTable))
550 return vMemory[findTable(_sTable)]->getHeadLineElement(_vCol);
551
552 return std::vector<std::string>();
553 }
554
555 std::string getTopHeadLineElement(int _i, const std::string& _sTable) const
556 {
557 return getHeadLineElement(_i, _sTable).substr(0, getHeadLineElement(_i, _sTable).find('\n'));
558 }
559
560 int getAppendedZeroes(int _i, const std::string& _sTable) const
561 {
562 return vMemory[findTable(_sTable)]->getAppendedZeroes(_i);
563 }
564
565 int getColElements(const VectorIndex& cols, const std::string& _sTable) const;
566
567 std::string getComment(const std::string& _sTable) const
568 {
569 return vMemory[findTable(_sTable)]->getComment();
570 }
571
572 NumeRe::TableMetaData getMetaData(const std::string& _sTable) const
573 {
574 return vMemory[findTable(_sTable)]->getMetaData();
575 }
576
577 // WRITE ACCESS METHODS
578 inline void writeToTable(int _nLine, int _nCol, const std::string& _sCache, const mu::value_type& _dData)
579 {
580 vMemory[findTable(_sCache)]->writeData(_nLine, _nCol, _dData);
581 }
582
583 inline void writeToTable(int _nLine, int _nCol, const std::string& _sCache, const std::string& _sValue)
584 {
585 vMemory[findTable(_sCache)]->writeData(_nLine, _nCol, _sValue);
586 }
587
588 inline void writeToTable(Indices& _idx, const std::string& _sCache, mu::value_type* _dData, unsigned int _nNum)
589 {
590 vMemory[findTable(_sCache)]->writeData(_idx, _dData, _nNum);
591 }
592
593 inline void writeToTable(Indices& _idx, const std::string& _sCache, const ValueVector& _values)
594 {
595 vMemory[findTable(_sCache)]->writeData(_idx, _values);
596 }
597
598 bool setHeadLineElement(int _i, const std::string& _sTable, std::string _sHead)
599 {
600 return vMemory[findTable(_sTable)]->setHeadLineElement(_i, _sHead);
601 }
602
603 void overwriteColumn(int col, const std::string& _sCache, TableColumn::ColumnType type);
604
605 void writeComment(const std::string& _sTable, const std::string& _comment)
606 {
607 vMemory[findTable(_sTable)]->writeComment(_comment);
608 }
609
610 void setMetaData(const std::string& _sTable, const NumeRe::TableMetaData& meta)
611 {
612 vMemory[findTable(_sTable)]->setMetaData(meta);
613 }
614
615
616 // MAF METHODS
617 // IMPLEMENTATIONS FOR THE TABLE METHODS
618 std::vector<mu::value_type> std(const std::string& sTable, std::string sDir) const
619 {
620 return resolveMAF(sTable, sDir, MemoryManager::std);
621 }
622
623 std::vector<mu::value_type> avg(const std::string& sTable, std::string sDir) const
624 {
625 return resolveMAF(sTable, sDir, MemoryManager::avg);
626 }
627
628 std::vector<mu::value_type> max(const std::string& sTable, std::string sDir) const
629 {
630 return resolveMAF(sTable, sDir, MemoryManager::max);
631 }
632
633 std::vector<mu::value_type> min(const std::string& sTable, std::string sDir) const
634 {
635 return resolveMAF(sTable, sDir, MemoryManager::min);
636 }
637
638 std::vector<mu::value_type> prd(const std::string& sTable, std::string sDir) const
639 {
640 return resolveMAF(sTable, sDir, MemoryManager::prd);
641 }
642
643 std::vector<mu::value_type> sum(const std::string& sTable, std::string sDir) const
644 {
645 return resolveMAF(sTable, sDir, MemoryManager::sum);
646 }
647
648 std::vector<mu::value_type> num(const std::string& sTable, std::string sDir) const
649 {
650 return resolveMAF(sTable, sDir, MemoryManager::num);
651 }
652
653 std::vector<mu::value_type> and_func(const std::string& sTable, std::string sDir) const
654 {
655 return resolveMAF(sTable, sDir, MemoryManager::and_func);
656 }
657
658 std::vector<mu::value_type> or_func(const std::string& sTable, std::string sDir) const
659 {
660 return resolveMAF(sTable, sDir, MemoryManager::or_func);
661 }
662
663 std::vector<mu::value_type> xor_func(const std::string& sTable, std::string sDir) const
664 {
665 return resolveMAF(sTable, sDir, MemoryManager::xor_func);
666 }
667
668 std::vector<mu::value_type> cnt(const std::string& sTable, std::string sDir) const
669 {
670 return resolveMAF(sTable, sDir, MemoryManager::cnt);
671 }
672
673 std::vector<mu::value_type> norm(const std::string& sTable, std::string sDir) const
674 {
675 return resolveMAF(sTable, sDir, MemoryManager::norm);
676 }
677
678 std::vector<mu::value_type> med(const std::string& sTable, std::string sDir) const
679 {
680 return resolveMAF(sTable, sDir, MemoryManager::med);
681 }
682
683 std::vector<mu::value_type> cmp(const std::string& sTable, std::string sDir, mu::value_type dRef = 0.0, int nType = 0) const
684 {
685 std::vector<mu::value_type> vResults;
686 long long int nlines = getLines(sTable, false);
687 long long int ncols = getCols(sTable, false);
688
689 long long int nGridOffset = sDir.find("grid") != std::string::npos ? 2 : 0;
690
691 // If a grid is required, get the grid dimensions
692 // of this table
693 if (nGridOffset)
694 {
695 std::vector<mu::value_type> vSize = vMemory[findTable(sTable)]->size(VectorIndex(), GRID);
696 nlines = vSize.front().real();
697 ncols = vSize.back().real()+nGridOffset; // compensate the offset
698 }
699
700 VectorIndex _idx = parseEvery(sDir, sTable);
701
702 if (sDir.find("cols") != std::string::npos)
703 {
704 for (size_t i = 0; i < _idx.size(); i++)
705 {
706 if (_idx[i]+nGridOffset < 0 || _idx[i]+nGridOffset >= ncols)
707 continue;
708
709 vResults.push_back(cmp(sTable, 0, nlines-1, _idx[i]+nGridOffset, -1, dRef.real(), nType));
710 }
711 }
712 else if (sDir.find("lines") != std::string::npos)
713 {
714 for (size_t i = 0; i < _idx.size(); i++)
715 {
716 if (_idx[i]+nGridOffset < 0 || _idx[i]+nGridOffset >= nlines)
717 continue;
718
719 vResults.push_back(cmp(sTable, _idx[i]+nGridOffset, -1, 0, ncols-1, dRef.real(), nType));
720 }
721 }
722 else
723 vResults.push_back(cmp(sTable, 0, nlines-1, nGridOffset, ncols-1, dRef.real(), nType));
724
725 if (!vResults.size())
726 vResults.push_back(NAN);
727
728 return vResults;
729 }
730
731 std::vector<mu::value_type> pct(const std::string& sTable, std::string sDir, mu::value_type dPct = 0.5) const
732 {
733 std::vector<mu::value_type> vResults;
734 long long int nlines = getLines(sTable, false);
735 long long int ncols = getCols(sTable, false);
736
737 long long int nGridOffset = sDir.find("grid") != std::string::npos ? 2 : 0;
738
739 // If a grid is required, get the grid dimensions
740 // of this table
741 if (nGridOffset)
742 {
743 std::vector<mu::value_type> vSize = vMemory[findTable(sTable)]->size(VectorIndex(), GRID);
744 nlines = vSize.front().real();
745 ncols = vSize.back().real()+nGridOffset; // compensate the offset
746 }
747
748 VectorIndex _idx = parseEvery(sDir, sTable);
749
750 if (sDir.find("cols") != std::string::npos)
751 {
752 for (size_t i = 0; i < _idx.size(); i++)
753 {
754 if (_idx[i]+nGridOffset < 0 || _idx[i]+nGridOffset >= ncols)
755 continue;
756
757 vResults.push_back(pct(sTable, 0, nlines-1, _idx[i]+nGridOffset, -1, dPct.real()));
758 }
759 }
760 else if (sDir.find("lines") != std::string::npos)
761 {
762 for (size_t i = 0; i < _idx.size(); i++)
763 {
764 if (_idx[i]+nGridOffset < 0 || _idx[i]+nGridOffset >= nlines)
765 continue;
766
767 vResults.push_back(pct(sTable, _idx[i]+nGridOffset, -1, 0, ncols-1, dPct.real()));
768 }
769 }
770 else
771 vResults.push_back(pct(sTable, 0, nlines-1, nGridOffset, ncols-1, dPct.real()));
772
773 if (!vResults.size())
774 vResults.push_back(NAN);
775
776 return vResults;
777 }
778
779 std::vector<mu::value_type> size(const std::string& sTable, std::string sDir) const
780 {
781 VectorIndex _idx = parseEvery(sDir, sTable);
782
783 if (sDir.find("cols") != std::string::npos)
784 return vMemory[findTable(sTable)]->size(_idx, COLS | (sDir.find("grid") != std::string::npos ? GRID : 0));
785 else if (sDir.find("lines") != std::string::npos)
786 return vMemory[findTable(sTable)]->size(_idx, LINES | (sDir.find("grid") != std::string::npos ? GRID : 0));
787 else
788 return vMemory[findTable(sTable)]->size(VectorIndex(), sDir.find("grid") != std::string::npos ? GRID : ALL);
789 }
790
791 std::vector<mu::value_type> minpos(const std::string& sTable, std::string sDir) const
792 {
793 VectorIndex _idx = parseEvery(sDir, sTable);
794
795 if (sDir.find("cols") != std::string::npos)
796 return vMemory[findTable(sTable)]->minpos(_idx, COLS | (sDir.find("grid") != std::string::npos ? GRID : 0));
797 else if (sDir.find("lines") != std::string::npos)
798 return vMemory[findTable(sTable)]->minpos(_idx, LINES | (sDir.find("grid") != std::string::npos ? GRID : 0));
799 else
800 return vMemory[findTable(sTable)]->minpos(VectorIndex(0, VectorIndex::OPEN_END), sDir.find("grid") != std::string::npos ? GRID : ALL);
801 }
802
803 std::vector<mu::value_type> maxpos(const std::string& sTable, std::string sDir) const
804 {
805 VectorIndex _idx = parseEvery(sDir, sTable);
806
807 if (sDir.find("cols") != std::string::npos)
808 return vMemory[findTable(sTable)]->maxpos(_idx, COLS | (sDir.find("grid") != std::string::npos ? GRID : 0));
809 else if (sDir.find("lines") != std::string::npos)
810 return vMemory[findTable(sTable)]->maxpos(_idx, LINES | (sDir.find("grid") != std::string::npos ? GRID : 0));
811 else
812 return vMemory[findTable(sTable)]->maxpos(VectorIndex(0, VectorIndex::OPEN_END), sDir.find("grid") != std::string::npos ? GRID : ALL);
813 }
814
815
816 // IMPLEMENTATIONS FOR THE MAFS
817 inline mu::value_type std(const std::string& _sCache, long long int i1, long long int i2, long long int j1 = 0, long long int j2 = -1) const
818 {
819 return vMemory[findTable(_sCache)]->std(VectorIndex(i1, i2), VectorIndex(j1, j2));
820 }
821
822 inline mu::value_type std(const std::string& _sCache, const VectorIndex& _vLine, const VectorIndex& _vCol) const
823 {
824 return vMemory[findTable(_sCache)]->std(_vLine, _vCol);
825 }
826
827 inline mu::value_type avg(const std::string& _sCache, long long int i1, long long int i2, long long int j1 = 0, long long int j2 = -1) const
828 {
829 return vMemory[findTable(_sCache)]->avg(VectorIndex(i1, i2), VectorIndex(j1, j2));
830 }
831
832 inline mu::value_type avg(const std::string& _sCache, const VectorIndex& _vLine, const VectorIndex& _vCol) const
833 {
834 return vMemory[findTable(_sCache)]->avg(_vLine, _vCol);
835 }
836
837 inline mu::value_type max(const std::string& _sCache, long long int i1, long long int i2, long long int j1 = 0, long long int j2 = -1) const
838 {
839 return vMemory[findTable(_sCache)]->max(VectorIndex(i1, i2), VectorIndex(j1, j2));
840 }
841
842 inline mu::value_type max(const std::string& _sCache, const VectorIndex& _vLine, const VectorIndex& _vCol) const
843 {
844 return vMemory[findTable(_sCache)]->max(_vLine, _vCol);
845 }
846
847 inline mu::value_type min(const std::string& _sCache, long long int i1, long long int i2, long long int j1 = 0, long long int j2 = -1) const
848 {
849 return vMemory[findTable(_sCache)]->min(VectorIndex(i1, i2), VectorIndex(j1, j2));
850 }
851
852 inline mu::value_type min(const std::string& _sCache, const VectorIndex& _vLine, const VectorIndex& _vCol) const
853 {
854 return vMemory[findTable(_sCache)]->min(_vLine, _vCol);
855 }
856
857 inline mu::value_type prd(const std::string& _sCache, const VectorIndex& _vLine, const VectorIndex& _vCol) const
858 {
859 return vMemory[findTable(_sCache)]->prd(_vLine, _vCol);
860 }
861
862 inline mu::value_type prd(const std::string& _sCache, long long int i1, long long int i2, long long int j1 = 0, long long int j2 = -1) const
863 {
864 return vMemory[findTable(_sCache)]->prd(VectorIndex(i1, i2), VectorIndex(j1, j2));
865 }
866
867 inline mu::value_type sum(const std::string& _sCache, const VectorIndex& _vLine, const VectorIndex& _vCol) const
868 {
869 return vMemory[findTable(_sCache)]->sum(_vLine, _vCol);
870 }
871
872 inline mu::value_type sum(const std::string& _sCache, long long int i1, long long int i2, long long int j1 = 0, long long int j2 = -1) const
873 {
874 return vMemory[findTable(_sCache)]->sum(VectorIndex(i1, i2), VectorIndex(j1, j2));
875 }
876
877 inline mu::value_type num(const std::string& _sCache, const VectorIndex& _vLine, const VectorIndex& _vCol) const
878 {
879 return vMemory[findTable(_sCache)]->num(_vLine, _vCol);
880 }
881
882 inline mu::value_type num(const std::string& _sCache, long long int i1, long long int i2, long long int j1 = 0, long long int j2 = -1) const
883 {
884 return vMemory[findTable(_sCache)]->num(VectorIndex(i1, i2), VectorIndex(j1, j2));
885 }
886
887 inline mu::value_type and_func(const std::string& _sCache, long long int i1, long long int i2, long long int j1 = 0, long long int j2 = -1) const
888 {
889 return vMemory[findTable(_sCache)]->and_func(VectorIndex(i1, i2), VectorIndex(j1, j2));
890 }
891
892 inline mu::value_type and_func(const std::string& _sCache, const VectorIndex& _vLine, const VectorIndex& _vCol) const
893 {
894 return vMemory[findTable(_sCache)]->and_func(_vLine, _vCol);
895 }
896
897 inline mu::value_type or_func(const std::string& _sCache, long long int i1, long long int i2, long long int j1 = 0, long long int j2 = -1) const
898 {
899 return vMemory[findTable(_sCache)]->or_func(VectorIndex(i1, i2), VectorIndex(j1, j2));
900 }
901
902 inline mu::value_type or_func(const std::string& _sCache, const VectorIndex& _vLine, const VectorIndex& _vCol) const
903 {
904 return vMemory[findTable(_sCache)]->or_func(_vLine, _vCol);
905 }
906
907 inline mu::value_type xor_func(const std::string& _sCache, long long int i1, long long int i2, long long int j1 = 0, long long int j2 = -1) const
908 {
909 return vMemory[findTable(_sCache)]->xor_func(VectorIndex(i1, i2), VectorIndex(j1, j2));
910 }
911
912 inline mu::value_type xor_func(const std::string& _sCache, const VectorIndex& _vLine, const VectorIndex& _vCol) const
913 {
914 return vMemory[findTable(_sCache)]->xor_func(_vLine, _vCol);
915 }
916
917 inline mu::value_type cnt(const std::string& _sCache, const VectorIndex& _vLine, const VectorIndex& _vCol) const
918 {
919 return vMemory[findTable(_sCache)]->cnt(_vLine, _vCol);
920 }
921
922 inline mu::value_type cnt(const std::string& _sCache, long long int i1, long long int i2, long long int j1 = 0, long long int j2 = -1) const
923 {
924 return vMemory[findTable(_sCache)]->cnt(VectorIndex(i1, i2), VectorIndex(j1, j2));
925 }
926
927 inline mu::value_type norm(const std::string& _sCache, const VectorIndex& _vLine, const VectorIndex& _vCol) const
928 {
929 return vMemory[findTable(_sCache)]->norm(_vLine, _vCol);
930 }
931
932 inline mu::value_type norm(const std::string& _sCache, long long int i1, long long int i2, long long int j1 = 0, long long int j2 = -1) const
933 {
934 return vMemory[findTable(_sCache)]->norm(VectorIndex(i1, i2), VectorIndex(j1, j2));
935 }
936
937 inline mu::value_type cmp(const std::string& _sCache, const VectorIndex& _vLine, const VectorIndex& _vCol, mu::value_type dRef = 0.0, int nType = 0) const
938 {
939 return vMemory[findTable(_sCache)]->cmp(_vLine, _vCol, dRef, nType);
940 }
941
942 inline mu::value_type cmp(const std::string& _sCache, long long int i1, long long int i2, long long int j1 = 0, long long int j2 = -1, mu::value_type dRef = 0.0, int nType = 0) const
943 {
944 return vMemory[findTable(_sCache)]->cmp(VectorIndex(i1, i2), VectorIndex(j1, j2), dRef, nType);
945 }
946
947 inline mu::value_type med(const std::string& _sCache, const VectorIndex& _vLine, const VectorIndex& _vCol) const
948 {
949 return vMemory[findTable(_sCache)]->med(_vLine, _vCol);
950 }
951
952 inline mu::value_type med(const std::string& _sCache, long long int i1, long long int i2, long long int j1 = 0, long long int j2 = -1) const
953 {
954 return vMemory[findTable(_sCache)]->med(VectorIndex(i1, i2), VectorIndex(j1, j2));
955 }
956
957 inline mu::value_type pct(const std::string& _sCache, const VectorIndex& _vLine, const VectorIndex& _vCol, mu::value_type dPct = 0.5) const
958 {
959 return vMemory[findTable(_sCache)]->pct(_vLine, _vCol, dPct);
960 }
961
962 inline mu::value_type pct(const std::string& _sCache, long long int i1, long long int i2, long long int j1 = 0, long long int j2 = -1, mu::value_type dPct = 0.5) const
963 {
964 return vMemory[findTable(_sCache)]->pct(VectorIndex(i1, i2), VectorIndex(j1, j2), dPct);
965 }
966
967};
968
969#endif
970
971
std::string ValidFileName(std::string _sFileName, const std::string sExtension=".dat", bool checkExtension=true, bool doCleanPath=true) const
This member function evaluates, whether the passed filename is a valid filename. One may supply a pre...
Definition: filesystem.cpp:280
This class represents a single table in memory, or a - so to say - single memory page to be handled b...
Definition: memory.hpp:68
AppDir
Definition: memory.hpp:71
@ GRID
Definition: memory.hpp:75
@ LINES
Definition: memory.hpp:73
@ COLS
Definition: memory.hpp:74
@ ALL
Definition: memory.hpp:72
RankingStrategy
Definition: memory.hpp:79
This class represents the central memory managing instance. It will handle all tables and clusters,...
std::string matchTableAsParameter(const std::string &sExpression, char cFollowing=' ')
TableColumn::ColumnType getType(const VectorIndex &_vCol, const std::string &_sTable) const
mu::value_type cnt(const std::string &_sCache, long long int i1, long long int i2, long long int j1=0, long long int j2=-1) const
void removeData(bool bAutoSave=false)
Removes the "data()" table, if it is available.
mu::value_type and_func(const std::string &_sCache, const VectorIndex &_vLine, const VectorIndex &_vCol) const
bool loadFromNewCacheFile()
This member function tries to load the contents of the cache file in the new cache file format....
std::vector< mu::value_type > getElement(const VectorIndex &_vLine, const VectorIndex &_vCol, const std::string &_sTable) const
std::vector< mu::value_type > med(const std::string &sTable, std::string sDir) const
void reorderColumn(size_t _nLayer, const std::vector< int > &vIndex, long long int i1, long long int i2, long long int j1=0)
size_t mapStringViewFind(StringView view) 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
int getHeadlineCount(const std::string &_sTable) const
mu::value_type std(const std::string &_sCache, const VectorIndex &_vLine, const VectorIndex &_vCol) const
bool smooth(const std::string &_sCache, const VectorIndex &_vLine, const VectorIndex &_vCol, const NumeRe::FilterSettings &_settings, AppDir Direction=ALL)
std::string sPluginCommands
mu::value_type num(const std::string &_sCache, long long int i1, long long int i2, long long int j1=0, long long int j2=-1) const
bool saveToCacheFile()
This member function saves the contents of this class to the cache file so that they may be restored ...
std::string getComment(const std::string &_sTable) const
mu::value_type std(const std::string &_sCache, long long int i1, long long int i2, long long int j1=0, long long int j2=-1) const
mu::value_type or_func(const std::string &_sCache, long long int i1, long long int i2, long long int j1=0, long long int j2=-1) const
std::vector< mu::value_type > findCols(const std::string &sTable, const std::vector< std::string > &vCols) const
std::string sUserdefinedFuncs
mu::value_type pct(const std::string &_sCache, const VectorIndex &_vLine, const VectorIndex &_vCol, mu::value_type dPct=0.5) const
mu::value_type tableLinesCount
bool getSaveStatus() const
Returns, whether there's at least a single table in memory, which has not been saved yet.
mu::value_type num(const std::string &_sCache, const VectorIndex &_vLine, const VectorIndex &_vCol) const
ValueVector getElementAsString(const VectorIndex &_vLine, const VectorIndex &_vCol, const std::string &_sTable) const
int getAppendedZeroes(int _i, const std::string &_sTable) const
mu::value_type cmp(const std::string &_sCache, const VectorIndex &_vLine, const VectorIndex &_vCol, mu::value_type dRef=0.0, int nType=0) 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
mu::value_type pct(const std::string &_sCache, long long int i1, long long int i2, long long int j1=0, long long int j2=-1, mu::value_type dPct=0.5) const
mu::value_type and_func(const std::string &_sCache, long long int i1, long long int i2, long long int j1=0, long long int j2=-1) const
mu::value_type tableColumnsCount
void importTable(NumeRe::Table _table, int _nLayer, const VectorIndex &lines=VectorIndex(0, VectorIndex::OPEN_END), const VectorIndex &cols=VectorIndex(0, VectorIndex::OPEN_END))
std::vector< int > sortElements(const std::string &sLine)
This member function wraps the sorting functionality and evaluates the passed parameter string before...
bool isValidElement(long long int _nLine, long long int _nCol, const std::string &_sTable) const
std::vector< mu::value_type > min(const std::string &sTable, std::string sDir) const
long long int getLastSaved() const
Returns the earliest time-point, when a table was saved. This value is used to determine the elapsed ...
std::vector< mu::value_type > norm(const std::string &sTable, std::string sDir) const
mu::value_type avg(const std::string &_sCache, long long int i1, long long int i2, long long int j1=0, long long int j2=-1) const
std::string getTopHeadLineElement(int _i, const std::string &_sTable) const
virtual void melt(Memory *_mem, const std::string &sTable, bool overrideTarget=false) override
This member function either combines the contents of the passed Memory instance with an existing one ...
std::vector< mu::value_type > pct(const std::string &sTable, std::string sDir, mu::value_type dPct=0.5) const
void deleteBulk(const std::string &_sCache, const VectorIndex &_vLine, const VectorIndex &_vCol)
void removeTablesFromMemory()
Removes all tables in memory and re- initializes the MemoryManager with the default table.
void deleteBulk(const std::string &_sCache, int i1, int i2, int j1=0, int j2=0)
NumeRe::TableMetaData getMetaData(const std::string &_sTable) const
mu::value_type cnt(const std::string &_sCache, const VectorIndex &_vLine, const VectorIndex &_vCol) 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
mu::value_type xor_func(const std::string &_sCache, const VectorIndex &_vLine, const VectorIndex &_vCol) const
void shrink(const std::string &_sCache)
bool exists(const std::string &sTable) const
mu::value_type sum(const std::string &_sCache, long long int i1, long long int i2, long long int j1=0, long long int j2=-1) const
mu::value_type sum(const std::string &_sCache, const VectorIndex &_vLine, const VectorIndex &_vCol) const
mu::value_type min(const std::string &_sCache, const VectorIndex &_vLine, const VectorIndex &_vCol) const
const std::map< std::string, std::pair< size_t, size_t > > & getTableMap() const
mu::value_type xor_func(const std::string &_sCache, long long int i1, long long int i2, long long int j1=0, long long int j2=-1) const
mu::value_type norm(const std::string &_sCache, const VectorIndex &_vLine, const VectorIndex &_vCol) const
mu::value_type min(const std::string &_sCache, long long int i1, long long int i2, long long int j1=0, long long int j2=-1) const
void setPredefinedCommands(const std::string &sCommands)
mu::value_type max(const std::string &_sCache, const VectorIndex &_vLine, const VectorIndex &_vCol) const
std::vector< Memory * > vMemory
NumeRe::Table extractTable(int _nLayer, const std::string &_sTable="", const VectorIndex &lines=VectorIndex(0, VectorIndex::OPEN_END), const VectorIndex &cols=VectorIndex(0, VectorIndex::OPEN_END))
mu::value_type med(const std::string &_sCache, const VectorIndex &_vLine, const VectorIndex &_vCol) const
std::vector< mu::value_type > cmp(const std::string &sTable, std::string sDir, mu::value_type dRef=0.0, int nType=0) const
virtual bool saveLayer(std::string _sFileName, const std::string &_sTable, unsigned short nPrecision) override
bool setCategories(const std::string &_sTable, const VectorIndex &_vCol, const std::vector< std::string > &vCategories)
bool isEmpty(const std::string &sTable) 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 prd(const std::string &_sCache, const VectorIndex &_vLine, const VectorIndex &_vCol) const
size_t findTable(const std::string &sTable) const
std::fstream cache_file
void setUserdefinedFuncs(const std::string &sUserFuncs)
void swapTables(std::string sTable1, std::string sTable2)
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
bool deleteTable(const std::string &sCache)
This member function removes the selected table.
void setMetaData(const std::string &_sTable, const NumeRe::TableMetaData &meta)
NumeRe::Table extractTable(const std::string &_sTable, const VectorIndex &lines=VectorIndex(0, VectorIndex::OPEN_END), const VectorIndex &cols=VectorIndex(0, VectorIndex::OPEN_END))
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 writeToTable(Indices &_idx, const std::string &_sCache, mu::value_type *_dData, unsigned int _nNum)
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
void setCacheFileName(std::string _sFileName)
This member function updates the name of the cache file.
void overwriteColumn(int col, const std::string &_sCache, TableColumn::ColumnType type)
This member function converts the selected column to the needed type, if this column shall be overwri...
void writeToTable(Indices &_idx, const std::string &_sCache, const ValueVector &_values)
unsigned int getNumberOfTables() const
void setPredefinedFuncs(const std::string &sFuncs)
bool retouch(const std::string &_sCache, const VectorIndex &_vLine, const VectorIndex &_vCol, AppDir Direction=ALL)
mu::value_type med(const std::string &_sCache, long long int i1, long long int i2, long long int j1=0, long long int j2=-1) 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
int getCols(const std::string &sTable, bool _bFull=false) const
bool resample(const std::string &_sCache, const VectorIndex &_vLine, const VectorIndex &_vCol, std::pair< size_t, size_t > samples, AppDir Direction=ALL, std::string sFilter="lanczos3")
void importTable(NumeRe::Table _table, const std::string &_sTable, const VectorIndex &lines=VectorIndex(0, VectorIndex::OPEN_END), const VectorIndex &cols=VectorIndex(0, VectorIndex::OPEN_END))
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
mu::value_type max(const std::string &_sCache, long long int i1, long long int i2, long long int j1=0, long long int j2=-1) const
bool isValid() const
Evaluates, whether there's at least a single non-empty table.
std::vector< mu::value_type > std(const std::string &sTable, std::string sDir) const
void setSaveStatus(bool _bIsSaved)
Changes the save status of all tables in memory.
std::vector< mu::value_type > getZScore(const std::string &sTable, size_t col, const VectorIndex &_vIndex) const
bool loadFromLegacyCacheFile()
This member function loads the contents of the cache file assuming the legacy format.
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
void deleteEntry(int _nLine, int _nCol, const std::string &_sCache)
bool addTable(const std::string &sCache, const Settings &_option)
This member function creates a new table. It is checked, whether its name is valid and not already us...
void renameTable(const std::string &sCache, const std::string &sNewName, bool bForceRenaming=false)
bool updateDimensionVariables(StringView sTableName)
This member function updates the dimension variables for the selected table to be used in expressions...
bool resizeTable(int _nCols, const std::string &_sTable)
Memory * getTable(const std::string &sTable)
This member function returns a pointer to an existing Memory instance representing the selected table...
VectorIndex parseEvery(std::string &sDir, const std::string &sTableName) const
This member function extracts and parses the every expression part of a MAF call.
AnovaResult getOneWayAnova(const std::string &sTable, size_t colCategories, size_t colValues, const VectorIndex &_vIndex, double significance) const
std::string getTableNames() const
mu::value_type avg(const std::string &_sCache, const VectorIndex &_vLine, const VectorIndex &_vCol) const
bool containsTablesOrClusters(const std::string &sCmdLine)
This member function evaluates, whether the passed command line contains tables or clusters.
~MemoryManager()
MemoryManager destructor. Clears all created tables.
int getLines(const std::string &sTable, bool _bFull=false) const
std::string sPredefinedFuncs
void writeToTable(int _nLine, int _nCol, const std::string &_sCache, const mu::value_type &_dData)
std::vector< mu::value_type > resolveMAF(const std::string &sTableName, std::string sDir, mu::value_type(MemoryManager::*MAF)(const std::string &, long long int, long long int, long long int, long long int) const) const
This member function is the abstract implementation of a MAF function call. Most of the MAFs use this...
std::string sPredefinedCommands
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
mu::value_type prd(const std::string &_sCache, long long int i1, long long int i2, long long int j1=0, long long int j2=-1) const
std::vector< mu::value_type > minpos(const std::string &sTable, std::string sDir) const
MemoryManager()
Default MemoryManager constructor. Creates the default table and initializes the list of predefined c...
bool convertColumns(const std::string &_sTable, const VectorIndex &_vCol, const std::string &_sType)
mu::value_type cmp(const std::string &_sCache, long long int i1, long long int i2, long long int j1=0, long long int j2=-1, mu::value_type dRef=0.0, int nType=0) const
mu::value_type or_func(const std::string &_sCache, const VectorIndex &_vLine, const VectorIndex &_vCol) const
void writeToTable(int _nLine, int _nCol, const std::string &_sCache, const std::string &_sValue)
bool loadFromCacheFile()
This member function wraps the loading of the tables from the cache file. It will automatically detec...
int getBytes(const std::string &sTable) const
std::vector< mu::value_type > maxpos(const std::string &sTable, std::string sDir) const
int getSize(int _nLayer) const
std::map< std::string, std::pair< size_t, size_t > > mCachesMap
std::vector< mu::value_type > size(const std::string &sTable, std::string sDir) const
bool setHeadLineElement(int _i, const std::string &_sTable, std::string _sHead)
std::vector< std::string > getHeadLineElement(const VectorIndex &_vCol, const std::string &_sTable) const
std::string sCache_file
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.
void setPluginCommands(const std::string &sPluginCmds)
mu::value_type norm(const std::string &_sCache, long long int i1, long long int i2, long long int j1=0, long long int j2=-1) const
std::vector< mu::value_type > prd(const std::string &sTable, std::string sDir) const
This class is the management class for the different clusters, which are currently available in memor...
Definition: cluster.hpp:447
This class represents the file input and output adapter for the MemoryManager class,...
Definition: fileadapter.hpp:39
This data container is a copy- efficient table to interchange data between Kernel and GUI.
Definition: table.hpp:87
This class manages the setting values of the internal (kernel) settings of this application.
Definition: settings.hpp:663
std::string to_string() const
This member function returns a copy of the viewed section of the string (via std::string::substr)....
This class is the immutable (const) version of a string view. It can be constructed from a MutableStr...
Common exception class for all exceptions thrown in NumeRe.
Definition: error.hpp:32
@ CACHE_ALREADY_EXISTS
Definition: error.hpp:45
@ TABLE_DOESNT_EXIST
INSERT HERE.
Definition: error.hpp:211
@ CACHE_DOESNT_EXIST
Definition: error.hpp:47
@ CACHE_CANNOT_BE_RENAMED
Definition: error.hpp:46
static size_t invalid_position
Definition: error.hpp:235
This class abstracts all the index logics, i.e. the logical differences between single indices and in...
Definition: structures.hpp:42
size_t size() const
This member function returns the size of the indices stored in this class.
Definition: structures.hpp:314
std::vector< std::string > ValueVector
This type defines a generic value vector.
Definition: memory.hpp:58
MUP_BASETYPE value_type
The numeric datatype used by the parser.
Definition: muParserDef.h:251
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,...
Definition: tools.cpp:113
Contains the relevant results of the ANOVA F test.
Definition: memory.hpp:40
This structure is central for managing the indices of a table or cluster read or write data access....
This structure contains the necessary information to create an instance of one of the following filte...
Definition: filtering.hpp:40
Encapsulating structure to gather all table meta data information.
Definition: table.hpp:32