26 #include <boost/numeric/ublas/matrix_sparse.hpp> 27 #include <boost/numeric/ublas/banded.hpp> 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;
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;
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;
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;
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;
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;
246 int main(
int argc,
char* argv[])
252 if (argc>1 && !strcmp(argv[1],
"-v"))
os_ = &cout;
253 if (
os_) *
os_ <<
"LinearSolverTest\n";
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)
#define TEST_PROLOG(argc, argv)
int main(int argc, char *argv[])
KernelTraitsBase< Kernel >::space_type::abscissa_type x
KernelTraitsBase< Kernel >::space_type::ordinate_type y