choleskyDecomp

Computs Cholesky decomposition of symmetric positive definite matrix 'A'. The factorization has the form: \A = U**T * U, if UPLO = 'U', or \A = L * L**T, if UPLO = 'L' Where U is an upper triangular matrix and L is lower triangular.

choleskyDecomp
(
Flag!"allowDestroy" allowDestroy = No.allowDestroy
Iterator
SliceKind kind
)
(
char uplo
,
Slice!(Iterator, 2, kind) a
)

Parameters

allowDestroy

flag to delete the source matrix.

a Slice!(Iterator, 2, kind)

symmetric 'N x N' matrix.

uplo char

if uplo is Upper, then upper triangle of A is stored, else lower.

Return Value

Type: auto

Examples

import mir.algorithm.iteration: equal, eachUploPair;
import mir.ndslice;
import mir.random.algorithm;
import mir.random.variable;
import mir.math.common: approxEqual;

auto A =
       [ 25, double.nan, double.nan,
         15, 18,  double.nan,
         -5,  0, 11 ]
         .sliced(3, 3);

auto B = randomSlice(uniformVar(-100, 100), 3, 100);

auto C = choleskyDecomp('L', A);
auto X = C.solve(B);

A.eachUploPair!"a = b";
assert(equal!approxEqual(mtimes(A, X), B));

Meta