378 SUBROUTINE cdrges3( NSIZES, NN, NTYPES, DOTYPE, ISEED, THRESH,
379 $ NOUNIT, A, LDA, B, S, T, Q, LDQ, Z, ALPHA,
380 $ BETA, WORK, LWORK, RWORK, RESULT, BWORK,
388 INTEGER INFO, LDA, LDQ, LWORK, NOUNIT, NSIZES, NTYPES
392 LOGICAL BWORK( * ), DOTYPE( * )
393 INTEGER ISEED( 4 ), NN( * )
394 REAL RESULT( 13 ), RWORK( * )
395 COMPLEX A( LDA, * ), ALPHA( * ), B( LDA, * ),
396 $ beta( * ), q( ldq, * ), s( lda, * ),
397 $ t( lda, * ), work( * ), z( ldq, * )
404 PARAMETER ( ZERO = 0.0e+0, one = 1.0e+0 )
406 parameter( czero = ( 0.0e+0, 0.0e+0 ),
407 $ cone = ( 1.0e+0, 0.0e+0 ) )
409 parameter( maxtyp = 26 )
412 LOGICAL BADNN, ILABAD
414 INTEGER I, IADD, IINFO, IN, ISORT, J, JC, JR, JSIZE,
415 $ jtype, knteig, maxwrk, minwrk, mtypes, n, n1,
416 $ nb, nerrs, nmats, nmax, ntest, ntestt, rsub,
418 REAL SAFMAX, SAFMIN, TEMP1, TEMP2, ULP, ULPINV
422 LOGICAL LASIGN( MAXTYP ), LBSIGN( MAXTYP )
423 INTEGER IOLDSD( 4 ), KADD( 6 ), KAMAGN( MAXTYP ),
424 $ KATYPE( MAXTYP ), KAZERO( MAXTYP ),
425 $ kbmagn( maxtyp ), kbtype( maxtyp ),
426 $ kbzero( maxtyp ), kclass( maxtyp ),
427 $ ktrian( maxtyp ), kz1( 6 ), kz2( 6 )
435 EXTERNAL clctes, ilaenv, slamch, clarnd
442 INTRINSIC abs, aimag, conjg, max, min, real, sign
448 abs1( x ) = abs( real( x ) ) + abs( aimag( x ) )
451 DATA kclass / 15*1, 10*2, 1*3 /
452 DATA kz1 / 0, 1, 2, 1, 3, 3 /
453 DATA kz2 / 0, 0, 1, 2, 1, 1 /
454 DATA kadd / 0, 0, 0, 0, 3, 2 /
455 DATA katype / 0, 1, 0, 1, 2, 3, 4, 1, 4, 4, 1, 1, 4,
456 $ 4, 4, 2, 4, 5, 8, 7, 9, 4*4, 0 /
457 DATA kbtype / 0, 0, 1, 1, 2, -3, 1, 4, 1, 1, 4, 4,
458 $ 1, 1, -4, 2, -4, 8*8, 0 /
459 DATA kazero / 6*1, 2, 1, 2*2, 2*1, 2*2, 3, 1, 3,
461 DATA kbzero / 6*1, 1, 2, 2*1, 2*2, 2*1, 4, 1, 4,
463 DATA kamagn / 8*1, 2, 3, 2, 3, 2, 3, 7*1, 2, 3, 3,
465 DATA kbmagn / 8*1, 3, 2, 3, 2, 2, 3, 7*1, 3, 2, 3,
467 DATA ktrian / 16*0, 10*1 /
468 DATA lasign / 6*.false., .true., .false., 2*.true.,
469 $ 2*.false., 3*.true., .false., .true.,
470 $ 3*.false., 5*.true., .false. /
471 DATA lbsign / 7*.false., .true., 2*.false.,
472 $ 2*.true., 2*.false., .true., .false., .true.,
484 nmax = max( nmax, nn( j ) )
489 IF( nsizes.LT.0 )
THEN
491 ELSE IF( badnn )
THEN
493 ELSE IF( ntypes.LT.0 )
THEN
495 ELSE IF( thresh.LT.zero )
THEN
497 ELSE IF( lda.LE.1 .OR. lda.LT.nmax )
THEN
499 ELSE IF( ldq.LE.1 .OR. ldq.LT.nmax )
THEN
511 IF( info.EQ.0 .AND. lwork.GE.1 )
THEN
513 nb = max( 1, ilaenv( 1,
'CGEQRF',
' ', nmax, nmax, -1, -1 ),
514 $ ilaenv( 1,
'CUNMQR',
'LC', nmax, nmax, nmax, -1 ),
515 $ ilaenv( 1,
'CUNGQR',
' ', nmax, nmax, nmax, -1 ) )
516 maxwrk = max( nmax+nmax*nb, 3*nmax*nmax)
520 IF( lwork.LT.minwrk )
524 CALL xerbla(
'CDRGES3', -info )
530 IF( nsizes.EQ.0 .OR. ntypes.EQ.0 )
533 ulp = slamch(
'Precision' )
534 safmin = slamch(
'Safe minimum' )
535 safmin = safmin / ulp
536 safmax = one / safmin
550 DO 190 jsize = 1, nsizes
553 rmagn( 2 ) = safmax*ulp / real( n1 )
554 rmagn( 3 ) = safmin*ulpinv*real( n1 )
556 IF( nsizes.NE.1 )
THEN
557 mtypes = min( maxtyp, ntypes )
559 mtypes = min( maxtyp+1, ntypes )
564 DO 180 jtype = 1, mtypes
565 IF( .NOT.dotype( jtype ) )
573 ioldsd( j ) = iseed( j )
603 IF( mtypes.GT.maxtyp )
606 IF( kclass( jtype ).LT.3 )
THEN
610 IF( abs( katype( jtype ) ).EQ.3 )
THEN
611 in = 2*( ( n-1 ) / 2 ) + 1
613 $
CALL claset(
'Full', n, n, czero, czero, a, lda )
617 CALL clatm4( katype( jtype ), in, kz1( kazero( jtype ) ),
618 $ kz2( kazero( jtype ) ), lasign( jtype ),
619 $ rmagn( kamagn( jtype ) ), ulp,
620 $ rmagn( ktrian( jtype )*kamagn( jtype ) ), 2,
622 iadd = kadd( kazero( jtype ) )
623 IF( iadd.GT.0 .AND. iadd.LE.n )
624 $ a( iadd, iadd ) = rmagn( kamagn( jtype ) )
628 IF( abs( kbtype( jtype ) ).EQ.3 )
THEN
629 in = 2*( ( n-1 ) / 2 ) + 1
631 $
CALL claset(
'Full', n, n, czero, czero, b, lda )
635 CALL clatm4( kbtype( jtype ), in, kz1( kbzero( jtype ) ),
636 $ kz2( kbzero( jtype ) ), lbsign( jtype ),
637 $ rmagn( kbmagn( jtype ) ), one,
638 $ rmagn( ktrian( jtype )*kbmagn( jtype ) ), 2,
640 iadd = kadd( kbzero( jtype ) )
641 IF( iadd.NE.0 .AND. iadd.LE.n )
642 $ b( iadd, iadd ) = rmagn( kbmagn( jtype ) )
644 IF( kclass( jtype ).EQ.2 .AND. n.GT.0 )
THEN
653 q( jr, jc ) = clarnd( 3, iseed )
654 z( jr, jc ) = clarnd( 3, iseed )
656 CALL clarfg( n+1-jc, q( jc, jc ), q( jc+1, jc ), 1,
658 work( 2*n+jc ) = sign( one, real( q( jc, jc ) ) )
660 CALL clarfg( n+1-jc, z( jc, jc ), z( jc+1, jc ), 1,
662 work( 3*n+jc ) = sign( one, real( z( jc, jc ) ) )
665 ctemp = clarnd( 3, iseed )
668 work( 3*n ) = ctemp / abs( ctemp )
669 ctemp = clarnd( 3, iseed )
672 work( 4*n ) = ctemp / abs( ctemp )
678 a( jr, jc ) = work( 2*n+jr )*
679 $ conjg( work( 3*n+jc ) )*
681 b( jr, jc ) = work( 2*n+jr )*
682 $ conjg( work( 3*n+jc ) )*
686 CALL cunm2r(
'L',
'N', n, n, n-1, q, ldq, work, a,
687 $ lda, work( 2*n+1 ), iinfo )
690 CALL cunm2r(
'R',
'C', n, n, n-1, z, ldq, work( n+1 ),
691 $ a, lda, work( 2*n+1 ), iinfo )
694 CALL cunm2r(
'L',
'N', n, n, n-1, q, ldq, work, b,
695 $ lda, work( 2*n+1 ), iinfo )
698 CALL cunm2r(
'R',
'C', n, n, n-1, z, ldq, work( n+1 ),
699 $ b, lda, work( 2*n+1 ), iinfo )
709 a( jr, jc ) = rmagn( kamagn( jtype ) )*
711 b( jr, jc ) = rmagn( kbmagn( jtype ) )*
719 IF( iinfo.NE.0 )
THEN
720 WRITE( nounit, fmt = 9999 )
'Generator', iinfo, n, jtype,
735 IF( isort.EQ.0 )
THEN
753 CALL clacpy(
'Full', n, n, a, lda, s, lda )
754 CALL clacpy(
'Full', n, n, b, lda, t, lda )
755 ntest = 1 + rsub + isort
756 result( 1+rsub+isort ) = ulpinv
757 CALL cgges3(
'V',
'V', sort, clctes, n, s, lda, t, lda,
758 $ sdim, alpha, beta, q, ldq, z, ldq, work,
759 $ lwork, rwork, bwork, iinfo )
760 IF( iinfo.NE.0 .AND. iinfo.NE.n+2 )
THEN
761 result( 1+rsub+isort ) = ulpinv
762 WRITE( nounit, fmt = 9999 )
'CGGES3', iinfo, n, jtype,
772 IF( isort.EQ.0 )
THEN
773 CALL cget51( 1, n, a, lda, s, lda, q, ldq, z, ldq,
774 $ work, rwork, result( 1 ) )
775 CALL cget51( 1, n, b, lda, t, lda, q, ldq, z, ldq,
776 $ work, rwork, result( 2 ) )
778 CALL cget54( n, a, lda, b, lda, s, lda, t, lda, q,
779 $ ldq, z, ldq, work, result( 2+rsub ) )
782 CALL cget51( 3, n, b, lda, t, lda, q, ldq, q, ldq, work,
783 $ rwork, result( 3+rsub ) )
784 CALL cget51( 3, n, b, lda, t, lda, z, ldq, z, ldq, work,
785 $ rwork, result( 4+rsub ) )
796 temp2 = ( abs1( alpha( j )-s( j, j ) ) /
797 $ max( safmin, abs1( alpha( j ) ), abs1( s( j,
798 $ j ) ) )+abs1( beta( j )-t( j, j ) ) /
799 $ max( safmin, abs1( beta( j ) ), abs1( t( j,
803 IF( s( j+1, j ).NE.zero )
THEN
805 result( 5+rsub ) = ulpinv
809 IF( s( j, j-1 ).NE.zero )
THEN
811 result( 5+rsub ) = ulpinv
814 temp1 = max( temp1, temp2 )
816 WRITE( nounit, fmt = 9998 )j, n, jtype, ioldsd
819 result( 6+rsub ) = temp1
821 IF( isort.GE.1 )
THEN
829 IF( clctes( alpha( i ), beta( i ) ) )
830 $ knteig = knteig + 1
833 $ result( 13 ) = ulpinv
842 ntestt = ntestt + ntest
847 IF( result( jr ).GE.thresh )
THEN
852 IF( nerrs.EQ.0 )
THEN
853 WRITE( nounit, fmt = 9997 )
'CGS'
857 WRITE( nounit, fmt = 9996 )
858 WRITE( nounit, fmt = 9995 )
859 WRITE( nounit, fmt = 9994 )
'Unitary'
863 WRITE( nounit, fmt = 9993 )
'unitary',
'''',
864 $
'transpose', (
'''', j = 1, 8 )
868 IF( result( jr ).LT.10000.0 )
THEN
869 WRITE( nounit, fmt = 9992 )n, jtype, ioldsd, jr,
872 WRITE( nounit, fmt = 9991 )n, jtype, ioldsd, jr,
883 CALL alasvm(
'CGS', nounit, nerrs, ntestt, 0 )
889 9999
FORMAT(
' CDRGES3: ', a,
' returned INFO=', i6,
'.', / 9x,
'N=',
890 $ i6,
', JTYPE=', i6,
', ISEED=(', 4( i4,
',' ), i5,
')' )
892 9998
FORMAT(
' CDRGES3: S not in Schur form at eigenvalue ', i6,
'.',
893 $ / 9x,
'N=', i6,
', JTYPE=', i6,
', ISEED=(', 3( i5,
',' ),
896 9997
FORMAT( / 1x, a3,
' -- Complex Generalized Schur from problem ',
899 9996
FORMAT(
' Matrix types (see CDRGES3 for details): ' )
901 9995
FORMAT(
' Special Matrices:', 23x,
902 $
'(J''=transposed Jordan block)',
903 $ /
' 1=(0,0) 2=(I,0) 3=(0,I) 4=(I,I) 5=(J'',J'') ',
904 $
'6=(diag(J'',I), diag(I,J''))', /
' Diagonal Matrices: ( ',
905 $
'D=diag(0,1,2,...) )', /
' 7=(D,I) 9=(large*D, small*I',
906 $
') 11=(large*I, small*D) 13=(large*D, large*I)', /
907 $
' 8=(I,D) 10=(small*D, large*I) 12=(small*I, large*D) ',
908 $
' 14=(small*D, small*I)', /
' 15=(D, reversed D)' )
909 9994
FORMAT(
' Matrices Rotated by Random ', a,
' Matrices U, V:',
910 $ /
' 16=Transposed Jordan Blocks 19=geometric ',
911 $
'alpha, beta=0,1', /
' 17=arithm. alpha&beta ',
912 $
' 20=arithmetic alpha, beta=0,1', /
' 18=clustered ',
913 $
'alpha, beta=0,1 21=random alpha, beta=0,1',
914 $ /
' Large & Small Matrices:', /
' 22=(large, small) ',
915 $
'23=(small,large) 24=(small,small) 25=(large,large)',
916 $ /
' 26=random O(1) matrices.' )
918 9993
FORMAT( /
' Tests performed: (S is Schur, T is triangular, ',
919 $
'Q and Z are ', a,
',', / 19x,
920 $
'l and r are the appropriate left and right', / 19x,
921 $
'eigenvectors, resp., a is alpha, b is beta, and', / 19x, a,
922 $
' means ', a,
'.)', /
' Without ordering: ',
923 $ /
' 1 = | A - Q S Z', a,
924 $
' | / ( |A| n ulp ) 2 = | B - Q T Z', a,
925 $
' | / ( |B| n ulp )', /
' 3 = | I - QQ', a,
926 $
' | / ( n ulp ) 4 = | I - ZZ', a,
927 $
' | / ( n ulp )', /
' 5 = A is in Schur form S',
928 $ /
' 6 = difference between (alpha,beta)',
929 $
' and diagonals of (S,T)', /
' With ordering: ',
930 $ /
' 7 = | (A,B) - Q (S,T) Z', a,
' | / ( |(A,B)| n ulp )',
931 $ /
' 8 = | I - QQ', a,
932 $
' | / ( n ulp ) 9 = | I - ZZ', a,
933 $
' | / ( n ulp )', /
' 10 = A is in Schur form S',
934 $ /
' 11 = difference between (alpha,beta) and diagonals',
935 $
' of (S,T)', /
' 12 = SDIM is the correct number of ',
936 $
'selected eigenvalues', / )
937 9992
FORMAT(
' Matrix order=', i5,
', type=', i2,
', seed=',
938 $ 4( i4,
',' ),
' result ', i2,
' is', 0p, f8.2 )
939 9991
FORMAT(
' Matrix order=', i5,
', type=', i2,
', seed=',
940 $ 4( i4,
',' ),
' result ', i2,
' is', 1p, e10.3 )