Computes the inverse of a positive definite matrix from its Cholesky factor.
Note: x should be the Cholesky factor (L or U), not the original matrix.
Arguments
- x
An mlx array.
- upper
Logical; if
TRUE,xis upper triangular, otherwise lower triangular.- device
Execution target for APIs that expose a one-off device or stream override. Supply
"gpu","cpu", or anmlx_streamcreated viamlx_new_stream(). Ordinary array operations use the currentmlx_device()instead.
Details
For a more R-like interface, see chol2inv().
Examples
# Create a positive definite matrix
A <- matrix(rnorm(9), 3, 3)
A <- t(A) %*% A
# Compute Cholesky factor
L <- chol(A, pivot = FALSE, upper = FALSE)
# Get inverse from Cholesky factor
mlx_cholesky_inv(as_mlx(L), device = "cpu")
#> mlx array [3 x 3]
#> dtype: float32
#> values:
#> [,1] [,2] [,3]
#> [1,] 0.1525249 0.000000 0.000000
#> [2,] 0.0000000 1.428797 0.000000
#> [3,] 0.0000000 0.000000 2.136137