Is it possible to slice/assign one column of ti.Matrix at once

Hi there! Just as the title shows, I am wondering if it is possible to slice or assign a single column of ti.Matrix at once.

In numpy, we can slice a column vector of the 2x2 matrix below and assign a new column like this:

a = np.array([[1,2],[3,4]])
a[:, 0] = [4,5]

Is it possible to do so in Taichi?
The reason why I’d like to have this feature is that I am learning the Siggraph 2012 FEM course, and the alg is shown below. In the alg I need to assign the column vector of H to force f.

Thx!

a = ti.Matrix([[1,2],[3,4]])
a[:, 0] = ti.Vector([4,5])

We don’t support matrix slicing yet, but this is definitely a cool feature to have!
For now, we may walk around by using static-for:

a = ti.Matrix([[1,2],[3,4]])
b = ti.Vector([4,5])
for i in ti.static(range(2)):
  a[i, 0] = b[i]
1 个赞

Thank you! Really hope we can have the matrix slicing feature introduced soon.