486 SUBROUTINE clatmr( M, N, DIST, ISEED, SYM, D, MODE, COND, DMAX,
487 $ RSIGN, GRADE, DL, MODEL, CONDL, DR, MODER,
488 $ CONDR, PIVTNG, IPIVOT, KL, KU, SPARSE, ANORM,
489 $ PACK, A, LDA, IWORK, INFO )
496 CHARACTER DIST, GRADE, PACK, PIVTNG, RSIGN, SYM
497 INTEGER INFO, KL, KU, LDA, M, MODE, MODEL, MODER, N
498 REAL ANORM, COND, CONDL, CONDR, SPARSE
502 INTEGER IPIVOT( * ), ISEED( 4 ), IWORK( * )
503 COMPLEX A( LDA, * ), D( * ), DL( * ), DR( * )
510 PARAMETER ( ZERO = 0.0e0 )
512 parameter( one = 1.0e0 )
514 parameter( cone = ( 1.0e0, 0.0e0 ) )
516 parameter( czero = ( 0.0e0, 0.0e0 ) )
519 LOGICAL BADPVT, DZERO, FULBND
520 INTEGER I, IDIST, IGRADE, IISUB, IPACK, IPVTNG, IRSIGN,
521 $ ISUB, ISYM, J, JJSUB, JSUB, K, KLL, KUU, MNMIN,
522 $ mnsub, mxsub, npvts
524 COMPLEX CALPHA, CTEMP
531 REAL CLANGB, CLANGE, CLANSB, CLANSP, CLANSY
532 COMPLEX CLATM2, CLATM3
533 EXTERNAL lsame, clangb, clange,
534 $ clansb, clansp, clansy,
541 INTRINSIC abs, conjg, max, min, mod, real
552 IF( m.EQ.0 .OR. n.EQ.0 )
557 IF( lsame( dist,
'U' ) )
THEN
559 ELSE IF( lsame( dist,
'S' ) )
THEN
561 ELSE IF( lsame( dist,
'N' ) )
THEN
563 ELSE IF( lsame( dist,
'D' ) )
THEN
571 IF( lsame( sym,
'H' ) )
THEN
573 ELSE IF( lsame( sym,
'N' ) )
THEN
575 ELSE IF( lsame( sym,
'S' ) )
THEN
583 IF( lsame( rsign,
'F' ) )
THEN
585 ELSE IF( lsame( rsign,
'T' ) )
THEN
593 IF( lsame( pivtng,
'N' ) )
THEN
595 ELSE IF( lsame( pivtng,
' ' ) )
THEN
597 ELSE IF( lsame( pivtng,
'L' ) )
THEN
600 ELSE IF( lsame( pivtng,
'R' ) )
THEN
603 ELSE IF( lsame( pivtng,
'B' ) )
THEN
606 ELSE IF( lsame( pivtng,
'F' ) )
THEN
615 IF( lsame( grade,
'N' ) )
THEN
617 ELSE IF( lsame( grade,
'L' ) )
THEN
619 ELSE IF( lsame( grade,
'R' ) )
THEN
621 ELSE IF( lsame( grade,
'B' ) )
THEN
623 ELSE IF( lsame( grade,
'E' ) )
THEN
625 ELSE IF( lsame( grade,
'H' ) )
THEN
627 ELSE IF( lsame( grade,
'S' ) )
THEN
635 IF( lsame( pack,
'N' ) )
THEN
637 ELSE IF( lsame( pack,
'U' ) )
THEN
639 ELSE IF( lsame( pack,
'L' ) )
THEN
641 ELSE IF( lsame( pack,
'C' ) )
THEN
643 ELSE IF( lsame( pack,
'R' ) )
THEN
645 ELSE IF( lsame( pack,
'B' ) )
THEN
647 ELSE IF( lsame( pack,
'Q' ) )
THEN
649 ELSE IF( lsame( pack,
'Z' ) )
THEN
664 IF( igrade.EQ.4 .AND. model.EQ.0 )
THEN
666 IF( dl( i ).EQ.czero )
674 IF( ipvtng.GT.0 )
THEN
676 IF( ipivot( j ).LE.0 .OR. ipivot( j ).GT.npvts )
685 ELSE IF( m.NE.n .AND. ( isym.EQ.0 .OR. isym.EQ.2 ) )
THEN
687 ELSE IF( n.LT.0 )
THEN
689 ELSE IF( idist.EQ.-1 )
THEN
691 ELSE IF( isym.EQ.-1 )
THEN
693 ELSE IF( mode.LT.-6 .OR. mode.GT.6 )
THEN
695 ELSE IF( ( mode.NE.-6 .AND. mode.NE.0 .AND. mode.NE.6 ) .AND.
698 ELSE IF( ( mode.NE.-6 .AND. mode.NE.0 .AND. mode.NE.6 ) .AND.
699 $ irsign.EQ.-1 )
THEN
701 ELSE IF( igrade.EQ.-1 .OR. ( igrade.EQ.4 .AND. m.NE.n ) .OR.
702 $ ( ( igrade.EQ.1 .OR. igrade.EQ.2 .OR. igrade.EQ.3 .OR.
703 $ igrade.EQ.4 .OR. igrade.EQ.6 ) .AND. isym.EQ.0 ) .OR.
704 $ ( ( igrade.EQ.1 .OR. igrade.EQ.2 .OR. igrade.EQ.3 .OR.
705 $ igrade.EQ.4 .OR. igrade.EQ.5 ) .AND. isym.EQ.2 ) )
THEN
707 ELSE IF( igrade.EQ.4 .AND. dzero )
THEN
709 ELSE IF( ( igrade.EQ.1 .OR. igrade.EQ.3 .OR. igrade.EQ.4 .OR.
710 $ igrade.EQ.5 .OR. igrade.EQ.6 ) .AND.
711 $ ( model.LT.-6 .OR. model.GT.6 ) )
THEN
713 ELSE IF( ( igrade.EQ.1 .OR. igrade.EQ.3 .OR. igrade.EQ.4 .OR.
714 $ igrade.EQ.5 .OR. igrade.EQ.6 ) .AND.
715 $ ( model.NE.-6 .AND. model.NE.0 .AND. model.NE.6 ) .AND.
716 $ condl.LT.one )
THEN
718 ELSE IF( ( igrade.EQ.2 .OR. igrade.EQ.3 ) .AND.
719 $ ( moder.LT.-6 .OR. moder.GT.6 ) )
THEN
721 ELSE IF( ( igrade.EQ.2 .OR. igrade.EQ.3 ) .AND.
722 $ ( moder.NE.-6 .AND. moder.NE.0 .AND. moder.NE.6 ) .AND.
723 $ condr.LT.one )
THEN
725 ELSE IF( ipvtng.EQ.-1 .OR. ( ipvtng.EQ.3 .AND. m.NE.n ) .OR.
726 $ ( ( ipvtng.EQ.1 .OR. ipvtng.EQ.2 ) .AND. ( isym.EQ.0 .OR.
727 $ isym.EQ.2 ) ) )
THEN
729 ELSE IF( ipvtng.NE.0 .AND. badpvt )
THEN
731 ELSE IF( kl.LT.0 )
THEN
733 ELSE IF( ku.LT.0 .OR. ( ( isym.EQ.0 .OR. isym.EQ.2 ) .AND. kl.NE.
736 ELSE IF( sparse.LT.zero .OR. sparse.GT.one )
THEN
738 ELSE IF( ipack.EQ.-1 .OR. ( ( ipack.EQ.1 .OR. ipack.EQ.2 .OR.
739 $ ipack.EQ.5 .OR. ipack.EQ.6 ) .AND. isym.EQ.1 ) .OR.
740 $ ( ipack.EQ.3 .AND. isym.EQ.1 .AND. ( kl.NE.0 .OR. m.NE.
741 $ n ) ) .OR. ( ipack.EQ.4 .AND. isym.EQ.1 .AND. ( ku.NE.
742 $ 0 .OR. m.NE.n ) ) )
THEN
744 ELSE IF( ( ( ipack.EQ.0 .OR. ipack.EQ.1 .OR. ipack.EQ.2 ) .AND.
745 $ lda.LT.max( 1, m ) ) .OR. ( ( ipack.EQ.3 .OR. ipack.EQ.
746 $ 4 ) .AND. lda.LT.1 ) .OR. ( ( ipack.EQ.5 .OR. ipack.EQ.
747 $ 6 ) .AND. lda.LT.kuu+1 ) .OR.
748 $ ( ipack.EQ.7 .AND. lda.LT.kll+kuu+1 ) )
THEN
753 CALL xerbla(
'CLATMR', -info )
760 IF( kuu.EQ.n-1 .AND. kll.EQ.m-1 )
766 iseed( i ) = mod( abs( iseed( i ) ), 4096 )
769 iseed( 4 ) = 2*( iseed( 4 ) / 2 ) + 1
775 CALL clatm1( mode, cond, irsign, idist, iseed, d, mnmin, info )
780 IF( mode.NE.0 .AND. mode.NE.-6 .AND. mode.NE.6 )
THEN
786 temp = max( temp, abs( d( i ) ) )
788 IF( temp.EQ.zero .AND. dmax.NE.czero )
THEN
792 IF( temp.NE.zero )
THEN
798 d( i ) = calpha*d( i )
807 d( i ) = real( d( i ) )
813 IF( igrade.EQ.1 .OR. igrade.EQ.3 .OR. igrade.EQ.4 .OR. igrade.EQ.
814 $ 5 .OR. igrade.EQ.6 )
THEN
815 CALL clatm1( model, condl, 0, idist, iseed, dl, m, info )
824 IF( igrade.EQ.2 .OR. igrade.EQ.3 )
THEN
825 CALL clatm1( moder, condr, 0, idist, iseed, dr, n, info )
834 IF( ipvtng.GT.0 )
THEN
842 iwork( i ) = iwork( k )
846 DO 90 i = npvts, 1, -1
849 iwork( i ) = iwork( k )
865 IF( ipack.EQ.0 )
THEN
869 ctemp = clatm3( m, n, i, j, isub, jsub, kl, ku,
870 $ idist, iseed, d, igrade, dl, dr, ipvtng,
872 a( isub, jsub ) = ctemp
873 a( jsub, isub ) = conjg( ctemp )
876 ELSE IF( isym.EQ.1 )
THEN
879 ctemp = clatm3( m, n, i, j, isub, jsub, kl, ku,
880 $ idist, iseed, d, igrade, dl, dr, ipvtng,
882 a( isub, jsub ) = ctemp
885 ELSE IF( isym.EQ.2 )
THEN
888 ctemp = clatm3( m, n, i, j, isub, jsub, kl, ku,
889 $ idist, iseed, d, igrade, dl, dr, ipvtng,
891 a( isub, jsub ) = ctemp
892 a( jsub, isub ) = ctemp
897 ELSE IF( ipack.EQ.1 )
THEN
901 ctemp = clatm3( m, n, i, j, isub, jsub, kl, ku,
903 $ iseed, d, igrade, dl, dr, ipvtng, iwork,
905 mnsub = min( isub, jsub )
906 mxsub = max( isub, jsub )
907 IF( mxsub.EQ.isub .AND. isym.EQ.0 )
THEN
908 a( mnsub, mxsub ) = conjg( ctemp )
910 a( mnsub, mxsub ) = ctemp
913 $ a( mxsub, mnsub ) = czero
917 ELSE IF( ipack.EQ.2 )
THEN
921 ctemp = clatm3( m, n, i, j, isub, jsub, kl, ku,
923 $ iseed, d, igrade, dl, dr, ipvtng, iwork,
925 mnsub = min( isub, jsub )
926 mxsub = max( isub, jsub )
927 IF( mxsub.EQ.jsub .AND. isym.EQ.0 )
THEN
928 a( mxsub, mnsub ) = conjg( ctemp )
930 a( mxsub, mnsub ) = ctemp
933 $ a( mnsub, mxsub ) = czero
937 ELSE IF( ipack.EQ.3 )
THEN
941 ctemp = clatm3( m, n, i, j, isub, jsub, kl, ku,
943 $ iseed, d, igrade, dl, dr, ipvtng, iwork,
949 mnsub = min( isub, jsub )
950 mxsub = max( isub, jsub )
951 k = mxsub*( mxsub-1 ) / 2 + mnsub
955 jjsub = ( k-1 ) / lda + 1
956 iisub = k - lda*( jjsub-1 )
958 IF( mxsub.EQ.isub .AND. isym.EQ.0 )
THEN
959 a( iisub, jjsub ) = conjg( ctemp )
961 a( iisub, jjsub ) = ctemp
966 ELSE IF( ipack.EQ.4 )
THEN
970 ctemp = clatm3( m, n, i, j, isub, jsub, kl, ku,
972 $ iseed, d, igrade, dl, dr, ipvtng, iwork,
977 mnsub = min( isub, jsub )
978 mxsub = max( isub, jsub )
979 IF( mnsub.EQ.1 )
THEN
982 k = n*( n+1 ) / 2 - ( n-mnsub+1 )*( n-mnsub+2 ) /
983 $ 2 + mxsub - mnsub + 1
988 jjsub = ( k-1 ) / lda + 1
989 iisub = k - lda*( jjsub-1 )
991 IF( mxsub.EQ.jsub .AND. isym.EQ.0 )
THEN
992 a( iisub, jjsub ) = conjg( ctemp )
994 a( iisub, jjsub ) = ctemp
999 ELSE IF( ipack.EQ.5 )
THEN
1002 DO 240 i = j - kuu, j
1004 a( j-i+1, i+n ) = czero
1006 ctemp = clatm3( m, n, i, j, isub, jsub, kl, ku,
1007 $ idist, iseed, d, igrade, dl, dr, ipvtng,
1009 mnsub = min( isub, jsub )
1010 mxsub = max( isub, jsub )
1011 IF( mxsub.EQ.jsub .AND. isym.EQ.0 )
THEN
1012 a( mxsub-mnsub+1, mnsub ) = conjg( ctemp )
1014 a( mxsub-mnsub+1, mnsub ) = ctemp
1020 ELSE IF( ipack.EQ.6 )
THEN
1023 DO 260 i = j - kuu, j
1024 ctemp = clatm3( m, n, i, j, isub, jsub, kl, ku,
1026 $ iseed, d, igrade, dl, dr, ipvtng, iwork,
1028 mnsub = min( isub, jsub )
1029 mxsub = max( isub, jsub )
1030 IF( mxsub.EQ.isub .AND. isym.EQ.0 )
THEN
1031 a( mnsub-mxsub+kuu+1, mxsub ) = conjg( ctemp )
1033 a( mnsub-mxsub+kuu+1, mxsub ) = ctemp
1038 ELSE IF( ipack.EQ.7 )
THEN
1040 IF( isym.NE.1 )
THEN
1042 DO 280 i = j - kuu, j
1043 ctemp = clatm3( m, n, i, j, isub, jsub, kl, ku,
1044 $ idist, iseed, d, igrade, dl, dr, ipvtng,
1046 mnsub = min( isub, jsub )
1047 mxsub = max( isub, jsub )
1049 $ a( j-i+1+kuu, i+n ) = czero
1050 IF( mxsub.EQ.isub .AND. isym.EQ.0 )
THEN
1051 a( mnsub-mxsub+kuu+1, mxsub ) = conjg( ctemp )
1053 a( mnsub-mxsub+kuu+1, mxsub ) = ctemp
1055 IF( i.GE.1 .AND. mnsub.NE.mxsub )
THEN
1056 IF( mnsub.EQ.isub .AND. isym.EQ.0 )
THEN
1057 a( mxsub-mnsub+1+kuu,
1058 $ mnsub ) = conjg( ctemp )
1060 a( mxsub-mnsub+1+kuu, mnsub ) = ctemp
1065 ELSE IF( isym.EQ.1 )
THEN
1067 DO 300 i = j - kuu, j + kll
1068 ctemp = clatm3( m, n, i, j, isub, jsub, kl, ku,
1069 $ idist, iseed, d, igrade, dl, dr, ipvtng,
1071 a( isub-jsub+kuu+1, jsub ) = ctemp
1082 IF( ipack.EQ.0 )
THEN
1083 IF( isym.EQ.0 )
THEN
1086 a( i, j ) = clatm2( m, n, i, j, kl, ku, idist,
1087 $ iseed, d, igrade, dl, dr, ipvtng,
1089 a( j, i ) = conjg( a( i, j ) )
1092 ELSE IF( isym.EQ.1 )
THEN
1095 a( i, j ) = clatm2( m, n, i, j, kl, ku, idist,
1096 $ iseed, d, igrade, dl, dr, ipvtng,
1100 ELSE IF( isym.EQ.2 )
THEN
1103 a( i, j ) = clatm2( m, n, i, j, kl, ku, idist,
1104 $ iseed, d, igrade, dl, dr, ipvtng,
1106 a( j, i ) = a( i, j )
1111 ELSE IF( ipack.EQ.1 )
THEN
1115 a( i, j ) = clatm2( m, n, i, j, kl, ku, idist,
1117 $ d, igrade, dl, dr, ipvtng, iwork, sparse )
1123 ELSE IF( ipack.EQ.2 )
THEN
1127 IF( isym.EQ.0 )
THEN
1128 a( j, i ) = conjg( clatm2( m, n, i, j, kl, ku,
1129 $ idist, iseed, d, igrade, dl, dr,
1130 $ ipvtng, iwork, sparse ) )
1132 a( j, i ) = clatm2( m, n, i, j, kl, ku, idist,
1133 $ iseed, d, igrade, dl, dr, ipvtng,
1141 ELSE IF( ipack.EQ.3 )
THEN
1148 IF( isub.GT.lda )
THEN
1152 a( isub, jsub ) = clatm2( m, n, i, j, kl, ku,
1154 $ iseed, d, igrade, dl, dr, ipvtng,
1159 ELSE IF( ipack.EQ.4 )
THEN
1161 IF( isym.EQ.0 .OR. isym.EQ.2 )
THEN
1170 k = n*( n+1 ) / 2 - ( n-i+1 )*( n-i+2 ) / 2 +
1176 jsub = ( k-1 ) / lda + 1
1177 isub = k - lda*( jsub-1 )
1179 a( isub, jsub ) = clatm2( m, n, i, j, kl, ku,
1180 $ idist, iseed, d, igrade, dl, dr,
1181 $ ipvtng, iwork, sparse )
1183 $ a( isub, jsub ) = conjg( a( isub, jsub ) )
1192 IF( isub.GT.lda )
THEN
1196 a( isub, jsub ) = clatm2( m, n, i, j, kl, ku,
1197 $ idist, iseed, d, igrade, dl, dr,
1198 $ ipvtng, iwork, sparse )
1203 ELSE IF( ipack.EQ.5 )
THEN
1206 DO 480 i = j - kuu, j
1208 a( j-i+1, i+n ) = czero
1210 IF( isym.EQ.0 )
THEN
1211 a( j-i+1, i ) = conjg( clatm2( m, n, i, j,
1213 $ ku, idist, iseed, d, igrade, dl,
1214 $ dr, ipvtng, iwork, sparse ) )
1216 a( j-i+1, i ) = clatm2( m, n, i, j, kl, ku,
1217 $ idist, iseed, d, igrade, dl, dr,
1218 $ ipvtng, iwork, sparse )
1224 ELSE IF( ipack.EQ.6 )
THEN
1227 DO 500 i = j - kuu, j
1228 a( i-j+kuu+1, j ) = clatm2( m, n, i, j, kl, ku,
1230 $ iseed, d, igrade, dl, dr, ipvtng,
1235 ELSE IF( ipack.EQ.7 )
THEN
1237 IF( isym.NE.1 )
THEN
1239 DO 520 i = j - kuu, j
1240 a( i-j+kuu+1, j ) = clatm2( m, n, i, j, kl, ku,
1241 $ idist, iseed, d, igrade, dl,
1242 $ dr, ipvtng, iwork, sparse )
1244 $ a( j-i+1+kuu, i+n ) = czero
1245 IF( i.GE.1 .AND. i.NE.j )
THEN
1246 IF( isym.EQ.0 )
THEN
1247 a( j-i+1+kuu, i ) = conjg( a( i-j+kuu+1,
1250 a( j-i+1+kuu, i ) = a( i-j+kuu+1, j )
1255 ELSE IF( isym.EQ.1 )
THEN
1257 DO 540 i = j - kuu, j + kll
1258 a( i-j+kuu+1, j ) = clatm2( m, n, i, j, kl, ku,
1259 $ idist, iseed, d, igrade, dl,
1260 $ dr, ipvtng, iwork, sparse )
1271 IF( ipack.EQ.0 )
THEN
1272 onorm = clange(
'M', m, n, a, lda, tempa )
1273 ELSE IF( ipack.EQ.1 )
THEN
1274 onorm = clansy(
'M',
'U', n, a, lda, tempa )
1275 ELSE IF( ipack.EQ.2 )
THEN
1276 onorm = clansy(
'M',
'L', n, a, lda, tempa )
1277 ELSE IF( ipack.EQ.3 )
THEN
1278 onorm = clansp(
'M',
'U', n, a, tempa )
1279 ELSE IF( ipack.EQ.4 )
THEN
1280 onorm = clansp(
'M',
'L', n, a, tempa )
1281 ELSE IF( ipack.EQ.5 )
THEN
1282 onorm = clansb(
'M',
'L', n, kll, a, lda, tempa )
1283 ELSE IF( ipack.EQ.6 )
THEN
1284 onorm = clansb(
'M',
'U', n, kuu, a, lda, tempa )
1285 ELSE IF( ipack.EQ.7 )
THEN
1286 onorm = clangb(
'M', n, kll, kuu, a, lda, tempa )
1289 IF( anorm.GE.zero )
THEN
1291 IF( anorm.GT.zero .AND. onorm.EQ.zero )
THEN
1298 ELSE IF( ( anorm.GT.one .AND. onorm.LT.one ) .OR.
1299 $ ( anorm.LT.one .AND. onorm.GT.one ) )
THEN
1303 IF( ipack.LE.2 )
THEN
1305 CALL csscal( m, one / onorm, a( 1, j ), 1 )
1306 CALL csscal( m, anorm, a( 1, j ), 1 )
1309 ELSE IF( ipack.EQ.3 .OR. ipack.EQ.4 )
THEN
1311 CALL csscal( n*( n+1 ) / 2, one / onorm, a, 1 )
1312 CALL csscal( n*( n+1 ) / 2, anorm, a, 1 )
1314 ELSE IF( ipack.GE.5 )
THEN
1317 CALL csscal( kll+kuu+1, one / onorm, a( 1, j ), 1 )
1318 CALL csscal( kll+kuu+1, anorm, a( 1, j ), 1 )
1327 IF( ipack.LE.2 )
THEN
1329 CALL csscal( m, anorm / onorm, a( 1, j ), 1 )
1332 ELSE IF( ipack.EQ.3 .OR. ipack.EQ.4 )
THEN
1334 CALL csscal( n*( n+1 ) / 2, anorm / onorm, a, 1 )
1336 ELSE IF( ipack.GE.5 )
THEN
1339 CALL csscal( kll+kuu+1, anorm / onorm, a( 1, j ), 1 )