/* Table of content FFT FFT2d Lanco LiveAgua Pgmer PrT ReadM ReadMask Show SaveCT SaveM SaveT */ #include #include #include #include typedef struct { float re; float im; } cmp ; typedef struct { float r ; float an; } plr ; typedef struct { int m; int n; float* a; } pgmDscr; typedef struct { int m; int n; int *num; } MDscr; cmp A(cmp x,cmp y) { cmp res; res.re=x.re+y.re; res.im=x.im+y.im; return (res); } cmp M(cmp x,cmp y) { cmp res; res.re=x.re*y.re-x.im*y.im; res.im=x.im*y.re+x.re*y.im; return(res); } cmp mPolar(plr x) { cmp res; res.re=cos(x.an)*x.r; res.im=sin(x.an)*x.r; return(res); } float mAbs(cmp x) { return(sqrt(x.re*x.re+x.im*x.im)); } plr mExp_p(cmp x) { plr res; res.r=exp(x.re); res.an=x.im; return(res); } plr mCmp(cmp x) { plr res; res.r=mAbs(x); res.an=(float)atan((double)(x.im/x.re)); return(res); } float mCmpdd(int m,int n,cmp *wfrom,plr *wto) { int i,j; float maxampl; plr z; maxampl=0.0; for(i=0;imaxampl) maxampl=z.r; *(wto+i*n+j)=z; } return(maxampl); } float Power(int m,int n,cmp *x) { int i,j; float power; plr z; power=0.0; for (i=0;i",jm); /* Loop N 1 */ for(jn=0;jndd*(*(matr+ii*nn+jj)+0.5) ) *(y+i*n+j)=1; else *(y+i*n+j)=0; jj++; }; ii++; } } /* ReadM reads matrix from M.dat-file and returns M-descriptor */ MDscr ReadM(char *name) { char *rname; FILE *f; MDscr res; int i,m,n; rname=calloc(20,sizeof(char)); strcat(rname,name); strcat(rname,"M.dat"); f=fopen(rname,"r"); free(rname); fscanf(f,"%i %i",&m,&n); res.m=m; res.n=n; res.num=(int*)calloc(m*n,sizeof(int)); for(i=0;ipar) | (krit1<-par) | (krit2>par) | (krit2<-par)) *(ay+i*n+j)=zero; else *(ay+i*n+j)=*(ax+i*n+j); } } /***** Restores a dot matrix according to groth of values ******************/ void LiveAgua(int m,int n,cmp *x, int *y) { int i,j,k,im,jm; float mx; cmp z; int *oo; oo=(int*)calloc(m*n,sizeof(int)); for(i=0;i0;k--) { mx=-20000.0; for(i=0;i=mx) { mx=z.re; im=i;jm=j; }; }; *(y+im*n+jm)=k-1; *(oo+im*n+jm)=1000; }; } /***** Reads manually typed pattern for MskFlt ******************************/ void ReadMask(char *name,cmp *ay) { int i,j,m,n; cmp z; float az; FILE *f; f=fopen(name,"r"); fscanf(f,"%i %i",&m,&n); for(i=0;i0 ) cur=cur<>(-shift); res=res+cur; m=m<<1; } ; return(res); } int log2i(int x) { int res; for(res=0;x>1;res++) x=x/2; return(res); }; void RevSort( int n, cmp *(wherefrom),cmp *(whereto)) { int i,k; for (i=0;i