26 #include <tests/myratest.h> 37 myra::out() << typestring<Number>() << std::endl;
41 auto action = make_DimmAction(A);
44 Precision error = frobenius(action.make_Matrix()-A.make_Matrix());
45 myra::out() <<
" |A(action) - A(dense)| = " << error << std::endl;
46 REQUIRE(error < tolerance);
53 Precision error = frobenius(A*X-B);
54 myra::out() <<
" |A*X - B| = " << error << std::endl;
55 REQUIRE(error < tolerance);
61 auto alpha = random<Number>();
62 auto beta = random<Number>();
63 auto C = alpha*A*X + beta*B;
64 action.multiply(X,B,alpha,beta);
65 Precision error = frobenius(B-C);
66 myra::out() <<
" | (alpha*A*X+beta*B)[action] - (alpha*A*X+beta*B)[dense] | = " << error << std::endl;
67 REQUIRE(error < tolerance);
73 ADD_TEST(
"DimmAction",
"[iterative]")
78 test<NumberS>(IJ,K,1.0e-4f);
79 test<NumberD>(IJ,K,1.0e-12);
80 test<NumberC>(IJ,K,1.0e-4f);
81 test<NumberZ>(IJ,K,1.0e-12);
Interface class for representing subranges of DiagonalMatrix's.
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
Routines for multiplying by a DiagonalMatrix.
Definition: stlprint.h:32
Routines for printing the contents of various std::container's to a std::ostream using operator <<...
Various utility functions/classes related to scalar Number types.
static DiagonalMatrix< Number > random(int N)
Generates a random DiagonalMatrix of specified size.
Definition: DiagonalMatrix.cpp:217
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
Simplistic random number functions.
An Action for multiplying by a DiagonalMatrix using dimm()
Container for a diagonal matrix, O(n) storage. Used by SVD, row/column scaling, etc.
float
|A(action) - A(dense)| = 0
|A*X - B| = 0
| (alpha*A*X+beta*B)[action] - (alpha*A*X+beta*B)[dense] | = 4.90162e-08
double
|A(action) - A(dense)| = 0
|A*X - B| = 0
| (alpha*A*X+beta*B)[action] - (alpha*A*X+beta*B)[dense] | = 3.64275e-16
std::complex<float>
|A(action) - A(dense)| = 0
|A*X - B| = 0
| (alpha*A*X+beta*B)[action] - (alpha*A*X+beta*B)[dense] | = 3.78002e-07
std::complex<double>
|A(action) - A(dense)| = 0
|A*X - B| = 0
| (alpha*A*X+beta*B)[action] - (alpha*A*X+beta*B)[dense] | = 8.31973e-16