Arcane  v3.14.10.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
ArrayBounds.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* ArrayBounds.h (C) 2000-2022 */
9/* */
10/* Gestion des itérations sur les tableaux N-dimensions */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_UTILS_ARRAYBOUNDS_H
13#define ARCANE_UTILS_ARRAYBOUNDS_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/ArrayExtents.h"
18
19/*
20 * ATTENTION:
21 *
22 * Toutes les classes de ce fichier sont expérimentales et l'API n'est pas
23 * figée. A NE PAS UTILISER EN DEHORS DE ARCANE.
24 */
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
28namespace Arcane
29{
30
31/*---------------------------------------------------------------------------*/
32/*---------------------------------------------------------------------------*/
33
34template <typename Extents>
36: private ArrayExtents<Extents>
37{
38 public:
39
41 using BaseClass::asStdArray;
42 using BaseClass::constExtent;
43 using BaseClass::getIndices;
44 using IndexType = typename BaseClass::IndexType;
45 using ArrayExtentType = Arcane::ArrayExtents<Extents>;
46
47 public:
48
49 ArrayBoundsBase() = default;
50 constexpr explicit ArrayBoundsBase(const BaseClass& rhs)
52 {
53 }
54
55 constexpr explicit ArrayBoundsBase(const std::array<Int32, Extents::nb_dynamic>& v)
56 : BaseClass(v)
57 {
58 }
59
60 public:
61
62 constexpr ARCCORE_HOST_DEVICE Int64 nbElement() const { return this->totalNbElement(); }
63};
64
65/*---------------------------------------------------------------------------*/
66/*---------------------------------------------------------------------------*/
67
68template <typename Extents>
70: public ArrayBoundsBase<Extents>
71{
72 public:
73
74 using ExtentsType = Extents;
75 using BaseClass = ArrayBoundsBase<ExtentsType>;
76 using ArrayExtentsType = ArrayExtents<ExtentsType>;
77
78 public:
79
80 template <typename X = Extents, typename = std::enable_if_t<X::nb_dynamic == 4, void>>
81 constexpr ArrayBounds(Int32 dim1, Int32 dim2, Int32 dim3, Int32 dim4)
82 : BaseClass(ArrayExtentsType(dim1, dim2, dim3, dim4))
83 {
84 }
85
86 template <typename X = Extents, typename = std::enable_if_t<X::nb_dynamic == 3, void>>
87 constexpr ArrayBounds(Int32 dim1, Int32 dim2, Int32 dim3)
88 : BaseClass(ArrayExtentsType(dim1, dim2, dim3))
89 {
90 }
91
92 template <typename X = Extents, typename = std::enable_if_t<X::nb_dynamic == 2, void>>
93 constexpr ArrayBounds(Int32 dim1, Int32 dim2)
94 : BaseClass(ArrayExtentsType(dim1, dim2))
95 {
96 }
97
98 template <typename X = Extents, typename = std::enable_if_t<X::nb_dynamic == 1, void>>
99 constexpr ArrayBounds(Int32 dim1)
100 : BaseClass(ArrayExtentsType(dim1))
101 {
102 }
103
104 constexpr explicit ArrayBounds(const ArrayExtentsType& v)
105 : BaseClass(v)
106 {
107 }
108
109 constexpr explicit ArrayBounds(std::array<Int32, Extents::nb_dynamic>& v)
110 : BaseClass(v)
111 {
112 }
113};
114
115/*---------------------------------------------------------------------------*/
116/*---------------------------------------------------------------------------*/
117
118} // End namespace Arcane
119
120/*---------------------------------------------------------------------------*/
121/*---------------------------------------------------------------------------*/
122
123#endif
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-