Nektar++
Functions
Nektar::TriangularMatrixVectorMultiplicationUnitTests Namespace Reference

Functions

 BOOST_AUTO_TEST_CASE (TestUpperTriangularMatrixVectorMultiplication)
 
 BOOST_AUTO_TEST_CASE (TestScaledUpperTriangularMatrixVectorMultiplication)
 
 BOOST_AUTO_TEST_CASE (TestLowerTriangularMatrixVectorMultiplication)
 
 BOOST_AUTO_TEST_CASE (TestScaledLowerTriangularMatrixVectorMultiplication)
 
 BOOST_AUTO_TEST_CASE (TestUpperTriangularSolve)
 
 BOOST_AUTO_TEST_CASE (TestUpperTriangularTransposeSolve)
 
 BOOST_AUTO_TEST_CASE (TestLowerTriangularSolve)
 
 BOOST_AUTO_TEST_CASE (TestLowerTriangularTransposeSolve)
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/8]

Nektar::TriangularMatrixVectorMultiplicationUnitTests::BOOST_AUTO_TEST_CASE ( TestLowerTriangularMatrixVectorMultiplication  )

Definition at line 85 of file TestTriangularMatrixOperations.cpp.

86{
87 // [1 0 0 0]
88 // [2 6 0 0]
89 // [5 8 7 0]
90 // [3 4 9 10]
91
92 NekDouble a_buf[] = {1, 2, 5, 3, 6, 8, 4, 7, 9, 10};
93 NekDouble x_buf[] = {10, 20, 30, 40};
94
95 NekMatrix<NekDouble, StandardMatrixTag> m(4, 4, a_buf, eLOWER_TRIANGULAR);
96 NekVector<NekDouble> x(4, x_buf);
97
98 NekVector<NekDouble> result = m * x;
99
100 NekDouble expected_result_buf[] = {10, 140, 420, 780};
101 NekVector<NekDouble> expected_result(4, expected_result_buf);
102 BOOST_CHECK_EQUAL(expected_result, result);
103}
double NekDouble

References Nektar::eLOWER_TRIANGULAR.

◆ BOOST_AUTO_TEST_CASE() [2/8]

Nektar::TriangularMatrixVectorMultiplicationUnitTests::BOOST_AUTO_TEST_CASE ( TestLowerTriangularSolve  )

Definition at line 171 of file TestTriangularMatrixOperations.cpp.

172{
173 // [1 2 3 4]
174 // [0 5 6 7]
175 // [0 0 8 9]
176 // [0 0 0 10]
177
178 NekDouble a_buf[] = {1, 2, 5, 3, 6, 8, 4, 7, 9, 10};
180
181 NekDouble b_buf[] = {10, 140, 420, 780};
182 NekVector<NekDouble> b(4, b_buf);
183
184 LinearSystem sys(m);
185 NekVector<NekDouble> x = sys.Solve(b);
186
187 NekDouble expected_result_buf[] = {10, 20, 30, 40};
188 NekVector<NekDouble> expected_result(4, expected_result_buf);
189
190 BOOST_CHECK_EQUAL(expected_result, x);
191}

References Nektar::eLOWER_TRIANGULAR, and Nektar::LinearSystem::Solve().

◆ BOOST_AUTO_TEST_CASE() [3/8]

Nektar::TriangularMatrixVectorMultiplicationUnitTests::BOOST_AUTO_TEST_CASE ( TestLowerTriangularTransposeSolve  )

Definition at line 193 of file TestTriangularMatrixOperations.cpp.

194{
195 // [1 2 3 4]
196 // [0 5 6 7]
197 // [0 0 8 9]
198 // [0 0 0 10]
199
200 NekDouble a_buf[] = {1, 2, 5, 3, 6, 8, 4, 7, 9, 10};
202
203 NekDouble b_buf[] = {320, 520, 570, 400};
204 NekVector<NekDouble> b(4, b_buf);
205
206 LinearSystem sys(m);
207 NekVector<NekDouble> x = sys.SolveTranspose(b);
208
209 NekDouble expected_result_buf[] = {10, 20, 30, 40};
210 NekVector<NekDouble> expected_result(4, expected_result_buf);
211
212 BOOST_CHECK_EQUAL(expected_result, x);
213}

References Nektar::eLOWER_TRIANGULAR, and Nektar::LinearSystem::SolveTranspose().

◆ BOOST_AUTO_TEST_CASE() [4/8]

Nektar::TriangularMatrixVectorMultiplicationUnitTests::BOOST_AUTO_TEST_CASE ( TestScaledLowerTriangularMatrixVectorMultiplication  )

Definition at line 105 of file TestTriangularMatrixOperations.cpp.

106{
107 // [1 0 0 0]
108 // [2 6 0 0]
109 // [5 8 7 0]
110 // [3 4 9 10]
111
112 NekDouble a_buf[] = {1, 2, 5, 3, 6, 8, 4, 7, 9, 10};
113 NekDouble x_buf[] = {10, 20, 30, 40};
114
115 std::shared_ptr<NekMatrix<NekDouble, StandardMatrixTag>> m(
116 new NekMatrix<NekDouble>(4, 4, a_buf, eLOWER_TRIANGULAR));
117 NekMatrix<NekMatrix<NekDouble>, ScaledMatrixTag> scaled(3.0, m);
118 NekVector<NekDouble> x(4, x_buf);
119
120 NekVector<NekDouble> result = scaled * x;
121
122 NekDouble expected_result_buf[] = {30, 420, 1260, 2340};
123 NekVector<NekDouble> expected_result(4, expected_result_buf);
124 BOOST_CHECK_EQUAL(expected_result, result);
125}

References Nektar::eLOWER_TRIANGULAR.

◆ BOOST_AUTO_TEST_CASE() [5/8]

Nektar::TriangularMatrixVectorMultiplicationUnitTests::BOOST_AUTO_TEST_CASE ( TestScaledUpperTriangularMatrixVectorMultiplication  )

Definition at line 63 of file TestTriangularMatrixOperations.cpp.

64{
65 // [1 2 3 4]
66 // [0 5 6 7]
67 // [0 0 8 9]
68 // [0 0 0 10]
69
70 NekDouble a_buf[] = {1, 2, 5, 3, 6, 8, 4, 7, 9, 10};
71 NekDouble x_buf[] = {10, 20, 30, 40};
72
73 std::shared_ptr<NekMatrix<NekDouble, StandardMatrixTag>> m(
74 new NekMatrix<NekDouble>(4, 4, a_buf, eUPPER_TRIANGULAR));
75 NekMatrix<NekMatrix<NekDouble>, ScaledMatrixTag> scaled(2, m);
76 NekVector<NekDouble> x(4, x_buf);
77
78 NekVector<NekDouble> result = scaled * x;
79
80 NekDouble expected_result_buf[] = {600, 1120, 1200, 800};
81 NekVector<NekDouble> expected_result(4, expected_result_buf);
82 BOOST_CHECK_EQUAL(expected_result, result);
83}

References Nektar::eUPPER_TRIANGULAR.

◆ BOOST_AUTO_TEST_CASE() [6/8]

Nektar::TriangularMatrixVectorMultiplicationUnitTests::BOOST_AUTO_TEST_CASE ( TestUpperTriangularMatrixVectorMultiplication  )

Definition at line 43 of file TestTriangularMatrixOperations.cpp.

44{
45 // [1 2 3 4]
46 // [0 5 6 7]
47 // [0 0 8 9]
48 // [0 0 0 10]
49
50 NekDouble a_buf[] = {1, 2, 5, 3, 6, 8, 4, 7, 9, 10};
51 NekDouble x_buf[] = {10, 20, 30, 40};
52
53 NekMatrix<NekDouble, StandardMatrixTag> m(4, 4, a_buf, eUPPER_TRIANGULAR);
54 NekVector<NekDouble> x(4, x_buf);
55
56 NekVector<NekDouble> result = m * x;
57
58 NekDouble expected_result_buf[] = {300, 560, 600, 400};
59 NekVector<NekDouble> expected_result(4, expected_result_buf);
60 BOOST_CHECK_EQUAL(expected_result, result);
61}

References Nektar::eUPPER_TRIANGULAR.

◆ BOOST_AUTO_TEST_CASE() [7/8]

Nektar::TriangularMatrixVectorMultiplicationUnitTests::BOOST_AUTO_TEST_CASE ( TestUpperTriangularSolve  )

Definition at line 127 of file TestTriangularMatrixOperations.cpp.

128{
129 // [1 2 3 4]
130 // [0 5 6 7]
131 // [0 0 8 9]
132 // [0 0 0 10]
133
134 NekDouble a_buf[] = {1, 2, 5, 3, 6, 8, 4, 7, 9, 10};
136
137 NekDouble b_buf[] = {300, 560, 600, 400};
138 NekVector<NekDouble> b(4, b_buf);
139
140 LinearSystem sys(m);
141 NekVector<NekDouble> x = sys.Solve(b);
142
143 NekDouble expected_result_buf[] = {10, 20, 30, 40};
144 NekVector<NekDouble> expected_result(4, expected_result_buf);
145
146 BOOST_CHECK_EQUAL(expected_result, x);
147}

References Nektar::eUPPER_TRIANGULAR, and Nektar::LinearSystem::Solve().

◆ BOOST_AUTO_TEST_CASE() [8/8]

Nektar::TriangularMatrixVectorMultiplicationUnitTests::BOOST_AUTO_TEST_CASE ( TestUpperTriangularTransposeSolve  )

Definition at line 149 of file TestTriangularMatrixOperations.cpp.

150{
151 // [1 2 3 4]
152 // [0 5 6 7]
153 // [0 0 8 9]
154 // [0 0 0 10]
155
156 NekDouble a_buf[] = {1, 2, 5, 3, 6, 8, 4, 7, 9, 10};
158
159 NekDouble b_buf[] = {10, 120, 390, 850};
160 NekVector<NekDouble> b(4, b_buf);
161
162 LinearSystem sys(m);
163 NekVector<NekDouble> x = sys.SolveTranspose(b);
164
165 NekDouble expected_result_buf[] = {10, 20, 30, 40};
166 NekVector<NekDouble> expected_result(4, expected_result_buf);
167
168 BOOST_CHECK_EQUAL(expected_result, x);
169}

References Nektar::eUPPER_TRIANGULAR, and Nektar::LinearSystem::SolveTranspose().