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.

dchkqp3rk.f 29 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797
  1. *> \brief \b DCHKQP3RK
  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 DCHKQP3RK( DOTYPE, NM, MVAL, NN, NVAL, NNS, NSVAL,
  12. * $ NNB, NBVAL, NXVAL, THRESH, A, COPYA,
  13. * $ B, COPYB, S, TAU,
  14. * $ WORK, IWORK, NOUT )
  15. * IMPLICIT NONE
  16. *
  17. * -- LAPACK test routine --
  18. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  19. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  20. *
  21. * .. Scalar Arguments ..
  22. * INTEGER NM, NN, NNS, NNB, NOUT
  23. * DOUBLE PRECISION THRESH
  24. * ..
  25. * .. Array Arguments ..
  26. * LOGICAL DOTYPE( * )
  27. * INTEGER IWORK( * ), MVAL( * ), NBVAL( * ), NSVAL( * ),
  28. * $ NVAL( * ), NXVAL( * )
  29. * DOUBLE PRECISION A( * ), COPYA( * ), B( * ), COPYB( * ),
  30. * $ S( * ), TAU( * ), WORK( * )
  31. * ..
  32. *
  33. *
  34. *> \par Purpose:
  35. * =============
  36. *>
  37. *> \verbatim
  38. *>
  39. *> DCHKQP3RK tests DGEQP3RK.
  40. *> \endverbatim
  41. *
  42. * Arguments:
  43. * ==========
  44. *
  45. *> \param[in] DOTYPE
  46. *> \verbatim
  47. *> DOTYPE is LOGICAL array, dimension (NTYPES)
  48. *> The matrix types to be used for testing. Matrices of type j
  49. *> (for 1 <= j <= NTYPES) are used for testing if DOTYPE(j) =
  50. *> .TRUE.; if DOTYPE(j) = .FALSE., then type j is not used.
  51. *> \endverbatim
  52. *>
  53. *> \param[in] NM
  54. *> \verbatim
  55. *> NM is INTEGER
  56. *> The number of values of M contained in the vector MVAL.
  57. *> \endverbatim
  58. *>
  59. *> \param[in] MVAL
  60. *> \verbatim
  61. *> MVAL is INTEGER array, dimension (NM)
  62. *> The values of the matrix row dimension M.
  63. *> \endverbatim
  64. *>
  65. *> \param[in] NN
  66. *> \verbatim
  67. *> NN is INTEGER
  68. *> The number of values of N contained in the vector NVAL.
  69. *> \endverbatim
  70. *>
  71. *> \param[in] NVAL
  72. *> \verbatim
  73. *> NVAL is INTEGER array, dimension (NN)
  74. *> The values of the matrix column dimension N.
  75. *> \endverbatim
  76. *>
  77. *> \param[in] NNS
  78. *> \verbatim
  79. *> NNS is INTEGER
  80. *> The number of values of NRHS contained in the vector NSVAL.
  81. *> \endverbatim
  82. *>
  83. *> \param[in] NSVAL
  84. *> \verbatim
  85. *> NSVAL is INTEGER array, dimension (NNS)
  86. *> The values of the number of right hand sides NRHS.
  87. *> \endverbatim
  88. *>
  89. *> \param[in] NNB
  90. *> \verbatim
  91. *> NNB is INTEGER
  92. *> The number of values of NB and NX contained in the
  93. *> vectors NBVAL and NXVAL. The blocking parameters are used
  94. *> in pairs (NB,NX).
  95. *> \endverbatim
  96. *>
  97. *> \param[in] NBVAL
  98. *> \verbatim
  99. *> NBVAL is INTEGER array, dimension (NNB)
  100. *> The values of the blocksize NB.
  101. *> \endverbatim
  102. *>
  103. *> \param[in] NXVAL
  104. *> \verbatim
  105. *> NXVAL is INTEGER array, dimension (NNB)
  106. *> The values of the crossover point NX.
  107. *> \endverbatim
  108. *>
  109. *> \param[in] THRESH
  110. *> \verbatim
  111. *> THRESH is DOUBLE PRECISION
  112. *> The threshold value for the test ratios. A result is
  113. *> included in the output file if RESULT >= THRESH. To have
  114. *> every test ratio printed, use THRESH = 0.
  115. *> \endverbatim
  116. *>
  117. *> \param[out] A
  118. *> \verbatim
  119. *> A is DOUBLE PRECISION array, dimension (MMAX*NMAX)
  120. *> where MMAX is the maximum value of M in MVAL and NMAX is the
  121. *> maximum value of N in NVAL.
  122. *> \endverbatim
  123. *>
  124. *> \param[out] COPYA
  125. *> \verbatim
  126. *> COPYA is DOUBLE PRECISION array, dimension (MMAX*NMAX)
  127. *> \endverbatim
  128. *>
  129. *> \param[out] B
  130. *> \verbatim
  131. *> B is DOUBLE PRECISION array, dimension (MMAX*NSMAX)
  132. *> where MMAX is the maximum value of M in MVAL and NSMAX is the
  133. *> maximum value of NRHS in NSVAL.
  134. *> \endverbatim
  135. *>
  136. *> \param[out] COPYB
  137. *> \verbatim
  138. *> COPYB is DOUBLE PRECISION array, dimension (MMAX*NSMAX)
  139. *> \endverbatim
  140. *>
  141. *> \param[out] S
  142. *> \verbatim
  143. *> S is DOUBLE PRECISION array, dimension
  144. *> (min(MMAX,NMAX))
  145. *> \endverbatim
  146. *>
  147. *> \param[out] TAU
  148. *> \verbatim
  149. *> TAU is DOUBLE PRECISION array, dimension (MMAX)
  150. *> \endverbatim
  151. *>
  152. *> \param[out] WORK
  153. *> \verbatim
  154. *> WORK is DOUBLE PRECISION array, dimension
  155. *> (MMAX*NMAX + 4*NMAX + MMAX)
  156. *> \endverbatim
  157. *>
  158. *> \param[out] IWORK
  159. *> \verbatim
  160. *> IWORK is INTEGER array, dimension (2*NMAX)
  161. *> \endverbatim
  162. *>
  163. *> \param[in] NOUT
  164. *> \verbatim
  165. *> NOUT is INTEGER
  166. *> The unit number for output.
  167. *> \endverbatim
  168. *
  169. * Authors:
  170. * ========
  171. *
  172. *> \author Univ. of Tennessee
  173. *> \author Univ. of California Berkeley
  174. *> \author Univ. of Colorado Denver
  175. *> \author NAG Ltd.
  176. *
  177. *> \ingroup double_lin
  178. *
  179. * =====================================================================
  180. SUBROUTINE DCHKQP3RK( DOTYPE, NM, MVAL, NN, NVAL, NNS, NSVAL,
  181. $ NNB, NBVAL, NXVAL, THRESH, A, COPYA,
  182. $ B, COPYB, S, TAU,
  183. $ WORK, IWORK, NOUT )
  184. IMPLICIT NONE
  185. *
  186. * -- LAPACK test routine --
  187. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  188. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  189. *
  190. * .. Scalar Arguments ..
  191. INTEGER NM, NN, NNB, NNS, NOUT
  192. DOUBLE PRECISION THRESH
  193. * ..
  194. * .. Array Arguments ..
  195. LOGICAL DOTYPE( * )
  196. INTEGER IWORK( * ), NBVAL( * ), MVAL( * ), NVAL( * ),
  197. $ NSVAL( * ), NXVAL( * )
  198. DOUBLE PRECISION A( * ), COPYA( * ), B( * ), COPYB( * ),
  199. $ S( * ), TAU( * ), WORK( * )
  200. * ..
  201. *
  202. * =====================================================================
  203. *
  204. * .. Parameters ..
  205. INTEGER NTYPES
  206. PARAMETER ( NTYPES = 19 )
  207. INTEGER NTESTS
  208. PARAMETER ( NTESTS = 5 )
  209. DOUBLE PRECISION ONE, ZERO, BIGNUM
  210. PARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0,
  211. $ BIGNUM = 1.0D+38 )
  212. * ..
  213. * .. Local Scalars ..
  214. CHARACTER DIST, TYPE
  215. CHARACTER*3 PATH
  216. INTEGER I, IHIGH, ILOW, IM, IMAT, IN, INC_ZERO,
  217. $ INB, IND_OFFSET_GEN,
  218. $ IND_IN, IND_OUT, INS, INFO,
  219. $ ISTEP, J, J_INC, J_FIRST_NZ, JB_ZERO,
  220. $ KFACT, KL, KMAX, KU, LDA, LW, LWORK,
  221. $ LWORK_MQR, M, MINMN, MINMNB_GEN, MODE, N,
  222. $ NB, NB_ZERO, NERRS, NFAIL, NB_GEN, NRHS,
  223. $ NRUN, NX, T
  224. DOUBLE PRECISION ANORM, CNDNUM, EPS, ABSTOL, RELTOL,
  225. $ DTEMP, MAXC2NRMK, RELMAXC2NRMK
  226. * ..
  227. * .. Local Arrays ..
  228. INTEGER ISEED( 4 ), ISEEDY( 4 )
  229. DOUBLE PRECISION RESULT( NTESTS ), RDUMMY( 1 )
  230. * ..
  231. * .. External Functions ..
  232. DOUBLE PRECISION DLAMCH, DQPT01, DQRT11, DQRT12, DLANGE,
  233. $ DLAPY2
  234. EXTERNAL DLAMCH, DQPT01, DQRT11, DQRT12, DLANGE
  235. * ..
  236. * .. External Subroutines ..
  237. EXTERNAL ALAERH, ALAHD, ALASUM, DAXPY, DGEQP3RK,
  238. $ DLACPY, DLAORD, DLASET, DLATB4, DLATMS,
  239. $ DORMQR, DSWAP, ICOPY, XLAENV
  240. * ..
  241. * .. Intrinsic Functions ..
  242. INTRINSIC ABS, DBLE, MAX, MIN, MOD
  243. * ..
  244. * .. Scalars in Common ..
  245. LOGICAL LERR, OK
  246. CHARACTER*32 SRNAMT
  247. INTEGER INFOT, IOUNIT
  248. * ..
  249. * .. Common blocks ..
  250. COMMON / INFOC / INFOT, IOUNIT, OK, LERR
  251. COMMON / SRNAMC / SRNAMT
  252. * ..
  253. * .. Data statements ..
  254. DATA ISEEDY / 1988, 1989, 1990, 1991 /
  255. * ..
  256. * .. Executable Statements ..
  257. *
  258. * Initialize constants and the random number seed.
  259. *
  260. PATH( 1: 1 ) = 'Double precision'
  261. PATH( 2: 3 ) = 'QK'
  262. NRUN = 0
  263. NFAIL = 0
  264. NERRS = 0
  265. DO I = 1, 4
  266. ISEED( I ) = ISEEDY( I )
  267. END DO
  268. EPS = DLAMCH( 'Epsilon' )
  269. INFOT = 0
  270. *
  271. DO IM = 1, NM
  272. *
  273. * Do for each value of M in MVAL.
  274. *
  275. M = MVAL( IM )
  276. LDA = MAX( 1, M )
  277. *
  278. DO IN = 1, NN
  279. *
  280. * Do for each value of N in NVAL.
  281. *
  282. N = NVAL( IN )
  283. MINMN = MIN( M, N )
  284. LWORK = MAX( 1, M*MAX( M, N )+4*MINMN+MAX( M, N ),
  285. $ M*N + 2*MINMN + 4*N )
  286. *
  287. DO INS = 1, NNS
  288. NRHS = NSVAL( INS )
  289. *
  290. * Set up parameters with DLATB4 and generate
  291. * M-by-NRHS B matrix with DLATMS.
  292. * IMAT = 14:
  293. * Random matrix, CNDNUM = 2, NORM = ONE,
  294. * MODE = 3 (geometric distribution of singular values).
  295. *
  296. CALL DLATB4( PATH, 14, M, NRHS, TYPE, KL, KU, ANORM,
  297. $ MODE, CNDNUM, DIST )
  298. *
  299. SRNAMT = 'DLATMS'
  300. CALL DLATMS( M, NRHS, DIST, ISEED, TYPE, S, MODE,
  301. $ CNDNUM, ANORM, KL, KU, 'No packing',
  302. $ COPYB, LDA, WORK, INFO )
  303. *
  304. * Check error code from DLATMS.
  305. *
  306. IF( INFO.NE.0 ) THEN
  307. CALL ALAERH( PATH, 'DLATMS', INFO, 0, ' ', M,
  308. $ NRHS, -1, -1, -1, 6, NFAIL, NERRS,
  309. $ NOUT )
  310. CYCLE
  311. END IF
  312. *
  313. DO IMAT = 1, NTYPES
  314. *
  315. * Do the tests only if DOTYPE( IMAT ) is true.
  316. *
  317. IF( .NOT.DOTYPE( IMAT ) )
  318. $ CYCLE
  319. *
  320. * The type of distribution used to generate the random
  321. * eigen-/singular values:
  322. * ( 'S' for symmetric distribution ) => UNIFORM( -1, 1 )
  323. *
  324. * Do for each type of NON-SYMMETRIC matrix: CNDNUM NORM MODE
  325. * 1. Zero matrix
  326. * 2. Random, Diagonal, CNDNUM = 2 CNDNUM = 2 ONE 3 ( geometric distribution of singular values )
  327. * 3. Random, Upper triangular, CNDNUM = 2 CNDNUM = 2 ONE 3 ( geometric distribution of singular values )
  328. * 4. Random, Lower triangular, CNDNUM = 2 CNDNUM = 2 ONE 3 ( geometric distribution of singular values )
  329. * 5. Random, First column is zero, CNDNUM = 2 CNDNUM = 2 ONE 3 ( geometric distribution of singular values )
  330. * 6. Random, Last MINMN column is zero, CNDNUM = 2 CNDNUM = 2 ONE 3 ( geometric distribution of singular values )
  331. * 7. Random, Last N column is zero, CNDNUM = 2 CNDNUM = 2 ONE 3 ( geometric distribution of singular values )
  332. * 8. Random, Middle column in MINMN is zero, CNDNUM = 2 CNDNUM = 2 ONE 3 ( geometric distribution of singular values )
  333. * 9. Random, First half of MINMN columns are zero, CNDNUM = 2 CNDNUM = 2 ONE 3 ( geometric distribution of singular values )
  334. * 10. Random, Last columns are zero starting from MINMN/2+1, CNDNUM = 2 CNDNUM = 2 ONE 3 ( geometric distribution of singular values )
  335. * 11. Random, Half MINMN columns in the middle are zero starting
  336. * from MINMN/2-(MINMN/2)/2+1, CNDNUM = 2 CNDNUM = 2 ONE 3 ( geometric distribution of singular values )
  337. * 12. Random, Odd columns are ZERO, CNDNUM = 2 CNDNUM = 2 ONE 3 ( geometric distribution of singular values )
  338. * 13. Random, Even columns are ZERO, CNDNUM = 2 CNDNUM = 2 ONE 3 ( geometric distribution of singular values )
  339. * 14. Random, CNDNUM = 2 CNDNUM = 2 ONE 3 ( geometric distribution of singular values )
  340. * 15. Random, CNDNUM = sqrt(0.1/EPS) CNDNUM = BADC1 = sqrt(0.1/EPS) ONE 3 ( geometric distribution of singular values )
  341. * 16. Random, CNDNUM = 0.1/EPS CNDNUM = BADC2 = 0.1/EPS ONE 3 ( geometric distribution of singular values )
  342. * 17. Random, CNDNUM = 0.1/EPS, CNDNUM = BADC2 = 0.1/EPS ONE 2 ( one small singular value, S(N)=1/CNDNUM )
  343. * one small singular value S(N)=1/CNDNUM
  344. * 18. Random, CNDNUM = 2, scaled near underflow CNDNUM = 2 SMALL = SAFMIN
  345. * 19. Random, CNDNUM = 2, scaled near overflow CNDNUM = 2 LARGE = 1.0/( 0.25 * ( SAFMIN / EPS ) ) 3 ( geometric distribution of singular values )
  346. *
  347. IF( IMAT.EQ.1 ) THEN
  348. *
  349. * Matrix 1: Zero matrix
  350. *
  351. CALL DLASET( 'Full', M, N, ZERO, ZERO, COPYA, LDA )
  352. DO I = 1, MINMN
  353. S( I ) = ZERO
  354. END DO
  355. *
  356. ELSE IF( (IMAT.GE.2 .AND. IMAT.LE.4 )
  357. $ .OR. (IMAT.GE.14 .AND. IMAT.LE.19 ) ) THEN
  358. *
  359. * Matrices 2-5.
  360. *
  361. * Set up parameters with DLATB4 and generate a test
  362. * matrix with DLATMS.
  363. *
  364. CALL DLATB4( PATH, IMAT, M, N, TYPE, KL, KU, ANORM,
  365. $ MODE, CNDNUM, DIST )
  366. *
  367. SRNAMT = 'DLATMS'
  368. CALL DLATMS( M, N, DIST, ISEED, TYPE, S, MODE,
  369. $ CNDNUM, ANORM, KL, KU, 'No packing',
  370. $ COPYA, LDA, WORK, INFO )
  371. *
  372. * Check error code from DLATMS.
  373. *
  374. IF( INFO.NE.0 ) THEN
  375. CALL ALAERH( PATH, 'DLATMS', INFO, 0, ' ', M, N,
  376. $ -1, -1, -1, IMAT, NFAIL, NERRS,
  377. $ NOUT )
  378. CYCLE
  379. END IF
  380. *
  381. CALL DLAORD( 'Decreasing', MINMN, S, 1 )
  382. *
  383. ELSE IF( MINMN.GE.2
  384. $ .AND. IMAT.GE.5 .AND. IMAT.LE.13 ) THEN
  385. *
  386. * Rectangular matrices 5-13 that contain zero columns,
  387. * only for matrices MINMN >=2.
  388. *
  389. * JB_ZERO is the column index of ZERO block.
  390. * NB_ZERO is the column block size of ZERO block.
  391. * NB_GEN is the column blcok size of the
  392. * generated block.
  393. * J_INC in the non_zero column index increment
  394. * for matrix 12 and 13.
  395. * J_FIRS_NZ is the index of the first non-zero
  396. * column.
  397. *
  398. IF( IMAT.EQ.5 ) THEN
  399. *
  400. * First column is zero.
  401. *
  402. JB_ZERO = 1
  403. NB_ZERO = 1
  404. NB_GEN = N - NB_ZERO
  405. *
  406. ELSE IF( IMAT.EQ.6 ) THEN
  407. *
  408. * Last column MINMN is zero.
  409. *
  410. JB_ZERO = MINMN
  411. NB_ZERO = 1
  412. NB_GEN = N - NB_ZERO
  413. *
  414. ELSE IF( IMAT.EQ.7 ) THEN
  415. *
  416. * Last column N is zero.
  417. *
  418. JB_ZERO = N
  419. NB_ZERO = 1
  420. NB_GEN = N - NB_ZERO
  421. *
  422. ELSE IF( IMAT.EQ.8 ) THEN
  423. *
  424. * Middle column in MINMN is zero.
  425. *
  426. JB_ZERO = MINMN / 2 + 1
  427. NB_ZERO = 1
  428. NB_GEN = N - NB_ZERO
  429. *
  430. ELSE IF( IMAT.EQ.9 ) THEN
  431. *
  432. * First half of MINMN columns is zero.
  433. *
  434. JB_ZERO = 1
  435. NB_ZERO = MINMN / 2
  436. NB_GEN = N - NB_ZERO
  437. *
  438. ELSE IF( IMAT.EQ.10 ) THEN
  439. *
  440. * Last columns are zero columns,
  441. * starting from (MINMN / 2 + 1) column.
  442. *
  443. JB_ZERO = MINMN / 2 + 1
  444. NB_ZERO = N - JB_ZERO + 1
  445. NB_GEN = N - NB_ZERO
  446. *
  447. ELSE IF( IMAT.EQ.11 ) THEN
  448. *
  449. * Half of the columns in the middle of MINMN
  450. * columns is zero, starting from
  451. * MINMN/2 - (MINMN/2)/2 + 1 column.
  452. *
  453. JB_ZERO = MINMN / 2 - (MINMN / 2) / 2 + 1
  454. NB_ZERO = MINMN / 2
  455. NB_GEN = N - NB_ZERO
  456. *
  457. ELSE IF( IMAT.EQ.12 ) THEN
  458. *
  459. * Odd-numbered columns are zero,
  460. *
  461. NB_GEN = N / 2
  462. NB_ZERO = N - NB_GEN
  463. J_INC = 2
  464. J_FIRST_NZ = 2
  465. *
  466. ELSE IF( IMAT.EQ.13 ) THEN
  467. *
  468. * Even-numbered columns are zero.
  469. *
  470. NB_ZERO = N / 2
  471. NB_GEN = N - NB_ZERO
  472. J_INC = 2
  473. J_FIRST_NZ = 1
  474. *
  475. END IF
  476. *
  477. *
  478. * 1) Set the first NB_ZERO columns in COPYA(1:M,1:N)
  479. * to zero.
  480. *
  481. CALL DLASET( 'Full', M, NB_ZERO, ZERO, ZERO,
  482. $ COPYA, LDA )
  483. *
  484. * 2) Generate an M-by-(N-NB_ZERO) matrix with the
  485. * chosen singular value distribution
  486. * in COPYA(1:M,NB_ZERO+1:N).
  487. *
  488. CALL DLATB4( PATH, IMAT, M, NB_GEN, TYPE, KL, KU,
  489. $ ANORM, MODE, CNDNUM, DIST )
  490. *
  491. SRNAMT = 'DLATMS'
  492. *
  493. IND_OFFSET_GEN = NB_ZERO * LDA
  494. *
  495. CALL DLATMS( M, NB_GEN, DIST, ISEED, TYPE, S, MODE,
  496. $ CNDNUM, ANORM, KL, KU, 'No packing',
  497. $ COPYA( IND_OFFSET_GEN + 1 ), LDA,
  498. $ WORK, INFO )
  499. *
  500. * Check error code from DLATMS.
  501. *
  502. IF( INFO.NE.0 ) THEN
  503. CALL ALAERH( PATH, 'DLATMS', INFO, 0, ' ', M,
  504. $ NB_GEN, -1, -1, -1, IMAT, NFAIL,
  505. $ NERRS, NOUT )
  506. CYCLE
  507. END IF
  508. *
  509. * 3) Swap the gererated colums from the right side
  510. * NB_GEN-size block in COPYA into correct column
  511. * positions.
  512. *
  513. IF( IMAT.EQ.6
  514. $ .OR. IMAT.EQ.7
  515. $ .OR. IMAT.EQ.8
  516. $ .OR. IMAT.EQ.10
  517. $ .OR. IMAT.EQ.11 ) THEN
  518. *
  519. * Move by swapping the generated columns
  520. * from the right NB_GEN-size block from
  521. * (NB_ZERO+1:NB_ZERO+JB_ZERO)
  522. * into columns (1:JB_ZERO-1).
  523. *
  524. DO J = 1, JB_ZERO-1, 1
  525. CALL DSWAP( M,
  526. $ COPYA( ( NB_ZERO+J-1)*LDA+1), 1,
  527. $ COPYA( (J-1)*LDA + 1 ), 1 )
  528. END DO
  529. *
  530. ELSE IF( IMAT.EQ.12 .OR. IMAT.EQ.13 ) THEN
  531. *
  532. * ( IMAT = 12, Odd-numbered ZERO columns. )
  533. * Swap the generated columns from the right
  534. * NB_GEN-size block into the even zero colums in the
  535. * left NB_ZERO-size block.
  536. *
  537. * ( IMAT = 13, Even-numbered ZERO columns. )
  538. * Swap the generated columns from the right
  539. * NB_GEN-size block into the odd zero colums in the
  540. * left NB_ZERO-size block.
  541. *
  542. DO J = 1, NB_GEN, 1
  543. IND_OUT = ( NB_ZERO+J-1 )*LDA + 1
  544. IND_IN = ( J_INC*(J-1)+(J_FIRST_NZ-1) )*LDA
  545. $ + 1
  546. CALL DSWAP( M,
  547. $ COPYA( IND_OUT ), 1,
  548. $ COPYA( IND_IN), 1 )
  549. END DO
  550. *
  551. END IF
  552. *
  553. * 5) Order the singular values generated by
  554. * DLAMTS in decreasing order and add trailing zeros
  555. * that correspond to zero columns.
  556. * The total number of singular values is MINMN.
  557. *
  558. MINMNB_GEN = MIN( M, NB_GEN )
  559. *
  560. DO I = MINMNB_GEN+1, MINMN
  561. S( I ) = ZERO
  562. END DO
  563. *
  564. ELSE
  565. *
  566. * IF(MINMN.LT.2) skip this size for this matrix type.
  567. *
  568. CYCLE
  569. END IF
  570. *
  571. * Initialize a copy array for a pivot array for DGEQP3RK.
  572. *
  573. DO I = 1, N
  574. IWORK( I ) = 0
  575. END DO
  576. *
  577. DO INB = 1, NNB
  578. *
  579. * Do for each pair of values (NB,NX) in NBVAL and NXVAL.
  580. *
  581. NB = NBVAL( INB )
  582. CALL XLAENV( 1, NB )
  583. NX = NXVAL( INB )
  584. CALL XLAENV( 3, NX )
  585. *
  586. * We do MIN(M,N)+1 because we need a test for KMAX > N,
  587. * when KMAX is larger than MIN(M,N), KMAX should be
  588. * KMAX = MIN(M,N)
  589. *
  590. DO KMAX = 0, MIN(M,N)+1
  591. *
  592. * Get a working copy of COPYA into A( 1:M,1:N ).
  593. * Get a working copy of COPYB into A( 1:M, (N+1):NRHS ).
  594. * Get a working copy of COPYB into into B( 1:M, 1:NRHS ).
  595. * Get a working copy of IWORK(1:N) awith zeroes into
  596. * which is going to be used as pivot array IWORK( N+1:2N ).
  597. * NOTE: IWORK(2N+1:3N) is going to be used as a WORK array
  598. * for the routine.
  599. *
  600. CALL DLACPY( 'All', M, N, COPYA, LDA, A, LDA )
  601. CALL DLACPY( 'All', M, NRHS, COPYB, LDA,
  602. $ A( LDA*N + 1 ), LDA )
  603. CALL DLACPY( 'All', M, NRHS, COPYB, LDA,
  604. $ B, LDA )
  605. CALL ICOPY( N, IWORK( 1 ), 1, IWORK( N+1 ), 1 )
  606. DO I = 1, NTESTS
  607. RESULT( I ) = ZERO
  608. END DO
  609. *
  610. ABSTOL = -1.0
  611. RELTOL = -1.0
  612. *
  613. * Compute the QR factorization with pivoting of A
  614. *
  615. LW = MAX( 1, MAX( 2*N + NB*( N+NRHS+1 ),
  616. $ 3*N + NRHS - 1 ) )
  617. *
  618. * Compute DGEQP3RK factorization of A.
  619. *
  620. SRNAMT = 'DGEQP3RK'
  621. CALL DGEQP3RK( M, N, NRHS, KMAX, ABSTOL, RELTOL,
  622. $ A, LDA, KFACT, MAXC2NRMK,
  623. $ RELMAXC2NRMK, IWORK( N+1 ), TAU,
  624. $ WORK, LW, IWORK( 2*N+1 ), INFO )
  625. *
  626. * Check error code from DGEQP3RK.
  627. *
  628. IF( INFO.LT.0 )
  629. $ CALL ALAERH( PATH, 'DGEQP3RK', INFO, 0, ' ',
  630. $ M, N, NX, -1, NB, IMAT,
  631. $ NFAIL, NERRS, NOUT )
  632. *
  633. * Compute test 1:
  634. *
  635. * This test in only for the full rank factorization of
  636. * the matrix A.
  637. *
  638. * Array S(1:min(M,N)) contains svd(A) the sigular values
  639. * of the original matrix A in decreasing absolute value
  640. * order. The test computes svd(R), the vector sigular
  641. * values of the upper trapezoid of A(1:M,1:N) that
  642. * contains the factor R, in decreasing order. The test
  643. * returns the ratio:
  644. *
  645. * 2-norm(svd(R) - svd(A)) / ( max(M,N) * 2-norm(svd(A)) * EPS )
  646. *
  647. IF( KFACT.EQ.MINMN ) THEN
  648. *
  649. RESULT( 1 ) = DQRT12( M, N, A, LDA, S, WORK,
  650. $ LWORK )
  651. *
  652. NRUN = NRUN + 1
  653. *
  654. * End test 1
  655. *
  656. END IF
  657. *
  658. * Compute test 2:
  659. *
  660. * The test returns the ratio:
  661. *
  662. * 1-norm( A*P - Q*R ) / ( max(M,N) * 1-norm(A) * EPS )
  663. *
  664. RESULT( 2 ) = DQPT01( M, N, KFACT, COPYA, A, LDA, TAU,
  665. $ IWORK( N+1 ), WORK, LWORK )
  666. *
  667. * Compute test 3:
  668. *
  669. * The test returns the ratio:
  670. *
  671. * 1-norm( Q**T * Q - I ) / ( M * EPS )
  672. *
  673. RESULT( 3 ) = DQRT11( M, KFACT, A, LDA, TAU, WORK,
  674. $ LWORK )
  675. *
  676. NRUN = NRUN + 2
  677. *
  678. * Compute test 4:
  679. *
  680. * This test is only for the factorizations with the
  681. * rank greater than 2.
  682. * The elements on the diagonal of R should be non-
  683. * increasing.
  684. *
  685. * The test returns the ratio:
  686. *
  687. * Returns 1.0D+100 if abs(R(K+1,K+1)) > abs(R(K,K)),
  688. * K=1:KFACT-1
  689. *
  690. IF( MIN(KFACT, MINMN).GE.2 ) THEN
  691. *
  692. DO J = 1, KFACT-1, 1
  693. DTEMP = (( ABS( A( (J-1)*LDA+J ) ) -
  694. $ ABS( A( (J)*LDA+J+1 ) ) ) /
  695. $ ABS( A(1) ) )
  696. *
  697. IF( DTEMP.LT.ZERO ) THEN
  698. RESULT( 4 ) = BIGNUM
  699. END IF
  700. *
  701. END DO
  702. *
  703. NRUN = NRUN + 1
  704. *
  705. * End test 4.
  706. *
  707. END IF
  708. *
  709. * Compute test 5:
  710. *
  711. * This test in only for matrix A with min(M,N) > 0.
  712. *
  713. * The test returns the ratio:
  714. *
  715. * 1-norm(Q**T * B - Q**T * B ) /
  716. * ( M * EPS )
  717. *
  718. * (1) Compute B:=Q**T * B in the matrix B.
  719. *
  720. IF( MINMN.GT.0 ) THEN
  721. *
  722. LWORK_MQR = MAX(1, NRHS)
  723. CALL DORMQR( 'Left', 'Transpose',
  724. $ M, NRHS, KFACT, A, LDA, TAU, B, LDA,
  725. $ WORK, LWORK_MQR, INFO )
  726. *
  727. DO I = 1, NRHS
  728. *
  729. * Compare N+J-th column of A and J-column of B.
  730. *
  731. CALL DAXPY( M, -ONE, A( ( N+I-1 )*LDA+1 ), 1,
  732. $ B( ( I-1 )*LDA+1 ), 1 )
  733. END DO
  734. *
  735. RESULT( 5 ) = ABS(
  736. $ DLANGE( 'One-norm', M, NRHS, B, LDA, RDUMMY ) /
  737. $ ( DBLE( M )*DLAMCH( 'Epsilon' ) ) )
  738. *
  739. NRUN = NRUN + 1
  740. *
  741. * End compute test 5.
  742. *
  743. END IF
  744. *
  745. * Print information about the tests that did not
  746. * pass the threshold.
  747. *
  748. DO T = 1, NTESTS
  749. IF( RESULT( T ).GE.THRESH ) THEN
  750. IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 )
  751. $ CALL ALAHD( NOUT, PATH )
  752. WRITE( NOUT, FMT = 9999 ) 'DGEQP3RK', M, N,
  753. $ NRHS, KMAX, ABSTOL, RELTOL, NB, NX,
  754. $ IMAT, T, RESULT( T )
  755. NFAIL = NFAIL + 1
  756. END IF
  757. END DO
  758. *
  759. * END DO KMAX = 1, MIN(M,N)+1
  760. *
  761. END DO
  762. *
  763. * END DO for INB = 1, NNB
  764. *
  765. END DO
  766. *
  767. * END DO for IMAT = 1, NTYPES
  768. *
  769. END DO
  770. *
  771. * END DO for INS = 1, NNS
  772. *
  773. END DO
  774. *
  775. * END DO for IN = 1, NN
  776. *
  777. END DO
  778. *
  779. * END DO for IM = 1, NM
  780. *
  781. END DO
  782. *
  783. * Print a summary of the results.
  784. *
  785. CALL ALASUM( PATH, NOUT, NFAIL, NRUN, NERRS )
  786. *
  787. 9999 FORMAT( 1X, A, ' M =', I5, ', N =', I5, ', NRHS =', I5,
  788. $ ', KMAX =', I5, ', ABSTOL =', G12.5,
  789. $ ', RELTOL =', G12.5, ', NB =', I4, ', NX =', I4,
  790. $ ', type ', I2, ', test ', I2, ', ratio =', G12.5 )
  791. *
  792. * End of DCHKQP3RK
  793. *
  794. END