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 Basic\n";
38 std::cout <<
" V=" <<
array1(1) <<
"\n";
41 std::cout <<
" V=" <<
array1(1) <<
"\n";
47 std::cout <<
" V=" <<
array2(1, 2) <<
"\n";
53 std::cout <<
" V=" <<
array3(1, 2, 3) <<
"\n";
69 std::cout <<
"Array3: extents=" <<
array3.extent0()
70 <<
"," <<
array3.extent1() <<
"," <<
array3.extent2() <<
"\n";
75 std::cout <<
" MDDim2 slice i=" << i <<
" X=" <<
span_array2.extent0() <<
" Y=" <<
span_array2.extent1() <<
"\n";
85 std::cout <<
"Array2: extents=" <<
array2.extent0() <<
"," <<
array2.extent1() <<
"\n";
89 std::cout <<
" MDDim1 slice i=" << i <<
" X=" <<
span_array2.extent0() <<
"\n";
97 std::cout <<
" V=" <<
array4(1, 2, 3, 4) <<
"\n";
121 std::cout <<
"TEST_NUMARRAY Basic2\n";
126 std::cout <<
" V=" <<
array1(1) <<
"\n";
131 std::cout <<
" V=" <<
array2(1,2) <<
"\n";
136 std::cout <<
" V=" <<
array3(1,2,3) <<
"\n";
141 std::cout <<
" V=" <<
array4(1,2,3,4) <<
"\n";
149 std::cout <<
"TEST_NUMARRAY Extents\n";
184 constexpr int nb_x = 3;
185 constexpr int nb_y = 4;
186 constexpr int nb_z = 5;
193 for(
Int32 x=0,
xn=v.dim1Size(); x<
xn; ++x ){
194 for(
Int32 y=0,
yn=v.dim2Size(); y<
yn; ++y ){
195 for(
Int32 z=0,
zn=v.dim3Size(); z<
zn; ++z ){
205 std::cout <<
"CAPACITY V1=" << v.capacity() <<
"\n";
207 std::cout <<
"CAPACITY V2=" << v.capacity() <<
"\n";
209 std::cout <<
"CAPACITY V3=" << v.capacity() <<
"\n";
211 std::cout <<
"CAPACITY V4=" << v.capacity() <<
"\n";
215#if NUMARRAY_HAS_VALID_RESIZE
221 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
222 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
223 24 , 25, 26, 27, 28, 29, 20 , 21, 22, 23, 24, 25
229 for(
Int64 x=0,
xn=v.dim1Size(); x<
xn; ++x ){
230 for(
Int64 y=0,
yn=v.dim2Size(); y<
yn; ++y ){
231 for(
Int64 z=0,
zn=v.dim3Size(); z<
zn; ++z ){
236 std::cout <<
"XYZ=" << x <<
" " << y <<
" " << z
237 <<
" V=" <<
val1 <<
" offset=" << offset <<
"\n";
255 std::cout <<
"IN_CREATE_1\n";
257 std::cout <<
"IN_CREATE_2\n";
258 for(
Int32 i=0; i<size; ++i )
309 std::cout <<
"PART_1\n";
314 std::cout <<
"PART_2\n";
319 std::cout <<
"PART_3\n";
326 std::cout <<
"PART_4\n";
328 std::cout <<
"PART_5\n";
340 auto [i,
j,
k] = index();
352 for(
Int32 i=0; i<a.dim1Size(); ++i ){
353 for(
Int32 j=0;
j<a.dim2Size(); ++
j ){
354 a(i,
j) = (i*253) +
j;
361 for(
Int32 i=0; i<a.dim1Size(); ++i ){
362 for(
Int32 j=0;
j<a.dim2Size(); ++
j ){
363 for(
Int32 k=0;
k<a.dim3Size(); ++
k ){
364 a(i,
j,
k) = (i*253) + (
j*27) +
k;
376 std::cout <<
"TEST_NUMARRAY2 Layout\n";
382 auto values = a.to1DSpan();
383 std::cout <<
"V=" << values <<
"\n";
384 UniqueArray<Real> ref_value = { 0, 1, 2, 3, 4, 253, 254, 255, 256, 257, 506, 507, 508, 509, 510 };
392 auto values = a.to1DSpan();
393 std::cout <<
"V=" << values <<
"\n";
394 UniqueArray<Real> ref_value = { 0, 253, 506, 1, 254, 507, 2, 255, 508, 3, 256, 509, 4, 257, 510 };
402template<
typename NumArray3>
411 auto values = a.to1DSpan();
412 std::cout <<
"V=" << values <<
"\n";
415 0, 1, 2, 3, 4, 27, 28, 29, 30, 31, 54, 55, 56, 57, 58,
416 253, 254, 255, 256, 257, 280, 281, 282, 283, 284, 307, 308, 309, 310, 311
421template<
typename NumArray3>
428 auto values = a.to1DSpan();
429 std::cout <<
"V=" << values <<
"\n";
432 0, 253, 27, 280, 54, 307, 1, 254, 28, 281, 55, 308, 2, 255, 29,
433 282, 56, 309, 3, 256, 30, 283, 57, 310, 4, 257, 31, 284, 58, 311
440 std::cout <<
"TEST_NUMARRAY3 Layout\n";
444 std::cout <<
"TEST_NUMARRAY3 RightLayout 1\n";
445 _checkRightLayoutDim3(a);
449 std::cout <<
"TEST_NUMARRAY3 RightLayout 2\n";
450 _checkRightLayoutDim3(a);
454 std::cout <<
"TEST_NUMARRAY3 RightLayout 3\n";
455 _checkRightLayoutDim3(a);
459 std::cout <<
"TEST_NUMARRAY3 RightLayout 4\n";
460 _checkRightLayoutDim3(a);
464 std::cout <<
"TEST_NUMARRAY3 RightLayout 5\n";
465 _checkRightLayoutDim3(a);
470 std::cout <<
"TEST_NUMARRAY3 LeftLayout 1\n";
471 _checkLeftLayoutDim3(a);
475 std::cout <<
"TEST_NUMARRAY3 LeftLayout 2\n";
476 _checkLeftLayoutDim3(a);
480 std::cout <<
"TEST_NUMARRAY3 LeftLayout 3\n";
481 _checkLeftLayoutDim3(a);
485 std::cout <<
"TEST_NUMARRAY3 LeftLayout 4\n";
486 _checkLeftLayoutDim3(a);
490 std::cout <<
"TEST_NUMARRAY3 LeftLayout 5\n";
491 _checkLeftLayoutDim3(a);
502 a(2) =
Real2(0.0,3.2);
509 const Real3 v(0.0,3.2,5.6);
518 const Real2 v0(1.2,1.7);
531 const Real3 v0(1.2,3.4,1.7);
550 const char*
values1_str =
"1 3 -2 \n -7 -5 12 \n 3 9 11\n";
551 NumArray<Int32, MDDim1> ref_value(9, { 1, 3, -2, -7, -5, 12, 3, 9, 11 });
559 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";
560 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 });
568namespace TestCopyNumArray
582 std::cout <<
w.to1DSpan() <<
"\n";
584 std::cout <<
b.a_.to1DSpan() <<
"\n";
592 std::cout <<
tpq.to1DSpan() <<
"\n";
600 using namespace TestCopyNumArray;
603 std::cout <<
"Val 4 = "
605 <<
" " <<
test4.a_.to1DSpan() <<
"\n";
607 std::cout <<
"Val 5 = " << &
test5 <<
" " <<
test5.to1DSpan() <<
"\n";
#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 -*-