NFFT  3.3.0
nfct/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 
26 #define NFFT_PRECISION_DOUBLE
27 
28 #include "nfft3mp.h"
29 
30 static void simple_test_nfct_1d(void)
31 {
32  NFCT(plan) p;
33 
34  const char *error_str;
35 
36  int N = 14;
37  int M = 19;
38 
40  NFCT(init_1d)(&p,N,M);
41 
43  NFFT(vrand_real)(p.x, p.M_total, NFFT_K(0.0), NFFT_K(0.5));
44 
46  if( p.flags & PRE_ONE_PSI)
47  NFCT(precompute_one_psi)(&p);
48 
50  NFFT(vrand_real)(p.f_hat, p.N_total, NFFT_K(0.0), NFFT_K(1.0));
51  NFFT(vpr_double)(p.f_hat,p.N_total,"given Fourier coefficients, vector f_hat");
52 
54  error_str = NFCT(check)(&p);
55  if (error_str != 0)
56  {
57  printf("Error in nfct module: %s\n", error_str);
58  return;
59  }
60 
62  NFCT(trafo_direct)(&p);
63  NFFT(vpr_double)(p.f,p.M_total,"ndct, vector f");
64 
66  NFCT(trafo)(&p);
67  NFFT(vpr_double)(p.f,p.M_total,"nfct, vector f");
68 
70  NFCT(adjoint_direct)(&p);
71  NFFT(vpr_double)(p.f_hat,p.N_total,"adjoint ndct, vector f_hat");
72 
74  NFCT(adjoint)(&p);
75  NFFT(vpr_double)(p.f_hat,p.N_total,"adjoint nfct, vector f_hat");
76 
78  NFCT(finalize)(&p);
79 }
80 
81 int main(void)
82 {
83  printf("Computing one dimensional ndct, nfct, adjoint ndct, and adjoint nfct...\n\n");
84  simple_test_nfct_1d();
85  printf("\n\n");
86 
87  return EXIT_SUCCESS;
88 }