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

« back to all changes in this revision

Viewing changes to examples/misc-examples/dassl1.sce

  • 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
//DASSL
 
3
// PROBLEM 1:   LINEAR DIFFERENTIAL/ALGEBRAIC SYSTEM
 
4
//
 
5
//X1DOT + 10.0*X1 = 0  
 
6
//X1 + X2 = 1
 
7
//X1(0) = 1.0, X2(0) = 0.0
 
8
//
 
9
t=1:10;t0=0;y0=[1;0];y0d=[-10;0];
 
10
info=list([],0,[],[],[],0,0);
 
11
// with default atol and rtol parameters
 
12
//    Calling Scilab functions
 
13
deff('[r,ires]=dres1(t,y,ydot)','r=[ydot(1,:)+10*y(1,:);y(2,:)+y(1,:)-1];ires=0')
 
14
deff('pd=djac1(t,y,ydot,cj)','pd=[cj+10,0;1,1]')
 
15
//   scilab function, without jacobian
 
16
yy0=dassl([y0,y0d],t0,t,dres1,info);
 
17
if norm(dres1(yy0(1,:),yy0(2:3,:),yy0(4:5,:)),1)>1.d-6 then pause,end
 
18
//   scilab functions, with jacobian
 
19
yy1=dassl([y0,y0d],t0,t,dres1,djac1,info);
 
20
if norm(dres1(yy1(1,:),yy1(2:3,:),yy1(4:5,:)),1)>1.d-6 then pause,end
 
21
// fortran routine dres1 in dir. routines/default, without jocabian
 
22
yy2=dassl([y0,y0d],t0,t,'dres1',info);   //=yy0
 
23
if norm(dres1(yy2(1,:),yy2(2:3,:),yy2(4:5,:)),1)>1.4d-6 then pause,end
 
24
// fortran routines dres1 and djac1 in dir. routines/default, with jacobian
 
25
yy3=dassl([y0,y0d],t0,t,'dres1','djac1',info);  //=yy1
 
26
if norm(dres1(yy3(1,:),yy3(2:3,:),yy3(4:5,:)),1)>1.d-6 then pause,end
 
27
//if norm(yy3-yy1,1)  > Eps then pause,end
 
28
yy3bis=dassl([y0,y0d],t0,t,'dres1',djac1,info); 
 
29
if norm(dres1(yy3bis(1,:),yy3bis(2:3,:),yy3bis(4:5,:)),1)>1.d-6 then pause,end
 
30
// call fortran dres1 and scilab's djac1
 
31
yy3ter=dassl([y0,y0d],t0,t,dres1,'djac1',info);
 
32
if norm(dres1(yy3ter(1,:),yy3ter(2:3,:),yy3ter(4:5,:)),1)>1.d-6 then pause,end
 
33
//
 
34
// with specific atol and rtol parameters
 
35
atol=1.d-6;rtol=0;
 
36
//   scilab function, without jacobian
 
37
yy4=dassl([y0,y0d],t0,t,atol,rtol,dres1,info);
 
38
if norm(dres1(yy4(1,:),yy4(2:3,:),yy4(4:5,:)),1)>1.d-5 then pause,end
 
39
//   fortran routine dres1 in dir. routines/default, without jocabian
 
40
yy5=dassl([y0,y0d],t0,t,atol,rtol,'dres1',info); //=yy4
 
41
if norm(dres1(yy5(1,:),yy5(2:3,:),yy5(4:5,:)),1)>1.d-5 then pause,end
 
42
//   scilab functions,
 
43
yy6=dassl([y0,y0d],t0,t,atol,rtol,dres1,djac1,info); 
 
44
if norm(dres1(yy6(1,:),yy6(2:3,:),yy6(4:5,:)),1)>1.d-5 then pause,end
 
45
//   fortran routines 
 
46
yy7=dassl([y0,y0d],t0,t,atol,rtol,'dres1','djac1',info); //==yy6
 
47
if norm(dres1(yy7(1,:),yy7(2:3,:),yy7(4:5,:)),1)>1.d-5 then pause,end
 
48