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_rook.f 17 kB

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