00001 /* Copyright Inria/Enpc */ 00002 00003 00004 /************************************ 00005 * simple example 3 (passing a chain) 00006 * -->host('make /tmp/ext3c.o'); 00007 * -->link('/tmp/ext3c.o','ext3c','C'); 00008 * -->a=[1,2,3];b=[4,5,6];n=3; 00009 * -->c=call('ext3c','yes',1,'c',n,2,'i',a,3,'d',b,4,'d','out',[1,3],5,'d') 00010 * -->c-(sin(a)+cos(b) ) 00011 * -->c=call('ext3c','no',1,'c',n,2,'i',a,3,'d',b,4,'d','out',[1,3],5,'d') 00012 * -->c-(a+b ) 00013 ************************************/ 00014 00015 #include <math.h> 00016 #include <string.h> 00017 00018 int ext3c(char *ch, int *n, double *a, double *b, double *c) 00019 { 00020 static int k; 00021 if (strcmp(ch, "yes") == 0) 00022 { 00023 for (k = 0; k < *n; ++k) 00024 c[k] = sin(a[k]) + cos(b[k]); 00025 } 00026 else 00027 { 00028 for (k = 0; k < *n; ++k) 00029 c[k] = a[k] + b[k]; 00030 } 00031 return(0); 00032 }
1.5.1