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

#include <yat/utility/MatrixMutable.h>

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

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

 MatrixMutable (const MatrixMutable &)=delete
 The copy constructor.
 
virtual ~MatrixMutable (void)
 The destructor.
 
void all (const double value)
 
iterator begin (void)
 
column_iterator begin_column (size_t i)
 
row_iterator begin_row (size_t i)
 
VectorView column_view (size_t i)
 
void div (const MatrixBase &b)
 
iterator end (void)
 
column_iterator end_column (size_t i)
 
row_iterator end_row (size_t i)
 
virtual gsl_matrix * gsl_matrix_p (void)=0
 
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...
 
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+= (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_iterator begin (void) const
 
const_column_iterator begin_column (size_t i) const
 
const_row_iterator begin_row (size_t i) const
 
const_iterator end (void) const
 
const_column_iterator end_column (size_t i) const
 
const_row_iterator end_row (size_t i) const
 
virtual const gsl_matrix * gsl_matrix_p (void) const=0
 
const_iterator begin (void) const
 
const_column_iterator begin_column (size_t i) const
 
const_row_iterator begin_row (size_t i) const
 
const VectorConstView column_const_view (size_t) const
 
size_t columns (void) const
 
const_iterator end (void) const
 
const_column_iterator end_column (size_t i) const
 
const_row_iterator end_row (size_t i) 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
 
const double & operator() (size_t row, size_t column) const
 Element access operator. More...
 
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 MatrixBase &other)
 Behaves like operator=(const MatrixBase&)
 
virtual void copy_assign (const gsl_matrix *rhs)=0
 Behaves like operator=(const MatrixBase&)
 
virtual void move_assign (MatrixMutable &&other)
 
virtual void move_assign (gsl_matrix *&&rhs)=0
 
gsl_matrix * create_gsl_matrix_copy (void) const
 Create a new copy of the internal GSL matrix. More...
 

Protected Attributes

gsl_matrix * blas_result_
 

Friends

class detail::Mover
 

Related Functions

(Note that these are not member functions.)

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 class for mutable matrices including Matrix and view. The interface allows altering elements of the matrix data but not alter the dimensions.

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

Member Function Documentation

◆ all()

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

Set all elements to value.

◆ begin() [1/3]

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

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  )

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

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)

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

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)

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)
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.

◆ create_gsl_matrix_copy()

gsl_matrix* theplu::yat::utility::MatrixBase::create_gsl_matrix_copy ( void  ) const
protectedinherited

Create a new copy of the internal GSL matrix.

Necessary memory for the new GSL matrix is allocated and the caller is responsible for freeing the allocated memory.

Returns
A pointer to a copy of the internal GSL matrix.
Exceptions
GSL_errorif memory cannot be allocated for the new copy, or if dimensions mismatch.

◆ div()

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

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
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  )
Returns
iterator pointing to end of matrix

◆ end_column() [1/3]

const_column_iterator theplu::yat::utility::MatrixBase::end_column
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)
Returns
iterator pointing to end of column i

◆ end_row() [1/3]

const_row_iterator theplu::yat::utility::MatrixBase::end_row
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)
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
Returns
A const pointer to the internal GSL matrix.

◆ gsl_matrix_p() [2/3]

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

Implemented in theplu::yat::utility::Matrix, and theplu::yat::utility::MatrixView.

◆ gsl_matrix_p() [3/3]

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

Implements theplu::yat::utility::MatrixBase.

Implemented in theplu::yat::utility::Matrix, and theplu::yat::utility::MatrixView.

◆ move_assign() [1/2]

virtual void theplu::yat::utility::MatrixMutable::move_assign ( MatrixMutable &&  other)
protectedvirtual

◆ move_assign() [2/2]

virtual void theplu::yat::utility::MatrixMutable::move_assign ( gsl_matrix *&&  rhs)
protectedpure virtual

◆ mul()

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

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 
)

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*=()

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

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)

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)
inline

Addition and assign operator.

Returns
A reference to resulting Matrix

◆ operator+=() [3/3]

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

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 )

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)
inline

Subtraction and assign operator.

Returns
A reference to the resulting VectorMutable.

◆ operator-=() [3/3]

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

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/3]

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

The assignment operator.

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

◆ operator=() [2/3]

template<class T >
MatrixMutable& theplu::yat::utility::MatrixMutable::operator= ( const MatrixExpression< T > &  rhs)
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/3]

template<class T >
MatrixMutable& theplu::yat::utility::MatrixMutable::operator= ( MatrixExpression< T > &&  rhs)
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==()

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

◆ 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  )
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 
)

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 
)

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 
)

Swap rows i and j.

Exceptions
GSL_errorif either index is out of bounds.

Friends And Related Function Documentation

◆ 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).

◆ 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.

Member Data Documentation

◆ blas_result_

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

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 file:

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