126
127
128
129
130
131
132 CHARACTER UPLO
133 INTEGER INFO, ITYPE, LDA, LDB, N
134
135
136 COMPLEX A( LDA, * ), B( LDB, * )
137
138
139
140
141
142 REAL ONE
143 parameter( one = 1.0e+0 )
144 COMPLEX CONE, HALF
145 parameter( cone = ( 1.0e+0, 0.0e+0 ),
146 $ half = ( 0.5e+0, 0.0e+0 ) )
147
148
149 LOGICAL UPPER
150 INTEGER K, KB, NB
151
152
155
156
157 INTRINSIC max, min
158
159
160 LOGICAL LSAME
161 INTEGER ILAENV
163
164
165
166
167
168 info = 0
169 upper =
lsame( uplo,
'U' )
170 IF( itype.LT.1 .OR. itype.GT.3 ) THEN
171 info = -1
172 ELSE IF( .NOT.upper .AND. .NOT.
lsame( uplo,
'L' ) )
THEN
173 info = -2
174 ELSE IF( n.LT.0 ) THEN
175 info = -3
176 ELSE IF( lda.LT.max( 1, n ) ) THEN
177 info = -5
178 ELSE IF( ldb.LT.max( 1, n ) ) THEN
179 info = -7
180 END IF
181 IF( info.NE.0 ) THEN
182 CALL xerbla(
'CHEGST', -info )
183 RETURN
184 END IF
185
186
187
188 IF( n.EQ.0 )
189 $ RETURN
190
191
192
193 nb =
ilaenv( 1,
'CHEGST', uplo, n, -1, -1, -1 )
194
195 IF( nb.LE.1 .OR. nb.GE.n ) THEN
196
197
198
199 CALL chegs2( itype, uplo, n, a, lda, b, ldb, info )
200 ELSE
201
202
203
204 IF( itype.EQ.1 ) THEN
205 IF( upper ) THEN
206
207
208
209 DO 10 k = 1, n, nb
210 kb = min( n-k+1, nb )
211
212
213
214 CALL chegs2( itype, uplo, kb, a( k, k ), lda,
215 $ b( k, k ), ldb, info )
216 IF( k+kb.LE.n ) THEN
217 CALL ctrsm(
'Left', uplo,
'Conjugate transpose',
218 $ 'Non-unit', kb, n-k-kb+1, cone,
219 $ b( k, k ), ldb, a( k, k+kb ), lda )
220 CALL chemm(
'Left', uplo, kb, n-k-kb+1, -half,
221 $ a( k, k ), lda, b( k, k+kb ), ldb,
222 $ cone, a( k, k+kb ), lda )
223 CALL cher2k( uplo,
'Conjugate transpose',
224 $ n-k-kb+1,
225 $ kb, -cone, a( k, k+kb ), lda,
226 $ b( k, k+kb ), ldb, one,
227 $ a( k+kb, k+kb ), lda )
228 CALL chemm(
'Left', uplo, kb, n-k-kb+1, -half,
229 $ a( k, k ), lda, b( k, k+kb ), ldb,
230 $ cone, a( k, k+kb ), lda )
231 CALL ctrsm(
'Right', uplo,
'No transpose',
232 $ 'Non-unit', kb, n-k-kb+1, cone,
233 $ b( k+kb, k+kb ), ldb, a( k, k+kb ),
234 $ lda )
235 END IF
236 10 CONTINUE
237 ELSE
238
239
240
241 DO 20 k = 1, n, nb
242 kb = min( n-k+1, nb )
243
244
245
246 CALL chegs2( itype, uplo, kb, a( k, k ), lda,
247 $ b( k, k ), ldb, info )
248 IF( k+kb.LE.n ) THEN
249 CALL ctrsm(
'Right', uplo,
250 $ 'Conjugate transpose',
251 $ 'Non-unit', n-k-kb+1, kb, cone,
252 $ b( k, k ), ldb, a( k+kb, k ), lda )
253 CALL chemm(
'Right', uplo, n-k-kb+1, kb, -half,
254 $ a( k, k ), lda, b( k+kb, k ), ldb,
255 $ cone, a( k+kb, k ), lda )
256 CALL cher2k( uplo,
'No transpose', n-k-kb+1, kb,
257 $ -cone, a( k+kb, k ), lda,
258 $ b( k+kb, k ), ldb, one,
259 $ a( k+kb, k+kb ), lda )
260 CALL chemm(
'Right', uplo, n-k-kb+1, kb, -half,
261 $ a( k, k ), lda, b( k+kb, k ), ldb,
262 $ cone, a( k+kb, k ), lda )
263 CALL ctrsm(
'Left', uplo,
'No transpose',
264 $ 'Non-unit', n-k-kb+1, kb, cone,
265 $ b( k+kb, k+kb ), ldb, a( k+kb, k ),
266 $ lda )
267 END IF
268 20 CONTINUE
269 END IF
270 ELSE
271 IF( upper ) THEN
272
273
274
275 DO 30 k = 1, n, nb
276 kb = min( n-k+1, nb )
277
278
279
280 CALL ctrmm(
'Left', uplo,
'No transpose',
281 $ 'Non-unit',
282 $ k-1, kb, cone, b, ldb, a( 1, k ), lda )
283 CALL chemm(
'Right', uplo, k-1, kb, half, a( k,
284 $ k ),
285 $ lda, b( 1, k ), ldb, cone, a( 1, k ),
286 $ lda )
287 CALL cher2k( uplo,
'No transpose', k-1, kb, cone,
288 $ a( 1, k ), lda, b( 1, k ), ldb, one, a,
289 $ lda )
290 CALL chemm(
'Right', uplo, k-1, kb, half, a( k,
291 $ k ),
292 $ lda, b( 1, k ), ldb, cone, a( 1, k ),
293 $ lda )
294 CALL ctrmm(
'Right', uplo,
'Conjugate transpose',
295 $ 'Non-unit', k-1, kb, cone, b( k, k ), ldb,
296 $ a( 1, k ), lda )
297 CALL chegs2( itype, uplo, kb, a( k, k ), lda,
298 $ b( k, k ), ldb, info )
299 30 CONTINUE
300 ELSE
301
302
303
304 DO 40 k = 1, n, nb
305 kb = min( n-k+1, nb )
306
307
308
309 CALL ctrmm(
'Right', uplo,
'No transpose',
310 $ 'Non-unit',
311 $ kb, k-1, cone, b, ldb, a( k, 1 ), lda )
312 CALL chemm(
'Left', uplo, kb, k-1, half, a( k, k ),
313 $ lda, b( k, 1 ), ldb, cone, a( k, 1 ),
314 $ lda )
315 CALL cher2k( uplo,
'Conjugate transpose', k-1, kb,
316 $ cone, a( k, 1 ), lda, b( k, 1 ), ldb,
317 $ one, a, lda )
318 CALL chemm(
'Left', uplo, kb, k-1, half, a( k, k ),
319 $ lda, b( k, 1 ), ldb, cone, a( k, 1 ),
320 $ lda )
321 CALL ctrmm(
'Left', uplo,
'Conjugate transpose',
322 $ 'Non-unit', kb, k-1, cone, b( k, k ), ldb,
323 $ a( k, 1 ), lda )
324 CALL chegs2( itype, uplo, kb, a( k, k ), lda,
325 $ b( k, k ), ldb, info )
326 40 CONTINUE
327 END IF
328 END IF
329 END IF
330 RETURN
331
332
333
subroutine xerbla(srname, info)
subroutine chegs2(itype, uplo, n, a, lda, b, ldb, info)
CHEGS2 reduces a Hermitian definite generalized eigenproblem to standard form, using the factorizatio...
subroutine chemm(side, uplo, m, n, alpha, a, lda, b, ldb, beta, c, ldc)
CHEMM
subroutine cher2k(uplo, trans, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
CHER2K
integer function ilaenv(ispec, name, opts, n1, n2, n3, n4)
ILAENV
logical function lsame(ca, cb)
LSAME
subroutine ctrmm(side, uplo, transa, diag, m, n, alpha, a, lda, b, ldb)
CTRMM
subroutine ctrsm(side, uplo, transa, diag, m, n, alpha, a, lda, b, ldb)
CTRSM