SedSat3 1.1.6
Sediment Source Apportionment Tool - Advanced statistical methods for environmental pollution research
Loading...
Searching...
No Matches
CMBMatrix Class Reference

Matrix class with labeled rows and columns for Chemical Mass Balance analysis. More...

#include </home/runner/work/SedSat3/SedSat3/cmbmatrix.h>

Inheritance diagram for CMBMatrix:
Inheritance graph
Collaboration diagram for CMBMatrix:
Collaboration graph

Public Member Functions

 CMBMatrix ()
 Default constructor - creates an empty matrix.
 
 CMBMatrix (int n)
 Constructs a square matrix with given dimension.
 
 CMBMatrix (int n, int m)
 Constructs a rectangular matrix with given dimensions.
 
 CMBMatrix (const CMBMatrix &mp)
 Copy constructor.
 
CMatrix toMatrix () const
 Converts to base CMatrix type (without labels)
 
CMBMatrixoperator= (const CMBMatrix &mp)
 Assignment operator.
 
QJsonObject toJsonObject () const override
 Serializes matrix to JSON format.
 
bool ReadFromJsonObject (const QJsonObject &jsonobject) override
 Deserializes matrix from JSON format.
 
string ToString () const override
 Converts matrix to CSV-formatted string.
 
bool writetofile (QFile *file) override
 Writes matrix to file in CSV format.
 
double valueAt (int i, int j) const
 Gets value at specified matrix position.
 
string ColumnLabel (int i)
 Gets column label at specified index.
 
string RowLabel (int i)
 Gets row label at specified index.
 
void SetColumnLabel (int i, const string &label)
 Sets column label at specified index.
 
void SetRowLabel (int i, const string &label)
 Sets row label at specified index.
 
void SetColumnLabels (const vector< string > &label)
 Sets all column labels at once.
 
void SetRowLabels (const vector< string > &label)
 Sets all row labels at once.
 
QTableWidget * ToTable () override
 Creates a QTableWidget for displaying matrix data.
 
vector< stringRowLabels () const
 Gets all row labels.
 
vector< stringColumnLabels () const
 Gets all column labels.
 
CMBVector GetRow (const string &rowlabel)
 Extracts a row by its label.
 
CMBVector GetColumn (const string &columnlabel)
 Extracts a column by its label.
 
QStringList RowLabelCategories ()
 Gets unique row label categories.
 
void SetBooleanValue (bool val)
 Sets boolean display mode for table widget.
 
- Public Member Functions inherited from Interface
 Interface ()
 Default constructor.
 
 Interface (const Interface &intf)
 Copy constructor.
 
Interfaceoperator= (const Interface &intf)
 Assignment operator.
 
virtual bool Read (const QStringList &strlist)
 Parse object data from a string list.
 
string GetNotes () const
 Get the notes/annotations associated with this object.
 
void SetNotes (const string &note)
 Set the notes for this object, replacing any existing notes.
 
void AppendtoNotes (const string &note)
 Append a note to existing notes.
 
void ClearNotes ()
 Clear all notes associated with this object.
 
void SetLimit (_range lowhigh, const double &value)
 Set upper or lower limit for value highlighting.
 
void SetOption (options_key opt, bool val)
 Set a configuration option.
 
bool Option (options_key opt)
 Get the current value of a configuration option.
 
optionsGetOptions ()
 Get reference to the options structure.
 
QString XAxisLabel () const
 Get the X-axis label.
 
QString YAxisLabel () const
 Get the Y-axis label.
 
bool SetXAxisLabel (const QString &label)
 Set the X-axis label.
 
bool SetYAxisLabel (const QString &label)
 Set the Y-axis label.
 

Private Attributes

vector< stringcolumnlabels
 Labels for each column.
 
vector< stringrowlabels
 Labels for each row.
 
bool boolean_values = false
 Display values as Pass/Fail instead of numbers.
 

Additional Inherited Members

- Public Attributes inherited from Interface
double lowlimit
 Lower threshold for value highlighting (when enabled)
 
double highlimit
 Upper threshold for value highlighting (when enabled)
 
bool highlightoutsideoflimit = false
 Flag indicating whether to highlight values outside defined limits.
 

Detailed Description

Matrix class with labeled rows and columns for Chemical Mass Balance analysis.

Extends CMatrix with string labels for rows and columns, JSON serialization, table widget generation, and specialized operations for CMB calculations. Inherits from both CMatrix (for mathematical operations) and Interface (for I/O and visualization).

Definition at line 18 of file cmbmatrix.h.

Constructor & Destructor Documentation

◆ CMBMatrix() [1/4]

CMBMatrix::CMBMatrix ( )

Default constructor - creates an empty matrix.

Definition at line 6 of file cmbmatrix.cpp.

◆ CMBMatrix() [2/4]

CMBMatrix::CMBMatrix ( int  n)

Constructs a square matrix with given dimension.

Parameters
nNumber of rows and columns

Definition at line 20 of file cmbmatrix.cpp.

References columnlabels, and rowlabels.

◆ CMBMatrix() [3/4]

CMBMatrix::CMBMatrix ( int  n,
int  m 
)

Constructs a rectangular matrix with given dimensions.

Parameters
nNumber of columns
mNumber of rows

Definition at line 25 of file cmbmatrix.cpp.

References columnlabels, and rowlabels.

◆ CMBMatrix() [4/4]

CMBMatrix::CMBMatrix ( const CMBMatrix mp)

Copy constructor.

Parameters
mpMatrix to copy from

Definition at line 11 of file cmbmatrix.cpp.

References columnlabels, Interface::highlightoutsideoflimit, Interface::highlimit, Interface::lowlimit, and rowlabels.

Member Function Documentation

◆ ColumnLabel()

string CMBMatrix::ColumnLabel ( int  i)
inline

Gets column label at specified index.

Parameters
iColumn index
Returns
Column label string

Definition at line 97 of file cmbmatrix.h.

References columnlabels.

◆ ColumnLabels()

vector< string > CMBMatrix::ColumnLabels ( ) const
inline

Gets all column labels.

Returns
Vector of column label strings

Definition at line 153 of file cmbmatrix.h.

References columnlabels.

Referenced by GetRow().

◆ GetColumn()

CMBVector CMBMatrix::GetColumn ( const string columnlabel)

Extracts a column by its label.

Parameters
columnlabelLabel of the column to extract
Returns
CMBVector containing the column values with row labels

Definition at line 218 of file cmbmatrix.cpp.

References columnlabels, RowLabels(), and CMBVector::SetLabels().

◆ GetRow()

CMBVector CMBMatrix::GetRow ( const string rowlabel)

Extracts a row by its label.

Parameters
rowlabelLabel of the row to extract
Returns
CMBVector containing the row values with column labels

Definition at line 204 of file cmbmatrix.cpp.

References ColumnLabels(), rowlabels, and CMBVector::SetLabels().

◆ operator=()

CMBMatrix & CMBMatrix::operator= ( const CMBMatrix mp)

Assignment operator.

Parameters
mpMatrix to assign from
Returns
Reference to this matrix

Definition at line 31 of file cmbmatrix.cpp.

References columnlabels, Interface::highlightoutsideoflimit, Interface::highlimit, Interface::lowlimit, and rowlabels.

◆ ReadFromJsonObject()

bool CMBMatrix::ReadFromJsonObject ( const QJsonObject &  jsonobject)
overridevirtual

Deserializes matrix from JSON format.

Parameters
jsonobjectJSON object to read from
Returns
true if successful, false otherwise

Reimplemented from Interface.

Definition at line 67 of file cmbmatrix.cpp.

References columnlabels, and rowlabels.

Referenced by Results::ReadFromJson().

◆ RowLabel()

string CMBMatrix::RowLabel ( int  i)
inline

Gets row label at specified index.

Parameters
iRow index
Returns
Row label string

Definition at line 104 of file cmbmatrix.h.

References rowlabels.

◆ RowLabelCategories()

QStringList CMBMatrix::RowLabelCategories ( )

Gets unique row label categories.

Returns
QStringList of unique row labels (no duplicates)

Definition at line 233 of file cmbmatrix.cpp.

References rowlabels.

◆ RowLabels()

vector< string > CMBMatrix::RowLabels ( ) const
inline

Gets all row labels.

Returns
Vector of row label strings

Definition at line 147 of file cmbmatrix.h.

References rowlabels.

Referenced by GetColumn(), and operator*().

◆ SetBooleanValue()

void CMBMatrix::SetBooleanValue ( bool  val)
inline

Sets boolean display mode for table widget.

When true, matrix values are displayed as "Pass" (0) or "Fail" (1) in the table widget instead of numeric values.

Parameters
valTrue to enable boolean display mode

Definition at line 183 of file cmbmatrix.h.

References boolean_values.

Referenced by Conductor::ExecuteBracketingAnalysisBatch(), and Results::ReadFromJson().

◆ SetColumnLabel()

void CMBMatrix::SetColumnLabel ( int  i,
const string label 
)
inline

Sets column label at specified index.

Parameters
iColumn index
labelLabel string to set

Definition at line 111 of file cmbmatrix.h.

References columnlabels.

Referenced by SourceSinkData::BracketTest(), Elemental_Profile_Set::CalculateCorrelationMatrix(), Elemental_Profile_Set::CalculateCovarianceMatrix(), Elemental_Profile_Set::DetectOutliers(), and SourceSinkData::MCMC_Batch().

◆ SetColumnLabels()

void CMBMatrix::SetColumnLabels ( const vector< string > &  label)
inline

Sets all column labels at once.

Parameters
labelVector of label strings

Definition at line 124 of file cmbmatrix.h.

References columnlabels.

◆ SetRowLabel()

void CMBMatrix::SetRowLabel ( int  i,
const string label 
)
inline

Sets row label at specified index.

Parameters
iRow index
labelLabel string to set

Definition at line 118 of file cmbmatrix.h.

References rowlabels.

Referenced by SourceSinkData::BracketTest(), Elemental_Profile_Set::CalculateCorrelationMatrix(), Elemental_Profile_Set::CalculateCovarianceMatrix(), Elemental_Profile_Set::DetectOutliers(), and SourceSinkData::MCMC_Batch().

◆ SetRowLabels()

void CMBMatrix::SetRowLabels ( const vector< string > &  label)
inline

Sets all row labels at once.

Parameters
labelVector of label strings

Definition at line 130 of file cmbmatrix.h.

References rowlabels.

◆ toJsonObject()

QJsonObject CMBMatrix::toJsonObject ( ) const
overridevirtual

Serializes matrix to JSON format.

Returns
JSON object containing matrix data, row labels, and column labels

Reimplemented from Interface.

Definition at line 41 of file cmbmatrix.cpp.

References columnlabels, matrix, rowlabels, and valueAt().

◆ toMatrix()

CMatrix CMBMatrix::toMatrix ( ) const

Converts to base CMatrix type (without labels)

Returns
CMatrix representation

Definition at line 197 of file cmbmatrix.cpp.

Referenced by operator*().

◆ ToString()

string CMBMatrix::ToString ( ) const
overridevirtual

Converts matrix to CSV-formatted string.

Returns
String representation with labels and comma-separated values

Reimplemented from Interface.

Definition at line 101 of file cmbmatrix.cpp.

References columnlabels, rowlabels, and valueAt().

Referenced by writetofile().

◆ ToTable()

QTableWidget * CMBMatrix::ToTable ( )
overridevirtual

Creates a QTableWidget for displaying matrix data.

Generates a read-only table widget with labeled rows and columns. Highlights cells outside limit range if highlighting is enabled. Displays boolean values as "Pass"/"Fail" if boolean mode is set.

Returns
Pointer to newly created QTableWidget (caller takes ownership)

Reimplemented from Interface.

Definition at line 122 of file cmbmatrix.cpp.

References boolean_values, columnlabels, Interface::highlightoutsideoflimit, Interface::highlimit, Interface::lowlimit, and rowlabels.

◆ valueAt()

double CMBMatrix::valueAt ( int  i,
int  j 
) const

Gets value at specified matrix position.

Parameters
iRow index
jColumn index
Returns
Matrix value at position (i,j)

Definition at line 184 of file cmbmatrix.cpp.

Referenced by toJsonObject(), and ToString().

◆ writetofile()

bool CMBMatrix::writetofile ( QFile *  file)
overridevirtual

Writes matrix to file in CSV format.

Parameters
fileFile pointer to write to
Returns
true if successful

Reimplemented from Interface.

Definition at line 96 of file cmbmatrix.cpp.

References ToString().

Member Data Documentation

◆ boolean_values

bool CMBMatrix::boolean_values = false
private

Display values as Pass/Fail instead of numbers.

Definition at line 188 of file cmbmatrix.h.

Referenced by SetBooleanValue(), and ToTable().

◆ columnlabels

vector<string> CMBMatrix::columnlabels
private

◆ rowlabels


The documentation for this class was generated from the following files: