@@ -20,6 +20,64 @@ namespace LvArray
2020namespace testing
2121{
2222
23+ template < int M, typename MATRIX, typename SYM_MATRIX >
24+ LVARRAY_HOST_DEVICE inline
25+ std::enable_if_t < M == 2 >
26+ checkSymmetricToDense ( MATRIX const & matrix, SYM_MATRIX const symMatrix )
27+ {
28+ PORTABLE_EXPECT_EQ ( matrix[ 0 ][ 0 ], symMatrix[ 0 ] );
29+ PORTABLE_EXPECT_EQ ( matrix[ 1 ][ 1 ], symMatrix[ 1 ] );
30+
31+ PORTABLE_EXPECT_EQ ( matrix[ 0 ][ 1 ], symMatrix[ 2 ] );
32+ PORTABLE_EXPECT_EQ ( matrix[ 1 ][ 0 ], symMatrix[ 2 ] );
33+ }
34+
35+ template < int M, typename MATRIX, typename SYM_MATRIX >
36+ LVARRAY_HOST_DEVICE inline
37+ std::enable_if_t < M == 2 >
38+ checkDenseToSymmetric ( MATRIX const & matrix, SYM_MATRIX const symMatrix )
39+ {
40+ PORTABLE_EXPECT_EQ ( matrix[ 0 ][ 0 ], symMatrix[ 0 ] );
41+ PORTABLE_EXPECT_EQ ( matrix[ 1 ][ 1 ], symMatrix[ 1 ] );
42+
43+ PORTABLE_EXPECT_EQ ( matrix[ 0 ][ 1 ], symMatrix[ 2 ] );
44+ }
45+
46+ template < int M, typename MATRIX, typename SYM_MATRIX >
47+ LVARRAY_HOST_DEVICE inline
48+ std::enable_if_t < M == 3 >
49+ checkSymmetricToDense ( MATRIX const & matrix, SYM_MATRIX const symMatrix )
50+ {
51+ PORTABLE_EXPECT_EQ ( matrix[ 0 ][ 0 ], symMatrix[ 0 ] );
52+ PORTABLE_EXPECT_EQ ( matrix[ 1 ][ 1 ], symMatrix[ 1 ] );
53+ PORTABLE_EXPECT_EQ ( matrix[ 2 ][ 2 ], symMatrix[ 2 ] );
54+
55+ PORTABLE_EXPECT_EQ ( matrix[ 1 ][ 2 ], symMatrix[ 3 ] );
56+ PORTABLE_EXPECT_EQ ( matrix[ 2 ][ 1 ], symMatrix[ 3 ] );
57+
58+ PORTABLE_EXPECT_EQ ( matrix[ 0 ][ 2 ], symMatrix[ 4 ] );
59+ PORTABLE_EXPECT_EQ ( matrix[ 2 ][ 0 ], symMatrix[ 4 ] );
60+
61+ PORTABLE_EXPECT_EQ ( matrix[ 0 ][ 1 ], symMatrix[ 5 ] );
62+ PORTABLE_EXPECT_EQ ( matrix[ 1 ][ 0 ], symMatrix[ 5 ] );
63+ }
64+
65+ template < int M, typename MATRIX, typename SYM_MATRIX >
66+ LVARRAY_HOST_DEVICE inline
67+ std::enable_if_t < M == 3 >
68+ checkDenseToSymmetric ( MATRIX const & matrix, SYM_MATRIX const symMatrix )
69+ {
70+ PORTABLE_EXPECT_EQ ( matrix[ 0 ][ 0 ], symMatrix[ 0 ] );
71+ PORTABLE_EXPECT_EQ ( matrix[ 1 ][ 1 ], symMatrix[ 1 ] );
72+ PORTABLE_EXPECT_EQ ( matrix[ 2 ][ 2 ], symMatrix[ 2 ] );
73+
74+ PORTABLE_EXPECT_EQ ( matrix[ 1 ][ 2 ], symMatrix[ 3 ] );
75+
76+ PORTABLE_EXPECT_EQ ( matrix[ 0 ][ 2 ], symMatrix[ 4 ] );
77+
78+ PORTABLE_EXPECT_EQ ( matrix[ 0 ][ 1 ], symMatrix[ 5 ] );
79+ }
80+
2381template < typename T_N_POLICY_TUPLE >
2482class FixedSizeSquareMatrixTest : public ::testing::Test
2583{
@@ -310,22 +368,7 @@ class FixedSizeSquareMatrixTest : public ::testing::Test
310368 #define _TEST ( symMatrix, matrix ) \
311369 fill ( matrix, matrixASeed ); \
312370 tensorOps::symmetricToDense< N >( matrix, symMatrix ); \
313- for ( int j = 0 ; j < N; ++j ) \
314- { PORTABLE_EXPECT_EQ ( matrix[ j ][ j ], symMatrix[ j ] ); } \
315- if ( N == 2 ) \
316- { \
317- PORTABLE_EXPECT_EQ ( matrix[ 0 ][ 1 ], symMatrix[ 2 ] ); \
318- PORTABLE_EXPECT_EQ ( matrix[ 1 ][ 0 ], symMatrix[ 2 ] ); \
319- } \
320- else \
321- { \
322- PORTABLE_EXPECT_EQ ( matrix[ 0 ][ 1 ], symMatrix[ 5 ] ); \
323- PORTABLE_EXPECT_EQ ( matrix[ 1 ][ 0 ], symMatrix[ 5 ] ); \
324- PORTABLE_EXPECT_EQ ( matrix[ 0 ][ 2 ], symMatrix[ 4 ] ); \
325- PORTABLE_EXPECT_EQ ( matrix[ 2 ][ 0 ], symMatrix[ 4 ] ); \
326- PORTABLE_EXPECT_EQ ( matrix[ 1 ][ 2 ], symMatrix[ 3 ] ); \
327- PORTABLE_EXPECT_EQ ( matrix[ 2 ][ 1 ], symMatrix[ 3 ] ); \
328- }
371+ checkSymmetricToDense< N >( matrix, symMatrix );
329372
330373 #define _TEST_PERMS ( symMatrix, matrix0, matrix1, matrix2, matrix3 ) \
331374 _TEST ( symMatrix, matrix0 ) \
@@ -361,18 +404,7 @@ class FixedSizeSquareMatrixTest : public ::testing::Test
361404 #define _TEST ( symMatrix, matrix ) \
362405 fill ( symMatrix, symMatrixASeed ); \
363406 tensorOps::denseToSymmetric< N >( symMatrix, matrix ); \
364- for ( int j = 0 ; j < N; ++j ) \
365- { PORTABLE_EXPECT_EQ ( matrix[ j ][ j ], symMatrix[ j ] ); } \
366- if ( N == 2 ) \
367- { \
368- PORTABLE_EXPECT_EQ ( matrix[ 0 ][ 1 ], symMatrix[ 2 ] ); \
369- } \
370- else \
371- { \
372- PORTABLE_EXPECT_EQ ( matrix[ 0 ][ 1 ], symMatrix[ 5 ] ); \
373- PORTABLE_EXPECT_EQ ( matrix[ 0 ][ 2 ], symMatrix[ 4 ] ); \
374- PORTABLE_EXPECT_EQ ( matrix[ 1 ][ 2 ], symMatrix[ 3 ] ); \
375- }
407+ checkDenseToSymmetric< N >( matrix, symMatrix );
376408
377409 #define _TEST_PERMS ( symMatrix, matrix0, matrix1, matrix2, matrix3 ) \
378410 _TEST ( symMatrix, matrix0 ) \
0 commit comments