# cholesky_update¶

probnum.utils.linalg.cholesky_update(S1, S2=None)[source]

Compute Cholesky update/factorization $$L$$ such that $$L L^\top = S_1 S_1^\top + S_2 S_2^\top$$ holds.

This can be used in various ways. For example, $$S_1$$ and $$S_2$$ do not need to be Cholesky factors; any matrix square-root is sufficient. As long as $$L L^\top = S_1 S_1^\top + S_2 S_2^\top$$ is well-defined (and admits a Cholesky-decomposition), $$S_1$$ and $$S_2$$ do not even have to be square.

Parameters
• S1 (ndarray) – First matrix square-root. Not necessarily a Cholesky factor, any (possibly even non-square) matrix $$S$$ such that $$C = S S^\top$$ holds, is sufficient.

• S2 (Optional[ndarray]) – Second matrix square-root. Not necessarily a Cholesky factor, any (possibly even non-square) matrix $$S$$ such that $$C = S S^\top$$ holds, is sufficient. Optional. Default is None.

Returns

Return type

Lower Cholesky factor $$L$$ of $$L L^\top =S1 S1^\top + S2 S2^\top$$, if S2 was not None. Otherwise, lower Cholesky factor of $$L L^\top =S1 S1^\top$$.

Examples

>>> from probnum.utils.linalg import cholesky_update
>>> from probnum.problems.zoo.linalg import random_spd_matrix
>>> import numpy as np


Compute the Cholesky-factor of a sum of SPD matrices.

>>> rng = np.random.default_rng(seed=3)
>>> C1 = random_spd_matrix(rng, dim=5)
>>> S1 = np.linalg.cholesky(C1)
>>> C2 = random_spd_matrix(rng, dim=5)
>>> S2 = np.linalg.cholesky(C2)
>>> C = C1 + C2
>>> S = cholesky_update(S1, S2)
>>> np.allclose(np.linalg.cholesky(C), S)
True


Turn a (potentially non-square) matrix square-root into a Cholesky factor

>>> A = np.random.rand(3, 5)
>>> S = cholesky_update(A @ S1)
>>> np.allclose(np.linalg.cholesky(A @ C1 @ A.T), S)
True