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,
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 
void print(const Matrix &A, const string &s, ostream &stream)
Definition: Matrix.cpp:155
System(const Matrix &A, const Vector &b)
Definition: iterative.h:52
const Matrix & A_
Definition: iterative.h:47
void multiplyInPlace(const Vector &x, Vector &e) const
Definition: iterative.h:83
const Vector & b_
Definition: iterative.h:48
Eigen::MatrixXd Matrix
Definition: base/Matrix.h:39
V conjugateGradients(const S &Ab, V x, const ConjugateGradientParameters &parameters, bool steepest)
DiscreteKey S(1, 2)
Implementation of Conjugate Gradient solver for a linear system.
const Vector & b() const
Definition: iterative.h:60
Factor Graph Values.
Vector conjugateGradientDescent(const System &Ab, const Vector &x, const ConjugateGradientParameters &parameters)
Definition: iterative.cpp:45
Eigen::VectorXd Vector
Definition: Vector.h:38
const Matrix & A() const
Definition: iterative.h:57
RealScalar alpha
Array< double, 1, 3 > e(1./3., 0.5, 2.)
RealScalar s
Vector gradient(const Vector &x) const
Definition: iterative.h:73
Iterative methods, template implementation.
Vector operator^(const Vector &e) const
Definition: iterative.h:63
const G & b
Definition: Group.h:86
static ConjugateGradientParameters parameters
void transposeMultiplyAdd(double alpha, const Vector &e, Vector &x) const
Definition: iterative.h:88
traits
Definition: chartTesting.h:28
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
Vector steepestDescent(const System &Ab, const Vector &x, const ConjugateGradientParameters &parameters)
Definition: iterative.cpp:40
Vector operator*(const Vector &x) const
Definition: iterative.h:78


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:34:26