|
Momentum
A library for solving nonlinear optimization problems related to human body kinematics
|
Efficient and numerically stable representation of a low-rank-plus-diagonal Gaussian covariance matrix C = sigma^2 * I + A^T * A where C and I are [n x n] and the basis A is [m x n] (m may be larger or smaller than n). More...
#include <covariance_matrix.h>
Public Member Functions | |
| LowRankCovarianceMatrixT ()=default | |
| void | reset (T sigma, Eigen::Ref< const Eigen::MatrixX< T > > A) |
| (Re)build the covariance from a regularizer sigma and basis A. | |
| Eigen::Index | dimension () const |
| Returns n, the dimension of the covariance (number of columns of A). | |
| const Eigen::MatrixX< T > & | basis () const |
| Returns the stored basis A passed to reset(). | |
| T | sigma () const |
| Returns the diagonal regularizer sigma passed to reset(). | |
| Eigen::VectorX< T > | inverse_times_vec (Eigen::Ref< const Eigen::VectorX< T > > rhs) const |
| Returns C^{-1} * rhs, computed via two triangular solves on R. | |
| Eigen::VectorX< T > | times_vec (Eigen::Ref< const Eigen::VectorX< T > > rhs) const |
| Returns C * rhs = sigma^2 * rhs + A^T * (A * rhs). | |
| Eigen::MatrixX< T > | inverse_times_mat (Eigen::Ref< const Eigen::MatrixX< T > > rhs) const |
| Column-wise application of C^{-1} to a matrix rhs. | |
| Eigen::MatrixX< T > | times_mat (Eigen::Ref< const Eigen::MatrixX< T > > rhs) const |
| Column-wise application of C to a matrix rhs. | |
| const Eigen::MatrixX< T > & | R () const |
| Returns the upper-triangular R factor of the QR factorization of [sigma*I; A], so that C = R^T * R. | |
| T | logDeterminant () const |
| Returns log(det(C)), computed stably as 2 * sum(log|diag(R)|). | |
| T | inverse_logDeterminant () const |
| Returns log(det(C^{-1})) = -log(det(C)). | |
Efficient and numerically stable representation of a low-rank-plus-diagonal Gaussian covariance matrix C = sigma^2 * I + A^T * A where C and I are [n x n] and the basis A is [m x n] (m may be larger or smaller than n).
Access to C^{-1} is computed via the QR factorization of the augmented matrix [sigma*I; A], which keeps the construction numerically stable and avoids ever forming A^T * A explicitly.
Definition at line 27 of file covariance_matrix.h.
|
default |
|
nodiscard |
Returns the stored basis A passed to reset().
Definition at line 38 of file covariance_matrix.cpp.
|
nodiscard |
Returns n, the dimension of the covariance (number of columns of A).
Definition at line 33 of file covariance_matrix.cpp.
Referenced by inverse_times_mat(), and logDeterminant().
|
nodiscard |
Returns log(det(C^{-1})) = -log(det(C)).
Definition at line 114 of file covariance_matrix.cpp.
References logDeterminant().
|
nodiscard |
Column-wise application of C^{-1} to a matrix rhs.
Definition at line 71 of file covariance_matrix.cpp.
References dimension(), MT_CHECK, and R().
|
nodiscard |
Returns C^{-1} * rhs, computed via two triangular solves on R.
Definition at line 48 of file covariance_matrix.cpp.
|
nodiscard |
Returns log(det(C)), computed stably as 2 * sum(log|diag(R)|).
Definition at line 95 of file covariance_matrix.cpp.
References dimension(), MT_CHECK, and R().
Referenced by inverse_logDeterminant().
|
nodiscard |
Returns the upper-triangular R factor of the QR factorization of [sigma*I; A], so that C = R^T * R.
Definition at line 90 of file covariance_matrix.cpp.
Referenced by inverse_times_mat(), inverse_times_vec(), and logDeterminant().
| void momentum::LowRankCovarianceMatrixT< T >::reset | ( | T | sigma, |
| Eigen::Ref< const Eigen::MatrixX< T > > | A ) |
(Re)build the covariance from a regularizer sigma and basis A.
Computes the QR factorization of [sigma*I; A] from scratch (batch update; not an incremental/online refinement of any previous state).
| sigma | Diagonal regularizer; must be > 0. |
| A | Low-rank basis with n columns and m rows. |
Definition at line 15 of file covariance_matrix.cpp.
References sigma().
|
nodiscard |
Returns the diagonal regularizer sigma passed to reset().
Definition at line 43 of file covariance_matrix.cpp.
Referenced by reset().
|
nodiscard |
Column-wise application of C to a matrix rhs.
Definition at line 82 of file covariance_matrix.cpp.
|
nodiscard |
Returns C * rhs = sigma^2 * rhs + A^T * (A * rhs).
Definition at line 60 of file covariance_matrix.cpp.