nfsft_benchomp_createdataset.c
/*
* Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <complex.h>
#include "config.h"
#include "nfft3.h"
#include "infft.h"
void nfsft_benchomp_createdataset(unsigned int trafo_adjoint, int N, int M)
{
int t, j, k, n;
R *x;
C *f, *f_hat;
int N_total = (2*N+2) * (2*N+2);
nfsft_plan ptemp;
nfsft_init_guru(&ptemp, N, M, NFSFT_MALLOC_X | NFSFT_MALLOC_F |
NFSFT_MALLOC_F_HAT | NFSFT_NORMALIZED | NFSFT_PRESERVE_F_HAT,
PRE_PHI_HUT | PRE_PSI | FFTW_INIT | FFT_OUT_OF_PLACE, 6);
x = (R*) nfft_malloc(2*M*sizeof(R));
f = (C*) nfft_malloc(M*sizeof(C));
f_hat = (C*) nfft_malloc(N_total*sizeof(C));
/* init pseudo-random nodes */
for (j = 0; j < M; j++)
{
x[2*j]= X(drand48)() - K(0.5);
x[2*j+1]= K(0.5) * X(drand48)();
}
if (trafo_adjoint==0)
{
for (k = 0; k <= N; k++)
for (n = -k; n <= k; n++)
nfft_vrand_unit_complex(f_hat+NFSFT_INDEX(k,n,&ptemp),1);
}
else
{
nfft_vrand_unit_complex(f,M);
}
printf("%d %d %d\n", trafo_adjoint, N, M);
for (j=0; j < M; j++)
{
for (t=0; t < 2; t++)
printf("%.16e ", x[2*j+t]);
printf("\n");
}
if (trafo_adjoint==0)
{
for (k = 0; k <= N; k++)
for (n = -k; n <= k; n++)
printf("%.16e %.16e\n", creal(f_hat[NFSFT_INDEX(k,n,&ptemp)]), cimag(f_hat[NFSFT_INDEX(k,n,&ptemp)]));
}
else
{
for (j=0; j < M; j++)
printf("%.16e %.16e\n", creal(f[j]), cimag(f[j]));
}
nfft_free(x);
nfft_free(f);
nfft_free(f_hat);
}
int main(int argc, char **argv)
{
int trafo_adjoint;
int N;
int M;
if (argc < 4) {
fprintf(stderr, "usage: tr_adj N M\n");
return -1;
}
trafo_adjoint = atoi(argv[1]);
if (trafo_adjoint < 0 && trafo_adjoint > 1)
trafo_adjoint = 1;
N = atoi(argv[2]);
M = atoi(argv[3]);
fprintf(stderr, "tr_adj=%d, N=%d, M=%d\n", trafo_adjoint, N, M);
nfsft_benchomp_createdataset(trafo_adjoint, N, M);
return 0;
}
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:190
PRE_PSI
#define PRE_PSI
Definition nfft3.h:185
FFTW_INIT
#define FFTW_INIT
Definition nfft3.h:191
PRE_PHI_HUT
#define PRE_PHI_HUT
Definition nfft3.h:181
NFSFT_MALLOC_X
#define NFSFT_MALLOC_X
Definition nfft3.h:582
NFSFT_NORMALIZED
#define NFSFT_NORMALIZED
Definition nfft3.h:579
NFSFT_INDEX
#define NFSFT_INDEX(k, n, plan)
Definition nfft3.h:599
NFSFT_MALLOC_F_HAT
#define NFSFT_MALLOC_F_HAT
Definition nfft3.h:583
NFSFT_PRESERVE_F_HAT
#define NFSFT_PRESERVE_F_HAT
Definition nfft3.h:585
NFSFT_MALLOC_F
#define NFSFT_MALLOC_F
Definition nfft3.h:584
infft.h
Internal header file for auxiliary definitions and functions.
nfft3.h
Header file for the nfft3 library.
nfft_vrand_unit_complex
void nfft_vrand_unit_complex(fftw_complex *x, const NFFT_INT n)
Inits a vector of random complex numbers in .
nfft_malloc
void * nfft_malloc(size_t n)
nfft_free
void nfft_free(void *p)
nfsft_plan
data structure for an NFSFT (nonequispaced fast spherical Fourier transform) plan with double precisi...
Definition nfft3.h:575