gtsam
Loading...
Searching...
No Matches
RegularImplicitSchurFactor.h
Go to the documentation of this file.
1
7
8#pragma once
9
14
15#include <iosfwd>
16#include <map>
17#include <string>
18#include <vector>
19
20namespace gtsam {
21
39template<class CAMERA>
41 public FlatGaussianFactor {
42
43public:
45 typedef std::shared_ptr<This> shared_ptr;
46
47protected:
48
49 // This factor is closely related to a CameraSet
50 typedef CameraSet<CAMERA> Set;
51
52 typedef typename CAMERA::Measurement Z;
53 static const int D = traits<CAMERA>::dimension;
54 static const int ZDim = traits<Z>::dimension;
55
56 typedef Eigen::Matrix<double, ZDim, D> MatrixZD;
57 typedef Eigen::Matrix<double, D, D> MatrixDD;
58 typedef Eigen::Matrix<double, D, 1> DVector;
59 typedef Eigen::Matrix<double, ZDim, 1> ZVector;
60 typedef std::vector<MatrixZD, Eigen::aligned_allocator<MatrixZD> > FBlocks;
61
62 FBlocks FBlocks_;
63 const Matrix PointCovariance_;
64 const Matrix E_;
65 const Vector b_;
66
68 MatrixDD cameraHessianBlock(size_t position) const {
69 const MatrixZD& cameraJacobian = FBlocks_[position];
70 const Matrix23 pointJacobian =
71 E_.block<ZDim, 3>(ZDim * position, 0);
72 return cameraJacobian.transpose() *
73 (cameraJacobian -
74 pointJacobian * PointCovariance_ * pointJacobian.transpose() *
75 cameraJacobian);
76 }
77
79 DVector cameraHessianDiagonal(size_t position) const {
80 const MatrixZD& cameraJacobian = FBlocks_[position];
81 const Eigen::Matrix<double, D, 3> cameraPointInformation =
82 cameraJacobian.transpose() *
83 E_.block<ZDim, 3>(ZDim * position, 0);
84 DVector diagonal;
85 for (int column = 0; column < D; ++column) {
86 diagonal(column) = cameraJacobian.col(column).squaredNorm();
87 diagonal(column) -=
88 cameraPointInformation.row(column) * PointCovariance_ *
89 cameraPointInformation.row(column).transpose();
90 }
91 return diagonal;
92 }
93
95 template <class OFFSET>
96 void multiplyHessianAddFlat(double alpha, const OFFSET& offset,
97 const double* x, double* y) const {
98 typedef Eigen::Map<DVector> DMap;
99 typedef Eigen::Map<const DVector> ConstDMap;
100
101 Vector3 pointProjection = Vector3::Zero();
102 for (size_t position = 0; position < size(); ++position) {
103 const ZVector cameraError =
104 FBlocks_[position] * ConstDMap(x + offset(position));
105 pointProjection.noalias() +=
106 E_.block<ZDim, 3>(ZDim * position, 0).transpose() * cameraError;
107 }
108 const Vector3 pointCorrection = PointCovariance_ * pointProjection;
109
110 for (size_t position = 0; position < size(); ++position) {
111 const ZVector cameraError =
112 FBlocks_[position] * ConstDMap(x + offset(position));
113 const ZVector projectedError =
114 cameraError -
115 E_.block<ZDim, 3>(ZDim * position, 0) * pointCorrection;
116 DMap output(y + offset(position));
117 output.noalias() +=
118 alpha * FBlocks_[position].transpose() * projectedError;
119 }
120 }
121
123 template <class OFFSET>
124 void gradientAtZeroAddFlat(const OFFSET& offset, double* gradient) const {
125 typedef Eigen::Map<DVector> DMap;
126
127 Vector3 pointProjection = Vector3::Zero();
128 for (size_t position = 0; position < size(); ++position) {
129 pointProjection.noalias() +=
130 E_.block<ZDim, 3>(ZDim * position, 0).transpose() *
131 b_.segment<ZDim>(ZDim * position);
132 }
133 const Vector3 pointCorrection = PointCovariance_ * pointProjection;
134
135 for (size_t position = 0; position < size(); ++position) {
136 const ZVector projectedRhs =
137 b_.segment<ZDim>(ZDim * position) -
138 E_.block<ZDim, 3>(ZDim * position, 0) * pointCorrection;
139 DMap output(gradient + offset(position));
140 output.noalias() -= FBlocks_[position].transpose() * projectedRhs;
141 }
142 }
143
144public:
145
149
151
161 RegularImplicitSchurFactor(const KeyVector& keys, const FBlocks& Fs,
162 const Matrix& E, const Matrix& P, const Vector& b)
163 : GaussianFactor(keys), FBlocks_(Fs), PointCovariance_(P), E_(E), b_(b) {}
164
167 }
168
169 const FBlocks& Fs() const {
170 return FBlocks_;
171 }
172
173 const Matrix& E() const {
174 return E_;
175 }
176
177 const Vector& b() const {
178 return b_;
179 }
180
181 const Matrix& getPointCovariance() const {
182 return PointCovariance_;
183 }
184
186 void print(const std::string& s = "", const KeyFormatter& keyFormatter =
187 DefaultKeyFormatter) const override {
188 std::cout << " RegularImplicitSchurFactor " << std::endl;
189 Factor::print(s);
190 for (size_t pos = 0; pos < size(); ++pos) {
191 std::cout << "Fblock:\n" << FBlocks_[pos] << std::endl;
192 }
193 std::cout << "PointCovariance:\n" << PointCovariance_ << std::endl;
194 std::cout << "E:\n" << E_ << std::endl;
195 std::cout << "b:\n" << b_.transpose() << std::endl;
196 }
197
199 bool equals(const GaussianFactor& lf, double tol) const override {
200 const This* f = dynamic_cast<const This*>(&lf);
201 if (!f)
202 return false;
203 for (size_t k = 0; k < FBlocks_.size(); ++k) {
204 if (keys_[k] != f->keys_[k])
205 return false;
206 if (!equal_with_abs_tol(FBlocks_[k], f->FBlocks_[k], tol))
207 return false;
208 }
210 && equal_with_abs_tol(E_, f->E_, tol)
211 && equal_with_abs_tol(b_, f->b_, tol);
212 }
213
215 DenseIndex getDim(const_iterator variable) const override {
216 return D;
217 }
218
220 SymmetricBlockMatrix* info) const override {
221 throw std::runtime_error(
222 "RegularImplicitSchurFactor::updateHessian not implemented");
223 }
224
227 DenseIndex beginCol, DenseIndex endCol) const override {
228 throw std::runtime_error(
229 "RegularImplicitSchurFactor::updateHessian not implemented");
230 }
231
232 Matrix augmentedJacobian() const override {
233 throw std::runtime_error(
234 "RegularImplicitSchurFactor::augmentedJacobian not implemented");
235 return Matrix();
236 }
237 std::pair<Matrix, Vector> jacobian() const override {
238 throw std::runtime_error(
239 "RegularImplicitSchurFactor::jacobian not implemented");
240 return {Matrix(), Vector()};
241 }
242
244 Matrix augmentedInformation() const override {
245 // Do the Schur complement
246 SymmetricBlockMatrix augmentedHessian =
248 return augmentedHessian.selfadjointView();
249 }
250
252 Matrix information() const override {
253 Matrix augmented = augmentedInformation();
254 int m = this->keys_.size();
255 size_t M = D * m;
256 return augmented.block(0, 0, M, M);
257 }
258
261
263 void hessianDiagonalAdd(VectorValues &d) const override {
264 for (size_t position = 0; position < size(); ++position) {
265 const DVector diagonal = cameraHessianDiagonal(position);
266 auto result = d.emplace(keys_[position], diagonal);
267 if (!result.second) {
268 result.first->second += diagonal;
269 }
270 }
271 }
272
277 void hessianDiagonal(double* d) const override {
278 typedef Eigen::Map<DVector> DMap;
279 for (size_t position = 0; position < size(); ++position) {
280 DMap(d + D * keys_[position]) += cameraHessianDiagonal(position);
281 }
282 }
283
285 std::map<Key, Matrix> hessianBlockDiagonal() const override {
286 std::map<Key, Matrix> blocks;
287 for (size_t position = 0; position < size(); ++position) {
288 blocks[keys_[position]] = cameraHessianBlock(position);
289 }
290 return blocks;
291 }
292
294 const std::vector<size_t>& blockSlots,
295 std::vector<Matrix>* diagonalBlocks) const override {
296 if (blockSlots.size() != size()) {
297 throw std::invalid_argument(
298 "RegularImplicitSchurFactor::hessianBlockDiagonalAdd: block slot "
299 "count mismatch");
300 }
301 for (size_t position = 0; position < size(); ++position) {
302 diagonalBlocks->at(blockSlots[position]).noalias() +=
303 cameraHessianBlock(position);
304 }
305 }
306
308 return std::make_shared<RegularImplicitSchurFactor<CAMERA> >(keys_,
310 throw std::runtime_error(
311 "RegularImplicitSchurFactor::clone not implemented");
312 }
313
315 return std::make_shared<RegularImplicitSchurFactor<CAMERA> >(keys_,
317 throw std::runtime_error(
318 "RegularImplicitSchurFactor::negate not implemented");
319 }
320
321 // Raw Vector version of y += F'*alpha*(I - E*P*E')*F*x, for testing
322 static
323 void multiplyHessianAdd(const Matrix& F, const Matrix& E,
324 const Matrix& PointCovariance, double alpha, const Vector& x, Vector& y) {
325 Vector e1 = F * x;
326 Vector d1 = E.transpose() * e1;
327 Vector d2 = PointCovariance * d1;
328 Vector e2 = E * d2;
329 Vector e3 = alpha * (e1 - e2);
330 y += F.transpose() * e3;
331 }
332
333 typedef std::vector<Vector2, Eigen::aligned_allocator<Vector2>> Error2s;
334
338 void projectError2(const Error2s& e1, Error2s& e2) const {
339
340 // d1 = E.transpose() * (e1-ZDim*b) = (3*2m)*2m
341 Vector3 d1;
342 d1.setZero();
343 for (size_t k = 0; k < size(); k++)
344 d1 += E_.block<ZDim, 3>(ZDim * k, 0).transpose()
345 * (e1[k] - ZDim * b_.segment<ZDim>(k * ZDim));
346
347 // d2 = E.transpose() * e1 = (3*2m)*2m
348 Vector3 d2 = PointCovariance_ * d1;
349
350 // e3 = alpha*(e1 - E*d2) = 1*[2m-(2m*3)*3]
351 for (size_t k = 0; k < size(); k++)
352 e2[k] = e1[k] - ZDim * b_.segment<ZDim>(k * ZDim)
353 - E_.block<ZDim, 3>(ZDim * k, 0) * d2;
354 }
355
356 /*
357 * This definition matches the linearized error in the Hessian Factor:
358 * LinError(x) = x'*H*x - 2*x'*eta + f
359 * with:
360 * H = F' * (I-E'*P*E) * F = F' * Q * F
361 * eta = F' * (I-E'*P*E) * b = F' * Q * b
362 * f = nonlinear error
363 * (x'*H*x - 2*x'*eta + f) = x'*F'*Q*F*x - 2*x'*F'*Q *b + f = x'*F'*Q*(F*x - 2*b) + f
364 */
365 double error(const VectorValues& x) const override {
366
367 // resize does not do malloc if correct size
368 e1.resize(size());
369 e2.resize(size());
370
371 // e1 = F * x - b = (2m*dm)*dm
372 for (size_t k = 0; k < size(); ++k)
373 e1[k] = FBlocks_[k] * x.at(keys_[k]);
374 projectError2(e1, e2);
375
376 double result = 0;
377 for (size_t k = 0; k < size(); ++k)
378 result += dot(e1[k], e2[k]);
379
380 double f = b_.squaredNorm();
381 return 0.5 * (result + f);
382 }
383
384 // needed to be GaussianFactor - (I - E*P*E')*(F*x - b)
385 // This is wrong and does not match the definition in Hessian,
386 // but it matches the definition of the Jacobian factor (JF)
387 double errorJF(const VectorValues& x) const {
388
389 // resize does not do malloc if correct size
390 e1.resize(size());
391 e2.resize(size());
392
393 // e1 = F * x - b = (2m*dm)*dm
394 for (size_t k = 0; k < size(); ++k)
395 e1[k] = FBlocks_[k] * x.at(keys_[k]) - b_.segment<ZDim>(k * ZDim);
396 projectError(e1, e2);
397
398 double result = 0;
399 for (size_t k = 0; k < size(); ++k)
400 result += dot(e2[k], e2[k]);
401
402 // std::cout << "implicitFactor::error result " << result << std::endl;
403 return 0.5 * result;
404 }
408 void projectError(const Error2s& e1, Error2s& e2) const {
409
410 // d1 = E.transpose() * e1 = (3*2m)*2m
411 Vector3 d1;
412 d1.setZero();
413 for (size_t k = 0; k < size(); k++)
414 d1 += E_.block<ZDim, 3>(ZDim * k, 0).transpose() * e1[k];
415
416 // d2 = E.transpose() * e1 = (3*2m)*2m
417 Vector3 d2 = PointCovariance_ * d1;
418
419 // e3 = alpha*(e1 - E*d2) = 1*[2m-(2m*3)*3]
420 for (size_t k = 0; k < size(); k++)
421 e2[k] = e1[k] - E_.block<ZDim, 3>(ZDim * k, 0) * d2;
422 }
423
425 mutable Error2s e1, e2;
426
431 void multiplyHessianAdd(double alpha, const double* x, double* y) const {
433 alpha, [&](size_t position) { return D * keys_[position]; }, x, y);
434 }
435
437 double alpha, const std::vector<size_t>& scalarOffsets,
438 const double* x, double* y) const override {
439 if (scalarOffsets.size() != size()) {
440 throw std::invalid_argument(
441 "RegularImplicitSchurFactor::multiplyHessianAdd: offset count "
442 "mismatch");
443 }
445 alpha, [&](size_t position) { return scalarOffsets[position]; }, x, y);
446 }
447
451 void multiplyHessianAdd(double alpha, const VectorValues& x,
452 VectorValues& y) const override {
453
454 // resize does not do malloc if correct size
455 e1.resize(size());
456 e2.resize(size());
457
458 // e1 = F * x = (2m*dm)*dm
459 for (size_t k = 0; k < size(); ++k)
460 e1[k] = FBlocks_[k] * x.at(keys_[k]);
461
462 projectError(e1, e2);
463
464 // y += F.transpose()*e2 = (2d*2m)*2m
465 for (size_t k = 0; k < size(); ++k) {
466 Key key = keys_[k];
467 static const Vector empty;
468 std::pair<VectorValues::iterator, bool> it = y.tryInsert(key, empty);
469 Vector& yi = it.first->second;
470 // Create the value as a zero vector if it does not exist.
471 if (it.second)
472 yi = Vector::Zero(FBlocks_[k].cols());
473 yi += FBlocks_[k].transpose() * alpha * e2[k];
474 }
475 }
476
480 void multiplyHessianDummy(double alpha, const VectorValues& x,
481 VectorValues& y) const {
482
483 for (size_t k = 0; k < size(); ++k) {
484 static const Vector empty;
485 Key key = keys_[k];
486 std::pair<VectorValues::iterator, bool> it = y.tryInsert(key, empty);
487 Vector& yi = it.first->second;
488 yi = x.at(key);
489 }
490 }
491
495 VectorValues gradientAtZero() const override {
496 // calculate Q*b
497 e1.resize(size());
498 e2.resize(size());
499 for (size_t k = 0; k < size(); k++)
500 e1[k] = b_.segment<ZDim>(ZDim * k);
501 projectError(e1, e2);
502
503 // g = F.transpose()*e2
504 VectorValues g;
505 for (size_t k = 0; k < size(); ++k) {
506 Key key = keys_[k];
507 g.insert(key, -FBlocks_[k].transpose() * e2[k]);
508 }
509
510 // return it
511 return g;
512 }
513
514 void gradientAtZeroAdd(const std::vector<size_t>& scalarOffsets,
515 double* gradient) const override {
516 if (scalarOffsets.size() != size()) {
517 throw std::invalid_argument(
518 "RegularImplicitSchurFactor::gradientAtZeroAdd: offset count "
519 "mismatch");
520 }
522 [&](size_t position) { return scalarOffsets[position]; }, gradient);
523 }
524
528 void gradientAtZero(double* d) const override {
530 [&](size_t position) { return D * keys_[position]; }, d);
531 }
532
534 Vector gradient(Key key, const VectorValues& x) const override {
535 throw std::runtime_error(
536 "gradient for RegularImplicitSchurFactor is not implemented yet");
537 }
538
539};
540// end class RegularImplicitSchurFactor
541
542template<class CAMERA>
544
545template<class CAMERA>
547
548// traits
549template<class CAMERA> struct traits<RegularImplicitSchurFactor<CAMERA> > : public Testable<
550 RegularImplicitSchurFactor<CAMERA> > {
551};
552
553}
Base class to create smart factors on poses or cameras.
Optional preindexed kernels for Gaussian factors.
Factor Graph Values.
Global functions in a separate testing namespace.
Definition chartTesting.h:28
KeyFormatter DefaultKeyFormatter
Assign default key formatter.
Definition Key.cpp:30
ptrdiff_t DenseIndex
The index type for Eigen objects.
Definition types.h:49
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
Definition Key.h:91
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition Key.h:35
double dot(const V1 &a, const V2 &b)
Dot product.
Definition Vector.h:191
std::uint64_t Key
Integer nonlinear key type.
Definition types.h:43
bool equal_with_abs_tol(const Eigen::DenseBase< MATRIX > &A, const Eigen::DenseBase< MATRIX > &B, double tol=1e-9)
equals with a tolerance
Definition Matrix.h:81
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition Group.h:37
This class stores a dense matrix and allows it to be accessed as a collection of blocks.
Definition SymmetricBlockMatrix.h:80
Eigen::SelfAdjointView< constBlock, Eigen::Upper > selfadjointView(DenseIndex I, DenseIndex J) const
Return the square sub-matrix that contains blocks(i:j, i:j).
Definition SymmetricBlockMatrix.h:211
A helper that implements the traits interface for GTSAM types.
Definition Testable.h:152
A set of cameras, all with their own calibration.
Definition CameraSet.h:37
static SymmetricBlockMatrix SchurComplement(const std::vector< Eigen::Matrix< double, ZDim, ND >, Eigen::aligned_allocator< Eigen::Matrix< double, ZDim, ND > > > &Fs, const Matrix &E, const Eigen::Matrix< double, N, N > &P, const Vector &b)
Do Schur complement, given Jacobian as Fs,E,P, return SymmetricBlockMatrix G = F' * F - F' * E * P * ...
Definition CameraSet.h:175
const KeyVector & keys() const
Access the factor's involved variable keys.
Definition Factor.h:143
KeyVector keys_
The keys involved in this factor.
Definition Factor.h:88
bool empty() const
Whether the factor is empty (involves zero variables).
Definition Factor.h:131
virtual void print(const std::string &s="Factor", const KeyFormatter &formatter=DefaultKeyFormatter) const
print
Definition Factor.cpp:29
KeyVector::const_iterator const_iterator
Const iterator over keys.
Definition Factor.h:83
size_t size() const
Definition Factor.h:160
Optional preindexed kernels for matrix-free Gaussian factors.
Definition FlatGaussianFactor.h:35
std::shared_ptr< This > shared_ptr
shared_ptr to this class
Definition GaussianFactor.h:42
GaussianFactor()
Default constructor creates empty factor.
Definition GaussianFactor.h:49
VectorValues hessianDiagonal() const
Return the diagonal of the Hessian for this factor.
Definition GaussianFactor.cpp:49
VectorValues represents a collection of vector-valued variables associated each with a unique integer...
Definition VectorValues.h:73
iterator insert(const std::pair< Key, Vector > &key_value)
Insert a vector value with key j.
Definition VectorValues.cpp:90
std::pair< VectorValues::iterator, bool > emplace(Key j, Args &&... args)
Emplace a vector value with key j.
Definition VectorValues.h:187
Vector & at(Key j)
Read/write access to the vector value with key j, throws std::out_of_range if j does not exist,...
Definition VectorValues.h:141
std::pair< iterator, bool > tryInsert(Key j, const Vector &value)
insert that mimics the STL map insert - if the value already exists, the map is not modified and an i...
Definition VectorValues.h:222
RegularImplicitSchurFactor.
Definition RegularImplicitSchurFactor.h:41
void multiplyHessianAddFlat(double alpha, const OFFSET &offset, const double *x, double *y) const
Apply the Hessian using a caller-supplied scalar offset lookup.
Definition RegularImplicitSchurFactor.h:96
void gradientAtZeroAdd(const std::vector< size_t > &scalarOffsets, double *gradient) const override
Add this factor's zero-point gradient to a flat output vector.
Definition RegularImplicitSchurFactor.h:514
const Matrix E_
The 2m*3 E Jacobian with respect to the point.
Definition RegularImplicitSchurFactor.h:64
void hessianBlockDiagonalAdd(const std::vector< size_t > &blockSlots, std::vector< Matrix > *diagonalBlocks) const override
Add this factor's Hessian diagonal to ordered variable blocks.
Definition RegularImplicitSchurFactor.h:293
void projectError(const Error2s &e1, Error2s &e2) const
Calculate corrected error Q*e = (I - E*P*E')*e.
Definition RegularImplicitSchurFactor.h:408
GaussianFactor::shared_ptr clone() const override
Clone a factor (make a deep copy).
Definition RegularImplicitSchurFactor.h:307
void hessianDiagonalAdd(VectorValues &d) const override
Add the diagonal of the Hessian for this factor to existing VectorValues.
Definition RegularImplicitSchurFactor.h:263
std::shared_ptr< This > shared_ptr
shared_ptr to this class
Definition RegularImplicitSchurFactor.h:45
RegularImplicitSchurFactor(const KeyVector &keys, const FBlocks &Fs, const Matrix &E, const Matrix &P, const Vector &b)
Construct from blocks of F, E, inv(E'*E), and RHS vector b.
Definition RegularImplicitSchurFactor.h:161
RegularImplicitSchurFactor()
Constructor.
Definition RegularImplicitSchurFactor.h:147
void gradientAtZeroAddFlat(const OFFSET &offset, double *gradient) const
Add the zero-point gradient using a scalar offset lookup.
Definition RegularImplicitSchurFactor.h:124
void multiplyHessianAdd(double alpha, const std::vector< size_t > &scalarOffsets, const double *x, double *y) const override
Add this factor's Hessian-vector product to a flat output vector.
Definition RegularImplicitSchurFactor.h:436
const Vector b_
2m-dimensional RHS vector
Definition RegularImplicitSchurFactor.h:65
std::pair< Matrix, Vector > jacobian() const override
Return the dense Jacobian and right-hand-side , with the noise models baked into A and b.
Definition RegularImplicitSchurFactor.h:237
Eigen::Matrix< double, D, D > MatrixDD
camera Hessian
Definition RegularImplicitSchurFactor.h:57
void gradientAtZero(double *d) const override
Calculate gradient, which is -F'Q*b, see paper - RAW MEMORY ACCESS.
Definition RegularImplicitSchurFactor.h:528
static const int ZDim
Measurement dimension.
Definition RegularImplicitSchurFactor.h:54
MatrixDD cameraHessianBlock(size_t position) const
Return one camera block of F' * (I - E*P*E') * F.
Definition RegularImplicitSchurFactor.h:68
Matrix information() const override
Compute full information matrix
Definition RegularImplicitSchurFactor.h:252
~RegularImplicitSchurFactor() override
Destructor.
Definition RegularImplicitSchurFactor.h:166
void updateHessian(const KeyVector &keys, SymmetricBlockMatrix *info) const override
Update an information matrix by adding the information corresponding to this factor (used internally ...
Definition RegularImplicitSchurFactor.h:219
FBlocks FBlocks_
All ZDim*D F blocks (one for each camera).
Definition RegularImplicitSchurFactor.h:62
VectorValues gradientAtZero() const override
Calculate gradient, which is -F'Q*b, see paper.
Definition RegularImplicitSchurFactor.h:495
void updateHessian(const KeyVector &keys, SymmetricBlockMatrix *info, DenseIndex beginCol, DenseIndex endCol) const override
Update an information matrix by adding the information corresponding to this factor (used internally ...
Definition RegularImplicitSchurFactor.h:225
Eigen::Matrix< double, ZDim, D > MatrixZD
type of an F block
Definition RegularImplicitSchurFactor.h:56
DVector cameraHessianDiagonal(size_t position) const
Return the diagonal of one camera Hessian block without forming it.
Definition RegularImplicitSchurFactor.h:79
const Matrix PointCovariance_
the 3*3 matrix P = inv(E'E) (2*2 if degenerate)
Definition RegularImplicitSchurFactor.h:63
void multiplyHessianAdd(double alpha, const VectorValues &x, VectorValues &y) const override
Hessian-vector multiply, i.e.
Definition RegularImplicitSchurFactor.h:451
std::map< Key, Matrix > hessianBlockDiagonal() const override
Return the block diagonal of the Hessian for this factor.
Definition RegularImplicitSchurFactor.h:285
Matrix augmentedInformation() const override
Compute full augmented information matrix
Definition RegularImplicitSchurFactor.h:244
GaussianFactor::shared_ptr negate() const override
Construct the corresponding anti-factor to negate information stored stored in this factor.
Definition RegularImplicitSchurFactor.h:314
Error2s e1
Scratch space for keyed compatibility methods.
Definition RegularImplicitSchurFactor.h:425
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
print
Definition RegularImplicitSchurFactor.h:186
DenseIndex getDim(const_iterator variable) const override
Degrees of freedom of camera.
Definition RegularImplicitSchurFactor.h:215
bool equals(const GaussianFactor &lf, double tol) const override
equals
Definition RegularImplicitSchurFactor.h:199
Matrix augmentedJacobian() const override
Return a dense Jacobian matrix, augmented with b with the noise models baked into A and b.
Definition RegularImplicitSchurFactor.h:232
RegularImplicitSchurFactor This
Typedef to this class.
Definition RegularImplicitSchurFactor.h:44
static const int D
Camera dimension.
Definition RegularImplicitSchurFactor.h:53
void projectError2(const Error2s &e1, Error2s &e2) const
Calculate corrected error Q*(e-ZDim*b) = (I - E*P*E')*(e-ZDim*b).
Definition RegularImplicitSchurFactor.h:338
void multiplyHessianAdd(double alpha, const double *x, double *y) const
double* Hessian-vector multiply, i.e.
Definition RegularImplicitSchurFactor.h:431
void hessianDiagonal(double *d) const override
add the contribution of this factor to the diagonal of the hessian d(output) = d(input) + deltaHessia...
Definition RegularImplicitSchurFactor.h:277
void multiplyHessianDummy(double alpha, const VectorValues &x, VectorValues &y) const
Dummy version to measure overhead of key access.
Definition RegularImplicitSchurFactor.h:480
Vector gradient(Key key, const VectorValues &x) const override
Gradient wrt a key at any values.
Definition RegularImplicitSchurFactor.h:534
The Factor::error simply extracts the.