GEDLIB  1.0
Public Member Functions | Related Functions | List of all members
ged::Matrix< ScalarT > Class Template Reference

A matrix class with basic functionality. More...

#include <matrix.hpp>

Public Member Functions

 Matrix ()
 Constructs an empty cost matrix.
 
 Matrix (std::size_t num_rows, std::size_t num_cols, ScalarT val=0)
 Constructs a matrix of given size with default entries. More...
 
 Matrix (const Matrix &matrix)
 Copy constructor. More...
 
void operator= (const Matrix &matrix)
 Assignment operator. More...
 
void swap (Matrix &matrix)
 Swaps the matrix with another matrix. More...
 
const ScalarT & operator() (std::size_t row, std::size_t col) const
 Provides access to a cell. More...
 
ScalarT & operator() (std::size_t row, std::size_t col)
 Provides access to a cell. More...
 
ScalarT * data ()
 Provides access to internal data. More...
 
const ScalarT * data () const
 Provides constant access to internal data. More...
 
std::size_t num_rows () const
 Returns the number of rows. More...
 
std::size_t num_cols () const
 Returns the number of columns. More...
 
void resize (std::size_t num_rows, std::size_t num_cols)
 Resizes the matrix. More...
 
void set_to_val (const ScalarT &val)
 Sets all cells to val.
 
void power (std::size_t n)
 Takes the matrix to the power of n.
 
ScalarT max () const
 Returns the maximal coefficient.
 
ScalarT min () const
 Returns the minimal coefficient.
 
void transpose ()
 Transposes the matrix.
 
Matrix< ScalarT > transposed () const
 Returns the transposed matrix.
 
Matrix< ScalarT > & operator*= (const ScalarT &scalar)
 Matrix-scalar multiplication assignment.
 
Matrix< ScalarT > & operator+= (const Matrix< ScalarT > &matrix)
 Matrix-matrix addition assignment.
 
Matrix< ScalarT > & operator-= (const Matrix< ScalarT > &matrix)
 Matrix-matrix substraction assignment.
 
Matrix< ScalarT > operator* (const ScalarT &scalar) const
 Matrix-scalar multiplication.
 
Matrix< ScalarT > operator+ (const Matrix< ScalarT > &matrix) const
 Matrix-matrix addition.
 
Matrix< ScalarT > operator- (const Matrix< ScalarT > &matrix) const
 Matrix-matrix addition.
 
Eigen::Matrix< ScalarT, Eigen::Dynamic, Eigen::Dynamic > & matrix ()
 Returns reference to the internal Eigen matrix.
 
const Eigen::Matrix< ScalarT, Eigen::Dynamic, Eigen::Dynamic > & matrix () const
 Returns constant reference to the internal Eigen matrix.
 

Related Functions

(Note that these are not member functions.)

template<typename ScalarT >
std::ostream & operator<< (std::ostream &os, const Matrix< ScalarT > &matrix)
 Streams a matrix. More...
 

Detailed Description

template<class ScalarT>
class ged::Matrix< ScalarT >

A matrix class with basic functionality.

Definition at line 38 of file matrix.hpp.

Constructor & Destructor Documentation

◆ Matrix() [1/2]

template<class ScalarT>
ged::Matrix< ScalarT >::Matrix ( std::size_t  num_rows,
std::size_t  num_cols,
ScalarT  val = 0 
)

Constructs a matrix of given size with default entries.

Parameters
[in]num_rowsThe number of rows.
[in]num_colsThe number of columns.
[in]valThe default value of all cells.

Definition at line 34 of file matrix.ipp.

◆ Matrix() [2/2]

template<class ScalarT>
ged::Matrix< ScalarT >::Matrix ( const Matrix< ScalarT > &  matrix)

Copy constructor.

Parameters
[in]matrixMatrix that should be copied.

Definition at line 44 of file matrix.ipp.

Member Function Documentation

◆ data() [1/2]

template<class ScalarT >
ScalarT * ged::Matrix< ScalarT >::data ( )

Provides access to internal data.

Returns
Pointer to the data array.

Definition at line 71 of file matrix.ipp.

◆ data() [2/2]

template<class ScalarT >
const ScalarT * ged::Matrix< ScalarT >::data ( ) const

Provides constant access to internal data.

Returns
Constant pointer to the data array.

Definition at line 78 of file matrix.ipp.

◆ num_cols()

template<class ScalarT >
std::size_t ged::Matrix< ScalarT >::num_cols ( ) const

Returns the number of columns.

Returns
The number of columns.

Definition at line 110 of file matrix.ipp.

◆ num_rows()

template<class ScalarT >
std::size_t ged::Matrix< ScalarT >::num_rows ( ) const

Returns the number of rows.

Returns
The number of rows.

Definition at line 85 of file matrix.ipp.

◆ operator()() [1/2]

template<class ScalarT >
const ScalarT & ged::Matrix< ScalarT >::operator() ( std::size_t  row,
std::size_t  col 
) const

Provides access to a cell.

Parameters
[in]rowRow of the cell.
[in]colColumn of the cell.
Returns
Constant reference to the cell (row,col).

Definition at line 57 of file matrix.ipp.

◆ operator()() [2/2]

template<class ScalarT >
ScalarT & ged::Matrix< ScalarT >::operator() ( std::size_t  row,
std::size_t  col 
)

Provides access to a cell.

Parameters
[in]rowRow of the cell.
[in]colColumn of the cell.
Returns
Reference to the cell (row,col).

Definition at line 64 of file matrix.ipp.

◆ operator=()

template<class ScalarT >
void ged::Matrix< ScalarT >::operator= ( const Matrix< ScalarT > &  matrix)

Assignment operator.

Parameters
[in]matrixMatrix that should be assigned.

Definition at line 50 of file matrix.ipp.

◆ resize()

template<class ScalarT >
void ged::Matrix< ScalarT >::resize ( std::size_t  num_rows,
std::size_t  num_cols 
)

Resizes the matrix.

Parameters
[in]num_rowsNew number of rows.
[in]num_colsNew number of columns.

Definition at line 92 of file matrix.ipp.

◆ swap()

template<class ScalarT >
void ged::Matrix< ScalarT >::swap ( Matrix< ScalarT > &  matrix)

Swaps the matrix with another matrix.

Parameters
[in,out]matrixMatrix that is to be swapped with the calling matrix.

Definition at line 156 of file matrix.ipp.

Friends And Related Function Documentation

◆ operator<<()

template<typename ScalarT >
std::ostream & operator<< ( std::ostream &  os,
const Matrix< ScalarT > &  matrix 
)
related

Streams a matrix.

Parameters
[in,out]osOutput stream.
[in]matrixThe matrix that should be streamed.
Returns
The output stream os.

Definition at line 240 of file matrix.ipp.


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