00001 SUBROUTINE SSYT21( ITYPE, UPLO, N, KBAND, A, LDA, D, E, U, LDU, V,
00002 $ LDV, TAU, WORK, RESULT )
00003
00004
00005
00006
00007
00008
00009 CHARACTER UPLO
00010 INTEGER ITYPE, KBAND, LDA, LDU, LDV, N
00011
00012
00013 REAL A( LDA, * ), D( * ), E( * ), RESULT( 2 ),
00014 $ TAU( * ), U( LDU, * ), V( LDV, * ), WORK( * )
00015
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 REAL ZERO, ONE, TEN
00143 PARAMETER ( ZERO = 0.0E0, ONE = 1.0E0, TEN = 10.0E0 )
00144
00145
00146 LOGICAL LOWER
00147 CHARACTER CUPLO
00148 INTEGER IINFO, J, JCOL, JR, JROW
00149 REAL ANORM, ULP, UNFL, VSAVE, WNORM
00150
00151
00152 LOGICAL LSAME
00153 REAL SLAMCH, SLANGE, SLANSY
00154 EXTERNAL LSAME, SLAMCH, SLANGE, SLANSY
00155
00156
00157 EXTERNAL SGEMM, SLACPY, SLARFY, SLASET, SORM2L, SORM2R,
00158 $ SSYR, SSYR2
00159
00160
00161 INTRINSIC MAX, MIN, REAL
00162
00163
00164
00165 RESULT( 1 ) = ZERO
00166 IF( ITYPE.EQ.1 )
00167 $ RESULT( 2 ) = ZERO
00168 IF( N.LE.0 )
00169 $ RETURN
00170
00171 IF( LSAME( UPLO, 'U' ) ) THEN
00172 LOWER = .FALSE.
00173 CUPLO = 'U'
00174 ELSE
00175 LOWER = .TRUE.
00176 CUPLO = 'L'
00177 END IF
00178
00179 UNFL = SLAMCH( 'Safe minimum' )
00180 ULP = SLAMCH( 'Epsilon' )*SLAMCH( 'Base' )
00181
00182
00183
00184 IF( ITYPE.LT.1 .OR. ITYPE.GT.3 ) THEN
00185 RESULT( 1 ) = TEN / ULP
00186 RETURN
00187 END IF
00188
00189
00190
00191
00192
00193 IF( ITYPE.EQ.3 ) THEN
00194 ANORM = ONE
00195 ELSE
00196 ANORM = MAX( SLANSY( '1', CUPLO, N, A, LDA, WORK ), UNFL )
00197 END IF
00198
00199
00200
00201 IF( ITYPE.EQ.1 ) THEN
00202
00203
00204
00205 CALL SLASET( 'Full', N, N, ZERO, ZERO, WORK, N )
00206 CALL SLACPY( CUPLO, N, N, A, LDA, WORK, N )
00207
00208 DO 10 J = 1, N
00209 CALL SSYR( CUPLO, N, -D( J ), U( 1, J ), 1, WORK, N )
00210 10 CONTINUE
00211
00212 IF( N.GT.1 .AND. KBAND.EQ.1 ) THEN
00213 DO 20 J = 1, N - 1
00214 CALL SSYR2( CUPLO, N, -E( J ), U( 1, J ), 1, U( 1, J+1 ),
00215 $ 1, WORK, N )
00216 20 CONTINUE
00217 END IF
00218 WNORM = SLANSY( '1', CUPLO, N, WORK, N, WORK( N**2+1 ) )
00219
00220 ELSE IF( ITYPE.EQ.2 ) THEN
00221
00222
00223
00224 CALL SLASET( 'Full', N, N, ZERO, ZERO, WORK, N )
00225
00226 IF( LOWER ) THEN
00227 WORK( N**2 ) = D( N )
00228 DO 40 J = N - 1, 1, -1
00229 IF( KBAND.EQ.1 ) THEN
00230 WORK( ( N+1 )*( J-1 )+2 ) = ( ONE-TAU( J ) )*E( J )
00231 DO 30 JR = J + 2, N
00232 WORK( ( J-1 )*N+JR ) = -TAU( J )*E( J )*V( JR, J )
00233 30 CONTINUE
00234 END IF
00235
00236 VSAVE = V( J+1, J )
00237 V( J+1, J ) = ONE
00238 CALL SLARFY( 'L', N-J, V( J+1, J ), 1, TAU( J ),
00239 $ WORK( ( N+1 )*J+1 ), N, WORK( N**2+1 ) )
00240 V( J+1, J ) = VSAVE
00241 WORK( ( N+1 )*( J-1 )+1 ) = D( J )
00242 40 CONTINUE
00243 ELSE
00244 WORK( 1 ) = D( 1 )
00245 DO 60 J = 1, N - 1
00246 IF( KBAND.EQ.1 ) THEN
00247 WORK( ( N+1 )*J ) = ( ONE-TAU( J ) )*E( J )
00248 DO 50 JR = 1, J - 1
00249 WORK( J*N+JR ) = -TAU( J )*E( J )*V( JR, J+1 )
00250 50 CONTINUE
00251 END IF
00252
00253 VSAVE = V( J, J+1 )
00254 V( J, J+1 ) = ONE
00255 CALL SLARFY( 'U', J, V( 1, J+1 ), 1, TAU( J ), WORK, N,
00256 $ WORK( N**2+1 ) )
00257 V( J, J+1 ) = VSAVE
00258 WORK( ( N+1 )*J+1 ) = D( J+1 )
00259 60 CONTINUE
00260 END IF
00261
00262 DO 90 JCOL = 1, N
00263 IF( LOWER ) THEN
00264 DO 70 JROW = JCOL, N
00265 WORK( JROW+N*( JCOL-1 ) ) = WORK( JROW+N*( JCOL-1 ) )
00266 $ - A( JROW, JCOL )
00267 70 CONTINUE
00268 ELSE
00269 DO 80 JROW = 1, JCOL
00270 WORK( JROW+N*( JCOL-1 ) ) = WORK( JROW+N*( JCOL-1 ) )
00271 $ - A( JROW, JCOL )
00272 80 CONTINUE
00273 END IF
00274 90 CONTINUE
00275 WNORM = SLANSY( '1', CUPLO, N, WORK, N, WORK( N**2+1 ) )
00276
00277 ELSE IF( ITYPE.EQ.3 ) THEN
00278
00279
00280
00281 IF( N.LT.2 )
00282 $ RETURN
00283 CALL SLACPY( ' ', N, N, U, LDU, WORK, N )
00284 IF( LOWER ) THEN
00285 CALL SORM2R( 'R', 'T', N, N-1, N-1, V( 2, 1 ), LDV, TAU,
00286 $ WORK( N+1 ), N, WORK( N**2+1 ), IINFO )
00287 ELSE
00288 CALL SORM2L( 'R', 'T', N, N-1, N-1, V( 1, 2 ), LDV, TAU,
00289 $ WORK, N, WORK( N**2+1 ), IINFO )
00290 END IF
00291 IF( IINFO.NE.0 ) THEN
00292 RESULT( 1 ) = TEN / ULP
00293 RETURN
00294 END IF
00295
00296 DO 100 J = 1, N
00297 WORK( ( N+1 )*( J-1 )+1 ) = WORK( ( N+1 )*( J-1 )+1 ) - ONE
00298 100 CONTINUE
00299
00300 WNORM = SLANGE( '1', N, N, WORK, N, WORK( N**2+1 ) )
00301 END IF
00302
00303 IF( ANORM.GT.WNORM ) THEN
00304 RESULT( 1 ) = ( WNORM / ANORM ) / ( N*ULP )
00305 ELSE
00306 IF( ANORM.LT.ONE ) THEN
00307 RESULT( 1 ) = ( MIN( WNORM, N*ANORM ) / ANORM ) / ( N*ULP )
00308 ELSE
00309 RESULT( 1 ) = MIN( WNORM / ANORM, REAL( N ) ) / ( N*ULP )
00310 END IF
00311 END IF
00312
00313
00314
00315
00316
00317 IF( ITYPE.EQ.1 ) THEN
00318 CALL SGEMM( 'N', 'C', N, N, N, ONE, U, LDU, U, LDU, ZERO, WORK,
00319 $ N )
00320
00321 DO 110 J = 1, N
00322 WORK( ( N+1 )*( J-1 )+1 ) = WORK( ( N+1 )*( J-1 )+1 ) - ONE
00323 110 CONTINUE
00324
00325 RESULT( 2 ) = MIN( SLANGE( '1', N, N, WORK, N,
00326 $ WORK( N**2+1 ) ), REAL( N ) ) / ( N*ULP )
00327 END IF
00328
00329 RETURN
00330
00331
00332
00333 END