8#include <similie/misc/binomial_coefficient.hpp>
9#include <similie/misc/portable_stl.hpp>
10#include <similie/tensor/tensor_impl.hpp>
17template <TensorNatIndex... TensorIndex>
20 static_assert(((TensorIndex::rank() == 1) && ...));
30 ddc::DiscreteElement<
TensorIndex...>(ddc::DiscreteElement<TensorIndex>(0)...),
32 ddc::DiscreteVector<TensorIndex>(TensorIndex::size())...));
35 static constexpr std::size_t
rank()
37 return (0 + ... + TensorIndex::rank());
40 static constexpr std::size_t
size()
42 return (1 * ... * TensorIndex::size());
48 std::array<std::size_t,
sizeof...(TensorIndex)>
const sizes {TensorIndex::size()...};
49 for (std::size_t i = 1; i < sizes.size(); ++i) {
50 if (sizes[i] != sizes[0]) {
56 if constexpr (
rank() == 0) {
60 ddc::type_seq_element_t<0, ddc::TypeSeq<TensorIndex...>>
::mem_size() +
rank()
71 KOKKOS_FUNCTION
static constexpr std::size_t
mem_id(
72 std::array<std::size_t,
rank()>
const& natural_ids)
74 if constexpr (
rank() == 0) {
77 std::array<std::size_t,
rank()> sorted_ids(natural_ids);
78 misc::detail::sort(sorted_ids.begin(), sorted_ids.end());
80 ddc::type_seq_element_t<0, ddc::TypeSeq<TensorIndex...>>
::mem_size()
84 == TensorIndex::mem_size() - 1
87 TensorIndex::mem_size()
88 - sorted_ids[ddc::type_seq_rank_v<
90 ddc::TypeSeq<TensorIndex...>>]
92 - ddc::type_seq_rank_v<
94 ddc::TypeSeq<TensorIndex...>>
97 - ddc::type_seq_rank_v<
99 ddc::TypeSeq<TensorIndex...>>))
106 std::array<std::size_t,
rank()>
const& natural_ids)
108 return mem_id(natural_ids);
116 template <
class Tensor,
class Elem,
class Id,
class FunctorType>
118 const FunctorType& access,
122 return access(tensor, elem);
125 KOKKOS_FUNCTION
static constexpr std::array<std::size_t,
rank()>
129 if constexpr (
rank() == 0) {
130 return std::array<std::size_t,
rank()> {};
132 std::array<std::size_t,
rank()> ids;
134 std::size_t r =
rank();
135 for (std::size_t i = 0; i <
rank(); ++i) {
137 for (std::size_t j = 0; j < d; ++j) {
138 const std::size_t subtriangle_size
140 if (triangle_size - subtriangle_size >
mem_id) {
141 ids[i] = ddc::type_seq_element_t<0, ddc::TypeSeq<
TensorIndex...>>
::
158 TensorIndexConcept<TensorSymmetricIndex<TensorNaturalIndex<detail::DimensionConcept>>>);
KOKKOS_FUNCTION constexpr std::size_t binomial_coefficient(std::size_t n, std::size_t k) noexcept
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_to_mem_id(std::size_t access_id)
static KOKKOS_FUNCTION constexpr subindices_domain_t subindices_domain()
static constexpr std::size_t rank()
static constexpr std::size_t access_size()
static KOKKOS_FUNCTION constexpr std::array< std::size_t, rank()> mem_id_to_canonical_natural_ids(std::size_t mem_id)
static constexpr bool is_tensor_index
static KOKKOS_FUNCTION constexpr std::size_t access_id(std::array< std::size_t, rank()> const &natural_ids)
static KOKKOS_FUNCTION constexpr Tensor::element_type process_access(const FunctorType &access, Tensor const &tensor, Elem const &elem)
static constexpr std::size_t mem_size()
static constexpr std::size_t size()
static KOKKOS_FUNCTION constexpr std::size_t mem_id(std::array< std::size_t, rank()> const &natural_ids)