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 LinearOperator exposing 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 full CovarianceMatrix hierarchy.

See also

CovKernelAsLinopViaFFT

A 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

count

dtype

solvematvecs

H

Hermitian adjoint.

T

Transpose this linear operator.

n_pts

Return the number of points covered.

ndim

shape

Shape of the covariance matrix (n, n).

Methods

adjoint

Hermitian adjoint.

dot

Matrix-matrix or matrix-vector multiplication.

get_diagonal

Return the diagonal entries of the matrix (variances).

itercount

Return the cumulated number of GMRES matrix-vector products performed.

matmat

Matrix-matrix multiplication.

matvec

Matrix-vector multiplication.

reset_comptors

Reset the internal call counters (count and solvematvecs) to zero.

rmatmat

Adjoint matrix-matrix multiplication.

rmatvec

Adjoint matrix-vector multiplication.

solve

Solve Ax = b, with A, the current covariance matrix instance.

todense

Explicit dense representation of the covariance matrix.

transpose

Transpose this linear operator.