#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.
References A, os_, unit_assert, x, and y.
Referenced by main().
44 if (
os_) *
os_ <<
"testDouble()\n";
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;
52 ublas::vector<double>
y(2);
56 ublas::vector<double>
x = solver.solve(
A,
y);
58 if (
os_) *
os_ <<
"A: " <<
A << endl;
59 if (
os_) *
os_ <<
"y: " <<
y << endl;
60 if (
os_) *
os_ <<
"x: " << x << endl;
KernelTraitsBase< Kernel >::space_type::abscissa_type x
KernelTraitsBase< Kernel >::space_type::ordinate_type y
§ testComplex()
Definition at line 67 of file LinearSolverTest.cpp.
References A, os_, unit_assert, x, and y.
Referenced by main().
69 if (
os_) *
os_ <<
"testComplex()\n";
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;
77 ublas::vector< complex<double> >
y(2);
81 ublas::vector< complex<double> >
x = solver.solve(
A,
y);
83 if (
os_) *
os_ <<
"A: " <<
A << endl;
84 if (
os_) *
os_ <<
"y: " <<
y << endl;
85 if (
os_) *
os_ <<
"x: " << x << endl;
KernelTraitsBase< Kernel >::space_type::abscissa_type x
KernelTraitsBase< Kernel >::space_type::ordinate_type y
§ testDoubleQR()
Definition at line 91 of file LinearSolverTest.cpp.
References A, os_, pwiz::math::LinearSolver< LinearSolverType_QR >::solve(), unit_assert_equal, x, and y.
Referenced by main().
93 if (
os_) *
os_ <<
"testDoubleQR()\n";
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.;
101 ublas::vector<double>
y(2);
105 ublas::vector<double>
x = solver.
solve(
A,
y);
107 if (
os_) *
os_ <<
"A: " <<
A << endl;
108 if (
os_) *
os_ <<
"y: " <<
y << endl;
109 if (
os_) *
os_ <<
"x: " << x << endl;
111 if (
os_) *
os_ <<
x(0) <<
" - 1. = " <<
x(0) - 1. << endl;
vector_type solve(const matrix_type &A, const vector_type &y)
solve system of linear equations Ax = y using boost::ublas; note: extra copying inefficiencies for ea...
#define unit_assert_equal(x, y, epsilon)
KernelTraitsBase< Kernel >::space_type::abscissa_type x
KernelTraitsBase< Kernel >::space_type::ordinate_type y
§ testSparse()
Definition at line 144 of file LinearSolverTest.cpp.
References A, os_, unit_assert_equal, x, and y.
Referenced by main().
146 if (
os_) *
os_ <<
"testSparse()\n";
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.;
154 ublas::vector<double>
y(2);
158 ublas::vector<double>
x = solver.solve(
A,
y);
160 if (
os_) *
os_ <<
"A: " <<
A << endl;
161 if (
os_) *
os_ <<
"y: " <<
y << endl;
162 if (
os_) *
os_ <<
"x: " << x << endl;
#define unit_assert_equal(x, y, epsilon)
KernelTraitsBase< Kernel >::space_type::abscissa_type x
KernelTraitsBase< Kernel >::space_type::ordinate_type y
§ testBanded()
Definition at line 196 of file LinearSolverTest.cpp.
References A, os_, unit_assert_equal, x, and y.
Referenced by main().
198 if (
os_) *
os_ <<
"testBanded()\n";
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.;
206 ublas::vector<double>
y(2);
210 ublas::vector<double>
x = solver.solve(
A,
y);
212 if (
os_) *
os_ <<
"A: " <<
A << endl;
213 if (
os_) *
os_ <<
"y: " <<
y << endl;
214 if (
os_) *
os_ <<
"x: " << x << endl;
#define unit_assert_equal(x, y, epsilon)
KernelTraitsBase< Kernel >::space_type::abscissa_type x
KernelTraitsBase< Kernel >::space_type::ordinate_type y
§ testBandedComplex()
void testBandedComplex |
( |
| ) |
|
Definition at line 221 of file LinearSolverTest.cpp.
References A, pwiz::math::MatchedFilter::details::norm(), os_, unit_assert, x, and y.
223 if (
os_) *
os_ <<
"testBandedComplex()\n";
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.;
231 ublas::vector< complex<double> >
y(2);
235 ublas::vector< complex<double> >
x = solver.solve(
A,
y);
237 if (
os_) *
os_ <<
"A: " <<
A << endl;
238 if (
os_) *
os_ <<
"y: " <<
y << endl;
239 if (
os_) *
os_ <<
"x: " << x << endl;
KernelTraitsBase< Kernel >::space_type::abscissa_type x
KernelTraitsBase< Kernel >::space_type::ordinate_type y
§ main()
int main |
( |
int |
argc, |
|
|
char * |
argv[] |
|
) |
| |
Definition at line 246 of file LinearSolverTest.cpp.
References os_, TEST_EPILOG, TEST_FAILED, TEST_PROLOG, testBanded(), testComplex(), testDouble(), testDoubleQR(), and testSparse().
252 if (argc>1 && !strcmp(argv[1],
"-v"))
os_ = &cout;
253 if (
os_) *
os_ <<
"LinearSolverTest\n";
#define TEST_PROLOG(argc, argv)
§ os_