yat  0.21pre
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | Related Functions | List of all members
theplu::yat::utility::Matrix Class Reference

Interface to GSL matrix. More...

#include <yat/utility/Matrix.h>

Inheritance diagram for theplu::yat::utility::Matrix:
theplu::yat::utility::MatrixMutable theplu::yat::utility::MatrixBase theplu::yat::utility::BasicMatrix< MatrixBase >

Public Types

typedef double & reference
 
typedef Container2DIterator< MatrixMutable, double, double & > iterator
 
typedef StrideIterator< double * > column_iterator
 
typedef StrideIterator< double * > row_iterator
 
typedef double value_type
 
typedef const double & const_reference
 
typedef Container2DIterator< const MatrixBase, const double, const double & > const_iterator
 
typedef StrideIterator< const double * > const_column_iterator
 
typedef StrideIterator< const double * > const_row_iterator
 
typedef MatrixBase derived_type
 

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 (const MatrixBase &)
 
virtual ~Matrix (void)
 Destructor.
 
template<class T >
 Matrix (const MatrixExpression< T > &other)
 
 Matrix (Matrix &&) noexcept
 The move constructor. More...
 
 Matrix (MatrixMutable &&)
 
template<class T >
 Matrix (MatrixExpression< T > &&other)
 
 Matrix (std::istream &, char sep='\0')
 The istream constructor. More...
 
gsl_matrix * gsl_matrix_p (void)
 
const gsl_matrix * gsl_matrix_p (void) const
 
void resize (size_t r, size_t c, double init_value=0)
 Resize Matrix. More...
 
void transpose (void)
 Transpose the matrix. More...
 
const Matrixoperator= (const Matrix &other)
 The assignment operator. More...
 
Matrixoperator= (Matrix &&other)
 Move assignment operatorOnly reason they mention those 1e-5 peaks. More...
 
const Matrixoperator*= (const Matrix &)
 Multiply and assignment operator. More...
 
MatrixMutableoperator= (const MatrixMutable &other)
 The assignment operator. More...
 
MatrixMutableoperator= (const MatrixBase &other)
 The assignment operator.
 
template<class T >
MatrixMutableoperator= (const MatrixExpression< T > &rhs)
 
MatrixMutableoperator= (MatrixMutable &&other)
 Move assignment operator.
 
template<class T >
MatrixMutableoperator= (MatrixExpression< T > &&rhs)
 
const MatrixMutableoperator*= (double d)
 Multiply and assignment operator. More...
 
void all (const double value)
 
iterator begin (void)
 
const_iterator begin (void) const
 
const_iterator begin (void) const
 
column_iterator begin_column (size_t i)
 
const_column_iterator begin_column (size_t i) const
 
const_column_iterator begin_column (size_t i) const
 
row_iterator begin_row (size_t i)
 
const_row_iterator begin_row (size_t i) const
 
const_row_iterator begin_row (size_t i) const
 
VectorView column_view (size_t i)
 
void div (const MatrixBase &b)
 
iterator end (void)
 
const_iterator end (void) const
 
const_iterator end (void) const
 
column_iterator end_column (size_t i)
 
const_column_iterator end_column (size_t i) const
 
const_column_iterator end_column (size_t i) const
 
row_iterator end_row (size_t i)
 
const_row_iterator end_row (size_t i) const
 
const_row_iterator end_row (size_t i) const
 
virtual const gsl_matrix * gsl_matrix_p (void) const=0
 
void mul (const MatrixBase &b)
 
VectorView row_view (size_t)
 
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...
 
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...
 
const MatrixMutableoperator+= (const MatrixBase &b)
 Add and assign operator. More...
 
template<class T >
MatrixMutableoperator+= (const MatrixExpression< T > &rhs)
 Addition and assign operator. More...
 
const MatrixMutableoperator+= (const double d)
 Add and assign operator. More...
 
const MatrixMutableoperator-= (const MatrixBase &)
 Subtract and assign operator. More...
 
template<class T >
MatrixMutableoperator-= (const MatrixExpression< T > &rhs)
 Subtraction and assign operator. More...
 
const MatrixMutableoperator-= (const double d)
 Subtract and assign operator. More...
 
const MatrixMutableoperator*= (double d)
 Multiply and assignment operator. More...
 
const VectorConstView column_const_view (size_t) const
 
size_t columns (void) const
 
bool equal (const MatrixBase &, const double precision=0) const
 Check whether matrices are equal within a user defined precision, set by precision. More...
 
size_t rows (void) const
 
const VectorConstView row_const_view (size_t) const
 
bool operator== (const MatrixBase &other) const
 Comparison operator. Takes squared time. More...
 
bool operator!= (const MatrixBase &other) const
 Comparison operator. Takes squared time. More...
 

Protected Member Functions

void copy_assign (const gsl_matrix *rhs)
 
void move_assign (MatrixMutable &&rhs)
 
void move_assign (gsl_matrix *&&rhs)
 
void copy_assign (const MatrixBase &other)
 Behaves like operator=(const MatrixBase&)
 
virtual void copy_assign (const gsl_matrix *rhs)=0
 Behaves like operator=(const MatrixBase&)
 
void copy_assign (const MatrixBase &other)
 Behaves like operator=(const MatrixBase&)
 

Protected Attributes

gsl_matrix * blas_result_
 

Friends

class detail::Mover
 

Related Functions

(Note that these are not member functions.)

template<class Derived1 , class Derived2 >
expression::MatrixBinary< Derived1, Derived2, expression::Plusoperator+ (const BasicMatrix< Derived1 > &lhs, const BasicMatrix< Derived2 > &rhs)
 Matrix addition operator. More...
 
template<class Derived1 , class Derived2 >
expression::MatrixBinary< Derived1, Derived2, expression::Minusoperator- (const BasicMatrix< Derived1 > &lhs, const BasicMatrix< Derived2 > &rhs)
 Matrix subtraction operator. More...
 
template<class Derived1 , class Derived2 >
expression::MatrixProduct< BasicMatrix< Derived1 >, BasicMatrix< Derived2 > > operator* (const BasicMatrix< Derived1 > &lhs, const BasicMatrix< Derived2 > &rhs)
 Matrix multiplication operator. More...
 
template<class T >
expression::ScaledMatrix< T > operator* (const BasicMatrix< T > &A, double k)
 
template<class T >
expression::ScaledMatrix< T > operator* (double k, const BasicMatrix< T > &A)
 
template<typename T >
expression::ScaledMatrix< T > operator- (const BasicMatrix< T > &m)
 negation operator More...
 
template<typename T >
expression::TransposedMatrix< T > transpose (const BasicMatrix< T > &A)
 transpose function More...
 
void inverse_svd (const MatrixBase &input, Matrix &result)
 
bool nan (const MatrixBase &templat, Matrix &flag)
 Create a Matrix flag indicating NaN's in another Matrix templat. More...
 
bool isnull (const MatrixBase &)
 Check if all elements of the Matrix are zero. More...
 
double max (const MatrixBase &)
 Get the maximum value of the Matrix. More...
 
double min (const MatrixBase &)
 Get the minimum value of the Matrix. More...
 
double trace (const MatrixBase &)
 Trace of matrix. More...
 
void swap (MatrixMutable &, MatrixMutable &)
 Exchange all elements between the matrices by copying. More...
 
void minmax_index (const MatrixBase &M, std::pair< size_t, size_t > &min, std::pair< size_t, size_t > &max)
 Locate the maximum and minimum element in the matrix, M. More...
 
std::ostream & operator<< (std::ostream &s, const MatrixBase &)
 The output operator for the MatrixBase class.
 

Detailed Description

Interface to GSL matrix.

For the time being 'double' is the only type supported.

[File streams] Reading and writing vectors to file streams
are of course supported. These are implemented without using GSL functionality, and thus binary read and write to streams are not supported.
Note
All GSL matrix related functions are not implement but most functionality defined for GSL matrices can be achieved with this interface class. Most notable GSL functionality not supported are no binary file support.

Member Typedef Documentation

◆ column_iterator

Mutable iterator that iterates over one column

◆ const_column_iterator

Read-only iterator that iterates over one column

◆ const_iterator

typedef Container2DIterator<const MatrixBase, const double, const double&> theplu::yat::utility::MatrixBase::const_iterator
inherited

Read-only iterator that iterates over all elements

◆ const_reference

typedef const double& theplu::yat::utility::MatrixBase::const_reference
inherited

const_reference type is const double&

Since
New in yat 0.5

◆ const_row_iterator

Read-only iterator that iterates over one row

◆ derived_type

Class that inherits from BasicMatrix

◆ iterator

Mutable iterator that iterates over all elements

◆ reference

reference type is double&

Since
New in yat 0.5

◆ row_iterator

Mutable iterator that iterates over one row

◆ value_type

value_type is double

Since
New in yat 0.5

Constructor & Destructor Documentation

◆ Matrix() [1/9]

theplu::yat::utility::Matrix::Matrix ( void  )

The default constructor.

This constructor does not initialize underlying (essential) structures.

◆ Matrix() [2/9]

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.

Exceptions
GSL_errorif memory allocation fails.

◆ Matrix() [3/9]

theplu::yat::utility::Matrix::Matrix ( const Matrix )

The copy constructor.

Exceptions
AGSL_error is indirectly thrown if memory allocation fails.

◆ Matrix() [4/9]

theplu::yat::utility::Matrix::Matrix ( const MatrixBase )
explicit

Copy from the base class.

Since
New in yat 0.20

◆ Matrix() [5/9]

template<class T >
theplu::yat::utility::Matrix::Matrix ( const MatrixExpression< T > &  other)

Constructor from a matrix expression. A matrix expression is result operator+, operator-, and operator*, or combinations of them.

A typical usage looks like

Matrix A( B * C + D)

where B, C, and D are all instances of class Matrix.

Typically MatrixExpression only exists as rvalue, and this operator is not called but the rvalue version, operator=(MatrixExpression<T>&&)

Invalidates, references, iterators and views.

Since
new in yat 0.15

◆ Matrix() [6/9]

theplu::yat::utility::Matrix::Matrix ( Matrix &&  )
noexcept

The move constructor.

Invalidates references, iterators, and views.

Since
new in yat 0.15

◆ Matrix() [7/9]

theplu::yat::utility::Matrix::Matrix ( MatrixMutable &&  )

Not implemented yet

Since
New in yat 0.20

◆ Matrix() [8/9]

template<class T >
theplu::yat::utility::Matrix::Matrix ( MatrixExpression< T > &&  other)
inline

Move constructor from a matrix expression. A matrix expression is result operator+, operator-, and operator*, or combinations of them.

A typical usage looks like

Matrix A( B * C + D)

where B, C, and D are all instances of class Matrix.

Invalidates, references, iterators and views.

Since
new in yat 0.15

◆ Matrix() [9/9]

theplu::yat::utility::Matrix::Matrix ( std::istream &  ,
char  sep = '\0' 
)
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.

  • If sep is the default '\0' value then column elements are separated with white space characters except the new line character. Multiple sequential white space characters are treated as one separator.
  • Setting sep to something else than the default value will change the behaviour to use the sep character as the separator between column elements. Multiple sequential sep characters will be treated as separating elements with missing values.

End of input is the end of file marker and this treatment cannot be redefined using the provided API.

Exceptions
GSL_errorif memory allocation fails, IO_error if unexpected input is found in the input stream.

Member Function Documentation

◆ all()

void theplu::yat::utility::MatrixMutable::all ( const double  value)
inherited

Set all elements to value.

◆ begin() [1/3]

const_iterator theplu::yat::utility::MatrixBase::begin
inherited

Iterator iterates along a row. When end of row is reached it jumps to beginning of next row.

Returns
const_iterator pointing to upper-left element.

◆ begin() [2/3]

iterator theplu::yat::utility::MatrixMutable::begin ( void  )
inherited

Iterator iterates along a row. When end of row is reached it jumps to beginning of next row.

Returns
iterator pointing to upper-left element.

◆ begin() [3/3]

const_iterator theplu::yat::utility::MatrixBase::begin ( void  ) const
inherited

Iterator iterates along a row. When end of row is reached it jumps to beginning of next row.

Returns
const_iterator pointing to upper-left element.

◆ begin_column() [1/3]

const_column_iterator theplu::yat::utility::MatrixBase::begin_column
inherited

Iterator iterates along a column.

Returns
const_iterator pointing to first element of column i.

◆ begin_column() [2/3]

column_iterator theplu::yat::utility::MatrixMutable::begin_column ( size_t  i)
inherited

Iterator iterates along a column.

Returns
iterator pointing to first element of column i.

◆ begin_column() [3/3]

const_column_iterator theplu::yat::utility::MatrixBase::begin_column ( size_t  i) const
inherited

Iterator iterates along a column.

Returns
const_iterator pointing to first element of column i.

◆ begin_row() [1/3]

const_row_iterator theplu::yat::utility::MatrixBase::begin_row
inherited

Iterator iterates along a row.

Returns
const_iterator pointing to first element of row i.

◆ begin_row() [2/3]

row_iterator theplu::yat::utility::MatrixMutable::begin_row ( size_t  i)
inherited

Iterator iterates along a row.

Returns
iterator pointing to first element of row i.

◆ begin_row() [3/3]

const_row_iterator theplu::yat::utility::MatrixBase::begin_row ( size_t  i) const
inherited

Iterator iterates along a row.

Returns
const_iterator pointing to first element of row i.

◆ column_const_view()

const VectorConstView theplu::yat::utility::MatrixBase::column_const_view ( size_t  ) const
inherited
Returns
const vector view of column i

◆ column_view()

VectorView theplu::yat::utility::MatrixMutable::column_view ( size_t  i)
inherited
Returns
Vector view of column i

◆ columns()

size_t theplu::yat::utility::MatrixBase::columns ( void  ) const
inherited
Returns
The number of columns in the matrix.

◆ copy_assign()

void theplu::yat::utility::Matrix::copy_assign ( const gsl_matrix *  rhs)
protectedvirtual

Allocate necessary memory in underlying GSL matrix and copy data from rhs. It is safe to copy from an rhs that overlap in underlying data structure.

Implements theplu::yat::utility::MatrixMutable.

◆ div()

void theplu::yat::utility::MatrixMutable::div ( const MatrixBase b)
inherited

Elementwise division of the elements of the calling matrix by the elements of matrix b, $ a_{ij} = a_{ij} / b_{ij} \; \forall i,j $. The result is stored into the calling matrix.

Exceptions
GSL_errorif dimensions mismatch.

◆ end() [1/3]

const_iterator theplu::yat::utility::MatrixBase::end
inherited
Returns
const_iterator pointing to end of matrix

◆ end() [2/3]

const_iterator theplu::yat::utility::MatrixBase::end ( void  ) const
inherited
Returns
const_iterator pointing to end of matrix

◆ end() [3/3]

iterator theplu::yat::utility::MatrixMutable::end ( void  )
inherited
Returns
iterator pointing to end of matrix

◆ end_column() [1/3]

const_column_iterator theplu::yat::utility::MatrixBase::end_column
inherited
Returns
const_iterator pointing to end of column i

◆ end_column() [2/3]

const_column_iterator theplu::yat::utility::MatrixBase::end_column ( size_t  i) const
inherited
Returns
const_iterator pointing to end of column i

◆ end_column() [3/3]

column_iterator theplu::yat::utility::MatrixMutable::end_column ( size_t  i)
inherited
Returns
iterator pointing to end of column i

◆ end_row() [1/3]

const_row_iterator theplu::yat::utility::MatrixBase::end_row
inherited
Returns
const_iterator pointing to end of row i

◆ end_row() [2/3]

const_row_iterator theplu::yat::utility::MatrixBase::end_row ( size_t  i) const
inherited
Returns
const_iterator pointing to end of row i

◆ end_row() [3/3]

row_iterator theplu::yat::utility::MatrixMutable::end_row ( size_t  i)
inherited
Returns
iterator pointing to end of row i

◆ equal()

bool theplu::yat::utility::MatrixBase::equal ( const MatrixBase ,
const double  precision = 0 
) const
inherited

Check whether matrices are equal within a user defined precision, set by precision.

Returns
True if each element deviates less or equal than d. If any matrix contain a NaN, false is always returned.
See also
operator== and operator!=

◆ gsl_matrix_p() [1/3]

virtual const gsl_matrix* theplu::yat::utility::MatrixBase::gsl_matrix_p
inherited
Returns
A const pointer to the internal GSL matrix.

◆ gsl_matrix_p() [2/3]

gsl_matrix* theplu::yat::utility::Matrix::gsl_matrix_p ( void  )
virtual
Returns
A pointer to the internal GSL matrix.

Implements theplu::yat::utility::MatrixMutable.

◆ gsl_matrix_p() [3/3]

const gsl_matrix* theplu::yat::utility::Matrix::gsl_matrix_p ( void  ) const
virtual
Returns
A const pointer to the internal GSL matrix.

Implements theplu::yat::utility::MatrixMutable.

◆ move_assign() [1/2]

void theplu::yat::utility::Matrix::move_assign ( MatrixMutable &&  rhs)
protectedvirtual

If rhs is a Matrix, move assignment is used, i.e., the operation is cheap (constant time) only swapping a two pointers. If rhs is a MatrixView, which doesn't own its data, data is aligned by copying instead. Dimensions of lhs and rhs do not need to be the same.

Reimplemented from theplu::yat::utility::MatrixMutable.

◆ move_assign() [2/2]

void theplu::yat::utility::Matrix::move_assign ( gsl_matrix *&&  rhs)
protectedvirtual

Move assign data in rhs into this. Currently, the passed rhs must own its data and move assignment is therefore always used. Dimensions of lhs and rhs do not need to be the same.

Implements theplu::yat::utility::MatrixMutable.

◆ mul()

void theplu::yat::utility::MatrixMutable::mul ( const MatrixBase b)
inherited

Multiply the elements of Matrix b with the elements of the calling Matrix , $ a_{ij} = a_{ij} * b_{ij} \; \forall i,j $. The result is stored into the calling Matrix.

Exceptions
GSL_errorif dimensions mismatch.

◆ operator!=()

bool theplu::yat::utility::MatrixBase::operator!= ( const MatrixBase other) const
inherited

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.

Returns
False if all elements are equal otherwise true.
See also
equal

◆ operator()() [1/2]

const double& theplu::yat::utility::MatrixBase::operator() ( size_t  row,
size_t  column 
) const
inherited

Element access operator.

Returns
Const reference to the element position (row, column).
Exceptions
IfGSL range checks are enabled in the underlying GSL library a GSL_error exception is thrown if either index is out of range.

◆ operator()() [2/2]

double& theplu::yat::utility::MatrixMutable::operator() ( size_t  row,
size_t  column 
)
inherited

Element access operator.

Returns
Reference to the element position (row, column).
Exceptions
IfGSL range checks are enabled in the underlying GSL library a GSL_error exception is thrown if either index is out of range.

◆ operator*=() [1/3]

const MatrixMutable& theplu::yat::utility::MatrixMutable::operator*=

Multiply and assignment operator.

Multiply the elements of the left hand side Matrix with a scalar d, $ a_{ij} = d * a_{ij} \; \forall i,j $.

Exceptions
GSL_errorif memory allocation fails.

◆ operator*=() [2/3]

const Matrix& theplu::yat::utility::Matrix::operator*= ( const Matrix )

Multiply and assignment operator.

Returns
Const reference to the resulting Matrix.
Note
invalidates views and iterators
Exceptions
GSL_errorif memory allocation fails.

◆ operator*=() [3/3]

const MatrixMutable& theplu::yat::utility::MatrixMutable::operator*= ( double  d)
inherited

Multiply and assignment operator.

Multiply the elements of the left hand side Matrix with a scalar d, $ a_{ij} = d * a_{ij} \; \forall i,j $.

Exceptions
GSL_errorif memory allocation fails.

◆ operator+=() [1/3]

const MatrixMutable& theplu::yat::utility::MatrixMutable::operator+= ( const MatrixBase b)
inherited

Add and assign operator.

Elementwise addition of the elements of Matrix b to the left hand side Matrix , $ a_{ij} = a_{ij} + b_{ij} \; \forall i,j $.

Returns
A const reference to the resulting Matrix.
Exceptions
GSL_errorif dimensions mismatch.

◆ operator+=() [2/3]

template<class T >
MatrixMutable& theplu::yat::utility::MatrixMutable::operator+= ( const MatrixExpression< T > &  rhs)
inlineinherited

Addition and assign operator.

Returns
A reference to resulting Matrix

◆ operator+=() [3/3]

const MatrixMutable& theplu::yat::utility::MatrixMutable::operator+= ( const double  d)
inherited

Add and assign operator.

Add the scalar value d to the left hand side Matrix, $ a_{ij} = a_{ij} + d \; \forall i,j $.

◆ operator-=() [1/3]

const MatrixMutable& theplu::yat::utility::MatrixMutable::operator-= ( const MatrixBase )
inherited

Subtract and assign operator.

Elementwise subtraction of the elements of Matrix b to the left hand side Matrix , $ a_{ij} = a_{ij} + b_{ij} \; \forall i,j $.

Returns
A const reference to the resulting Matrix.
Exceptions
GSL_errorif dimensions mismatch.

◆ operator-=() [2/3]

template<class T >
MatrixMutable& theplu::yat::utility::MatrixMutable::operator-= ( const MatrixExpression< T > &  rhs)
inlineinherited

Subtraction and assign operator.

Returns
A reference to the resulting VectorMutable.

◆ operator-=() [3/3]

const MatrixMutable& theplu::yat::utility::MatrixMutable::operator-= ( const double  d)
inherited

Subtract and assign operator.

Subtract the scalar value d to the left hand side Matrix, $ a_{ij} = a_{ij} + d \; \forall i,j $.

◆ operator=() [1/5]

const Matrix& theplu::yat::utility::Matrix::operator= ( const Matrix other)

The assignment operator.

Note
views and iterators are invalidated.
Returns
A const reference to the resulting Matrix.

◆ operator=() [2/5]

template<class T >
MatrixMutable& theplu::yat::utility::MatrixMutable::operator= ( class T  )
inline

Assignment from a matrix expression. A matrix expression is the result of operator+, operator-, and operator*, or combinations of them.

A typical usage looks like

A = B * C + D;

where A, B, C, and D are all instances of class Matrix.

Typically MatrixExpression only exists as rvalue, and this operator is not called but the rvalue version, operator=(MatrixExpression<T>&&)

Invalidates, references, iterators and views.

Since
new in yat 0.15

◆ operator=() [3/5]

MatrixMutable& theplu::yat::utility::MatrixMutable::operator=

The assignment operator.

Note
If lhs needs to be resized, views and iterators are invalidated.
Returns
A const reference to the resulting Matrix.

◆ operator=() [4/5]

template<class T >
MatrixMutable& theplu::yat::utility::MatrixMutable::operator= ( class T  )
inline

Move assignment from a matrix expression. A matrix expression is the result of operator+, operator-, and operator*, or combinations of them.

A typical usage looks like

A = B * C + D;

where B, C, and D are all instances of class Matrix.

Invalidates references, iterators, and views.

Since
new in yat 0.15

◆ operator=() [5/5]

Matrix& theplu::yat::utility::Matrix::operator= ( Matrix &&  other)

Move assignment operatorOnly reason they mention those 1e-5 peaks.

Invalidates references, iterators, and views.

Since
new in yat 0.15

◆ operator==()

bool theplu::yat::utility::MatrixBase::operator== ( const MatrixBase other) const
inherited

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.

Returns
True if all elements are equal otherwise false.
See also
equal

◆ resize()

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.

Note
underlying GSL matrix is destroyed and views and iterators are invalidated

◆ row_const_view()

const VectorConstView theplu::yat::utility::MatrixBase::row_const_view ( size_t  ) const
inherited
Returns
const vector view of i

◆ row_view()

VectorView theplu::yat::utility::MatrixMutable::row_view ( size_t  )
inherited
Returns
Vector view of i

◆ rows()

size_t theplu::yat::utility::MatrixBase::rows ( void  ) const
inherited
Returns
The number of rows in the matrix.

◆ swap_columns()

void theplu::yat::utility::MatrixMutable::swap_columns ( const size_t  i,
const size_t  j 
)
inherited

Swap columns i and j.

Exceptions
GSL_errorif either index is out of bounds.

◆ swap_rowcol()

void theplu::yat::utility::MatrixMutable::swap_rowcol ( const size_t  i,
const size_t  j 
)
inherited

Swap row i and column j.

The Matrix must be square.

Exceptions
GSL_errorif either index is out of bounds, or if matrix is not square.

◆ swap_rows()

void theplu::yat::utility::MatrixMutable::swap_rows ( const size_t  i,
const size_t  j 
)
inherited

Swap rows i and j.

Exceptions
GSL_errorif either index is out of bounds.

◆ transpose()

void theplu::yat::utility::Matrix::transpose ( void  )

Transpose the matrix.

Note
Unless matrix is square, views and iterators are invalidated.
Exceptions
GSL_errorif memory allocation fails for the new transposed matrix.

Friends And Related Function Documentation

◆ inverse_svd()

void inverse_svd ( const MatrixBase input,
Matrix result 
)
related

Calculate inverse of a (square) Matrix using SVD

Since
New in yat 0.15
Note
Space for Matrix result reallocated and references, iterators and views are invalidated.

◆ isnull()

bool isnull ( const MatrixBase )
related

Check if all elements of the Matrix are zero.

Returns
True if all elements in the Matrix is zero, false otherwise.

◆ max()

double max ( const MatrixBase )
related

Get the maximum value of the Matrix.

Returns
The maximum value of the Matrix.

◆ min()

double min ( const MatrixBase )
related

Get the minimum value of the Matrix.

Returns
The minimum value of the Matrix.

◆ minmax_index()

void minmax_index ( const MatrixBase M,
std::pair< size_t, size_t > &  min,
std::pair< size_t, size_t > &  max 
)
related

Locate the maximum and minimum element in the matrix, M.

The indices to the element with the minimum and maximum values of the matrix are returned through parameters min and max, respectively.

Note
Lower index has precedence (searching in row-major order).

◆ nan()

bool nan ( const MatrixBase templat,
Matrix flag 
)
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.

Note
If sizes mismatch, space for Matrix flag is reallocated and references, iterators, and views are invalidated.
Returns
True if the templat Matrix contains at least one NaN.

◆ operator*() [1/3]

template<class Derived1 , class Derived2 >
expression::MatrixProduct< BasicMatrix< Derived1 >, BasicMatrix< Derived2 > > operator* ( const BasicMatrix< Derived1 > &  lhs,
const BasicMatrix< Derived2 > &  rhs 
)
related

Matrix multiplication operator.

Since
new in yat 0.15
Returns
A Matrix Expression that can be converted to a Matrix

◆ operator*() [2/3]

template<class T >
expression::ScaledMatrix< T > operator* ( const BasicMatrix< T > &  A,
double  k 
)
related

Calculate a scaled Matrix of A as $ result_{ij} = k * A_{ij} $

Since
new in yat 0.15
Returns
A Matrix Expression that can be converted to a Matrix

◆ operator*() [3/3]

template<class T >
expression::ScaledMatrix< T > operator* ( double  k,
const BasicMatrix< T > &  A 
)
related

Calculate a scaled Matrix of A as $ result_{ij} = k * A_{ij} $

Since
new in yat 0.15
Returns
A Matrix Expression that can be converted to a Matrix

◆ operator+()

template<class Derived1 , class Derived2 >
expression::MatrixBinary< Derived1, Derived2, expression::Plus > operator+ ( const BasicMatrix< Derived1 > &  lhs,
const BasicMatrix< Derived2 > &  rhs 
)
related

Matrix addition operator.

Elementwise addition of the elements , $ result_{ij} = lhs_{ij} + rhs_{ij} \; \forall i,j $.

Since
new in yat 0.15
Returns
A Matrix Expression that can be converted to a Matrix

◆ operator-() [1/2]

template<class Derived1 , class Derived2 >
expression::MatrixBinary< Derived1, Derived2, expression::Minus > operator- ( const BasicMatrix< Derived1 > &  lhs,
const BasicMatrix< Derived2 > &  rhs 
)
related

Matrix subtraction operator.

Elementwise addition of the elements , $ result_{ij} = lhs_{ij} - rhs_{ij} \; \forall i,j $.

Since
new in yat 0.15
Returns
A Matrix Expression that can be converted to a Matrix

◆ operator-() [2/2]

template<typename T >
expression::ScaledMatrix< T > operator- ( const BasicMatrix< T > &  m)
related

negation operator

Since
new in yat 0.15

◆ swap()

void swap ( MatrixMutable ,
MatrixMutable  
)
related

Exchange all elements between the matrices by copying.

This function swaps element by element and matrices must have the same size. References and iterators are not invalidated.

If you do not care about iterators and references, std::swap is typically faster (only swapping a couple of pointers).

Exceptions
GSL_errorif sizes are not equal.

◆ trace()

double trace ( const MatrixBase )
related

Trace of matrix.

Returns
sum of diagonal elements
Since
New in yat 0.9

◆ transpose()

template<typename T >
expression::TransposedMatrix< T > transpose ( const BasicMatrix< T > &  A)
related

transpose function

Since
new in yat 0.15

Member Data Documentation

◆ blas_result_

gsl_matrix* theplu::yat::utility::MatrixMutable::blas_result_
protectedinherited

blas_result_ is used to temporarily store result in BLAS calls. Memory is not allocated for blas_result_ until it is needed.


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

Generated on Wed Jan 25 2023 03:34:29 for yat by  doxygen 1.8.14