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.

zdrvsy_rk.f 17 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  1. *> \brief \b ZDRVSY_RK
  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 ZDRVSY_RK( DOTYPE, NN, NVAL, NRHS, THRESH, TSTERR,
  12. * NMAX, A, AFAC, E, AINV, B, X, XACT, WORK,
  13. * RWORK, IWORK, NOUT )
  14. *
  15. * .. Scalar Arguments ..
  16. * LOGICAL TSTERR
  17. * INTEGER NMAX, NN, NOUT, NRHS
  18. * DOUBLE PRECISION THRESH
  19. * ..
  20. * .. Array Arguments ..
  21. * LOGICAL DOTYPE( * )
  22. * INTEGER IWORK( * ), NVAL( * )
  23. * DOUBLE PRECISION RWORK( * )
  24. * COMPLEX*16 A( * ), AFAC( * ), AINV( * ), B( * ), E( *),
  25. * $ WORK( * ), X( * ), XACT( * )
  26. * ..
  27. *
  28. *
  29. *> \par Purpose:
  30. * =============
  31. *>
  32. *> \verbatim
  33. *>
  34. *> ZDRVSY_RK tests the driver routines ZSYSV_RK.
  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 DOUBLE PRECISION
  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*16 array, dimension (NMAX*NMAX)
  91. *> \endverbatim
  92. *>
  93. *> \param[out] AFAC
  94. *> \verbatim
  95. *> AFAC is COMPLEX*16 array, dimension (NMAX*NMAX)
  96. *> \endverbatim
  97. *>
  98. *> \param[out] E
  99. *> \verbatim
  100. *> E is COMPLEX*16 array, dimension (NMAX)
  101. *> \endverbatim
  102. *>
  103. *> \param[out] AINV
  104. *> \verbatim
  105. *> AINV is COMPLEX*16 array, dimension (NMAX*NMAX)
  106. *> \endverbatim
  107. *>
  108. *> \param[out] B
  109. *> \verbatim
  110. *> B is COMPLEX*16 array, dimension (NMAX*NRHS)
  111. *> \endverbatim
  112. *>
  113. *> \param[out] X
  114. *> \verbatim
  115. *> X is COMPLEX*16 array, dimension (NMAX*NRHS)
  116. *> \endverbatim
  117. *>
  118. *> \param[out] XACT
  119. *> \verbatim
  120. *> XACT is COMPLEX*16 array, dimension (NMAX*NRHS)
  121. *> \endverbatim
  122. *>
  123. *> \param[out] WORK
  124. *> \verbatim
  125. *> WORK is COMPLEX*16 array, dimension (NMAX*max(2,NRHS))
  126. *> \endverbatim
  127. *>
  128. *> \param[out] RWORK
  129. *> \verbatim
  130. *> RWORK is DOUBLE PRECISION array, dimension (NMAX+2*NRHS)
  131. *> \endverbatim
  132. *>
  133. *> \param[out] IWORK
  134. *> \verbatim
  135. *> IWORK is INTEGER array, dimension (NMAX)
  136. *> \endverbatim
  137. *>
  138. *> \param[in] NOUT
  139. *> \verbatim
  140. *> NOUT is INTEGER
  141. *> The unit number for output.
  142. *> \endverbatim
  143. *
  144. * Authors:
  145. * ========
  146. *
  147. *> \author Univ. of Tennessee
  148. *> \author Univ. of California Berkeley
  149. *> \author Univ. of Colorado Denver
  150. *> \author NAG Ltd.
  151. *
  152. *> \date December 2016
  153. *
  154. *> \ingroup complex16_lin
  155. *
  156. * =====================================================================
  157. SUBROUTINE ZDRVSY_RK( DOTYPE, NN, NVAL, NRHS, THRESH, TSTERR,
  158. $ NMAX, A, AFAC, E, AINV, B, X, XACT, WORK,
  159. $ RWORK, IWORK, NOUT )
  160. *
  161. * -- LAPACK test routine (version 3.7.0) --
  162. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  163. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  164. * December 2016
  165. *
  166. * .. Scalar Arguments ..
  167. LOGICAL TSTERR
  168. INTEGER NMAX, NN, NOUT, NRHS
  169. DOUBLE PRECISION THRESH
  170. * ..
  171. * .. Array Arguments ..
  172. LOGICAL DOTYPE( * )
  173. INTEGER IWORK( * ), NVAL( * )
  174. DOUBLE PRECISION RWORK( * )
  175. COMPLEX*16 A( * ), AFAC( * ), AINV( * ), B( * ), E( * ),
  176. $ WORK( * ), X( * ), XACT( * )
  177. * ..
  178. *
  179. * =====================================================================
  180. *
  181. * .. Parameters ..
  182. DOUBLE PRECISION ONE, ZERO
  183. PARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 )
  184. INTEGER NTYPES, NTESTS
  185. PARAMETER ( NTYPES = 11, NTESTS = 3 )
  186. INTEGER NFACT
  187. PARAMETER ( NFACT = 2 )
  188. * ..
  189. * .. Local Scalars ..
  190. LOGICAL ZEROT
  191. CHARACTER DIST, FACT, TYPE, UPLO, XTYPE
  192. CHARACTER*3 MATPATH, PATH
  193. INTEGER I, I1, I2, IFACT, IMAT, IN, INFO, IOFF, IUPLO,
  194. $ IZERO, J, K, KL, KU, LDA, LWORK, MODE, N,
  195. $ NB, NBMIN, NERRS, NFAIL, NIMAT, NRUN, NT
  196. DOUBLE PRECISION AINVNM, ANORM, CNDNUM, RCONDC
  197. * ..
  198. * .. Local Arrays ..
  199. CHARACTER FACTS( NFACT ), UPLOS( 2 )
  200. INTEGER ISEED( 4 ), ISEEDY( 4 )
  201. DOUBLE PRECISION RESULT( NTESTS )
  202. * ..
  203. * .. External Functions ..
  204. DOUBLE PRECISION ZLANSY
  205. EXTERNAL ZLANSY
  206. * ..
  207. * .. External Subroutines ..
  208. EXTERNAL ALADHD, ALAERH, ALASVM, XLAENV, ZERRVX, ZGET04,
  209. $ ZLACPY, ZLARHS, ZLATB4, ZLATMS, ZLATSY,
  210. $ ZSYSV_RK, ZSYT01_3, ZSYT02, ZSYTRF_RK, ZSYTRI_3
  211. * ..
  212. * .. Scalars in Common ..
  213. LOGICAL LERR, OK
  214. CHARACTER*32 SRNAMT
  215. INTEGER INFOT, NUNIT
  216. * ..
  217. * .. Common blocks ..
  218. COMMON / INFOC / INFOT, NUNIT, OK, LERR
  219. COMMON / SRNAMC / SRNAMT
  220. * ..
  221. * .. Intrinsic Functions ..
  222. INTRINSIC MAX, MIN
  223. * ..
  224. * .. Data statements ..
  225. DATA ISEEDY / 1988, 1989, 1990, 1991 /
  226. DATA UPLOS / 'U', 'L' / , FACTS / 'F', 'N' /
  227. * ..
  228. * .. Executable Statements ..
  229. *
  230. * Initialize constants and the random number seed.
  231. *
  232. * Test path
  233. *
  234. PATH( 1: 1 ) = 'Zomplex precision'
  235. PATH( 2: 3 ) = 'SK'
  236. *
  237. * Path to generate matrices
  238. *
  239. MATPATH( 1: 1 ) = 'Zomplex precision'
  240. MATPATH( 2: 3 ) = 'SY'
  241. *
  242. NRUN = 0
  243. NFAIL = 0
  244. NERRS = 0
  245. DO 10 I = 1, 4
  246. ISEED( I ) = ISEEDY( I )
  247. 10 CONTINUE
  248. LWORK = MAX( 2*NMAX, NMAX*NRHS )
  249. *
  250. * Test the error exits
  251. *
  252. IF( TSTERR )
  253. $ CALL ZERRVX( PATH, NOUT )
  254. INFOT = 0
  255. *
  256. * Set the block size and minimum block size for which the block
  257. * routine should be used, which will be later returned by ILAENV.
  258. *
  259. NB = 1
  260. NBMIN = 2
  261. CALL XLAENV( 1, NB )
  262. CALL XLAENV( 2, NBMIN )
  263. *
  264. * Do for each value of N in NVAL
  265. *
  266. DO 180 IN = 1, NN
  267. N = NVAL( IN )
  268. LDA = MAX( N, 1 )
  269. XTYPE = 'N'
  270. NIMAT = NTYPES
  271. IF( N.LE.0 )
  272. $ NIMAT = 1
  273. *
  274. DO 170 IMAT = 1, NIMAT
  275. *
  276. * Do the tests only if DOTYPE( IMAT ) is true.
  277. *
  278. IF( .NOT.DOTYPE( IMAT ) )
  279. $ GO TO 170
  280. *
  281. * Skip types 3, 4, 5, or 6 if the matrix size is too small.
  282. *
  283. ZEROT = IMAT.GE.3 .AND. IMAT.LE.6
  284. IF( ZEROT .AND. N.LT.IMAT-2 )
  285. $ GO TO 170
  286. *
  287. * Do first for UPLO = 'U', then for UPLO = 'L'
  288. *
  289. DO 160 IUPLO = 1, 2
  290. UPLO = UPLOS( IUPLO )
  291. *
  292. IF( IMAT.NE.NTYPES ) THEN
  293. *
  294. * Begin generate the test matrix A.
  295. *
  296. * Set up parameters with ZLATB4 for the matrix generator
  297. * based on the type of matrix to be generated.
  298. *
  299. CALL ZLATB4( MATPATH, IMAT, N, N, TYPE, KL, KU, ANORM,
  300. $ MODE, CNDNUM, DIST )
  301. *
  302. * Generate a matrix with ZLATMS.
  303. *
  304. SRNAMT = 'ZLATMS'
  305. CALL ZLATMS( N, N, DIST, ISEED, TYPE, RWORK, MODE,
  306. $ CNDNUM, ANORM, KL, KU, UPLO, A, LDA,
  307. $ WORK, INFO )
  308. *
  309. * Check error code from DLATMS and handle error.
  310. *
  311. IF( INFO.NE.0 ) THEN
  312. CALL ALAERH( PATH, 'ZLATMS', INFO, 0, UPLO, N, N,
  313. $ -1, -1, -1, IMAT, NFAIL, NERRS, NOUT )
  314. GO TO 160
  315. END IF
  316. *
  317. * For types 3-6, zero one or more rows and columns of
  318. * the matrix to test that INFO is returned correctly.
  319. *
  320. IF( ZEROT ) THEN
  321. IF( IMAT.EQ.3 ) THEN
  322. IZERO = 1
  323. ELSE IF( IMAT.EQ.4 ) THEN
  324. IZERO = N
  325. ELSE
  326. IZERO = N / 2 + 1
  327. END IF
  328. *
  329. IF( IMAT.LT.6 ) THEN
  330. *
  331. * Set row and column IZERO to zero.
  332. *
  333. IF( IUPLO.EQ.1 ) THEN
  334. IOFF = ( IZERO-1 )*LDA
  335. DO 20 I = 1, IZERO - 1
  336. A( IOFF+I ) = ZERO
  337. 20 CONTINUE
  338. IOFF = IOFF + IZERO
  339. DO 30 I = IZERO, N
  340. A( IOFF ) = ZERO
  341. IOFF = IOFF + LDA
  342. 30 CONTINUE
  343. ELSE
  344. IOFF = IZERO
  345. DO 40 I = 1, IZERO - 1
  346. A( IOFF ) = ZERO
  347. IOFF = IOFF + LDA
  348. 40 CONTINUE
  349. IOFF = IOFF - IZERO
  350. DO 50 I = IZERO, N
  351. A( IOFF+I ) = ZERO
  352. 50 CONTINUE
  353. END IF
  354. ELSE
  355. IF( IUPLO.EQ.1 ) THEN
  356. *
  357. * Set the first IZERO rows and columns to zero.
  358. *
  359. IOFF = 0
  360. DO 70 J = 1, N
  361. I2 = MIN( J, IZERO )
  362. DO 60 I = 1, I2
  363. A( IOFF+I ) = ZERO
  364. 60 CONTINUE
  365. IOFF = IOFF + LDA
  366. 70 CONTINUE
  367. ELSE
  368. *
  369. * Set the first IZERO rows and columns to zero.
  370. *
  371. IOFF = 0
  372. DO 90 J = 1, N
  373. I1 = MAX( J, IZERO )
  374. DO 80 I = I1, N
  375. A( IOFF+I ) = ZERO
  376. 80 CONTINUE
  377. IOFF = IOFF + LDA
  378. 90 CONTINUE
  379. END IF
  380. END IF
  381. ELSE
  382. IZERO = 0
  383. END IF
  384. ELSE
  385. *
  386. * IMAT = NTYPES: Use a special block diagonal matrix to
  387. * test alternate code for the 2-by-2 blocks.
  388. *
  389. CALL ZLATSY( UPLO, N, A, LDA, ISEED )
  390. END IF
  391. *
  392. DO 150 IFACT = 1, NFACT
  393. *
  394. * Do first for FACT = 'F', then for other values.
  395. *
  396. FACT = FACTS( IFACT )
  397. *
  398. * Compute the condition number for comparison with
  399. * the value returned by ZSYSVX_ROOK.
  400. *
  401. IF( ZEROT ) THEN
  402. IF( IFACT.EQ.1 )
  403. $ GO TO 150
  404. RCONDC = ZERO
  405. *
  406. ELSE IF( IFACT.EQ.1 ) THEN
  407. *
  408. * Compute the 1-norm of A.
  409. *
  410. ANORM = ZLANSY( '1', UPLO, N, A, LDA, RWORK )
  411. *
  412. * Factor the matrix A.
  413. *
  414. CALL ZLACPY( UPLO, N, N, A, LDA, AFAC, LDA )
  415. CALL ZSYTRF_RK( UPLO, N, AFAC, LDA, E, IWORK, AINV,
  416. $ LWORK, INFO )
  417. *
  418. * Compute inv(A) and take its norm.
  419. *
  420. CALL ZLACPY( UPLO, N, N, AFAC, LDA, AINV, LDA )
  421. LWORK = (N+NB+1)*(NB+3)
  422. *
  423. * We need to copute the invesrse to compute
  424. * RCONDC that is used later in TEST3.
  425. *
  426. CALL ZSYTRI_3( UPLO, N, AINV, LDA, E, IWORK,
  427. $ WORK, LWORK, INFO )
  428. AINVNM = ZLANSY( '1', UPLO, N, AINV, LDA, RWORK )
  429. *
  430. * Compute the 1-norm condition number of A.
  431. *
  432. IF( ANORM.LE.ZERO .OR. AINVNM.LE.ZERO ) THEN
  433. RCONDC = ONE
  434. ELSE
  435. RCONDC = ( ONE / ANORM ) / AINVNM
  436. END IF
  437. END IF
  438. *
  439. * Form an exact solution and set the right hand side.
  440. *
  441. SRNAMT = 'ZLARHS'
  442. CALL ZLARHS( MATPATH, XTYPE, UPLO, ' ', N, N, KL, KU,
  443. $ NRHS, A, LDA, XACT, LDA, B, LDA, ISEED,
  444. $ INFO )
  445. XTYPE = 'C'
  446. *
  447. * --- Test ZSYSV_RK ---
  448. *
  449. IF( IFACT.EQ.2 ) THEN
  450. CALL ZLACPY( UPLO, N, N, A, LDA, AFAC, LDA )
  451. CALL ZLACPY( 'Full', N, NRHS, B, LDA, X, LDA )
  452. *
  453. * Factor the matrix and solve the system using
  454. * ZSYSV_RK.
  455. *
  456. SRNAMT = 'ZSYSV_RK'
  457. CALL ZSYSV_RK( UPLO, N, NRHS, AFAC, LDA, E, IWORK,
  458. $ X, LDA, WORK, LWORK, INFO )
  459. *
  460. * Adjust the expected value of INFO to account for
  461. * pivoting.
  462. *
  463. K = IZERO
  464. IF( K.GT.0 ) THEN
  465. 100 CONTINUE
  466. IF( IWORK( K ).LT.0 ) THEN
  467. IF( IWORK( K ).NE.-K ) THEN
  468. K = -IWORK( K )
  469. GO TO 100
  470. END IF
  471. ELSE IF( IWORK( K ).NE.K ) THEN
  472. K = IWORK( K )
  473. GO TO 100
  474. END IF
  475. END IF
  476. *
  477. * Check error code from ZSYSV_RK and handle error.
  478. *
  479. IF( INFO.NE.K ) THEN
  480. CALL ALAERH( PATH, 'ZSYSV_RK', INFO, K, UPLO,
  481. $ N, N, -1, -1, NRHS, IMAT, NFAIL,
  482. $ NERRS, NOUT )
  483. GO TO 120
  484. ELSE IF( INFO.NE.0 ) THEN
  485. GO TO 120
  486. END IF
  487. *
  488. *+ TEST 1 Reconstruct matrix from factors and compute
  489. * residual.
  490. *
  491. CALL ZSYT01_3( UPLO, N, A, LDA, AFAC, LDA, E,
  492. $ IWORK, AINV, LDA, RWORK,
  493. $ RESULT( 1 ) )
  494. *
  495. *+ TEST 2 Compute residual of the computed solution.
  496. *
  497. CALL ZLACPY( 'Full', N, NRHS, B, LDA, WORK, LDA )
  498. CALL ZSYT02( UPLO, N, NRHS, A, LDA, X, LDA, WORK,
  499. $ LDA, RWORK, RESULT( 2 ) )
  500. *
  501. *+ TEST 3
  502. * Check solution from generated exact solution.
  503. *
  504. CALL ZGET04( N, NRHS, X, LDA, XACT, LDA, RCONDC,
  505. $ RESULT( 3 ) )
  506. NT = 3
  507. *
  508. * Print information about the tests that did not pass
  509. * the threshold.
  510. *
  511. DO 110 K = 1, NT
  512. IF( RESULT( K ).GE.THRESH ) THEN
  513. IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 )
  514. $ CALL ALADHD( NOUT, PATH )
  515. WRITE( NOUT, FMT = 9999 )'ZSYSV_RK', UPLO,
  516. $ N, IMAT, K, RESULT( K )
  517. NFAIL = NFAIL + 1
  518. END IF
  519. 110 CONTINUE
  520. NRUN = NRUN + NT
  521. 120 CONTINUE
  522. END IF
  523. *
  524. 150 CONTINUE
  525. *
  526. 160 CONTINUE
  527. 170 CONTINUE
  528. 180 CONTINUE
  529. *
  530. * Print a summary of the results.
  531. *
  532. CALL ALASVM( PATH, NOUT, NFAIL, NRUN, NERRS )
  533. *
  534. 9999 FORMAT( 1X, A, ', UPLO=''', A1, ''', N =', I5, ', type ', I2,
  535. $ ', test ', I2, ', ratio =', G12.5 )
  536. RETURN
  537. *
  538. * End of ZDRVSY_RK
  539. *
  540. END