8#include <similie/misc/binomial_coefficient.hpp>
9#include <similie/misc/portable_stl.hpp>
11#include "tensor_impl.hpp"
18template <TensorNatIndex... TensorIndex>
29 ddc::DiscreteElement<
TensorIndex...>(ddc::DiscreteElement<TensorIndex>(0)...),
31 ddc::DiscreteVector<TensorIndex>(TensorIndex::size())...));
34 KOKKOS_FUNCTION
static constexpr std::size_t
rank()
36 return (TensorIndex::rank() + ...);
39 KOKKOS_FUNCTION
static constexpr std::size_t
size()
41 return (TensorIndex::size() * ...);
44 KOKKOS_FUNCTION
static constexpr std::size_t
mem_size()
47 ddc::type_seq_element_t<0, ddc::detail::TypeSeq<TensorIndex...>>
::mem_size()
57 KOKKOS_FUNCTION
static constexpr std::size_t
mem_id(
58 std::array<std::size_t,
rank()>
const natural_ids)
60 std::array<std::size_t,
rank()> sorted_ids(natural_ids);
61 misc::detail::sort(sorted_ids.begin(), sorted_ids.end());
63 ddc::type_seq_element_t<0, ddc::detail::TypeSeq<TensorIndex...>>
::mem_size()
66 - ((sorted_ids[ddc::type_seq_rank_v<
69 == TensorIndex::mem_size() - 1
72 TensorIndex::mem_size()
73 - sorted_ids[ddc::type_seq_rank_v<
75 ddc::detail::TypeSeq<TensorIndex...>>]
77 - ddc::type_seq_rank_v<
79 ddc::detail::TypeSeq<TensorIndex...>>
82 - ddc::type_seq_rank_v<
84 ddc::detail::TypeSeq<TensorIndex...>>))
89 KOKKOS_FUNCTION
static constexpr std::size_t
access_id(
90 std::array<std::size_t,
rank()>
const natural_ids)
92 return mem_id(natural_ids);
100 template <
class Tensor,
class Elem,
class Id,
class FunctorType>
102 const FunctorType& access,
106 return access(tensor, elem);
109 KOKKOS_FUNCTION
static constexpr std::array<std::size_t,
rank()>
113 if constexpr (
rank() == 0) {
114 return std::array<std::size_t,
rank()> {};
116 std::array<std::size_t,
rank()> ids;
119 std::size_t r =
rank();
120 for (std::size_t i = 0; i <
rank(); ++i) {
122 for (std::size_t j = 0; j < d; ++j) {
123 const std::size_t subtriangle_size
125 if (triangle_size - subtriangle_size >
mem_id) {
126 ids[i] = ddc::type_seq_element_t<0, ddc::detail::TypeSeq<
TensorIndex...>>
::
constexpr std::size_t binomial_coefficient(std::size_t n, std::size_t k) noexcept
Tensor(ddc::Chunk< ElementType, SupportType, Allocator >) -> Tensor< ElementType, SupportType, Kokkos::layout_right, typename Allocator::memory_space >
The top-level namespace of SimiLie.
static constexpr bool is_explicitely_stored_tensor
ddc::DiscreteDomain< TensorIndex... > subindices_domain_t
static KOKKOS_FUNCTION constexpr std::size_t access_id(std::array< std::size_t, rank()> const natural_ids)
static KOKKOS_FUNCTION constexpr std::size_t access_id_to_mem_id(std::size_t access_id)
static KOKKOS_FUNCTION constexpr subindices_domain_t subindices_domain()
static KOKKOS_FUNCTION constexpr std::array< std::size_t, rank()> mem_id_to_canonical_natural_ids(std::size_t mem_id)
static KOKKOS_FUNCTION constexpr std::size_t access_size()
static KOKKOS_FUNCTION constexpr Tensor::element_type process_access(const FunctorType &access, Tensor tensor, Elem elem)
static constexpr bool is_tensor_index
static KOKKOS_FUNCTION constexpr std::size_t size()
static KOKKOS_FUNCTION constexpr std::size_t mem_size()
static KOKKOS_FUNCTION constexpr std::size_t rank()
static KOKKOS_FUNCTION constexpr std::size_t mem_id(std::array< std::size_t, rank()> const natural_ids)