Created
March 6, 2022 15:08
-
-
Save mralfarrakhan/0631eae2ac9364cfe3f3adc2380b26d9 to your computer and use it in GitHub Desktop.
Basic 1D convolution function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <vector> | |
| template<typename T> | |
| auto convolve(std::vector<T> v1, std::vector<T> v2){ | |
| std::vector<T> res(v1.size() + v2.size() - 1); | |
| for(int i = 0; i < v1.size(); i++){ | |
| int j = i; | |
| for(const auto &ev2 : v2){ | |
| res[j++] += v1[i]*ev2; | |
| } | |
| } | |
| return res; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment