MCPcopy Create free account
hub / github.com/AMReX-Codes/amrex / main

Function main

Tests/SmallMatrix/main.cpp:20–334  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18}
19
20int main (int argc, char* argv[])
21{
22 static_assert(Order::C == Order::RowMajor &&
23 Order::F == Order::ColumnMajor);
24 static_assert(has_omega<SmallMatrix<Real,2,2>>::value);
25 static_assert(!has_omega<SmallMatrix<int,2,2>>::value);
26 static_assert(!has_omega<SmallMatrix<unsigned int,2,2>>::value);
27
28 amrex::Initialize(argc, argv);
29 // 0-based indexing
30 {
31 SmallMatrix<Real,3,4> m34{};
32 for (int j = 0; j < 4; ++j) {
33 for (int i = 0; i < 3; ++i) {
34 AMREX_ALWAYS_ASSERT(m34(i,j) == 0.0_rt);
35 }
36 }
37 }
38 {
39 SmallVector<Real,3> cv{};
40 SmallRowVector<Real,3> rv{};
41 SmallVector<int,3> cv2{1,2,3};
42 SmallRowVector<int,3> rv2{0,10,20};
43 SmallVector<int,5> cv3{0,1,2};
44 for (int j = 0; j < 3; ++j) {
45 AMREX_ALWAYS_ASSERT(cv(j) == 0.0_rt &&
46 rv(j) == 0.0_rt &&
47 cv2(j) == j+1 &&
48 rv2(j) == j*10 &&
49 cv3(j) == j);
50 }
51 AMREX_ALWAYS_ASSERT(cv3(3) == 0 && cv3(4) == 0);
52 }
53 {
54 SmallMatrix<int,3,4> m34{{0,3,6,9},
55 {1,4,7,10},
56 {2,5,8,11}};
57 int v = 0;
58 for (int j = 0; j < 4; ++j) {
59 for (int i = 0; i < 3; ++i) {
60 AMREX_ALWAYS_ASSERT(m34(i,j) == v++);
61 }
62 }
63 std::cout << m34;
64 }
65 {
66 SmallMatrix<int,3,4,Order::C> m34{{0,1,2,3},
67 {4,5,6,7},
68 {8,9,10,11}};
69 int v = 0;
70 for (int i = 0; i < 3; ++i) {
71 for (int j = 0; j < 4; ++j) {
72 AMREX_ALWAYS_ASSERT(m34(i,j) == v++);
73 }
74 }
75 }
76 {
77 auto v3 = SmallVector<double,3>::Zero();

Callers

nothing calls this directly

Calls 9

IdentityClass · 0.85
transposeMethod · 0.80
traceMethod · 0.80
InitializeFunction · 0.50
FinalizeFunction · 0.50
setValMethod · 0.45
productMethod · 0.45
sumMethod · 0.45
dotMethod · 0.45

Tested by

no test coverage detected