summaryrefslogtreecommitdiff
path: root/TESTING/MATGEN/zlatm5.f
blob: a1c0a6ca03801b7c4efecfbea24fea2066abf21e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
      SUBROUTINE ZLATM5( PRTYPE, M, N, A, LDA, B, LDB, C, LDC, D, LDD,
     $                   E, LDE, F, LDF, R, LDR, L, LDL, ALPHA, QBLCKA,
     $                   QBLCKB )
*
*  -- LAPACK test routine (version 3.1) --
*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
*     November 2006
*
*     .. Scalar Arguments ..
      INTEGER            LDA, LDB, LDC, LDD, LDE, LDF, LDL, LDR, M, N,
     $                   PRTYPE, QBLCKA, QBLCKB
      DOUBLE PRECISION   ALPHA
*     ..
*     .. Array Arguments ..
      COMPLEX*16         A( LDA, * ), B( LDB, * ), C( LDC, * ),
     $                   D( LDD, * ), E( LDE, * ), F( LDF, * ),
     $                   L( LDL, * ), R( LDR, * )
*     ..
*
*  Purpose
*  =======
*
*  ZLATM5 generates matrices involved in the Generalized Sylvester
*  equation:
*
*      A * R - L * B = C
*      D * R - L * E = F
*
*  They also satisfy (the diagonalization condition)
*
*   [ I -L ] ( [ A  -C ], [ D -F ] ) [ I  R ] = ( [ A    ], [ D    ] )
*   [    I ] ( [     B ]  [    E ] ) [    I ]   ( [    B ]  [    E ] )
*
*
*  Arguments
*  =========
*
*  PRTYPE  (input) INTEGER
*          "Points" to a certian type of the matrices to generate
*          (see futher details).
*
*  M       (input) INTEGER
*          Specifies the order of A and D and the number of rows in
*          C, F,  R and L.
*
*  N       (input) INTEGER
*          Specifies the order of B and E and the number of columns in
*          C, F, R and L.
*
*  A       (output) COMPLEX*16 array, dimension (LDA, M).
*          On exit A M-by-M is initialized according to PRTYPE.
*
*  LDA     (input) INTEGER
*          The leading dimension of A.
*
*  B       (output) COMPLEX*16 array, dimension (LDB, N).
*          On exit B N-by-N is initialized according to PRTYPE.
*
*  LDB     (input) INTEGER
*          The leading dimension of B.
*
*  C       (output) COMPLEX*16 array, dimension (LDC, N).
*          On exit C M-by-N is initialized according to PRTYPE.
*
*  LDC     (input) INTEGER
*          The leading dimension of C.
*
*  D       (output) COMPLEX*16 array, dimension (LDD, M).
*          On exit D M-by-M is initialized according to PRTYPE.
*
*  LDD     (input) INTEGER
*          The leading dimension of D.
*
*  E       (output) COMPLEX*16 array, dimension (LDE, N).
*          On exit E N-by-N is initialized according to PRTYPE.
*
*  LDE     (input) INTEGER
*          The leading dimension of E.
*
*  F       (output) COMPLEX*16 array, dimension (LDF, N).
*          On exit F M-by-N is initialized according to PRTYPE.
*
*  LDF     (input) INTEGER
*          The leading dimension of F.
*
*  R       (output) COMPLEX*16 array, dimension (LDR, N).
*          On exit R M-by-N is initialized according to PRTYPE.
*
*  LDR     (input) INTEGER
*          The leading dimension of R.
*
*  L       (output) COMPLEX*16 array, dimension (LDL, N).
*          On exit L M-by-N is initialized according to PRTYPE.
*
*  LDL     (input) INTEGER
*          The leading dimension of L.
*
*  ALPHA   (input) DOUBLE PRECISION
*          Parameter used in generating PRTYPE = 1 and 5 matrices.
*
*  QBLCKA  (input) INTEGER
*          When PRTYPE = 3, specifies the distance between 2-by-2
*          blocks on the diagonal in A. Otherwise, QBLCKA is not
*          referenced. QBLCKA > 1.
*
*  QBLCKB  (input) INTEGER
*          When PRTYPE = 3, specifies the distance between 2-by-2
*          blocks on the diagonal in B. Otherwise, QBLCKB is not
*          referenced. QBLCKB > 1.
*
*
*  Further Details
*  ===============
*
*  PRTYPE = 1: A and B are Jordan blocks, D and E are identity matrices
*
*             A : if (i == j) then A(i, j) = 1.0
*                 if (j == i + 1) then A(i, j) = -1.0
*                 else A(i, j) = 0.0,            i, j = 1...M
*
*             B : if (i == j) then B(i, j) = 1.0 - ALPHA
*                 if (j == i + 1) then B(i, j) = 1.0
*                 else B(i, j) = 0.0,            i, j = 1...N
*
*             D : if (i == j) then D(i, j) = 1.0
*                 else D(i, j) = 0.0,            i, j = 1...M
*
*             E : if (i == j) then E(i, j) = 1.0
*                 else E(i, j) = 0.0,            i, j = 1...N
*
*             L =  R are chosen from [-10...10],
*                  which specifies the right hand sides (C, F).
*
*  PRTYPE = 2 or 3: Triangular and/or quasi- triangular.
*
*             A : if (i <= j) then A(i, j) = [-1...1]
*                 else A(i, j) = 0.0,             i, j = 1...M
*
*                 if (PRTYPE = 3) then
*                    A(k + 1, k + 1) = A(k, k)
*                    A(k + 1, k) = [-1...1]
*                    sign(A(k, k + 1) = -(sin(A(k + 1, k))
*                        k = 1, M - 1, QBLCKA
*
*             B : if (i <= j) then B(i, j) = [-1...1]
*                 else B(i, j) = 0.0,            i, j = 1...N
*
*                 if (PRTYPE = 3) then
*                    B(k + 1, k + 1) = B(k, k)
*                    B(k + 1, k) = [-1...1]
*                    sign(B(k, k + 1) = -(sign(B(k + 1, k))
*                        k = 1, N - 1, QBLCKB
*
*             D : if (i <= j) then D(i, j) = [-1...1].
*                 else D(i, j) = 0.0,            i, j = 1...M
*
*
*             E : if (i <= j) then D(i, j) = [-1...1]
*                 else E(i, j) = 0.0,            i, j = 1...N
*
*                 L, R are chosen from [-10...10],
*                 which specifies the right hand sides (C, F).
*
*  PRTYPE = 4 Full
*             A(i, j) = [-10...10]
*             D(i, j) = [-1...1]    i,j = 1...M
*             B(i, j) = [-10...10]
*             E(i, j) = [-1...1]    i,j = 1...N
*             R(i, j) = [-10...10]
*             L(i, j) = [-1...1]    i = 1..M ,j = 1...N
*
*             L, R specifies the right hand sides (C, F).
*
*  PRTYPE = 5 special case common and/or close eigs.
*
*  =====================================================================
*
*     .. Parameters ..
      COMPLEX*16         ONE, TWO, ZERO, HALF, TWENTY
      PARAMETER          ( ONE = ( 1.0D+0, 0.0D+0 ),
     $                   TWO = ( 2.0D+0, 0.0D+0 ),
     $                   ZERO = ( 0.0D+0, 0.0D+0 ),
     $                   HALF = ( 0.5D+0, 0.0D+0 ),
     $                   TWENTY = ( 2.0D+1, 0.0D+0 ) )
*     ..
*     .. Local Scalars ..
      INTEGER            I, J, K
      COMPLEX*16         IMEPS, REEPS
*     ..
*     .. Intrinsic Functions ..
      INTRINSIC          DCMPLX, MOD, SIN
*     ..
*     .. External Subroutines ..
      EXTERNAL           ZGEMM
*     ..
*     .. Executable Statements ..
*
      IF( PRTYPE.EQ.1 ) THEN
         DO 20 I = 1, M
            DO 10 J = 1, M
               IF( I.EQ.J ) THEN
                  A( I, J ) = ONE
                  D( I, J ) = ONE
               ELSE IF( I.EQ.J-1 ) THEN
                  A( I, J ) = -ONE
                  D( I, J ) = ZERO
               ELSE
                  A( I, J ) = ZERO
                  D( I, J ) = ZERO
               END IF
   10       CONTINUE
   20    CONTINUE
*
         DO 40 I = 1, N
            DO 30 J = 1, N
               IF( I.EQ.J ) THEN
                  B( I, J ) = ONE - ALPHA
                  E( I, J ) = ONE
               ELSE IF( I.EQ.J-1 ) THEN
                  B( I, J ) = ONE
                  E( I, J ) = ZERO
               ELSE
                  B( I, J ) = ZERO
                  E( I, J ) = ZERO
               END IF
   30       CONTINUE
   40    CONTINUE
*
         DO 60 I = 1, M
            DO 50 J = 1, N
               R( I, J ) = ( HALF-SIN( DCMPLX( I / J ) ) )*TWENTY
               L( I, J ) = R( I, J )
   50       CONTINUE
   60    CONTINUE
*
      ELSE IF( PRTYPE.EQ.2 .OR. PRTYPE.EQ.3 ) THEN
         DO 80 I = 1, M
            DO 70 J = 1, M
               IF( I.LE.J ) THEN
                  A( I, J ) = ( HALF-SIN( DCMPLX( I ) ) )*TWO
                  D( I, J ) = ( HALF-SIN( DCMPLX( I*J ) ) )*TWO
               ELSE
                  A( I, J ) = ZERO
                  D( I, J ) = ZERO
               END IF
   70       CONTINUE
   80    CONTINUE
*
         DO 100 I = 1, N
            DO 90 J = 1, N
               IF( I.LE.J ) THEN
                  B( I, J ) = ( HALF-SIN( DCMPLX( I+J ) ) )*TWO
                  E( I, J ) = ( HALF-SIN( DCMPLX( J ) ) )*TWO
               ELSE
                  B( I, J ) = ZERO
                  E( I, J ) = ZERO
               END IF
   90       CONTINUE
  100    CONTINUE
*
         DO 120 I = 1, M
            DO 110 J = 1, N
               R( I, J ) = ( HALF-SIN( DCMPLX( I*J ) ) )*TWENTY
               L( I, J ) = ( HALF-SIN( DCMPLX( I+J ) ) )*TWENTY
  110       CONTINUE
  120    CONTINUE
*
         IF( PRTYPE.EQ.3 ) THEN
            IF( QBLCKA.LE.1 )
     $         QBLCKA = 2
            DO 130 K = 1, M - 1, QBLCKA
               A( K+1, K+1 ) = A( K, K )
               A( K+1, K ) = -SIN( A( K, K+1 ) )
  130       CONTINUE
*
            IF( QBLCKB.LE.1 )
     $         QBLCKB = 2
            DO 140 K = 1, N - 1, QBLCKB
               B( K+1, K+1 ) = B( K, K )
               B( K+1, K ) = -SIN( B( K, K+1 ) )
  140       CONTINUE
         END IF
*
      ELSE IF( PRTYPE.EQ.4 ) THEN
         DO 160 I = 1, M
            DO 150 J = 1, M
               A( I, J ) = ( HALF-SIN( DCMPLX( I*J ) ) )*TWENTY
               D( I, J ) = ( HALF-SIN( DCMPLX( I+J ) ) )*TWO
  150       CONTINUE
  160    CONTINUE
*
         DO 180 I = 1, N
            DO 170 J = 1, N
               B( I, J ) = ( HALF-SIN( DCMPLX( I+J ) ) )*TWENTY
               E( I, J ) = ( HALF-SIN( DCMPLX( I*J ) ) )*TWO
  170       CONTINUE
  180    CONTINUE
*
         DO 200 I = 1, M
            DO 190 J = 1, N
               R( I, J ) = ( HALF-SIN( DCMPLX( J / I ) ) )*TWENTY
               L( I, J ) = ( HALF-SIN( DCMPLX( I*J ) ) )*TWO
  190       CONTINUE
  200    CONTINUE
*
      ELSE IF( PRTYPE.GE.5 ) THEN
         REEPS = HALF*TWO*TWENTY / ALPHA
         IMEPS = ( HALF-TWO ) / ALPHA
         DO 220 I = 1, M
            DO 210 J = 1, N
               R( I, J ) = ( HALF-SIN( DCMPLX( I*J ) ) )*ALPHA / TWENTY
               L( I, J ) = ( HALF-SIN( DCMPLX( I+J ) ) )*ALPHA / TWENTY
  210       CONTINUE
  220    CONTINUE
*
         DO 230 I = 1, M
            D( I, I ) = ONE
  230    CONTINUE
*
         DO 240 I = 1, M
            IF( I.LE.4 ) THEN
               A( I, I ) = ONE
               IF( I.GT.2 )
     $            A( I, I ) = ONE + REEPS
               IF( MOD( I, 2 ).NE.0 .AND. I.LT.M ) THEN
                  A( I, I+1 ) = IMEPS
               ELSE IF( I.GT.1 ) THEN
                  A( I, I-1 ) = -IMEPS
               END IF
            ELSE IF( I.LE.8 ) THEN
               IF( I.LE.6 ) THEN
                  A( I, I ) = REEPS
               ELSE
                  A( I, I ) = -REEPS
               END IF
               IF( MOD( I, 2 ).NE.0 .AND. I.LT.M ) THEN
                  A( I, I+1 ) = ONE
               ELSE IF( I.GT.1 ) THEN
                  A( I, I-1 ) = -ONE
               END IF
            ELSE
               A( I, I ) = ONE
               IF( MOD( I, 2 ).NE.0 .AND. I.LT.M ) THEN
                  A( I, I+1 ) = IMEPS*2
               ELSE IF( I.GT.1 ) THEN
                  A( I, I-1 ) = -IMEPS*2
               END IF
            END IF
  240    CONTINUE
*
         DO 250 I = 1, N
            E( I, I ) = ONE
            IF( I.LE.4 ) THEN
               B( I, I ) = -ONE
               IF( I.GT.2 )
     $            B( I, I ) = ONE - REEPS
               IF( MOD( I, 2 ).NE.0 .AND. I.LT.N ) THEN
                  B( I, I+1 ) = IMEPS
               ELSE IF( I.GT.1 ) THEN
                  B( I, I-1 ) = -IMEPS
               END IF
            ELSE IF( I.LE.8 ) THEN
               IF( I.LE.6 ) THEN
                  B( I, I ) = REEPS
               ELSE
                  B( I, I ) = -REEPS
               END IF
               IF( MOD( I, 2 ).NE.0 .AND. I.LT.N ) THEN
                  B( I, I+1 ) = ONE + IMEPS
               ELSE IF( I.GT.1 ) THEN
                  B( I, I-1 ) = -ONE - IMEPS
               END IF
            ELSE
               B( I, I ) = ONE - REEPS
               IF( MOD( I, 2 ).NE.0 .AND. I.LT.N ) THEN
                  B( I, I+1 ) = IMEPS*2
               ELSE IF( I.GT.1 ) THEN
                  B( I, I-1 ) = -IMEPS*2
               END IF
            END IF
  250    CONTINUE
      END IF
*
*     Compute rhs (C, F)
*
      CALL ZGEMM( 'N', 'N', M, N, M, ONE, A, LDA, R, LDR, ZERO, C, LDC )
      CALL ZGEMM( 'N', 'N', M, N, N, -ONE, L, LDL, B, LDB, ONE, C, LDC )
      CALL ZGEMM( 'N', 'N', M, N, M, ONE, D, LDD, R, LDR, ZERO, F, LDF )
      CALL ZGEMM( 'N', 'N', M, N, N, -ONE, L, LDL, E, LDE, ONE, F, LDF )
*
*     End of ZLATM5
*
      END