Routine bas-niveau
fr - eng


calc_fft_c - routine de calcul de fft

Module

Paramètres

Contenu du fichier


/* calc_fft_c subroutine
 *
 * modnum fft computation routine
 *
 * Copyright (C) 2007-2011 Alan Layec
 *
 * This file is part of modnumlib.
 *
 * modnumlib is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * modnumlib is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with modnumlib; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 */

/* REVISION HISTORY :
 * $Log$
 */

#include "modnum_lib.h"

#include "modnum_fft.h"

/* calc_fft_c :
 * computation of in place fft using :
 * 0/1 - fft of the Standard Signal Scilab library
 * 2   - fft of the fftw library
 *
 * Input parameters :
 *   - fft_pr_struct *fft_pr
 * Input/Output parameters:
 *   - double *r_i,*r_o : time/freq domain
 *                   in/out buffer
 *
 * Return int 0 or ierr of fft842/dfftmx
 *
 */

int calc_fft_c(fft_pr_struct *fft_pr,double *r_i,double *i_i)
{
 int i,j,k;
 int ierr = 0;

 int n;
 int isn;
 int ffttyp;
 int n_work;
 double *work;

 guru_dim_struct gdim;
 fftw_iodim iodim;
 fftw_plan p;
 double *ptr_d;

 n      = fft_pr->lfft;
 isn    = fft_pr->isn;
 ffttyp = fft_pr->ffttyp;
 n_work = fft_pr->nwork;
 work   = fft_pr->work;

 switch(ffttyp)
 {
  case 0 :{ /* fft842 */
           if ((isn==0)||(isn==-1)) {
             k = 0;
           }
           else {
             k = 1;
           }
           C2F(fft842)(&k,&n,r_i,i_i,&ierr);
           break;
  }
  case 1 :{ /* dfftmx */
           if ((isn==0)||(isn==-1)) {
             k = -1;
           }
           else {
             k = 1;
           }
           C2F(dfft2)(r_i,i_i,(i=1,&i),&n,(j=1,&j),&k,&ierr,work,&n_work);
           break;
  }
  case 2 :{ /* fftw */
           gdim.rank=1;
           gdim.dims=&iodim;
           gdim.dims[0].n=n;
           gdim.dims[0].is=1;
           gdim.dims[0].os=1;
           gdim.howmany_rank=0;
           gdim.howmany_dims=0;
           if ((isn!=0)&&(isn!=-1)) {
             ptr_d = i_i;
             i_i=r_i;
             r_i=ptr_d; 
           }
           p=get_fftw_plan(&gdim,r_i,i_i,r_i,i_i,cur_fftw_flags,isn);
           fftw_execute_split_dft(p,r_i,i_i,r_i,i_i);
           break;
  }
  break;
 }
 return ierr;
}

Auteurs

A. Layec