Note
Go to the end to download the full example code.
Cholesky decomposition for SPD systems#
Cholesky factors a symmetric positive-definite A = L L^T at roughly
half the cost of LU, and the factorization succeeding at all (every
sqrt argument staying positive) is itself a certificate of
positive-definiteness.
import numpy as np
from mathematicskit.linalg import cholesky_decompose, cholesky_solve, is_symmetric_positive_definite, random_spd_matrix
Factor and solve#
L @ L.T == A: True
recovered x: [1. 2. 3. 4. 5.]
matches x_true: True
Positive-definiteness as a byproduct of the factorization succeeding#
is_symmetric_positive_definite(A): True
is_symmetric_positive_definite(non-SPD): False
Total running time of the script: (0 minutes 0.001 seconds)