36#include <boost/test/tools/floating_point_comparison.hpp>
37#include <boost/test/unit_test.hpp>
43 double matrix_buf[] = {10, 5, 2};
45 double b_buf[] = {20, 50, 10};
47 std::shared_ptr<NekMatrix<double>>
A(
66 double expected_result_buf[] = {2, 10, 5};
69 BOOST_CHECK_EQUAL(result1, expectedResult);
70 BOOST_CHECK_EQUAL(result2, expectedResult);
71 BOOST_CHECK_EQUAL(result3, expectedResult);
72 BOOST_CHECK_EQUAL(result4, expectedResult);
73 BOOST_CHECK_EQUAL(result5, expectedResult);
74 BOOST_CHECK_EQUAL(result6, expectedResult);
75 BOOST_CHECK_EQUAL(result7, expectedResult);
76 BOOST_CHECK_EQUAL(result8, expectedResult);
81 double matrix_buf[] = {10, 5, 2};
83 double b_buf[] = {20, 50, 10};
85 std::shared_ptr<NekMatrix<double>>
A(
98 double expected_result_buf[] = {2, 10, 5};
101 linsys.
Solve(b1, result1);
102 linsys.
Solve(b2, result3);
103 linsys.
Solve(b3, result4);
104 linsys.
Solve(b4, result2);
106 BOOST_CHECK_EQUAL(result1, expectedResult);
107 BOOST_CHECK_EQUAL(*result2, expectedResult);
108 BOOST_CHECK_EQUAL(result3, expectedResult);
109 BOOST_CHECK_EQUAL(*result4, expectedResult);
114 double matrix_buf[] = {10, 5, 2};
116 double result_buf[] = {20, 50, 10};
118 std::shared_ptr<NekMatrix<double>>
A(
126 double expected_result_buf[] = {2, 10, 5};
129 BOOST_CHECK_EQUAL(result, expectedResult);
130 std::shared_ptr<NekVector<double>> b1 = b;
132 BOOST_CHECK_EQUAL(result1, expectedResult);
135 BOOST_CHECK_EQUAL(expectedResult, result2);
140 double matrix_buf[] = {10.0, 0.0, 0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 2.0};
142 double result_buf[] = {20, 50, 10};
144 std::shared_ptr<NekMatrix<double>>
A(
152 double epsilon = 1e-14;
154 BOOST_CHECK_CLOSE(result[0], 2.0, epsilon);
155 BOOST_CHECK_CLOSE(result[1], 10.0, epsilon);
156 BOOST_CHECK_CLOSE(result[2], 5.0, epsilon);
162 double matrix_buf[] = {81, -5, -28, 4};
164 double b_buf[] = {-941, 348};
166 std::shared_ptr<NekMatrix<double>>
A(
172 double epsilon = 1e-11;
174 BOOST_CHECK_CLOSE(result[0], 32.5, epsilon);
175 BOOST_CHECK_CLOSE(result[1], 127.625, epsilon);
178 BOOST_CHECK_CLOSE(result[0], -11.0, epsilon);
179 BOOST_CHECK_CLOSE(result[1], 10.0, epsilon);
186 double matrix_buf[] = {
187 -85, -55, -37, -35, 97, 50, 79, 56, 49, 63, 57, -59, 45,
188 -8, -93, 92, 43, -62, 77, 66, 54, -5, 99, -61, -50, -12,
189 -18, 31, -26, -62, 1, -47, -91, -47, -61, 41, -58, -90, 53,
190 -1, 94, 83, -86, 23, -84, 19, -50, 88, -53, 85, 49, 78,
191 17, 72, -99, -85, -86, 30, 80, 72, 66, -29, -91, -53, -19,
192 -47, 68, -72, -87, 79, 43, -66, -53, -61, -23, -37, 31, -34,
193 -42, 88, -76, -65, 25, 28, -61, -60, 9, 29, -66, -32, 78,
194 39, 94, 68, -17, -98, -36, 40, 22, 5};
196 double b_buf[] = {12719, -3169, -16810, 7408, -14945,
197 -6822, 10166, 7023, 8679, -11826};
199 std::shared_ptr<NekMatrix<double>>
A(
205 double epsilon = 1e-11;
206 BOOST_CHECK_CLOSE(result[0], -88.0, epsilon);
207 BOOST_CHECK_CLOSE(result[1], -43.0, epsilon);
208 BOOST_CHECK_CLOSE(result[2], -73.0, epsilon);
209 BOOST_CHECK_CLOSE(result[3], 25.0, epsilon);
210 BOOST_CHECK_CLOSE(result[4], 4.0, epsilon);
211 BOOST_CHECK_CLOSE(result[5], -59.0, epsilon);
212 BOOST_CHECK_CLOSE(result[6], 62.0, epsilon);
213 BOOST_CHECK_CLOSE(result[7], -55.0, epsilon);
214 BOOST_CHECK_CLOSE(result[8], 25.0, epsilon);
215 BOOST_CHECK_CLOSE(result[9], 9.0, epsilon);
257 double matrix_buf[] = {
258 -85, -55, -37, -35, 97, 50, 79, 56, 49, 63, 57, -59, 45,
259 -8, -93, 92, 43, -62, 77, 66, 54, -5, 99, -61, -50, -12,
260 -18, 31, -26, -62, 1, -47, -91, -47, -61, 41, -58, -90, 53,
261 -1, 94, 83, -86, 23, -84, 19, -50, 88, -53, 85, 49, 78,
262 17, 72, -99, -85, -86, 30, 80, 72, 66, -29, -91, -53, -19,
263 -47, 68, -72, -87, 79, 43, -66, -53, -61, -23, -37, 31, -34,
264 -42, 88, -76, -65, 25, 28, -61, -60, 9, 29, -66, -32, 78,
265 39, 94, 68, -17, -98, -36, 40, 22, 5};
267 double b_buf[] = {12719, -3169, -16810, 7408, -14945,
268 -6822, 10166, 7023, 8679, -11826};
269 double result_buf[10] = {0};
271 std::shared_ptr<NekMatrix<double>>
A(
273 std::shared_ptr<NekVector<double>> b(
280 double epsilon = 1e-11;
281 BOOST_CHECK_CLOSE(result[0], -88.0, epsilon);
282 BOOST_CHECK_CLOSE(result[1], -43.0, epsilon);
283 BOOST_CHECK_CLOSE(result[2], -73.0, epsilon);
284 BOOST_CHECK_CLOSE(result[3], 25.0, epsilon);
285 BOOST_CHECK_CLOSE(result[4], 4.0, epsilon);
286 BOOST_CHECK_CLOSE(result[5], -59.0, epsilon);
287 BOOST_CHECK_CLOSE(result[6], 62.0, epsilon);
288 BOOST_CHECK_CLOSE(result[7], -55.0, epsilon);
289 BOOST_CHECK_CLOSE(result[8], 25.0, epsilon);
290 BOOST_CHECK_CLOSE(result[9], 9.0, epsilon);
296 m.SetValue(0, 0, 3.0);
297 m.SetValue(0, 1, 4.0);
301 m.SetValue(2, 2, 11);
303 BOOST_CHECK_EQUAL(4.0, m(1, 0));
305 double b_buf[] = {-20.0, 30.0, -20.0};
312 double epsilon = 1e-11;
313 BOOST_CHECK_CLOSE(x[0], 3.0, epsilon);
314 BOOST_CHECK_CLOSE(x[1], 4.0, epsilon);
315 BOOST_CHECK_CLOSE(x[2], -5.0, epsilon);
316 BOOST_CHECK_CLOSE(xt[0], 3.0, epsilon);
317 BOOST_CHECK_CLOSE(xt[1], 4.0, epsilon);
318 BOOST_CHECK_CLOSE(xt[2], -5.0, epsilon);
RawType_t< VectorType > SolveTranspose(const VectorType &b)
RawType_t< VectorType > Solve(const VectorType &b)
BOOST_AUTO_TEST_CASE(TestLinearSystemSolveWithReturnValue)