Skip to main content

snode

import taichi as ti
ti.init()
x = ti.field(ti.f32)
snode = ti.root.dense(ti.ij,(10,10))
snode.place(x)
# same as
# x = ti.field(ti.f32, (10,10))

print(x.shape)


x[1,3] = 1
x[1,5] = 2.1
x[2,3] = 3.5
x[3,3] = 2

@ti.kernel
def test():
for i,j in x:
print('x[{},{}]={}'.format(i,j,x[i,j]))

test()
x[0,0]=0.000000
x[0,1]=0.000000
x[0,2]=0.000000
x[0,3]=0.000000
x[0,4]=0.000000
x[0,5]=0.000000
x[0,6]=0.000000
x[0,7]=0.000000
x[0,8]=0.000000
x[0,9]=0.000000
x[1,0]=0.000000
x[1,1]=0.000000
x[1,2]=0.000000
x[1,3]=1.000000
x[1,4]=0.000000
x[1,5]=2.100000
x[1,6]=0.000000
x[1,7]=0.000000
x[1,8]=0.000000
x[1,9]=0.000000
x[2,0]=0.000000
x[2,1]=0.000000
x[2,2]=0.000000
x[2,3]=3.500000
x[2,4]=0.000000
x[2,5]=0.000000
x[2,6]=0.000000
x[2,7]=0.000000
x[2,8]=0.000000
x[2,9]=0.000000
x[3,0]=0.000000
x[3,1]=0.000000
x[3,2]=0.000000
x[3,3]=2.000000
x[3,4]=0.000000
x[3,5]=0.000000
x[3,6]=0.000000
x[3,7]=0.000000
x[3,8]=0.000000
x[3,9]=0.000000
x[4,0]=0.000000
x[4,1]=0.000000
x[4,2]=0.000000
x[4,3]=0.000000
x[4,4]=0.000000
x[4,5]=0.000000
x[4,6]=0.000000
x[4,7]=0.000000
x[4,8]=0.000000
x[4,9]=0.000000
x[5,0]=0.000000
x[5,1]=0.000000
x[5,2]=0.000000
x[5,3]=0.000000
x[5,4]=0.000000
x[5,5]=0.000000
x[5,6]=0.000000
x[5,7]=0.000000
x[5,8]=0.000000
x[5,9]=0.000000
x[6,0]=0.000000
x[6,1]=0.000000
x[6,2]=0[Taichi] Starting on arch=arm64
.000000
x[6,3]=0.000000
x[6,4]=0.000000
x[6,5]=0.000000
x[6,6]=0.000000
x[6,7]=0.000000
x[6,8]=0.000000
x[6,9]=0.000000
x[7,0]=0.000000
x[7,1]=0.000000
x[7,2]=0.000000
x[7,3]=0.000000
x[7,4]=0.000000
x[7,5]=0.000000
x[7,6]=0.000000
x[7,7]=0.000000
x[7,8]=0.000000
x[7,9]=0.000000
x[8,0]=0.000000
x[8,1]=0.000000
x[8,2]=0.000000
x[8,3]=0.000000
x[8,4]=0.000000
x[8,5]=0.000000
x[8,6]=0.000000
x[8,7]=0.000000
x[8,8]=0.000000
x[8,9]=0.000000
x[9,0]=0.000000
x[9,1]=0.000000
x[9,2]=0.000000
x[9,3]=0.000000
x[9,4]=0.000000
x[9,5]=0.000000
x[9,6]=0.000000
x[9,7]=0.000000
x[9,8]=0.000000
x[9,9]=0.000000
(10, 10)
import taichi as ti
ti.init()
x = ti.Vector.field(3,ti.f32)
snode = ti.root.dense(ti.ij,(10,10))
snode.place(x)
# same as
# x = ti.field(ti.f32, (10,10))

print(x.shape)


x[1,3] = ti.Vector([1,2,3])
x[1,5] = ti.Vector([1,2,3])
x[2,3] = ti.Vector([1,2,3])
x[3,3] = ti.Vector([1,2,3])

@ti.kernel
def test():
for i,j in x:
print('x[{},{}]'.format(i,j),end='\t')
print(x[i,j])

test()
x[0,0]  [0.000000, 0.000000, 0.000000]
x[0,1] [0.000000, 0.000000, 0.000000]
x[0,2] [0.000000, 0.000000, 0.000000]
x[0,3] [0.000000, 0.000000, 0.000000]
x[0,4] [0.000000, 0.000000, 0.000000]
x[0,5] [0.000000, 0.000000, 0.000000]
x[0,6] [0.000000, 0.000000, 0.000000]
x[0,7] [0.000000, 0.000000, 0.000000]
x[0,8] [0.000000, 0.000000, 0.000000]
x[0,9] [0.000000, 0.000000, 0.000000]
x[1,0] [0.000000, 0.000000, 0.000000]
x[1,1] [0.000000, 0.000000, 0.000000]
x[1,2] [0.000000, 0.000000, 0.000000]
x[1,3] [1.000000, 2.000000, 3.000000]
x[1,4] [0.000000, 0.000000, 0.000000]
x[1,5] [1.000000, 2.000000, 3.000000]
x[1,6] [0.000000, 0.000000, 0.000000]
x[1,7] [0.000000, 0.000000, 0.000000]
x[1,8] [0.000000, 0.000000, 0.000000]
x[1,9] [0.000000, 0.000000, 0.000000]
x[2,0] [0.000000, 0.000000, 0.000000]
x[2,1] [0.000000, 0.000000, 0.000000]
x[2,2] [0.000000, 0.000000, 0.000000]
x[2,3] [1.000000, 2.000000, 3.000000]
x[2,4] [0.000000, 0.000000, 0.000000]
x[2,5] [0.000000, 0.000000, 0.000000]
x[2,6] [0.00[Taichi] Starting on arch=arm64
0000, 0.000000, 0.000000]
x[2,7] [0.000000, 0.000000, 0.000000]
x[2,8] [0.000000, 0.000000, 0.000000]
x[2,9] [0.000000, 0.000000, 0.000000]
x[3,0] [0.000000, 0.000000, 0.000000]
x[3,1] [0.000000, 0.000000, 0.000000]
x[3,2] [0.000000, 0.000000, 0.000000]
x[3,3] [1.000000, 2.000000, 3.000000]
x[3,4] [0.000000, 0.000000, 0.000000]
x[3,5] [0.000000, 0.000000, 0.000000]
x[3,6] [0.000000, 0.000000, 0.000000]
x[3,7] [0.000000, 0.000000, 0.000000]
x[3,8] [0.000000, 0.000000, 0.000000]
x[3,9] [0.000000, 0.000000, 0.000000]
x[4,0] [0.000000, 0.000000, 0.000000]
x[4,1] [0.000000, 0.000000, 0.000000]
x[4,2] [0.000000, 0.000000, 0.000000]
x[4,3] [0.000000, 0.000000, 0.000000]
x[4,4] [0.000000, 0.000000, 0.000000]
x[4,5] [0.000000, 0.000000, 0.000000]
x[4,6] [0.000000, 0.000000, 0.000000]
x[4,7] [0.000000, 0.000000, 0.000000]
x[4,8] [0.000000, 0.000000, 0.000000]
x[4,9] [0.000000, 0.000000, 0.000000]
x[5,0] [0.000000, 0.000000, 0.000000]
x[5,1] [0.000000, 0.000000, 0.000000]
x[5,2] [0.000000, 0.000000, 0.000000]
x[5,3] [0.000000, 0.000000, 0.000000]
x[5,4] [0.000000, 0.000000, 0.000000]
x[5,5] [0.000000, 0.000000, 0.000000]
x[5,6] [0.000000, 0.000000, 0.000000]
x[5,7] [0.000000, 0.000000, 0.000000]
x[5,8] [0.000000, 0.000000, 0.000000]
x[5,9] [0.000000, 0.000000, 0.000000]
x[6,0] [0.000000, 0.000000, 0.000000]
x[6,1] [0.000000, 0.000000, 0.000000]
x[6,2] [0.000000, 0.000000, 0.000000]
x[6,3] [0.000000, 0.000000, 0.000000]
x[6,4] [0.000000, 0.000000, 0.000000]
x[6,5] [0.000000, 0.000000, 0.000000]
x[6,6] [0.000000, 0.000000, 0.000000]
x[6,7] [0.000000, 0.000000, 0.000000]
x[6,8] [0.000000, 0.000000, 0.000000]
x[6,9] [0.000000, 0.000000, 0.000000]
x[7,0] [0.000000, 0.000000, 0.000000]
x[7,1] [0.000000, 0.000000, 0.000000]
x[7,2] [0.000000, 0.000000, 0.000000]
x[7,3] [0.000000, 0.000000, 0.000000]
x[7,4] [0.000000, 0.000000, 0.000000]
x[7,5] [0.000000, 0.000000, 0.000000]
x[7,6] [0.000000, 0.000000, 0.000000]
x[7,7] [0.000000, 0.000000, 0.000000]
x[7,8] [0.000000, 0.000000, 0.000000]
x[7,9] [0.000000, 0.000000, 0.000000]
x[8,0] [0.000000, 0.000000, 0.000000]
x[8,1] [0.000000, 0.000000, 0.000000]
x[8,2] [0.000000, 0.000000, 0.000000]
x[8,3] [0.000000, 0.000000, 0.000000]
x[8,4] [0.000000, 0.000000, 0.000000]
x[8,5] [0.000000, 0.000000, 0.000000]
x[8,6] [0.000000, 0.000000, 0.000000]
x[8,7] [0.000000, 0.000000, 0.000000]
x[8,8] [0.000000, 0.000000, 0.000000]
x[8,9] [0.000000, 0.000000, 0.000000]
x[9,0] [0.000000, 0.000000, 0.000000]
x[9,1] [0.000000, 0.000000, 0.000000]
x[9,2] [0.000000, 0.000000, 0.000000]
x[9,3] [0.000000, 0.000000, 0.000000]
x[9,4] [0.000000, 0.000000, 0.000000]
x[9,5] [0.000000, 0.000000, 0.000000]
x[9,6] [0.000000, 0.000000, 0.000000]
x[9,7] [0.000000, 0.000000, 0.000000]
x[9,8] [0.000000, 0.000000, 0.000000]
x[9,9] [0.000000, 0.000000, 0.000000]
(10, 10)
import taichi as ti
ti.init()
x = ti.field(ti.f32)
snode = ti.root.pointer(ti.ij,(10,10))
snode.place(x)
# print(x.shape)

x[1,3] = 1.3
x[1,5] = 1.6
x[2,3] = 1.4
x[3,3] = 1.0

@ti.kernel
def test():
for i,j in x:
print('x[{},{}]={}'.format(i,j,x[i,j]))

test()
x[1,3]=1.300000
x[1,5]=1.600000
x[2,3]=1.400000
x[3,3]=1.000000
[Taichi] Starting on arch=arm64