gtsam
Loading...
Searching...
No Matches
LinearEquality.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
18
19#pragma once
20
21#include <gtsam/config.h>
22
23#ifdef GTSAM_ALLOW_DEPRECATED_SINCE_V43
24
26
27namespace gtsam {
28
33class LinearEquality: public JacobianFactor {
34public:
35 typedef LinearEquality This;
36 typedef JacobianFactor Base;
37 typedef std::shared_ptr<This> shared_ptr;
38
39private:
40 Key dualKey_;
41
42public:
44 LinearEquality() :
45 Base() {
46 }
47
51 explicit LinearEquality(const JacobianFactor& jf, Key dualKey) :
52 Base(jf), dualKey_(dualKey) {
53 if (!jf.isConstrained()) {
54 throw std::runtime_error(
55 "Cannot convert an unconstrained JacobianFactor to LinearEquality");
56 }
57 }
58
60 explicit LinearEquality(const HessianFactor& hf) {
61 throw std::runtime_error("Cannot convert HessianFactor to LinearEquality");
62 }
63
65 LinearEquality(Key i1, const Matrix& A1, const Vector& b, Key dualKey) :
66 Base(i1, A1, b, noiseModel::Constrained::All(b.rows())), dualKey_(dualKey) {
67 }
68
70 LinearEquality(Key i1, const Matrix& A1, Key i2, const Matrix& A2,
71 const Vector& b, Key dualKey) :
72 Base(i1, A1, i2, A2, b, noiseModel::Constrained::All(b.rows())), dualKey_(
73 dualKey) {
74 }
75
77 LinearEquality(Key i1, const Matrix& A1, Key i2, const Matrix& A2, Key i3,
78 const Matrix& A3, const Vector& b, Key dualKey) :
79 Base(i1, A1, i2, A2, i3, A3, b, noiseModel::Constrained::All(b.rows())), dualKey_(
80 dualKey) {
81 }
82
86 template<typename TERMS>
87 LinearEquality(const TERMS& terms, const Vector& b, Key dualKey) :
88 Base(terms, b, noiseModel::Constrained::All(b.rows())), dualKey_(dualKey) {
89 }
90
92 ~LinearEquality() override {
93 }
94
96 bool equals(const GaussianFactor& lf, double tol = 1e-9) const override {
97 return Base::equals(lf, tol);
98 }
99
101 void print(const std::string& s = "", const KeyFormatter& formatter =
102 DefaultKeyFormatter) const override {
103 Base::print(s, formatter);
104 }
105
107 GaussianFactor::shared_ptr clone() const override {
108 return std::static_pointer_cast < GaussianFactor
109 > (std::make_shared < LinearEquality > (*this));
110 }
111
113 Key dualKey() const {
114 return dualKey_;
115 }
116
118 bool active() const {
119 return true;
120 }
121
123 Vector error_vector(const VectorValues& c) const {
124 return unweighted_error(c);
125 }
126
131 double error(const VectorValues& c) const override {
132 return 0.0;
133 }
134
135};
136// \ LinearEquality
137
139template<> struct traits<LinearEquality> : public Testable<LinearEquality> {
140};
141
142} // \ namespace gtsam
143
144#endif // GTSAM_ALLOW_DEPRECATED_SINCE_V43
Global functions in a separate testing namespace.
Definition chartTesting.h:28
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition Matrix.cpp:143
std::uint64_t Key
Integer nonlinear key type.
Definition types.h:43
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition Group.h:37
A helper that implements the traits interface for GTSAM types.
Definition Testable.h:152
A Gaussian factor in the squared-error form.
Definition JacobianFactor.h:92