142
143
144
145
146
147 IMPLICIT NONE
148
149
150 CHARACTER UPLO
151 INTEGER M, NB, J1, LDA, LDH
152
153
154 INTEGER IPIV( * )
155 REAL A( LDA, * ), H( LDH, * ), WORK( * )
156
157
158
159
160 REAL ZERO, ONE
161 parameter( zero = 0.0e+0, one = 1.0e+0 )
162
163
164 INTEGER J, K, K1, I1, I2, MJ
165 REAL PIV, ALPHA
166
167
168 LOGICAL LSAME
169 INTEGER ISAMAX, ILAENV
171
172
176
177
178 INTRINSIC max
179
180
181
182 j = 1
183
184
185
186
187 k1 = (2-j1)+1
188
189 IF(
lsame( uplo,
'U' ) )
THEN
190
191
192
193
194
195 10 CONTINUE
196 IF ( j.GT.min(m, nb) )
197 $ GO TO 20
198
199
200
201
202
203
204 k = j1+j-1
205 IF( j.EQ.m ) THEN
206
207
208
209 mj = 1
210 ELSE
211 mj = m-j+1
212 END IF
213
214
215
216
217 IF( k.GT.2 ) THEN
218
219
220
221
222
223
224
225 CALL sgemv(
'No transpose', mj, j-k1,
226 $ -one, h( j, k1 ), ldh,
227 $ a( 1, j ), 1,
228 $ one, h( j, j ), 1 )
229 END IF
230
231
232
233 CALL scopy( mj, h( j, j ), 1, work( 1 ), 1 )
234
235 IF( j.GT.k1 ) THEN
236
237
238
239
240 alpha = -a( k-1, j )
241 CALL saxpy( mj, alpha, a( k-2, j ), lda, work( 1 ), 1 )
242 END IF
243
244
245
246 a( k, j ) = work( 1 )
247
248 IF( j.LT.m ) THEN
249
250
251
252
253 IF( k.GT.1 ) THEN
254 alpha = -a( k, j )
255 CALL saxpy( m-j, alpha, a( k-1, j+1 ), lda,
256 $ work( 2 ), 1 )
257 ENDIF
258
259
260
261 i2 =
isamax( m-j, work( 2 ), 1 ) + 1
262 piv = work( i2 )
263
264
265
266 IF( (i2.NE.2) .AND. (piv.NE.0) ) THEN
267
268
269
270 i1 = 2
271 work( i2 ) = work( i1 )
272 work( i1 ) = piv
273
274
275
276 i1 = i1+j-1
277 i2 = i2+j-1
278 CALL sswap( i2-i1-1, a( j1+i1-1, i1+1 ), lda,
279 $ a( j1+i1, i2 ), 1 )
280
281
282
283 IF( i2.LT.m )
284 $
CALL sswap( m-i2, a( j1+i1-1, i2+1 ), lda,
285 $ a( j1+i2-1, i2+1 ), lda )
286
287
288
289 piv = a( i1+j1-1, i1 )
290 a( j1+i1-1, i1 ) = a( j1+i2-1, i2 )
291 a( j1+i2-1, i2 ) = piv
292
293
294
295 CALL sswap( i1-1, h( i1, 1 ), ldh, h( i2, 1 ), ldh )
296 ipiv( i1 ) = i2
297
298 IF( i1.GT.(k1-1) ) THEN
299
300
301
302
303 CALL sswap( i1-k1+1, a( 1, i1 ), 1,
304 $ a( 1, i2 ), 1 )
305 END IF
306 ELSE
307 ipiv( j+1 ) = j+1
308 ENDIF
309
310
311
312 a( k, j+1 ) = work( 2 )
313
314 IF( j.LT.nb ) THEN
315
316
317
318 CALL scopy( m-j, a( k+1, j+1 ), lda,
319 $ h( j+1, j+1 ), 1 )
320 END IF
321
322
323
324
325 IF( j.LT.(m-1) ) THEN
326 IF( a( k, j+1 ).NE.zero ) THEN
327 alpha = one / a( k, j+1 )
328 CALL scopy( m-j-1, work( 3 ), 1, a( k, j+2 ), lda )
329 CALL sscal( m-j-1, alpha, a( k, j+2 ), lda )
330 ELSE
331 CALL slaset(
'Full', 1, m-j-1, zero, zero,
332 $ a( k, j+2 ), lda)
333 END IF
334 END IF
335 END IF
336 j = j + 1
337 GO TO 10
338 20 CONTINUE
339
340 ELSE
341
342
343
344
345
346 30 CONTINUE
347 IF( j.GT.min( m, nb ) )
348 $ GO TO 40
349
350
351
352
353
354
355 k = j1+j-1
356 IF( j.EQ.m ) THEN
357
358
359
360 mj = 1
361 ELSE
362 mj = m-j+1
363 END IF
364
365
366
367
368 IF( k.GT.2 ) THEN
369
370
371
372
373
374
375
376 CALL sgemv(
'No transpose', mj, j-k1,
377 $ -one, h( j, k1 ), ldh,
378 $ a( j, 1 ), lda,
379 $ one, h( j, j ), 1 )
380 END IF
381
382
383
384 CALL scopy( mj, h( j, j ), 1, work( 1 ), 1 )
385
386 IF( j.GT.k1 ) THEN
387
388
389
390
391 alpha = -a( j, k-1 )
392 CALL saxpy( mj, alpha, a( j, k-2 ), 1, work( 1 ), 1 )
393 END IF
394
395
396
397 a( j, k ) = work( 1 )
398
399 IF( j.LT.m ) THEN
400
401
402
403
404 IF( k.GT.1 ) THEN
405 alpha = -a( j, k )
406 CALL saxpy( m-j, alpha, a( j+1, k-1 ), 1,
407 $ work( 2 ), 1 )
408 ENDIF
409
410
411
412 i2 =
isamax( m-j, work( 2 ), 1 ) + 1
413 piv = work( i2 )
414
415
416
417 IF( (i2.NE.2) .AND. (piv.NE.0) ) THEN
418
419
420
421 i1 = 2
422 work( i2 ) = work( i1 )
423 work( i1 ) = piv
424
425
426
427 i1 = i1+j-1
428 i2 = i2+j-1
429 CALL sswap( i2-i1-1, a( i1+1, j1+i1-1 ), 1,
430 $ a( i2, j1+i1 ), lda )
431
432
433
434 IF( i2.LT.m )
435 $
CALL sswap( m-i2, a( i2+1, j1+i1-1 ), 1,
436 $ a( i2+1, j1+i2-1 ), 1 )
437
438
439
440 piv = a( i1, j1+i1-1 )
441 a( i1, j1+i1-1 ) = a( i2, j1+i2-1 )
442 a( i2, j1+i2-1 ) = piv
443
444
445
446 CALL sswap( i1-1, h( i1, 1 ), ldh, h( i2, 1 ), ldh )
447 ipiv( i1 ) = i2
448
449 IF( i1.GT.(k1-1) ) THEN
450
451
452
453
454 CALL sswap( i1-k1+1, a( i1, 1 ), lda,
455 $ a( i2, 1 ), lda )
456 END IF
457 ELSE
458 ipiv( j+1 ) = j+1
459 ENDIF
460
461
462
463 a( j+1, k ) = work( 2 )
464
465 IF( j.LT.nb ) THEN
466
467
468
469 CALL scopy( m-j, a( j+1, k+1 ), 1,
470 $ h( j+1, j+1 ), 1 )
471 END IF
472
473
474
475
476 IF( j.LT.(m-1) ) THEN
477 IF( a( j+1, k ).NE.zero ) THEN
478 alpha = one / a( j+1, k )
479 CALL scopy( m-j-1, work( 3 ), 1, a( j+2, k ), 1 )
480 CALL sscal( m-j-1, alpha, a( j+2, k ), 1 )
481 ELSE
482 CALL slaset(
'Full', m-j-1, 1, zero, zero,
483 $ a( j+2, k ), lda )
484 END IF
485 END IF
486 END IF
487 j = j + 1
488 GO TO 30
489 40 CONTINUE
490 END IF
491 RETURN
492
493
494
subroutine xerbla(srname, info)
subroutine saxpy(n, sa, sx, incx, sy, incy)
SAXPY
subroutine scopy(n, sx, incx, sy, incy)
SCOPY
subroutine sgemv(trans, m, n, alpha, a, lda, x, incx, beta, y, incy)
SGEMV
integer function isamax(n, sx, incx)
ISAMAX
integer function ilaenv(ispec, name, opts, n1, n2, n3, n4)
ILAENV
subroutine slaset(uplo, m, n, alpha, beta, a, lda)
SLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
logical function lsame(ca, cb)
LSAME
subroutine sscal(n, sa, sx, incx)
SSCAL
subroutine sswap(n, sx, incx, sy, incy)
SSWAP