/* 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. */ /* sousecht Scicos dowsample block * Type 4 simulation function ver 1.0 - scilab-3.0 * 22 Décembre 2004 Author : - IRCOM GROUP - A.Layec */ /* REVISION HISTORY : * $Log$ */ #include <stdio.h> #include <scicos/scicos_block.h> #include "modnum_lib.h" /* Cette fonction de simulation réalise un sous échantillonnage d'un * vecteur d'entrée de taille nu vers un vecteur de sortie de taille ny. * Pour chaque vecteur, la fonction recopie les valeurs de u dans y * lorsque l'échantillon testé est celui qui correspond au numéro count * exemple count = c.i + nech * * Entrée régulière : signal surechantilonné * Sortie régulière : signal sous échantillonnés * Entrée évènementielle : néant * Sortie évènementielle : néant * * Paramètres entier : insz[0] : taille du vecteur en entrée * ipar[0] : nombre d'échantillons * ipar[1] : echantillon initial */ /*prototype*/ void sousecht(scicos_block *block,int flag) { /*déclaration des variables*/ double *y; double *u; int nu,nech; int *init_c; int *counter; int mu=1; /*récupération des adresses des ports réguliers*/ y=(double *)block->outptr[0]; u=(double *)block->inptr[0]; /*récupération du nombre d'échantillons*/ nu=block->insz[0]; nech=block->ipar[0]; /*récupération de la valeur du compteur*/ init_c=&block->ipar[1]; /*initialisation*/ if(flag==4) { /*allocation du tableau pour les compteurs*/ if (((*block->work)=(int *)scicos_malloc(mu*sizeof(int))) == NULL) { set_block_error(-16); return; } /* */ counter=(int *) *block->work; /*appel copyi_c*/ copyi_c(&mu,init_c,counter); } /*calcul des sorties*/ else if((flag==1)||(flag==6)) { /* */ counter=(int *) *block->work; /*appel routine sousecht_c*/ sousechty_c(&nu,&mu,&nech,counter,&u[0],&y[0]); } /*calcul des états*/ else if(flag==2) { /* */ counter=(int *) *block->work; /*appel routine calc_init_c*/ calc_init_c(&nu, &mu, &nech, counter); } /*terminaison*/ else if(flag==5) { scicos_free(*block->work); } }