5

In the Repa package there are stencils that allow values to be calculated from neighbouring values in a convenient way (useful for convolutions, image blurring, diffusion simulations etc).

In the current Repa package I can make stencils with any shape, but only two-dimensional stencils can be applied using mapStencil2. Is there a way to apply stencils to arrays with a different dimension? There isn't even a way to apply one-dimensional stencils. I am looking for a way to apply three-dimensional stencils.

Thanks

leftaroundabout
  • 117,950
  • 5
  • 174
  • 319
user668074
  • 1,111
  • 10
  • 16
  • 1
    I imagine `mapStencil2` should be generalizable to a higher fixed dimension, but I am not sure what that means for the magic type `type PC5 = P C (P (S D) (P (S D) (P (S D) (P (S D) X))))`... :) – Alec Oct 17 '16 at 06:06
  • Yeah, I saw that type too. No idea how to parse it. If there was a version available for one-dimension maybe it would be clearer. The source code for `mapStencil2` is also a bit obtuse for me. – user668074 Oct 17 '16 at 06:11
  • The `mapStencil2` function is repa is hyperoptimized, but only works for small stencils. See e.g. [convolveP](https://hackage.haskell.org/package/repa-algorithms-3.2.1.1/docs/src/Data-Array-Repa-Algorithms-Convolve.html#convolveP) for a simpler implementation (but still 2D only). If you want such functions for the general n-dimensional (or even 3D) case, you will probably have to write them yourself. – user2407038 Oct 17 '16 at 18:04
  • Ok, that's a bit inconvenient. It's funny to have generic stencils in the package without being able to use them. Is it likely that Repa had a generic `mapStencil` function in the past and it was removed? Maybe I can make a new function based on that. – user668074 Oct 18 '16 at 01:26

0 Answers0