bug 68 fix (tolerance setting) and warning removed
Serge Steer [Tue, 20 May 2008 15:42:46 +0000 (15:42 +0000)]
scilab/modules/cacsd/sci_gateway/fortran/sci_f_tzer.f
scilab/modules/cacsd/src/fortran/sszer.f
scilab/modules/cacsd/tests/nonreg_tests/bug_68.dia.ref [new file with mode: 0644]
scilab/modules/cacsd/tests/nonreg_tests/bug_68.tst [new file with mode: 0644]

index 9862bf3..4551547 100644 (file)
@@ -14,8 +14,7 @@ c
 c     ----------------------------
       character*(*) fname
       include 'stack.h'
-      double precision dnrm2,tol,atol,eps,gi,rcond,ur,ui,vr,vi,xr,xi
-      integer p,ind,q,job,ido,n,top1
+      double precision eps
       integer iadr,sadr
 
       iadr(l)=l+l-1
@@ -25,7 +24,7 @@ c     ----------------------------
          call error(18)
          return
       endif
-      eps=0.1*sqrt(stk(leps))
+      eps=stk(leps)
 c
       err=0
 c     calcule de zeros multivariables
@@ -163,4 +162,4 @@ c     sortie des resultats
       
    99    return
       end
-c     ----------------------------
\ No newline at end of file
+c     ----------------------------
index c0121b9..1130e9e 100644 (file)
@@ -172,7 +172,7 @@ C
           sum = sum + (c(i,j)*c(i,j))
  60   continue
 C
-      heps = eps * sqrt(sum)
+      heps = 10.0*eps * sqrt(sum)
 C
 C       reduce this system to one with the same invariant zeros and with
 C       d full row rank mu (the normal rank of the original system)
@@ -180,6 +180,7 @@ C
       iro = p
       isigma = 0
 C
+
       call preduc(bf,naf,mplusn,m,n,p,heps,iro,isigma,mu,nu,wrk1,nwrk1,
      &            wrk2,nwrk2)
 C
@@ -216,6 +217,7 @@ C
       call preduc(af,naf,mplusn,mm,nn,pp,heps,iro,isigma,mu,nu,wrk1,
      &            nwrk1,wrk2,nwrk2)
 C
+
       if (nu .eq. 0) return
       mnu = mm + nu
  80   continue
@@ -274,7 +276,7 @@ Cc
  150  ierr = ierr + 2
       return
       end
-        subroutine preduc(abf,naf,mplusn,m,n,p,heps,iro,isigma,mu,nu,
+      subroutine preduc(abf,naf,mplusn,m,n,p,heps,iro,isigma,mu,nu,
      1                    wrk1,nwrk1,wrk2,nwrk2)
 c%calling sequence
 c       subroutine preduc(abf,naf,mplusn,m,n,p,heps,iro,isigma,mu,nu,
diff --git a/scilab/modules/cacsd/tests/nonreg_tests/bug_68.dia.ref b/scilab/modules/cacsd/tests/nonreg_tests/bug_68.dia.ref
new file mode 100644 (file)
index 0000000..0f249d8
--- /dev/null
@@ -0,0 +1,68 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2005-2008 - INRIA -Serge Steer
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- Non-regression test for bug 68 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=68
+//
+// <-- Short Description -->
+//Precision problem with the trzeros function,
+s=poly(0,'s');
+A=[-113.63636,-2840909.1,113.63636,2840909.1,0,0;
+   1,0,0,0,0,0;
+   347.22222,8680555.6,-366.66667,-11111111,19.444444,2430555.6;
+   0,0,1,0,0,0;
+   0,0,50,6250000,-50,-6250000;
+   0,0,0,0,1,0]
+ A  =
+         column 1 to 5
+  - 113.63636  - 2840909.1    113.63636    2840909.1    0.         
+    1.           0.           0.           0.           0.         
+    347.22222    8680555.6  - 366.66667  - 11111111.    19.444444  
+    0.           0.           1.           0.           0.         
+    0.           0.           50.          6250000.   - 50.        
+    0.           0.           0.           0.           1.         
+         column 6
+    0.         
+    0.         
+    2430555.6  
+    0.         
+  - 6250000.   
+    0.         
+System =syslin('c',A,[1;0;0;0;0;0],[0 0 0 1 0 0]);
+Td=1/0.1;alpha=1000;Ti=1/0.1;Tr=1/10000;Kp=1e2;
+PID=tf2ss(syslin('c',Kp*(1+Td*s)/(1+Td/alpha*s)));
+Hrond1=PID*System;closed1=(1/.(Hrond1));
+ClosedZeros1=trzeros(closed1);
+Hrond2=System*PID;closed2=(1/.(Hrond2));
+ClosedZeros2=trzeros(closed2);
+C1=gsort([real(ClosedZeros1) imag(ClosedZeros1)],'lr')
+ C1  =
+    0.2121313    0.         
+  - 0.2121327    0.         
+  - 50.931607    2302.31    
+  - 50.931607  - 2302.31    
+  -100.          0.         
+  - 214.21991  - 3851.5601  
+  - 214.21991    3851.5601  
+C2=gsort([real(ClosedZeros2) imag(ClosedZeros2)],'lr')
+ C2  =
+    0.2121314    0.         
+  - 0.2121327    0.         
+  - 50.931607    2302.31    
+  - 50.931607  - 2302.31    
+  - 100.         0.         
+  - 214.21991  - 3851.5601  
+  - 214.21991    3851.5601  
+if norm(C1-C2)>1d-5 then bugmes();quit;end
diff --git a/scilab/modules/cacsd/tests/nonreg_tests/bug_68.tst b/scilab/modules/cacsd/tests/nonreg_tests/bug_68.tst
new file mode 100644 (file)
index 0000000..71b0137
--- /dev/null
@@ -0,0 +1,39 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2005-2008 - INRIA -Serge Steer
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- Non-regression test for bug 68 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=68
+//
+// <-- Short Description -->
+//Precision problem with the trzeros function, 
+
+s=poly(0,'s'); 
+A=[-113.63636,-2840909.1,113.63636,2840909.1,0,0;
+   1,0,0,0,0,0;
+   347.22222,8680555.6,-366.66667,-11111111,19.444444,2430555.6;
+   0,0,1,0,0,0;
+   0,0,50,6250000,-50,-6250000;
+   0,0,0,0,1,0]
+
+System =syslin('c',A,[1;0;0;0;0;0],[0 0 0 1 0 0]);
+
+Td=1/0.1;alpha=1000;Ti=1/0.1;Tr=1/10000;Kp=1e2;
+PID=tf2ss(syslin('c',Kp*(1+Td*s)/(1+Td/alpha*s)));
+
+Hrond1=PID*System;closed1=(1/.(Hrond1));
+ClosedZeros1=trzeros(closed1);
+
+Hrond2=System*PID;closed2=(1/.(Hrond2));
+ClosedZeros2=trzeros(closed2);
+
+C1=gsort([real(ClosedZeros1) imag(ClosedZeros1)],'lr')
+C2=gsort([real(ClosedZeros2) imag(ClosedZeros2)],'lr')
+
+if norm(C1-C2)>1d-5 then pause,end
+