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.

zdrvhe_rk.f 17 kB

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