gsl::Matrix Class Reference

#include <mia/core/gsl_matrix.hh>

Public Types

typedef const_matrix_iterator const_iterator
 
typedef matrix_iterator iterator
 

Public Member Functions

matrix_iterator begin ()
 
const_matrix_iterator begin () const
 
size_t cols () const
 
Matrix column_covariance () const
 
double dot_column (int c, const Vector &col) const
 
double dot_row (int r, const Vector &v) const
 
matrix_iterator end ()
 
const_matrix_iterator end () const
 
VectorView get_column (int c)
 
ConstVectorView get_column (int c) const
 
VectorView get_row (int r)
 
ConstVectorView get_row (int r) const
 
bool is_valid () const
 
bool is_writable () const
 
 Matrix ()
 
 Matrix (size_t rows, size_t columns, bool clean)
 
 Matrix (size_t rows, size_t columns, double init)
 
 Matrix (size_t rows, size_t columns, const double *init)
 
 Matrix (const Matrix &other)
 
 Matrix (Matrix &&other)
 
 Matrix (gsl_matrix *m)
 
 Matrix (const gsl_matrix *m)
 
 operator const gsl_matrix * () const
 
 operator gsl_matrix * ()
 
double operator() (size_t i, size_t j) const
 
Matrixoperator*= (double rhs)
 
Matrixoperator+= (const Matrix &rhs)
 
Matrixoperator-= (const Matrix &rhs)
 
Matrixoperator= (const Matrix &other)
 
Matrixoperator= (Matrix &&other)
 
void print (std::ostream &os) const
 
void reset (size_t rows, size_t columns, bool clean)
 
void reset (size_t rows, size_t columns, double init)
 
Matrix row_covariance () const
 
size_t rows () const
 
void set (size_t i, size_t j, double x)
 
void set_column (int c, const Vector &col)
 
void set_row (int r, const Vector &row)
 
Matrix transposed () const
 
 ~Matrix ()
 

Detailed Description

This is a wrapper class around the GSL matrix type. It provides a compatibility to avoid handling de-alloction manually.

Definition at line 158 of file gsl_matrix.hh.

Member Typedef Documentation

◆ const_iterator

◆ iterator

Definition at line 160 of file gsl_matrix.hh.

Constructor & Destructor Documentation

◆ Matrix() [1/8]

gsl::Matrix::Matrix ( )

◆ Matrix() [2/8]

gsl::Matrix::Matrix ( size_t  rows,
size_t  columns,
bool  clean 
)

Create a matrix of size rows \(\times\) columns,

Parameters
rows
columns
cleanallocate zeroing out all elements

◆ Matrix() [3/8]

gsl::Matrix::Matrix ( size_t  rows,
size_t  columns,
double  init 
)

Create a matrix of size rows \(\times\) columns,

Parameters
rows
columns
initset the matrix elements to this value

◆ Matrix() [4/8]

gsl::Matrix::Matrix ( size_t  rows,
size_t  columns,
const double *  init 
)

Create a matrix of size rows \(\times\) columns and initialize it with the given data

Parameters
rows
columns
initthe input data in row major format

◆ Matrix() [5/8]

gsl::Matrix::Matrix ( const Matrix other)

Copy constructor that executes a deep copy

◆ Matrix() [6/8]

gsl::Matrix::Matrix ( Matrix &&  other)

move constructor

◆ Matrix() [7/8]

gsl::Matrix::Matrix ( gsl_matrix *  m)

Wrap an existing GSL matrix

Parameters
mthe GSL matrix

◆ Matrix() [8/8]

gsl::Matrix::Matrix ( const gsl_matrix *  m)

Wrap an existing GSL constant matrix

Parameters
mthe GSL matrix

◆ ~Matrix()

gsl::Matrix::~Matrix ( )

Member Function Documentation

◆ begin() [1/2]

matrix_iterator gsl::Matrix::begin ( )

Iterator over the matrix elements of the matrix, column indices are the fastest changing indices.

Returns
the begin of the range

◆ begin() [2/2]

const_matrix_iterator gsl::Matrix::begin ( ) const

Read only iterator over the matrix elements of the matrix, column indices are the fastest changing indices.

Returns
the begin of the range

◆ cols()

size_t gsl::Matrix::cols ( ) const
Returns
the number of columns in the matrix

◆ column_covariance()

Matrix gsl::Matrix::column_covariance ( ) const

Evaluate the covariance matrix between the columns of this matrix

Returns
the covariance matrix

◆ dot_column()

double gsl::Matrix::dot_column ( int  c,
const Vector col 
) const

Evaluate the dot product between a column of the matrix and a given vector

Parameters
cindex of column, must be in [0, this->cols()-1]
colvector to evaluate the dot product with. The vector's size must be equal to the number of matrix rows.
Returns
the dot product of the row vector and the input vector

◆ dot_row()

double gsl::Matrix::dot_row ( int  r,
const Vector v 
) const

Evaluate the dot product between a row of the matrix and a given vector

Parameters
rindex of row, must be in [0, this->rows()-1]
vvector to evaluate the dot product with. The vector's size must be equal to the number of matrix columns.
Returns
the dot product of the row vector and the input vector

◆ end() [1/2]

matrix_iterator gsl::Matrix::end ( )

Iterator over the matrix elements of the matrix, column indices are the fastest changing indices.

Returns
the end of the range

◆ end() [2/2]

const_matrix_iterator gsl::Matrix::end ( ) const

Read only iterator over the matrix elements of the matrix, column indices are the fastest changing indices.

Returns
the end of the range

◆ get_column() [1/2]

VectorView gsl::Matrix::get_column ( int  c)

Get a read-write view of a matrix column

Parameters
cindex of the matrix column
Returns
view

◆ get_column() [2/2]

ConstVectorView gsl::Matrix::get_column ( int  c) const

Get a read-only view of a matrix column

Parameters
cindex of the matrix column
Returns
view

◆ get_row() [1/2]

VectorView gsl::Matrix::get_row ( int  r)

Get a read-write view of a matrix row

Parameters
rindex of the matrix row
Returns
view

◆ get_row() [2/2]

ConstVectorView gsl::Matrix::get_row ( int  r) const

Get a read-only view of a matrix row

Parameters
rindex of the matrix row
Returns
constant view

◆ is_valid()

bool gsl::Matrix::is_valid ( ) const

◆ is_writable()

bool gsl::Matrix::is_writable ( ) const

◆ operator const gsl_matrix *()

gsl::Matrix::operator const gsl_matrix * ( ) const

operator to get the underlying const gsl_matrix pointer

◆ operator gsl_matrix *()

gsl::Matrix::operator gsl_matrix * ( )

operator to get the underlying gsl_matrix pointer

◆ operator()()

double gsl::Matrix::operator() ( size_t  i,
size_t  j 
) const

Get a value of the matrix

Parameters
irow
jcolumn
Returns
the value

◆ operator*=()

Matrix& gsl::Matrix::operator*= ( double  rhs)
inline

Scale elements with a factor

Parameters
rhsscaling factor
Returns
reference of this matrix

Definition at line 422 of file gsl_matrix.hh.

References EXPORT_GSL, gsl::operator*(), gsl::operator+(), and gsl::operator-().

◆ operator+=()

Matrix& gsl::Matrix::operator+= ( const Matrix rhs)
inline

Element wise matrix addition

Parameters
rhsmatrix to add
Returns
reference of this matrix

Definition at line 412 of file gsl_matrix.hh.

◆ operator-=()

Matrix& gsl::Matrix::operator-= ( const Matrix rhs)
inline

Element wise matrix subtraction

Parameters
rhsmatrix to subtract
Returns
reference of this matrix

Definition at line 402 of file gsl_matrix.hh.

◆ operator=() [1/2]

Matrix& gsl::Matrix::operator= ( const Matrix other)

Copy operator that executes a deep copy

◆ operator=() [2/2]

Matrix& gsl::Matrix::operator= ( Matrix &&  other)

Move operator that

◆ print()

void gsl::Matrix::print ( std::ostream &  os) const

Print matrix to a ostream

Parameters
osoutput stream to write to

Referenced by gsl::operator<<().

◆ reset() [1/2]

void gsl::Matrix::reset ( size_t  rows,
size_t  columns,
bool  clean 
)

Reset the matrix with the new dimensions.

Parameters
rows
columns
clean- set all values to zero

◆ reset() [2/2]

void gsl::Matrix::reset ( size_t  rows,
size_t  columns,
double  init 
)

Reset the matrix with the new dimensions.

Parameters
rows
columns
init- set all values to init

◆ row_covariance()

Matrix gsl::Matrix::row_covariance ( ) const

Evaluate the covariance matrix between the rows of this matrix

Returns
the covariance matrix

◆ rows()

size_t gsl::Matrix::rows ( ) const
Returns
the number of rows in the matrix

◆ set()

void gsl::Matrix::set ( size_t  i,
size_t  j,
double  x 
)

Set a value of the matrix

Parameters
irow
jcolumn
xvalue

◆ set_column()

void gsl::Matrix::set_column ( int  c,
const Vector col 
)

Set a matrix column

Parameters
cindex of column to be set, must be in [0, this->cols()-1]
colvector containing the new values. It's size must be equal to the number of rows of the matrix

◆ set_row()

void gsl::Matrix::set_row ( int  r,
const Vector row 
)

Set a matrix row

Parameters
rindex of row to be set, must be in [0, this->rows()-1]
rowvector containing the new values. It's size must be equal to the number of columns of the matrix

◆ transposed()

Matrix gsl::Matrix::transposed ( ) const

Acquire the transposed matrix.

Returns
transposed matrix as newly created object

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