197
198
199
200
201
202
203 CHARACTER DIRECT, SIDE, STOREV, TRANS
204 INTEGER K, LDC, LDT, LDV, LDWORK, M, N
205
206
207 DOUBLE PRECISION C( LDC, * ), T( LDT, * ), V( LDV, * ),
208 $ WORK( LDWORK, * )
209
210
211
212
213
214 DOUBLE PRECISION ONE
215 parameter( one = 1.0d+0 )
216
217
218 CHARACTER TRANST
219 INTEGER I, J
220
221
222 LOGICAL LSAME
224
225
227
228
229
230
231
232 IF( m.LE.0 .OR. n.LE.0 )
233 $ RETURN
234
235 IF(
lsame( trans,
'N' ) )
THEN
236 transt = 'T'
237 ELSE
238 transt = 'N'
239 END IF
240
241 IF(
lsame( storev,
'C' ) )
THEN
242
243 IF(
lsame( direct,
'F' ) )
THEN
244
245
246
247
248
249 IF(
lsame( side,
'L' ) )
THEN
250
251
252
253
254
255
256
257
258 DO 10 j = 1, k
259 CALL dcopy( n, c( j, 1 ), ldc, work( 1, j ), 1 )
260 10 CONTINUE
261
262
263
264 CALL dtrmm(
'Right',
'Lower',
'No transpose',
'Unit', n,
265 $ k, one, v, ldv, work, ldwork )
266 IF( m.GT.k ) THEN
267
268
269
270 CALL dgemm(
'Transpose',
'No transpose', n, k, m-k,
271 $ one, c( k+1, 1 ), ldc, v( k+1, 1 ), ldv,
272 $ one, work, ldwork )
273 END IF
274
275
276
277 CALL dtrmm(
'Right',
'Upper', transt,
'Non-unit', n, k,
278 $ one, t, ldt, work, ldwork )
279
280
281
282 IF( m.GT.k ) THEN
283
284
285
286 CALL dgemm(
'No transpose',
'Transpose', m-k, n, k,
287 $ -one, v( k+1, 1 ), ldv, work, ldwork, one,
288 $ c( k+1, 1 ), ldc )
289 END IF
290
291
292
293 CALL dtrmm(
'Right',
'Lower',
'Transpose',
'Unit', n, k,
294 $ one, v, ldv, work, ldwork )
295
296
297
298 DO 30 j = 1, k
299 DO 20 i = 1, n
300 c( j, i ) = c( j, i ) - work( i, j )
301 20 CONTINUE
302 30 CONTINUE
303
304 ELSE IF(
lsame( side,
'R' ) )
THEN
305
306
307
308
309
310
311
312 DO 40 j = 1, k
313 CALL dcopy( m, c( 1, j ), 1, work( 1, j ), 1 )
314 40 CONTINUE
315
316
317
318 CALL dtrmm(
'Right',
'Lower',
'No transpose',
'Unit', m,
319 $ k, one, v, ldv, work, ldwork )
320 IF( n.GT.k ) THEN
321
322
323
324 CALL dgemm(
'No transpose',
'No transpose', m, k, n-k,
325 $ one, c( 1, k+1 ), ldc, v( k+1, 1 ), ldv,
326 $ one, work, ldwork )
327 END IF
328
329
330
331 CALL dtrmm(
'Right',
'Upper', trans,
'Non-unit', m, k,
332 $ one, t, ldt, work, ldwork )
333
334
335
336 IF( n.GT.k ) THEN
337
338
339
340 CALL dgemm(
'No transpose',
'Transpose', m, n-k, k,
341 $ -one, work, ldwork, v( k+1, 1 ), ldv, one,
342 $ c( 1, k+1 ), ldc )
343 END IF
344
345
346
347 CALL dtrmm(
'Right',
'Lower',
'Transpose',
'Unit', m, k,
348 $ one, v, ldv, work, ldwork )
349
350
351
352 DO 60 j = 1, k
353 DO 50 i = 1, m
354 c( i, j ) = c( i, j ) - work( i, j )
355 50 CONTINUE
356 60 CONTINUE
357 END IF
358
359 ELSE
360
361
362
363
364
365 IF(
lsame( side,
'L' ) )
THEN
366
367
368
369
370
371
372
373
374 DO 70 j = 1, k
375 CALL dcopy( n, c( m-k+j, 1 ), ldc, work( 1, j ), 1 )
376 70 CONTINUE
377
378
379
380 CALL dtrmm(
'Right',
'Upper',
'No transpose',
'Unit', n,
381 $ k, one, v( m-k+1, 1 ), ldv, work, ldwork )
382 IF( m.GT.k ) THEN
383
384
385
386 CALL dgemm(
'Transpose',
'No transpose', n, k, m-k,
387 $ one, c, ldc, v, ldv, one, work, ldwork )
388 END IF
389
390
391
392 CALL dtrmm(
'Right',
'Lower', transt,
'Non-unit', n, k,
393 $ one, t, ldt, work, ldwork )
394
395
396
397 IF( m.GT.k ) THEN
398
399
400
401 CALL dgemm(
'No transpose',
'Transpose', m-k, n, k,
402 $ -one, v, ldv, work, ldwork, one, c, ldc )
403 END IF
404
405
406
407 CALL dtrmm(
'Right',
'Upper',
'Transpose',
'Unit', n, k,
408 $ one, v( m-k+1, 1 ), ldv, work, ldwork )
409
410
411
412 DO 90 j = 1, k
413 DO 80 i = 1, n
414 c( m-k+j, i ) = c( m-k+j, i ) - work( i, j )
415 80 CONTINUE
416 90 CONTINUE
417
418 ELSE IF(
lsame( side,
'R' ) )
THEN
419
420
421
422
423
424
425
426 DO 100 j = 1, k
427 CALL dcopy( m, c( 1, n-k+j ), 1, work( 1, j ), 1 )
428 100 CONTINUE
429
430
431
432 CALL dtrmm(
'Right',
'Upper',
'No transpose',
'Unit', m,
433 $ k, one, v( n-k+1, 1 ), ldv, work, ldwork )
434 IF( n.GT.k ) THEN
435
436
437
438 CALL dgemm(
'No transpose',
'No transpose', m, k, n-k,
439 $ one, c, ldc, v, ldv, one, work, ldwork )
440 END IF
441
442
443
444 CALL dtrmm(
'Right',
'Lower', trans,
'Non-unit', m, k,
445 $ one, t, ldt, work, ldwork )
446
447
448
449 IF( n.GT.k ) THEN
450
451
452
453 CALL dgemm(
'No transpose',
'Transpose', m, n-k, k,
454 $ -one, work, ldwork, v, ldv, one, c, ldc )
455 END IF
456
457
458
459 CALL dtrmm(
'Right',
'Upper',
'Transpose',
'Unit', m, k,
460 $ one, v( n-k+1, 1 ), ldv, work, ldwork )
461
462
463
464 DO 120 j = 1, k
465 DO 110 i = 1, m
466 c( i, n-k+j ) = c( i, n-k+j ) - work( i, j )
467 110 CONTINUE
468 120 CONTINUE
469 END IF
470 END IF
471
472 ELSE IF(
lsame( storev,
'R' ) )
THEN
473
474 IF(
lsame( direct,
'F' ) )
THEN
475
476
477
478
479 IF(
lsame( side,
'L' ) )
THEN
480
481
482
483
484
485
486
487
488 DO 130 j = 1, k
489 CALL dcopy( n, c( j, 1 ), ldc, work( 1, j ), 1 )
490 130 CONTINUE
491
492
493
494 CALL dtrmm(
'Right',
'Upper',
'Transpose',
'Unit', n, k,
495 $ one, v, ldv, work, ldwork )
496 IF( m.GT.k ) THEN
497
498
499
500 CALL dgemm(
'Transpose',
'Transpose', n, k, m-k, one,
501 $ c( k+1, 1 ), ldc, v( 1, k+1 ), ldv, one,
502 $ work, ldwork )
503 END IF
504
505
506
507 CALL dtrmm(
'Right',
'Upper', transt,
'Non-unit', n, k,
508 $ one, t, ldt, work, ldwork )
509
510
511
512 IF( m.GT.k ) THEN
513
514
515
516 CALL dgemm(
'Transpose',
'Transpose', m-k, n, k, -one,
517 $ v( 1, k+1 ), ldv, work, ldwork, one,
518 $ c( k+1, 1 ), ldc )
519 END IF
520
521
522
523 CALL dtrmm(
'Right',
'Upper',
'No transpose',
'Unit', n,
524 $ k, one, v, ldv, work, ldwork )
525
526
527
528 DO 150 j = 1, k
529 DO 140 i = 1, n
530 c( j, i ) = c( j, i ) - work( i, j )
531 140 CONTINUE
532 150 CONTINUE
533
534 ELSE IF(
lsame( side,
'R' ) )
THEN
535
536
537
538
539
540
541
542 DO 160 j = 1, k
543 CALL dcopy( m, c( 1, j ), 1, work( 1, j ), 1 )
544 160 CONTINUE
545
546
547
548 CALL dtrmm(
'Right',
'Upper',
'Transpose',
'Unit', m, k,
549 $ one, v, ldv, work, ldwork )
550 IF( n.GT.k ) THEN
551
552
553
554 CALL dgemm(
'No transpose',
'Transpose', m, k, n-k,
555 $ one, c( 1, k+1 ), ldc, v( 1, k+1 ), ldv,
556 $ one, work, ldwork )
557 END IF
558
559
560
561 CALL dtrmm(
'Right',
'Upper', trans,
'Non-unit', m, k,
562 $ one, t, ldt, work, ldwork )
563
564
565
566 IF( n.GT.k ) THEN
567
568
569
570 CALL dgemm(
'No transpose',
'No transpose', m, n-k, k,
571 $ -one, work, ldwork, v( 1, k+1 ), ldv, one,
572 $ c( 1, k+1 ), ldc )
573 END IF
574
575
576
577 CALL dtrmm(
'Right',
'Upper',
'No transpose',
'Unit', m,
578 $ k, one, v, ldv, work, ldwork )
579
580
581
582 DO 180 j = 1, k
583 DO 170 i = 1, m
584 c( i, j ) = c( i, j ) - work( i, j )
585 170 CONTINUE
586 180 CONTINUE
587
588 END IF
589
590 ELSE
591
592
593
594
595 IF(
lsame( side,
'L' ) )
THEN
596
597
598
599
600
601
602
603
604 DO 190 j = 1, k
605 CALL dcopy( n, c( m-k+j, 1 ), ldc, work( 1, j ), 1 )
606 190 CONTINUE
607
608
609
610 CALL dtrmm(
'Right',
'Lower',
'Transpose',
'Unit', n, k,
611 $ one, v( 1, m-k+1 ), ldv, work, ldwork )
612 IF( m.GT.k ) THEN
613
614
615
616 CALL dgemm(
'Transpose',
'Transpose', n, k, m-k, one,
617 $ c, ldc, v, ldv, one, work, ldwork )
618 END IF
619
620
621
622 CALL dtrmm(
'Right',
'Lower', transt,
'Non-unit', n, k,
623 $ one, t, ldt, work, ldwork )
624
625
626
627 IF( m.GT.k ) THEN
628
629
630
631 CALL dgemm(
'Transpose',
'Transpose', m-k, n, k, -one,
632 $ v, ldv, work, ldwork, one, c, ldc )
633 END IF
634
635
636
637 CALL dtrmm(
'Right',
'Lower',
'No transpose',
'Unit', n,
638 $ k, one, v( 1, m-k+1 ), ldv, work, ldwork )
639
640
641
642 DO 210 j = 1, k
643 DO 200 i = 1, n
644 c( m-k+j, i ) = c( m-k+j, i ) - work( i, j )
645 200 CONTINUE
646 210 CONTINUE
647
648 ELSE IF(
lsame( side,
'R' ) )
THEN
649
650
651
652
653
654
655
656 DO 220 j = 1, k
657 CALL dcopy( m, c( 1, n-k+j ), 1, work( 1, j ), 1 )
658 220 CONTINUE
659
660
661
662 CALL dtrmm(
'Right',
'Lower',
'Transpose',
'Unit', m, k,
663 $ one, v( 1, n-k+1 ), ldv, work, ldwork )
664 IF( n.GT.k ) THEN
665
666
667
668 CALL dgemm(
'No transpose',
'Transpose', m, k, n-k,
669 $ one, c, ldc, v, ldv, one, work, ldwork )
670 END IF
671
672
673
674 CALL dtrmm(
'Right',
'Lower', trans,
'Non-unit', m, k,
675 $ one, t, ldt, work, ldwork )
676
677
678
679 IF( n.GT.k ) THEN
680
681
682
683 CALL dgemm(
'No transpose',
'No transpose', m, n-k, k,
684 $ -one, work, ldwork, v, ldv, one, c, ldc )
685 END IF
686
687
688
689 CALL dtrmm(
'Right',
'Lower',
'No transpose',
'Unit', m,
690 $ k, one, v( 1, n-k+1 ), ldv, work, ldwork )
691
692
693
694 DO 240 j = 1, k
695 DO 230 i = 1, m
696 c( i, n-k+j ) = c( i, n-k+j ) - work( i, j )
697 230 CONTINUE
698 240 CONTINUE
699
700 END IF
701
702 END IF
703 END IF
704
705 RETURN
706
707
708
subroutine dcopy(n, dx, incx, dy, incy)
DCOPY
subroutine dgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
DGEMM
logical function lsame(ca, cb)
LSAME
subroutine dtrmm(side, uplo, transa, diag, m, n, alpha, a, lda, b, ldb)
DTRMM