9 template <
unsigned Dim>
10 template <
class... Args>
13 static_assert(
Dim ==
sizeof...(args),
"Wrong number of arguments.");
16 template <
unsigned Dim>
19 for (
auto& index : indices) {
25 template <
unsigned Dim>
27 for (
unsigned int d = 0; d <
Dim; ++d) {
28 indices_m[d] =
Index(sizes[d]);
32 template <
unsigned Dim>
37 template <
unsigned Dim>
42 template <
unsigned Dim>
44 unsigned s = indices_m[0].length();
45 for (
unsigned int d = 1; d <
Dim; ++d) {
46 s *= indices_m[d].length();
51 template <
unsigned Dim>
54 for (
unsigned d = 0; d <
Dim; ++d) {
55 r = r || indices_m[d].empty();
60 template <
unsigned Dim>
63 for (
unsigned d = 0; d <
Dim; ++d) {
64 out << idx[d] << ((d ==
Dim - 1) ?
'}' :
',');
69 template <
unsigned Dim>
72 for (
unsigned d = 0; d <
Dim; ++d) {
78 template <
unsigned Dim>
81 for (
unsigned d = 0; d <
Dim; ++d) {
82 r[d] = indices_m[d].
grow(ncells);
87 template <
unsigned Dim>
90 r[dim] = indices_m[dim].
grow(ncells);
94 template <
unsigned Dim>
97 for (
unsigned int d = 0; (d <
Dim) && touch; ++d) {
98 touch = touch && indices_m[d].touches(a.
indices_m[d]);
103 template <
unsigned Dim>
106 for (
unsigned int d = 0; (d <
Dim) && cont; ++d) {
107 cont = cont && indices_m[d].contains(a.
indices_m[d]);
112 template <
unsigned Dim>
121 return indices_m[d].
split(l[d], r[d], i);
124 template <
unsigned Dim>
133 return indices_m[d].
split(l[d], r[d], a);
136 template <
unsigned Dim>
145 return indices_m[d].
split(l[d], r[d]);
148 template <
unsigned Dim>
150 unsigned int max_dim = 0;
151 unsigned int max_length = 0;
152 for (
unsigned int d = 0; d <
Dim; ++d) {
153 if (indices_m[d].length() > max_length) {
155 max_length = indices_m[d].length();
158 return split(l, r, max_dim);
161 template <
unsigned Dim>
163 auto construct = [&]<
size_t... Idx>(
const std::index_sequence<Idx...>&) {
166 return construct(std::make_index_sequence<Dim>{});
169 template <
unsigned Dim>
171 auto construct = [&]<
size_t... Idx>(
const std::index_sequence<Idx...>&) {
174 return construct(std::make_index_sequence<Dim>{});
177 template <
unsigned Dim>
179 auto construct = [&]<
size_t... Idx>(
const std::index_sequence<Idx...>&) {
182 return construct(std::make_index_sequence<Dim>{});
185 template <
unsigned Dim>
190 template <
unsigned Dim>
192 return indices_m +
Dim;
195 template <
unsigned Dim>
201 template <
unsigned Dim>
204 return indices_m +
Dim;
207 template <
unsigned Dim>
209 for (
unsigned d = 0; d <
Dim; d++) {
210 if (nd1[d] != nd2[d]) {
217 template <
unsigned Dim>
219 return !(nd1 == nd2);
Implementations for FFT constructor/destructor and transforms.
bool operator!=(const NDIndex< Dim > &nd1, const NDIndex< Dim > &nd2)
bool operator==(const NDIndex< Dim > &nd1, const NDIndex< Dim > &nd2)
std::ostream & operator<<(std::ostream &os, const BConds< Field, Dim > &bc)
KOKKOS_INLINE_FUNCTION constexpr iterator begin()
KOKKOS_INLINE_FUNCTION bool touches(const NDIndex< Dim > &) const
KOKKOS_INLINE_FUNCTION bool empty() const noexcept
KOKKOS_INLINE_FUNCTION Vector< int, Dim > last() const
KOKKOS_INLINE_FUNCTION unsigned size() const noexcept
KOKKOS_INLINE_FUNCTION Vector< int, Dim > first() const
KOKKOS_FUNCTION NDIndex()
KOKKOS_INLINE_FUNCTION const ippl::Index & operator[](unsigned d) const noexcept
KOKKOS_INLINE_FUNCTION bool split(NDIndex< Dim > &l, NDIndex< Dim > &r, unsigned d, int i) const
KOKKOS_INLINE_FUNCTION NDIndex< Dim > intersect(const NDIndex< Dim > &) const
Index indices_m[Dim]
Array of indices.
KOKKOS_INLINE_FUNCTION bool contains(const NDIndex< Dim > &a) const
KOKKOS_INLINE_FUNCTION Vector< size_t, Dim > length() const
KOKKOS_INLINE_FUNCTION constexpr iterator end()
KOKKOS_INLINE_FUNCTION NDIndex< Dim > grow(int ncells) const