24 #include <tests/myratest.h> 33 myra::out() << typestring<Number>() << std::endl;
36 auto C1 = multiply(A);
37 auto C2 = gemm(A.make_Matrix(),
'H',A.make_Matrix());
38 Precision error = frobenius(C1.make_Matrix()-C2)/frobenius(C2);
39 myra::out() <<
"|A'A(sparse) - A'A(dense)| = " << error << std::endl;
40 myra::out() << C1.pattern() << std::endl;
41 REQUIRE(error < tolerance);
47 myra::out() << typestring<Number>() << std::endl;
51 auto C1 = multiply(A,B);
52 auto C2 = gemm(A.make_Matrix(),
'H',B.make_Matrix());
53 Precision error = frobenius(C1.make_Matrix()-C2)/frobenius(C2);
54 myra::out() <<
"|A'B(sparse) - A'B(dense)| = " << error << std::endl;
55 myra::out() << C1.pattern() << std::endl;
56 REQUIRE(error < tolerance);
61 ADD_TEST(
"multiply",
"[sparse]")
67 test1<NumberS>(Ai,Aj,An,1.0e-4f);
68 test1<NumberD>(Ai,Aj,An,1.0e-10);
69 test1<NumberC>(Ai,Aj,An,1.0e-4f);
70 test1<NumberZ>(Ai,Aj,An,1.0e-10);
75 test2<NumberS>(Ai,Aj,An,Bi,Bj,Bn,1.0e-4f);
76 test2<NumberD>(Ai,Aj,An,Bi,Bj,Bn,1.0e-10);
77 test2<NumberC>(Ai,Aj,An,Bi,Bj,Bn,1.0e-4f);
78 test2<NumberZ>(Ai,Aj,An,Bi,Bj,Bn,1.0e-10);
Routines to multiply "fat inner products" of SparseMatrix's, C = A'A and C = A'B. ...
Interface class for representing subranges of dense Matrix's.
Routines for computing Frobenius norms of various algebraic containers.
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.
General purpose dense matrix container, O(i*j) storage.
Range/Iterator types associated with Pattern.
Reflects Precision trait for a Number, scalar Number types should specialize it.
Definition: Number.h:33
Variety of routines all for dense Matrix*Matrix multiplies. Delegates to the BLAS.
Range/Iterator types associated with SparseMatrix.
float
|A'A(sparse) - A'A(dense)| = 4.35266e-08
size 10 by 10 Pattern:
[ x - x x - x - x x - ]
[ - x - - - x - - - - ]
[ x - x x x x x - x - ]
[ x - x x - - x - - - ]
[ - - x - x - - - x - ]
[ x x x - - x - - x - ]
[ - - x x - - x - - - ]
[ x - - - - - - x - - ]
[ x - x - x x - - x x ]
[ - - - - - - - - x x ]
double
|A'A(sparse) - A'A(dense)| = 0
size 10 by 10 Pattern:
[ x - - - - - x - - - ]
[ - x - x x x - x x x ]
[ - - - - - - - - - - ]
[ - x - x - x - - - x ]
[ - x - - x - - x - x ]
[ - x - x - x - - - - ]
[ x - - - - - x x - - ]
[ - x - - x - x x x x ]
[ - x - - - - - x x x ]
[ - x - x x - - x x x ]
std::complex<float>
|A'A(sparse) - A'A(dense)| = 5.35833e-08
size 10 by 10 Pattern:
[ x - - x - - - x - - ]
[ - x - - - - x - - x ]
[ - - x - - - - - x - ]
[ x - - x x - x x - x ]
[ - - - x x x x - x x ]
[ - - - - x x - - - - ]
[ - x - x x - x - x x ]
[ x - - x - - - x x x ]
[ - - x - x - x x x - ]
[ - x - x x - x x - x ]
std::complex<double>
|A'A(sparse) - A'A(dense)| = 9.69401e-17
size 10 by 10 Pattern:
[ x - - x - - - x - - ]
[ - x x - x x x - x x ]
[ - x x - x - x - - - ]
[ x - - x x - x x - - ]
[ - x x x x - x - - - ]
[ - x - - - x - - - - ]
[ - x x x x - x - x x ]
[ x - - x - - - x - x ]
[ - x - - - - x - x - ]
[ - x - - - - x x - x ]
float
|A'B(sparse) - A'B(dense)| = 6.48248e-09
size 10 by 15 Pattern:
[ - x - x - - - - - - - - - - x ]
[ - - - - - - x - - - - - - - - ]
[ - - - - - x - - - x x - - - x ]
[ x - - x - - x - - - - x - x x ]
[ - - - - - x - - - - - x - - x ]
[ - - - x - - x x x x x - - x - ]
[ - - - - - x - - - x x - - x x ]
[ x x - x - - x - - x x - - x x ]
[ - - - x - - - - - - - - - - - ]
[ - - - - - - - - - - - x - - - ]
double
|A'B(sparse) - A'B(dense)| = 0
size 10 by 15 Pattern:
[ x x - - x - x - x x x x x x x ]
[ x - - x - - - - - - - - - - - ]
[ - - - x - - - - - - - - - - - ]
[ - x x - x - - - - - - - - - x ]
[ - x x x x - x - - - - x - x x ]
[ - x - - x - - - - - - - - - x ]
[ x x - - x - - - - - - - - x x ]
[ x x - - - - - - x x x x x - - ]
[ - x x x - - x - - - x - - x - ]
[ - - - - - - - - - - - - - - - ]
std::complex<float>
|A'B(sparse) - A'B(dense)| = 2.07961e-08
size 10 by 15 Pattern:
[ x - - - - - - - - - - - - - - ]
[ x - - - - - - x - - x - x - - ]
[ - - - - - - - x - - x - x - x ]
[ - - - - - - - x - - x - - - - ]
[ - - x - - - - x - - - - - - - ]
[ x - - - - - - x - - x - - - - ]
[ - - x - - - - - - x - x x - x ]
[ - - - - - - - - - - - - - - - ]
[ - - - - - - - - - - - x - - - ]
[ - - - - - - - x - - x - x - x ]
std::complex<double>
|A'B(sparse) - A'B(dense)| = 2.64554e-17
size 10 by 15 Pattern:
[ - - - x - - - x - - x - x - - ]
[ - - x - x - - - - x x - - - - ]
[ - x - - - x - x - - x - x x - ]
[ - - x - x x - - - - x - - - - ]
[ - x - - - - - - - x x - - x - ]
[ - x x - x - - x - x x - x x - ]
[ - x - x - x - - - - - x - - - ]
[ - - - - - x - - - x - - - - - ]
[ - x - - - x - - - x x - - x - ]
[ - - - - - - - - - - - - - - - ]