iterative.h
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3  * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4  * Atlanta, Georgia 30332-0415
5  * All Rights Reserved
6  * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7 
8  * See LICENSE for the license information
9 
10  * -------------------------------------------------------------------------- */
11 
19 #pragma once
20 
21 #include <gtsam/base/Matrix.h>
24 
25 namespace gtsam {
26 
36  template<class S, class V, class E>
37  V conjugateGradients(const S& Ab, V x,
38  const ConjugateGradientParameters &parameters, bool steepest = false);
39 
44  class GTSAM_EXPORT System {
45 
46  private:
47  const Matrix& A_;
48  const Vector& b_;
49 
50  public:
51 
52  System(const Matrix& A, const Vector& b) :
53  A_(A), b_(b) {
54  }
55 
57  const Matrix& A() const { return A_; }
58 
60  const Vector& b() const { return b_; }
61 
63  Vector operator^(const Vector& e) const {
64  return A_ ^ e;
65  }
66 
70  void print (const std::string& s = "System") const;
71 
73  Vector gradient(const Vector& x) const {
74  return A() ^ (A() * x - b());
75  }
76 
78  Vector operator*(const Vector& x) const {
79  return A() * x;
80  }
81 
83  void multiplyInPlace(const Vector& x, Vector& e) const {
84  e = A() * x;
85  }
86 
88  void transposeMultiplyAdd(double alpha, const Vector& e, Vector& x) const {
89  x += alpha * A().transpose() * e;
90  }
91  };
92 
96  GTSAM_EXPORT Vector steepestDescent(
97  const System& Ab,
98  const Vector& x,
99  const IterativeOptimizationParameters & parameters);
100 
104  GTSAM_EXPORT Vector conjugateGradientDescent(
105  const System& Ab,
106  const Vector& x,
107  const ConjugateGradientParameters & parameters);
108 
114  GTSAM_EXPORT Vector steepestDescent(
115  const Matrix& A,
116  const Vector& b,
117  const Vector& x,
118  const ConjugateGradientParameters & parameters);
119 
123  GTSAM_EXPORT Vector conjugateGradientDescent(
124  const Matrix& A,
125  const Vector& b,
126  const Vector& x,
127  const ConjugateGradientParameters & parameters);
128 
132  GTSAM_EXPORT VectorValues steepestDescent(
133  const GaussianFactorGraph& fg,
134  const VectorValues& x,
135  const ConjugateGradientParameters & parameters);
136 
141  const GaussianFactorGraph& fg,
142  const VectorValues& x,
143  const ConjugateGradientParameters & parameters);
144 
145 
146 } // namespace gtsam
147 
149 
gtsam::System::System
System(const Matrix &A, const Vector &b)
Definition: iterative.h:52
VectorValues
gtsam::System::operator^
Vector operator^(const Vector &e) const
Definition: iterative.h:63
gtsam::steepestDescent
Vector steepestDescent(const System &Ab, const Vector &x, const ConjugateGradientParameters &parameters)
Definition: iterative.cpp:40
gtsam::System::A_
const Matrix & A_
Definition: iterative.h:47
alpha
RealScalar alpha
Definition: level1_cplx_impl.h:147
s
RealScalar s
Definition: level1_cplx_impl.h:126
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Matrix.h
typedef and functions to augment Eigen's MatrixXd
x
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
Definition: gnuplot_common_settings.hh:12
gtsam::Matrix
Eigen::MatrixXd Matrix
Definition: base/Matrix.h:39
gtsam::Vector
Eigen::VectorXd Vector
Definition: Vector.h:38
gtsam::System::transposeMultiplyAdd
void transposeMultiplyAdd(double alpha, const Vector &e, Vector &x) const
Definition: iterative.h:88
gtsam::conjugateGradientDescent
Vector conjugateGradientDescent(const System &Ab, const Vector &x, const ConjugateGradientParameters &parameters)
Definition: iterative.cpp:45
gtsam::print
void print(const Matrix &A, const string &s, ostream &stream)
Definition: Matrix.cpp:155
ConjugateGradientSolver.h
Implementation of Conjugate Gradient solver for a linear system.
A
Definition: test_numpy_dtypes.cpp:298
gtsam::conjugateGradients
V conjugateGradients(const S &Ab, V x, const ConjugateGradientParameters &parameters, bool steepest)
Definition: iterative-inl.h:126
gtsam::System::A
const Matrix & A() const
Definition: iterative.h:57
gtsam::System::b_
const Vector & b_
Definition: iterative.h:48
parameters
static ConjugateGradientParameters parameters
Definition: testIterative.cpp:33
gtsam::System
Definition: iterative.h:44
iterative-inl.h
Iterative methods, template implementation.
VectorValues.h
Factor Graph Values.
gtsam::System::b
const Vector & b() const
Definition: iterative.h:60
gtsam::b
const G & b
Definition: Group.h:79
gtsam
traits
Definition: SFMdata.h:40
gtsam::System::operator*
Vector operator*(const Vector &x) const
Definition: iterative.h:78
exampleQR::Ab
Matrix Ab
Definition: testNoiseModel.cpp:207
gtsam::System::multiplyInPlace
void multiplyInPlace(const Vector &x, Vector &e) const
Definition: iterative.h:83
V
MatrixXcd V
Definition: EigenSolver_EigenSolver_MatrixType.cpp:15
gtsam::System::gradient
Vector gradient(const Vector &x) const
Definition: iterative.h:73
S
DiscreteKey S(1, 2)


gtsam
Author(s):
autogenerated on Fri Nov 1 2024 03:32:54