NFFT Logo 3.2.2
nsfft/simple_test.c
00001 /*
00002  * Copyright (c) 2002, 2012 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 /* $Id: simple_test.c 3896 2012-10-10 12:19:26Z tovo $ */
00020 #include "config.h"
00021 
00022 #include <stdio.h>
00023 #include <math.h>
00024 #include <string.h>
00025 #include <stdlib.h>
00026 #ifdef HAVE_COMPLEX_H
00027 #include <complex.h>
00028 #endif
00029 
00030 #include "nfft3util.h"
00031 #include "nfft3.h"
00032 #include "infft.h"
00033 
00034 static void simple_test_nsfft(int d, int J, int M)
00035 {
00036   int K=12;
00037   nsfft_plan p;
00038 
00039   nsfft_init(&p, d, J, M, 6, NSDFT);
00040 
00041   nsfft_init_random_nodes_coeffs(&p);
00042 
00043   nfft_vpr_complex(p.f_hat, K, "frequencies, vector f_hat (first few entries)");
00044 
00046   nsfft_trafo_direct(&p);
00047   nfft_vpr_complex(p.f, K, "nsdft, vector f (first few entries)");
00048 
00050   nsfft_trafo(&p);
00051   nfft_vpr_complex(p.f, K, "nsfft, vector f (first few entries)");
00052 
00054   nsfft_adjoint_direct(&p);
00055   nfft_vpr_complex(p.f_hat, K, "adjoint nsdft, vector f_hat, (first few entries)");
00056 
00058   nsfft_adjoint(&p);
00059   nfft_vpr_complex(p.f_hat, K, "adjoint nsfft, vector f_hat, (first few entries)");
00060 
00062   nsfft_finalize(&p);
00063 }
00064 
00065 int main(int argc,char **argv)
00066 {
00067   int d, J, M;
00068 
00069   system("clear");
00070   printf("1) computing a two dimensional nsdft, nsfft and adjoints\n\n");
00071   d=2;
00072   J=5;
00073   M=(J+4)*X(exp2i)(J+1);
00074   simple_test_nsfft(d,J,M);
00075   getc(stdin);
00076 
00077   system("clear");
00078   printf("2) computing a three dimensional nsdft, nsfft and adjoints\n\n");
00079   d=3;
00080   J=5;
00081   M=6*X(exp2i)(J)*(X(exp2i)((J+1)/2+1)-1)+X(exp2i)(3*(J/2+1));
00082   simple_test_nsfft(d,J,M);
00083 
00084   return 1;
00085 }

Generated on Fri Oct 12 2012 by Doxygen 1.8.0-20120409