示例#1
0
def apply_mask(t: ti.i32):
  #for i, j in mask:
  for i in range(n_grid):
    for j in range(n_grid):
      #ti.atom
      radius = (i - 128)**2 + (j - 128)**2
      if radius > 20**2 and radius < 30**2:
      #if (i > 108 and i < 148) and not (i > 118 and i < 138) or (j > 108 and j < 148) and not (j > 118 and j < 138) or ():
      #f (i < 118 or i > 138) and (j < 118 or j > 138) and (i > 108 or i < 148) and (j > 108 or j < 148):
        ti.atomic_sub(p[t-1, i, j], p[t-1, i, j] * (mask[i,j] / (mask[i,j] + 0.5)))
示例#2
0
    def atomic_sub(self, other):
        """Return the new expression of computing atomic sub between self and a given operand.

        Args:
            other (Any): Given operand.

        Returns:
            :class:`~taichi.lang.expr.Expr`: The computing expression of atomic sub."""
        _taichi_skip_traceback = 1
        return ti.atomic_sub(self, other)
示例#3
0
 def reduce(a: ti.any_arr()) -> ti.i32:
     s = 0
     for i in a:
         ti.atomic_add(s, a[i])
         ti.atomic_sub(s, 2)
     return s
示例#4
0
 def atomic_sub(self, other):
     import taichi as ti
     return ti.atomic_sub(self, other)
 def func():
     a = 0
     for i in range(10):
         ti.atomic_sub(a, i)
     A[None] = a
示例#6
0
 def func():
     for i in range(n):
         # this is an expr with side effect, make sure it's not optimized out.
         ti.atomic_sub(c[None], step)
示例#7
0
 def atomic_sub(self, other):
     import taichi as ti
     _taichi_skip_traceback = 1
     return ti.atomic_sub(self, other)
示例#8
0
 def atomic_sub(self, other):
     _taichi_skip_traceback = 1
     return ti.atomic_sub(self, other)
示例#9
0
 def reduce(a: ti.types.ndarray()) -> ti.i32:
     s = 0
     for i in a:
         ti.atomic_add(s, a[i])
         ti.atomic_sub(s, 2)
     return s
示例#10
0
    def test_u8_sub_u16() -> ti.uint8:
        x: ti.uint8 = 255
        y: ti.uint16 = 100

        ti.atomic_sub(x, y)
        return x
示例#11
0
    def test_u16_sub_u8() -> ti.uint16:
        x: ti.uint16 = 1000
        y: ti.uint8 = 255

        ti.atomic_sub(x, y)
        return x