Fixed some SVD issues.

Make the SVD's output unitary.
Improved unit tests.
Added an assert to the SVD ctor to check whether rows>=cols.
This commit is contained in:
Hauke Heibel 2010-09-24 17:32:44 +02:00
parent 053261de88
commit 316dadc8e4
3 changed files with 3132 additions and 3130 deletions

View File

@ -83,11 +83,14 @@ template<typename _MatrixType> class SVD
* \sa JacobiSVD()
*/
SVD(Index rows, Index cols) : m_matU(rows, rows),
m_matV(cols,cols),
m_sigma(std::min(rows, cols)),
m_workMatrix(rows, cols),
m_rv1(cols),
m_isInitialized(false) {}
m_matV(cols,cols),
m_sigma(std::min(rows, cols)),
m_workMatrix(rows, cols),
m_rv1(cols),
m_isInitialized(false)
{
ei_assert(rows >= cols && "SVD is only defined if rows>=cols.");
}
SVD(const MatrixType& matrix) : m_matU(matrix.rows(), matrix.rows()),
m_matV(matrix.cols(),matrix.cols()),

View File

@ -95,6 +95,8 @@ template<typename MatrixType> void svd_verify_assert()
VERIFY_RAISES_ASSERT(svd.computePositiveUnitary(&tmp,&tmp))
VERIFY_RAISES_ASSERT(svd.computeRotationScaling(&tmp,&tmp))
VERIFY_RAISES_ASSERT(svd.computeScalingRotation(&tmp,&tmp))
VERIFY_RAISES_ASSERT(SVD<MatrixXf>(10, 20))
}
void test_svd()
@ -116,7 +118,4 @@ void test_svd()
CALL_SUBTEST_2( svd_verify_assert<Matrix4d>() );
CALL_SUBTEST_3( svd_verify_assert<MatrixXf>() );
CALL_SUBTEST_4( svd_verify_assert<MatrixXd>() );
// Test problem size constructors
CALL_SUBTEST_9( SVD<MatrixXf>(10, 20) );
}

File diff suppressed because it is too large Load Diff