ext4c.c

Go to the documentation of this file.
00001 /* Copyright Inria/Enpc */
00002 #include <math.h>
00003 #include "stack-c.h"
00004 
00005 /************************************
00006  *     simple example 4 (reading a scilab chain) 
00007  *     -->link('ext4c.o','ext4c','C'); 
00008  *     -->a=[1,2,3];b=[4,5,6];n=3;YesOrNo='yes' 
00009  *     -->c=call('ext4c',n,1,'i',a,2,'d',b,3,'d','out',[1,3],4,'d') 
00010  *     -->c=sin(a)+cos(b) 
00011  *     -->YesOrNo='no' 
00012  *     -->c=a+b 
00013  *     -->clear yes  --> undefined variable : yes 
00014  ************************************/
00015 
00016 #define MAXCH 10
00017 
00018 int ext4c(int *n, double *a, double *b, double *c)
00019 {
00020   int k;
00021   char ch[MAXCH];
00022   int lch=MAXCH;
00023 
00024   /* We search a Scilab Object name YesOrNo 
00025    * check that it is a string 
00026    * and store the string in ch 
00027    * lch is used on entry to give the maximum number 
00028    * of characters which can be stored in ch 
00029    * After the call lch contains the number of 
00030    * copied characters
00031    */
00032 
00033   ReadString("YesOrNo", &lch, ch);
00034   /******************************/
00035   if (strcmp(ch, "yes") == 0) 
00036     {
00037       for (k = 0; k < *n; ++k) 
00038         c[k] = sin(a[k]) + cos(b[k]);
00039     } 
00040   else 
00041     {
00042       for (k = 0; k < *n; ++k) 
00043         c[k] = a[k] + b[k];
00044     }
00045   return(0);
00046 }
00047 

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