コード例 #1
0
ファイル: test_utils.c プロジェクト: odmanV2/freecenter
static void ifftx(complex_t data[], complex_t temp[], int n)
{
    int i;
    int h;
    int p;
    int t;
    int i2;
    complex_t wkt;

    if (n > 1)
    {
        h = n/2;
        for (i = 0;  i < h;  i++)
        {
            i2 = i*2;
            temp[i] = data[i2];         /* Even */
            temp[h + i] = data[i2 + 1]; /* Odd */
        }
        fftx(&temp[0], &data[0], h);
        fftx(&temp[h], &data[h], h);
        p = 0;
        t = MAX_FFT_LEN/n;
        for (i = 0;  i < h;  i++)
        {
            wkt = complex_mul(&icircle[p], &temp[h + i]);
            data[i] = complex_add(&temp[i], &wkt);
            data[h + i] = complex_sub(&temp[i], &wkt);
            p += t;
        }
    }
}
コード例 #2
0
ファイル: filter_tools.c プロジェクト: Jaroslav23/sipxtapi
void ifft(complex_t data[], int len)
{
    int i;
    double x;
    complex_t temp[MAX_FFT_LEN];

    /* A very slow and clunky FFT, that's just fine for filter design. */
    for (i = 0;  i < MAX_FFT_LEN/2;  i++)
    {
        x = (2.0*3.1415926535*i)/(double) MAX_FFT_LEN;
        circle[i] = expj(x);
    }
    fftx(data, temp, len);
}
コード例 #3
0
ファイル: test_utils.c プロジェクト: odmanV2/freecenter
SPAN_DECLARE(void) fft(complex_t data[], int len)
{
    int i;
    double x;
    complex_t temp[MAX_FFT_LEN];

    /* A very slow and clunky FFT, that's just fine for tests. */
    if (!circle_init)
    {
        for (i = 0;  i < MAX_FFT_LEN/2;  i++)
        {
            x = -(2.0*3.1415926535*i)/(double) MAX_FFT_LEN;
            circle[i] = expj(x);
        }
        circle_init = true;
    }
    fftx(data, temp, len);
}
コード例 #4
0
ファイル: fft.c プロジェクト: kapteyn-astro/gipsy
static	void	outmap( fint  lpt ,	/* number of points in X */
                        fint  mpt ,	/* number of points in Y */
                        fint  lmin ,	/* lower x map coordinate */
                        fint  mmin ,	/* lower y map coordinate */
                        fchar set[] ,	/* set name */
                        fint  sub[] ,	/* subset levels */
                        fint  nset ,	/* number of sets */
                        fint  modo )	/* output mode, amp./pha. or cos./sin. */
{
   fint		i, itab, k, m, md, mi, mj, ms, mph, mphh;
   fint		q, r, ri, rj, rs, row;
   fint		n;
   fint		count[MAXSET], nblank[MAXSET];
   float	rbuf[2*SIZE], cbuf[2*SIZE];
   float	datamax[MAXSET], datamin[MAXSET];
   float	fr, fi, zr, zi;

   for ( k = 0; k < nset; count[k++] = 0 );
   if ( FORM == -1 ) {			/* complex ---FFT---> real */
      k = 0;				/* set number */
      rs = MIN( mpt, ( 2 * SIZE ) / lpt );	/* number of rows per pass */
      for ( r = 0 ; r < mpt; r += rs ) {/* loop to get data from scratch file */
         getrow( rbuf, rs * lpt, r / rs );
         md = 0;
         do {
            m = shiftr( mmin, mpt, r + md );
            ms = MIN( rs - md, mpt + mmin - m );
            i = md * lpt;
            writxy( set[k], sub[k], lmin, m, &rbuf[i], lpt, ms );
            md = md + ms;
         } while ( md != rs );
         n = lpt * rs;
         minmax3_c( rbuf, &n, &datamin[k], &datamax[k], &nblank[k], &count[k] );
      }
   } else if ( FORM == 0 ) {		/* real ---FFT---> complex */
      q = POWTAB[ MAXP2 - LOGP2Y - 1 ];	/* table offset factor */
      mph = mpt / 2;			/* y-dimension of transform */
      mphh = mph / 2 + 1;
      getrow( cbuf, 2 * lpt, 0 );	/* create row MPH */
      putrow( cbuf, 2 * lpt, mph );
      fr = 0.5 * SIGN;
      fi = 0.5;
      for  ( ri = 0; ri < mphh; ri++ ) {
         rj = mph - ri;
         itab = ri * q;			/* calculate table position */
         zr = 0.5 - fr * SINTAB[itab];
         zi =       fi * COSTAB[itab];
         getrow( cbuf, 2 * lpt, ri );
         getrow( rbuf, 2 * lpt, rj );
         fxrl( zr, zi, cbuf, rbuf, ri, rj, lpt );	/* fixup real ---> complex */
         fftx( cbuf );			/* do the FFT in x-direction */
         vector( cbuf, lpt, 1, modo );
         mi = shiftr( mmin, mpt, ri );
         for ( k = 0; k < nset; k++ ) {
            i = k * lpt;
            writxy( set[k], sub[k], lmin, mi, &cbuf[i], lpt , 1 );
            minmax3_c( &cbuf[i], &lpt, &datamin[k], &datamax[k], &nblank[k],
               &count[k] );
         }
         if ( ri > 0 ) {		/* do not double lines */
            mirror( cbuf, lpt, -lmin );
            mi = shiftr( mmin, mpt, mpt - ri );
            for ( k = 0; k < nset; k++ ) {
               i = k * lpt;
               writxy( set[k], sub[k], lmin, mi, &cbuf[i], lpt, 1 );
               minmax3_c( &cbuf[i], &lpt, &datamin[k], &datamax[k], &nblank[k],
                  &count[k] );
            }
         }
         if ( ri == rj ) break;		/* we've done it */
         fftx( rbuf );			/* do the FFT in x-direction */
         vector( rbuf, lpt, 1, modo );
         mj = shiftr( mmin, mpt, rj );
         for ( k = 0; k < nset; k++ ) {
            i = k * lpt;
            writxy( set[k], sub[k], lmin, mj, &rbuf[i], lpt, 1 );
            minmax3_c( &rbuf[i], &lpt, &datamin[k], &datamax[k], &nblank[k],
               &count[k] );
         }
         if ( rj < mph ) {		/* do not double lines */
            mirror( rbuf, lpt, -lmin );
            mj = shiftr( mmin, mpt, mpt - rj );
            for ( k = 0; k < nset; k++ ) {
               i = k * lpt;
               writxy( set[k], sub[k], lmin, mj, &rbuf[i], lpt, 1 );
               minmax3_c( &rbuf[i], &lpt, &datamin[k], &datamax[k], &nblank[k],
                  &count[k] );
            }
         }
      }
   } else if ( FORM == 1 ) {		/* complex ---FFT---> complex */
      for ( row = 0; row < mpt; row++ ) {
         getrow( cbuf, 2 * lpt, row );
         vector( cbuf, lpt, 1, modo );
         m = shiftr( mmin, mpt, row );
         for ( k = 0; k < nset; k++ ) {
            i = k * lpt;
            writxy( set[k], sub[k], lmin, m, &cbuf[i], lpt, 1 );
            minmax3_c( &cbuf[i], &lpt, &datamin[k], &datamax[k], &nblank[k],
               &count[k] );
         }
      }
   }
   {
      fint	change = 1;
      fint	one = 1;

      for ( k = 0; k < nset; k++ ) {
         wminmax_c( set[k], &sub[k], &datamin[k], &datamax[k],
            &nblank[k], &one, &change );
      }
   }
}
コード例 #5
0
ファイル: fft.c プロジェクト: kapteyn-astro/gipsy
static	void	inpmap( fint  lpt ,	/* number of points in X */
                        fint  mpt ,	/* number of points in Y */
                        fint  lmin ,	/* left most x map coordinate */
                        fint  mmin ,	/* lower most y map coordinate */
                        fchar set[] ,	/* input set name */
                        fint  sub[] ,	/* subsets */
                        fint  nset ,	/* number of sets */
                        fint  modi )	/* input mode, amp./pha. or cos./sin. */
{
   fint		i, itab, k, m, md, mi, mj, mph, mphh, ms;
   fint		q, r, ri, rj, row, rs, wor;
   float	rbuf[2*SIZE], cbuf[2*SIZE];
   float	fr, fi, zr, zi;

   if ( FORM == -1 ) {			/* complex ---FFT---> real */
      q = POWTAB[ MAXP2 - LOGP2Y - 1 ];	/* table offset factor */
      mph = mpt / 2;			/* number of rows to load */
      mphh = mph / 2 + 1;
      fr = -0.5 * SIGN;			/* calculate factors */
      fi = -0.5;
      for ( ri = 0 ; ri < mphh; ri++ ) {	/*  loop to load data */
         rj = mph - ri;
         itab = ri * q;			/*  get table position */
         zr = 0.5 - fr * SINTAB[itab];
         zi =       fi * COSTAB[itab];
         mi = shiftr( mmin, mpt, ri );
         for ( k = 0; k < nset; k++ ) {	/* get data */
            i= k * lpt;
            readxy( set[k], sub[k], lmin, mi, &cbuf[i], lpt, 1 );
         }
         mj = shiftr( mmin, mpt, rj );
         for ( k = 0; k < nset; k++ ) {	/*  get data */
            i = k * lpt;
            readxy( set[k], sub[k], lmin, mj, &rbuf[i], lpt, 1 );
         }
         vector( cbuf, lpt, modi, 1 );
         vector( rbuf, lpt, modi, 1 );
         fftx( cbuf );			/* do the FFT */
         fftx( rbuf );
         /* fixup for complex to real transform */
         fxrl( zr, zi, cbuf, rbuf, ri, rj, lpt );
         /* store in scratch file */
         wor = bitrev( ri, LOGP2Y );
         putrow( cbuf, 2 * lpt, wor );
         if ( ( ri != rj ) && ( ri != 0 ) ) {
            wor = bitrev( rj, LOGP2Y );
            putrow( rbuf, 2 * lpt, wor );
         }
      }
   } else if ( FORM == 0 ) {		/* real ---FFT---> complex */
      rs = MIN( mpt, ( 2 * SIZE ) / lpt );	/* number of rows in one pass */
      k = 0;				/* subset number */
      for  ( r = 0; r < mpt; r += rs ) {/* loop to load data */
         md = 0;
         do {
            m = shiftr( mmin, mpt, r + md );
            ms = MIN( rs - md, mpt + mmin - m );
            i = md * lpt;
            readxy( set[k], sub[k], lmin, m, &cbuf[i], lpt, ms );
            md = md + ms;
         } while ( md != rs );
         for ( row = r; row < ( r + rs ); row += 2 ) {
            i = ( row - r ) * lpt;
            wor = bitrev( row / 2, LOGP2Y );
            putrow( &cbuf[i], 2 * lpt, wor );
         }
      }
   } else if ( FORM == 1 ) {		/* complex ---FFT---> complex */
      for  ( row = 0; row < mpt; row++ ) {
         m = shiftr( mmin, mpt, row );	/* get data from disk */
         for ( k = 0; k < nset; k++ ) {
            i = k * lpt;
            readxy( set[k], sub[k], lmin, m, &cbuf[i], lpt, 1 );
         }
         vector( cbuf, lpt, modi, 1 );
         fftx( cbuf );
         wor = bitrev( row, LOGP2Y );
         putrow( cbuf, 2 * lpt, wor );
      }
   }
}