24 #include <tests/myratest.h> 33 myra::out() <<
"test1 " << typestring<Number>() << std::endl;
37 A.transform_diagonal([](
const Number& a){
return realpart(a);});
39 auto B1 = hemm(
'L',
'U',A,X);
40 auto B2 = hemm(
'L',
'U',A.make_Matrix(),X);
41 Precision B_error = frobenius(B1-B2);
42 auto C1 = hemm(
'L',
'L',A,X);
43 auto C2 = hemm(
'L',
'L',A.make_Matrix(),X);
44 Precision C_error = frobenius(C1-C2);
45 myra::out() <<
" error in hemm('L','U') = " << B_error << std::endl;
46 myra::out() <<
" error in hemm('L','L') = " << C_error << std::endl;
47 REQUIRE(B_error < tolerance);
48 REQUIRE(C_error < tolerance);
54 myra::out() <<
"test2 " << typestring<Number>() << std::endl;
58 A.transform_diagonal([](
const Number& a){
return realpart(a);});
60 auto B1 = hemm(
'R',
'U',A,X);
61 auto B2 = hemm(
'R',
'U',A.make_Matrix(),X);
62 Precision B_error = frobenius(B1-B2);
63 auto C1 = hemm(
'R',
'L',A,X);
64 auto C2 = hemm(
'R',
'L',A.make_Matrix(),X);
65 Precision C_error = frobenius(C1-C2);
66 myra::out() <<
" error in hemm('R','U') = " << B_error << std::endl;
67 myra::out() <<
" error in hemm('R','L') = " << C_error << std::endl;
68 REQUIRE(B_error < tolerance);
69 REQUIRE(C_error < tolerance);
74 ADD_TEST(
"sparse_hemm",
"[sparse]")
77 test1<NumberS>(15,40,8,1.0e-4f);
78 test1<NumberD>(15,40,8,1.0e-9);
79 test1<NumberC>(15,40,8,1.0e-4f);
80 test1<NumberZ>(15,40,8,1.0e-9);
82 test2<NumberS>(15,40,8,1.0e-4f);
83 test2<NumberD>(15,40,8,1.0e-9);
84 test2<NumberC>(15,40,8,1.0e-4f);
85 test2<NumberZ>(15,40,8,1.0e-9);
Interface class for representing subranges of dense Matrix's.
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 hermitian Matrix * dense Matrix multiplication.
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.
Various utility functions/classes related to scalar Number types.
Routines for hermitian SparseMatrix * dense Matrix multiplication.
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
Range/Iterator types associated with SparseMatrix.
test1 float
error in hemm('L','U') = 1.2495e-07
error in hemm('L','L') = 3.51724e-07
test1 double
error in hemm('L','U') = 2.83817e-16
error in hemm('L','L') = 3.6817e-16
test1 std::complex<float>
error in hemm('L','U') = 5.19281e-07
error in hemm('L','L') = 5.62858e-07
test1 std::complex<double>
error in hemm('L','U') = 1.06808e-15
error in hemm('L','L') = 1.1866e-15
test2 float
error in hemm('R','U') = 3.08221e-07
error in hemm('R','L') = 2.27604e-07
test2 double
error in hemm('R','U') = 3.39066e-16
error in hemm('R','L') = 4.11565e-16
test2 std::complex<float>
error in hemm('R','U') = 0
error in hemm('R','L') = 5.02576e-07
test2 std::complex<double>
error in hemm('R','U') = 0
error in hemm('R','L') = 0