Momentum
A library for solving nonlinear optimization problems related to human body kinematics
Loading...
Searching...
No Matches
momentum::OnlineBlockHouseholderQR< T > Class Template Reference

Online Householder QR solver for least-squares problems with block-arrowhead structure. More...

#include <online_householder_qr.h>

Public Types

using MatrixType = Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>
using VectorType = Eigen::Matrix<T, Eigen::Dynamic, 1>

Public Member Functions

 OnlineBlockHouseholderQR (Eigen::Index n_common, T lambda=T(0))
 Constructs a solver for problems with n_common shared unknowns.
void add (size_t iBlock, MatrixType A_diag, MatrixType A_common, VectorType b)
 Copying overload of addMutating().
void addMutating (size_t iBlock, Eigen::Ref< MatrixType > A_diag, Eigen::Ref< MatrixType > A_common, Eigen::Ref< VectorType > b)
 In-place addition; convenience wrapper that wraps the matrices in ColumnIndexedMatrix views without remapping.
void addMutating (size_t iBlock, ColumnIndexedMatrix< MatrixType > A_diag, ColumnIndexedMatrix< MatrixType > A_common, Eigen::Ref< VectorType > b)
 In-place addition that also accepts column-remapped views, so callers can pass arbitrary subsets of the columns in A_diag and A_common.
VectorType x_dense () const
 Retrieves the full dense result [x_0; x_1; ...; x_{B-1}; x_n].
VectorType x_i (size_t iBlock) const
 Retrieves the answer for a single diagonal block iBlock.
VectorType x_n () const
 Retrieves the answer for just the final "common" rows.
const MatrixType & R_ii (size_t iBlock) const
const VectorType & y_i (size_t iBlock) const
MatrixType R_dense () const
MatrixType y_dense () const
VectorType At_times_b_i (size_t iBlock) const
VectorType At_times_b_n () const
VectorType At_times_b_dense () const
T At_times_b_dot (Eigen::Ref< const VectorType > rhs) const
void reset ()

Detailed Description

template<typename T>
class momentum::OnlineBlockHouseholderQR< T >

Online Householder QR solver for least-squares problems with block-arrowhead structure.

Solves

min || A * x - b ||_2

where A has the block structure

[ A_11 A_1n ]
[ A_22 A_2n ]
[ A_33 A_3n ]
[ ... ... ]

i.e. independent diagonal blocks A_ii (one set of disjoint x_i per block) plus a shared set of "common" columns A_in that are used by every block.

This is the case for calibration problems, where each hand pose is independent but a shared set of calibration parameters connects them.

Besides the blockwise structure, the behavior of this solver is identical to OnlineHouseholderQR — see that class's notes for the algorithmic details. The key takeaway is that this can be used in an online fashion: poses are passed in one at a time and the Jacobians can then be thrown away.

Note
A future version could also discard the intermediate R_ii_ and R_in_ blocks if memory becomes an issue (only R_nn_ is required to compute x_n()).

Usage contract

  1. Construct with the number of common unknowns n_common and (optionally) lambda damping. Diagonal block sizes are inferred from each add() call.
  2. Call add()/addMutating() once per block, supplying a unique iBlock index. Internal R_ii_, R_in_, R_nn_, y_i_, and y_n_ are mutated incrementally.
  3. Retrieve results via x_dense(), x_i(iBlock), or x_n().
  4. Call reset() to discard accumulated state and reuse the solver.

Definition at line 260 of file online_householder_qr.h.

Member Typedef Documentation

◆ MatrixType

template<typename T>
using momentum::OnlineBlockHouseholderQR< T >::MatrixType = Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>

Definition at line 262 of file online_householder_qr.h.

◆ VectorType

template<typename T>
using momentum::OnlineBlockHouseholderQR< T >::VectorType = Eigen::Matrix<T, Eigen::Dynamic, 1>

Definition at line 263 of file online_householder_qr.h.

Constructor & Destructor Documentation

◆ OnlineBlockHouseholderQR()

template<typename T>
momentum::OnlineBlockHouseholderQR< T >::OnlineBlockHouseholderQR ( Eigen::Index n_common,
T lambda = T(0) )
explicit

Constructs a solver for problems with n_common shared unknowns.

Per-block unknown counts are determined from the first add() call for each block. lambda implements LM-style damping, emulating

| [ lambda * I ] [ x ] - [ 0 ] |^2
| [ A ] [ b ] |

without materializing the extra rows.

Definition at line 249 of file online_householder_qr.cpp.

Member Function Documentation

◆ add()

template<typename T>
void momentum::OnlineBlockHouseholderQR< T >::add ( size_t iBlock,
MatrixType A_diag,
MatrixType A_common,
VectorType b )
inline

Copying overload of addMutating().

Definition at line 277 of file online_householder_qr.h.

References addMutating().

◆ addMutating() [1/2]

template<typename T>
void momentum::OnlineBlockHouseholderQR< T >::addMutating ( size_t iBlock,
ColumnIndexedMatrix< MatrixType > A_diag,
ColumnIndexedMatrix< MatrixType > A_common,
Eigen::Ref< VectorType > b )

In-place addition that also accepts column-remapped views, so callers can pass arbitrary subsets of the columns in A_diag and A_common.

Parameters
iBlockIndex identifying the diagonal block this contribution belongs to. The first call with a given iBlock fixes the size of R_ii_[iBlock]; later calls must provide a matching A_diag.cols().
A_diagBlock-local Jacobian columns for this iBlock. A_diag.cols() defines the per-block unknown count.
A_commonJacobian columns for the shared unknowns. Must have n_common columns.
bResidual vector with A_diag.rows() entries.
Postcondition
R_ii_[iBlock], R_in_[iBlock], R_nn_, y_i_[iBlock], and y_n_ are updated. The contents of A_diag, A_common, and b are arbitrary on return.

Definition at line 257 of file online_householder_qr.cpp.

References momentum::ColumnIndexedMatrix< MatrixType >::col(), momentum::ColumnIndexedMatrix< MatrixType >::cols(), MT_CHECK, R_ii(), momentum::ColumnIndexedMatrix< MatrixType >::rows(), and y_i().

◆ addMutating() [2/2]

template<typename T>
void momentum::OnlineBlockHouseholderQR< T >::addMutating ( size_t iBlock,
Eigen::Ref< MatrixType > A_diag,
Eigen::Ref< MatrixType > A_common,
Eigen::Ref< VectorType > b )
inline

In-place addition; convenience wrapper that wraps the matrices in ColumnIndexedMatrix views without remapping.

Definition at line 283 of file online_householder_qr.h.

References addMutating().

Referenced by add(), addMutating(), and momentum::MultiposeSolverT< T >::doIteration().

◆ At_times_b_dense()

template<typename T>
OnlineBlockHouseholderQR< T >::VectorType momentum::OnlineBlockHouseholderQR< T >::At_times_b_dense ( ) const
nodiscard

Definition at line 477 of file online_householder_qr.cpp.

References y_i().

Referenced by At_times_b_dot().

◆ At_times_b_dot()

template<typename T>
T momentum::OnlineBlockHouseholderQR< T >::At_times_b_dot ( Eigen::Ref< const VectorType > rhs) const
nodiscard

Definition at line 501 of file online_householder_qr.cpp.

References At_times_b_dense().

◆ At_times_b_i()

template<typename T>
OnlineBlockHouseholderQR< T >::VectorType momentum::OnlineBlockHouseholderQR< T >::At_times_b_i ( size_t iBlock) const
nodiscard

Definition at line 457 of file online_householder_qr.cpp.

◆ At_times_b_n()

template<typename T>
OnlineBlockHouseholderQR< T >::VectorType momentum::OnlineBlockHouseholderQR< T >::At_times_b_n ( ) const
nodiscard

Definition at line 466 of file online_householder_qr.cpp.

◆ R_dense()

template<typename T>
OnlineBlockHouseholderQR< T >::MatrixType momentum::OnlineBlockHouseholderQR< T >::R_dense ( ) const
nodiscard

Definition at line 365 of file online_householder_qr.cpp.

References MT_CHECK, and R_ii().

◆ R_ii()

template<typename T>
const MatrixType & momentum::OnlineBlockHouseholderQR< T >::R_ii ( size_t iBlock) const
inlinenodiscard

Definition at line 332 of file online_householder_qr.h.

Referenced by addMutating(), and R_dense().

◆ reset()

template<typename T>
void momentum::OnlineBlockHouseholderQR< T >::reset ( )

Definition at line 506 of file online_householder_qr.cpp.

◆ x_dense()

template<typename T>
OnlineBlockHouseholderQR< T >::VectorType momentum::OnlineBlockHouseholderQR< T >::x_dense ( ) const
nodiscard

Retrieves the full dense result [x_0; x_1; ...; x_{B-1}; x_n].

Definition at line 414 of file online_householder_qr.cpp.

References x_n().

Referenced by momentum::MultiposeSolverT< T >::doIteration().

◆ x_i()

template<typename T>
OnlineBlockHouseholderQR< T >::VectorType momentum::OnlineBlockHouseholderQR< T >::x_i ( size_t iBlock) const
nodiscard

Retrieves the answer for a single diagonal block iBlock.

Note
Re-runs the back-substitution for the final ("common") rows on each call; batch-retrieve via x_dense() if calling for many blocks.

Definition at line 450 of file online_householder_qr.cpp.

◆ x_n()

template<typename T>
OnlineBlockHouseholderQR< T >::VectorType momentum::OnlineBlockHouseholderQR< T >::x_n ( ) const
nodiscard

Retrieves the answer for just the final "common" rows.

Definition at line 445 of file online_householder_qr.cpp.

Referenced by x_dense().

◆ y_dense()

template<typename T>
OnlineBlockHouseholderQR< T >::MatrixType momentum::OnlineBlockHouseholderQR< T >::y_dense ( ) const
nodiscard

Definition at line 391 of file online_householder_qr.cpp.

References y_i().

◆ y_i()

template<typename T>
const VectorType & momentum::OnlineBlockHouseholderQR< T >::y_i ( size_t iBlock) const
inlinenodiscard

Definition at line 336 of file online_householder_qr.h.

Referenced by addMutating(), At_times_b_dense(), and y_dense().


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