2009-12-28 17:56:58 +08:00
|
|
|
/*
|
|
|
|
|
* iterative.cpp
|
|
|
|
|
* @brief Iterative methods, implementation
|
|
|
|
|
* @author Frank Dellaert
|
|
|
|
|
* Created on: Dec 28, 2009
|
|
|
|
|
*/
|
2010-01-11 16:32:59 +08:00
|
|
|
#include <iostream>
|
2009-12-28 17:56:58 +08:00
|
|
|
|
2010-01-11 16:32:59 +08:00
|
|
|
#include "Vector.h"
|
|
|
|
|
#include "Matrix.h"
|
2009-12-28 17:56:58 +08:00
|
|
|
#include "GaussianFactorGraph.h"
|
2009-12-29 00:26:16 +08:00
|
|
|
#include "iterative-inl.h"
|
2009-12-28 17:56:58 +08:00
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
namespace gtsam {
|
|
|
|
|
|
2010-01-11 16:32:59 +08:00
|
|
|
/* ************************************************************************* */
|
|
|
|
|
void System::print (const string& s) const {
|
|
|
|
|
cout << s << endl;
|
|
|
|
|
gtsam::print(A_, "A");
|
|
|
|
|
gtsam::print(b_, "b");
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-28 17:56:58 +08:00
|
|
|
/* ************************************************************************* */
|
2009-12-29 00:15:26 +08:00
|
|
|
Vector steepestDescent(const System& Ab, const Vector& x, bool verbose,
|
2010-01-11 16:32:59 +08:00
|
|
|
double epsilon, double epsilon_abs, size_t maxIterations) {
|
2009-12-29 00:15:26 +08:00
|
|
|
return conjugateGradients<System, Vector, Vector> (Ab, x, verbose, epsilon,
|
2010-01-11 16:32:59 +08:00
|
|
|
epsilon_abs, maxIterations, true);
|
2009-12-28 20:37:34 +08:00
|
|
|
}
|
|
|
|
|
|
2009-12-28 17:56:58 +08:00
|
|
|
Vector conjugateGradientDescent(const System& Ab, const Vector& x,
|
2010-01-11 16:32:59 +08:00
|
|
|
bool verbose, double epsilon, double epsilon_abs, size_t maxIterations) {
|
2009-12-29 00:15:26 +08:00
|
|
|
return conjugateGradients<System, Vector, Vector> (Ab, x, verbose, epsilon,
|
2010-01-11 16:32:59 +08:00
|
|
|
epsilon_abs, maxIterations);
|
2009-12-28 17:56:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ************************************************************************* */
|
2009-12-28 20:37:34 +08:00
|
|
|
Vector steepestDescent(const Matrix& A, const Vector& b, const Vector& x,
|
2010-01-11 16:32:59 +08:00
|
|
|
bool verbose, double epsilon, double epsilon_abs, size_t maxIterations) {
|
2009-12-29 01:28:48 +08:00
|
|
|
System Ab(A, b);
|
2009-12-29 00:15:26 +08:00
|
|
|
return conjugateGradients<System, Vector, Vector> (Ab, x, verbose, epsilon,
|
2010-01-11 16:32:59 +08:00
|
|
|
epsilon_abs, maxIterations, true);
|
2009-12-28 20:37:34 +08:00
|
|
|
}
|
|
|
|
|
|
2009-12-28 17:56:58 +08:00
|
|
|
Vector conjugateGradientDescent(const Matrix& A, const Vector& b,
|
2010-01-11 16:32:59 +08:00
|
|
|
const Vector& x, bool verbose, double epsilon, double epsilon_abs, size_t maxIterations) {
|
2009-12-29 01:28:48 +08:00
|
|
|
System Ab(A, b);
|
2009-12-29 00:15:26 +08:00
|
|
|
return conjugateGradients<System, Vector, Vector> (Ab, x, verbose, epsilon,
|
2010-01-11 16:32:59 +08:00
|
|
|
epsilon_abs, maxIterations);
|
2009-12-28 17:56:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ************************************************************************* */
|
2009-12-28 20:37:34 +08:00
|
|
|
VectorConfig steepestDescent(const GaussianFactorGraph& fg,
|
2010-01-11 16:32:59 +08:00
|
|
|
const VectorConfig& x, bool verbose, double epsilon, double epsilon_abs, size_t maxIterations) {
|
2009-12-28 20:37:34 +08:00
|
|
|
return conjugateGradients<GaussianFactorGraph, VectorConfig, Errors> (fg,
|
2010-01-11 16:32:59 +08:00
|
|
|
x, verbose, epsilon, epsilon_abs, maxIterations, true);
|
2009-12-28 20:37:34 +08:00
|
|
|
}
|
|
|
|
|
|
2009-12-28 17:56:58 +08:00
|
|
|
VectorConfig conjugateGradientDescent(const GaussianFactorGraph& fg,
|
2010-01-11 16:32:59 +08:00
|
|
|
const VectorConfig& x, bool verbose, double epsilon, double epsilon_abs, size_t maxIterations) {
|
2009-12-28 20:37:34 +08:00
|
|
|
return conjugateGradients<GaussianFactorGraph, VectorConfig, Errors> (fg,
|
2010-01-11 16:32:59 +08:00
|
|
|
x, verbose, epsilon, epsilon_abs, maxIterations);
|
2009-12-28 17:56:58 +08:00
|
|
|
}
|
|
|
|
|
|
2009-12-31 20:55:16 +08:00
|
|
|
/* ************************************************************************* */
|
2009-12-28 17:56:58 +08:00
|
|
|
|
|
|
|
|
} // namespace gtsam
|