42 static double my_weight(
double z,
double a,
double b,
double c)
44 return pow(0.25-z*z,b)/(c+pow(fabs(z),2*a));
50 int j,k,k0,k1,l,my_N[2],my_n[2];
57 my_N[0]=N; my_n[0]=X(next_power_of_2)(N);
58 my_N[1]=N; my_n[1]=X(next_power_of_2)(N);
59 nfft_init_guru(&p, 2, my_N, M, my_n, 6,
60 PRE_PHI_HUT| PRE_FULL_PSI|
61 MALLOC_X| MALLOC_F_HAT| MALLOC_F|
62 FFTW_INIT| FFT_OUT_OF_PLACE,
63 FFTW_MEASURE| FFTW_DESTROY_INPUT);
67 fprintf(stderr,
"Using the generic solver!");
70 fp=fopen(
"input_data.dat",
"r");
73 fscanf(fp,
"%le %le %le",&p.
x[2*j+0],&p.
x[2*j+1],&tmp_y);
80 nfft_precompute_one_psi(&p);
83 if(ip.
flags & PRECOMPUTE_DAMP)
84 for(k0=0;k0<p.
N[0];k0++)
85 for(k1=0;k1<p.
N[1];k1++)
87 my_weight(((
double)(k0-p.
N[0]/2))/p.
N[0],0.5,3,0.001)*
88 my_weight(((
double)(k1-p.
N[1]/2))/p.
N[1],0.5,3,0.001);
95 solver_before_loop_complex(&ip);
98 fprintf(stderr,
"Residual ||r||=%e,\n",sqrt(ip.
dot_r_iter));
110 static void glacier_cv(
int N,
int M,
int M_cv,
unsigned solver_flags)
112 int j,k,k0,k1,l,my_N[2],my_n[2];
116 double _Complex* cp_y;
121 my_N[0]=N; my_n[0]=X(next_power_of_2)(N);
122 my_N[1]=N; my_n[1]=X(next_power_of_2)(N);
123 nfft_init_guru(&p, 2, my_N, M_re, my_n, 6,
124 PRE_PHI_HUT| PRE_FULL_PSI|
125 MALLOC_X| MALLOC_F_HAT| MALLOC_F|
126 FFTW_INIT| FFT_OUT_OF_PLACE,
127 FFTW_MEASURE| FFTW_DESTROY_INPUT);
134 cp_y = (
double _Complex*)
nfft_malloc(M*
sizeof(
double _Complex));
135 nfft_init_guru(&cp, 2, my_N, M, my_n, 6,
136 PRE_PHI_HUT| PRE_FULL_PSI|
138 FFTW_INIT| FFT_OUT_OF_PLACE,
139 FFTW_MEASURE| FFTW_DESTROY_INPUT);
144 fp=fopen(
"input_data.dat",
"r");
147 fscanf(fp,
"%le %le %le",&cp.
x[2*j+0],&cp.
x[2*j+1],&tmp_y);
155 p.
x[2*j+0]=cp.
x[2*j+0];
156 p.
x[2*j+1]=cp.
x[2*j+1];
162 nfft_precompute_one_psi(&p);
166 nfft_precompute_one_psi(&cp);
169 if(ip.
flags & PRECOMPUTE_DAMP)
170 for(k0=0;k0<p.
N[0];k0++)
171 for(k1=0;k1<p.
N[1];k1++)
173 my_weight(((
double)(k0-p.
N[0]/2))/p.
N[0],0.5,3,0.001)*
174 my_weight(((
double)(k1-p.
N[1]/2))/p.
N[1],0.5,3,0.001);
181 solver_before_loop_complex(&ip);
193 fprintf(stderr,
"r=%1.2e, ",r);
194 printf(
"$%1.1e$ & ",r);
199 fprintf(stderr,
"r_1=%1.2e\t",r);
200 printf(
"$%1.1e$ & ",r);
209 int main(
int argc,
char **argv)
215 fprintf(stderr,
"Call this program from the Matlab script glacier.m!");
220 glacier(atoi(argv[1]),atoi(argv[2]));
222 for(M_cv=atoi(argv[3]);M_cv<=atoi(argv[5]);M_cv+=atoi(argv[4]))
224 fprintf(stderr,
"\nM_cv=%d,\t",M_cv);
225 printf(
"$%d$ & ",M_cv);
226 fprintf(stderr,
"cgne+damp: ");
227 glacier_cv(atoi(argv[1]),atoi(argv[2]),M_cv,CGNE| PRECOMPUTE_DAMP);
230 fprintf(stderr,
"cgnr: ");
231 glacier_cv(atoi(argv[1]),atoi(argv[2]),M_cv,CGNR);
232 fprintf(stderr,
"cgnr: ");
233 glacier_cv(atoi(argv[1])/4,atoi(argv[2]),M_cv,CGNR);
234 printf(
"XXX \\\\\n");
237 fprintf(stderr,
"\n");
fftw_complex * f_hat
Vector of Fourier coefficients, size is N_total * sizeof( fftw_complex )
unsigned flags
iteration type
double dot_r_iter
weighted dotproduct of r_iter
fftw_complex * f
Vector of samples, size is M_total * sizeof( fftw_complex )
#define NFFT_SWAP_complex(x, y)
Swapping of two vectors.
void nfft_trafo(nfft_plan *ths)
user routines
int M_total
Total number of samples.
Header file for utility functions used by the nfft3 library.
static void glacier(int N, int M)
Reconstruction routine.
unsigned nfft_flags
Flags for precomputation, (de)allocation, and FFTW usage, default setting is PRE_PHI_HUT | PRE_PSI | ...
void nfft_upd_axpy_complex(fftw_complex *x, double a, fftw_complex *y, int n)
Updates .
void * nfft_malloc(size_t n)
double nfft_dot_complex(fftw_complex *x, int n)
Computes the inner/dot product .
static void glacier_cv(int N, int M, int M_cv, unsigned solver_flags)
Reconstruction routine with cross validation.
static double my_weight(double z, double a, double b, double c)
Generalised Sobolev weight.
fftw_complex * y
right hand side, samples
double * x
Nodes in time/spatial domain, size is doubles.
void solver_loop_one_step_complex(solver_plan_complex *ths)
void solver_loop_one_step
void solver_finalize_complex(solver_plan_complex *ths)
void solver_finalize
int N_total
Total number of Fourier coefficients.
double * w_hat
damping factors
fftw_complex * f_hat_iter
iterative solution