LAPACK  3.4.2
LAPACK: Linear Algebra PACKage
 All Files Functions Groups
clatm5.f
Go to the documentation of this file.
1 *> \brief \b CLATM5
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 CLATM5( PRTYPE, M, N, A, LDA, B, LDB, C, LDC, D, LDD,
12 * E, LDE, F, LDF, R, LDR, L, LDL, ALPHA, QBLCKA,
13 * QBLCKB )
14 *
15 * .. Scalar Arguments ..
16 * INTEGER LDA, LDB, LDC, LDD, LDE, LDF, LDL, LDR, M, N,
17 * $ PRTYPE, QBLCKA, QBLCKB
18 * REAL ALPHA
19 * ..
20 * .. Array Arguments ..
21 * COMPLEX A( LDA, * ), B( LDB, * ), C( LDC, * ),
22 * $ D( LDD, * ), E( LDE, * ), F( LDF, * ),
23 * $ L( LDL, * ), R( LDR, * )
24 * ..
25 *
26 *
27 *> \par Purpose:
28 * =============
29 *>
30 *> \verbatim
31 *>
32 *> CLATM5 generates matrices involved in the Generalized Sylvester
33 *> equation:
34 *>
35 *> A * R - L * B = C
36 *> D * R - L * E = F
37 *>
38 *> They also satisfy (the diagonalization condition)
39 *>
40 *> [ I -L ] ( [ A -C ], [ D -F ] ) [ I R ] = ( [ A ], [ D ] )
41 *> [ I ] ( [ B ] [ E ] ) [ I ] ( [ B ] [ E ] )
42 *>
43 *> \endverbatim
44 *
45 * Arguments:
46 * ==========
47 *
48 *> \param[in] PRTYPE
49 *> \verbatim
50 *> PRTYPE is INTEGER
51 *> "Points" to a certian type of the matrices to generate
52 *> (see futher details).
53 *> \endverbatim
54 *>
55 *> \param[in] M
56 *> \verbatim
57 *> M is INTEGER
58 *> Specifies the order of A and D and the number of rows in
59 *> C, F, R and L.
60 *> \endverbatim
61 *>
62 *> \param[in] N
63 *> \verbatim
64 *> N is INTEGER
65 *> Specifies the order of B and E and the number of columns in
66 *> C, F, R and L.
67 *> \endverbatim
68 *>
69 *> \param[out] A
70 *> \verbatim
71 *> A is COMPLEX array, dimension (LDA, M).
72 *> On exit A M-by-M is initialized according to PRTYPE.
73 *> \endverbatim
74 *>
75 *> \param[in] LDA
76 *> \verbatim
77 *> LDA is INTEGER
78 *> The leading dimension of A.
79 *> \endverbatim
80 *>
81 *> \param[out] B
82 *> \verbatim
83 *> B is COMPLEX array, dimension (LDB, N).
84 *> On exit B N-by-N is initialized according to PRTYPE.
85 *> \endverbatim
86 *>
87 *> \param[in] LDB
88 *> \verbatim
89 *> LDB is INTEGER
90 *> The leading dimension of B.
91 *> \endverbatim
92 *>
93 *> \param[out] C
94 *> \verbatim
95 *> C is COMPLEX array, dimension (LDC, N).
96 *> On exit C M-by-N is initialized according to PRTYPE.
97 *> \endverbatim
98 *>
99 *> \param[in] LDC
100 *> \verbatim
101 *> LDC is INTEGER
102 *> The leading dimension of C.
103 *> \endverbatim
104 *>
105 *> \param[out] D
106 *> \verbatim
107 *> D is COMPLEX array, dimension (LDD, M).
108 *> On exit D M-by-M is initialized according to PRTYPE.
109 *> \endverbatim
110 *>
111 *> \param[in] LDD
112 *> \verbatim
113 *> LDD is INTEGER
114 *> The leading dimension of D.
115 *> \endverbatim
116 *>
117 *> \param[out] E
118 *> \verbatim
119 *> E is COMPLEX array, dimension (LDE, N).
120 *> On exit E N-by-N is initialized according to PRTYPE.
121 *> \endverbatim
122 *>
123 *> \param[in] LDE
124 *> \verbatim
125 *> LDE is INTEGER
126 *> The leading dimension of E.
127 *> \endverbatim
128 *>
129 *> \param[out] F
130 *> \verbatim
131 *> F is COMPLEX array, dimension (LDF, N).
132 *> On exit F M-by-N is initialized according to PRTYPE.
133 *> \endverbatim
134 *>
135 *> \param[in] LDF
136 *> \verbatim
137 *> LDF is INTEGER
138 *> The leading dimension of F.
139 *> \endverbatim
140 *>
141 *> \param[out] R
142 *> \verbatim
143 *> R is COMPLEX array, dimension (LDR, N).
144 *> On exit R M-by-N is initialized according to PRTYPE.
145 *> \endverbatim
146 *>
147 *> \param[in] LDR
148 *> \verbatim
149 *> LDR is INTEGER
150 *> The leading dimension of R.
151 *> \endverbatim
152 *>
153 *> \param[out] L
154 *> \verbatim
155 *> L is COMPLEX array, dimension (LDL, N).
156 *> On exit L M-by-N is initialized according to PRTYPE.
157 *> \endverbatim
158 *>
159 *> \param[in] LDL
160 *> \verbatim
161 *> LDL is INTEGER
162 *> The leading dimension of L.
163 *> \endverbatim
164 *>
165 *> \param[in] ALPHA
166 *> \verbatim
167 *> ALPHA is REAL
168 *> Parameter used in generating PRTYPE = 1 and 5 matrices.
169 *> \endverbatim
170 *>
171 *> \param[in] QBLCKA
172 *> \verbatim
173 *> QBLCKA is INTEGER
174 *> When PRTYPE = 3, specifies the distance between 2-by-2
175 *> blocks on the diagonal in A. Otherwise, QBLCKA is not
176 *> referenced. QBLCKA > 1.
177 *> \endverbatim
178 *>
179 *> \param[in] QBLCKB
180 *> \verbatim
181 *> QBLCKB is INTEGER
182 *> When PRTYPE = 3, specifies the distance between 2-by-2
183 *> blocks on the diagonal in B. Otherwise, QBLCKB is not
184 *> referenced. QBLCKB > 1.
185 *> \endverbatim
186 *
187 * Authors:
188 * ========
189 *
190 *> \author Univ. of Tennessee
191 *> \author Univ. of California Berkeley
192 *> \author Univ. of Colorado Denver
193 *> \author NAG Ltd.
194 *
195 *> \date November 2011
196 *
197 *> \ingroup complex_matgen
198 *
199 *> \par Further Details:
200 * =====================
201 *>
202 *> \verbatim
203 *>
204 *> PRTYPE = 1: A and B are Jordan blocks, D and E are identity matrices
205 *>
206 *> A : if (i == j) then A(i, j) = 1.0
207 *> if (j == i + 1) then A(i, j) = -1.0
208 *> else A(i, j) = 0.0, i, j = 1...M
209 *>
210 *> B : if (i == j) then B(i, j) = 1.0 - ALPHA
211 *> if (j == i + 1) then B(i, j) = 1.0
212 *> else B(i, j) = 0.0, i, j = 1...N
213 *>
214 *> D : if (i == j) then D(i, j) = 1.0
215 *> else D(i, j) = 0.0, i, j = 1...M
216 *>
217 *> E : if (i == j) then E(i, j) = 1.0
218 *> else E(i, j) = 0.0, i, j = 1...N
219 *>
220 *> L = R are chosen from [-10...10],
221 *> which specifies the right hand sides (C, F).
222 *>
223 *> PRTYPE = 2 or 3: Triangular and/or quasi- triangular.
224 *>
225 *> A : if (i <= j) then A(i, j) = [-1...1]
226 *> else A(i, j) = 0.0, i, j = 1...M
227 *>
228 *> if (PRTYPE = 3) then
229 *> A(k + 1, k + 1) = A(k, k)
230 *> A(k + 1, k) = [-1...1]
231 *> sign(A(k, k + 1) = -(sin(A(k + 1, k))
232 *> k = 1, M - 1, QBLCKA
233 *>
234 *> B : if (i <= j) then B(i, j) = [-1...1]
235 *> else B(i, j) = 0.0, i, j = 1...N
236 *>
237 *> if (PRTYPE = 3) then
238 *> B(k + 1, k + 1) = B(k, k)
239 *> B(k + 1, k) = [-1...1]
240 *> sign(B(k, k + 1) = -(sign(B(k + 1, k))
241 *> k = 1, N - 1, QBLCKB
242 *>
243 *> D : if (i <= j) then D(i, j) = [-1...1].
244 *> else D(i, j) = 0.0, i, j = 1...M
245 *>
246 *>
247 *> E : if (i <= j) then D(i, j) = [-1...1]
248 *> else E(i, j) = 0.0, i, j = 1...N
249 *>
250 *> L, R are chosen from [-10...10],
251 *> which specifies the right hand sides (C, F).
252 *>
253 *> PRTYPE = 4 Full
254 *> A(i, j) = [-10...10]
255 *> D(i, j) = [-1...1] i,j = 1...M
256 *> B(i, j) = [-10...10]
257 *> E(i, j) = [-1...1] i,j = 1...N
258 *> R(i, j) = [-10...10]
259 *> L(i, j) = [-1...1] i = 1..M ,j = 1...N
260 *>
261 *> L, R specifies the right hand sides (C, F).
262 *>
263 *> PRTYPE = 5 special case common and/or close eigs.
264 *> \endverbatim
265 *>
266 * =====================================================================
267  SUBROUTINE clatm5( PRTYPE, M, N, A, LDA, B, LDB, C, LDC, D, LDD,
268  $ e, lde, f, ldf, r, ldr, l, ldl, alpha, qblcka,
269  $ qblckb )
270 *
271 * -- LAPACK computational routine (version 3.4.0) --
272 * -- LAPACK is a software package provided by Univ. of Tennessee, --
273 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
274 * November 2011
275 *
276 * .. Scalar Arguments ..
277  INTEGER lda, ldb, ldc, ldd, lde, ldf, ldl, ldr, m, n,
278  $ prtype, qblcka, qblckb
279  REAL alpha
280 * ..
281 * .. Array Arguments ..
282  COMPLEX a( lda, * ), b( ldb, * ), c( ldc, * ),
283  $ d( ldd, * ), e( lde, * ), f( ldf, * ),
284  $ l( ldl, * ), r( ldr, * )
285 * ..
286 *
287 * =====================================================================
288 *
289 * .. Parameters ..
290  COMPLEX one, two, zero, half, twenty
291  parameter( one = ( 1.0e+0, 0.0e+0 ),
292  $ two = ( 2.0e+0, 0.0e+0 ),
293  $ zero = ( 0.0e+0, 0.0e+0 ),
294  $ half = ( 0.5e+0, 0.0e+0 ),
295  $ twenty = ( 2.0e+1, 0.0e+0 ) )
296 * ..
297 * .. Local Scalars ..
298  INTEGER i, j, k
299  COMPLEX imeps, reeps
300 * ..
301 * .. Intrinsic Functions ..
302  INTRINSIC cmplx, mod, sin
303 * ..
304 * .. External Subroutines ..
305  EXTERNAL cgemm
306 * ..
307 * .. Executable Statements ..
308 *
309  IF( prtype.EQ.1 ) THEN
310  DO 20 i = 1, m
311  DO 10 j = 1, m
312  IF( i.EQ.j ) THEN
313  a( i, j ) = one
314  d( i, j ) = one
315  ELSE IF( i.EQ.j-1 ) THEN
316  a( i, j ) = -one
317  d( i, j ) = zero
318  ELSE
319  a( i, j ) = zero
320  d( i, j ) = zero
321  END IF
322  10 continue
323  20 continue
324 *
325  DO 40 i = 1, n
326  DO 30 j = 1, n
327  IF( i.EQ.j ) THEN
328  b( i, j ) = one - alpha
329  e( i, j ) = one
330  ELSE IF( i.EQ.j-1 ) THEN
331  b( i, j ) = one
332  e( i, j ) = zero
333  ELSE
334  b( i, j ) = zero
335  e( i, j ) = zero
336  END IF
337  30 continue
338  40 continue
339 *
340  DO 60 i = 1, m
341  DO 50 j = 1, n
342  r( i, j ) = ( half-sin( cmplx( i / j ) ) )*twenty
343  l( i, j ) = r( i, j )
344  50 continue
345  60 continue
346 *
347  ELSE IF( prtype.EQ.2 .OR. prtype.EQ.3 ) THEN
348  DO 80 i = 1, m
349  DO 70 j = 1, m
350  IF( i.LE.j ) THEN
351  a( i, j ) = ( half-sin( cmplx( i ) ) )*two
352  d( i, j ) = ( half-sin( cmplx( i*j ) ) )*two
353  ELSE
354  a( i, j ) = zero
355  d( i, j ) = zero
356  END IF
357  70 continue
358  80 continue
359 *
360  DO 100 i = 1, n
361  DO 90 j = 1, n
362  IF( i.LE.j ) THEN
363  b( i, j ) = ( half-sin( cmplx( i+j ) ) )*two
364  e( i, j ) = ( half-sin( cmplx( j ) ) )*two
365  ELSE
366  b( i, j ) = zero
367  e( i, j ) = zero
368  END IF
369  90 continue
370  100 continue
371 *
372  DO 120 i = 1, m
373  DO 110 j = 1, n
374  r( i, j ) = ( half-sin( cmplx( i*j ) ) )*twenty
375  l( i, j ) = ( half-sin( cmplx( i+j ) ) )*twenty
376  110 continue
377  120 continue
378 *
379  IF( prtype.EQ.3 ) THEN
380  IF( qblcka.LE.1 )
381  $ qblcka = 2
382  DO 130 k = 1, m - 1, qblcka
383  a( k+1, k+1 ) = a( k, k )
384  a( k+1, k ) = -sin( a( k, k+1 ) )
385  130 continue
386 *
387  IF( qblckb.LE.1 )
388  $ qblckb = 2
389  DO 140 k = 1, n - 1, qblckb
390  b( k+1, k+1 ) = b( k, k )
391  b( k+1, k ) = -sin( b( k, k+1 ) )
392  140 continue
393  END IF
394 *
395  ELSE IF( prtype.EQ.4 ) THEN
396  DO 160 i = 1, m
397  DO 150 j = 1, m
398  a( i, j ) = ( half-sin( cmplx( i*j ) ) )*twenty
399  d( i, j ) = ( half-sin( cmplx( i+j ) ) )*two
400  150 continue
401  160 continue
402 *
403  DO 180 i = 1, n
404  DO 170 j = 1, n
405  b( i, j ) = ( half-sin( cmplx( i+j ) ) )*twenty
406  e( i, j ) = ( half-sin( cmplx( i*j ) ) )*two
407  170 continue
408  180 continue
409 *
410  DO 200 i = 1, m
411  DO 190 j = 1, n
412  r( i, j ) = ( half-sin( cmplx( j / i ) ) )*twenty
413  l( i, j ) = ( half-sin( cmplx( i*j ) ) )*two
414  190 continue
415  200 continue
416 *
417  ELSE IF( prtype.GE.5 ) THEN
418  reeps = half*two*twenty / alpha
419  imeps = ( half-two ) / alpha
420  DO 220 i = 1, m
421  DO 210 j = 1, n
422  r( i, j ) = ( half-sin( cmplx( i*j ) ) )*alpha / twenty
423  l( i, j ) = ( half-sin( cmplx( i+j ) ) )*alpha / twenty
424  210 continue
425  220 continue
426 *
427  DO 230 i = 1, m
428  d( i, i ) = one
429  230 continue
430 *
431  DO 240 i = 1, m
432  IF( i.LE.4 ) THEN
433  a( i, i ) = one
434  IF( i.GT.2 )
435  $ a( i, i ) = one + reeps
436  IF( mod( i, 2 ).NE.0 .AND. i.LT.m ) THEN
437  a( i, i+1 ) = imeps
438  ELSE IF( i.GT.1 ) THEN
439  a( i, i-1 ) = -imeps
440  END IF
441  ELSE IF( i.LE.8 ) THEN
442  IF( i.LE.6 ) THEN
443  a( i, i ) = reeps
444  ELSE
445  a( i, i ) = -reeps
446  END IF
447  IF( mod( i, 2 ).NE.0 .AND. i.LT.m ) THEN
448  a( i, i+1 ) = one
449  ELSE IF( i.GT.1 ) THEN
450  a( i, i-1 ) = -one
451  END IF
452  ELSE
453  a( i, i ) = one
454  IF( mod( i, 2 ).NE.0 .AND. i.LT.m ) THEN
455  a( i, i+1 ) = imeps*2
456  ELSE IF( i.GT.1 ) THEN
457  a( i, i-1 ) = -imeps*2
458  END IF
459  END IF
460  240 continue
461 *
462  DO 250 i = 1, n
463  e( i, i ) = one
464  IF( i.LE.4 ) THEN
465  b( i, i ) = -one
466  IF( i.GT.2 )
467  $ b( i, i ) = one - reeps
468  IF( mod( i, 2 ).NE.0 .AND. i.LT.n ) THEN
469  b( i, i+1 ) = imeps
470  ELSE IF( i.GT.1 ) THEN
471  b( i, i-1 ) = -imeps
472  END IF
473  ELSE IF( i.LE.8 ) THEN
474  IF( i.LE.6 ) THEN
475  b( i, i ) = reeps
476  ELSE
477  b( i, i ) = -reeps
478  END IF
479  IF( mod( i, 2 ).NE.0 .AND. i.LT.n ) THEN
480  b( i, i+1 ) = one + imeps
481  ELSE IF( i.GT.1 ) THEN
482  b( i, i-1 ) = -one - imeps
483  END IF
484  ELSE
485  b( i, i ) = one - reeps
486  IF( mod( i, 2 ).NE.0 .AND. i.LT.n ) THEN
487  b( i, i+1 ) = imeps*2
488  ELSE IF( i.GT.1 ) THEN
489  b( i, i-1 ) = -imeps*2
490  END IF
491  END IF
492  250 continue
493  END IF
494 *
495 * Compute rhs (C, F)
496 *
497  CALL cgemm( 'N', 'N', m, n, m, one, a, lda, r, ldr, zero, c, ldc )
498  CALL cgemm( 'N', 'N', m, n, n, -one, l, ldl, b, ldb, one, c, ldc )
499  CALL cgemm( 'N', 'N', m, n, m, one, d, ldd, r, ldr, zero, f, ldf )
500  CALL cgemm( 'N', 'N', m, n, n, -one, l, ldl, e, lde, one, f, ldf )
501 *
502 * End of CLATM5
503 *
504  END