|
MTL5 -- Matrix Template Library C++ API
mtl:: -- C++20 header-only linear algebra for mixed-precision algorithm design
|
Dense row/column-major matrix with configurable dimensions and storage. More...
#include <dense2D.hpp>
Public Types | |
| using | param_type = Parameters |
| using | orientation = typename Parameters::orientation |
| using | index_type = typename Parameters::index_type |
| using | dim_type = typename Parameters::dimensions_type |
| using | size_type = typename Parameters::size_type |
| using | actual_storage = typename Parameters::storage |
| using | memory_space = ::mtl::detail::memory_space_of_t<Parameters> |
| Where the elements live (#223). | |
| using | memory_type = detail::contiguous_memory_block<Value, actual_storage, static_size, memory_space> |
| using | value_type = Value |
| using | reference = std::conditional_t<read_only, const Value&, Value&> |
| using | const_reference = const Value& |
| using | pointer = std::conditional_t<read_only, const Value*, Value*> |
| using | const_pointer = const Value* |
| using | handle_type = typename memory_type::handle_type |
| What data() returns: how the memory space names the storage (#1017). | |
| using | const_handle_type = typename memory_type::const_handle_type |
Public Member Functions | |
| dense2D () | |
| dense2D (size_type rows, size_type cols) | |
| dense2D (const dim_type &d) | |
| dense2D (size_type rows, size_type cols, handle_type ptr) | |
| dense2D (size_type rows, size_type cols, const Value *ptr) | |
| dense2D (size_type rows, size_type cols, handle_type h) | |
| dense2D (std::initializer_list< std::initializer_list< Value > > il) | |
| dense2D (const dense2D &)=default | |
| dense2D & | operator= (const dense2D &)=default |
| ~dense2D ()=default | |
| template<typename P2> requires (!read_only && host_access && !std::same_as<P2, Parameters> && dense2D<Value, P2>::read_only && dense2D<Value, P2>::host_access) | |
| dense2D (const dense2D< Value, P2 > &view) | |
| An owning matrix from a read-only view: copies the elements, so the copy can be changed. | |
| template<typename P2> requires (!read_only && host_access && AllocatingMemorySpace<memory_space, Value> && dense2D<Value, P2>::host_access && detail::mat_params_differ_only_in_space_v<Parameters, P2>) | |
| dense2D (const dense2D< Value, P2 > &src) | |
| A copy of a matrix in another memory space (#1012): the bundles agree in every axis but the space, so the layouts match, and both spaces are host-accessible, so the copy is a host loop. | |
| template<typename P2> requires (!read_only && host_access && dense2D<Value, P2>::host_access && detail::mat_params_differ_only_in_space_v<Parameters, P2>) | |
| dense2D & | operator= (const dense2D< Value, P2 > &src) |
| Assignment from a matrix in another host-accessible memory space (#1012), with the rules of expression assignment: a matrix over an external buffer keeps it and receives the elements in the source's shape, and a source with another element count throws. | |
| dense2D (const dense2D &other) | |
| Copying a read-only view gives another view of the same buffer, not a copy of its elements: like the view itself, the copy is valid only while the caller's buffer is (#855). | |
| dense2D & | operator= (const dense2D &)=delete |
| dense2D (dense2D &&other) noexcept(std::is_nothrow_move_constructible_v< memory_type >) | |
| dense2D & | operator= (dense2D &&)=delete |
| A matrix over an external buffer with as many elements keeps its buffer and receives the elements, in the source's shape; the source keeps its own (#829). | |
| dense2D & | operator= (dense2D &&other) noexcept |
| template<typename Expr> requires (!read_only && host_access && Matrix<Expr> && traits::is_expression_v<Expr> && std::convertible_to<typename Expr::value_type, Value>) | |
| dense2D (const Expr &expr) | |
| template<typename Expr> requires (!read_only && host_access && Matrix<Expr> && traits::is_expression_v<Expr> && std::convertible_to<typename Expr::value_type, Value>) | |
| dense2D & | operator= (const Expr &expr) |
| template<typename Expr> requires (!read_only && host_access && Matrix<Expr> && traits::is_expression_v<Expr> && std::convertible_to<typename Expr::value_type, Value>) | |
| dense2D & | operator+= (const Expr &expr) |
| template<typename Expr> requires (!read_only && host_access && Matrix<Expr> && traits::is_expression_v<Expr> && std::convertible_to<typename Expr::value_type, Value>) | |
| dense2D & | operator-= (const Expr &expr) |
| Value & | operator() (size_type r, size_type c) |
| const_reference | operator() (size_type r, size_type c) const |
| size_type | num_rows () const |
| size_type | num_cols () const |
| size_type | size () const |
| size_type | get_ldim () const |
| bool | owns_memory () const noexcept |
| Whether this matrix owns its elements: false for one made over an external pointer, whose elements belong to the caller. | |
| handle_type | data () |
| const_handle_type | data () const |
| Value * | begin () |
| const_pointer | begin () const |
| Value * | end () |
| const_pointer | end () const |
| void | change_dim (size_type r, size_type c) |
| void | checked_change_dim (size_type r, size_type c) |
| dense2D & | operator+= (const dense2D &other) |
| dense2D & | operator-= (const dense2D &other) |
| template<typename S> requires (!read_only && host_access && Scalar<S>) | |
| dense2D & | operator*= (const S &alpha) |
| template<typename S> requires (!read_only && host_access && Field<S>) | |
| dense2D & | operator/= (const S &alpha) |
| void | swap (dense2D &other) noexcept |
Static Public Attributes | |
| static constexpr bool | is_fixed = dim_type::is_fixed |
| static constexpr std::size_t | static_size |
| static constexpr bool | host_access = memory_space::host_accessible |
| static constexpr bool | read_only = std::is_same_v<actual_storage, tag::read_only> |
| A read-only view (tag::read_only storage) over a caller's const Value*: only const access, so writing through it does not compile. | |
Friends | |
| void | swap (dense2D &a, dense2D &b) noexcept |
| Found by ADL (using std::swap; swap(a, b);): exchanges the storage, so a matrix over an external buffer and an owning one trade places. | |
Dense row/column-major matrix with configurable dimensions and storage.
| using mtl::mat::dense2D< Value, Parameters >::actual_storage = typename Parameters::storage |
| using mtl::mat::dense2D< Value, Parameters >::const_handle_type = typename memory_type::const_handle_type |
| using mtl::mat::dense2D< Value, Parameters >::const_pointer = const Value* |
| using mtl::mat::dense2D< Value, Parameters >::const_reference = const Value& |
| using mtl::mat::dense2D< Value, Parameters >::dim_type = typename Parameters::dimensions_type |
| using mtl::mat::dense2D< Value, Parameters >::handle_type = typename memory_type::handle_type |
What data() returns: how the memory space names the storage (#1017).
Value* and const Value* in every space whose handle is a pointer, host memory included; an object with an offset in a space whose storage is not addressed by a pointer, whose host address begin() gives where the space is host-accessible.
| using mtl::mat::dense2D< Value, Parameters >::index_type = typename Parameters::index_type |
| using mtl::mat::dense2D< Value, Parameters >::memory_space = ::mtl::detail::memory_space_of_t<Parameters> |
Where the elements live (#223).
Element access needs host access. A parameter bundle without a memory_space (one written before #223) is host.
| using mtl::mat::dense2D< Value, Parameters >::memory_type = detail::contiguous_memory_block<Value, actual_storage, static_size, memory_space> |
| using mtl::mat::dense2D< Value, Parameters >::orientation = typename Parameters::orientation |
| using mtl::mat::dense2D< Value, Parameters >::param_type = Parameters |
| using mtl::mat::dense2D< Value, Parameters >::pointer = std::conditional_t<read_only, const Value*, Value*> |
| using mtl::mat::dense2D< Value, Parameters >::reference = std::conditional_t<read_only, const Value&, Value&> |
| using mtl::mat::dense2D< Value, Parameters >::size_type = typename Parameters::size_type |
| using mtl::mat::dense2D< Value, Parameters >::value_type = Value |
|
inline |
|
inline |
|
inlineexplicit |
|
inline |
|
inline |
|
inline |
|
inline |
|
default |
|
default |
|
inlineexplicit |
An owning matrix from a read-only view: copies the elements, so the copy can be changed.
The view may differ in orientation and index base. Explicit (#855): implicit, it let a view passed to a by-value dense2D parameter deep-copy without a word at the call site. Write dense2D<double>(view).
|
inlineexplicit |
A copy of a matrix in another memory space (#1012): the bundles agree in every axis but the space, so the layouts match, and both spaces are host-accessible, so the copy is a host loop.
This matrix owns its copy, so its space must allocate. Explicit, as the view copy above (#855).
|
inline |
Copying a read-only view gives another view of the same buffer, not a copy of its elements: like the view itself, the copy is valid only while the caller's buffer is (#855).
For an owning copy, construct a dense2D<Value> from it.
|
inlinenoexcept |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
default |
|
delete |
|
inline |
Assignment from a matrix in another host-accessible memory space (#1012), with the rules of expression assignment: a matrix over an external buffer keeps it and receives the elements in the source's shape, and a source with another element count throws.
Two views of one buffer in the same shape copy nothing. A source that overlaps this matrix's storage otherwise (part of it, the same buffer in another shape, or the buffer a resize would free) is copied out first.
|
inline |
|
delete |
A matrix over an external buffer with as many elements keeps its buffer and receives the elements, in the source's shape; the source keeps its own (#829).
An owning matrix stays owning: a source over an external buffer is copied, not taken over (#856).
|
inlinenoexcept |
|
inlinenoexcept |
Whether this matrix owns its elements: false for one made over an external pointer, whose elements belong to the caller.
|
inline |
|
inlinenoexcept |
|
friend |
Found by ADL (using std::swap; swap(a, b);): exchanges the storage, so a matrix over an external buffer and an owning one trade places.
std::swap goes through the moves instead, and a move into an external matrix of another size aborts (#856).
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
A read-only view (tag::read_only storage) over a caller's const Value*: only const access, so writing through it does not compile.
It is still a dense2D<Value, Parameters>, so every operation that takes const dense2D<V, P>& accepts it. Copying it gives another view of the same buffer; it cannot be assigned to or resized.
|
staticconstexpr |