NFFT  3.4.1
nsfft/simple_test.c
1 /*
2  * Copyright (c) 2002, 2017 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 #include <stdio.h>
20 #include <math.h>
21 #include <string.h>
22 #include <stdlib.h>
23 #include <complex.h>
24 
25 #include "nfft3.h"
26 
27 static void simple_test_nsfft(int d, int J, int M)
28 {
29  int K=12;
30  nsfft_plan p;
31 
32  nsfft_init(&p, d, J, M, 6, NSDFT);
33 
35 
36  nfft_vpr_complex(p.f_hat, K, "frequencies, vector f_hat (first few entries)");
37 
39  nsfft_trafo_direct(&p);
40  nfft_vpr_complex(p.f, K, "nsdft, vector f (first few entries)");
41 
43  nsfft_trafo(&p);
44  nfft_vpr_complex(p.f, K, "nsfft, vector f (first few entries)");
45 
47  nsfft_adjoint_direct(&p);
48  nfft_vpr_complex(p.f_hat, K, "adjoint nsdft, vector f_hat, (first few entries)");
49 
51  nsfft_adjoint(&p);
52  nfft_vpr_complex(p.f_hat, K, "adjoint nsfft, vector f_hat, (first few entries)");
53 
55  nsfft_finalize(&p);
56 }
57 
58 int main(int argc,char **argv)
59 {
60  int d, J, M;
61 
62  system("clear");
63  printf("1) computing a two dimensional nsdft, nsfft and adjoints\n\n");
64  d=2;
65  J=5;
66  M=(J+4)*nfft_exp2i(J+1);
67  simple_test_nsfft(d,J,M);
68  getc(stdin);
69 
70  system("clear");
71  printf("2) computing a three dimensional nsdft, nsfft and adjoints\n\n");
72  d=3;
73  J=5;
74  M=6*nfft_exp2i(J)*(nfft_exp2i((J+1)/2+1)-1)+nfft_exp2i(3*(J/2+1));
75  simple_test_nsfft(d,J,M);
76 
77  return 1;
78 }
void nsfft_init(nsfft_plan *ths, int d, int J, int M, int m, unsigned flags)
Definition: nsfft.c:1778
fftw_complex * f
Samples.
Definition: nfft3.h:475
void nfft_vpr_complex(fftw_complex *x, const NFFT_INT n, const char *text)
Print complex vector to standard output.
void nsfft_init_random_nodes_coeffs(nsfft_plan *ths)
Definition: nsfft.c:723
void nsfft_adjoint(nsfft_plan *ths)
Definition: nsfft.c:1549
Header file for the nfft3 library.
void nsfft_finalize(nsfft_plan *ths)
Definition: nsfft.c:1885
#define NSDFT
Definition: nfft3.h:476
void nsfft_trafo(nsfft_plan *ths)
Definition: nsfft.c:1541
data structure for an NSFFT (nonequispaced sparse fast Fourier transform) plan with double precision ...
Definition: nfft3.h:475
fftw_complex * f_hat
Fourier coefficients.
Definition: nfft3.h:475