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.

zchksy_aa.f 18 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  1. *> \brief \b ZCHKSY_AA
  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 ZCHKSY_AA( DOTYPE, NN, NVAL, NNB, NBVAL, NNS, NSVAL,
  12. * THRESH, TSTERR, NMAX, A, AFAC, AINV, B, X,
  13. * XACT, 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 RWORK( * )
  24. * COMPLEX*16 A( * ), AFAC( * ), AINV( * ), B( * ),
  25. * $ WORK( * ), X( * ), XACT( * )
  26. * ..
  27. *
  28. *
  29. *> \par Purpose:
  30. * =============
  31. *>
  32. *> \verbatim
  33. *>
  34. *> ZCHKSY_AA tests ZSYTRF_AA, -TRS_AA.
  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] NNB
  61. *> \verbatim
  62. *> NNB is INTEGER
  63. *> The number of values of NB contained in the vector NBVAL.
  64. *> \endverbatim
  65. *>
  66. *> \param[in] NBVAL
  67. *> \verbatim
  68. *> NBVAL is INTEGER array, dimension (NBVAL)
  69. *> The values of the blocksize NB.
  70. *> \endverbatim
  71. *>
  72. *> \param[in] NNS
  73. *> \verbatim
  74. *> NNS is INTEGER
  75. *> The number of values of NRHS contained in the vector NSVAL.
  76. *> \endverbatim
  77. *>
  78. *> \param[in] NSVAL
  79. *> \verbatim
  80. *> NSVAL is INTEGER array, dimension (NNS)
  81. *> The values of the number of right hand sides NRHS.
  82. *> \endverbatim
  83. *>
  84. *> \param[in] THRESH
  85. *> \verbatim
  86. *> THRESH is DOUBLE PRECISION
  87. *> The threshold value for the test ratios. A result is
  88. *> included in the output file if RESULT >= THRESH. To have
  89. *> every test ratio printed, use THRESH = 0.
  90. *> \endverbatim
  91. *>
  92. *> \param[in] TSTERR
  93. *> \verbatim
  94. *> TSTERR is LOGICAL
  95. *> Flag that indicates whether error exits are to be tested.
  96. *> \endverbatim
  97. *>
  98. *> \param[in] NMAX
  99. *> \verbatim
  100. *> NMAX is INTEGER
  101. *> The maximum value permitted for N, used in dimensioning the
  102. *> work arrays.
  103. *> \endverbatim
  104. *>
  105. *> \param[out] A
  106. *> \verbatim
  107. *> A is COMPLEX*16 array, dimension (NMAX*NMAX)
  108. *> \endverbatim
  109. *>
  110. *> \param[out] AFAC
  111. *> \verbatim
  112. *> AFAC is COMPLEX*16 array, dimension (NMAX*NMAX)
  113. *> \endverbatim
  114. *>
  115. *> \param[out] AINV
  116. *> \verbatim
  117. *> AINV is COMPLEX*16 array, dimension (NMAX*NMAX)
  118. *> \endverbatim
  119. *>
  120. *> \param[out] B
  121. *> \verbatim
  122. *> B is COMPLEX*16 array, dimension (NMAX*NSMAX)
  123. *> where NSMAX is the largest entry in NSVAL.
  124. *> \endverbatim
  125. *>
  126. *> \param[out] X
  127. *> \verbatim
  128. *> X is COMPLEX*16 array, dimension (NMAX*NSMAX)
  129. *> \endverbatim
  130. *>
  131. *> \param[out] XACT
  132. *> \verbatim
  133. *> XACT is COMPLEX*16 array, dimension (NMAX*NSMAX)
  134. *> \endverbatim
  135. *>
  136. *> \param[out] WORK
  137. *> \verbatim
  138. *> WORK is COMPLEX*16 array, dimension (NMAX*max(3,NSMAX))
  139. *> \endverbatim
  140. *>
  141. *> \param[out] RWORK
  142. *> \verbatim
  143. *> RWORK is COMPLEX*16 array, dimension (max(NMAX,2*NSMAX))
  144. *> \endverbatim
  145. *>
  146. *> \param[out] IWORK
  147. *> \verbatim
  148. *> IWORK is INTEGER array, dimension (2*NMAX)
  149. *> \endverbatim
  150. *>
  151. *> \param[in] NOUT
  152. *> \verbatim
  153. *> NOUT is INTEGER
  154. *> The unit number for output.
  155. *> \endverbatim
  156. *
  157. * Authors:
  158. * ========
  159. *
  160. *> \author Univ. of Tennessee
  161. *> \author Univ. of California Berkeley
  162. *> \author Univ. of Colorado Denver
  163. *> \author NAG Ltd.
  164. *
  165. *> \date November 2017
  166. *
  167. *> \ingroup complex16_lin
  168. *
  169. * =====================================================================
  170. SUBROUTINE ZCHKSY_AA( DOTYPE, NN, NVAL, NNB, NBVAL, NNS, NSVAL,
  171. $ THRESH, TSTERR, NMAX, A, AFAC, AINV, B,
  172. $ X, XACT, WORK, RWORK, IWORK, NOUT )
  173. *
  174. * -- LAPACK test routine (version 3.8.0) --
  175. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  176. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  177. * November 2017
  178. *
  179. IMPLICIT NONE
  180. *
  181. * .. Scalar Arguments ..
  182. LOGICAL TSTERR
  183. INTEGER NN, NNB, NNS, NMAX, NOUT
  184. DOUBLE PRECISION THRESH
  185. * ..
  186. * .. Array Arguments ..
  187. LOGICAL DOTYPE( * )
  188. INTEGER IWORK( * ), NBVAL( * ), NSVAL( * ), NVAL( * )
  189. DOUBLE PRECISION RWORK( * )
  190. COMPLEX*16 A( * ), AFAC( * ), AINV( * ), B( * ),
  191. $ WORK( * ), X( * ), XACT( * )
  192. * ..
  193. *
  194. * =====================================================================
  195. *
  196. * .. Parameters ..
  197. DOUBLE PRECISION ZERO
  198. PARAMETER ( ZERO = 0.0D+0 )
  199. COMPLEX*16 CZERO
  200. PARAMETER ( CZERO = ( 0.0D+0, 0.0D+0 ) )
  201. INTEGER NTYPES
  202. PARAMETER ( NTYPES = 10 )
  203. INTEGER NTESTS
  204. PARAMETER ( NTESTS = 9 )
  205. * ..
  206. * .. Local Scalars ..
  207. LOGICAL ZEROT
  208. CHARACTER DIST, TYPE, UPLO, XTYPE
  209. CHARACTER*3 PATH, MATPATH
  210. INTEGER I, I1, I2, IMAT, IN, INB, INFO, IOFF, IRHS,
  211. $ IUPLO, IZERO, J, K, KL, KU, LDA, LWORK, MODE,
  212. $ N, NB, NERRS, NFAIL, NIMAT, NRHS, NRUN, NT
  213. DOUBLE PRECISION ANORM, CNDNUM
  214. * ..
  215. * .. Local Arrays ..
  216. CHARACTER UPLOS( 2 )
  217. INTEGER ISEED( 4 ), ISEEDY( 4 )
  218. DOUBLE PRECISION RESULT( NTESTS )
  219. * ..
  220. * .. External Subroutines ..
  221. EXTERNAL ALAERH, ALAHD, ALASUM, ZERRSY, ZLACPY, ZLARHS,
  222. $ ZLATB4, ZLATMS, ZSYT02, ZSYT01_AA, ZSYTRF_AA,
  223. $ ZSYTRS_AA, XLAENV
  224. * ..
  225. * .. Intrinsic Functions ..
  226. INTRINSIC MAX, MIN
  227. * ..
  228. * .. Scalars in Common ..
  229. LOGICAL LERR, OK
  230. CHARACTER*32 SRNAMT
  231. INTEGER INFOT, NUNIT
  232. * ..
  233. * .. Common blocks ..
  234. COMMON / INFOC / INFOT, NUNIT, OK, LERR
  235. COMMON / SRNAMC / SRNAMT
  236. * ..
  237. * .. Data statements ..
  238. DATA ISEEDY / 1988, 1989, 1990, 1991 /
  239. DATA UPLOS / 'U', 'L' /
  240. * ..
  241. * .. Executable Statements ..
  242. *
  243. * Initialize constants and the random number seed.
  244. *
  245. * Test path
  246. *
  247. PATH( 1: 1 ) = 'Zomplex precision'
  248. PATH( 2: 3 ) = 'SA'
  249. *
  250. * Path to generate matrices
  251. *
  252. MATPATH( 1: 1 ) = 'Zomplex precision'
  253. MATPATH( 2: 3 ) = 'SY'
  254. NRUN = 0
  255. NFAIL = 0
  256. NERRS = 0
  257. DO 10 I = 1, 4
  258. ISEED( I ) = ISEEDY( I )
  259. 10 CONTINUE
  260. *
  261. * Test the error exits
  262. *
  263. IF( TSTERR )
  264. $ CALL ZERRSY( PATH, NOUT )
  265. INFOT = 0
  266. *
  267. * Set the minimum block size for which the block routine should
  268. * be used, which will be later returned by ILAENV
  269. *
  270. CALL XLAENV( 2, 2 )
  271. *
  272. * Do for each value of N in NVAL
  273. *
  274. DO 180 IN = 1, NN
  275. N = NVAL( IN )
  276. IF( N .GT. NMAX ) THEN
  277. NFAIL = NFAIL + 1
  278. WRITE(NOUT, 9995) 'M ', N, NMAX
  279. GO TO 180
  280. END IF
  281. LDA = MAX( N, 1 )
  282. XTYPE = 'N'
  283. NIMAT = NTYPES
  284. IF( N.LE.0 )
  285. $ NIMAT = 1
  286. *
  287. IZERO = 0
  288. *
  289. * Do for each value of matrix type IMAT
  290. *
  291. DO 170 IMAT = 1, NIMAT
  292. *
  293. * Do the tests only if DOTYPE( IMAT ) is true.
  294. *
  295. IF( .NOT.DOTYPE( IMAT ) )
  296. $ GO TO 170
  297. *
  298. * Skip types 3, 4, 5, or 6 if the matrix size is too small.
  299. *
  300. ZEROT = IMAT.GE.3 .AND. IMAT.LE.6
  301. IF( ZEROT .AND. N.LT.IMAT-2 )
  302. $ GO TO 170
  303. *
  304. * Do first for UPLO = 'U', then for UPLO = 'L'
  305. *
  306. DO 160 IUPLO = 1, 2
  307. UPLO = UPLOS( IUPLO )
  308. *
  309. * Begin generate the test matrix A.
  310. *
  311. *
  312. * Set up parameters with ZLATB4 for the matrix generator
  313. * based on the type of matrix to be generated.
  314. *
  315. CALL ZLATB4( MATPATH, IMAT, N, N, TYPE, KL, KU,
  316. $ ANORM, MODE, CNDNUM, DIST )
  317. *
  318. * Generate a matrix with ZLATMS.
  319. *
  320. SRNAMT = 'ZLATMS'
  321. CALL ZLATMS( N, N, DIST, ISEED, TYPE, RWORK, MODE,
  322. $ CNDNUM, ANORM, KL, KU, UPLO, A, LDA, WORK,
  323. $ INFO )
  324. *
  325. * Check error code from ZLATMS and handle error.
  326. *
  327. IF( INFO.NE.0 ) THEN
  328. CALL ALAERH( PATH, 'ZLATMS', INFO, 0, UPLO, N, N, -1,
  329. $ -1, -1, IMAT, NFAIL, NERRS, NOUT )
  330. *
  331. * Skip all tests for this generated matrix
  332. *
  333. GO TO 160
  334. END IF
  335. *
  336. * For matrix types 3-6, zero one or more rows and
  337. * columns of the matrix to test that INFO is returned
  338. * correctly.
  339. *
  340. IF( ZEROT ) THEN
  341. IF( IMAT.EQ.3 ) THEN
  342. IZERO = 1
  343. ELSE IF( IMAT.EQ.4 ) THEN
  344. IZERO = N
  345. ELSE
  346. IZERO = N / 2 + 1
  347. END IF
  348. *
  349. IF( IMAT.LT.6 ) THEN
  350. *
  351. * Set row and column IZERO to zero.
  352. *
  353. IF( IUPLO.EQ.1 ) THEN
  354. IOFF = ( IZERO-1 )*LDA
  355. DO 20 I = 1, IZERO - 1
  356. A( IOFF+I ) = CZERO
  357. 20 CONTINUE
  358. IOFF = IOFF + IZERO
  359. DO 30 I = IZERO, N
  360. A( IOFF ) = CZERO
  361. IOFF = IOFF + LDA
  362. 30 CONTINUE
  363. ELSE
  364. IOFF = IZERO
  365. DO 40 I = 1, IZERO - 1
  366. A( IOFF ) = CZERO
  367. IOFF = IOFF + LDA
  368. 40 CONTINUE
  369. IOFF = IOFF - IZERO
  370. DO 50 I = IZERO, N
  371. A( IOFF+I ) = CZERO
  372. 50 CONTINUE
  373. END IF
  374. ELSE
  375. IF( IUPLO.EQ.1 ) THEN
  376. *
  377. * Set the first IZERO rows and columns to zero.
  378. *
  379. IOFF = 0
  380. DO 70 J = 1, N
  381. I2 = MIN( J, IZERO )
  382. DO 60 I = 1, I2
  383. A( IOFF+I ) = CZERO
  384. 60 CONTINUE
  385. IOFF = IOFF + LDA
  386. 70 CONTINUE
  387. IZERO = 1
  388. ELSE
  389. *
  390. * Set the last IZERO rows and columns to zero.
  391. *
  392. IOFF = 0
  393. DO 90 J = 1, N
  394. I1 = MAX( J, IZERO )
  395. DO 80 I = I1, N
  396. A( IOFF+I ) = CZERO
  397. 80 CONTINUE
  398. IOFF = IOFF + LDA
  399. 90 CONTINUE
  400. END IF
  401. END IF
  402. ELSE
  403. IZERO = 0
  404. END IF
  405. *
  406. * End generate the test matrix A.
  407. *
  408. * Do for each value of NB in NBVAL
  409. *
  410. DO 150 INB = 1, NNB
  411. *
  412. * Set the optimal blocksize, which will be later
  413. * returned by ILAENV.
  414. *
  415. NB = NBVAL( INB )
  416. CALL XLAENV( 1, NB )
  417. *
  418. * Copy the test matrix A into matrix AFAC which
  419. * will be factorized in place. This is needed to
  420. * preserve the test matrix A for subsequent tests.
  421. *
  422. CALL ZLACPY( UPLO, N, N, A, LDA, AFAC, LDA )
  423. *
  424. * Compute the L*D*L**T or U*D*U**T factorization of the
  425. * matrix. IWORK stores details of the interchanges and
  426. * the block structure of D. AINV is a work array for
  427. * block factorization, LWORK is the length of AINV.
  428. *
  429. SRNAMT = 'ZSYTRF_AA'
  430. LWORK = MAX( 1, N*NB + N )
  431. CALL ZSYTRF_AA( UPLO, N, AFAC, LDA, IWORK, AINV,
  432. $ LWORK, INFO )
  433. *
  434. * Adjust the expected value of INFO to account for
  435. * pivoting.
  436. *
  437. c IF( IZERO.GT.0 ) THEN
  438. c J = 1
  439. c K = IZERO
  440. c 100 CONTINUE
  441. c IF( J.EQ.K ) THEN
  442. c K = IWORK( J )
  443. c ELSE IF( IWORK( J ).EQ.K ) THEN
  444. c K = J
  445. c END IF
  446. c IF( J.LT.K ) THEN
  447. c J = J + 1
  448. c GO TO 100
  449. c END IF
  450. c ELSE
  451. K = 0
  452. c END IF
  453. *
  454. * Check error code from ZSYTRF and handle error.
  455. *
  456. IF( INFO.NE.K ) THEN
  457. CALL ALAERH( PATH, 'ZSYTRF_AA', INFO, K, UPLO,
  458. $ N, N, -1, -1, NB, IMAT, NFAIL, NERRS,
  459. $ NOUT )
  460. END IF
  461. *
  462. *+ TEST 1
  463. * Reconstruct matrix from factors and compute residual.
  464. *
  465. CALL ZSYT01_AA( UPLO, N, A, LDA, AFAC, LDA, IWORK,
  466. $ AINV, LDA, RWORK, RESULT( 1 ) )
  467. NT = 1
  468. *
  469. *
  470. * Print information about the tests that did not pass
  471. * the threshold.
  472. *
  473. DO 110 K = 1, NT
  474. IF( RESULT( K ).GE.THRESH ) THEN
  475. IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 )
  476. $ CALL ALAHD( NOUT, PATH )
  477. WRITE( NOUT, FMT = 9999 )UPLO, N, NB, IMAT, K,
  478. $ RESULT( K )
  479. NFAIL = NFAIL + 1
  480. END IF
  481. 110 CONTINUE
  482. NRUN = NRUN + NT
  483. *
  484. * Skip solver test if INFO is not 0.
  485. *
  486. IF( INFO.NE.0 ) THEN
  487. GO TO 140
  488. END IF
  489. *
  490. * Do for each value of NRHS in NSVAL.
  491. *
  492. DO 130 IRHS = 1, NNS
  493. NRHS = NSVAL( IRHS )
  494. *
  495. *+ TEST 2 (Using TRS)
  496. * Solve and compute residual for A * X = B.
  497. *
  498. * Choose a set of NRHS random solution vectors
  499. * stored in XACT and set up the right hand side B
  500. *
  501. SRNAMT = 'ZLARHS'
  502. CALL ZLARHS( MATPATH, XTYPE, UPLO, ' ', N, N,
  503. $ KL, KU, NRHS, A, LDA, XACT, LDA,
  504. $ B, LDA, ISEED, INFO )
  505. CALL ZLACPY( 'Full', N, NRHS, B, LDA, X, LDA )
  506. *
  507. SRNAMT = 'ZSYTRS_AA'
  508. LWORK = MAX( 1, 3*N-2 )
  509. CALL ZSYTRS_AA( UPLO, N, NRHS, AFAC, LDA,
  510. $ IWORK, X, LDA, WORK, LWORK,
  511. $ INFO )
  512. *
  513. * Check error code from ZSYTRS and handle error.
  514. *
  515. IF( INFO.NE.0 ) THEN
  516. IF( IZERO.EQ.0 ) THEN
  517. CALL ALAERH( PATH, 'ZSYTRS_AA', INFO, 0,
  518. $ UPLO, N, N, -1, -1, NRHS, IMAT,
  519. $ NFAIL, NERRS, NOUT )
  520. END IF
  521. ELSE
  522. CALL ZLACPY( 'Full', N, NRHS, B, LDA, WORK, LDA
  523. $ )
  524. *
  525. * Compute the residual for the solution
  526. *
  527. CALL ZSYT02( UPLO, N, NRHS, A, LDA, X, LDA,
  528. $ WORK, LDA, RWORK, RESULT( 2 ) )
  529. *
  530. *
  531. * Print information about the tests that did not pass
  532. * the threshold.
  533. *
  534. DO 120 K = 2, 2
  535. IF( RESULT( K ).GE.THRESH ) THEN
  536. IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 )
  537. $ CALL ALAHD( NOUT, PATH )
  538. WRITE( NOUT, FMT = 9998 )UPLO, N, NRHS,
  539. $ IMAT, K, RESULT( K )
  540. NFAIL = NFAIL + 1
  541. END IF
  542. 120 CONTINUE
  543. END IF
  544. NRUN = NRUN + 1
  545. *
  546. * End do for each value of NRHS in NSVAL.
  547. *
  548. 130 CONTINUE
  549. 140 CONTINUE
  550. 150 CONTINUE
  551. 160 CONTINUE
  552. 170 CONTINUE
  553. 180 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, ', NB =', I4, ', type ',
  560. $ I2, ', test ', I2, ', ratio =', G12.5 )
  561. 9998 FORMAT( ' UPLO = ''', A1, ''', N =', I5, ', NRHS=', I3, ', type ',
  562. $ I2, ', test(', I2, ') =', G12.5 )
  563. 9995 FORMAT( ' Invalid input value: ', A4, '=', I6, '; must be <=',
  564. $ I6 )
  565. RETURN
  566. *
  567. * End of ZCHKSY_AA
  568. *
  569. END