ampsci
High-precision calculations for one- and two-valence atomic systems
LinAlg::Matrix_view< T >

ok

template<typename T>
class LinAlg::Matrix_view< T >

Non-owning 2D view onto a Matrix.

Provides row/column element access to an existing matrix buffer without ownership or resize capability. Supports both mutable (Matrix_view<T>) and read-only (Matrix_view<const T>) access.

Implicitly constructible from Matrix<T> (mutable view) and from const Matrix<T> (const view only).

Note
Iterators (begin()/end()) yield raw pointers into the flat buffer.

#include <Matrix.hpp>

Public Member Functions

 Matrix_view (T *data, std::size_t rows, std::size_t cols)
 Construct from raw pointer and dimensions (no ownership)
 
 Matrix_view (Matrix< std::remove_const_t< T > > &m)
 Implicit conversion from mutable Matrix (works for both mutable and const view)
 
template<typename U = T, typename = std::enable_if_t<std::is_const_v<U>>>
 Matrix_view (const Matrix< std::remove_const_t< T > > &m)
 Implicit conversion from const Matrix (only for Matrix_view<const T>)
 
std::size_t rows () const
 Return rows [major index size].
 
std::size_t cols () const
 Return columns [minor index size].
 
std::size_t size () const
 Return rows*columns [total array size].
 
bool empty () const
 Bool - is empty? (same as size==0)
 
T * data ()
 Raw pointer to first element, mutable.
 
const T * data () const
 Raw pointer to first element, const.
 
T * operator[] (std::size_t i)
 [] index access (no range checking). [i] returns pointer to ith row, mutable
 
const T * operator[] (std::size_t i) const
 [] index access (no range checking). [i] returns const pointer to ith row
 
T & at (std::size_t i, std::size_t j)
 at(i,j): element access with range checking, mutable
 
at (std::size_t i, std::size_t j) const
 at(i,j): element access with range checking, const
 
const T & atc (std::size_t i, std::size_t j) const
 at(i,j): element access with range checking, const ref
 
T & operator() (std::size_t i, std::size_t j)
 () index access with range checking, mutable
 
operator() (std::size_t i, std::size_t j) const
 () index access with range checking, const
 
auto begin ()
 Iterators over flat data buffer.
 
auto end ()
 
auto cbegin () const
 
auto cend () const
 

Constructor & Destructor Documentation

◆ Matrix_view() [1/3]

template<typename T >
LinAlg::Matrix_view< T >::Matrix_view ( T *  data,
std::size_t  rows,
std::size_t  cols 
)
inline

Construct from raw pointer and dimensions (no ownership)

◆ Matrix_view() [2/3]

template<typename T >
LinAlg::Matrix_view< T >::Matrix_view ( Matrix< std::remove_const_t< T > > &  m)
inline

Implicit conversion from mutable Matrix (works for both mutable and const view)

◆ Matrix_view() [3/3]

template<typename T >
template<typename U = T, typename = std::enable_if_t<std::is_const_v<U>>>
LinAlg::Matrix_view< T >::Matrix_view ( const Matrix< std::remove_const_t< T > > &  m)
inline

Implicit conversion from const Matrix (only for Matrix_view<const T>)

Member Function Documentation

◆ rows()

template<typename T >
std::size_t LinAlg::Matrix_view< T >::rows ( ) const
inline

Return rows [major index size].

◆ cols()

template<typename T >
std::size_t LinAlg::Matrix_view< T >::cols ( ) const
inline

Return columns [minor index size].

◆ size()

template<typename T >
std::size_t LinAlg::Matrix_view< T >::size ( ) const
inline

Return rows*columns [total array size].

◆ empty()

template<typename T >
bool LinAlg::Matrix_view< T >::empty ( ) const
inline

Bool - is empty? (same as size==0)

◆ data() [1/2]

template<typename T >
T * LinAlg::Matrix_view< T >::data ( )
inline

Raw pointer to first element, mutable.

◆ data() [2/2]

template<typename T >
const T * LinAlg::Matrix_view< T >::data ( ) const
inline

Raw pointer to first element, const.

◆ operator[]() [1/2]

template<typename T >
T * LinAlg::Matrix_view< T >::operator[] ( std::size_t  i)
inline

[] index access (no range checking). [i] returns pointer to ith row, mutable

◆ operator[]() [2/2]

template<typename T >
const T * LinAlg::Matrix_view< T >::operator[] ( std::size_t  i) const
inline

[] index access (no range checking). [i] returns const pointer to ith row

◆ at() [1/2]

template<typename T >
T & LinAlg::Matrix_view< T >::at ( std::size_t  i,
std::size_t  j 
)
inline

at(i,j): element access with range checking, mutable

◆ at() [2/2]

template<typename T >
T LinAlg::Matrix_view< T >::at ( std::size_t  i,
std::size_t  j 
) const
inline

at(i,j): element access with range checking, const

◆ atc()

template<typename T >
const T & LinAlg::Matrix_view< T >::atc ( std::size_t  i,
std::size_t  j 
) const
inline

at(i,j): element access with range checking, const ref

◆ operator()() [1/2]

template<typename T >
T & LinAlg::Matrix_view< T >::operator() ( std::size_t  i,
std::size_t  j 
)
inline

() index access with range checking, mutable

◆ operator()() [2/2]

template<typename T >
T LinAlg::Matrix_view< T >::operator() ( std::size_t  i,
std::size_t  j 
) const
inline

() index access with range checking, const

◆ begin()

template<typename T >
auto LinAlg::Matrix_view< T >::begin ( )
inline

Iterators over flat data buffer.


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