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.

cdrvsy_rook.f 17 kB

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