File: htrianr.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 (44 lines) | stat: -rw-r--r-- 895 bytes parent folder | download | duplicates (2)
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
function [A,U,rk]=htrianr(A)
//[A,U,rk]=htrianr(a)
//triangularization of polynomial matrix A.  A is [m,n], m<=n.
//U=right unimodular basis
//the output value of A equals  A*U
//rk=normal rank of A
//Warning: there is an elimination of neglectable terms
//!
// Copyright INRIA
A=clean(A); 
[m,n]=size(A);U=eye(n,n);
l1=n+1;
for l=m:-1:maxi((m-n),1)
 l1=l1-1;
 if l1<>0 then
  Al=A(l,1:l1);
  if norm(coeff(Al),1) > 1.d-10 then
    [pg,Ul]=hrmt(Al);
    Ul=clean(Ul,1.d-10);
    A(l,1:l1)=[0*ones(1,l1-1) pg];
    U(:,1:l1)=U(:,1:l1)*Ul;
         if l>1 then
          A(1:l-1,1:l1)=A(1:l-1,1:l1)*Ul;
	end
  else
  l1=l1+1
  end
 end
end
U=clean(U,1.d-10);
k0=0;k1=0;tol=norm(coeff(A),1);
v=[];w=[];
for k=1:n
   if maxi(abs(coeff(A(:,k)))) <= sqrt(%eps)*tol then
      k0=k0+1;v=[v,k];                           else
      k1=k1+1,w=[w,k];
   end
end
ww=[v,w];
A=A(:,ww);U=U(:,ww);
rk=n-k0;