Zsinft.cin

From TORI
Jump to navigation Jump to search

// zsinft.cin is complex double routine for evaluation of the discrete sin transform (dsft)

// The routine below is suppoesed to be compiled together with routines zfour1.cin and zrealft.cin


#include <math.h>

void zsinft(z_type y[], int n)
{
        void zrealft(z_type data[], unsigned long n, int isign);
        int j,n2=n+2;
        z_type sum,y1,y2;
        double theta,wi=0.0,wr=1.0,wpi,wpr,wtemp;

        theta=M_PI/(double) n;
        wtemp=sin((double)0.5*theta);
        wpr = -2*wtemp*wtemp;
        wpi=sin(theta);
        y[1]=0.0;
        for (j=2;j<=(n>>1)+1;j++) {
                wr=(wtemp=wr)*wpr-wi*wpi+wr;
                wi=wi*wpr+wtemp*wpi+wi;
                y1=wi*(y[j]+y[n2-j]);
                y2=0.5*(y[j]-y[n2-j]);
                y[j]=y1+y2;
                y[n2-j]=y1-y2;
        }
        zrealft(y,n,1);
        y[1]*=0.5;
        sum=y[2]=0.0;
        for (j=1;j<=n-1;j+=2) {
                sum += y[j];
                y[j]=y[j+1];
                y[j+1]=sum;
        }
}

Keywords

SFTT, Fourier, Sin