Skip to content

Commit

Permalink
[Lang] Use ti.linalg.SparseMatrixBuilder in code
Browse files Browse the repository at this point in the history
  • Loading branch information
FantasyVR committed Oct 15, 2021
1 parent a651e27 commit 0b948d8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions examples/simulation/implicit_mass_spring.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ def __init__(self, N):
self.gravity = ti.Vector([0.0, -2.0])
self.init_pos()
self.init_edges()
self.MassBuilder = ti.SparseMatrixBuilder(2 * self.NV,
self.MassBuilder = ti.linalg.SparseMatrixBuilder(2 * self.NV,
2 * self.NV,
max_num_triplets=10000)
self.DBuilder = ti.SparseMatrixBuilder(2 * self.NV,
self.DBuilder = ti.linalg.SparseMatrixBuilder(2 * self.NV,
2 * self.NV,
max_num_triplets=10000)
self.KBuilder = ti.SparseMatrixBuilder(2 * self.NV,
self.KBuilder = ti.linalg.SparseMatrixBuilder(2 * self.NV,
2 * self.NV,
max_num_triplets=10000)
self.init_mass_sp(self.MassBuilder)
Expand Down
2 changes: 1 addition & 1 deletion examples/simulation/stable_fluid.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def fill_laplacian_matrix(A: ti.sparse_matrix_builder()):
A[row, row] += center

N = res * res
K = ti.SparseMatrixBuilder(N, N, max_num_triplets=N * 6)
K = ti.linalg.SparseMatrixBuilder(N, N, max_num_triplets=N * 6)
b = ti.field(ti.f32, shape=N)

fill_laplacian_matrix(K)
Expand Down
4 changes: 2 additions & 2 deletions misc/sparse_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

n = 8

K = ti.SparseMatrixBuilder(n, n, max_num_triplets=100)
f = ti.SparseMatrixBuilder(n, 1, max_num_triplets=100)
K = ti.linalg.SparseMatrixBuilder(n, n, max_num_triplets=100)
f = ti.linalg.SparseMatrixBuilder(n, 1, max_num_triplets=100)


@ti.kernel
Expand Down
6 changes: 3 additions & 3 deletions tests/python/test_spmv.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
@ti.test(arch=ti.cpu)
def test_sparse_matrix_vector_multiplication1():
n = 8
Abuilder = ti.SparseMatrixBuilder(n, n, max_num_triplets=100)
Abuilder = ti.linalg.SparseMatrixBuilder(n, n, max_num_triplets=100)
b = ti.field(ti.f32, shape=n)

@ti.kernel
Expand All @@ -25,7 +25,7 @@ def fill(Abuilder: ti.sparse_matrix_builder(), b: ti.template()):
@ti.test(arch=ti.cpu)
def test_sparse_matrix_vector_multiplication2():
n = 8
Abuilder = ti.SparseMatrixBuilder(n, n, max_num_triplets=100)
Abuilder = ti.linalg.SparseMatrixBuilder(n, n, max_num_triplets=100)
b = ti.field(ti.f32, shape=n)

@ti.kernel
Expand All @@ -49,7 +49,7 @@ def fill(Abuilder: ti.sparse_matrix_builder(), b: ti.template()):
@ti.test(arch=ti.cpu)
def test_sparse_matrix_vector_multiplication3():
n = 8
Abuilder = ti.SparseMatrixBuilder(n, n, max_num_triplets=100)
Abuilder = ti.linalg.SparseMatrixBuilder(n, n, max_num_triplets=100)
b = ti.field(ti.f32, shape=n)

@ti.kernel
Expand Down

0 comments on commit 0b948d8

Please sign in to comment.