* 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.
This commit is contained in:
Benoit Jacob 2009-10-23 18:05:55 -04:00
parent e17e4f3654
commit 46f0fe3b4b
2 changed files with 6 additions and 0 deletions

View File

@ -61,6 +61,8 @@ template<typename MatrixType> 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<MatrixType>::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();

View File

@ -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<MatrixXf> s;
MatrixXf m = MatrixXf::Random(10,1);
s.compute(m);
}
}