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
|
*> \brief \b SCHKQ3
*
* =========== DOCUMENTATION ===========
*
* Online html documentation available at
* http://www.netlib.org/lapack/explore-html/
*
* Definition:
* ===========
*
* SUBROUTINE SCHKQ3( DOTYPE, NM, MVAL, NN, NVAL, NNB, NBVAL, NXVAL,
* THRESH, A, COPYA, S, TAU, WORK, IWORK,
* NOUT )
*
* .. Scalar Arguments ..
* INTEGER NM, NN, NNB, NOUT
* REAL THRESH
* ..
* .. Array Arguments ..
* LOGICAL DOTYPE( * )
* INTEGER IWORK( * ), MVAL( * ), NBVAL( * ), NVAL( * ),
* $ NXVAL( * )
* REAL A( * ), COPYA( * ), S( * ),
* $ TAU( * ), WORK( * )
* ..
*
*
*> \par Purpose:
* =============
*>
*> \verbatim
*>
*> SCHKQ3 tests SGEQP3.
*> \endverbatim
*
* Arguments:
* ==========
*
*> \param[in] DOTYPE
*> \verbatim
*> DOTYPE is LOGICAL array, dimension (NTYPES)
*> The matrix types to be used for testing. Matrices of type j
*> (for 1 <= j <= NTYPES) are used for testing if DOTYPE(j) =
*> .TRUE.; if DOTYPE(j) = .FALSE., then type j is not used.
*> \endverbatim
*>
*> \param[in] NM
*> \verbatim
*> NM is INTEGER
*> The number of values of M contained in the vector MVAL.
*> \endverbatim
*>
*> \param[in] MVAL
*> \verbatim
*> MVAL is INTEGER array, dimension (NM)
*> The values of the matrix row dimension M.
*> \endverbatim
*>
*> \param[in] NN
*> \verbatim
*> NN is INTEGER
*> The number of values of N contained in the vector NVAL.
*> \endverbatim
*>
*> \param[in] NVAL
*> \verbatim
*> NVAL is INTEGER array, dimension (NN)
*> The values of the matrix column dimension N.
*> \endverbatim
*>
*> \param[in] NNB
*> \verbatim
*> NNB is INTEGER
*> The number of values of NB and NX contained in the
*> vectors NBVAL and NXVAL. The blocking parameters are used
*> in pairs (NB,NX).
*> \endverbatim
*>
*> \param[in] NBVAL
*> \verbatim
*> NBVAL is INTEGER array, dimension (NNB)
*> The values of the blocksize NB.
*> \endverbatim
*>
*> \param[in] NXVAL
*> \verbatim
*> NXVAL is INTEGER array, dimension (NNB)
*> The values of the crossover point NX.
*> \endverbatim
*>
*> \param[in] THRESH
*> \verbatim
*> THRESH is 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.
*> \endverbatim
*>
*> \param[out] A
*> \verbatim
*> A is REAL array, dimension (MMAX*NMAX)
*> where MMAX is the maximum value of M in MVAL and NMAX is the
*> maximum value of N in NVAL.
*> \endverbatim
*>
*> \param[out] COPYA
*> \verbatim
*> COPYA is REAL array, dimension (MMAX*NMAX)
*> \endverbatim
*>
*> \param[out] S
*> \verbatim
*> S is REAL array, dimension
*> (min(MMAX,NMAX))
*> \endverbatim
*>
*> \param[out] TAU
*> \verbatim
*> TAU is REAL array, dimension (MMAX)
*> \endverbatim
*>
*> \param[out] WORK
*> \verbatim
*> WORK is REAL array, dimension
*> (MMAX*NMAX + 4*NMAX + MMAX)
*> \endverbatim
*>
*> \param[out] IWORK
*> \verbatim
*> IWORK is INTEGER array, dimension (2*NMAX)
*> \endverbatim
*>
*> \param[in] NOUT
*> \verbatim
*> NOUT is INTEGER
*> The unit number for output.
*> \endverbatim
*
* Authors:
* ========
*
*> \author Univ. of Tennessee
*> \author Univ. of California Berkeley
*> \author Univ. of Colorado Denver
*> \author NAG Ltd.
*
*> \date November 2011
*
*> \ingroup single_lin
*
* =====================================================================
SUBROUTINE SCHKQ3( DOTYPE, NM, MVAL, NN, NVAL, NNB, NBVAL, NXVAL,
$ THRESH, A, COPYA, S, TAU, WORK, IWORK,
$ NOUT )
*
* -- LAPACK test routine (version 3.4.0) --
* -- LAPACK is a software package provided by Univ. of Tennessee, --
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
* November 2011
*
* .. Scalar Arguments ..
INTEGER NM, NN, NNB, NOUT
REAL THRESH
* ..
* .. Array Arguments ..
LOGICAL DOTYPE( * )
INTEGER IWORK( * ), MVAL( * ), NBVAL( * ), NVAL( * ),
$ NXVAL( * )
REAL A( * ), COPYA( * ), S( * ),
$ TAU( * ), WORK( * )
* ..
*
* =====================================================================
*
* .. Parameters ..
INTEGER NTYPES
PARAMETER ( NTYPES = 6 )
INTEGER NTESTS
PARAMETER ( NTESTS = 3 )
REAL ONE, ZERO
PARAMETER ( ONE = 1.0E0, ZERO = 0.0E0 )
* ..
* .. Local Scalars ..
CHARACTER*3 PATH
INTEGER I, IHIGH, ILOW, IM, IMODE, IN, INB, INFO,
$ ISTEP, K, LDA, LW, LWORK, M, MNMIN, MODE, N,
$ NB, NERRS, NFAIL, NRUN, NX
REAL EPS
* ..
* .. Local Arrays ..
INTEGER ISEED( 4 ), ISEEDY( 4 )
REAL RESULT( NTESTS )
* ..
* .. External Functions ..
REAL SLAMCH, SQPT01, SQRT11, SQRT12
EXTERNAL SLAMCH, SQPT01, SQRT11, SQRT12
* ..
* .. External Subroutines ..
EXTERNAL ALAHD, ALASUM, ICOPY, SGEQP3, SLACPY, SLAORD,
$ SLASET, SLATMS, XLAENV
* ..
* .. Intrinsic Functions ..
INTRINSIC MAX, MIN
* ..
* .. Scalars in Common ..
LOGICAL LERR, OK
CHARACTER*32 SRNAMT
INTEGER INFOT, IOUNIT
* ..
* .. Common blocks ..
COMMON / INFOC / INFOT, IOUNIT, OK, LERR
COMMON / SRNAMC / SRNAMT
* ..
* .. Data statements ..
DATA ISEEDY / 1988, 1989, 1990, 1991 /
* ..
* .. Executable Statements ..
*
* Initialize constants and the random number seed.
*
PATH( 1: 1 ) = 'Single precision'
PATH( 2: 3 ) = 'Q3'
NRUN = 0
NFAIL = 0
NERRS = 0
DO 10 I = 1, 4
ISEED( I ) = ISEEDY( I )
10 CONTINUE
EPS = SLAMCH( 'Epsilon' )
INFOT = 0
*
DO 90 IM = 1, NM
*
* Do for each value of M in MVAL.
*
M = MVAL( IM )
LDA = MAX( 1, M )
*
DO 80 IN = 1, NN
*
* Do for each value of N in NVAL.
*
N = NVAL( IN )
MNMIN = MIN( M, N )
LWORK = MAX( 1, M*MAX( M, N )+4*MNMIN+MAX( M, N ),
$ M*N + 2*MNMIN + 4*N )
*
DO 70 IMODE = 1, NTYPES
IF( .NOT.DOTYPE( IMODE ) )
$ GO TO 70
*
* Do for each type of matrix
* 1: zero matrix
* 2: one small singular value
* 3: geometric distribution of singular values
* 4: first n/2 columns fixed
* 5: last n/2 columns fixed
* 6: every second column fixed
*
MODE = IMODE
IF( IMODE.GT.3 )
$ MODE = 1
*
* Generate test matrix of size m by n using
* singular value distribution indicated by `mode'.
*
DO 20 I = 1, N
IWORK( I ) = 0
20 CONTINUE
IF( IMODE.EQ.1 ) THEN
CALL SLASET( 'Full', M, N, ZERO, ZERO, COPYA, LDA )
DO 30 I = 1, MNMIN
S( I ) = ZERO
30 CONTINUE
ELSE
CALL SLATMS( M, N, 'Uniform', ISEED, 'Nonsymm', S,
$ MODE, ONE / EPS, ONE, M, N, 'No packing',
$ COPYA, LDA, WORK, INFO )
IF( IMODE.GE.4 ) THEN
IF( IMODE.EQ.4 ) THEN
ILOW = 1
ISTEP = 1
IHIGH = MAX( 1, N / 2 )
ELSE IF( IMODE.EQ.5 ) THEN
ILOW = MAX( 1, N / 2 )
ISTEP = 1
IHIGH = N
ELSE IF( IMODE.EQ.6 ) THEN
ILOW = 1
ISTEP = 2
IHIGH = N
END IF
DO 40 I = ILOW, IHIGH, ISTEP
IWORK( I ) = 1
40 CONTINUE
END IF
CALL SLAORD( 'Decreasing', MNMIN, S, 1 )
END IF
*
DO 60 INB = 1, NNB
*
* Do for each pair of values (NB,NX) in NBVAL and NXVAL.
*
NB = NBVAL( INB )
CALL XLAENV( 1, NB )
NX = NXVAL( INB )
CALL XLAENV( 3, NX )
*
* Get a working copy of COPYA into A and a copy of
* vector IWORK.
*
CALL SLACPY( 'All', M, N, COPYA, LDA, A, LDA )
CALL ICOPY( N, IWORK( 1 ), 1, IWORK( N+1 ), 1 )
*
* Compute the QR factorization with pivoting of A
*
LW = MAX( 1, 2*N+NB*( N+1 ) )
*
* Compute the QP3 factorization of A
*
SRNAMT = 'SGEQP3'
CALL SGEQP3( M, N, A, LDA, IWORK( N+1 ), TAU, WORK,
$ LW, INFO )
*
* Compute norm(svd(a) - svd(r))
*
RESULT( 1 ) = SQRT12( M, N, A, LDA, S, WORK,
$ LWORK )
*
* Compute norm( A*P - Q*R )
*
RESULT( 2 ) = SQPT01( M, N, MNMIN, COPYA, A, LDA, TAU,
$ IWORK( N+1 ), WORK, LWORK )
*
* Compute Q'*Q
*
RESULT( 3 ) = SQRT11( M, MNMIN, A, LDA, TAU, WORK,
$ LWORK )
*
* Print information about the tests that did not pass
* the threshold.
*
DO 50 K = 1, NTESTS
IF( RESULT( K ).GE.THRESH ) THEN
IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 )
$ CALL ALAHD( NOUT, PATH )
WRITE( NOUT, FMT = 9999 )'SGEQP3', M, N, NB,
$ IMODE, K, RESULT( K )
NFAIL = NFAIL + 1
END IF
50 CONTINUE
NRUN = NRUN + NTESTS
*
60 CONTINUE
70 CONTINUE
80 CONTINUE
90 CONTINUE
*
* Print a summary of the results.
*
CALL ALASUM( PATH, NOUT, NFAIL, NRUN, NERRS )
*
9999 FORMAT( 1X, A, ' M =', I5, ', N =', I5, ', NB =', I4, ', type ',
$ I2, ', test ', I2, ', ratio =', G12.5 )
*
* End of SCHKQ3
*
END
|