aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/svd_common.h
diff options
context:
space:
mode:
authorGravatar Patrick Peltzer <peltzer@stce.rwth-aachen.de>2019-01-17 01:17:39 +0100
committerGravatar Patrick Peltzer <peltzer@stce.rwth-aachen.de>2019-01-17 01:17:39 +0100
commit15e53d5d93bd79fa415416d3f979975f0014a64d (patch)
treeccc062d964f707c9c1c250965490d87fbc145885 /test/svd_common.h
parent7f32109c11b9cbc3cedc72e59683bf5839d35d75 (diff)
PR 567: makes all dense solvers inherit SoverBase (LU,Cholesky,QR,SVD).
This changeset also includes: * add HouseholderSequence::conjugateIf * define int as the StorageIndex type for all dense solvers * dedicated unit tests, including assertion checking * _check_solve_assertion(): this method can be implemented in derived solver classes to implement custom checks * CompleteOrthogonalDecompositions: add applyZOnTheLeftInPlace, fix scalar type in applyZAdjointOnTheLeftInPlace(), add missing assertions * Cholesky: add missing assertions * FullPivHouseholderQR: Corrected Scalar type in _solve_impl() * BDCSVD: Unambiguous return type for ternary operator * SVDBase: Corrected Scalar type in _solve_impl()
Diffstat (limited to 'test/svd_common.h')
-rw-r--r--test/svd_common.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/svd_common.h b/test/svd_common.h
index cba066593..5c0f2a0e4 100644
--- a/test/svd_common.h
+++ b/test/svd_common.h
@@ -17,6 +17,7 @@
#endif
#include "svd_fill.h"
+#include "solverbase.h"
// Check that the matrix m is properly reconstructed and that the U and V factors are unitary
// The SVD must have already been computed.
@@ -219,12 +220,33 @@ void svd_min_norm(const MatrixType& m, unsigned int computationOptions)
VERIFY_IS_APPROX(x21, x3);
}
+template<typename MatrixType, typename SolverType>
+void svd_test_solvers(const MatrixType& m, const SolverType& solver) {
+ Index rows, cols, cols2;
+
+ rows = m.rows();
+ cols = m.cols();
+
+ if(MatrixType::ColsAtCompileTime==Dynamic)
+ {
+ cols2 = internal::random<int>(2,EIGEN_TEST_MAX_SIZE);
+ }
+ else
+ {
+ cols2 = cols;
+ }
+ typedef Matrix<typename MatrixType::Scalar, MatrixType::ColsAtCompileTime, MatrixType::ColsAtCompileTime> CMatrixType;
+ check_solverbase<CMatrixType, MatrixType>(m, solver, rows, cols, cols2);
+}
+
// Check full, compare_to_full, least_square, and min_norm for all possible compute-options
template<typename SvdType, typename MatrixType>
void svd_test_all_computation_options(const MatrixType& m, bool full_only)
{
// if (QRPreconditioner == NoQRPreconditioner && m.rows() != m.cols())
// return;
+ STATIC_CHECK(( internal::is_same<typename SvdType::StorageIndex,int>::value ));
+
SvdType fullSvd(m, ComputeFullU|ComputeFullV);
CALL_SUBTEST(( svd_check_full(m, fullSvd) ));
CALL_SUBTEST(( svd_least_square<SvdType>(m, ComputeFullU | ComputeFullV) ));
@@ -234,6 +256,9 @@ void svd_test_all_computation_options(const MatrixType& m, bool full_only)
// remark #111: statement is unreachable
#pragma warning disable 111
#endif
+
+ svd_test_solvers(m, fullSvd);
+
if(full_only)
return;
@@ -448,6 +473,8 @@ void svd_verify_assert(const MatrixType& m)
VERIFY_RAISES_ASSERT(svd.singularValues())
VERIFY_RAISES_ASSERT(svd.matrixV())
VERIFY_RAISES_ASSERT(svd.solve(rhs))
+ VERIFY_RAISES_ASSERT(svd.transpose().solve(rhs))
+ VERIFY_RAISES_ASSERT(svd.adjoint().solve(rhs))
MatrixType a = MatrixType::Zero(rows, cols);
a.setZero();
svd.compute(a, 0);