| NFFT 3.5.0

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

accuracy.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 <math.h>
20 #include <stdlib.h>
21 #include <complex.h>
22
23 #include "nfft3.h"
24
26 #define CSWAP(x,y) {double _Complex * NFFT_SWAP_temp__; \
27 NFFT_SWAP_temp__=(x); (x)=(y); (y)=NFFT_SWAP_temp__;}
28
29 void accuracy(int d)
30 {
31 int m,t;
32 nnfft_plan my_plan;
33 double _Complex *slow;
34
35 int N[d],n[d];
36 int M_total,N_total;
37 M_total=10000;N_total=1;
38
39 slow=(double _Complex*)nfft_malloc(M_total*sizeof(double _Complex));
40
41 for(t=0; t<d; t++)
42 {
43 N[t]=(1<<(12/d));
44 n[t]=2*N[t];
45 N_total*=N[t];
46 }
47
49 for(m=0; m<10; m++)
50 {
51 nnfft_init_guru(&my_plan, d, N_total, M_total, N, n, m,
52 PRE_PSI| PRE_PHI_HUT|
53 MALLOC_X| MALLOC_V| MALLOC_F_HAT| MALLOC_F);
54
55
57 nfft_vrand_shifted_unit_double(my_plan.x, d*my_plan.M_total);
58 nfft_vrand_shifted_unit_double(my_plan.v, d*my_plan.N_total);
59
61 if(my_plan.nnfft_flags & PRE_PSI)
62 nnfft_precompute_psi(&my_plan);
63
64 if(my_plan.nnfft_flags & PRE_LIN_PSI)
65 nnfft_precompute_lin_psi(&my_plan);
66
67 if(my_plan.nnfft_flags & PRE_FULL_PSI)
68 nnfft_precompute_full_psi(&my_plan);
69
71 if(my_plan.nnfft_flags & PRE_PHI_HUT)
72 nnfft_precompute_phi_hut(&my_plan);
73
75 nfft_vrand_unit_complex(my_plan.f_hat, my_plan.N_total);
76
78 nnfft_trafo_direct(&my_plan);
79
80 CSWAP(my_plan.f,slow);
81
83 nnfft_trafo(&my_plan);
84
85 printf("%e, %e\n",
86 nfft_error_l_infty_complex(slow, my_plan.f, M_total),
87 nfft_error_l_infty_1_complex(slow, my_plan.f, M_total, my_plan.f_hat,
88 my_plan.N_total));
89
91 nnfft_finalize(&my_plan);
92 }
93 }
94
95 int main(void)
96 {
97 int d;
98 for(d=1; d<4; d++)
99 accuracy(d);
100
101 return 1;
102 }
nnfft_precompute_psi
void nnfft_precompute_psi(nnfft_plan *ths_plan)
Definition: nnfft.c:385
nnfft_plan::f_hat
fftw_complex * f_hat
Fourier coefficients.
Definition: nfft3.h:424
nnfft_plan::nnfft_flags
unsigned nnfft_flags
flags for precomputation, malloc
Definition: nfft3.h:424
nnfft_plan::f
fftw_complex * f
Samples.
Definition: nfft3.h:424
MALLOC_X
#define MALLOC_X
Definition: nfft3.h:199
MALLOC_F_HAT
#define MALLOC_F_HAT
Definition: nfft3.h:200
nnfft_plan::v
double * v
nodes (in fourier domain)
Definition: nfft3.h:424
nnfft_trafo
void nnfft_trafo(nnfft_plan *ths_plan)
user routines
Definition: nnfft.c:291
nfft_vrand_shifted_unit_double
void nfft_vrand_shifted_unit_double(double *x, const NFFT_INT n)
Inits a vector of random double numbers in .
nnfft_precompute_phi_hut
void nnfft_precompute_phi_hut(nnfft_plan *ths_plan)
initialisation of direct transform
Definition: nnfft.c:347
nnfft_precompute_full_psi
void nnfft_precompute_full_psi(nnfft_plan *ths_plan)
computes all entries of B explicitly
Definition: nnfft.c:424
MALLOC_V
#define MALLOC_V
Definition: nfft3.h:425
nnfft_precompute_lin_psi
void nnfft_precompute_lin_psi(nnfft_plan *ths_plan)
create a lookup table
Definition: nnfft.c:367
nfft_vrand_unit_complex
void nfft_vrand_unit_complex(fftw_complex *x, const NFFT_INT n)
Inits a vector of random complex numbers in .
nnfft_plan::M_total
NFFT_INT M_total
Total number of samples.
Definition: nfft3.h:424
MALLOC_F
#define MALLOC_F
Definition: nfft3.h:201
nnfft_plan
data structure for an NNFFT (nonequispaced in time and frequency fast Fourier transform) plan with do...
Definition: nfft3.h:424
nnfft_plan::x
double * x
nodes (in time/spatial domain)
Definition: nfft3.h:424
PRE_LIN_PSI
#define PRE_LIN_PSI
Definition: nfft3.h:195
PRE_PSI
#define PRE_PSI
Definition: nfft3.h:197
nfft_malloc
void * nfft_malloc(size_t n)
nnfft_plan::N_total
NFFT_INT N_total
Total number of Fourier coefficients.
Definition: nfft3.h:424
PRE_FULL_PSI
#define PRE_FULL_PSI
Definition: nfft3.h:198
nfft3.h
Header file for the nfft3 library.
PRE_PHI_HUT
#define PRE_PHI_HUT
Definition: nfft3.h:193
nnfft_init_guru
void nnfft_init_guru(nnfft_plan *ths_plan, int d, int N_total, int M_total, int *N, int *N1, int m, unsigned nnfft_flags)
Definition: nnfft.c:577
nnfft_finalize
void nnfft_finalize(nnfft_plan *ths_plan)
Definition: nnfft.c:655
CSWAP
#define CSWAP(x, y)
Swap two vectors.
Definition: infft.h:139