3
4
5
6
7
8
9 CHARACTER UPLO
10 INTEGER IA, INFO, JA, LWORK, N
11
12
13 INTEGER DESCA( * )
14 DOUBLE PRECISION D( * ), E( * )
15 COMPLEX*16 A( * ), TAU( * ), WORK( * )
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402 INTEGER BLOCK_CYCLIC_2D, DLEN_, DTYPE_, CTXT_, M_, N_,
403 $ MB_, NB_, RSRC_, CSRC_, LLD_
404 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
405 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
406 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
407 DOUBLE PRECISION ONE
408 parameter( one = 1.0d0 )
409 COMPLEX*16 Z_ONE, Z_NEGONE, Z_ZERO
410 parameter( z_one = 1.0d0, z_negone = -1.0d0,
411 $ z_zero = 0.0d0 )
412 DOUBLE PRECISION ZERO
413 parameter( zero = 0.0d+0 )
414
415
416
417
418
419
420 LOGICAL BALANCED, INTERLEAVE, TWOGEMMS, UPPER
421 INTEGER ANB, BINDEX, CURCOL, CURROW, I, ICTXT, INDEX,
422 $ INDEXA, INDEXINH, INDEXINV, INH, INHB, INHT,
423 $ INHTB, INTMP, INV, INVB, INVT, INVTB, J, LDA,
424 $ LDV, LDZG, LII, LIIB, LIIP1, LIJ, LIJB, LIJP1,
425 $ LTLIP1, LTNM1, LWMIN, MAXINDEX, MININDEX,
426 $ MYCOL, MYFIRSTROW, MYROW, MYSETNUM, NBZG, NP,
427 $ NPB, NPCOL, NPM0, NPM1, NPROW, NPS, NPSET, NQ,
428 $ NQB, NQM1, NUMROWS, NXTCOL, NXTROW, PBMAX,
429 $ PBMIN, PBSIZE, PNB, ROWSPERPROC
430 DOUBLE PRECISION NORM, SAFMAX, SAFMIN
431 COMPLEX*16 ALPHA, BETA, C, CONJTOPH, CONJTOPV,
432 $ ONEOVERBETA, TOPH, TOPNV, TOPTAU, TOPV
433
434
435
436
437
438
439 INTEGER IDUM1( 1 ), IDUM2( 1 )
440 DOUBLE PRECISION DTMP( 5 )
441 COMPLEX*16 CC( 3 )
442
443
446 $
pxerbla, zgebr2d, zgebs2d, zgemm, zgemv,
447 $ zgerv2d, zgesd2d, zgsum2d, zlamov, zscal,
449
450
451
452 LOGICAL LSAME
453 INTEGER ICEIL, NUMROC, PJLAENV
454 DOUBLE PRECISION DZNRM2, PDLAMCH
456
457
458 INTRINSIC dble, dcmplx, dconjg, dimag, ichar,
max,
min,
459 $ mod, sign, sqrt
460
461
462
463
464
465 IF( block_cyclic_2d*csrc_*ctxt_*dlen_*dtype_*lld_*mb_*m_*nb_*n_*
466 $ rsrc_.LT.0 )RETURN
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488 ictxt = desca( ctxt_ )
489 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
490
491 safmax = sqrt(
pdlamch( ictxt,
'O' ) ) / n
492 safmin = sqrt(
pdlamch( ictxt,
'S' ) )
493
494
495
496 info = 0
497 IF( nprow.EQ.-1 ) THEN
498 info = -( 600+ctxt_ )
499 ELSE
500
501
502
503 pnb =
pjlaenv( ictxt, 2,
'PZHETTRD',
'L', 0, 0, 0, 0 )
504 anb =
pjlaenv( ictxt, 3,
'PZHETTRD',
'L', 0, 0, 0, 0 )
505
506 interleave = (
pjlaenv( ictxt, 4,
'PZHETTRD',
'L', 1, 0, 0,
507 $ 0 ).EQ.1 )
508 twogemms = (
pjlaenv( ictxt, 4,
'PZHETTRD',
'L', 2, 0, 0,
509 $ 0 ).EQ.1 )
510 balanced = (
pjlaenv( ictxt, 4,
'PZHETTRD',
'L', 3, 0, 0,
511 $ 0 ).EQ.1 )
512
513 CALL chk1mat( n, 2, n, 2, ia, ja, desca, 6, info )
514
515
516 upper =
lsame( uplo,
'U' )
517 IF( info.EQ.0 .AND. desca( nb_ ).NE.1 )
518 $ info = 600 + nb_
519 IF( info.EQ.0 ) THEN
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534 nps =
max(
numroc( n, 1, 0, 0, nprow ), 2*anb )
535 lwmin = 2*( anb+1 )*( 4*nps+2 ) + nps
536
537 work( 1 ) = dcmplx( lwmin )
538 IF( .NOT.
lsame( uplo,
'L' ) )
THEN
539 info = -1
540 ELSE IF( ia.NE.1 ) THEN
541 info = -4
542 ELSE IF( ja.NE.1 ) THEN
543 info = -5
544 ELSE IF( nprow.NE.npcol ) THEN
545 info = -( 600+ctxt_ )
546 ELSE IF( desca( dtype_ ).NE.1 ) THEN
547 info = -( 600+dtype_ )
548 ELSE IF( desca( mb_ ).NE.1 ) THEN
549 info = -( 600+mb_ )
550 ELSE IF( desca( nb_ ).NE.1 ) THEN
551 info = -( 600+nb_ )
552 ELSE IF( desca( rsrc_ ).NE.0 ) THEN
553 info = -( 600+rsrc_ )
554 ELSE IF( desca( csrc_ ).NE.0 ) THEN
555 info = -( 600+csrc_ )
556 ELSE IF( lwork.LT.lwmin ) THEN
557 info = -11
558 END IF
559 END IF
560 IF( upper ) THEN
561 idum1( 1 ) = ichar( 'U' )
562 ELSE
563 idum1( 1 ) = ichar( 'L' )
564 END IF
565 idum2( 1 ) = 1
566
567 CALL pchk1mat( n, 2, n, 2, ia, ja, desca, 6, 1, idum1, idum2,
568 $ info )
569 END IF
570
571 IF( info.NE.0 ) THEN
572 CALL pxerbla( ictxt,
'PZHETTRD', -info )
573 RETURN
574 END IF
575
576
577
578 IF( n.EQ.0 )
579 $ RETURN
580
581
582
583
584 np =
numroc( n, 1, myrow, 0, nprow )
585 nq =
numroc( n, 1, mycol, 0, npcol )
586
587 nxtrow = 0
588 nxtcol = 0
589
590 liip1 = 1
591 lijp1 = 1
592 npm1 = np
593 nqm1 = nq
594
595 lda = desca( lld_ )
596 ictxt = desca( ctxt_ )
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615 inh = 1
616
617 IF( interleave ) THEN
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633 ldv = 4*(
max( npm1, nqm1 ) ) + 2
634
635 inh = 1
636
637 inv = inh + ldv / 2
638 invt = inh + ( anb+1 )*ldv
639
640 inht = invt + ldv / 2
641 intmp = invt + ldv*( anb+1 )
642
643 ELSE
644 ldv =
max( npm1, nqm1 )
645
646 inht = inh + ldv*( anb+1 )
647 inv = inht + ldv*( anb+1 )
648
649
650
651
652
653
654
655 invt = inv + ldv*( anb+1 ) + 1
656 intmp = invt + ldv*( 2*anb )
657
658 END IF
659
660 IF( info.NE.0 ) THEN
661 CALL pxerbla( ictxt,
'PZHETTRD', -info )
662 work( 1 ) = dcmplx( lwmin )
663 RETURN
664 END IF
665
666
667
668
669
670
671
672
673
674
675
676
677 DO 10 i = 1, np
678 work( inh+i-1 ) = z_zero
679 work( inv+i-1 ) = z_zero
680 10 CONTINUE
681 DO 20 i = 1, nq
682 work( inht+i-1 ) = z_zero
683 20 CONTINUE
684
685
686
687 topnv = z_zero
688
689 ltlip1 = lijp1
690 ltnm1 = npm1
691 IF( mycol.GT.myrow ) THEN
692 ltlip1 = ltlip1 + 1
693 ltnm1 = ltnm1 - 1
694 END IF
695
696
697 DO 210 minindex = 1, n - 1, anb
698
699
700 maxindex =
min( minindex+anb-1, n )
701 lijb =
numroc( maxindex, 1, mycol, 0, npcol ) + 1
702 liib =
numroc( maxindex, 1, myrow, 0, nprow ) + 1
703
704 nqb = nq - lijb + 1
705 npb = np - liib + 1
706 inhtb = inht + lijb - 1
707 invtb = invt + lijb - 1
708 inhb = inh + liib - 1
709 invb = inv + liib - 1
710
711
712
713
714 DO 160 index = minindex,
min( maxindex, n-1 )
715
716 bindex = index - minindex
717
718 currow = nxtrow
719 curcol = nxtcol
720
721 nxtrow = mod( currow+1, nprow )
722 nxtcol = mod( curcol+1, npcol )
723
724 lii = liip1
725 lij = lijp1
726 npm0 = npm1
727
728 IF( myrow.EQ.currow ) THEN
729 npm1 = npm1 - 1
730 liip1 = liip1 + 1
731 END IF
732 IF( mycol.EQ.curcol ) THEN
733 nqm1 = nqm1 - 1
734 lijp1 = lijp1 + 1
735 ltlip1 = ltlip1 + 1
736 ltnm1 = ltnm1 - 1
737 END IF
738
739
740
741
742
743
744
745
746
747
748 IF( mycol.EQ.curcol ) THEN
749
750 indexa = lii + ( lij-1 )*lda
751 indexinv = inv + lii - 1 + ( bindex-1 )*ldv
752 indexinh = inh + lii - 1 + ( bindex-1 )*ldv
753 conjtoph = dconjg( work( inht+lij-1+bindex*ldv ) )
754 conjtopv = dconjg( topnv )
755
756 IF( index.GT.1 ) THEN
757 DO 30 i = 0, npm0 - 1
758
759 a( indexa+i ) = a( indexa+i ) -
760 $ work( indexinv+ldv+i )*conjtoph -
761 $ work( indexinh+ldv+i )*conjtopv
762 30 CONTINUE
763 END IF
764
765
766 END IF
767
768
769 IF( mycol.EQ.curcol ) THEN
770
771
772
773 IF( myrow.EQ.currow ) THEN
774 dtmp( 2 ) = dble( a( lii+( lij-1 )*lda ) )
775 ELSE
776 dtmp( 2 ) = zero
777 END IF
778 IF( myrow.EQ.nxtrow ) THEN
779 dtmp( 3 ) = dble( a( liip1+( lij-1 )*lda ) )
780 dtmp( 4 ) = dimag( a( liip1+( lij-1 )*lda ) )
781 ELSE
782 dtmp( 3 ) = zero
783 dtmp( 4 ) = zero
784 END IF
785
786 norm = dznrm2( npm1, a( liip1+( lij-1 )*lda ), 1 )
787 dtmp( 1 ) = norm
788
789
790
791
792
793 dtmp( 5 ) = zero
794 IF( dtmp( 1 ).GE.safmax .OR. dtmp( 1 ).LT.safmin ) THEN
795 dtmp( 5 ) = one
796 dtmp( 1 ) = zero
797 END IF
798
799 dtmp( 1 ) = dtmp( 1 )*dtmp( 1 )
800 CALL dgsum2d( ictxt, 'C', ' ', 5, 1, dtmp, 5, -1,
801 $ curcol )
802 IF( dtmp( 5 ).EQ.zero ) THEN
803 dtmp( 1 ) = sqrt( dtmp( 1 ) )
804 ELSE
805 dtmp( 1 ) = norm
806 CALL pdtreecomb( ictxt,
'C', 1, dtmp, -1, mycol,
808 END IF
809
810 norm = dtmp( 1 )
811
812 d( lij ) = dtmp( 2 )
813 IF( myrow.EQ.currow .AND. mycol.EQ.curcol ) THEN
814 a( lii+( lij-1 )*lda ) = dcmplx( d( lij ), zero )
815 END IF
816
817
818 alpha = dcmplx( dtmp( 3 ), dtmp( 4 ) )
819
820 norm = sign( norm, dble( alpha ) )
821
822 IF( norm.EQ.zero ) THEN
823 toptau = zero
824 ELSE
825 beta = norm + alpha
826 toptau = beta / norm
827 oneoverbeta = 1.0d0 / beta
828
829 CALL zscal( npm1, oneoverbeta,
830 $ a( liip1+( lij-1 )*lda ), 1 )
831 END IF
832
833 IF( myrow.EQ.nxtrow ) THEN
834 a( liip1+( lij-1 )*lda ) = z_one
835 END IF
836
837 tau( lij ) = toptau
838 e( lij ) = -norm
839
840 END IF
841
842
843
844
845 DO 40 i = 0, npm1 - 1
846 work( inv+liip1-1+bindex*ldv+npm1+i ) = a( liip1+i+
847 $ ( lij-1 )*lda )
848 40 CONTINUE
849
850 IF( mycol.EQ.curcol ) THEN
851 work( inv+liip1-1+bindex*ldv+npm1+npm1 ) = toptau
852 CALL zgebs2d( ictxt, 'R', ' ', npm1+npm1+1, 1,
853 $ work( inv+liip1-1+bindex*ldv ),
854 $ npm1+npm1+1 )
855 ELSE
856 CALL zgebr2d( ictxt, 'R', ' ', npm1+npm1+1, 1,
857 $ work( inv+liip1-1+bindex*ldv ),
858 $ npm1+npm1+1, myrow, curcol )
859 toptau = work( inv+liip1-1+bindex*ldv+npm1+npm1 )
860 END IF
861 DO 50 i = 0, npm1 - 1
862 work( inh+liip1-1+( bindex+1 )*ldv+i ) = work( inv+liip1-
863 $ 1+bindex*ldv+npm1+i )
864 50 CONTINUE
865
866 IF( index.LT.n ) THEN
867 IF( myrow.EQ.nxtrow .AND. mycol.EQ.curcol )
868 $ a( liip1+( lij-1 )*lda ) = e( lij )
869 END IF
870
871
872
873
874 IF( myrow.EQ.mycol ) THEN
875 DO 60 i = 0, npm1 + npm1
876 work( invt+lijp1-1+bindex*ldv+i ) = work( inv+liip1-1+
877 $ bindex*ldv+i )
878 60 CONTINUE
879 ELSE
880 CALL zgesd2d( ictxt, npm1+npm1, 1,
881 $ work( inv+liip1-1+bindex*ldv ), npm1+npm1,
882 $ mycol, myrow )
883 CALL zgerv2d( ictxt, nqm1+nqm1, 1,
884 $ work( invt+lijp1-1+bindex*ldv ), nqm1+nqm1,
885 $ mycol, myrow )
886 END IF
887
888 DO 70 i = 0, nqm1 - 1
889 work( inht+lijp1-1+( bindex+1 )*ldv+i ) = work( invt+
890 $ lijp1-1+bindex*ldv+nqm1+i )
891 70 CONTINUE
892
893
894
895
896 IF( index.GT.1 ) THEN
897 DO 90 j = lijp1, lijb - 1
898 DO 80 i = 0, npm1 - 1
899
900 a( liip1+i+( j-1 )*lda ) = a( liip1+i+( j-1 )*lda )
901 $ - work( inv+liip1-1+bindex*ldv+i )*
902 $ dconjg( work( inht+j-1+bindex*ldv ) ) -
903 $ work( inh+liip1-1+bindex*ldv+i )*
904 $ dconjg( work( invt+j-1+bindex*ldv ) )
905 80 CONTINUE
906 90 CONTINUE
907 END IF
908
909
910
911
912
913
914
915
916
917
918
919
920
921 work( inv+liip1-1+( bindex+1 )*ldv ) = z_zero
922 work( invt+lijp1-1+( bindex+1 )*ldv+nqm1-1 ) = z_zero
923
924
925 IF( myrow.EQ.mycol ) THEN
926 IF( ltnm1.GT.1 ) THEN
927 CALL ztrmvt(
'L', ltnm1-1,
928 $ a( ltlip1+1+( lijp1-1 )*lda ), lda,
929 $ work( invt+lijp1-1+( bindex+1 )*ldv ), 1,
930 $ work( inh+ltlip1+1-1+( bindex+1 )*ldv ),
931 $ 1, work( inv+ltlip1+1-1+( bindex+1 )*
932 $ ldv ), 1, work( inht+lijp1-1+( bindex+
933 $ 1 )*ldv ), 1 )
934 END IF
935 DO 100 i = 1, ltnm1
936 work( invt+lijp1+i-1-1+( bindex+1 )*ldv )
937 $ = work( invt+lijp1+i-1-1+( bindex+1 )*ldv ) +
938 $ a( ltlip1+i-1+( lijp1+i-1-1 )*lda )*
939 $ work( inh+ltlip1+i-1-1+( bindex+1 )*ldv )
940 100 CONTINUE
941 ELSE
942 IF( ltnm1.GT.0 )
943 $
CALL ztrmvt(
'L', ltnm1, a( ltlip1+( lijp1-1 )*lda ),
944 $ lda, work( invt+lijp1-1+( bindex+1 )*
945 $ ldv ), 1, work( inh+ltlip1-1+( bindex+
946 $ 1 )*ldv ), 1, work( inv+ltlip1-1+
947 $ ( bindex+1 )*ldv ), 1,
948 $ work( inht+lijp1-1+( bindex+1 )*ldv ),
949 $ 1 )
950
951 END IF
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967 DO 110 i = 1, 2*( bindex+1 )
968 work( intmp-1+i ) = 0
969 110 CONTINUE
970
971 IF( balanced ) THEN
972 npset = nprow
973 mysetnum = myrow
974 rowsperproc =
iceil( nqb, npset )
975 myfirstrow =
min( nqb+1, 1+rowsperproc*mysetnum )
976 numrows =
min( rowsperproc, nqb-myfirstrow+1 )
977
978
979
980
981 CALL zgemv( 'C', numrows, bindex+1, z_one,
982 $ work( inhtb+myfirstrow-1 ), ldv,
983 $ work( inhtb+myfirstrow-1+( bindex+1 )*ldv ),
984 $ 1, z_zero, work( intmp ), 1 )
985
986 CALL zgemv( 'C', numrows, bindex+1, z_one,
987 $ work( invtb+myfirstrow-1 ), ldv,
988 $ work( inhtb+myfirstrow-1+( bindex+1 )*ldv ),
989 $ 1, z_zero, work( intmp+bindex+1 ), 1 )
990
991
992 CALL zgsum2d( ictxt, 'C', ' ', 2*( bindex+1 ), 1,
993 $ work( intmp ), 2*( bindex+1 ), -1, -1 )
994 ELSE
995
996
997 CALL zgemv( 'C', nqb, bindex+1, z_one, work( inhtb ),
998 $ ldv, work( inhtb+( bindex+1 )*ldv ), 1,
999 $ z_zero, work( intmp ), 1 )
1000
1001 CALL zgemv( 'C', nqb, bindex+1, z_one, work( invtb ),
1002 $ ldv, work( inhtb+( bindex+1 )*ldv ), 1,
1003 $ z_zero, work( intmp+bindex+1 ), 1 )
1004
1005 END IF
1006
1007
1008
1009 IF( balanced ) THEN
1010 mysetnum = mycol
1011
1012 rowsperproc =
iceil( npb, npset )
1013 myfirstrow =
min( npb+1, 1+rowsperproc*mysetnum )
1014 numrows =
min( rowsperproc, npb-myfirstrow+1 )
1015
1016 CALL zgsum2d( ictxt, 'R', ' ', 2*( bindex+1 ), 1,
1017 $ work( intmp ), 2*( bindex+1 ), -1, -1 )
1018
1019
1020
1021 IF( index.GT.1. ) THEN
1022 CALL zgemv( 'N', numrows, bindex+1, z_negone,
1023 $ work( invb+myfirstrow-1 ), ldv,
1024 $ work( intmp ), 1, z_one,
1025 $ work( invb+myfirstrow-1+( bindex+1 )*
1026 $ ldv ), 1 )
1027
1028
1029 CALL zgemv( 'N', numrows, bindex+1, z_negone,
1030 $ work( inhb+myfirstrow-1 ), ldv,
1031 $ work( intmp+bindex+1 ), 1, z_one,
1032 $ work( invb+myfirstrow-1+( bindex+1 )*
1033 $ ldv ), 1 )
1034 END IF
1035
1036 ELSE
1037
1038 CALL zgemv( 'N', npb, bindex+1, z_negone, work( invb ),
1039 $ ldv, work( intmp ), 1, z_one,
1040 $ work( invb+( bindex+1 )*ldv ), 1 )
1041
1042
1043
1044 CALL zgemv( 'N', npb, bindex+1, z_negone, work( inhb ),
1045 $ ldv, work( intmp+bindex+1 ), 1, z_one,
1046 $ work( invb+( bindex+1 )*ldv ), 1 )
1047
1048 END IF
1049
1050
1051
1052
1053 IF( myrow.EQ.mycol ) THEN
1054 DO 120 i = 0, nqm1 - 1
1055 work( intmp+i ) = work( invt+lijp1-1+( bindex+1 )*ldv+
1056 $ i )
1057 120 CONTINUE
1058 ELSE
1059 CALL zgesd2d( ictxt, nqm1, 1,
1060 $ work( invt+lijp1-1+( bindex+1 )*ldv ),
1061 $ nqm1, mycol, myrow )
1062 CALL zgerv2d( ictxt, npm1, 1, work( intmp ), npm1, mycol,
1063 $ myrow )
1064
1065 END IF
1066 DO 130 i = 0, npm1 - 1
1067 work( inv+liip1-1+( bindex+1 )*ldv+i ) = work( inv+liip1-
1068 $ 1+( bindex+1 )*ldv+i ) + work( intmp+i )
1069 130 CONTINUE
1070
1071
1072
1073 CALL zgsum2d( ictxt, 'R', ' ', npm1, 1,
1074 $ work( inv+liip1-1+( bindex+1 )*ldv ), npm1,
1075 $ myrow, nxtcol )
1076
1077
1078
1079
1080
1081
1082 IF( mycol.EQ.nxtcol ) THEN
1083 cc( 1 ) = z_zero
1084 DO 140 i = 0, npm1 - 1
1085 cc( 1 ) = cc( 1 ) + dconjg( work( inv+liip1-1+
1086 $ ( bindex+1 )*ldv+i ) )*
1087 $ work( inh+liip1-1+( bindex+1 )*ldv+i )
1088 140 CONTINUE
1089 IF( myrow.EQ.nxtrow ) THEN
1090 cc( 2 ) = work( inv+liip1-1+( bindex+1 )*ldv )
1091 cc( 3 ) = work( inh+liip1-1+( bindex+1 )*ldv )
1092 ELSE
1093 cc( 2 ) = z_zero
1094 cc( 3 ) = z_zero
1095 END IF
1096 CALL zgsum2d( ictxt, 'C', ' ', 3, 1, cc, 3, -1, nxtcol )
1097
1098 topv = cc( 2 )
1099 c = cc( 1 )
1100 toph = cc( 3 )
1101
1102 topnv = toptau*( topv-c*dconjg( toptau ) / 2*toph )
1103
1104
1105
1106
1107
1108 DO 150 i = 0, npm1 - 1
1109 work( inv+liip1-1+( bindex+1 )*ldv+i ) = toptau*
1110 $ ( work( inv+liip1-1+( bindex+1 )*ldv+i )-c*
1111 $ dconjg( toptau ) / 2*work( inh+liip1-1+( bindex+
1112 $ 1 )*ldv+i ) )
1113 150 CONTINUE
1114
1115 END IF
1116
1117
1118 160 CONTINUE
1119
1120
1121
1122
1123 IF( maxindex.LT.n ) THEN
1124
1125 DO 170 i = 0, npm1 - 1
1126 work( intmp+i ) = work( inh+liip1-1+anb*ldv+i )
1127 170 CONTINUE
1128
1129
1130
1131 IF( .NOT.twogemms ) THEN
1132 IF( interleave ) THEN
1133 ldzg = ldv / 2
1134 ELSE
1135 CALL zlamov( 'A', ltnm1, anb, work( inht+lijp1-1 ),
1136 $ ldv, work( invt+lijp1-1+anb*ldv ), ldv )
1137
1138 CALL zlamov( 'A', ltnm1, anb, work( inv+ltlip1-1 ),
1139 $ ldv, work( inh+ltlip1-1+anb*ldv ), ldv )
1140 ldzg = ldv
1141 END IF
1142 nbzg = anb*2
1143 ELSE
1144 ldzg = ldv
1145 nbzg = anb
1146 END IF
1147
1148
1149 DO 180 pbmin = 1, ltnm1, pnb
1150
1151 pbsize =
min( pnb, ltnm1-pbmin+1 )
1152 pbmax =
min( ltnm1, pbmin+pnb-1 )
1153 CALL zgemm( 'N', 'C', pbsize, pbmax, nbzg, z_negone,
1154 $ work( inh+ltlip1-1+pbmin-1 ), ldzg,
1155 $ work( invt+lijp1-1 ), ldzg, z_one,
1156 $ a( ltlip1+pbmin-1+( lijp1-1 )*lda ), lda )
1157 IF( twogemms ) THEN
1158 CALL zgemm( 'N', 'C', pbsize, pbmax, anb, z_negone,
1159 $ work( inv+ltlip1-1+pbmin-1 ), ldzg,
1160 $ work( inht+lijp1-1 ), ldzg, z_one,
1161 $ a( ltlip1+pbmin-1+( lijp1-1 )*lda ), lda )
1162 END IF
1163 180 CONTINUE
1164
1165
1166
1167 DO 190 i = 0, npm1 - 1
1168 work( inv+liip1-1+i ) = work( inv+liip1-1+anb*ldv+i )
1169 work( inh+liip1-1+i ) = work( intmp+i )
1170 190 CONTINUE
1171 DO 200 i = 0, nqm1 - 1
1172 work( inht+lijp1-1+i ) = work( inht+lijp1-1+anb*ldv+i )
1173 200 CONTINUE
1174
1175
1176 END IF
1177
1178
1179
1180 210 CONTINUE
1181
1182 IF( mycol.EQ.nxtcol ) THEN
1183 IF( myrow.EQ.nxtrow ) THEN
1184
1185 d( nq ) = dble( a( np+( nq-1 )*lda ) )
1186 a( np+( nq-1 )*lda ) = d( nq )
1187
1188 CALL dgebs2d( ictxt, 'C', ' ', 1, 1, d( nq ), 1 )
1189 ELSE
1190 CALL dgebr2d( ictxt, 'C', ' ', 1, 1, d( nq ), 1, nxtrow,
1191 $ nxtcol )
1192 END IF
1193 END IF
1194
1195
1196
1197
1198 work( 1 ) = dcmplx( lwmin )
1199 RETURN
1200
1201
1202
1203
subroutine chk1mat(ma, mapos0, na, napos0, ia, ja, desca, descapos0, info)
integer function iceil(inum, idenom)
integer function numroc(n, nb, iproc, isrcproc, nprocs)
subroutine pchk1mat(ma, mapos0, na, napos0, ia, ja, desca, descapos0, nextra, ex, expos, info)
double precision function pdlamch(ictxt, cmach)
subroutine dcombnrm2(x, y)
subroutine pdtreecomb(ictxt, scope, n, mine, rdest0, cdest0, subptr)
integer function pjlaenv(ictxt, ispec, name, opts, n1, n2, n3, n4)
subroutine pxerbla(ictxt, srname, info)
subroutine ztrmvt(uplo, n, t, ldt, x, incx, y, incy, w, incw, z, incz)