35#ifndef NEKTAR_UNIT_TESTS_LIB_UTILITIES_LINEAR_ALGEBRA_TEST_COMBINATION_RUNNER_H
36#define NEKTAR_UNIT_TESTS_LIB_UTILITIES_LINEAR_ALGEBRA_TEST_COMBINATION_RUNNER_H
38#include <boost/test/tools/floating_point_comparison.hpp>
39#include <boost/test/unit_test.hpp>
45template <
typename LhsScaledInnerMatrixType,
typename LhsBlockInnerMatrixType,
46 typename RhsScaledInnerMatrixType,
typename RhsBlockInnerMatrixType>
60 BOOST_CHECK_EQUAL(l1 + r1, result);
61 BOOST_CHECK_EQUAL(l1 + r2, result);
62 BOOST_CHECK_EQUAL(l1 + r3, result);
63 BOOST_CHECK_EQUAL(l2 + r1, result);
64 BOOST_CHECK_EQUAL(l2 + r2, result);
65 BOOST_CHECK_EQUAL(l2 + r3, result);
66 BOOST_CHECK_EQUAL(l3 + r1, result);
67 BOOST_CHECK_EQUAL(l3 + r2, result);
68 BOOST_CHECK_EQUAL(l3 + r3, result);
71template <
typename LhsScaledInnerMatrixType,
typename LhsBlockInnerMatrixType,
72 typename RhsScaledInnerMatrixType,
typename RhsBlockInnerMatrixType>
86 BOOST_CHECK_EQUAL(l1 - r1, result);
87 BOOST_CHECK_EQUAL(l1 - r2, result);
88 BOOST_CHECK_EQUAL(l1 - r3, result);
89 BOOST_CHECK_EQUAL(l2 - r1, result);
90 BOOST_CHECK_EQUAL(l2 - r2, result);
91 BOOST_CHECK_EQUAL(l2 - r3, result);
92 BOOST_CHECK_EQUAL(l3 - r1, result);
93 BOOST_CHECK_EQUAL(l3 - r2, result);
94 BOOST_CHECK_EQUAL(l3 - r3, result);
97template <
typename NumberType>
100 unsigned int blockRows,
unsigned int blockColumns,
102 ScaledMatrixTag>> &m2,
105 NumberType *inner_values =
new NumberType[m1.GetStorageSize()];
107 m1.begin(), m1.end(), inner_values,
108 std::bind(std::divides<NumberType>(), std::placeholders::_1, scale));
111 std::shared_ptr<NekMatrix<NumberType, StandardMatrixTag>> inner(
113 m1.GetRows(), m1.GetColumns(), inner_values, s,
114 m1.GetNumberOfSubDiagonals(), m1.GetNumberOfSuperDiagonals()));
115 m2 = std::make_shared<
119 unsigned int numberOfRows = m1.GetRows() / blockRows;
120 unsigned int numberOfColumns = m1.GetColumns() / blockColumns;
121 m3 = std::make_shared<NekMatrix<NekMatrix<NumberType>, BlockMatrixTag>>(
122 blockRows, blockColumns, numberOfRows, numberOfColumns);
124 for (
unsigned int blockRow = 0; blockRow < blockRows; ++blockRow)
126 for (
unsigned int blockColumn = 0; blockColumn < blockColumns;
129 std::shared_ptr<NekMatrix<NumberType>> block(
131 for (
unsigned int i = 0; i < numberOfRows; ++i)
133 for (
unsigned int j = 0; j < numberOfRows; ++j)
135 (*block)(i, j) = m1(numberOfRows * blockRow + i,
136 numberOfColumns * blockColumn + j);
140 m3->SetBlock(blockRow, blockColumn, block);
144 delete[] inner_values;
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)
void RunAllAddCombinations(const NekMatrix< NekDouble, StandardMatrixTag > &l1, const NekMatrix< NekMatrix< NekDouble, LhsScaledInnerMatrixType >, ScaledMatrixTag > &l2, const NekMatrix< NekMatrix< NekDouble, LhsBlockInnerMatrixType >, BlockMatrixTag > &l3, const NekMatrix< NekDouble, StandardMatrixTag > &r1, const NekMatrix< NekMatrix< NekDouble, RhsScaledInnerMatrixType >, ScaledMatrixTag > &r2, const NekMatrix< NekMatrix< NekDouble, RhsBlockInnerMatrixType >, BlockMatrixTag > &r3, const NekMatrix< NekDouble, StandardMatrixTag > &result)
void RunAllSubCombinations(const NekMatrix< NekDouble, StandardMatrixTag > &l1, const NekMatrix< NekMatrix< NekDouble, LhsScaledInnerMatrixType >, ScaledMatrixTag > &l2, const NekMatrix< NekMatrix< NekDouble, LhsBlockInnerMatrixType >, BlockMatrixTag > &l3, const NekMatrix< NekDouble, StandardMatrixTag > &r1, const NekMatrix< NekMatrix< NekDouble, RhsScaledInnerMatrixType >, ScaledMatrixTag > &r2, const NekMatrix< NekMatrix< NekDouble, RhsBlockInnerMatrixType >, BlockMatrixTag > &r3, const NekMatrix< NekDouble, StandardMatrixTag > &result)