27#if GTSAM_ENABLE_BOOST_SERIALIZATION
28#include <boost/serialization/version.hpp>
29#include <boost/serialization/split_member.hpp>
49 GTSAM_EXPORT std::pair<std::shared_ptr<GaussianConditional>, std::shared_ptr<JacobianFactor> >
99 typedef VerticalBlockMatrix::Block ABlock;
100 typedef VerticalBlockMatrix::constBlock constABlock;
101 typedef ABlock::ColXpr BVector;
102 typedef constABlock::ConstColXpr constBVector;
107 noiseModel::Diagonal::shared_ptr model_;
130 const Vector& b,
const SharedDiagonal& model = SharedDiagonal());
133 template <
int M,
int N1,
134 typename = std::enable_if_t<(M != Eigen::Dynamic &&
135 N1 != Eigen::Dynamic)>>
137 const Eigen::Matrix<double, M, 1>& b,
138 const SharedDiagonal& model = SharedDiagonal());
142 Key i2,
const Matrix& A2,
143 const Vector& b,
const SharedDiagonal& model = SharedDiagonal());
146 template <
int M,
int N1,
int N2,
147 typename = std::enable_if_t<(M != Eigen::Dynamic &&
148 N1 != Eigen::Dynamic &&
149 N2 != Eigen::Dynamic)>>
151 Key i2,
const Eigen::Matrix<double, M, N2>& A2,
152 const Eigen::Matrix<double, M, 1>& b,
153 const SharedDiagonal& model = SharedDiagonal());
157 const Matrix& A2,
Key i3,
const Matrix& A3,
158 const Vector& b,
const SharedDiagonal& model = SharedDiagonal());
161 template <
int M,
int N1,
int N2,
int N3,
162 typename = std::enable_if_t<(M != Eigen::Dynamic &&
163 N1 != Eigen::Dynamic &&
164 N2 != Eigen::Dynamic &&
165 N3 != Eigen::Dynamic)>>
167 Key i2,
const Eigen::Matrix<double, M, N2>& A2,
168 Key i3,
const Eigen::Matrix<double, M, N3>& A3,
169 const Eigen::Matrix<double, M, 1>& b,
170 const SharedDiagonal& model = SharedDiagonal());
175 template<
typename TERMS>
176 JacobianFactor(
const TERMS& terms,
const Vector& b,
const SharedDiagonal& model = SharedDiagonal());
181 template <
typename KEYS>
183 const SharedDiagonal& sigmas = SharedDiagonal());
186 template <
typename KEYS>
188 const SharedDiagonal& model);
227 return std::static_pointer_cast<GaussianFactor>(
228 std::make_shared<JacobianFactor>(*
this));
235 void print(
const std::string& s =
"",
243 using GaussianFactor::error;
252 double deltaError(
const VectorValues& c,
double* oldError =
nullptr,
253 double* newError =
nullptr)
const override;
263 Matrix augmentedInformation()
const override;
268 Matrix information()
const override;
271 using Base::hessianDiagonal;
274 void hessianDiagonalAdd(
VectorValues& d)
const override;
277 void hessianDiagonal(
double* d)
const override;
280 std::map<Key,Matrix> hessianBlockDiagonal()
const override;
285 std::pair<Matrix, Vector> jacobian()
const override;
290 std::pair<Matrix, Vector> jacobianUnweighted()
const;
295 Matrix augmentedJacobian()
const override;
300 Matrix augmentedJacobianUnweighted()
const;
317 return model_ && model_->isConstrained();
324 return Ab_(variable -
begin()).cols();
330 size_t rows()
const {
return Ab_.rows(); }
335 size_t cols()
const {
return Ab_.cols(); }
338 const SharedDiagonal&
get_model()
const {
return model_; }
344 const constBVector
getb()
const {
return Ab_(
size()).col(0); }
350 constABlock
getA()
const {
return Ab_.range(0,
size()); }
390 void transposeMultiplyAdd(
double alpha,
const Vector& e,
394 void multiplyHessianAdd(
double alpha,
const VectorValues& x,
405 void multiplyHessianAdd(
double alpha,
const double* x,
double* y,
406 const std::vector<size_t>& accumulatedDims)
const;
412 void gradientAtZero(
double* d)
const override;
421 std::pair<std::shared_ptr<GaussianConditional>, shared_ptr>
425 void setModel(
bool anyConstrained,
const Vector& sigmas);
438 friend GTSAM_EXPORT std::pair<std::shared_ptr<GaussianConditional>, shared_ptr>
448 std::shared_ptr<GaussianConditional> splitConditional(
size_t nrFrontals);
453 template<
typename TERMS>
454 void fillTerms(
const TERMS& terms,
const Vector& b,
const SharedDiagonal&
noiseModel);
457 void checkAb(
const SharedDiagonal& model,
466 void JacobianFactorHelper(
476 template<
class KEYS,
class DIMENSIONS>
478 const SharedDiagonal& model = SharedDiagonal()) :
479 Base(keys), Ab_(dims.begin(), dims.end(), m, true), model_(model) {
483 template<
typename T>
friend class ExpressionFactor;
485#if GTSAM_ENABLE_BOOST_SERIALIZATION
487 friend class boost::serialization::access;
488 template<
class ARCHIVE>
489 void save(ARCHIVE & ar,
const unsigned int version)
const {
494 ar << BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
495 ar << BOOST_SERIALIZATION_NVP(Ab_);
496 bool model_null =
false;
497 if(model_.get() ==
nullptr) {
499 ar << boost::serialization::make_nvp(
"model_null", model_null);
501 ar << boost::serialization::make_nvp(
"model_null", model_null);
502 ar << BOOST_SERIALIZATION_NVP(model_);
506 template<
class ARCHIVE>
507 void load(ARCHIVE & ar,
const unsigned int version) {
509 ar >> BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
510 ar >> BOOST_SERIALIZATION_NVP(Ab_);
512 ar >> BOOST_SERIALIZATION_NVP(model_);
515 ar >> BOOST_SERIALIZATION_NVP(model_null);
517 ar >> BOOST_SERIALIZATION_NVP(model_);
522 BOOST_SERIALIZATION_SPLIT_MEMBER()
532#if GTSAM_ENABLE_BOOST_SERIALIZATION
536#include <gtsam/linear/JacobianFactor-inl.h>
A matrix with column blocks of pre-defined sizes.
VariableSlots describes the structure of a combined factor in terms of where each block comes from in...
A factor with a quadratic error function - a Gaussian.
Included from all GTSAM files.
std::vector< T, typename internal::FastDefaultVectorAllocator< T >::type > FastVector
FastVector is a type alias to a std::vector with a custom memory allocator.
Definition FastVector.h:33
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
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition Matrix.cpp:143
std::pair< GaussianConditional::shared_ptr, JacobianFactor::shared_ptr > EliminateQR(const GaussianFactorGraph &factors, const Ordering &keys)
Multiply all factors and eliminate the given keys from the resulting factor using a QR variant that h...
Definition JacobianFactor.cpp:976
Point2 operator*(double s, const Point2 &p)
multiply with scalar
Definition Point2.h:52
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
std::uint64_t Key
Integer nonlinear key type.
Definition types.h:43
All noise models live in the noiseModel namespace.
Definition LossFunctions.cpp:33
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
Template to create a binary predicate.
Definition Testable.h:112
A helper that implements the traits interface for GTSAM types.
Definition Testable.h:152
This class stores a dense matrix and allows it to be accessed as a collection of vertical blocks.
Definition VerticalBlockMatrix.h:47
const_iterator find(Key key) const
find
Definition Factor.h:140
const_iterator begin() const
Iterator at beginning of involved variable keys.
Definition Factor.h:146
KeyVector::const_iterator const_iterator
Const iterator over keys.
Definition Factor.h:83
KeyVector::iterator iterator
Iterator over keys.
Definition Factor.h:80
size_t size() const
Definition Factor.h:160
A combined factor is assembled as one block of rows for each component factor.
Definition VariableSlots.h:51
A GaussianConditional functions as the node in a Bayes network.
Definition GaussianConditional.h:43
An abstract virtual base class for JacobianFactor and HessianFactor.
Definition GaussianFactor.h:39
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
A Linear Factor Graph is a factor graph where all factors are Gaussian, i.e.
Definition GaussianFactorGraph.h:77
A Gaussian factor using the canonical parameters (information form).
Definition HessianFactor.h:101
A Gaussian factor in the squared-error form.
Definition JacobianFactor.h:92
const constBVector getb() const
Get a view of the r.h.s.
Definition JacobianFactor.h:344
BVector getb()
Get a view of the r.h.s.
Definition JacobianFactor.h:353
const SharedDiagonal & get_model() const
get a copy of model
Definition JacobianFactor.h:338
JacobianFactor(const GaussianFactor &gf)
Convert from other GaussianFactor.
Definition JacobianFactor.cpp:51
JacobianFactor(const JacobianFactor &jf)
Copy constructor.
Definition JacobianFactor.h:115
JacobianFactor This
Typedef to this class.
Definition JacobianFactor.h:95
bool isConstrained() const
is noise model constrained ?
Definition JacobianFactor.h:316
constABlock getA() const
Get a view of the A matrix, not weighted by noise.
Definition JacobianFactor.h:350
GaussianFactor::shared_ptr clone() const override
Clone this JacobianFactor.
Definition JacobianFactor.h:226
bool isJacobian() const override
Identify JacobianFactor-based types.
Definition JacobianFactor.h:232
ABlock getA(iterator variable)
Get a view of the A matrix for the variable pointed to by the given key iterator (non-const version).
Definition JacobianFactor.h:356
SharedDiagonal & get_model()
get a copy of model (non-const version)
Definition JacobianFactor.h:341
DenseIndex getDim(const_iterator variable) const override
Return the dimension of the variable pointed to by the given key iterator todo: Remove this in favor ...
Definition JacobianFactor.h:323
VerticalBlockMatrix & matrixObject()
Mutable access to the full augmented Jacobian matrix of this factor as a VerticalBlockMatrix object.
Definition JacobianFactor.h:306
ABlock getA()
Get a view of the A matrix.
Definition JacobianFactor.h:359
GaussianFactor Base
Typedef to base class.
Definition JacobianFactor.h:96
~JacobianFactor() override
Virtual destructor.
Definition JacobianFactor.h:223
const VerticalBlockMatrix & matrixObject() const
Return the full augmented Jacobian matrix of this factor as a VerticalBlockMatrix object.
Definition JacobianFactor.h:303
size_t rows() const
return the number of rows in the corresponding linear system
Definition JacobianFactor.h:330
std::shared_ptr< This > shared_ptr
shared_ptr to this class
Definition JacobianFactor.h:97
size_t cols() const
return the number of columns in the corresponding linear system
Definition JacobianFactor.h:335
ABlock getA(const Key &key)
Get a view of the A matrix for the variable pointed to by the given key.
Definition JacobianFactor.h:365
constABlock getA(const_iterator variable) const
Get a view of the A matrix for the variable pointed to by the given key iterator.
Definition JacobianFactor.h:347
VectorValues represents a collection of vector-valued variables associated each with a unique integer...
Definition VectorValues.h:73
The Factor::error simply extracts the.