1 // =============================================================================
2 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 // Copyright (C) ????-2008 - INRIA
4 // Copyright (C) 2009 - DIGITEO
6 // This file is distributed under the same license as the Scilab package.
7 // =============================================================================
8 // <-- ENGLISH IMPOSED -->
9 // <-- CLI SHELL MODE -->
14 routines=[pref(ones(1,12))+string(1:12)+suf(ones(1,12))];
15 copyfile(SCI+filesep()+'modules'+filesep()+'dynamic_link'+filesep()+'tests'+filesep()+'unit_tests'+filesep()+'externals.f', TMPDIR);
17 ilib_for_link(routines,'externals.f',[],"f");
18 // load the shared library
20 //===========================================================
21 //(very) simple example 1
22 //===========================================================
23 a=[1,2,3];b=[4,5,6];n=3;
24 c=call('ext1f',n,1,'i',a,2,'d',b,3,'d','out',[1,3],4,'d');
25 if norm(c-(a+b)) > %eps then bugmes();quit;end
26 //===========================================================
28 //===========================================================
29 a=[1,2,3];b=[4,5,6];n=3;
30 c=call('ext2f',n,1,'i',a,2,'d',b,3,'d','out',[1,3],4,'d');
31 if norm(c-(sin(a)+cos(b))) > %eps then bugmes();quit;end
32 //===========================================================
34 //===========================================================
35 a=[1,2,3];b=[4,5,6];n=3;
36 c=call('ext3f','yes',1,'c',n,2,'i',a,3,'d',b,4,'d','out',[1,3],5,'d');
37 if norm(c-(sin(a)+cos(b)))> %eps then bugmes();quit;end
38 c=call('ext3f','no',1,'c',n,2,'i',a,3,'d',b,4,'d','out',[1,3],5,'d');
39 if norm(c-(a+b)) > %eps then bugmes();quit;end
40 //===========================================================
42 //===========================================================
43 a=[1,2,3];b=[4,5,6];n=3;yes='yes';
44 c=call('ext4f',n,1,'i',a,2,'d',b,3,'d','out',[1,3],4,'d');
45 if norm(c-(sin(a)+cos(b))) > %eps then bugmes();quit;end
47 c=call('ext4f',n,1,'i',a,2,'d',b,3,'d','out',[1,3],4,'d');
48 if norm(c-(a+b)) > %eps then bugmes();quit;end
49 //clear yes --> undefined variable : yes
50 //===========================================================
52 //===========================================================
53 // reading vector a in scilab internal stack
55 c=call('ext5f',b,1,'d','out',[1,3],2,'d');
56 if norm(c-(a+2*b)) > %eps then bugmes();quit;end
57 //===========================================================
59 //===========================================================
60 //reading vector with name='a' in scilab internal stack
62 c=call('ext6f','a',1,'c',b,2,'d','out',[1,3],3,'d');
63 if norm(c-(a+2*b)) > %eps then bugmes();quit;end
64 //===========================================================
66 //===========================================================
67 //creating vector c in scilab internal stack
70 //c does not exist (c made by ext7f)
71 c1=call('ext7f',a,1,'d',b,2,'d','out',2);
72 if norm(c1-b) > %eps then bugmes();quit;end
74 if norm(c-(a+2*b)) > %eps then bugmes();quit;end
76 if d<>"test" then bugmes();quit;end
77 //===========================================================
79 //===========================================================
80 //call ext8f argument function with dynamic link
81 yref=ode([1;0;0],0,[0.4,4],'ext8f');
82 //===========================================================
84 //===========================================================
85 //passing a parameter to ext9f routine by a list:
86 param=[0.04,10000,3d+7];
87 y=ode([1;0;0],0,[0.4,4],list('ext9f',param));
88 if norm(y-yref) > 10000*%eps then bugmes();quit;end
89 //===========================================================
91 //===========================================================
92 //Passing a parameter to argument function of ode
93 param=[0.04,10000,3d+7];
94 y=ode([1;0;0],0,[0.4,4],'ext10f');
95 //param must be defined as a scilab variable upon calling ode
96 if norm(y-yref) > 10000*%eps then bugmes();quit;end
97 //===========================================================
99 //===========================================================
100 //sharing common data
103 call('ext11f',n,1,'i',a,2,'r','out',2); //loads b with a
104 c=call('ext12f',n,1,'i','out',[1,10],2,'r'); //loads c with b
105 if norm(c-a) > %eps then bugmes();quit;end
106 //===========================================================