12#ifndef ARCCORE_BASE_ARRAYVIEWCOMMON_H
13#define ARCCORE_BASE_ARRAYVIEWCOMMON_H
17#include "arccore/base/ArrayIterator.h"
27namespace Arccore::impl
34template<
typename ViewType> ARCCORE_HOST_DEVICE
35auto subViewInterval(ViewType view,
36 typename ViewType::size_type index,
37 typename ViewType::size_type nb_interval) -> ViewType
39 using size_type =
typename ViewType::size_type;
42 if (index<0 || index>=nb_interval)
44 size_type n = view.size();
45 size_type isize = n / nb_interval;
46 size_type ibegin = index * isize;
48 if ((index+1)==nb_interval)
50 return ViewType::create(view.data()+ibegin,isize);
62template<
typename ViewType>
inline void
63dumpArray(std::ostream& o,ViewType val,
int max_print)
65 using size_type =
typename ViewType::size_type;
66 size_type n = val.size();
67 if (max_print>0 && n>max_print){
71 size_type z = (max_print/2);
73 o <<
"[0]=\"" << val[0] <<
'"';
74 for( size_type i=1; i<z; ++i )
75 o <<
" [" << i <<
"]=\"" << val[i] <<
'"';
76 o <<
" ... ... (skipping indexes " << z <<
" to " << z2 <<
" ) ... ... ";
77 for( size_type i=(z2+1); i<n; ++i )
78 o <<
" [" << i <<
"]=\"" << val[i] <<
'"';
81 for( size_type i=0; i<n; ++i ){
84 o <<
"[" << i <<
"]=\"" << val[i] <<
'"';
93template<
typename ViewType>
inline bool
94areEqual(ViewType rhs, ViewType lhs)
96 using size_type =
typename ViewType::size_type;
97 if (rhs.size()!=lhs.size())
99 size_type s = rhs.size();
100 for( size_type i=0; i<s; ++i ){
111template<
typename View2DType>
inline bool
112areEqual2D(View2DType rhs, View2DType lhs)
114 using size_type =
typename View2DType::size_type;
115 const size_type dim1_size = rhs.dim1Size();
116 const size_type dim2_size = rhs.dim2Size();
117 if (dim1_size!=lhs.dim1Size())
119 if (dim2_size!=lhs.dim2Size())
121 for( size_type i=0; i<dim1_size; ++i ){
122 for( size_type j=0; j<dim2_size; ++j ){
123 if (rhs(i,j)!=lhs(i,j))
134extern "C++" ARCCORE_BASE_EXPORT
void
135arccoreThrowTooBigInteger [[noreturn]] (std::size_t size);
137extern "C++" ARCCORE_BASE_EXPORT
void
138arccoreThrowTooBigInt64 [[noreturn]] (std::size_t size);
140extern "C++" ARCCORE_BASE_EXPORT
void
141arccoreThrowNegativeSize [[noreturn]] (
Int64 size);
147inline constexpr ARCCORE_HOST_DEVICE
void
148arccoreCheckIsPositive(
Int64 size)
151#ifdef ARCCORE_DEVICE_CODE
152 assert(
"'size' is negative");
154 impl::arccoreThrowNegativeSize(size);
160inline constexpr ARCCORE_HOST_DEVICE
void
161arccoreCheckIsValidInteger(
Int64 size)
163 if (size>=ARCCORE_INTEGER_MAX){
164#ifdef ARCCORE_DEVICE_CODE
165 assert(
"'size' is bigger than ARCCORE_INTEGER_MAX");
167 impl::arccoreThrowTooBigInteger(size);
173inline constexpr ARCCORE_HOST_DEVICE
void
174arccoreCheckIsValidInt64(
size_t size)
176 if (size>=ARCCORE_INT64_MAX){
177#ifdef ARCCORE_DEVICE_CODE
178 assert(
"'size' is bigger than ARCCORE_INT64_MAX");
180 impl::arccoreThrowTooBigInt64(size);
201inline constexpr ARCCORE_HOST_DEVICE
Integer
204 impl::arccoreCheckIsValidInteger(size);
205 return static_cast<Integer>(size);
217 impl::arccoreCheckIsValidInteger(size);
218 impl::arccoreCheckIsPositive(size);
219 return static_cast<Integer>(size);
228inline constexpr ARCCORE_BASE_EXPORT
Integer
231 impl::arccoreCheckIsValidInteger(size);
232 return static_cast<Integer>(size);
242inline constexpr ARCCORE_HOST_DEVICE
Integer
245 impl::arccoreCheckIsValidInteger(size);
246 impl::arccoreCheckIsPositive(size);
247 return static_cast<Integer>(size);
256inline constexpr ARCCORE_HOST_DEVICE
Integer
259 impl::arccoreCheckIsValidInteger(size);
260 return static_cast<Integer>(size);
269inline constexpr ARCCORE_HOST_DEVICE
Integer
272 impl::arccoreCheckIsValidInteger(size);
273 impl::arccoreCheckIsPositive(size);
274 return static_cast<Integer>(size);
284inline constexpr ARCCORE_HOST_DEVICE
Int64
287 impl::arccoreCheckIsValidInt64(size);
288 return static_cast<Int64>(size);
301 template<
typename SizeType> ARCCORE_HOST_DEVICE
313 static ARCCORE_HOST_DEVICE
Int64 check(std::size_t size)
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Espace de nom de Arccore.
constexpr ARCCORE_HOST_DEVICE Integer arccoreCheckArraySize(unsigned long long size)
Vérifie que size peut être converti dans un 'Integer' pour servir de taille à un tableau....
Int32 Integer
Type représentant un entier.
std::int64_t Int64
Type entier signé sur 64 bits.
constexpr ARCCORE_HOST_DEVICE Int64 arccoreCheckLargeArraySize(size_t size)
Vérifie que size peut être converti dans un 'Int64' pour servir de taille à un tableau.
std::int32_t Int32
Type entier signé sur 32 bits.
void dumpArray(std::ostream &o, ConstArrayView< T > val, int max_print)
Affiche sur le flot o les valeurs du tableau val.
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)