26#include <Eigen/Eigenvalues>
27#include <Eigen/IterativeLinearSolvers>
29#include <Eigen/SparseCore>
30#include <Eigen/src/Core/util/Constants.h>
49template <
typename KernelValue,
typename FunctionValue,
59template <
typename KernelValue,
typename FunctionValue>
121 constexpr scalar_type limit = std::numeric_limits<scalar_type>::max() *
160 template <base::concepts::dense_vector InputData>
192 return (
spectre_.array().abs2().rowwise().sum() /
206 return (
decomposition_.eigenvalues().array() + reg_param).log().sum();
221 largest_eigenvalue * std::numeric_limits<scalar_type>::epsilon();
223 eigenvalue_safe_limit - smallest_eigenvalue;
225 if (reg_param < reg_param_safe_limit) {
226 return reg_param_safe_limit;
244template <
typename KernelValue,
typename FunctionValue>
270 solver_.compute(kernel_matrix);
283 "Non-zero regularization parameter cannot be used in this "
286 coefficients =
solver_.solve(data);
291 Eigen::PartialPivLU<kernel_matrix_type>
solver_;
300template <
typename KernelValue,
typename FunctionValue>
306 Eigen::SparseMatrix<KernelValue, Eigen::RowMajor>;
327 solver_.compute(kernel_matrix);
340 "Non-zero regularization parameter cannot be used in this "
343 coefficients =
solver_.solve(data);
Eigen::VectorX< FunctionValue > vector_type
Type of vectors.
Eigen::SparseMatrix< KernelValue, Eigen::RowMajor > kernel_matrix_type
Type of matrices.
KernelValue scalar_type
Type of scalars.
Eigen::BiCGSTAB< kernel_matrix_type > solver_
Solver of the kernel matrix.
void compute(const kernel_matrix_type &kernel_matrix, const vector_type &data)
Compute internal matrices.
kernel_matrix_solver()=default
Constructor.
void solve(vector_type &coefficients, scalar_type reg_param, const vector_type &data) const
Solve the linear equation with a regularization parameter.
KernelValue scalar_type
Type of scalars.
Eigen::PartialPivLU< kernel_matrix_type > solver_
Solver of the kernel matrix.
Eigen::VectorX< FunctionValue > vector_type
Type of vectors.
void compute(const kernel_matrix_type &kernel_matrix, const vector_type &data)
Compute internal matrices.
kernel_matrix_solver()=default
Constructor.
void solve(vector_type &coefficients, scalar_type reg_param, const vector_type &data) const
Solve the linear equation with a regularization parameter.
Eigen::MatrixX< KernelValue > kernel_matrix_type
Type of matrices.
auto calc_log_determinant(const scalar_type ®_param) const -> scalar_type
Calculate the logarithm of the determinant of kernel matrix plus regularization parameter.
vector_type spectre_
Data transformed to the space determined by the eigen vectors.
kernel_matrix_solver()=default
Constructor.
auto calc_reg_term(const scalar_type ®_param) const -> scalar_type
Calculate the regularization term.
auto calc_common_coeff(scalar_type reg_param) const -> scalar_type
Calculate the coefficient of the kernel common in variables.
auto calc_reg_term(const InputData &data, scalar_type reg_param) const -> scalar_type
Calculate the regularization term for a vector.
Eigen::MatrixX< KernelValue > kernel_matrix_type
Type of matrices.
Eigen::VectorX< FunctionValue > vector_type
Type of vectors.
auto correct_reg_param_if_needed(const scalar_type ®_param) const noexcept -> scalar_type
Correct regularization parameter if needed.
KernelValue scalar_type
Type of scalars.
void compute(const kernel_matrix_type &kernel_matrix, const vector_type &data)
Compute internal matrices.
void solve(vector_type &coefficients, scalar_type reg_param, const vector_type &data) const
Solve the linear equation with a regularization parameter.
auto eigenvalues() const -> decltype(auto)
Get eigenvalues.
Eigen::SelfAdjointEigenSolver< kernel_matrix_type > decomposition_
Eigen decomposition of the kernel matrix.
auto calc_mle_objective(scalar_type reg_param) const -> scalar_type
Calculate maximum likelihood estimation (MLE) objective function scheuerer2011.
Class to solve linear equations of kernel matrices.
Definition of dense_vector concept.
Definition of exceptions.
Definition of kernel_matrix_type enumeration.
Definition of macros for logging.
Namespace of internal implementations.
kernel_matrix_type
Enumeration of types of kernel matrices.
Definition of NUM_COLLECT_PRECONDITION macro.
#define NUM_COLLECT_PRECONDITION(CONDITION,...)
Check whether a precondition is satisfied and throw an exception if not.