| NFFT 3.5.0

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

nfsft_benchomp_createdataset.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 <stdio.h>
20 #include <math.h>
21 #include <string.h>
22 #include <stdlib.h>
23 #include <complex.h>
24
25 #include "config.h"
26
27 #include "nfft3.h"
28 #include "infft.h"
29
30 void nfsft_benchomp_createdataset(unsigned int trafo_adjoint, int N, int M)
31 {
32 int t, j, k, n;
33 R *x;
34 C *f, *f_hat;
35 int N_total = (2*N+2) * (2*N+2);
36 nfsft_plan ptemp;
37
38 nfsft_init_guru(&ptemp, N, M, NFSFT_MALLOC_X | NFSFT_MALLOC_F |
39 NFSFT_MALLOC_F_HAT | NFSFT_NORMALIZED | NFSFT_PRESERVE_F_HAT,
40 PRE_PHI_HUT | PRE_PSI | FFTW_INIT | FFT_OUT_OF_PLACE, 6);
41
42 x = (R*) nfft_malloc(2*M*sizeof(R));
43 f = (C*) nfft_malloc(M*sizeof(C));
44 f_hat = (C*) nfft_malloc(N_total*sizeof(C));
45
46 /* init pseudo-random nodes */
47 for (j = 0; j < M; j++)
48 {
49 x[2*j]= X(drand48)() - K(0.5);
50 x[2*j+1]= K(0.5) * X(drand48)();
51 }
52
53 if (trafo_adjoint==0)
54 {
55 for (k = 0; k <= N; k++)
56 for (n = -k; n <= k; n++)
57 nfft_vrand_unit_complex(f_hat+NFSFT_INDEX(k,n,&ptemp),1);
58 }
59 else
60 {
61 nfft_vrand_unit_complex(f,M);
62 }
63
64 printf("%d %d %d\n", trafo_adjoint, N, M);
65
66 for (j=0; j < M; j++)
67 {
68 for (t=0; t < 2; t++)
69 printf("%.16e ", x[2*j+t]);
70 printf("\n");
71 }
72
73 if (trafo_adjoint==0)
74 {
75 for (k = 0; k <= N; k++)
76 for (n = -k; n <= k; n++)
77 printf("%.16e %.16e\n", creal(f_hat[NFSFT_INDEX(k,n,&ptemp)]), cimag(f_hat[NFSFT_INDEX(k,n,&ptemp)]));
78 }
79 else
80 {
81 for (j=0; j < M; j++)
82 printf("%.16e %.16e\n", creal(f[j]), cimag(f[j]));
83 }
84
85 nfft_free(x);
86 nfft_free(f);
87 nfft_free(f_hat);
88 }
89
90 int main(int argc, char **argv)
91 {
92 int trafo_adjoint;
93 int N;
94 int M;
95
96 if (argc < 4) {
97 fprintf(stderr, "usage: tr_adj N M\n");
98 return -1;
99 }
100
101 trafo_adjoint = atoi(argv[1]);
102 if (trafo_adjoint < 0 && trafo_adjoint > 1)
103 trafo_adjoint = 1;
104
105 N = atoi(argv[2]);
106 M = atoi(argv[3]);
107 fprintf(stderr, "tr_adj=%d, N=%d, M=%d\n", trafo_adjoint, N, M);
108
109 nfsft_benchomp_createdataset(trafo_adjoint, N, M);
110
111 return 0;
112 }
NFSFT_MALLOC_F_HAT
#define NFSFT_MALLOC_F_HAT
Definition: nfft3.h:579
NFSFT_NORMALIZED
#define NFSFT_NORMALIZED
Definition: nfft3.h:575
NFSFT_MALLOC_X
#define NFSFT_MALLOC_X
Definition: nfft3.h:578
NFSFT_PRESERVE_F_HAT
#define NFSFT_PRESERVE_F_HAT
Definition: nfft3.h:581
nfsft_plan
data structure for an NFSFT (nonequispaced fast spherical Fourier transform) plan with double precisi...
Definition: nfft3.h:574
nfft_free
void nfft_free(void *p)
nfft_vrand_unit_complex
void nfft_vrand_unit_complex(fftw_complex *x, const NFFT_INT n)
Inits a vector of random complex numbers in .
FFTW_INIT
#define FFTW_INIT
Definition: nfft3.h:203
X
#define X(name)
Include header for C99 complex datatype.
Definition: fastsum.h:57
FFT_OUT_OF_PLACE
#define FFT_OUT_OF_PLACE
Definition: nfft3.h:202
PRE_PSI
#define PRE_PSI
Definition: nfft3.h:197
nfft_malloc
void * nfft_malloc(size_t n)
NFSFT_MALLOC_F
#define NFSFT_MALLOC_F
Definition: nfft3.h:580
nfft3.h
Header file for the nfft3 library.
PRE_PHI_HUT
#define PRE_PHI_HUT
Definition: nfft3.h:193
NFSFT_INDEX
#define NFSFT_INDEX(k, n, plan)
Definition: nfft3.h:594