OpenMS
Matrix< Value > Class Template Reference

A class representing a thin wrapper around an Eigen matrix. More...

#include <OpenMS/DATASTRUCTURES/Matrix.h>

Inheritance diagram for Matrix< Value >:
[legend]
Collaboration diagram for Matrix< Value >:
[legend]

Public Types

using EigenMatrixType = Eigen::Matrix< Value, Eigen::Dynamic, Eigen::Dynamic >
 Eigen matrix type. More...
 

Public Member Functions

 Matrix ()=default
 
 ~Matrix ()=default
 
 Matrix (const Matrix &other)=default
 
Matrixoperator= (const Matrix &other)=default
 
 Matrix (Matrix &&other) noexcept=default
 
Matrixoperator= (Matrix &&other) noexcept=default
 
 Matrix (Size rows, Size cols, Value value=Value())
 Constructor to create a matrix with specified dimensions and fill value. More...
 
const Value & getValue (size_t const i, size_t const j) const
 
Value & getValue (size_t const i, size_t const j)
 
void setValue (size_t const i, size_t const j, const Value &value)
 
void resize (size_t rows, size_t cols)
 
int innerStride () const
 
int outerStride () const
 
bool rowMajor () const
 
template<typename T , long int ROWS, long int COLS>
void setMatrix (T const (&array)[ROWS][COLS])
 Sets the matrix values using a 2D array. More...
 
bool operator== (const Matrix &rhs) const
 Equality operator. Compares two matrices for equality. More...
 
const EigenMatrixTypegetEigenMatrix () const
 Get a const reference to the underlying Eigen matrix. More...
 
EigenMatrixTypegetEigenMatrix ()
 Get a reference to the underlying Eigen matrix. More...
 

Friends

std::ostream & operator<< (std::ostream &os, const Matrix< Value > &matrix)
 Friend function to output the matrix to an output stream. More...
 

Detailed Description

template<typename Value>
class OpenMS::Matrix< Value >

A class representing a thin wrapper around an Eigen matrix.

The Matrix class provides functionality for creating, manipulating, and accessing matrices. It is implemented using the Eigen library and supports various operations such as resizing, clearing, accessing elements, setting values, and comparing matrices.

Member Typedef Documentation

◆ EigenMatrixType

using EigenMatrixType = Eigen::Matrix<Value, Eigen::Dynamic, Eigen::Dynamic>

Eigen matrix type.

Constructor & Destructor Documentation

◆ Matrix() [1/4]

Matrix ( )
default

◆ ~Matrix()

~Matrix ( )
default

◆ Matrix() [2/4]

Matrix ( const Matrix< Value > &  other)
default

◆ Matrix() [3/4]

Matrix ( Matrix< Value > &&  other)
defaultnoexcept

◆ Matrix() [4/4]

Matrix ( Size  rows,
Size  cols,
Value  value = Value() 
)
inline

Constructor to create a matrix with specified dimensions and fill value.

Parameters
rowsNumber of rows in the matrix.
colsNumber of columns in the matrix.
valueInitial value to fill the matrix.

Member Function Documentation

◆ getEigenMatrix() [1/2]

EigenMatrixType& getEigenMatrix ( )
inline

Get a reference to the underlying Eigen matrix.

Returns
reference to the Eigen matrix.

◆ getEigenMatrix() [2/2]

const EigenMatrixType& getEigenMatrix ( ) const
inline

Get a const reference to the underlying Eigen matrix.

Returns
Const reference to the Eigen matrix.

Referenced by BilinearInterpolation< Key, Value >::empty().

◆ getValue() [1/2]

Value& getValue ( size_t const  i,
size_t const  j 
)
inline

◆ getValue() [2/2]

const Value& getValue ( size_t const  i,
size_t const  j 
) const
inline

◆ innerStride()

int innerStride ( ) const
inline

◆ operator=() [1/2]

Matrix& operator= ( const Matrix< Value > &  other)
default

◆ operator=() [2/2]

Matrix& operator= ( Matrix< Value > &&  other)
defaultnoexcept

◆ operator==()

bool operator== ( const Matrix< Value > &  rhs) const
inline

Equality operator. Compares two matrices for equality.

Parameters
rhsThe matrix to be compared.
Returns
True if matrices are equal, false otherwise.

References OpenMS::Internal::operator==().

◆ outerStride()

int outerStride ( ) const
inline

◆ resize()

void resize ( size_t  rows,
size_t  cols 
)
inline

◆ rowMajor()

bool rowMajor ( ) const
inline

◆ setMatrix()

void setMatrix ( T const (&)  array[ROWS][COLS])
inline

Sets the matrix values using a 2D array.

This function resizes the matrix to the specified number of rows and columns, and then assigns the values from the 2D array to the corresponding elements in the matrix.

Template Parameters
TThe type of the matrix elements.
ROWSThe number of rows in the matrix.
COLSThe number of columns in the matrix.
Parameters
arrayThe 2D array containing the values to be assigned to the matrix.

References Matrix< Value >::resize().

◆ setValue()

void setValue ( size_t const  i,
size_t const  j,
const Value &  value 
)
inline

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const Matrix< Value > &  matrix 
)
friend

Friend function to output the matrix to an output stream.

Parameters
osOutput stream.
matrixMatrix to be output.
Returns
Reference to the output stream.