00001 SUBROUTINE ZHPT21( ITYPE, UPLO, N, KBAND, AP, D, E, U, LDU, VP,
00002 $ TAU, WORK, RWORK, RESULT )
00003
00004
00005
00006
00007
00008
00009 CHARACTER UPLO
00010 INTEGER ITYPE, KBAND, LDU, N
00011
00012
00013 DOUBLE PRECISION D( * ), E( * ), RESULT( 2 ), RWORK( * )
00014 COMPLEX*16 AP( * ), TAU( * ), U( LDU, * ), VP( * ),
00015 $ WORK( * )
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166 DOUBLE PRECISION ZERO, ONE, TEN
00167 PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0, TEN = 10.0D+0 )
00168 DOUBLE PRECISION HALF
00169 PARAMETER ( HALF = 1.0D+0 / 2.0D+0 )
00170 COMPLEX*16 CZERO, CONE
00171 PARAMETER ( CZERO = ( 0.0D+0, 0.0D+0 ),
00172 $ CONE = ( 1.0D+0, 0.0D+0 ) )
00173
00174
00175 LOGICAL LOWER
00176 CHARACTER CUPLO
00177 INTEGER IINFO, J, JP, JP1, JR, LAP
00178 DOUBLE PRECISION ANORM, ULP, UNFL, WNORM
00179 COMPLEX*16 TEMP, VSAVE
00180
00181
00182 LOGICAL LSAME
00183 DOUBLE PRECISION DLAMCH, ZLANGE, ZLANHP
00184 COMPLEX*16 ZDOTC
00185 EXTERNAL LSAME, DLAMCH, ZLANGE, ZLANHP, ZDOTC
00186
00187
00188 EXTERNAL ZAXPY, ZCOPY, ZGEMM, ZHPMV, ZHPR, ZHPR2,
00189 $ ZLACPY, ZLASET, ZUPMTR
00190
00191
00192 INTRINSIC DBLE, DCMPLX, MAX, MIN
00193
00194
00195
00196
00197
00198 RESULT( 1 ) = ZERO
00199 IF( ITYPE.EQ.1 )
00200 $ RESULT( 2 ) = ZERO
00201 IF( N.LE.0 )
00202 $ RETURN
00203
00204 LAP = ( N*( N+1 ) ) / 2
00205
00206 IF( LSAME( UPLO, 'U' ) ) THEN
00207 LOWER = .FALSE.
00208 CUPLO = 'U'
00209 ELSE
00210 LOWER = .TRUE.
00211 CUPLO = 'L'
00212 END IF
00213
00214 UNFL = DLAMCH( 'Safe minimum' )
00215 ULP = DLAMCH( 'Epsilon' )*DLAMCH( 'Base' )
00216
00217
00218
00219 IF( ITYPE.LT.1 .OR. ITYPE.GT.3 ) THEN
00220 RESULT( 1 ) = TEN / ULP
00221 RETURN
00222 END IF
00223
00224
00225
00226
00227
00228 IF( ITYPE.EQ.3 ) THEN
00229 ANORM = ONE
00230 ELSE
00231 ANORM = MAX( ZLANHP( '1', CUPLO, N, AP, RWORK ), UNFL )
00232 END IF
00233
00234
00235
00236 IF( ITYPE.EQ.1 ) THEN
00237
00238
00239
00240 CALL ZLASET( 'Full', N, N, CZERO, CZERO, WORK, N )
00241 CALL ZCOPY( LAP, AP, 1, WORK, 1 )
00242
00243 DO 10 J = 1, N
00244 CALL ZHPR( CUPLO, N, -D( J ), U( 1, J ), 1, WORK )
00245 10 CONTINUE
00246
00247 IF( N.GT.1 .AND. KBAND.EQ.1 ) THEN
00248 DO 20 J = 1, N - 1
00249 CALL ZHPR2( CUPLO, N, -DCMPLX( E( J ) ), U( 1, J ), 1,
00250 $ U( 1, J-1 ), 1, WORK )
00251 20 CONTINUE
00252 END IF
00253 WNORM = ZLANHP( '1', CUPLO, N, WORK, RWORK )
00254
00255 ELSE IF( ITYPE.EQ.2 ) THEN
00256
00257
00258
00259 CALL ZLASET( 'Full', N, N, CZERO, CZERO, WORK, N )
00260
00261 IF( LOWER ) THEN
00262 WORK( LAP ) = D( N )
00263 DO 40 J = N - 1, 1, -1
00264 JP = ( ( 2*N-J )*( J-1 ) ) / 2
00265 JP1 = JP + N - J
00266 IF( KBAND.EQ.1 ) THEN
00267 WORK( JP+J+1 ) = ( CONE-TAU( J ) )*E( J )
00268 DO 30 JR = J + 2, N
00269 WORK( JP+JR ) = -TAU( J )*E( J )*VP( JP+JR )
00270 30 CONTINUE
00271 END IF
00272
00273 IF( TAU( J ).NE.CZERO ) THEN
00274 VSAVE = VP( JP+J+1 )
00275 VP( JP+J+1 ) = CONE
00276 CALL ZHPMV( 'L', N-J, CONE, WORK( JP1+J+1 ),
00277 $ VP( JP+J+1 ), 1, CZERO, WORK( LAP+1 ), 1 )
00278 TEMP = -HALF*TAU( J )*ZDOTC( N-J, WORK( LAP+1 ), 1,
00279 $ VP( JP+J+1 ), 1 )
00280 CALL ZAXPY( N-J, TEMP, VP( JP+J+1 ), 1, WORK( LAP+1 ),
00281 $ 1 )
00282 CALL ZHPR2( 'L', N-J, -TAU( J ), VP( JP+J+1 ), 1,
00283 $ WORK( LAP+1 ), 1, WORK( JP1+J+1 ) )
00284
00285 VP( JP+J+1 ) = VSAVE
00286 END IF
00287 WORK( JP+J ) = D( J )
00288 40 CONTINUE
00289 ELSE
00290 WORK( 1 ) = D( 1 )
00291 DO 60 J = 1, N - 1
00292 JP = ( J*( J-1 ) ) / 2
00293 JP1 = JP + J
00294 IF( KBAND.EQ.1 ) THEN
00295 WORK( JP1+J ) = ( CONE-TAU( J ) )*E( J )
00296 DO 50 JR = 1, J - 1
00297 WORK( JP1+JR ) = -TAU( J )*E( J )*VP( JP1+JR )
00298 50 CONTINUE
00299 END IF
00300
00301 IF( TAU( J ).NE.CZERO ) THEN
00302 VSAVE = VP( JP1+J )
00303 VP( JP1+J ) = CONE
00304 CALL ZHPMV( 'U', J, CONE, WORK, VP( JP1+1 ), 1, CZERO,
00305 $ WORK( LAP+1 ), 1 )
00306 TEMP = -HALF*TAU( J )*ZDOTC( J, WORK( LAP+1 ), 1,
00307 $ VP( JP1+1 ), 1 )
00308 CALL ZAXPY( J, TEMP, VP( JP1+1 ), 1, WORK( LAP+1 ),
00309 $ 1 )
00310 CALL ZHPR2( 'U', J, -TAU( J ), VP( JP1+1 ), 1,
00311 $ WORK( LAP+1 ), 1, WORK )
00312 VP( JP1+J ) = VSAVE
00313 END IF
00314 WORK( JP1+J+1 ) = D( J+1 )
00315 60 CONTINUE
00316 END IF
00317
00318 DO 70 J = 1, LAP
00319 WORK( J ) = WORK( J ) - AP( J )
00320 70 CONTINUE
00321 WNORM = ZLANHP( '1', CUPLO, N, WORK, RWORK )
00322
00323 ELSE IF( ITYPE.EQ.3 ) THEN
00324
00325
00326
00327 IF( N.LT.2 )
00328 $ RETURN
00329 CALL ZLACPY( ' ', N, N, U, LDU, WORK, N )
00330 CALL ZUPMTR( 'R', CUPLO, 'C', N, N, VP, TAU, WORK, N,
00331 $ WORK( N**2+1 ), IINFO )
00332 IF( IINFO.NE.0 ) THEN
00333 RESULT( 1 ) = TEN / ULP
00334 RETURN
00335 END IF
00336
00337 DO 80 J = 1, N
00338 WORK( ( N+1 )*( J-1 )+1 ) = WORK( ( N+1 )*( J-1 )+1 ) - CONE
00339 80 CONTINUE
00340
00341 WNORM = ZLANGE( '1', N, N, WORK, N, RWORK )
00342 END IF
00343
00344 IF( ANORM.GT.WNORM ) THEN
00345 RESULT( 1 ) = ( WNORM / ANORM ) / ( N*ULP )
00346 ELSE
00347 IF( ANORM.LT.ONE ) THEN
00348 RESULT( 1 ) = ( MIN( WNORM, N*ANORM ) / ANORM ) / ( N*ULP )
00349 ELSE
00350 RESULT( 1 ) = MIN( WNORM / ANORM, DBLE( N ) ) / ( N*ULP )
00351 END IF
00352 END IF
00353
00354
00355
00356
00357
00358 IF( ITYPE.EQ.1 ) THEN
00359 CALL ZGEMM( 'N', 'C', N, N, N, CONE, U, LDU, U, LDU, CZERO,
00360 $ WORK, N )
00361
00362 DO 90 J = 1, N
00363 WORK( ( N+1 )*( J-1 )+1 ) = WORK( ( N+1 )*( J-1 )+1 ) - CONE
00364 90 CONTINUE
00365
00366 RESULT( 2 ) = MIN( ZLANGE( '1', N, N, WORK, N, RWORK ),
00367 $ DBLE( N ) ) / ( N*ULP )
00368 END IF
00369
00370 RETURN
00371
00372
00373
00374 END