Arcane  v3.16.9.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
ArrayBounds.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2025 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-2025 */
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>
35class ArrayBoundsBase
36: private ArrayExtents<Extents>
37{
38 public:
39
40 using BaseClass = ArrayExtents<Extents>;
41 using BaseClass::asStdArray;
42 using BaseClass::constExtent;
43 using BaseClass::getIndices;
44 using IndexType ARCANE_DEPRECATED_REASON("Use 'MDIndexType' instead") = typename BaseClass::MDIndexType;
45 using MDIndexType = typename BaseClass::MDIndexType;
46 using ArrayExtentType = Arcane::ArrayExtents<Extents>;
47
48 public:
49
50 ArrayBoundsBase() = default;
51 constexpr explicit ArrayBoundsBase(const BaseClass& rhs)
53 {
54 }
55
56 constexpr explicit ArrayBoundsBase(const std::array<Int32, Extents::nb_dynamic>& v)
57 : BaseClass(v)
58 {
59 }
60
61 public:
62
63 constexpr ARCCORE_HOST_DEVICE Int64 nbElement() const { return this->totalNbElement(); }
64};
65
66/*---------------------------------------------------------------------------*/
67/*---------------------------------------------------------------------------*/
68
69template <typename Extents>
70class ArrayBounds
71: public ArrayBoundsBase<Extents>
72{
73 public:
74
75 using ExtentsType = Extents;
76 using BaseClass = ArrayBoundsBase<ExtentsType>;
77 using ArrayExtentsType = ArrayExtents<ExtentsType>;
78
79 public:
80
81 template <typename X = Extents, typename = std::enable_if_t<X::nb_dynamic == 4, void>>
82 constexpr ArrayBounds(Int32 dim1, Int32 dim2, Int32 dim3, Int32 dim4)
83 : BaseClass(ArrayExtentsType(dim1, dim2, dim3, dim4))
84 {
85 }
86
87 template <typename X = Extents, typename = std::enable_if_t<X::nb_dynamic == 3, void>>
88 constexpr ArrayBounds(Int32 dim1, Int32 dim2, Int32 dim3)
89 : BaseClass(ArrayExtentsType(dim1, dim2, dim3))
90 {
91 }
92
93 template <typename X = Extents, typename = std::enable_if_t<X::nb_dynamic == 2, void>>
94 constexpr ArrayBounds(Int32 dim1, Int32 dim2)
95 : BaseClass(ArrayExtentsType(dim1, dim2))
96 {
97 }
98
99 template <typename X = Extents, typename = std::enable_if_t<X::nb_dynamic == 1, void>>
100 constexpr ArrayBounds(Int32 dim1)
101 : BaseClass(ArrayExtentsType(dim1))
102 {
103 }
104
105 constexpr explicit ArrayBounds(const ArrayExtentsType& v)
106 : BaseClass(v)
107 {
108 }
109
110 constexpr explicit ArrayBounds(std::array<Int32, Extents::nb_dynamic>& v)
111 : BaseClass(v)
112 {
113 }
114};
115
116/*---------------------------------------------------------------------------*/
117/*---------------------------------------------------------------------------*/
118
119} // End namespace Arcane
120
121/*---------------------------------------------------------------------------*/
122/*---------------------------------------------------------------------------*/
123
124#endif
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
std::int64_t Int64
Type entier signé sur 64 bits.
std::int32_t Int32
Type entier signé sur 32 bits.