LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ clatmt()

subroutine clatmt ( integer m,
integer n,
character dist,
integer, dimension( 4 ) iseed,
character sym,
real, dimension( * ) d,
integer mode,
real cond,
real dmax,
integer rank,
integer kl,
integer ku,
character pack,
complex, dimension( lda, * ) a,
integer lda,
complex, dimension( * ) work,
integer info )

CLATMT

Purpose:
!>
!>    CLATMT generates random matrices with specified singular values
!>    (or hermitian with specified eigenvalues)
!>    for testing LAPACK programs.
!>
!>    CLATMT operates by applying the following sequence of
!>    operations:
!>
!>      Set the diagonal to D, where D may be input or
!>         computed according to MODE, COND, DMAX, and SYM
!>         as described below.
!>
!>      Generate a matrix with the appropriate band structure, by one
!>         of two methods:
!>
!>      Method A:
!>          Generate a dense M x N matrix by multiplying D on the left
!>              and the right by random unitary matrices, then:
!>
!>          Reduce the bandwidth according to KL and KU, using
!>              Householder transformations.
!>
!>      Method B:
!>          Convert the bandwidth-0 (i.e., diagonal) matrix to a
!>              bandwidth-1 matrix using Givens rotations, 
!>              out-of-band elements back, much as in QR; then convert
!>              the bandwidth-1 to a bandwidth-2 matrix, etc.  Note
!>              that for reasonably small bandwidths (relative to M and
!>              N) this requires less storage, as a dense matrix is not
!>              generated.  Also, for hermitian or symmetric matrices,
!>              only one triangle is generated.
!>
!>      Method A is chosen if the bandwidth is a large fraction of the
!>          order of the matrix, and LDA is at least M (so a dense
!>          matrix can be stored.)  Method B is chosen if the bandwidth
!>          is small (< 1/2 N for hermitian or symmetric, < .3 N+M for
!>          non-symmetric), or LDA is less than M and not less than the
!>          bandwidth.
!>
!>      Pack the matrix if desired. Options specified by PACK are:
!>         no packing
!>         zero out upper half (if hermitian)
!>         zero out lower half (if hermitian)
!>         store the upper half columnwise (if hermitian or upper
!>               triangular)
!>         store the lower half columnwise (if hermitian or lower
!>               triangular)
!>         store the lower triangle in banded format (if hermitian or
!>               lower triangular)
!>         store the upper triangle in banded format (if hermitian or
!>               upper triangular)
!>         store the entire matrix in banded format
!>      If Method B is chosen, and band format is specified, then the
!>         matrix will be generated in the band format, so no repacking
!>         will be necessary.
!> 
Parameters
[in]M
!>          M is INTEGER
!>           The number of rows of A. Not modified.
!> 
[in]N
!>          N is INTEGER
!>           The number of columns of A. N must equal M if the matrix
!>           is symmetric or hermitian (i.e., if SYM is not 'N')
!>           Not modified.
!> 
[in]DIST
!>          DIST is CHARACTER*1
!>           On entry, DIST specifies the type of distribution to be used
!>           to generate the random eigen-/singular values.
!>           'U' => UNIFORM( 0, 1 )  ( 'U' for uniform )
!>           'S' => UNIFORM( -1, 1 ) ( 'S' for symmetric )
!>           'N' => NORMAL( 0, 1 )   ( 'N' for normal )
!>           Not modified.
!> 
[in,out]ISEED
!>          ISEED is INTEGER array, dimension ( 4 )
!>           On entry ISEED specifies the seed of the random number
!>           generator. They should lie between 0 and 4095 inclusive,
!>           and ISEED(4) should be odd. The random number generator
!>           uses a linear congruential sequence limited to small
!>           integers, and so should produce machine independent
!>           random numbers. The values of ISEED are changed on
!>           exit, and can be used in the next call to CLATMT
!>           to continue the same random number sequence.
!>           Changed on exit.
!> 
[in]SYM
!>          SYM is CHARACTER*1
!>           If SYM='H', the generated matrix is hermitian, with
!>             eigenvalues specified by D, COND, MODE, and DMAX; they
!>             may be positive, negative, or zero.
!>           If SYM='P', the generated matrix is hermitian, with
!>             eigenvalues (= singular values) specified by D, COND,
!>             MODE, and DMAX; they will not be negative.
!>           If SYM='N', the generated matrix is nonsymmetric, with
!>             singular values specified by D, COND, MODE, and DMAX;
!>             they will not be negative.
!>           If SYM='S', the generated matrix is (complex) symmetric,
!>             with singular values specified by D, COND, MODE, and
!>             DMAX; they will not be negative.
!>           Not modified.
!> 
[in,out]D
!>          D is REAL array, dimension ( MIN( M, N ) )
!>           This array is used to specify the singular values or
!>           eigenvalues of A (see SYM, above.)  If MODE=0, then D is
!>           assumed to contain the singular/eigenvalues, otherwise
!>           they will be computed according to MODE, COND, and DMAX,
!>           and placed in D.
!>           Modified if MODE is nonzero.
!> 
[in]MODE
!>          MODE is INTEGER
!>           On entry this describes how the singular/eigenvalues are to
!>           be specified:
!>           MODE = 0 means use D as input
!>           MODE = 1 sets D(1)=1 and D(2:RANK)=1.0/COND
!>           MODE = 2 sets D(1:RANK-1)=1 and D(RANK)=1.0/COND
!>           MODE = 3 sets D(I)=COND**(-(I-1)/(RANK-1))
!>           MODE = 4 sets D(i)=1 - (i-1)/(N-1)*(1 - 1/COND)
!>           MODE = 5 sets D to random numbers in the range
!>                    ( 1/COND , 1 ) such that their logarithms
!>                    are uniformly distributed.
!>           MODE = 6 set D to random numbers from same distribution
!>                    as the rest of the matrix.
!>           MODE < 0 has the same meaning as ABS(MODE), except that
!>              the order of the elements of D is reversed.
!>           Thus if MODE is positive, D has entries ranging from
!>              1 to 1/COND, if negative, from 1/COND to 1,
!>           If SYM='H', and MODE is neither 0, 6, nor -6, then
!>              the elements of D will also be multiplied by a random
!>              sign (i.e., +1 or -1.)
!>           Not modified.
!> 
[in]COND
!>          COND is REAL
!>           On entry, this is used as described under MODE above.
!>           If used, it must be >= 1. Not modified.
!> 
[in]DMAX
!>          DMAX is REAL
!>           If MODE is neither -6, 0 nor 6, the contents of D, as
!>           computed according to MODE and COND, will be scaled by
!>           DMAX / max(abs(D(i))); thus, the maximum absolute eigen- or
!>           singular value (which is to say the norm) will be abs(DMAX).
!>           Note that DMAX need not be positive: if DMAX is negative
!>           (or zero), D will be scaled by a negative number (or zero).
!>           Not modified.
!> 
[in]RANK
!>          RANK is INTEGER
!>           The rank of matrix to be generated for modes 1,2,3 only.
!>           D( RANK+1:N ) = 0.
!>           Not modified.
!> 
[in]KL
!>          KL is INTEGER
!>           This specifies the lower bandwidth of the  matrix. For
!>           example, KL=0 implies upper triangular, KL=1 implies upper
!>           Hessenberg, and KL being at least M-1 means that the matrix
!>           has full lower bandwidth.  KL must equal KU if the matrix
!>           is symmetric or hermitian.
!>           Not modified.
!> 
[in]KU
!>          KU is INTEGER
!>           This specifies the upper bandwidth of the  matrix. For
!>           example, KU=0 implies lower triangular, KU=1 implies lower
!>           Hessenberg, and KU being at least N-1 means that the matrix
!>           has full upper bandwidth.  KL must equal KU if the matrix
!>           is symmetric or hermitian.
!>           Not modified.
!> 
[in]PACK
!>          PACK is CHARACTER*1
!>           This specifies packing of matrix as follows:
!>           'N' => no packing
!>           'U' => zero out all subdiagonal entries (if symmetric
!>                  or hermitian)
!>           'L' => zero out all superdiagonal entries (if symmetric
!>                  or hermitian)
!>           'C' => store the upper triangle columnwise (only if the
!>                  matrix is symmetric, hermitian, or upper triangular)
!>           'R' => store the lower triangle columnwise (only if the
!>                  matrix is symmetric, hermitian, or lower triangular)
!>           'B' => store the lower triangle in band storage scheme
!>                  (only if the matrix is symmetric, hermitian, or
!>                  lower triangular)
!>           'Q' => store the upper triangle in band storage scheme
!>                  (only if the matrix is symmetric, hermitian, or
!>                  upper triangular)
!>           'Z' => store the entire matrix in band storage scheme
!>                      (pivoting can be provided for by using this
!>                      option to store A in the trailing rows of
!>                      the allocated storage)
!>
!>           Using these options, the various LAPACK packed and banded
!>           storage schemes can be obtained:
!>           GB                    - use 'Z'
!>           PB, SB, HB, or TB     - use 'B' or 'Q'
!>           PP, SP, HB, or TP     - use 'C' or 'R'
!>
!>           If two calls to CLATMT differ only in the PACK parameter,
!>           they will generate mathematically equivalent matrices.
!>           Not modified.
!> 
[in,out]A
!>          A is COMPLEX array, dimension ( LDA, N )
!>           On exit A is the desired test matrix.  A is first generated
!>           in full (unpacked) form, and then packed, if so specified
!>           by PACK.  Thus, the first M elements of the first N
!>           columns will always be modified.  If PACK specifies a
!>           packed or banded storage scheme, all LDA elements of the
!>           first N columns will be modified; the elements of the
!>           array which do not correspond to elements of the generated
!>           matrix are set to zero.
!>           Modified.
!> 
[in]LDA
!>          LDA is INTEGER
!>           LDA specifies the first dimension of A as declared in the
!>           calling program.  If PACK='N', 'U', 'L', 'C', or 'R', then
!>           LDA must be at least M.  If PACK='B' or 'Q', then LDA must
!>           be at least MIN( KL, M-1) (which is equal to MIN(KU,N-1)).
!>           If PACK='Z', LDA must be large enough to hold the packed
!>           array: MIN( KU, N-1) + MIN( KL, M-1) + 1.
!>           Not modified.
!> 
[out]WORK
!>          WORK is COMPLEX array, dimension ( 3*MAX( N, M ) )
!>           Workspace.
!>           Modified.
!> 
[out]INFO
!>          INFO is INTEGER
!>           Error code.  On exit, INFO will be set to one of the
!>           following values:
!>             0 => normal return
!>            -1 => M negative or unequal to N and SYM='S', 'H', or 'P'
!>            -2 => N negative
!>            -3 => DIST illegal string
!>            -5 => SYM illegal string
!>            -7 => MODE not in range -6 to 6
!>            -8 => COND less than 1.0, and MODE neither -6, 0 nor 6
!>           -10 => KL negative
!>           -11 => KU negative, or SYM is not 'N' and KU is not equal to
!>                  KL
!>           -12 => PACK illegal string, or PACK='U' or 'L', and SYM='N';
!>                  or PACK='C' or 'Q' and SYM='N' and KL is not zero;
!>                  or PACK='R' or 'B' and SYM='N' and KU is not zero;
!>                  or PACK='U', 'L', 'C', 'R', 'B', or 'Q', and M is not
!>                  N.
!>           -14 => LDA is less than M, or PACK='Z' and LDA is less than
!>                  MIN(KU,N-1) + MIN(KL,M-1) + 1.
!>            1  => Error return from SLATM7
!>            2  => Cannot scale to DMAX (max. sing. value is 0)
!>            3  => Error return from CLAGGE, CLAGHE or CLAGSY
!> 
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.

Definition at line 338 of file clatmt.f.

340*
341* -- LAPACK computational routine --
342* -- LAPACK is a software package provided by Univ. of Tennessee, --
343* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
344*
345* .. Scalar Arguments ..
346 REAL COND, DMAX
347 INTEGER INFO, KL, KU, LDA, M, MODE, N, RANK
348 CHARACTER DIST, PACK, SYM
349* ..
350* .. Array Arguments ..
351 COMPLEX A( LDA, * ), WORK( * )
352 REAL D( * )
353 INTEGER ISEED( 4 )
354* ..
355*
356* =====================================================================
357*
358* .. Parameters ..
359 REAL ZERO
360 parameter( zero = 0.0e+0 )
361 REAL ONE
362 parameter( one = 1.0e+0 )
363 COMPLEX CZERO
364 parameter( czero = ( 0.0e+0, 0.0e+0 ) )
365 REAL TWOPI
366 parameter( twopi = 6.28318530717958647692528676655900576839e+0 )
367* ..
368* .. Local Scalars ..
369 COMPLEX C, CT, CTEMP, DUMMY, EXTRA, S, ST
370 REAL ALPHA, ANGLE, REALC, TEMP
371 INTEGER I, IC, ICOL, IDIST, IENDCH, IINFO, IL, ILDA,
372 $ IOFFG, IOFFST, IPACK, IPACKG, IR, IR1, IR2,
373 $ IROW, IRSIGN, ISKEW, ISYM, ISYMPK, J, JC, JCH,
374 $ JKL, JKU, JR, K, LLB, MINLDA, MNMIN, MR, NC,
375 $ UUB
376 LOGICAL CSYM, GIVENS, ILEXTR, ILTEMP, TOPDWN
377* ..
378* .. External Functions ..
379 COMPLEX CLARND
380 REAL SLARND
381 LOGICAL LSAME
382 EXTERNAL clarnd, slarnd, lsame
383* ..
384* .. External Subroutines ..
385 EXTERNAL clagge, claghe, clagsy,
386 $ clarot, clartg, claset,
388* ..
389* .. Intrinsic Functions ..
390 INTRINSIC abs, cmplx, conjg, cos, max, min, mod, real,
391 $ sin
392* ..
393* .. Executable Statements ..
394*
395* 1) Decode and Test the input parameters.
396* Initialize flags & seed.
397*
398 info = 0
399*
400* Quick return if possible
401*
402 IF( m.EQ.0 .OR. n.EQ.0 )
403 $ RETURN
404*
405* Decode DIST
406*
407 IF( lsame( dist, 'U' ) ) THEN
408 idist = 1
409 ELSE IF( lsame( dist, 'S' ) ) THEN
410 idist = 2
411 ELSE IF( lsame( dist, 'N' ) ) THEN
412 idist = 3
413 ELSE
414 idist = -1
415 END IF
416*
417* Decode SYM
418*
419 IF( lsame( sym, 'N' ) ) THEN
420 isym = 1
421 irsign = 0
422 csym = .false.
423 ELSE IF( lsame( sym, 'P' ) ) THEN
424 isym = 2
425 irsign = 0
426 csym = .false.
427 ELSE IF( lsame( sym, 'S' ) ) THEN
428 isym = 2
429 irsign = 0
430 csym = .true.
431 ELSE IF( lsame( sym, 'H' ) ) THEN
432 isym = 2
433 irsign = 1
434 csym = .false.
435 ELSE
436 isym = -1
437 END IF
438*
439* Decode PACK
440*
441 isympk = 0
442 IF( lsame( pack, 'N' ) ) THEN
443 ipack = 0
444 ELSE IF( lsame( pack, 'U' ) ) THEN
445 ipack = 1
446 isympk = 1
447 ELSE IF( lsame( pack, 'L' ) ) THEN
448 ipack = 2
449 isympk = 1
450 ELSE IF( lsame( pack, 'C' ) ) THEN
451 ipack = 3
452 isympk = 2
453 ELSE IF( lsame( pack, 'R' ) ) THEN
454 ipack = 4
455 isympk = 3
456 ELSE IF( lsame( pack, 'B' ) ) THEN
457 ipack = 5
458 isympk = 3
459 ELSE IF( lsame( pack, 'Q' ) ) THEN
460 ipack = 6
461 isympk = 2
462 ELSE IF( lsame( pack, 'Z' ) ) THEN
463 ipack = 7
464 ELSE
465 ipack = -1
466 END IF
467*
468* Set certain internal parameters
469*
470 mnmin = min( m, n )
471 llb = min( kl, m-1 )
472 uub = min( ku, n-1 )
473 mr = min( m, n+llb )
474 nc = min( n, m+uub )
475*
476 IF( ipack.EQ.5 .OR. ipack.EQ.6 ) THEN
477 minlda = uub + 1
478 ELSE IF( ipack.EQ.7 ) THEN
479 minlda = llb + uub + 1
480 ELSE
481 minlda = m
482 END IF
483*
484* Use Givens rotation method if bandwidth small enough,
485* or if LDA is too small to store the matrix unpacked.
486*
487 givens = .false.
488 IF( isym.EQ.1 ) THEN
489 IF( real( llb+uub ).LT.0.3*real( max( 1, mr+nc ) ) )
490 $ givens = .true.
491 ELSE
492 IF( 2*llb.LT.m )
493 $ givens = .true.
494 END IF
495 IF( lda.LT.m .AND. lda.GE.minlda )
496 $ givens = .true.
497*
498* Set INFO if an error
499*
500 IF( m.LT.0 ) THEN
501 info = -1
502 ELSE IF( m.NE.n .AND. isym.NE.1 ) THEN
503 info = -1
504 ELSE IF( n.LT.0 ) THEN
505 info = -2
506 ELSE IF( idist.EQ.-1 ) THEN
507 info = -3
508 ELSE IF( isym.EQ.-1 ) THEN
509 info = -5
510 ELSE IF( abs( mode ).GT.6 ) THEN
511 info = -7
512 ELSE IF( ( mode.NE.0 .AND. abs( mode ).NE.6 ) .AND. cond.LT.one )
513 $ THEN
514 info = -8
515 ELSE IF( kl.LT.0 ) THEN
516 info = -10
517 ELSE IF( ku.LT.0 .OR. ( isym.NE.1 .AND. kl.NE.ku ) ) THEN
518 info = -11
519 ELSE IF( ipack.EQ.-1 .OR. ( isympk.EQ.1 .AND. isym.EQ.1 ) .OR.
520 $ ( isympk.EQ.2 .AND. isym.EQ.1 .AND. kl.GT.0 ) .OR.
521 $ ( isympk.EQ.3 .AND. isym.EQ.1 .AND. ku.GT.0 ) .OR.
522 $ ( isympk.NE.0 .AND. m.NE.n ) ) THEN
523 info = -12
524 ELSE IF( lda.LT.max( 1, minlda ) ) THEN
525 info = -14
526 END IF
527*
528 IF( info.NE.0 ) THEN
529 CALL xerbla( 'CLATMT', -info )
530 RETURN
531 END IF
532*
533* Initialize random number generator
534*
535 DO 100 i = 1, 4
536 iseed( i ) = mod( abs( iseed( i ) ), 4096 )
537 100 CONTINUE
538*
539 IF( mod( iseed( 4 ), 2 ).NE.1 )
540 $ iseed( 4 ) = iseed( 4 ) + 1
541*
542* 2) Set up D if indicated.
543*
544* Compute D according to COND and MODE
545*
546 CALL slatm7( mode, cond, irsign, idist, iseed, d, mnmin, rank,
547 $ iinfo )
548 IF( iinfo.NE.0 ) THEN
549 info = 1
550 RETURN
551 END IF
552*
553* Choose Top-Down if D is (apparently) increasing,
554* Bottom-Up if D is (apparently) decreasing.
555*
556 IF( abs( d( 1 ) ).LE.abs( d( rank ) ) ) THEN
557 topdwn = .true.
558 ELSE
559 topdwn = .false.
560 END IF
561*
562 IF( mode.NE.0 .AND. abs( mode ).NE.6 ) THEN
563*
564* Scale by DMAX
565*
566 temp = abs( d( 1 ) )
567 DO 110 i = 2, rank
568 temp = max( temp, abs( d( i ) ) )
569 110 CONTINUE
570*
571 IF( temp.GT.zero ) THEN
572 alpha = dmax / temp
573 ELSE
574 info = 2
575 RETURN
576 END IF
577*
578 CALL sscal( rank, alpha, d, 1 )
579*
580 END IF
581*
582 CALL claset( 'Full', lda, n, czero, czero, a, lda )
583*
584* 3) Generate Banded Matrix using Givens rotations.
585* Also the special case of UUB=LLB=0
586*
587* Compute Addressing constants to cover all
588* storage formats. Whether GE, HE, SY, GB, HB, or SB,
589* upper or lower triangle or both,
590* the (i,j)-th element is in
591* A( i - ISKEW*j + IOFFST, j )
592*
593 IF( ipack.GT.4 ) THEN
594 ilda = lda - 1
595 iskew = 1
596 IF( ipack.GT.5 ) THEN
597 ioffst = uub + 1
598 ELSE
599 ioffst = 1
600 END IF
601 ELSE
602 ilda = lda
603 iskew = 0
604 ioffst = 0
605 END IF
606*
607* IPACKG is the format that the matrix is generated in. If this is
608* different from IPACK, then the matrix must be repacked at the
609* end. It also signals how to compute the norm, for scaling.
610*
611 ipackg = 0
612*
613* Diagonal Matrix -- We are done, unless it
614* is to be stored HP/SP/PP/TP (PACK='R' or 'C')
615*
616 IF( llb.EQ.0 .AND. uub.EQ.0 ) THEN
617 DO 120 j = 1, mnmin
618 a( ( 1-iskew )*j+ioffst, j ) = cmplx( d( j ) )
619 120 CONTINUE
620*
621 IF( ipack.LE.2 .OR. ipack.GE.5 )
622 $ ipackg = ipack
623*
624 ELSE IF( givens ) THEN
625*
626* Check whether to use Givens rotations,
627* Householder transformations, or nothing.
628*
629 IF( isym.EQ.1 ) THEN
630*
631* Non-symmetric -- A = U D V
632*
633 IF( ipack.GT.4 ) THEN
634 ipackg = ipack
635 ELSE
636 ipackg = 0
637 END IF
638*
639 DO 130 j = 1, mnmin
640 a( ( 1-iskew )*j+ioffst, j ) = cmplx( d( j ) )
641 130 CONTINUE
642*
643 IF( topdwn ) THEN
644 jkl = 0
645 DO 160 jku = 1, uub
646*
647* Transform from bandwidth JKL, JKU-1 to JKL, JKU
648*
649* Last row actually rotated is M
650* Last column actually rotated is MIN( M+JKU, N )
651*
652 DO 150 jr = 1, min( m+jku, n ) + jkl - 1
653 extra = czero
654 angle = twopi*slarnd( 1, iseed )
655 c = cos( angle )*clarnd( 5, iseed )
656 s = sin( angle )*clarnd( 5, iseed )
657 icol = max( 1, jr-jkl )
658 IF( jr.LT.m ) THEN
659 il = min( n, jr+jku ) + 1 - icol
660 CALL clarot( .true., jr.GT.jkl, .false., il,
661 $ c,
662 $ s, a( jr-iskew*icol+ioffst, icol ),
663 $ ilda, extra, dummy )
664 END IF
665*
666* Chase "EXTRA" back up
667*
668 ir = jr
669 ic = icol
670 DO 140 jch = jr - jkl, 1, -jkl - jku
671 IF( ir.LT.m ) THEN
672 CALL clartg( a( ir+1-iskew*( ic+1 )+ioffst,
673 $ ic+1 ), extra, realc, s, dummy )
674 dummy = clarnd( 5, iseed )
675 c = conjg( realc*dummy )
676 s = conjg( -s*dummy )
677 END IF
678 irow = max( 1, jch-jku )
679 il = ir + 2 - irow
680 ctemp = czero
681 iltemp = jch.GT.jku
682 CALL clarot( .false., iltemp, .true., il, c,
683 $ s,
684 $ a( irow-iskew*ic+ioffst, ic ),
685 $ ilda, ctemp, extra )
686 IF( iltemp ) THEN
687 CALL clartg( a( irow+1-iskew*( ic+1 )+ioffst,
688 $ ic+1 ), ctemp, realc, s, dummy )
689 dummy = clarnd( 5, iseed )
690 c = conjg( realc*dummy )
691 s = conjg( -s*dummy )
692*
693 icol = max( 1, jch-jku-jkl )
694 il = ic + 2 - icol
695 extra = czero
696 CALL clarot( .true., jch.GT.jku+jkl,
697 $ .true.,
698 $ il, c, s, a( irow-iskew*icol+
699 $ ioffst, icol ), ilda, extra,
700 $ ctemp )
701 ic = icol
702 ir = irow
703 END IF
704 140 CONTINUE
705 150 CONTINUE
706 160 CONTINUE
707*
708 jku = uub
709 DO 190 jkl = 1, llb
710*
711* Transform from bandwidth JKL-1, JKU to JKL, JKU
712*
713 DO 180 jc = 1, min( n+jkl, m ) + jku - 1
714 extra = czero
715 angle = twopi*slarnd( 1, iseed )
716 c = cos( angle )*clarnd( 5, iseed )
717 s = sin( angle )*clarnd( 5, iseed )
718 irow = max( 1, jc-jku )
719 IF( jc.LT.n ) THEN
720 il = min( m, jc+jkl ) + 1 - irow
721 CALL clarot( .false., jc.GT.jku, .false., il,
722 $ c,
723 $ s, a( irow-iskew*jc+ioffst, jc ),
724 $ ilda, extra, dummy )
725 END IF
726*
727* Chase "EXTRA" back up
728*
729 ic = jc
730 ir = irow
731 DO 170 jch = jc - jku, 1, -jkl - jku
732 IF( ic.LT.n ) THEN
733 CALL clartg( a( ir+1-iskew*( ic+1 )+ioffst,
734 $ ic+1 ), extra, realc, s, dummy )
735 dummy = clarnd( 5, iseed )
736 c = conjg( realc*dummy )
737 s = conjg( -s*dummy )
738 END IF
739 icol = max( 1, jch-jkl )
740 il = ic + 2 - icol
741 ctemp = czero
742 iltemp = jch.GT.jkl
743 CALL clarot( .true., iltemp, .true., il, c,
744 $ s,
745 $ a( ir-iskew*icol+ioffst, icol ),
746 $ ilda, ctemp, extra )
747 IF( iltemp ) THEN
748 CALL clartg( a( ir+1-iskew*( icol+1 )+ioffst,
749 $ icol+1 ), ctemp, realc, s,
750 $ dummy )
751 dummy = clarnd( 5, iseed )
752 c = conjg( realc*dummy )
753 s = conjg( -s*dummy )
754 irow = max( 1, jch-jkl-jku )
755 il = ir + 2 - irow
756 extra = czero
757 CALL clarot( .false., jch.GT.jkl+jku,
758 $ .true.,
759 $ il, c, s, a( irow-iskew*icol+
760 $ ioffst, icol ), ilda, extra,
761 $ ctemp )
762 ic = icol
763 ir = irow
764 END IF
765 170 CONTINUE
766 180 CONTINUE
767 190 CONTINUE
768*
769 ELSE
770*
771* Bottom-Up -- Start at the bottom right.
772*
773 jkl = 0
774 DO 220 jku = 1, uub
775*
776* Transform from bandwidth JKL, JKU-1 to JKL, JKU
777*
778* First row actually rotated is M
779* First column actually rotated is MIN( M+JKU, N )
780*
781 iendch = min( m, n+jkl ) - 1
782 DO 210 jc = min( m+jku, n ) - 1, 1 - jkl, -1
783 extra = czero
784 angle = twopi*slarnd( 1, iseed )
785 c = cos( angle )*clarnd( 5, iseed )
786 s = sin( angle )*clarnd( 5, iseed )
787 irow = max( 1, jc-jku+1 )
788 IF( jc.GT.0 ) THEN
789 il = min( m, jc+jkl+1 ) + 1 - irow
790 CALL clarot( .false., .false., jc+jkl.LT.m,
791 $ il,
792 $ c, s, a( irow-iskew*jc+ioffst,
793 $ jc ), ilda, dummy, extra )
794 END IF
795*
796* Chase "EXTRA" back down
797*
798 ic = jc
799 DO 200 jch = jc + jkl, iendch, jkl + jku
800 ilextr = ic.GT.0
801 IF( ilextr ) THEN
802 CALL clartg( a( jch-iskew*ic+ioffst, ic ),
803 $ extra, realc, s, dummy )
804 dummy = clarnd( 5, iseed )
805 c = realc*dummy
806 s = s*dummy
807 END IF
808 ic = max( 1, ic )
809 icol = min( n-1, jch+jku )
810 iltemp = jch + jku.LT.n
811 ctemp = czero
812 CALL clarot( .true., ilextr, iltemp,
813 $ icol+2-ic,
814 $ c, s, a( jch-iskew*ic+ioffst, ic ),
815 $ ilda, extra, ctemp )
816 IF( iltemp ) THEN
817 CALL clartg( a( jch-iskew*icol+ioffst,
818 $ icol ), ctemp, realc, s, dummy )
819 dummy = clarnd( 5, iseed )
820 c = realc*dummy
821 s = s*dummy
822 il = min( iendch, jch+jkl+jku ) + 2 - jch
823 extra = czero
824 CALL clarot( .false., .true.,
825 $ jch+jkl+jku.LE.iendch, il, c, s,
826 $ a( jch-iskew*icol+ioffst,
827 $ icol ), ilda, ctemp, extra )
828 ic = icol
829 END IF
830 200 CONTINUE
831 210 CONTINUE
832 220 CONTINUE
833*
834 jku = uub
835 DO 250 jkl = 1, llb
836*
837* Transform from bandwidth JKL-1, JKU to JKL, JKU
838*
839* First row actually rotated is MIN( N+JKL, M )
840* First column actually rotated is N
841*
842 iendch = min( n, m+jku ) - 1
843 DO 240 jr = min( n+jkl, m ) - 1, 1 - jku, -1
844 extra = czero
845 angle = twopi*slarnd( 1, iseed )
846 c = cos( angle )*clarnd( 5, iseed )
847 s = sin( angle )*clarnd( 5, iseed )
848 icol = max( 1, jr-jkl+1 )
849 IF( jr.GT.0 ) THEN
850 il = min( n, jr+jku+1 ) + 1 - icol
851 CALL clarot( .true., .false., jr+jku.LT.n,
852 $ il,
853 $ c, s, a( jr-iskew*icol+ioffst,
854 $ icol ), ilda, dummy, extra )
855 END IF
856*
857* Chase "EXTRA" back down
858*
859 ir = jr
860 DO 230 jch = jr + jku, iendch, jkl + jku
861 ilextr = ir.GT.0
862 IF( ilextr ) THEN
863 CALL clartg( a( ir-iskew*jch+ioffst, jch ),
864 $ extra, realc, s, dummy )
865 dummy = clarnd( 5, iseed )
866 c = realc*dummy
867 s = s*dummy
868 END IF
869 ir = max( 1, ir )
870 irow = min( m-1, jch+jkl )
871 iltemp = jch + jkl.LT.m
872 ctemp = czero
873 CALL clarot( .false., ilextr, iltemp,
874 $ irow+2-ir,
875 $ c, s, a( ir-iskew*jch+ioffst,
876 $ jch ), ilda, extra, ctemp )
877 IF( iltemp ) THEN
878 CALL clartg( a( irow-iskew*jch+ioffst, jch ),
879 $ ctemp, realc, s, dummy )
880 dummy = clarnd( 5, iseed )
881 c = realc*dummy
882 s = s*dummy
883 il = min( iendch, jch+jkl+jku ) + 2 - jch
884 extra = czero
885 CALL clarot( .true., .true.,
886 $ jch+jkl+jku.LE.iendch, il, c, s,
887 $ a( irow-iskew*jch+ioffst, jch ),
888 $ ilda, ctemp, extra )
889 ir = irow
890 END IF
891 230 CONTINUE
892 240 CONTINUE
893 250 CONTINUE
894*
895 END IF
896*
897 ELSE
898*
899* Symmetric -- A = U D U'
900* Hermitian -- A = U D U*
901*
902 ipackg = ipack
903 ioffg = ioffst
904*
905 IF( topdwn ) THEN
906*
907* Top-Down -- Generate Upper triangle only
908*
909 IF( ipack.GE.5 ) THEN
910 ipackg = 6
911 ioffg = uub + 1
912 ELSE
913 ipackg = 1
914 END IF
915*
916 DO 260 j = 1, mnmin
917 a( ( 1-iskew )*j+ioffg, j ) = cmplx( d( j ) )
918 260 CONTINUE
919*
920 DO 290 k = 1, uub
921 DO 280 jc = 1, n - 1
922 irow = max( 1, jc-k )
923 il = min( jc+1, k+2 )
924 extra = czero
925 ctemp = a( jc-iskew*( jc+1 )+ioffg, jc+1 )
926 angle = twopi*slarnd( 1, iseed )
927 c = cos( angle )*clarnd( 5, iseed )
928 s = sin( angle )*clarnd( 5, iseed )
929 IF( csym ) THEN
930 ct = c
931 st = s
932 ELSE
933 ctemp = conjg( ctemp )
934 ct = conjg( c )
935 st = conjg( s )
936 END IF
937 CALL clarot( .false., jc.GT.k, .true., il, c, s,
938 $ a( irow-iskew*jc+ioffg, jc ), ilda,
939 $ extra, ctemp )
940 CALL clarot( .true., .true., .false.,
941 $ min( k, n-jc )+1, ct, st,
942 $ a( ( 1-iskew )*jc+ioffg, jc ), ilda,
943 $ ctemp, dummy )
944*
945* Chase EXTRA back up the matrix
946*
947 icol = jc
948 DO 270 jch = jc - k, 1, -k
949 CALL clartg( a( jch+1-iskew*( icol+1 )+ioffg,
950 $ icol+1 ), extra, realc, s, dummy )
951 dummy = clarnd( 5, iseed )
952 c = conjg( realc*dummy )
953 s = conjg( -s*dummy )
954 ctemp = a( jch-iskew*( jch+1 )+ioffg, jch+1 )
955 IF( csym ) THEN
956 ct = c
957 st = s
958 ELSE
959 ctemp = conjg( ctemp )
960 ct = conjg( c )
961 st = conjg( s )
962 END IF
963 CALL clarot( .true., .true., .true., k+2, c,
964 $ s,
965 $ a( ( 1-iskew )*jch+ioffg, jch ),
966 $ ilda, ctemp, extra )
967 irow = max( 1, jch-k )
968 il = min( jch+1, k+2 )
969 extra = czero
970 CALL clarot( .false., jch.GT.k, .true., il,
971 $ ct,
972 $ st, a( irow-iskew*jch+ioffg, jch ),
973 $ ilda, extra, ctemp )
974 icol = jch
975 270 CONTINUE
976 280 CONTINUE
977 290 CONTINUE
978*
979* If we need lower triangle, copy from upper. Note that
980* the order of copying is chosen to work for 'q' -> 'b'
981*
982 IF( ipack.NE.ipackg .AND. ipack.NE.3 ) THEN
983 DO 320 jc = 1, n
984 irow = ioffst - iskew*jc
985 IF( csym ) THEN
986 DO 300 jr = jc, min( n, jc+uub )
987 a( jr+irow, jc ) = a( jc-iskew*jr+ioffg, jr )
988 300 CONTINUE
989 ELSE
990 DO 310 jr = jc, min( n, jc+uub )
991 a( jr+irow, jc ) = conjg( a( jc-iskew*jr+
992 $ ioffg, jr ) )
993 310 CONTINUE
994 END IF
995 320 CONTINUE
996 IF( ipack.EQ.5 ) THEN
997 DO 340 jc = n - uub + 1, n
998 DO 330 jr = n + 2 - jc, uub + 1
999 a( jr, jc ) = czero
1000 330 CONTINUE
1001 340 CONTINUE
1002 END IF
1003 IF( ipackg.EQ.6 ) THEN
1004 ipackg = ipack
1005 ELSE
1006 ipackg = 0
1007 END IF
1008 END IF
1009 ELSE
1010*
1011* Bottom-Up -- Generate Lower triangle only
1012*
1013 IF( ipack.GE.5 ) THEN
1014 ipackg = 5
1015 IF( ipack.EQ.6 )
1016 $ ioffg = 1
1017 ELSE
1018 ipackg = 2
1019 END IF
1020*
1021 DO 350 j = 1, mnmin
1022 a( ( 1-iskew )*j+ioffg, j ) = cmplx( d( j ) )
1023 350 CONTINUE
1024*
1025 DO 380 k = 1, uub
1026 DO 370 jc = n - 1, 1, -1
1027 il = min( n+1-jc, k+2 )
1028 extra = czero
1029 ctemp = a( 1+( 1-iskew )*jc+ioffg, jc )
1030 angle = twopi*slarnd( 1, iseed )
1031 c = cos( angle )*clarnd( 5, iseed )
1032 s = sin( angle )*clarnd( 5, iseed )
1033 IF( csym ) THEN
1034 ct = c
1035 st = s
1036 ELSE
1037 ctemp = conjg( ctemp )
1038 ct = conjg( c )
1039 st = conjg( s )
1040 END IF
1041 CALL clarot( .false., .true., n-jc.GT.k, il, c,
1042 $ s,
1043 $ a( ( 1-iskew )*jc+ioffg, jc ), ilda,
1044 $ ctemp, extra )
1045 icol = max( 1, jc-k+1 )
1046 CALL clarot( .true., .false., .true., jc+2-icol,
1047 $ ct, st, a( jc-iskew*icol+ioffg,
1048 $ icol ), ilda, dummy, ctemp )
1049*
1050* Chase EXTRA back down the matrix
1051*
1052 icol = jc
1053 DO 360 jch = jc + k, n - 1, k
1054 CALL clartg( a( jch-iskew*icol+ioffg, icol ),
1055 $ extra, realc, s, dummy )
1056 dummy = clarnd( 5, iseed )
1057 c = realc*dummy
1058 s = s*dummy
1059 ctemp = a( 1+( 1-iskew )*jch+ioffg, jch )
1060 IF( csym ) THEN
1061 ct = c
1062 st = s
1063 ELSE
1064 ctemp = conjg( ctemp )
1065 ct = conjg( c )
1066 st = conjg( s )
1067 END IF
1068 CALL clarot( .true., .true., .true., k+2, c,
1069 $ s,
1070 $ a( jch-iskew*icol+ioffg, icol ),
1071 $ ilda, extra, ctemp )
1072 il = min( n+1-jch, k+2 )
1073 extra = czero
1074 CALL clarot( .false., .true., n-jch.GT.k, il,
1075 $ ct, st, a( ( 1-iskew )*jch+ioffg,
1076 $ jch ), ilda, ctemp, extra )
1077 icol = jch
1078 360 CONTINUE
1079 370 CONTINUE
1080 380 CONTINUE
1081*
1082* If we need upper triangle, copy from lower. Note that
1083* the order of copying is chosen to work for 'b' -> 'q'
1084*
1085 IF( ipack.NE.ipackg .AND. ipack.NE.4 ) THEN
1086 DO 410 jc = n, 1, -1
1087 irow = ioffst - iskew*jc
1088 IF( csym ) THEN
1089 DO 390 jr = jc, max( 1, jc-uub ), -1
1090 a( jr+irow, jc ) = a( jc-iskew*jr+ioffg, jr )
1091 390 CONTINUE
1092 ELSE
1093 DO 400 jr = jc, max( 1, jc-uub ), -1
1094 a( jr+irow, jc ) = conjg( a( jc-iskew*jr+
1095 $ ioffg, jr ) )
1096 400 CONTINUE
1097 END IF
1098 410 CONTINUE
1099 IF( ipack.EQ.6 ) THEN
1100 DO 430 jc = 1, uub
1101 DO 420 jr = 1, uub + 1 - jc
1102 a( jr, jc ) = czero
1103 420 CONTINUE
1104 430 CONTINUE
1105 END IF
1106 IF( ipackg.EQ.5 ) THEN
1107 ipackg = ipack
1108 ELSE
1109 ipackg = 0
1110 END IF
1111 END IF
1112 END IF
1113*
1114* Ensure that the diagonal is real if Hermitian
1115*
1116 IF( .NOT.csym ) THEN
1117 DO 440 jc = 1, n
1118 irow = ioffst + ( 1-iskew )*jc
1119 a( irow, jc ) = cmplx( real( a( irow, jc ) ) )
1120 440 CONTINUE
1121 END IF
1122*
1123 END IF
1124*
1125 ELSE
1126*
1127* 4) Generate Banded Matrix by first
1128* Rotating by random Unitary matrices,
1129* then reducing the bandwidth using Householder
1130* transformations.
1131*
1132* Note: we should get here only if LDA .ge. N
1133*
1134 IF( isym.EQ.1 ) THEN
1135*
1136* Non-symmetric -- A = U D V
1137*
1138 CALL clagge( mr, nc, llb, uub, d, a, lda, iseed, work,
1139 $ iinfo )
1140 ELSE
1141*
1142* Symmetric -- A = U D U' or
1143* Hermitian -- A = U D U*
1144*
1145 IF( csym ) THEN
1146 CALL clagsy( m, llb, d, a, lda, iseed, work, iinfo )
1147 ELSE
1148 CALL claghe( m, llb, d, a, lda, iseed, work, iinfo )
1149 END IF
1150 END IF
1151*
1152 IF( iinfo.NE.0 ) THEN
1153 info = 3
1154 RETURN
1155 END IF
1156 END IF
1157*
1158* 5) Pack the matrix
1159*
1160 IF( ipack.NE.ipackg ) THEN
1161 IF( ipack.EQ.1 ) THEN
1162*
1163* 'U' -- Upper triangular, not packed
1164*
1165 DO 460 j = 1, m
1166 DO 450 i = j + 1, m
1167 a( i, j ) = czero
1168 450 CONTINUE
1169 460 CONTINUE
1170*
1171 ELSE IF( ipack.EQ.2 ) THEN
1172*
1173* 'L' -- Lower triangular, not packed
1174*
1175 DO 480 j = 2, m
1176 DO 470 i = 1, j - 1
1177 a( i, j ) = czero
1178 470 CONTINUE
1179 480 CONTINUE
1180*
1181 ELSE IF( ipack.EQ.3 ) THEN
1182*
1183* 'C' -- Upper triangle packed Columnwise.
1184*
1185 icol = 1
1186 irow = 0
1187 DO 500 j = 1, m
1188 DO 490 i = 1, j
1189 irow = irow + 1
1190 IF( irow.GT.lda ) THEN
1191 irow = 1
1192 icol = icol + 1
1193 END IF
1194 a( irow, icol ) = a( i, j )
1195 490 CONTINUE
1196 500 CONTINUE
1197*
1198 ELSE IF( ipack.EQ.4 ) THEN
1199*
1200* 'R' -- Lower triangle packed Columnwise.
1201*
1202 icol = 1
1203 irow = 0
1204 DO 520 j = 1, m
1205 DO 510 i = j, m
1206 irow = irow + 1
1207 IF( irow.GT.lda ) THEN
1208 irow = 1
1209 icol = icol + 1
1210 END IF
1211 a( irow, icol ) = a( i, j )
1212 510 CONTINUE
1213 520 CONTINUE
1214*
1215 ELSE IF( ipack.GE.5 ) THEN
1216*
1217* 'B' -- The lower triangle is packed as a band matrix.
1218* 'Q' -- The upper triangle is packed as a band matrix.
1219* 'Z' -- The whole matrix is packed as a band matrix.
1220*
1221 IF( ipack.EQ.5 )
1222 $ uub = 0
1223 IF( ipack.EQ.6 )
1224 $ llb = 0
1225*
1226 DO 540 j = 1, uub
1227 DO 530 i = min( j+llb, m ), 1, -1
1228 a( i-j+uub+1, j ) = a( i, j )
1229 530 CONTINUE
1230 540 CONTINUE
1231*
1232 DO 560 j = uub + 2, n
1233 DO 550 i = j - uub, min( j+llb, m )
1234 a( i-j+uub+1, j ) = a( i, j )
1235 550 CONTINUE
1236 560 CONTINUE
1237 END IF
1238*
1239* If packed, zero out extraneous elements.
1240*
1241* Symmetric/Triangular Packed --
1242* zero out everything after A(IROW,ICOL)
1243*
1244 IF( ipack.EQ.3 .OR. ipack.EQ.4 ) THEN
1245 DO 580 jc = icol, m
1246 DO 570 jr = irow + 1, lda
1247 a( jr, jc ) = czero
1248 570 CONTINUE
1249 irow = 0
1250 580 CONTINUE
1251*
1252 ELSE IF( ipack.GE.5 ) THEN
1253*
1254* Packed Band --
1255* 1st row is now in A( UUB+2-j, j), zero above it
1256* m-th row is now in A( M+UUB-j,j), zero below it
1257* last non-zero diagonal is now in A( UUB+LLB+1,j ),
1258* zero below it, too.
1259*
1260 ir1 = uub + llb + 2
1261 ir2 = uub + m + 2
1262 DO 610 jc = 1, n
1263 DO 590 jr = 1, uub + 1 - jc
1264 a( jr, jc ) = czero
1265 590 CONTINUE
1266 DO 600 jr = max( 1, min( ir1, ir2-jc ) ), lda
1267 a( jr, jc ) = czero
1268 600 CONTINUE
1269 610 CONTINUE
1270 END IF
1271 END IF
1272*
1273 RETURN
1274*
1275* End of CLATMT
1276*
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine clagge(m, n, kl, ku, d, a, lda, iseed, work, info)
CLAGGE
Definition clagge.f:114
subroutine claghe(n, k, d, a, lda, iseed, work, info)
CLAGHE
Definition claghe.f:102
subroutine clagsy(n, k, d, a, lda, iseed, work, info)
CLAGSY
Definition clagsy.f:102
complex function clarnd(idist, iseed)
CLARND
Definition clarnd.f:75
subroutine clarot(lrows, lleft, lright, nl, c, s, a, lda, xleft, xright)
CLAROT
Definition clarot.f:230
subroutine clartg(f, g, c, s, r)
CLARTG generates a plane rotation with real cosine and complex sine.
Definition clartg.f90:116
subroutine claset(uplo, m, n, alpha, beta, a, lda)
CLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
Definition claset.f:104
logical function lsame(ca, cb)
LSAME
Definition lsame.f:48
subroutine sscal(n, sa, sx, incx)
SSCAL
Definition sscal.f:79
real function slarnd(idist, iseed)
SLARND
Definition slarnd.f:73
subroutine slatm7(mode, cond, irsign, idist, iseed, d, n, rank, info)
SLATM7
Definition slatm7.f:122
Here is the call graph for this function:
Here is the caller graph for this function: