From abfc98e13d738c4ac4e97147e52a2cacecd7347c Mon Sep 17 00:00:00 2001 From: jingwuOUO Date: Mon, 2 Nov 2020 15:39:39 -0500 Subject: [PATCH] Fixed forcing comparing eigenvector. --- gtsam/linear/tests/testPowerMethod.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gtsam/linear/tests/testPowerMethod.cpp b/gtsam/linear/tests/testPowerMethod.cpp index ccac4556c..2e0f2152b 100644 --- a/gtsam/linear/tests/testPowerMethod.cpp +++ b/gtsam/linear/tests/testPowerMethod.cpp @@ -82,14 +82,15 @@ TEST(PowerMethod, useFactorGraph) { } // Store the max eigenvalue and its according eigenvector const auto ev1 = solver.eigenvalues()(maxIdx).real(); - auto ev2 = solver.eigenvectors().col(maxIdx).real(); Vector initial = Vector4::Random(); PowerMethod pf(L.first, initial); - pf.compute(50, 1e-4); + pf.compute(100, 1e-5); EXPECT_DOUBLES_EQUAL(ev1, pf.eigenvalue(), 1e-8); auto actual2 = pf.eigenvector(); - EXPECT(assert_equal(ev2, actual2, 3e-5)); + const double ritzValue = actual2.dot(L.first * actual2); + const double ritzResidual = (L.first * actual2 - ritzValue * actual2).norm(); + EXPECT_DOUBLES_EQUAL(0, ritzResidual, 1e-5); } /* ************************************************************************* */