C++ is the ultimate language when we look for speed and optimization. C++ code is compiled into binaries that can be called in Python. To validate the implementation, i developed a simple program in python that can call FT functions several times with different signal lengths. For each call, python is used to calculate the time the function will take to return the results. Then, Compare the return arrays from both FT and FFT and show the error between them.
I assume you're using linux, using windows should work fine but with some few tweaks.
Follow instructions to install the latest version of python for your platform in the python docs
It is recommended working within a virtual environment whenever using Python for projects. This keeps your dependencies for each project separate and organaized. Instructions for setting up a virtual enviornment for your platform can be found in the python docs
Once you have your virtual environment setup and running, install dependencies by running:
pip install -r requirements.txt
This will install all of the required packages selected within the requirements.txt
file.
First, clone the pybind11 repository by running:
git clone https://github.com/pybind/pybind11.git
Compile c++ code by running:
You need to install cmake and make
mkdir build
cd build/
cmake ..
make
Navigate back to the project directory by running:
cd ../
python run.py
From the output plot, we can see that FT time complexity is in the order of N^2 while FFT is in the order of (N log(N)). The output error is almost zero.