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.

sdrves.f 34 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958
  1. *> \brief \b SDRVES
  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 SDRVES( NSIZES, NN, NTYPES, DOTYPE, ISEED, THRESH,
  12. * NOUNIT, A, LDA, H, HT, WR, WI, WRT, WIT, VS,
  13. * LDVS, RESULT, WORK, NWORK, IWORK, BWORK, INFO )
  14. *
  15. * .. Scalar Arguments ..
  16. * INTEGER INFO, LDA, LDVS, NOUNIT, NSIZES, NTYPES, NWORK
  17. * REAL THRESH
  18. * ..
  19. * .. Array Arguments ..
  20. * LOGICAL BWORK( * ), DOTYPE( * )
  21. * INTEGER ISEED( 4 ), IWORK( * ), NN( * )
  22. * REAL A( LDA, * ), H( LDA, * ), HT( LDA, * ),
  23. * $ RESULT( 13 ), VS( LDVS, * ), WI( * ), WIT( * ),
  24. * $ WORK( * ), WR( * ), WRT( * )
  25. * ..
  26. *
  27. *
  28. *> \par Purpose:
  29. * =============
  30. *>
  31. *> \verbatim
  32. *>
  33. *> SDRVES checks the nonsymmetric eigenvalue (Schur form) problem
  34. *> driver SGEES.
  35. *>
  36. *> When SDRVES is called, a number of matrix "sizes" ("n's") and a
  37. *> number of matrix "types" are specified. For each size ("n")
  38. *> and each type of matrix, one matrix will be generated and used
  39. *> to test the nonsymmetric eigenroutines. For each matrix, 13
  40. *> tests will be performed:
  41. *>
  42. *> (1) 0 if T is in Schur form, 1/ulp otherwise
  43. *> (no sorting of eigenvalues)
  44. *>
  45. *> (2) | A - VS T VS' | / ( n |A| ulp )
  46. *>
  47. *> Here VS is the matrix of Schur eigenvectors, and T is in Schur
  48. *> form (no sorting of eigenvalues).
  49. *>
  50. *> (3) | I - VS VS' | / ( n ulp ) (no sorting of eigenvalues).
  51. *>
  52. *> (4) 0 if WR+sqrt(-1)*WI are eigenvalues of T
  53. *> 1/ulp otherwise
  54. *> (no sorting of eigenvalues)
  55. *>
  56. *> (5) 0 if T(with VS) = T(without VS),
  57. *> 1/ulp otherwise
  58. *> (no sorting of eigenvalues)
  59. *>
  60. *> (6) 0 if eigenvalues(with VS) = eigenvalues(without VS),
  61. *> 1/ulp otherwise
  62. *> (no sorting of eigenvalues)
  63. *>
  64. *> (7) 0 if T is in Schur form, 1/ulp otherwise
  65. *> (with sorting of eigenvalues)
  66. *>
  67. *> (8) | A - VS T VS' | / ( n |A| ulp )
  68. *>
  69. *> Here VS is the matrix of Schur eigenvectors, and T is in Schur
  70. *> form (with sorting of eigenvalues).
  71. *>
  72. *> (9) | I - VS VS' | / ( n ulp ) (with sorting of eigenvalues).
  73. *>
  74. *> (10) 0 if WR+sqrt(-1)*WI are eigenvalues of T
  75. *> 1/ulp otherwise
  76. *> (with sorting of eigenvalues)
  77. *>
  78. *> (11) 0 if T(with VS) = T(without VS),
  79. *> 1/ulp otherwise
  80. *> (with sorting of eigenvalues)
  81. *>
  82. *> (12) 0 if eigenvalues(with VS) = eigenvalues(without VS),
  83. *> 1/ulp otherwise
  84. *> (with sorting of eigenvalues)
  85. *>
  86. *> (13) if sorting worked and SDIM is the number of
  87. *> eigenvalues which were SELECTed
  88. *>
  89. *> The "sizes" are specified by an array NN(1:NSIZES); the value of
  90. *> each element NN(j) specifies one size.
  91. *> The "types" are specified by a logical array DOTYPE( 1:NTYPES );
  92. *> if DOTYPE(j) is .TRUE., then matrix type "j" will be generated.
  93. *> Currently, the list of possible types is:
  94. *>
  95. *> (1) The zero matrix.
  96. *> (2) The identity matrix.
  97. *> (3) A (transposed) Jordan block, with 1's on the diagonal.
  98. *>
  99. *> (4) A diagonal matrix with evenly spaced entries
  100. *> 1, ..., ULP and random signs.
  101. *> (ULP = (first number larger than 1) - 1 )
  102. *> (5) A diagonal matrix with geometrically spaced entries
  103. *> 1, ..., ULP and random signs.
  104. *> (6) A diagonal matrix with "clustered" entries 1, ULP, ..., ULP
  105. *> and random signs.
  106. *>
  107. *> (7) Same as (4), but multiplied by a constant near
  108. *> the overflow threshold
  109. *> (8) Same as (4), but multiplied by a constant near
  110. *> the underflow threshold
  111. *>
  112. *> (9) A matrix of the form U' T U, where U is orthogonal and
  113. *> T has evenly spaced entries 1, ..., ULP with random signs
  114. *> on the diagonal and random O(1) entries in the upper
  115. *> triangle.
  116. *>
  117. *> (10) A matrix of the form U' T U, where U is orthogonal and
  118. *> T has geometrically spaced entries 1, ..., ULP with random
  119. *> signs on the diagonal and random O(1) entries in the upper
  120. *> triangle.
  121. *>
  122. *> (11) A matrix of the form U' T U, where U is orthogonal and
  123. *> T has "clustered" entries 1, ULP,..., ULP with random
  124. *> signs on the diagonal and random O(1) entries in the upper
  125. *> triangle.
  126. *>
  127. *> (12) A matrix of the form U' T U, where U is orthogonal and
  128. *> T has real or complex conjugate paired eigenvalues randomly
  129. *> chosen from ( ULP, 1 ) and random O(1) entries in the upper
  130. *> triangle.
  131. *>
  132. *> (13) A matrix of the form X' T X, where X has condition
  133. *> SQRT( ULP ) and T has evenly spaced entries 1, ..., ULP
  134. *> with random signs on the diagonal and random O(1) entries
  135. *> in the upper triangle.
  136. *>
  137. *> (14) A matrix of the form X' T X, where X has condition
  138. *> SQRT( ULP ) and T has geometrically spaced entries
  139. *> 1, ..., ULP with random signs on the diagonal and random
  140. *> O(1) entries in the upper triangle.
  141. *>
  142. *> (15) A matrix of the form X' T X, where X has condition
  143. *> SQRT( ULP ) and T has "clustered" entries 1, ULP,..., ULP
  144. *> with random signs on the diagonal and random O(1) entries
  145. *> in the upper triangle.
  146. *>
  147. *> (16) A matrix of the form X' T X, where X has condition
  148. *> SQRT( ULP ) and T has real or complex conjugate paired
  149. *> eigenvalues randomly chosen from ( ULP, 1 ) and random
  150. *> O(1) entries in the upper triangle.
  151. *>
  152. *> (17) Same as (16), but multiplied by a constant
  153. *> near the overflow threshold
  154. *> (18) Same as (16), but multiplied by a constant
  155. *> near the underflow threshold
  156. *>
  157. *> (19) Nonsymmetric matrix with random entries chosen from (-1,1).
  158. *> If N is at least 4, all entries in first two rows and last
  159. *> row, and first column and last two columns are zero.
  160. *> (20) Same as (19), but multiplied by a constant
  161. *> near the overflow threshold
  162. *> (21) Same as (19), but multiplied by a constant
  163. *> near the underflow threshold
  164. *> \endverbatim
  165. *
  166. * Arguments:
  167. * ==========
  168. *
  169. *> \param[in] NSIZES
  170. *> \verbatim
  171. *> NSIZES is INTEGER
  172. *> The number of sizes of matrices to use. If it is zero,
  173. *> SDRVES does nothing. It must be at least zero.
  174. *> \endverbatim
  175. *>
  176. *> \param[in] NN
  177. *> \verbatim
  178. *> NN is INTEGER array, dimension (NSIZES)
  179. *> An array containing the sizes to be used for the matrices.
  180. *> Zero values will be skipped. The values must be at least
  181. *> zero.
  182. *> \endverbatim
  183. *>
  184. *> \param[in] NTYPES
  185. *> \verbatim
  186. *> NTYPES is INTEGER
  187. *> The number of elements in DOTYPE. If it is zero, SDRVES
  188. *> does nothing. It must be at least zero. If it is MAXTYP+1
  189. *> and NSIZES is 1, then an additional type, MAXTYP+1 is
  190. *> defined, which is to use whatever matrix is in A. This
  191. *> is only useful if DOTYPE(1:MAXTYP) is .FALSE. and
  192. *> DOTYPE(MAXTYP+1) is .TRUE. .
  193. *> \endverbatim
  194. *>
  195. *> \param[in] DOTYPE
  196. *> \verbatim
  197. *> DOTYPE is LOGICAL array, dimension (NTYPES)
  198. *> If DOTYPE(j) is .TRUE., then for each size in NN a
  199. *> matrix of that size and of type j will be generated.
  200. *> If NTYPES is smaller than the maximum number of types
  201. *> defined (PARAMETER MAXTYP), then types NTYPES+1 through
  202. *> MAXTYP will not be generated. If NTYPES is larger
  203. *> than MAXTYP, DOTYPE(MAXTYP+1) through DOTYPE(NTYPES)
  204. *> will be ignored.
  205. *> \endverbatim
  206. *>
  207. *> \param[in,out] ISEED
  208. *> \verbatim
  209. *> ISEED is INTEGER array, dimension (4)
  210. *> On entry ISEED specifies the seed of the random number
  211. *> generator. The array elements should be between 0 and 4095;
  212. *> if not they will be reduced mod 4096. Also, ISEED(4) must
  213. *> be odd. The random number generator uses a linear
  214. *> congruential sequence limited to small integers, and so
  215. *> should produce machine independent random numbers. The
  216. *> values of ISEED are changed on exit, and can be used in the
  217. *> next call to SDRVES to continue the same random number
  218. *> sequence.
  219. *> \endverbatim
  220. *>
  221. *> \param[in] THRESH
  222. *> \verbatim
  223. *> THRESH is REAL
  224. *> A test will count as "failed" if the "error", computed as
  225. *> described above, exceeds THRESH. Note that the error
  226. *> is scaled to be O(1), so THRESH should be a reasonably
  227. *> small multiple of 1, e.g., 10 or 100. In particular,
  228. *> it should not depend on the precision (single vs. double)
  229. *> or the size of the matrix. It must be at least zero.
  230. *> \endverbatim
  231. *>
  232. *> \param[in] NOUNIT
  233. *> \verbatim
  234. *> NOUNIT is INTEGER
  235. *> The FORTRAN unit number for printing out error messages
  236. *> (e.g., if a routine returns INFO not equal to 0.)
  237. *> \endverbatim
  238. *>
  239. *> \param[out] A
  240. *> \verbatim
  241. *> A is REAL array, dimension (LDA, max(NN))
  242. *> Used to hold the matrix whose eigenvalues are to be
  243. *> computed. On exit, A contains the last matrix actually used.
  244. *> \endverbatim
  245. *>
  246. *> \param[in] LDA
  247. *> \verbatim
  248. *> LDA is INTEGER
  249. *> The leading dimension of A, and H. LDA must be at
  250. *> least 1 and at least max(NN).
  251. *> \endverbatim
  252. *>
  253. *> \param[out] H
  254. *> \verbatim
  255. *> H is REAL array, dimension (LDA, max(NN))
  256. *> Another copy of the test matrix A, modified by SGEES.
  257. *> \endverbatim
  258. *>
  259. *> \param[out] HT
  260. *> \verbatim
  261. *> HT is REAL array, dimension (LDA, max(NN))
  262. *> Yet another copy of the test matrix A, modified by SGEES.
  263. *> \endverbatim
  264. *>
  265. *> \param[out] WR
  266. *> \verbatim
  267. *> WR is REAL array, dimension (max(NN))
  268. *> \endverbatim
  269. *>
  270. *> \param[out] WI
  271. *> \verbatim
  272. *> WI is REAL array, dimension (max(NN))
  273. *>
  274. *> The real and imaginary parts of the eigenvalues of A.
  275. *> On exit, WR + WI*i are the eigenvalues of the matrix in A.
  276. *> \endverbatim
  277. *>
  278. *> \param[out] WRT
  279. *> \verbatim
  280. *> WRT is REAL array, dimension (max(NN))
  281. *> \endverbatim
  282. *>
  283. *> \param[out] WIT
  284. *> \verbatim
  285. *> WIT is REAL array, dimension (max(NN))
  286. *>
  287. *> Like WR, WI, these arrays contain the eigenvalues of A,
  288. *> but those computed when SGEES only computes a partial
  289. *> eigendecomposition, i.e. not Schur vectors
  290. *> \endverbatim
  291. *>
  292. *> \param[out] VS
  293. *> \verbatim
  294. *> VS is REAL array, dimension (LDVS, max(NN))
  295. *> VS holds the computed Schur vectors.
  296. *> \endverbatim
  297. *>
  298. *> \param[in] LDVS
  299. *> \verbatim
  300. *> LDVS is INTEGER
  301. *> Leading dimension of VS. Must be at least max(1,max(NN)).
  302. *> \endverbatim
  303. *>
  304. *> \param[out] RESULT
  305. *> \verbatim
  306. *> RESULT is REAL array, dimension (13)
  307. *> The values computed by the 13 tests described above.
  308. *> The values are currently limited to 1/ulp, to avoid overflow.
  309. *> \endverbatim
  310. *>
  311. *> \param[out] WORK
  312. *> \verbatim
  313. *> WORK is REAL array, dimension (NWORK)
  314. *> \endverbatim
  315. *>
  316. *> \param[in] NWORK
  317. *> \verbatim
  318. *> NWORK is INTEGER
  319. *> The number of entries in WORK. This must be at least
  320. *> 5*NN(j)+2*NN(j)**2 for all j.
  321. *> \endverbatim
  322. *>
  323. *> \param[out] IWORK
  324. *> \verbatim
  325. *> IWORK is INTEGER array, dimension (max(NN))
  326. *> \endverbatim
  327. *>
  328. *> \param[out] BWORK
  329. *> \verbatim
  330. *> BWORK is LOGICAL array, dimension (max(NN))
  331. *> \endverbatim
  332. *>
  333. *> \param[out] INFO
  334. *> \verbatim
  335. *> INFO is INTEGER
  336. *> If 0, then everything ran OK.
  337. *> -1: NSIZES < 0
  338. *> -2: Some NN(j) < 0
  339. *> -3: NTYPES < 0
  340. *> -6: THRESH < 0
  341. *> -9: LDA < 1 or LDA < NMAX, where NMAX is max( NN(j) ).
  342. *> -17: LDVS < 1 or LDVS < NMAX, where NMAX is max( NN(j) ).
  343. *> -20: NWORK too small.
  344. *> If SLATMR, SLATMS, SLATME or SGEES returns an error code,
  345. *> the absolute value of it is returned.
  346. *>
  347. *>-----------------------------------------------------------------------
  348. *>
  349. *> Some Local Variables and Parameters:
  350. *> ---- ----- --------- --- ----------
  351. *>
  352. *> ZERO, ONE Real 0 and 1.
  353. *> MAXTYP The number of types defined.
  354. *> NMAX Largest value in NN.
  355. *> NERRS The number of tests which have exceeded THRESH
  356. *> COND, CONDS,
  357. *> IMODE Values to be passed to the matrix generators.
  358. *> ANORM Norm of A; passed to matrix generators.
  359. *>
  360. *> OVFL, UNFL Overflow and underflow thresholds.
  361. *> ULP, ULPINV Finest relative precision and its inverse.
  362. *> RTULP, RTULPI Square roots of the previous 4 values.
  363. *>
  364. *> The following four arrays decode JTYPE:
  365. *> KTYPE(j) The general type (1-10) for type "j".
  366. *> KMODE(j) The MODE value to be passed to the matrix
  367. *> generator for type "j".
  368. *> KMAGN(j) The order of magnitude ( O(1),
  369. *> O(overflow^(1/2) ), O(underflow^(1/2) )
  370. *> KCONDS(j) Selectw whether CONDS is to be 1 or
  371. *> 1/sqrt(ulp). (0 means irrelevant.)
  372. *> \endverbatim
  373. *
  374. * Authors:
  375. * ========
  376. *
  377. *> \author Univ. of Tennessee
  378. *> \author Univ. of California Berkeley
  379. *> \author Univ. of Colorado Denver
  380. *> \author NAG Ltd.
  381. *
  382. *> \ingroup single_eig
  383. *
  384. * =====================================================================
  385. SUBROUTINE SDRVES( NSIZES, NN, NTYPES, DOTYPE, ISEED, THRESH,
  386. $ NOUNIT, A, LDA, H, HT, WR, WI, WRT, WIT, VS,
  387. $ LDVS, RESULT, WORK, NWORK, IWORK, BWORK, INFO )
  388. *
  389. * -- LAPACK test routine --
  390. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  391. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  392. *
  393. * .. Scalar Arguments ..
  394. INTEGER INFO, LDA, LDVS, NOUNIT, NSIZES, NTYPES, NWORK
  395. REAL THRESH
  396. * ..
  397. * .. Array Arguments ..
  398. LOGICAL BWORK( * ), DOTYPE( * )
  399. INTEGER ISEED( 4 ), IWORK( * ), NN( * )
  400. REAL A( LDA, * ), H( LDA, * ), HT( LDA, * ),
  401. $ RESULT( 13 ), VS( LDVS, * ), WI( * ), WIT( * ),
  402. $ WORK( * ), WR( * ), WRT( * )
  403. * ..
  404. *
  405. * =====================================================================
  406. *
  407. * .. Parameters ..
  408. REAL ZERO, ONE
  409. PARAMETER ( ZERO = 0.0E0, ONE = 1.0E0 )
  410. INTEGER MAXTYP
  411. PARAMETER ( MAXTYP = 21 )
  412. * ..
  413. * .. Local Scalars ..
  414. LOGICAL BADNN
  415. CHARACTER SORT
  416. CHARACTER*3 PATH
  417. INTEGER I, IINFO, IMODE, ISORT, ITYPE, IWK, J, JCOL,
  418. $ JSIZE, JTYPE, KNTEIG, LWORK, MTYPES, N,
  419. $ NERRS, NFAIL, NMAX, NNWORK, NTEST, NTESTF,
  420. $ NTESTT, RSUB, SDIM
  421. REAL ANORM, COND, CONDS, OVFL, RTULP, RTULPI, TMP,
  422. $ ULP, ULPINV, UNFL
  423. * ..
  424. * .. Local Arrays ..
  425. CHARACTER ADUMMA( 1 )
  426. INTEGER IDUMMA( 1 ), IOLDSD( 4 ), KCONDS( MAXTYP ),
  427. $ KMAGN( MAXTYP ), KMODE( MAXTYP ),
  428. $ KTYPE( MAXTYP )
  429. REAL RES( 2 )
  430. * ..
  431. * .. Arrays in Common ..
  432. LOGICAL SELVAL( 20 )
  433. REAL SELWI( 20 ), SELWR( 20 )
  434. * ..
  435. * .. Scalars in Common ..
  436. INTEGER SELDIM, SELOPT
  437. * ..
  438. * .. Common blocks ..
  439. COMMON / SSLCT / SELOPT, SELDIM, SELVAL, SELWR, SELWI
  440. * ..
  441. * .. External Functions ..
  442. LOGICAL SSLECT
  443. REAL SLAMCH
  444. EXTERNAL SSLECT, SLAMCH
  445. * ..
  446. * .. External Subroutines ..
  447. EXTERNAL SGEES, SHST01, SLABAD, SLACPY, SLASUM, SLATME,
  448. $ SLATMR, SLATMS, SLASET, XERBLA
  449. * ..
  450. * .. Intrinsic Functions ..
  451. INTRINSIC ABS, MAX, SIGN, SQRT
  452. * ..
  453. * .. Data statements ..
  454. DATA KTYPE / 1, 2, 3, 5*4, 4*6, 6*6, 3*9 /
  455. DATA KMAGN / 3*1, 1, 1, 1, 2, 3, 4*1, 1, 1, 1, 1, 2,
  456. $ 3, 1, 2, 3 /
  457. DATA KMODE / 3*0, 4, 3, 1, 4, 4, 4, 3, 1, 5, 4, 3,
  458. $ 1, 5, 5, 5, 4, 3, 1 /
  459. DATA KCONDS / 3*0, 5*0, 4*1, 6*2, 3*0 /
  460. * ..
  461. * .. Executable Statements ..
  462. *
  463. PATH( 1: 1 ) = 'Single precision'
  464. PATH( 2: 3 ) = 'ES'
  465. *
  466. * Check for errors
  467. *
  468. NTESTT = 0
  469. NTESTF = 0
  470. INFO = 0
  471. SELOPT = 0
  472. *
  473. * Important constants
  474. *
  475. BADNN = .FALSE.
  476. NMAX = 0
  477. DO 10 J = 1, NSIZES
  478. NMAX = MAX( NMAX, NN( J ) )
  479. IF( NN( J ).LT.0 )
  480. $ BADNN = .TRUE.
  481. 10 CONTINUE
  482. *
  483. * Check for errors
  484. *
  485. IF( NSIZES.LT.0 ) THEN
  486. INFO = -1
  487. ELSE IF( BADNN ) THEN
  488. INFO = -2
  489. ELSE IF( NTYPES.LT.0 ) THEN
  490. INFO = -3
  491. ELSE IF( THRESH.LT.ZERO ) THEN
  492. INFO = -6
  493. ELSE IF( NOUNIT.LE.0 ) THEN
  494. INFO = -7
  495. ELSE IF( LDA.LT.1 .OR. LDA.LT.NMAX ) THEN
  496. INFO = -9
  497. ELSE IF( LDVS.LT.1 .OR. LDVS.LT.NMAX ) THEN
  498. INFO = -17
  499. ELSE IF( 5*NMAX+2*NMAX**2.GT.NWORK ) THEN
  500. INFO = -20
  501. END IF
  502. *
  503. IF( INFO.NE.0 ) THEN
  504. CALL XERBLA( 'SDRVES', -INFO )
  505. RETURN
  506. END IF
  507. *
  508. * Quick return if nothing to do
  509. *
  510. IF( NSIZES.EQ.0 .OR. NTYPES.EQ.0 )
  511. $ RETURN
  512. *
  513. * More Important constants
  514. *
  515. UNFL = SLAMCH( 'Safe minimum' )
  516. OVFL = ONE / UNFL
  517. CALL SLABAD( UNFL, OVFL )
  518. ULP = SLAMCH( 'Precision' )
  519. ULPINV = ONE / ULP
  520. RTULP = SQRT( ULP )
  521. RTULPI = ONE / RTULP
  522. *
  523. * Loop over sizes, types
  524. *
  525. NERRS = 0
  526. *
  527. DO 270 JSIZE = 1, NSIZES
  528. N = NN( JSIZE )
  529. MTYPES = MAXTYP
  530. IF( NSIZES.EQ.1 .AND. NTYPES.EQ.MAXTYP+1 )
  531. $ MTYPES = MTYPES + 1
  532. *
  533. DO 260 JTYPE = 1, MTYPES
  534. IF( .NOT.DOTYPE( JTYPE ) )
  535. $ GO TO 260
  536. *
  537. * Save ISEED in case of an error.
  538. *
  539. DO 20 J = 1, 4
  540. IOLDSD( J ) = ISEED( J )
  541. 20 CONTINUE
  542. *
  543. * Compute "A"
  544. *
  545. * Control parameters:
  546. *
  547. * KMAGN KCONDS KMODE KTYPE
  548. * =1 O(1) 1 clustered 1 zero
  549. * =2 large large clustered 2 identity
  550. * =3 small exponential Jordan
  551. * =4 arithmetic diagonal, (w/ eigenvalues)
  552. * =5 random log symmetric, w/ eigenvalues
  553. * =6 random general, w/ eigenvalues
  554. * =7 random diagonal
  555. * =8 random symmetric
  556. * =9 random general
  557. * =10 random triangular
  558. *
  559. IF( MTYPES.GT.MAXTYP )
  560. $ GO TO 90
  561. *
  562. ITYPE = KTYPE( JTYPE )
  563. IMODE = KMODE( JTYPE )
  564. *
  565. * Compute norm
  566. *
  567. GO TO ( 30, 40, 50 )KMAGN( JTYPE )
  568. *
  569. 30 CONTINUE
  570. ANORM = ONE
  571. GO TO 60
  572. *
  573. 40 CONTINUE
  574. ANORM = OVFL*ULP
  575. GO TO 60
  576. *
  577. 50 CONTINUE
  578. ANORM = UNFL*ULPINV
  579. GO TO 60
  580. *
  581. 60 CONTINUE
  582. *
  583. CALL SLASET( 'Full', LDA, N, ZERO, ZERO, A, LDA )
  584. IINFO = 0
  585. COND = ULPINV
  586. *
  587. * Special Matrices -- Identity & Jordan block
  588. *
  589. * Zero
  590. *
  591. IF( ITYPE.EQ.1 ) THEN
  592. IINFO = 0
  593. *
  594. ELSE IF( ITYPE.EQ.2 ) THEN
  595. *
  596. * Identity
  597. *
  598. DO 70 JCOL = 1, N
  599. A( JCOL, JCOL ) = ANORM
  600. 70 CONTINUE
  601. *
  602. ELSE IF( ITYPE.EQ.3 ) THEN
  603. *
  604. * Jordan Block
  605. *
  606. DO 80 JCOL = 1, N
  607. A( JCOL, JCOL ) = ANORM
  608. IF( JCOL.GT.1 )
  609. $ A( JCOL, JCOL-1 ) = ONE
  610. 80 CONTINUE
  611. *
  612. ELSE IF( ITYPE.EQ.4 ) THEN
  613. *
  614. * Diagonal Matrix, [Eigen]values Specified
  615. *
  616. CALL SLATMS( N, N, 'S', ISEED, 'S', WORK, IMODE, COND,
  617. $ ANORM, 0, 0, 'N', A, LDA, WORK( N+1 ),
  618. $ IINFO )
  619. *
  620. ELSE IF( ITYPE.EQ.5 ) THEN
  621. *
  622. * Symmetric, eigenvalues specified
  623. *
  624. CALL SLATMS( N, N, 'S', ISEED, 'S', WORK, IMODE, COND,
  625. $ ANORM, N, N, 'N', A, LDA, WORK( N+1 ),
  626. $ IINFO )
  627. *
  628. ELSE IF( ITYPE.EQ.6 ) THEN
  629. *
  630. * General, eigenvalues specified
  631. *
  632. IF( KCONDS( JTYPE ).EQ.1 ) THEN
  633. CONDS = ONE
  634. ELSE IF( KCONDS( JTYPE ).EQ.2 ) THEN
  635. CONDS = RTULPI
  636. ELSE
  637. CONDS = ZERO
  638. END IF
  639. *
  640. ADUMMA( 1 ) = ' '
  641. CALL SLATME( N, 'S', ISEED, WORK, IMODE, COND, ONE,
  642. $ ADUMMA, 'T', 'T', 'T', WORK( N+1 ), 4,
  643. $ CONDS, N, N, ANORM, A, LDA, WORK( 2*N+1 ),
  644. $ IINFO )
  645. *
  646. ELSE IF( ITYPE.EQ.7 ) THEN
  647. *
  648. * Diagonal, random eigenvalues
  649. *
  650. CALL SLATMR( N, N, 'S', ISEED, 'S', WORK, 6, ONE, ONE,
  651. $ 'T', 'N', WORK( N+1 ), 1, ONE,
  652. $ WORK( 2*N+1 ), 1, ONE, 'N', IDUMMA, 0, 0,
  653. $ ZERO, ANORM, 'NO', A, LDA, IWORK, IINFO )
  654. *
  655. ELSE IF( ITYPE.EQ.8 ) THEN
  656. *
  657. * Symmetric, random eigenvalues
  658. *
  659. CALL SLATMR( N, N, 'S', ISEED, 'S', WORK, 6, ONE, ONE,
  660. $ 'T', 'N', WORK( N+1 ), 1, ONE,
  661. $ WORK( 2*N+1 ), 1, ONE, 'N', IDUMMA, N, N,
  662. $ ZERO, ANORM, 'NO', A, LDA, IWORK, IINFO )
  663. *
  664. ELSE IF( ITYPE.EQ.9 ) THEN
  665. *
  666. * General, random eigenvalues
  667. *
  668. CALL SLATMR( N, N, 'S', ISEED, 'N', WORK, 6, ONE, ONE,
  669. $ 'T', 'N', WORK( N+1 ), 1, ONE,
  670. $ WORK( 2*N+1 ), 1, ONE, 'N', IDUMMA, N, N,
  671. $ ZERO, ANORM, 'NO', A, LDA, IWORK, IINFO )
  672. IF( N.GE.4 ) THEN
  673. CALL SLASET( 'Full', 2, N, ZERO, ZERO, A, LDA )
  674. CALL SLASET( 'Full', N-3, 1, ZERO, ZERO, A( 3, 1 ),
  675. $ LDA )
  676. CALL SLASET( 'Full', N-3, 2, ZERO, ZERO, A( 3, N-1 ),
  677. $ LDA )
  678. CALL SLASET( 'Full', 1, N, ZERO, ZERO, A( N, 1 ),
  679. $ LDA )
  680. END IF
  681. *
  682. ELSE IF( ITYPE.EQ.10 ) THEN
  683. *
  684. * Triangular, random eigenvalues
  685. *
  686. CALL SLATMR( N, N, 'S', ISEED, 'N', WORK, 6, ONE, ONE,
  687. $ 'T', 'N', WORK( N+1 ), 1, ONE,
  688. $ WORK( 2*N+1 ), 1, ONE, 'N', IDUMMA, N, 0,
  689. $ ZERO, ANORM, 'NO', A, LDA, IWORK, IINFO )
  690. *
  691. ELSE
  692. *
  693. IINFO = 1
  694. END IF
  695. *
  696. IF( IINFO.NE.0 ) THEN
  697. WRITE( NOUNIT, FMT = 9992 )'Generator', IINFO, N, JTYPE,
  698. $ IOLDSD
  699. INFO = ABS( IINFO )
  700. RETURN
  701. END IF
  702. *
  703. 90 CONTINUE
  704. *
  705. * Test for minimal and generous workspace
  706. *
  707. DO 250 IWK = 1, 2
  708. IF( IWK.EQ.1 ) THEN
  709. NNWORK = 3*N
  710. ELSE
  711. NNWORK = 5*N + 2*N**2
  712. END IF
  713. NNWORK = MAX( NNWORK, 1 )
  714. *
  715. * Initialize RESULT
  716. *
  717. DO 100 J = 1, 13
  718. RESULT( J ) = -ONE
  719. 100 CONTINUE
  720. *
  721. * Test with and without sorting of eigenvalues
  722. *
  723. DO 210 ISORT = 0, 1
  724. IF( ISORT.EQ.0 ) THEN
  725. SORT = 'N'
  726. RSUB = 0
  727. ELSE
  728. SORT = 'S'
  729. RSUB = 6
  730. END IF
  731. *
  732. * Compute Schur form and Schur vectors, and test them
  733. *
  734. CALL SLACPY( 'F', N, N, A, LDA, H, LDA )
  735. CALL SGEES( 'V', SORT, SSLECT, N, H, LDA, SDIM, WR,
  736. $ WI, VS, LDVS, WORK, NNWORK, BWORK, IINFO )
  737. IF( IINFO.NE.0 .AND. IINFO.NE.N+2 ) THEN
  738. RESULT( 1+RSUB ) = ULPINV
  739. WRITE( NOUNIT, FMT = 9992 )'SGEES1', IINFO, N,
  740. $ JTYPE, IOLDSD
  741. INFO = ABS( IINFO )
  742. GO TO 220
  743. END IF
  744. *
  745. * Do Test (1) or Test (7)
  746. *
  747. RESULT( 1+RSUB ) = ZERO
  748. DO 120 J = 1, N - 2
  749. DO 110 I = J + 2, N
  750. IF( H( I, J ).NE.ZERO )
  751. $ RESULT( 1+RSUB ) = ULPINV
  752. 110 CONTINUE
  753. 120 CONTINUE
  754. DO 130 I = 1, N - 2
  755. IF( H( I+1, I ).NE.ZERO .AND. H( I+2, I+1 ).NE.
  756. $ ZERO )RESULT( 1+RSUB ) = ULPINV
  757. 130 CONTINUE
  758. DO 140 I = 1, N - 1
  759. IF( H( I+1, I ).NE.ZERO ) THEN
  760. IF( H( I, I ).NE.H( I+1, I+1 ) .OR.
  761. $ H( I, I+1 ).EQ.ZERO .OR.
  762. $ SIGN( ONE, H( I+1, I ) ).EQ.
  763. $ SIGN( ONE, H( I, I+1 ) ) )RESULT( 1+RSUB )
  764. $ = ULPINV
  765. END IF
  766. 140 CONTINUE
  767. *
  768. * Do Tests (2) and (3) or Tests (8) and (9)
  769. *
  770. LWORK = MAX( 1, 2*N*N )
  771. CALL SHST01( N, 1, N, A, LDA, H, LDA, VS, LDVS, WORK,
  772. $ LWORK, RES )
  773. RESULT( 2+RSUB ) = RES( 1 )
  774. RESULT( 3+RSUB ) = RES( 2 )
  775. *
  776. * Do Test (4) or Test (10)
  777. *
  778. RESULT( 4+RSUB ) = ZERO
  779. DO 150 I = 1, N
  780. IF( H( I, I ).NE.WR( I ) )
  781. $ RESULT( 4+RSUB ) = ULPINV
  782. 150 CONTINUE
  783. IF( N.GT.1 ) THEN
  784. IF( H( 2, 1 ).EQ.ZERO .AND. WI( 1 ).NE.ZERO )
  785. $ RESULT( 4+RSUB ) = ULPINV
  786. IF( H( N, N-1 ).EQ.ZERO .AND. WI( N ).NE.ZERO )
  787. $ RESULT( 4+RSUB ) = ULPINV
  788. END IF
  789. DO 160 I = 1, N - 1
  790. IF( H( I+1, I ).NE.ZERO ) THEN
  791. TMP = SQRT( ABS( H( I+1, I ) ) )*
  792. $ SQRT( ABS( H( I, I+1 ) ) )
  793. RESULT( 4+RSUB ) = MAX( RESULT( 4+RSUB ),
  794. $ ABS( WI( I )-TMP ) /
  795. $ MAX( ULP*TMP, UNFL ) )
  796. RESULT( 4+RSUB ) = MAX( RESULT( 4+RSUB ),
  797. $ ABS( WI( I+1 )+TMP ) /
  798. $ MAX( ULP*TMP, UNFL ) )
  799. ELSE IF( I.GT.1 ) THEN
  800. IF( H( I+1, I ).EQ.ZERO .AND. H( I, I-1 ).EQ.
  801. $ ZERO .AND. WI( I ).NE.ZERO )RESULT( 4+RSUB )
  802. $ = ULPINV
  803. END IF
  804. 160 CONTINUE
  805. *
  806. * Do Test (5) or Test (11)
  807. *
  808. CALL SLACPY( 'F', N, N, A, LDA, HT, LDA )
  809. CALL SGEES( 'N', SORT, SSLECT, N, HT, LDA, SDIM, WRT,
  810. $ WIT, VS, LDVS, WORK, NNWORK, BWORK,
  811. $ IINFO )
  812. IF( IINFO.NE.0 .AND. IINFO.NE.N+2 ) THEN
  813. RESULT( 5+RSUB ) = ULPINV
  814. WRITE( NOUNIT, FMT = 9992 )'SGEES2', IINFO, N,
  815. $ JTYPE, IOLDSD
  816. INFO = ABS( IINFO )
  817. GO TO 220
  818. END IF
  819. *
  820. RESULT( 5+RSUB ) = ZERO
  821. DO 180 J = 1, N
  822. DO 170 I = 1, N
  823. IF( H( I, J ).NE.HT( I, J ) )
  824. $ RESULT( 5+RSUB ) = ULPINV
  825. 170 CONTINUE
  826. 180 CONTINUE
  827. *
  828. * Do Test (6) or Test (12)
  829. *
  830. RESULT( 6+RSUB ) = ZERO
  831. DO 190 I = 1, N
  832. IF( WR( I ).NE.WRT( I ) .OR. WI( I ).NE.WIT( I ) )
  833. $ RESULT( 6+RSUB ) = ULPINV
  834. 190 CONTINUE
  835. *
  836. * Do Test (13)
  837. *
  838. IF( ISORT.EQ.1 ) THEN
  839. RESULT( 13 ) = ZERO
  840. KNTEIG = 0
  841. DO 200 I = 1, N
  842. IF( SSLECT( WR( I ), WI( I ) ) .OR.
  843. $ SSLECT( WR( I ), -WI( I ) ) )
  844. $ KNTEIG = KNTEIG + 1
  845. IF( I.LT.N ) THEN
  846. IF( ( SSLECT( WR( I+1 ),
  847. $ WI( I+1 ) ) .OR. SSLECT( WR( I+1 ),
  848. $ -WI( I+1 ) ) ) .AND.
  849. $ ( .NOT.( SSLECT( WR( I ),
  850. $ WI( I ) ) .OR. SSLECT( WR( I ),
  851. $ -WI( I ) ) ) ) .AND. IINFO.NE.N+2 )
  852. $ RESULT( 13 ) = ULPINV
  853. END IF
  854. 200 CONTINUE
  855. IF( SDIM.NE.KNTEIG ) THEN
  856. RESULT( 13 ) = ULPINV
  857. END IF
  858. END IF
  859. *
  860. 210 CONTINUE
  861. *
  862. * End of Loop -- Check for RESULT(j) > THRESH
  863. *
  864. 220 CONTINUE
  865. *
  866. NTEST = 0
  867. NFAIL = 0
  868. DO 230 J = 1, 13
  869. IF( RESULT( J ).GE.ZERO )
  870. $ NTEST = NTEST + 1
  871. IF( RESULT( J ).GE.THRESH )
  872. $ NFAIL = NFAIL + 1
  873. 230 CONTINUE
  874. *
  875. IF( NFAIL.GT.0 )
  876. $ NTESTF = NTESTF + 1
  877. IF( NTESTF.EQ.1 ) THEN
  878. WRITE( NOUNIT, FMT = 9999 )PATH
  879. WRITE( NOUNIT, FMT = 9998 )
  880. WRITE( NOUNIT, FMT = 9997 )
  881. WRITE( NOUNIT, FMT = 9996 )
  882. WRITE( NOUNIT, FMT = 9995 )THRESH
  883. WRITE( NOUNIT, FMT = 9994 )
  884. NTESTF = 2
  885. END IF
  886. *
  887. DO 240 J = 1, 13
  888. IF( RESULT( J ).GE.THRESH ) THEN
  889. WRITE( NOUNIT, FMT = 9993 )N, IWK, IOLDSD, JTYPE,
  890. $ J, RESULT( J )
  891. END IF
  892. 240 CONTINUE
  893. *
  894. NERRS = NERRS + NFAIL
  895. NTESTT = NTESTT + NTEST
  896. *
  897. 250 CONTINUE
  898. 260 CONTINUE
  899. 270 CONTINUE
  900. *
  901. * Summary
  902. *
  903. CALL SLASUM( PATH, NOUNIT, NERRS, NTESTT )
  904. *
  905. 9999 FORMAT( / 1X, A3, ' -- Real Schur Form Decomposition Driver',
  906. $ / ' Matrix types (see SDRVES for details): ' )
  907. *
  908. 9998 FORMAT( / ' Special Matrices:', / ' 1=Zero matrix. ',
  909. $ ' ', ' 5=Diagonal: geometr. spaced entries.',
  910. $ / ' 2=Identity matrix. ', ' 6=Diagona',
  911. $ 'l: clustered entries.', / ' 3=Transposed Jordan block. ',
  912. $ ' ', ' 7=Diagonal: large, evenly spaced.', / ' ',
  913. $ '4=Diagonal: evenly spaced entries. ', ' 8=Diagonal: s',
  914. $ 'mall, evenly spaced.' )
  915. 9997 FORMAT( ' Dense, Non-Symmetric Matrices:', / ' 9=Well-cond., ev',
  916. $ 'enly spaced eigenvals.', ' 14=Ill-cond., geomet. spaced e',
  917. $ 'igenals.', / ' 10=Well-cond., geom. spaced eigenvals. ',
  918. $ ' 15=Ill-conditioned, clustered e.vals.', / ' 11=Well-cond',
  919. $ 'itioned, clustered e.vals. ', ' 16=Ill-cond., random comp',
  920. $ 'lex ', / ' 12=Well-cond., random complex ', 6X, ' ',
  921. $ ' 17=Ill-cond., large rand. complx ', / ' 13=Ill-condi',
  922. $ 'tioned, evenly spaced. ', ' 18=Ill-cond., small rand.',
  923. $ ' complx ' )
  924. 9996 FORMAT( ' 19=Matrix with random O(1) entries. ', ' 21=Matrix ',
  925. $ 'with small random entries.', / ' 20=Matrix with large ran',
  926. $ 'dom entries. ', / )
  927. 9995 FORMAT( ' Tests performed with test threshold =', F8.2,
  928. $ / ' ( A denotes A on input and T denotes A on output)',
  929. $ / / ' 1 = 0 if T in Schur form (no sort), ',
  930. $ ' 1/ulp otherwise', /
  931. $ ' 2 = | A - VS T transpose(VS) | / ( n |A| ulp ) (no sort)',
  932. $ / ' 3 = | I - VS transpose(VS) | / ( n ulp ) (no sort) ', /
  933. $ ' 4 = 0 if WR+sqrt(-1)*WI are eigenvalues of T (no sort),',
  934. $ ' 1/ulp otherwise', /
  935. $ ' 5 = 0 if T same no matter if VS computed (no sort),',
  936. $ ' 1/ulp otherwise', /
  937. $ ' 6 = 0 if WR, WI same no matter if VS computed (no sort)',
  938. $ ', 1/ulp otherwise' )
  939. 9994 FORMAT( ' 7 = 0 if T in Schur form (sort), ', ' 1/ulp otherwise',
  940. $ / ' 8 = | A - VS T transpose(VS) | / ( n |A| ulp ) (sort)',
  941. $ / ' 9 = | I - VS transpose(VS) | / ( n ulp ) (sort) ',
  942. $ / ' 10 = 0 if WR+sqrt(-1)*WI are eigenvalues of T (sort),',
  943. $ ' 1/ulp otherwise', /
  944. $ ' 11 = 0 if T same no matter if VS computed (sort),',
  945. $ ' 1/ulp otherwise', /
  946. $ ' 12 = 0 if WR, WI same no matter if VS computed (sort),',
  947. $ ' 1/ulp otherwise', /
  948. $ ' 13 = 0 if sorting successful, 1/ulp otherwise', / )
  949. 9993 FORMAT( ' N=', I5, ', IWK=', I2, ', seed=', 4( I4, ',' ),
  950. $ ' type ', I2, ', test(', I2, ')=', G10.3 )
  951. 9992 FORMAT( ' SDRVES: ', A, ' returned INFO=', I6, '.', / 9X, 'N=',
  952. $ I6, ', JTYPE=', I6, ', ISEED=(', 3( I5, ',' ), I5, ')' )
  953. *
  954. RETURN
  955. *
  956. * End of SDRVES
  957. *
  958. END