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
      53
      54
      55
      56
      57
      58
      59
      60
      61
      62
      63
      64
      65
      66
      67
      68
      69
      70
      71
      72
      73
      74
      75
      76
      77
      78
      79
      80
      81
      82
      83
      84
      85
      86
      87
      88
      89
      90
      91
      92
      93
      94
      95
      96
      97
      98
      99
     100
     101
     102
     103
     104
     105
     106
     107
     108
     109
     110
     111
     112
     113
     114
     115
     116
     117
     118
     119
     120
     121
     122
     123
     124
     125
     126
     127
     128
     129
     130
     131
     132
     133
     134
     135
     136
     137
     138
     139
     140
     141
     142
     143
     144
     145
     146
     147
     148
     149
     150
     151
     152
     153
     154
     155
     156
     157
     158
     159
     160
     161
     162
     163
     164
     165
     166
     167
     168
     169
     170
     171
     172
     173
     174
     175
     176
     177
     178
     179
     180
     181
     182
     183
     184
     185
     186
     187
     188
     189
      SUBROUTINE DGET53ALDABLDBSCALEWRWIRESULTINFO )
*
*  -- LAPACK test routine (version 3.1) --
*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
*     November 2006
*
*     .. Scalar Arguments ..
      INTEGER            INFOLDALDB
      DOUBLE PRECISION   RESULTSCALEWIWR
*     ..
*     .. Array Arguments ..
      DOUBLE PRECISION   ALDA* ), BLDB* )
*     ..
*
*  Purpose
*  =======
*
*  DGET53  checks the generalized eigenvalues computed by DLAG2.
*
*  The basic test for an eigenvalue is:
*
*                               | det( s A - w B ) |
*      RESULT =  ---------------------------------------------------
*                ulp max( s norm(A), |w| norm(B) )*norm( s A - w B )
*
*  Two "safety checks" are performed:
*
*  (1)  ulp*max( s*norm(A), |w|*norm(B) )  must be at least
*       safe_minimum.  This insures that the test performed is
*       not essentially  det(0*A + 0*B)=0.
*
*  (2)  s*norm(A) + |w|*norm(B) must be less than 1/safe_minimum.
*       This insures that  s*A - w*B  will not overflow.
*
*  If these tests are not passed, then  s  and  w  are scaled and
*  tested anyway, if this is possible.
*
*  Arguments
*  =========
*
*  A       (input) DOUBLE PRECISION array, dimension (LDA, 2)
*          The 2x2 matrix A.
*
*  LDA     (input) INTEGER
*          The leading dimension of A.  It must be at least 2.
*
*  B       (input) DOUBLE PRECISION array, dimension (LDB, N)
*          The 2x2 upper-triangular matrix B.
*
*  LDB     (input) INTEGER
*          The leading dimension of B.  It must be at least 2.
*
*  SCALE   (input) DOUBLE PRECISION
*          The "scale factor" s in the formula  s A - w B .  It is
*          assumed to be non-negative.
*
*  WR      (input) DOUBLE PRECISION
*          The real part of the eigenvalue  w  in the formula
*          s A - w B .
*
*  WI      (input) DOUBLE PRECISION
*          The imaginary part of the eigenvalue  w  in the formula
*          s A - w B .
*
*  RESULT  (output) DOUBLE PRECISION
*          If INFO is 2 or less, the value computed by the test
*             described above.
*          If INFO=3, this will just be 1/ulp.
*
*  INFO    (output) INTEGER
*          =0:  The input data pass the "safety checks".
*          =1:  s*norm(A) + |w|*norm(B) > 1/safe_minimum.
*          =2:  ulp*max( s*norm(A), |w|*norm(B) ) < safe_minimum
*          =3:  same as INFO=2, but  s  and  w  could not be scaled so
*               as to compute the test.
*
*  =====================================================================
*
*     .. Parameters ..
      DOUBLE PRECISION   ZEROONE
      PARAMETER          ( ZERO = 0.0D0ONE = 1.0D0 )
*     ..
*     .. Local Scalars ..
      DOUBLE PRECISION   ABSWANORMBNORMCI11CI12CI22CNORM,
     $                   CR11CR12CR21CR22CSCALEDETIDETRS1,
     $                   SAFMINSCALESSIGMINTEMPULPWISWRS
*     ..
*     .. External Functions ..
      DOUBLE PRECISION   DLAMCH
      EXTERNAL           DLAMCH
*     ..
*     .. Intrinsic Functions ..
      INTRINSIC          ABSMAXSQRT
*     ..
*     .. Executable Statements ..
*
*     Initialize
*
      INFO = 0
      RESULT = ZERO
      SCALES = SCALE
      WRS = WR
      WIS = WI
*
*     Machine constants and norms
*
      SAFMIN = DLAMCH'Safe minimum' )
      ULP = DLAMCH'Epsilon' )*DLAMCH'Base' )
      ABSW = ABSWRS ) + ABSWIS )
      ANORM = MAXABSA11 ) )+ABSA21 ) ),
     $        ABSA12 ) )+ABSA22 ) ), SAFMIN )
      BNORM = MAXABSB11 ) ), ABSB12 ) )+ABSB22 ) ),
     $        SAFMIN )
*
*     Check for possible overflow.
*
      TEMP = ( SAFMIN*BNORM )*ABSW + ( SAFMIN*ANORM )*SCALES
      IFTEMP.GE.ONE ) THEN
*
*        Scale down to avoid overflow
*
         INFO = 1
         TEMP = ONE / TEMP
         SCALES = SCALES*TEMP
         WRS = WRS*TEMP
         WIS = WIS*TEMP
         ABSW = ABSWRS ) + ABSWIS )
      END IF
      S1 = MAXULP*MAXSCALES*ANORMABSW*BNORM ),
     $     SAFMIN*MAXSCALESABSW ) )
*
*     Check for W and SCALE essentially zero.
*
      IFS1.LT.SAFMIN ) THEN
         INFO = 2
         IFSCALES.LT.SAFMIN .AND. ABSW.LT.SAFMIN ) THEN
            INFO = 3
            RESULT = ONE / ULP
            RETURN
         END IF
*
*        Scale up to avoid underflow
*
         TEMP = ONE / MAXSCALES*ANORM+ABSW*BNORMSAFMIN )
         SCALES = SCALES*TEMP
         WRS = WRS*TEMP
         WIS = WIS*TEMP
         ABSW = ABSWRS ) + ABSWIS )
         S1 = MAXULP*MAXSCALES*ANORMABSW*BNORM ),
     $        SAFMIN*MAXSCALESABSW ) )
         IFS1.LT.SAFMIN ) THEN
            INFO = 3
            RESULT = ONE / ULP
            RETURN
         END IF
      END IF
*
*     Compute C = s A - w B
*
      CR11 = SCALES*A11 ) - WRS*B11 )
      CI11 = -WIS*B11 )
      CR21 = SCALES*A21 )
      CR12 = SCALES*A12 ) - WRS*B12 )
      CI12 = -WIS*B12 )
      CR22 = SCALES*A22 ) - WRS*B22 )
      CI22 = -WIS*B22 )
*
*     Compute the smallest singular value of s A - w B:
*
*                 |det( s A - w B )|
*     sigma_min = ------------------
*                 norm( s A - w B )
*
      CNORM = MAXABSCR11 )+ABSCI11 )+ABSCR21 ),
     $        ABSCR12 )+ABSCI12 )+ABSCR22 )+ABSCI22 ), SAFMIN )
      CSCALE = ONE / SQRTCNORM )
      DETR = ( CSCALE*CR11 )*CSCALE*CR22 ) -
     $       ( CSCALE*CI11 )*CSCALE*CI22 ) -
     $       ( CSCALE*CR12 )*CSCALE*CR21 )
      DETI = ( CSCALE*CR11 )*CSCALE*CI22 ) +
     $       ( CSCALE*CI11 )*CSCALE*CR22 ) -
     $       ( CSCALE*CI12 )*CSCALE*CR21 )
      SIGMIN = ABSDETR ) + ABSDETI )
      RESULT = SIGMIN / S1
      RETURN
*
*     End of DGET53
*
      END