File: %25lss_inv.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 (52 lines) | stat: -rw-r--r-- 1,100 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
45
46
47
48
49
50
51
52
function x=%lss_inv(a)
// Copyright INRIA
d=a(5);
[m,n]=size(d);
polyn=(type(d)==2);constant=(type(d)==1);
if constant&(m==n) then 
  minsv=mini(svd(d));rcd=rcond(d);s=poly(0,'s');
end
if constant&(m<>n) then 
  minsv=mini(svd(d));s=poly(0,'s');
end

if polyn then rcd=0;minsv=0;s=poly(0,varn(d));end
if m==n then 
  if rcd > 1.d-6 then
    x=invsyslin(a)
  else
    h=systmat(a);
    se=rand('seed');
    valfa=rand(1,10,'normal')/100;
    rand('seed',se);
    www=[];
    for k=1:10
    www=[www,rcond(horner(h,valfa(k)))];end
    [w,k1]=maxi(www);alfa=valfa(k1);
    x=invrs(a,alfa);
  end
elseif m<n then
  warning('non square system! --> right inverse')
  if minsv > 1.d-6 then
    x=invsyslin(a)
  else
    [stmp,ws]=rowregul(a,0,0);
    if mini(svd(stmp(5))) > 1.d-6 then
      x=invsyslin(stmp)*ws
    else
      error(19)
    end
  end
elseif m>n then
  warning('non square system! --> left inverse')
  if minsv > 1.d-6 then
    x=invsyslin(a)
  else
    [stmp,ws]=rowregul(a,0,0);
    if mini(svd(stmp(5))) > 1.d-6 then
      x=invsyslin(stmp)*ws
    else
      error(19)
    end
  end
end