OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
dchktr.f
Go to the documentation of this file.
1*> \brief \b DCHKTR
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 DCHKTR( DOTYPE, NN, NVAL, NNB, NBVAL, NNS, NSVAL,
12* THRESH, TSTERR, NMAX, A, AINV, B, X, XACT,
13* WORK, RWORK, IWORK, NOUT )
14*
15* .. Scalar Arguments ..
16* LOGICAL TSTERR
17* INTEGER NMAX, NN, NNB, NNS, NOUT
18* DOUBLE PRECISION THRESH
19* ..
20* .. Array Arguments ..
21* LOGICAL DOTYPE( * )
22* INTEGER IWORK( * ), NBVAL( * ), NSVAL( * ), NVAL( * )
23* DOUBLE PRECISION A( * ), AINV( * ), B( * ), RWORK( * ),
24* $ WORK( * ), X( * ), XACT( * )
25* ..
26*
27*
28*> \par Purpose:
29* =============
30*>
31*> \verbatim
32*>
33*> DCHKTR tests DTRTRI, -TRS, -RFS, and -CON, and DLATRS
34*> \endverbatim
35*
36* Arguments:
37* ==========
38*
39*> \param[in] DOTYPE
40*> \verbatim
41*> DOTYPE is LOGICAL array, dimension (NTYPES)
42*> The matrix types to be used for testing. Matrices of type j
43*> (for 1 <= j <= NTYPES) are used for testing if DOTYPE(j) =
44*> .TRUE.; if DOTYPE(j) = .FALSE., then type j is not used.
45*> \endverbatim
46*>
47*> \param[in] NN
48*> \verbatim
49*> NN is INTEGER
50*> The number of values of N contained in the vector NVAL.
51*> \endverbatim
52*>
53*> \param[in] NVAL
54*> \verbatim
55*> NVAL is INTEGER array, dimension (NN)
56*> The values of the matrix column dimension N.
57*> \endverbatim
58*>
59*> \param[in] NNB
60*> \verbatim
61*> NNB is INTEGER
62*> The number of values of NB contained in the vector NBVAL.
63*> \endverbatim
64*>
65*> \param[in] NBVAL
66*> \verbatim
67*> NBVAL is INTEGER array, dimension (NNB)
68*> The values of the blocksize NB.
69*> \endverbatim
70*>
71*> \param[in] NNS
72*> \verbatim
73*> NNS is INTEGER
74*> The number of values of NRHS contained in the vector NSVAL.
75*> \endverbatim
76*>
77*> \param[in] NSVAL
78*> \verbatim
79*> NSVAL is INTEGER array, dimension (NNS)
80*> The values of the number of right hand sides NRHS.
81*> \endverbatim
82*>
83*> \param[in] THRESH
84*> \verbatim
85*> THRESH is DOUBLE PRECISION
86*> The threshold value for the test ratios. A result is
87*> included in the output file if RESULT >= THRESH. To have
88*> every test ratio printed, use THRESH = 0.
89*> \endverbatim
90*>
91*> \param[in] TSTERR
92*> \verbatim
93*> TSTERR is LOGICAL
94*> Flag that indicates whether error exits are to be tested.
95*> \endverbatim
96*>
97*> \param[in] NMAX
98*> \verbatim
99*> NMAX is INTEGER
100*> The leading dimension of the work arrays.
101*> NMAX >= the maximum value of N in NVAL.
102*> \endverbatim
103*>
104*> \param[out] A
105*> \verbatim
106*> A is DOUBLE PRECISION array, dimension (NMAX*NMAX)
107*> \endverbatim
108*>
109*> \param[out] AINV
110*> \verbatim
111*> AINV is DOUBLE PRECISION array, dimension (NMAX*NMAX)
112*> \endverbatim
113*>
114*> \param[out] B
115*> \verbatim
116*> B is DOUBLE PRECISION array, dimension (NMAX*NSMAX)
117*> where NSMAX is the largest entry in NSVAL.
118*> \endverbatim
119*>
120*> \param[out] X
121*> \verbatim
122*> X is DOUBLE PRECISION array, dimension (NMAX*NSMAX)
123*> \endverbatim
124*>
125*> \param[out] XACT
126*> \verbatim
127*> XACT is DOUBLE PRECISION array, dimension (NMAX*NSMAX)
128*> \endverbatim
129*>
130*> \param[out] WORK
131*> \verbatim
132*> WORK is DOUBLE PRECISION array, dimension
133*> (NMAX*max(3,NSMAX))
134*> \endverbatim
135*>
136*> \param[out] RWORK
137*> \verbatim
138*> RWORK is DOUBLE PRECISION array, dimension
139*> (max(NMAX,2*NSMAX))
140*> \endverbatim
141*>
142*> \param[out] IWORK
143*> \verbatim
144*> IWORK is INTEGER array, dimension (NMAX)
145*> \endverbatim
146*>
147*> \param[in] NOUT
148*> \verbatim
149*> NOUT is INTEGER
150*> The unit number for output.
151*> \endverbatim
152*
153* Authors:
154* ========
155*
156*> \author Univ. of Tennessee
157*> \author Univ. of California Berkeley
158*> \author Univ. of Colorado Denver
159*> \author NAG Ltd.
160*
161*> \ingroup double_lin
162*
163* =====================================================================
164 SUBROUTINE dchktr( DOTYPE, NN, NVAL, NNB, NBVAL, NNS, NSVAL,
165 $ THRESH, TSTERR, NMAX, A, AINV, B, X, XACT,
166 $ WORK, RWORK, IWORK, NOUT )
167*
168* -- LAPACK test routine --
169* -- LAPACK is a software package provided by Univ. of Tennessee, --
170* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
171*
172* .. Scalar Arguments ..
173 LOGICAL TSTERR
174 INTEGER NMAX, NN, NNB, NNS, NOUT
175 DOUBLE PRECISION THRESH
176* ..
177* .. Array Arguments ..
178 LOGICAL DOTYPE( * )
179 INTEGER IWORK( * ), NBVAL( * ), NSVAL( * ), NVAL( * )
180 DOUBLE PRECISION A( * ), AINV( * ), B( * ), RWORK( * ),
181 $ work( * ), x( * ), xact( * )
182* ..
183*
184* =====================================================================
185*
186* .. Parameters ..
187 INTEGER NTYPE1, NTYPES
188 PARAMETER ( NTYPE1 = 10, ntypes = 18 )
189 INTEGER NTESTS
190 parameter( ntests = 9 )
191 INTEGER NTRAN
192 parameter( ntran = 3 )
193 DOUBLE PRECISION ONE, ZERO
194 parameter( one = 1.0d0, zero = 0.0d0 )
195* ..
196* .. Local Scalars ..
197 CHARACTER DIAG, NORM, TRANS, UPLO, XTYPE
198 CHARACTER*3 PATH
199 INTEGER I, IDIAG, IMAT, IN, INB, INFO, IRHS, ITRAN,
200 $ iuplo, k, lda, n, nb, nerrs, nfail, nrhs, nrun
201 DOUBLE PRECISION AINVNM, ANORM, DUMMY, RCOND, RCONDC, RCONDI,
202 $ RCONDO, SCALE
203* ..
204* .. Local Arrays ..
205 CHARACTER TRANSS( NTRAN ), UPLOS( 2 )
206 INTEGER ISEED( 4 ), ISEEDY( 4 )
207 DOUBLE PRECISION RESULT( NTESTS )
208* ..
209* .. External Functions ..
210 LOGICAL LSAME
211 DOUBLE PRECISION DLANTR
212 EXTERNAL lsame, dlantr
213* ..
214* .. External Subroutines ..
215 EXTERNAL alaerh, alahd, alasum, dcopy, derrtr, dget04,
218 $ dtrtrs, xlaenv
219* ..
220* .. Scalars in Common ..
221 LOGICAL LERR, OK
222 CHARACTER*32 SRNAMT
223 INTEGER INFOT, IOUNIT
224* ..
225* .. Common blocks ..
226 COMMON / infoc / infot, iounit, ok, lerr
227 COMMON / srnamc / srnamt
228* ..
229* .. Intrinsic Functions ..
230 INTRINSIC max
231* ..
232* .. Data statements ..
233 DATA iseedy / 1988, 1989, 1990, 1991 /
234 DATA uplos / 'U', 'L' / , transs / 'N', 'T', 'C' /
235* ..
236* .. Executable Statements ..
237*
238* Initialize constants and the random number seed.
239*
240 path( 1: 1 ) = 'Double precision'
241 path( 2: 3 ) = 'TR'
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 derrtr( path, nout )
253 infot = 0
254 CALL xlaenv( 2, 2 )
255*
256 DO 120 in = 1, nn
257*
258* Do for each value of N in NVAL
259*
260 n = nval( in )
261 lda = max( 1, n )
262 xtype = 'N'
263*
264 DO 80 imat = 1, ntype1
265*
266* Do the tests only if DOTYPE( IMAT ) is true.
267*
268 IF( .NOT.dotype( imat ) )
269 $ GO TO 80
270*
271 DO 70 iuplo = 1, 2
272*
273* Do first for UPLO = 'U', then for UPLO = 'L'
274*
275 uplo = uplos( iuplo )
276*
277* Call DLATTR to generate a triangular test matrix.
278*
279 srnamt = 'DLATTR'
280 CALL dlattr( imat, uplo, 'No transpose', diag, iseed, n,
281 $ a, lda, x, work, info )
282*
283* Set IDIAG = 1 for non-unit matrices, 2 for unit.
284*
285 IF( lsame( diag, 'N' ) ) THEN
286 idiag = 1
287 ELSE
288 idiag = 2
289 END IF
290*
291 DO 60 inb = 1, nnb
292*
293* Do for each blocksize in NBVAL
294*
295 nb = nbval( inb )
296 CALL xlaenv( 1, nb )
297*
298*+ TEST 1
299* Form the inverse of A.
300*
301 CALL dlacpy( uplo, n, n, a, lda, ainv, lda )
302 srnamt = 'DTRTRI'
303 CALL dtrtri( uplo, diag, n, ainv, lda, info )
304*
305* Check error code from DTRTRI.
306*
307 IF( info.NE.0 )
308 $ CALL alaerh( path, 'DTRTRI', info, 0, uplo // diag,
309 $ n, n, -1, -1, nb, imat, nfail, nerrs,
310 $ nout )
311*
312* Compute the infinity-norm condition number of A.
313*
314 anorm = dlantr( 'I', uplo, diag, n, n, a, lda, rwork )
315 ainvnm = dlantr( 'I', uplo, diag, n, n, ainv, lda,
316 $ rwork )
317 IF( anorm.LE.zero .OR. ainvnm.LE.zero ) THEN
318 rcondi = one
319 ELSE
320 rcondi = ( one / anorm ) / ainvnm
321 END IF
322*
323* Compute the residual for the triangular matrix times
324* its inverse. Also compute the 1-norm condition number
325* of A.
326*
327 CALL dtrt01( uplo, diag, n, a, lda, ainv, lda, rcondo,
328 $ rwork, result( 1 ) )
329*
330* Print the test ratio if it is .GE. THRESH.
331*
332 IF( result( 1 ).GE.thresh ) THEN
333 IF( nfail.EQ.0 .AND. nerrs.EQ.0 )
334 $ CALL alahd( nout, path )
335 WRITE( nout, fmt = 9999 )uplo, diag, n, nb, imat,
336 $ 1, result( 1 )
337 nfail = nfail + 1
338 END IF
339 nrun = nrun + 1
340*
341* Skip remaining tests if not the first block size.
342*
343 IF( inb.NE.1 )
344 $ GO TO 60
345*
346 DO 40 irhs = 1, nns
347 nrhs = nsval( irhs )
348 xtype = 'N'
349*
350 DO 30 itran = 1, ntran
351*
352* Do for op(A) = A, A**T, or A**H.
353*
354 trans = transs( itran )
355 IF( itran.EQ.1 ) THEN
356 norm = 'O'
357 rcondc = rcondo
358 ELSE
359 norm = 'I'
360 rcondc = rcondi
361 END IF
362*
363*+ TEST 2
364* Solve and compute residual for op(A)*x = b.
365*
366 srnamt = 'DLARHS'
367 CALL dlarhs( path, xtype, uplo, trans, n, n, 0,
368 $ idiag, nrhs, a, lda, xact, lda, b,
369 $ lda, iseed, info )
370 xtype = 'C'
371 CALL dlacpy( 'Full', n, nrhs, b, lda, x, lda )
372*
373 srnamt = 'DTRTRS'
374 CALL dtrtrs( uplo, trans, diag, n, nrhs, a, lda,
375 $ x, lda, info )
376*
377* Check error code from DTRTRS.
378*
379 IF( info.NE.0 )
380 $ CALL alaerh( path, 'DTRTRS', info, 0,
381 $ uplo // trans // diag, n, n, -1,
382 $ -1, nrhs, imat, nfail, nerrs,
383 $ nout )
384*
385* This line is needed on a Sun SPARCstation.
386*
387 IF( n.GT.0 )
388 $ dummy = a( 1 )
389*
390 CALL dtrt02( uplo, trans, diag, n, nrhs, a, lda,
391 $ x, lda, b, lda, work, result( 2 ) )
392*
393*+ TEST 3
394* Check solution from generated exact solution.
395*
396 CALL dget04( n, nrhs, x, lda, xact, lda, rcondc,
397 $ result( 3 ) )
398*
399*+ TESTS 4, 5, and 6
400* Use iterative refinement to improve the solution
401* and compute error bounds.
402*
403 srnamt = 'DTRRFS'
404 CALL dtrrfs( uplo, trans, diag, n, nrhs, a, lda,
405 $ b, lda, x, lda, rwork,
406 $ rwork( nrhs+1 ), work, iwork,
407 $ info )
408*
409* Check error code from DTRRFS.
410*
411 IF( info.NE.0 )
412 $ CALL alaerh( path, 'DTRRFS', info, 0,
413 $ uplo // trans // diag, n, n, -1,
414 $ -1, nrhs, imat, nfail, nerrs,
415 $ nout )
416*
417 CALL dget04( n, nrhs, x, lda, xact, lda, rcondc,
418 $ result( 4 ) )
419 CALL dtrt05( uplo, trans, diag, n, nrhs, a, lda,
420 $ b, lda, x, lda, xact, lda, rwork,
421 $ rwork( nrhs+1 ), result( 5 ) )
422*
423* Print information about the tests that did not
424* pass the threshold.
425*
426 DO 20 k = 2, 6
427 IF( result( k ).GE.thresh ) THEN
428 IF( nfail.EQ.0 .AND. nerrs.EQ.0 )
429 $ CALL alahd( nout, path )
430 WRITE( nout, fmt = 9998 )uplo, trans,
431 $ diag, n, nrhs, imat, k, result( k )
432 nfail = nfail + 1
433 END IF
434 20 CONTINUE
435 nrun = nrun + 5
436 30 CONTINUE
437 40 CONTINUE
438*
439*+ TEST 7
440* Get an estimate of RCOND = 1/CNDNUM.
441*
442 DO 50 itran = 1, 2
443 IF( itran.EQ.1 ) THEN
444 norm = 'O'
445 rcondc = rcondo
446 ELSE
447 norm = 'I'
448 rcondc = rcondi
449 END IF
450 srnamt = 'DTRCON'
451 CALL dtrcon( norm, uplo, diag, n, a, lda, rcond,
452 $ work, iwork, info )
453*
454* Check error code from DTRCON.
455*
456 IF( info.NE.0 )
457 $ CALL alaerh( path, 'DTRCON', info, 0,
458 $ norm // uplo // diag, n, n, -1, -1,
459 $ -1, imat, nfail, nerrs, nout )
460*
461 CALL dtrt06( rcond, rcondc, uplo, diag, n, a, lda,
462 $ rwork, result( 7 ) )
463*
464* Print the test ratio if it is .GE. THRESH.
465*
466 IF( result( 7 ).GE.thresh ) THEN
467 IF( nfail.EQ.0 .AND. nerrs.EQ.0 )
468 $ CALL alahd( nout, path )
469 WRITE( nout, fmt = 9997 )norm, uplo, n, imat,
470 $ 7, result( 7 )
471 nfail = nfail + 1
472 END IF
473 nrun = nrun + 1
474 50 CONTINUE
475 60 CONTINUE
476 70 CONTINUE
477 80 CONTINUE
478*
479* Use pathological test matrices to test DLATRS.
480*
481 DO 110 imat = ntype1 + 1, ntypes
482*
483* Do the tests only if DOTYPE( IMAT ) is true.
484*
485 IF( .NOT.dotype( imat ) )
486 $ GO TO 110
487*
488 DO 100 iuplo = 1, 2
489*
490* Do first for UPLO = 'U', then for UPLO = 'L'
491*
492 uplo = uplos( iuplo )
493 DO 90 itran = 1, ntran
494*
495* Do for op(A) = A, A**T, and A**H.
496*
497 trans = transs( itran )
498*
499* Call DLATTR to generate a triangular test matrix.
500*
501 srnamt = 'DLATTR'
502 CALL dlattr( imat, uplo, trans, diag, iseed, n, a,
503 $ lda, x, work, info )
504*
505*+ TEST 8
506* Solve the system op(A)*x = b.
507*
508 srnamt = 'DLATRS'
509 CALL dcopy( n, x, 1, b, 1 )
510 CALL dlatrs( uplo, trans, diag, 'N', n, a, lda, b,
511 $ scale, rwork, info )
512*
513* Check error code from DLATRS.
514*
515 IF( info.NE.0 )
516 $ CALL alaerh( path, 'DLATRS', info, 0,
517 $ uplo // trans // diag // 'N', n, n,
518 $ -1, -1, -1, imat, nfail, nerrs, nout )
519*
520 CALL dtrt03( uplo, trans, diag, n, 1, a, lda, scale,
521 $ rwork, one, b, lda, x, lda, work,
522 $ result( 8 ) )
523*
524*+ TEST 9
525* Solve op(A)*X = b again with NORMIN = 'Y'.
526*
527 CALL dcopy( n, x, 1, b( n+1 ), 1 )
528 CALL dlatrs( uplo, trans, diag, 'Y', n, a, lda,
529 $ b( n+1 ), scale, rwork, info )
530*
531* Check error code from DLATRS.
532*
533 IF( info.NE.0 )
534 $ CALL alaerh( path, 'DLATRS', info, 0,
535 $ uplo // trans // diag // 'Y', n, n,
536 $ -1, -1, -1, imat, nfail, nerrs, nout )
537*
538 CALL dtrt03( uplo, trans, diag, n, 1, a, lda, scale,
539 $ rwork, one, b( n+1 ), lda, x, lda, work,
540 $ result( 9 ) )
541*
542* Print information about the tests that did not pass
543* the threshold.
544*
545 IF( result( 8 ).GE.thresh ) THEN
546 IF( nfail.EQ.0 .AND. nerrs.EQ.0 )
547 $ CALL alahd( nout, path )
548 WRITE( nout, fmt = 9996 )'DLATRS', uplo, trans,
549 $ diag, 'N', n, imat, 8, result( 8 )
550 nfail = nfail + 1
551 END IF
552 IF( result( 9 ).GE.thresh ) THEN
553 IF( nfail.EQ.0 .AND. nerrs.EQ.0 )
554 $ CALL alahd( nout, path )
555 WRITE( nout, fmt = 9996 )'DLATRS', uplo, trans,
556 $ diag, 'Y', n, imat, 9, result( 9 )
557 nfail = nfail + 1
558 END IF
559 nrun = nrun + 2
560 90 CONTINUE
561 100 CONTINUE
562 110 CONTINUE
563 120 CONTINUE
564*
565* Print a summary of the results.
566*
567 CALL alasum( path, nout, nfail, nrun, nerrs )
568*
569 9999 FORMAT( ' UPLO=''', a1, ''', DIAG=''', a1, ''', N=', i5, ', NB=',
570 $ i4, ', type ', i2, ', test(', i2, ')= ', g12.5 )
571 9998 FORMAT( ' UPLO=''', a1, ''', TRANS=''', a1, ''', DIAG=''', a1,
572 $ ''', N=', i5, ', NB=', i4, ', type ', i2, ',
573 $ test(', i2, ')= ', g12.5 )
574 9997 FORMAT( ' NORM=''', a1, ''', UPLO =''', a1, ''', N=', i5, ',',
575 $ 11x, ' type ', i2, ', test(', i2, ')=', g12.5 )
576 9996 FORMAT( 1x, a, '( ''', a1, ''', ''', a1, ''', ''', a1, ''', ''',
577 $ a1, ''',', i5, ', ... ), type ', i2, ', test(', i2, ')=',
578 $ g12.5 )
579 RETURN
580*
581* End of DCHKTR
582*
583 END
subroutine dlacpy(uplo, m, n, a, lda, b, ldb)
DLACPY copies all or part of one two-dimensional array to another.
Definition dlacpy.f:103
subroutine xlaenv(ispec, nvalue)
XLAENV
Definition xlaenv.f:81
subroutine alasum(type, nout, nfail, nrun, nerrs)
ALASUM
Definition alasum.f:73
subroutine alahd(iounit, path)
ALAHD
Definition alahd.f:107
subroutine alaerh(path, subnam, info, infoe, opts, m, n, kl, ku, n5, imat, nfail, nerrs, nout)
ALAERH
Definition alaerh.f:147
double precision function dlantr(norm, uplo, diag, m, n, a, lda, work)
DLANTR returns the value of the 1-norm, or the Frobenius norm, or the infinity norm,...
Definition dlantr.f:141
subroutine dlatrs(uplo, trans, diag, normin, n, a, lda, x, scale, cnorm, info)
DLATRS solves a triangular system of equations with the scale factor set to prevent overflow.
Definition dlatrs.f:238
subroutine dtrcon(norm, uplo, diag, n, a, lda, rcond, work, iwork, info)
DTRCON
Definition dtrcon.f:137
subroutine dtrtri(uplo, diag, n, a, lda, info)
DTRTRI
Definition dtrtri.f:109
subroutine dtrtrs(uplo, trans, diag, n, nrhs, a, lda, b, ldb, info)
DTRTRS
Definition dtrtrs.f:140
subroutine dtrrfs(uplo, trans, diag, n, nrhs, a, lda, b, ldb, x, ldx, ferr, berr, work, iwork, info)
DTRRFS
Definition dtrrfs.f:182
subroutine dcopy(n, dx, incx, dy, incy)
DCOPY
Definition dcopy.f:82
subroutine dlarhs(path, xtype, uplo, trans, m, n, kl, ku, nrhs, a, lda, x, ldx, b, ldb, iseed, info)
DLARHS
Definition dlarhs.f:205
subroutine dchktr(dotype, nn, nval, nnb, nbval, nns, nsval, thresh, tsterr, nmax, a, ainv, b, x, xact, work, rwork, iwork, nout)
DCHKTR
Definition dchktr.f:167
subroutine dtrt05(uplo, trans, diag, n, nrhs, a, lda, b, ldb, x, ldx, xact, ldxact, ferr, berr, reslts)
DTRT05
Definition dtrt05.f:181
subroutine dlattr(imat, uplo, trans, diag, iseed, n, a, lda, b, work, info)
DLATTR
Definition dlattr.f:133
subroutine dtrt03(uplo, trans, diag, n, nrhs, a, lda, scale, cnorm, tscal, x, ldx, b, ldb, work, resid)
DTRT03
Definition dtrt03.f:169
subroutine dtrt02(uplo, trans, diag, n, nrhs, a, lda, x, ldx, b, ldb, work, resid)
DTRT02
Definition dtrt02.f:150
subroutine derrtr(path, nunit)
DERRTR
Definition derrtr.f:55
subroutine dtrt01(uplo, diag, n, a, lda, ainv, ldainv, rcond, work, resid)
DTRT01
Definition dtrt01.f:124
subroutine dtrt06(rcond, rcondc, uplo, diag, n, a, lda, work, rat)
DTRT06
Definition dtrt06.f:121
subroutine dget04(n, nrhs, x, ldx, xact, ldxact, rcond, resid)
DGET04
Definition dget04.f:102
#define max(a, b)
Definition macros.h:21