|
Momentum
A library for solving nonlinear optimization problems related to human body kinematics
|
Online Householder QR solver for band-plus-arrowhead matrices. 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 | |
| OnlineBandedHouseholderQR (Eigen::Index n_band, Eigen::Index n_common, Eigen::Index bandwidth, T lambda=T(0)) | |
| Constructs a banded solver. | |
| void | add (size_t iCol_offset, MatrixType A_band, MatrixType A_common, VectorType b) |
| Copying overload of addMutating() that takes both banded and common contributions. | |
| void | add (MatrixType A_common, VectorType b) |
| Copying overload for contributions that only touch the common columns. | |
| void | addMutating (const Eigen::Index iCol_offset, Eigen::Ref< MatrixType > A_band, 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 (Eigen::Ref< MatrixType > A_common, Eigen::Ref< VectorType > b) |
| In-place addition for contributions that only touch the common columns. | |
| void | addMutating (Eigen::Index iCol_offset, ColumnIndexedMatrix< MatrixType > A_band, ColumnIndexedMatrix< MatrixType > A_common, Eigen::Ref< VectorType > b) |
In-place addition that accepts column-remapped views, so callers can pass arbitrary subsets of the columns in A_band and A_common. | |
| void | addMutating (ColumnIndexedMatrix< MatrixType > A_common, Eigen::Ref< VectorType > b) |
| Common-only addition overload. Use when a contribution touches no banded columns. | |
| void | zeroBandedPart (Eigen::Index iCol_offset, ColumnIndexedMatrix< MatrixType > A_band, ColumnIndexedMatrix< MatrixType > A_common, Eigen::Ref< VectorType > b) |
Zeros out just the banded part of A_band by applying Householder rotations. | |
| VectorType | x_dense () const |
| Retrieves the full dense result vector of length n_band() + n_common(). | |
| MatrixType | R_dense () const |
| MatrixType | y_dense () const |
| VectorType | At_times_b () const |
| void | reset () |
| Discards accumulated state, keeping the existing dimensions and damping. | |
| Eigen::Index | bandwidth () const |
| Eigen::Index | n_band () const |
| Eigen::Index | n_common () const |
Online Householder QR solver for band-plus-arrowhead matrices.
The left-hand part of the matrix is required to have a limited column-bandwidth, and a "common" section is permitted on the right, like this:
Here "bandwidth" is in columns; the matrix above has a bandwidth of 2 because no row spans more than two columns (excluding the common section). The common section holds parameters shared by every row.
While this seems specialized, it maps to a very common class of problems where the band structure represents a time dimension (smoothness constraints tend to connect adjacent timepoints) and the common parameters are shared across time. For example:
Definition at line 406 of file online_householder_qr.h.
| using momentum::OnlineBandedHouseholderQR< T >::MatrixType = Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> |
Definition at line 408 of file online_householder_qr.h.
| using momentum::OnlineBandedHouseholderQR< T >::VectorType = Eigen::Matrix<T, Eigen::Dynamic, 1> |
Definition at line 409 of file online_householder_qr.h.
|
explicit |
Constructs a banded solver.
| n_band | Number of banded (per-time) unknowns. |
| n_common | Number of common unknowns (the right-hand "arrowhead"). |
| bandwidth | Maximum number of banded columns any single row may touch. |
| lambda | LM-style damping; emulates the augmented system | [lambda*I; A] [x] - [0; b] |^2 without materializing the extra rows. |
Definition at line 520 of file online_householder_qr.cpp.
References bandwidth(), MT_CHECK, n_band(), and n_common().
|
inline |
Copying overload for contributions that only touch the common columns.
Definition at line 429 of file online_householder_qr.h.
References addMutating().
|
inline |
Copying overload of addMutating() that takes both banded and common contributions.
Definition at line 424 of file online_householder_qr.h.
References addMutating().
| void momentum::OnlineBandedHouseholderQR< T >::addMutating | ( | ColumnIndexedMatrix< MatrixType > | A_common, |
| Eigen::Ref< VectorType > | b ) |
Common-only addition overload. Use when a contribution touches no banded columns.
Definition at line 644 of file online_householder_qr.cpp.
References momentum::ColumnIndexedMatrix< MatrixType >::col(), momentum::ColumnIndexedMatrix< MatrixType >::cols(), MT_CHECK, n_band(), n_common(), and momentum::ColumnIndexedMatrix< MatrixType >::rows().
|
inline |
In-place addition; convenience wrapper that wraps the matrices in ColumnIndexedMatrix views without remapping.
Definition at line 435 of file online_householder_qr.h.
References addMutating().
Referenced by add(), add(), addMutating(), addMutating(), and addMutating().
| void momentum::OnlineBandedHouseholderQR< T >::addMutating | ( | Eigen::Index | iCol_offset, |
| ColumnIndexedMatrix< MatrixType > | A_band, | ||
| ColumnIndexedMatrix< MatrixType > | A_common, | ||
| Eigen::Ref< VectorType > | b ) |
In-place addition that accepts column-remapped views, so callers can pass arbitrary subsets of the columns in A_band and A_common.
| iCol_offset | Global column index of A_band's left-most column. Must satisfy iCol_offset + A_band.cols() <= n_band(). |
| A_band | Banded contribution. A_band.cols() must be at most bandwidth(). |
| A_common | Common contribution. A_common.cols() must equal n_common(). |
| b | Residual vector with A_band.rows() entries. |
A_band, A_common, and b are arbitrary on return. Definition at line 569 of file online_householder_qr.cpp.
References addMutating(), and zeroBandedPart().
|
inline |
In-place addition for contributions that only touch the common columns.
Definition at line 448 of file online_householder_qr.h.
References addMutating().
|
nodiscard |
Definition at line 756 of file online_householder_qr.cpp.
References bandwidth(), n_band(), and n_common().
Referenced by momentum::SequenceSolverT< T >::doIteration().
|
inlinenodiscard |
Definition at line 517 of file online_householder_qr.h.
Referenced by At_times_b(), OnlineBandedHouseholderQR(), R_dense(), and x_dense().
|
inlinenodiscard |
Definition at line 521 of file online_householder_qr.h.
Referenced by addMutating(), At_times_b(), OnlineBandedHouseholderQR(), R_dense(), and x_dense().
|
inlinenodiscard |
Definition at line 525 of file online_householder_qr.h.
Referenced by addMutating(), At_times_b(), OnlineBandedHouseholderQR(), R_dense(), x_dense(), and zeroBandedPart().
|
nodiscard |
Definition at line 678 of file online_householder_qr.cpp.
References bandwidth(), n_band(), and n_common().
| void momentum::OnlineBandedHouseholderQR< T >::reset | ( | ) |
Discards accumulated state, keeping the existing dimensions and damping.
Definition at line 560 of file online_householder_qr.cpp.
|
nodiscard |
Retrieves the full dense result vector of length n_band() + n_common().
Definition at line 709 of file online_householder_qr.cpp.
References bandwidth(), n_band(), and n_common().
Referenced by momentum::SequenceSolverT< T >::doIteration().
|
inlinenodiscard |
Definition at line 507 of file online_householder_qr.h.
| void momentum::OnlineBandedHouseholderQR< T >::zeroBandedPart | ( | Eigen::Index | iCol_offset, |
| ColumnIndexedMatrix< MatrixType > | A_band, | ||
| ColumnIndexedMatrix< MatrixType > | A_common, | ||
| Eigen::Ref< VectorType > | b ) |
Zeros out just the banded part of A_band by applying Householder rotations.
A_common is updated in place but will still have nonzero entries on return, so after calling this you should follow up with addMutating(A_common, b) to fold the remaining common contribution into the factorization.
Why is this useful? If you are careful, you can call zeroBandedPart on multiple non-overlapping segments of the banded matrix in parallel; only the A_common processing must be serialized. Because the number of common variables is usually much smaller than the number of banded variables, this can provide a substantial speedup in practice.
iCol_offset, A_band, A_common, b satisfy the same shape rules as addMutating(). A_band is zeroed; A_common and b are mutated and must be passed to the common-only addMutating() to finish the contribution. Definition at line 579 of file online_householder_qr.cpp.
References momentum::ColumnIndexedMatrix< MatrixType >::col(), momentum::ColumnIndexedMatrix< MatrixType >::cols(), MT_CHECK, n_common(), and momentum::ColumnIndexedMatrix< MatrixType >::rows().
Referenced by addMutating().