8#include <similie/csr/csr.hpp>
9#include <similie/misc/stride.hpp>
10#include <similie/young_tableau/young_tableau.hpp>
12#include "tensor_impl.hpp"
19template <
class YoungTableau, TensorNatIndex... TensorIndex>
32 ddc::DiscreteElement<
TensorIndex...>(ddc::DiscreteElement<TensorIndex>(0)...),
34 ddc::DiscreteVector<TensorIndex>(TensorIndex::size())...));
37 KOKKOS_FUNCTION
static constexpr std::size_t
rank()
39 return (TensorIndex::rank() + ...);
42 KOKKOS_FUNCTION
static constexpr std::size_t
size()
44 return (TensorIndex::size() * ...);
47 KOKKOS_FUNCTION
static constexpr std::size_t
mem_size()
49 return YoungTableau::irrep_dim();
57 KOKKOS_FUNCTION
static constexpr std::pair<std::vector<double>, std::vector<std::size_t>>
60 std::pair<std::vector<double>, std::vector<std::size_t>> result {};
61 constexpr csr::Csr v = young_tableau::template v<
64 ddc::DiscreteElement<
TensorIndex...>(ddc::DiscreteElement<TensorIndex>(0)...),
66 ddc::DiscreteVector<TensorIndex>(TensorIndex::size())...)));
67 for (std::size_t j = 0; j < v.
values().
size(); ++j) {
68 if (((v.
idx()[ddc::type_seq_rank_v<
TensorIndex, ddc::detail::TypeSeq<TensorIndex...>>]
70 == TensorIndex::access_id(natural_ids))
72 std::get<0>(result).push_back(v.
values()[j]);
77 std::get<1>(result).push_back(k);
83 KOKKOS_FUNCTION
static constexpr std::size_t
access_id(
84 std::array<std::size_t,
sizeof...(
TensorIndex)>
const natural_ids)
86 return ((misc::detail::stride<TensorIndex, TensorIndex...>()
88 [ddc::type_seq_rank_v<
TensorIndex, ddc::detail::TypeSeq<TensorIndex...>>])
92 KOKKOS_FUNCTION
static constexpr std::pair<std::vector<double>, std::vector<std::size_t>>
95 std::pair<std::vector<double>, std::vector<std::size_t>> result {};
96 constexpr csr::Csr v = young_tableau::template v<
99 ddc::DiscreteElement<
TensorIndex...>(ddc::DiscreteElement<TensorIndex>(0)...),
101 ddc::DiscreteVector<TensorIndex>(TensorIndex::size())...)));
102 for (std::size_t j = 0; j < v.
values().
size(); ++j) {
103 if (((v.
idx()[ddc::type_seq_rank_v<
TensorIndex, ddc::detail::TypeSeq<TensorIndex...>>]
105 == ((
access_id % misc::detail::next_stride<TensorIndex, TensorIndex...>())
106 / misc::detail::stride<TensorIndex, TensorIndex...>()))
108 std::get<0>(result).push_back(v.
values()[j]);
113 std::get<1>(result).push_back(k);
119 template <
class Tensor,
class Elem,
class Id,
class FunctorType>
121 const FunctorType& access,
125 return access(tensor, elem);
130template <
class YoungTableauIndex,
class... Id>
133 ddc::DiscreteDomain<YoungTableauIndex>,
134 Kokkos::layout_right,
135 Kokkos::DefaultHostExecutionSpace::memory_space>
139 ddc::DiscreteDomain<YoungTableauIndex>,
140 Kokkos::layout_right,
141 Kokkos::DefaultHostExecutionSpace::memory_space> compressed,
144 ddc::DiscreteDomain<Id...>,
145 Kokkos::layout_right,
146 Kokkos::DefaultHostExecutionSpace::memory_space> tensor)
148 typename YoungTableauIndex::young_tableau young_tableau;
149 csr::Csr u = young_tableau.template u<YoungTableauIndex, Id...>(tensor.domain());
154template <
class YoungTableauIndex,
class... Id>
157 ddc::DiscreteDomain<Id...>,
158 Kokkos::layout_right,
159 Kokkos::DefaultHostExecutionSpace::memory_space>
163 ddc::DiscreteDomain<Id...>,
164 Kokkos::layout_right,
165 Kokkos::DefaultHostExecutionSpace::memory_space> uncompressed,
168 ddc::DiscreteDomain<YoungTableauIndex>,
169 Kokkos::layout_right,
170 Kokkos::DefaultHostExecutionSpace::memory_space> tensor)
172 typename YoungTableauIndex::young_tableau young_tableau;
173 csr::Csr v = young_tableau.template v<YoungTableauIndex, Id...>(uncompressed.domain());
constexpr std::array< std::array< std::size_t, N >, sizeof...(TailTensorIndex)> idx() const
constexpr std::array< double, N > values() const
constexpr std::array< std::size_t, HeadTensorIndex::mem_size()+1 > coalesc_idx() const
sil::tensor::Tensor< double, ddc::DiscreteDomain< TailTensorIndex... >, Kokkos::layout_right, Kokkos::DefaultHostExecutionSpace::memory_space > tensor_prod(sil::tensor::Tensor< double, ddc::DiscreteDomain< TailTensorIndex... >, Kokkos::layout_right, Kokkos::DefaultHostExecutionSpace::memory_space > prod, sil::tensor::Tensor< double, ddc::DiscreteDomain< HeadTensorIndex >, Kokkos::layout_right, Kokkos::DefaultHostExecutionSpace::memory_space > dense, Csr< N, HeadTensorIndex, TailTensorIndex... > csr)
Tensor(ddc::Chunk< ElementType, SupportType, Allocator >) -> Tensor< ElementType, SupportType, Kokkos::layout_right, typename Allocator::memory_space >
tensor::Tensor< double, ddc::DiscreteDomain< YoungTableauIndex >, Kokkos::layout_right, Kokkos::DefaultHostExecutionSpace::memory_space > compress(tensor::Tensor< double, ddc::DiscreteDomain< YoungTableauIndex >, Kokkos::layout_right, Kokkos::DefaultHostExecutionSpace::memory_space > compressed, tensor::Tensor< double, ddc::DiscreteDomain< Id... >, Kokkos::layout_right, Kokkos::DefaultHostExecutionSpace::memory_space > tensor)
tensor::Tensor< double, ddc::DiscreteDomain< Id... >, Kokkos::layout_right, Kokkos::DefaultHostExecutionSpace::memory_space > uncompress(tensor::Tensor< double, ddc::DiscreteDomain< Id... >, Kokkos::layout_right, Kokkos::DefaultHostExecutionSpace::memory_space > uncompressed, tensor::Tensor< double, ddc::DiscreteDomain< YoungTableauIndex >, Kokkos::layout_right, Kokkos::DefaultHostExecutionSpace::memory_space > tensor)
The top-level namespace of SimiLie.
static KOKKOS_FUNCTION constexpr std::size_t rank()
static KOKKOS_FUNCTION constexpr subindices_domain_t subindices_domain()
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 KOKKOS_FUNCTION constexpr std::size_t mem_size()
static KOKKOS_FUNCTION constexpr std::size_t access_id(std::array< std::size_t, sizeof...(TensorIndex)> const natural_ids)
static KOKKOS_FUNCTION constexpr std::pair< std::vector< double >, std::vector< std::size_t > > mem_lin_comb(std::array< std::size_t, sizeof...(TensorIndex)> const natural_ids)
static KOKKOS_FUNCTION constexpr std::pair< std::vector< double >, std::vector< std::size_t > > access_id_to_mem_lin_comb(std::size_t access_id)
static constexpr bool is_explicitely_stored_tensor
ddc::DiscreteDomain< TensorIndex... > subindices_domain_t
static constexpr bool is_tensor_index
YoungTableau young_tableau
static KOKKOS_FUNCTION constexpr std::size_t size()