00001 SUBROUTINE CHEGS2( ITYPE, UPLO, N, A, LDA, B, LDB, INFO )
00002
00003
00004
00005
00006
00007
00008
00009 CHARACTER UPLO
00010 INTEGER INFO, ITYPE, LDA, LDB, N
00011
00012
00013 COMPLEX A( LDA, * ), B( LDB, * )
00014
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 REAL ONE, HALF
00076 PARAMETER ( ONE = 1.0E+0, HALF = 0.5E+0 )
00077 COMPLEX CONE
00078 PARAMETER ( CONE = ( 1.0E+0, 0.0E+0 ) )
00079
00080
00081 LOGICAL UPPER
00082 INTEGER K
00083 REAL AKK, BKK
00084 COMPLEX CT
00085
00086
00087 EXTERNAL CAXPY, CHER2, CLACGV, CSSCAL, CTRMV, CTRSV,
00088 $ XERBLA
00089
00090
00091 INTRINSIC MAX
00092
00093
00094 LOGICAL LSAME
00095 EXTERNAL LSAME
00096
00097
00098
00099
00100
00101 INFO = 0
00102 UPPER = LSAME( UPLO, 'U' )
00103 IF( ITYPE.LT.1 .OR. ITYPE.GT.3 ) THEN
00104 INFO = -1
00105 ELSE IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
00106 INFO = -2
00107 ELSE IF( N.LT.0 ) THEN
00108 INFO = -3
00109 ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
00110 INFO = -5
00111 ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
00112 INFO = -7
00113 END IF
00114 IF( INFO.NE.0 ) THEN
00115 CALL XERBLA( 'CHEGS2', -INFO )
00116 RETURN
00117 END IF
00118
00119 IF( ITYPE.EQ.1 ) THEN
00120 IF( UPPER ) THEN
00121
00122
00123
00124 DO 10 K = 1, N
00125
00126
00127
00128 AKK = A( K, K )
00129 BKK = B( K, K )
00130 AKK = AKK / BKK**2
00131 A( K, K ) = AKK
00132 IF( K.LT.N ) THEN
00133 CALL CSSCAL( N-K, ONE / BKK, A( K, K+1 ), LDA )
00134 CT = -HALF*AKK
00135 CALL CLACGV( N-K, A( K, K+1 ), LDA )
00136 CALL CLACGV( N-K, B( K, K+1 ), LDB )
00137 CALL CAXPY( N-K, CT, B( K, K+1 ), LDB, A( K, K+1 ),
00138 $ LDA )
00139 CALL CHER2( UPLO, N-K, -CONE, A( K, K+1 ), LDA,
00140 $ B( K, K+1 ), LDB, A( K+1, K+1 ), LDA )
00141 CALL CAXPY( N-K, CT, B( K, K+1 ), LDB, A( K, K+1 ),
00142 $ LDA )
00143 CALL CLACGV( N-K, B( K, K+1 ), LDB )
00144 CALL CTRSV( UPLO, 'Conjugate transpose', 'Non-unit',
00145 $ N-K, B( K+1, K+1 ), LDB, A( K, K+1 ),
00146 $ LDA )
00147 CALL CLACGV( N-K, A( K, K+1 ), LDA )
00148 END IF
00149 10 CONTINUE
00150 ELSE
00151
00152
00153
00154 DO 20 K = 1, N
00155
00156
00157
00158 AKK = A( K, K )
00159 BKK = B( K, K )
00160 AKK = AKK / BKK**2
00161 A( K, K ) = AKK
00162 IF( K.LT.N ) THEN
00163 CALL CSSCAL( N-K, ONE / BKK, A( K+1, K ), 1 )
00164 CT = -HALF*AKK
00165 CALL CAXPY( N-K, CT, B( K+1, K ), 1, A( K+1, K ), 1 )
00166 CALL CHER2( UPLO, N-K, -CONE, A( K+1, K ), 1,
00167 $ B( K+1, K ), 1, A( K+1, K+1 ), LDA )
00168 CALL CAXPY( N-K, CT, B( K+1, K ), 1, A( K+1, K ), 1 )
00169 CALL CTRSV( UPLO, 'No transpose', 'Non-unit', N-K,
00170 $ B( K+1, K+1 ), LDB, A( K+1, K ), 1 )
00171 END IF
00172 20 CONTINUE
00173 END IF
00174 ELSE
00175 IF( UPPER ) THEN
00176
00177
00178
00179 DO 30 K = 1, N
00180
00181
00182
00183 AKK = A( K, K )
00184 BKK = B( K, K )
00185 CALL CTRMV( UPLO, 'No transpose', 'Non-unit', K-1, B,
00186 $ LDB, A( 1, K ), 1 )
00187 CT = HALF*AKK
00188 CALL CAXPY( K-1, CT, B( 1, K ), 1, A( 1, K ), 1 )
00189 CALL CHER2( UPLO, K-1, CONE, A( 1, K ), 1, B( 1, K ), 1,
00190 $ A, LDA )
00191 CALL CAXPY( K-1, CT, B( 1, K ), 1, A( 1, K ), 1 )
00192 CALL CSSCAL( K-1, BKK, A( 1, K ), 1 )
00193 A( K, K ) = AKK*BKK**2
00194 30 CONTINUE
00195 ELSE
00196
00197
00198
00199 DO 40 K = 1, N
00200
00201
00202
00203 AKK = A( K, K )
00204 BKK = B( K, K )
00205 CALL CLACGV( K-1, A( K, 1 ), LDA )
00206 CALL CTRMV( UPLO, 'Conjugate transpose', 'Non-unit', K-1,
00207 $ B, LDB, A( K, 1 ), LDA )
00208 CT = HALF*AKK
00209 CALL CLACGV( K-1, B( K, 1 ), LDB )
00210 CALL CAXPY( K-1, CT, B( K, 1 ), LDB, A( K, 1 ), LDA )
00211 CALL CHER2( UPLO, K-1, CONE, A( K, 1 ), LDA, B( K, 1 ),
00212 $ LDB, A, LDA )
00213 CALL CAXPY( K-1, CT, B( K, 1 ), LDB, A( K, 1 ), LDA )
00214 CALL CLACGV( K-1, B( K, 1 ), LDB )
00215 CALL CSSCAL( K-1, BKK, A( K, 1 ), LDA )
00216 CALL CLACGV( K-1, A( K, 1 ), LDA )
00217 A( K, K ) = AKK*BKK**2
00218 40 CONTINUE
00219 END IF
00220 END IF
00221 RETURN
00222
00223
00224
00225 END