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

Vector class with string labels for Chemical Mass Balance analysis. More...

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

Inheritance diagram for CMBVector:
Inheritance graph
Collaboration diagram for CMBVector:
Collaboration graph

Public Member Functions

 CMBVector ()
 Default constructor - creates an empty vector.
 
 CMBVector (int n)
 Constructs a vector with given size.
 
 CMBVector (const CMBVector &mp)
 Copy constructor from CMBVector.
 
 CMBVector (const CVector_arma &mp)
 Constructs from Armadillo vector.
 
CMBVectoroperator= (const CMBVector &mp)
 Assignment operator from CMBVector.
 
 CMBVector (const CVector &mp)
 Constructs from base CVector.
 
CMBVectoroperator= (const CVector &mp)
 Assignment operator from base CVector.
 
CMBVectoroperator= (const CVector_arma &mp)
 Assignment operator from Armadillo vector.
 
QJsonObject toJsonObject () const override
 Serializes vector to JSON format.
 
bool ReadFromJsonObject (const QJsonObject &jsonobject) override
 Deserializes vector from JSON format.
 
string ToString () const override
 Converts vector to CSV-formatted string.
 
QTableWidget * ToTable () override
 Creates a QTableWidget for displaying vector data.
 
bool writetofile (QFile *file) override
 Writes vector to file in CSV format.
 
double valueAt (int i) const
 Gets value at specified index.
 
string Label (int i) const
 Gets label at specified index.
 
double valueAt (const string &label) const
 Gets value by element label.
 
int LookupLabel (const string &label) const
 Finds index of element with given label.
 
vector< stringLabels () const
 Gets all element labels.
 
void SetLabel (int i, const string &label)
 Sets label at specified index.
 
void SetLabels (const vector< string > &label)
 Sets all element labels at once.
 
void SetBooleanValue (bool val)
 Sets boolean display mode for table widget.
 
CVector toVector () const
 Converts to base CVector type (without labels)
 
CMBVector Sort (const CMBVector &sortvector=CMBVector()) const
 Sorts vector by values in descending order.
 
CMBVector AbsSort (const CMBVector &sortvector=CMBVector()) const
 Sorts vector by absolute values in descending order.
 
string MaxElement () const
 Finds label of element with maximum value.
 
string MaxAbsElement () const
 Finds label of element with maximum absolute value.
 
CMBVector Eliminate (const string &element) const
 Creates new vector with specified element removed.
 
void append (const string &label, const double &val)
 Appends a labeled element to the vector.
 
CMBVector Extract (int start, int end) const
 Extracts a range of elements by index.
 
int size () const
 Gets number of elements in vector.
 
CMBVector ExtractWithinRange (const double &lowval, const double &highval) const
 Extracts elements with values within specified range.
 
CMBVector ExtractUpToMinimum () const
 Extracts elements up to first minimum value.
 
- 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< stringlabels
 Labels for each element.
 
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

Vector class with string labels for Chemical Mass Balance analysis.

Extends CVector with element labels, JSON serialization, table widget generation, and specialized operations for CMB calculations. Supports both numeric and boolean display modes, sorting operations, and range-based extraction.

Examples
/home/runner/work/SedSat3/SedSat3/src/elemental_profile.cpp.

Definition at line 16 of file cmbvector.h.

Constructor & Destructor Documentation

◆ CMBVector() [1/5]

CMBVector::CMBVector ( )

Default constructor - creates an empty vector.

Definition at line 6 of file cmbvector.cpp.

◆ CMBVector() [2/5]

CMBVector::CMBVector ( int  n)

Constructs a vector with given size.

Parameters
nNumber of elements

Definition at line 32 of file cmbvector.cpp.

References labels.

◆ CMBVector() [3/5]

CMBVector::CMBVector ( const CMBVector mp)

Copy constructor from CMBVector.

Parameters
mpVector to copy from

Definition at line 11 of file cmbvector.cpp.

References boolean_values, Interface::highlightoutsideoflimit, Interface::highlimit, labels, and Interface::lowlimit.

◆ CMBVector() [4/5]

CMBVector::CMBVector ( const CVector_arma &  mp)

Constructs from Armadillo vector.

Parameters
mpArmadillo vector to copy from

Definition at line 26 of file cmbvector.cpp.

References labels.

◆ CMBVector() [5/5]

CMBVector::CMBVector ( const CVector &  mp)

Constructs from base CVector.

Parameters
mpBase vector to copy from

Definition at line 21 of file cmbvector.cpp.

References labels.

Member Function Documentation

◆ AbsSort()

CMBVector CMBVector::AbsSort ( const CMBVector sortvector = CMBVector()) const

Sorts vector by absolute values in descending order.

Parameters
sortvectorOptional vector to use for sorting order (default: sort by self)
Returns
New sorted CMBVector with labels preserved

Definition at line 219 of file cmbvector.cpp.

References append(), Eliminate(), MaxAbsElement(), and valueAt().

◆ append()

void CMBVector::append ( const string label,
const double &  val 
)

◆ Eliminate()

CMBVector CMBVector::Eliminate ( const string element) const

Creates new vector with specified element removed.

Parameters
elementLabel of element to remove
Returns
New CMBVector without the specified element

Definition at line 261 of file cmbvector.cpp.

References append(), Label(), and valueAt().

Referenced by AbsSort(), and Sort().

◆ Extract()

CMBVector CMBVector::Extract ( int  start,
int  end 
) const

Extracts a range of elements by index.

Parameters
startStarting index (inclusive)
endEnding index (inclusive)
Returns
New CMBVector containing elements from start to end

Definition at line 303 of file cmbvector.cpp.

References append(), Label(), and valueAt().

◆ ExtractUpToMinimum()

CMBVector CMBVector::ExtractUpToMinimum ( ) const

Extracts elements up to first minimum value.

Returns elements from start until the first element whose value is less than the previous element's value.

Returns
New CMBVector containing elements up to minimum

Definition at line 291 of file cmbvector.cpp.

References append(), labels, size(), and valueAt().

Referenced by Conductor::ExecuteSDFAM().

◆ ExtractWithinRange()

CMBVector CMBVector::ExtractWithinRange ( const double &  lowval,
const double &  highval 
) const

Extracts elements with values within specified range.

Parameters
lowvalLower bound (exclusive)
highvalUpper bound (exclusive)
Returns
New CMBVector containing elements within range

Definition at line 280 of file cmbvector.cpp.

References append(), labels, size(), and valueAt().

Referenced by Conductor::ExecuteANOVA().

◆ Label()

string CMBVector::Label ( int  i) const
inline

Gets label at specified index.

Parameters
iElement index
Returns
Label string at position i
Examples
/home/runner/work/SedSat3/SedSat3/src/elemental_profile.cpp.

Definition at line 118 of file cmbvector.h.

References labels.

Referenced by Eliminate(), Extract(), MaxAbsElement(), MaxElement(), Elemental_Profile::SelectTopElements(), and Elemental_Profile_Set::SelectTopElementsAggregate().

◆ Labels()

vector< string > CMBVector::Labels ( ) const
inline

Gets all element labels.

Returns
Vector of label strings

Definition at line 138 of file cmbvector.h.

References labels.

Referenced by Conductor::ExecuteANOVA(), Conductor::ExecuteSDFAM(), operator*(), operator*(), operator+(), operator+(), operator+(), operator-(), operator-(), operator-(), operator/(), and GeneralChart::PlotVector().

◆ LookupLabel()

int CMBVector::LookupLabel ( const string label) const

Finds index of element with given label.

Parameters
labelElement label to find
Returns
Index of element, or -1 if not found

Definition at line 149 of file cmbvector.cpp.

References labels.

◆ MaxAbsElement()

string CMBVector::MaxAbsElement ( ) const

Finds label of element with maximum absolute value.

Returns
Label of element with maximum absolute value

Definition at line 248 of file cmbvector.cpp.

References Label(), and valueAt().

Referenced by AbsSort().

◆ MaxElement()

string CMBVector::MaxElement ( ) const

Finds label of element with maximum value.

Returns
Label of element with maximum value

Definition at line 235 of file cmbvector.cpp.

References Label(), and valueAt().

Referenced by Sort().

◆ operator=() [1/3]

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

Assignment operator from CMBVector.

Parameters
mpVector to assign from
Returns
Reference to this vector

Definition at line 38 of file cmbvector.cpp.

References boolean_values, Interface::highlightoutsideoflimit, Interface::highlimit, labels, and Interface::lowlimit.

◆ operator=() [2/3]

CMBVector & CMBVector::operator= ( const CVector &  mp)

Assignment operator from base CVector.

Parameters
mpVector to assign from
Returns
Reference to this vector

Definition at line 57 of file cmbvector.cpp.

References labels.

◆ operator=() [3/3]

CMBVector & CMBVector::operator= ( const CVector_arma &  mp)

Assignment operator from Armadillo vector.

Parameters
mpArmadillo vector to assign from
Returns
Reference to this vector

Definition at line 50 of file cmbvector.cpp.

References labels.

◆ ReadFromJsonObject()

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

Deserializes vector from JSON format.

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

Reimplemented from Interface.

Definition at line 81 of file cmbvector.cpp.

References labels, and Interface::SetXAxisLabel().

Referenced by Results::ReadFromJson(), and CMBVectorSet::ReadFromJsonObject().

◆ SetBooleanValue()

void CMBVector::SetBooleanValue ( bool  val)
inline

Sets boolean display mode for table widget.

When true, values are displayed as "Pass" (0) or "Fail" (1) instead of numeric values.

Parameters
valTrue to enable boolean display mode

Definition at line 161 of file cmbvector.h.

References boolean_values.

Referenced by Conductor::ExecuteBracketingAnalysis().

◆ SetLabel()

void CMBVector::SetLabel ( int  i,
const string label 
)
inline

Sets label at specified index.

Parameters
iElement index
labelLabel string to set

Definition at line 145 of file cmbvector.h.

References labels.

Referenced by SourceSinkData::BracketTest(), Elemental_Profile_Set::CalculateBoxCoxParameters(), Elemental_Profile_Set::CalculateDotProduct(), SourceSinkData::DFATransformed(), and SourceSinkData::DiscriminantFunctionAnalysis().

◆ SetLabels()

◆ size()

int CMBVector::size ( ) const
inline

◆ Sort()

CMBVector CMBVector::Sort ( const CMBVector sortvector = CMBVector()) const

Sorts vector by values in descending order.

Parameters
sortvectorOptional vector to use for sorting order (default: sort by self)
Returns
New sorted CMBVector with labels preserved

Definition at line 203 of file cmbvector.cpp.

References append(), Eliminate(), MaxElement(), and valueAt().

◆ toJsonObject()

QJsonObject CMBVector::toJsonObject ( ) const
overridevirtual

Serializes vector to JSON format.

Returns
JSON object containing vector data and labels

Reimplemented from Interface.

Definition at line 65 of file cmbvector.cpp.

References labels, valueAt(), vector, Interface::XAxisLabel(), and Interface::YAxisLabel().

◆ ToString()

string CMBVector::ToString ( ) const
overridevirtual

Converts vector to CSV-formatted string.

Returns
String representation with labels and values

Reimplemented from Interface.

Definition at line 107 of file cmbvector.cpp.

References boolean_values, labels, valueAt(), Interface::XAxisLabel(), and Interface::YAxisLabel().

Referenced by CMBVectorSet::ToString(), and writetofile().

◆ ToTable()

QTableWidget * CMBVector::ToTable ( )
overridevirtual

Creates a QTableWidget for displaying vector data.

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

Returns
Pointer to newly created QTableWidget (caller takes ownership)

Reimplemented from Interface.

Definition at line 157 of file cmbvector.cpp.

References boolean_values, Interface::highlightoutsideoflimit, Interface::highlimit, labels, Interface::lowlimit, valueAt(), and Interface::YAxisLabel().

◆ toVector()

CVector CMBVector::toVector ( ) const

Converts to base CVector type (without labels)

Returns
CVector representation

Definition at line 196 of file cmbvector.cpp.

Referenced by operator*().

◆ valueAt() [1/2]

double CMBVector::valueAt ( const string label) const

Gets value by element label.

Parameters
labelElement label to find
Returns
Value corresponding to label, or -999 if not found

Definition at line 141 of file cmbvector.cpp.

References labels, and valueAt().

◆ valueAt() [2/2]

double CMBVector::valueAt ( int  i) const

Gets value at specified index.

Parameters
iElement index
Returns
Value at position i

Definition at line 136 of file cmbvector.cpp.

Referenced by AbsSort(), SourceSinkData::BracketTest(), Eliminate(), Conductor::ExecuteSDFAM(), Extract(), ExtractUpToMinimum(), ExtractWithinRange(), MaxAbsElement(), MaxElement(), Sort(), toJsonObject(), ToString(), ToTable(), and valueAt().

◆ writetofile()

bool CMBVector::writetofile ( QFile *  file)
overridevirtual

Writes vector to file in CSV format.

Parameters
fileFile pointer to write to
Returns
true if successful

Reimplemented from Interface.

Definition at line 130 of file cmbvector.cpp.

References ToString().

Member Data Documentation

◆ boolean_values

bool CMBVector::boolean_values = false
private

Display values as Pass/Fail instead of numbers.

Definition at line 243 of file cmbvector.h.

Referenced by CMBVector(), operator=(), SetBooleanValue(), ToString(), and ToTable().

◆ labels


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