155
156
157
158
159
160
161 CHARACTER DIAG, TRANS, UPLO
162 INTEGER INFO, LDA, LDB, N, NRHS
163
164
165 INTEGER IPIV( * )
166 REAL A( LDA, * ), B( LDB, * )
167
168
169
170
171
172 REAL ONE
173 parameter( one = 1.0e+0 )
174
175
176 LOGICAL NOUNIT
177 INTEGER J, K, KP
178 REAL D11, D12, D21, D22, T1, T2
179
180
181 LOGICAL LSAME
183
184
186
187
188 INTRINSIC abs, max
189
190
191
192
193
194 info = 0
195 IF( .NOT.
lsame( uplo,
'U' ) .AND. .NOT.
lsame( uplo,
'L' ) )
THEN
196 info = -1
197 ELSE IF( .NOT.
lsame( trans,
'N' ) .AND. .NOT.
198 $
lsame( trans,
'T' ) .AND. .NOT.
lsame( trans,
'C' ) )
THEN
199 info = -2
200 ELSE IF( .NOT.
lsame( diag,
'U' ) .AND. .NOT.
lsame( diag,
'N' ) )
201 $ THEN
202 info = -3
203 ELSE IF( n.LT.0 ) THEN
204 info = -4
205 ELSE IF( lda.LT.max( 1, n ) ) THEN
206 info = -6
207 ELSE IF( ldb.LT.max( 1, n ) ) THEN
208 info = -9
209 END IF
210 IF( info.NE.0 ) THEN
211 CALL xerbla(
'SLAVSY ', -info )
212 RETURN
213 END IF
214
215
216
217 IF( n.EQ.0 )
218 $ RETURN
219
220 nounit =
lsame( diag,
'N' )
221
222
223
224
225
226 IF(
lsame( trans,
'N' ) )
THEN
227
228
229
230
231 IF(
lsame( uplo,
'U' ) )
THEN
232
233
234
235 k = 1
236 10 CONTINUE
237 IF( k.GT.n )
238 $ GO TO 30
239 IF( ipiv( k ).GT.0 ) THEN
240
241
242
243
244
245 IF( nounit )
246 $
CALL sscal( nrhs, a( k, k ), b( k, 1 ), ldb )
247
248
249
250 IF( k.GT.1 ) THEN
251
252
253
254 CALL sger( k-1, nrhs, one, a( 1, k ), 1, b( k, 1 ),
255 $ ldb, b( 1, 1 ), ldb )
256
257
258
259 kp = ipiv( k )
260 IF( kp.NE.k )
261 $
CALL sswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
262 END IF
263 k = k + 1
264 ELSE
265
266
267
268
269
270 IF( nounit ) THEN
271 d11 = a( k, k )
272 d22 = a( k+1, k+1 )
273 d12 = a( k, k+1 )
274 d21 = d12
275 DO 20 j = 1, nrhs
276 t1 = b( k, j )
277 t2 = b( k+1, j )
278 b( k, j ) = d11*t1 + d12*t2
279 b( k+1, j ) = d21*t1 + d22*t2
280 20 CONTINUE
281 END IF
282
283
284
285 IF( k.GT.1 ) THEN
286
287
288
289 CALL sger( k-1, nrhs, one, a( 1, k ), 1, b( k, 1 ),
290 $ ldb, b( 1, 1 ), ldb )
291 CALL sger( k-1, nrhs, one, a( 1, k+1 ), 1,
292 $ b( k+1, 1 ), ldb, b( 1, 1 ), ldb )
293
294
295
296 kp = abs( ipiv( k ) )
297 IF( kp.NE.k )
298 $
CALL sswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
299 END IF
300 k = k + 2
301 END IF
302 GO TO 10
303 30 CONTINUE
304
305
306
307
308 ELSE
309
310
311
312 k = n
313 40 CONTINUE
314 IF( k.LT.1 )
315 $ GO TO 60
316
317
318
319
320 IF( ipiv( k ).GT.0 ) THEN
321
322
323
324
325
326 IF( nounit )
327 $
CALL sscal( nrhs, a( k, k ), b( k, 1 ), ldb )
328
329
330
331 IF( k.NE.n ) THEN
332 kp = ipiv( k )
333
334
335
336 CALL sger( n-k, nrhs, one, a( k+1, k ), 1, b( k, 1 ),
337 $ ldb, b( k+1, 1 ), ldb )
338
339
340
341
342 IF( kp.NE.k )
343 $
CALL sswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
344 END IF
345 k = k - 1
346
347 ELSE
348
349
350
351
352
353 IF( nounit ) THEN
354 d11 = a( k-1, k-1 )
355 d22 = a( k, k )
356 d21 = a( k, k-1 )
357 d12 = d21
358 DO 50 j = 1, nrhs
359 t1 = b( k-1, j )
360 t2 = b( k, j )
361 b( k-1, j ) = d11*t1 + d12*t2
362 b( k, j ) = d21*t1 + d22*t2
363 50 CONTINUE
364 END IF
365
366
367
368 IF( k.NE.n ) THEN
369
370
371
372 CALL sger( n-k, nrhs, one, a( k+1, k ), 1, b( k, 1 ),
373 $ ldb, b( k+1, 1 ), ldb )
374 CALL sger( n-k, nrhs, one, a( k+1, k-1 ), 1,
375 $ b( k-1, 1 ), ldb, b( k+1, 1 ), ldb )
376
377
378
379
380 kp = abs( ipiv( k ) )
381 IF( kp.NE.k )
382 $
CALL sswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
383 END IF
384 k = k - 2
385 END IF
386 GO TO 40
387 60 CONTINUE
388 END IF
389
390
391
392
393
394 ELSE
395
396
397
398
399
400 IF(
lsame( uplo,
'U' ) )
THEN
401
402
403
404 k = n
405 70 CONTINUE
406 IF( k.LT.1 )
407 $ GO TO 90
408
409
410
411 IF( ipiv( k ).GT.0 ) THEN
412 IF( k.GT.1 ) THEN
413
414
415
416 kp = ipiv( k )
417 IF( kp.NE.k )
418 $
CALL sswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
419
420
421
422 CALL sgemv(
'Transpose', k-1, nrhs, one, b, ldb,
423 $ a( 1, k ), 1, one, b( k, 1 ), ldb )
424 END IF
425 IF( nounit )
426 $
CALL sscal( nrhs, a( k, k ), b( k, 1 ), ldb )
427 k = k - 1
428
429
430
431 ELSE
432 IF( k.GT.2 ) THEN
433
434
435
436 kp = abs( ipiv( k ) )
437 IF( kp.NE.k-1 )
438 $
CALL sswap( nrhs, b( k-1, 1 ), ldb, b( kp, 1 ),
439 $ ldb )
440
441
442
443 CALL sgemv(
'Transpose', k-2, nrhs, one, b, ldb,
444 $ a( 1, k ), 1, one, b( k, 1 ), ldb )
445 CALL sgemv(
'Transpose', k-2, nrhs, one, b, ldb,
446 $ a( 1, k-1 ), 1, one, b( k-1, 1 ), ldb )
447 END IF
448
449
450
451 IF( nounit ) THEN
452 d11 = a( k-1, k-1 )
453 d22 = a( k, k )
454 d12 = a( k-1, k )
455 d21 = d12
456 DO 80 j = 1, nrhs
457 t1 = b( k-1, j )
458 t2 = b( k, j )
459 b( k-1, j ) = d11*t1 + d12*t2
460 b( k, j ) = d21*t1 + d22*t2
461 80 CONTINUE
462 END IF
463 k = k - 2
464 END IF
465 GO TO 70
466 90 CONTINUE
467
468
469
470
471
472 ELSE
473
474
475
476 k = 1
477 100 CONTINUE
478 IF( k.GT.n )
479 $ GO TO 120
480
481
482
483 IF( ipiv( k ).GT.0 ) THEN
484 IF( k.LT.n ) THEN
485
486
487
488 kp = ipiv( k )
489 IF( kp.NE.k )
490 $
CALL sswap( nrhs, b( k, 1 ), ldb, b( kp, 1 ), ldb )
491
492
493
494 CALL sgemv(
'Transpose', n-k, nrhs, one, b( k+1, 1 ),
495 $ ldb, a( k+1, k ), 1, one, b( k, 1 ), ldb )
496 END IF
497 IF( nounit )
498 $
CALL sscal( nrhs, a( k, k ), b( k, 1 ), ldb )
499 k = k + 1
500
501
502
503 ELSE
504 IF( k.LT.n-1 ) THEN
505
506
507
508 kp = abs( ipiv( k ) )
509 IF( kp.NE.k+1 )
510 $
CALL sswap( nrhs, b( k+1, 1 ), ldb, b( kp, 1 ),
511 $ ldb )
512
513
514
515 CALL sgemv(
'Transpose', n-k-1, nrhs, one,
516 $ b( k+2, 1 ), ldb, a( k+2, k+1 ), 1, one,
517 $ b( k+1, 1 ), ldb )
518 CALL sgemv(
'Transpose', n-k-1, nrhs, one,
519 $ b( k+2, 1 ), ldb, a( k+2, k ), 1, one,
520 $ b( k, 1 ), ldb )
521 END IF
522
523
524
525 IF( nounit ) THEN
526 d11 = a( k, k )
527 d22 = a( k+1, k+1 )
528 d21 = a( k+1, k )
529 d12 = d21
530 DO 110 j = 1, nrhs
531 t1 = b( k, j )
532 t2 = b( k+1, j )
533 b( k, j ) = d11*t1 + d12*t2
534 b( k+1, j ) = d21*t1 + d22*t2
535 110 CONTINUE
536 END IF
537 k = k + 2
538 END IF
539 GO TO 100
540 120 CONTINUE
541 END IF
542
543 END IF
544 RETURN
545
546
547
subroutine xerbla(srname, info)
subroutine sgemv(trans, m, n, alpha, a, lda, x, incx, beta, y, incy)
SGEMV
subroutine sger(m, n, alpha, x, incx, y, incy, a, lda)
SGER
logical function lsame(ca, cb)
LSAME
subroutine sscal(n, sa, sx, incx)
SSCAL
subroutine sswap(n, sx, incx, sy, incy)
SSWAP