/* nfilter_c subroutine * FIR computation * with classic discrete convolution method * IRCOM GROUP - Author : A.Layec * * Copyright (C) 2007 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" /* nfilter_c : routine de calcul d'un filtre à réponse impulsionnelle fini * par convolution numérique * * Entrées : * n : longueur du vecteur d'entrée à filtrer * nbcoef : longueur de la réponse impulsionelle * u : adresse de départ du vecteur d'entrée à filtrer * pulse : adresse de départ de la réponse impulsionelle * * Sorties : * y : adresse de départ du vecteur filtré * * Entrées/sorties : * z : adresse de départ du vecteur mémoire du filtre */ void nfilter_c(int *n,int *nbcoef,double *u,double *pulse,double *y,double *z) { /*déclaration*/ double somme; int i,j; for(j=0;j<(*n);j++) { /*calcul sortie*/ somme=0; for(i=0;i<(*nbcoef)-1;i++) { somme=somme+z[(*nbcoef)-1-i]*pulse[i]; } somme=somme+u[j]*pulse[*nbcoef-1]; /*calcul mémoire*/ for(i=0;i<(*nbcoef)-1;i++) { z[(*nbcoef)-i-1]=z[(*nbcoef)-i-2]; } z[0]=u[j]; /*recopie sortie dans y*/ y[j]=somme; } return; }