NFFT Logo 3.0 API Reference
Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals

glacier.c

00001 #include <stdio.h>
00002 #include <math.h>
00003 #include <string.h>
00004 #include <stdlib.h>
00005 #include "util.h"
00006 #include "nfft3.h"
00007 
00016 double my_weight(double z,double a,double b,double c)
00017 {
00018     return pow(0.25-z*z,b)/(c+pow(fabs(z),2*a));
00019 }
00020 
00022 void glacier(int N,int M)
00023 {  
00024   int j,k,k0,k1,l,my_N[2],my_n[2];
00025   double tmp_y;
00026   nfft_plan p;
00027   infft_plan ip;
00028   FILE* fp;
00029    
00030   /* initialise p */
00031   my_N[0]=N; my_n[0]=nfft_next_power_of_2(N);
00032   my_N[1]=N; my_n[1]=nfft_next_power_of_2(N);
00033   nfft_init_guru(&p, 2, my_N, M, my_n, 6, 
00034      PRE_PHI_HUT| PRE_FULL_PSI|
00035      MALLOC_X| MALLOC_F_HAT| MALLOC_F|
00036      FFTW_INIT| FFT_OUT_OF_PLACE,
00037      FFTW_MEASURE| FFTW_DESTROY_INPUT);
00038 
00039   /* initialise ip, specific */
00040   infft_init_advanced(&ip,&p, CGNE| PRECOMPUTE_DAMP);
00041 
00042   /* init nodes */
00043   fp=fopen("input_data.dat","r");
00044   for(j=0;j<p.M_total;j++)
00045   {
00046       fscanf(fp,"%le %le %le",&p.x[2*j+0],&p.x[2*j+1],&tmp_y);
00047       ip.y[j]=tmp_y;
00048   }
00049   fclose(fp);
00050   
00051   /* precompute psi */
00052   if(p.nfft_flags & PRE_ONE_PSI)
00053       nfft_precompute_one_psi(&p);
00054   
00055   /* initialise damping factors */
00056   if(ip.flags & PRECOMPUTE_DAMP)
00057     for(k0=0;k0<p.N[0];k0++)
00058       for(k1=0;k1<p.N[1];k1++)
00059         ip.w_hat[k0*p.N[1]+k1]=
00060       my_weight(((double)(k0-p.N[0]/2))/p.N[0],0.5,3,0.001)*
00061       my_weight(((double)(k1-p.N[1]/2))/p.N[1],0.5,3,0.001);
00062   
00063   /* init some guess */
00064   for(k=0;k<p.N_total;k++)
00065       ip.f_hat_iter[k]=0; 
00066 
00067   /* inverse trafo */  
00068   infft_before_loop(&ip);
00069   for(l=0;l<40;l++)
00070     { 
00071       fprintf(stderr,"Residual ||r||=%e,\n",sqrt(ip.dot_r_iter));
00072       infft_loop_one_step(&ip);
00073     }
00074 
00075   for(k=0;k<p.N_total;k++)
00076     printf("%le %le\n",creal(ip.f_hat_iter[k]),cimag(ip.f_hat_iter[k]));
00077 
00078   infft_finalize(&ip);  
00079   nfft_finalize(&p);  
00080 }
00081 
00083 int main(int argc, char **argv)
00084 {
00085   glacier(atoi(argv[1]),atoi(argv[2]));
00086 
00087   return 1;
00088 }
00089 /* \} */

Generated on 1 Nov 2006 by Doxygen 1.4.4