26 #include <boost/make_shared.hpp> 33 class GaussianFactorGraph;
34 class GaussianConditional;
45 GTSAM_EXPORT std::pair<boost::shared_ptr<GaussianConditional>, boost::shared_ptr<JacobianFactor> >
46 EliminateQR(
const GaussianFactorGraph& factors,
const Ordering& keys);
95 typedef VerticalBlockMatrix::Block ABlock;
96 typedef VerticalBlockMatrix::constBlock constABlock;
97 typedef ABlock::ColXpr BVector;
98 typedef constABlock::ConstColXpr constBVector;
103 noiseModel::Diagonal::shared_ptr model_;
124 const Vector& b,
const SharedDiagonal& model = SharedDiagonal());
128 Key i2,
const Matrix& A2,
129 const Vector& b,
const SharedDiagonal& model = SharedDiagonal());
133 const Matrix& A2,
Key i3,
const Matrix& A3,
134 const Vector& b,
const SharedDiagonal& model = SharedDiagonal());
139 template<
typename TERMS>
140 JacobianFactor(
const TERMS& terms,
const Vector& b,
const SharedDiagonal& model = SharedDiagonal());
146 template<
typename KEYS>
148 const KEYS& keys,
const VerticalBlockMatrix& augmentedMatrix,
const SharedDiagonal& sigmas = SharedDiagonal());
156 boost::optional<const Ordering&> ordering = boost::none,
157 boost::optional<const VariableSlots&> p_variableSlots = boost::none);
164 return boost::static_pointer_cast<GaussianFactor>(
165 boost::make_shared<JacobianFactor>(*
this));
169 virtual void print(
const std::string& s =
"",
170 const KeyFormatter& formatter = DefaultKeyFormatter)
const;
185 virtual Matrix augmentedInformation()
const;
190 virtual Matrix information()
const;
196 virtual void hessianDiagonal(
double* d)
const;
199 virtual std::map<Key,Matrix> hessianBlockDiagonal()
const;
204 virtual std::pair<Matrix, Vector> jacobian()
const;
209 std::pair<Matrix, Vector> jacobianUnweighted()
const;
214 virtual Matrix augmentedJacobian()
const;
219 Matrix augmentedJacobianUnweighted()
const;
235 virtual bool empty()
const {
return size() == 0 ; }
239 return model_ && model_->isConstrained();
258 const SharedDiagonal&
get_model()
const {
return model_; }
264 const constBVector
getb()
const {
return Ab_(size()).col(0); }
270 constABlock
getA()
const {
return Ab_.
range(0, size()); }
273 BVector
getb() {
return Ab_(size()).col(0); }
293 void transposeMultiplyAdd(
double alpha,
const Vector& e,
VectorValues& x)
const;
306 void multiplyHessianAdd(
double alpha,
const double* x,
double* y,
307 const std::vector<size_t>& accumulatedDims)
const;
313 virtual void gradientAtZero(
double* d)
const;
322 std::pair<boost::shared_ptr<GaussianConditional>, shared_ptr>
326 void setModel(
bool anyConstrained,
const Vector& sigmas);
339 friend GTSAM_EXPORT std::pair<boost::shared_ptr<GaussianConditional>, shared_ptr>
349 boost::shared_ptr<GaussianConditional> splitConditional(
size_t nrFrontals);
354 template<
typename TERMS>
355 void fillTerms(
const TERMS& terms,
const Vector& b,
const SharedDiagonal& noiseModel);
365 template<
class KEYS,
class DIMENSIONS>
367 const SharedDiagonal& model = SharedDiagonal()) :
368 Base(keys), Ab_(dims.begin(), dims.end(), m, true), model_(model) {
372 template<
typename T>
friend class ExpressionFactor;
375 friend class boost::serialization::access;
376 template<
class ARCHIVE>
377 void serialize(ARCHIVE & ar,
const unsigned int ) {
378 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(
Base);
379 ar & BOOST_SERIALIZATION_NVP(Ab_);
380 ar & BOOST_SERIALIZATION_NVP(model_);
391 #include <gtsam/linear/JacobianFactor-inl.h> virtual bool empty() const
Check if the factor is empty.
Definition: JacobianFactor.h:235
DenseIndex cols() const
Column size.
Definition: VerticalBlockMatrix.h:117
This is the base class for all factor types.
Definition: Factor.h:54
ptrdiff_t DenseIndex
The index type for Eigen objects.
Definition: types.h:63
bool isConstrained() const
is noise model constrained ?
Definition: JacobianFactor.h:238
const constBVector getb() const
Get a view of the r.h.s.
Definition: JacobianFactor.h:264
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition: Matrix.cpp:141
boost::shared_ptr< This > shared_ptr
shared_ptr to this class
Definition: JacobianFactor.h:93
Block range(DenseIndex startBlock, DenseIndex endBlock)
access ranges of blocks at a time
Definition: VerticalBlockMatrix.h:129
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:57
Template to create a binary predicate.
Definition: Testable.h:110
A helper that implements the traits interface for GTSAM types.
Definition: Testable.h:150
A Linear Factor Graph is a factor graph where all factors are Gaussian, i.e.
Definition: GaussianFactorGraph.h:65
Included from all GTSAM files.
An abstract virtual base class for JacobianFactor and HessianFactor.
Definition: GaussianFactor.h:38
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:721
BVector getb()
Get a view of the r.h.s.
Definition: JacobianFactor.h:273
size_t rows() const
return the number of rows in the corresponding linear system
Definition: JacobianFactor.h:250
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:267
Definition: VerticalBlockMatrix.h:41
boost::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition: Key.h:33
constABlock getA() const
Get a view of the A matrix, not weighted by noise.
Definition: JacobianFactor.h:270
VerticalBlockMatrix & matrixObject()
Mutable access to the full augmented Jacobian matrix of this factor as a VerticalBlockMatrix object.
Definition: JacobianFactor.h:225
virtual ~JacobianFactor()
Virtual destructor.
Definition: JacobianFactor.h:160
size_t cols() const
return the number of columns in the corresponding linear system
Definition: JacobianFactor.h:255
This class represents a collection of vector-valued variables associated each with a unique integer i...
Definition: VectorValues.h:73
const VerticalBlockMatrix & matrixObject() const
Return the full augmented Jacobian matrix of this factor as a VerticalBlockMatrix object.
Definition: JacobianFactor.h:222
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
Definition: Key.h:56
SharedDiagonal & get_model()
get a copy of model (non-const version)
Definition: JacobianFactor.h:261
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition: concepts.h:30
JacobianFactor(const JacobianFactor &jf)
Copy constructor.
Definition: JacobianFactor.h:111
virtual DenseIndex getDim(const_iterator variable) const
Return the dimension of the variable pointed to by the given key iterator todo: Remove this in favor ...
Definition: JacobianFactor.h:245
JacobianFactor This
Typedef to this class.
Definition: JacobianFactor.h:91
A Gaussian factor in the squared-error form.
Definition: JacobianFactor.h:87
A matrix with column blocks of pre-defined sizes.
virtual GaussianFactor::shared_ptr clone() const
Clone this JacobianFactor.
Definition: JacobianFactor.h:163
A factor with a quadratic error function - a Gaussian.
Definition: SymmetricBlockMatrix.h:51
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
DenseIndex rows() const
Row size.
Definition: VerticalBlockMatrix.h:114
GaussianFactor Base
Typedef to base class.
Definition: JacobianFactor.h:92
ABlock getA()
Get a view of the A matrix.
Definition: JacobianFactor.h:279
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:276
KeyVector::iterator iterator
Iterator over keys.
Definition: Factor.h:64
KeyVector::const_iterator const_iterator
Const iterator over keys.
Definition: Factor.h:67
Definition: Ordering.h:34
const SharedDiagonal & get_model() const
get a copy of model
Definition: JacobianFactor.h:258
Point2 operator *(double s, const Point2 &p)
multiply with scalar
Definition: Point2.h:170
A Gaussian factor using the canonical parameters (information form)
Definition: HessianFactor.h:101
boost::shared_ptr< This > shared_ptr
shared_ptr to this class
Definition: GaussianFactor.h:42