stev47 / StaticKernels.jl

Julia-native non-allocating kernel operations on arrays
Other
25 stars 0 forks source link

Allow specifying output axes for use with extensions. #10

Open stev47 opened 1 year ago

stev47 commented 1 year ago

Allow more flexibility in output axes. Currently we only allow

Discussed in https://github.com/stev47/StaticKernels.jl/discussions/9

Originally posted by **RoyiAvital** April 29, 2023 Given 2 vectors: ```julia vA = [1, 2, 3, 4, 5]; vB = [4, 5, 6] ``` I would like to perform their convolution using `StaticKernels.jl`. I would be something like: ```julia vK = Kernel{(0:(length(vB) - 1), )}(@inline vW -> vW[0] * vB[3] + vW[1] * vB[2] + vW[2] * vB[1]); map(vK, extend(vA, StaticKernels.ExtensionConstant(0))); ``` The problem is I can get only 5 (the length of the data `vA`) elements as output and not `length(vA) + length(vB) - 1`. I was wondering if there a trick to do with the boundary extension to get the output of the full convolution? In the case above I can define `vAA = [0, 0, 1, 2, 3, 4, 5]` and then run on it to get the required result, yet I wonder if it can be done without explicitly extend the vector.