Skip to contents

Computes the inverse of a triangular matrix.

Usage

mlx_tri_inv(x, upper = FALSE, device = NULL)

Arguments

x

An mlx array.

upper

Logical; if TRUE, x is upper triangular, otherwise lower triangular.

device

Execution target for APIs that expose a one-off device or stream override. Supply "gpu", "cpu", or an mlx_stream created via mlx_new_stream(). Ordinary array operations use the current mlx_device() instead.

Value

The inverse of the triangular matrix x.

Details

Note: MLX may crash if x is not triangular.

Examples

# Lower triangular matrix
L <- mlx_matrix(c(1:3, 0, 4:5, 0, 0, 6), 3, 3)
mlx_tri_inv(L, upper = FALSE, device = "cpu")
#> mlx array [3 x 3]
#>   dtype: float32
#>   values:
#>             [,1]       [,2]      [,3]
#> [1,]  1.00000000  0.0000000 0.0000000
#> [2,] -0.50000000  0.2500000 0.0000000
#> [3,] -0.08333334 -0.2083333 0.1666667