/* Modnumlib Scicos interfacing function * Copyright (C) 2009 Alan Layec * * This library 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. * * This library 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 this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ /* fftcmplx Scicos fft complexe * Type 4 simulation function ver 1.1b - scilab-3.0 * 15 décembre 2004 - IRCOM GROUP - Author : A.Layec * 12 Mars 2009 - INRIA - Author : A.Layec */ /* REVISION HISTORY : * $Log$ */ #include <scicos/scicos_block.h> #include "modnum_lib.h" /* Cette fonction réalise la fft complexe du vecteur {u1[];u2[]}. * u1 et u2 sont places dans y1 et y2 respectivement par dcopy puis la fft est réalisée. * Suivant la valeur de ipar[0] on réalise une fft directe (0 où -1) ou indirecte (1). * Suivant la valeur de ipar[1] on appele fft842(ipar[1]=0) où dfftmx(ipar[1]=1) via dfft2. * Si dfftmx est choisie alors on place la taille du mot de travail dans ipar[2]. * * entrées réguliéres : u1[0..nu-1] : vecteur des réels du mot complexe d'entrée * u2[0..nu-1] : vecteur des imaginaires du mot complexe d'entrée * * sorties régulières : y1[0..nu-1] : vecteur des réels du mot complexe de sortie * y2[0..nu-1] : vecteur des imaginaires du mot complexe de sortie * * paramètres entiers : ipar[0] : signe de l'exponentiel (-1 où 0 : fft directe; 1 : fft indirecte) * ipar[1] : flag choix fft (0:fft842/1:dfftmx) * ipar[2] : taille du mot de travail pour dfftmx */ /*prototype*/ void fftcmplx(scicos_block *block,int flag) { /*Déclaration des variables*/ double *y1,*y2; double *u1,*u2; int nu,i,j,k,ierr; double *z__; /*fft variables*/ fft_pr_struct fft_pr; /*Récupération des adresses des ports réguliers*/ y1=(double *)block->outptr[0]; y2=(double *)block->outptr[1]; u1=(double *)block->inptr[0]; u2=(double *)block->inptr[1]; /*Récupération de la taille du port d'entrée*/ nu=block->insz[0]; /* init : fait l'allocation de work */ if (flag==4) { if (block->ipar[1]==1) { /*cas fftmx*/ /*allocation dynamique*/ if ((*block->work=scicos_malloc(sizeof(double)*block->ipar[2]))== NULL) { set_block_error(-16); return; } } } /* calcule sortie */ else if ((flag==1)||(flag==6)) { /* initialize fft_pr*/ fft_pr.lfft = nu; fft_pr.isn = block->ipar[0]; fft_pr.ffttyp = block->ipar[1]; fft_pr.nwork = block->ipar[2]; fft_pr.work = *block->work; /*Recopie u dans y*/ cmplxcopy_c(&nu,&u1[0],&u2[0],&y1[0],&y2[0]); /*Appel routine fft*/ ierr=calc_fft_c(&fft_pr,&y1[0],&y2[0]); } /*Terminaison */ else if (flag==5) { /*Libère mémoire allouée*/ if (block->ipar[1]==1) { /*cas fftmx*/ scicos_free(*block->work); } } }