Loading...
Searching...
No Matches
Backend.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// Copyright (c) gpridge developers
3// See LICENSE for details.
4
34
35#ifndef GPR_LINALG_BACKEND_H_
36#define GPR_LINALG_BACKEND_H_
37
38#include <Eigen/Dense>
39#include <concepts>
40
42#include "BackendInterface.h"
44
45// Distributed overloads declare their explicit process-grid parameter in
46// the selected backend header.
47#if !defined(GPR_LINALG_SCALAPACK) && !defined(GPR_LINALG_SLATE)
48namespace gpr {
49namespace linalg {
50
60bool cholesky(const EigenMatrix& C, EigenMatrix& L);
61
71Eigen::VectorXd forward_solve(const EigenMatrix& L, const Eigen::VectorXd& b);
72
82Eigen::VectorXd back_solve(const EigenMatrix& L, const Eigen::VectorXd& b);
83
94
106
118 const EigenMatrix& B);
119
133Eigen::VectorXd bordered_cholesky_diagonal(const EigenMatrix& L,
134 const EigenMatrix& B,
135 const Eigen::VectorXd& prior);
136
147
159double trace_product(const EigenMatrix& A, const EigenMatrix& B);
160
169double log_det_cholesky(const EigenMatrix& L);
170
171} // namespace linalg
172} // namespace gpr
173#endif
174
175// Compile-time backend selection
176#if defined(GPR_LINALG_CUSOLVER)
177#include "CusolverBackend.h"
178#elif defined(GPR_LINALG_CHOLMOD)
179#include "CholmodBackend.h"
180#elif defined(GPR_LINALG_KOKKOS)
181#include "KokkosBackend.h"
182#elif defined(GPR_LINALG_STDPAR)
183#include "StdParBackend.h"
184#elif defined(GPR_LINALG_SLATE)
185#include "SlateBackend.h"
186#elif defined(GPR_LINALG_SCALAPACK)
187#include "ScalapackBackend.h"
188#else
189#include "EigenBackend.h"
190#endif
191
192#include "CholeskyUpdate.h"
193#include "DenseFactorTrace.h"
194
195namespace gpr {
196namespace linalg {
197
198#if defined(GPR_LINALG_CUSOLVER)
200#elif defined(GPR_LINALG_CHOLMOD)
202#elif defined(GPR_LINALG_KOKKOS)
204#elif defined(GPR_LINALG_STDPAR)
206#elif defined(GPR_LINALG_SLATE)
208#elif defined(GPR_LINALG_SCALAPACK)
210#else
212#endif
213
215
216#if !defined(GPR_LINALG_SCALAPACK)
219template <class B>
221 requires(const typename BackendTraits<B>::matrix_type& a,
222 const typename BackendTraits<B>::matrix_type& b,
224 const typename BackendTraits<B>::vector_type& v) {
225 {
226 cholesky(a, out)
227 } -> std::same_as<bool>;
228 {
230 } -> std::same_as<bool>;
231 {
232 forward_solve(a, v)
233 } -> std::same_as<typename BackendTraits<B>::vector_type>;
234 {
235 back_solve(a, v)
236 } -> std::same_as<typename BackendTraits<B>::vector_type>;
237 {
239 } -> std::same_as<typename BackendTraits<B>::matrix_type>;
240 {
241 back_solve_mat(a, b)
242 } -> std::same_as<typename BackendTraits<B>::matrix_type>;
243 {
245 } -> std::same_as<typename BackendTraits<B>::vector_type>;
246 {
248 } -> std::same_as<typename BackendTraits<B>::matrix_type>;
249 {
250 trace_product(a, b)
251 } -> std::same_as<double>;
252 {
254 } -> std::same_as<double>;
255 };
256
258 "the selected linalg backend must provide the full local "
259 "operation set on its declared operand types");
260#endif
261
262} // namespace linalg
263} // namespace gpr
264
265#endif // GPR_LINALG_BACKEND_H_
Vocabulary of the swappable dense linear-algebra backend.
cuSOLVER + cuBLAS backend with runtime CUDA loading via gpulite.
Default linalg backend — header-only Eigen implementations.
Direct CBLAS/LAPACKE backend with C++17 parallel algorithms.
eon_relax_band_t eon_relax_surface_fn void eon_relax_outcome_t * out
Dense and structured linear algebra behind the GP: Cholesky and eigen solvers, linear operators,...
EigenMatrix back_solve_mat(const EigenMatrix &L, const EigenMatrix &B)
Back triangular solve with matrix RHS (BLAS equivalent: dtrsm with side=L, uplo=L,...
Eigen::VectorXd forward_solve(const EigenMatrix &L, const Eigen::VectorXd &b)
Forward triangular solve with vector RHS (BLAS equivalent: dtrsv).
bool cholesky_rank_update(EigenMatrix &lower, const Eigen::VectorXd &vector)
Update the selected backend's live Cholesky factor in its existing layout.
EigenMatrix forward_solve_mat(const EigenMatrix &L, const EigenMatrix &B)
Forward triangular solve with matrix RHS (BLAS equivalent: dtrsm).
Eigen::VectorXd forward_solve_mat_colwise_squared_norm(const EigenMatrix &L, const EigenMatrix &B)
Forward triangular solve followed by columnwise squared norms.
backend::EigenTag ActiveBackend
Definition Backend.h:211
double log_det_cholesky(const EigenMatrix &L)
Half log-determinant from Cholesky factor.
Eigen::VectorXd back_solve(const EigenMatrix &L, const Eigen::VectorXd &b)
Back triangular solve with vector RHS (BLAS equivalent: dtrsv).
double trace_product(const EigenMatrix &A, const EigenMatrix &B)
Frobenius inner product / trace of matrix product.
Eigen::VectorXd bordered_cholesky_diagonal(const EigenMatrix &L, const EigenMatrix &B, const Eigen::VectorXd &prior)
Posterior diagonal from bordered Cholesky pivots.
EigenMatrix cholesky_inverse(const EigenMatrix &L)
Symmetric inverse from Cholesky factor (LAPACK equivalent: dpotri).
bool cholesky(const EigenMatrix &C, EigenMatrix &L)
Cholesky decomposition (LAPACK equivalent: dpotrf).
BackendTraits< ActiveBackend > ActiveBackendTraits
Definition Backend.h:214
Gaussian-process regression, kernels, priors, and the searches that run on the surrogate.
Definition Macros.h:16
Eigen::Matrix< double, EigenDynamic, EigenDynamic, EigenMatrixStorage > EigenMatrix
Definition Macros.h:20