7#include <Kokkos_Core.hpp>
11template <std::
size_t N,
class ElementType,
bool CONTIGUOUS = true>
14template <std::
size_t N,
class ElementType>
15struct ViewNDMaker<N, ElementType, true>
18 = Kokkos::mdspan<ElementType, Kokkos::dextents<std::size_t, N>, Kokkos::layout_right>;
21template <std::
size_t N,
class ElementType>
22struct ViewNDMaker<N, ElementType, false>
25 = Kokkos::mdspan<ElementType, Kokkos::dextents<std::size_t, N>, Kokkos::layout_stride>;
40std::ostream& stream_impl(
42 Kokkos::mdspan<ElementType, Extents, Layout, Accessor>
const& s,
43 std::index_sequence<I0, Is...>)
45 if constexpr (
sizeof...(Is) > 0) {
47 for (std::size_t i0 = 0; i0 < s.extent(I0); ++i0) {
50 Kokkos::submdspan(s, i0, ((
void)Is, Kokkos::full_extent)...),
51 std::make_index_sequence<
sizeof...(Is)>());
56 for (std::size_t i0 = 0; i0 < s.extent(I0) - 1; ++i0) {
59 os << s(s.extent(I0) - 1) <<
']';
86template <std::
size_t N,
class ElementType>
87using SpanND = Kokkos::mdspan<ElementType, Kokkos::dextents<std::size_t, N>>;
89template <std::
size_t N,
class ElementType>
90using ViewND = SpanND<N, ElementType const>;
92template <
class ElementType>
93using Span1D = SpanND<1, ElementType>;
95template <
class ElementType>
96using Span2D = SpanND<2, ElementType>;
98template <
class ElementType>
99using View1D = ViewND<1, ElementType>;
101template <
class ElementType>
102using View2D = ViewND<2, ElementType>;
104template <std::
size_t N>
105using DKokkosView = Kokkos::View<double[N]>;
107template <std::
size_t N>
108using DKokkosView_h = Kokkos::View<double[N], Kokkos::HostSpace>;
110template <
class ElementType, std::
size_t N>
111KOKKOS_FUNCTION Span1D<ElementType> as_span(std::array<ElementType, N>& arr)
noexcept
113 return Span1D<ElementType>(arr.data(), N);
116template <
class ElementType, std::
size_t N>
117KOKKOS_FUNCTION Span1D<const ElementType> as_span(std::array<ElementType, N>
const& arr)
noexcept
119 return Span1D<const ElementType>(arr.data(), N);
122using DSpan1D = Span1D<double>;
124using DSpan2D = Span2D<double>;
126using CDSpan1D = Span1D<double const>;
128using CDSpan2D = Span2D<double const>;
130using DView1D = View1D<double>;
132using DView2D = View2D<double>;
135using Matrix_2x2 = std::array<std::array<double, 2>, 2>;
142template <
class ElementType,
class Extents,
class Layout,
class Accessor>
143std::ostream& operator<<(
145 Kokkos::mdspan<ElementType, Extents, Layout, Accessor>
const& s)
147 return detail::stream_impl(os, s, std::make_index_sequence<Extents::rank()>());