/* 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. */ /* discrgen Scicos discrete generator block * Type 4 simulation function - scilab-3.0 * IRCOM GROUP - Author : A.Layec */ /* REVISION HISTORY : * $Log$ */ #include <math.h> #include "scicos_block.h" #define M_PI 3.14159265358979323846 /* rpar[0] : amplitude * rpar[1] : longueur de la période (en échantillons) * ipar[0] : option (1:cos,2:sin) */ /* cwr_c : routine de calcul d'une onde à fréquence constante (1 composante) * * Entrées : * n : longueur du vecteur * ampl : amplitude de l'onde * opt : option de la routine (1:cos, 2:sin) * theta_i : pas de l'angle * * Sorties : * y : adresse de départ du vecteur de sortie * * Entrées/Sorties : * theta : angle instantanée * * Dépendances : * math.h * */ void cwr_c(int *n,double *ampl,int *opt,double *theta_i,double *y,double *theta) { /*déclaration*/ int i; for (i=0;i<(*n);i++) { switch (*opt) { case 1 : { y[i]=(*ampl)*cos((*theta)); break; } case 2 : { y[i]=(*ampl)*sin((*theta)); break; } } *theta=(*theta)+(*theta_i); } return; } void discrgen(scicos_block *block,int flag) { /*déclaration des variables*/ int ny; int opt; double inc; /*incrément de l'angle*/ double ampl; double *y; /*récupération de la taille de sortie*/ ny=block->outsz[0]; /*récupération de l'adresse de sortie*/ y=(double *)block->outptr[0]; /*récupération des paramètres*/ ampl=block->rpar[0]; inc=(2*M_PI)/block->rpar[1]; opt=block->ipar[0]; if(flag==1) { /*Appel cw_r*/ cwr_c(&ny,&l,&opt,&inc,&y[0],&block->z[0]); } }