Skip to content

Utils

Utility functions for the linear algebra module.

PSDAnnotation

Marker class for PSD (Positive Semi-Definite) annotations.

__call__

__call__(A)

Make PSD annotation callable.

psd

psd(A)

Mark a linear operator as positive semi-definite.

This function acts as a marker/wrapper for positive semi-definite matrices.

Parameters:

  • A (LinearOperator) –

    A LinearOperator that is assumed to be positive semi-definite.

Returns:

add_jitter

add_jitter(matrix, jitter=1e-06)

Add jitter to the diagonal of a matrix for numerical stability.

This function adds a small positive value (jitter) to the diagonal elements of a square matrix to improve numerical stability, particularly for Cholesky decompositions and matrix inversions.

Parameters:

  • matrix (Array) –

    A square matrix to which jitter will be added.

  • jitter (float | Array, default: 1e-06 ) –

    The jitter value to add to the diagonal. Defaults to 1e-6.

Returns:

  • Array –

    The matrix with jitter added to its diagonal.

Examples:

>>> import jax.numpy as jnp
>>> from gpjax.linalg.utils import add_jitter
>>> matrix = jnp.array([[1.0, 0.5], [0.5, 1.0]])
>>> jittered_matrix = add_jitter(matrix, jitter=0.01)