Skończyło się na testowaniu kilku rzeczy i ostatecznie skończyłem z tymi trzema funkcjami, które robią to, co chcę i że rozważałem proste przykłady.
Przetestowałem to na niektórych wejściach i miałem dobre wyniki. Nie przeprowadziłem jednak obszernych testów.
//Note after each operation status should be 0 on success
std::vector<std::complex<float>> fft_complex(std::vector<std::complex<float>>& in){
std::vector<std::complex<float>> out(in.size());
DFTI_DESCRIPTOR_HANDLE descriptor;
MKL_LONG status;
status = DftiCreateDescriptor(&descriptor, DFTI_SINGLE, DFTI_COMPLEX, 1, in.size()); //Specify size and precision
status = DftiSetValue(descriptor, DFTI_PLACEMENT, DFTI_NOT_INPLACE); //Out of place FFT
status = DftiCommitDescriptor(descriptor); //Finalize the descriptor
status = DftiComputeForward(descriptor, in.data(), out.data()); //Compute the Forward FFT
status = DftiFreeDescriptor(&descriptor); //Free the descriptor
return out;
}
std::vector<std::complex<float>> fft_real(std::vector<float>& in_real){
std::vector<std::complex<float>> in(in_real.size());
std::copy(in_real.begin(), in_real.end(), in.begin());
return fft_complex(in);
}
std::vector<float> ifft(std::vector<std::complex<float>>& in){
std::vector<std::complex<float>> out(in.size());
DFTI_DESCRIPTOR_HANDLE descriptor;
MKL_LONG status;
status = DftiCreateDescriptor(&descriptor, DFTI_SINGLE, DFTI_COMPLEX, 1, in.size()); //Specify size and precision
status = DftiSetValue(descriptor, DFTI_PLACEMENT, DFTI_NOT_INPLACE); //Out of place FFT
status = DftiSetValue(descriptor, DFTI_BACKWARD_SCALE, 1.0f/in.size()); //Scale down the output
status = DftiCommitDescriptor(descriptor); //Finalize the descriptor
status = DftiComputeBackward(descriptor, in.data(), out.data()); //Compute the Forward FFT
status = DftiFreeDescriptor(&descriptor); //Free the descriptor
std::vector<float> output(out.size());
for(std::size_t i = 0; i < out.size(); ++i){
output[i] = out[i].real();
}
return output;
}
ja zakładam, że odnosimy się do tych przykładów [] (https://software.intel.com/en-us/node/471390), być może bardziej konkretnie te "C Interface". W takim przypadku przeczytaj link [Fourier Transform Functions] (https://software.intel.com/en-us/node/470818#8EB0A29C-06D8-4C97-ACD0-C8A320501A6A) znajdujący się u góry. – SleuthEye
@SleuthEye Tak, miałem na myśli. Osobiście nie uważam tych nadętych przykładów za użyteczne, ale prawdopodobnie wystarczy to dla innych. Chciałbym znaleźć prostsze przykłady. Wygląda na to, że prawdopodobnie będę musiał z nimi zrobić. –
Kontynuowałem sprawdzanie oficjalnych przykładów, ale niektóre z nich nawet nie kompilują ... To nie jest dobry sposób na początek ... –