| NFFT 3.5.0

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

fastsum_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 fastsum_benchomp_createdataset(unsigned int d, int L, int M)
31 {
32 int t, j, k;
33 R *x;
34 R *y;
35 C *alpha;
36
37 x = (R*) NFFT(malloc)((size_t)(d * L) * sizeof(R));
38 y = (R*) NFFT(malloc)((size_t)(d * L) * sizeof(R));
39 alpha = (C*) NFFT(malloc)((size_t)(L) * sizeof(C));
40
42 k = 0;
43 while (k < L)
44 {
45 R r_max = K(1.0);
46 R r2 = K(0.0);
47
48 for (j = 0; j < d; j++)
49 x[k * d + j] = K(2.0) * r_max * NFFT(drand48)() - r_max;
50
51 for (j = 0; j < d; j++)
52 r2 += x[k * d + j] * x[k * d + j];
53
54 if (r2 >= r_max * r_max)
55 continue;
56
57 k++;
58 }
59
60 NFFT(vrand_unit_complex)(alpha, L);
61
63 k = 0;
64 while (k < M)
65 {
66 R r_max = K(1.0);
67 R r2 = K(0.0);
68
69 for (j = 0; j < d; j++)
70 y[k * d + j] = K(2.0) * r_max * NFFT(drand48)() - r_max;
71
72 for (j = 0; j < d; j++)
73 r2 += y[k * d + j] * y[k * d + j];
74
75 if (r2 >= r_max * r_max)
76 continue;
77
78 k++;
79 }
80
81 printf("%d %d %d\n", d, L, M);
82
83 for (j = 0; j < L; j++)
84 {
85 for (t = 0; t < d; t++)
86 printf("%.16" __FES__ " ", x[d * j + t]);
87 printf("\n");
88 }
89
90 for (j = 0; j < L; j++)
91 printf("%.16" __FES__ " %.16" __FES__ "\n", CREAL(alpha[j]), CIMAG(alpha[j]));
92
93 for (j = 0; j < M; j++)
94 {
95 for (t = 0; t < d; t++)
96 printf("%.16" __FES__ " ", y[d * j + t]);
97 printf("\n");
98 }
99
100 NFFT(free)(x);
101 NFFT(free)(y);
102 NFFT(free)(alpha);
103 }
104
105 int main(int argc, char **argv)
106 {
107 int d;
108 int L;
109 int M;
110
111 if (argc < 4)
112 {
113 fprintf(stderr, "usage: d L M\n");
114 return -1;
115 }
116
117 d = atoi(argv[1]);
118 L = atoi(argv[2]);
119 M = atoi(argv[3]);
120
121 fprintf(stderr, "d=%d, L=%d, M=%d\n", d, L, M);
122
123 fastsum_benchomp_createdataset(d, L, M);
124
125 return 0;
126 }
127
nfft3.h
Header file for the nfft3 library.