Loading...
Searching...
No Matches
DenseFactorTrace.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// Copyright (c) gpridge developers
3
4#ifndef GPR_LINALG_DENSE_FACTOR_TRACE_H_
5#define GPR_LINALG_DENSE_FACTOR_TRACE_H_
6
7#include <limits>
8
10
11namespace gpr::linalg {
12
19inline double trace_solve_product(const EigenMatrix& L, const EigenMatrix& A)
20{
21 if (L.rows() != L.cols() || A.rows() != L.rows() || A.cols() != L.cols())
22 return std::numeric_limits<double>::quiet_NaN();
23 if (L.rows() == 0) return 0.0;
24 const EigenMatrix solved =
25 L.transpose().triangularView<Eigen::Upper>().solve(
26 L.triangularView<Eigen::Lower>().solve(A));
27 return solved.trace();
28}
29
33{
34 if (L.rows() != L.cols()) return std::numeric_limits<double>::quiet_NaN();
35 if (L.rows() == 0) return 0.0;
36 return L.triangularView<Eigen::Lower>()
37 .solve(EigenMatrix::Identity(L.rows(), L.cols()))
38 .squaredNorm();
39}
40
41} // namespace gpr::linalg
42
43#endif // GPR_LINALG_DENSE_FACTOR_TRACE_H_
Dense and structured linear algebra behind the GP: Cholesky and eigen solvers, linear operators,...
double dense_factor_inverse_trace(const EigenMatrix &L)
double trace_solve_product(const EigenMatrix &L, const EigenMatrix &A)
Eigen::Matrix< double, EigenDynamic, EigenDynamic, EigenMatrixStorage > EigenMatrix
Definition Macros.h:20