37 static void construct(
char * file,
int N,
int M,
int Z, fftw_complex *mem)
47 fp=fopen(
"knots.dat",
"r");
51 fscanf(fp,
"%le %le %le",&my_plan.
x[2*j+0],&my_plan.
x[2*j+1],&tmp);
61 my_plan.
f_hat[j] = mem[(z*N*N+N*N*Z/2+j)%(N*N*Z)];
70 fprintf(fp,
"%le %le %le %le %le\n",my_plan.
x[2*j+0],my_plan.
x[2*j+1],tmp/Z-0.5,
71 creal(my_plan.
f[j]),cimag(my_plan.
f[j]));
83 static void fft(
int N,
int M,
int Z, fftw_complex *mem)
86 plan = fftw_plan_many_dft(1, &Z, N*N,
91 FFTW_FORWARD, FFTW_ESTIMATE);
94 fftw_destroy_plan(plan);
101 static void read_data(
int N,
int M,
int Z, fftw_complex *mem)
106 fin=fopen(
"input_f.dat",
"r");
112 fscanf(fin,
"%le ",&real );
113 mem[(z*N*N+N*N*Z/2+i)%(N*N*Z)]=real;
119 int main(
int argc,
char **argv)
124 printf(
"usage: ./construct_data FILENAME N M Z\n");
128 mem = (fftw_complex*)
nfft_malloc(
sizeof(fftw_complex) * atoi(argv[2]) * atoi(argv[2]) * atoi(argv[4]));
130 read_data(atoi(argv[2]),atoi(argv[3]),atoi(argv[4]), mem);
132 fft(atoi(argv[2]),atoi(argv[3]),atoi(argv[4]), mem);
134 construct(argv[1],atoi(argv[2]),atoi(argv[3]),atoi(argv[4]), mem);
fftw_complex * f_hat
Fourier coefficients.
static void read_data(int N, int M, int Z, fftw_complex *mem)
read fills the memory with the file input_data_f.dat as the real part of f and with zeros for the ima...
void nfft_init_2d(nfft_plan *ths, int N1, int N2, int M)
void nfft_precompute_psi(nfft_plan *ths)
static void fft(int N, int M, int Z, fftw_complex *mem)
fft makes an 1D-ftt for every knot through all layers
data structure for an NFFT (nonequispaced fast Fourier transform) plan with double precision ...
NFFT_INT M_total
Total number of samples.
void nfft_trafo(nfft_plan *ths)
void * nfft_malloc(size_t n)
void nfft_finalize(nfft_plan *ths)
Header file for the nfft3 library.
double * x
Nodes in time/spatial domain, size is doubles.
unsigned flags
Flags for precomputation, (de)allocation, and FFTW usage, default setting is PRE_PHI_HUT | PRE_PSI | ...
static void construct(char *file, int N, int M, int Z, fftw_complex *mem)
construct makes an 2d-nfft for every slice