Nektar++
Functions
Nektar::FullMatrixOperationsUnitTests Namespace Reference

Functions

template<typename DataType , typename MatrixType >
int foo (NekMatrix< DataType, MatrixType > &d)
 
template<typename DataType >
int foo (NekMatrix< DataType, BlockMatrixTag > &d)
 
 BOOST_AUTO_TEST_CASE (TestDoubleSquareFullVectorMultiplication)
 
 BOOST_AUTO_TEST_CASE (TestDoubleSquareFullVectorMultiplicationWithAliasing)
 
 BOOST_AUTO_TEST_CASE (TestDoubleSquareFullVectorMultiplicationWithSharedArrayAliasing)
 
 BOOST_AUTO_TEST_CASE (TestDoubleSquareFullVectorMultiplicationWithSharedArrayAliasingAndMatrixTranspose)
 
 BOOST_AUTO_TEST_CASE (TestDoubleSquareFullVectorMultiplicationWithSharedArrayAliasingAndOverlap)
 
 BOOST_AUTO_TEST_CASE (TestScaledDoubleSquareFullVectorMultiplication)
 
 BOOST_AUTO_TEST_CASE (TestThreeMatrixMultiplication)
 
 BOOST_AUTO_TEST_CASE (TestThreeMatrixMultiplicationWithTranspose)
 
 BOOST_AUTO_TEST_CASE (TestThreeWrappedMatrixMultiplicationWithTranspose)
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/9]

Nektar::FullMatrixOperationsUnitTests::BOOST_AUTO_TEST_CASE ( TestDoubleSquareFullVectorMultiplication  )

Definition at line 57 of file TestFullMatrixOperations.cpp.

58{
60 NekMatrix<NekMatrix<double>, BlockMatrixTag> m2(2, 2, 2, 2);
61 foo(m1);
62 foo(m2);
63 double m_buf[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
64 double v_buf[] = {4, 5, 6};
65
66 NekMatrix<double> m(3, 3, m_buf);
67 NekVector<double> v(3, v_buf);
68
69 double expected_result_buf[] = {66, 81, 96};
70 NekVector<double> expected_result(3, expected_result_buf);
71
72 NekVector<double> result = m * v;
73
74 BOOST_CHECK_EQUAL(expected_result, result);
75}
int foo(NekMatrix< DataType, BlockMatrixTag > &d)

References foo().

◆ BOOST_AUTO_TEST_CASE() [2/9]

Nektar::FullMatrixOperationsUnitTests::BOOST_AUTO_TEST_CASE ( TestDoubleSquareFullVectorMultiplicationWithAliasing  )

Definition at line 77 of file TestFullMatrixOperations.cpp.

78{
79 double m_buf[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
80 double v_buf[] = {4, 5, 6};
81
82 NekMatrix<double> m(3, 3, m_buf);
83 NekVector<double> v(3, v_buf);
84
85 double expected_result_buf[] = {66, 81, 96};
86 NekVector<double> expected_result(3, expected_result_buf);
87
88 v = m * v;
89
90 BOOST_CHECK_EQUAL(expected_result, v);
91}

◆ BOOST_AUTO_TEST_CASE() [3/9]

Nektar::FullMatrixOperationsUnitTests::BOOST_AUTO_TEST_CASE ( TestDoubleSquareFullVectorMultiplicationWithSharedArrayAliasing  )

Definition at line 93 of file TestFullMatrixOperations.cpp.

95{
96 double m_buf[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
97 double v_buf[] = {4, 5, 6};
98
99 Array<OneD, double> vector_array(3, v_buf);
100
101 NekMatrix<double> m(3, 3, m_buf);
102 NekVector<double> v(3, vector_array, eWrapper);
103 NekVector<double> result(3, vector_array, eWrapper);
104
105 double expected_result_buf[] = {66, 81, 96};
106 NekVector<double> expected_result(3, expected_result_buf);
107
108 result = m * v;
109
110 BOOST_CHECK_EQUAL(expected_result, result);
111 BOOST_CHECK_EQUAL(vector_array[0], 66);
112 BOOST_CHECK_EQUAL(vector_array[1], 81);
113 BOOST_CHECK_EQUAL(vector_array[2], 96);
114}

References Nektar::eWrapper.

◆ BOOST_AUTO_TEST_CASE() [4/9]

Nektar::FullMatrixOperationsUnitTests::BOOST_AUTO_TEST_CASE ( TestDoubleSquareFullVectorMultiplicationWithSharedArrayAliasingAndMatrixTranspose  )

Definition at line 116 of file TestFullMatrixOperations.cpp.

118{
119 double m_buf[] = {1, 4, 7, 2, 5, 8, 3, 6, 9};
120 double v_buf[] = {4, 5, 6};
121
122 Array<OneD, double> vector_array(3, v_buf);
123
124 NekMatrix<double> m(3, 3, m_buf);
125 NekVector<double> v(3, vector_array, eWrapper);
126 NekVector<double> result(3, vector_array, eWrapper);
127
128 double expected_result_buf[] = {66, 81, 96};
129 NekVector<double> expected_result(3, expected_result_buf);
130
131 result = Transpose(m) * v;
132
133 BOOST_CHECK_EQUAL(expected_result, result);
134 BOOST_CHECK_EQUAL(vector_array[0], 66);
135 BOOST_CHECK_EQUAL(vector_array[1], 81);
136 BOOST_CHECK_EQUAL(vector_array[2], 96);
137}
NekMatrix< InnerMatrixType, BlockMatrixTag > Transpose(NekMatrix< InnerMatrixType, BlockMatrixTag > &rhs)

References Nektar::eWrapper, and Nektar::Transpose().

◆ BOOST_AUTO_TEST_CASE() [5/9]

Nektar::FullMatrixOperationsUnitTests::BOOST_AUTO_TEST_CASE ( TestDoubleSquareFullVectorMultiplicationWithSharedArrayAliasingAndOverlap  )

Definition at line 139 of file TestFullMatrixOperations.cpp.

141{
142 double m_buf[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
143 double v_buf[] = {4, 5, 6, 0};
144
145 Array<OneD, double> vector_array(4, v_buf);
146 Array<OneD, double> tmp;
147
148 NekMatrix<double> m(3, 3, m_buf);
149 NekVector<double> v(3, vector_array, eWrapper);
150 NekVector<double> result(3, tmp = vector_array + 1, eWrapper);
151
152 double expected_result_buf[] = {66, 81, 96};
153 NekVector<double> expected_result(3, expected_result_buf);
154
155 result = m * v;
156
157 BOOST_CHECK_EQUAL(expected_result, result);
158 BOOST_CHECK_EQUAL(vector_array[1], 66);
159 BOOST_CHECK_EQUAL(vector_array[2], 81);
160 BOOST_CHECK_EQUAL(vector_array[3], 96);
161}

References Nektar::eWrapper.

◆ BOOST_AUTO_TEST_CASE() [6/9]

Nektar::FullMatrixOperationsUnitTests::BOOST_AUTO_TEST_CASE ( TestScaledDoubleSquareFullVectorMultiplication  )

Definition at line 163 of file TestFullMatrixOperations.cpp.

164{
165 double m_buf[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
166 double v_buf[] = {4, 5, 6};
167
168 std::shared_ptr<NekMatrix<double>> inner(
169 new NekMatrix<double>(3, 3, m_buf));
170 NekMatrix<NekMatrix<double>, ScaledMatrixTag> m(7.0, inner);
171 NekVector<double> v(3, v_buf);
172
173 double expected_result_buf[] = {462, 567, 672};
174 NekVector<double> expected_result(3, expected_result_buf);
175
176 NekVector<double> result = m * v;
177
178 BOOST_CHECK_EQUAL(expected_result, result);
179}

◆ BOOST_AUTO_TEST_CASE() [7/9]

Nektar::FullMatrixOperationsUnitTests::BOOST_AUTO_TEST_CASE ( TestThreeMatrixMultiplication  )

Definition at line 181 of file TestFullMatrixOperations.cpp.

182{
183 double buf1[] = {1.0, 2.0, 3.0, 4.0};
184 double buf2[] = {5.0, 6.0, 7.0, 8.0};
185 double buf3[] = {9.0, 10.0, 11.0, 12.0};
186
187 NekMatrix<double> m1(2, 2, buf1);
188 NekMatrix<double> m2(2, 2, buf2);
189 NekMatrix<double> m3(2, 2, buf3);
190
191 double expected_result_buf[] = {517, 766, 625, 926};
192 NekMatrix<double> expected_result(2, 2, expected_result_buf);
193
194 NekMatrix<double> result1 = m1 * m2 * m3;
195 NekMatrix<double> result2 = m1 * (m2 * m3);
196 BOOST_CHECK_EQUAL(expected_result, m1 * m2 * m3);
197
198 BOOST_CHECK_EQUAL(expected_result, m1 * (m2 * m3));
199}

◆ BOOST_AUTO_TEST_CASE() [8/9]

Nektar::FullMatrixOperationsUnitTests::BOOST_AUTO_TEST_CASE ( TestThreeMatrixMultiplicationWithTranspose  )

Definition at line 201 of file TestFullMatrixOperations.cpp.

202{
203 double buf1[] = {1.0, 2.0, 3.0, 4.0};
204 double buf2[] = {5.0, 6.0, 7.0, 8.0};
205 double buf3[] = {9.0, 11.0, 10.0, 12.0};
206
207 NekMatrix<double> m1(2, 2, buf1);
208 NekMatrix<double> m2(2, 2, buf2);
209 NekMatrix<double> m3(2, 2, buf3);
210
211 double expected_result_buf[] = {517, 766, 625, 926};
212 NekMatrix<double> expected_result(2, 2, expected_result_buf);
213
214 BOOST_CHECK_EQUAL(expected_result, m1 * m2 * Transpose(m3));
215}

References Nektar::Transpose().

◆ BOOST_AUTO_TEST_CASE() [9/9]

Nektar::FullMatrixOperationsUnitTests::BOOST_AUTO_TEST_CASE ( TestThreeWrappedMatrixMultiplicationWithTranspose  )

Definition at line 217 of file TestFullMatrixOperations.cpp.

218{
219 double buf1[] = {1.0, 2.0, 3.0, 4.0};
220 double buf2[] = {5.0, 6.0, 7.0, 8.0};
221 double buf3[] = {9.0, 11.0, 10.0, 12.0};
222 double out_buf[] = {0.0, 0.0, 0.0, 0.0};
223
224 Array<OneD, double> array_buf1(4, buf1);
225 Array<OneD, double> array_buf2(4, buf2);
226 Array<OneD, double> array_buf3(4, buf3);
227 Array<OneD, double> array_out_buf(4, out_buf);
228
229 NekMatrix<double> m1(2, 2, array_buf1, eWrapper);
230 NekMatrix<double> m2(2, 2, array_buf2, eWrapper);
231 NekMatrix<double> m3(2, 2, array_buf3, eWrapper);
232 NekMatrix<double> result(2, 2, array_out_buf, eWrapper);
233
234 double expected_result_buf[] = {517, 766, 625, 926};
235 NekMatrix<double> expected_result(2, 2, expected_result_buf);
236
237 result = m1 * m2 * Transpose(m3);
238 BOOST_CHECK_EQUAL(expected_result, result);
239 BOOST_CHECK_EQUAL(array_out_buf[0], 517.0);
240 BOOST_CHECK_EQUAL(array_out_buf[1], 766.0);
241 BOOST_CHECK_EQUAL(array_out_buf[2], 625.0);
242 BOOST_CHECK_EQUAL(array_out_buf[3], 926.0);
243 BOOST_CHECK_EQUAL(result(0, 0), 517.0);
244 BOOST_CHECK_EQUAL(result(1, 0), 766.0);
245 BOOST_CHECK_EQUAL(result(0, 1), 625.0);
246 BOOST_CHECK_EQUAL(result(1, 1), 926.0);
247}

References Nektar::eWrapper, and Nektar::Transpose().

◆ foo() [1/2]

template<typename DataType >
int Nektar::FullMatrixOperationsUnitTests::foo ( NekMatrix< DataType, BlockMatrixTag > &  d)

Definition at line 52 of file TestFullMatrixOperations.cpp.

53{
54 return 2;
55}

◆ foo() [2/2]

template<typename DataType , typename MatrixType >
int Nektar::FullMatrixOperationsUnitTests::foo ( NekMatrix< DataType, MatrixType > &  d)

Definition at line 46 of file TestFullMatrixOperations.cpp.

47{
48 return 1;
49}

Referenced by BOOST_AUTO_TEST_CASE().