gtsam/gtsam_unstable/linear/iterative.cpp

72 lines
2.6 KiB
C++
Raw Normal View History

/* ----------------------------------------------------------------------------
* GTSAM Copyright 2010, Georgia Tech Research Corporation,
* Atlanta, Georgia 30332-0415
* All Rights Reserved
* Authors: Frank Dellaert, et al. (see THANKS for the full author list)
* See LICENSE for the license information
* -------------------------------------------------------------------------- */
/**
* @file iterative.cpp
2009-12-28 17:56:58 +08:00
* @brief Iterative methods, implementation
* @author Frank Dellaert
* @date Dec 28, 2009
2009-12-28 17:56:58 +08:00
*/
2012-06-04 04:45:00 +08:00
#include <gtsam_unstable/linear/iterative-inl.h>
#include <gtsam/base/Vector.h>
#include <gtsam/base/Matrix.h>
2012-06-07 10:11:16 +08:00
#include <gtsam/linear/JacobianFactorGraph.h>
2012-06-09 00:45:16 +08:00
#include <gtsam/linear/IterativeSolver.h>
2012-06-04 04:45:00 +08:00
#include <iostream>
2009-12-28 17:56:58 +08:00
using namespace std;
namespace gtsam {
/* ************************************************************************* */
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
/* ************************************************************************* */
2012-06-09 00:45:16 +08:00
Vector steepestDescent(const System& Ab, const Vector& x, const ConjugateGradientParameters & parameters) {
return conjugateGradients<System, Vector, Vector> (Ab, x, parameters, true);
}
2012-06-09 00:45:16 +08:00
Vector conjugateGradientDescent(const System& Ab, const Vector& x, const ConjugateGradientParameters & parameters) {
return conjugateGradients<System, Vector, Vector> (Ab, x, parameters);
2009-12-28 17:56:58 +08:00
}
/* ************************************************************************* */
2012-06-09 00:45:16 +08:00
Vector steepestDescent(const Matrix& A, const Vector& b, const Vector& x, const ConjugateGradientParameters & parameters) {
System Ab(A, b);
return conjugateGradients<System, Vector, Vector> (Ab, x, parameters, true);
}
2012-06-09 00:45:16 +08:00
Vector conjugateGradientDescent(const Matrix& A, const Vector& b, const Vector& x, const ConjugateGradientParameters & parameters) {
System Ab(A, b);
return conjugateGradients<System, Vector, Vector> (Ab, x, parameters);
2009-12-28 17:56:58 +08:00
}
/* ************************************************************************* */
2012-06-09 00:45:16 +08:00
VectorValues steepestDescent(const FactorGraph<JacobianFactor>& fg, const VectorValues& x, const ConjugateGradientParameters & parameters) {
return conjugateGradients<FactorGraph<JacobianFactor>, VectorValues, Errors> (fg, x, parameters, true);
}
2012-06-09 00:45:16 +08:00
VectorValues conjugateGradientDescent(const FactorGraph<JacobianFactor>& fg, const VectorValues& x, const ConjugateGradientParameters & parameters) {
return conjugateGradients<FactorGraph<JacobianFactor>, VectorValues, Errors> (fg, x, parameters);
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