We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mdarray
Creating a simple 2D array with mdspan requires multiple steps because mdspan is non-owning.
mdspan
// Create a mapping: layout_left map(extents(N,M)); // Create an allocation vector<int> data(map.required_span_size()); // Create mdspan: mdspan a(data.data(), map);
mdarray is a multidimensional array with value-semantics and makes the above simpler
// default layout mdarray a(N,M); // other layout mdarray b(layout_left(extents(N,M)));
mdarray has the
element_type
extents
The accessor policy is replaced by a container type.
template<class ElementType, class Extents, class Layout, class Accessor> class mdspan { public: ... template<class ... Indices> reference operator [] (Indices ... idx) const { return acc_.access(ptr_, map_(idx...)); } private: typename Accessor::data_handle_type ptr_; Layout::mapping<Extents> map_; Accessor acc_; }; template<class ElementType, class Extents, class Layout, class Container> class mdarray { public: ... template<class ... Indices> reference operator [] (Indices ... idx) { return ctr_[map_(idx...)]); } private: Layout::mapping<Extents> map_; Container ctr_; };
The following table gives an overview of the three approaches. In this table we use these shorthands:
mda_t
c_t
container_type
e
m
me
c
a
v
mda_t::value_type
mda
mds
mda_t::to_mdspan
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Super Brief
mdarray
introductionWhy we want
mdarray
Creating a simple 2D array with
mdspan
requires multiple steps becausemdspan
is non-owning.mdarray
is a multidimensional array with value-semantics and makes the above simplerWhat aspects of
mdspan
doesmdarray
havemdarray
has theelement_type
,extents
andmdspan
The accessor policy is replaced by a container type.
Design issues left at last time
Constructor
Overview Table
The following table gives an overview of the three approaches.
In this table we use these shorthands:
mda_t
: a specialization ofmdarray
c_t
: thecontainer_type
ofmda_t
e
: anextents
objectm
: a layout mapping objectme
: aextents
object or a layout mapping objectc
: an instance ofc_t
a
: an allocator objectv
: a value (something convertible tomda_t::value_type
mda
: anmdarray
object, not necessarily the same type asmda_t
mds
: anmdspan
obejct, not necessarily the same as returned bymda_t::to_mdspan
The text was updated successfully, but these errors were encountered: