-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanalysisresult.hpp
More file actions
89 lines (74 loc) · 2.96 KB
/
analysisresult.hpp
File metadata and controls
89 lines (74 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// SPDX-FileCopyrightText: 2024 Petros Koutsolampros
//
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#include "genlib/simplematrix.hpp"
#include "latticemap.hpp"
#include "shapegraph.hpp"
#include "shapemap.hpp"
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
struct AnalysisResult {
bool completed = false;
private:
[[maybe_unused]] unsigned _padding0 : 3 * 8;
[[maybe_unused]] unsigned _padding1 : 4 * 8;
public:
std::optional<std::vector<AttributeColumnStats>> columnStats = std::nullopt;
void addAttribute(std::string attribute) {
auto colIt = std::find(m_newAttributes.begin(), m_newAttributes.end(), attribute);
if (colIt == m_newAttributes.end()) {
m_newAttributes.push_back(attribute);
}
}
const std::vector<std::string> &getAttributes() const { return m_newAttributes; }
size_t getColumnIndex(const std::string &column) {
auto iter = std::find(m_newAttributes.begin(), m_newAttributes.end(), column);
if (iter == m_newAttributes.end()) {
std::stringstream message;
message << "Unknown column name " << column;
throw std::out_of_range(message.str());
}
return static_cast<size_t>(std::distance(m_newAttributes.begin(), iter));
}
double getValue(size_t row, size_t column) { return m_attributeDatata(row, column); }
void setValue(size_t row, size_t column, double value) {
m_attributeDatata(row, column) = value;
}
void incrValue(size_t row, size_t column, double value = 1) {
m_attributeDatata(row, column) += value;
}
AnalysisResult(std::vector<std::string> &&attributeNames = std::vector<std::string>(),
size_t rowCount = 0, double defValue = -1.0f)
: _padding0(0), _padding1(0), m_newAttributes(attributeNames),
m_attributeDatata(genlib::RowMatrix<double>(rowCount, attributeNames.size())),
m_newShapeMaps(), m_newLatticeMaps(), m_newShapeGraphs() {
m_attributeDatata.initialiseValues(defValue);
}
genlib::RowMatrix<double> getAttributeData() const { return m_attributeDatata; }
protected:
std::vector<std::string> m_newAttributes = std::vector<std::string>();
genlib::RowMatrix<double> m_attributeDatata;
std::vector<ShapeMap> m_newShapeMaps;
std::vector<LatticeMap> m_newLatticeMaps;
std::vector<ShapeGraph> m_newShapeGraphs;
};
struct AppendableAnalysisResult : public AnalysisResult {
bool firstRun = true;
private:
[[maybe_unused]] unsigned _padding0 : 3 * 8;
[[maybe_unused]] unsigned _padding1 : 4 * 8;
public:
void append(const AnalysisResult &other) {
if (firstRun) {
completed = other.completed;
firstRun = false;
} else {
completed &= other.completed;
}
m_newAttributes.insert(m_newAttributes.end(), other.getAttributes().begin(),
other.getAttributes().end());
}
};