covmats.CovKernelAsLinop#
- class covmats.CovKernelAsLinop(*args, **kwargs)[source]#
Abstract class providing linear operator capability from a kernel definition.
Given a covariance kernel and a set of points, this builds a
LinearOperatorexposing matrix-vector products with the corresponding (Npts, Npts) covariance matrix, without requiring the user to assemble it densely themselves. It only provides linear-operator capabilities (matrix-vector products and, via GMRES, linear solves) – no sampling or other statistical calculations, unlike the fullCovarianceMatrixhierarchy.See also
CovKernelAsLinopViaFFTA subclass specialized for stationary kernels on regular grids, using FFT-based matrix-vector products that avoid building the dense matrix even once.
- __init__(pts: ndarray[tuple[Any, ...], dtype[floating]], kernel: Callable, len_scale: ndarray[tuple[Any, ...], dtype[floating]], nugget: float = 0.0, k: int = 100, is_use_preconditioner: bool = False) None[source]#
Initialize the instance.
- Parameters:
pts (NDArrayFloat) – Coordinates of the points covered by the covariance matrix, with shape (Npts, Ndim), Ndim being the number of spatial dimensions.
kernel (Callable) – Covariance kernel. It must accept an array of (scaled) distances and return the associated covariance values, e.g. an exponential or Matérn kernel.
len_scale (NDArrayFloat) – Correlation length(s) used to scale the points coordinates before evaluating the kernel. Either a scalar (isotropic) or a vector with one length per dimension (anisotropic).
nugget (float, optional) – Nugget effect (diagonal regularization) added to the covariance matrix to improve its conditioning, by default 0.0 (no nugget).
k (int, optional) – Number of local centers used to build the preconditioner when is_use_preconditioner is True, by default 100.
is_use_preconditioner (bool, optional) – Whether to build a sparse preconditioner at instance creation and use it when solving \(\mathbf{Ax} = \mathbf{b}\) systems with
CovKernelAsLinop.solve(). By default False.
Properties
Hermitian adjoint.
Transpose this linear operator.
Return the number of points covered.
Shape of the covariance matrix (n, n).
Methods
Hermitian adjoint.
Matrix-matrix or matrix-vector multiplication.
Return the diagonal entries of the matrix (variances).
Return the cumulated number of GMRES matrix-vector products performed.
Matrix-matrix multiplication.
Matrix-vector multiplication.
Reset the internal call counters (count and solvematvecs) to zero.
Adjoint matrix-matrix multiplication.
Adjoint matrix-vector multiplication.
Solve Ax = b, with A, the current covariance matrix instance.
Explicit dense representation of the covariance matrix.
Transpose this linear operator.