Skip to content

Instantly share code, notes, and snippets.

@adamnemecek
Created January 9, 2024 16:40
Show Gist options
  • Save adamnemecek/0317b9ede0a4b6726ca144c4d63c6bd0 to your computer and use it in GitHub Desktop.
Save adamnemecek/0317b9ede0a4b6726ca144c4d63c6bd0 to your computer and use it in GitHub Desktop.
convolution == superposition
using DSP: conv
@assert conv([1, 0, 0], 1:4) .+ # [1, 2, 3, 4, 0, 0]
conv([0, 2, 0], 1:4) .+ # [0, 2, 4, 6, 8, 0]
conv([0, 0, 3], 1:4) == # [0, 0, 3, 6, 9, 12]
conv([1, 2, 3], 1:4) # [1, 4, 10, 16, 17, 12]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment