Zcosft1.cin: Difference between revisions
Jump to navigation
Jump to search
imported>Dmitrii Kouznetsov (Load from TORI) |
imported>Roger A. Lohmann mNo edit summary |
||
Line 1: | Line 1: | ||
{{subpages}} | |||
// [[zcosft1.cin]] is C++ routine required for compilation of examples with [[DCTI]], Discrete Fourier transform of the First kind. | // [[zcosft1.cin]] is C++ routine required for compilation of examples with [[DCTI]], Discrete Fourier transform of the First kind. | ||
Latest revision as of 20:52, 9 September 2020
// zcosft1.cin is C++ routine required for compilation of examples with DCTI, Discrete Fourier transform of the First kind.
void zcosft1(z_type y[], int n) { /* void zrealft(z_type data[], unsigned long n, int isign);*/ int j,n2; z_type sum,y1,y2; double theta,wi=0.0,wpi,wpr,wr=1.0,wtemp; theta=M_PI/n; wtemp=sin(0.5*theta); wpr = -2.0*wtemp*wtemp; wpi=sin(theta); sum=0.5*(y[1]-y[n+1]); y[1]=0.5*(y[1]+y[n+1]); n2=n+2; for (j=2;j<=(n>>1);j++) { wr=(wtemp=wr)*wpr-wi*wpi+wr; wi=wi*wpr+wtemp*wpi+wi; y1=0.5*(y[j]+y[n2-j]); y2=(y[j]-y[n2-j]); y[j]=y1-wi*y2; y[n2-j]=y1+wi*y2; sum += wr*y2; } zrealft(y,n,1); y[n+1]=y[2]; y[2]=sum; for(j=4;j<=n;j+=2) {sum += y[j]; y[j]=sum;} }