#include "LinearSolver.hpp"
#include "pwiz/utility/misc/unit.hpp"
#include <boost/numeric/ublas/matrix_sparse.hpp>
#include <boost/numeric/ublas/banded.hpp>
#include "pwiz/utility/misc/Std.hpp"
#include <cstring>
Go to the source code of this file.
◆ testDouble()
Definition at line 42 of file LinearSolverTest.cpp.
43{
44 if (
os_) *
os_ <<
"testDouble()\n";
45
47
48 ublas::matrix<double>
A(2,2);
49 A(0,0) = 1;
A(0,1) = 2;
50 A(1,0) = 3;
A(1,1) = 4;
51
52 ublas::vector<double>
y(2);
55
56 ublas::vector<double>
x = solver.solve(
A,
y);
57
58 if (
os_) *
os_ <<
"A: " <<
A << endl;
59 if (
os_) *
os_ <<
"y: " <<
y << endl;
60 if (
os_) *
os_ <<
"x: " <<
x << endl;
61
64}
KernelTraitsBase< Kernel >::space_type::abscissa_type x
KernelTraitsBase< Kernel >::space_type::ordinate_type y
References A, os_, unit_assert, x, and y.
Referenced by main().
◆ testComplex()
Definition at line 67 of file LinearSolverTest.cpp.
68{
69 if (
os_) *
os_ <<
"testComplex()\n";
70
72
73 ublas::matrix< complex<double> >
A(2,2);
74 A(0,0) = 1;
A(0,1) = 2;
75 A(1,0) = 3;
A(1,1) = 4;
76
77 ublas::vector< complex<double> >
y(2);
80
81 ublas::vector< complex<double> >
x = solver.solve(
A,
y);
82
83 if (
os_) *
os_ <<
"A: " <<
A << endl;
84 if (
os_) *
os_ <<
"y: " <<
y << endl;
85 if (
os_) *
os_ <<
"x: " <<
x << endl;
86
89}
References A, os_, unit_assert, x, and y.
Referenced by main().
◆ testDoubleQR()
Definition at line 91 of file LinearSolverTest.cpp.
92{
93 if (
os_) *
os_ <<
"testDoubleQR()\n";
94
96
97 ublas::matrix<double>
A(2,2);
98 A(0,0) = 1.;
A(0,1) = 2.;
99 A(1,0) = 3.;
A(1,1) = 4.;
100
101 ublas::vector<double>
y(2);
104
105 ublas::vector<double>
x = solver.solve(
A,
y);
106
107 if (
os_) *
os_ <<
"A: " <<
A << endl;
108 if (
os_) *
os_ <<
"y: " <<
y << endl;
109 if (
os_) *
os_ <<
"x: " <<
x << endl;
110
111 if (
os_) *
os_ <<
x(0) <<
" - 1. = " <<
x(0) - 1. << endl;
112
115}
#define unit_assert_equal(x, y, epsilon)
References A, os_, unit_assert_equal, x, and y.
Referenced by main().
◆ testSparse()
Definition at line 144 of file LinearSolverTest.cpp.
145{
146 if (
os_) *
os_ <<
"testSparse()\n";
147
149
150 ublas::mapped_matrix<double>
A(2,2,4);
151 A(0,0) = 1.;
A(0,1) = 2.;
152 A(1,0) = 3.;
A(1,1) = 4.;
153
154 ublas::vector<double>
y(2);
157
158 ublas::vector<double>
x = solver.solve(
A,
y);
159
160 if (
os_) *
os_ <<
"A: " <<
A << endl;
161 if (
os_) *
os_ <<
"y: " <<
y << endl;
162 if (
os_) *
os_ <<
"x: " <<
x << endl;
163
166}
References A, os_, unit_assert_equal, x, and y.
Referenced by main().
◆ testBanded()
Definition at line 196 of file LinearSolverTest.cpp.
197{
198 if (
os_) *
os_ <<
"testBanded()\n";
199
201
202 ublas::banded_matrix<double>
A(2,2,1,1);
203 A(0,0) = 1.;
A(0,1) = 2.;
204 A(1,0) = 3.;
A(1,1) = 4.;
205
206 ublas::vector<double>
y(2);
209
210 ublas::vector<double>
x = solver.solve(
A,
y);
211
212 if (
os_) *
os_ <<
"A: " <<
A << endl;
213 if (
os_) *
os_ <<
"y: " <<
y << endl;
214 if (
os_) *
os_ <<
"x: " <<
x << endl;
215
218}
References A, os_, unit_assert_equal, x, and y.
Referenced by main().
◆ testBandedComplex()
void testBandedComplex |
( |
| ) |
|
Definition at line 221 of file LinearSolverTest.cpp.
222{
223 if (
os_) *
os_ <<
"testBandedComplex()\n";
224
226
227 ublas::banded_matrix< complex<double> >
A(2,2,1,1);
228 A(0,0) = 1.;
A(0,1) = 2.;
229 A(1,0) = 3.;
A(1,1) = 4.;
230
231 ublas::vector< complex<double> >
y(2);
234
235 ublas::vector< complex<double> >
x = solver.solve(
A,
y);
236
237 if (
os_) *
os_ <<
"A: " <<
A << endl;
238 if (
os_) *
os_ <<
"y: " <<
y << endl;
239 if (
os_) *
os_ <<
"x: " <<
x << endl;
240
243}
References A, os_, unit_assert, x, and y.
◆ main()
int main |
( |
int |
argc, |
|
|
char * |
argv[] |
|
) |
| |
Definition at line 246 of file LinearSolverTest.cpp.
247{
249
250 try
251 {
252 if (argc>1 && !strcmp(argv[1],
"-v"))
os_ = &cout;
253 if (
os_) *
os_ <<
"LinearSolverTest\n";
254
258
260
262
263 }
264 catch (exception& e)
265 {
267 }
268 catch (...)
269 {
271 }
272
274}
#define TEST_PROLOG(argc, argv)
References os_, TEST_EPILOG, TEST_FAILED, TEST_PROLOG, testBanded(), testComplex(), testDouble(), testDoubleQR(), and testSparse().
◆ os_