error(number): converting occurrences remaining in all .sce .sci files
[scilab.git] / scilab / modules / overloading / macros / %lss_inv.sci
1 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2 // Copyright (C) INRIA
3 //
4 // Copyright (C) 2012 - 2016 - Scilab Enterprises
5 //
6 // This file is hereby licensed under the terms of the GNU GPL v2.0,
7 // pursuant to article 5.3.4 of the CeCILL v.2.1.
8 // This file was originally licensed under the terms of the CeCILL v2.1,
9 // and continues to be available under such terms.
10 // For more information, see the COPYING file which you should have received
11 // along with this program.
12
13 function x=%lss_inv(a)
14
15     d=a(5);
16     [m,n]=size(d);
17     polyn=(type(d)==2);constant=(type(d)==1);
18     if constant&(m==n) then
19         minsv=min(svd(d));rcd=rcond(d);s=poly(0,"s");
20     end
21     if constant&(m<>n) then
22         minsv=min(svd(d));s=poly(0,"s");
23     end
24
25     if polyn then rcd=0;minsv=0;s=poly(0,varn(d));end
26     if m==n then
27         if rcd > 1.d-6 then
28             x=invsyslin(a)
29         else
30             h=systmat(a);
31             se=rand("seed");
32             valfa=rand(1,10,"normal")/100;
33             rand("seed",se);
34             www=[];
35             for k=1:10
36             www=[www,rcond(horner(h,valfa(k)))];end
37             [w,k1]=max(www);alfa=valfa(k1);
38             x=invrs(a,alfa);
39         end
40     elseif m<n then
41         warning("non square system! --> right inverse")
42         if minsv > 1.d-6 then
43             x=invsyslin(a)
44         else
45             [stmp,ws]=rowregul(a,0,0);
46             if min(svd(stmp(5))) > 1.d-6 then
47                 x=invsyslin(stmp)*ws
48             else
49                 error(msprintf(_("%s: The problem is singular.\n"), "%lss_inv"));
50             end
51         end
52     elseif m>n then
53         warning("non square system! --> left inverse")
54         if minsv > 1.d-6 then
55             x=invsyslin(a)
56         else
57             [stmp,ws]=rowregul(a,0,0);
58             if min(svd(stmp(5))) > 1.d-6 then
59                 x=invsyslin(stmp)*ws
60             else
61                 error(msprintf(_("%s: The problem is singular.\n"), "%lss_inv"));
62             end
63         end
64     end
65 endfunction