-
Hello JAX Team, |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 15 replies
-
You can express the sparse matrix a, b, c = ... # tridiagnoal
def operator_A(x):
return a * x[1:] + b * x + c * x[:-1] I think most of sparse matrices in FEM can be expressed in stencil computations, thus it is not very hard to re-express them. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
One can 'assemble the finite element system' by using from jax.experimental import sparse
def spsolve(row, col, data, b):
A = sparse.coo.COO((data, row, col), shape=(size,) * 2)
return jax.scipy.sparse.linalg.cg(partial(sparse.coo.coo_matvec, A), b) |
Beta Was this translation helpful? Give feedback.
-
Thanks to all the participants in this discussion, I really appreciate your help! |
Beta Was this translation helpful? Give feedback.
jax.experimental.sparse
does support autodiff of sparse matrix operations. If you can add a small self-contained example of what sort of computation you're hoping to do, I may be able to help you translate it to sparse types.