S3 method for all.equal following R semantics. Returns TRUE if arrays
are close, or a character vector describing differences if they are not.
Usage
# S3 method for class 'equal.mlx'
all(target, current, tolerance = sqrt(.Machine$double.eps), ...)
Arguments
- target, current
MLX arrays to compare
- tolerance
Numeric tolerance for comparison (default: sqrt(.Machine$double.eps))
- ...
Additional arguments (currently ignored)
Value
Either TRUE or a character vector describing differences.
Details
This method follows R's all.equal() semantics:
Returns TRUE if arrays are close within tolerance
Returns a character vector describing differences otherwise
Checks dimensions/shapes before comparing values
The tolerance is converted to MLX's rtol and atol parameters:
rtol = tolerance
atol = tolerance
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-6))
all.equal(a, b) # TRUE
#> [1] "Arrays are not all close within tolerance"
c <- as_mlx(c(1.0, 2.0, 10.0))
all.equal(a, c) # Character vector describing difference
#> [1] "Arrays are not all close within tolerance"