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
|
SUBROUTINE CCKCSD( NM, MVAL, PVAL, QVAL, NMATS, ISEED, THRESH,
$ MMAX, X, XF, U1, U2, V1T, V2T, THETA, IWORK,
$ WORK, RWORK, NIN, NOUT, INFO )
IMPLICIT NONE
*
* Originally CCKGSV
* -- LAPACK test routine (version 3.3.0) --
* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
* November 2010
*
* Adapted to CCKCSD
* July 2010
*
* .. Scalar Arguments ..
INTEGER INFO, NIN, NM, NMATS, MMAX, NOUT
REAL THRESH
* ..
* .. Array Arguments ..
INTEGER ISEED( 4 ), IWORK( * ), MVAL( * ), PVAL( * ),
$ QVAL( * )
REAL RWORK( * ), THETA( * )
COMPLEX U1( * ), U2( * ), V1T( * ), V2T( * ),
$ WORK( * ), X( * ), XF( * )
* ..
*
* Purpose
* =======
*
* CCKCSD tests CUNCSD:
* the CSD for an M-by-M unitary matrix X partitioned as
* [ X11 X12; X21 X22 ]. X11 is P-by-Q.
*
* Arguments
* =========
*
* NM (input) INTEGER
* The number of values of M contained in the vector MVAL.
*
* MVAL (input) INTEGER array, dimension (NM)
* The values of the matrix row dimension M.
*
* PVAL (input) INTEGER array, dimension (NM)
* The values of the matrix row dimension P.
*
* QVAL (input) INTEGER array, dimension (NM)
* The values of the matrix column dimension Q.
*
* NMATS (input) INTEGER
* The number of matrix types to be tested for each combination
* of matrix dimensions. If NMATS >= NTYPES (the maximum
* number of matrix types), then all the different types are
* generated for testing. If NMATS < NTYPES, another input line
* is read to get the numbers of the matrix types to be used.
*
* ISEED (input/output) INTEGER array, dimension (4)
* On entry, the seed of the random number generator. The array
* elements should be between 0 and 4095, otherwise they will be
* reduced mod 4096, and ISEED(4) must be odd.
* On exit, the next seed in the random number sequence after
* all the test matrices have been generated.
*
* THRESH (input) REAL
* The threshold value for the test ratios. A result is
* included in the output file if RESULT >= THRESH. To have
* every test ratio printed, use THRESH = 0.
*
* MMAX (input) INTEGER
* The maximum value permitted for M, used in dimensioning the
* work arrays.
*
* X (workspace) COMPLEX array, dimension (MMAX*MMAX)
*
* XF (workspace) COMPLEX array, dimension (MMAX*MMAX)
*
* U1 (workspace) COMPLEX array, dimension (MMAX*MMAX)
*
* U2 (workspace) COMPLEX array, dimension (MMAX*MMAX)
*
* V1T (workspace) COMPLEX array, dimension (MMAX*MMAX)
*
* V2T (workspace) COMPLEX array, dimension (MMAX*MMAX)
*
* THETA (workspace) REAL array, dimension (MMAX)
*
* IWORK (workspace) INTEGER array, dimension (MMAX)
*
* WORK (workspace) COMPLEX array
*
* RWORK (workspace) REAL array
*
* NIN (input) INTEGER
* The unit number for input.
*
* NOUT (input) INTEGER
* The unit number for output.
*
* INFO (output) INTEGER
* = 0 : successful exit
* > 0 : If CLAROR returns an error code, the absolute value
* of it is returned.
*
* =====================================================================
*
* .. Parameters ..
INTEGER NTESTS
PARAMETER ( NTESTS = 9 )
INTEGER NTYPES
PARAMETER ( NTYPES = 3 )
REAL GAPDIGIT, ORTH, PIOVER2, TEN
PARAMETER ( GAPDIGIT = 10.0E0, ORTH = 1.0E-4,
$ PIOVER2 = 1.57079632679489662E0,
$ TEN = 10.0D0 )
COMPLEX ZERO, ONE
PARAMETER ( ZERO = (0.0E0,0.0E0), ONE = (1.0E0,0.0E0) )
* ..
* .. Local Scalars ..
LOGICAL FIRSTT
CHARACTER*3 PATH
INTEGER I, IINFO, IM, IMAT, J, LDU1, LDU2, LDV1T,
$ LDV2T, LDX, LWORK, M, NFAIL, NRUN, NT, P, Q, R
* ..
* .. Local Arrays ..
LOGICAL DOTYPE( NTYPES )
DOUBLE PRECISION RESULT( NTESTS )
* ..
* .. External Subroutines ..
EXTERNAL ALAHDG, ALAREQ, ALASUM, CCSDTS, CLACSG, CLAROR,
$ CLASET
* ..
* .. Intrinsic Functions ..
INTRINSIC ABS, COS, MIN, SIN
* ..
* .. External Functions ..
REAL CLANGE, SLARND
EXTERNAL CLANGE, SLARND
* ..
* .. Executable Statements ..
*
* Initialize constants and the random number seed.
*
PATH( 1: 3 ) = 'CSD'
INFO = 0
NRUN = 0
NFAIL = 0
FIRSTT = .TRUE.
CALL ALAREQ( PATH, NMATS, DOTYPE, NTYPES, NIN, NOUT )
LDX = MMAX
LDU1 = MMAX
LDU2 = MMAX
LDV1T = MMAX
LDV2T = MMAX
LWORK = MMAX*MMAX
*
* Do for each value of M in MVAL.
*
DO 30 IM = 1, NM
M = MVAL( IM )
P = PVAL( IM )
Q = QVAL( IM )
*
DO 20 IMAT = 1, NTYPES
*
* Do the tests only if DOTYPE( IMAT ) is true.
*
IF( .NOT.DOTYPE( IMAT ) )
$ GO TO 20
*
* Generate X
*
IF( IMAT.EQ.1 ) THEN
CALL CLAROR( 'L', 'I', M, M, X, LDX, ISEED, WORK, IINFO )
IF( M .NE. 0 .AND. IINFO .NE. 0 ) THEN
WRITE( NOUT, FMT = 9999 ) M, IINFO
INFO = ABS( IINFO )
GO TO 20
END IF
ELSE IF( IMAT.EQ.2 ) THEN
R = MIN( P, M-P, Q, M-Q )
DO I = 1, R
THETA(I) = PIOVER2 * SLARND( 1, ISEED )
END DO
CALL CLACSG( M, P, Q, THETA, ISEED, X, LDX, WORK )
DO I = 1, M
DO J = 1, M
X(I+(J-1)*LDX) = X(I+(J-1)*LDX) +
$ ORTH*SLARND(2,ISEED)
END DO
END DO
ELSE
R = MIN( P, M-P, Q, M-Q )
DO I = 1, R+1
THETA(I) = TEN**(-SLARND(1,ISEED)*GAPDIGIT)
END DO
DO I = 2, R+1
THETA(I) = THETA(I-1) + THETA(I)
END DO
DO I = 1, R
THETA(I) = PIOVER2 * THETA(I) / THETA(R+1)
END DO
CALL CLACSG( M, P, Q, THETA, ISEED, X, LDX, WORK )
END IF
*
NT = 9
*
CALL CCSDTS( M, P, Q, X, XF, LDX, U1, LDU1, U2, LDU2, V1T,
$ LDV1T, V2T, LDV2T, THETA, IWORK, WORK, LWORK,
$ RWORK, RESULT )
*
* Print information about the tests that did not
* pass the threshold.
*
DO 10 I = 1, NT
IF( RESULT( I ).GE.THRESH ) THEN
IF( NFAIL.EQ.0 .AND. FIRSTT ) THEN
FIRSTT = .FALSE.
CALL ALAHDG( NOUT, PATH )
END IF
WRITE( NOUT, FMT = 9998 )M, P, Q, IMAT, I,
$ RESULT( I )
NFAIL = NFAIL + 1
END IF
10 CONTINUE
NRUN = NRUN + NT
20 CONTINUE
30 CONTINUE
*
* Print a summary of the results.
*
CALL ALASUM( PATH, NOUT, NFAIL, NRUN, 0 )
*
9999 FORMAT( ' CLAROR in CCKCSD: M = ', I5, ', INFO = ', I15 )
9998 FORMAT( ' M=', I4, ' P=', I4, ', Q=', I4, ', type ', I2,
$ ', test ', I2, ', ratio=', G13.6 )
RETURN
*
* End of CCKCSD
*
END
*
*
*
SUBROUTINE CLACSG( M, P, Q, THETA, ISEED, X, LDX, WORK )
IMPLICIT NONE
*
INTEGER LDX, M, P, Q
INTEGER ISEED( 4 )
REAL THETA( * )
COMPLEX WORK( * ), X( LDX, * )
*
COMPLEX ONE, ZERO
PARAMETER ( ONE = (1.0E0,0.0E0), ZERO = (0.0E0,0.0E0) )
*
INTEGER I, INFO, R
*
R = MIN( P, M-P, Q, M-Q )
*
CALL CLASET( 'Full', M, M, ZERO, ZERO, X, LDX )
*
DO I = 1, MIN(P,Q)-R
X(I,I) = ONE
END DO
DO I = 1, R
X(MIN(P,Q)-R+I,MIN(P,Q)-R+I) = CMPLX ( COS(THETA(I)), 0.0E0 )
END DO
DO I = 1, MIN(P,M-Q)-R
X(P-I+1,M-I+1) = -ONE
END DO
DO I = 1, R
X(P-(MIN(P,M-Q)-R)+1-I,M-(MIN(P,M-Q)-R)+1-I) =
$ CMPLX( -SIN(THETA(R-I+1)), 0.0E0 )
END DO
DO I = 1, MIN(M-P,Q)-R
X(M-I+1,Q-I+1) = ONE
END DO
DO I = 1, R
X(M-(MIN(M-P,Q)-R)+1-I,Q-(MIN(M-P,Q)-R)+1-I) =
$ CMPLX( SIN(THETA(R-I+1)), 0.0E0 )
END DO
DO I = 1, MIN(M-P,M-Q)-R
X(P+I,Q+I) = ONE
END DO
DO I = 1, R
X(P+(MIN(M-P,M-Q)-R)+I,Q+(MIN(M-P,M-Q)-R)+I) =
$ CMPLX( COS(THETA(I)), 0.0E0 )
END DO
CALL CLAROR( 'Left', 'No init', P, M, X, LDX, ISEED, WORK, INFO )
CALL CLAROR( 'Left', 'No init', M-P, M, X(P+1,1), LDX,
$ ISEED, WORK, INFO )
CALL CLAROR( 'Right', 'No init', M, Q, X, LDX, ISEED,
$ WORK, INFO )
CALL CLAROR( 'Right', 'No init', M, M-Q,
$ X(1,Q+1), LDX, ISEED, WORK, INFO )
*
END
|