26 #include <tests/myratest.h> 32 template<
class Precision>
void test(
int N, Precision tolerance)
34 myra::out() << typestring<Precision>() << std::endl;
40 const auto& X = XD.first;
41 const auto& D = XD.second;
44 Precision R_error = frobenius(A-X*D*transpose(X))/frobenius(D);
45 myra::out() <<
" |A-X*D*X'| = " << R_error << std::endl;
47 Precision X_error = frobenius(gemm(X,
'T',X)-I)/N;
48 myra::out() <<
" |X'*X -I| = " << X_error << std::endl;
53 Precision Xk_error = frobenius(gemm(Xk,
'T',Xk)-Ik)/N;
54 myra::out() <<
" |Xk'Xk-Ik| = " << Xk_error << std::endl;
57 for (
int n = 0; n < N-1; ++n)
58 sorted &= D(n) <= D(n+1);
59 myra::out() << std::boolalpha;
60 myra::out() <<
" sorted D(n) <= D(n+1) = " << sorted << std::endl;
62 REQUIRE(R_error < tolerance);
63 REQUIRE(X_error < tolerance);
64 REQUIRE(Xk_error < tolerance);
71 ADD_TEST(
"ssyev",
"[dense][lapack]")
72 { test<float>(50,1.0e-4f); }
75 ADD_TEST(
"ssyev_stress",
"[dense][lapack][.]")
79 for (
int n = 1; n < N; ++n)
80 for (
int t = 0; t < T; ++t)
81 test<float>(n,1.0e-4f);
85 ADD_TEST(
"dsyev",
"[dense][lapack]")
86 { test<double>(50,1.0e-12); }
89 ADD_TEST(
"dsyev_stress",
"[dense][lapack][.]")
93 for (
int n = 1; n < N; ++n)
94 for (
int t = 0; t < T; ++t)
95 test<double>(n,1.0e-12);
Interface class for representing subranges of DiagonalMatrix's.
Computes all eigenpairs of real symmetric Matrix.
Interface class for representing subranges of dense Matrix's.
MatrixRange< Number > left(int j) const
Returns the j leftmost columns, this(:,0:j)
Definition: MatrixRange.cpp:223
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.
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.
static Matrix< Number > identity(int IJ)
Generates an identity Matrix of specified size.
Definition: Matrix.cpp:349
General purpose dense matrix container, O(i*j) storage.
Container for a diagonal matrix, O(n) storage. Used by SVD, row/column scaling, etc.
Variety of routines all for dense Matrix*Matrix multiplies. Delegates to the BLAS.