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 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304
|
SUBROUTINE DGET52( LEFT, N, A, LDA, B, LDB, E, LDE, ALPHAR,
$ ALPHAI, BETA, WORK, RESULT )
*
* -- LAPACK test routine (version 3.0) --
* Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
* Courant Institute, Argonne National Lab, and Rice University
* September 30, 1994
*
* .. Scalar Arguments ..
LOGICAL LEFT
INTEGER LDA, LDB, LDE, N
* ..
* .. Array Arguments ..
DOUBLE PRECISION A( LDA, * ), ALPHAI( * ), ALPHAR( * ),
$ B( LDB, * ), BETA( * ), E( LDE, * ),
$ RESULT( 2 ), WORK( * )
* ..
*
* Purpose
* =======
*
* DGET52 does an eigenvector check for the generalized eigenvalue
* problem.
*
* The basic test for right eigenvectors is:
*
* | b(j) A E(j) - a(j) B E(j) |
* RESULT(1) = max -------------------------------
* j n ulp max( |b(j) A|, |a(j) B| )
*
* using the 1-norm. Here, a(j)/b(j) = w is the j-th generalized
* eigenvalue of A - w B, or, equivalently, b(j)/a(j) = m is the j-th
* generalized eigenvalue of m A - B.
*
* For real eigenvalues, the test is straightforward. For complex
* eigenvalues, E(j) and a(j) are complex, represented by
* Er(j) + i*Ei(j) and ar(j) + i*ai(j), resp., so the test for that
* eigenvector becomes
*
* max( |Wr|, |Wi| )
* --------------------------------------------
* n ulp max( |b(j) A|, (|ar(j)|+|ai(j)|) |B| )
*
* where
*
* Wr = b(j) A Er(j) - ar(j) B Er(j) + ai(j) B Ei(j)
*
* Wi = b(j) A Ei(j) - ai(j) B Er(j) - ar(j) B Ei(j)
*
* T T _
* For left eigenvectors, A , B , a, and b are used.
*
* DGET52 also tests the normalization of E. Each eigenvector is
* supposed to be normalized so that the maximum "absolute value"
* of its elements is 1, where in this case, "absolute value"
* of a complex value x is |Re(x)| + |Im(x)| ; let us call this
* maximum "absolute value" norm of a vector v M(v).
* if a(j)=b(j)=0, then the eigenvector is set to be the jth coordinate
* vector. The normalization test is:
*
* RESULT(2) = max | M(v(j)) - 1 | / ( n ulp )
* eigenvectors v(j)
*
* Arguments
* =========
*
* LEFT (input) LOGICAL
* =.TRUE.: The eigenvectors in the columns of E are assumed
* to be *left* eigenvectors.
* =.FALSE.: The eigenvectors in the columns of E are assumed
* to be *right* eigenvectors.
*
* N (input) INTEGER
* The size of the matrices. If it is zero, DGET52 does
* nothing. It must be at least zero.
*
* A (input) DOUBLE PRECISION array, dimension (LDA, N)
* The matrix A.
*
* LDA (input) INTEGER
* The leading dimension of A. It must be at least 1
* and at least N.
*
* B (input) DOUBLE PRECISION array, dimension (LDB, N)
* The matrix B.
*
* LDB (input) INTEGER
* The leading dimension of B. It must be at least 1
* and at least N.
*
* E (input) DOUBLE PRECISION array, dimension (LDE, N)
* The matrix of eigenvectors. It must be O( 1 ). Complex
* eigenvalues and eigenvectors always come in pairs, the
* eigenvalue and its conjugate being stored in adjacent
* elements of ALPHAR, ALPHAI, and BETA. Thus, if a(j)/b(j)
* and a(j+1)/b(j+1) are a complex conjugate pair of
* generalized eigenvalues, then E(,j) contains the real part
* of the eigenvector and E(,j+1) contains the imaginary part.
* Note that whether E(,j) is a real eigenvector or part of a
* complex one is specified by whether ALPHAI(j) is zero or not.
*
* LDE (input) INTEGER
* The leading dimension of E. It must be at least 1 and at
* least N.
*
* ALPHAR (input) DOUBLE PRECISION array, dimension (N)
* The real parts of the values a(j) as described above, which,
* along with b(j), define the generalized eigenvalues.
* Complex eigenvalues always come in complex conjugate pairs
* a(j)/b(j) and a(j+1)/b(j+1), which are stored in adjacent
* elements in ALPHAR, ALPHAI, and BETA. Thus, if the j-th
* and (j+1)-st eigenvalues form a pair, ALPHAR(j+1)/BETA(j+1)
* is assumed to be equal to ALPHAR(j)/BETA(j).
*
* ALPHAI (input) DOUBLE PRECISION array, dimension (N)
* The imaginary parts of the values a(j) as described above,
* which, along with b(j), define the generalized eigenvalues.
* If ALPHAI(j)=0, then the eigenvalue is real, otherwise it
* is part of a complex conjugate pair. Complex eigenvalues
* always come in complex conjugate pairs a(j)/b(j) and
* a(j+1)/b(j+1), which are stored in adjacent elements in
* ALPHAR, ALPHAI, and BETA. Thus, if the j-th and (j+1)-st
* eigenvalues form a pair, ALPHAI(j+1)/BETA(j+1) is assumed to
* be equal to -ALPHAI(j)/BETA(j). Also, nonzero values in
* ALPHAI are assumed to always come in adjacent pairs.
*
* BETA (input) DOUBLE PRECISION array, dimension (N)
* The values b(j) as described above, which, along with a(j),
* define the generalized eigenvalues.
*
* WORK (workspace) DOUBLE PRECISION array, dimension (N**2+N)
*
* RESULT (output) DOUBLE PRECISION array, dimension (2)
* The values computed by the test described above. If A E or
* B E is likely to overflow, then RESULT(1:2) is set to
* 10 / ulp.
*
* =====================================================================
*
* .. Parameters ..
DOUBLE PRECISION ZERO, ONE, TEN
PARAMETER ( ZERO = 0.0D0, ONE = 1.0D0, TEN = 10.0D0 )
* ..
* .. Local Scalars ..
LOGICAL ILCPLX
CHARACTER NORMAB, TRANS
INTEGER J, JVEC
DOUBLE PRECISION ABMAX, ACOEF, ALFMAX, ANORM, BCOEFI, BCOEFR,
$ BETMAX, BNORM, ENORM, ENRMER, ERRNRM, SAFMAX,
$ SAFMIN, SALFI, SALFR, SBETA, SCALE, TEMP1, ULP
* ..
* .. External Functions ..
DOUBLE PRECISION DLAMCH, DLANGE
EXTERNAL DLAMCH, DLANGE
* ..
* .. External Subroutines ..
EXTERNAL DGEMV
* ..
* .. Intrinsic Functions ..
INTRINSIC ABS, DBLE, MAX
* ..
* .. Executable Statements ..
*
RESULT( 1 ) = ZERO
RESULT( 2 ) = ZERO
IF( N.LE.0 )
$ RETURN
*
SAFMIN = DLAMCH( 'Safe minimum' )
SAFMAX = ONE / SAFMIN
ULP = DLAMCH( 'Epsilon' )*DLAMCH( 'Base' )
*
IF( LEFT ) THEN
TRANS = 'T'
NORMAB = 'I'
ELSE
TRANS = 'N'
NORMAB = 'O'
END IF
*
* Norm of A, B, and E:
*
ANORM = MAX( DLANGE( NORMAB, N, N, A, LDA, WORK ), SAFMIN )
BNORM = MAX( DLANGE( NORMAB, N, N, B, LDB, WORK ), SAFMIN )
ENORM = MAX( DLANGE( 'O', N, N, E, LDE, WORK ), ULP )
ALFMAX = SAFMAX / MAX( ONE, BNORM )
BETMAX = SAFMAX / MAX( ONE, ANORM )
*
* Compute error matrix.
* Column i = ( b(i) A - a(i) B ) E(i) / max( |a(i) B| |b(i) A| )
*
ILCPLX = .FALSE.
DO 10 JVEC = 1, N
IF( ILCPLX ) THEN
*
* 2nd Eigenvalue/-vector of pair -- do nothing
*
ILCPLX = .FALSE.
ELSE
SALFR = ALPHAR( JVEC )
SALFI = ALPHAI( JVEC )
SBETA = BETA( JVEC )
IF( SALFI.EQ.ZERO ) THEN
*
* Real eigenvalue and -vector
*
ABMAX = MAX( ABS( SALFR ), ABS( SBETA ) )
IF( ABS( SALFR ).GT.ALFMAX .OR. ABS( SBETA ).GT.
$ BETMAX .OR. ABMAX.LT.ONE ) THEN
SCALE = ONE / MAX( ABMAX, SAFMIN )
SALFR = SCALE*SALFR
SBETA = SCALE*SBETA
END IF
SCALE = ONE / MAX( ABS( SALFR )*BNORM,
$ ABS( SBETA )*ANORM, SAFMIN )
ACOEF = SCALE*SBETA
BCOEFR = SCALE*SALFR
CALL DGEMV( TRANS, N, N, ACOEF, A, LDA, E( 1, JVEC ), 1,
$ ZERO, WORK( N*( JVEC-1 )+1 ), 1 )
CALL DGEMV( TRANS, N, N, -BCOEFR, B, LDA, E( 1, JVEC ),
$ 1, ONE, WORK( N*( JVEC-1 )+1 ), 1 )
ELSE
*
* Complex conjugate pair
*
ILCPLX = .TRUE.
IF( JVEC.EQ.N ) THEN
RESULT( 1 ) = TEN / ULP
RETURN
END IF
ABMAX = MAX( ABS( SALFR )+ABS( SALFI ), ABS( SBETA ) )
IF( ABS( SALFR )+ABS( SALFI ).GT.ALFMAX .OR.
$ ABS( SBETA ).GT.BETMAX .OR. ABMAX.LT.ONE ) THEN
SCALE = ONE / MAX( ABMAX, SAFMIN )
SALFR = SCALE*SALFR
SALFI = SCALE*SALFI
SBETA = SCALE*SBETA
END IF
SCALE = ONE / MAX( ( ABS( SALFR )+ABS( SALFI ) )*BNORM,
$ ABS( SBETA )*ANORM, SAFMIN )
ACOEF = SCALE*SBETA
BCOEFR = SCALE*SALFR
BCOEFI = SCALE*SALFI
IF( LEFT ) THEN
BCOEFI = -BCOEFI
END IF
*
CALL DGEMV( TRANS, N, N, ACOEF, A, LDA, E( 1, JVEC ), 1,
$ ZERO, WORK( N*( JVEC-1 )+1 ), 1 )
CALL DGEMV( TRANS, N, N, -BCOEFR, B, LDA, E( 1, JVEC ),
$ 1, ONE, WORK( N*( JVEC-1 )+1 ), 1 )
CALL DGEMV( TRANS, N, N, BCOEFI, B, LDA, E( 1, JVEC+1 ),
$ 1, ONE, WORK( N*( JVEC-1 )+1 ), 1 )
*
CALL DGEMV( TRANS, N, N, ACOEF, A, LDA, E( 1, JVEC+1 ),
$ 1, ZERO, WORK( N*JVEC+1 ), 1 )
CALL DGEMV( TRANS, N, N, -BCOEFI, B, LDA, E( 1, JVEC ),
$ 1, ONE, WORK( N*JVEC+1 ), 1 )
CALL DGEMV( TRANS, N, N, -BCOEFR, B, LDA, E( 1, JVEC+1 ),
$ 1, ONE, WORK( N*JVEC+1 ), 1 )
END IF
END IF
10 CONTINUE
*
ERRNRM = DLANGE( 'One', N, N, WORK, N, WORK( N**2+1 ) ) / ENORM
*
* Compute RESULT(1)
*
RESULT( 1 ) = ERRNRM / ULP
*
* Normalization of E:
*
ENRMER = ZERO
ILCPLX = .FALSE.
DO 40 JVEC = 1, N
IF( ILCPLX ) THEN
ILCPLX = .FALSE.
ELSE
TEMP1 = ZERO
IF( ALPHAI( JVEC ).EQ.ZERO ) THEN
DO 20 J = 1, N
TEMP1 = MAX( TEMP1, ABS( E( J, JVEC ) ) )
20 CONTINUE
ENRMER = MAX( ENRMER, TEMP1-ONE )
ELSE
ILCPLX = .TRUE.
DO 30 J = 1, N
TEMP1 = MAX( TEMP1, ABS( E( J, JVEC ) )+
$ ABS( E( J, JVEC+1 ) ) )
30 CONTINUE
ENRMER = MAX( ENRMER, TEMP1-ONE )
END IF
END IF
40 CONTINUE
*
* Compute RESULT(2) : the normalization error in E.
*
RESULT( 2 ) = ENRMER / ( DBLE( N )*ULP )
*
RETURN
*
* End of DGET52
*
END
|