Exemple #1
0
    def make_tests():
        x = 1.5
        v = ti.math.vec3(1.1, 2.2, 3.3)

        assert ti.floor(x) == 1
        assert ti.floor(x, dt) == 1.0
        assert ti.floor(x, int) == 1

        assert all(ti.floor(v) == [1, 2, 3])
        assert all(ti.floor(v, dt) == [1.0, 2.0, 3.0])
        assert all(ti.floor(v, int) == [1, 2, 3])

        assert ti.ceil(x) == 2
        assert ti.ceil(x, dt) == 2.0
        assert ti.ceil(x, int) == 2

        assert all(ti.ceil(v) == [2, 3, 4])
        assert all(ti.ceil(v, dt) == [2.0, 3.0, 4.0])
        assert all(ti.ceil(v, int) == [2, 3, 4])

        assert ti.round(x) == 2
        assert ti.round(x, dt) == 2.0
        assert ti.round(x, int) == 2

        assert all(ti.round(v) == [1, 2, 3])
        assert all(ti.round(v, dt) == [1.0, 2.0, 3.0])
        assert all(ti.round(v, int) == [1, 2, 3])
Exemple #2
0
 def func():
     xi[0] = -yi[None]
     xi[1] = ~yi[None]
     xi[2] = ti.logical_not(yi[None])
     xi[3] = ti.abs(yi[None])
     xf[0] = -yf[None]
     xf[1] = ti.abs(yf[None])
     xf[2] = ti.sqrt(yf[None])
     xf[3] = ti.sin(yf[None])
     xf[4] = ti.cos(yf[None])
     xf[5] = ti.tan(yf[None])
     xf[6] = ti.asin(yf[None])
     xf[7] = ti.acos(yf[None])
     xf[8] = ti.tanh(yf[None])
     xf[9] = ti.floor(yf[None])
     xf[10] = ti.ceil(yf[None])
     xf[11] = ti.exp(yf[None])
     xf[12] = ti.log(yf[None])
     xf[13] = ti.rsqrt(yf[None])
     xf[14] = ti.round(yf[None])