LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
clatmt.f
Go to the documentation of this file.
1*> \brief \b CLATMT
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8* Definition:
9* ===========
10*
11* SUBROUTINE CLATMT( M, N, DIST, ISEED, SYM, D, MODE, COND, DMAX,
12* RANK, KL, KU, PACK, A, LDA, WORK, INFO )
13*
14* .. Scalar Arguments ..
15* REAL COND, DMAX
16* INTEGER INFO, KL, KU, LDA, M, MODE, N, RANK
17* CHARACTER DIST, PACK, SYM
18* ..
19* .. Array Arguments ..
20* COMPLEX A( LDA, * ), WORK( * )
21* REAL D( * )
22* INTEGER ISEED( 4 )
23* ..
24*
25*
26*> \par Purpose:
27* =============
28*>
29*> \verbatim
30*>
31*> CLATMT generates random matrices with specified singular values
32*> (or hermitian with specified eigenvalues)
33*> for testing LAPACK programs.
34*>
35*> CLATMT operates by applying the following sequence of
36*> operations:
37*>
38*> Set the diagonal to D, where D may be input or
39*> computed according to MODE, COND, DMAX, and SYM
40*> as described below.
41*>
42*> Generate a matrix with the appropriate band structure, by one
43*> of two methods:
44*>
45*> Method A:
46*> Generate a dense M x N matrix by multiplying D on the left
47*> and the right by random unitary matrices, then:
48*>
49*> Reduce the bandwidth according to KL and KU, using
50*> Householder transformations.
51*>
52*> Method B:
53*> Convert the bandwidth-0 (i.e., diagonal) matrix to a
54*> bandwidth-1 matrix using Givens rotations, "chasing"
55*> out-of-band elements back, much as in QR; then convert
56*> the bandwidth-1 to a bandwidth-2 matrix, etc. Note
57*> that for reasonably small bandwidths (relative to M and
58*> N) this requires less storage, as a dense matrix is not
59*> generated. Also, for hermitian or symmetric matrices,
60*> only one triangle is generated.
61*>
62*> Method A is chosen if the bandwidth is a large fraction of the
63*> order of the matrix, and LDA is at least M (so a dense
64*> matrix can be stored.) Method B is chosen if the bandwidth
65*> is small (< 1/2 N for hermitian or symmetric, < .3 N+M for
66*> non-symmetric), or LDA is less than M and not less than the
67*> bandwidth.
68*>
69*> Pack the matrix if desired. Options specified by PACK are:
70*> no packing
71*> zero out upper half (if hermitian)
72*> zero out lower half (if hermitian)
73*> store the upper half columnwise (if hermitian or upper
74*> triangular)
75*> store the lower half columnwise (if hermitian or lower
76*> triangular)
77*> store the lower triangle in banded format (if hermitian or
78*> lower triangular)
79*> store the upper triangle in banded format (if hermitian or
80*> upper triangular)
81*> store the entire matrix in banded format
82*> If Method B is chosen, and band format is specified, then the
83*> matrix will be generated in the band format, so no repacking
84*> will be necessary.
85*> \endverbatim
86*
87* Arguments:
88* ==========
89*
90*> \param[in] M
91*> \verbatim
92*> M is INTEGER
93*> The number of rows of A. Not modified.
94*> \endverbatim
95*>
96*> \param[in] N
97*> \verbatim
98*> N is INTEGER
99*> The number of columns of A. N must equal M if the matrix
100*> is symmetric or hermitian (i.e., if SYM is not 'N')
101*> Not modified.
102*> \endverbatim
103*>
104*> \param[in] DIST
105*> \verbatim
106*> DIST is CHARACTER*1
107*> On entry, DIST specifies the type of distribution to be used
108*> to generate the random eigen-/singular values.
109*> 'U' => UNIFORM( 0, 1 ) ( 'U' for uniform )
110*> 'S' => UNIFORM( -1, 1 ) ( 'S' for symmetric )
111*> 'N' => NORMAL( 0, 1 ) ( 'N' for normal )
112*> Not modified.
113*> \endverbatim
114*>
115*> \param[in,out] ISEED
116*> \verbatim
117*> ISEED is INTEGER array, dimension ( 4 )
118*> On entry ISEED specifies the seed of the random number
119*> generator. They should lie between 0 and 4095 inclusive,
120*> and ISEED(4) should be odd. The random number generator
121*> uses a linear congruential sequence limited to small
122*> integers, and so should produce machine independent
123*> random numbers. The values of ISEED are changed on
124*> exit, and can be used in the next call to CLATMT
125*> to continue the same random number sequence.
126*> Changed on exit.
127*> \endverbatim
128*>
129*> \param[in] SYM
130*> \verbatim
131*> SYM is CHARACTER*1
132*> If SYM='H', the generated matrix is hermitian, with
133*> eigenvalues specified by D, COND, MODE, and DMAX; they
134*> may be positive, negative, or zero.
135*> If SYM='P', the generated matrix is hermitian, with
136*> eigenvalues (= singular values) specified by D, COND,
137*> MODE, and DMAX; they will not be negative.
138*> If SYM='N', the generated matrix is nonsymmetric, with
139*> singular values specified by D, COND, MODE, and DMAX;
140*> they will not be negative.
141*> If SYM='S', the generated matrix is (complex) symmetric,
142*> with singular values specified by D, COND, MODE, and
143*> DMAX; they will not be negative.
144*> Not modified.
145*> \endverbatim
146*>
147*> \param[in,out] D
148*> \verbatim
149*> D is REAL array, dimension ( MIN( M, N ) )
150*> This array is used to specify the singular values or
151*> eigenvalues of A (see SYM, above.) If MODE=0, then D is
152*> assumed to contain the singular/eigenvalues, otherwise
153*> they will be computed according to MODE, COND, and DMAX,
154*> and placed in D.
155*> Modified if MODE is nonzero.
156*> \endverbatim
157*>
158*> \param[in] MODE
159*> \verbatim
160*> MODE is INTEGER
161*> On entry this describes how the singular/eigenvalues are to
162*> be specified:
163*> MODE = 0 means use D as input
164*> MODE = 1 sets D(1)=1 and D(2:RANK)=1.0/COND
165*> MODE = 2 sets D(1:RANK-1)=1 and D(RANK)=1.0/COND
166*> MODE = 3 sets D(I)=COND**(-(I-1)/(RANK-1))
167*> MODE = 4 sets D(i)=1 - (i-1)/(N-1)*(1 - 1/COND)
168*> MODE = 5 sets D to random numbers in the range
169*> ( 1/COND , 1 ) such that their logarithms
170*> are uniformly distributed.
171*> MODE = 6 set D to random numbers from same distribution
172*> as the rest of the matrix.
173*> MODE < 0 has the same meaning as ABS(MODE), except that
174*> the order of the elements of D is reversed.
175*> Thus if MODE is positive, D has entries ranging from
176*> 1 to 1/COND, if negative, from 1/COND to 1,
177*> If SYM='H', and MODE is neither 0, 6, nor -6, then
178*> the elements of D will also be multiplied by a random
179*> sign (i.e., +1 or -1.)
180*> Not modified.
181*> \endverbatim
182*>
183*> \param[in] COND
184*> \verbatim
185*> COND is REAL
186*> On entry, this is used as described under MODE above.
187*> If used, it must be >= 1. Not modified.
188*> \endverbatim
189*>
190*> \param[in] DMAX
191*> \verbatim
192*> DMAX is REAL
193*> If MODE is neither -6, 0 nor 6, the contents of D, as
194*> computed according to MODE and COND, will be scaled by
195*> DMAX / max(abs(D(i))); thus, the maximum absolute eigen- or
196*> singular value (which is to say the norm) will be abs(DMAX).
197*> Note that DMAX need not be positive: if DMAX is negative
198*> (or zero), D will be scaled by a negative number (or zero).
199*> Not modified.
200*> \endverbatim
201*>
202*> \param[in] RANK
203*> \verbatim
204*> RANK is INTEGER
205*> The rank of matrix to be generated for modes 1,2,3 only.
206*> D( RANK+1:N ) = 0.
207*> Not modified.
208*> \endverbatim
209*>
210*> \param[in] KL
211*> \verbatim
212*> KL is INTEGER
213*> This specifies the lower bandwidth of the matrix. For
214*> example, KL=0 implies upper triangular, KL=1 implies upper
215*> Hessenberg, and KL being at least M-1 means that the matrix
216*> has full lower bandwidth. KL must equal KU if the matrix
217*> is symmetric or hermitian.
218*> Not modified.
219*> \endverbatim
220*>
221*> \param[in] KU
222*> \verbatim
223*> KU is INTEGER
224*> This specifies the upper bandwidth of the matrix. For
225*> example, KU=0 implies lower triangular, KU=1 implies lower
226*> Hessenberg, and KU being at least N-1 means that the matrix
227*> has full upper bandwidth. KL must equal KU if the matrix
228*> is symmetric or hermitian.
229*> Not modified.
230*> \endverbatim
231*>
232*> \param[in] PACK
233*> \verbatim
234*> PACK is CHARACTER*1
235*> This specifies packing of matrix as follows:
236*> 'N' => no packing
237*> 'U' => zero out all subdiagonal entries (if symmetric
238*> or hermitian)
239*> 'L' => zero out all superdiagonal entries (if symmetric
240*> or hermitian)
241*> 'C' => store the upper triangle columnwise (only if the
242*> matrix is symmetric, hermitian, or upper triangular)
243*> 'R' => store the lower triangle columnwise (only if the
244*> matrix is symmetric, hermitian, or lower triangular)
245*> 'B' => store the lower triangle in band storage scheme
246*> (only if the matrix is symmetric, hermitian, or
247*> lower triangular)
248*> 'Q' => store the upper triangle in band storage scheme
249*> (only if the matrix is symmetric, hermitian, or
250*> upper triangular)
251*> 'Z' => store the entire matrix in band storage scheme
252*> (pivoting can be provided for by using this
253*> option to store A in the trailing rows of
254*> the allocated storage)
255*>
256*> Using these options, the various LAPACK packed and banded
257*> storage schemes can be obtained:
258*> GB - use 'Z'
259*> PB, SB, HB, or TB - use 'B' or 'Q'
260*> PP, SP, HB, or TP - use 'C' or 'R'
261*>
262*> If two calls to CLATMT differ only in the PACK parameter,
263*> they will generate mathematically equivalent matrices.
264*> Not modified.
265*> \endverbatim
266*>
267*> \param[in,out] A
268*> \verbatim
269*> A is COMPLEX array, dimension ( LDA, N )
270*> On exit A is the desired test matrix. A is first generated
271*> in full (unpacked) form, and then packed, if so specified
272*> by PACK. Thus, the first M elements of the first N
273*> columns will always be modified. If PACK specifies a
274*> packed or banded storage scheme, all LDA elements of the
275*> first N columns will be modified; the elements of the
276*> array which do not correspond to elements of the generated
277*> matrix are set to zero.
278*> Modified.
279*> \endverbatim
280*>
281*> \param[in] LDA
282*> \verbatim
283*> LDA is INTEGER
284*> LDA specifies the first dimension of A as declared in the
285*> calling program. If PACK='N', 'U', 'L', 'C', or 'R', then
286*> LDA must be at least M. If PACK='B' or 'Q', then LDA must
287*> be at least MIN( KL, M-1) (which is equal to MIN(KU,N-1)).
288*> If PACK='Z', LDA must be large enough to hold the packed
289*> array: MIN( KU, N-1) + MIN( KL, M-1) + 1.
290*> Not modified.
291*> \endverbatim
292*>
293*> \param[out] WORK
294*> \verbatim
295*> WORK is COMPLEX array, dimension ( 3*MAX( N, M ) )
296*> Workspace.
297*> Modified.
298*> \endverbatim
299*>
300*> \param[out] INFO
301*> \verbatim
302*> INFO is INTEGER
303*> Error code. On exit, INFO will be set to one of the
304*> following values:
305*> 0 => normal return
306*> -1 => M negative or unequal to N and SYM='S', 'H', or 'P'
307*> -2 => N negative
308*> -3 => DIST illegal string
309*> -5 => SYM illegal string
310*> -7 => MODE not in range -6 to 6
311*> -8 => COND less than 1.0, and MODE neither -6, 0 nor 6
312*> -10 => KL negative
313*> -11 => KU negative, or SYM is not 'N' and KU is not equal to
314*> KL
315*> -12 => PACK illegal string, or PACK='U' or 'L', and SYM='N';
316*> or PACK='C' or 'Q' and SYM='N' and KL is not zero;
317*> or PACK='R' or 'B' and SYM='N' and KU is not zero;
318*> or PACK='U', 'L', 'C', 'R', 'B', or 'Q', and M is not
319*> N.
320*> -14 => LDA is less than M, or PACK='Z' and LDA is less than
321*> MIN(KU,N-1) + MIN(KL,M-1) + 1.
322*> 1 => Error return from SLATM7
323*> 2 => Cannot scale to DMAX (max. sing. value is 0)
324*> 3 => Error return from CLAGGE, CLAGHE or CLAGSY
325*> \endverbatim
326*
327* Authors:
328* ========
329*
330*> \author Univ. of Tennessee
331*> \author Univ. of California Berkeley
332*> \author Univ. of Colorado Denver
333*> \author NAG Ltd.
334*
335*> \ingroup complex_matgen
336*
337* =====================================================================
338 SUBROUTINE clatmt( M, N, DIST, ISEED, SYM, D, MODE, COND, DMAX,
339 $ RANK, KL, KU, PACK, A, LDA, WORK, INFO )
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*
1277 END
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
subroutine clarot(lrows, lleft, lright, nl, c, s, a, lda, xleft, xright)
CLAROT
Definition clarot.f:230
subroutine clatmt(m, n, dist, iseed, sym, d, mode, cond, dmax, rank, kl, ku, pack, a, lda, work, info)
CLATMT
Definition clatmt.f:340
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
subroutine sscal(n, sa, sx, incx)
SSCAL
Definition sscal.f:79
subroutine slatm7(mode, cond, irsign, idist, iseed, d, n, rank, info)
SLATM7
Definition slatm7.f:122