also allow to add an offset.

This commit is contained in:
suter_a 2019-10-24 13:02:34 +02:00
parent 2650c7d12b
commit 503336e685

View File

@ -4,33 +4,42 @@
#include <fftw3.h>
void fftw3_test_syntax() {
std::cout << "fftw3_test [N]" << std::endl;
std::cout << std::endl;
std::cout << "fftw3_test [N [offset]]" << std::endl;
std::cout << " N: 2^N Fourier Power" << std::endl;
std::cout << " default value if not given: N=13 (2^13 = 8192)" << std::endl;
std::cout << " offset: allows to have a length != 2^N, namely 2^N + offset" << std::endl;
std::cout << " default value of offset if not given is 0." << std::endl;
std::cout << std::endl;
}
int main(int argc, char *argv[]) {
unsigned int N=8192;
unsigned int offset=0;
if (argc > 2) {
if (argc > 3) {
fftw3_test_syntax();
return 1;
}
if (argc == 2) {
int a = -1.0;
int status = sscanf(argv[1], "%d", &a);
int a=-1;
for (int i=1; i<argc; i++) {
int status = sscanf(argv[i], "%d", &a);
if (status != 1) {
fftw3_test_syntax();
return 2;
}
N = (int)pow(2.0, a);
if (i==1) // N
N = (unsigned int)pow(2.0, a);
if (i==2) // offset
offset = (unsigned int)a;
}
std::cout << "debug> N=" << N << std::endl;
std::cout << "debug> N=" << N << ", offset=" << offset << std::endl;
fftw_complex *in, *out;
fftw_plan my_plan;
N += offset;
in = (fftw_complex*) fftw_malloc(sizeof(fftw_complex)*N);
out = (fftw_complex*) fftw_malloc(sizeof(fftw_complex)*N);