cholesky

Contents

cholesky#

class saiunit.linalg.cholesky(a, *, upper=False, symmetrize_input=True, **kwargs)#

Compute the Cholesky decomposition of a matrix.

SaiUnit implementation of numpy.linalg.cholesky().

The Cholesky decomposition of a positive-definite Hermitian matrix A is:

\[A = LL^H \quad \text{(lower)} \qquad \text{or} \qquad A = U^HU \quad \text{(upper)}\]

where L is lower-triangular, U is upper-triangular, and \(X^H\) is the Hermitian transpose of X.

For a Quantity with unit u, the resulting unit is u ** 0.5.

Parameters:
  • a (Array | ndarray | bool | number | bool | int | float | complex | saiunit.Quantity) – Input quantity representing a (batched) positive-definite Hermitian matrix. Must have shape (..., N, N).

  • upper (bool) – If True, compute the upper Cholesky factor U. If False (default), compute the lower Cholesky factor L.

  • symmetrize_input (bool) – If True (default), symmetrize the input before decomposition for improved autodiff behavior.

Returns:

out – Cholesky factor of shape (..., N, N). The resulting unit is a.unit ** 0.5. If the input is not Hermitian positive-definite, the result will contain NaN entries.

Return type:

saiunit.Quantity | Array

See also

saiunit.linalg.inv

Compute the inverse of a matrix.

saiunit.linalg.solve

Solve a linear system of equations.

Examples

>>> import saiunit as u
>>> import jax.numpy as jnp
>>> x = jnp.array([[2., 1.],
...                [1., 2.]]) * u.meter2
>>> L = u.linalg.cholesky(x)
>>> L.unit
Unit("m")
>>> u.math.allclose(x, L @ L.T)
Array(True, dtype=bool)