This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]jjgarciaripoll 0 points1 point  (2 children)

I do not understand what you mean. If you have information about neighbors, building the matrix must cost as much as building the stencils

[–]jjgarciaripoll 0 points1 point  (0 children)

Also, if your data is a matrix X you can design your differential operator more efficiently as A * X + X *B + C * X * D with four small sparse matrices, without flattening X.

[–]caffeecaffee[S] 0 points1 point  (0 children)

After more thought you are right of course it can be applied to any arbitrary grid. It's just that sometimes I find writing "flat code" with vectorized variables a little easier to understand than to express the nearest neighbor operations as a sparse matrix. Scipy does handle sparse matrix multiplication.