File: pfss.sci

package info (click to toggle)
scilab 2.4-1
  • links: PTS
  • area: non-free
  • in suites: potato, slink
  • size: 55,196 kB
  • ctags: 38,019
  • sloc: ansic: 231,970; fortran: 148,976; tcl: 7,099; makefile: 4,585; sh: 2,978; csh: 154; cpp: 101; asm: 39; sed: 5
file content (88 lines) | stat: -rw-r--r-- 2,136 bytes parent folder | download
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
function elts=pfss(S,rmax,cord)
//Syntax : elts=pfss(S)
//Partial fraction decomposition of the linear system S (in state-space form):
// elts is the list of linear systems which add up to S
// i.e. elts=list(S1,S2,S3,...,Sn) with S1 + S2 +... +Sn = S
// Each Si contains some poles of S according to the block-diagonalization
// of the A matrix of S.
// If S is given in transfer form, it is first converted into state-space
// and each subsystem is then converted in transfer form.
//!
// Copyright INRIA
flag=0;
[LHS,RHS]=argn(0);
FLAG=S(1)
if FLAG(1)=='r' then flag=1;S=tf2ss(S);end
if RHS==1 then rmax=[];cord=[];end
if RHS==2 then 
  if type(rmax)==10 then cord=rmax;end
  if type(rmax)==1 then cord=[];end
end
//-compat type(S)<>15 retained for list/tlist compatibility
if type(S)<>15&type(S)<>16 then error(91,1),end
[t,f,g,h,dd,dom]=S([1:5,7]);
if t(1)<>'lss' then error(91,1),end;
[n,n]=size(f);
if rmax==[] then
[f,x,bs]=bdiag(f);
else
[f,x,bs]=bdiag(f,rmax);
end
h=h*x;g=x\g;
k=1;ll=0;
elts=list();
for l=bs',
          ind=k:k+l-1;
          f1l=f(ind,ind);
          gl=g(ind,:);
          hl=h(:,ind);
          elts(ll+1)=syslin('c',f1l,gl,hl)
          ll=ll+1;k=k+l;
end;
if RHS==2  then
select cord
case 'c'
  nb=size(bs,'*');
  class=[];
    for k=1:nb
     oneortwo=bs(k);ss=elts(k);A=ss(2);
     if oneortwo==1 then 
        class=[class,real(spec(A))];end
     if oneortwo>1 then 
        class=[class,mini(real(spec(A)))];end
    end;
  [cl,indi]=sort(-class);
  elts1=elts;
     for k=1:size(elts);
        elts(k)=elts1(indi(k));end
case 'd'
  nb=size(bs,'*');
  class=[];
    for k=1:nb
     oneortwo=bs(k);ss=elts(k);A=ss(2);
     if oneortwo==1 then 
        class=[class,abs(spec(A))];end
     if oneortwo>1 then 
        class=[class,maxi(abs(spec(A)))];end
    end;
  [cl,indi]=sort(-class);
  elts1=elts;
     for k=1:size(elts);
        elts(k)=elts1(indi(k));end
end
end
if type(dd)==1 then
if norm(dd,'fro')<>0 then elts(ll+1)=dd,end
end
if type(dd)==2 then 
if norm(coeff(dd),1) > %eps then elts(ll+1)=dd,end
end
if flag==1 then
   k=size(elts);
   for kk=1:k,elts(kk)=ss2tf(elts(kk));end
 end