19 const Eigen::Index n = A_.cols();
20 const Eigen::Index m = A_.rows();
27 qrFactorization_.reset(n,
sigma);
28 Eigen::VectorX<T> b = Eigen::VectorX<T>::Zero(m);
29 qrFactorization_.add(A_, b);
49 Eigen::Ref<
const Eigen::VectorX<T>> rhs)
const {
50 const auto&
R = qrFactorization_.R();
55 return R.template triangularView<Eigen::Upper>().solve(
56 R.template triangularView<Eigen::Upper>().transpose().solve(rhs));
61 Eigen::Ref<
const Eigen::VectorX<T>> rhs)
const {
65 Eigen::VectorX<T> result = (sigma_ * sigma_) * rhs;
66 result.noalias() += A_.transpose() * (A_ * rhs);
72 Eigen::Ref<
const Eigen::MatrixX<T>> rhs)
const {
73 const auto&
R = qrFactorization_.R();
77 return R.template triangularView<Eigen::Upper>().solve(
78 R.template triangularView<Eigen::Upper>().transpose().solve(rhs));
83 Eigen::Ref<
const Eigen::MatrixX<T>> rhs)
const {
84 Eigen::MatrixX<T> result = (sigma_ * sigma_) * rhs;
85 result.noalias() += A_.transpose() * (A_ * rhs);
91 return qrFactorization_.R();
96 const auto&
R = qrFactorization_.R();
104 for (Eigen::Index i = 0; i <
dimension(); ++i) {
106 result += std::log(
R(i, i));
110 return T(2) * result;
#define MT_CHECK(condition,...)
Runtime check macros with two interchangeable backends:
Efficient and numerically stable representation of a low-rank-plus-diagonal Gaussian covariance matri...
Eigen::MatrixX< T > times_mat(Eigen::Ref< const Eigen::MatrixX< T > > rhs) const
Column-wise application of C to a matrix rhs.
Eigen::VectorX< T > times_vec(Eigen::Ref< const Eigen::VectorX< T > > rhs) const
Returns C * rhs = sigma^2 * rhs + A^T * (A * rhs).
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::Index dimension() const
Returns n, the dimension of the covariance (number of columns of A).
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 inverse_logDeterminant() const
Returns log(det(C^{-1})) = -log(det(C)).
const Eigen::MatrixX< T > & basis() const
Returns the stored basis A passed to reset().
void reset(T sigma, Eigen::Ref< const Eigen::MatrixX< T > > A)
(Re)build the covariance from a regularizer sigma and basis A.
Eigen::MatrixX< T > inverse_times_mat(Eigen::Ref< const Eigen::MatrixX< T > > rhs) const
Column-wise application of C^{-1} to a matrix rhs.
T sigma() const
Returns the diagonal regularizer sigma passed to reset().
T logDeterminant() const
Returns log(det(C)), computed stably as 2 * sum(log|diag(R)|).