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 formula.
Unlike Pythons's math.isclose
, this implementation is symmetric. I.e.
isclose(a,b) == isclose(b,a)
.
Parameters:
- type (
DType
): Thedtype
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.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!
If you'd like to share more information, please report an issue on GitHub
😔 What went wrong?