patch from Mathworks that fixes convergence problem with some particular pencils...
authorjames <james@8a072113-8704-0410-8d35-dd094bca7971>
Fri, 19 Oct 2012 21:45:55 +0000 (21:45 +0000)
committerjames <james@8a072113-8704-0410-8d35-dd094bca7971>
Fri, 19 Oct 2012 21:45:55 +0000 (21:45 +0000)
SRC/dhgeqz.f
SRC/shgeqz.f

index f6989aa..9836a29 100644 (file)
 *           Exceptional shift.  Chosen for no particularly good reason.
 *           (Single shift only.)
 *
-            IF( ( DBLE( MAXIT )*SAFMIN )*ABS( H( ILAST-1, ILAST ) ).LT.
+            IF( ( DBLE( MAXIT )*SAFMIN )*ABS( H( ILAST, ILAST-1 ) ).LT.
      $          ABS( T( ILAST-1, ILAST-1 ) ) ) THEN
-               ESHIFT = ESHIFT + H( ILAST, ILAST-1 ) /
+               ESHIFT = H( ILAST, ILAST-1 ) /
      $                  T( ILAST-1, ILAST-1 )
             ELSE
                ESHIFT = ESHIFT + ONE / ( SAFMIN*DBLE( MAXIT ) )
      $                  T( ILAST-1, ILAST-1 ), LDT, SAFMIN*SAFETY, S1,
      $                  S2, WR, WR2, WI )
 *
+            IF ( ABS( (WR/S1)*T( ILAST, ILAST ) - H( ILAST, ILAST ) )
+     $         .GT. ABS( (WR2/S2)*T( ILAST, ILAST ) 
+     $         - H( ILAST, ILAST ) ) ) THEN
+               TEMP = WR
+               WR = WR2
+               WR2 = TEMP
+               TEMP = S1
+               S1 = S2
+               S2 = TEMP
+            END IF
             TEMP = MAX( S1, SAFMIN*MAX( ONE, ABS( WR ), ABS( WI ) ) )
             IF( WI.NE.ZERO )
      $         GO TO 200
index 4bd1a1d..6fb82a2 100644 (file)
 *           Exceptional shift.  Chosen for no particularly good reason.
 *           (Single shift only.)
 *
-            IF( ( REAL( MAXIT )*SAFMIN )*ABS( H( ILAST-1, ILAST ) ).LT.
+            IF( ( REAL( MAXIT )*SAFMIN )*ABS( H( ILAST, ILAST-1 ) ).LT.
      $          ABS( T( ILAST-1, ILAST-1 ) ) ) THEN
-               ESHIFT = ESHIFT + H( ILAST, ILAST-1 ) /
+               ESHIFT = H( ILAST, ILAST-1 ) /
      $                  T( ILAST-1, ILAST-1 )
             ELSE
                ESHIFT = ESHIFT + ONE / ( SAFMIN*REAL( MAXIT ) )
      $                  T( ILAST-1, ILAST-1 ), LDT, SAFMIN*SAFETY, S1,
      $                  S2, WR, WR2, WI )
 *
+            IF ( ABS( (WR/S1)*T( ILAST, ILAST ) - H( ILAST, ILAST ) )
+     $         .GT. ABS( (WR2/S2)*T( ILAST, ILAST ) 
+     $         - H( ILAST, ILAST ) ) ) THEN
+               TEMP = WR
+               WR = WR2
+               WR2 = TEMP
+               TEMP = S1
+               S1 = S2
+               S2 = TEMP
+            END IF
             TEMP = MAX( S1, SAFMIN*MAX( ONE, ABS( WR ), ABS( WI ) ) )
             IF( WI.NE.ZERO )
      $         GO TO 200