lucid.linalg.cholesky

lucid.linalg.cholesky(a: Tensor, /) Tensor

The cholesky function performs the Cholesky decomposition of a symmetric positive-definite matrix.

Function Signature

def cholesky(a: Tensor) -> Tensor

Parameters

  • a (Tensor):

    A symmetric, positive-definite matrix \(\mathbf{A}\) to decompose.

Returns

  • Tensor:

    A lower triangular matrix \(\mathbf{L}\) such that:

    \[\mathbf{A} = \mathbf{L} \mathbf{L}^\top\]

Forward Calculation

The Cholesky decomposition computes a lower triangular matrix \(\mathbf{L}\) such that:

\[\mathbf{A} = \mathbf{L} \mathbf{L}^\top\]

Here, \(\mathbf{L}^\top\) is the transpose of the matrix \(\mathbf{L}\).

Backward Gradient Calculation

The gradient of the Cholesky decomposition involves differentiating the decomposition itself. For a positive-definite matrix \(\mathbf{A}\), the gradient with respect to \(\mathbf{L}\) is computed using matrix calculus techniques.

\[\frac{\partial \mathbf{A}}{\partial \mathbf{L}} = 2 \cdot \mathbf{L} \cdot \frac{\partial \mathbf{L}}{\partial \mathbf{L}^\top}\]

Raises

Attention

  • ValueError: If the input tensor \(\mathbf{A}\) is not square.

  • LinAlgError: If the input tensor \(\mathbf{A}\) is not symmetric or not positive definite.

Example

>>> import lucid
>>> a = lucid.Tensor([[4.0, 2.0], [2.0, 3.0]])
>>> l = lucid.linalg.cholesky(a)
>>> print(l)
Tensor([[2.0, 0.0], [1.0, 1.41421356]])

Note

  • The Cholesky decomposition is unique if \(\mathbf{A}\) is symmetric and positive definite.

  • The input matrix must satisfy these conditions for the function to work as expected.

  • The resulting lower triangular matrix \(\mathbf{L}\) can be used to solve linear systems or compute determinants.