Skip to contents

Moore-Penrose pseudoinverse for MLX arrays

Usage

pinv(x, device = NULL)

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 an mlx_stream created via mlx_new_stream(). Ordinary array operations use the current mlx_device() instead.

Value

An mlx object containing the pseudoinverse.

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".

See also

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