40#include <boost/test/tools/floating_point_comparison.hpp>
41#include <boost/test/unit_test.hpp>
45namespace BandedMatrixVectorMultiplicationUnitTests
56 NekDouble a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0};
57 Blas::Dgbmv(
'T', 4, 4, 1, 1, 1.0, a, 3, x, 1, 0.0, y, 1);
59 NekDouble expected_result_buf[] = {5, 26, 65, 67};
62 BOOST_CHECK_EQUAL(expected_result, result);
74 NekDouble a[] = {0, 0, 0, 1, 2, 3, 4, 0, 0, 5, 6, 7, 8, 0,
75 0, 9, 10, 11, 12, 0, 0, 13, 14, 15, 16, 0, 0, 0};
76 Blas::Dgbmv(
'T', 4, 4, 3, 3, 1.0, a, 7, x, 1, 0.0, y, 1);
78 NekDouble expected_result_buf[] = {30, 70, 110, 150};
81 BOOST_CHECK_EQUAL(expected_result, result);
93 NekDouble a[] = {0, 1, 2, 11, 3, 4, 5, 12, 6, 7, 8, 0, 9, 10, 0, 0};
95 Blas::Dgbmv(
'T', 4, 4, 2, 1, 1.0, a, 4, x, 1, 0.0, y, 1);
97 NekDouble expected_result_buf[] = {38, 74, 65, 67};
100 BOOST_CHECK_EQUAL(expected_result, result);
111 NekDouble a[] = {0, 1, 3, 6, 2, 4, 7, 0, 5, 8, 0, 0};
113 Blas::Dgbmv(
'N', 3, 3, 2, 1, 1.0, a, 4, x, 1, 0.0, y, 1);
115 NekDouble expected_result_buf[] = {5, 26, 44};
118 BOOST_CHECK_EQUAL(expected_result, result);
131 NekDouble buf[] = {0, 1, 3, 2, 4, 6, 5, 7, 9, 8, 10, 0};
133 std::shared_ptr<DenseMatrix> m(
136 std::shared_ptr<ScaledMatrix> scaled(
new ScaledMatrix(2.0, m));
138 NekDouble vector_buf[] = {1.0, 2.0, 3.0, 4.0};
144 NekDouble expected_result_buf[] = {5, 26, 65, 67};
147 BOOST_CHECK_EQUAL(expected_result, result);
149 BOOST_CHECK_EQUAL(expectedScaledResult, scaledResult);
154 TestUnequalNumbersOfSubAndSuperDiagonalsMatrixVectorMultiply)
166 NekDouble buf[] = {0, 0, 1, 13, 0, 6, 2, 14, 10, 7,
167 3, 15, 11, 8, 4, 16, 12, 9, 5, 0};
171 NekDouble vector_buf[] = {1, 2, 3, 4, 5};
176 NekDouble expected_result_buf[] = {43, 82, 129, 106, 89};
178 BOOST_CHECK_EQUAL(expected_result, result);
194 NekDouble buf[] = {0, 0, 1, 0, 6, 2, 10, 7, 3, 11, 8, 4, 12, 9, 5};
198 NekDouble vector_buf[] = {1, 2, 3, 4, 5};
203 NekDouble expected_result_buf[] = {43, 69, 101, 61, 25};
205 BOOST_CHECK_EQUAL(expected_result, result);
221 NekDouble buf[] = {0, 0, 0, 1, 0, 0, 6, 2, 0, 10,
222 7, 3, 2, 11, 8, 4, 5, 12, 9, 5};
226 NekDouble vector_buf[] = {1, 2, 3, 4, 5};
231 NekDouble expected_result_buf[] = {51, 94, 101, 61, 25};
233 BOOST_CHECK_EQUAL(expected_result, result);
249 NekDouble buf[] = {0, 0, 0, 0, 1, 0, 0, 0, 6, 2, 0, 0, 10,
250 7, 3, 0, 2, 11, 8, 4, 8, 5, 12, 9, 5};
254 NekDouble vector_buf[] = {1, 2, 3, 4, 5};
259 NekDouble expected_result_buf[] = {91, 94, 101, 61, 25};
261 BOOST_CHECK_EQUAL(expected_result, result);
277 NekDouble buf[] = {0, 0, 1, 13, 7, 0, 6, 2, 14, 5, 10, 7, 3,
278 15, 4, 11, 8, 4, 16, 0, 12, 9, 5, 0, 0};
282 NekDouble vector_buf[] = {1, 2, 3, 4, 5};
287 NekDouble expected_result_buf[] = {43, 82, 136, 116, 101};
289 BOOST_CHECK_EQUAL(expected_result, result);
305 NekDouble buf[] = {0, 0, 1, 13, 7, 20, 0, 6, 2, 14, 5, 21, 10, 7, 3,
306 15, 4, 0, 11, 8, 4, 16, 0, 0, 12, 9, 5, 0, 0, 0};
310 NekDouble vector_buf[] = {1, 2, 3, 4, 5};
315 NekDouble expected_result_buf[] = {43, 82, 136, 136, 143};
317 BOOST_CHECK_EQUAL(expected_result, result);
333 NekDouble buf[] = {0, 0, 1, 13, 7, 20, 30, 0, 6, 2, 14, 5,
334 21, 0, 10, 7, 3, 15, 4, 0, 0, 11, 8, 4,
335 16, 0, 0, 0, 12, 9, 5, 0, 0, 0, 0};
339 NekDouble vector_buf[] = {1, 2, 3, 4, 5};
344 NekDouble expected_result_buf[] = {43, 82, 136, 136, 173};
346 BOOST_CHECK_EQUAL(expected_result, result);
366 NekDouble vector_buf[] = {1, 2, 3, 4, 5};
371 NekDouble expected_result_buf[] = {5, 2, 27, 16, 10};
373 BOOST_CHECK_EQUAL(expected_result, result);
382 double buf[] = {0, 0, -.23, -6.98, 0, 2.54, 2.46, 2.56,
383 -3.66, -2.73, 2.46, -4.78, -2.13, 4.07, -3.82, 0};
388 double b_buf[] = {4.42, 27.13, -6.14, 10.5};
403 double buf[] = {0, 0, 1, 13, 7, 20, 30, 0, 6, 2, 14, 5,
404 21, 0, 10, 7, 3, 15, 4, 0, 0, 11, 8, 4,
405 16, 0, 0, 0, 12, 9, 5, 0, 0, 0, 0};
409 double b_buf[] = {43, 82, 136, 136, 173};
416 double expected_result_buf[] = {1, 2, 3, 4, 5};
419 BOOST_CHECK_CLOSE(expected_result[0], result[0], .00001);
420 BOOST_CHECK_CLOSE(expected_result[1], result[1], .00001);
421 BOOST_CHECK_CLOSE(expected_result[2], result[2], .00001);
422 BOOST_CHECK_CLOSE(expected_result[3], result[3], .00001);
423 BOOST_CHECK_CLOSE(expected_result[4], result[4], .00001);
429namespace BandedMatrixMatrixMultiplicationTests
439 double lhs_buf[] = {0, 2, 16, 22, 10, 4, 18, 24,
440 12, 6, 20, 0, 14, 8, 0, 0};
441 double rhs_buf[] = {0, 30, 38, 32, 40, 34, 42, 36};
447 std::shared_ptr<NekMatrix<NekMatrix<double>, BlockMatrixTag>> lhs3;
450 std::shared_ptr<NekMatrix<NekMatrix<double>, ScaledMatrixTag>> rhs2;
451 std::shared_ptr<NekMatrix<NekMatrix<double>, BlockMatrixTag>> rhs3;
456 double result_buf[] = {60, 480, 660, 0, 396, 736, 1412, 768,
457 400, 568, 924, 1640, 0, 504, 756, 1128};
RawType_t< VectorType > Solve(const VectorType &b)
static void Dgbmv(const char &trans, const int &m, const int &n, const int &kl, const int &ku, const double &alpha, const double *a, const int &lda, const double *x, const int &incx, const double &beta, double *y, const int &incy)
BLAS level 2: Matrix vector multiply y = alpha A x plus beta y where A[m x n] is banded.
BOOST_AUTO_TEST_CASE(TestMatrixMatrixMultiplication)
BOOST_AUTO_TEST_CASE(TestDirectBlasCall)
void GenerateMatrices(const NekMatrix< NumberType, StandardMatrixTag > &m1, NumberType scale, unsigned int blockRows, unsigned int blockColumns, std::shared_ptr< NekMatrix< NekMatrix< NumberType, StandardMatrixTag >, ScaledMatrixTag > > &m2, std::shared_ptr< NekMatrix< NekMatrix< NumberType >, BlockMatrixTag > > &m3)
NekMatrix< DenseMatrix, ScaledMatrixTag > ScaledMatrix
NekMatrix< NekDouble, StandardMatrixTag > DenseMatrix