8#include <gtest/gtest.h>
10#include "arcane/utils/NumArray.h"
12#include "arcane/utils/Real2.h"
13#include "arcane/utils/Real3.h"
14#include "arcane/utils/Real2x2.h"
15#include "arcane/utils/Real3x3.h"
17#include "arcane/utils/NumArrayUtils.h"
33 std::cout <<
"TEST_NUMARRAY Empty\n";
44 std::cout <<
"TEST_NUMARRAY Basic\n";
49 std::cout <<
" V=" <<
array1(1) <<
"\n";
52 std::cout <<
" V=" <<
array1(1) <<
"\n";
58 std::cout <<
" V=" <<
array2(1, 2) <<
"\n";
64 std::cout <<
" V=" <<
array3(1, 2, 3) <<
"\n";
80 std::cout <<
"Array3: extents=" <<
array3.extent0()
81 <<
"," <<
array3.extent1() <<
"," <<
array3.extent2() <<
"\n";
86 std::cout <<
" MDDim2 slice i=" << i <<
" X=" <<
span_array2.extent0() <<
" Y=" <<
span_array2.extent1() <<
"\n";
96 std::cout <<
"Array2: extents=" <<
array2.extent0() <<
"," <<
array2.extent1() <<
"\n";
100 std::cout <<
" MDDim1 slice i=" << i <<
" X=" <<
span_array2.extent0() <<
"\n";
108 std::cout <<
" V=" <<
array4(1, 2, 3, 4) <<
"\n";
109 array4.resize(8, 3, 7, 5);
132 std::cout <<
"TEST_NUMARRAY Basic2\n";
137 std::cout <<
" V=" <<
array1(1) <<
"\n";
142 std::cout <<
" V=" <<
array2(1,2) <<
"\n";
147 std::cout <<
" V=" <<
array3(1,2,3) <<
"\n";
152 std::cout <<
" V=" <<
array4(1,2,3,4) <<
"\n";
160 std::cout <<
"TEST_NUMARRAY Extents\n";
195 constexpr int nb_x = 3;
196 constexpr int nb_y = 4;
197 constexpr int nb_z = 5;
204 for(
Int32 x=0,
xn=v.dim1Size(); x<
xn; ++x ){
205 for(
Int32 y=0,
yn=v.dim2Size(); y<
yn; ++y ){
206 for(
Int32 z=0,
zn=v.dim3Size(); z<
zn; ++z ){
216 std::cout <<
"CAPACITY V1=" << v.capacity() <<
"\n";
218 std::cout <<
"CAPACITY V2=" << v.capacity() <<
"\n";
220 std::cout <<
"CAPACITY V3=" << v.capacity() <<
"\n";
222 std::cout <<
"CAPACITY V4=" << v.capacity() <<
"\n";
226#if NUMARRAY_HAS_VALID_RESIZE
232 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
233 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
234 24 , 25, 26, 27, 28, 29, 20 , 21, 22, 23, 24, 25
240 for(
Int64 x=0,
xn=v.dim1Size(); x<
xn; ++x ){
241 for(
Int64 y=0,
yn=v.dim2Size(); y<
yn; ++y ){
242 for(
Int64 z=0,
zn=v.dim3Size(); z<
zn; ++z ){
247 std::cout <<
"XYZ=" << x <<
" " << y <<
" " << z
248 <<
" V=" <<
val1 <<
" offset=" << offset <<
"\n";
266 std::cout <<
"IN_CREATE_1\n";
268 std::cout <<
"IN_CREATE_2\n";
269 for(
Int32 i=0; i<size; ++i )
320 std::cout <<
"PART_1\n";
325 std::cout <<
"PART_2\n";
330 std::cout <<
"PART_3\n";
337 std::cout <<
"PART_4\n";
339 std::cout <<
"PART_5\n";
351 auto [i,
j,
k] = index();
363 for(
Int32 i=0; i<a.dim1Size(); ++i ){
364 for(
Int32 j=0;
j<a.dim2Size(); ++
j ){
365 a(i,
j) = (i*253) +
j;
372 for(
Int32 i=0; i<a.dim1Size(); ++i ){
373 for(
Int32 j=0;
j<a.dim2Size(); ++
j ){
374 for(
Int32 k=0;
k<a.dim3Size(); ++
k ){
375 a(i,
j,
k) = (i*253) + (
j*27) +
k;
387 std::cout <<
"TEST_NUMARRAY2 Layout\n";
393 auto values = a.to1DSpan();
394 std::cout <<
"V=" << values <<
"\n";
395 UniqueArray<Real> ref_value = { 0, 1, 2, 3, 4, 253, 254, 255, 256, 257, 506, 507, 508, 509, 510 };
403 auto values = a.to1DSpan();
404 std::cout <<
"V=" << values <<
"\n";
405 UniqueArray<Real> ref_value = { 0, 253, 506, 1, 254, 507, 2, 255, 508, 3, 256, 509, 4, 257, 510 };
413template<
typename NumArray3>
422 auto values = a.to1DSpan();
423 std::cout <<
"V=" << values <<
"\n";
426 0, 1, 2, 3, 4, 27, 28, 29, 30, 31, 54, 55, 56, 57, 58,
427 253, 254, 255, 256, 257, 280, 281, 282, 283, 284, 307, 308, 309, 310, 311
432template<
typename NumArray3>
439 auto values = a.to1DSpan();
440 std::cout <<
"V=" << values <<
"\n";
443 0, 253, 27, 280, 54, 307, 1, 254, 28, 281, 55, 308, 2, 255, 29,
444 282, 56, 309, 3, 256, 30, 283, 57, 310, 4, 257, 31, 284, 58, 311
451 std::cout <<
"TEST_NUMARRAY3 Layout\n";
455 std::cout <<
"TEST_NUMARRAY3 RightLayout 1\n";
456 _checkRightLayoutDim3(a);
460 std::cout <<
"TEST_NUMARRAY3 RightLayout 2\n";
461 _checkRightLayoutDim3(a);
465 std::cout <<
"TEST_NUMARRAY3 RightLayout 3\n";
466 _checkRightLayoutDim3(a);
470 std::cout <<
"TEST_NUMARRAY3 RightLayout 4\n";
471 _checkRightLayoutDim3(a);
475 std::cout <<
"TEST_NUMARRAY3 RightLayout 5\n";
476 _checkRightLayoutDim3(a);
481 std::cout <<
"TEST_NUMARRAY3 LeftLayout 1\n";
482 _checkLeftLayoutDim3(a);
486 std::cout <<
"TEST_NUMARRAY3 LeftLayout 2\n";
487 _checkLeftLayoutDim3(a);
491 std::cout <<
"TEST_NUMARRAY3 LeftLayout 3\n";
492 _checkLeftLayoutDim3(a);
496 std::cout <<
"TEST_NUMARRAY3 LeftLayout 4\n";
497 _checkLeftLayoutDim3(a);
501 std::cout <<
"TEST_NUMARRAY3 LeftLayout 5\n";
502 _checkLeftLayoutDim3(a);
513 a(2) =
Real2(0.0,3.2);
520 const Real3 v(0.0,3.2,5.6);
529 const Real2 v0(1.2,1.7);
542 const Real3 v0(1.2,3.4,1.7);
561 const char*
values1_str =
"1 3 -2 \n -7 -5 12 \n 3 9 11\n";
562 NumArray<Int32, MDDim1> ref_value(9, { 1, 3, -2, -7, -5, 12, 3, 9, 11 });
570 const char*
values1_str =
"1.1 3.3 -2.5 \n \n 2.1 4.99 12.23 \n 23 \n 45.1 11.9e2 -12.6e4\n";
571 NumArray<Real, MDDim1> ref_value(10, { 1.1, 3.3, -2.5, 2.1, 4.99, 12.23, 23, 45.1, 11.9e2, -12.6e4 });
579namespace TestCopyNumArray
593 std::cout <<
w.to1DSpan() <<
"\n";
595 std::cout <<
b.a_.to1DSpan() <<
"\n";
603 std::cout <<
tpq.to1DSpan() <<
"\n";
611 using namespace TestCopyNumArray;
614 std::cout <<
"Val 4 = "
616 <<
" " <<
test4.a_.to1DSpan() <<
"\n";
618 std::cout <<
"Val 5 = " << &
test5 <<
" " <<
test5.to1DSpan() <<
"\n";
627 std::cout <<
"Test_SpanUsage";
#define ASSERT_TRUE(condition)
Vérifie que condition est vrai.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Tableaux multi-dimensionnels pour les types numériques accessibles sur accélérateurs.
Classe gérant un vecteur de réel de dimension 2.
Classe gérant une matrice de réel de dimension 2x2.
Classe gérant un vecteur de réel de dimension 3.
Classe gérant une matrice de réel de dimension 3x3.
void readFromText(NumArray< double, MDDim1 > &v, std::istream &input)
Remplit v avec les valeurs de input.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-