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 // =============================================================================
9 // <-- ENGLISH IMPOSED -->
10 // <-- CLI SHELL MODE -->
17 routines=[pref(ones(1,12))+string(1:12)+suf(ones(1,12))];
18 copyfile(SCI+filesep()+'modules'+filesep()+'dynamic_link'+filesep()+'tests'+filesep()+'unit_tests'+filesep()+'externals.f', TMPDIR);
20 ilib_for_link(routines,'externals.f',[],"f");
22 // load the shared library
25 //===========================================================
26 //(very) simple example 1
27 //===========================================================
28 a=[1,2,3];b=[4,5,6];n=3;
29 c=call('ext1f',n,1,'i',a,2,'d',b,3,'d','out',[1,3],4,'d');
30 if norm(c-(a+b)) > %eps then pause,end
32 //===========================================================
34 //===========================================================
35 a=[1,2,3];b=[4,5,6];n=3;
36 c=call('ext2f',n,1,'i',a,2,'d',b,3,'d','out',[1,3],4,'d');
37 if norm(c-(sin(a)+cos(b))) > %eps then pause,end
39 //===========================================================
41 //===========================================================
42 a=[1,2,3];b=[4,5,6];n=3;
43 c=call('ext3f','yes',1,'c',n,2,'i',a,3,'d',b,4,'d','out',[1,3],5,'d');
44 if norm(c-(sin(a)+cos(b)))> %eps then pause,end
45 c=call('ext3f','no',1,'c',n,2,'i',a,3,'d',b,4,'d','out',[1,3],5,'d');
46 if norm(c-(a+b)) > %eps then pause,end
48 //===========================================================
50 //===========================================================
51 a=[1,2,3];b=[4,5,6];n=3;yes='yes';
52 c=call('ext4f',n,1,'i',a,2,'d',b,3,'d','out',[1,3],4,'d');
53 if norm(c-(sin(a)+cos(b))) > %eps then pause,end
55 c=call('ext4f',n,1,'i',a,2,'d',b,3,'d','out',[1,3],4,'d');
56 if norm(c-(a+b)) > %eps then pause,end
57 //clear yes --> undefined variable : yes
59 //===========================================================
61 //===========================================================
62 // reading vector a in scilab internal stack
64 c=call('ext5f',b,1,'d','out',[1,3],2,'d');
65 if norm(c-(a+2*b)) > %eps then pause,end
67 //===========================================================
69 //===========================================================
70 //reading vector with name='a' in scilab internal stack
72 c=call('ext6f','a',1,'c',b,2,'d','out',[1,3],3,'d');
73 if norm(c-(a+2*b)) > %eps then pause,end
75 //===========================================================
77 //===========================================================
78 //creating vector c in scilab internal stack
81 //c does not exist (c made by ext7f)
82 c1=call('ext7f',a,1,'d',b,2,'d','out',2);
83 if norm(c1-b) > %eps then pause,end
85 if norm(c-(a+2*b)) > %eps then pause,end
87 if d<>"test" then pause,end
89 //===========================================================
91 //===========================================================
92 //call ext8f argument function with dynamic link
93 yref=ode([1;0;0],0,[0.4,4],'ext8f');
95 //===========================================================
97 //===========================================================
98 //passing a parameter to ext9f routine by a list:
99 param=[0.04,10000,3d+7];
100 y=ode([1;0;0],0,[0.4,4],list('ext9f',param));
101 if norm(y-yref) > 10000*%eps then pause,end
103 //===========================================================
105 //===========================================================
106 //Passing a parameter to argument function of ode
107 param=[0.04,10000,3d+7];
108 y=ode([1;0;0],0,[0.4,4],'ext10f');
109 //param must be defined as a scilab variable upon calling ode
110 if norm(y-yref) > 10000*%eps then pause,end
112 //===========================================================
114 //===========================================================
115 //sharing common data
118 call('ext11f',n,1,'i',a,2,'r','out',2); //loads b with a
119 c=call('ext12f',n,1,'i','out',[1,10],2,'r'); //loads c with b
120 if norm(c-a) > %eps then pause,end
122 //===========================================================