Ivorforce / NumDot

Tensor math and scientific computation for the Godot game engine.
https://numdot.readthedocs.io
MIT License
19 stars 7 forks source link

Add optimized 1D and 2D convolution #109

Open 20akshay00 opened 1 month ago

20akshay00 commented 1 month ago

An analogue of scipy.signal.convolve2d would be extremely useful to simulate the following classes of models for example:

1) Cellular automata, where we typically perform computations based on the neighbours of a cell. The SIRS demo is currently held back due to this.

2) 2D Differential equations, where we need to apply a Laplacian operation which manifests as a convolution on a discrete grid. Alternatively, this can be implemented through matrix multiplication also.

3) Image processing of course.

Perhaps a case can be made that this is a fairly specialized function similar to a fft or quadgk, etc. Whether it is general enough to warrant addition into NumDot or if these things must be maintained in a separate SciDot project is up for discussion.

ToDo

Ivorforce commented 1 month ago

At the same time, we can probably also add convolve1d. NumPy has it too, and xtensor at least has an implementation for 1D convolutions (even if it's a bit... manual).

Ivorforce commented 3 weeks ago

With #110 implemented, 2D and 1D convolutions are already possible. Explicitly 2D and 1D convolutions should still be implemented since they're the most common by far, and are likely to benefit from optimization.