function

# isclose

isclose[type: DType, simd_width: Int](a: SIMD[type, simd_width], b: SIMD[type, simd_width], *, atol: SIMD[type, 1] = #kgen.float_literal<1|100000000>, rtol: SIMD[type, 1] = #kgen.float_literal<1|100000>, equal_nan: Bool = 0) -> SIMD[bool, \$1]

Checks if the two input values are numerically within a tolerance.

When the type is integral, then equality is checked. When the type is floating point, then this checks if the two input values are numerically the close using the $abs(a - b) <= max(rtol * max(abs(a), abs(b)), atol)$ formula.

Unlike Pythons's math.isclose, this implementation is symmetric. I.e. isclose(a,b) == isclose(b,a).

Parameters:

• type (DType): The dtype of the input and output SIMD vector.
• simd_width (Int): The width of the input and output SIMD vector.

Args:

• a (SIMD[type, simd_width]): The first value to compare.
• b (SIMD[type, simd_width]): The second value to compare.
• atol (SIMD[type, 1]): The absolute tolerance.
• rtol (SIMD[type, 1]): The relative tolerance.
• equal_nan (Bool): Whether to treat nans as equal.

Returns:

A boolean vector where a and b are equal within the specified tolerance.