Returns a boolean array indicating which elements of two arrays are close
within specified tolerances.
Usage
mlx_isclose(a, b, rtol = 1e-05, atol = 1e-08, equal_nan = FALSE)
Arguments
- a, b
MLX arrays or objects coercible to MLX arrays
- rtol
Relative tolerance (default: 1e-5)
- atol
Absolute tolerance (default: 1e-8)
- equal_nan
If TRUE, NaN values are considered equal (default: FALSE)
Value
An mlx array of booleans with element-wise comparison results
Details
Two values are considered close if:
abs(a - b) <= (atol + rtol * abs(b))
Infinite values with matching signs are considered equal.
Supports NumPy-style broadcasting.
Examples
a <- as_mlx(c(1.0, 2.0, 3.0))
b <- as_mlx(c(1.0 + 1e-6, 2.0 + 1e-6, 3.0 + 1e-3))
mlx_isclose(a, b) # First two TRUE, last FALSE
#> mlx array [3]
#> dtype: bool
#> values:
#> [1] TRUE TRUE FALSE