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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
|
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) ????-2008 - INRIA
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution. The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
// Making object files
// Interface file
ifile="zallfi.o";
ufiles=["/tmp/ex1c.o","/tmp/ex2f.o","/tmp/ex4f.o","/tmp/ex5f.o","/tmp/ex6c.o","/tmp/ex7f.o","/tmp/ex8c.o","/tmp/ex9f.o","/tmp/ex10f.o","/tmp/ex11c.o","/tmp/ex12c.o","/tmp/ex13c.o","/tmp/ex14c.o","/tmp/ex15c.o","/tmp/ex16c.o"];
files=G_make([ifile,ufiles],"zallfi.dll");
//2-Link object files .o with addinter
//addinter(files,'intex1',intex1_funs);
exec("zallfi.sce");
//Run Scilab functions:
a=[1,2,3];b=[4,5,6];
c=ext1c(a,b);
if norm(c-(a+b)) > %eps then pause,end
//Run Scilab functions:
a=1:20;b=1:10;
d=som(a=1:20,b=1:10);
d1=ones(1,10) + a(1:10)+b(1:10);
if norm(d-d1') > %eps then pause,end;
//Run Scilab functions:
n=3;a=13;incx=2;incy=3;x=1:10;y=2*x;
ynew=scilabdaxpy(n,a,x,incx,y,incy);
y(1:incy:n*incy)=y(1:incy:n*incy)+a*x(1:incx:n*incx);
if norm(ynew-y) > %eps then pause,end
//Run Scilab functions:
sys=ssrand(2,2,3,list("co",1));
n=contrb(sys,0.01)
if n <> 1 then pause,end
//Run Scilab functions:
a=1:5;b=-a;c=ones(3,3);
[a,b,c,d]=foobar("mul",a,b,c)
[a,b,c,d]=foobar("add",a,b,c)
w=["this" "is"; "naw" "gaad"]
rep=calc6a(w);
if rep<>["this" "is"; "now" "good"] then pause,end;
//calc5: creation of a character string matrix.
a=calc6b();
a1="char "; a1=matrix(a1(ones(1,6))+string(0:5),3,2);
if a<>a1 then pause,end
//Run Scilab functions:
if calc("one")<>1 then pause,end
if calc("two")<>2 then pause,end
if calc("other")<>-1 then pause,end
//calc8: matrix of integer type created by C function (malloc and free).
a=calc8();
if norm(a - matrix(0:14,3,5)) > %eps then pause,end
//calc7: function with two optional values, a string and a scilab variable.
bb=33; //scilab optional variable
[a,b,c,d]=calc9(10);
if c<>"toto" then pause,end
if norm(d-[2,4,6,8])> %eps then pause,end
if b<>bb then pause,end
//Test Scilab functions:
// calc1: 3 matrix input variables and at most 3 output variables of
// types double, real, int
l=calc10(list(1,[2,3],[1,2;3,4]));
if norm(l(1)-2) > %eps then pause,end
if norm(l(2)-([2,3]+[1,2])) > %eps then pause,end
if norm(l(3)-([1,2;3,4]+[1,3;2,4])) > %eps then pause,end
//Run Scilab functions:
a=[1,2,3]+%i*[4,5,6];
b=ext11c(a);
if norm(b-([4,5,6]+%i*[1,2,3])) > %eps then pause,end
//Run Scilab functions:
b=ccalc12();
if norm(b-(0:9)) > %eps then pause,end
//Run Scilab functions:
a=rand(2,3);
b=ext13c(a);
if norm(b- matrix(2*a,3,2)) > %eps then pause,end
//Run Scilab functions:
a=[0,0,1.23;0,2.32,0;3.45,0,0];
ai=[0,0,9;0,6,0;7,0,0];
spa=sparse(a);
spai=sparse(a+%i*ai);
// simple sparse argument
b=spt1(spa);
if norm(full(b- spa)) > %eps then pause,end
b=spt1(spai);
if norm(full(b- spai)) > %eps then pause,end
// sparse argument + conversion to int
b=spt2(spa);
if norm(full(b- int(spa))) > %eps then pause,end
b=spt2(spai);
if norm(full(b- int(spai))) > %eps then pause,end
// sparse and return a sparse in a list
b=spt3(spa);
if norm(full(b(1)- spa)) > %eps then pause,end
b=spt3(spai);
if norm(full(b(1)- spai)) > %eps then pause,end
// new sparse in intersci
b=spt4(spa);
if norm(full(b- 2*spa)) > %eps then pause,end
b=spt4(spai);
if norm(full(b- 2*spai)) > %eps then pause,end
// new sparse + conversion to int
b=spt5(spa);
if norm(full(b- int(2*spa))) > %eps then pause,end
b=spt5(spai);
if norm(full(b- int(2*spai))) > %eps then pause,end
// new sparse returned in a list
b=spt6(spa);
if norm(full(b(1)- 2*spa)) > %eps then pause,end
b=spt6(spai);
if norm(full(b(1)- 2*spai)) > %eps then pause,end
// list argument with a sparse
b=spt7(list(spa));
if norm(full(b- spa)) > %eps then pause,end
b=spt7(list(spai));
if norm(full(b- spai)) > %eps then pause,end
// list argument + conversion
b=spt8(list(spa));
if norm(full(b- int(spa))) > %eps then pause,end
b=spt8(list(spai));
if norm(full(b- int(spai))) > %eps then pause,end
// list argument + list output
b=spt9(list(spa));
if norm(full(b(1)- spa)) > %eps then pause,end
b=spt9(list(spai));
if norm(full(b(1)- spai)) > %eps then pause,end
b=spt10(spa);
if norm(full(b- 2*spa)) > %eps then pause,end
//Run Scilab functions:
a=[0,0,1.23;0,2.32,0;3.45,0,0];
// simple matrix argument
b=mat1(a);
if norm(b- a) > %eps then pause,end
// matrix argument + conversion to int
b=mat2(a);
if norm(b- int(a)) > %eps then pause,end
// matrix and return a matrix in a list
b=mat3(a);
if norm(b(1)- a) > %eps then pause,end
// new matrix in intersci
b=mat4(a);
if norm(b- 2*a) > %eps then pause,end
// new matrix + conversion to int
b=mat5(a);
if norm(b- int(2*a)) > %eps then pause,end
// new matrix returned in a list
b=mat6(a);
if norm(b(1)- 2*a) > %eps then pause,end
// list argument with a matrix
b=mat7(list(a));
if norm(b- a) > %eps then pause,end
// list argument + conversion
b=mat8(list(a));
if norm(b- int(a)) > %eps then pause,end
// list argument + list output
b=mat9(list(a));
if norm(b(1)- a) > %eps then pause,end
// cintf
b=mat10();
if norm(b'- (0:9)) > %eps then pause,end
// cintf + list
b=mat11();
if norm(b(1)'- (0:9)) > %eps then pause,end
|