-
Notifications
You must be signed in to change notification settings - Fork 1
/
datamatrix.h
151 lines (130 loc) · 3.71 KB
/
datamatrix.h
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#ifndef DATAMATRIX_H
#define DATAMATRIX_H
#include <vector>
#include <string>
#include <QObject>
#include <QString>
#include <iostream>
#include <QFile>
#include <QJsonDocument>
#include <QJsonParseError>
#include <QJsonObject>
#include <QJsonValue>
#include <QJsonArray>
class DataMatrix
{
private:
std::vector<std::vector<double>> *data; // Reference of a 2D vector
std::vector<std::string> *rowLabel; // Vector of labels for the rows
std::vector<std::string> *columnLabel; // Vector of labels for the columns
public:
DataMatrix() : data(new std::vector<std::vector<double>>), rowLabel(new std::vector<std::string>), columnLabel(new std::vector<std::string>) {}
/**
* @brief Constructor of Data Matrix objects
*
* @param Data reference of a 2D vector
* @param RowLabel reference of a string vector
* @param ColumnLabel reference of a string vector
*/
DataMatrix(const std::vector<std::vector<double>> &data, const std::vector<std::string> &rowLabel, const std::vector<std::string> &columnLabel);
/**
* @brief Copy constructor of Data Matrix objects
*
* @param Table
*/
DataMatrix(const DataMatrix &table);
/**
* @brief Destructor of Data Matrix objects
*
*/
~DataMatrix();
/**
* @brief Ridefinition of operator =
*
* @param Table
*/
DataMatrix &operator=(const DataMatrix &table);
/**
* @brief Adds a row in n poition
*
* @param a reference to the vector to add
* @param n index in which to insert the row
* @param label label of the new row
*/
void addRow(const std::vector<double> &a, unsigned int n = 0, const std::string &label = "");
/**
* @brief Adds a column in n position
*
* @param a reference to the vector to add
* @param n index in which to insert the column
* @param label label of the new column
*/
void addColumn(const std::vector<double> &a, unsigned int n = 0, const std::string &label = "");
/**
* @brief Deletes the row at n index
*
* @param n index of the row to remove
*/
void deleteRow(unsigned int n);
/**
* @brief Deletes the column at n index
*
* @param n index of the column to remove
*/
void deleteColumn(unsigned int n);
/**
* @brief Getter for the data at n position
*
* @return std::vector<std::vector<double>> vector of data
*/
std::vector<double> *getColumnData(unsigned int n) const;
/**
* @brief Getter for the data at n position
*
* @return std::vector<std::vector<double>> vector of data
*/
std::vector<double> *getRowData(unsigned int n) const;
/**
* @brief Getter for the Row Label object
*
* @return std::vector<string>*
*/
std::vector<std::string> *getRowLabel() const;
/**
* @brief Getter fot the Column Label object
*
* @return std::vector<std::string>*
*/
std::vector<std::string> *getColumnLabel() const;
/**
* @brief Getter for the data from the matrix
*
* @return std::vector<std::string>*
*/
std::vector<std::vector<double>> *getData() const;
/**
* @brief Counter for the number of rows
*
* @param The number of rows
*/
unsigned int getRowCount() const;
/**
* @brief Counter for the number of columns
*
* @param The number of columns
*/
unsigned int getColumnCount() const;
/**
* @brief Reads from file
*
* @param Path of the .json file
*/
void read(std::string path = "inputfile.json");
/**
* @brief Writes to file
*
* @param Path of the .json file
*/
void write(std::string path = "1.json") const;
};
#endif