⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 idgt_fac.c

📁 Matlab时频分析工具箱,希望能对大家有所帮助啊
💻 C
字号:
#include "config.h"#ifdef HAVE_COMPLEX_H#include <complex.h>#endif#include <stdlib.h>#include <stdio.h>#include <math.h>#include "fftw3.h"#include "dgt.h"void idgt_fac(ltfat_complex *cin, ltfat_complex *gf, const int L, const int W,	     const int R, const int a, const int M, ltfat_complex *f){   /*  --------- initial declarations -------------- */   int b, N, c, d, p, q, h_a, h_m;      ltfat_complex *gbase, *fbase, *cbase;   int l, k, r, s, u, w, rw, nm, mm, km;   int ld1, ld2, ld3;   div_t domod;   fftw_plan p_before, p_after;   ltfat_complex *ff, *cf;      /*  ----------- calculation of parameters and plans -------- */   b=L/M;   N=L/a;      c=gcd(a, M,&h_a, &h_m);   p=a/c;   q=M/c;   d=b/p;   h_a=-h_a;   ff = (ltfat_complex*)ltfat_malloc(L*W*sizeof(ltfat_complex));   cf = (ltfat_complex*)ltfat_malloc(c*d*q*q*W*R*sizeof(ltfat_complex));   /* Create plans. In-place. */      p_before = fftw_plan_many_dft(1, &d, c*p*q*W,				 ff, NULL,				 c*p*q*W, 1,				 ff, NULL,				 c*p*q*W, 1,				 FFTW_BACKWARD, FFTW_OPTITYPE);   p_after = fftw_plan_many_dft(1, &d, c*q*q*W*R,				cf, NULL,				c*q*q*W*R, 1,				cf, NULL,				c*q*q*W*R, 1,				FFTW_FORWARD, FFTW_OPTITYPE);      /* -------- compute coefficient factorization ----------- */   /* Leading dimensions of the 4dim array. */   ld1=q*R;   ld2=q*R*q*W;   ld3=c*q*R*q*W;      for (rw=0;rw<R;rw++)   {      for (w=0;w<W;w++)      {	 for (s=0;s<d;s++)	 {	    for (l=0;l<q;l++)	    {	       for (u=0;u<q;u++)	       {	       		  /*Add N to make sure it is positive */		  domod= div(u+s*q-l*h_a+N*M,N);		  for (r=0;r<c;r++)		  {	#ifdef HAVE_COMPLEX_H	  		     cf[u+rw*q+(l+q*w)*ld1+r*ld2+s*ld3]    = cin[r+l*c+domod.rem*M+rw*M*N+w*M*N*R];#else		     cf[u+rw*q+(l+q*w)*ld1+r*ld2+s*ld3][0] = cin[r+l*c+domod.rem*M+rw*M*N+w*M*N*R][0];		     cf[u+rw*q+(l+q*w)*ld1+r*ld2+s*ld3][1] = cin[r+l*c+domod.rem*M+rw*M*N+w*M*N*R][1];#endif		  }	       }	    }	 }      }              }   /* Do fft of length d */   fftw_execute(p_after);   /* -------- compute matrix multiplication ---------- */      /* Do the matmul  */   for (r=0;r<c;r++)   {      for (s=0;s<d;s++)      {		 gbase=gf+(r+s*c)*p*q*R;	 fbase=ff+(r+s*c)*p*q*W;	 cbase=cf+(r+s*c)*q*q*W*R;	 for (nm=0;nm<q*W;nm++)	 {	    for (km=0;km<p;km++)	    {#ifdef HAVE_COMPLEX_H	       fbase[km+nm*p]=0.0;	       for (mm=0;mm<q*R;mm++)	       {		 fbase[km+nm*p]+=gbase[km+mm*p]*cbase[mm+nm*q*R];	       }	       /* Scale because of FFTWs normalization. */	       fbase[km+nm*p]=fbase[km+nm*p]/d;#else	       fbase[km+nm*p][0]=0.0;	       fbase[km+nm*p][1]=0.0;	       for (mm=0;mm<q*R;mm++)	       {		 fbase[km+nm*p][0]+=gbase[km+mm*p][0]*cbase[mm+nm*q*R][0]-gbase[km+mm*p][1]*cbase[mm+nm*q*R][1];		 fbase[km+nm*p][1]+=gbase[km+mm*p][0]*cbase[mm+nm*q*R][1]+gbase[km+mm*p][1]*cbase[mm+nm*q*R][0];	       }	       /* Scale because of FFTWs normalization. */	       fbase[km+nm*p][0]=fbase[km+nm*p][0]/d;	       fbase[km+nm*p][1]=fbase[km+nm*p][1]/d;#endif	    }		  	 }	      	       }   }            /* ----------- compute inverse signal factorization ---------- */   /* Do ifft to begin inverse signal factorization.*/   fftw_execute(p_before);   /* Leading dimensions of the 4dim array. */   ld2=p*q*W;   ld3=c*p*q*W;   for (w=0;w<W;w++)   {      for (s=0;s<d;s++)      {	 for (l=0;l<q;l++)	 {	    for (k=0;k<p;k++)	    {	       /* Add L*M to make sure it is always positive */	       domod = div(k*M+s*p*M+l*(c-h_m*M)+L*M, L);	       	       for (r=0;r<c;r++)	       {		  #ifdef HAVE_COMPLEX_H		  f[r+domod.rem+L*w] = ff[k+(l+q*w)*p+r*ld2+s*ld3];#else		  f[r+domod.rem+L*w][0] = ff[k+(l+q*w)*p+r*ld2+s*ld3][0];		  f[r+domod.rem+L*w][1] = ff[k+(l+q*w)*p+r*ld2+s*ld3][1];#endif	       }	    }	 }      }   }               /* -----------  Clean up ----------------- */      ltfat_free(ff);   ltfat_free(cf);   }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -