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 (const gsl_matrix *m)
| Matrix (const Matrix &other)
| Matrix (gsl_matrix *m)
| Matrix (Matrix &&other)
| Matrix (size_t rows, size_t columns, bool clean)
| Matrix (size_t rows, size_t columns, const double *init)
| Matrix (size_t rows, size_t columns, double init)
| operator const gsl_matrix * () const
| operator gsl_matrix * ()
double | operator() (size_t i, size_t j) const
Matrix & | operator*= (double rhs)
Matrix & | operator+= (const Matrix &rhs)
Matrix & | operator-= (const Matrix &rhs)
Matrix & | operator= (const Matrix &other)
Matrix & | operator= (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 171 of file gsl_matrix.hh.

## Member Typedef Documentation

## const_iterator

typedef const_matrix_iterator gsl::Matrix::const_iterator

Definition at line 175 of file gsl_matrix.hh.

## iterator

typedef matrix_iterator gsl::Matrix::iterator

Definition at line 174 of file gsl_matrix.hh.

## Constructor & Destructor Documentation

## Matrix() [1/8]

gsl::Matrix::Matrix | ( |  | ) |

Referenced by column_covariance(), Matrix(), Matrix(), operator*=(), operator+=(), operator-=(), operator=(), operator=(), row_covariance(), and transposed().

## 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 |
  clean | allocate zeroing out all elements

References rows().

## 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 |
  init | set the matrix elements to this value

References rows().

## 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 |
  init | the input data in row major format

References rows().

## Matrix() [5/8]

gsl::Matrix::Matrix | ( | const Matrix & | other | ) |

Copy constructor that executes a deep copy

References Matrix().

## Matrix() [6/8]

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

move constructor

References Matrix().

## Matrix() [7/8]

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

Wrap an existing GSL matrix

Parameters

  m | the GSL matrix

## Matrix() [8/8]

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

Wrap an existing GSL constant matrix

Parameters

  m | the 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

References 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

  c | index of column, must be in [0, this->cols()-1]
  col | vector 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

  r | index of row, must be in [0, this->rows()-1]
  v | vector 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

  c | index 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

  c | index 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

  r | index 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

  r | index 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

  i | row
  j | column

Returns
  the value

## operator*=()

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

inline

Scale elements with a factor

Parameters

  rhs | scaling factor

Returns
  reference of this matrix

Definition at line 438 of file gsl_matrix.hh.

References Matrix().

## operator+=()

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

inline

Element wise matrix addition

Parameters

  rhs | matrix to add

Returns
  reference of this matrix

Definition at line 427 of file gsl_matrix.hh.

References Matrix().

## operator-=()

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

inline

Element wise matrix subtraction

Parameters

  rhs | matrix to subtract

Returns
  reference of this matrix

Definition at line 416 of file gsl_matrix.hh.

References Matrix().

## operator=() [1/2]

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

Copy operator that executes a deep copy

References Matrix().

## operator=() [2/2]

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

Move operator that

References Matrix().

## print()

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

Print matrix to a ostream

Parameters

  os | output 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

References rows().

## 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

References rows().

## row_covariance()

Matrix gsl::Matrix::row_covariance | ( |  | ) | const

Evaluate the covariance matrix between the rows of this matrix

Returns
  the covariance matrix

References Matrix().

## rows()

size_t gsl::Matrix::rows | ( |  | ) | const

Returns
  the number of rows in the matrix

Referenced by Matrix(), Matrix(), Matrix(), reset(), and reset().

## set()

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

Set a value of the matrix

Parameters

  i | row
  j | column
  x | value

## set_column()

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

Set a matrix column

Parameters

  c | index of column to be set, must be in [0, this->cols()-1]
  col | vector 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

  r | index of row to be set, must be in [0, this->rows()-1]
  row | vector 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

References Matrix().

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

- gsl_matrix.hh