295
296
297
298
299
300
301 CHARACTER HOWMNY, SIDE
302 INTEGER INFO, LDP, LDS, LDVL, LDVR, M, MM, N
303
304
305 LOGICAL SELECT( * )
306 DOUBLE PRECISION P( LDP, * ), S( LDS, * ), VL( LDVL, * ),
307 $ VR( LDVR, * ), WORK( * )
308
309
310
311
312
313
314 DOUBLE PRECISION ZERO, ONE, SAFETY
315 parameter( zero = 0.0d+0, one = 1.0d+0,
316 $ safety = 1.0d+2 )
317
318
319 LOGICAL COMPL, COMPR, IL2BY2, ILABAD, ILALL, ILBACK,
320 $ ILBBAD, ILCOMP, ILCPLX, LSA, LSB
321 INTEGER I, IBEG, IEIG, IEND, IHWMNY, IINFO, IM, ISIDE,
322 $ J, JA, JC, JE, JR, JW, NA, NW
323 DOUBLE PRECISION ACOEF, ACOEFA, ANORM, ASCALE, BCOEFA, BCOEFI,
324 $ BCOEFR, BIG, BIGNUM, BNORM, BSCALE, CIM2A,
325 $ CIM2B, CIMAGA, CIMAGB, CRE2A, CRE2B, CREALA,
326 $ CREALB, DMIN, SAFMIN, SALFAR, SBETA, SCALE,
327 $ SMALL, TEMP, TEMP2, TEMP2I, TEMP2R, ULP, XMAX,
328 $ XSCALE
329
330
331 DOUBLE PRECISION BDIAG( 2 ), SUM( 2, 2 ), SUMS( 2, 2 ),
332 $ SUMP( 2, 2 )
333
334
335 LOGICAL LSAME
336 DOUBLE PRECISION DLAMCH
338
339
341
342
343 INTRINSIC abs, max, min
344
345
346
347
348
349 IF(
lsame( howmny,
'A' ) )
THEN
350 ihwmny = 1
351 ilall = .true.
352 ilback = .false.
353 ELSE IF(
lsame( howmny,
'S' ) )
THEN
354 ihwmny = 2
355 ilall = .false.
356 ilback = .false.
357 ELSE IF(
lsame( howmny,
'B' ) )
THEN
358 ihwmny = 3
359 ilall = .true.
360 ilback = .true.
361 ELSE
362 ihwmny = -1
363 ilall = .true.
364 END IF
365
366 IF(
lsame( side,
'R' ) )
THEN
367 iside = 1
368 compl = .false.
369 compr = .true.
370 ELSE IF(
lsame( side,
'L' ) )
THEN
371 iside = 2
372 compl = .true.
373 compr = .false.
374 ELSE IF(
lsame( side,
'B' ) )
THEN
375 iside = 3
376 compl = .true.
377 compr = .true.
378 ELSE
379 iside = -1
380 END IF
381
382 info = 0
383 IF( iside.LT.0 ) THEN
384 info = -1
385 ELSE IF( ihwmny.LT.0 ) THEN
386 info = -2
387 ELSE IF( n.LT.0 ) THEN
388 info = -4
389 ELSE IF( lds.LT.max( 1, n ) ) THEN
390 info = -6
391 ELSE IF( ldp.LT.max( 1, n ) ) THEN
392 info = -8
393 END IF
394 IF( info.NE.0 ) THEN
395 CALL xerbla(
'DTGEVC', -info )
396 RETURN
397 END IF
398
399
400
401 IF( .NOT.ilall ) THEN
402 im = 0
403 ilcplx = .false.
404 DO 10 j = 1, n
405 IF( ilcplx ) THEN
406 ilcplx = .false.
407 GO TO 10
408 END IF
409 IF( j.LT.n ) THEN
410 IF( s( j+1, j ).NE.zero )
411 $ ilcplx = .true.
412 END IF
413 IF( ilcplx ) THEN
414 IF( SELECT( j ) .OR. SELECT( j+1 ) )
415 $ im = im + 2
416 ELSE
417 IF( SELECT( j ) )
418 $ im = im + 1
419 END IF
420 10 CONTINUE
421 ELSE
422 im = n
423 END IF
424
425
426
427 ilabad = .false.
428 ilbbad = .false.
429 DO 20 j = 1, n - 1
430 IF( s( j+1, j ).NE.zero ) THEN
431 IF( p( j, j ).EQ.zero .OR. p( j+1, j+1 ).EQ.zero .OR.
432 $ p( j, j+1 ).NE.zero )ilbbad = .true.
433 IF( j.LT.n-1 ) THEN
434 IF( s( j+2, j+1 ).NE.zero )
435 $ ilabad = .true.
436 END IF
437 END IF
438 20 CONTINUE
439
440 IF( ilabad ) THEN
441 info = -5
442 ELSE IF( ilbbad ) THEN
443 info = -7
444 ELSE IF( compl .AND. ldvl.LT.n .OR. ldvl.LT.1 ) THEN
445 info = -10
446 ELSE IF( compr .AND. ldvr.LT.n .OR. ldvr.LT.1 ) THEN
447 info = -12
448 ELSE IF( mm.LT.im ) THEN
449 info = -13
450 END IF
451 IF( info.NE.0 ) THEN
452 CALL xerbla(
'DTGEVC', -info )
453 RETURN
454 END IF
455
456
457
458 m = im
459 IF( n.EQ.0 )
460 $ RETURN
461
462
463
464 safmin =
dlamch(
'Safe minimum' )
465 big = one / safmin
467 small = safmin*n / ulp
468 big = one / small
469 bignum = one / ( safmin*n )
470
471
472
473
474
475
476 anorm = abs( s( 1, 1 ) )
477 IF( n.GT.1 )
478 $ anorm = anorm + abs( s( 2, 1 ) )
479 bnorm = abs( p( 1, 1 ) )
480 work( 1 ) = zero
481 work( n+1 ) = zero
482
483 DO 50 j = 2, n
484 temp = zero
485 temp2 = zero
486 IF( s( j, j-1 ).EQ.zero ) THEN
487 iend = j - 1
488 ELSE
489 iend = j - 2
490 END IF
491 DO 30 i = 1, iend
492 temp = temp + abs( s( i, j ) )
493 temp2 = temp2 + abs( p( i, j ) )
494 30 CONTINUE
495 work( j ) = temp
496 work( n+j ) = temp2
497 DO 40 i = iend + 1, min( j+1, n )
498 temp = temp + abs( s( i, j ) )
499 temp2 = temp2 + abs( p( i, j ) )
500 40 CONTINUE
501 anorm = max( anorm, temp )
502 bnorm = max( bnorm, temp2 )
503 50 CONTINUE
504
505 ascale = one / max( anorm, safmin )
506 bscale = one / max( bnorm, safmin )
507
508
509
510 IF( compl ) THEN
511 ieig = 0
512
513
514
515 ilcplx = .false.
516 DO 220 je = 1, n
517
518
519
520
521
522
523 IF( ilcplx ) THEN
524 ilcplx = .false.
525 GO TO 220
526 END IF
527 nw = 1
528 IF( je.LT.n ) THEN
529 IF( s( je+1, je ).NE.zero ) THEN
530 ilcplx = .true.
531 nw = 2
532 END IF
533 END IF
534 IF( ilall ) THEN
535 ilcomp = .true.
536 ELSE IF( ilcplx ) THEN
537 ilcomp = SELECT( je ) .OR. SELECT( je+1 )
538 ELSE
539 ilcomp = SELECT( je )
540 END IF
541 IF( .NOT.ilcomp )
542 $ GO TO 220
543
544
545
546
547 IF( .NOT.ilcplx ) THEN
548 IF( abs( s( je, je ) ).LE.safmin .AND.
549 $ abs( p( je, je ) ).LE.safmin ) THEN
550
551
552
553 ieig = ieig + 1
554 DO 60 jr = 1, n
555 vl( jr, ieig ) = zero
556 60 CONTINUE
557 vl( ieig, ieig ) = one
558 GO TO 220
559 END IF
560 END IF
561
562
563
564 DO 70 jr = 1, nw*n
565 work( 2*n+jr ) = zero
566 70 CONTINUE
567
568
569
570
571
572 IF( .NOT.ilcplx ) THEN
573
574
575
576 temp = one / max( abs( s( je, je ) )*ascale,
577 $ abs( p( je, je ) )*bscale, safmin )
578 salfar = ( temp*s( je, je ) )*ascale
579 sbeta = ( temp*p( je, je ) )*bscale
580 acoef = sbeta*ascale
581 bcoefr = salfar*bscale
582 bcoefi = zero
583
584
585
586 scale = one
587 lsa = abs( sbeta ).GE.safmin .AND. abs( acoef ).LT.small
588 lsb = abs( salfar ).GE.safmin .AND. abs( bcoefr ).LT.
589 $ small
590 IF( lsa )
591 $ scale = ( small / abs( sbeta ) )*min( anorm, big )
592 IF( lsb )
593 $ scale = max( scale, ( small / abs( salfar ) )*
594 $ min( bnorm, big ) )
595 IF( lsa .OR. lsb ) THEN
596 scale = min( scale, one /
597 $ ( safmin*max( one, abs( acoef ),
598 $ abs( bcoefr ) ) ) )
599 IF( lsa ) THEN
600 acoef = ascale*( scale*sbeta )
601 ELSE
602 acoef = scale*acoef
603 END IF
604 IF( lsb ) THEN
605 bcoefr = bscale*( scale*salfar )
606 ELSE
607 bcoefr = scale*bcoefr
608 END IF
609 END IF
610 acoefa = abs( acoef )
611 bcoefa = abs( bcoefr )
612
613
614
615 work( 2*n+je ) = one
616 xmax = one
617 ELSE
618
619
620
621 CALL dlag2( s( je, je ), lds, p( je, je ), ldp,
622 $ safmin*safety, acoef, temp, bcoefr, temp2,
623 $ bcoefi )
624 bcoefi = -bcoefi
625 IF( bcoefi.EQ.zero ) THEN
626 info = je
627 RETURN
628 END IF
629
630
631
632 acoefa = abs( acoef )
633 bcoefa = abs( bcoefr ) + abs( bcoefi )
634 scale = one
635 IF( acoefa*ulp.LT.safmin .AND. acoefa.GE.safmin )
636 $ scale = ( safmin / ulp ) / acoefa
637 IF( bcoefa*ulp.LT.safmin .AND. bcoefa.GE.safmin )
638 $ scale = max( scale, ( safmin / ulp ) / bcoefa )
639 IF( safmin*acoefa.GT.ascale )
640 $ scale = ascale / ( safmin*acoefa )
641 IF( safmin*bcoefa.GT.bscale )
642 $ scale = min( scale, bscale / ( safmin*bcoefa ) )
643 IF( scale.NE.one ) THEN
644 acoef = scale*acoef
645 acoefa = abs( acoef )
646 bcoefr = scale*bcoefr
647 bcoefi = scale*bcoefi
648 bcoefa = abs( bcoefr ) + abs( bcoefi )
649 END IF
650
651
652
653 temp = acoef*s( je+1, je )
654 temp2r = acoef*s( je, je ) - bcoefr*p( je, je )
655 temp2i = -bcoefi*p( je, je )
656 IF( abs( temp ).GT.abs( temp2r )+abs( temp2i ) ) THEN
657 work( 2*n+je ) = one
658 work( 3*n+je ) = zero
659 work( 2*n+je+1 ) = -temp2r / temp
660 work( 3*n+je+1 ) = -temp2i / temp
661 ELSE
662 work( 2*n+je+1 ) = one
663 work( 3*n+je+1 ) = zero
664 temp = acoef*s( je, je+1 )
665 work( 2*n+je ) = ( bcoefr*p( je+1, je+1 )-acoef*
666 $ s( je+1, je+1 ) ) / temp
667 work( 3*n+je ) = bcoefi*p( je+1, je+1 ) / temp
668 END IF
669 xmax = max( abs( work( 2*n+je ) )+abs( work( 3*n+je ) ),
670 $ abs( work( 2*n+je+1 ) )+abs( work( 3*n+je+1 ) ) )
671 END IF
672
673 dmin = max( ulp*acoefa*anorm, ulp*bcoefa*bnorm, safmin )
674
675
676
677
678
679
680
681 il2by2 = .false.
682
683 DO 160 j = je + nw, n
684 IF( il2by2 ) THEN
685 il2by2 = .false.
686 GO TO 160
687 END IF
688
689 na = 1
690 bdiag( 1 ) = p( j, j )
691 IF( j.LT.n ) THEN
692 IF( s( j+1, j ).NE.zero ) THEN
693 il2by2 = .true.
694 bdiag( 2 ) = p( j+1, j+1 )
695 na = 2
696 END IF
697 END IF
698
699
700
701 xscale = one / max( one, xmax )
702 temp = max( work( j ), work( n+j ),
703 $ acoefa*work( j )+bcoefa*work( n+j ) )
704 IF( il2by2 )
705 $ temp = max( temp, work( j+1 ), work( n+j+1 ),
706 $ acoefa*work( j+1 )+bcoefa*work( n+j+1 ) )
707 IF( temp.GT.bignum*xscale ) THEN
708 DO 90 jw = 0, nw - 1
709 DO 80 jr = je, j - 1
710 work( ( jw+2 )*n+jr ) = xscale*
711 $ work( ( jw+2 )*n+jr )
712 80 CONTINUE
713 90 CONTINUE
714 xmax = xmax*xscale
715 END IF
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733 DO 120 jw = 1, nw
734 DO 110 ja = 1, na
735 sums( ja, jw ) = zero
736 sump( ja, jw ) = zero
737
738 DO 100 jr = je, j - 1
739 sums( ja, jw ) = sums( ja, jw ) +
740 $ s( jr, j+ja-1 )*
741 $ work( ( jw+1 )*n+jr )
742 sump( ja, jw ) = sump( ja, jw ) +
743 $ p( jr, j+ja-1 )*
744 $ work( ( jw+1 )*n+jr )
745 100 CONTINUE
746 110 CONTINUE
747 120 CONTINUE
748
749 DO 130 ja = 1, na
750 IF( ilcplx ) THEN
751 sum( ja, 1 ) = -acoef*sums( ja, 1 ) +
752 $ bcoefr*sump( ja, 1 ) -
753 $ bcoefi*sump( ja, 2 )
754 sum( ja, 2 ) = -acoef*sums( ja, 2 ) +
755 $ bcoefr*sump( ja, 2 ) +
756 $ bcoefi*sump( ja, 1 )
757 ELSE
758 sum( ja, 1 ) = -acoef*sums( ja, 1 ) +
759 $ bcoefr*sump( ja, 1 )
760 END IF
761 130 CONTINUE
762
763
764
765
766
767 CALL dlaln2( .true., na, nw, dmin, acoef, s( j, j ), lds,
768 $ bdiag( 1 ), bdiag( 2 ), sum, 2, bcoefr,
769 $ bcoefi, work( 2*n+j ), n, scale, temp,
770 $ iinfo )
771 IF( scale.LT.one ) THEN
772 DO 150 jw = 0, nw - 1
773 DO 140 jr = je, j - 1
774 work( ( jw+2 )*n+jr ) = scale*
775 $ work( ( jw+2 )*n+jr )
776 140 CONTINUE
777 150 CONTINUE
778 xmax = scale*xmax
779 END IF
780 xmax = max( xmax, temp )
781 160 CONTINUE
782
783
784
785
786 ieig = ieig + 1
787 IF( ilback ) THEN
788 DO 170 jw = 0, nw - 1
789 CALL dgemv(
'N', n, n+1-je, one, vl( 1, je ), ldvl,
790 $ work( ( jw+2 )*n+je ), 1, zero,
791 $ work( ( jw+4 )*n+1 ), 1 )
792 170 CONTINUE
793 CALL dlacpy(
' ', n, nw, work( 4*n+1 ), n, vl( 1, je ),
794 $ ldvl )
795 ibeg = 1
796 ELSE
797 CALL dlacpy(
' ', n, nw, work( 2*n+1 ), n, vl( 1, ieig ),
798 $ ldvl )
799 ibeg = je
800 END IF
801
802
803
804 xmax = zero
805 IF( ilcplx ) THEN
806 DO 180 j = ibeg, n
807 xmax = max( xmax, abs( vl( j, ieig ) )+
808 $ abs( vl( j, ieig+1 ) ) )
809 180 CONTINUE
810 ELSE
811 DO 190 j = ibeg, n
812 xmax = max( xmax, abs( vl( j, ieig ) ) )
813 190 CONTINUE
814 END IF
815
816 IF( xmax.GT.safmin ) THEN
817 xscale = one / xmax
818
819 DO 210 jw = 0, nw - 1
820 DO 200 jr = ibeg, n
821 vl( jr, ieig+jw ) = xscale*vl( jr, ieig+jw )
822 200 CONTINUE
823 210 CONTINUE
824 END IF
825 ieig = ieig + nw - 1
826
827 220 CONTINUE
828 END IF
829
830
831
832 IF( compr ) THEN
833 ieig = im + 1
834
835
836
837 ilcplx = .false.
838 DO 500 je = n, 1, -1
839
840
841
842
843
844
845
846
847
848 IF( ilcplx ) THEN
849 ilcplx = .false.
850 GO TO 500
851 END IF
852 nw = 1
853 IF( je.GT.1 ) THEN
854 IF( s( je, je-1 ).NE.zero ) THEN
855 ilcplx = .true.
856 nw = 2
857 END IF
858 END IF
859 IF( ilall ) THEN
860 ilcomp = .true.
861 ELSE IF( ilcplx ) THEN
862 ilcomp = SELECT( je ) .OR. SELECT( je-1 )
863 ELSE
864 ilcomp = SELECT( je )
865 END IF
866 IF( .NOT.ilcomp )
867 $ GO TO 500
868
869
870
871
872 IF( .NOT.ilcplx ) THEN
873 IF( abs( s( je, je ) ).LE.safmin .AND.
874 $ abs( p( je, je ) ).LE.safmin ) THEN
875
876
877
878 ieig = ieig - 1
879 DO 230 jr = 1, n
880 vr( jr, ieig ) = zero
881 230 CONTINUE
882 vr( ieig, ieig ) = one
883 GO TO 500
884 END IF
885 END IF
886
887
888
889 DO 250 jw = 0, nw - 1
890 DO 240 jr = 1, n
891 work( ( jw+2 )*n+jr ) = zero
892 240 CONTINUE
893 250 CONTINUE
894
895
896
897
898
899 IF( .NOT.ilcplx ) THEN
900
901
902
903 temp = one / max( abs( s( je, je ) )*ascale,
904 $ abs( p( je, je ) )*bscale, safmin )
905 salfar = ( temp*s( je, je ) )*ascale
906 sbeta = ( temp*p( je, je ) )*bscale
907 acoef = sbeta*ascale
908 bcoefr = salfar*bscale
909 bcoefi = zero
910
911
912
913 scale = one
914 lsa = abs( sbeta ).GE.safmin .AND. abs( acoef ).LT.small
915 lsb = abs( salfar ).GE.safmin .AND. abs( bcoefr ).LT.
916 $ small
917 IF( lsa )
918 $ scale = ( small / abs( sbeta ) )*min( anorm, big )
919 IF( lsb )
920 $ scale = max( scale, ( small / abs( salfar ) )*
921 $ min( bnorm, big ) )
922 IF( lsa .OR. lsb ) THEN
923 scale = min( scale, one /
924 $ ( safmin*max( one, abs( acoef ),
925 $ abs( bcoefr ) ) ) )
926 IF( lsa ) THEN
927 acoef = ascale*( scale*sbeta )
928 ELSE
929 acoef = scale*acoef
930 END IF
931 IF( lsb ) THEN
932 bcoefr = bscale*( scale*salfar )
933 ELSE
934 bcoefr = scale*bcoefr
935 END IF
936 END IF
937 acoefa = abs( acoef )
938 bcoefa = abs( bcoefr )
939
940
941
942 work( 2*n+je ) = one
943 xmax = one
944
945
946
947
948 DO 260 jr = 1, je - 1
949 work( 2*n+jr ) = bcoefr*p( jr, je ) -
950 $ acoef*s( jr, je )
951 260 CONTINUE
952 ELSE
953
954
955
956 CALL dlag2( s( je-1, je-1 ), lds, p( je-1, je-1 ), ldp,
957 $ safmin*safety, acoef, temp, bcoefr, temp2,
958 $ bcoefi )
959 IF( bcoefi.EQ.zero ) THEN
960 info = je - 1
961 RETURN
962 END IF
963
964
965
966 acoefa = abs( acoef )
967 bcoefa = abs( bcoefr ) + abs( bcoefi )
968 scale = one
969 IF( acoefa*ulp.LT.safmin .AND. acoefa.GE.safmin )
970 $ scale = ( safmin / ulp ) / acoefa
971 IF( bcoefa*ulp.LT.safmin .AND. bcoefa.GE.safmin )
972 $ scale = max( scale, ( safmin / ulp ) / bcoefa )
973 IF( safmin*acoefa.GT.ascale )
974 $ scale = ascale / ( safmin*acoefa )
975 IF( safmin*bcoefa.GT.bscale )
976 $ scale = min( scale, bscale / ( safmin*bcoefa ) )
977 IF( scale.NE.one ) THEN
978 acoef = scale*acoef
979 acoefa = abs( acoef )
980 bcoefr = scale*bcoefr
981 bcoefi = scale*bcoefi
982 bcoefa = abs( bcoefr ) + abs( bcoefi )
983 END IF
984
985
986
987
988 temp = acoef*s( je, je-1 )
989 temp2r = acoef*s( je, je ) - bcoefr*p( je, je )
990 temp2i = -bcoefi*p( je, je )
991 IF( abs( temp ).GE.abs( temp2r )+abs( temp2i ) ) THEN
992 work( 2*n+je ) = one
993 work( 3*n+je ) = zero
994 work( 2*n+je-1 ) = -temp2r / temp
995 work( 3*n+je-1 ) = -temp2i / temp
996 ELSE
997 work( 2*n+je-1 ) = one
998 work( 3*n+je-1 ) = zero
999 temp = acoef*s( je-1, je )
1000 work( 2*n+je ) = ( bcoefr*p( je-1, je-1 )-acoef*
1001 $ s( je-1, je-1 ) ) / temp
1002 work( 3*n+je ) = bcoefi*p( je-1, je-1 ) / temp
1003 END IF
1004
1005 xmax = max( abs( work( 2*n+je ) )+abs( work( 3*n+je ) ),
1006 $ abs( work( 2*n+je-1 ) )+abs( work( 3*n+je-1 ) ) )
1007
1008
1009
1010
1011 creala = acoef*work( 2*n+je-1 )
1012 cimaga = acoef*work( 3*n+je-1 )
1013 crealb = bcoefr*work( 2*n+je-1 ) -
1014 $ bcoefi*work( 3*n+je-1 )
1015 cimagb = bcoefi*work( 2*n+je-1 ) +
1016 $ bcoefr*work( 3*n+je-1 )
1017 cre2a = acoef*work( 2*n+je )
1018 cim2a = acoef*work( 3*n+je )
1019 cre2b = bcoefr*work( 2*n+je ) - bcoefi*work( 3*n+je )
1020 cim2b = bcoefi*work( 2*n+je ) + bcoefr*work( 3*n+je )
1021 DO 270 jr = 1, je - 2
1022 work( 2*n+jr ) = -creala*s( jr, je-1 ) +
1023 $ crealb*p( jr, je-1 ) -
1024 $ cre2a*s( jr, je ) + cre2b*p( jr, je )
1025 work( 3*n+jr ) = -cimaga*s( jr, je-1 ) +
1026 $ cimagb*p( jr, je-1 ) -
1027 $ cim2a*s( jr, je ) + cim2b*p( jr, je )
1028 270 CONTINUE
1029 END IF
1030
1031 dmin = max( ulp*acoefa*anorm, ulp*bcoefa*bnorm, safmin )
1032
1033
1034
1035 il2by2 = .false.
1036 DO 370 j = je - nw, 1, -1
1037
1038
1039
1040
1041 IF( .NOT.il2by2 .AND. j.GT.1 ) THEN
1042 IF( s( j, j-1 ).NE.zero ) THEN
1043 il2by2 = .true.
1044 GO TO 370
1045 END IF
1046 END IF
1047 bdiag( 1 ) = p( j, j )
1048 IF( il2by2 ) THEN
1049 na = 2
1050 bdiag( 2 ) = p( j+1, j+1 )
1051 ELSE
1052 na = 1
1053 END IF
1054
1055
1056
1057 CALL dlaln2( .false., na, nw, dmin, acoef, s( j, j ),
1058 $ lds, bdiag( 1 ), bdiag( 2 ), work( 2*n+j ),
1059 $ n, bcoefr, bcoefi, sum, 2, scale, temp,
1060 $ iinfo )
1061 IF( scale.LT.one ) THEN
1062
1063 DO 290 jw = 0, nw - 1
1064 DO 280 jr = 1, je
1065 work( ( jw+2 )*n+jr ) = scale*
1066 $ work( ( jw+2 )*n+jr )
1067 280 CONTINUE
1068 290 CONTINUE
1069 END IF
1070 xmax = max( scale*xmax, temp )
1071
1072 DO 310 jw = 1, nw
1073 DO 300 ja = 1, na
1074 work( ( jw+1 )*n+j+ja-1 ) = sum( ja, jw )
1075 300 CONTINUE
1076 310 CONTINUE
1077
1078
1079
1080 IF( j.GT.1 ) THEN
1081
1082
1083
1084 xscale = one / max( one, xmax )
1085 temp = acoefa*work( j ) + bcoefa*work( n+j )
1086 IF( il2by2 )
1087 $ temp = max( temp, acoefa*work( j+1 )+bcoefa*
1088 $ work( n+j+1 ) )
1089 temp = max( temp, acoefa, bcoefa )
1090 IF( temp.GT.bignum*xscale ) THEN
1091
1092 DO 330 jw = 0, nw - 1
1093 DO 320 jr = 1, je
1094 work( ( jw+2 )*n+jr ) = xscale*
1095 $ work( ( jw+2 )*n+jr )
1096 320 CONTINUE
1097 330 CONTINUE
1098 xmax = xmax*xscale
1099 END IF
1100
1101
1102
1103
1104
1105
1106 DO 360 ja = 1, na
1107 IF( ilcplx ) THEN
1108 creala = acoef*work( 2*n+j+ja-1 )
1109 cimaga = acoef*work( 3*n+j+ja-1 )
1110 crealb = bcoefr*work( 2*n+j+ja-1 ) -
1111 $ bcoefi*work( 3*n+j+ja-1 )
1112 cimagb = bcoefi*work( 2*n+j+ja-1 ) +
1113 $ bcoefr*work( 3*n+j+ja-1 )
1114 DO 340 jr = 1, j - 1
1115 work( 2*n+jr ) = work( 2*n+jr ) -
1116 $ creala*s( jr, j+ja-1 ) +
1117 $ crealb*p( jr, j+ja-1 )
1118 work( 3*n+jr ) = work( 3*n+jr ) -
1119 $ cimaga*s( jr, j+ja-1 ) +
1120 $ cimagb*p( jr, j+ja-1 )
1121 340 CONTINUE
1122 ELSE
1123 creala = acoef*work( 2*n+j+ja-1 )
1124 crealb = bcoefr*work( 2*n+j+ja-1 )
1125 DO 350 jr = 1, j - 1
1126 work( 2*n+jr ) = work( 2*n+jr ) -
1127 $ creala*s( jr, j+ja-1 ) +
1128 $ crealb*p( jr, j+ja-1 )
1129 350 CONTINUE
1130 END IF
1131 360 CONTINUE
1132 END IF
1133
1134 il2by2 = .false.
1135 370 CONTINUE
1136
1137
1138
1139
1140 ieig = ieig - nw
1141 IF( ilback ) THEN
1142
1143 DO 410 jw = 0, nw - 1
1144 DO 380 jr = 1, n
1145 work( ( jw+4 )*n+jr ) = work( ( jw+2 )*n+1 )*
1146 $ vr( jr, 1 )
1147 380 CONTINUE
1148
1149
1150
1151
1152
1153 DO 400 jc = 2, je
1154 DO 390 jr = 1, n
1155 work( ( jw+4 )*n+jr ) = work( ( jw+4 )*n+jr ) +
1156 $ work( ( jw+2 )*n+jc )*vr( jr, jc )
1157 390 CONTINUE
1158 400 CONTINUE
1159 410 CONTINUE
1160
1161 DO 430 jw = 0, nw - 1
1162 DO 420 jr = 1, n
1163 vr( jr, ieig+jw ) = work( ( jw+4 )*n+jr )
1164 420 CONTINUE
1165 430 CONTINUE
1166
1167 iend = n
1168 ELSE
1169 DO 450 jw = 0, nw - 1
1170 DO 440 jr = 1, n
1171 vr( jr, ieig+jw ) = work( ( jw+2 )*n+jr )
1172 440 CONTINUE
1173 450 CONTINUE
1174
1175 iend = je
1176 END IF
1177
1178
1179
1180 xmax = zero
1181 IF( ilcplx ) THEN
1182 DO 460 j = 1, iend
1183 xmax = max( xmax, abs( vr( j, ieig ) )+
1184 $ abs( vr( j, ieig+1 ) ) )
1185 460 CONTINUE
1186 ELSE
1187 DO 470 j = 1, iend
1188 xmax = max( xmax, abs( vr( j, ieig ) ) )
1189 470 CONTINUE
1190 END IF
1191
1192 IF( xmax.GT.safmin ) THEN
1193 xscale = one / xmax
1194 DO 490 jw = 0, nw - 1
1195 DO 480 jr = 1, iend
1196 vr( jr, ieig+jw ) = xscale*vr( jr, ieig+jw )
1197 480 CONTINUE
1198 490 CONTINUE
1199 END IF
1200 500 CONTINUE
1201 END IF
1202
1203 RETURN
1204
1205
1206
subroutine xerbla(srname, info)
subroutine dgemv(trans, m, n, alpha, a, lda, x, incx, beta, y, incy)
DGEMV
subroutine dlacpy(uplo, m, n, a, lda, b, ldb)
DLACPY copies all or part of one two-dimensional array to another.
subroutine dlag2(a, lda, b, ldb, safmin, scale1, scale2, wr1, wr2, wi)
DLAG2 computes the eigenvalues of a 2-by-2 generalized eigenvalue problem, with scaling as necessary ...
subroutine dlaln2(ltrans, na, nw, smin, ca, a, lda, d1, d2, b, ldb, wr, wi, x, ldx, scale, xnorm, info)
DLALN2 solves a 1-by-1 or 2-by-2 linear system of equations of the specified form.
double precision function dlamch(cmach)
DLAMCH
logical function lsame(ca, cb)
LSAME