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.

cchkhb2stg.f 32 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894
  1. *> \brief \b CCHKHB2STG
  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 CCHKHB2STG( NSIZES, NN, NWDTHS, KK, NTYPES, DOTYPE,
  12. * ISEED, THRESH, NOUNIT, A, LDA, SD, SE, D1,
  13. * D2, D3, U, LDU, WORK, LWORK, RWORK RESULT,
  14. * INFO )
  15. *
  16. * .. Scalar Arguments ..
  17. * INTEGER INFO, LDA, LDU, LWORK, NOUNIT, NSIZES, NTYPES,
  18. * $ NWDTHS
  19. * REAL THRESH
  20. * ..
  21. * .. Array Arguments ..
  22. * LOGICAL DOTYPE( * )
  23. * INTEGER ISEED( 4 ), KK( * ), NN( * )
  24. * REAL RESULT( * ), RWORK( * ), SD( * ), SE( * ),
  25. * $ D1( * ), D2( * ), D3( * )
  26. * COMPLEX A( LDA, * ), U( LDU, * ), WORK( * )
  27. * ..
  28. *
  29. *
  30. *> \par Purpose:
  31. * =============
  32. *>
  33. *> \verbatim
  34. *>
  35. *> CCHKHB2STG tests the reduction of a Hermitian band matrix to tridiagonal
  36. *> from, used with the Hermitian eigenvalue problem.
  37. *>
  38. *> CHBTRD factors a Hermitian band matrix A as U S U* , where * means
  39. *> conjugate transpose, S is symmetric tridiagonal, and U is unitary.
  40. *> CHBTRD can use either just the lower or just the upper triangle
  41. *> of A; CCHKHB2STG checks both cases.
  42. *>
  43. *> CHETRD_HB2ST factors a Hermitian band matrix A as U S U* ,
  44. *> where * means conjugate transpose, S is symmetric tridiagonal, and U is
  45. *> unitary. CHETRD_HB2ST can use either just the lower or just
  46. *> the upper triangle of A; CCHKHB2STG checks both cases.
  47. *>
  48. *> DSTEQR factors S as Z D1 Z'.
  49. *> D1 is the matrix of eigenvalues computed when Z is not computed
  50. *> and from the S resulting of DSBTRD "U" (used as reference for DSYTRD_SB2ST)
  51. *> D2 is the matrix of eigenvalues computed when Z is not computed
  52. *> and from the S resulting of DSYTRD_SB2ST "U".
  53. *> D3 is the matrix of eigenvalues computed when Z is not computed
  54. *> and from the S resulting of DSYTRD_SB2ST "L".
  55. *>
  56. *> When CCHKHB2STG is called, a number of matrix "sizes" ("n's"), a number
  57. *> of bandwidths ("k's"), and a number of matrix "types" are
  58. *> specified. For each size ("n"), each bandwidth ("k") less than or
  59. *> equal to "n", and each type of matrix, one matrix will be generated
  60. *> and used to test the hermitian banded reduction routine. For each
  61. *> matrix, a number of tests will be performed:
  62. *>
  63. *> (1) | A - V S V* | / ( |A| n ulp ) computed by CHBTRD with
  64. *> UPLO='U'
  65. *>
  66. *> (2) | I - UU* | / ( n ulp )
  67. *>
  68. *> (3) | A - V S V* | / ( |A| n ulp ) computed by CHBTRD with
  69. *> UPLO='L'
  70. *>
  71. *> (4) | I - UU* | / ( n ulp )
  72. *>
  73. *> (5) | D1 - D2 | / ( |D1| ulp ) where D1 is computed by
  74. *> DSBTRD with UPLO='U' and
  75. *> D2 is computed by
  76. *> CHETRD_HB2ST with UPLO='U'
  77. *>
  78. *> (6) | D1 - D3 | / ( |D1| ulp ) where D1 is computed by
  79. *> DSBTRD with UPLO='U' and
  80. *> D3 is computed by
  81. *> CHETRD_HB2ST with UPLO='L'
  82. *>
  83. *> The "sizes" are specified by an array NN(1:NSIZES); the value of
  84. *> each element NN(j) specifies one size.
  85. *> The "types" are specified by a logical array DOTYPE( 1:NTYPES );
  86. *> if DOTYPE(j) is .TRUE., then matrix type "j" will be generated.
  87. *> Currently, the list of possible types is:
  88. *>
  89. *> (1) The zero matrix.
  90. *> (2) The identity matrix.
  91. *>
  92. *> (3) A diagonal matrix with evenly spaced entries
  93. *> 1, ..., ULP and random signs.
  94. *> (ULP = (first number larger than 1) - 1 )
  95. *> (4) A diagonal matrix with geometrically spaced entries
  96. *> 1, ..., ULP and random signs.
  97. *> (5) A diagonal matrix with "clustered" entries 1, ULP, ..., ULP
  98. *> and random signs.
  99. *>
  100. *> (6) Same as (4), but multiplied by SQRT( overflow threshold )
  101. *> (7) Same as (4), but multiplied by SQRT( underflow threshold )
  102. *>
  103. *> (8) A matrix of the form U* D U, where U is unitary and
  104. *> D has evenly spaced entries 1, ..., ULP with random signs
  105. *> on the diagonal.
  106. *>
  107. *> (9) A matrix of the form U* D U, where U is unitary and
  108. *> D has geometrically spaced entries 1, ..., ULP with random
  109. *> signs on the diagonal.
  110. *>
  111. *> (10) A matrix of the form U* D U, where U is unitary and
  112. *> D has "clustered" entries 1, ULP,..., ULP with random
  113. *> signs on the diagonal.
  114. *>
  115. *> (11) Same as (8), but multiplied by SQRT( overflow threshold )
  116. *> (12) Same as (8), but multiplied by SQRT( underflow threshold )
  117. *>
  118. *> (13) Hermitian matrix with random entries chosen from (-1,1).
  119. *> (14) Same as (13), but multiplied by SQRT( overflow threshold )
  120. *> (15) Same as (13), but multiplied by SQRT( underflow threshold )
  121. *> \endverbatim
  122. *
  123. * Arguments:
  124. * ==========
  125. *
  126. *> \param[in] NSIZES
  127. *> \verbatim
  128. *> NSIZES is INTEGER
  129. *> The number of sizes of matrices to use. If it is zero,
  130. *> CCHKHB2STG does nothing. It must be at least zero.
  131. *> \endverbatim
  132. *>
  133. *> \param[in] NN
  134. *> \verbatim
  135. *> NN is INTEGER array, dimension (NSIZES)
  136. *> An array containing the sizes to be used for the matrices.
  137. *> Zero values will be skipped. The values must be at least
  138. *> zero.
  139. *> \endverbatim
  140. *>
  141. *> \param[in] NWDTHS
  142. *> \verbatim
  143. *> NWDTHS is INTEGER
  144. *> The number of bandwidths to use. If it is zero,
  145. *> CCHKHB2STG does nothing. It must be at least zero.
  146. *> \endverbatim
  147. *>
  148. *> \param[in] KK
  149. *> \verbatim
  150. *> KK is INTEGER array, dimension (NWDTHS)
  151. *> An array containing the bandwidths to be used for the band
  152. *> matrices. The values must be at least zero.
  153. *> \endverbatim
  154. *>
  155. *> \param[in] NTYPES
  156. *> \verbatim
  157. *> NTYPES is INTEGER
  158. *> The number of elements in DOTYPE. If it is zero, CCHKHB2STG
  159. *> does nothing. It must be at least zero. If it is MAXTYP+1
  160. *> and NSIZES is 1, then an additional type, MAXTYP+1 is
  161. *> defined, which is to use whatever matrix is in A. This
  162. *> is only useful if DOTYPE(1:MAXTYP) is .FALSE. and
  163. *> DOTYPE(MAXTYP+1) is .TRUE. .
  164. *> \endverbatim
  165. *>
  166. *> \param[in] DOTYPE
  167. *> \verbatim
  168. *> DOTYPE is LOGICAL array, dimension (NTYPES)
  169. *> If DOTYPE(j) is .TRUE., then for each size in NN a
  170. *> matrix of that size and of type j will be generated.
  171. *> If NTYPES is smaller than the maximum number of types
  172. *> defined (PARAMETER MAXTYP), then types NTYPES+1 through
  173. *> MAXTYP will not be generated. If NTYPES is larger
  174. *> than MAXTYP, DOTYPE(MAXTYP+1) through DOTYPE(NTYPES)
  175. *> will be ignored.
  176. *> \endverbatim
  177. *>
  178. *> \param[in,out] ISEED
  179. *> \verbatim
  180. *> ISEED is INTEGER array, dimension (4)
  181. *> On entry ISEED specifies the seed of the random number
  182. *> generator. The array elements should be between 0 and 4095;
  183. *> if not they will be reduced mod 4096. Also, ISEED(4) must
  184. *> be odd. The random number generator uses a linear
  185. *> congruential sequence limited to small integers, and so
  186. *> should produce machine independent random numbers. The
  187. *> values of ISEED are changed on exit, and can be used in the
  188. *> next call to CCHKHB2STG to continue the same random number
  189. *> sequence.
  190. *> \endverbatim
  191. *>
  192. *> \param[in] THRESH
  193. *> \verbatim
  194. *> THRESH is REAL
  195. *> A test will count as "failed" if the "error", computed as
  196. *> described above, exceeds THRESH. Note that the error
  197. *> is scaled to be O(1), so THRESH should be a reasonably
  198. *> small multiple of 1, e.g., 10 or 100. In particular,
  199. *> it should not depend on the precision (single vs. double)
  200. *> or the size of the matrix. It must be at least zero.
  201. *> \endverbatim
  202. *>
  203. *> \param[in] NOUNIT
  204. *> \verbatim
  205. *> NOUNIT is INTEGER
  206. *> The FORTRAN unit number for printing out error messages
  207. *> (e.g., if a routine returns IINFO not equal to 0.)
  208. *> \endverbatim
  209. *>
  210. *> \param[in,out] A
  211. *> \verbatim
  212. *> A is COMPLEX array, dimension
  213. *> (LDA, max(NN))
  214. *> Used to hold the matrix whose eigenvalues are to be
  215. *> computed.
  216. *> \endverbatim
  217. *>
  218. *> \param[in] LDA
  219. *> \verbatim
  220. *> LDA is INTEGER
  221. *> The leading dimension of A. It must be at least 2 (not 1!)
  222. *> and at least max( KK )+1.
  223. *> \endverbatim
  224. *>
  225. *> \param[out] SD
  226. *> \verbatim
  227. *> SD is REAL array, dimension (max(NN))
  228. *> Used to hold the diagonal of the tridiagonal matrix computed
  229. *> by CHBTRD.
  230. *> \endverbatim
  231. *>
  232. *> \param[out] SE
  233. *> \verbatim
  234. *> SE is REAL array, dimension (max(NN))
  235. *> Used to hold the off-diagonal of the tridiagonal matrix
  236. *> computed by CHBTRD.
  237. *> \endverbatim
  238. *>
  239. *> \param[out] D1
  240. *> \verbatim
  241. *> D1 is REAL array, dimension (max(NN))
  242. *> Used store eigenvalues resulting from the tridiagonal
  243. *> form using the DSBTRD.
  244. *> \endverbatim
  245. *>
  246. *> \param[out] D2
  247. *> \verbatim
  248. *> D2 is REAL array, dimension (max(NN))
  249. *> \endverbatim
  250. *>
  251. *> \param[out] D3
  252. *> \verbatim
  253. *> D3 is REAL array, dimension (max(NN))
  254. *> \endverbatim
  255. *>
  256. *> \param[out] U
  257. *> \verbatim
  258. *> U is COMPLEX array, dimension (LDU, max(NN))
  259. *> Used to hold the unitary matrix computed by CHBTRD.
  260. *> \endverbatim
  261. *>
  262. *> \param[in] LDU
  263. *> \verbatim
  264. *> LDU is INTEGER
  265. *> The leading dimension of U. It must be at least 1
  266. *> and at least max( NN ).
  267. *> \endverbatim
  268. *>
  269. *> \param[out] WORK
  270. *> \verbatim
  271. *> WORK is COMPLEX array, dimension (LWORK)
  272. *> \endverbatim
  273. *>
  274. *> \param[in] LWORK
  275. *> \verbatim
  276. *> LWORK is INTEGER
  277. *> The number of entries in WORK. This must be at least
  278. *> max( LDA+1, max(NN)+1 )*max(NN).
  279. *> \endverbatim
  280. *>
  281. *> \param[out] RWORK
  282. *> \verbatim
  283. *> RWORK is REAL array
  284. *> \endverbatim
  285. *>
  286. *> \param[out] RESULT
  287. *> \verbatim
  288. *> RESULT is REAL array, dimension (4)
  289. *> The values computed by the tests described above.
  290. *> The values are currently limited to 1/ulp, to avoid
  291. *> overflow.
  292. *> \endverbatim
  293. *>
  294. *> \param[out] INFO
  295. *> \verbatim
  296. *> INFO is INTEGER
  297. *> If 0, then everything ran OK.
  298. *>
  299. *>-----------------------------------------------------------------------
  300. *>
  301. *> Some Local Variables and Parameters:
  302. *> ---- ----- --------- --- ----------
  303. *> ZERO, ONE Real 0 and 1.
  304. *> MAXTYP The number of types defined.
  305. *> NTEST The number of tests performed, or which can
  306. *> be performed so far, for the current matrix.
  307. *> NTESTT The total number of tests performed so far.
  308. *> NMAX Largest value in NN.
  309. *> NMATS The number of matrices generated so far.
  310. *> NERRS The number of tests which have exceeded THRESH
  311. *> so far.
  312. *> COND, IMODE Values to be passed to the matrix generators.
  313. *> ANORM Norm of A; passed to matrix generators.
  314. *>
  315. *> OVFL, UNFL Overflow and underflow thresholds.
  316. *> ULP, ULPINV Finest relative precision and its inverse.
  317. *> RTOVFL, RTUNFL Square roots of the previous 2 values.
  318. *> The following four arrays decode JTYPE:
  319. *> KTYPE(j) The general type (1-10) for type "j".
  320. *> KMODE(j) The MODE value to be passed to the matrix
  321. *> generator for type "j".
  322. *> KMAGN(j) The order of magnitude ( O(1),
  323. *> O(overflow^(1/2) ), O(underflow^(1/2) )
  324. *> \endverbatim
  325. *
  326. * Authors:
  327. * ========
  328. *
  329. *> \author Univ. of Tennessee
  330. *> \author Univ. of California Berkeley
  331. *> \author Univ. of Colorado Denver
  332. *> \author NAG Ltd.
  333. *
  334. *> \ingroup complex_eig
  335. *
  336. * =====================================================================
  337. SUBROUTINE CCHKHB2STG( NSIZES, NN, NWDTHS, KK, NTYPES, DOTYPE,
  338. $ ISEED, THRESH, NOUNIT, A, LDA, SD, SE, D1,
  339. $ D2, D3, U, LDU, WORK, LWORK, RWORK, RESULT,
  340. $ INFO )
  341. *
  342. * -- LAPACK test routine --
  343. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  344. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  345. *
  346. * .. Scalar Arguments ..
  347. INTEGER INFO, LDA, LDU, LWORK, NOUNIT, NSIZES, NTYPES,
  348. $ NWDTHS
  349. REAL THRESH
  350. * ..
  351. * .. Array Arguments ..
  352. LOGICAL DOTYPE( * )
  353. INTEGER ISEED( 4 ), KK( * ), NN( * )
  354. REAL RESULT( * ), RWORK( * ), SD( * ), SE( * ),
  355. $ D1( * ), D2( * ), D3( * )
  356. COMPLEX A( LDA, * ), U( LDU, * ), WORK( * )
  357. * ..
  358. *
  359. * =====================================================================
  360. *
  361. * .. Parameters ..
  362. COMPLEX CZERO, CONE
  363. PARAMETER ( CZERO = ( 0.0E+0, 0.0E+0 ),
  364. $ CONE = ( 1.0E+0, 0.0E+0 ) )
  365. REAL ZERO, ONE, TWO, TEN
  366. PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0, TWO = 2.0E+0,
  367. $ TEN = 10.0E+0 )
  368. REAL HALF
  369. PARAMETER ( HALF = ONE / TWO )
  370. INTEGER MAXTYP
  371. PARAMETER ( MAXTYP = 15 )
  372. * ..
  373. * .. Local Scalars ..
  374. LOGICAL BADNN, BADNNB
  375. INTEGER I, IINFO, IMODE, ITYPE, J, JC, JCOL, JR, JSIZE,
  376. $ JTYPE, JWIDTH, K, KMAX, LH, LW, MTYPES, N,
  377. $ NERRS, NMATS, NMAX, NTEST, NTESTT
  378. REAL ANINV, ANORM, COND, OVFL, RTOVFL, RTUNFL,
  379. $ TEMP1, TEMP2, TEMP3, TEMP4, ULP, ULPINV, UNFL
  380. * ..
  381. * .. Local Arrays ..
  382. INTEGER IDUMMA( 1 ), IOLDSD( 4 ), KMAGN( MAXTYP ),
  383. $ KMODE( MAXTYP ), KTYPE( MAXTYP )
  384. * ..
  385. * .. External Functions ..
  386. REAL SLAMCH
  387. EXTERNAL SLAMCH
  388. * ..
  389. * .. External Subroutines ..
  390. EXTERNAL SLASUM, XERBLA, CHBT21, CHBTRD, CLACPY, CLASET,
  391. $ CLATMR, CLATMS, CHETRD_HB2ST, CSTEQR
  392. * ..
  393. * .. Intrinsic Functions ..
  394. INTRINSIC ABS, REAL, CONJG, MAX, MIN, SQRT
  395. * ..
  396. * .. Data statements ..
  397. DATA KTYPE / 1, 2, 5*4, 5*5, 3*8 /
  398. DATA KMAGN / 2*1, 1, 1, 1, 2, 3, 1, 1, 1, 2, 3, 1,
  399. $ 2, 3 /
  400. DATA KMODE / 2*0, 4, 3, 1, 4, 4, 4, 3, 1, 4, 4, 0,
  401. $ 0, 0 /
  402. * ..
  403. * .. Executable Statements ..
  404. *
  405. * Check for errors
  406. *
  407. NTESTT = 0
  408. INFO = 0
  409. *
  410. * Important constants
  411. *
  412. BADNN = .FALSE.
  413. NMAX = 1
  414. DO 10 J = 1, NSIZES
  415. NMAX = MAX( NMAX, NN( J ) )
  416. IF( NN( J ).LT.0 )
  417. $ BADNN = .TRUE.
  418. 10 CONTINUE
  419. *
  420. BADNNB = .FALSE.
  421. KMAX = 0
  422. DO 20 J = 1, NSIZES
  423. KMAX = MAX( KMAX, KK( J ) )
  424. IF( KK( J ).LT.0 )
  425. $ BADNNB = .TRUE.
  426. 20 CONTINUE
  427. KMAX = MIN( NMAX-1, KMAX )
  428. *
  429. * Check for errors
  430. *
  431. IF( NSIZES.LT.0 ) THEN
  432. INFO = -1
  433. ELSE IF( BADNN ) THEN
  434. INFO = -2
  435. ELSE IF( NWDTHS.LT.0 ) THEN
  436. INFO = -3
  437. ELSE IF( BADNNB ) THEN
  438. INFO = -4
  439. ELSE IF( NTYPES.LT.0 ) THEN
  440. INFO = -5
  441. ELSE IF( LDA.LT.KMAX+1 ) THEN
  442. INFO = -11
  443. ELSE IF( LDU.LT.NMAX ) THEN
  444. INFO = -15
  445. ELSE IF( ( MAX( LDA, NMAX )+1 )*NMAX.GT.LWORK ) THEN
  446. INFO = -17
  447. END IF
  448. *
  449. IF( INFO.NE.0 ) THEN
  450. CALL XERBLA( 'CCHKHB2STG', -INFO )
  451. RETURN
  452. END IF
  453. *
  454. * Quick return if possible
  455. *
  456. IF( NSIZES.EQ.0 .OR. NTYPES.EQ.0 .OR. NWDTHS.EQ.0 )
  457. $ RETURN
  458. *
  459. * More Important constants
  460. *
  461. UNFL = SLAMCH( 'Safe minimum' )
  462. OVFL = ONE / UNFL
  463. ULP = SLAMCH( 'Epsilon' )*SLAMCH( 'Base' )
  464. ULPINV = ONE / ULP
  465. RTUNFL = SQRT( UNFL )
  466. RTOVFL = SQRT( OVFL )
  467. *
  468. * Loop over sizes, types
  469. *
  470. NERRS = 0
  471. NMATS = 0
  472. *
  473. DO 190 JSIZE = 1, NSIZES
  474. N = NN( JSIZE )
  475. ANINV = ONE / REAL( MAX( 1, N ) )
  476. *
  477. DO 180 JWIDTH = 1, NWDTHS
  478. K = KK( JWIDTH )
  479. IF( K.GT.N )
  480. $ GO TO 180
  481. K = MAX( 0, MIN( N-1, K ) )
  482. *
  483. IF( NSIZES.NE.1 ) THEN
  484. MTYPES = MIN( MAXTYP, NTYPES )
  485. ELSE
  486. MTYPES = MIN( MAXTYP+1, NTYPES )
  487. END IF
  488. *
  489. DO 170 JTYPE = 1, MTYPES
  490. IF( .NOT.DOTYPE( JTYPE ) )
  491. $ GO TO 170
  492. NMATS = NMATS + 1
  493. NTEST = 0
  494. *
  495. DO 30 J = 1, 4
  496. IOLDSD( J ) = ISEED( J )
  497. 30 CONTINUE
  498. *
  499. * Compute "A".
  500. * Store as "Upper"; later, we will copy to other format.
  501. *
  502. * Control parameters:
  503. *
  504. * KMAGN KMODE KTYPE
  505. * =1 O(1) clustered 1 zero
  506. * =2 large clustered 2 identity
  507. * =3 small exponential (none)
  508. * =4 arithmetic diagonal, (w/ eigenvalues)
  509. * =5 random log hermitian, w/ eigenvalues
  510. * =6 random (none)
  511. * =7 random diagonal
  512. * =8 random hermitian
  513. * =9 positive definite
  514. * =10 diagonally dominant tridiagonal
  515. *
  516. IF( MTYPES.GT.MAXTYP )
  517. $ GO TO 100
  518. *
  519. ITYPE = KTYPE( JTYPE )
  520. IMODE = KMODE( JTYPE )
  521. *
  522. * Compute norm
  523. *
  524. GO TO ( 40, 50, 60 )KMAGN( JTYPE )
  525. *
  526. 40 CONTINUE
  527. ANORM = ONE
  528. GO TO 70
  529. *
  530. 50 CONTINUE
  531. ANORM = ( RTOVFL*ULP )*ANINV
  532. GO TO 70
  533. *
  534. 60 CONTINUE
  535. ANORM = RTUNFL*N*ULPINV
  536. GO TO 70
  537. *
  538. 70 CONTINUE
  539. *
  540. CALL CLASET( 'Full', LDA, N, CZERO, CZERO, A, LDA )
  541. IINFO = 0
  542. IF( JTYPE.LE.15 ) THEN
  543. COND = ULPINV
  544. ELSE
  545. COND = ULPINV*ANINV / TEN
  546. END IF
  547. *
  548. * Special Matrices -- Identity & Jordan block
  549. *
  550. * Zero
  551. *
  552. IF( ITYPE.EQ.1 ) THEN
  553. IINFO = 0
  554. *
  555. ELSE IF( ITYPE.EQ.2 ) THEN
  556. *
  557. * Identity
  558. *
  559. DO 80 JCOL = 1, N
  560. A( K+1, JCOL ) = ANORM
  561. 80 CONTINUE
  562. *
  563. ELSE IF( ITYPE.EQ.4 ) THEN
  564. *
  565. * Diagonal Matrix, [Eigen]values Specified
  566. *
  567. CALL CLATMS( N, N, 'S', ISEED, 'H', RWORK, IMODE,
  568. $ COND, ANORM, 0, 0, 'Q', A( K+1, 1 ), LDA,
  569. $ WORK, IINFO )
  570. *
  571. ELSE IF( ITYPE.EQ.5 ) THEN
  572. *
  573. * Hermitian, eigenvalues specified
  574. *
  575. CALL CLATMS( N, N, 'S', ISEED, 'H', RWORK, IMODE,
  576. $ COND, ANORM, K, K, 'Q', A, LDA, WORK,
  577. $ IINFO )
  578. *
  579. ELSE IF( ITYPE.EQ.7 ) THEN
  580. *
  581. * Diagonal, random eigenvalues
  582. *
  583. CALL CLATMR( N, N, 'S', ISEED, 'H', WORK, 6, ONE,
  584. $ CONE, 'T', 'N', WORK( N+1 ), 1, ONE,
  585. $ WORK( 2*N+1 ), 1, ONE, 'N', IDUMMA, 0, 0,
  586. $ ZERO, ANORM, 'Q', A( K+1, 1 ), LDA,
  587. $ IDUMMA, IINFO )
  588. *
  589. ELSE IF( ITYPE.EQ.8 ) THEN
  590. *
  591. * Hermitian, random eigenvalues
  592. *
  593. CALL CLATMR( N, N, 'S', ISEED, 'H', WORK, 6, ONE,
  594. $ CONE, 'T', 'N', WORK( N+1 ), 1, ONE,
  595. $ WORK( 2*N+1 ), 1, ONE, 'N', IDUMMA, K, K,
  596. $ ZERO, ANORM, 'Q', A, LDA, IDUMMA, IINFO )
  597. *
  598. ELSE IF( ITYPE.EQ.9 ) THEN
  599. *
  600. * Positive definite, eigenvalues specified.
  601. *
  602. CALL CLATMS( N, N, 'S', ISEED, 'P', RWORK, IMODE,
  603. $ COND, ANORM, K, K, 'Q', A, LDA,
  604. $ WORK( N+1 ), IINFO )
  605. *
  606. ELSE IF( ITYPE.EQ.10 ) THEN
  607. *
  608. * Positive definite tridiagonal, eigenvalues specified.
  609. *
  610. IF( N.GT.1 )
  611. $ K = MAX( 1, K )
  612. CALL CLATMS( N, N, 'S', ISEED, 'P', RWORK, IMODE,
  613. $ COND, ANORM, 1, 1, 'Q', A( K, 1 ), LDA,
  614. $ WORK, IINFO )
  615. DO 90 I = 2, N
  616. TEMP1 = ABS( A( K, I ) ) /
  617. $ SQRT( ABS( A( K+1, I-1 )*A( K+1, I ) ) )
  618. IF( TEMP1.GT.HALF ) THEN
  619. A( K, I ) = HALF*SQRT( ABS( A( K+1,
  620. $ I-1 )*A( K+1, I ) ) )
  621. END IF
  622. 90 CONTINUE
  623. *
  624. ELSE
  625. *
  626. IINFO = 1
  627. END IF
  628. *
  629. IF( IINFO.NE.0 ) THEN
  630. WRITE( NOUNIT, FMT = 9999 )'Generator', IINFO, N,
  631. $ JTYPE, IOLDSD
  632. INFO = ABS( IINFO )
  633. RETURN
  634. END IF
  635. *
  636. 100 CONTINUE
  637. *
  638. * Call CHBTRD to compute S and U from upper triangle.
  639. *
  640. CALL CLACPY( ' ', K+1, N, A, LDA, WORK, LDA )
  641. *
  642. NTEST = 1
  643. CALL CHBTRD( 'V', 'U', N, K, WORK, LDA, SD, SE, U, LDU,
  644. $ WORK( LDA*N+1 ), IINFO )
  645. *
  646. IF( IINFO.NE.0 ) THEN
  647. WRITE( NOUNIT, FMT = 9999 )'CHBTRD(U)', IINFO, N,
  648. $ JTYPE, IOLDSD
  649. INFO = ABS( IINFO )
  650. IF( IINFO.LT.0 ) THEN
  651. RETURN
  652. ELSE
  653. RESULT( 1 ) = ULPINV
  654. GO TO 150
  655. END IF
  656. END IF
  657. *
  658. * Do tests 1 and 2
  659. *
  660. CALL CHBT21( 'Upper', N, K, 1, A, LDA, SD, SE, U, LDU,
  661. $ WORK, RWORK, RESULT( 1 ) )
  662. *
  663. * Before converting A into lower for DSBTRD, run DSYTRD_SB2ST
  664. * otherwise matrix A will be converted to lower and then need
  665. * to be converted back to upper in order to run the upper case
  666. * ofDSYTRD_SB2ST
  667. *
  668. * Compute D1 the eigenvalues resulting from the tridiagonal
  669. * form using the DSBTRD and used as reference to compare
  670. * with the DSYTRD_SB2ST routine
  671. *
  672. * Compute D1 from the DSBTRD and used as reference for the
  673. * DSYTRD_SB2ST
  674. *
  675. CALL SCOPY( N, SD, 1, D1, 1 )
  676. IF( N.GT.0 )
  677. $ CALL SCOPY( N-1, SE, 1, RWORK, 1 )
  678. *
  679. CALL CSTEQR( 'N', N, D1, RWORK, WORK, LDU,
  680. $ RWORK( N+1 ), IINFO )
  681. IF( IINFO.NE.0 ) THEN
  682. WRITE( NOUNIT, FMT = 9999 )'CSTEQR(N)', IINFO, N,
  683. $ JTYPE, IOLDSD
  684. INFO = ABS( IINFO )
  685. IF( IINFO.LT.0 ) THEN
  686. RETURN
  687. ELSE
  688. RESULT( 5 ) = ULPINV
  689. GO TO 150
  690. END IF
  691. END IF
  692. *
  693. * DSYTRD_SB2ST Upper case is used to compute D2.
  694. * Note to set SD and SE to zero to be sure not reusing
  695. * the one from above. Compare it with D1 computed
  696. * using the DSBTRD.
  697. *
  698. CALL SLASET( 'Full', N, 1, ZERO, ZERO, SD, N )
  699. CALL SLASET( 'Full', N, 1, ZERO, ZERO, SE, N )
  700. CALL CLACPY( ' ', K+1, N, A, LDA, U, LDU )
  701. LH = MAX(1, 4*N)
  702. LW = LWORK - LH
  703. CALL CHETRD_HB2ST( 'N', 'N', "U", N, K, U, LDU, SD, SE,
  704. $ WORK, LH, WORK( LH+1 ), LW, IINFO )
  705. *
  706. * Compute D2 from the DSYTRD_SB2ST Upper case
  707. *
  708. CALL SCOPY( N, SD, 1, D2, 1 )
  709. IF( N.GT.0 )
  710. $ CALL SCOPY( N-1, SE, 1, RWORK, 1 )
  711. *
  712. CALL CSTEQR( 'N', N, D2, RWORK, WORK, LDU,
  713. $ RWORK( N+1 ), IINFO )
  714. IF( IINFO.NE.0 ) THEN
  715. WRITE( NOUNIT, FMT = 9999 )'CSTEQR(N)', IINFO, N,
  716. $ JTYPE, IOLDSD
  717. INFO = ABS( IINFO )
  718. IF( IINFO.LT.0 ) THEN
  719. RETURN
  720. ELSE
  721. RESULT( 5 ) = ULPINV
  722. GO TO 150
  723. END IF
  724. END IF
  725. *
  726. * Convert A from Upper-Triangle-Only storage to
  727. * Lower-Triangle-Only storage.
  728. *
  729. DO 120 JC = 1, N
  730. DO 110 JR = 0, MIN( K, N-JC )
  731. A( JR+1, JC ) = CONJG( A( K+1-JR, JC+JR ) )
  732. 110 CONTINUE
  733. 120 CONTINUE
  734. DO 140 JC = N + 1 - K, N
  735. DO 130 JR = MIN( K, N-JC ) + 1, K
  736. A( JR+1, JC ) = ZERO
  737. 130 CONTINUE
  738. 140 CONTINUE
  739. *
  740. * Call CHBTRD to compute S and U from lower triangle
  741. *
  742. CALL CLACPY( ' ', K+1, N, A, LDA, WORK, LDA )
  743. *
  744. NTEST = 3
  745. CALL CHBTRD( 'V', 'L', N, K, WORK, LDA, SD, SE, U, LDU,
  746. $ WORK( LDA*N+1 ), IINFO )
  747. *
  748. IF( IINFO.NE.0 ) THEN
  749. WRITE( NOUNIT, FMT = 9999 )'CHBTRD(L)', IINFO, N,
  750. $ JTYPE, IOLDSD
  751. INFO = ABS( IINFO )
  752. IF( IINFO.LT.0 ) THEN
  753. RETURN
  754. ELSE
  755. RESULT( 3 ) = ULPINV
  756. GO TO 150
  757. END IF
  758. END IF
  759. NTEST = 4
  760. *
  761. * Do tests 3 and 4
  762. *
  763. CALL CHBT21( 'Lower', N, K, 1, A, LDA, SD, SE, U, LDU,
  764. $ WORK, RWORK, RESULT( 3 ) )
  765. *
  766. * DSYTRD_SB2ST Lower case is used to compute D3.
  767. * Note to set SD and SE to zero to be sure not reusing
  768. * the one from above. Compare it with D1 computed
  769. * using the DSBTRD.
  770. *
  771. CALL SLASET( 'Full', N, 1, ZERO, ZERO, SD, N )
  772. CALL SLASET( 'Full', N, 1, ZERO, ZERO, SE, N )
  773. CALL CLACPY( ' ', K+1, N, A, LDA, U, LDU )
  774. LH = MAX(1, 4*N)
  775. LW = LWORK - LH
  776. CALL CHETRD_HB2ST( 'N', 'N', "L", N, K, U, LDU, SD, SE,
  777. $ WORK, LH, WORK( LH+1 ), LW, IINFO )
  778. *
  779. * Compute D3 from the 2-stage Upper case
  780. *
  781. CALL SCOPY( N, SD, 1, D3, 1 )
  782. IF( N.GT.0 )
  783. $ CALL SCOPY( N-1, SE, 1, RWORK, 1 )
  784. *
  785. CALL CSTEQR( 'N', N, D3, RWORK, WORK, LDU,
  786. $ RWORK( N+1 ), IINFO )
  787. IF( IINFO.NE.0 ) THEN
  788. WRITE( NOUNIT, FMT = 9999 )'CSTEQR(N)', IINFO, N,
  789. $ JTYPE, IOLDSD
  790. INFO = ABS( IINFO )
  791. IF( IINFO.LT.0 ) THEN
  792. RETURN
  793. ELSE
  794. RESULT( 6 ) = ULPINV
  795. GO TO 150
  796. END IF
  797. END IF
  798. *
  799. *
  800. * Do Tests 3 and 4 which are similar to 11 and 12 but with the
  801. * D1 computed using the standard 1-stage reduction as reference
  802. *
  803. NTEST = 6
  804. TEMP1 = ZERO
  805. TEMP2 = ZERO
  806. TEMP3 = ZERO
  807. TEMP4 = ZERO
  808. *
  809. DO 151 J = 1, N
  810. TEMP1 = MAX( TEMP1, ABS( D1( J ) ), ABS( D2( J ) ) )
  811. TEMP2 = MAX( TEMP2, ABS( D1( J )-D2( J ) ) )
  812. TEMP3 = MAX( TEMP3, ABS( D1( J ) ), ABS( D3( J ) ) )
  813. TEMP4 = MAX( TEMP4, ABS( D1( J )-D3( J ) ) )
  814. 151 CONTINUE
  815. *
  816. RESULT(5) = TEMP2 / MAX( UNFL, ULP*MAX( TEMP1, TEMP2 ) )
  817. RESULT(6) = TEMP4 / MAX( UNFL, ULP*MAX( TEMP3, TEMP4 ) )
  818. *
  819. * End of Loop -- Check for RESULT(j) > THRESH
  820. *
  821. 150 CONTINUE
  822. NTESTT = NTESTT + NTEST
  823. *
  824. * Print out tests which fail.
  825. *
  826. DO 160 JR = 1, NTEST
  827. IF( RESULT( JR ).GE.THRESH ) THEN
  828. *
  829. * If this is the first test to fail,
  830. * print a header to the data file.
  831. *
  832. IF( NERRS.EQ.0 ) THEN
  833. WRITE( NOUNIT, FMT = 9998 )'CHB'
  834. WRITE( NOUNIT, FMT = 9997 )
  835. WRITE( NOUNIT, FMT = 9996 )
  836. WRITE( NOUNIT, FMT = 9995 )'Hermitian'
  837. WRITE( NOUNIT, FMT = 9994 )'unitary', '*',
  838. $ 'conjugate transpose', ( '*', J = 1, 6 )
  839. END IF
  840. NERRS = NERRS + 1
  841. WRITE( NOUNIT, FMT = 9993 )N, K, IOLDSD, JTYPE,
  842. $ JR, RESULT( JR )
  843. END IF
  844. 160 CONTINUE
  845. *
  846. 170 CONTINUE
  847. 180 CONTINUE
  848. 190 CONTINUE
  849. *
  850. * Summary
  851. *
  852. CALL SLASUM( 'CHB', NOUNIT, NERRS, NTESTT )
  853. RETURN
  854. *
  855. 9999 FORMAT( ' CCHKHB2STG: ', A, ' returned INFO=', I6, '.', / 9X,
  856. $ 'N=', I6, ', JTYPE=', I6, ', ISEED=(', 3( I5, ',' ), I5,
  857. $ ')' )
  858. 9998 FORMAT( / 1X, A3,
  859. $ ' -- Complex Hermitian Banded Tridiagonal Reduction Routines'
  860. $ )
  861. 9997 FORMAT( ' Matrix types (see SCHK23 for details): ' )
  862. *
  863. 9996 FORMAT( / ' Special Matrices:',
  864. $ / ' 1=Zero matrix. ',
  865. $ ' 5=Diagonal: clustered entries.',
  866. $ / ' 2=Identity matrix. ',
  867. $ ' 6=Diagonal: large, evenly spaced.',
  868. $ / ' 3=Diagonal: evenly spaced entries. ',
  869. $ ' 7=Diagonal: small, evenly spaced.',
  870. $ / ' 4=Diagonal: geometr. spaced entries.' )
  871. 9995 FORMAT( ' Dense ', A, ' Banded Matrices:',
  872. $ / ' 8=Evenly spaced eigenvals. ',
  873. $ ' 12=Small, evenly spaced eigenvals.',
  874. $ / ' 9=Geometrically spaced eigenvals. ',
  875. $ ' 13=Matrix with random O(1) entries.',
  876. $ / ' 10=Clustered eigenvalues. ',
  877. $ ' 14=Matrix with large random entries.',
  878. $ / ' 11=Large, evenly spaced eigenvals. ',
  879. $ ' 15=Matrix with small random entries.' )
  880. *
  881. 9994 FORMAT( / ' Tests performed: (S is Tridiag, U is ', A, ',',
  882. $ / 20X, A, ' means ', A, '.', / ' UPLO=''U'':',
  883. $ / ' 1= | A - U S U', A1, ' | / ( |A| n ulp ) ',
  884. $ ' 2= | I - U U', A1, ' | / ( n ulp )', / ' UPLO=''L'':',
  885. $ / ' 3= | A - U S U', A1, ' | / ( |A| n ulp ) ',
  886. $ ' 4= | I - U U', A1, ' | / ( n ulp )' / ' Eig check:',
  887. $ /' 5= | D1 - D2', '', ' | / ( |D1| ulp ) ',
  888. $ ' 6= | D1 - D3', '', ' | / ( |D1| ulp ) ' )
  889. 9993 FORMAT( ' N=', I5, ', K=', I4, ', seed=', 4( I4, ',' ), ' type ',
  890. $ I2, ', test(', I2, ')=', G10.3 )
  891. *
  892. * End of CCHKHB2STG
  893. *
  894. END