This repository contains a C++ Implementation of matlab conv(input, kernel) function using the FFTW3 library.
Make sure you have the FFTW3 library installed. You can find more information about FFTW3 here.
Download fftw from website and place in Pwelch folder.
The Conv_Corr class is the core of this implementation. It includes a function FFT_Convolution with the following parameters:
-
input: The input signal represented as std::complex.
-
kernel: the polynomial coefficients
#include "Conv_Corr.h"
#include "defines.h"
#include <iostream>
int main(int argc, char *argv[])
{
Conv_Corr conv;
vector<c_double> inp(50000);
for(int i=0;i< (int)inp.size();i++){
inp[i].real(i*2);
inp[i].imag(i*2+1);
}
vector<double> kernel(512);
for(int i=0; i< (int)(kernel.size());i++){
kernel[i] = i;
}
vector<c_double> out = conv.FFT_Convolution(inp, kernel);
return ;
}
- create new project in Visual Studio.
- Configure the project settings if needed.
- add header and library file of fftw3 to project
- Build the project using the "Build" menu or by pressing
Ctrl + Shift + B
. - Run the executable generated in the output directory or run in Visual Studio.
- make sure that libfftw3-3.dll is in project directory
Feel free to contribute to this project by submitting issues or pull requests. Your feedback and contributions are highly appreciated.
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.
Implementation of matlab conv(input, kernel) function. First download FFTW fftw-3.3.5 at https://www.fftw.org/download.html. Second, add these files to your project.