example.cpp#

The file example.cpp is a simple example of computing a complex 1D four-point FFT in-place.


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
*  Copyright (C) 2023--2024, High Performance Kernels LLC                     *
*                                                                             *
*    This software and the related documents are provided as is, WITHOUT ANY  *
*  WARRANTY, without even the implied warranty of MERCHANTABILITY or FITNESS  *
*  FOR A PARTICULAR PURPOSE.                                                  *
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

#include <complex>
#include <iostream>
#include <vector>

#include <hpk/fft/makeFactory.hpp>

int main() {
    auto factory = hpk::fft::makeFactory<float>();
    auto fft = factory->makeInplace({4});  // Four points
    std::vector<std::complex<float>> v = {7.0f, 0.0f, 0.0f, 0.0f};
    std::cout << "Time:";
    for (const auto& point : v) std::cout << ' ' << point;
    std::cout << '\n';
    fft->forward(v.data());  // Compute the FFT!
    std::cout << "Freq:";
    for (const auto& point : v) std::cout << ' ' << point;
    std::cout << '\n';
}