Matrix and vector norms for mlx arrays
mlx_norm.RdMatrix and vector norms for mlx arrays
Arguments
- x
- An mlx array. 
- ord
- Numeric or character norm order. Use - NULLfor the default 2-norm.
- axis
- Optional integer vector of axes (1-indexed) along which to compute the norm. 
- drop
- If - TRUE(default), drop dimensions of length 1. If- FALSE, retain all dimensions. Equivalent to- keepdims = TRUEin underlying mlx functions.
Examples
x <- as_mlx(matrix(1:4, 2, 2))
mlx_norm(x)
#> mlx array []
#>   dtype: float32
#>   device: gpu
#>   values:
#> [1] 5.477226
mlx_norm(x, ord = 2)
#> mlx array []
#>   dtype: float32
#>   device: gpu
#>   values:
#> [1] 5.464986
mlx_norm(x, axis = 2)
#> mlx array [2]
#>   dtype: float32
#>   device: gpu
#>   values:
#> [1] 3.162278 4.472136