13#ifndef ARCANE_DATATYPE_REALARRAYVARIANT_H
14#define ARCANE_DATATYPE_REALARRAYVARIANT_H
18#include "arcane/utils/Array.h"
19#include "arcane/utils/ArrayView.h"
20#include "arcane/utils/Real2.h"
21#include "arcane/utils/Real3.h"
22#if defined(ARCANE_HAS_ACCELERATOR_API)
23#include "arcane/utils/NumArray.h"
43 static const Integer MAX_SIZE = 9;
45 RealArrayVariant() =
default;
53#if defined(ARCANE_HAS_ACCELERATOR_API)
54 template <
typename LayoutType>
56 : RealArrayVariant(v.mdspan())
58 template <
typename LayoutType>
63 template <
typename LayoutType>
69 RealArrayVariant(
Real2 r)
71 _setValue(
reinterpret_cast<Real*
>(&r), 2);
73 RealArrayVariant(
Real3 r)
75 _setValue(
reinterpret_cast<Real*
>(&r), 3);
78 RealArrayVariant& operator=(
const RealArrayVariant& rhs) =
default;
84 RealArrayVariant& operator=(
Real2 r)
86 _setValue(
reinterpret_cast<Real*
>(&r), 2);
89 RealArrayVariant& operator=(
Real3 r)
91 _setValue(
reinterpret_cast<Real*
>(&r), 3);
97 ARCANE_ASSERT(index < m_nb_value, (
"Index out of range"));
98 return m_value[index];
102 ARCANE_ASSERT(index < m_nb_value, (
"Index out of range"));
103 return m_value[index];
107 ARCANE_ASSERT(index < m_nb_value, (
"Index out of range"));
108 return m_value[index];
112 ARCANE_ASSERT(index < m_nb_value, (
"Index out of range"));
113 return m_value[index];
116 Int32 size()
const {
return m_nb_value; }
117 Real* data() {
return m_value; }
118 const Real* data()
const {
return m_value; }
120 operator Real2()
const {
return Real2(m_value[0], m_value[1]); }
121 operator Real3()
const {
return Real3(m_value[0], m_value[1], m_value[2]); }
123#if defined(ARCANE_HAS_ACCELERATOR_API)
127 for (
Integer i = 0, n = m_nb_value; i < n; ++i)
135 Real m_value[MAX_SIZE];
136 Int32 m_nb_value = 0;
140 void _setValue(
const Real* v,
Int32 nb_value)
142 m_nb_value = nb_value;
143 ARCANE_ASSERT(nb_value <= MAX_SIZE, (
"Size is too large"));
144 for (
Integer i = 0; i < nb_value; ++i)
ConstArrayView< T > constView() const
Constant view of this array.
Constant view of an array of type T.
constexpr const_pointer data() const noexcept
Pointer to the allocated memory.
constexpr Integer size() const noexcept
Number of elements in the array.
Base class for multi-dimensional views.
constexpr __host__ __device__ Int32 extent0() const
Value of the first dimension.
Multi-dimensional arrays for numerical types accessible on accelerators.
Class managing a 2-dimensional real vector.
Class managing a 3-dimensional real vector.
constexpr __host__ __device__ pointer data() const noexcept
Pointer to the start of the view.
1D data vector with value semantics (STL style).
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.
double Real
Type representing a real number.
std::int32_t Int32
Signed integer type of 32 bits.