accuracy.c
/*
* Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <math.h>
#include <stdlib.h>
#include <complex.h>
#include "nfft3.h"
#define CSWAP(x,y) {double _Complex * NFFT_SWAP_temp__; \
NFFT_SWAP_temp__=(x); (x)=(y); (y)=NFFT_SWAP_temp__;}
void accuracy(int d)
{
int m,t;
nnfft_plan my_plan;
double _Complex *slow;
int N[d],n[d];
int M_total,N_total;
M_total=10000;N_total=1;
slow=(double _Complex*)nfft_malloc(M_total*sizeof(double _Complex));
for(t=0; t<d; t++)
{
N[t]=(1<<(12/d));
n[t]=2*N[t];
N_total*=N[t];
}
for(m=0; m<10; m++)
{
nnfft_init_guru(&my_plan, d, N_total, M_total, N, n, m,
PRE_PSI| PRE_PHI_HUT|
MALLOC_X| MALLOC_V| MALLOC_F_HAT| MALLOC_F);
nfft_vrand_shifted_unit_double(my_plan.x, d*my_plan.M_total);
nfft_vrand_shifted_unit_double(my_plan.v, d*my_plan.N_total);
if(my_plan.nnfft_flags & PRE_PSI)
nnfft_precompute_psi(&my_plan);
if(my_plan.nnfft_flags & PRE_LIN_PSI)
nnfft_precompute_lin_psi(&my_plan);
if(my_plan.nnfft_flags & PRE_FULL_PSI)
nnfft_precompute_full_psi(&my_plan);
if(my_plan.nnfft_flags & PRE_PHI_HUT)
nnfft_precompute_phi_hut(&my_plan);
nfft_vrand_unit_complex(my_plan.f_hat, my_plan.N_total);
nnfft_trafo_direct(&my_plan);
CSWAP(my_plan.f,slow);
nnfft_trafo(&my_plan);
printf("%e, %e\n",
nfft_error_l_infty_complex(slow, my_plan.f, M_total),
nfft_error_l_infty_1_complex(slow, my_plan.f, M_total, my_plan.f_hat,
my_plan.N_total));
nnfft_finalize(&my_plan);
}
}
int main(void)
{
int d;
for(d=1; d<4; d++)
accuracy(d);
return 1;
}
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