From 46f0fe3b4b2ba36328543b5215a3c13f4f570c84 Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Fri, 23 Oct 2009 18:05:55 -0400 Subject: [PATCH] SVD: * implement default ctor, users were relying on the compiler generater one and reported issues on the forum * turns out that we crash on 1x1 matrices but work on Nx1. No interest in fixing that, so just guard by assert and unit test. --- Eigen/src/SVD/SVD.h | 3 +++ test/svd.cpp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/Eigen/src/SVD/SVD.h b/Eigen/src/SVD/SVD.h index d117c1583..da43cc9ca 100644 --- a/Eigen/src/SVD/SVD.h +++ b/Eigen/src/SVD/SVD.h @@ -61,6 +61,8 @@ template class SVD public: + SVD() {} // a user who relied on compiler-generated default compiler reported problems with MSVC in 2.0.7 + SVD(const MatrixType& matrix) : m_matU(matrix.rows(), std::min(matrix.rows(), matrix.cols())), m_matV(matrix.cols(),matrix.cols()), @@ -108,6 +110,7 @@ void SVD::compute(const MatrixType& matrix) const int n = matrix.cols(); const int nu = std::min(m,n); ei_assert(m>=n && "In Eigen 2.0, SVD only works for MxN matrices with M>=N. Sorry!"); + ei_assert(m>1 && "In Eigen 2.0, SVD doesn't work on 1x1 matrices"); m_matU.resize(m, nu); m_matU.setZero(); diff --git a/test/svd.cpp b/test/svd.cpp index 688c3f402..3158782d8 100644 --- a/test/svd.cpp +++ b/test/svd.cpp @@ -95,5 +95,8 @@ void test_svd() // complex are not implemented yet // CALL_SUBTEST( svd(MatrixXcd(6,6)) ); // CALL_SUBTEST( svd(MatrixXcf(3,3)) ); + SVD s; + MatrixXf m = MatrixXf::Random(10,1); + s.compute(m); } }