~ubuntu-branches/ubuntu/hoary/scilab/hoary

« back to all changes in this revision

Viewing changes to macros/auto/flts.sci

  • 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
function [y,xf]=flts(u,sl,x0)
 
2
// Copyright INRIA
 
3
[lhs,rhs]=argn(0)
 
4
if type(u)<>1 then error(53,1),end
 
5
if rhs<=1 then error(39),end
 
6
[nu,mu]=size(u)
 
7
 
 
8
if type(sl)<>16 then error(97,2),end
 
9
flag=sl(1);
 
10
select flag(1)
 
11
  case 'lss' then 
 
12
    if rhs==2 then x0=sl(6),end
 
13
    [nb,mb]=size(sl(3))
 
14
    if mb<>nu then
 
15
       error(60),
 
16
    end;
 
17
    select sl(7)
 
18
     case 'c' then error(94,2),
 
19
    end;
 
20
    np=maxi(degree(sl(5)))
 
21
    [xf,x]=ltitr(sl(2),sl(3),u(:,1:(mu-np)),x0)
 
22
   if type(sl(5))==1 then
 
23
      y=sl(4)*x+sl(5)*u
 
24
    else
 
25
      y=sl(4)*x+rtitr(sl(5),eye(sl(5)),u)
 
26
    end
 
27
   case 'r'  then  
 
28
    if lhs>1 then error('flts: invalid lhs'),end
 
29
    [num,den]=sl(['num','den']);[ns,ne]=size(num)
 
30
       select sl('dt')
 
31
        case 'c' then error(94,2),
 
32
       end;
 
33
    if ne<>nu then error(60), end;
 
34
    for l=1:1:ns,
 
35
       pp=den(l,1);
 
36
       for k=2:ne,[pg,uu]=bezout(pp,den(l,k)),pp=pp*uu(1,2),end
 
37
       nden(l)=pp
 
38
       for k=1:ne,nnum(l,k)=num(l,k)*pdiv(pp,den(l,k)),end,
 
39
    end;
 
40
    for l=1:ns, nm(l)=degree(nden(l))-maxi(degree(nnum(l,:))),end
 
41
    ly=mu+mini(nm)
 
42
    if rhs==3 then
 
43
       [mx,nx]=size(x0);maxdgd=maxi(degree(nden))
 
44
       if nx<maxdgd then
 
45
         error('AT LEAST '+string(maxdgd)+' PAST VALUES!')
 
46
       end;
 
47
       if mx<>ns+ne then error(60),end
 
48
    end;
 
49
      y=0*ones(ns,ly);
 
50
    for l=1:ns
 
51
      ddl=degree(nden(l))
 
52
      dnl=maxi(degree(nnum(l,:)))
 
53
      lent=ly-ddl+dnl
 
54
      select rhs
 
55
        case 2 then yl=rtitr(nnum(l,:),nden(l),u(:,1:lent));
 
56
                    [nn,mm]=size(yl);
 
57
                    y(l,1:mm)=yl;
 
58
//                    y=y(:,1:lent);
 
59
        case 3 then
 
60
               up=x0(1:ne,maxdgd-ddl+1:maxdgd);
 
61
               yp=x0(ne+l,maxdgd-ddl+1:maxdgd);
 
62
               y(l,:)=rtitr(nnum(l,:),nden(l),u(:,1:lent),up,yp);
 
63
      end;
 
64
    end,
 
65
    l=size(y,2);
 
66
    y=y(:,1:min(mu,l));
 
67
  else error(97,2)
 
68
end;
 
69
 
 
70
 
 
71