LAPACK  3.4.2
LAPACK: Linear Algebra PACKage
 All Files Functions Groups
zdrvsy.f
Go to the documentation of this file.
1 *> \brief \b ZDRVSY
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 ZDRVSY( DOTYPE, NN, NVAL, NRHS, THRESH, TSTERR, NMAX,
12 * A, AFAC, AINV, B, X, XACT, WORK, RWORK, IWORK,
13 * NOUT )
14 *
15 * .. Scalar Arguments ..
16 * LOGICAL TSTERR
17 * INTEGER NMAX, NN, NOUT, NRHS
18 * DOUBLE PRECISION THRESH
19 * ..
20 * .. Array Arguments ..
21 * LOGICAL DOTYPE( * )
22 * INTEGER IWORK( * ), NVAL( * )
23 * DOUBLE PRECISION RWORK( * )
24 * COMPLEX*16 A( * ), AFAC( * ), AINV( * ), B( * ),
25 * $ WORK( * ), X( * ), XACT( * )
26 * ..
27 *
28 *
29 *> \par Purpose:
30 * =============
31 *>
32 *> \verbatim
33 *>
34 *> ZDRVSY tests the driver routines ZSYSV and -SVX.
35 *> \endverbatim
36 *
37 * Arguments:
38 * ==========
39 *
40 *> \param[in] DOTYPE
41 *> \verbatim
42 *> DOTYPE is LOGICAL array, dimension (NTYPES)
43 *> The matrix types to be used for testing. Matrices of type j
44 *> (for 1 <= j <= NTYPES) are used for testing if DOTYPE(j) =
45 *> .TRUE.; if DOTYPE(j) = .FALSE., then type j is not used.
46 *> \endverbatim
47 *>
48 *> \param[in] NN
49 *> \verbatim
50 *> NN is INTEGER
51 *> The number of values of N contained in the vector NVAL.
52 *> \endverbatim
53 *>
54 *> \param[in] NVAL
55 *> \verbatim
56 *> NVAL is INTEGER array, dimension (NN)
57 *> The values of the matrix dimension N.
58 *> \endverbatim
59 *>
60 *> \param[in] NRHS
61 *> \verbatim
62 *> NRHS is INTEGER
63 *> The number of right hand side vectors to be generated for
64 *> each linear system.
65 *> \endverbatim
66 *>
67 *> \param[in] THRESH
68 *> \verbatim
69 *> THRESH is DOUBLE PRECISION
70 *> The threshold value for the test ratios. A result is
71 *> included in the output file if RESULT >= THRESH. To have
72 *> every test ratio printed, use THRESH = 0.
73 *> \endverbatim
74 *>
75 *> \param[in] TSTERR
76 *> \verbatim
77 *> TSTERR is LOGICAL
78 *> Flag that indicates whether error exits are to be tested.
79 *> \endverbatim
80 *>
81 *> \param[in] NMAX
82 *> \verbatim
83 *> NMAX is INTEGER
84 *> The maximum value permitted for N, used in dimensioning the
85 *> work arrays.
86 *> \endverbatim
87 *>
88 *> \param[out] A
89 *> \verbatim
90 *> A is COMPLEX*16 array, dimension (NMAX*NMAX)
91 *> \endverbatim
92 *>
93 *> \param[out] AFAC
94 *> \verbatim
95 *> AFAC is COMPLEX*16 array, dimension (NMAX*NMAX)
96 *> \endverbatim
97 *>
98 *> \param[out] AINV
99 *> \verbatim
100 *> AINV is COMPLEX*16 array, dimension (NMAX*NMAX)
101 *> \endverbatim
102 *>
103 *> \param[out] B
104 *> \verbatim
105 *> B is COMPLEX*16 array, dimension (NMAX*NRHS)
106 *> \endverbatim
107 *>
108 *> \param[out] X
109 *> \verbatim
110 *> X is COMPLEX*16 array, dimension (NMAX*NRHS)
111 *> \endverbatim
112 *>
113 *> \param[out] XACT
114 *> \verbatim
115 *> XACT is COMPLEX*16 array, dimension (NMAX*NRHS)
116 *> \endverbatim
117 *>
118 *> \param[out] WORK
119 *> \verbatim
120 *> WORK is COMPLEX*16 array, dimension
121 *> (NMAX*max(2,NRHS))
122 *> \endverbatim
123 *>
124 *> \param[out] RWORK
125 *> \verbatim
126 *> RWORK is DOUBLE PRECISION array, dimension (NMAX+2*NRHS)
127 *> \endverbatim
128 *>
129 *> \param[out] IWORK
130 *> \verbatim
131 *> IWORK is INTEGER array, dimension (NMAX)
132 *> \endverbatim
133 *>
134 *> \param[in] NOUT
135 *> \verbatim
136 *> NOUT is INTEGER
137 *> The unit number for output.
138 *> \endverbatim
139 *
140 * Authors:
141 * ========
142 *
143 *> \author Univ. of Tennessee
144 *> \author Univ. of California Berkeley
145 *> \author Univ. of Colorado Denver
146 *> \author NAG Ltd.
147 *
148 *> \date November 2011
149 *
150 *> \ingroup complex16_lin
151 *
152 * =====================================================================
153  SUBROUTINE zdrvsy( DOTYPE, NN, NVAL, NRHS, THRESH, TSTERR, NMAX,
154  $ a, afac, ainv, b, x, xact, work, rwork, iwork,
155  $ nout )
156 *
157 * -- LAPACK test routine (version 3.4.0) --
158 * -- LAPACK is a software package provided by Univ. of Tennessee, --
159 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
160 * November 2011
161 *
162 * .. Scalar Arguments ..
163  LOGICAL tsterr
164  INTEGER nmax, nn, nout, nrhs
165  DOUBLE PRECISION thresh
166 * ..
167 * .. Array Arguments ..
168  LOGICAL dotype( * )
169  INTEGER iwork( * ), nval( * )
170  DOUBLE PRECISION rwork( * )
171  COMPLEX*16 a( * ), afac( * ), ainv( * ), b( * ),
172  $ work( * ), x( * ), xact( * )
173 * ..
174 *
175 * =====================================================================
176 *
177 * .. Parameters ..
178  DOUBLE PRECISION one, zero
179  parameter( one = 1.0d+0, zero = 0.0d+0 )
180  INTEGER ntypes, ntests
181  parameter( ntypes = 11, ntests = 6 )
182  INTEGER nfact
183  parameter( nfact = 2 )
184 * ..
185 * .. Local Scalars ..
186  LOGICAL zerot
187  CHARACTER dist, fact, type, uplo, xtype
188  CHARACTER*3 path
189  INTEGER i, i1, i2, ifact, imat, in, info, ioff, iuplo,
190  $ izero, j, k, k1, kl, ku, lda, lwork, mode, n,
191  $ nb, nbmin, nerrs, nfail, nimat, nrun, nt
192  DOUBLE PRECISION ainvnm, anorm, cndnum, rcond, rcondc
193 * ..
194 * .. Local Arrays ..
195  CHARACTER facts( nfact ), uplos( 2 )
196  INTEGER iseed( 4 ), iseedy( 4 )
197  DOUBLE PRECISION result( ntests )
198 * ..
199 * .. External Functions ..
200  DOUBLE PRECISION dget06, zlansy
201  EXTERNAL dget06, zlansy
202 * ..
203 * .. External Subroutines ..
204  EXTERNAL aladhd, alaerh, alasvm, xlaenv, zerrvx, zget04,
207  $ zsytri2
208 * ..
209 * .. Scalars in Common ..
210  LOGICAL lerr, ok
211  CHARACTER*32 srnamt
212  INTEGER infot, nunit
213 * ..
214 * .. Common blocks ..
215  common / infoc / infot, nunit, ok, lerr
216  common / srnamc / srnamt
217 * ..
218 * .. Intrinsic Functions ..
219  INTRINSIC dcmplx, max, min
220 * ..
221 * .. Data statements ..
222  DATA iseedy / 1988, 1989, 1990, 1991 /
223  DATA uplos / 'U', 'L' / , facts / 'F', 'N' /
224 * ..
225 * .. Executable Statements ..
226 *
227 * Initialize constants and the random number seed.
228 *
229  path( 1: 1 ) = 'Zomplex precision'
230  path( 2: 3 ) = 'SY'
231  nrun = 0
232  nfail = 0
233  nerrs = 0
234  DO 10 i = 1, 4
235  iseed( i ) = iseedy( i )
236  10 continue
237  lwork = max( 2*nmax, nmax*nrhs )
238 *
239 * Test the error exits
240 *
241  IF( tsterr )
242  $ CALL zerrvx( path, nout )
243  infot = 0
244 *
245 * Set the block size and minimum block size for testing.
246 *
247  nb = 1
248  nbmin = 2
249  CALL xlaenv( 1, nb )
250  CALL xlaenv( 2, nbmin )
251 *
252 * Do for each value of N in NVAL
253 *
254  DO 180 in = 1, nn
255  n = nval( in )
256  lda = max( n, 1 )
257  xtype = 'N'
258  nimat = ntypes
259  IF( n.LE.0 )
260  $ nimat = 1
261 *
262  DO 170 imat = 1, nimat
263 *
264 * Do the tests only if DOTYPE( IMAT ) is true.
265 *
266  IF( .NOT.dotype( imat ) )
267  $ go to 170
268 *
269 * Skip types 3, 4, 5, or 6 if the matrix size is too small.
270 *
271  zerot = imat.GE.3 .AND. imat.LE.6
272  IF( zerot .AND. n.LT.imat-2 )
273  $ go to 170
274 *
275 * Do first for UPLO = 'U', then for UPLO = 'L'
276 *
277  DO 160 iuplo = 1, 2
278  uplo = uplos( iuplo )
279 *
280  IF( imat.NE.ntypes ) THEN
281 *
282 * Set up parameters with ZLATB4 and generate a test
283 * matrix with ZLATMS.
284 *
285  CALL zlatb4( path, imat, n, n, type, kl, ku, anorm,
286  $ mode, cndnum, dist )
287 *
288  srnamt = 'ZLATMS'
289  CALL zlatms( n, n, dist, iseed, type, rwork, mode,
290  $ cndnum, anorm, kl, ku, uplo, a, lda,
291  $ work, info )
292 *
293 * Check error code from ZLATMS.
294 *
295  IF( info.NE.0 ) THEN
296  CALL alaerh( path, 'ZLATMS', info, 0, uplo, n, n,
297  $ -1, -1, -1, imat, nfail, nerrs, nout )
298  go to 160
299  END IF
300 *
301 * For types 3-6, zero one or more rows and columns of
302 * the matrix to test that INFO is returned correctly.
303 *
304  IF( zerot ) THEN
305  IF( imat.EQ.3 ) THEN
306  izero = 1
307  ELSE IF( imat.EQ.4 ) THEN
308  izero = n
309  ELSE
310  izero = n / 2 + 1
311  END IF
312 *
313  IF( imat.LT.6 ) THEN
314 *
315 * Set row and column IZERO to zero.
316 *
317  IF( iuplo.EQ.1 ) THEN
318  ioff = ( izero-1 )*lda
319  DO 20 i = 1, izero - 1
320  a( ioff+i ) = zero
321  20 continue
322  ioff = ioff + izero
323  DO 30 i = izero, n
324  a( ioff ) = zero
325  ioff = ioff + lda
326  30 continue
327  ELSE
328  ioff = izero
329  DO 40 i = 1, izero - 1
330  a( ioff ) = zero
331  ioff = ioff + lda
332  40 continue
333  ioff = ioff - izero
334  DO 50 i = izero, n
335  a( ioff+i ) = zero
336  50 continue
337  END IF
338  ELSE
339  IF( iuplo.EQ.1 ) THEN
340 *
341 * Set the first IZERO rows to zero.
342 *
343  ioff = 0
344  DO 70 j = 1, n
345  i2 = min( j, izero )
346  DO 60 i = 1, i2
347  a( ioff+i ) = zero
348  60 continue
349  ioff = ioff + lda
350  70 continue
351  ELSE
352 *
353 * Set the last IZERO rows to zero.
354 *
355  ioff = 0
356  DO 90 j = 1, n
357  i1 = max( j, izero )
358  DO 80 i = i1, n
359  a( ioff+i ) = zero
360  80 continue
361  ioff = ioff + lda
362  90 continue
363  END IF
364  END IF
365  ELSE
366  izero = 0
367  END IF
368  ELSE
369 *
370 * IMAT = NTYPES: Use a special block diagonal matrix to
371 * test alternate code for the 2-by-2 blocks.
372 *
373  CALL zlatsy( uplo, n, a, lda, iseed )
374  END IF
375 *
376  DO 150 ifact = 1, nfact
377 *
378 * Do first for FACT = 'F', then for other values.
379 *
380  fact = facts( ifact )
381 *
382 * Compute the condition number for comparison with
383 * the value returned by ZSYSVX.
384 *
385  IF( zerot ) THEN
386  IF( ifact.EQ.1 )
387  $ go to 150
388  rcondc = zero
389 *
390  ELSE IF( ifact.EQ.1 ) THEN
391 *
392 * Compute the 1-norm of A.
393 *
394  anorm = zlansy( '1', uplo, n, a, lda, rwork )
395 *
396 * Factor the matrix A.
397 *
398  CALL zlacpy( uplo, n, n, a, lda, afac, lda )
399  CALL zsytrf( uplo, n, afac, lda, iwork, work,
400  $ lwork, info )
401 *
402 * Compute inv(A) and take its norm.
403 *
404  CALL zlacpy( uplo, n, n, afac, lda, ainv, lda )
405  lwork = (n+nb+1)*(nb+3)
406  CALL zsytri2( uplo, n, ainv, lda, iwork, work,
407  $ lwork, info )
408  ainvnm = zlansy( '1', uplo, n, ainv, lda, rwork )
409 *
410 * Compute the 1-norm condition number of A.
411 *
412  IF( anorm.LE.zero .OR. ainvnm.LE.zero ) THEN
413  rcondc = one
414  ELSE
415  rcondc = ( one / anorm ) / ainvnm
416  END IF
417  END IF
418 *
419 * Form an exact solution and set the right hand side.
420 *
421  srnamt = 'ZLARHS'
422  CALL zlarhs( path, xtype, uplo, ' ', n, n, kl, ku,
423  $ nrhs, a, lda, xact, lda, b, lda, iseed,
424  $ info )
425  xtype = 'C'
426 *
427 * --- Test ZSYSV ---
428 *
429  IF( ifact.EQ.2 ) THEN
430  CALL zlacpy( uplo, n, n, a, lda, afac, lda )
431  CALL zlacpy( 'Full', n, nrhs, b, lda, x, lda )
432 *
433 * Factor the matrix and solve the system using ZSYSV.
434 *
435  srnamt = 'ZSYSV '
436  CALL zsysv( uplo, n, nrhs, afac, lda, iwork, x,
437  $ lda, work, lwork, info )
438 *
439 * Adjust the expected value of INFO to account for
440 * pivoting.
441 *
442  k = izero
443  IF( k.GT.0 ) THEN
444  100 continue
445  IF( iwork( k ).LT.0 ) THEN
446  IF( iwork( k ).NE.-k ) THEN
447  k = -iwork( k )
448  go to 100
449  END IF
450  ELSE IF( iwork( k ).NE.k ) THEN
451  k = iwork( k )
452  go to 100
453  END IF
454  END IF
455 *
456 * Check error code from ZSYSV .
457 *
458  IF( info.NE.k ) THEN
459  CALL alaerh( path, 'ZSYSV ', info, k, uplo, n,
460  $ n, -1, -1, nrhs, imat, nfail,
461  $ nerrs, nout )
462  go to 120
463  ELSE IF( info.NE.0 ) THEN
464  go to 120
465  END IF
466 *
467 * Reconstruct matrix from factors and compute
468 * residual.
469 *
470  CALL zsyt01( uplo, n, a, lda, afac, lda, iwork,
471  $ ainv, lda, rwork, result( 1 ) )
472 *
473 * Compute residual of the computed solution.
474 *
475  CALL zlacpy( 'Full', n, nrhs, b, lda, work, lda )
476  CALL zsyt02( uplo, n, nrhs, a, lda, x, lda, work,
477  $ lda, rwork, result( 2 ) )
478 *
479 * Check solution from generated exact solution.
480 *
481  CALL zget04( n, nrhs, x, lda, xact, lda, rcondc,
482  $ result( 3 ) )
483  nt = 3
484 *
485 * Print information about the tests that did not pass
486 * the threshold.
487 *
488  DO 110 k = 1, nt
489  IF( result( k ).GE.thresh ) THEN
490  IF( nfail.EQ.0 .AND. nerrs.EQ.0 )
491  $ CALL aladhd( nout, path )
492  WRITE( nout, fmt = 9999 )'ZSYSV ', uplo, n,
493  $ imat, k, result( k )
494  nfail = nfail + 1
495  END IF
496  110 continue
497  nrun = nrun + nt
498  120 continue
499  END IF
500 *
501 * --- Test ZSYSVX ---
502 *
503  IF( ifact.EQ.2 )
504  $ CALL zlaset( uplo, n, n, dcmplx( zero ),
505  $ dcmplx( zero ), afac, lda )
506  CALL zlaset( 'Full', n, nrhs, dcmplx( zero ),
507  $ dcmplx( zero ), x, lda )
508 *
509 * Solve the system and compute the condition number and
510 * error bounds using ZSYSVX.
511 *
512  srnamt = 'ZSYSVX'
513  CALL zsysvx( fact, uplo, n, nrhs, a, lda, afac, lda,
514  $ iwork, b, lda, x, lda, rcond, rwork,
515  $ rwork( nrhs+1 ), work, lwork,
516  $ rwork( 2*nrhs+1 ), info )
517 *
518 * Adjust the expected value of INFO to account for
519 * pivoting.
520 *
521  k = izero
522  IF( k.GT.0 ) THEN
523  130 continue
524  IF( iwork( k ).LT.0 ) THEN
525  IF( iwork( k ).NE.-k ) THEN
526  k = -iwork( k )
527  go to 130
528  END IF
529  ELSE IF( iwork( k ).NE.k ) THEN
530  k = iwork( k )
531  go to 130
532  END IF
533  END IF
534 *
535 * Check the error code from ZSYSVX.
536 *
537  IF( info.NE.k ) THEN
538  CALL alaerh( path, 'ZSYSVX', info, k, fact // uplo,
539  $ n, n, -1, -1, nrhs, imat, nfail,
540  $ nerrs, nout )
541  go to 150
542  END IF
543 *
544  IF( info.EQ.0 ) THEN
545  IF( ifact.GE.2 ) THEN
546 *
547 * Reconstruct matrix from factors and compute
548 * residual.
549 *
550  CALL zsyt01( uplo, n, a, lda, afac, lda, iwork,
551  $ ainv, lda, rwork( 2*nrhs+1 ),
552  $ result( 1 ) )
553  k1 = 1
554  ELSE
555  k1 = 2
556  END IF
557 *
558 * Compute residual of the computed solution.
559 *
560  CALL zlacpy( 'Full', n, nrhs, b, lda, work, lda )
561  CALL zsyt02( uplo, n, nrhs, a, lda, x, lda, work,
562  $ lda, rwork( 2*nrhs+1 ), result( 2 ) )
563 *
564 * Check solution from generated exact solution.
565 *
566  CALL zget04( n, nrhs, x, lda, xact, lda, rcondc,
567  $ result( 3 ) )
568 *
569 * Check the error bounds from iterative refinement.
570 *
571  CALL zpot05( uplo, n, nrhs, a, lda, b, lda, x, lda,
572  $ xact, lda, rwork, rwork( nrhs+1 ),
573  $ result( 4 ) )
574  ELSE
575  k1 = 6
576  END IF
577 *
578 * Compare RCOND from ZSYSVX with the computed value
579 * in RCONDC.
580 *
581  result( 6 ) = dget06( rcond, rcondc )
582 *
583 * Print information about the tests that did not pass
584 * the threshold.
585 *
586  DO 140 k = k1, 6
587  IF( result( k ).GE.thresh ) THEN
588  IF( nfail.EQ.0 .AND. nerrs.EQ.0 )
589  $ CALL aladhd( nout, path )
590  WRITE( nout, fmt = 9998 )'ZSYSVX', fact, uplo,
591  $ n, imat, k, result( k )
592  nfail = nfail + 1
593  END IF
594  140 continue
595  nrun = nrun + 7 - k1
596 *
597  150 continue
598 *
599  160 continue
600  170 continue
601  180 continue
602 *
603 * Print a summary of the results.
604 *
605  CALL alasvm( path, nout, nfail, nrun, nerrs )
606 *
607  9999 format( 1x, a, ', UPLO=''', a1, ''', N =', i5, ', type ', i2,
608  $ ', test ', i2, ', ratio =', g12.5 )
609  9998 format( 1x, a, ', FACT=''', a1, ''', UPLO=''', a1, ''', N =', i5,
610  $ ', type ', i2, ', test ', i2, ', ratio =', g12.5 )
611  return
612 *
613 * End of ZDRVSY
614 *
615  END