30 #include <tests/myratest.h> 39 myra::out() << typestring<Precision>() << std::endl;
43 for (
int n = 0; n < N; ++n)
45 for (
int n = 0; n < N-1; ++n)
48 auto UVt = bdsqr_inplace(B0,B1);
53 Precision R_error = frobenius(B-U*S*Vt)/frobenius(S);
54 myra::out() <<
" |B-U*S*V'| = " << R_error << std::endl;
57 Precision U_error = frobenius(gemm(U,
'T',U)-I)/N;
58 Precision V_error = frobenius(gemm(Vt,Vt,
'T')-I)/N;
59 myra::out() <<
" |U'U-I| = " << U_error << std::endl;
60 myra::out() <<
" |VV'-I| = " << V_error << std::endl;
66 Precision Uk_error = frobenius(gemm(Uk,
'T',Uk)-Ik)/N;
67 Precision Vk_error = frobenius(gemm(Vk,Vk,
'T')-Ik)/N;
68 myra::out() <<
" |Uk'Uk-Ik| = " << Uk_error << std::endl;
69 myra::out() <<
" |Vk'Vk-Ik| = " << Vk_error << std::endl;
72 for (
int n = 0; n < N; ++n)
73 positive &= S(n) >= 0;
74 myra::out() << std::boolalpha;
75 myra::out() <<
" positive S >= 0 = " << positive << std::endl;
78 for (
int n = 0; n < N-1; ++n)
79 sorted &= S(n) >= S(n+1);
80 myra::out() << std::boolalpha;
81 myra::out() <<
" sorted S(n) >= S(n+1) = " << sorted << std::endl;
82 myra::out() << std::endl;
84 REQUIRE(R_error < tolerance);
85 REQUIRE(U_error < tolerance);
86 REQUIRE(V_error < tolerance);
87 REQUIRE(Uk_error < tolerance);
88 REQUIRE(Vk_error < tolerance);
94 template<
class Precision>
void test_random(
int N, Precision tolerance)
98 test_detail(B0,B1,tolerance);
102 template<
class Precision>
void test_split0(
int N,
int S, Precision tolerance)
107 test_detail(B0,B1,tolerance);
111 template<
class Precision>
void test_split1(
int N,
int S, Precision tolerance)
116 test_detail(B0,B1,tolerance);
122 ADD_TEST(
"sbdsqr",
"[dense][lapack]")
123 { test_random<float>(50,1.0e-4f); }
126 ADD_TEST(
"sbdsqr_split0",
"[dense][lapack]")
127 { test_split0<float>(100,27,1.0e-4f); }
130 ADD_TEST(
"sbdsqr_split1",
"[dense][lapack]")
131 { test_split1<float>(100,27,1.0e-4f); }
134 ADD_TEST(
"sbdsqr_stress",
"[dense][lapack][.]")
138 for (
int n = 1; n < N; ++n)
139 for (
int t = 0; t < T; ++t)
140 test_random<float>(n,1.0e-4f);
144 ADD_TEST(
"dbdsqr",
"[dense][lapack]")
145 { test_random<double>(10,1.0e-12); }
148 ADD_TEST(
"dbdsqr_split0",
"[dense][lapack]")
149 { test_split0<double>(100,27,1.0e-12); }
152 ADD_TEST(
"dbdsqr_split1",
"[dense][lapack]")
153 { test_split1<double>(100,27,1.0e-12); }
156 ADD_TEST(
"dbdsqr_stress",
"[dense][lapack][.]")
160 for (
int n = 1; n < N; ++n)
161 for (
int t = 0; t < T; ++t)
162 test_random<double>(n,1.0e-12);
Interface class for representing subranges of DiagonalMatrix's.
Interface class for representing subranges of dense Matrix's.
Interface class for representing subranges of dense Vector's.
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.
Replaces small values with explicit zeros.
Routines for multiplying by a DiagonalMatrix.
static Vector< Number > random(int N)
Generates a random Vector of specified size.
Definition: Vector.cpp:276
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.
int size() const
Size inspector.
Definition: Vector.cpp:118
Tabulates a vector of length N, allows random access.
Definition: conjugate.h:21
Container for either a column vector or row vector (depends upon the usage context) ...
Returns the diagonal of a dense Matrix or LowerMatrix.
CMatrixRange< Number > left(int j) const
Returns a MatrixRange over the j leftmost columns, this(:,0:j)
Definition: Matrix.cpp:263
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.
Computes all singular triples (u,s,v) of a real bidiagonal matrix.
CMatrixRange< Number > top(int i) const
Returns a MatrixRange over the i topmost rows, this(0:i,:)
Definition: Matrix.cpp:207