26 #include <boost/make_shared.hpp>
33 class GaussianFactorGraph;
34 class GaussianConditional;
40 GTSAM_EXPORT std::pair<boost::shared_ptr<GaussianConditional>, boost::shared_ptr<JacobianFactor> >
41 EliminateQR(
const GaussianFactorGraph& factors,
const Ordering& keys);
91 noiseModel::Diagonal::shared_ptr model_;
94 typedef VerticalBlockMatrix::Block ABlock;
95 typedef VerticalBlockMatrix::constBlock constABlock;
96 typedef ABlock::ColXpr BVector;
97 typedef constABlock::ConstColXpr constBVector;
117 const Vector& b,
const SharedDiagonal& model = SharedDiagonal());
121 Key i2,
const Matrix& A2,
122 const Vector& b,
const SharedDiagonal& model = SharedDiagonal());
126 const Matrix& A2,
Key i3,
const Matrix& A3,
127 const Vector& b,
const SharedDiagonal& model = SharedDiagonal());
132 template<
typename TERMS>
133 JacobianFactor(
const TERMS& terms,
const Vector& b,
const SharedDiagonal& model = SharedDiagonal());
139 template<
typename KEYS>
141 const KEYS& keys,
const VerticalBlockMatrix& augmentedMatrix,
const SharedDiagonal& sigmas = SharedDiagonal());
149 boost::optional<const Ordering&> ordering = boost::none,
150 boost::optional<const VariableSlots&> variableSlots = boost::none);
158 boost::make_shared<JacobianFactor>(*this));
162 virtual void print(
const std::string& s =
"",
163 const KeyFormatter& formatter = DefaultKeyFormatter)
const;
178 virtual Matrix augmentedInformation()
const;
183 virtual Matrix information()
const;
189 virtual void hessianDiagonal(
double* d)
const;
192 virtual std::map<Key,Matrix> hessianBlockDiagonal()
const;
197 virtual std::pair<Matrix, Vector> jacobian()
const;
202 std::pair<Matrix, Vector> jacobianUnweighted()
const;
207 virtual Matrix augmentedJacobian()
const;
212 Matrix augmentedJacobianUnweighted()
const;
228 virtual bool empty()
const {
return size() == 0 ; }
241 size_t rows()
const {
return Ab_.rows(); }
246 size_t cols()
const {
return Ab_.cols(); }
249 const SharedDiagonal&
get_model()
const {
return model_; }
255 const constBVector
getb()
const {
return Ab_(size()).col(0); }
261 constABlock
getA()
const {
return Ab_.range(0, size()); }
264 BVector
getb() {
return Ab_(size()).col(0); }
270 ABlock
getA() {
return Ab_.range(0, size()); }
282 void multiplyHessianAdd(
double alpha,
const double* x,
double* y, std::vector<size_t> keys)
const;
290 virtual void gradientAtZero(
double* d)
const;
296 std::pair<boost::shared_ptr<GaussianConditional>, boost::shared_ptr<JacobianFactor> >
300 void setModel(
bool anyConstrained,
const Vector& sigmas);
313 friend GTSAM_EXPORT std::pair<boost::shared_ptr<GaussianConditional>, boost::shared_ptr<JacobianFactor> >
321 boost::shared_ptr<GaussianConditional> splitConditional(
size_t nrFrontals);
326 template<
typename TERMS>
327 void fillTerms(
const TERMS& terms,
const Vector& b,
const SharedDiagonal& noiseModel);
332 friend class boost::serialization::access;
333 template<
class ARCHIVE>
334 void serialize(ARCHIVE & ar,
const unsigned int version) {
335 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(
Base);
336 ar & BOOST_SERIALIZATION_NVP(Ab_);
337 ar & BOOST_SERIALIZATION_NVP(model_);
343 #include <gtsam/linear/JacobianFactor-inl.h>
void transposeMultiplyAdd(double alpha, const Matrix &A, const Vector &e, Vector &x)
BLAS Level-2 style x <- x + alpha*A'*e.
Definition: Matrix.cpp:168
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:236
size_t cols() const
return the number of columns in the corresponding linear system
Definition: JacobianFactor.h:246
SharedDiagonal & get_model()
get a copy of model (non-const version)
Definition: JacobianFactor.h:252
ABlock getA()
Get a view of the A matrix.
Definition: JacobianFactor.h:270
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:258
A Gaussian factor using the canonical parameters (information form)
Definition: HessianFactor.h:131
const VerticalBlockMatrix & matrixObject() const
Return the full augmented Jacobian matrix of this factor as a VerticalBlockMatrix object...
Definition: JacobianFactor.h:215
const SharedDiagonal & get_model() const
get a copy of model
Definition: JacobianFactor.h:249
JacobianFactor(const JacobianFactor &jf)
Copy constructor.
Definition: JacobianFactor.h:104
Definition: VerticalBlockMatrix.h:41
A Gaussian factor in the squared-error form.
Definition: JacobianFactor.h:82
This is the base class for all factor types.
Definition: Factor.h:51
Included from all GTSAM files.
GaussianFactor Base
Typedef to base class.
Definition: JacobianFactor.h:86
Point2 operator*(double s, const Point2 &p)
multiply with scalar
Definition: Point2.h:249
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:267
BVector getb()
Get a view of the r.h.s.
Definition: JacobianFactor.h:264
void print(const Matrix &A, const string &s, ostream &stream)
print a matrix
Definition: Matrix.cpp:183
constABlock getA() const
Get a view of the A matrix, not weighted by noise.
Definition: JacobianFactor.h:261
virtual ~JacobianFactor()
Virtual destructor.
Definition: JacobianFactor.h:153
A factor with a quadratic error function - a Gaussian.
A matrix with column blocks of pre-defined sizes.
void multiplyHessianAdd(double alpha, const double *x, double *y) const
y += alpha * A'*A*x
Definition: JacobianFactor.h:284
Template to create a binary predicate.
Definition: Testable.h:102
bool isConstrained() const
is noise model constrained ?
Definition: JacobianFactor.h:231
size_t Key
Integer nonlinear key type.
Definition: types.h:59
ptrdiff_t DenseIndex
The index type for Eigen objects.
Definition: types.h:74
boost::shared_ptr< This > shared_ptr
shared_ptr to this class
Definition: GaussianFactor.h:39
virtual GaussianFactor::shared_ptr clone() const
Clone this JacobianFactor.
Definition: JacobianFactor.h:156
FastVector< Key >::iterator iterator
Iterator over keys.
Definition: Factor.h:61
virtual bool empty() const
Check if the factor is empty.
Definition: JacobianFactor.h:228
This class represents a collection of vector-valued variables associated each with a unique integer i...
Definition: VectorValues.h:89
A Linear Factor Graph is a factor graph where all factors are Gaussian, i.e.
Definition: GaussianFactorGraph.h:65
JacobianFactor This
Typedef to this class.
Definition: JacobianFactor.h:85
Definition: Ordering.h:30
size_t rows() const
return the number of rows in the corresponding linear system
Definition: JacobianFactor.h:241
const constBVector getb() const
Get a view of the r.h.s.
Definition: JacobianFactor.h:255
boost::shared_ptr< This > shared_ptr
shared_ptr to this class
Definition: JacobianFactor.h:87
boost::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition: types.h:62
FastVector< Key >::const_iterator const_iterator
Const iterator over keys.
Definition: Factor.h:64
VerticalBlockMatrix & matrixObject()
Mutable access to the full augmented Jacobian matrix of this factor as a VerticalBlockMatrix object...
Definition: JacobianFactor.h:218
An abstract virtual base class for JacobianFactor and HessianFactor.
Definition: GaussianFactor.h:35