intex8c.c File Reference

#include "stack-c.h"

Include dependency graph for intex8c.c:

Go to the source code of this file.

Functions

int intex8c (char *fname)


Function Documentation

int intex8c ( char *  fname  ) 

Definition at line 16 of file intex8c.c.

References CheckLhs, CheckRhs, CreateVar, Err, GetRhsVar, i, LhsVar, m1, m2, mlhs, mrhs, n1, n2, SciFunction, and stk.

00018 {
00019   int ibegin;
00020   static int l1, m1, n1, m2, n2, l2,mlhs,mrhs,lf, l4,l5,i;
00021   static int minlhs=1, minrhs=3, maxlhs=3, maxrhs=3;
00022   
00023   CheckRhs(minrhs,maxrhs) ;
00024   CheckLhs(minlhs,maxlhs) ;
00025 
00026   /* Getting x1 and x2 at l1 and l2 . x1 is m1 x n1 and x2 is m2 x n2 */
00027   GetRhsVar(1, "d", &m1, &n1, &l1);
00028   GetRhsVar(2, "d", &m2, &n2, &l2);
00029   /* Getting the Scilab function:
00030      It is the 3rd input parameter of ex8c and it is a function ("f") */
00031   GetRhsVar(3, "f", &mlhs, &mrhs, &lf);
00032   /*   It is at lf and has mlhs outputs and mrhs inputs */
00033 
00034   if ( mrhs != 2 ) 
00035     {
00036       Scierror(999,"%s: Third argument has an invalid rhs\r\n",fname);
00037       return 0;
00038     }
00039 
00040   /* 
00041    *  To call a_function it is required that its input arguments are
00042    *  stored in the last positions of the variables stack. NOTE that when 
00043    *  called, the function destroys its input variables and replaces them by 
00044    *  the output variables. so in this  case we need to make a copy of
00045    *  them.
00046    *  Remark: if the calling sequence of ex8c had been ex8c(a_function,x1,x2)
00047    *  the following two copies would be un-necessary.
00048    */
00049 
00050   CreateVar(3+1, "d", &m1, &n1, &l4);
00051   for (i =0 ; i < m1*n1 ; i++) *stk(l4+i) = *stk(l1+i);
00052 
00053   CreateVar(3+mrhs, "d", &m2, &n2, &l5);
00054   for (i =0 ; i < m1*n1 ; i++) *stk(l5+i) = *stk(l2+i);
00055 
00056   /* 
00057    *  Here a_function  takes  variables 4 and 5 as inputs and generates output
00058    *  variables at positions 4 to 4-1+mlhs
00059    *  ibegin must be the index of the first input variable of a_function
00060    */
00061   
00062   ibegin=3+1;
00063 
00064   /* execute the function */
00065 
00066   SciFunction(&ibegin,&lf,&mlhs,&mrhs);
00067   /* check if an error has occured while running a_function */
00068   if (Err > 0 ) return 0;
00069   
00070   /* output variables: 4 and 5 (created by a_function) and possibly 6
00071    * if a_function has 3 output parameters
00072    */
00073 
00074   LhsVar(1) = 4;
00075   LhsVar(2) = 5;
00076   if ( mlhs == 3) LhsVar(3) = 6;
00077   return 0;
00078 }


Generated on Sun Mar 4 16:07:52 2007 for Scilab [trunk] by  doxygen 1.5.1