SedSat3 1.1.6
Sediment Source Apportionment Tool - Advanced statistical methods for environmental pollution research
Loading...
Searching...
No Matches
cmbmatrix.h
Go to the documentation of this file.
1// SedSAT3 – Sediment Source Assessment Tool, version 3
2// U.S. Geological Survey. See LICENSE.md and DISCLAIMER.md in the repository root.
3
4#ifndef CMBMATRIX_H
5#define CMBMATRIX_H
6
7#include "Matrix.h"
8#include "interface.h"
9#include "range.h"
10#include "cmbvector.h"
11
21class CMBMatrix : public CMatrix, public Interface
22{
23public:
27 CMBMatrix();
28
33 CMBMatrix(int n);
34
40 CMBMatrix(int n, int m);
41
46 CMBMatrix(const CMBMatrix& mp);
47
52 CMatrix toMatrix() const;
53
59 CMBMatrix& operator=(const CMBMatrix& mp);
60
65 QJsonObject toJsonObject() const override;
66
72 bool ReadFromJsonObject(const QJsonObject& jsonobject) override;
73
78 string ToString() const override;
79
85 bool writetofile(QFile* file) override;
86
93 double valueAt(int i, int j) const;
94
100 string ColumnLabel(int i) { return columnlabels[i]; }
101
107 string RowLabel(int i) { return rowlabels[i]; }
108
114 void SetColumnLabel(int i, const string& label) { columnlabels[i] = label; }
115
121 void SetRowLabel(int i, const string& label) { rowlabels[i] = label; }
122
127 void SetColumnLabels(const vector<string>& label) { columnlabels = label; }
128
133 void SetRowLabels(const vector<string>& label) { rowlabels = label; }
134
144 QTableWidget* ToTable() override;
145
151
157
163 CMBVector GetRow(const string& rowlabel);
164
170 CMBVector GetColumn(const string& columnlabel);
171
176 QStringList RowLabelCategories();
177
186 void SetBooleanValue(bool val) { boolean_values = val; }
187
188private:
191 bool boolean_values = false;
192};
193
203CMBVector operator*(const CMBMatrix& M, const CMBVector& V);
204
205#endif // CMBMATRIX_H
Matrix class with labeled rows and columns for Chemical Mass Balance analysis.
Definition cmbmatrix.h:22
CMBMatrix()
Default constructor - creates an empty matrix.
Definition cmbmatrix.cpp:9
string ColumnLabel(int i)
Gets column label at specified index.
Definition cmbmatrix.h:100
void SetRowLabel(int i, const string &label)
Sets row label at specified index.
Definition cmbmatrix.h:121
vector< string > ColumnLabels() const
Gets all column labels.
Definition cmbmatrix.h:156
CMatrix toMatrix() const
Converts to base CMatrix type (without labels).
bool boolean_values
Display values as Pass/Fail instead of numbers.
Definition cmbmatrix.h:191
string ToString() const override
Converts matrix to CSV-formatted string.
bool ReadFromJsonObject(const QJsonObject &jsonobject) override
Deserializes matrix from JSON format.
Definition cmbmatrix.cpp:70
QJsonObject toJsonObject() const override
Serializes matrix to JSON format.
Definition cmbmatrix.cpp:44
void SetColumnLabel(int i, const string &label)
Sets column label at specified index.
Definition cmbmatrix.h:114
QTableWidget * ToTable() override
Creates a QTableWidget for displaying matrix data.
string RowLabel(int i)
Gets row label at specified index.
Definition cmbmatrix.h:107
void SetBooleanValue(bool val)
Sets boolean display mode for table widget.
Definition cmbmatrix.h:186
QStringList RowLabelCategories()
Gets unique row label categories.
void SetColumnLabels(const vector< string > &label)
Sets all column labels at once.
Definition cmbmatrix.h:127
CMBMatrix & operator=(const CMBMatrix &mp)
Assignment operator.
Definition cmbmatrix.cpp:34
vector< string > columnlabels
Labels for each column.
Definition cmbmatrix.h:189
double valueAt(int i, int j) const
Gets value at specified matrix position.
CMBVector GetColumn(const string &columnlabel)
Extracts a column by its label.
void SetRowLabels(const vector< string > &label)
Sets all row labels at once.
Definition cmbmatrix.h:133
CMBVector GetRow(const string &rowlabel)
Extracts a row by its label.
vector< string > RowLabels() const
Gets all row labels.
Definition cmbmatrix.h:150
bool writetofile(QFile *file) override
Writes matrix to file in CSV format.
Definition cmbmatrix.cpp:99
vector< string > rowlabels
Labels for each row.
Definition cmbmatrix.h:190
Vector class with string labels for Chemical Mass Balance analysis.
Definition cmbvector.h:20
Interface()
Default constructor.
Definition interface.cpp:6
STL class.
CMBVector operator*(const CMBMatrix &M, const CMBVector &V)
Matrix-vector multiplication operator.