NFFT  3.3.0
nsfft/simple_test.c
1 /*
2  * Copyright (c) 2002, 2015 Jens Keiner, Stefan Kunis, Daniel Potts
3  *
4  * This program is free software; you can redistribute it and/or modify it under
5  * the terms of the GNU General Public License as published by the Free Software
6  * Foundation; either version 2 of the License, or (at your option) any later
7  * version.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12  * details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc., 51
16  * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
18 
19 /* $Id$ */
20 
21 #include <stdio.h>
22 #include <math.h>
23 #include <string.h>
24 #include <stdlib.h>
25 #include <complex.h>
26 
27 #include "nfft3.h"
28 
29 static void simple_test_nsfft(int d, int J, int M)
30 {
31  int K=12;
32  nsfft_plan p;
33 
34  nsfft_init(&p, d, J, M, 6, NSDFT);
35 
36  nsfft_init_random_nodes_coeffs(&p);
37 
38  nfft_vpr_complex(p.f_hat, K, "frequencies, vector f_hat (first few entries)");
39 
41  nsfft_trafo_direct(&p);
42  nfft_vpr_complex(p.f, K, "nsdft, vector f (first few entries)");
43 
45  nsfft_trafo(&p);
46  nfft_vpr_complex(p.f, K, "nsfft, vector f (first few entries)");
47 
49  nsfft_adjoint_direct(&p);
50  nfft_vpr_complex(p.f_hat, K, "adjoint nsdft, vector f_hat, (first few entries)");
51 
53  nsfft_adjoint(&p);
54  nfft_vpr_complex(p.f_hat, K, "adjoint nsfft, vector f_hat, (first few entries)");
55 
57  nsfft_finalize(&p);
58 }
59 
60 int main(int argc,char **argv)
61 {
62  int d, J, M;
63 
64  system("clear");
65  printf("1) computing a two dimensional nsdft, nsfft and adjoints\n\n");
66  d=2;
67  J=5;
68  M=(J+4)*nfft_exp2i(J+1);
69  simple_test_nsfft(d,J,M);
70  getc(stdin);
71 
72  system("clear");
73  printf("2) computing a three dimensional nsdft, nsfft and adjoints\n\n");
74  d=3;
75  J=5;
76  M=6*nfft_exp2i(J)*(nfft_exp2i((J+1)/2+1)-1)+nfft_exp2i(3*(J/2+1));
77  simple_test_nsfft(d,J,M);
78 
79  return 1;
80 }
fftw_complex * f
Samples.
Definition: nfft3.h:477
void nfft_vpr_complex(fftw_complex *x, const NFFT_INT n, const char *text)
Print complex vector to standard output.
data structure for an NSFFT (nonequispaced sparse fast Fourier transform) plan with double precision ...
Definition: nfft3.h:477
fftw_complex * f_hat
Fourier coefficients.
Definition: nfft3.h:477