NFFT Logo 3.2.3
nfsft_benchomp_createdataset.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 3372 2009-10-21 06:04:05Z skunis $ */
20 
21 #include <stdio.h>
22 #include <math.h>
23 #include <string.h>
24 #include <stdlib.h>
25 #include <complex.h>
26 
27 #include "config.h"
28 
29 #include "nfft3util.h"
30 #include "nfft3.h"
31 #include "infft.h"
32 
33 void nfsft_benchomp_createdataset(unsigned int trafo_adjoint, int N, int M)
34 {
35  int t, j, k, n;
36  R *x;
37  C *f, *f_hat;
38  int N_total = (2*N+2) * (2*N+2);
39  nfsft_plan ptemp;
40 
41  nfsft_init_guru(&ptemp, N, M, NFSFT_MALLOC_X | NFSFT_MALLOC_F |
42  NFSFT_MALLOC_F_HAT | NFSFT_NORMALIZED | NFSFT_PRESERVE_F_HAT,
43  PRE_PHI_HUT | PRE_PSI | FFTW_INIT | FFT_OUT_OF_PLACE, 6);
44 
45  x = (R*) nfft_malloc(2*M*sizeof(R));
46  f = (C*) nfft_malloc(M*sizeof(C));
47  f_hat = (C*) nfft_malloc(N_total*sizeof(C));
48 
49  /* init pseudo-random nodes */
50  for (j = 0; j < M; j++)
51  {
52  x[2*j]= nfft_drand48() - K(0.5);
53  x[2*j+1]= K(0.5) * nfft_drand48();
54  }
55 
56  if (trafo_adjoint==0)
57  {
58  for (k = 0; k <= N; k++)
59  for (n = -k; n <= k; n++)
60  nfft_vrand_unit_complex(f_hat+NFSFT_INDEX(k,n,&ptemp),1);
61  }
62  else
63  {
65  }
66 
67  printf("%d %d %d\n", trafo_adjoint, N, M);
68 
69  for (j=0; j < M; j++)
70  {
71  for (t=0; t < 2; t++)
72  printf("%.16e ", x[2*j+t]);
73  printf("\n");
74  }
75 
76  if (trafo_adjoint==0)
77  {
78  for (k = 0; k <= N; k++)
79  for (n = -k; n <= k; n++)
80  printf("%.16e %.16e\n", creal(f_hat[NFSFT_INDEX(k,n,&ptemp)]), cimag(f_hat[NFSFT_INDEX(k,n,&ptemp)]));
81  }
82  else
83  {
84  for (j=0; j < M; j++)
85  printf("%.16e %.16e\n", creal(f[j]), cimag(f[j]));
86  }
87 
88  nfft_free(x);
89  nfft_free(f);
90  nfft_free(f_hat);
91 }
92 
93 int main(int argc, char **argv)
94 {
95  int trafo_adjoint;
96  int N;
97  int M;
98 
99  if (argc < 4) {
100  fprintf(stderr, "usage: tr_adj N M\n");
101  return -1;
102  }
103 
104  trafo_adjoint = atoi(argv[1]);
105  if (trafo_adjoint < 0 && trafo_adjoint > 1)
106  trafo_adjoint = 1;
107 
108  N = atoi(argv[2]);
109  M = atoi(argv[3]);
110  fprintf(stderr, "tr_adj=%d, N=%d, M=%d\n", trafo_adjoint, N, M);
111 
112  nfsft_benchomp_createdataset(trafo_adjoint, N, M);
113 
114  return 0;
115 }

Generated on Tue Apr 30 2013 by Doxygen 1.8.1