3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
11 * SUBROUTINE ZLATM4( ITYPE, N, NZ1, NZ2, RSIGN, AMAGN, RCOND,
12 * TRIANG, IDIST, ISEED, A, LDA )
14 * .. Scalar Arguments ..
16 * INTEGER IDIST, ITYPE, LDA, N, NZ1, NZ2
17 * DOUBLE PRECISION AMAGN, RCOND, TRIANG
19 * .. Array Arguments ..
21 * COMPLEX*16 A( LDA, * )
30 *> ZLATM4 generates basic square matrices, which may later be
31 *> multiplied by others in order to produce test matrices. It is
32 *> intended mainly to be used to test the generalized eigenvalue
35 *> It first generates the diagonal and (possibly) subdiagonal,
36 *> according to the value of ITYPE, NZ1, NZ2, RSIGN, AMAGN, and RCOND.
37 *> It then fills in the upper triangle with random numbers, if TRIANG is
47 *> The "type" of matrix on the diagonal and sub-diagonal.
48 *> If ITYPE < 0, then type abs(ITYPE) is generated and then
49 *> swapped end for end (A(I,J) := A'(N-J,N-I).) See also
50 *> the description of AMAGN and RSIGN.
53 *> = 0: the zero matrix.
55 *> = 2: a transposed Jordan block.
56 *> = 3: If N is odd, then a k+1 x k+1 transposed Jordan block
57 *> followed by a k x k identity block, where k=(N-1)/2.
58 *> If N is even, then k=(N-2)/2, and a zero diagonal entry
59 *> is tacked onto the end.
61 *> Diagonal types. The diagonal consists of NZ1 zeros, then
62 *> k=N-NZ1-NZ2 nonzeros. The subdiagonal is zero. ITYPE
63 *> specifies the nonzero diagonal entries as follows:
65 *> = 5: 1, RCOND, ..., RCOND
66 *> = 6: 1, ..., 1, RCOND
67 *> = 7: 1, a, a^2, ..., a^(k-1)=RCOND
68 *> = 8: 1, 1-d, 1-2*d, ..., 1-(k-1)*d=RCOND
69 *> = 9: random numbers chosen from (RCOND,1)
70 *> = 10: random numbers with distribution IDIST (see ZLARND.)
76 *> The order of the matrix.
82 *> If abs(ITYPE) > 3, then the first NZ1 diagonal entries will
89 *> If abs(ITYPE) > 3, then the last NZ2 diagonal entries will
96 *> = .TRUE.: The diagonal and subdiagonal entries will be
97 *> multiplied by random numbers of magnitude 1.
98 *> = .FALSE.: The diagonal and subdiagonal entries will be
99 *> left as they are (usually non-negative real.)
104 *> AMAGN is DOUBLE PRECISION
105 *> The diagonal and subdiagonal entries will be multiplied by
111 *> RCOND is DOUBLE PRECISION
112 *> If abs(ITYPE) > 4, then the smallest diagonal entry will be
113 *> RCOND. RCOND must be between 0 and 1.
118 *> TRIANG is DOUBLE PRECISION
119 *> The entries above the diagonal will be random numbers with
120 *> magnitude bounded by TRIANG (i.e., random numbers multiplied
127 *> On entry, DIST specifies the type of distribution to be used
128 *> to generate a random matrix .
129 *> = 1: real and imaginary parts each UNIFORM( 0, 1 )
130 *> = 2: real and imaginary parts each UNIFORM( -1, 1 )
131 *> = 3: real and imaginary parts each NORMAL( 0, 1 )
132 *> = 4: complex number uniform in DISK( 0, 1 )
135 *> \param[in,out] ISEED
137 *> ISEED is INTEGER array, dimension (4)
138 *> On entry ISEED specifies the seed of the random number
139 *> generator. The values of ISEED are changed on exit, and can
140 *> be used in the next call to ZLATM4 to continue the same
141 *> random number sequence.
142 *> Note: ISEED(4) should be odd, for the random number generator
148 *> A is COMPLEX*16 array, dimension (LDA, N)
149 *> Array to be computed.
155 *> Leading dimension of A. Must be at least 1 and at least N.
161 *> \author Univ. of Tennessee
162 *> \author Univ. of California Berkeley
163 *> \author Univ. of Colorado Denver
166 *> \date November 2011
168 *> \ingroup complex16_eig
170 * =====================================================================
171 SUBROUTINE ZLATM4( ITYPE, N, NZ1, NZ2, RSIGN, AMAGN, RCOND,
172 $ TRIANG, IDIST, ISEED, A, LDA )
174 * -- LAPACK test routine (version 3.4.0) --
175 * -- LAPACK is a software package provided by Univ. of Tennessee, --
176 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
179 * .. Scalar Arguments ..
181 INTEGER IDIST, ITYPE, LDA, N, NZ1, NZ2
182 DOUBLE PRECISION AMAGN, RCOND, TRIANG
184 * .. Array Arguments ..
186 COMPLEX*16 A( LDA, * )
189 * =====================================================================
192 DOUBLE PRECISION ZERO, ONE
193 PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )
194 COMPLEX*16 CZERO, CONE
195 PARAMETER ( CZERO = ( 0.0D+0, 0.0D+0 ),
196 $ CONE = ( 1.0D+0, 0.0D+0 ) )
198 * .. Local Scalars ..
199 INTEGER I, ISDB, ISDE, JC, JD, JR, K, KBEG, KEND, KLEN
200 DOUBLE PRECISION ALPHA
203 * .. External Functions ..
204 DOUBLE PRECISION DLARAN
206 EXTERNAL DLARAN, ZLARND
208 * .. External Subroutines ..
211 * .. Intrinsic Functions ..
212 INTRINSIC ABS, DBLE, DCMPLX, EXP, LOG, MAX, MIN, MOD
214 * .. Executable Statements ..
218 CALL ZLASET( 'Full', N, N, CZERO, CZERO, A, LDA )
220 * Insure a correct ISEED
222 IF( MOD( ISEED( 4 ), 2 ).NE.1 )
223 $ ISEED( 4 ) = ISEED( 4 ) + 1
225 * Compute diagonal and subdiagonal according to ITYPE, NZ1, NZ2,
228 IF( ITYPE.NE.0 ) THEN
229 IF( ABS( ITYPE ).GE.4 ) THEN
230 KBEG = MAX( 1, MIN( N, NZ1+1 ) )
231 KEND = MAX( KBEG, MIN( N, N-NZ2 ) )
232 KLEN = KEND + 1 - KBEG
240 GO TO ( 10, 30, 50, 80, 100, 120, 140, 160,
241 $ 180, 200 )ABS( ITYPE )
243 * abs(ITYPE) = 1: Identity
251 * abs(ITYPE) = 2: Transposed Jordan block
261 * abs(ITYPE) = 3: Transposed Jordan block, followed by the
271 DO 70 JD = K + 2, 2*K + 1
276 * abs(ITYPE) = 4: 1,...,k
279 DO 90 JD = KBEG, KEND
280 A( JD, JD ) = DCMPLX( JD-NZ1 )
284 * abs(ITYPE) = 5: One large D value:
287 DO 110 JD = KBEG + 1, KEND
288 A( JD, JD ) = DCMPLX( RCOND )
290 A( KBEG, KBEG ) = CONE
293 * abs(ITYPE) = 6: One small D value:
296 DO 130 JD = KBEG, KEND - 1
299 A( KEND, KEND ) = DCMPLX( RCOND )
302 * abs(ITYPE) = 7: Exponentially distributed D values:
305 A( KBEG, KBEG ) = CONE
307 ALPHA = RCOND**( ONE / DBLE( KLEN-1 ) )
309 A( NZ1+I, NZ1+I ) = DCMPLX( ALPHA**DBLE( I-1 ) )
314 * abs(ITYPE) = 8: Arithmetically distributed D values:
317 A( KBEG, KBEG ) = CONE
319 ALPHA = ( ONE-RCOND ) / DBLE( KLEN-1 )
321 A( NZ1+I, NZ1+I ) = DCMPLX( DBLE( KLEN-I )*ALPHA+RCOND )
326 * abs(ITYPE) = 9: Randomly distributed D values on ( RCOND, 1):
330 DO 190 JD = KBEG, KEND
331 A( JD, JD ) = EXP( ALPHA*DLARAN( ISEED ) )
335 * abs(ITYPE) = 10: Randomly distributed D values from DIST
338 DO 210 JD = KBEG, KEND
339 A( JD, JD ) = ZLARND( IDIST, ISEED )
346 DO 230 JD = KBEG, KEND
347 A( JD, JD ) = AMAGN*DBLE( A( JD, JD ) )
349 DO 240 JD = ISDB, ISDE
350 A( JD+1, JD ) = AMAGN*DBLE( A( JD+1, JD ) )
353 * If RSIGN = .TRUE., assign random signs to diagonal and
357 DO 250 JD = KBEG, KEND
358 IF( DBLE( A( JD, JD ) ).NE.ZERO ) THEN
359 CTEMP = ZLARND( 3, ISEED )
360 CTEMP = CTEMP / ABS( CTEMP )
361 A( JD, JD ) = CTEMP*DBLE( A( JD, JD ) )
364 DO 260 JD = ISDB, ISDE
365 IF( DBLE( A( JD+1, JD ) ).NE.ZERO ) THEN
366 CTEMP = ZLARND( 3, ISEED )
367 CTEMP = CTEMP / ABS( CTEMP )
368 A( JD+1, JD ) = CTEMP*DBLE( A( JD+1, JD ) )
373 * Reverse if ITYPE < 0
375 IF( ITYPE.LT.0 ) THEN
376 DO 270 JD = KBEG, ( KBEG+KEND-1 ) / 2
378 A( JD, JD ) = A( KBEG+KEND-JD, KBEG+KEND-JD )
379 A( KBEG+KEND-JD, KBEG+KEND-JD ) = CTEMP
381 DO 280 JD = 1, ( N-1 ) / 2
382 CTEMP = A( JD+1, JD )
383 A( JD+1, JD ) = A( N+1-JD, N-JD )
384 A( N+1-JD, N-JD ) = CTEMP
390 * Fill in upper triangle
392 IF( TRIANG.NE.ZERO ) THEN
394 DO 290 JR = 1, JC - 1
395 A( JR, JC ) = TRIANG*ZLARND( IDIST, ISEED )