DDC 0.0.0

a discrete domain computation library

discrete_domain.hpp
1// Copyright (C) The DDC development team, see COPYRIGHT.md file
2//
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
7#include <cassert>
8#include <cstddef>
9#include <iterator>
10#include <tuple>
11#include <type_traits>
12
13#include "ddc/detail/type_seq.hpp"
14#include "ddc/discrete_element.hpp"
15#include "ddc/discrete_vector.hpp"
16
17namespace ddc {
18
19template <class DDim>
20struct DiscreteDomainIterator;
21
22template <class... DDims>
23class DiscreteDomain;
24
25template <class T>
26struct is_discrete_domain : std::false_type
27{
28};
29
30template <class... Tags>
31struct is_discrete_domain<DiscreteDomain<Tags...>> : std::true_type
32{
33};
34
35template <class T>
37
38
39namespace detail {
40
41template <class... Tags>
42struct ToTypeSeq<DiscreteDomain<Tags...>>
43{
44 using type = TypeSeq<Tags...>;
45};
46
47} // namespace detail
48
49template <class... DDims>
51{
52 template <class...>
53 friend class DiscreteDomain;
54
55public:
57
58 using mlength_type = DiscreteVector<DDims...>;
59
60private:
61 DiscreteElement<DDims...> m_element_begin;
62
63 DiscreteElement<DDims...> m_element_end;
64
65public:
66 static KOKKOS_FUNCTION constexpr std::size_t rank()
67 {
68 return sizeof...(DDims);
69 }
70
71 KOKKOS_DEFAULTED_FUNCTION DiscreteDomain() = default;
72
74 template <class... DDoms, class = std::enable_if_t<(is_discrete_domain_v<DDoms> && ...)>>
75 explicit KOKKOS_FUNCTION constexpr DiscreteDomain(DDoms const&... domains)
76 : m_element_begin(domains.front()...)
77 , m_element_end((domains.front() + domains.extents())...)
78 {
79 }
80
85 KOKKOS_FUNCTION constexpr DiscreteDomain(
86 discrete_element_type const& element_begin,
87 mlength_type const& size)
88 : m_element_begin(element_begin)
89 , m_element_end(element_begin + size)
90 {
91 }
92
93 KOKKOS_DEFAULTED_FUNCTION DiscreteDomain(DiscreteDomain const& x) = default;
94
95 KOKKOS_DEFAULTED_FUNCTION DiscreteDomain(DiscreteDomain&& x) = default;
96
97 KOKKOS_DEFAULTED_FUNCTION ~DiscreteDomain() = default;
98
99 KOKKOS_DEFAULTED_FUNCTION DiscreteDomain& operator=(DiscreteDomain const& x) = default;
100
101 KOKKOS_DEFAULTED_FUNCTION DiscreteDomain& operator=(DiscreteDomain&& x) = default;
102
103 template <class... ODims>
104 KOKKOS_FUNCTION constexpr bool operator==(DiscreteDomain<ODims...> const& other) const
105 {
106 return m_element_begin == other.m_element_begin && m_element_end == other.m_element_end;
107 }
108
109#if __cplusplus <= 201703L
110 // Shall not be necessary anymore in C++20
111 // `a!=b` shall be translated by the compiler to `!(a==b)`
112 KOKKOS_FUNCTION constexpr bool operator!=(DiscreteDomain const& other) const
113 {
114 return !(*this == other);
115 }
116#endif
117
118 KOKKOS_FUNCTION constexpr std::size_t size() const
119 {
120 return (1ul * ... * (uid<DDims>(m_element_end) - uid<DDims>(m_element_begin)));
121 }
122
123 KOKKOS_FUNCTION constexpr mlength_type extents() const noexcept
124 {
125 return mlength_type((uid<DDims>(m_element_end) - uid<DDims>(m_element_begin))...);
126 }
127
128 template <class QueryDDim>
129 KOKKOS_FUNCTION constexpr DiscreteVector<QueryDDim> extent() const noexcept
130 {
132 uid<QueryDDim>(m_element_end) - uid<QueryDDim>(m_element_begin));
133 }
134
135 KOKKOS_FUNCTION constexpr discrete_element_type front() const noexcept
136 {
137 return m_element_begin;
138 }
139
140 KOKKOS_FUNCTION constexpr discrete_element_type back() const noexcept
141 {
142 return discrete_element_type((uid<DDims>(m_element_end) - 1)...);
143 }
144
145 KOKKOS_FUNCTION constexpr DiscreteDomain take_first(mlength_type n) const
146 {
147 return DiscreteDomain(front(), n);
148 }
149
150 KOKKOS_FUNCTION constexpr DiscreteDomain take_last(mlength_type n) const
151 {
152 return DiscreteDomain(front() + (extents() - n), n);
153 }
154
155 KOKKOS_FUNCTION constexpr DiscreteDomain remove_first(mlength_type n) const
156 {
157 return DiscreteDomain(front() + n, extents() - n);
158 }
159
160 KOKKOS_FUNCTION constexpr DiscreteDomain remove_last(mlength_type n) const
161 {
162 return DiscreteDomain(front(), extents() - n);
163 }
164
165 KOKKOS_FUNCTION constexpr DiscreteDomain remove(mlength_type n1, mlength_type n2) const
166 {
167 return DiscreteDomain(front() + n1, extents() - n1 - n2);
168 }
169
170 template <class... ODDims>
171 KOKKOS_FUNCTION constexpr auto restrict(DiscreteDomain<ODDims...> const& odomain) const
172 {
173 assert(((uid<ODDims>(m_element_begin) <= uid<ODDims>(odomain.m_element_begin)) && ...));
174 assert(((uid<ODDims>(m_element_end) >= uid<ODDims>(odomain.m_element_end)) && ...));
175 const DiscreteVector<DDims...> myextents = extents();
176 const DiscreteVector<ODDims...> oextents = odomain.extents();
177 return DiscreteDomain(
179 (uid_or<DDims>(odomain.m_element_begin, uid<DDims>(m_element_begin)))...),
180 DiscreteVector<DDims...>((get_or<DDims>(oextents, get<DDims>(myextents)))...));
181 }
182
183 KOKKOS_FUNCTION constexpr bool empty() const noexcept
184 {
185 return size() == 0;
186 }
187
188 KOKKOS_FUNCTION constexpr explicit operator bool()
189 {
190 return !empty();
191 }
192
193 template <
194 std::size_t N = sizeof...(DDims),
195 class DDim0 = std::enable_if_t<N == 1, std::tuple_element_t<0, std::tuple<DDims...>>>>
196 KOKKOS_FUNCTION auto begin() const
197 {
199 }
200
201 template <
202 std::size_t N = sizeof...(DDims),
203 class DDim0 = std::enable_if_t<N == 1, std::tuple_element_t<0, std::tuple<DDims...>>>>
204 KOKKOS_FUNCTION auto end() const
205 {
206 return DiscreteDomainIterator<DDim0>(m_element_end);
207 }
208
209 template <
210 std::size_t N = sizeof...(DDims),
211 class DDim0 = std::enable_if_t<N == 1, std::tuple_element_t<0, std::tuple<DDims...>>>>
212 KOKKOS_FUNCTION auto cbegin() const
213 {
215 }
216
217 template <
218 std::size_t N = sizeof...(DDims),
219 class DDim0 = std::enable_if_t<N == 1, std::tuple_element_t<0, std::tuple<DDims...>>>>
220 KOKKOS_FUNCTION auto cend() const
221 {
222 return DiscreteDomainIterator<DDim0>(m_element_end);
223 }
224
225 template <
226 std::size_t N = sizeof...(DDims),
227 class = std::enable_if_t<N == 1, std::tuple_element_t<0, std::tuple<DDims...>>>>
228 KOKKOS_FUNCTION constexpr decltype(auto) operator[](std::size_t n)
229 {
230 return begin()[n];
231 }
232
233 template <
234 std::size_t N = sizeof...(DDims),
235 class = std::enable_if_t<N == 1, std::tuple_element_t<0, std::tuple<DDims...>>>>
236 KOKKOS_FUNCTION constexpr decltype(auto) operator[](std::size_t n) const
237 {
238 return begin()[n];
239 }
240};
241
242template <>
244{
245 template <class...>
246 friend class DiscreteDomain;
247
248public:
250
252
253 static KOKKOS_FUNCTION constexpr std::size_t rank()
254 {
255 return 0;
256 }
257
258 KOKKOS_DEFAULTED_FUNCTION constexpr DiscreteDomain() = default;
259
260 // Construct a DiscreteDomain from a reordered copy of `domain`
261 template <class... ODDims>
262 explicit KOKKOS_FUNCTION constexpr DiscreteDomain(
263 [[maybe_unused]] DiscreteDomain<ODDims...> const& domain)
264 {
265 }
266
271 KOKKOS_FUNCTION constexpr DiscreteDomain(
272 [[maybe_unused]] discrete_element_type const& element_begin,
273 [[maybe_unused]] mlength_type const& size)
274 {
275 }
276
277 KOKKOS_DEFAULTED_FUNCTION DiscreteDomain(DiscreteDomain const& x) = default;
278
279 KOKKOS_DEFAULTED_FUNCTION DiscreteDomain(DiscreteDomain&& x) = default;
280
281 KOKKOS_DEFAULTED_FUNCTION ~DiscreteDomain() = default;
282
283 KOKKOS_DEFAULTED_FUNCTION DiscreteDomain& operator=(DiscreteDomain const& x) = default;
284
285 KOKKOS_DEFAULTED_FUNCTION DiscreteDomain& operator=(DiscreteDomain&& x) = default;
286
287 KOKKOS_FUNCTION constexpr bool operator==([[maybe_unused]] DiscreteDomain const& other) const
288 {
289 return true;
290 }
291
292#if __cplusplus <= 201703L
293 // Shall not be necessary anymore in C++20
294 // `a!=b` shall be translated by the compiler to `!(a==b)`
295 KOKKOS_FUNCTION constexpr bool operator!=(DiscreteDomain const& other) const
296 {
297 return !(*this == other);
298 }
299#endif
300
301 KOKKOS_FUNCTION constexpr std::size_t size() const
302 {
303 return 1;
304 }
305
306 KOKKOS_FUNCTION constexpr mlength_type extents() const noexcept
307 {
308 return {};
309 }
310
311 KOKKOS_FUNCTION constexpr discrete_element_type front() const noexcept
312 {
313 return {};
314 }
315
316 KOKKOS_FUNCTION constexpr discrete_element_type back() const noexcept
317 {
318 return {};
319 }
320
321 KOKKOS_FUNCTION constexpr DiscreteDomain take_first([[maybe_unused]] mlength_type n) const
322 {
323 return *this;
324 }
325
326 KOKKOS_FUNCTION constexpr DiscreteDomain take_last([[maybe_unused]] mlength_type n) const
327 {
328 return *this;
329 }
330
331 KOKKOS_FUNCTION constexpr DiscreteDomain remove_first([[maybe_unused]] mlength_type n) const
332 {
333 return *this;
334 }
335
336 KOKKOS_FUNCTION constexpr DiscreteDomain remove_last([[maybe_unused]] mlength_type n) const
337 {
338 return *this;
339 }
340
341 KOKKOS_FUNCTION constexpr DiscreteDomain remove(
342 [[maybe_unused]] mlength_type n1,
343 [[maybe_unused]] mlength_type n2) const
344 {
345 return *this;
346 }
347
348 template <class... ODims>
349 KOKKOS_FUNCTION constexpr DiscreteDomain restrict(DiscreteDomain<ODims...> const&) const
350 {
351 return *this;
352 }
353
354 KOKKOS_FUNCTION constexpr bool empty() const noexcept
355 {
356 return false;
357 }
358
359 KOKKOS_FUNCTION constexpr explicit operator bool()
360 {
361 return true;
362 }
363};
364
365template <class... QueryDDims, class... DDims>
366KOKKOS_FUNCTION constexpr DiscreteDomain<QueryDDims...> select(
367 DiscreteDomain<DDims...> const& domain)
368{
369 return DiscreteDomain<QueryDDims...>(
370 select<QueryDDims...>(domain.front()),
371 select<QueryDDims...>(domain.extents()));
372}
373
374namespace detail {
375
376template <class T>
377struct ConvertTypeSeqToDiscreteDomain;
378
379template <class... DDims>
380struct ConvertTypeSeqToDiscreteDomain<detail::TypeSeq<DDims...>>
381{
382 using type = DiscreteDomain<DDims...>;
383};
384
385template <class T>
386using convert_type_seq_to_discrete_domain = typename ConvertTypeSeqToDiscreteDomain<T>::type;
387
388} // namespace detail
389
390// Computes the cartesian product of DiscreteDomain types
391// Example usage : "using DDom = cartesian_prod_t<DDom1,DDom2,DDom3>;"
392template <typename... DDom>
394
395template <typename... DDim1, typename... DDim2>
397{
398 using type = ddc::DiscreteDomain<DDim1..., DDim2...>;
399};
400
401template <typename DDom>
402struct cartesian_prod<DDom>
403{
404 using type = DDom;
405};
406
407template <typename DDom1, typename DDom2, typename... Tail>
408struct cartesian_prod<DDom1, DDom2, Tail...>
409{
410 using type =
412};
413
414template <typename... DDom>
415using cartesian_prod_t = typename cartesian_prod<DDom...>::type;
416
417// Computes the substraction DDom_a - DDom_b in the sense of linear spaces(retained dimensions are those in DDom_a which are not in DDom_b)
418template <class... DDimsA, class... DDimsB>
419KOKKOS_FUNCTION constexpr auto remove_dims_of(
420 DiscreteDomain<DDimsA...> const& DDom_a,
421 [[maybe_unused]] DiscreteDomain<DDimsB...> const& DDom_b) noexcept
422{
423 using TagSeqA = detail::TypeSeq<DDimsA...>;
424 using TagSeqB = detail::TypeSeq<DDimsB...>;
425
426 using type_seq_r = type_seq_remove_t<TagSeqA, TagSeqB>;
427 return detail::convert_type_seq_to_discrete_domain<type_seq_r>(DDom_a);
428}
429
433template <class... DDimsB, class DDomA>
434KOKKOS_FUNCTION constexpr auto remove_dims_of(DDomA const& DDom_a) noexcept
435{
436 using TagSeqA = typename detail::ToTypeSeq<DDomA>::type;
437 using TagSeqB = detail::TypeSeq<DDimsB...>;
438
439 using type_seq_r = type_seq_remove_t<TagSeqA, TagSeqB>;
440 return detail::convert_type_seq_to_discrete_domain<type_seq_r>(DDom_a);
441}
442
443namespace detail {
444
445// Checks if dimension of DDom_a is DDim1. If not, returns restriction to DDim2 of DDom_b. May not be usefull in its own, it helps for replace_dim_of
446template <typename DDim1, typename DDim2, typename DDimA, typename... DDimsB>
447KOKKOS_FUNCTION constexpr std::conditional_t<
448 std::is_same_v<DDimA, DDim1>,
451replace_dim_of_1d(
452 DiscreteDomain<DDimA> const& DDom_a,
453 [[maybe_unused]] DiscreteDomain<DDimsB...> const& DDom_b) noexcept
454{
455 if constexpr (std::is_same_v<DDimA, DDim1>) {
456 return ddc::select<DDim2>(DDom_b);
457 } else {
458 return DDom_a;
459 }
460}
461
462} // namespace detail
463
464// Replace in DDom_a the dimension Dim1 by the dimension Dim2 of DDom_b
465template <typename DDim1, typename DDim2, typename... DDimsA, typename... DDimsB>
466KOKKOS_FUNCTION constexpr auto replace_dim_of(
467 DiscreteDomain<DDimsA...> const& DDom_a,
468 [[maybe_unused]] DiscreteDomain<DDimsB...> const& DDom_b) noexcept
469{
470 // TODO : static_asserts
471 using TagSeqA = detail::TypeSeq<DDimsA...>;
472 using TagSeqB = detail::TypeSeq<DDim1>;
473 using TagSeqC = detail::TypeSeq<DDim2>;
474
475 using type_seq_r = ddc::type_seq_replace_t<TagSeqA, TagSeqB, TagSeqC>;
476 return ddc::detail::convert_type_seq_to_discrete_domain<type_seq_r>(
477 detail::replace_dim_of_1d<
478 DDim1,
479 DDim2,
480 DDimsA,
481 DDimsB...>(ddc::select<DDimsA>(DDom_a), DDom_b)...);
482}
483
484template <class... QueryDDims, class... DDims>
485KOKKOS_FUNCTION constexpr DiscreteVector<QueryDDims...> extents(
486 DiscreteDomain<DDims...> const& domain) noexcept
487{
488 return DiscreteVector<QueryDDims...>(select<QueryDDims>(domain).size()...);
489}
490
491template <class... QueryDDims, class... DDims>
492KOKKOS_FUNCTION constexpr DiscreteElement<QueryDDims...> front(
493 DiscreteDomain<DDims...> const& domain) noexcept
494{
495 return DiscreteElement<QueryDDims...>(select<QueryDDims>(domain).front()...);
496}
497
498template <class... QueryDDims, class... DDims>
499KOKKOS_FUNCTION constexpr DiscreteElement<QueryDDims...> back(
500 DiscreteDomain<DDims...> const& domain) noexcept
501{
502 return DiscreteElement<QueryDDims...>(select<QueryDDims>(domain).back()...);
503}
504
505namespace detail {
506
507template <class QueryDDimSeq>
508struct Selection;
509
510template <class... QueryDDims>
511struct Selection<detail::TypeSeq<QueryDDims...>>
512{
513 template <class Domain>
514 static KOKKOS_FUNCTION constexpr auto select(Domain const& domain)
515 {
516 return ddc::select<QueryDDims...>(domain);
517 }
518};
519
520} // namespace detail
521
522template <class QueryDDimSeq, class... DDims>
523KOKKOS_FUNCTION constexpr auto select_by_type_seq(DiscreteDomain<DDims...> const& domain)
524{
525 return detail::Selection<QueryDDimSeq>::select(domain);
526}
527
528template <class DDim>
530{
531private:
533
534public:
535 using iterator_category = std::random_access_iterator_tag;
536
538
539 using difference_type = std::ptrdiff_t;
540
541 KOKKOS_DEFAULTED_FUNCTION DiscreteDomainIterator() = default;
542
543 KOKKOS_FUNCTION constexpr explicit DiscreteDomainIterator(DiscreteElement<DDim> value)
544 : m_value(value)
545 {
546 }
547
548 KOKKOS_FUNCTION constexpr DiscreteElement<DDim> operator*() const noexcept
549 {
550 return m_value;
551 }
552
553 KOKKOS_FUNCTION constexpr DiscreteDomainIterator& operator++()
554 {
555 ++m_value.uid();
556 return *this;
557 }
558
559 KOKKOS_FUNCTION constexpr DiscreteDomainIterator operator++(int)
560 {
561 auto tmp = *this;
562 ++*this;
563 return tmp;
564 }
565
566 KOKKOS_FUNCTION constexpr DiscreteDomainIterator& operator--()
567 {
568 --m_value.uid();
569 return *this;
570 }
571
572 KOKKOS_FUNCTION constexpr DiscreteDomainIterator operator--(int)
573 {
574 auto tmp = *this;
575 --*this;
576 return tmp;
577 }
578
580 {
581 if (n >= difference_type(0))
582 m_value.uid() += static_cast<DiscreteElementType>(n);
583 else
584 m_value.uid() -= static_cast<DiscreteElementType>(-n);
585 return *this;
586 }
587
589 {
590 if (n >= difference_type(0))
591 m_value.uid() -= static_cast<DiscreteElementType>(n);
592 else
593 m_value.uid() += static_cast<DiscreteElementType>(-n);
594 return *this;
595 }
596
597 KOKKOS_FUNCTION constexpr DiscreteElement<DDim> operator[](difference_type n) const
598 {
599 return m_value + n;
600 }
601
602 friend KOKKOS_FUNCTION constexpr bool operator==(
603 DiscreteDomainIterator const& xx,
604 DiscreteDomainIterator const& yy)
605 {
606 return xx.m_value == yy.m_value;
607 }
608
609 friend KOKKOS_FUNCTION constexpr bool operator!=(
610 DiscreteDomainIterator const& xx,
611 DiscreteDomainIterator const& yy)
612 {
613 return xx.m_value != yy.m_value;
614 }
615
616 friend KOKKOS_FUNCTION constexpr bool operator<(
617 DiscreteDomainIterator const& xx,
618 DiscreteDomainIterator const& yy)
619 {
620 return xx.m_value < yy.m_value;
621 }
622
623 friend KOKKOS_FUNCTION constexpr bool operator>(
624 DiscreteDomainIterator const& xx,
625 DiscreteDomainIterator const& yy)
626 {
627 return yy < xx;
628 }
629
630 friend KOKKOS_FUNCTION constexpr bool operator<=(
631 DiscreteDomainIterator const& xx,
632 DiscreteDomainIterator const& yy)
633 {
634 return !(yy < xx);
635 }
636
637 friend KOKKOS_FUNCTION constexpr bool operator>=(
638 DiscreteDomainIterator const& xx,
639 DiscreteDomainIterator const& yy)
640 {
641 return !(xx < yy);
642 }
643
644 friend KOKKOS_FUNCTION constexpr DiscreteDomainIterator operator+(
647 {
648 return i += n;
649 }
650
651 friend KOKKOS_FUNCTION constexpr DiscreteDomainIterator operator+(
654 {
655 return i += n;
656 }
657
658 friend KOKKOS_FUNCTION constexpr DiscreteDomainIterator operator-(
661 {
662 return i -= n;
663 }
664
665 friend KOKKOS_FUNCTION constexpr difference_type operator-(
666 DiscreteDomainIterator const& xx,
667 DiscreteDomainIterator const& yy)
668 {
669 return (yy.m_value > xx.m_value) ? (-static_cast<difference_type>(yy.m_value - xx.m_value))
670 : (xx.m_value - yy.m_value);
671 }
672};
673
674} // namespace ddc
Definition: discrete_domain.hpp:244
KOKKOS_FUNCTION constexpr discrete_element_type back() const noexcept
Definition: discrete_domain.hpp:316
KOKKOS_DEFAULTED_FUNCTION ~DiscreteDomain()=default
KOKKOS_FUNCTION constexpr DiscreteDomain take_first(mlength_type n) const
Definition: discrete_domain.hpp:321
static KOKKOS_FUNCTION constexpr std::size_t rank()
Definition: discrete_domain.hpp:253
KOKKOS_DEFAULTED_FUNCTION DiscreteDomain(DiscreteDomain const &x)=default
KOKKOS_FUNCTION constexpr bool operator!=(DiscreteDomain const &other) const
Definition: discrete_domain.hpp:295
KOKKOS_FUNCTION constexpr mlength_type extents() const noexcept
Definition: discrete_domain.hpp:306
friend class DiscreteDomain
Definition: discrete_domain.hpp:246
KOKKOS_DEFAULTED_FUNCTION constexpr DiscreteDomain()=default
KOKKOS_DEFAULTED_FUNCTION DiscreteDomain & operator=(DiscreteDomain &&x)=default
KOKKOS_FUNCTION constexpr bool empty() const noexcept
Definition: discrete_domain.hpp:354
KOKKOS_FUNCTION constexpr DiscreteDomain remove_first(mlength_type n) const
Definition: discrete_domain.hpp:331
KOKKOS_FUNCTION constexpr DiscreteDomain remove_last(mlength_type n) const
Definition: discrete_domain.hpp:336
KOKKOS_FUNCTION constexpr std::size_t size() const
Definition: discrete_domain.hpp:301
KOKKOS_DEFAULTED_FUNCTION DiscreteDomain & operator=(DiscreteDomain const &x)=default
KOKKOS_FUNCTION constexpr DiscreteDomain(DiscreteDomain< ODDims... > const &domain)
Definition: discrete_domain.hpp:262
KOKKOS_FUNCTION constexpr DiscreteDomain restrict(DiscreteDomain< ODims... > const &) const
Definition: discrete_domain.hpp:349
KOKKOS_FUNCTION constexpr DiscreteDomain remove(mlength_type n1, mlength_type n2) const
Definition: discrete_domain.hpp:341
KOKKOS_FUNCTION constexpr bool operator==(DiscreteDomain const &other) const
Definition: discrete_domain.hpp:287
KOKKOS_FUNCTION constexpr DiscreteDomain take_last(mlength_type n) const
Definition: discrete_domain.hpp:326
KOKKOS_FUNCTION constexpr DiscreteDomain(discrete_element_type const &element_begin, mlength_type const &size)
Construct a DiscreteDomain starting from element_begin with size points.
Definition: discrete_domain.hpp:271
KOKKOS_DEFAULTED_FUNCTION DiscreteDomain(DiscreteDomain &&x)=default
KOKKOS_FUNCTION constexpr discrete_element_type front() const noexcept
Definition: discrete_domain.hpp:311
Definition: discrete_domain.hpp:51
KOKKOS_DEFAULTED_FUNCTION DiscreteDomain(DiscreteDomain const &x)=default
KOKKOS_DEFAULTED_FUNCTION DiscreteDomain(DiscreteDomain &&x)=default
KOKKOS_FUNCTION constexpr DiscreteDomain take_first(mlength_type n) const
Definition: discrete_domain.hpp:145
DiscreteVector< DDims... > mlength_type
Definition: discrete_domain.hpp:58
KOKKOS_FUNCTION auto begin() const
Definition: discrete_domain.hpp:196
static KOKKOS_FUNCTION constexpr std::size_t rank()
Definition: discrete_domain.hpp:66
KOKKOS_FUNCTION constexpr bool empty() const noexcept
Definition: discrete_domain.hpp:183
KOKKOS_FUNCTION constexpr std::size_t size() const
Definition: discrete_domain.hpp:118
friend class DiscreteDomain
Definition: discrete_domain.hpp:53
KOKKOS_FUNCTION constexpr DiscreteDomain remove_last(mlength_type n) const
Definition: discrete_domain.hpp:160
KOKKOS_FUNCTION constexpr DiscreteVector< QueryDDim > extent() const noexcept
Definition: discrete_domain.hpp:129
KOKKOS_FUNCTION constexpr discrete_element_type front() const noexcept
Definition: discrete_domain.hpp:135
KOKKOS_FUNCTION constexpr bool operator!=(DiscreteDomain const &other) const
Definition: discrete_domain.hpp:112
KOKKOS_FUNCTION constexpr DiscreteDomain(DDoms const &... domains)
Construct a DiscreteDomain by copies and merge of domains.
Definition: discrete_domain.hpp:75
KOKKOS_FUNCTION constexpr DiscreteDomain(discrete_element_type const &element_begin, mlength_type const &size)
Construct a DiscreteDomain starting from element_begin with size points.
Definition: discrete_domain.hpp:85
KOKKOS_DEFAULTED_FUNCTION DiscreteDomain & operator=(DiscreteDomain &&x)=default
KOKKOS_FUNCTION constexpr bool operator==(DiscreteDomain< ODims... > const &other) const
Definition: discrete_domain.hpp:104
KOKKOS_FUNCTION constexpr DiscreteDomain take_last(mlength_type n) const
Definition: discrete_domain.hpp:150
KOKKOS_FUNCTION constexpr DiscreteDomain remove_first(mlength_type n) const
Definition: discrete_domain.hpp:155
KOKKOS_FUNCTION auto cbegin() const
Definition: discrete_domain.hpp:212
KOKKOS_FUNCTION auto end() const
Definition: discrete_domain.hpp:204
KOKKOS_DEFAULTED_FUNCTION ~DiscreteDomain()=default
KOKKOS_FUNCTION auto cend() const
Definition: discrete_domain.hpp:220
KOKKOS_FUNCTION constexpr DiscreteDomain remove(mlength_type n1, mlength_type n2) const
Definition: discrete_domain.hpp:165
KOKKOS_FUNCTION constexpr auto restrict(DiscreteDomain< ODDims... > const &odomain) const
Definition: discrete_domain.hpp:171
KOKKOS_FUNCTION constexpr decltype(auto) operator[](std::size_t n) const
Definition: discrete_domain.hpp:236
KOKKOS_FUNCTION constexpr discrete_element_type back() const noexcept
Definition: discrete_domain.hpp:140
KOKKOS_DEFAULTED_FUNCTION DiscreteDomain & operator=(DiscreteDomain const &x)=default
DiscreteElement< DDims... > discrete_element_type
Definition: discrete_domain.hpp:56
KOKKOS_FUNCTION constexpr mlength_type extents() const noexcept
Definition: discrete_domain.hpp:123
KOKKOS_DEFAULTED_FUNCTION DiscreteDomain()=default
KOKKOS_FUNCTION constexpr decltype(auto) operator[](std::size_t n)
Definition: discrete_domain.hpp:228
KOKKOS_FUNCTION constexpr value_type & uid() noexcept
Definition: discrete_element.hpp:223
A DiscreteVector is a vector in the discrete dimension.
Definition: discrete_vector.hpp:254
The top-level namespace of DDC.
Definition: aligned_allocator.hpp:11
KOKKOS_FUNCTION constexpr DiscreteElement< QueryDDims... > back(DiscreteDomain< DDims... > const &domain) noexcept
Definition: discrete_domain.hpp:499
typename cartesian_prod< typename cartesian_prod< DDom1, DDom2 >::type, Tail... >::type type
Definition: discrete_domain.hpp:411
KOKKOS_FUNCTION constexpr auto select_by_type_seq(DiscreteDomain< DDims... > const &domain)
Definition: discrete_domain.hpp:523
std::size_t DiscreteElementType
A DiscreteCoordElement is a scalar that identifies an element of the discrete dimension.
Definition: discrete_element.hpp:48
KOKKOS_FUNCTION constexpr DiscreteElement< QueryDDims... > front(DiscreteDomain< DDims... > const &domain) noexcept
Definition: discrete_domain.hpp:492
typename cartesian_prod< DDom... >::type cartesian_prod_t
Definition: discrete_domain.hpp:415
KOKKOS_FUNCTION constexpr DiscreteVector< QueryDDims... > extents(DiscreteDomain< DDims... > const &domain) noexcept
Definition: discrete_domain.hpp:485
KOKKOS_FUNCTION constexpr auto remove_dims_of(DiscreteDomain< DDimsA... > const &DDom_a, DiscreteDomain< DDimsB... > const &DDom_b) noexcept
Definition: discrete_domain.hpp:419
KOKKOS_FUNCTION constexpr auto replace_dim_of(DiscreteDomain< DDimsA... > const &DDom_a, DiscreteDomain< DDimsB... > const &DDom_b) noexcept
Definition: discrete_domain.hpp:466
constexpr bool is_discrete_domain_v
Definition: discrete_domain.hpp:36
DDom type
Definition: discrete_domain.hpp:404
KOKKOS_FUNCTION constexpr DiscreteDomain< QueryDDims... > select(DiscreteDomain< DDims... > const &domain)
Definition: discrete_domain.hpp:366
Definition: discrete_domain.hpp:393
Definition: discrete_domain.hpp:530
KOKKOS_FUNCTION constexpr DiscreteDomainIterator operator--(int)
Definition: discrete_domain.hpp:572
friend KOKKOS_FUNCTION constexpr bool operator<=(DiscreteDomainIterator const &xx, DiscreteDomainIterator const &yy)
Definition: discrete_domain.hpp:630
KOKKOS_FUNCTION constexpr DiscreteElement< DDim > operator*() const noexcept
Definition: discrete_domain.hpp:548
friend KOKKOS_FUNCTION constexpr bool operator>=(DiscreteDomainIterator const &xx, DiscreteDomainIterator const &yy)
Definition: discrete_domain.hpp:637
KOKKOS_DEFAULTED_FUNCTION DiscreteDomainIterator()=default
KOKKOS_FUNCTION constexpr DiscreteElement< DDim > operator[](difference_type n) const
Definition: discrete_domain.hpp:597
KOKKOS_FUNCTION constexpr DiscreteDomainIterator & operator--()
Definition: discrete_domain.hpp:566
KOKKOS_FUNCTION constexpr DiscreteDomainIterator operator++(int)
Definition: discrete_domain.hpp:559
friend KOKKOS_FUNCTION constexpr DiscreteDomainIterator operator-(DiscreteDomainIterator i, difference_type n)
Definition: discrete_domain.hpp:658
friend KOKKOS_FUNCTION constexpr DiscreteDomainIterator operator+(DiscreteDomainIterator i, difference_type n)
Definition: discrete_domain.hpp:644
friend KOKKOS_FUNCTION constexpr bool operator>(DiscreteDomainIterator const &xx, DiscreteDomainIterator const &yy)
Definition: discrete_domain.hpp:623
friend KOKKOS_FUNCTION constexpr bool operator!=(DiscreteDomainIterator const &xx, DiscreteDomainIterator const &yy)
Definition: discrete_domain.hpp:609
friend KOKKOS_FUNCTION constexpr bool operator<(DiscreteDomainIterator const &xx, DiscreteDomainIterator const &yy)
Definition: discrete_domain.hpp:616
KOKKOS_FUNCTION constexpr DiscreteDomainIterator & operator+=(difference_type n)
Definition: discrete_domain.hpp:579
std::ptrdiff_t difference_type
Definition: discrete_domain.hpp:539
KOKKOS_FUNCTION constexpr DiscreteDomainIterator & operator++()
Definition: discrete_domain.hpp:553
friend KOKKOS_FUNCTION constexpr DiscreteDomainIterator operator+(difference_type n, DiscreteDomainIterator i)
Definition: discrete_domain.hpp:651
friend KOKKOS_FUNCTION constexpr bool operator==(DiscreteDomainIterator const &xx, DiscreteDomainIterator const &yy)
Definition: discrete_domain.hpp:602
std::random_access_iterator_tag iterator_category
Definition: discrete_domain.hpp:535
KOKKOS_FUNCTION constexpr DiscreteDomainIterator(DiscreteElement< DDim > value)
Definition: discrete_domain.hpp:543
KOKKOS_FUNCTION constexpr DiscreteDomainIterator & operator-=(difference_type n)
Definition: discrete_domain.hpp:588
friend KOKKOS_FUNCTION constexpr difference_type operator-(DiscreteDomainIterator const &xx, DiscreteDomainIterator const &yy)
Definition: discrete_domain.hpp:665
Definition: discrete_domain.hpp:27