limit

Module

Provides interfaces to query numeric various numeric properties of types.

You can import these APIs from the math package. For example:

from math.limit import inf

inf

inf[type: DType]() -> SIMD[type, 1]

Gets a +inf value for the given dtype.

Constraints:

Can only be used for FP dtypes.

Parameters:

  • type (DType): The value dtype.

Returns:

The +inf value of the given dtype.

neginf

neginf[type: DType]() -> SIMD[type, 1]

Gets a -inf value for the given dtype.

Constraints:

Can only be used for FP dtypes.

Parameters:

  • type (DType): The value dtype.

Returns:

The -inf value of the given dtype.

isinf

isinf[type: DType, simd_width: Int](val: SIMD[type, simd_width]) -> SIMD[bool, simd_width]

Checks if the value is infinite.

This is always False for non-FP data types.

Parameters:

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

Args:

  • val (SIMD[type, simd_width]): The value to check.

Returns:

True if val is infinite and False otherwise.

isfinite

isfinite[type: DType, simd_width: Int](val: SIMD[type, simd_width]) -> SIMD[bool, simd_width]

Checks if the value is not infinite.

This is always True for non-FP data types.

Parameters:

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

Args:

  • val (SIMD[type, simd_width]): The value to check.

Returns:

True if val is finite and False otherwise.

max_finite

max_finite[type: DType]() -> SIMD[type, 1]

Returns the maximum finite value of type.

Parameters:

  • type (DType): The value dtype.

Returns:

The maximum representable value of the type. Does not include infinity for floating-point types.

max_or_inf

max_or_inf[type: DType]() -> SIMD[type, 1]

Returns the maximum value of type.

Parameters:

  • type (DType): The value dtype.

Returns:

The maximum value of the type or infinity for floating-point types.

min_finite

min_finite[type: DType]() -> SIMD[type, 1]

Returns the minimum (lowest) finite value of type.

Parameters:

  • type (DType): The value dtype.

Returns:

The minimum representable value of the type. Does not include negative infinity for floating-point types.

min_or_neginf

min_or_neginf[type: DType]() -> SIMD[type, 1]

Returns the minimum value of type.

Parameters:

  • type (DType): The value dtype.

Returns:

The minimum value of the type or infinity for floating-point types.