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 87 of file TestTriangularMatrixOperations.cpp.

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

References Nektar::eLOWER_TRIANGULAR.

◆ BOOST_AUTO_TEST_CASE() [2/8]

Nektar::TriangularMatrixVectorMultiplicationUnitTests::BOOST_AUTO_TEST_CASE ( TestLowerTriangularSolve  )

Definition at line 173 of file TestTriangularMatrixOperations.cpp.

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

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

◆ BOOST_AUTO_TEST_CASE() [3/8]

Nektar::TriangularMatrixVectorMultiplicationUnitTests::BOOST_AUTO_TEST_CASE ( TestLowerTriangularTransposeSolve  )

Definition at line 195 of file TestTriangularMatrixOperations.cpp.

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

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

◆ BOOST_AUTO_TEST_CASE() [4/8]

Nektar::TriangularMatrixVectorMultiplicationUnitTests::BOOST_AUTO_TEST_CASE ( TestScaledLowerTriangularMatrixVectorMultiplication  )

Definition at line 107 of file TestTriangularMatrixOperations.cpp.

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

References Nektar::eLOWER_TRIANGULAR.

◆ BOOST_AUTO_TEST_CASE() [5/8]

Nektar::TriangularMatrixVectorMultiplicationUnitTests::BOOST_AUTO_TEST_CASE ( TestScaledUpperTriangularMatrixVectorMultiplication  )

Definition at line 65 of file TestTriangularMatrixOperations.cpp.

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

References Nektar::eUPPER_TRIANGULAR.

◆ BOOST_AUTO_TEST_CASE() [6/8]

Nektar::TriangularMatrixVectorMultiplicationUnitTests::BOOST_AUTO_TEST_CASE ( TestUpperTriangularMatrixVectorMultiplication  )

Definition at line 45 of file TestTriangularMatrixOperations.cpp.

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

References Nektar::eUPPER_TRIANGULAR.

◆ BOOST_AUTO_TEST_CASE() [7/8]

Nektar::TriangularMatrixVectorMultiplicationUnitTests::BOOST_AUTO_TEST_CASE ( TestUpperTriangularSolve  )

Definition at line 129 of file TestTriangularMatrixOperations.cpp.

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

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

◆ BOOST_AUTO_TEST_CASE() [8/8]

Nektar::TriangularMatrixVectorMultiplicationUnitTests::BOOST_AUTO_TEST_CASE ( TestUpperTriangularTransposeSolve  )

Definition at line 151 of file TestTriangularMatrixOperations.cpp.

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

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