LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
cdrvsy_rook.f
Go to the documentation of this file.
1 *> \brief \b CDRVSY_ROOK
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 CDRVSY_ROOK( DOTYPE, NN, NVAL, NRHS, THRESH, TSTERR,
12 * NMAX, A, AFAC, AINV, B, X, XACT, WORK, RWORK,
13 * 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 RWORK( * )
24 * COMPLEX A( * ), AFAC( * ), AINV( * ), B( * ),
25 * $ WORK( * ), X( * ), XACT( * )
26 * ..
27 *
28 *
29 *> \par Purpose:
30 * =============
31 *>
32 *> \verbatim
33 *>
34 *> CDRVSY_ROOK tests the driver routines CSYSV_ROOK.
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 COMPLEX array, dimension (NMAX*NMAX)
91 *> \endverbatim
92 *>
93 *> \param[out] AFAC
94 *> \verbatim
95 *> AFAC is COMPLEX array, dimension (NMAX*NMAX)
96 *> \endverbatim
97 *>
98 *> \param[out] AINV
99 *> \verbatim
100 *> AINV is COMPLEX array, dimension (NMAX*NMAX)
101 *> \endverbatim
102 *>
103 *> \param[out] B
104 *> \verbatim
105 *> B is COMPLEX array, dimension (NMAX*NRHS)
106 *> \endverbatim
107 *>
108 *> \param[out] X
109 *> \verbatim
110 *> X is COMPLEX array, dimension (NMAX*NRHS)
111 *> \endverbatim
112 *>
113 *> \param[out] XACT
114 *> \verbatim
115 *> XACT is COMPLEX array, dimension (NMAX*NRHS)
116 *> \endverbatim
117 *>
118 *> \param[out] WORK
119 *> \verbatim
120 *> \endverbatim
121 *>
122 *> \param[out] RWORK
123 *> \verbatim
124 *> RWORK is REAL array, dimension (NMAX+2*NRHS)
125 *> \endverbatim
126 *>
127 *> \param[out] IWORK
128 *> \verbatim
129 *> IWORK is INTEGER array, dimension (NMAX)
130 *> \endverbatim
131 *>
132 *> \param[in] NOUT
133 *> \verbatim
134 *> NOUT is INTEGER
135 *> The unit number for output.
136 *> \endverbatim
137 *
138 * Authors:
139 * ========
140 *
141 *> \author Univ. of Tennessee
142 *> \author Univ. of California Berkeley
143 *> \author Univ. of Colorado Denver
144 *> \author NAG Ltd.
145 *
146 *> \date November 2013
147 *
148 *> \ingroup complex_lin
149 *
150 * =====================================================================
151  SUBROUTINE cdrvsy_rook( DOTYPE, NN, NVAL, NRHS, THRESH, TSTERR,
152  $ nmax, a, afac, ainv, b, x, xact, work,
153  $ rwork, iwork, nout )
154 *
155 * -- LAPACK test routine (version 3.5.0) --
156 * -- LAPACK is a software package provided by Univ. of Tennessee, --
157 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
158 * November 2013
159 *
160 * .. Scalar Arguments ..
161  LOGICAL TSTERR
162  INTEGER NMAX, NN, NOUT, NRHS
163  REAL THRESH
164 * ..
165 * .. Array Arguments ..
166  LOGICAL DOTYPE( * )
167  INTEGER IWORK( * ), NVAL( * )
168  REAL RWORK( * )
169  COMPLEX A( * ), AFAC( * ), AINV( * ), B( * ),
170  $ work( * ), x( * ), xact( * )
171 * ..
172 *
173 * =====================================================================
174 *
175 * .. Parameters ..
176  REAL ONE, ZERO
177  parameter ( one = 1.0e+0, zero = 0.0e+0 )
178  INTEGER NTYPES, NTESTS
179  parameter ( ntypes = 11, ntests = 3 )
180  INTEGER NFACT
181  parameter ( nfact = 2 )
182 * ..
183 * .. Local Scalars ..
184  LOGICAL ZEROT
185  CHARACTER DIST, FACT, TYPE, UPLO, XTYPE
186  CHARACTER*3 MATPATH, PATH
187  INTEGER I, I1, I2, IFACT, IMAT, IN, INFO, IOFF, IUPLO,
188  $ izero, j, k, kl, ku, lda, lwork, mode, n,
189  $ nb, nbmin, nerrs, nfail, nimat, nrun, nt
190  REAL AINVNM, ANORM, CNDNUM, RCONDC
191 * ..
192 * .. Local Arrays ..
193  CHARACTER FACTS( nfact ), UPLOS( 2 )
194  INTEGER ISEED( 4 ), ISEEDY( 4 )
195  REAL RESULT( ntests )
196 
197 * ..
198 * .. External Functions ..
199  REAL CLANSY
200  EXTERNAL clansy
201 * ..
202 * .. External Subroutines ..
203  EXTERNAL aladhd, alaerh, alasvm, xlaenv, cerrvx, cget04,
207 * ..
208 * .. Scalars in Common ..
209  LOGICAL LERR, OK
210  CHARACTER*32 SRNAMT
211  INTEGER INFOT, NUNIT
212 * ..
213 * .. Common blocks ..
214  COMMON / infoc / infot, nunit, ok, lerr
215  COMMON / srnamc / srnamt
216 * ..
217 * .. Intrinsic Functions ..
218  INTRINSIC max, min
219 * ..
220 * .. Data statements ..
221  DATA iseedy / 1988, 1989, 1990, 1991 /
222  DATA uplos / 'U', 'L' / , facts / 'F', 'N' /
223 * ..
224 * .. Executable Statements ..
225 *
226 * Initialize constants and the random number seed.
227 *
228 * Test path
229 *
230  path( 1: 1 ) = 'Complex precision'
231  path( 2: 3 ) = 'SR'
232 *
233 * Path to generate matrices
234 *
235  matpath( 1: 1 ) = 'Complex precision'
236  matpath( 2: 3 ) = 'SY'
237 *
238  nrun = 0
239  nfail = 0
240  nerrs = 0
241  DO 10 i = 1, 4
242  iseed( i ) = iseedy( i )
243  10 CONTINUE
244  lwork = max( 2*nmax, nmax*nrhs )
245 *
246 * Test the error exits
247 *
248  IF( tsterr )
249  $ CALL cerrvx( path, nout )
250  infot = 0
251 *
252 * Set the block size and minimum block size for which the block
253 * routine should be used, which will be later returned by ILAENV.
254 *
255  nb = 1
256  nbmin = 2
257  CALL xlaenv( 1, nb )
258  CALL xlaenv( 2, nbmin )
259 *
260 * Do for each value of N in NVAL
261 *
262  DO 180 in = 1, nn
263  n = nval( in )
264  lda = max( n, 1 )
265  xtype = 'N'
266  nimat = ntypes
267  IF( n.LE.0 )
268  $ nimat = 1
269 *
270  DO 170 imat = 1, nimat
271 *
272 * Do the tests only if DOTYPE( IMAT ) is true.
273 *
274  IF( .NOT.dotype( imat ) )
275  $ GO TO 170
276 *
277 * Skip types 3, 4, 5, or 6 if the matrix size is too small.
278 *
279  zerot = imat.GE.3 .AND. imat.LE.6
280  IF( zerot .AND. n.LT.imat-2 )
281  $ GO TO 170
282 *
283 * Do first for UPLO = 'U', then for UPLO = 'L'
284 *
285  DO 160 iuplo = 1, 2
286  uplo = uplos( iuplo )
287 *
288  IF( imat.NE.ntypes ) THEN
289 *
290 * Begin generate the test matrix A.
291 *
292 * Set up parameters with CLATB4 for the matrix generator
293 * based on the type of matrix to be generated.
294 *
295  CALL clatb4( matpath, imat, n, n, TYPE, KL, KU, ANORM,
296  $ mode, cndnum, dist )
297 *
298 * Generate a matrix with CLATMS.
299 *
300  srnamt = 'CLATMS'
301  CALL clatms( n, n, dist, iseed, TYPE, RWORK, MODE,
302  $ cndnum, anorm, kl, ku, uplo, a, lda,
303  $ work, info )
304 *
305 * Check error code from CLATMS and handle error.
306 *
307  IF( info.NE.0 ) THEN
308  CALL alaerh( path, 'CLATMS', info, 0, uplo, n, n,
309  $ -1, -1, -1, imat, nfail, nerrs, nout )
310  GO TO 160
311  END IF
312 *
313 * For types 3-6, zero one or more rows and columns of
314 * the matrix to test that INFO is returned correctly.
315 *
316  IF( zerot ) THEN
317  IF( imat.EQ.3 ) THEN
318  izero = 1
319  ELSE IF( imat.EQ.4 ) THEN
320  izero = n
321  ELSE
322  izero = n / 2 + 1
323  END IF
324 *
325  IF( imat.LT.6 ) THEN
326 *
327 * Set row and column IZERO to zero.
328 *
329  IF( iuplo.EQ.1 ) THEN
330  ioff = ( izero-1 )*lda
331  DO 20 i = 1, izero - 1
332  a( ioff+i ) = zero
333  20 CONTINUE
334  ioff = ioff + izero
335  DO 30 i = izero, n
336  a( ioff ) = zero
337  ioff = ioff + lda
338  30 CONTINUE
339  ELSE
340  ioff = izero
341  DO 40 i = 1, izero - 1
342  a( ioff ) = zero
343  ioff = ioff + lda
344  40 CONTINUE
345  ioff = ioff - izero
346  DO 50 i = izero, n
347  a( ioff+i ) = zero
348  50 CONTINUE
349  END IF
350  ELSE
351  IF( iuplo.EQ.1 ) THEN
352 *
353 * Set the first IZERO rows and columns to zero.
354 *
355  ioff = 0
356  DO 70 j = 1, n
357  i2 = min( j, izero )
358  DO 60 i = 1, i2
359  a( ioff+i ) = zero
360  60 CONTINUE
361  ioff = ioff + lda
362  70 CONTINUE
363  ELSE
364 *
365 * Set the first IZERO rows and columns to zero.
366 *
367  ioff = 0
368  DO 90 j = 1, n
369  i1 = max( j, izero )
370  DO 80 i = i1, n
371  a( ioff+i ) = zero
372  80 CONTINUE
373  ioff = ioff + lda
374  90 CONTINUE
375  END IF
376  END IF
377  ELSE
378  izero = 0
379  END IF
380 *
381 * End generate the test matrix A.
382 *
383  ELSE
384 *
385 * IMAT = NTYPES: Use a special block diagonal matrix to
386 * test alternate code for the 2-by-2 blocks.
387 *
388  CALL clatsy( uplo, n, a, lda, iseed )
389  END IF
390 *
391  DO 150 ifact = 1, nfact
392 *
393 * Do first for FACT = 'F', then for other values.
394 *
395  fact = facts( ifact )
396 *
397 * Compute the condition number for comparison with
398 * the value returned by CSYSVX_ROOK.
399 *
400  IF( zerot ) THEN
401  IF( ifact.EQ.1 )
402  $ GO TO 150
403  rcondc = zero
404 *
405  ELSE IF( ifact.EQ.1 ) THEN
406 *
407 * Compute the 1-norm of A.
408 *
409  anorm = clansy( '1', uplo, n, a, lda, rwork )
410 *
411 * Factor the matrix A.
412 *
413 
414  CALL clacpy( uplo, n, n, a, lda, afac, lda )
415  CALL csytrf_rook( uplo, n, afac, lda, iwork, work,
416  $ lwork, info )
417 *
418 * Compute inv(A) and take its norm.
419 *
420  CALL clacpy( uplo, n, n, afac, lda, ainv, lda )
421  lwork = (n+nb+1)*(nb+3)
422  CALL csytri_rook( uplo, n, ainv, lda, iwork,
423  $ work, info )
424  ainvnm = clansy( '1', uplo, n, ainv, lda, rwork )
425 *
426 * Compute the 1-norm condition number of A.
427 *
428  IF( anorm.LE.zero .OR. ainvnm.LE.zero ) THEN
429  rcondc = one
430  ELSE
431  rcondc = ( one / anorm ) / ainvnm
432  END IF
433  END IF
434 *
435 * Form an exact solution and set the right hand side.
436 *
437  srnamt = 'CLARHS'
438  CALL clarhs( matpath, xtype, uplo, ' ', n, n, kl, ku,
439  $ nrhs, a, lda, xact, lda, b, lda, iseed,
440  $ info )
441  xtype = 'C'
442 *
443 * --- Test CSYSV_ROOK ---
444 *
445  IF( ifact.EQ.2 ) THEN
446  CALL clacpy( uplo, n, n, a, lda, afac, lda )
447  CALL clacpy( 'Full', n, nrhs, b, lda, x, lda )
448 *
449 * Factor the matrix and solve the system using
450 * CSYSV_ROOK.
451 *
452  srnamt = 'CSYSV_ROOK'
453  CALL csysv_rook( uplo, n, nrhs, afac, lda, iwork,
454  $ x, lda, work, lwork, info )
455 *
456 * Adjust the expected value of INFO to account for
457 * pivoting.
458 *
459  k = izero
460  IF( k.GT.0 ) THEN
461  100 CONTINUE
462  IF( iwork( k ).LT.0 ) THEN
463  IF( iwork( k ).NE.-k ) THEN
464  k = -iwork( k )
465  GO TO 100
466  END IF
467  ELSE IF( iwork( k ).NE.k ) THEN
468  k = iwork( k )
469  GO TO 100
470  END IF
471  END IF
472 *
473 * Check error code from CSYSV_ROOK and handle error.
474 *
475  IF( info.NE.k ) THEN
476  CALL alaerh( path, 'CSYSV_ROOK', info, k, uplo,
477  $ n, n, -1, -1, nrhs, imat, nfail,
478  $ nerrs, nout )
479  GO TO 120
480  ELSE IF( info.NE.0 ) THEN
481  GO TO 120
482  END IF
483 *
484 *+ TEST 1 Reconstruct matrix from factors and compute
485 * residual.
486 *
487  CALL csyt01_rook( uplo, n, a, lda, afac, lda,
488  $ iwork, ainv, lda, rwork,
489  $ result( 1 ) )
490 *
491 *+ TEST 2 Compute residual of the computed solution.
492 *
493  CALL clacpy( 'Full', n, nrhs, b, lda, work, lda )
494  CALL csyt02( uplo, n, nrhs, a, lda, x, lda, work,
495  $ lda, rwork, result( 2 ) )
496 *
497 *+ TEST 3
498 * Check solution from generated exact solution.
499 *
500  CALL cget04( n, nrhs, x, lda, xact, lda, rcondc,
501  $ result( 3 ) )
502  nt = 3
503 *
504 * Print information about the tests that did not pass
505 * the threshold.
506 *
507  DO 110 k = 1, nt
508  IF( result( k ).GE.thresh ) THEN
509  IF( nfail.EQ.0 .AND. nerrs.EQ.0 )
510  $ CALL aladhd( nout, path )
511  WRITE( nout, fmt = 9999 )'CSYSV_ROOK', uplo,
512  $ n, imat, k, result( k )
513  nfail = nfail + 1
514  END IF
515  110 CONTINUE
516  nrun = nrun + nt
517  120 CONTINUE
518  END IF
519 *
520  150 CONTINUE
521 *
522  160 CONTINUE
523  170 CONTINUE
524  180 CONTINUE
525 *
526 * Print a summary of the results.
527 *
528  CALL alasvm( path, nout, nfail, nrun, nerrs )
529 *
530  9999 FORMAT( 1x, a, ', UPLO=''', a1, ''', N =', i5, ', type ', i2,
531  $ ', test ', i2, ', ratio =', g12.5 )
532  RETURN
533 *
534 * End of CDRVSY_ROOK
535 *
536  END
subroutine alasvm(TYPE, NOUT, NFAIL, NRUN, NERRS)
ALASVM
Definition: alasvm.f:75
subroutine csytri_rook(UPLO, N, A, LDA, IPIV, WORK, INFO)
CSYTRI_ROOK
Definition: csytri_rook.f:131
subroutine alaerh(PATH, SUBNAM, INFO, INFOE, OPTS, M, N, KL, KU, N5, IMAT, NFAIL, NERRS, NOUT)
ALAERH
Definition: alaerh.f:149
subroutine clatsy(UPLO, N, X, LDX, ISEED)
CLATSY
Definition: clatsy.f:91
subroutine clarhs(PATH, XTYPE, UPLO, TRANS, M, N, KL, KU, NRHS, A, LDA, X, LDX, B, LDB, ISEED, INFO)
CLARHS
Definition: clarhs.f:211
subroutine csyt02(UPLO, N, NRHS, A, LDA, X, LDX, B, LDB, RWORK, RESID)
CSYT02
Definition: csyt02.f:129
subroutine cerrvx(PATH, NUNIT)
CERRVX
Definition: cerrvx.f:57
subroutine xlaenv(ISPEC, NVALUE)
XLAENV
Definition: xlaenv.f:83
subroutine csysv_rook(UPLO, N, NRHS, A, LDA, IPIV, B, LDB, WORK, LWORK, INFO)
CSYSV_ROOK computes the solution to system of linear equations A * X = B for SY matrices ...
Definition: csysv_rook.f:206
subroutine cdrvsy_rook(DOTYPE, NN, NVAL, NRHS, THRESH, TSTERR, NMAX, A, AFAC, AINV, B, X, XACT, WORK, RWORK, IWORK, NOUT)
CDRVSY_ROOK
Definition: cdrvsy_rook.f:154
subroutine claset(UPLO, M, N, ALPHA, BETA, A, LDA)
CLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values...
Definition: claset.f:108
subroutine clatms(M, N, DIST, ISEED, SYM, D, MODE, COND, DMAX, KL, KU, PACK, A, LDA, WORK, INFO)
CLATMS
Definition: clatms.f:334
subroutine aladhd(IOUNIT, PATH)
ALADHD
Definition: aladhd.f:80
subroutine csytrf_rook(UPLO, N, A, LDA, IPIV, WORK, LWORK, INFO)
CSYTRF_ROOK
Definition: csytrf_rook.f:210
subroutine clacpy(UPLO, M, N, A, LDA, B, LDB)
CLACPY copies all or part of one two-dimensional array to another.
Definition: clacpy.f:105
subroutine cpot05(UPLO, N, NRHS, A, LDA, B, LDB, X, LDX, XACT, LDXACT, FERR, BERR, RESLTS)
CPOT05
Definition: cpot05.f:167
subroutine clatb4(PATH, IMAT, M, N, TYPE, KL, KU, ANORM, MODE, CNDNUM, DIST)
CLATB4
Definition: clatb4.f:123
subroutine cget04(N, NRHS, X, LDX, XACT, LDXACT, RCOND, RESID)
CGET04
Definition: cget04.f:104
subroutine csyt01_rook(UPLO, N, A, LDA, AFAC, LDAFAC, IPIV, C, LDC, RWORK, RESID)
CSYT01_ROOK
Definition: csyt01_rook.f:127