IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /docs/manual/basics.md). For the complete Mojo documentation index, see llms.txt.
Skip to main content
Version: 1.0.0b1
For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).

isclose

isclose[dtype: DType, width: Int, *, symmetrical: Bool = True](a: SIMD[dtype, width], b: SIMD[dtype, width], *, atol: Float64 = 1.0E-8, rtol: Float64 = 1.0000000000000001E-5, equal_nan: Bool = False) -> SIMD[DType.bool, width]

Returns a boolean SIMD vector indicating which element pairs of a and b are equal within a given tolerance.

For floating-point dtypes, the following criteria apply:

  • Symmetric (Python math.isclose style), when symmetrical is true:
    |a - b| ≤ max(atol, rtol * max(|a|, |b|))
  • Asymmetric (NumPy style), when symmetrical is false:
    |a - b| ≤ atol + rtol * |b|

NaN values are considered equal only if equal_nan is true.

Parameters:

  • dtype (DType): Element type of the input and output vectors.
  • width (Int): Number of lanes in each SIMD vector.
  • symmetrical (Bool): If true, use the symmetric comparison formula (default: true).

Args:

Returns:

SIMD[DType.bool, width]: A boolean vector where a and b are equal within the given tolerance.