GTSAM  4.0.2
C++ library for smoothing and mapping (SAM)
KarcherMeanFactor.h
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 
12 /*
13  * @file KarcherMeanFactor.h
14  * @author Frank Dellaert
15  * @date March 2019
16  */
17 
18 #pragma once
19 
20 #include <gtsam/base/Matrix.h>
22 
23 #include <map>
24 #include <vector>
25 #include <optional>
26 
27 namespace gtsam {
33 template <class T>
34 T FindKarcherMean(const std::vector<T, Eigen::aligned_allocator<T>> &rotations);
35 
36 template <class T> T FindKarcherMean(std::initializer_list<T> &&rotations);
37 
46 template <class T> class KarcherMeanFactor : public NonlinearFactor {
47  // Compile time dimension: can be -1
48  enum { D = traits<T>::dimension };
49 
50  // Runtime dimension: always >=0
51  size_t d_;
52 
54  std::shared_ptr<JacobianFactor> whitenedJacobian_;
55 
56 public:
62  template <typename CONTAINER>
63  KarcherMeanFactor(const CONTAINER &keys, int d = D,
64  std::optional<double> beta = {});
65 
67  ~KarcherMeanFactor() override {}
68 
70  double error(const Values &c) const override { return 0; }
71 
73  size_t dim() const override { return d_; }
74 
76  std::shared_ptr<GaussianFactor> linearize(const Values &c) const override {
77  return whitenedJacobian_;
78  }
79 };
80 // \KarcherMeanFactor
81 } // namespace gtsam
Definition: Group.h:43
Definition: NonlinearFactor.h:68
std::shared_ptr< GaussianFactor > linearize(const Values &c) const override
linearize to a GaussianFactor
Definition: KarcherMeanFactor.h:76
KarcherMeanFactor(const CONTAINER &keys, int d=D, std::optional< double > beta={})
Definition: KarcherMeanFactor-inl.h:61
size_t dim() const override
get the dimension of the factor (number of rows on linearization)
Definition: KarcherMeanFactor.h:73
~KarcherMeanFactor() override
Destructor.
Definition: KarcherMeanFactor.h:67
Definition: KarcherMeanFactor.h:46
Definition: Values.h:65
typedef and functions to augment Eigen&#39;s MatrixXd
Definition: chartTesting.h:28
const KeyVector & keys() const
Access the factor&#39;s involved variable keys.
Definition: Factor.h:142
double error(const Values &c) const override
Calculate the error of the factor: always zero.
Definition: KarcherMeanFactor.h:70