guanaqo main
Utilities for scientific software
Loading...
Searching...
No Matches
guanaqo::MatrixView< T, I, S, O > Struct Template Reference

#include <guanaqo/mat-view.hpp>

Detailed Description

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
struct guanaqo::MatrixView< T, I, S, O >

A lightweight view of a 2D matrix.

Template Parameters
TElement type (may be const-qualified).
IIndex type for dimensions and strides.
SStride type for inner dimension. Can be an integral constant for compile-time known strides, or can be the same as I for runtime strides.
OStorage order (column-major or row-major).

Definition at line 68 of file mat-view.hpp.

Collaboration diagram for guanaqo::MatrixView< T, I, S, O >:

Classes

struct  PlainMatrixView
 POD type for designated initializers. More...

Public Types

using value_type = T
using index_type = I
using inner_stride_type = S

Public Member Functions

constexpr index_type outer_size () const
constexpr index_type inner_size () const
constexpr auto row_stride () const
constexpr index_type col_stride () const
 MatrixView (PlainMatrixView p)
value_typeoperator() (index_type r, index_type c) const
bool empty () const
MatrixView top_rows (index_type n) const
MatrixView left_cols (index_type n) const
MatrixView bottom_rows (index_type n) const
MatrixView right_cols (index_type n) const
MatrixView middle_rows (index_type r, index_type n) const
MatrixView middle_cols (index_type c, index_type n) const
MatrixView top_left (index_type nr, index_type nc) const
MatrixView top_right (index_type nr, index_type nc) const
MatrixView bottom_left (index_type nr, index_type nc) const
MatrixView bottom_right (index_type nr, index_type nc) const
MatrixView block (index_type r, index_type c, index_type nr, index_type nc) const
 operator MatrixView< const T, I, S, O > () const
MatrixView< T, I, S, transpose(O)> transposed () const
void set_constant (const value_type &t)
void set_constant (const value_type &t, Triangular tr)
void set_constant (const value_type &t, Triangular tr)
MatrixView< T, I, I, O > diagonal ()
void iter_diagonal (const auto f)
void iter_diagonal (const auto f) const
void set_diagonal (const value_type &t)
void add_to_diagonal (const value_type &t)
template<class Other>
void copy_values (const Other &other)
 MatrixView (const MatrixView &)=default
MatrixViewoperator= (const MatrixView &other)
template<class U, class J, class R>
MatrixViewoperator= (MatrixView< U, J, R, O > other)
template<class U, class J, class R>
MatrixViewoperator+= (MatrixView< U, J, R, O > other)
template<class U>
MatrixViewoperator+= (const U &u)
template<class Generator>
void generate (Generator gen)
MatrixViewreassign (MatrixView other)

Static Public Member Functions

static MatrixView as_column (std::span< T > v)
static MatrixView as_row (std::span< T > v)

Public Attributes

value_typedata
index_type rows
index_type cols
inner_stride_type inner_stride
index_type outer_stride

Static Public Attributes

static constexpr StorageOrder storage_order = O
static constexpr bool is_column_major = O == StorageOrder::ColMajor
static constexpr bool is_row_major = O == StorageOrder::RowMajor

Class Documentation

◆ guanaqo::MatrixView::PlainMatrixView

struct guanaqo::MatrixView::PlainMatrixView
Collaboration diagram for guanaqo::MatrixView< T, I, S, O >::PlainMatrixView:
Class Members
value_type * data = nullptr
index_type rows = 0
index_type cols = 1
inner_stride_type inner_stride
index_type outer_stride = inner_stride * (is_row_major ? cols : rows)

Member Typedef Documentation

◆ value_type

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
using guanaqo::MatrixView< T, I, S, O >::value_type = T

Definition at line 69 of file mat-view.hpp.

◆ index_type

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
using guanaqo::MatrixView< T, I, S, O >::index_type = I

Definition at line 70 of file mat-view.hpp.

◆ inner_stride_type

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
using guanaqo::MatrixView< T, I, S, O >::inner_stride_type = S

Definition at line 71 of file mat-view.hpp.

Constructor & Destructor Documentation

◆ MatrixView() [1/2]

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
guanaqo::MatrixView< T, I, S, O >::MatrixView ( PlainMatrixView< T, I, S, O > p)
inline

Definition at line 111 of file mat-view.hpp.

◆ MatrixView() [2/2]

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
guanaqo::MatrixView< T, I, S, O >::MatrixView ( const MatrixView< T, I, S, O > & )
default

Member Function Documentation

◆ outer_size()

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
index_type guanaqo::MatrixView< T, I, S, O >::outer_size ( ) const
inlinenodiscardconstexpr

Definition at line 82 of file mat-view.hpp.

Here is the caller graph for this function:

◆ inner_size()

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
index_type guanaqo::MatrixView< T, I, S, O >::inner_size ( ) const
inlinenodiscardconstexpr

Definition at line 85 of file mat-view.hpp.

Here is the caller graph for this function:

◆ row_stride()

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
auto guanaqo::MatrixView< T, I, S, O >::row_stride ( ) const
inlinenodiscardconstexpr

Definition at line 88 of file mat-view.hpp.

Here is the caller graph for this function:

◆ col_stride()

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
index_type guanaqo::MatrixView< T, I, S, O >::col_stride ( ) const
inlinenodiscardconstexpr

Definition at line 94 of file mat-view.hpp.

Here is the caller graph for this function:

◆ operator()()

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
value_type & guanaqo::MatrixView< T, I, S, O >::operator() ( index_type r,
index_type c ) const
inline

Definition at line 117 of file mat-view.hpp.

◆ empty()

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
bool guanaqo::MatrixView< T, I, S, O >::empty ( ) const
inlinenodiscard

Definition at line 130 of file mat-view.hpp.

◆ top_rows()

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
MatrixView guanaqo::MatrixView< T, I, S, O >::top_rows ( index_type n) const
inline

Definition at line 132 of file mat-view.hpp.

Here is the caller graph for this function:

◆ left_cols()

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
MatrixView guanaqo::MatrixView< T, I, S, O >::left_cols ( index_type n) const
inline

Definition at line 142 of file mat-view.hpp.

Here is the caller graph for this function:

◆ bottom_rows()

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
MatrixView guanaqo::MatrixView< T, I, S, O >::bottom_rows ( index_type n) const
inline

Definition at line 152 of file mat-view.hpp.

Here is the caller graph for this function:

◆ right_cols()

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
MatrixView guanaqo::MatrixView< T, I, S, O >::right_cols ( index_type n) const
inline

Definition at line 162 of file mat-view.hpp.

Here is the caller graph for this function:

◆ middle_rows()

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
MatrixView guanaqo::MatrixView< T, I, S, O >::middle_rows ( index_type r,
index_type n ) const
inline

Definition at line 172 of file mat-view.hpp.

Here is the caller graph for this function:

◆ middle_cols()

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
MatrixView guanaqo::MatrixView< T, I, S, O >::middle_cols ( index_type c,
index_type n ) const
inline

Definition at line 175 of file mat-view.hpp.

Here is the caller graph for this function:

◆ top_left()

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
MatrixView guanaqo::MatrixView< T, I, S, O >::top_left ( index_type nr,
index_type nc ) const
inline

Definition at line 178 of file mat-view.hpp.

◆ top_right()

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
MatrixView guanaqo::MatrixView< T, I, S, O >::top_right ( index_type nr,
index_type nc ) const
inline

Definition at line 181 of file mat-view.hpp.

◆ bottom_left()

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
MatrixView guanaqo::MatrixView< T, I, S, O >::bottom_left ( index_type nr,
index_type nc ) const
inline

Definition at line 184 of file mat-view.hpp.

◆ bottom_right()

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
MatrixView guanaqo::MatrixView< T, I, S, O >::bottom_right ( index_type nr,
index_type nc ) const
inline

Definition at line 187 of file mat-view.hpp.

◆ block()

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
MatrixView guanaqo::MatrixView< T, I, S, O >::block ( index_type r,
index_type c,
index_type nr,
index_type nc ) const
inline

Definition at line 190 of file mat-view.hpp.

◆ as_column()

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
MatrixView guanaqo::MatrixView< T, I, S, O >::as_column ( std::span< T > v)
inlinestatic

Definition at line 195 of file mat-view.hpp.

◆ as_row()

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
MatrixView guanaqo::MatrixView< T, I, S, O >::as_row ( std::span< T > v)
inlinestatic

Definition at line 205 of file mat-view.hpp.

◆ operator MatrixView< const T, I, S, O >()

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
guanaqo::MatrixView< T, I, S, O >::operator MatrixView< const T, I, S, O > ( ) const
inline

Definition at line 215 of file mat-view.hpp.

◆ transposed()

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
MatrixView< T, I, S, transpose(O)> guanaqo::MatrixView< T, I, S, O >::transposed ( ) const
inline

Definition at line 225 of file mat-view.hpp.

◆ set_constant() [1/3]

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
void guanaqo::MatrixView< T, I, S, O >::set_constant ( const value_type & t)
inline

Definition at line 235 of file mat-view.hpp.

◆ set_constant() [2/3]

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
void guanaqo::MatrixView< T, I, S, O >::set_constant ( const value_type & t,
Triangular tr )
inline

Definition at line 248 of file mat-view.hpp.

◆ set_constant() [3/3]

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
void guanaqo::MatrixView< T, I, S, O >::set_constant ( const value_type & t,
Triangular tr )
inline

Definition at line 277 of file mat-view.hpp.

◆ diagonal()

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
MatrixView< T, I, I, O > guanaqo::MatrixView< T, I, S, O >::diagonal ( )
inline

Definition at line 306 of file mat-view.hpp.

◆ iter_diagonal() [1/2]

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
void guanaqo::MatrixView< T, I, S, O >::iter_diagonal ( const auto f)
inline

Definition at line 315 of file mat-view.hpp.

Here is the caller graph for this function:

◆ iter_diagonal() [2/2]

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
void guanaqo::MatrixView< T, I, S, O >::iter_diagonal ( const auto f) const
inline

Definition at line 323 of file mat-view.hpp.

◆ set_diagonal()

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
void guanaqo::MatrixView< T, I, S, O >::set_diagonal ( const value_type & t)
inline

Definition at line 331 of file mat-view.hpp.

◆ add_to_diagonal()

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
void guanaqo::MatrixView< T, I, S, O >::add_to_diagonal ( const value_type & t)
inline

Definition at line 334 of file mat-view.hpp.

◆ copy_values()

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
template<class Other>
void guanaqo::MatrixView< T, I, S, O >::copy_values ( const Other & other)
inline

Definition at line 338 of file mat-view.hpp.

Here is the caller graph for this function:

◆ operator=() [1/2]

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
MatrixView & guanaqo::MatrixView< T, I, S, O >::operator= ( const MatrixView< T, I, S, O > & other)
inline

Definition at line 361 of file mat-view.hpp.

◆ operator=() [2/2]

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
template<class U, class J, class R>
MatrixView & guanaqo::MatrixView< T, I, S, O >::operator= ( MatrixView< U, J, R, O > other)
inline

Definition at line 370 of file mat-view.hpp.

◆ operator+=() [1/2]

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
template<class U, class J, class R>
MatrixView & guanaqo::MatrixView< T, I, S, O >::operator+= ( MatrixView< U, J, R, O > other)
inline

Definition at line 379 of file mat-view.hpp.

◆ operator+=() [2/2]

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
template<class U>
MatrixView & guanaqo::MatrixView< T, I, S, O >::operator+= ( const U & u)
inline

Definition at line 399 of file mat-view.hpp.

◆ generate()

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
template<class Generator>
void guanaqo::MatrixView< T, I, S, O >::generate ( Generator gen)
inline

Definition at line 412 of file mat-view.hpp.

◆ reassign()

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
MatrixView & guanaqo::MatrixView< T, I, S, O >::reassign ( MatrixView< T, I, S, O > other)
inline

Definition at line 417 of file mat-view.hpp.

Member Data Documentation

◆ storage_order

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
StorageOrder guanaqo::MatrixView< T, I, S, O >::storage_order = O
staticconstexpr

Definition at line 72 of file mat-view.hpp.

◆ is_column_major

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
bool guanaqo::MatrixView< T, I, S, O >::is_column_major = O == StorageOrder::ColMajor
staticconstexpr

Definition at line 73 of file mat-view.hpp.

◆ is_row_major

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
bool guanaqo::MatrixView< T, I, S, O >::is_row_major = O == StorageOrder::RowMajor
staticconstexpr

Definition at line 74 of file mat-view.hpp.

◆ data

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
value_type* guanaqo::MatrixView< T, I, S, O >::data

Definition at line 76 of file mat-view.hpp.

◆ rows

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
index_type guanaqo::MatrixView< T, I, S, O >::rows

Definition at line 77 of file mat-view.hpp.

◆ cols

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
index_type guanaqo::MatrixView< T, I, S, O >::cols

Definition at line 78 of file mat-view.hpp.

◆ inner_stride

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
inner_stride_type guanaqo::MatrixView< T, I, S, O >::inner_stride

Definition at line 79 of file mat-view.hpp.

◆ outer_stride

template<class T, class I = ptrdiff_t, class S = std::integral_constant<I, 1>, StorageOrder O = StorageOrder::ColMajor>
index_type guanaqo::MatrixView< T, I, S, O >::outer_stride

Definition at line 80 of file mat-view.hpp.


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