You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

dchksp.f 18 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567
  1. *> \brief \b DCHKSP
  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 DCHKSP( DOTYPE, NN, NVAL, NNS, NSVAL, 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, NNS, NOUT
  18. * DOUBLE PRECISION THRESH
  19. * ..
  20. * .. Array Arguments ..
  21. * LOGICAL DOTYPE( * )
  22. * INTEGER IWORK( * ), NSVAL( * ), NVAL( * )
  23. * DOUBLE PRECISION A( * ), AFAC( * ), AINV( * ), B( * ),
  24. * $ RWORK( * ), WORK( * ), X( * ), XACT( * )
  25. * ..
  26. *
  27. *
  28. *> \par Purpose:
  29. * =============
  30. *>
  31. *> \verbatim
  32. *>
  33. *> DCHKSP tests DSPTRF, -TRI, -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 DOUBLE PRECISION
  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[in] NMAX
  86. *> \verbatim
  87. *> NMAX is INTEGER
  88. *> The maximum value permitted for N, used in dimensioning the
  89. *> work arrays.
  90. *> \endverbatim
  91. *>
  92. *> \param[out] A
  93. *> \verbatim
  94. *> A is DOUBLE PRECISION array, dimension
  95. *> (NMAX*(NMAX+1)/2)
  96. *> \endverbatim
  97. *>
  98. *> \param[out] AFAC
  99. *> \verbatim
  100. *> AFAC is DOUBLE PRECISION array, dimension
  101. *> (NMAX*(NMAX+1)/2)
  102. *> \endverbatim
  103. *>
  104. *> \param[out] AINV
  105. *> \verbatim
  106. *> AINV is DOUBLE PRECISION array, dimension
  107. *> (NMAX*(NMAX+1)/2)
  108. *> \endverbatim
  109. *>
  110. *> \param[out] B
  111. *> \verbatim
  112. *> B is DOUBLE PRECISION array, dimension (NMAX*NSMAX)
  113. *> where NSMAX is the largest entry in NSVAL.
  114. *> \endverbatim
  115. *>
  116. *> \param[out] X
  117. *> \verbatim
  118. *> X is DOUBLE PRECISION array, dimension (NMAX*NSMAX)
  119. *> \endverbatim
  120. *>
  121. *> \param[out] XACT
  122. *> \verbatim
  123. *> XACT is DOUBLE PRECISION array, dimension (NMAX*NSMAX)
  124. *> \endverbatim
  125. *>
  126. *> \param[out] WORK
  127. *> \verbatim
  128. *> WORK is DOUBLE PRECISION array, dimension
  129. *> (NMAX*max(2,NSMAX))
  130. *> \endverbatim
  131. *>
  132. *> \param[out] RWORK
  133. *> \verbatim
  134. *> RWORK is DOUBLE PRECISION array,
  135. *> dimension (NMAX+2*NSMAX)
  136. *> \endverbatim
  137. *>
  138. *> \param[out] IWORK
  139. *> \verbatim
  140. *> IWORK is INTEGER array, dimension (2*NMAX)
  141. *> \endverbatim
  142. *>
  143. *> \param[in] NOUT
  144. *> \verbatim
  145. *> NOUT is INTEGER
  146. *> The unit number for output.
  147. *> \endverbatim
  148. *
  149. * Authors:
  150. * ========
  151. *
  152. *> \author Univ. of Tennessee
  153. *> \author Univ. of California Berkeley
  154. *> \author Univ. of Colorado Denver
  155. *> \author NAG Ltd.
  156. *
  157. *> \date December 2016
  158. *
  159. *> \ingroup double_lin
  160. *
  161. * =====================================================================
  162. SUBROUTINE DCHKSP( DOTYPE, NN, NVAL, NNS, NSVAL, THRESH, TSTERR,
  163. $ NMAX, A, AFAC, AINV, B, X, XACT, WORK, RWORK,
  164. $ IWORK, NOUT )
  165. *
  166. * -- LAPACK test routine (version 3.7.0) --
  167. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  168. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  169. * December 2016
  170. *
  171. * .. Scalar Arguments ..
  172. LOGICAL TSTERR
  173. INTEGER NMAX, NN, NNS, NOUT
  174. DOUBLE PRECISION THRESH
  175. * ..
  176. * .. Array Arguments ..
  177. LOGICAL DOTYPE( * )
  178. INTEGER IWORK( * ), NSVAL( * ), NVAL( * )
  179. DOUBLE PRECISION A( * ), AFAC( * ), AINV( * ), B( * ),
  180. $ RWORK( * ), WORK( * ), X( * ), XACT( * )
  181. * ..
  182. *
  183. * =====================================================================
  184. *
  185. * .. Parameters ..
  186. DOUBLE PRECISION ZERO
  187. PARAMETER ( ZERO = 0.0D+0 )
  188. INTEGER NTYPES
  189. PARAMETER ( NTYPES = 10 )
  190. INTEGER NTESTS
  191. PARAMETER ( NTESTS = 8 )
  192. * ..
  193. * .. Local Scalars ..
  194. LOGICAL TRFCON, ZEROT
  195. CHARACTER DIST, PACKIT, TYPE, UPLO, XTYPE
  196. CHARACTER*3 PATH
  197. INTEGER I, I1, I2, IMAT, IN, INFO, IOFF, IRHS, IUPLO,
  198. $ IZERO, J, K, KL, KU, LDA, MODE, N, NERRS,
  199. $ NFAIL, NIMAT, NPP, NRHS, NRUN, NT
  200. DOUBLE PRECISION ANORM, CNDNUM, RCOND, RCONDC
  201. * ..
  202. * .. Local Arrays ..
  203. CHARACTER UPLOS( 2 )
  204. INTEGER ISEED( 4 ), ISEEDY( 4 )
  205. DOUBLE PRECISION RESULT( NTESTS )
  206. * ..
  207. * .. External Functions ..
  208. LOGICAL LSAME
  209. DOUBLE PRECISION DGET06, DLANSP
  210. EXTERNAL LSAME, DGET06, DLANSP
  211. * ..
  212. * .. External Subroutines ..
  213. EXTERNAL ALAERH, ALAHD, ALASUM, DCOPY, DERRSY, DGET04,
  214. $ DLACPY, DLARHS, DLATB4, DLATMS, DPPT02, DPPT03,
  215. $ DPPT05, DSPCON, DSPRFS, DSPT01, DSPTRF, DSPTRI,
  216. $ DSPTRS
  217. * ..
  218. * .. Intrinsic Functions ..
  219. INTRINSIC MAX, MIN
  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. * ..
  234. * .. Executable Statements ..
  235. *
  236. * Initialize constants and the random number seed.
  237. *
  238. PATH( 1: 1 ) = 'Double precision'
  239. PATH( 2: 3 ) = 'SP'
  240. NRUN = 0
  241. NFAIL = 0
  242. NERRS = 0
  243. DO 10 I = 1, 4
  244. ISEED( I ) = ISEEDY( I )
  245. 10 CONTINUE
  246. *
  247. * Test the error exits
  248. *
  249. IF( TSTERR )
  250. $ CALL DERRSY( PATH, NOUT )
  251. INFOT = 0
  252. *
  253. * Do for each value of N in NVAL
  254. *
  255. DO 170 IN = 1, NN
  256. N = NVAL( IN )
  257. LDA = MAX( N, 1 )
  258. XTYPE = 'N'
  259. NIMAT = NTYPES
  260. IF( N.LE.0 )
  261. $ NIMAT = 1
  262. *
  263. IZERO = 0
  264. DO 160 IMAT = 1, NIMAT
  265. *
  266. * Do the tests only if DOTYPE( IMAT ) is true.
  267. *
  268. IF( .NOT.DOTYPE( IMAT ) )
  269. $ GO TO 160
  270. *
  271. * Skip types 3, 4, 5, or 6 if the matrix size is too small.
  272. *
  273. ZEROT = IMAT.GE.3 .AND. IMAT.LE.6
  274. IF( ZEROT .AND. N.LT.IMAT-2 )
  275. $ GO TO 160
  276. *
  277. * Do first for UPLO = 'U', then for UPLO = 'L'
  278. *
  279. DO 150 IUPLO = 1, 2
  280. UPLO = UPLOS( IUPLO )
  281. IF( LSAME( UPLO, 'U' ) ) THEN
  282. PACKIT = 'C'
  283. ELSE
  284. PACKIT = 'R'
  285. END IF
  286. *
  287. * Set up parameters with DLATB4 and generate a test matrix
  288. * with DLATMS.
  289. *
  290. CALL DLATB4( PATH, IMAT, N, N, TYPE, KL, KU, ANORM, MODE,
  291. $ CNDNUM, DIST )
  292. *
  293. SRNAMT = 'DLATMS'
  294. CALL DLATMS( N, N, DIST, ISEED, TYPE, RWORK, MODE,
  295. $ CNDNUM, ANORM, KL, KU, PACKIT, A, LDA, WORK,
  296. $ INFO )
  297. *
  298. * Check error code from DLATMS.
  299. *
  300. IF( INFO.NE.0 ) THEN
  301. CALL ALAERH( PATH, 'DLATMS', INFO, 0, UPLO, N, N, -1,
  302. $ -1, -1, IMAT, NFAIL, NERRS, NOUT )
  303. GO TO 150
  304. END IF
  305. *
  306. * For types 3-6, zero one or more rows and columns of
  307. * the matrix to test that INFO is returned correctly.
  308. *
  309. IF( ZEROT ) THEN
  310. IF( IMAT.EQ.3 ) THEN
  311. IZERO = 1
  312. ELSE IF( IMAT.EQ.4 ) THEN
  313. IZERO = N
  314. ELSE
  315. IZERO = N / 2 + 1
  316. END IF
  317. *
  318. IF( IMAT.LT.6 ) THEN
  319. *
  320. * Set row and column IZERO to zero.
  321. *
  322. IF( IUPLO.EQ.1 ) THEN
  323. IOFF = ( IZERO-1 )*IZERO / 2
  324. DO 20 I = 1, IZERO - 1
  325. A( IOFF+I ) = ZERO
  326. 20 CONTINUE
  327. IOFF = IOFF + IZERO
  328. DO 30 I = IZERO, N
  329. A( IOFF ) = ZERO
  330. IOFF = IOFF + I
  331. 30 CONTINUE
  332. ELSE
  333. IOFF = IZERO
  334. DO 40 I = 1, IZERO - 1
  335. A( IOFF ) = ZERO
  336. IOFF = IOFF + N - I
  337. 40 CONTINUE
  338. IOFF = IOFF - IZERO
  339. DO 50 I = IZERO, N
  340. A( IOFF+I ) = ZERO
  341. 50 CONTINUE
  342. END IF
  343. ELSE
  344. IOFF = 0
  345. IF( IUPLO.EQ.1 ) THEN
  346. *
  347. * Set the first IZERO rows and columns to zero.
  348. *
  349. DO 70 J = 1, N
  350. I2 = MIN( J, IZERO )
  351. DO 60 I = 1, I2
  352. A( IOFF+I ) = ZERO
  353. 60 CONTINUE
  354. IOFF = IOFF + J
  355. 70 CONTINUE
  356. ELSE
  357. *
  358. * Set the last IZERO rows and columns to zero.
  359. *
  360. DO 90 J = 1, N
  361. I1 = MAX( J, IZERO )
  362. DO 80 I = I1, N
  363. A( IOFF+I ) = ZERO
  364. 80 CONTINUE
  365. IOFF = IOFF + N - J
  366. 90 CONTINUE
  367. END IF
  368. END IF
  369. ELSE
  370. IZERO = 0
  371. END IF
  372. *
  373. * Compute the L*D*L' or U*D*U' factorization of the matrix.
  374. *
  375. NPP = N*( N+1 ) / 2
  376. CALL DCOPY( NPP, A, 1, AFAC, 1 )
  377. SRNAMT = 'DSPTRF'
  378. CALL DSPTRF( UPLO, N, AFAC, IWORK, INFO )
  379. *
  380. * Adjust the expected value of INFO to account for
  381. * pivoting.
  382. *
  383. K = IZERO
  384. IF( K.GT.0 ) THEN
  385. 100 CONTINUE
  386. IF( IWORK( K ).LT.0 ) THEN
  387. IF( IWORK( K ).NE.-K ) THEN
  388. K = -IWORK( K )
  389. GO TO 100
  390. END IF
  391. ELSE IF( IWORK( K ).NE.K ) THEN
  392. K = IWORK( K )
  393. GO TO 100
  394. END IF
  395. END IF
  396. *
  397. * Check error code from DSPTRF.
  398. *
  399. IF( INFO.NE.K )
  400. $ CALL ALAERH( PATH, 'DSPTRF', INFO, K, UPLO, N, N, -1,
  401. $ -1, -1, IMAT, NFAIL, NERRS, NOUT )
  402. IF( INFO.NE.0 ) THEN
  403. TRFCON = .TRUE.
  404. ELSE
  405. TRFCON = .FALSE.
  406. END IF
  407. *
  408. *+ TEST 1
  409. * Reconstruct matrix from factors and compute residual.
  410. *
  411. CALL DSPT01( UPLO, N, A, AFAC, IWORK, AINV, LDA, RWORK,
  412. $ RESULT( 1 ) )
  413. NT = 1
  414. *
  415. *+ TEST 2
  416. * Form the inverse and compute the residual.
  417. *
  418. IF( .NOT.TRFCON ) THEN
  419. CALL DCOPY( NPP, AFAC, 1, AINV, 1 )
  420. SRNAMT = 'DSPTRI'
  421. CALL DSPTRI( UPLO, N, AINV, IWORK, WORK, INFO )
  422. *
  423. * Check error code from DSPTRI.
  424. *
  425. IF( INFO.NE.0 )
  426. $ CALL ALAERH( PATH, 'DSPTRI', INFO, 0, UPLO, N, N,
  427. $ -1, -1, -1, IMAT, NFAIL, NERRS, NOUT )
  428. *
  429. CALL DPPT03( UPLO, N, A, AINV, WORK, LDA, RWORK,
  430. $ RCONDC, RESULT( 2 ) )
  431. NT = 2
  432. END IF
  433. *
  434. * Print information about the tests that did not pass
  435. * the threshold.
  436. *
  437. DO 110 K = 1, NT
  438. IF( RESULT( K ).GE.THRESH ) THEN
  439. IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 )
  440. $ CALL ALAHD( NOUT, PATH )
  441. WRITE( NOUT, FMT = 9999 )UPLO, N, IMAT, K,
  442. $ RESULT( K )
  443. NFAIL = NFAIL + 1
  444. END IF
  445. 110 CONTINUE
  446. NRUN = NRUN + NT
  447. *
  448. * Do only the condition estimate if INFO is not 0.
  449. *
  450. IF( TRFCON ) THEN
  451. RCONDC = ZERO
  452. GO TO 140
  453. END IF
  454. *
  455. DO 130 IRHS = 1, NNS
  456. NRHS = NSVAL( IRHS )
  457. *
  458. *+ TEST 3
  459. * Solve and compute residual for A * X = B.
  460. *
  461. SRNAMT = 'DLARHS'
  462. CALL DLARHS( PATH, XTYPE, UPLO, ' ', N, N, KL, KU,
  463. $ NRHS, A, LDA, XACT, LDA, B, LDA, ISEED,
  464. $ INFO )
  465. CALL DLACPY( 'Full', N, NRHS, B, LDA, X, LDA )
  466. *
  467. SRNAMT = 'DSPTRS'
  468. CALL DSPTRS( UPLO, N, NRHS, AFAC, IWORK, X, LDA,
  469. $ INFO )
  470. *
  471. * Check error code from DSPTRS.
  472. *
  473. IF( INFO.NE.0 )
  474. $ CALL ALAERH( PATH, 'DSPTRS', INFO, 0, UPLO, N, N,
  475. $ -1, -1, NRHS, IMAT, NFAIL, NERRS,
  476. $ NOUT )
  477. *
  478. CALL DLACPY( 'Full', N, NRHS, B, LDA, WORK, LDA )
  479. CALL DPPT02( UPLO, N, NRHS, A, X, LDA, WORK, LDA,
  480. $ RWORK, RESULT( 3 ) )
  481. *
  482. *+ TEST 4
  483. * Check solution from generated exact solution.
  484. *
  485. CALL DGET04( N, NRHS, X, LDA, XACT, LDA, RCONDC,
  486. $ RESULT( 4 ) )
  487. *
  488. *+ TESTS 5, 6, and 7
  489. * Use iterative refinement to improve the solution.
  490. *
  491. SRNAMT = 'DSPRFS'
  492. CALL DSPRFS( UPLO, N, NRHS, A, AFAC, IWORK, B, LDA, X,
  493. $ LDA, RWORK, RWORK( NRHS+1 ), WORK,
  494. $ IWORK( N+1 ), INFO )
  495. *
  496. * Check error code from DSPRFS.
  497. *
  498. IF( INFO.NE.0 )
  499. $ CALL ALAERH( PATH, 'DSPRFS', INFO, 0, UPLO, N, N,
  500. $ -1, -1, NRHS, IMAT, NFAIL, NERRS,
  501. $ NOUT )
  502. *
  503. CALL DGET04( N, NRHS, X, LDA, XACT, LDA, RCONDC,
  504. $ RESULT( 5 ) )
  505. CALL DPPT05( UPLO, N, NRHS, A, B, LDA, X, LDA, XACT,
  506. $ LDA, RWORK, RWORK( NRHS+1 ),
  507. $ RESULT( 6 ) )
  508. *
  509. * Print information about the tests that did not pass
  510. * the threshold.
  511. *
  512. DO 120 K = 3, 7
  513. IF( RESULT( K ).GE.THRESH ) THEN
  514. IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 )
  515. $ CALL ALAHD( NOUT, PATH )
  516. WRITE( NOUT, FMT = 9998 )UPLO, N, NRHS, IMAT,
  517. $ K, RESULT( K )
  518. NFAIL = NFAIL + 1
  519. END IF
  520. 120 CONTINUE
  521. NRUN = NRUN + 5
  522. 130 CONTINUE
  523. *
  524. *+ TEST 8
  525. * Get an estimate of RCOND = 1/CNDNUM.
  526. *
  527. 140 CONTINUE
  528. ANORM = DLANSP( '1', UPLO, N, A, RWORK )
  529. SRNAMT = 'DSPCON'
  530. CALL DSPCON( UPLO, N, AFAC, IWORK, ANORM, RCOND, WORK,
  531. $ IWORK( N+1 ), INFO )
  532. *
  533. * Check error code from DSPCON.
  534. *
  535. IF( INFO.NE.0 )
  536. $ CALL ALAERH( PATH, 'DSPCON', INFO, 0, UPLO, N, N, -1,
  537. $ -1, -1, IMAT, NFAIL, NERRS, NOUT )
  538. *
  539. RESULT( 8 ) = DGET06( RCOND, RCONDC )
  540. *
  541. * Print the test ratio if it is .GE. THRESH.
  542. *
  543. IF( RESULT( 8 ).GE.THRESH ) THEN
  544. IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 )
  545. $ CALL ALAHD( NOUT, PATH )
  546. WRITE( NOUT, FMT = 9999 )UPLO, N, IMAT, 8,
  547. $ RESULT( 8 )
  548. NFAIL = NFAIL + 1
  549. END IF
  550. NRUN = NRUN + 1
  551. 150 CONTINUE
  552. 160 CONTINUE
  553. 170 CONTINUE
  554. *
  555. * Print a summary of the results.
  556. *
  557. CALL ALASUM( PATH, NOUT, NFAIL, NRUN, NERRS )
  558. *
  559. 9999 FORMAT( ' UPLO = ''', A1, ''', N =', I5, ', type ', I2, ', test ',
  560. $ I2, ', ratio =', G12.5 )
  561. 9998 FORMAT( ' UPLO = ''', A1, ''', N =', I5, ', NRHS=', I3, ', type ',
  562. $ I2, ', test(', I2, ') =', G12.5 )
  563. RETURN
  564. *
  565. * End of DCHKSP
  566. *
  567. END