3.2.3
Main Page
Modules
Data Structures
Files
File List
Globals
examples
solver
solver/simple_test.c
1
/*
2
* Copyright (c) 2002, 2012 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: simple_test.c 3896 2012-10-10 12:19:26Z tovo $ */
20
#include "config.h"
21
22
#include <stdio.h>
23
#include <math.h>
24
#include <string.h>
25
#include <stdlib.h>
26
#ifdef HAVE_COMPLEX_H
27
#include <complex.h>
28
#endif
29
30
#include "
nfft3util.h
"
31
#include "
nfft3.h
"
32
33
/* void simple_test_infft_1d(int N, int M, int iter) */
34
/* { */
35
/* int k,l; /\**< index for nodes, freqencies,iter*\/ */
36
/* nfft_plan p; /\**< plan for the nfft *\/ */
37
/* infft_plan ip; /\**< plan for the inverse nfft *\/ */
38
39
/* /\** initialise an one dimensional plan *\/ */
40
/* nfft_init_1d(&p, N, M); */
41
42
/* /\** init pseudo random nodes *\/ */
43
/* nfft_vrand_shifted_unit_double(p.x,p.M_total); */
44
45
/* /\** precompute psi, the entries of the matrix B *\/ */
46
/* if(p.nfft_flags & PRE_ONE_PSI) */
47
/* nfft_precompute_one_psi(&p); */
48
49
/* /\** initialise inverse plan *\/ */
50
/* infft_init(&ip,&p); */
51
52
/* /\** init pseudo random samples and show them *\/ */
53
/* nfft_vrand_unit_complex(ip.y,p.M_total); */
54
/* nfft_vpr_complex(ip.y,p.M_total,"Given data, vector y"); */
55
56
/* /\** initialise some guess f_hat_0 and solve *\/ */
57
/* for(k=0;k<p.N_total;k++) */
58
/* ip.f_hat_iter[k]=0; */
59
60
/* nfft_vpr_complex(ip.f_hat_iter,p.N_total,"Initial guess, vector f_hat_iter"); */
61
62
/* NFFT_SWAP_complex(ip.f_hat_iter,p.f_hat); */
63
/* nfft_trafo(&p); */
64
/* nfft_vpr_complex(p.f,p.M_total,"Data fit, vector f"); */
65
/* NFFT_SWAP_complex(ip.f_hat_iter,p.f_hat); */
66
67
/* infft_before_loop(&ip); */
68
/* printf("\n Residual r=%e\n",ip.dot_r_iter); */
69
70
/* for(l=0;l<iter;l++) */
71
/* { */
72
/* printf("\n********** Iteration l=%d **********\n",l); */
73
/* infft_loop_one_step(&ip); */
74
/* nfft_vpr_complex(ip.f_hat_iter,p.N_total, */
75
/* "Approximate solution, vector f_hat_iter"); */
76
77
/* NFFT_SWAP_complex(ip.f_hat_iter,p.f_hat); */
78
/* nfft_trafo(&p); */
79
/* nfft_vpr_complex(p.f,p.M_total,"Data fit, vector f"); */
80
/* NFFT_SWAP_complex(ip.f_hat_iter,p.f_hat); */
81
82
/* printf("\n Residual r=%e\n",ip.dot_r_iter); */
83
/* } */
84
85
/* infft_finalize(&ip); */
86
/* nfft_finalize(&p); */
87
/* } */
88
90
static
void
simple_test_solver_nfft_1d(
int
N,
int
M,
int
iter)
91
{
92
int
k,l;
93
nfft_plan
p;
94
solver_plan_complex
ip;
97
nfft_init_1d(&p, N, M);
98
100
nfft_vrand_shifted_unit_double
(p.
x
,p.
M_total
);
101
103
if
(p.
nfft_flags
& PRE_ONE_PSI)
104
nfft_precompute_one_psi(&p);
105
107
solver_init_complex(&ip,(
nfft_mv_plan_complex
*)(&p));
108
110
nfft_vrand_unit_complex
(ip.
y
,p.
M_total
);
111
nfft_vpr_complex
(ip.
y
,p.
M_total
,
"Given data, vector y"
);
112
114
for
(k=0;k<p.
N_total
;k++)
115
ip.
f_hat_iter
[k]=0;
116
117
nfft_vpr_complex
(ip.
f_hat_iter
,p.
N_total
,
"Initial guess, vector f_hat_iter"
);
118
119
NFFT_SWAP_complex
(ip.
f_hat_iter
,p.
f_hat
);
120
nfft_trafo
(&p);
121
nfft_vpr_complex
(p.
f
,p.
M_total
,
"Data fit, vector f"
);
122
NFFT_SWAP_complex
(ip.
f_hat_iter
,p.
f_hat
);
123
124
solver_before_loop_complex(&ip);
125
printf(
"\n Residual r=%e\n"
,ip.
dot_r_iter
);
126
127
for
(l=0;l<iter;l++)
128
{
129
printf(
"\n********** Iteration l=%d **********\n"
,l);
130
solver_loop_one_step_complex
(&ip);
131
nfft_vpr_complex
(ip.
f_hat_iter
,p.
N_total
,
132
"Approximate solution, vector f_hat_iter"
);
133
134
NFFT_SWAP_complex
(ip.
f_hat_iter
,p.
f_hat
);
135
nfft_trafo
(&p);
136
nfft_vpr_complex
(p.
f
,p.
M_total
,
"Data fit, vector f"
);
137
NFFT_SWAP_complex
(ip.
f_hat_iter
,p.
f_hat
);
138
139
printf(
"\n Residual r=%e\n"
,ip.
dot_r_iter
);
140
}
141
142
solver_finalize_complex
(&ip);
143
nfft_finalize(&p);
144
}
145
147
int
main(
void
)
148
{
149
printf(
"\n Computing a one dimensional inverse nfft\n"
);
150
151
simple_test_solver_nfft_1d(8,4,5);
152
153
return
1;
154
}
155
/* \} */
Generated on Tue Apr 30 2013 by Doxygen 1.8.1