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.

dchksb2stg.f 31 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882
  1. *> \brief \b DCHKSB2STG
  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 DCHKSB2STG( NSIZES, NN, NWDTHS, KK, NTYPES, DOTYPE,
  12. * ISEED, THRESH, NOUNIT, A, LDA, SD, SE, D1,
  13. * D2, D3, U, LDU, WORK, LWORK, RESULT, INFO )
  14. *
  15. * .. Scalar Arguments ..
  16. * INTEGER INFO, LDA, LDU, LWORK, NOUNIT, NSIZES, NTYPES,
  17. * $ NWDTHS
  18. * DOUBLE PRECISION THRESH
  19. * ..
  20. * .. Array Arguments ..
  21. * LOGICAL DOTYPE( * )
  22. * INTEGER ISEED( 4 ), KK( * ), NN( * )
  23. * DOUBLE PRECISION A( LDA, * ), RESULT( * ), SD( * ), SE( * ),
  24. * $ D1( * ), D2( * ), D3( * ),
  25. * $ U( LDU, * ), WORK( * )
  26. * ..
  27. *
  28. *
  29. *> \par Purpose:
  30. * =============
  31. *>
  32. *> \verbatim
  33. *>
  34. *> DCHKSB2STG tests the reduction of a symmetric band matrix to tridiagonal
  35. *> form, used with the symmetric eigenvalue problem.
  36. *>
  37. *> DSBTRD factors a symmetric band matrix A as U S U' , where ' means
  38. *> transpose, S is symmetric tridiagonal, and U is orthogonal.
  39. *> DSBTRD can use either just the lower or just the upper triangle
  40. *> of A; DCHKSB2STG checks both cases.
  41. *>
  42. *> DSYTRD_SB2ST factors a symmetric band matrix A as U S U' ,
  43. *> where ' means transpose, S is symmetric tridiagonal, and U is
  44. *> orthogonal. DSYTRD_SB2ST can use either just the lower or just
  45. *> the upper triangle of A; DCHKSB2STG 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 DCHKSB2STG 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 symmetric 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 DSBTRD with
  63. *> UPLO='U'
  64. *>
  65. *> (2) | I - UU' | / ( n ulp )
  66. *>
  67. *> (3) | A - V S V' | / ( |A| n ulp ) computed by DSBTRD 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. *> DSYTRD_SB2ST 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. *> DSYTRD_SB2ST 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 orthogonal 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 orthogonal 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 orthogonal 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) Symmetric 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. *> DCHKSB2STG 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. *> DCHKSB2STG 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, DCHKSB2STG
  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 DCHKSB2STG to continue the same random number
  188. *> sequence.
  189. *> \endverbatim
  190. *>
  191. *> \param[in] THRESH
  192. *> \verbatim
  193. *> THRESH is DOUBLE PRECISION
  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 DOUBLE PRECISION 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 DOUBLE PRECISION array, dimension (max(NN))
  227. *> Used to hold the diagonal of the tridiagonal matrix computed
  228. *> by DSBTRD.
  229. *> \endverbatim
  230. *>
  231. *> \param[out] SE
  232. *> \verbatim
  233. *> SE is DOUBLE PRECISION array, dimension (max(NN))
  234. *> Used to hold the off-diagonal of the tridiagonal matrix
  235. *> computed by DSBTRD.
  236. *> \endverbatim
  237. *>
  238. *> \param[out] D1
  239. *> \verbatim
  240. *> D1 is DOUBLE PRECISION array, dimension (max(NN))
  241. *> \endverbatim
  242. *>
  243. *> \param[out] D2
  244. *> \verbatim
  245. *> D2 is DOUBLE PRECISION array, dimension (max(NN))
  246. *> \endverbatim
  247. *>
  248. *> \param[out] D3
  249. *> \verbatim
  250. *> D3 is DOUBLE PRECISION array, dimension (max(NN))
  251. *> \endverbatim
  252. *>
  253. *> \param[out] U
  254. *> \verbatim
  255. *> U is DOUBLE PRECISION array, dimension (LDU, max(NN))
  256. *> Used to hold the orthogonal matrix computed by DSBTRD.
  257. *> \endverbatim
  258. *>
  259. *> \param[in] LDU
  260. *> \verbatim
  261. *> LDU is INTEGER
  262. *> The leading dimension of U. It must be at least 1
  263. *> and at least max( NN ).
  264. *> \endverbatim
  265. *>
  266. *> \param[out] WORK
  267. *> \verbatim
  268. *> WORK is DOUBLE PRECISION array, dimension (LWORK)
  269. *> \endverbatim
  270. *>
  271. *> \param[in] LWORK
  272. *> \verbatim
  273. *> LWORK is INTEGER
  274. *> The number of entries in WORK. This must be at least
  275. *> max( LDA+1, max(NN)+1 )*max(NN).
  276. *> \endverbatim
  277. *>
  278. *> \param[out] RESULT
  279. *> \verbatim
  280. *> RESULT is DOUBLE PRECISION array, dimension (4)
  281. *> The values computed by the tests described above.
  282. *> The values are currently limited to 1/ulp, to avoid
  283. *> overflow.
  284. *> \endverbatim
  285. *>
  286. *> \param[out] INFO
  287. *> \verbatim
  288. *> INFO is INTEGER
  289. *> If 0, then everything ran OK.
  290. *>
  291. *>-----------------------------------------------------------------------
  292. *>
  293. *> Some Local Variables and Parameters:
  294. *> ---- ----- --------- --- ----------
  295. *> ZERO, ONE Real 0 and 1.
  296. *> MAXTYP The number of types defined.
  297. *> NTEST The number of tests performed, or which can
  298. *> be performed so far, for the current matrix.
  299. *> NTESTT The total number of tests performed so far.
  300. *> NMAX Largest value in NN.
  301. *> NMATS The number of matrices generated so far.
  302. *> NERRS The number of tests which have exceeded THRESH
  303. *> so far.
  304. *> COND, IMODE Values to be passed to the matrix generators.
  305. *> ANORM Norm of A; passed to matrix generators.
  306. *>
  307. *> OVFL, UNFL Overflow and underflow thresholds.
  308. *> ULP, ULPINV Finest relative precision and its inverse.
  309. *> RTOVFL, RTUNFL Square roots of the previous 2 values.
  310. *> The following four arrays decode JTYPE:
  311. *> KTYPE(j) The general type (1-10) for type "j".
  312. *> KMODE(j) The MODE value to be passed to the matrix
  313. *> generator for type "j".
  314. *> KMAGN(j) The order of magnitude ( O(1),
  315. *> O(overflow^(1/2) ), O(underflow^(1/2) )
  316. *> \endverbatim
  317. *
  318. * Authors:
  319. * ========
  320. *
  321. *> \author Univ. of Tennessee
  322. *> \author Univ. of California Berkeley
  323. *> \author Univ. of Colorado Denver
  324. *> \author NAG Ltd.
  325. *
  326. *> \ingroup double_eig
  327. *
  328. * =====================================================================
  329. SUBROUTINE DCHKSB2STG( NSIZES, NN, NWDTHS, KK, NTYPES, DOTYPE,
  330. $ ISEED, THRESH, NOUNIT, A, LDA, SD, SE, D1,
  331. $ D2, D3, U, LDU, WORK, LWORK, RESULT, INFO )
  332. *
  333. * -- LAPACK test routine --
  334. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  335. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  336. *
  337. * .. Scalar Arguments ..
  338. INTEGER INFO, LDA, LDU, LWORK, NOUNIT, NSIZES, NTYPES,
  339. $ NWDTHS
  340. DOUBLE PRECISION THRESH
  341. * ..
  342. * .. Array Arguments ..
  343. LOGICAL DOTYPE( * )
  344. INTEGER ISEED( 4 ), KK( * ), NN( * )
  345. DOUBLE PRECISION A( LDA, * ), RESULT( * ), SD( * ), SE( * ),
  346. $ D1( * ), D2( * ), D3( * ),
  347. $ U( LDU, * ), WORK( * )
  348. * ..
  349. *
  350. * =====================================================================
  351. *
  352. * .. Parameters ..
  353. DOUBLE PRECISION ZERO, ONE, TWO, TEN
  354. PARAMETER ( ZERO = 0.0D0, ONE = 1.0D0, TWO = 2.0D0,
  355. $ TEN = 10.0D0 )
  356. DOUBLE PRECISION HALF
  357. PARAMETER ( HALF = ONE / TWO )
  358. INTEGER MAXTYP
  359. PARAMETER ( MAXTYP = 15 )
  360. * ..
  361. * .. Local Scalars ..
  362. LOGICAL BADNN, BADNNB
  363. INTEGER I, IINFO, IMODE, ITYPE, J, JC, JCOL, JR, JSIZE,
  364. $ JTYPE, JWIDTH, K, KMAX, LH, LW, MTYPES, N,
  365. $ NERRS, NMATS, NMAX, NTEST, NTESTT
  366. DOUBLE PRECISION ANINV, ANORM, COND, OVFL, RTOVFL, RTUNFL,
  367. $ TEMP1, TEMP2, TEMP3, TEMP4, ULP, ULPINV, UNFL
  368. * ..
  369. * .. Local Arrays ..
  370. INTEGER IDUMMA( 1 ), IOLDSD( 4 ), KMAGN( MAXTYP ),
  371. $ KMODE( MAXTYP ), KTYPE( MAXTYP )
  372. * ..
  373. * .. External Functions ..
  374. DOUBLE PRECISION DLAMCH
  375. EXTERNAL DLAMCH
  376. * ..
  377. * .. External Subroutines ..
  378. EXTERNAL DLACPY, DLASET, DLASUM, DLATMR, DLATMS, DSBT21,
  379. $ DSBTRD, XERBLA, DSYTRD_SB2ST, DSTEQR
  380. * ..
  381. * .. Intrinsic Functions ..
  382. INTRINSIC ABS, DBLE, MAX, MIN, SQRT
  383. * ..
  384. * .. Data statements ..
  385. DATA KTYPE / 1, 2, 5*4, 5*5, 3*8 /
  386. DATA KMAGN / 2*1, 1, 1, 1, 2, 3, 1, 1, 1, 2, 3, 1,
  387. $ 2, 3 /
  388. DATA KMODE / 2*0, 4, 3, 1, 4, 4, 4, 3, 1, 4, 4, 0,
  389. $ 0, 0 /
  390. * ..
  391. * .. Executable Statements ..
  392. *
  393. * Check for errors
  394. *
  395. NTESTT = 0
  396. INFO = 0
  397. *
  398. * Important constants
  399. *
  400. BADNN = .FALSE.
  401. NMAX = 1
  402. DO 10 J = 1, NSIZES
  403. NMAX = MAX( NMAX, NN( J ) )
  404. IF( NN( J ).LT.0 )
  405. $ BADNN = .TRUE.
  406. 10 CONTINUE
  407. *
  408. BADNNB = .FALSE.
  409. KMAX = 0
  410. DO 20 J = 1, NSIZES
  411. KMAX = MAX( KMAX, KK( J ) )
  412. IF( KK( J ).LT.0 )
  413. $ BADNNB = .TRUE.
  414. 20 CONTINUE
  415. KMAX = MIN( NMAX-1, KMAX )
  416. *
  417. * Check for errors
  418. *
  419. IF( NSIZES.LT.0 ) THEN
  420. INFO = -1
  421. ELSE IF( BADNN ) THEN
  422. INFO = -2
  423. ELSE IF( NWDTHS.LT.0 ) THEN
  424. INFO = -3
  425. ELSE IF( BADNNB ) THEN
  426. INFO = -4
  427. ELSE IF( NTYPES.LT.0 ) THEN
  428. INFO = -5
  429. ELSE IF( LDA.LT.KMAX+1 ) THEN
  430. INFO = -11
  431. ELSE IF( LDU.LT.NMAX ) THEN
  432. INFO = -15
  433. ELSE IF( ( MAX( LDA, NMAX )+1 )*NMAX.GT.LWORK ) THEN
  434. INFO = -17
  435. END IF
  436. *
  437. IF( INFO.NE.0 ) THEN
  438. CALL XERBLA( 'DCHKSB2STG', -INFO )
  439. RETURN
  440. END IF
  441. *
  442. * Quick return if possible
  443. *
  444. IF( NSIZES.EQ.0 .OR. NTYPES.EQ.0 .OR. NWDTHS.EQ.0 )
  445. $ RETURN
  446. *
  447. * More Important constants
  448. *
  449. UNFL = DLAMCH( 'Safe minimum' )
  450. OVFL = ONE / UNFL
  451. ULP = DLAMCH( 'Epsilon' )*DLAMCH( 'Base' )
  452. ULPINV = ONE / ULP
  453. RTUNFL = SQRT( UNFL )
  454. RTOVFL = SQRT( OVFL )
  455. *
  456. * Loop over sizes, types
  457. *
  458. NERRS = 0
  459. NMATS = 0
  460. *
  461. DO 190 JSIZE = 1, NSIZES
  462. N = NN( JSIZE )
  463. ANINV = ONE / DBLE( MAX( 1, N ) )
  464. *
  465. DO 180 JWIDTH = 1, NWDTHS
  466. K = KK( JWIDTH )
  467. IF( K.GT.N )
  468. $ GO TO 180
  469. K = MAX( 0, MIN( N-1, K ) )
  470. *
  471. IF( NSIZES.NE.1 ) THEN
  472. MTYPES = MIN( MAXTYP, NTYPES )
  473. ELSE
  474. MTYPES = MIN( MAXTYP+1, NTYPES )
  475. END IF
  476. *
  477. DO 170 JTYPE = 1, MTYPES
  478. IF( .NOT.DOTYPE( JTYPE ) )
  479. $ GO TO 170
  480. NMATS = NMATS + 1
  481. NTEST = 0
  482. *
  483. DO 30 J = 1, 4
  484. IOLDSD( J ) = ISEED( J )
  485. 30 CONTINUE
  486. *
  487. * Compute "A".
  488. * Store as "Upper"; later, we will copy to other format.
  489. *
  490. * Control parameters:
  491. *
  492. * KMAGN KMODE KTYPE
  493. * =1 O(1) clustered 1 zero
  494. * =2 large clustered 2 identity
  495. * =3 small exponential (none)
  496. * =4 arithmetic diagonal, (w/ eigenvalues)
  497. * =5 random log symmetric, w/ eigenvalues
  498. * =6 random (none)
  499. * =7 random diagonal
  500. * =8 random symmetric
  501. * =9 positive definite
  502. * =10 diagonally dominant tridiagonal
  503. *
  504. IF( MTYPES.GT.MAXTYP )
  505. $ GO TO 100
  506. *
  507. ITYPE = KTYPE( JTYPE )
  508. IMODE = KMODE( JTYPE )
  509. *
  510. * Compute norm
  511. *
  512. GO TO ( 40, 50, 60 )KMAGN( JTYPE )
  513. *
  514. 40 CONTINUE
  515. ANORM = ONE
  516. GO TO 70
  517. *
  518. 50 CONTINUE
  519. ANORM = ( RTOVFL*ULP )*ANINV
  520. GO TO 70
  521. *
  522. 60 CONTINUE
  523. ANORM = RTUNFL*N*ULPINV
  524. GO TO 70
  525. *
  526. 70 CONTINUE
  527. *
  528. CALL DLASET( 'Full', LDA, N, ZERO, ZERO, A, LDA )
  529. IINFO = 0
  530. IF( JTYPE.LE.15 ) THEN
  531. COND = ULPINV
  532. ELSE
  533. COND = ULPINV*ANINV / TEN
  534. END IF
  535. *
  536. * Special Matrices -- Identity & Jordan block
  537. *
  538. * Zero
  539. *
  540. IF( ITYPE.EQ.1 ) THEN
  541. IINFO = 0
  542. *
  543. ELSE IF( ITYPE.EQ.2 ) THEN
  544. *
  545. * Identity
  546. *
  547. DO 80 JCOL = 1, N
  548. A( K+1, JCOL ) = ANORM
  549. 80 CONTINUE
  550. *
  551. ELSE IF( ITYPE.EQ.4 ) THEN
  552. *
  553. * Diagonal Matrix, [Eigen]values Specified
  554. *
  555. CALL DLATMS( N, N, 'S', ISEED, 'S', WORK, IMODE, COND,
  556. $ ANORM, 0, 0, 'Q', A( K+1, 1 ), LDA,
  557. $ WORK( N+1 ), IINFO )
  558. *
  559. ELSE IF( ITYPE.EQ.5 ) THEN
  560. *
  561. * Symmetric, eigenvalues specified
  562. *
  563. CALL DLATMS( N, N, 'S', ISEED, 'S', WORK, IMODE, COND,
  564. $ ANORM, K, K, 'Q', A, LDA, WORK( N+1 ),
  565. $ IINFO )
  566. *
  567. ELSE IF( ITYPE.EQ.7 ) THEN
  568. *
  569. * Diagonal, random eigenvalues
  570. *
  571. CALL DLATMR( N, N, 'S', ISEED, 'S', WORK, 6, ONE, ONE,
  572. $ 'T', 'N', WORK( N+1 ), 1, ONE,
  573. $ WORK( 2*N+1 ), 1, ONE, 'N', IDUMMA, 0, 0,
  574. $ ZERO, ANORM, 'Q', A( K+1, 1 ), LDA,
  575. $ IDUMMA, IINFO )
  576. *
  577. ELSE IF( ITYPE.EQ.8 ) THEN
  578. *
  579. * Symmetric, random eigenvalues
  580. *
  581. CALL DLATMR( N, N, 'S', ISEED, 'S', WORK, 6, ONE, ONE,
  582. $ 'T', 'N', WORK( N+1 ), 1, ONE,
  583. $ WORK( 2*N+1 ), 1, ONE, 'N', IDUMMA, K, K,
  584. $ ZERO, ANORM, 'Q', A, LDA, IDUMMA, IINFO )
  585. *
  586. ELSE IF( ITYPE.EQ.9 ) THEN
  587. *
  588. * Positive definite, eigenvalues specified.
  589. *
  590. CALL DLATMS( N, N, 'S', ISEED, 'P', WORK, IMODE, COND,
  591. $ ANORM, K, K, 'Q', A, LDA, WORK( N+1 ),
  592. $ IINFO )
  593. *
  594. ELSE IF( ITYPE.EQ.10 ) THEN
  595. *
  596. * Positive definite tridiagonal, eigenvalues specified.
  597. *
  598. IF( N.GT.1 )
  599. $ K = MAX( 1, K )
  600. CALL DLATMS( N, N, 'S', ISEED, 'P', WORK, IMODE, COND,
  601. $ ANORM, 1, 1, 'Q', A( K, 1 ), LDA,
  602. $ WORK( N+1 ), IINFO )
  603. DO 90 I = 2, N
  604. TEMP1 = ABS( A( K, I ) ) /
  605. $ SQRT( ABS( A( K+1, I-1 )*A( K+1, I ) ) )
  606. IF( TEMP1.GT.HALF ) THEN
  607. A( K, I ) = HALF*SQRT( ABS( A( K+1,
  608. $ I-1 )*A( K+1, I ) ) )
  609. END IF
  610. 90 CONTINUE
  611. *
  612. ELSE
  613. *
  614. IINFO = 1
  615. END IF
  616. *
  617. IF( IINFO.NE.0 ) THEN
  618. WRITE( NOUNIT, FMT = 9999 )'Generator', IINFO, N,
  619. $ JTYPE, IOLDSD
  620. INFO = ABS( IINFO )
  621. RETURN
  622. END IF
  623. *
  624. 100 CONTINUE
  625. *
  626. * Call DSBTRD to compute S and U from upper triangle.
  627. *
  628. CALL DLACPY( ' ', K+1, N, A, LDA, WORK, LDA )
  629. *
  630. NTEST = 1
  631. CALL DSBTRD( 'V', 'U', N, K, WORK, LDA, SD, SE, U, LDU,
  632. $ WORK( LDA*N+1 ), IINFO )
  633. *
  634. IF( IINFO.NE.0 ) THEN
  635. WRITE( NOUNIT, FMT = 9999 )'DSBTRD(U)', IINFO, N,
  636. $ JTYPE, IOLDSD
  637. INFO = ABS( IINFO )
  638. IF( IINFO.LT.0 ) THEN
  639. RETURN
  640. ELSE
  641. RESULT( 1 ) = ULPINV
  642. GO TO 150
  643. END IF
  644. END IF
  645. *
  646. * Do tests 1 and 2
  647. *
  648. CALL DSBT21( 'Upper', N, K, 1, A, LDA, SD, SE, U, LDU,
  649. $ WORK, RESULT( 1 ) )
  650. *
  651. * Before converting A into lower for DSBTRD, run DSYTRD_SB2ST
  652. * otherwise matrix A will be converted to lower and then need
  653. * to be converted back to upper in order to run the upper case
  654. * ofDSYTRD_SB2ST
  655. *
  656. * Compute D1 the eigenvalues resulting from the tridiagonal
  657. * form using the DSBTRD and used as reference to compare
  658. * with the DSYTRD_SB2ST routine
  659. *
  660. * Compute D1 from the DSBTRD and used as reference for the
  661. * DSYTRD_SB2ST
  662. *
  663. CALL DCOPY( N, SD, 1, D1, 1 )
  664. IF( N.GT.0 )
  665. $ CALL DCOPY( N-1, SE, 1, WORK, 1 )
  666. *
  667. CALL DSTEQR( 'N', N, D1, WORK, WORK( N+1 ), LDU,
  668. $ WORK( N+1 ), IINFO )
  669. IF( IINFO.NE.0 ) THEN
  670. WRITE( NOUNIT, FMT = 9999 )'DSTEQR(N)', IINFO, N,
  671. $ JTYPE, IOLDSD
  672. INFO = ABS( IINFO )
  673. IF( IINFO.LT.0 ) THEN
  674. RETURN
  675. ELSE
  676. RESULT( 5 ) = ULPINV
  677. GO TO 150
  678. END IF
  679. END IF
  680. *
  681. * DSYTRD_SB2ST Upper case is used to compute D2.
  682. * Note to set SD and SE to zero to be sure not reusing
  683. * the one from above. Compare it with D1 computed
  684. * using the DSBTRD.
  685. *
  686. CALL DLASET( 'Full', N, 1, ZERO, ZERO, SD, N )
  687. CALL DLASET( 'Full', N, 1, ZERO, ZERO, SE, N )
  688. CALL DLACPY( ' ', K+1, N, A, LDA, U, LDU )
  689. LH = MAX(1, 4*N)
  690. LW = LWORK - LH
  691. CALL DSYTRD_SB2ST( 'N', 'N', "U", N, K, U, LDU, SD, SE,
  692. $ WORK, LH, WORK( LH+1 ), LW, IINFO )
  693. *
  694. * Compute D2 from the DSYTRD_SB2ST Upper case
  695. *
  696. CALL DCOPY( N, SD, 1, D2, 1 )
  697. IF( N.GT.0 )
  698. $ CALL DCOPY( N-1, SE, 1, WORK, 1 )
  699. *
  700. CALL DSTEQR( 'N', N, D2, WORK, WORK( N+1 ), LDU,
  701. $ WORK( N+1 ), IINFO )
  702. IF( IINFO.NE.0 ) THEN
  703. WRITE( NOUNIT, FMT = 9999 )'DSTEQR(N)', IINFO, N,
  704. $ JTYPE, IOLDSD
  705. INFO = ABS( IINFO )
  706. IF( IINFO.LT.0 ) THEN
  707. RETURN
  708. ELSE
  709. RESULT( 5 ) = ULPINV
  710. GO TO 150
  711. END IF
  712. END IF
  713. *
  714. * Convert A from Upper-Triangle-Only storage to
  715. * Lower-Triangle-Only storage.
  716. *
  717. DO 120 JC = 1, N
  718. DO 110 JR = 0, MIN( K, N-JC )
  719. A( JR+1, JC ) = A( K+1-JR, JC+JR )
  720. 110 CONTINUE
  721. 120 CONTINUE
  722. DO 140 JC = N + 1 - K, N
  723. DO 130 JR = MIN( K, N-JC ) + 1, K
  724. A( JR+1, JC ) = ZERO
  725. 130 CONTINUE
  726. 140 CONTINUE
  727. *
  728. * Call DSBTRD to compute S and U from lower triangle
  729. *
  730. CALL DLACPY( ' ', K+1, N, A, LDA, WORK, LDA )
  731. *
  732. NTEST = 3
  733. CALL DSBTRD( 'V', 'L', N, K, WORK, LDA, SD, SE, U, LDU,
  734. $ WORK( LDA*N+1 ), IINFO )
  735. *
  736. IF( IINFO.NE.0 ) THEN
  737. WRITE( NOUNIT, FMT = 9999 )'DSBTRD(L)', IINFO, N,
  738. $ JTYPE, IOLDSD
  739. INFO = ABS( IINFO )
  740. IF( IINFO.LT.0 ) THEN
  741. RETURN
  742. ELSE
  743. RESULT( 3 ) = ULPINV
  744. GO TO 150
  745. END IF
  746. END IF
  747. NTEST = 4
  748. *
  749. * Do tests 3 and 4
  750. *
  751. CALL DSBT21( 'Lower', N, K, 1, A, LDA, SD, SE, U, LDU,
  752. $ WORK, RESULT( 3 ) )
  753. *
  754. * DSYTRD_SB2ST Lower case is used to compute D3.
  755. * Note to set SD and SE to zero to be sure not reusing
  756. * the one from above. Compare it with D1 computed
  757. * using the DSBTRD.
  758. *
  759. CALL DLASET( 'Full', N, 1, ZERO, ZERO, SD, N )
  760. CALL DLASET( 'Full', N, 1, ZERO, ZERO, SE, N )
  761. CALL DLACPY( ' ', K+1, N, A, LDA, U, LDU )
  762. LH = MAX(1, 4*N)
  763. LW = LWORK - LH
  764. CALL DSYTRD_SB2ST( 'N', 'N', "L", N, K, U, LDU, SD, SE,
  765. $ WORK, LH, WORK( LH+1 ), LW, IINFO )
  766. *
  767. * Compute D3 from the 2-stage Upper case
  768. *
  769. CALL DCOPY( N, SD, 1, D3, 1 )
  770. IF( N.GT.0 )
  771. $ CALL DCOPY( N-1, SE, 1, WORK, 1 )
  772. *
  773. CALL DSTEQR( 'N', N, D3, WORK, WORK( N+1 ), LDU,
  774. $ WORK( N+1 ), IINFO )
  775. IF( IINFO.NE.0 ) THEN
  776. WRITE( NOUNIT, FMT = 9999 )'DSTEQR(N)', IINFO, N,
  777. $ JTYPE, IOLDSD
  778. INFO = ABS( IINFO )
  779. IF( IINFO.LT.0 ) THEN
  780. RETURN
  781. ELSE
  782. RESULT( 6 ) = ULPINV
  783. GO TO 150
  784. END IF
  785. END IF
  786. *
  787. *
  788. * Do Tests 3 and 4 which are similar to 11 and 12 but with the
  789. * D1 computed using the standard 1-stage reduction as reference
  790. *
  791. NTEST = 6
  792. TEMP1 = ZERO
  793. TEMP2 = ZERO
  794. TEMP3 = ZERO
  795. TEMP4 = ZERO
  796. *
  797. DO 151 J = 1, N
  798. TEMP1 = MAX( TEMP1, ABS( D1( J ) ), ABS( D2( J ) ) )
  799. TEMP2 = MAX( TEMP2, ABS( D1( J )-D2( J ) ) )
  800. TEMP3 = MAX( TEMP3, ABS( D1( J ) ), ABS( D3( J ) ) )
  801. TEMP4 = MAX( TEMP4, ABS( D1( J )-D3( J ) ) )
  802. 151 CONTINUE
  803. *
  804. RESULT(5) = TEMP2 / MAX( UNFL, ULP*MAX( TEMP1, TEMP2 ) )
  805. RESULT(6) = TEMP4 / MAX( UNFL, ULP*MAX( TEMP3, TEMP4 ) )
  806. *
  807. * End of Loop -- Check for RESULT(j) > THRESH
  808. *
  809. 150 CONTINUE
  810. NTESTT = NTESTT + NTEST
  811. *
  812. * Print out tests which fail.
  813. *
  814. DO 160 JR = 1, NTEST
  815. IF( RESULT( JR ).GE.THRESH ) THEN
  816. *
  817. * If this is the first test to fail,
  818. * print a header to the data file.
  819. *
  820. IF( NERRS.EQ.0 ) THEN
  821. WRITE( NOUNIT, FMT = 9998 )'DSB'
  822. WRITE( NOUNIT, FMT = 9997 )
  823. WRITE( NOUNIT, FMT = 9996 )
  824. WRITE( NOUNIT, FMT = 9995 )'Symmetric'
  825. WRITE( NOUNIT, FMT = 9994 )'orthogonal', '''',
  826. $ 'transpose', ( '''', J = 1, 6 )
  827. END IF
  828. NERRS = NERRS + 1
  829. WRITE( NOUNIT, FMT = 9993 )N, K, IOLDSD, JTYPE,
  830. $ JR, RESULT( JR )
  831. END IF
  832. 160 CONTINUE
  833. *
  834. 170 CONTINUE
  835. 180 CONTINUE
  836. 190 CONTINUE
  837. *
  838. * Summary
  839. *
  840. CALL DLASUM( 'DSB', NOUNIT, NERRS, NTESTT )
  841. RETURN
  842. *
  843. 9999 FORMAT( ' DCHKSB2STG: ', A, ' returned INFO=', I6, '.', / 9X,
  844. $ 'N=', I6, ', JTYPE=', I6, ', ISEED=(', 3( I5, ',' ), I5,
  845. $ ')' )
  846. *
  847. 9998 FORMAT( / 1X, A3,
  848. $ ' -- Real Symmetric Banded Tridiagonal Reduction Routines' )
  849. 9997 FORMAT( ' Matrix types (see DCHKSB2STG for details): ' )
  850. *
  851. 9996 FORMAT( / ' Special Matrices:',
  852. $ / ' 1=Zero matrix. ',
  853. $ ' 5=Diagonal: clustered entries.',
  854. $ / ' 2=Identity matrix. ',
  855. $ ' 6=Diagonal: large, evenly spaced.',
  856. $ / ' 3=Diagonal: evenly spaced entries. ',
  857. $ ' 7=Diagonal: small, evenly spaced.',
  858. $ / ' 4=Diagonal: geometr. spaced entries.' )
  859. 9995 FORMAT( ' Dense ', A, ' Banded Matrices:',
  860. $ / ' 8=Evenly spaced eigenvals. ',
  861. $ ' 12=Small, evenly spaced eigenvals.',
  862. $ / ' 9=Geometrically spaced eigenvals. ',
  863. $ ' 13=Matrix with random O(1) entries.',
  864. $ / ' 10=Clustered eigenvalues. ',
  865. $ ' 14=Matrix with large random entries.',
  866. $ / ' 11=Large, evenly spaced eigenvals. ',
  867. $ ' 15=Matrix with small random entries.' )
  868. *
  869. 9994 FORMAT( / ' Tests performed: (S is Tridiag, U is ', A, ',',
  870. $ / 20X, A, ' means ', A, '.', / ' UPLO=''U'':',
  871. $ / ' 1= | A - U S U', A1, ' | / ( |A| n ulp ) ',
  872. $ ' 2= | I - U U', A1, ' | / ( n ulp )', / ' UPLO=''L'':',
  873. $ / ' 3= | A - U S U', A1, ' | / ( |A| n ulp ) ',
  874. $ ' 4= | I - U U', A1, ' | / ( n ulp )' / ' Eig check:',
  875. $ /' 5= | D1 - D2', '', ' | / ( |D1| ulp ) ',
  876. $ ' 6= | D1 - D3', '', ' | / ( |D1| ulp ) ' )
  877. 9993 FORMAT( ' N=', I5, ', K=', I4, ', seed=', 4( I4, ',' ), ' type ',
  878. $ I2, ', test(', I2, ')=', G10.3 )
  879. *
  880. * End of DCHKSB2STG
  881. *
  882. END