gtsam
Loading...
Searching...
No Matches
gtsam::BatchJacobianFactorBase Class Referenceabstract

Detailed Description

Common interface for compact batch Jacobian factors.

BatchJacobianFactorBase gives solvers a way to recognize compact batched Jacobian storage without treating it as a regular dense-block JacobianFactor. Generic GaussianFactor methods keep working through toJacobianFactor(), while the internal elimination adapter can access the compact storage without materializing structural zeros.

The intended fast path is a factor whose row blocks have already been whitened and therefore has either no model or a unit model. Non-unit diagonal models are still supported for compatibility paths.

Inheritance diagram for gtsam::BatchJacobianFactorBase:

Public Member Functions

virtual size_t rows () const =0
 Number of scalar rows represented by this factor.
virtual const SharedDiagonal & get_model () const =0
 Optional model on the compact factor. The intended fast path is whitened.
virtual JacobianFactor toJacobianFactor () const =0
 Convert compact storage to a dense-block JacobianFactor.
void print (const std::string &s="", const KeyFormatter &formatter=DefaultKeyFormatter) const override
 Print this compact factor by converting to a JacobianFactor.
bool equals (const GaussianFactor &factor, double tol=1e-9) const override
 Test equality by comparing dense JacobianFactor representations.
double error (const VectorValues &values) const override
 Compute the factor error by delegating to the dense compatibility factor.
double deltaError (const VectorValues &values, double *oldError=nullptr, double *newError=nullptr) const override
 Compute the error change by delegating to the dense compatibility factor.
Matrix augmentedJacobian () const override
 Return the dense augmented Jacobian matrix for compatibility callers.
std::pair< Matrix, Vector > jacobian () const override
 Return the dense Jacobian matrix and right-hand side vector.
Matrix augmentedInformation () const override
 Return the dense augmented information matrix for compatibility callers.
Matrix information () const override
 Return the dense information matrix for compatibility callers.
void hessianDiagonalAdd (VectorValues &diagonal) const override
 Add this factor's Hessian diagonal into the given VectorValues.
void hessianDiagonal (double *diagonal) const override
 Add this factor's Hessian diagonal into a raw scalar buffer.
std::map< Key, Matrix > hessianBlockDiagonal () const override
 Return the Hessian diagonal blocks keyed by variable.
GaussianFactor::shared_ptr negate () const override
 Return a factor representing the negated linear system.
void updateHessian (const KeyVector &keys, SymmetricBlockMatrix *info) const override
 Update the augmented Hessian using key lookup through the dense fallback.
virtual void multiplyHessianAdd (double alpha, const std::vector< size_t > &scalarOffsets, const double *x, double *y) const override
 Add this factor's Hessian-vector product using scalar offsets for keys().
virtual void gradientAtZeroAdd (const std::vector< size_t > &scalarOffsets, double *gradient) const override
 Add this factor's gradient at zero to a flat vector.
virtual void hessianBlockDiagonalAdd (const std::vector< size_t > &blockSlots, std::vector< Matrix > *diagonalBlocks) const override
 Add this factor's Hessian diagonal to ordered blocks.
void updateHessian (const KeyVector &keys, SymmetricBlockMatrix *info, DenseIndex beginCol, DenseIndex endCol) const override
 Update a column range of the augmented Hessian using the dense fallback.
void multiplyHessianAdd (double alpha, const VectorValues &x, VectorValues &y) const override
 Add the Hessian-vector product into y using the dense fallback.
VectorValues gradientAtZero () const override
 Return the full gradient evaluated at zero.
void gradientAtZero (double *d) const override
 Add the gradient evaluated at zero into a raw scalar buffer.
Vector gradient (Key key, const VectorValues &x) const override
 Return the gradient block for one key at the given linearization point.
 GaussianFactor ()
 Inherit GaussianFactor constructors.
template<typename CONTAINER>
 GaussianFactor (const CONTAINER &keys)
 Inherit GaussianFactor constructors.
Public Member Functions inherited from gtsam::GaussianFactor
 GaussianFactor ()
 Default constructor creates empty factor.
template<typename CONTAINER>
 GaussianFactor (const CONTAINER &keys)
 Construct from container of keys.
double error (const HybridValues &c) const override
 All factor types need to implement an error function.
virtual DenseIndex getDim (const_iterator variable) const =0
 Return the dimension of the variable pointed to by the given key iterator.
VectorValues hessianDiagonal () const
 Return the diagonal of the Hessian for this factor.
virtual GaussianFactor::shared_ptr clone () const =0
 Clone a factor (make a deep copy).
virtual bool isJacobian () const
 Fast check for JacobianFactor-based types.
Public Member Functions inherited from gtsam::Factor
virtual ~Factor ()=default
 Default destructor.
bool empty () const
 Whether the factor is empty (involves zero variables).
Key front () const
 First key.
Key back () const
 Last key.
const_iterator find (Key key) const
 find
const KeyVector & keys () const
 Access the factor's involved variable keys.
const_iterator begin () const
 Iterator at beginning of involved variable keys.
const_iterator end () const
 Iterator at end of involved variable keys.
size_t size () const
virtual void printKeys (const std::string &s="Factor", const KeyFormatter &formatter=DefaultKeyFormatter) const
 print only keys
bool equals (const This &other, double tol=1e-9) const
 check equality
KeyVector & keys ()
iterator begin ()
 Iterator at beginning of involved variable keys.
iterator end ()
 Iterator at end of involved variable keys.

Friends

class internal::BatchJacobianFactorElimination

Additional Inherited Members

template<typename CONTAINER>
static DenseIndex Slot (const CONTAINER &keys, Key key)
Public Types inherited from gtsam::GaussianFactor
typedef GaussianFactor This
 This class.
typedef std::shared_ptr< This > shared_ptr
 shared_ptr to this class
typedef Factor Base
 Our base class.
Public Types inherited from gtsam::Factor
typedef KeyVector::iterator iterator
 Iterator over keys.
typedef KeyVector::const_iterator const_iterator
 Const iterator over keys.
 Factor ()
 Default constructor for I/O.
template<typename CONTAINER>
 Factor (const CONTAINER &keys)
 Construct factor from container of keys.
template<typename ITERATOR>
 Factor (ITERATOR first, ITERATOR last)
 Construct factor from iterator keys.
template<typename CONTAINER>
static Factor FromKeys (const CONTAINER &keys)
 Construct factor from container of keys.
template<typename ITERATOR>
static Factor FromIterators (ITERATOR first, ITERATOR last)
 Construct factor from iterator keys.
Protected Attributes inherited from gtsam::Factor
KeyVector keys_
 The keys involved in this factor.

Member Function Documentation

◆ augmentedInformation()

Matrix gtsam::BatchJacobianFactorBase::augmentedInformation ( ) const
inlineoverridevirtual

Return the dense augmented information matrix for compatibility callers.

Implements gtsam::GaussianFactor.

◆ augmentedJacobian()

Matrix gtsam::BatchJacobianFactorBase::augmentedJacobian ( ) const
inlineoverridevirtual

Return the dense augmented Jacobian matrix for compatibility callers.

Implements gtsam::GaussianFactor.

◆ deltaError()

double gtsam::BatchJacobianFactorBase::deltaError ( const VectorValues & values,
double * oldError = nullptr,
double * newError = nullptr ) const
inlineoverridevirtual

Compute the error change by delegating to the dense compatibility factor.

Reimplemented from gtsam::GaussianFactor.

◆ equals()

bool gtsam::BatchJacobianFactorBase::equals ( const GaussianFactor & factor,
double tol = 1e-9 ) const
inlineoverridevirtual

Test equality by comparing dense JacobianFactor representations.

Implements gtsam::GaussianFactor.

◆ error()

double gtsam::BatchJacobianFactorBase::error ( const VectorValues & values) const
inlineoverridevirtual

Compute the factor error by delegating to the dense compatibility factor.

Reimplemented from gtsam::GaussianFactor.

◆ get_model()

virtual const SharedDiagonal & gtsam::BatchJacobianFactorBase::get_model ( ) const
pure virtual

Optional model on the compact factor. The intended fast path is whitened.

Implemented in gtsam::BatchJacobianFactor< ErrorDim, BlockDims >, and gtsam::BatchJacobianFactor< ErrorDim, BlockDims... >.

◆ gradient()

Vector gtsam::BatchJacobianFactorBase::gradient ( Key key,
const VectorValues & x ) const
inlineoverridevirtual

Return the gradient block for one key at the given linearization point.

Implements gtsam::GaussianFactor.

◆ gradientAtZero() [1/2]

VectorValues gtsam::BatchJacobianFactorBase::gradientAtZero ( ) const
inlineoverridevirtual

Return the full gradient evaluated at zero.

Implements gtsam::GaussianFactor.

◆ gradientAtZero() [2/2]

void gtsam::BatchJacobianFactorBase::gradientAtZero ( double * d) const
inlineoverridevirtual

Add the gradient evaluated at zero into a raw scalar buffer.

Implements gtsam::GaussianFactor.

◆ gradientAtZeroAdd()

virtual void gtsam::BatchJacobianFactorBase::gradientAtZeroAdd ( const std::vector< size_t > & scalarOffsets,
double * gradient ) const
inlineoverridevirtual

Add this factor's gradient at zero to a flat vector.

Parameters
scalarOffsetsFlat-vector offset for each entry in keys().
gradientOutput vector to which the gradient is added.
Exceptions
std::invalid_argumentif the offset count differs from size().

Implements gtsam::FlatGaussianFactor.

Reimplemented in gtsam::BatchJacobianFactor< ErrorDim, BlockDims >, and gtsam::BatchJacobianFactor< ErrorDim, BlockDims... >.

◆ hessianBlockDiagonal()

std::map< Key, Matrix > gtsam::BatchJacobianFactorBase::hessianBlockDiagonal ( ) const
inlineoverridevirtual

Return the Hessian diagonal blocks keyed by variable.

Implements gtsam::GaussianFactor.

◆ hessianBlockDiagonalAdd()

virtual void gtsam::BatchJacobianFactorBase::hessianBlockDiagonalAdd ( const std::vector< size_t > & blockSlots,
std::vector< Matrix > * diagonalBlocks ) const
inlineoverridevirtual

Add this factor's Hessian diagonal to ordered blocks.

Parameters
blockSlotsOutput block slot for each entry in keys().
diagonalBlocksBlocks to which diagonal contributions are added.
Exceptions
std::invalid_argumentif the slot count differs from size().

Implements gtsam::FlatGaussianFactor.

Reimplemented in gtsam::BatchJacobianFactor< ErrorDim, BlockDims >, and gtsam::BatchJacobianFactor< ErrorDim, BlockDims... >.

◆ hessianDiagonal()

void gtsam::BatchJacobianFactorBase::hessianDiagonal ( double * diagonal) const
inlineoverridevirtual

Add this factor's Hessian diagonal into a raw scalar buffer.

Implements gtsam::GaussianFactor.

◆ hessianDiagonalAdd()

void gtsam::BatchJacobianFactorBase::hessianDiagonalAdd ( VectorValues & diagonal) const
inlineoverridevirtual

Add this factor's Hessian diagonal into the given VectorValues.

Implements gtsam::GaussianFactor.

◆ information()

Matrix gtsam::BatchJacobianFactorBase::information ( ) const
inlineoverridevirtual

Return the dense information matrix for compatibility callers.

Implements gtsam::GaussianFactor.

◆ jacobian()

std::pair< Matrix, Vector > gtsam::BatchJacobianFactorBase::jacobian ( ) const
inlineoverridevirtual

Return the dense Jacobian matrix and right-hand side vector.

Implements gtsam::GaussianFactor.

◆ multiplyHessianAdd() [1/2]

virtual void gtsam::BatchJacobianFactorBase::multiplyHessianAdd ( double alpha,
const std::vector< size_t > & scalarOffsets,
const double * x,
double * y ) const
inlineoverridevirtual

Add this factor's Hessian-vector product using scalar offsets for keys().

This flat-vector interface avoids materializing a dense JacobianFactor.

Parameters
alphaScale applied to this factor's contribution.
scalarOffsetsFlat-vector offset for each entry in keys().
xInput vector containing every referenced key block.
yOutput vector to which the scaled product is added.
Exceptions
std::invalid_argumentif the offset count differs from size().

Implements gtsam::FlatGaussianFactor.

Reimplemented in gtsam::BatchJacobianFactor< ErrorDim, BlockDims >, and gtsam::BatchJacobianFactor< ErrorDim, BlockDims... >.

◆ multiplyHessianAdd() [2/2]

void gtsam::BatchJacobianFactorBase::multiplyHessianAdd ( double alpha,
const VectorValues & x,
VectorValues & y ) const
inlineoverridevirtual

Add the Hessian-vector product into y using the dense fallback.

Implements gtsam::GaussianFactor.

◆ negate()

GaussianFactor::shared_ptr gtsam::BatchJacobianFactorBase::negate ( ) const
inlineoverridevirtual

Return a factor representing the negated linear system.

Implements gtsam::GaussianFactor.

◆ print()

void gtsam::BatchJacobianFactorBase::print ( const std::string & s = "",
const KeyFormatter & formatter = DefaultKeyFormatter ) const
inlineoverridevirtual

Print this compact factor by converting to a JacobianFactor.

Implements gtsam::GaussianFactor.

◆ rows()

virtual size_t gtsam::BatchJacobianFactorBase::rows ( ) const
pure virtual

Number of scalar rows represented by this factor.

Implemented in gtsam::BatchJacobianFactor< ErrorDim, BlockDims >, and gtsam::BatchJacobianFactor< ErrorDim, BlockDims... >.

◆ toJacobianFactor()

virtual JacobianFactor gtsam::BatchJacobianFactorBase::toJacobianFactor ( ) const
pure virtual

◆ updateHessian() [1/2]

void gtsam::BatchJacobianFactorBase::updateHessian ( const KeyVector & keys,
SymmetricBlockMatrix * info ) const
inlineoverridevirtual

Update the augmented Hessian using key lookup through the dense fallback.

Implements gtsam::GaussianFactor.

◆ updateHessian() [2/2]

void gtsam::BatchJacobianFactorBase::updateHessian ( const KeyVector & keys,
SymmetricBlockMatrix * info,
DenseIndex beginCol,
DenseIndex endCol ) const
inlineoverridevirtual

Update a column range of the augmented Hessian using the dense fallback.

Implements gtsam::GaussianFactor.


The documentation for this class was generated from the following file: