dsslti4.c

Go to the documentation of this file.
00001 #include <memory.h>
00002 #include "scicos_block.h"
00003 #include "sci_mem_alloc.h"  /* malloc */
00004 #include "machine.h"
00005 
00006 extern int C2F(dmmul)();
00007 extern int C2F(dmmul1)();
00008 
00009 
00010 void dsslti4(scicos_block *block,int flag)
00011 {
00012   /* Copyright INRIA
00013      
00014   Scicos block simulator
00015   discrete state space linear system simulator
00016   rpar(1:nx*nx)=A
00017   rpar(nx*nx+1:nx*nx+nx*nu)=B
00018   rpar(nx*nx+nx*nu+1:nx*nx+nx*nu+nx*ny)=C */
00019   
00020   int un=1,lb,lc,ld;
00021   int nz=block->nz;
00022   double* z=block->z;
00023   double* rpar=block->rpar;
00024   double* y=block->outptr[0];
00025   double* u=block->inptr[0];
00026   int* outsz=block->outsz;
00027   int* insz=block->insz;
00028   double *w;
00029   
00030   lb=nz*nz;
00031   
00032   if (flag ==1 || flag ==6){
00033     /* y=c*x+d*u */
00034     lc=lb+nz*insz[0];
00035     ld=lc+nz*outsz[0];
00036     C2F(dmmul)(&rpar[lc],outsz,z,&nz,y,outsz,outsz,&nz,&un);
00037     C2F(dmmul1)(&rpar[ld],outsz,u,insz,y,outsz,outsz,insz,&un);
00038   }
00039   else if (flag ==2){
00040     /* x+=a*x+b*u */
00041     w =*block->work;
00042     memcpy(w,z,nz*sizeof(double));
00043     C2F(dmmul)(&rpar[0],&nz,w,&nz,z,&nz,&nz,&nz,&un);
00044     C2F(dmmul1)(&rpar[lb],&nz,u,insz,z,&nz,&nz,insz,&un);
00045   }
00046   else if (flag ==4){/* the workspace for temp storage
00047                       */
00048     if ((*block->work=
00049          scicos_malloc(sizeof(double)*nz))== NULL ) {
00050       set_block_error(-16);
00051       return;
00052     }
00053   }
00054   else if (flag ==5){
00055     scicos_free(*block->work);
00056   }
00057 }
00058 
00059 

Generated on Sun Mar 4 15:03:59 2007 for Scilab [trunk] by  doxygen 1.5.1