MTL5 -- Matrix Template Library C++ API
mtl:: -- C++20 header-only linear algebra for mixed-precision algorithm design
Loading...
Searching...
No Matches
mtl::mat Namespace Reference

Namespaces

namespace  fixed
namespace  non_fixed
namespace  expr
namespace  view

Classes

class  block_diagonal2D
 Block diagonal matrix – stores vector of dense2D blocks. More...
class  block_matrix_view
 Read-only, row-major view of a rows x cols matrix stored as blocks of the scheme S, cols / S::block_size blocks per row. More...
class  compressed2D
 CSR sparse matrix: three arrays – data (values), indices (column indices), starts (row pointers of length nrows+1). More...
class  coordinate2D
 COO sparse matrix: stores (row, col, value) triplets. More...
class  dense2D
 Dense row/column-major matrix with configurable dimensions and storage. More...
class  ell_matrix
 ELLPACK sparse matrix: each row stores up to max_width non-zeros. More...
class  identity2D
 Implicit identity matrix: no storage, O(1) element access. More...
struct  update_store
 Overwrite: a = b (default updater). More...
struct  update_plus
 Accumulate: a += b. More...
class  compressed2D_inserter
 RAII inserter for compressed2D. More...
struct  parameters
 Parameter bundle for matrix types. More...
class  permutation_matrix
 Implicit permutation matrix – stores only perm vector, O(n) storage. More...
class  shifted_inserter
 Offset decorator for sparse matrix inserters. More...
struct  fixed_dimensions

Typedefs

template<typename Value, typename Orientation = tag::row_major>
using const_matrix_view
 A read-only dense matrix over memory the caller owns (tag::read_only): const access only, no allocation, no copy of the elements.
template<typename Matrix, typename Updater = update_store<typename Matrix::value_type>>
using inserter
 Convenience alias: inserter<MatrixType, Updater>.

Functions

template<typename Value, typename VV, typename VP>
auto operator* (const block_diagonal2D< Value > &BD, const vec::dense_vector< VV, VP > &x)
template<BlockScheme S, Vector V>
requires (!Matrix<V>)
auto operator* (const block_matrix_view< S > &A, const V &x)
 A * x into a new dense_vector, through mult().
template<typename Value>
const_matrix_view< Value > const_view (std::size_t rows, std::size_t cols, const Value *ptr)
 A read-only row-major view of the rows x cols elements at ptr.
template<typename Value, typename Parameters>
auto const_view (const dense2D< Value, Parameters > &A)
 A read-only view of A's elements, in A's orientation and index base: hand a matrix to code that must not change it, without copying it.
template<typename Value, typename Parameters>
void const_view (const dense2D< Value, Parameters > &&)=delete
 A view of a temporary would dangle at the end of the full-expression.
template<typename Value, typename Parameters>
auto num_rows (const dense2D< Value, Parameters > &m)
template<typename Value, typename Parameters>
auto num_cols (const dense2D< Value, Parameters > &m)
template<typename Value, typename Parameters>
auto size (const dense2D< Value, Parameters > &m)
template<typename M1, typename M2>
requires (Matrix<std::remove_cvref_t<M1>> && Matrix<std::remove_cvref_t<M2>>)
auto operator+ (M1 &&a, M2 &&b)
template<typename M1, typename M2>
requires (Matrix<std::remove_cvref_t<M1>> && Matrix<std::remove_cvref_t<M2>>)
auto operator- (M1 &&a, M2 &&b)
template<typename M>
requires Matrix<std::remove_cvref_t<M>>
auto operator- (M &&m)
template<typename S, typename M>
requires ((!Collection<S> && Scalar<S>) && Matrix<std::remove_cvref_t<M>>)
auto operator* (const S &alpha, M &&m)
template<typename M, typename S>
requires (Matrix<std::remove_cvref_t<M>> && (!Collection<S> && Scalar<S>))
auto operator* (M &&m, const S &alpha)
template<typename M, typename S>
requires (Matrix<std::remove_cvref_t<M>> && (!Collection<S> && Scalar<S>))
auto operator/ (M &&m, const S &alpha)
template<Matrix M, Vector V>
requires (!Matrix<V>)
auto operator* (const M &A, const V &x)
template<Matrix M1, Matrix M2>
auto operator* (const M1 &A, const M2 &B)
template<typename V1, typename P1, typename V2, typename P2>
auto operator* (const compressed2D< V1, P1 > &A, const compressed2D< V2, P2 > &B)
template<typename V, typename P, typename VV, typename VP>
auto operator* (const compressed2D< V, P > &A, const vec::dense_vector< VV, VP > &x)
template<typename V, typename P, typename VV, typename VP>
auto operator* (const view::transposed_view< compressed2D< V, P > > &At, const vec::dense_vector< VV, VP > &x)
template<typename Value, typename VV, typename VP>
auto operator* (const permutation_matrix< Value > &P, const vec::dense_vector< VV, VP > &x)
template<typename Value, typename Params>
dense2D< Value, Params > reorder_rows (const dense2D< Value, Params > &A, const std::vector< std::size_t > &perm)
 Reorder rows: B(i,:) = A(perm[i],:).
template<typename Value, typename Params>
dense2D< Value, Params > reorder_cols (const dense2D< Value, Params > &A, const std::vector< std::size_t > &perm)
 Reorder columns: B(:,j) = A(:,perm[j]).
template<typename Value, typename Params>
dense2D< Value, Params > reorder (const dense2D< Value, Params > &A, const std::vector< std::size_t > &perm)
 Symmetric reorder: B = P * A * P^T B(i,j) = A(perm[i], perm[j]).
template<typename PV, typename MV, typename MP>
dense2D< std::common_type_t< PV, MV >, MP > operator* (const permutation_matrix< PV > &P, const dense2D< MV, MP > &A)
 P * A: permutation_matrix times dense2D -> reorder_rows.

Typedef Documentation

◆ const_matrix_view

template<typename Value, typename Orientation = tag::row_major>
using mtl::mat::const_matrix_view
Initial value:
dense2D<Value,
Dense row/column-major matrix with configurable dimensions and storage.
Definition dense2D.hpp:52
Parameter bundle for matrix types.
Definition parameter.hpp:23

A read-only dense matrix over memory the caller owns (tag::read_only): const access only, no allocation, no copy of the elements.

The buffer holds rows x cols elements in Orientation order with no padding.

◆ inserter

template<typename Matrix, typename Updater = update_store<typename Matrix::value_type>>
using mtl::mat::inserter
Initial value:
typename Matrix::value_type,
typename Matrix::param_type,
Updater>
RAII inserter for compressed2D.
Definition inserter.hpp:54

Convenience alias: inserter<MatrixType, Updater>.

Function Documentation

◆ const_view() [1/3]

template<typename Value, typename Parameters>
void mtl::mat::const_view ( const dense2D< Value, Parameters > && )
delete

A view of a temporary would dangle at the end of the full-expression.

◆ const_view() [2/3]

template<typename Value, typename Parameters>
auto mtl::mat::const_view ( const dense2D< Value, Parameters > & A)

A read-only view of A's elements, in A's orientation and index base: hand a matrix to code that must not change it, without copying it.

A must outlive the view.

◆ const_view() [3/3]

template<typename Value>
const_matrix_view< Value > mtl::mat::const_view ( std::size_t rows,
std::size_t cols,
const Value * ptr )

A read-only row-major view of the rows x cols elements at ptr.

For a column-major buffer, use const_matrix_view<Value, tag::col_major> directly. The buffer must outlive the view.

◆ num_cols()

template<typename Value, typename Parameters>
auto mtl::mat::num_cols ( const dense2D< Value, Parameters > & m)

◆ num_rows()

template<typename Value, typename Parameters>
auto mtl::mat::num_rows ( const dense2D< Value, Parameters > & m)

◆ operator*() [1/11]

template<typename Value, typename VV, typename VP>
auto mtl::mat::operator* ( const block_diagonal2D< Value > & BD,
const vec::dense_vector< VV, VP > & x )

◆ operator*() [2/11]

template<BlockScheme S, Vector V>
requires (!Matrix<V>)
auto mtl::mat::operator* ( const block_matrix_view< S > & A,
const V & x )

A * x into a new dense_vector, through mult().

Found by ADL, and more specialized than the generic Matrix * Vector operator, which would decode one block per element.

◆ operator*() [3/11]

template<typename V, typename P, typename VV, typename VP>
auto mtl::mat::operator* ( const compressed2D< V, P > & A,
const vec::dense_vector< VV, VP > & x )

◆ operator*() [4/11]

template<typename V1, typename P1, typename V2, typename P2>
auto mtl::mat::operator* ( const compressed2D< V1, P1 > & A,
const compressed2D< V2, P2 > & B )

◆ operator*() [5/11]

template<Matrix M, Vector V>
requires (!Matrix<V>)
auto mtl::mat::operator* ( const M & A,
const V & x )

◆ operator*() [6/11]

template<Matrix M1, Matrix M2>
auto mtl::mat::operator* ( const M1 & A,
const M2 & B )

◆ operator*() [7/11]

template<typename PV, typename MV, typename MP>
dense2D< std::common_type_t< PV, MV >, MP > mtl::mat::operator* ( const permutation_matrix< PV > & P,
const dense2D< MV, MP > & A )

P * A: permutation_matrix times dense2D -> reorder_rows.

◆ operator*() [8/11]

template<typename Value, typename VV, typename VP>
auto mtl::mat::operator* ( const permutation_matrix< Value > & P,
const vec::dense_vector< VV, VP > & x )

◆ operator*() [9/11]

template<typename S, typename M>
requires ((!Collection<S> && Scalar<S>) && Matrix<std::remove_cvref_t<M>>)
auto mtl::mat::operator* ( const S & alpha,
M && m )

◆ operator*() [10/11]

template<typename V, typename P, typename VV, typename VP>
auto mtl::mat::operator* ( const view::transposed_view< compressed2D< V, P > > & At,
const vec::dense_vector< VV, VP > & x )

◆ operator*() [11/11]

template<typename M, typename S>
requires (Matrix<std::remove_cvref_t<M>> && (!Collection<S> && Scalar<S>))
auto mtl::mat::operator* ( M && m,
const S & alpha )

◆ operator+()

template<typename M1, typename M2>
requires (Matrix<std::remove_cvref_t<M1>> && Matrix<std::remove_cvref_t<M2>>)
auto mtl::mat::operator+ ( M1 && a,
M2 && b )

◆ operator-() [1/2]

template<typename M>
requires Matrix<std::remove_cvref_t<M>>
auto mtl::mat::operator- ( M && m)

◆ operator-() [2/2]

template<typename M1, typename M2>
requires (Matrix<std::remove_cvref_t<M1>> && Matrix<std::remove_cvref_t<M2>>)
auto mtl::mat::operator- ( M1 && a,
M2 && b )

◆ operator/()

template<typename M, typename S>
requires (Matrix<std::remove_cvref_t<M>> && (!Collection<S> && Scalar<S>))
auto mtl::mat::operator/ ( M && m,
const S & alpha )

◆ reorder()

template<typename Value, typename Params>
dense2D< Value, Params > mtl::mat::reorder ( const dense2D< Value, Params > & A,
const std::vector< std::size_t > & perm )

Symmetric reorder: B = P * A * P^T B(i,j) = A(perm[i], perm[j]).

◆ reorder_cols()

template<typename Value, typename Params>
dense2D< Value, Params > mtl::mat::reorder_cols ( const dense2D< Value, Params > & A,
const std::vector< std::size_t > & perm )

Reorder columns: B(:,j) = A(:,perm[j]).

◆ reorder_rows()

template<typename Value, typename Params>
dense2D< Value, Params > mtl::mat::reorder_rows ( const dense2D< Value, Params > & A,
const std::vector< std::size_t > & perm )

Reorder rows: B(i,:) = A(perm[i],:).

◆ size()

template<typename Value, typename Parameters>
auto mtl::mat::size ( const dense2D< Value, Parameters > & m)