mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-07-25 06:14:26 +08:00
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.
This commit is contained in:
parent
e17e4f3654
commit
46f0fe3b4b
@ -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();
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user