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