|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Non-owning view of a contiguous buffer as a multidimensional grid. More...
#include <ah-mdspan.H>
Public Types | |
| using | extents_type = Extents |
| using | layout_type = LayoutPolicy |
| using | accessor_type = AccessorPolicy |
| using | mapping_type = typename layout_type::template mapping< extents_type > |
| using | element_type = T |
| using | value_type = std::remove_cv_t< T > |
| using | index_type = typename extents_type::index_type |
| using | rank_type = typename extents_type::rank_type |
| using | data_handle_type = typename accessor_type::data_handle_type |
| using | reference = typename accessor_type::reference |
Public Member Functions | |
| constexpr | mdspan () noexcept=default |
Empty view: data_handle() == nullptr, every extent is 0. | |
| constexpr | mdspan (const mdspan &) noexcept=default |
| constexpr | mdspan (mdspan &&) noexcept=default |
| constexpr mdspan & | operator= (const mdspan &) noexcept=default |
| constexpr mdspan & | operator= (mdspan &&) noexcept=default |
| template<class OtherT , class OtherAccessor > requires (not std::is_same_v<OtherT, T> and std::is_convertible_v<OtherT (*)[], T (*)[]>) | |
| constexpr | mdspan (const mdspan< OtherT, Extents, LayoutPolicy, OtherAccessor > &other) noexcept |
Converting constructor: view a non-const element type as a const-qualified one (mdspan<T,...> -> mdspan<const T,...>), mirroring how T* converts to const T*. | |
| constexpr | mdspan (data_handle_type p, const extents_type &e) noexcept |
View p through the shape e. | |
| constexpr | mdspan (data_handle_type p, const mapping_type &m) noexcept |
View p through an already-built mapping. | |
| constexpr | mdspan (data_handle_type p, const mapping_type &m, const accessor_type &a) noexcept |
View p through mapping m, reading via accessor a. | |
| template<class... IndexTypes> requires (sizeof...(IndexTypes) >= 1 and (std::is_convertible_v<IndexTypes, index_type> and ...)) | |
| constexpr | mdspan (data_handle_type p, IndexTypes... exts) noexcept |
View p as a grid with the given per-axis sizes. | |
| template<class OtherIndexType > requires std::is_convertible_v<const OtherIndexType &, index_type> | |
| constexpr | mdspan (data_handle_type p, const std::array< OtherIndexType, extents_type::rank_dynamic()> &dyn) noexcept |
View p as a grid whose dynamic axes are packed in an array. | |
| constexpr index_type | extent (rank_type r) const noexcept |
Run-time size of axis r. | |
| constexpr const extents_type & | extents () const noexcept |
| The shape of this view. | |
| constexpr const mapping_type & | mapping () const noexcept |
| The index-to-offset mapping (layout + shape) of this view. | |
| constexpr const accessor_type & | accessor () const noexcept |
| The element-access policy of this view. | |
| constexpr data_handle_type | data_handle () const noexcept |
Underlying pointer to the first element (nullptr for a default-built view). | |
| constexpr data_handle_type | data () const noexcept |
| constexpr index_type | size () const noexcept |
Total element count: the product of every extent(r). | |
| constexpr bool | empty () const noexcept |
| Checks if the view has no elements. | |
| template<class... Indices> requires (sizeof...(Indices) == extents_type::rank()) | |
| constexpr reference | operator() (Indices... idxs) const |
| Unchecked element access. | |
| template<class... Indices> requires (sizeof...(Indices) == extents_type::rank()) | |
| constexpr reference | at (Indices... idxs) const |
| Bounds-checked element access. | |
Static Public Member Functions | |
| static constexpr rank_type | rank () noexcept |
| Number of axes (compile-time constant). | |
Private Attributes | |
| data_handle_type | ptr_ {} |
| mapping_type | map_ {} |
| accessor_type | acc_ {} |
Non-owning view of a contiguous buffer as a multidimensional grid.
See the file-level documentation for the overview, the rationale for operator() over multi-argument operator[], and the bounds-checking policy (operator() is unchecked, .at() is checked).
| T | element type (may be const-qualified for a read-only view). |
| Extents | an Aleph::extents<IndexType, ...> (typically Aleph::dextents<IndexType, Rank>). |
| LayoutPolicy | Aleph::layout_right (default, row-major) or Aleph::layout_left (column-major). |
| AccessorPolicy | Aleph::default_accessor<T> (default). |
Definition at line 575 of file ah-mdspan.H.
| using Aleph::mdspan< T, Extents, LayoutPolicy, AccessorPolicy >::accessor_type = AccessorPolicy |
Definition at line 580 of file ah-mdspan.H.
| using Aleph::mdspan< T, Extents, LayoutPolicy, AccessorPolicy >::data_handle_type = typename accessor_type::data_handle_type |
Definition at line 586 of file ah-mdspan.H.
| using Aleph::mdspan< T, Extents, LayoutPolicy, AccessorPolicy >::element_type = T |
Definition at line 582 of file ah-mdspan.H.
| using Aleph::mdspan< T, Extents, LayoutPolicy, AccessorPolicy >::extents_type = Extents |
Definition at line 578 of file ah-mdspan.H.
| using Aleph::mdspan< T, Extents, LayoutPolicy, AccessorPolicy >::index_type = typename extents_type::index_type |
Definition at line 584 of file ah-mdspan.H.
| using Aleph::mdspan< T, Extents, LayoutPolicy, AccessorPolicy >::layout_type = LayoutPolicy |
Definition at line 579 of file ah-mdspan.H.
| using Aleph::mdspan< T, Extents, LayoutPolicy, AccessorPolicy >::mapping_type = typename layout_type::template mapping<extents_type> |
Definition at line 581 of file ah-mdspan.H.
| using Aleph::mdspan< T, Extents, LayoutPolicy, AccessorPolicy >::rank_type = typename extents_type::rank_type |
Definition at line 585 of file ah-mdspan.H.
| using Aleph::mdspan< T, Extents, LayoutPolicy, AccessorPolicy >::reference = typename accessor_type::reference |
Definition at line 587 of file ah-mdspan.H.
| using Aleph::mdspan< T, Extents, LayoutPolicy, AccessorPolicy >::value_type = std::remove_cv_t<T> |
Definition at line 583 of file ah-mdspan.H.
|
constexprdefaultnoexcept |
Empty view: data_handle() == nullptr, every extent is 0.
|
constexprdefaultnoexcept |
|
constexprdefaultnoexcept |
|
inlineconstexprnoexcept |
Converting constructor: view a non-const element type as a const-qualified one (mdspan<T,...> -> mdspan<const T,...>), mirroring how T* converts to const T*.
Only participates when OtherT actually converts to T (so this does not become a silent implicit cast between unrelated element types) and the shapes/layouts/accessors match.
Definition at line 613 of file ah-mdspan.H.
|
inlineconstexprnoexcept |
View p through the shape e.
| p | pointer to the first element of the buffer to view. |
| e | extents object defining the shape. |
Definition at line 621 of file ah-mdspan.H.
|
inlineconstexprnoexcept |
View p through an already-built mapping.
| p | pointer to the first element of the buffer to view. |
| m | mapping object defining the layout. |
Definition at line 629 of file ah-mdspan.H.
|
inlineconstexprnoexcept |
View p through mapping m, reading via accessor a.
| p | pointer to the first element of the buffer to view. |
| m | mapping object defining the layout. |
| a | accessor object defining element access. |
Definition at line 638 of file ah-mdspan.H.
|
inlineexplicitconstexprnoexcept |
View p as a grid with the given per-axis sizes.
Convenience constructor equivalent to mdspan(p, extents_type(exts...)).
| p | pointer to the first element of the buffer to view. |
| exts | one size per dynamic axis of Extents, in rank order. |
Definition at line 651 of file ah-mdspan.H.
|
inlineconstexprnoexcept |
View p as a grid whose dynamic axes are packed in an array.
Convenience constructor equivalent to mdspan(p, extents_type(dyn)). Matches CA::Dense_Cell_Storage::extents_type (a std::array of all per-axis sizes for a fully-dynamic dextents shape), so a lattice's own extents can be forwarded directly without unpacking them.
Definition at line 664 of file ah-mdspan.H.
|
inlineconstexprnoexcept |
The element-access policy of this view.
Definition at line 690 of file ah-mdspan.H.
References Aleph::mdspan< T, Extents, LayoutPolicy, AccessorPolicy >::acc_.
|
inlineconstexpr |
Bounds-checked element access.
| idxs | one index per axis, in rank order. |
| std::out_of_range | if any idxs[r] is outside [0, extent(r)). |
Definition at line 741 of file ah-mdspan.H.
References Aleph::mdspan< T, Extents, LayoutPolicy, AccessorPolicy >::acc_, ah_out_of_range_error_if, Aleph::blossom_maximum_cardinality_matching(), Aleph::mdspan< T, Extents, LayoutPolicy, AccessorPolicy >::extent(), Aleph::mdspan< T, Extents, LayoutPolicy, AccessorPolicy >::map_, Aleph::mdspan< T, Extents, LayoutPolicy, AccessorPolicy >::ptr_, r, and Aleph::mdspan< T, Extents, LayoutPolicy, AccessorPolicy >::rank().
|
inlineconstexprnoexcept |
Definition at line 696 of file ah-mdspan.H.
References Aleph::mdspan< T, Extents, LayoutPolicy, AccessorPolicy >::ptr_.
|
inlineconstexprnoexcept |
Underlying pointer to the first element (nullptr for a default-built view).
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 693 of file ah-mdspan.H.
References Aleph::mdspan< T, Extents, LayoutPolicy, AccessorPolicy >::ptr_.
|
inlineconstexprnoexcept |
Checks if the view has no elements.
true if any axis has extent 0, false otherwise. Definition at line 710 of file ah-mdspan.H.
References Aleph::mdspan< T, Extents, LayoutPolicy, AccessorPolicy >::extent(), r, and Aleph::mdspan< T, Extents, LayoutPolicy, AccessorPolicy >::rank().
|
inlineconstexprnoexcept |
Run-time size of axis r.
| r | The axis to query. |
Definition at line 678 of file ah-mdspan.H.
References Aleph::mdspan< T, Extents, LayoutPolicy, AccessorPolicy >::map_, and r.
Referenced by Aleph::mdspan< T, Extents, LayoutPolicy, AccessorPolicy >::at(), Aleph::mdspan< T, Extents, LayoutPolicy, AccessorPolicy >::empty(), and Aleph::mdspan< T, Extents, LayoutPolicy, AccessorPolicy >::size().
|
inlineconstexprnoexcept |
The shape of this view.
Definition at line 684 of file ah-mdspan.H.
References Aleph::mdspan< T, Extents, LayoutPolicy, AccessorPolicy >::map_.
|
inlineconstexprnoexcept |
The index-to-offset mapping (layout + shape) of this view.
Definition at line 687 of file ah-mdspan.H.
References Aleph::mdspan< T, Extents, LayoutPolicy, AccessorPolicy >::map_.
|
inlineconstexpr |
Unchecked element access.
| idxs | one index per axis, in rank order. |
idxs[r] is outside [0, extent(r)) — matches std::mdspan::operator[]'s contract exactly. Use at() for a bounds-checked variant. Definition at line 728 of file ah-mdspan.H.
References Aleph::mdspan< T, Extents, LayoutPolicy, AccessorPolicy >::acc_, Aleph::blossom_maximum_cardinality_matching(), Aleph::mdspan< T, Extents, LayoutPolicy, AccessorPolicy >::map_, and Aleph::mdspan< T, Extents, LayoutPolicy, AccessorPolicy >::ptr_.
|
constexprdefaultnoexcept |
|
constexprdefaultnoexcept |
|
inlinestaticconstexprnoexcept |
Number of axes (compile-time constant).
Definition at line 672 of file ah-mdspan.H.
Referenced by Aleph::mdspan< T, Extents, LayoutPolicy, AccessorPolicy >::at(), Aleph::mdspan< T, Extents, LayoutPolicy, AccessorPolicy >::empty(), and Aleph::mdspan< T, Extents, LayoutPolicy, AccessorPolicy >::size().
|
inlineconstexprnoexcept |
Total element count: the product of every extent(r).
Definition at line 699 of file ah-mdspan.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::mdspan< T, Extents, LayoutPolicy, AccessorPolicy >::extent(), r, and Aleph::mdspan< T, Extents, LayoutPolicy, AccessorPolicy >::rank().
|
private |
|
private |
Definition at line 591 of file ah-mdspan.H.
Referenced by Aleph::mdspan< T, Extents, LayoutPolicy, AccessorPolicy >::at(), Aleph::mdspan< T, Extents, LayoutPolicy, AccessorPolicy >::extent(), Aleph::mdspan< T, Extents, LayoutPolicy, AccessorPolicy >::extents(), Aleph::mdspan< T, Extents, LayoutPolicy, AccessorPolicy >::mapping(), and Aleph::mdspan< T, Extents, LayoutPolicy, AccessorPolicy >::operator()().
|
private |
Definition at line 590 of file ah-mdspan.H.
Referenced by Aleph::mdspan< T, Extents, LayoutPolicy, AccessorPolicy >::at(), Aleph::mdspan< T, Extents, LayoutPolicy, AccessorPolicy >::data(), Aleph::mdspan< T, Extents, LayoutPolicy, AccessorPolicy >::data_handle(), and Aleph::mdspan< T, Extents, LayoutPolicy, AccessorPolicy >::operator()().