Computational routine
eng
int_euler
/* 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.
*/
/* int_euler Scicos discrete integral by euler method block
* Type 2 simulation function ver 1.0 - scilab-2.6&2.7
* 17 novembre 2003 - IRCOM GROUP - Author : A.Layec
*/
/* REVISION HISTORY :
* $Log$
*/
#include "machine.h"
/* Cette fonction de simulation réalise une intégration discrète
* du vecteur d'entrée par la méthode d'Euler arrière (dérivée à gauche) :
* y[k]=h*u[k]+y[k-1]
* où h est le pas d'intégration, y[k] le vecteur de sortie,
* et u[k] le vecteur d'entrée
*
* entrée régulières : u[0..nu-1] vecteur d'entrée
* sorties régulières : y[0..nu-1] registre de sortie
* entrée évènementielle : Instants de déclenchement
* sortie évènementielle : néant.
* état discret : z[0..nu-1] vecteur des états de sortie discrets précédents
*
* paramètre réel : rpar[0] pas d'intégration
*/
/*prototype*/
void int_euler(flag,nevprt,t,xd,x,nx,z,nz,tvec,ntvec,rpar,nrpar,
ipar,nipar,inptr,insz,nin,outptr,outsz,nout)
integer *flag,*nevprt,*nx,*nz,*ntvec,*nrpar,ipar[],*nipar,insz[],*nin,outsz[],*nout;
double x[],xd[],z[],tvec[],rpar[];
double *inptr[],*outptr[],*t;
{
/*déclaration des variables*/
double *y;
double *u;
int i,nu;
/*récupération de l'adresses des ports réguliers*/
y=(double *)outptr[0];
u=(double *)inptr[0];
/*Récupération de la taille du port d'entrée*/
nu=insz[0];
/*Le flag 1 calcule l'integrale et place le résultat dans le registre y[]*/
if(*flag==1)
{
for(i=0;i<nu;i++) y[i]=rpar[0]*u[i]+z[i];
}
/*le flag 2 place l'état de sortie y dans z*/
else if(*flag==2)
{
for(i=0;i<nu;i++) z[i]=y[i];
}
}