~ubuntu-branches/ubuntu/karmic/scilab/karmic

« back to all changes in this revision

Viewing changes to tests/links.tst

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2002-03-21 16:57:43 UTC
  • Revision ID: james.westby@ubuntu.com-20020321165743-e9mv12c1tb1plztg
Tags: upstream-2.6
ImportĀ upstreamĀ versionĀ 2.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright INRIA
 
2
 
 
3
files=G_make(['externals.o'],'externals.dll');
 
4
pref='ext';
 
5
suf='f';
 
6
routines=[pref(ones(1,14))+string(1:14)+suf(ones(1,14))];
 
7
lktest=link('show');
 
8
if lktest==1 then
 
9
        link(files,routines);
 
10
else
 
11
        for s=routines; link(files,s);end
 
12
end
 
13
 
 
14
 
 
15
//(very) simple example 1
 
16
a=[1,2,3];b=[4,5,6];n=3;
 
17
c=call('ext1f',n,1,'i',a,2,'d',b,3,'d','out',[1,3],4,'d');
 
18
if norm(c-(a+b)) > %eps then pause,end
 
19
 
 
20
//Simple example #2
 
21
a=[1,2,3];b=[4,5,6];n=3;
 
22
c=call('ext2f',n,1,'i',a,2,'d',b,3,'d','out',[1,3],4,'d');
 
23
if norm(c-(sin(a)+cos(b))) > %eps then pause,end
 
24
 
 
25
//Example #3
 
26
a=[1,2,3];b=[4,5,6];n=3;
 
27
c=call('ext3f','yes',1,'c',n,2,'i',a,3,'d',b,4,'d','out',[1,3],5,'d');
 
28
if norm(c-(sin(a)+cos(b)))> %eps then pause,end
 
29
c=call('ext3f','no',1,'c',n,2,'i',a,3,'d',b,4,'d','out',[1,3],5,'d');
 
30
if norm(c-(a+b)) > %eps then pause,end
 
31
 
 
32
//Example #4 
 
33
a=[1,2,3];b=[4,5,6];n=3;yes='yes';
 
34
c=call('ext4f',n,1,'i',a,2,'d',b,3,'d','out',[1,3],4,'d');
 
35
if norm(c-(sin(a)+cos(b))) > %eps then pause,end
 
36
yes='no';
 
37
c=call('ext4f',n,1,'i',a,2,'d',b,3,'d','out',[1,3],4,'d');
 
38
if norm(c-(a+b)) > %eps then pause,end
 
39
//clear yes  --> undefined variable : yes
 
40
 
 
41
//Example #5 
 
42
// reading vector a in scilab internal stack
 
43
a=[1,2,3];b=[2,3,4];
 
44
c=call('ext5f',b,1,'d','out',[1,3],2,'d');
 
45
if norm(c-(a+2*b)) > %eps then pause,end
 
46
 
 
47
//Example #6
 
48
//reading  vector with name='a' in scilab internal stack
 
49
a=[1,2,3];b=[2,3,4];
 
50
c=call('ext6f','a',1,'c',b,2,'d','out',[1,3],3,'d');
 
51
if norm(c-(a+2*b)) > %eps then pause,end
 
52
 
 
53
 
 
54
//Example #7
 
55
//creating vector c in scilab internal stack
 
56
clear c;
 
57
a=[1,2,3]; b=[2,3,4];
 
58
//c does not exist (c made by ext7f)
 
59
c1=call('ext7f',a,1,'d',b,2,'d','out',2);
 
60
if norm(c1-b) > %eps then pause,end
 
61
//c now exists
 
62
if norm(c-(a+2*b)) > %eps then pause,end
 
63
//d exists 
 
64
if d<>"test" then pause,end
 
65
 
 
66
//Example #8 
 
67
//param must be defined as a scilab variable
 
68
param=[1,2,3];
 
69
y=call('ext8f','out',size(param),1,'d');
 
70
if norm(y-param) > %eps then pause,end
 
71
 
 
72
//Example #9
 
73
//call ext9f argument function with dynamic link
 
74
yref=ode([1;0;0],0,[0.4,4],'ext9f');
 
75
 
 
76
//Example #10
 
77
//passing a parameter to ext10f routine by a list:
 
78
param=[0.04,10000,3d+7];    
 
79
y=ode([1;0;0],0,[0.4,4],list('ext10f',param));
 
80
if norm(y-yref) > 10000*%eps then pause,end
 
81
 
 
82
//Example #11
 
83
//Passing a parameter to argument funtion of ode
 
84
param=[0.04,10000,3d+7];
 
85
y=ode([1;0;0],0,[0.4,4],'ext11f');
 
86
//param must be defined as a scilab variable upon calling ode
 
87
if norm(y-yref) > 10000*%eps then pause,end
 
88
 
 
89
//Example #12 
 
90
//same example as # 10 with call to matptr
 
91
//param must be defined as a scilab variable
 
92
param=[0.04,10000,3d+7];
 
93
y=ode([1;0;0],0,[0.4,4],'ext12f');
 
94
if norm(y-yref) > 10000*%eps then pause,end
 
95
 
 
96
//Example #13
 
97
//sharing common data
 
98
a=1:10;
 
99
n=10;a=1:10;
 
100
call('ext13f',n,1,'i',a,2,'r','out',2);  //loads b with a
 
101
c=call('ext14f',n,1,'i','out',[1,10],2,'r');  //loads c with b
 
102
if norm(c-a) > %eps then pause,end