OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
cchkpt.f
Go to the documentation of this file.
1*> \brief \b CCHKPT
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 CCHKPT( DOTYPE, NN, NVAL, NNS, NSVAL, THRESH, TSTERR,
12* A, D, E, B, X, XACT, WORK, RWORK, NOUT )
13*
14* .. Scalar Arguments ..
15* LOGICAL TSTERR
16* INTEGER NN, NNS, NOUT
17* REAL THRESH
18* ..
19* .. Array Arguments ..
20* LOGICAL DOTYPE( * )
21* INTEGER NSVAL( * ), NVAL( * )
22* REAL D( * ), RWORK( * )
23* COMPLEX A( * ), B( * ), E( * ), WORK( * ), X( * ),
24* $ XACT( * )
25* ..
26*
27*
28*> \par Purpose:
29* =============
30*>
31*> \verbatim
32*>
33*> CCHKPT tests CPTTRF, -TRS, -RFS, and -CON
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 dimension N.
57*> \endverbatim
58*>
59*> \param[in] NNS
60*> \verbatim
61*> NNS is INTEGER
62*> The number of values of NRHS contained in the vector NSVAL.
63*> \endverbatim
64*>
65*> \param[in] NSVAL
66*> \verbatim
67*> NSVAL is INTEGER array, dimension (NNS)
68*> The values of the number of right hand sides NRHS.
69*> \endverbatim
70*>
71*> \param[in] THRESH
72*> \verbatim
73*> THRESH is REAL
74*> The threshold value for the test ratios. A result is
75*> included in the output file if RESULT >= THRESH. To have
76*> every test ratio printed, use THRESH = 0.
77*> \endverbatim
78*>
79*> \param[in] TSTERR
80*> \verbatim
81*> TSTERR is LOGICAL
82*> Flag that indicates whether error exits are to be tested.
83*> \endverbatim
84*>
85*> \param[out] A
86*> \verbatim
87*> A is COMPLEX array, dimension (NMAX*2)
88*> \endverbatim
89*>
90*> \param[out] D
91*> \verbatim
92*> D is REAL array, dimension (NMAX*2)
93*> \endverbatim
94*>
95*> \param[out] E
96*> \verbatim
97*> E is COMPLEX array, dimension (NMAX*2)
98*> \endverbatim
99*>
100*> \param[out] B
101*> \verbatim
102*> B is COMPLEX array, dimension (NMAX*NSMAX)
103*> where NSMAX is the largest entry in NSVAL.
104*> \endverbatim
105*>
106*> \param[out] X
107*> \verbatim
108*> X is COMPLEX array, dimension (NMAX*NSMAX)
109*> \endverbatim
110*>
111*> \param[out] XACT
112*> \verbatim
113*> XACT is COMPLEX array, dimension (NMAX*NSMAX)
114*> \endverbatim
115*>
116*> \param[out] WORK
117*> \verbatim
118*> WORK is COMPLEX array, dimension
119*> (NMAX*max(3,NSMAX))
120*> \endverbatim
121*>
122*> \param[out] RWORK
123*> \verbatim
124*> RWORK is REAL array, dimension
125*> (max(NMAX,2*NSMAX))
126*> \endverbatim
127*>
128*> \param[in] NOUT
129*> \verbatim
130*> NOUT is INTEGER
131*> The unit number for output.
132*> \endverbatim
133*
134* Authors:
135* ========
136*
137*> \author Univ. of Tennessee
138*> \author Univ. of California Berkeley
139*> \author Univ. of Colorado Denver
140*> \author NAG Ltd.
141*
142*> \ingroup complex_lin
143*
144* =====================================================================
145 SUBROUTINE cchkpt( DOTYPE, NN, NVAL, NNS, NSVAL, THRESH, TSTERR,
146 $ A, D, E, B, X, XACT, WORK, RWORK, NOUT )
147*
148* -- LAPACK test routine --
149* -- LAPACK is a software package provided by Univ. of Tennessee, --
150* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
151*
152* .. Scalar Arguments ..
153 LOGICAL TSTERR
154 INTEGER NN, NNS, NOUT
155 REAL THRESH
156* ..
157* .. Array Arguments ..
158 LOGICAL DOTYPE( * )
159 INTEGER NSVAL( * ), NVAL( * )
160 REAL D( * ), RWORK( * )
161 COMPLEX A( * ), B( * ), E( * ), WORK( * ), X( * ),
162 $ xact( * )
163* ..
164*
165* =====================================================================
166*
167* .. Parameters ..
168 REAL ONE, ZERO
169 parameter( one = 1.0e+0, zero = 0.0e+0 )
170 INTEGER NTYPES
171 parameter( ntypes = 12 )
172 INTEGER NTESTS
173 parameter( ntests = 7 )
174* ..
175* .. Local Scalars ..
176 LOGICAL ZEROT
177 CHARACTER DIST, TYPE, UPLO
178 CHARACTER*3 PATH
179 INTEGER I, IA, IMAT, IN, INFO, IRHS, IUPLO, IX, IZERO,
180 $ j, k, kl, ku, lda, mode, n, nerrs, nfail,
181 $ nimat, nrhs, nrun
182 REAL AINVNM, ANORM, COND, DMAX, RCOND, RCONDC
183* ..
184* .. Local Arrays ..
185 CHARACTER UPLOS( 2 )
186 INTEGER ISEED( 4 ), ISEEDY( 4 )
187 REAL RESULT( NTESTS )
188 COMPLEX Z( 3 )
189* ..
190* .. External Functions ..
191 INTEGER ISAMAX
192 REAL CLANHT, SCASUM, SGET06
193 EXTERNAL isamax, clanht, scasum, sget06
194* ..
195* .. External Subroutines ..
196 EXTERNAL alaerh, alahd, alasum, ccopy, cerrgt, cget04,
200* ..
201* .. Intrinsic Functions ..
202 INTRINSIC abs, max, real
203* ..
204* .. Scalars in Common ..
205 LOGICAL LERR, OK
206 CHARACTER*32 SRNAMT
207 INTEGER INFOT, NUNIT
208* ..
209* .. Common blocks ..
210 COMMON / infoc / infot, nunit, ok, lerr
211 COMMON / srnamc / srnamt
212* ..
213* .. Data statements ..
214 DATA iseedy / 0, 0, 0, 1 / , uplos / 'U', 'L' /
215* ..
216* .. Executable Statements ..
217*
218 path( 1: 1 ) = 'Complex precision'
219 path( 2: 3 ) = 'PT'
220 nrun = 0
221 nfail = 0
222 nerrs = 0
223 DO 10 i = 1, 4
224 iseed( i ) = iseedy( i )
225 10 CONTINUE
226*
227* Test the error exits
228*
229 IF( tsterr )
230 $ CALL cerrgt( path, nout )
231 infot = 0
232*
233 DO 120 in = 1, nn
234*
235* Do for each value of N in NVAL.
236*
237 n = nval( in )
238 lda = max( 1, n )
239 nimat = ntypes
240 IF( n.LE.0 )
241 $ nimat = 1
242*
243 DO 110 imat = 1, nimat
244*
245* Do the tests only if DOTYPE( IMAT ) is true.
246*
247 IF( n.GT.0 .AND. .NOT.dotype( imat ) )
248 $ GO TO 110
249*
250* Set up parameters with CLATB4.
251*
252 CALL clatb4( path, imat, n, n, TYPE, kl, ku, anorm, mode,
253 $ cond, dist )
254*
255 zerot = imat.GE.8 .AND. imat.LE.10
256 IF( imat.LE.6 ) THEN
257*
258* Type 1-6: generate a Hermitian tridiagonal matrix of
259* known condition number in lower triangular band storage.
260*
261 srnamt = 'CLATMS'
262 CALL clatms( n, n, dist, iseed, TYPE, rwork, mode, cond,
263 $ anorm, kl, ku, 'B', a, 2, work, info )
264*
265* Check the error code from CLATMS.
266*
267 IF( info.NE.0 ) THEN
268 CALL alaerh( path, 'clatms', INFO, 0, ' ', N, N, KL,
269 $ KU, -1, IMAT, NFAIL, NERRS, NOUT )
270 GO TO 110
271 END IF
272 IZERO = 0
273*
274* Copy the matrix to D and E.
275*
276 IA = 1
277 DO 20 I = 1, N - 1
278 D( I ) = REAL( A( IA ) )
279 E( I ) = A( IA+1 )
280 IA = IA + 2
281 20 CONTINUE
282.GT. IF( N0 )
283 $ D( N ) = REAL( A( IA ) )
284 ELSE
285*
286* Type 7-12: generate a diagonally dominant matrix with
287* unknown condition number in the vectors D and E.
288*
289.NOT..OR..NOT. IF( ZEROT DOTYPE( 7 ) ) THEN
290*
291* Let E be complex, D real, with values from [-1,1].
292*
293 CALL SLARNV( 2, ISEED, N, D )
294 CALL CLARNV( 2, ISEED, N-1, E )
295*
296* Make the tridiagonal matrix diagonally dominant.
297*
298.EQ. IF( N1 ) THEN
299 D( 1 ) = ABS( D( 1 ) )
300 ELSE
301 D( 1 ) = ABS( D( 1 ) ) + ABS( E( 1 ) )
302 D( N ) = ABS( D( N ) ) + ABS( E( N-1 ) )
303 DO 30 I = 2, N - 1
304 D( I ) = ABS( D( I ) ) + ABS( E( I ) ) +
305 $ ABS( E( I-1 ) )
306 30 CONTINUE
307 END IF
308*
309* Scale D and E so the maximum element is ANORM.
310*
311 IX = ISAMAX( N, D, 1 )
312 DMAX = D( IX )
313 CALL SSCAL( N, ANORM / DMAX, D, 1 )
314 CALL CSSCAL( N-1, ANORM / DMAX, E, 1 )
315*
316.GT. ELSE IF( IZERO0 ) THEN
317*
318* Reuse the last matrix by copying back the zeroed out
319* elements.
320*
321.EQ. IF( IZERO1 ) THEN
322 D( 1 ) = Z( 2 )
323.GT. IF( N1 )
324 $ E( 1 ) = Z( 3 )
325.EQ. ELSE IF( IZERON ) THEN
326 E( N-1 ) = Z( 1 )
327 D( N ) = Z( 2 )
328 ELSE
329 E( IZERO-1 ) = Z( 1 )
330 D( IZERO ) = Z( 2 )
331 E( IZERO ) = Z( 3 )
332 END IF
333 END IF
334*
335* For types 8-10, set one row and column of the matrix to
336* zero.
337*
338 IZERO = 0
339.EQ. IF( IMAT8 ) THEN
340 IZERO = 1
341 Z( 2 ) = D( 1 )
342 D( 1 ) = ZERO
343.GT. IF( N1 ) THEN
344 Z( 3 ) = E( 1 )
345 E( 1 ) = ZERO
346 END IF
347.EQ. ELSE IF( IMAT9 ) THEN
348 IZERO = N
349.GT. IF( N1 ) THEN
350 Z( 1 ) = E( N-1 )
351 E( N-1 ) = ZERO
352 END IF
353 Z( 2 ) = D( N )
354 D( N ) = ZERO
355.EQ. ELSE IF( IMAT10 ) THEN
356 IZERO = ( N+1 ) / 2
357.GT. IF( IZERO1 ) THEN
358 Z( 1 ) = E( IZERO-1 )
359 Z( 3 ) = E( IZERO )
360 E( IZERO-1 ) = ZERO
361 E( IZERO ) = ZERO
362 END IF
363 Z( 2 ) = D( IZERO )
364 D( IZERO ) = ZERO
365 END IF
366 END IF
367*
368 CALL SCOPY( N, D, 1, D( N+1 ), 1 )
369.GT. IF( N1 )
370 $ CALL CCOPY( N-1, E, 1, E( N+1 ), 1 )
371*
372*+ TEST 1
373* Factor A as L*D*L' and compute the ratio
374* norm(L*D*L' - A) / (n * norm(A) * EPS )
375*
376 CALL CPTTRF( N, D( N+1 ), E( N+1 ), INFO )
377*
378* Check error code from CPTTRF.
379*
380.NE. IF( INFOIZERO ) THEN
381 CALL ALAERH( PATH, 'cpttrf', INFO, IZERO, ' ', N, N, -1,
382 $ -1, -1, IMAT, NFAIL, NERRS, NOUT )
383 GO TO 110
384 END IF
385*
386.GT. IF( INFO0 ) THEN
387 RCONDC = ZERO
388 GO TO 100
389 END IF
390*
391 CALL CPTT01( N, D, E, D( N+1 ), E( N+1 ), WORK,
392 $ RESULT( 1 ) )
393*
394* Print the test ratio if greater than or equal to THRESH.
395*
396.GE. IF( RESULT( 1 )THRESH ) THEN
397.EQ..AND..EQ. IF( NFAIL0 NERRS0 )
398 $ CALL ALAHD( NOUT, PATH )
399 WRITE( NOUT, FMT = 9999 )N, IMAT, 1, RESULT( 1 )
400 NFAIL = NFAIL + 1
401 END IF
402 NRUN = NRUN + 1
403*
404* Compute RCONDC = 1 / (norm(A) * norm(inv(A))
405*
406* Compute norm(A).
407*
408 ANORM = CLANHT( '1', N, D, E )
409*
410* Use CPTTRS to solve for one column at a time of inv(A),
411* computing the maximum column sum as we go.
412*
413 AINVNM = ZERO
414 DO 50 I = 1, N
415 DO 40 J = 1, N
416 X( J ) = ZERO
417 40 CONTINUE
418 X( I ) = ONE
419 CALL CPTTRS( 'lower', N, 1, D( N+1 ), E( N+1 ), X, LDA,
420 $ INFO )
421 AINVNM = MAX( AINVNM, SCASUM( N, X, 1 ) )
422 50 CONTINUE
423 RCONDC = ONE / MAX( ONE, ANORM*AINVNM )
424*
425 DO 90 IRHS = 1, NNS
426 NRHS = NSVAL( IRHS )
427*
428* Generate NRHS random solution vectors.
429*
430 IX = 1
431 DO 60 J = 1, NRHS
432 CALL CLARNV( 2, ISEED, N, XACT( IX ) )
433 IX = IX + LDA
434 60 CONTINUE
435*
436 DO 80 IUPLO = 1, 2
437*
438* Do first for UPLO = 'U', then for UPLO = 'L'.
439*
440 UPLO = UPLOS( IUPLO )
441*
442* Set the right hand side.
443*
444 CALL CLAPTM( UPLO, N, NRHS, ONE, D, E, XACT, LDA,
445 $ ZERO, B, LDA )
446*
447*+ TEST 2
448* Solve A*x = b and compute the residual.
449*
450 CALL CLACPY( 'full', N, NRHS, B, LDA, X, LDA )
451 CALL CPTTRS( UPLO, N, NRHS, D( N+1 ), E( N+1 ), X,
452 $ LDA, INFO )
453*
454* Check error code from CPTTRS.
455*
456.NE. IF( INFO0 )
457 $ CALL ALAERH( PATH, 'cpttrs', INFO, 0, UPLO, N, N,
458 $ -1, -1, NRHS, IMAT, NFAIL, NERRS,
459 $ NOUT )
460*
461 CALL CLACPY( 'full', N, NRHS, B, LDA, WORK, LDA )
462 CALL CPTT02( UPLO, N, NRHS, D, E, X, LDA, WORK, LDA,
463 $ RESULT( 2 ) )
464*
465*+ TEST 3
466* Check solution from generated exact solution.
467*
468 CALL CGET04( N, NRHS, X, LDA, XACT, LDA, RCONDC,
469 $ RESULT( 3 ) )
470*
471*+ TESTS 4, 5, and 6
472* Use iterative refinement to improve the solution.
473*
474 SRNAMT = 'cptrfs'
475 CALL CPTRFS( UPLO, N, NRHS, D, E, D( N+1 ), E( N+1 ),
476 $ B, LDA, X, LDA, RWORK, RWORK( NRHS+1 ),
477 $ WORK, RWORK( 2*NRHS+1 ), INFO )
478*
479* Check error code from CPTRFS.
480*
481.NE. IF( INFO0 )
482 $ CALL ALAERH( PATH, 'cptrfs', INFO, 0, UPLO, N, N,
483 $ -1, -1, NRHS, IMAT, NFAIL, NERRS,
484 $ NOUT )
485*
486 CALL CGET04( N, NRHS, X, LDA, XACT, LDA, RCONDC,
487 $ RESULT( 4 ) )
488 CALL CPTT05( N, NRHS, D, E, B, LDA, X, LDA, XACT, LDA,
489 $ RWORK, RWORK( NRHS+1 ), RESULT( 5 ) )
490*
491* Print information about the tests that did not pass the
492* threshold.
493*
494 DO 70 K = 2, 6
495.GE. IF( RESULT( K )THRESH ) THEN
496.EQ..AND..EQ. IF( NFAIL0 NERRS0 )
497 $ CALL ALAHD( NOUT, PATH )
498 WRITE( NOUT, FMT = 9998 )UPLO, N, NRHS, IMAT,
499 $ K, RESULT( K )
500 NFAIL = NFAIL + 1
501 END IF
502 70 CONTINUE
503 NRUN = NRUN + 5
504*
505 80 CONTINUE
506 90 CONTINUE
507*
508*+ TEST 7
509* Estimate the reciprocal of the condition number of the
510* matrix.
511*
512 100 CONTINUE
513 SRNAMT = 'cptcon'
514 CALL CPTCON( N, D( N+1 ), E( N+1 ), ANORM, RCOND, RWORK,
515 $ INFO )
516*
517* Check error code from CPTCON.
518*
519.NE. IF( INFO0 )
520 $ CALL ALAERH( PATH, 'cptcon', INFO, 0, ' ', N, N, -1, -1,
521 $ -1, IMAT, NFAIL, NERRS, NOUT )
522*
523 RESULT( 7 ) = SGET06( RCOND, RCONDC )
524*
525* Print the test ratio if greater than or equal to THRESH.
526*
527.GE. IF( RESULT( 7 )THRESH ) THEN
528.EQ..AND..EQ. IF( NFAIL0 NERRS0 )
529 $ CALL ALAHD( NOUT, PATH )
530 WRITE( NOUT, FMT = 9999 )N, IMAT, 7, RESULT( 7 )
531 NFAIL = NFAIL + 1
532 END IF
533 NRUN = NRUN + 1
534 110 CONTINUE
535 120 CONTINUE
536*
537* Print a summary of the results.
538*
539 CALL ALASUM( PATH, NOUT, NFAIL, NRUN, NERRS )
540*
541 9999 FORMAT( ' n =', I5, ', type ', I2, ', test ', I2, ', ratio = ',
542 $ G12.5 )
543 9998 FORMAT( ' uplo = ''', A1, ''', n =', I5, ', nrhs =', I3,
544 $ ', type ', I2, ', test ', I2, ', ratio = ', G12.5 )
545 RETURN
546*
547* End of CCHKPT
548*
549 END
subroutine slarnv(idist, iseed, n, x)
SLARNV returns a vector of random numbers from a uniform or normal distribution.
Definition slarnv.f:97
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
subroutine clacpy(uplo, m, n, a, lda, b, ldb)
CLACPY copies all or part of one two-dimensional array to another.
Definition clacpy.f:103
subroutine clarnv(idist, iseed, n, x)
CLARNV returns a vector of random numbers from a uniform or normal distribution.
Definition clarnv.f:99
subroutine cptrfs(uplo, n, nrhs, d, e, df, ef, b, ldb, x, ldx, ferr, berr, work, rwork, info)
CPTRFS
Definition cptrfs.f:183
subroutine cpttrf(n, d, e, info)
CPTTRF
Definition cpttrf.f:92
subroutine cpttrs(uplo, n, nrhs, d, e, b, ldb, info)
CPTTRS
Definition cpttrs.f:121
subroutine cptcon(n, d, e, anorm, rcond, rwork, info)
CPTCON
Definition cptcon.f:119
subroutine csscal(n, sa, cx, incx)
CSSCAL
Definition csscal.f:78
subroutine ccopy(n, cx, incx, cy, incy)
CCOPY
Definition ccopy.f:81
subroutine cchkpt(dotype, nn, nval, nns, nsval, thresh, tsterr, a, d, e, b, x, xact, work, rwork, nout)
CCHKPT
Definition cchkpt.f:147
subroutine claptm(uplo, n, nrhs, alpha, d, e, x, ldx, beta, b, ldb)
CLAPTM
Definition claptm.f:129
subroutine cptt05(n, nrhs, d, e, b, ldb, x, ldx, xact, ldxact, ferr, berr, reslts)
CPTT05
Definition cptt05.f:150
subroutine clatb4(path, imat, m, n, type, kl, ku, anorm, mode, cndnum, dist)
CLATB4
Definition clatb4.f:121
subroutine cerrgt(path, nunit)
CERRGT
Definition cerrgt.f:55
subroutine cptt01(n, d, e, df, ef, work, resid)
CPTT01
Definition cptt01.f:92
subroutine cget04(n, nrhs, x, ldx, xact, ldxact, rcond, resid)
CGET04
Definition cget04.f:102
subroutine cptt02(uplo, n, nrhs, d, e, x, ldx, b, ldb, resid)
CPTT02
Definition cptt02.f:115
subroutine clatms(m, n, dist, iseed, sym, d, mode, cond, dmax, kl, ku, pack, a, lda, work, info)
CLATMS
Definition clatms.f:332
subroutine sscal(n, sa, sx, incx)
SSCAL
Definition sscal.f:79
subroutine scopy(n, sx, incx, sy, incy)
SCOPY
Definition scopy.f:82
#define max(a, b)
Definition macros.h:21