3#ifndef TETL_LINALG_LAYOUT_TRANSPOSE_HPP
4#define TETL_LINALG_LAYOUT_TRANSPOSE_HPP
13template <
typename Extents>
14using transpose_extents_t =
extents<
typename Extents::index_type, Extents::static_extent(1), Extents::static_extent(0)>;
16template <
typename Extents>
17 requires(Extents::rank() == 2)
18[[nodiscard]]
constexpr auto transpose_extents(Extents
const& e) -> transpose_extents_t<Extents>
20 constexpr auto isDynamicE0 = Extents::static_extent(0) ==
dynamic_extent;
21 constexpr auto isDynamicE1 = Extents::static_extent(1) ==
dynamic_extent;
23 if constexpr (isDynamicE0) {
24 if constexpr (isDynamicE1) {
25 return transpose_extents_t<Extents>{
e.extent(1),
e.extent(0)};
27 return transpose_extents_t<Extents>{
e.extent(0)};
30 if constexpr (isDynamicE1) {
31 return transpose_extents_t<Extents>{
e.extent(1)};
33 return transpose_extents_t<Extents>{};
41template <
typename Layout>
43 template <
typename Extents>
44 requires(Extents::rank() == 2)
48 nested_mapping_t _nestedMapping;
55 constexpr explicit mapping(nested_mapping_t
const& map)
62 return detail::transpose_extents(_nestedMapping.extents());
67 return _nestedMapping.required_span_size();
70 template <
typename IndexType,
typename... Indices>
71 [[nodiscard]]
constexpr auto operator()(Indices... rest, IndexType i, IndexType j)
const
72 noexcept(
noexcept(_nestedMapping(rest..., j, i))) ->
typename Extents::size_type
74 return _nestedMapping(rest..., j, i);
77 [[nodiscard]]
constexpr auto nested_mapping() const -> nested_mapping_t {
return _nestedMapping; }
79 [[nodiscard]]
static constexpr auto is_always_unique() ->
bool {
return nested_mapping_t::is_always_unique(); }
83 return nested_mapping_t::is_always_contiguous();
88 return nested_mapping_t::is_always_strided();
91 [[nodiscard]]
constexpr auto is_unique() const noexcept(noexcept(_nestedMapping.
is_unique())) ->
bool
93 return _nestedMapping.is_unique();
98 return _nestedMapping.is_contiguous();
103 return _nestedMapping.is_strided();
106 [[nodiscard]]
constexpr auto stride(
size_t r)
const noexcept(
noexcept(_nestedMapping.stride(r))) ->
size_type
109 if (r == Extents::rank() - 1) {
110 return _nestedMapping.stride(r - 2);
112 if (r == Extents::rank() - 2) {
113 return _nestedMapping.stride(r - 1);
115 return _nestedMapping.stride(r);
118 template <
typename OtherExtents>
119 requires(Extents::rank() == OtherExtents::rank())
122 return lhs._nestedMapping == rhs._nestedMapping;
constexpr double e
Definition constants.hpp:29
constexpr auto dynamic_extent
etl::dynamic_extent is a constant of type etl::size_t that is used to differentiate etl::span of stat...
Definition dynamic_extent.hpp:14
Definition accessor_conjugate.hpp:12
extents(Integrals...) -> extents< etl::size_t, etl::size_t((Integrals(), etl::dynamic_extent))... >
static constexpr auto is_always_unique() -> bool
Definition layout_transpose.hpp:79
constexpr auto nested_mapping() const -> nested_mapping_t
Definition layout_transpose.hpp:77
static constexpr auto is_always_contiguous() -> bool
Definition layout_transpose.hpp:81
Extents extents_type
Definition layout_transpose.hpp:51
constexpr auto is_contiguous() const noexcept(noexcept(_nestedMapping.is_contiguous())) -> bool
Definition layout_transpose.hpp:96
constexpr mapping(nested_mapping_t const &map)
Definition layout_transpose.hpp:55
constexpr auto is_unique() const noexcept(noexcept(_nestedMapping.is_unique())) -> bool
Definition layout_transpose.hpp:91
constexpr auto required_span_size() const noexcept(noexcept(_nestedMapping.required_span_size()))
Definition layout_transpose.hpp:65
typename extents_type::size_type size_type
Definition layout_transpose.hpp:52
constexpr auto operator()(Indices... rest, IndexType i, IndexType j) const noexcept(noexcept(_nestedMapping(rest..., j, i))) -> typename Extents::size_type
Definition layout_transpose.hpp:71
layout_transpose layout_type
Definition layout_transpose.hpp:53
constexpr auto is_strided() const noexcept(noexcept(_nestedMapping.is_strided())) -> bool
Definition layout_transpose.hpp:101
constexpr auto extents() const noexcept(noexcept(_nestedMapping.extents())) -> extents_type
Definition layout_transpose.hpp:60
constexpr auto stride(size_t r) const noexcept(noexcept(_nestedMapping.stride(r))) -> size_type requires(is_always_strided())
Definition layout_transpose.hpp:106
static constexpr auto is_always_strided() -> bool
Definition layout_transpose.hpp:86
Definition layout_transpose.hpp:42