covmats.SparseCholeskyFactor#

class covmats.SparseCholeskyFactor(*args, **kwargs)[source]#

Sparse Cholesky factor of a matrix \(\mathbf{A}\).

Factorization

It relies on the \(\mathbf{LDL}^{\mathrm{T}} =\) \(\mathbf{PAP}^{\mathrm{T}}\) factorization where

  • \(\mathbf{L}\) is the sparse lower triangle with unit diagonal.

  • \(\mathbf{D}\) is the sparse diagonal matrix with diagonal entries.

  • \(\mathbf{P}\) is the rows permutation vector.

Note

Since this code is released under BSD 3-Clause License, it is not possible to include sparse factors provided by scikit-sparse, as it depends on external libraries with GPL licenses, such as SuiteSparse. The main goal of this implementation is therefore to mimic useful features while preserving the BSD 3-Clause License compatibility.

Examples

>>> from your_module import SparseCholeskyFactor
>>> L, D, P = ...  # sparse matrices
>>> factor = SparseCholeskyFactor(L, D, P)
>>> factor.matvec(x)
array([...])
__init__(L: sparray, D: sparray, P: _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]) None[source]#

Initialize the instance.

Parameters:
  • L (sp.sparse.sparray) – Sparse lower triangle \(\mathbf{L}\) of the factorization.

  • D (sp.sparse.sparray) – Sparse diagonal matrix \(\mathbf{{D}}\) of the factorization.

  • P (ArrayLike) – 1D vector \(\mathbf{{P}}\) storing rows permutations of the factorization.

Raises:

ValueError – If the dimensions of L, D and P do not match.

Properties

D

Sparse diagonal matrix \(\mathbf{D}\) of the factorization.

H

Hermitian adjoint.

L

Sparse lower triangle \(\mathbf{L}\) with unit diagonal of the factorization.

P

1D vector \(\mathbf{P}\) storing rows permutations of the factorization.

Pt

1D vector \(\mathbf{P}\) storing rows back-permutations of the factorization.

T

Transpose this linear operator.

invD

Inverse of \(\mathbf{D}\) in the factorization.

log_pdet

Log of the pseudo-determinant of the covariance matrix.

mat

Return \(\mathbf{A}\) as a dense array.

n_pts

Number of points in the domain (n).

ndim

shape

Shape of the square matrix (n, n).

sqrtD

Squared root of \(\mathbf{D}\) in the factorization.

sqrtinvD

Squared root inverse of \(\mathbf{D}\) in the factorization.

Methods

adjoint

Hermitian adjoint.

apply_P

Apply the permutation of rows.

apply_Pt

Apply the reverse permutation of rows.

colorize

Perform a colorizing transformation on data.

colorize_inv

Perform a colorizing transformation on data as in SparseCholeskyFactor:colorize() but for the inverse \(\mathbf{A}^{-1}\).

dot

Matrix-matrix or matrix-vector multiplication.

get_diagonal

Return the diagonal entries of the matrix \(\mathbf{A}\).

get_invdiagonal

Return the diagonal entries of the inverse matrix \(\mathbf{A}^{-1}\).

inv

Return the inverse \(\mathbf{A}^{-1}\) as a dense array.

matmat

Matrix-matrix multiplication.

matvec

Matrix-vector multiplication.

rmatmat

Adjoint matrix-matrix multiplication.

rmatvec

Adjoint matrix-vector multiplication.

solve

Return \(\mathbf{x} = \mathbf{A}^{-1} \mathbf{b}.\)

todense

Return \(\mathbf{A}\) as a dense array.

transpose

Transpose this linear operator.

whiten

Perform a whitening transformation on data.

whiten_inv

Perform a whitening transformation on data as in SparseCholeskyFactor:whiten() but for the inverse \(\mathbf{A}^{-1}\).