/* surecht_c subroutine * Up-Sampling Computation * * 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 <stdio.h> /* surecht_c routine de calcul de sur-échantillonnage en temporel * * Entrées : * opt : option 0: sur-échantillonnage classique * 1: sur-échantillonnage avec insertion de zéros(Dirac) * n : dimension 1 de la matrice d'entrée (scalaire) * m : dimension 2 de la matrice d'entrée (scalaire) * nech : facteur de sur-échantillonnage * init_c : adresse du compteur * u : pointeur sur double d'entrée (de taille n,m) * * Sortie : * y : pointeur sur double de sortie (de taille n*nech,m) * */ void surecht_c(int *opt,int *n,int *m,int *nech,int *init_c,double *u,double *y) { /*déclaration des variables compteur*/ int i,j,l; int counter; switch(*opt) { /*Suréchantillonnage classique*/ case 0 : for(l=0;l<(*m);l++) { for(j=0;j<(*n);j++) { for(i=0;i<(*nech);i++) { y[l*(*n)*(*nech)+j*(*nech)+i]=u[l*(*n)+j]; } } } break; /*Suréchantillonnage avec insertion zéro*/ case 1 : for(l=0;l<(*m);l++) { counter=init_c[l]; i=0; for(j=0;j<(*n)*(*nech);j++) { if(j==(counter-1)) { counter += (*nech); y[l*(*n)*(*nech)+j]=u[l*(*n)+i]; i++; } else { y[l*(*n)*(*nech)+j]=0.; } } init_c[l]=Abs(counter-(*n)*(*nech)); } break; default : break; } return; } void surechti_c(int *opt,int *n,int *m,int *nech,int *init_c,int *u,int *y) { /*déclaration des variables compteur*/ int i,j,l; int counter; switch(*opt) { /*Suréchantillonnage classique*/ case 0 : for(l=0;l<(*m);l++) { for(j=0;j<(*n);j++) { for(i=0;i<(*nech);i++) y[l*(*n)*(*nech)+j*(*nech)+i]=u[l*(*n)+j]; } } break; /*Suréchantillonnage avec insertion zéro*/ case 1 : for(l=0;l<(*m);l++) { counter=init_c[l]; i=0; for(j=0;j<(*n)*(*nech);j++) { y[l*(*n)*(*nech)+j]=0; if(j==(counter-1)) { counter += (*nech); y[l*(*n)*(*nech)+j]=u[l*(*n)+i]; i++; } else { y[l*(*n)*(*nech)+j]=0; } } init_c[l]=Abs(counter-(*n)*(*nech)); } break; default : break; } return; } void surechty_c(int *opt,int *n,int *m,int *nech,int *init_c,double *u,double *y) { /*déclaration des variables compteur*/ int i,j,l; int counter; switch(*opt) { /*Suréchantillonnage classique*/ case 0 : for(l=0;l<(*m);l++) { for(j=0;j<(*n);j++) { for(i=0;i<(*nech);i++) { y[l*(*n)*(*nech)+j*(*nech)+i]=u[l*(*n)+j]; } } } break; /*Suréchantillonnage avec insertion zéro*/ case 1 : for(l=0;l<(*m);l++) { counter=init_c[l]; i=0; for(j=0;j<(*n)*(*nech);j++) { if(j==(counter-1)) { counter += (*nech); y[l*(*n)*(*nech)+j]=u[l*(*n)+i]; i++; } else { y[l*(*n)*(*nech)+j]=0.; } } } break; default : break; } return; }