29 #include <tests/myratest.h> 40 myra::out() << typestring<Number>() << std::endl;
44 auto action = make_GemmAction(A);
47 Precision error = frobenius(action.make_Matrix()-A);
48 myra::out() <<
" |A(action) - A(dense)| = " << error << std::endl;
49 REQUIRE(error < tolerance);
56 Precision error = frobenius(A*X-B);
57 myra::out() <<
" |A*X - B| = " << error << std::endl;
58 REQUIRE(error < tolerance);
64 auto alpha = random<Number>();
65 auto beta = random<Number>();
66 auto C = alpha*A*X + beta*B;
67 action.multiply(X,B,alpha,beta);
68 Precision error = frobenius(B-C);
69 myra::out() <<
" | (alpha*A*X+beta*B)[action] - (alpha*A*X+beta*B)[dense] | = " << error << std::endl;
70 REQUIRE(error < tolerance);
77 myra::out() << typestring<Number>() << std::endl;
81 auto action = make_GemmAction(A);
84 Precision error = frobenius(action.make_Matrix()-A.make_Matrix());
85 myra::out() <<
" |A(action) - A(dense)| = " << error << std::endl;
86 REQUIRE(error < tolerance);
93 Precision error = frobenius(A*X-B);
94 myra::out() <<
" |A*X - B| = " << error << std::endl;
95 REQUIRE(error < tolerance);
101 auto alpha = random<Number>();
102 auto beta = random<Number>();
103 auto C = alpha*A*X + beta*B;
104 action.multiply(X,B,alpha,beta);
105 Precision error = frobenius(B-C);
106 myra::out() <<
" | (alpha*A*X+beta*B)[action] - (alpha*A*X+beta*B)[sparse] | = " << error << std::endl;
107 REQUIRE(error < tolerance);
113 ADD_TEST(
"GemmAction",
"[iterative]")
119 test1<NumberS>(I,J,K,1.0e-4f);
120 test1<NumberD>(I,J,K,1.0e-12);
121 test1<NumberC>(I,J,K,1.0e-4f);
122 test1<NumberZ>(I,J,K,1.0e-12);
125 test2<NumberS>(I,J,N,K,1.0e-4f);
126 test2<NumberD>(I,J,N,K,1.0e-12);
127 test2<NumberC>(I,J,N,K,1.0e-4f);
128 test2<NumberZ>(I,J,N,K,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.
Variety of routines for mixed dense*sparse or dense*sparse matrix multiplies. The dense*dense case is...
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
static SparseMatrix< Number > random(int I, int J, int N)
Generates a random SparseMatrix with size IxJ and (approximately) N nonzeros.
Definition: SparseMatrix.cpp:493
General purpose compressed-sparse-column (CSC) container.
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.
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
An Action for multiplying by a dense Matrix or SparseMatrix using gemm().
Simplistic random number functions.
Variety of routines all for dense Matrix*Matrix multiplies. Delegates to the BLAS.
Range/Iterator types associated with SparseMatrix.
float
|A(action) - A(dense)| = 0
|A*X - B| = 0
| (alpha*A*X+beta*B)[action] - (alpha*A*X+beta*B)[dense] | = 0
double
|A(action) - A(dense)| = 0
|A*X - B| = 0
| (alpha*A*X+beta*B)[action] - (alpha*A*X+beta*B)[dense] | = 0
std::complex<float>
|A(action) - A(dense)| = 0
|A*X - B| = 0
| (alpha*A*X+beta*B)[action] - (alpha*A*X+beta*B)[dense] | = 7.53541e-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] | = 1.4281e-15
float
|A(action) - A(dense)| = 0
|A*X - B| = 0
| (alpha*A*X+beta*B)[action] - (alpha*A*X+beta*B)[sparse] | = 1.07195e-07
double
|A(action) - A(dense)| = 0
|A*X - B| = 0
| (alpha*A*X+beta*B)[action] - (alpha*A*X+beta*B)[sparse] | = 3.09384e-16
std::complex<float>
|A(action) - A(dense)| = 0
|A*X - B| = 0
| (alpha*A*X+beta*B)[action] - (alpha*A*X+beta*B)[sparse] | = 3.19768e-07
std::complex<double>
|A(action) - A(dense)| = 0
|A*X - B| = 0
| (alpha*A*X+beta*B)[action] - (alpha*A*X+beta*B)[sparse] | = 7.59135e-16