Small fix
parent
b7f29a051a
commit
fbebd3ed69
|
|
@ -70,9 +70,7 @@ class AcceleratedPowerMethod : public PowerMethod<Operator> {
|
|||
|
||||
// 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
|
||||
|
|
|
|||
|
|
@ -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<double> 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_;
|
||||
|
|
|
|||
|
|
@ -76,7 +76,10 @@ TEST(AcceleratedPowerMethod, useFactorGraph) {
|
|||
|
||||
// Get eigenvalues and eigenvectors with Eigen
|
||||
auto L = fg.hessian();
|
||||
cout << L.first << endl;
|
||||
Eigen::EigenSolver<Matrix> 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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue