Loading...
Searching...
No Matches
iterative.h
Go to the documentation of this file.
/* ----------------------------------------------------------------------------
* 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
* -------------------------------------------------------------------------- */
#pragma once
#include <gtsam/base/Matrix.h>
#include <gtsam/linear/VectorValues.h>
#include <gtsam/linear/ConjugateGradientSolver.h>
namespace gtsam {
template<class S, class V, class E>
V conjugateGradients(const S& Ab, V x,
const ConjugateGradientParameters &parameters, bool steepest = false);
class GTSAM_EXPORT System {
private:
const Matrix& A_;
const Vector& b_;
public:
System(const Matrix& A, const Vector& b) :
A_(A), b_(b) {
}
const Matrix& A() const { return A_; }
const Vector& b() const { return b_; }
Vector operator^(const Vector& e) const {
return A_ ^ e;
}
void print (const std::string& s = "System") const;
Vector gradient(const Vector& x) const {
return A() ^ (A() * x - b());
}
Vector operator*(const Vector& x) const {
return A() * x;
}
void multiplyInPlace(const Vector& x, Vector& e) const {
e = A() * x;
}
void transposeMultiplyAdd(double alpha, const Vector& e, Vector& x) const {
x += alpha * A().transpose() * e;
}
};
GTSAM_EXPORT Vector steepestDescent(
const System& Ab,
const Vector& x,
const IterativeOptimizationParameters & parameters);
GTSAM_EXPORT Vector conjugateGradientDescent(
const System& Ab,
const Vector& x,
const ConjugateGradientParameters & parameters);
GTSAM_EXPORT Vector steepestDescent(
const Matrix& A,
const Vector& b,
const Vector& x,
const ConjugateGradientParameters & parameters);
GTSAM_EXPORT Vector conjugateGradientDescent(
const Matrix& A,
const Vector& b,
const Vector& x,
const ConjugateGradientParameters & parameters);
GTSAM_EXPORT VectorValues steepestDescent(
const GaussianFactorGraph& fg,
const VectorValues& x,
const ConjugateGradientParameters & parameters);
GTSAM_EXPORT VectorValues conjugateGradientDescent(
const GaussianFactorGraph& fg,
const VectorValues& x,
const ConjugateGradientParameters & parameters);
} // namespace gtsam
#include <gtsam/linear/iterative-inl.h>
Matrix.h
typedef and functions to augment Eigen's MatrixXd
iterative-inl.h
Iterative methods, template implementation.
ConjugateGradientSolver.h
Implementation of Conjugate Gradient solver for a linear system.
VectorValues.h
Factor Graph Values.
gtsam
Global functions in a separate testing namespace.
Definition chartTesting.h:28
gtsam::print
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition Matrix.cpp:156
gtsam::conjugateGradients
V conjugateGradients(const S &Ab, V x, const ConjugateGradientParameters &parameters, bool steepest)
Method of conjugate gradients (CG) template "System" class S needs gradient(S,v), e=S*v,...
Definition iterative-inl.h:125
gtsam::conjugateGradientDescent
Vector conjugateGradientDescent(const System &Ab, const Vector &x, const ConjugateGradientParameters &parameters)
Method of conjugate gradients (CG), System version.
Definition iterative.cpp:45
gtsam::ConjugateGradientParameters
parameters for the conjugate gradient method
Definition ConjugateGradientSolver.h:29
gtsam::GaussianFactorGraph
A Linear Factor Graph is a factor graph where all factors are Gaussian, i.e.
Definition GaussianFactorGraph.h:75
gtsam::System
Helper class encapsulating the combined system |Ax-b_|^2 Needed to run Conjugate Gradients on matrice...
Definition iterative.h:44
gtsam::System::operator*
Vector operator*(const Vector &x) const
Apply operator A.
Definition iterative.h:78
gtsam::System::A
const Matrix & A() const
Access A matrix.
Definition iterative.h:57
gtsam::System::multiplyInPlace
void multiplyInPlace(const Vector &x, Vector &e) const
Apply operator A in place.
Definition iterative.h:83
gtsam::System::b
const Vector & b() const
Access b vector.
Definition iterative.h:60
gtsam::System::gradient
Vector gradient(const Vector &x) const
gradient of objective function 0.5*|Ax-b_|^2 at x = A_'*(Ax-b_)
Definition iterative.h:73
gtsam::System::transposeMultiplyAdd
void transposeMultiplyAdd(double alpha, const Vector &e, Vector &x) const
x += alpha* A'*e
Definition iterative.h:88
gtsam::System::operator^
Vector operator^(const Vector &e) const
Apply operator A'*e.
Definition iterative.h:63
gtsam::IterativeOptimizationParameters
parameters for iterative linear solvers
Definition IterativeSolver.h:44
gtsam::VectorValues
VectorValues represents a collection of vector-valued variables associated each with a unique integer...
Definition VectorValues.h:74