PLASMA  2.4.5
PLASMA - Parallel Linear Algebra for Scalable Multi-core Architectures
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
zchkqr.f
Go to the documentation of this file.
1  SUBROUTINE zchkqr( DOTYPE, NM, MVAL, NN, NVAL, NNB, NBVAL, NXVAL,
2  $ ibval, nrhs, thresh, tsterr, nmax, a, af, aq,
3  $ ar, ac, b, x, xact, tau, work, rwork, iwork,
4  $ nout )
5 *
6  include 'plasmaf.h'
7 *
8 * -- LAPACK test routine (version 3.1) --
9 * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
10 * November 2006
11 *
12 * .. Scalar Arguments ..
13  LOGICAL tsterr
14  INTEGER nm, nmax, nn, nnb, nout, nrhs
15  DOUBLE PRECISION thresh
16 * ..
17 * .. Array Arguments ..
18  LOGICAL dotype( * )
19  INTEGER iwork( * ), mval( * ), nbval( * ), nval( * ),
20  $ nxval( * ), ibval( * )
21  DOUBLE PRECISION rwork( * )
22  COMPLEX*16 a( * ), ac( * ), af( * ), aq( * ), ar( * ),
23  $ b( * ), tau( * ), work( * ), x( * ), xact( * )
24 * ..
25 *
26 * Purpose
27 * =======
28 *
29 * ZCHKQR tests ZGEQRF, ZUNGQR and CUNMQR.
30 *
31 * Arguments
32 * =========
33 *
34 * DOTYPE (input) LOGICAL array, dimension (NTYPES)
35 * The matrix types to be used for testing. Matrices of type j
36 * (for 1 <= j <= NTYPES) are used for testing if DOTYPE(j) =
37 * .TRUE.; if DOTYPE(j) = .FALSE., then type j is not used.
38 *
39 * NM (input) INTEGER
40 * The number of values of M contained in the vector MVAL.
41 *
42 * MVAL (input) INTEGER array, dimension (NM)
43 * The values of the matrix row dimension M.
44 *
45 * NN (input) INTEGER
46 * The number of values of N contained in the vector NVAL.
47 *
48 * NVAL (input) INTEGER array, dimension (NN)
49 * The values of the matrix column dimension N.
50 *
51 * NNB (input) INTEGER
52 * The number of values of NB and NX contained in the
53 * vectors NBVAL and NXVAL. The blocking parameters are used
54 * in pairs (NB,NX).
55 *
56 * NBVAL (input) INTEGER array, dimension (NNB)
57 * The values of the blocksize NB.
58 *
59 * NXVAL (input) INTEGER array, dimension (NNB)
60 * The values of the crossover point NX.
61 *
62 * NRHS (input) INTEGER
63 * The number of right hand side vectors to be generated for
64 * each linear system.
65 *
66 * THRESH (input) DOUBLE PRECISION
67 * The threshold value for the test ratios. A result is
68 * included in the output file if RESULT >= THRESH. To have
69 * every test ratio printed, use THRESH = 0.
70 *
71 * TSTERR (input) LOGICAL
72 * Flag that indicates whether error exits are to be tested.
73 *
74 * NMAX (input) INTEGER
75 * The maximum value permitted for M or N, used in dimensioning
76 * the work arrays.
77 *
78 * A (workspace) COMPLEX*16 array, dimension (NMAX*NMAX)
79 *
80 * AF (workspace) COMPLEX*16 array, dimension (NMAX*NMAX)
81 *
82 * AQ (workspace) COMPLEX*16 array, dimension (NMAX*NMAX)
83 *
84 * AR (workspace) COMPLEX*16 array, dimension (NMAX*NMAX)
85 *
86 * AC (workspace) COMPLEX*16 array, dimension (NMAX*NMAX)
87 *
88 * B (workspace) COMPLEX*16 array, dimension (NMAX*NRHS)
89 *
90 * X (workspace) COMPLEX*16 array, dimension (NMAX*NRHS)
91 *
92 * XACT (workspace) COMPLEX*16 array, dimension (NMAX*NRHS)
93 *
94 * TAU (workspace) COMPLEX*16 array, dimension (NMAX)
95 *
96 * WORK (workspace) COMPLEX*16 array, dimension (NMAX*NMAX)
97 *
98 * RWORK (workspace) DOUBLE PRECISION array, dimension (NMAX)
99 *
100 * IWORK (workspace) INTEGER array, dimension (NMAX)
101 *
102 * NOUT (input) INTEGER
103 * The unit number for output.
104 *
105 * =====================================================================
106 *
107 * .. Parameters ..
108  INTEGER ntests
109  parameter( ntests = 7 )
110  INTEGER ntypes
111  parameter( ntypes = 8 )
112  DOUBLE PRECISION zero
113  parameter( zero = 0.0d0 )
114 * ..
115 * .. Local Scalars ..
116  CHARACTER dist, type
117  CHARACTER*3 path
118  INTEGER i, ik, im, imat, in, inb, info, k, kl, ku, lda,
119  $ lwork, m, minmn, mode, n, nb, nerrs, nfail, nk,
120  $ nrun, nt, nx, ib, irh, rhblk
121  DOUBLE PRECISION anorm, cndnum
122 * ..
123 * .. Local Arrays ..
124  INTEGER iseed( 4 ), iseedy( 4 ), kval( 4 )
125  DOUBLE PRECISION result( ntests )
126  INTEGER ht( 2 )
127 * ..
128 * .. External Functions ..
129  LOGICAL zgennd
130  EXTERNAL zgennd
131 * ..
132 * .. External Subroutines ..
133  EXTERNAL alaerh, alahd, alasum, xlaenv, zerrqr,
134  $ zget02, zlacpy, zlarhs, zlatb4, zlatms, zqrt01,
135  $ zqrt02, zqrt03
136 * ..
137 * .. Intrinsic Functions ..
138  INTRINSIC max, min
139 * ..
140 * .. Scalars in Common ..
141  LOGICAL lerr, ok
142  CHARACTER*32 srnamt
143  INTEGER infot, nunit
144 * ..
145 * .. Common blocks ..
146  common / infoc / infot, nunit, ok, lerr
147  common / srnamc / srnamt
148 * ..
149 * .. Data statements ..
150  DATA iseedy / 1988, 1989, 1990, 1991 /
151 * ..
152 * .. Executable Statements ..
153 *
154 * Initialize constants and the random number seed.
155 *
156  rhblk = 4
157  path( 1: 1 ) = 'Zomplex precision'
158  path( 2: 3 ) = 'QR'
159  nrun = 0
160  nfail = 0
161  nerrs = 0
162  DO 10 i = 1, 4
163  iseed( i ) = iseedy( i )
164  10 continue
165 *
166 * Test the error exits
167 *
168  IF( tsterr )
169  $ CALL zerrqr( path, nout )
170  infot = 0
171  CALL xlaenv( 2, 2 )
172 *
173  lda = nmax
174  lwork = nmax*max( nmax, nrhs )
175 *
176 * Do for each value of M in MVAL.
177 *
178  DO 70 im = 1, nm
179  m = mval( im )
180 *
181 * Do for each value of N in NVAL.
182 *
183  DO 60 in = 1, nn
184  n = nval( in )
185  IF ( m.LT.n )
186  $ go to 60
187  minmn = min( m, n )
188  DO 50 imat = 1, ntypes
189 *
190 * Do the tests only if DOTYPE( IMAT ) is true.
191 *
192  IF( .NOT.dotype( imat ) )
193  $ go to 50
194 *
195 * Set up parameters with ZLATB4 and generate a test matrix
196 * with ZLATMS.
197 *
198  CALL zlatb4( path, imat, m, n, type, kl, ku, anorm, mode,
199  $ cndnum, dist )
200 *
201  srnamt = 'ZLATMS'
202  CALL zlatms( m, n, dist, iseed, type, rwork, mode,
203  $ cndnum, anorm, kl, ku, 'No packing', a, lda,
204  $ work, info )
205 *
206 * Check error code from ZLATMS.
207 *
208  IF( info.NE.0 ) THEN
209  CALL alaerh( path, 'ZLATMS', info, 0, ' ', m, n, -1,
210  $ -1, -1, imat, nfail, nerrs, nout )
211  go to 50
212  END IF
213 *
214 * Set some values for K: the first value must be MINMN,
215 * corresponding to the call of ZQRT01; other values are
216 * used in the calls of ZQRT02, and must not exceed MINMN.
217 *
218  kval( 1 ) = minmn
219  kval( 2 ) = 0
220  kval( 3 ) = 1
221  kval( 4 ) = minmn / 2
222  IF( minmn.EQ.0 ) THEN
223  nk = 1
224  ELSE IF( minmn.EQ.1 ) THEN
225  nk = 2
226  ELSE IF( minmn.LE.3 ) THEN
227  nk = 3
228  ELSE
229  nk = 4
230  END IF
231 *
232 * Set Householder mode (tree or flat)
233 *
234  DO 45 irh = 0, 1
235  IF (irh .EQ. 0) THEN
236  CALL plasma_set(plasma_householder_mode,
237  $ plasma_flat_householder, info )
238  ELSE
239  CALL plasma_set(plasma_householder_mode,
240  $ plasma_tree_householder, info )
241  CALL plasma_set(plasma_householder_size,
242  $ rhblk, info)
243  END IF
244 *
245 * Do for each value of K in KVAL
246 *
247  DO 40 ik = 1, 2
248  k = kval( ik )
249 *
250 * Do for each pair of values (NB,NX) in NBVAL and NXVAL.
251 *
252  DO 30 inb = 1, nnb
253  nb = nbval( inb )
254  ib = ibval( inb )
255  CALL xlaenv( 1, nb )
256  nx = nxval( inb )
257  CALL xlaenv( 3, nx )
258  IF ( (max(m, n) / 10) .GT. nb ) THEN
259  goto 30
260  END IF
261  CALL plasma_set( plasma_tile_size, nb, info )
262  CALL plasma_set( plasma_inner_block_size, ib, info)
263 *
264 * Allocate HT
265 *
266  CALL plasma_alloc_workspace_zgeqrf( m, n, ht,
267  $ info )
268 *
269  DO i = 1, ntests
270  result( i ) = zero
271  END DO
272  nt = 2
273  IF( ik.EQ.1 ) THEN
274 *
275 * Test ZGEQRF
276 *
277  CALL zqrt01( m, n, a, af, aq, ar, lda, ht,
278  $ work, lwork, rwork, result( 1 ) )
279 * IF( .NOT.ZGENND( M, N, AF, LDA ) )
280 * $ RESULT( 8 ) = 2*THRESH
281 * NT = NT + 1
282  ELSE IF( m.GE.n ) THEN
283 *
284 * Test ZUNGQR, using factorization
285 * returned by ZQRT01
286 *
287  CALL zqrt02( m, n, k, a, af, aq, ar, lda, ht,
288  $ work, lwork, rwork, result( 1 ) )
289  END IF
290  IF( m.GE.k ) THEN
291 *
292 * Test ZUNMQR, using factorization returned
293 * by ZQRT01
294 *
295  CALL zqrt03( m, n, k, af, ac, ar, aq, lda, ht,
296  $ work, lwork, rwork, result( 3 ) )
297  nt = nt + 4
298 *
299 * If M>=N and K=N, call ZGEQRS to solve a system
300 * with NRHS right hand sides and compute the
301 * residual.
302 *
303  IF( k.EQ.n .AND. inb.EQ.1 ) THEN
304 *
305 * Generate a solution and set the right
306 * hand side.
307 *
308  srnamt = 'ZLARHS'
309  CALL zlarhs( path, 'New', 'Full',
310  $ 'No transpose', m, n, 0, 0,
311  $ nrhs, a, lda, xact, lda, b, lda,
312  $ iseed, info )
313 *
314  CALL zlacpy( 'Full', m, nrhs, b, lda, x,
315  $ lda )
316  srnamt = 'ZGEQRS'
317  CALL plasma_zgeqrs( m, n, nrhs, af, lda, ht,
318  $ x, lda, info )
319 *
320 * Check error code from ZGEQRS.
321 *
322  IF( info.NE.0 )
323  $ CALL alaerh( path, 'ZGEQRS', info, 0, ' ',
324  $ m, n, nrhs, -1, nb, imat,
325  $ nfail, nerrs, nout )
326 *
327  CALL zget02( 'No transpose', m, n, nrhs, a,
328  $ lda, x, lda, b, lda, rwork,
329  $ result( 7 ) )
330  nt = nt + 1
331  END IF
332  END IF
333 *
334 * Print information about the tests that did not
335 * pass the threshold.
336 *
337  DO 20 i = 1, ntests
338  IF( result( i ).GE.thresh ) THEN
339  IF( nfail.EQ.0 .AND. nerrs.EQ.0 )
340  $ CALL alahd( nout, path )
341  WRITE( nout, fmt = 9999 )m, n, k, nb, nx,
342  $ imat, i, result( i )
343  nfail = nfail + 1
344  END IF
345  20 continue
346  nrun = nrun + nt
347  30 continue
348  40 continue
349  45 continue
350  50 continue
351  60 continue
352  70 continue
353 *
354 * Print a summary of the results.
355 *
356  CALL alasum( path, nout, nfail, nrun, nerrs )
357 *
358  9999 format( ' M=', i5, ', N=', i5, ', K=', i5, ', NB=', i4, ', NX=',
359  $ i5, ', type ', i2, ', test(', i2, ')=', g12.5 )
360  return
361 *
362 * End of ZCHKQR
363 *
364  END