31 #include <tests/myratest.h> 40 myra::out() << typestring<Number>() << std::endl;
45 auto action = make_SymmAction(A);
48 Precision error = frobenius(action.make_Matrix()-A);
49 myra::out() <<
" |A(action) - A(dense)| = " << error << std::endl;
50 REQUIRE(error < tolerance);
57 Precision error = frobenius(A*X-B);
58 myra::out() <<
" |A*X - B| = " << error << std::endl;
59 REQUIRE(error < tolerance);
65 auto alpha = random<Number>();
66 auto beta = random<Number>();
67 auto C = alpha*A*X + beta*B;
68 action.multiply(X,B,alpha,beta);
69 Precision error = frobenius(B-C);
70 myra::out() <<
" | (alpha*A*X+beta*B)[action] - (alpha*A*X+beta*B)[dense] | = " << error << std::endl;
71 REQUIRE(error < tolerance);
78 myra::out() << typestring<Number>() << std::endl;
83 auto action = make_SymmAction(A);
86 Precision error = frobenius(action.make_Matrix()-A.make_Matrix());
87 myra::out() <<
" |A(action) - A(dense)| = " << error << std::endl;
88 REQUIRE(error < tolerance);
95 Precision error = frobenius(A*X-B);
96 myra::out() <<
" |A*X - B| = " << error << std::endl;
97 REQUIRE(error < tolerance);
103 auto alpha = random<Number>();
104 auto beta = random<Number>();
105 auto C = alpha*A*X + beta*B;
106 action.multiply(X,B,alpha,beta);
107 Precision error = frobenius(B-C);
108 myra::out() <<
" | (alpha*A*X+beta*B)[action] - (alpha*A*X+beta*B)[sparse] | = " << error << std::endl;
109 REQUIRE(error < tolerance);
115 ADD_TEST(
"SymmAction",
"[iterative]")
120 test1<NumberS>(IJ,K,1.0e-4f);
121 test1<NumberD>(IJ,K,1.0e-12);
122 test1<NumberC>(IJ,K,1.0e-4f);
123 test1<NumberZ>(IJ,K,1.0e-12);
126 test2<NumberS>(IJ,N,K,1.0e-4f);
127 test2<NumberD>(IJ,N,K,1.0e-12);
128 test2<NumberC>(IJ,N,K,1.0e-4f);
129 test2<NumberZ>(IJ,N,K,1.0e-12);
Returns a transposed copy of a SparseMatrix.
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.
An Action for multiplying by a symmetric dense Matrix. LowerMatrix or SparseMatrix using symm() ...
Returns a transposed copy of a Matrix. The inplace version only works on a square operand...
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
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| = 6.97664e-07
| (alpha*A*X+beta*B)[action] - (alpha*A*X+beta*B)[dense] | = 8.91215e-08
double
|A(action) - A(dense)| = 0
|A*X - B| = 1.09628e-15
| (alpha*A*X+beta*B)[action] - (alpha*A*X+beta*B)[dense] | = 1.42849e-15
std::complex<float>
|A(action) - A(dense)| = 0
|A*X - B| = 2.53684e-06
| (alpha*A*X+beta*B)[action] - (alpha*A*X+beta*B)[dense] | = 2.4389e-06
std::complex<double>
|A(action) - A(dense)| = 0
|A*X - B| = 4.98497e-15
| (alpha*A*X+beta*B)[action] - (alpha*A*X+beta*B)[dense] | = 2.66469e-15
float
|A(action) - A(dense)| = 0
|A*X - B| = 0
| (alpha*A*X+beta*B)[action] - (alpha*A*X+beta*B)[sparse] | = 1.23241e-07
double
|A(action) - A(dense)| = 0
|A*X - B| = 0
| (alpha*A*X+beta*B)[action] - (alpha*A*X+beta*B)[sparse] | = 3.97415e-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] | = 5.69568e-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] | = 4.30113e-16