ext14c.c

Go to the documentation of this file.
00001 /* Copyright Inria/Enpc */
00002 
00003 /************************************
00004  *     (very) simple example 1 
00005  *     with a C wrapper 
00006  *     -->link('ext1c.o','ext1cI','C'); 
00007  *     -->a=[1,2,3];b=[4,5,6];n=3; 
00008  *     -->c=fort('ext1cI',n,a,b)
00009  *     c=a+b 
00010  ************************************/
00011 
00012 #include "stack-c.h"
00013 
00014 int ext14cI(char *fname)
00015 { 
00016   int m1,n1,l1,m2,n2,l2,m3,n3,l3,n,l4;
00017   int minlhs=1, minrhs=3, maxlhs=1, maxrhs=3;
00018   Nbvars = 0;
00019   CheckRhs(minrhs,maxrhs) ;
00020   CheckLhs(minlhs,maxlhs) ;
00021   GetRhsVar( 1, "c", &m1, &n1, &l1);
00022   GetRhsVar( 2, "d", &m2, &n2, &l2);
00023   GetRhsVar( 3, "d", &m3, &n3, &l3);
00024   if ( m3*n3 != m2*n2) 
00025     {
00026       sciprint("%s :Incompatible dimensions\r\n",fname);
00027       Error(999); return(0);
00028     }
00029   CreateVar( 4, "d", &m2, &n2, &l4);
00030   n=m3*n3;
00031   ext14c(&n,stk(l2),stk(l3),stk(l4));
00032   LhsVar(1) = 4;
00033   PutLhsVar();
00034   return(0);
00035 }
00036 
00037 
00038 int ext14c(n, a, b, c)
00039      int *n;
00040      double *a, *b, *c;
00041 {   
00042   int k;
00043   for (k = 0; k < *n; ++k) 
00044     {
00045       c[k] = a[k] + b[k];
00046     }
00047   return(0);
00048 }
00049 

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