1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
|
// Copyright INRIA
files=G_make(['externals.o'],'externals.dll');
pref='ext';
suf='f';
routines=[pref(ones(1,14))+string(1:14)+suf(ones(1,14))];
lktest=link('show');
if lktest==1 then
link(files,routines);
else
for s=routines; link(files,s);end
end
//(very) simple example 1
a=[1,2,3];b=[4,5,6];n=3;
c=call('ext1f',n,1,'i',a,2,'d',b,3,'d','out',[1,3],4,'d');
if norm(c-(a+b)) > %eps then bugmes();quit;end
//Simple example #2
a=[1,2,3];b=[4,5,6];n=3;
c=call('ext2f',n,1,'i',a,2,'d',b,3,'d','out',[1,3],4,'d');
if norm(c-(sin(a)+cos(b))) > %eps then bugmes();quit;end
//Example #3
a=[1,2,3];b=[4,5,6];n=3;
c=call('ext3f','yes',1,'c',n,2,'i',a,3,'d',b,4,'d','out',[1,3],5,'d');
if norm(c-(sin(a)+cos(b)))> %eps then bugmes();quit;end
c=call('ext3f','no',1,'c',n,2,'i',a,3,'d',b,4,'d','out',[1,3],5,'d');
if norm(c-(a+b)) > %eps then bugmes();quit;end
//Example #4
a=[1,2,3];b=[4,5,6];n=3;yes='yes';
c=call('ext4f',n,1,'i',a,2,'d',b,3,'d','out',[1,3],4,'d');
if norm(c-(sin(a)+cos(b))) > %eps then bugmes();quit;end
yes='no';
c=call('ext4f',n,1,'i',a,2,'d',b,3,'d','out',[1,3],4,'d');
if norm(c-(a+b)) > %eps then bugmes();quit;end
//clear yes --> undefined variable : yes
//Example #5
// reading vector a in scilab internal stack
a=[1,2,3];b=[2,3,4];
c=call('ext5f',b,1,'d','out',[1,3],2,'d');
if norm(c-(a+2*b)) > %eps then bugmes();quit;end
//Example #6
//reading vector with name='a' in scilab internal stack
a=[1,2,3];b=[2,3,4];
c=call('ext6f','a',1,'c',b,2,'d','out',[1,3],3,'d');
if norm(c-(a+2*b)) > %eps then bugmes();quit;end
//Example #7
//creating vector c in scilab internal stack
clear c;
a=[1,2,3]; b=[2,3,4];
//c does not exist (c made by ext7f)
c1=call('ext7f',a,1,'d',b,2,'d','out',2);
if norm(c1-b) > %eps then bugmes();quit;end
//c now exists
if norm(c-(a+2*b)) > %eps then bugmes();quit;end
//d exists
if d<>"test" then bugmes();quit;end
//Example #8
//param must be defined as a scilab variable
param=[1,2,3];
y=call('ext8f','out',size(param),1,'d');
if norm(y-param) > %eps then bugmes();quit;end
//Example #9
//call ext9f argument function with dynamic link
yref=ode([1;0;0],0,[0.4,4],'ext9f');
//Example #10
//passing a parameter to ext10f routine by a list:
param=[0.04,10000,3d+7];
y=ode([1;0;0],0,[0.4,4],list('ext10f',param));
if norm(y-yref) > 100*%eps then bugmes();quit;end
//Example #11
//Passing a parameter to argument funtion of ode
param=[0.04,10000,3d+7];
y=ode([1;0;0],0,[0.4,4],'ext11f');
//param must be defined as a scilab variable upon calling ode
if norm(y-yref) > 100*%eps then bugmes();quit;end
//Example #12
//same example as # 10 with call to matptr
//param must be defined as a scilab variable
param=[0.04,10000,3d+7];
y=ode([1;0;0],0,[0.4,4],'ext12f');
if norm(y-yref) > 100*%eps then bugmes();quit;end
//Example #13
//sharing common data
a=1:10;
n=10;a=1:10;
call('ext13f',n,1,'i',a,2,'r','out',2); //loads b with a
c=call('ext14f',n,1,'i','out',[1,10],2,'r'); //loads c with b
if norm(c-a) > %eps then bugmes();quit;end
|