yat
0.14.5pre
|
Interface to GSL matrix. More...
#include <yat/utility/Matrix.h>
Public Types | |
typedef double | value_type |
typedef double & | reference |
typedef const double & | const_reference |
typedef StrideIterator< double * > | iterator |
typedef StrideIterator< const double * > | const_iterator |
typedef StrideIterator< double * > | column_iterator |
typedef StrideIterator< const double * > | const_column_iterator |
typedef StrideIterator< double * > | row_iterator |
typedef StrideIterator< const double * > | const_row_iterator |
Public Member Functions | |
Matrix (void) | |
The default constructor. More... | |
Matrix (const size_t &r, const size_t &c, double init_value=0) | |
Constructor allocating memory space for r times c elements, and sets all elements to init_value. More... | |
Matrix (const Matrix &) | |
The copy constructor. More... | |
Matrix (std::istream &, char sep='\0') throw (utility::IO_error, std::exception) | |
The istream constructor. More... | |
~Matrix (void) | |
The destructor. | |
void | all (const double value) |
iterator | begin (void) |
const_iterator | begin (void) const |
iterator | begin_column (size_t i) |
const_iterator | begin_column (size_t i) const |
iterator | begin_row (size_t i) |
const_iterator | begin_row (size_t i) const |
VectorView | column_view (size_t i) |
const VectorConstView | column_const_view (size_t) const |
size_t | columns (void) const |
void | div (const Matrix &b) |
iterator | end (void) |
const_iterator | end (void) const |
iterator | end_column (size_t i) |
const_iterator | end_column (size_t i) const |
iterator | end_row (size_t i) |
const_iterator | end_row (size_t i) const |
bool | equal (const Matrix &, const double precision=0) const |
Check whether matrices are equal within a user defined precision, set by precision. More... | |
const gsl_matrix * | gsl_matrix_p (void) const |
gsl_matrix * | gsl_matrix_p (void) |
void | mul (const Matrix &b) |
void | resize (size_t r, size_t c, double init_value=0) |
Resize Matrix. More... | |
size_t | rows (void) const |
VectorView | row_view (size_t) |
const VectorConstView | row_const_view (size_t) const |
void | swap_columns (const size_t i, const size_t j) |
Swap columns i and j. More... | |
void | swap_rowcol (const size_t i, const size_t j) |
Swap row i and column j. More... | |
void | swap_rows (const size_t i, const size_t j) |
Swap rows i and j. More... | |
void | transpose (void) |
Transpose the matrix. More... | |
double & | operator() (size_t row, size_t column) |
Element access operator. More... | |
const double & | operator() (size_t row, size_t column) const |
Element access operator. More... | |
bool | operator== (const Matrix &other) const |
Comparison operator. Takes squared time. More... | |
bool | operator!= (const Matrix &other) const |
Comparison operator. Takes squared time. More... | |
const Matrix & | operator= (const Matrix &other) |
The assignment operator. More... | |
const Matrix & | operator+= (const Matrix &b) |
Add and assign operator. More... | |
const Matrix & | operator+= (const double d) |
Add and assign operator. More... | |
const Matrix & | operator-= (const Matrix &) |
Subtract and assign operator. More... | |
const Matrix & | operator-= (const double d) |
Subtract and assign operator. More... | |
const Matrix & | operator*= (const Matrix &) |
Multiply and assignment operator. More... | |
const Matrix & | operator*= (double d) |
Multiply and assignment operator. More... | |
Related Functions | |
(Note that these are not member functions.) | |
bool | isnull (const Matrix &) |
Check if all elements of the Matrix are zero. More... | |
double | max (const Matrix &) |
Get the maximum value of the Matrix. More... | |
double | min (const Matrix &) |
Get the minimum value of the Matrix. More... | |
void | minmax_index (const Matrix &, std::pair< size_t, size_t > &min, std::pair< size_t, size_t > &max) |
Locate the maximum and minimum element in the Matrix. More... | |
bool | nan (const Matrix &templat, Matrix &flag) |
Create a Matrix flag indicating NaN's in another Matrix templat. More... | |
void | swap (Matrix &, Matrix &) |
Exchange all elements between the matrices by copying. More... | |
std::ostream & | operator<< (std::ostream &s, const Matrix &) |
The output operator for the Matrix class. | |
Vector | operator* (const Matrix &, const VectorBase &) |
Vector Matrix multiplication. | |
double | trace (const Matrix &) |
Trace of matrix. More... | |
Interface to GSL matrix.
For the time being 'double' is the only type supported.
typedef StrideIterator<double*> theplu::yat::utility::Matrix::column_iterator |
Mutable iterator that iterates over one column
typedef StrideIterator<const double*> theplu::yat::utility::Matrix::const_column_iterator |
Read-only iterator that iterates over one column
typedef StrideIterator<const double*> theplu::yat::utility::Matrix::const_iterator |
Read-only iterator that iterates over all elements
typedef const double& theplu::yat::utility::Matrix::const_reference |
const_reference type is const double&
typedef StrideIterator<const double*> theplu::yat::utility::Matrix::const_row_iterator |
Read-only iterator that iterates over one row
typedef StrideIterator<double*> theplu::yat::utility::Matrix::iterator |
Mutable iterator that iterates over all elements
typedef double& theplu::yat::utility::Matrix::reference |
reference type is double&
typedef StrideIterator<double*> theplu::yat::utility::Matrix::row_iterator |
Mutable iterator that iterates over one row
typedef double theplu::yat::utility::Matrix::value_type |
value_type is double
theplu::yat::utility::Matrix::Matrix | ( | void | ) |
The default constructor.
This constructor does not initialize underlying (essential) structures.
theplu::yat::utility::Matrix::Matrix | ( | const size_t & | r, |
const size_t & | c, | ||
double | init_value = 0 |
||
) |
Constructor allocating memory space for r times c elements, and sets all elements to init_value.
If r is zero c must be zero and vice versa.
GSL_error | if memory allocation fails. |
theplu::yat::utility::Matrix::Matrix | ( | const Matrix & | ) |
The copy constructor.
A | GSL_error is indirectly thrown if memory allocation fails. |
|
explicit |
The istream constructor.
The std::istream will be interpreted as outlined here:
Missing values, i.e. empty elements, are treated as NaN values (std::numeric_limits<double>::quiet_NaN() to be specific).
Matrix rows are separated with the new line character.
Column element separation has two modes depending on the value of sep.
End of input is the end of file marker and this treatment cannot be redefined using the provided API.
void theplu::yat::utility::Matrix::all | ( | const double | value | ) |
Set all elements to value.
iterator theplu::yat::utility::Matrix::begin | ( | void | ) |
Iterator iterates along a row. When end of row is reached it jumps to beginning of next row.
const_iterator theplu::yat::utility::Matrix::begin | ( | void | ) | const |
Iterator iterates along a row. When end of row is reached it jumps to beginning of next row.
iterator theplu::yat::utility::Matrix::begin_column | ( | size_t | i | ) |
Iterator iterates along a column.
const_iterator theplu::yat::utility::Matrix::begin_column | ( | size_t | i | ) | const |
Iterator iterates along a column.
iterator theplu::yat::utility::Matrix::begin_row | ( | size_t | i | ) |
Iterator iterates along a row.
const_iterator theplu::yat::utility::Matrix::begin_row | ( | size_t | i | ) | const |
Iterator iterates along a row.
const VectorConstView theplu::yat::utility::Matrix::column_const_view | ( | size_t | ) | const |
VectorView theplu::yat::utility::Matrix::column_view | ( | size_t | i | ) |
size_t theplu::yat::utility::Matrix::columns | ( | void | ) | const |
void theplu::yat::utility::Matrix::div | ( | const Matrix & | b | ) |
Elementwise division of the elements of the calling matrix by the elements of matrix b, . The result is stored into the calling matrix.
GSL_error | if dimensions mismatch. |
iterator theplu::yat::utility::Matrix::end | ( | void | ) |
const_iterator theplu::yat::utility::Matrix::end | ( | void | ) | const |
iterator theplu::yat::utility::Matrix::end_column | ( | size_t | i | ) |
const_iterator theplu::yat::utility::Matrix::end_column | ( | size_t | i | ) | const |
iterator theplu::yat::utility::Matrix::end_row | ( | size_t | i | ) |
const_iterator theplu::yat::utility::Matrix::end_row | ( | size_t | i | ) | const |
bool theplu::yat::utility::Matrix::equal | ( | const Matrix & | , |
const double | precision = 0 |
||
) | const |
Check whether matrices are equal within a user defined precision, set by precision.
const gsl_matrix* theplu::yat::utility::Matrix::gsl_matrix_p | ( | void | ) | const |
gsl_matrix* theplu::yat::utility::Matrix::gsl_matrix_p | ( | void | ) |
void theplu::yat::utility::Matrix::mul | ( | const Matrix & | b | ) |
bool theplu::yat::utility::Matrix::operator!= | ( | const Matrix & | other | ) | const |
Comparison operator. Takes squared time.
Checks are performed with exact matching, i.e., rounding off effects may destroy comparison. Use the equal function for comparing elements within a user defined precision.
double& theplu::yat::utility::Matrix::operator() | ( | size_t | row, |
size_t | column | ||
) |
Element access operator.
If | GSL range checks are enabled in the underlying GSL library a GSL_error exception is thrown if either index is out of range. |
const double& theplu::yat::utility::Matrix::operator() | ( | size_t | row, |
size_t | column | ||
) | const |
Element access operator.
If | GSL range checks are enabled in the underlying GSL library a GSL_error exception is thrown if either index is out of range. |
const Matrix& theplu::yat::utility::Matrix::operator*= | ( | double | d | ) |
const Matrix& theplu::yat::utility::Matrix::operator+= | ( | const double | d | ) |
Add and assign operator.
Add the scalar value d to the left hand side Matrix, .
const Matrix& theplu::yat::utility::Matrix::operator-= | ( | const double | d | ) |
Subtract and assign operator.
Subtract the scalar value d to the left hand side Matrix, .
The assignment operator.
bool theplu::yat::utility::Matrix::operator== | ( | const Matrix & | other | ) | const |
Comparison operator. Takes squared time.
Checks are performed with exact matching, i.e., rounding off effects may destroy comparison. Use the equal function for comparing elements within a user defined precision.
void theplu::yat::utility::Matrix::resize | ( | size_t | r, |
size_t | c, | ||
double | init_value = 0 |
||
) |
Resize Matrix.
All elements are set to init_value.
If r is zero c must be zero and vice versa.
const VectorConstView theplu::yat::utility::Matrix::row_const_view | ( | size_t | ) | const |
VectorView theplu::yat::utility::Matrix::row_view | ( | size_t | ) |
size_t theplu::yat::utility::Matrix::rows | ( | void | ) | const |
void theplu::yat::utility::Matrix::swap_columns | ( | const size_t | i, |
const size_t | j | ||
) |
Swap columns i and j.
GSL_error | if either index is out of bounds. |
void theplu::yat::utility::Matrix::swap_rowcol | ( | const size_t | i, |
const size_t | j | ||
) |
void theplu::yat::utility::Matrix::swap_rows | ( | const size_t | i, |
const size_t | j | ||
) |
Swap rows i and j.
GSL_error | if either index is out of bounds. |
void theplu::yat::utility::Matrix::transpose | ( | void | ) |
Transpose the matrix.
GSL_error | if memory allocation fails for the new transposed matrix. |
|
related |
|
related |
|
related |
|
related |
Create a Matrix flag indicating NaN's in another Matrix templat.
The flag Matrix is changed to contain 1's and 0's only. A 1 means that the corresponding element in the templat Matrix is valid and a zero means that the corresponding element is a NaN.
Exchange all elements between the matrices by copying.
The two matrices must have the same size.
GSL_error | if sizes are not equal. |
|
related |
Trace of matrix.