NFFT 3.5.3alpha
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
30void 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 |
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 {
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
90int 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}
#define FFT_OUT_OF_PLACE
Definition nfft3.h:196
#define PRE_PSI
Definition nfft3.h:191
#define FFTW_INIT
Definition nfft3.h:197
#define PRE_PHI_HUT
Definition nfft3.h:187
#define NFSFT_MALLOC_X
Definition nfft3.h:588
#define NFSFT_NORMALIZED
Definition nfft3.h:585
#define NFSFT_INDEX(k, n, plan)
Definition nfft3.h:605
#define NFSFT_MALLOC_F_HAT
Definition nfft3.h:589
#define NFSFT_PRESERVE_F_HAT
Definition nfft3.h:591
#define NFSFT_MALLOC_F
Definition nfft3.h:590
Internal header file for auxiliary definitions and functions.
Header file for the nfft3 library.
void nfft_vrand_unit_complex(fftw_complex *x, const NFFT_INT n)
Inits a vector of random complex numbers in .
void * nfft_malloc(size_t n)
void nfft_free(void *p)
data structure for an NFSFT (nonequispaced fast spherical Fourier transform) plan with double precisi...
Definition nfft3.h:581