diff --git a/gtsam/linear/AcceleratedPowerMethod.h b/gtsam/linear/AcceleratedPowerMethod.h index 2cbcaf67e..0e47c6a53 100644 --- a/gtsam/linear/AcceleratedPowerMethod.h +++ b/gtsam/linear/AcceleratedPowerMethod.h @@ -70,9 +70,7 @@ class AcceleratedPowerMethod : public PowerMethod { // initialize Ritz eigen vector and previous vector previousVector_ = update(x0, x00, beta_); - this->updateRitz(update(previousVector_, x0, beta_)); this->ritzVector_ = update(previousVector_, x0, beta_); - // this->updateRitz(update(previousVector_, x0, beta_)); this->perturb(); // set beta diff --git a/gtsam/linear/PowerMethod.h b/gtsam/linear/PowerMethod.h index fe9aabb46..4807e0e6a 100644 --- a/gtsam/linear/PowerMethod.h +++ b/gtsam/linear/PowerMethod.h @@ -75,11 +75,9 @@ class PowerMethod { return y; } + // Update the vector by dot product with A_ Vector update() const { return update(ritzVector_); } - // Update the ritzVector_ - void updateRitz(const Vector &ritz) { ritzVector_ = ritz; } - // Perturb the initial ritzvector void perturb() { // generate a 0.03*||x_0||_2 as stated in David's paper @@ -87,10 +85,11 @@ class PowerMethod { std::uniform_real_distribution uniform01(0.0, 1.0); int n = dim_; - Vector disturb(n); - for (int i = 0; i < n; ++i) { - disturb(i) = uniform01(rng); - } + // Vector disturb(n); + // for (int i = 0; i < n; ++i) { + // disturb(i) = uniform01(rng); + // } + Vector disturb = Vector::Random(n); disturb.normalize(); Vector x0 = ritzVector_; diff --git a/gtsam/linear/tests/testAcceleratedPowerMethod.cpp b/gtsam/linear/tests/testAcceleratedPowerMethod.cpp index 2a117d53b..a84a31a0f 100644 --- a/gtsam/linear/tests/testAcceleratedPowerMethod.cpp +++ b/gtsam/linear/tests/testAcceleratedPowerMethod.cpp @@ -76,7 +76,10 @@ TEST(AcceleratedPowerMethod, useFactorGraph) { // Get eigenvalues and eigenvectors with Eigen auto L = fg.hessian(); + cout << L.first << endl; Eigen::EigenSolver solver(L.first); + cout << solver.eigenvalues() << endl; + cout << solver.eigenvectors() << endl; // Check that we get zero eigenvalue and "constant" eigenvector EXPECT_DOUBLES_EQUAL(0.0, solver.eigenvalues()[0].real(), 1e-9);