1*> \brief \b SDRVPO
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 SDRVPO( DOTYPE, NN, NVAL, NRHS, THRESH, TSTERR, NMAX,
12*                          A, AFAC, ASAV, B, BSAV, X, XACT, S, WORK,
13*                          RWORK, IWORK, 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( * ), ASAV( * ), B( * ),
24*      $                   BSAV( * ), RWORK( * ), S( * ), WORK( * ),
25*      $                   X( * ), XACT( * )
26*       ..
27*
28*
29*> \par Purpose:
30*  =============
31*>
32*> \verbatim
33*>
34*> SDRVPO tests the driver routines SPOSV 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 REAL
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 REAL array, dimension (NMAX*NMAX)
91*> \endverbatim
92*>
93*> \param[out] AFAC
94*> \verbatim
95*>          AFAC is REAL array, dimension (NMAX*NMAX)
96*> \endverbatim
97*>
98*> \param[out] ASAV
99*> \verbatim
100*>          ASAV is REAL array, dimension (NMAX*NMAX)
101*> \endverbatim
102*>
103*> \param[out] B
104*> \verbatim
105*>          B is REAL array, dimension (NMAX*NRHS)
106*> \endverbatim
107*>
108*> \param[out] BSAV
109*> \verbatim
110*>          BSAV is REAL array, dimension (NMAX*NRHS)
111*> \endverbatim
112*>
113*> \param[out] X
114*> \verbatim
115*>          X is REAL array, dimension (NMAX*NRHS)
116*> \endverbatim
117*>
118*> \param[out] XACT
119*> \verbatim
120*>          XACT is REAL array, dimension (NMAX*NRHS)
121*> \endverbatim
122*>
123*> \param[out] S
124*> \verbatim
125*>          S is REAL array, dimension (NMAX)
126*> \endverbatim
127*>
128*> \param[out] WORK
129*> \verbatim
130*>          WORK is REAL array, dimension
131*>                      (NMAX*max(3,NRHS))
132*> \endverbatim
133*>
134*> \param[out] RWORK
135*> \verbatim
136*>          RWORK is REAL array, dimension (NMAX+2*NRHS)
137*> \endverbatim
138*>
139*> \param[out] IWORK
140*> \verbatim
141*>          IWORK is INTEGER array, dimension (NMAX)
142*> \endverbatim
143*>
144*> \param[in] NOUT
145*> \verbatim
146*>          NOUT is INTEGER
147*>          The unit number for output.
148*> \endverbatim
149*
150*  Authors:
151*  ========
152*
153*> \author Univ. of Tennessee
154*> \author Univ. of California Berkeley
155*> \author Univ. of Colorado Denver
156*> \author NAG Ltd.
157*
158*> \ingroup single_lin
159*
160*  =====================================================================
161      SUBROUTINE SDRVPO( DOTYPE, NN, NVAL, NRHS, THRESH, TSTERR, NMAX,
162     $                   A, AFAC, ASAV, B, BSAV, X, XACT, S, WORK,
163     $                   RWORK, IWORK, NOUT )
164*
165*  -- LAPACK test routine --
166*  -- LAPACK is a software package provided by Univ. of Tennessee,    --
167*  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
168*
169*     .. Scalar Arguments ..
170      LOGICAL            TSTERR
171      INTEGER            NMAX, NN, NOUT, NRHS
172      REAL               THRESH
173*     ..
174*     .. Array Arguments ..
175      LOGICAL            DOTYPE( * )
176      INTEGER            IWORK( * ), NVAL( * )
177      REAL               A( * ), AFAC( * ), ASAV( * ), B( * ),
178     $                   BSAV( * ), RWORK( * ), S( * ), WORK( * ),
179     $                   X( * ), XACT( * )
180*     ..
181*
182*  =====================================================================
183*
184*     .. Parameters ..
185      REAL               ONE, ZERO
186      PARAMETER          ( ONE = 1.0E+0, ZERO = 0.0E+0 )
187      INTEGER            NTYPES
188      PARAMETER          ( NTYPES = 9 )
189      INTEGER            NTESTS
190      PARAMETER          ( NTESTS = 6 )
191*     ..
192*     .. Local Scalars ..
193      LOGICAL            EQUIL, NOFACT, PREFAC, ZEROT
194      CHARACTER          DIST, EQUED, FACT, TYPE, UPLO, XTYPE
195      CHARACTER*3        PATH
196      INTEGER            I, IEQUED, IFACT, IMAT, IN, INFO, IOFF, IUPLO,
197     $                   IZERO, K, K1, KL, KU, LDA, MODE, N, NB, NBMIN,
198     $                   NERRS, NFACT, NFAIL, NIMAT, NRUN, NT
199      REAL               AINVNM, AMAX, ANORM, CNDNUM, RCOND, RCONDC,
200     $                   ROLDC, SCOND
201*     ..
202*     .. Local Arrays ..
203      CHARACTER          EQUEDS( 2 ), FACTS( 3 ), UPLOS( 2 )
204      INTEGER            ISEED( 4 ), ISEEDY( 4 )
205      REAL               RESULT( NTESTS )
206*     ..
207*     .. External Functions ..
208      LOGICAL            LSAME
209      REAL               SGET06, SLANSY
210      EXTERNAL           LSAME, SGET06, SLANSY
211*     ..
212*     .. External Subroutines ..
213      EXTERNAL           ALADHD, ALAERH, ALASVM, SERRVX, SGET04, SLACPY,
214     $                   SLAQSY, SLARHS, SLASET, SLATB4, SLATMS, SPOEQU,
215     $                   SPOSV, SPOSVX, SPOT01, SPOT02, SPOT05, SPOTRF,
216     $                   SPOTRI, XLAENV
217*     ..
218*     .. Intrinsic Functions ..
219      INTRINSIC          MAX
220*     ..
221*     .. Scalars in Common ..
222      LOGICAL            LERR, OK
223      CHARACTER*32       SRNAMT
224      INTEGER            INFOT, NUNIT
225*     ..
226*     .. Common blocks ..
227      COMMON             / INFOC / INFOT, NUNIT, OK, LERR
228      COMMON             / SRNAMC / SRNAMT
229*     ..
230*     .. Data statements ..
231      DATA               ISEEDY / 1988, 1989, 1990, 1991 /
232      DATA               UPLOS / 'U', 'L' /
233      DATA               FACTS / 'F', 'N', 'E' /
234      DATA               EQUEDS / 'N', 'Y' /
235*     ..
236*     .. Executable Statements ..
237*
238*     Initialize constants and the random number seed.
239*
240      PATH( 1: 1 ) = 'Single precision'
241      PATH( 2: 3 ) = 'PO'
242      NRUN = 0
243      NFAIL = 0
244      NERRS = 0
245      DO 10 I = 1, 4
246         ISEED( I ) = ISEEDY( I )
247   10 CONTINUE
248*
249*     Test the error exits
250*
251      IF( TSTERR )
252     $   CALL SERRVX( PATH, NOUT )
253      INFOT = 0
254*
255*     Set the block size and minimum block size for testing.
256*
257      NB = 1
258      NBMIN = 2
259      CALL XLAENV( 1, NB )
260      CALL XLAENV( 2, NBMIN )
261*
262*     Do for each value of N in NVAL
263*
264      DO 130 IN = 1, NN
265         N = NVAL( IN )
266         LDA = MAX( N, 1 )
267         XTYPE = 'N'
268         NIMAT = NTYPES
269         IF( N.LE.0 )
270     $      NIMAT = 1
271*
272         DO 120 IMAT = 1, NIMAT
273*
274*           Do the tests only if DOTYPE( IMAT ) is true.
275*
276            IF( .NOT.DOTYPE( IMAT ) )
277     $         GO TO 120
278*
279*           Skip types 3, 4, or 5 if the matrix size is too small.
280*
281            ZEROT = IMAT.GE.3 .AND. IMAT.LE.5
282            IF( ZEROT .AND. N.LT.IMAT-2 )
283     $         GO TO 120
284*
285*           Do first for UPLO = 'U', then for UPLO = 'L'
286*
287            DO 110 IUPLO = 1, 2
288               UPLO = UPLOS( IUPLO )
289*
290*              Set up parameters with SLATB4 and generate a test matrix
291*              with SLATMS.
292*
293               CALL SLATB4( PATH, IMAT, N, N, TYPE, KL, KU, ANORM, MODE,
294     $                      CNDNUM, DIST )
295*
296               SRNAMT = 'SLATMS'
297               CALL SLATMS( N, N, DIST, ISEED, TYPE, RWORK, MODE,
298     $                      CNDNUM, ANORM, KL, KU, UPLO, A, LDA, WORK,
299     $                      INFO )
300*
301*              Check error code from SLATMS.
302*
303               IF( INFO.NE.0 ) THEN
304                  CALL ALAERH( PATH, 'SLATMS', INFO, 0, UPLO, N, N, -1,
305     $                         -1, -1, IMAT, NFAIL, NERRS, NOUT )
306                  GO TO 110
307               END IF
308*
309*              For types 3-5, zero one row and column of the matrix to
310*              test that INFO is returned correctly.
311*
312               IF( ZEROT ) THEN
313                  IF( IMAT.EQ.3 ) THEN
314                     IZERO = 1
315                  ELSE IF( IMAT.EQ.4 ) THEN
316                     IZERO = N
317                  ELSE
318                     IZERO = N / 2 + 1
319                  END IF
320                  IOFF = ( IZERO-1 )*LDA
321*
322*                 Set row and column IZERO of A to 0.
323*
324                  IF( IUPLO.EQ.1 ) THEN
325                     DO 20 I = 1, IZERO - 1
326                        A( IOFF+I ) = ZERO
327   20                CONTINUE
328                     IOFF = IOFF + IZERO
329                     DO 30 I = IZERO, N
330                        A( IOFF ) = ZERO
331                        IOFF = IOFF + LDA
332   30                CONTINUE
333                  ELSE
334                     IOFF = IZERO
335                     DO 40 I = 1, IZERO - 1
336                        A( IOFF ) = ZERO
337                        IOFF = IOFF + LDA
338   40                CONTINUE
339                     IOFF = IOFF - IZERO
340                     DO 50 I = IZERO, N
341                        A( IOFF+I ) = ZERO
342   50                CONTINUE
343                  END IF
344               ELSE
345                  IZERO = 0
346               END IF
347*
348*              Save a copy of the matrix A in ASAV.
349*
350               CALL SLACPY( UPLO, N, N, A, LDA, ASAV, LDA )
351*
352               DO 100 IEQUED = 1, 2
353                  EQUED = EQUEDS( IEQUED )
354                  IF( IEQUED.EQ.1 ) THEN
355                     NFACT = 3
356                  ELSE
357                     NFACT = 1
358                  END IF
359*
360                  DO 90 IFACT = 1, NFACT
361                     FACT = FACTS( IFACT )
362                     PREFAC = LSAME( FACT, 'F' )
363                     NOFACT = LSAME( FACT, 'N' )
364                     EQUIL = LSAME( FACT, 'E' )
365*
366                     IF( ZEROT ) THEN
367                        IF( PREFAC )
368     $                     GO TO 90
369                        RCONDC = ZERO
370*
371                     ELSE IF( .NOT.LSAME( FACT, 'N' ) ) THEN
372*
373*                       Compute the condition number for comparison with
374*                       the value returned by SPOSVX (FACT = 'N' reuses
375*                       the condition number from the previous iteration
376*                       with FACT = 'F').
377*
378                        CALL SLACPY( UPLO, N, N, ASAV, LDA, AFAC, LDA )
379                        IF( EQUIL .OR. IEQUED.GT.1 ) THEN
380*
381*                          Compute row and column scale factors to
382*                          equilibrate the matrix A.
383*
384                           CALL SPOEQU( N, AFAC, LDA, S, SCOND, AMAX,
385     $                                  INFO )
386                           IF( INFO.EQ.0 .AND. N.GT.0 ) THEN
387                              IF( IEQUED.GT.1 )
388     $                           SCOND = ZERO
389*
390*                             Equilibrate the matrix.
391*
392                              CALL SLAQSY( UPLO, N, AFAC, LDA, S, SCOND,
393     $                                     AMAX, EQUED )
394                           END IF
395                        END IF
396*
397*                       Save the condition number of the
398*                       non-equilibrated system for use in SGET04.
399*
400                        IF( EQUIL )
401     $                     ROLDC = RCONDC
402*
403*                       Compute the 1-norm of A.
404*
405                        ANORM = SLANSY( '1', UPLO, N, AFAC, LDA, RWORK )
406*
407*                       Factor the matrix A.
408*
409                        CALL SPOTRF( UPLO, N, AFAC, LDA, INFO )
410*
411*                       Form the inverse of A.
412*
413                        CALL SLACPY( UPLO, N, N, AFAC, LDA, A, LDA )
414                        CALL SPOTRI( UPLO, N, A, LDA, INFO )
415*
416*                       Compute the 1-norm condition number of A.
417*
418                        AINVNM = SLANSY( '1', UPLO, N, A, LDA, RWORK )
419                        IF( ANORM.LE.ZERO .OR. AINVNM.LE.ZERO ) THEN
420                           RCONDC = ONE
421                        ELSE
422                           RCONDC = ( ONE / ANORM ) / AINVNM
423                        END IF
424                     END IF
425*
426*                    Restore the matrix A.
427*
428                     CALL SLACPY( UPLO, N, N, ASAV, LDA, A, LDA )
429*
430*                    Form an exact solution and set the right hand side.
431*
432                     SRNAMT = 'SLARHS'
433                     CALL SLARHS( PATH, XTYPE, UPLO, ' ', N, N, KL, KU,
434     $                            NRHS, A, LDA, XACT, LDA, B, LDA,
435     $                            ISEED, INFO )
436                     XTYPE = 'C'
437                     CALL SLACPY( 'Full', N, NRHS, B, LDA, BSAV, LDA )
438*
439                     IF( NOFACT ) THEN
440*
441*                       --- Test SPOSV  ---
442*
443*                       Compute the L*L' or U'*U factorization of the
444*                       matrix and solve the system.
445*
446                        CALL SLACPY( UPLO, N, N, A, LDA, AFAC, LDA )
447                        CALL SLACPY( 'Full', N, NRHS, B, LDA, X, LDA )
448*
449                        SRNAMT = 'SPOSV '
450                        CALL SPOSV( UPLO, N, NRHS, AFAC, LDA, X, LDA,
451     $                              INFO )
452*
453*                       Check error code from SPOSV .
454*
455                        IF( INFO.NE.IZERO ) THEN
456                           CALL ALAERH( PATH, 'SPOSV ', INFO, IZERO,
457     $                                  UPLO, N, N, -1, -1, NRHS, IMAT,
458     $                                  NFAIL, NERRS, NOUT )
459                           GO TO 70
460                        ELSE IF( INFO.NE.0 ) THEN
461                           GO TO 70
462                        END IF
463*
464*                       Reconstruct matrix from factors and compute
465*                       residual.
466*
467                        CALL SPOT01( UPLO, N, A, LDA, AFAC, LDA, RWORK,
468     $                               RESULT( 1 ) )
469*
470*                       Compute residual of the computed solution.
471*
472                        CALL SLACPY( 'Full', N, NRHS, B, LDA, WORK,
473     $                               LDA )
474                        CALL SPOT02( UPLO, N, NRHS, A, LDA, X, LDA,
475     $                               WORK, LDA, RWORK, RESULT( 2 ) )
476*
477*                       Check solution from generated exact solution.
478*
479                        CALL SGET04( N, NRHS, X, LDA, XACT, LDA, RCONDC,
480     $                               RESULT( 3 ) )
481                        NT = 3
482*
483*                       Print information about the tests that did not
484*                       pass the threshold.
485*
486                        DO 60 K = 1, NT
487                           IF( RESULT( K ).GE.THRESH ) THEN
488                              IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 )
489     $                           CALL ALADHD( NOUT, PATH )
490                              WRITE( NOUT, FMT = 9999 )'SPOSV ', UPLO,
491     $                           N, IMAT, K, RESULT( K )
492                              NFAIL = NFAIL + 1
493                           END IF
494   60                   CONTINUE
495                        NRUN = NRUN + NT
496   70                   CONTINUE
497                     END IF
498*
499*                    --- Test SPOSVX ---
500*
501                     IF( .NOT.PREFAC )
502     $                  CALL SLASET( UPLO, N, N, ZERO, ZERO, AFAC, LDA )
503                     CALL SLASET( 'Full', N, NRHS, ZERO, ZERO, X, LDA )
504                     IF( IEQUED.GT.1 .AND. N.GT.0 ) THEN
505*
506*                       Equilibrate the matrix if FACT='F' and
507*                       EQUED='Y'.
508*
509                        CALL SLAQSY( UPLO, N, A, LDA, S, SCOND, AMAX,
510     $                               EQUED )
511                     END IF
512*
513*                    Solve the system and compute the condition number
514*                    and error bounds using SPOSVX.
515*
516                     SRNAMT = 'SPOSVX'
517                     CALL SPOSVX( FACT, UPLO, N, NRHS, A, LDA, AFAC,
518     $                            LDA, EQUED, S, B, LDA, X, LDA, RCOND,
519     $                            RWORK, RWORK( NRHS+1 ), WORK, IWORK,
520     $                            INFO )
521*
522*                    Check the error code from SPOSVX.
523*
524                     IF( INFO.NE.IZERO ) THEN
525                        CALL ALAERH( PATH, 'SPOSVX', INFO, IZERO,
526     $                               FACT // UPLO, N, N, -1, -1, NRHS,
527     $                               IMAT, NFAIL, NERRS, NOUT )
528                        GO TO 90
529                     END IF
530*
531                     IF( INFO.EQ.0 ) THEN
532                        IF( .NOT.PREFAC ) THEN
533*
534*                          Reconstruct matrix from factors and compute
535*                          residual.
536*
537                           CALL SPOT01( UPLO, N, A, LDA, AFAC, LDA,
538     $                                  RWORK( 2*NRHS+1 ), RESULT( 1 ) )
539                           K1 = 1
540                        ELSE
541                           K1 = 2
542                        END IF
543*
544*                       Compute residual of the computed solution.
545*
546                        CALL SLACPY( 'Full', N, NRHS, BSAV, LDA, WORK,
547     $                               LDA )
548                        CALL SPOT02( UPLO, N, NRHS, ASAV, LDA, X, LDA,
549     $                               WORK, LDA, RWORK( 2*NRHS+1 ),
550     $                               RESULT( 2 ) )
551*
552*                       Check solution from generated exact solution.
553*
554                        IF( NOFACT .OR. ( PREFAC .AND. LSAME( EQUED,
555     $                      'N' ) ) ) THEN
556                           CALL SGET04( N, NRHS, X, LDA, XACT, LDA,
557     $                                  RCONDC, RESULT( 3 ) )
558                        ELSE
559                           CALL SGET04( N, NRHS, X, LDA, XACT, LDA,
560     $                                  ROLDC, RESULT( 3 ) )
561                        END IF
562*
563*                       Check the error bounds from iterative
564*                       refinement.
565*
566                        CALL SPOT05( UPLO, N, NRHS, ASAV, LDA, B, LDA,
567     $                               X, LDA, XACT, LDA, RWORK,
568     $                               RWORK( NRHS+1 ), RESULT( 4 ) )
569                     ELSE
570                        K1 = 6
571                     END IF
572*
573*                    Compare RCOND from SPOSVX with the computed value
574*                    in RCONDC.
575*
576                     RESULT( 6 ) = SGET06( RCOND, RCONDC )
577*
578*                    Print information about the tests that did not pass
579*                    the threshold.
580*
581                     DO 80 K = K1, 6
582                        IF( RESULT( K ).GE.THRESH ) THEN
583                           IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 )
584     $                        CALL ALADHD( NOUT, PATH )
585                           IF( PREFAC ) THEN
586                              WRITE( NOUT, FMT = 9997 )'SPOSVX', FACT,
587     $                           UPLO, N, EQUED, IMAT, K, RESULT( K )
588                           ELSE
589                              WRITE( NOUT, FMT = 9998 )'SPOSVX', FACT,
590     $                           UPLO, N, IMAT, K, RESULT( K )
591                           END IF
592                           NFAIL = NFAIL + 1
593                        END IF
594   80                CONTINUE
595                     NRUN = NRUN + 7 - K1
596   90             CONTINUE
597  100          CONTINUE
598  110       CONTINUE
599  120    CONTINUE
600  130 CONTINUE
601*
602*     Print a summary of the results.
603*
604      CALL ALASVM( PATH, NOUT, NFAIL, NRUN, NERRS )
605*
606 9999 FORMAT( 1X, A, ', UPLO=''', A1, ''', N =', I5, ', type ', I1,
607     $      ', test(', I1, ')=', G12.5 )
608 9998 FORMAT( 1X, A, ', FACT=''', A1, ''', UPLO=''', A1, ''', N=', I5,
609     $      ', type ', I1, ', test(', I1, ')=', G12.5 )
610 9997 FORMAT( 1X, A, ', FACT=''', A1, ''', UPLO=''', A1, ''', N=', I5,
611     $      ', EQUED=''', A1, ''', type ', I1, ', test(', I1, ') =',
612     $      G12.5 )
613      RETURN
614*
615*     End of SDRVPO
616*
617      END
618