def isnan(x): """Determines whether the parameter is a number, element-wise. Args: x (:mod:`~taichi.types.primitive_types`, :class:`taichi.Matrix`): The input. Example: >>> @ti.kernel >>> def test(): >>> x = vec4(nan, -nan, inf, 1) >>> ti.math.isnan(x) >>> >>> test() [1, 1, 0, 0] Returns: For each element i of the result, returns 1 if x[i] is posititve or negative floating point NaN (Not a Number) and 0 otherwise. """ ftype = impl.get_runtime().default_fp fx = ti.cast(x, ftype) if ti.static(ftype == ti.f64): y = ti.bit_cast(fx, ti.u64) return (ti.cast(y >> 32, ti.u32) & 0x7fffffff) + (ti.cast(y, ti.u32) != 0) > 0x7ff00000 y = ti.bit_cast(fx, ti.u32) return (y & 0x7fffffff) > 0x7f800000
def offset_ray(p, n): int_scale = 256.0 float_scale = 1.0 / 2048.0 origin = 1.0 / 256.0 ret = ti.Vector([0.0, 0.0, 0.0]) for k in ti.static(range(3)): i_of = int(int_scale * n[k]) i_p = ti.bit_cast(p[k], ti.i32) if p[k] < 0.0: i_p = i_p - i_of else: i_p = i_p + i_of f_p = ti.bit_cast(i_p, ti.f32) if abs(p[k]) < origin: ret[k] = p[k] + float_scale * n[k] else: ret[k] = f_p return ret
def func2(): z[None] = ti.bit_cast(y[None], ti.i32)
def func1(): y[None] = ti.bit_cast(x[None], ti.f32)