Doxygen Source Code Documentation
Main Page Alphabetical List Data Structures File List Data Fields Globals Search
sink.c
Go to the documentation of this file.00001 #include "mrilib.h"
00002
00003 #define sinc(x) (((x)==0.0) ? 1.0 : sin(x)/(x))
00004
00005 int main( int argc , char *argv[] )
00006 {
00007 int iarg , nP , nN , pp,nn ;
00008 double rr,qq, lam , val , beta=0.0 ;
00009
00010
00011
00012 if( argc < 4 || strcmp(argv[1],"-help") == 0 ){
00013 printf("Usage: sink N P lam [beta]\n"
00014 "Outputs to stdout the .1D file with 2*P+1 columns and 2*N+1 rows:\n"
00015 " sinc[ pi * (p-P*lam*n/N) ]\n"
00016 "OR, if beta != 0:\n"
00017 " sinc[ pi * (p-P*lam*( beta+(1-beta)*n/N)) ]\n"
00018 " +sinc[ pi * (p-P*lam*(-beta+(1-beta)*n/N)) ]\n"
00019 "for p=-P..P (column index) and n=-N..N (row index).\n"
00020 ) ;
00021 exit(0) ;
00022 }
00023
00024 nN = (int)strtod(argv[1],NULL); if( nN < 1 ){fprintf(stderr,"illegal N\n");exit(1);}
00025 nP = (int)strtod(argv[2],NULL); if( nP < 1 ){fprintf(stderr,"illegal P\n");exit(1);}
00026 lam = strtod(argv[3],NULL);
00027 if( argc > 4 ) beta = strtod(argv[4],NULL) ;
00028
00029 rr = (nP*lam*(1.0-beta))/nN ;
00030 qq = (nP*lam*beta) ;
00031
00032 for( nn=-nN ; nn <= nN ; nn++ ){
00033 for( pp=-nP ; pp <= nP ; pp++ ){
00034 val = sinc( PI * (pp-rr*nn-qq) ) ;
00035 #if 1
00036 if( beta != 0.0 ) val += 0.737*sinc( PI * (pp-rr*nn+qq) ) ;
00037 #endif
00038 printf(" %.12g",val) ;
00039 }
00040 printf("\n") ;
00041 }
00042
00043 exit(0) ;
00044 }