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 31 kB

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