![]() |
NFFT
3.3.2
|
00001 /* 00002 * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts 00003 * 00004 * This program is free software; you can redistribute it and/or modify it under 00005 * the terms of the GNU General Public License as published by the Free Software 00006 * Foundation; either version 2 of the License, or (at your option) any later 00007 * version. 00008 * 00009 * This program is distributed in the hope that it will be useful, but WITHOUT 00010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00011 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 00012 * details. 00013 * 00014 * You should have received a copy of the GNU General Public License along with 00015 * this program; if not, write to the Free Software Foundation, Inc., 51 00016 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 */ 00018 00019 #include <stdio.h> 00020 #include <math.h> 00021 #include <string.h> 00022 #include <stdlib.h> 00023 #include <complex.h> 00024 00025 #include "config.h" 00026 00027 #include "nfft3.h" 00028 #include "infft.h" 00029 00030 void nfft_benchomp_createdataset(unsigned int d, unsigned int trafo_adjoint, int *N, int M, double sigma) 00031 { 00032 int n[d]; 00033 int t, j; 00034 R *x; 00035 C *f, *f_hat; 00036 int N_total = 1; 00037 00038 for (t = 0; t < d; t++) 00039 N_total *= N[t]; 00040 00041 x = (R*) NFFT(malloc)(d*M*sizeof(R)); 00042 f = (C*) NFFT(malloc)(M*sizeof(C)); 00043 f_hat = (C*) NFFT(malloc)(N_total*sizeof(C)); 00044 00045 for (t=0; t<d; t++) 00046 n[t] = sigma*NFFT(next_power_of_2)(N[t]); 00047 00049 NFFT(vrand_shifted_unit_double)(x,d*M); 00050 00051 if (trafo_adjoint==0) 00052 { 00053 NFFT(vrand_unit_complex)(f_hat,N_total); 00054 } 00055 else 00056 { 00057 NFFT(vrand_unit_complex)(f,M); 00058 } 00059 00060 printf("%d %d ", d, trafo_adjoint); 00061 00062 for (t=0; t<d; t++) 00063 printf("%d ", N[t]); 00064 00065 for (t=0; t<d; t++) 00066 printf("%d ", n[t]); 00067 00068 printf("%d\n", M); 00069 00070 for (j=0; j < M; j++) 00071 { 00072 for (t=0; t < d; t++) 00073 printf("%.16e ", x[d*j+t]); 00074 printf("\n"); 00075 } 00076 00077 if (trafo_adjoint==0) 00078 { 00079 for (j=0; j < N_total; j++) 00080 printf("%.16e %.16e\n", creal(f_hat[j]), cimag(f_hat[j])); 00081 } 00082 else 00083 { 00084 for (j=0; j < M; j++) 00085 printf("%.16e %.16e\n", creal(f[j]), cimag(f[j])); 00086 } 00087 00088 NFFT(free)(x); 00089 NFFT(free)(f); 00090 NFFT(free)(f_hat); 00091 } 00092 00093 int main(int argc, char **argv) 00094 { 00095 int d; 00096 int *N; 00097 int M; 00098 int t; 00099 int trafo_adjoint; 00100 double sigma; 00101 00102 if (argc < 6) { 00103 fprintf(stderr, "usage: d tr_adj N_1 ... N_d M sigma\n"); 00104 return -1; 00105 } 00106 00107 d = atoi(argv[1]); 00108 00109 fprintf(stderr, "d=%d", d); 00110 00111 if (d < 1 || argc < 5+d) { 00112 fprintf(stderr, "usage: d tr_adj N_1 ... N_d M sigma\n"); 00113 return -1; 00114 } 00115 00116 N = malloc(d*sizeof(int)); 00117 00118 trafo_adjoint = atoi(argv[2]); 00119 if (trafo_adjoint < 0 && trafo_adjoint > 1) 00120 trafo_adjoint = 1; 00121 00122 fprintf(stderr, ", tr_adj=%d, N=", trafo_adjoint); 00123 00124 for (t=0; t<d; t++) 00125 N[t] = atoi(argv[3+t]); 00126 00127 for (t=0; t<d; t++) 00128 fprintf(stderr, "%d ",N[t]); 00129 00130 00131 M = atoi(argv[3+d]); 00132 sigma = atof(argv[4+d]); 00133 00134 fprintf(stderr, ", M=%d, sigma=%.16g\n", M, sigma); 00135 00136 nfft_benchomp_createdataset(d, trafo_adjoint, N, M, sigma); 00137 00138 free(N); 00139 00140 return 0; 00141 }