28 #include <tests/myratest.h> 36 myra::out() << typestring<Number>() << std::endl;
42 Solver solver(A.add_const());
47 Precision error = frobenius(action.make_Matrix()-inverse(A));
48 myra::out() <<
" |action.make_Matrix() - inv(A)| = " << error << std::endl;
49 REQUIRE(error < tolerance);
56 Precision error = frobenius(inverse(A)*X-B);
57 myra::out() <<
" |inv(A)*X - B| = " << error << std::endl;
58 REQUIRE(error < tolerance);
64 auto alpha = random<Number>();
65 auto beta = random<Number>();
66 auto C = alpha*inverse(A)*X + beta*B;
67 action.multiply(X,B,alpha,beta);
68 Precision error = frobenius(B-C);
69 myra::out() <<
" | (alpha*inv(A)*X+beta*B)[action] - (alpha*inv(A)*X+beta*B)[matrix] | = " << error << std::endl;
70 REQUIRE(error < tolerance);
76 ADD_TEST(
"SolveAction",
"[iterative]")
80 test<NumberS>(I,J,1.0e-4f);
81 test<NumberD>(I,J,1.0e-12);
82 test<NumberC>(I,J,1.0e-4f);
83 test<NumberZ>(I,J,1.0e-12);
Interface class for representing subranges of dense Matrix's.
Applies the "Action" of a linear operator, b := A*x, used in iterative solution algorithms.
static Matrix< Number > zeros(int I, int J)
Generates a zeros Matrix of specified size.
Definition: Matrix.cpp:357
Routines for computing Frobenius norms of various algebraic containers.
static Matrix< Number > random(int I, int J)
Generates a random Matrix of specified size.
Definition: Matrix.cpp:353
Action< typename ReflectNumber< Solver >::type > make_SolveAction(const Solver &solver, char op='N')
Free function for making SolveAction's.
Definition: SolveAction.h:67
Various utility functions/classes related to scalar Number types.
General purpose dense matrix container, O(i*j) storage.
Reflects Precision trait for a Number, scalar Number types should specialize it.
Definition: Number.h:33
General purpose linear solver, no symmetry/definiteness assumptions upon A (just square) ...
Overwrites a LowerMatrix, DiagonalMatrix, or square Matrix with its own inverse. Or, returns it as a copy.
Adapts a class with a .solve() method into an Action.
Factors a square matrix A into L*U, presents solve methods.
Definition: LUSolver.h:30
Simplistic random number functions.
Variety of routines all for dense Matrix*Matrix multiplies. Delegates to the BLAS.
float
|action.make_Matrix() - inv(A)| = 0
|inv(A)*X - B| = 2.22223e-06
| (alpha*inv(A)*X+beta*B)[action] - (alpha*inv(A)*X+beta*B)[matrix] | = 1.48848e-06
double
|action.make_Matrix() - inv(A)| = 0
|inv(A)*X - B| = 2.5947e-15
| (alpha*inv(A)*X+beta*B)[action] - (alpha*inv(A)*X+beta*B)[matrix] | = 2.38859e-15
std::complex<float>
|action.make_Matrix() - inv(A)| = 1.71119e-06
|inv(A)*X - B| = 3.2866e-06
| (alpha*inv(A)*X+beta*B)[action] - (alpha*inv(A)*X+beta*B)[matrix] | = 9.03918e-07
std::complex<double>
|action.make_Matrix() - inv(A)| = 4.64566e-15
|inv(A)*X - B| = 8.59021e-15
| (alpha*inv(A)*X+beta*B)[action] - (alpha*inv(A)*X+beta*B)[matrix] | = 2.89178e-15