LinAlg::cholesky

Cholesky decomposition.

Return the Cholesky decomposition. Only lower-triangular is returned.

Description

SciPhp\NdArray np::linalg()->cholesky( array|NdArray $m )

Parameters

$m
An array [1, 2, 3] or a NdArray. Matrix must be symmetric and positive-definite.

Return Values

SciPhp\NdArray Lower-triangular of the Cholesky decomposition.

Examples

Example #1: Calculating Cholesky decomposition

use SciPhp\NumPhp as np;

$m =
[[ 
2,  -1,  ],
 [-
1,   2, -],
 [ 
0,  -1,  ]];

$lower np::linalg()->cholesky($m);
$upper $lower->T;

echo 
"lower=\n$lower""upper=\n$upper";

The above example will output:

lower=
[[1.4142135623731    0                  0                ]
 [-0.70710678118655  1.2247448713916    0                ]
 [0                  -0.81649658092773  1.1547005383793  ]]
upper=
[[1.4142135623731    -0.70710678118655  0                ]
 [0                  1.2247448713916    -0.81649658092773]
 [0                  0                  1.1547005383793  ]]

See Also