26#include <Eigen/Eigenvalues>
49template <
typename KernelValue,
typename FunctionValue,
60template <base::concepts::real_scalar KernelValue,
typename FunctionValue>
91 "Kernel matrix must be a square matrix.");
93 "Matrix of additional terms must have the same number of rows as "
94 "the kernel matrix.");
97 "The number of variables must be larger than the number of "
104 "The matrix of additional terms must have full "
105 "column rank. (columns={}, rand={})",
137 "compute() must be called before solve().");
165 constexpr scalar_type limit = std::numeric_limits<scalar_type>::max() *
192 return (
spectre_.array().abs2().rowwise().sum() /
225 largest_eigenvalue * std::numeric_limits<scalar_type>::epsilon();
227 eigenvalue_safe_limit - smallest_eigenvalue;
229 if (reg_param < reg_param_safe_limit) {
230 return reg_param_safe_limit;
236 Eigen::SelfAdjointEigenSolver<kernel_matrix_type>
Class of exception on failure in algorithm.
index_type num_additional_terms_
Number of additional terms.
kernel_matrix_type transformed_kernel_matrix_
Kernel matrix transformed to the subspace not expressed by additional terms.
Eigen::ColPivHouseholderQR< additional_matrix_type > qr_decomposition_
QR decomposition_.
index_type kernel_subspace_dimensions_
Number of dimensions of the subspace which will be expressed using kernel matrices.
KernelValue scalar_type
Type of scalars.
void compute(const kernel_matrix_type &kernel_matrix, const additional_matrix_type &additional_matrix, const vector_type &data)
Compute internal matrices.
auto calc_mle_objective(scalar_type reg_param) const -> scalar_type
Calculate maximum likelihood estimation (MLE) objective function scheuerer2011.
kernel_matrix_type q_matrix_
Q matrix in QR decomposition.
Eigen::SelfAdjointEigenSolver< kernel_matrix_type > eigen_value_decomposition_
Eigenvalue decomposition.
void solve(vector_type &kernel_coefficients, vector_type &additional_coefficients, scalar_type reg_param) const
Solve the linear equation with a regularization parameter.
kernel_matrix_type data_transformation_matrix_
Matrix to transform data into the space determined by the eigen vectors.
vector_type spectre_
Data transformed to the space determined by the eigen vectors.
auto calc_log_determinant(const scalar_type ®_param) const -> scalar_type
Calculate the logarithm of the determinant of kernel matrix plus regularization parameter.
const vector_type * data_
Data.
Eigen::MatrixX< KernelValue > additional_matrix_type
Type of matrices of additional terms.
const kernel_matrix_type * kernel_matrix_
Kernel matrix.
Eigen::MatrixX< KernelValue > kernel_matrix_type
Type of matrices of kernels.
auto correct_reg_param_if_needed(const scalar_type ®_param) const noexcept -> scalar_type
Correct regularization parameter if needed.
general_spline_equation_solver()=default
Constructor.
Eigen::VectorX< FunctionValue > vector_type
Type of vectors.
index_type num_variables_
Number of variables.
auto calc_reg_term(const scalar_type ®_param) const -> scalar_type
Calculate the regularization term.
Class to solve linear equations of kernel matrices and matrices of additional terms in RBF interpolat...
Definition of exceptions.
Definition of index_type type.
Definition of kernel_matrix_type enumeration.
Definition of macros for logging.
#define NUM_COLLECT_LOG_AND_THROW(EXCEPTION_TYPE,...)
Write an error log and throw an exception for an error.
std::ptrdiff_t index_type
Type of indices in this library.
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.
Definition of real_scalar concept.