Moore-Penrose pseudoinverse for MLX arrays
Arguments
- x
An mlx object or coercible matrix.
- 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
As of MLX 0.31.1, this operation only runs on CPU. Run it inside
with_device() or local_device(), or pass device = "cpu".
Examples
x <- mlx_matrix(c(1, 2, 3, 4), 2, 2)
pinv(x, device = "cpu")
#> mlx array [2 x 2]
#> dtype: float32
#> values:
#> [,1] [,2]
#> [1,] -2 1.5000004
#> [2,] 1 -0.5000001