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.

dlatm6.f 9.7 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. *> \brief \b DLATM6
  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 DLATM6( TYPE, N, A, LDA, B, X, LDX, Y, LDY, ALPHA,
  12. * BETA, WX, WY, S, DIF )
  13. *
  14. * .. Scalar Arguments ..
  15. * INTEGER LDA, LDX, LDY, N, TYPE
  16. * DOUBLE PRECISION ALPHA, BETA, WX, WY
  17. * ..
  18. * .. Array Arguments ..
  19. * DOUBLE PRECISION A( LDA, * ), B( LDA, * ), DIF( * ), S( * ),
  20. * $ X( LDX, * ), Y( LDY, * )
  21. * ..
  22. *
  23. *
  24. *> \par Purpose:
  25. * =============
  26. *>
  27. *> \verbatim
  28. *>
  29. *> DLATM6 generates test matrices for the generalized eigenvalue
  30. *> problem, their corresponding right and left eigenvector matrices,
  31. *> and also reciprocal condition numbers for all eigenvalues and
  32. *> the reciprocal condition numbers of eigenvectors corresponding to
  33. *> the 1th and 5th eigenvalues.
  34. *>
  35. *> Test Matrices
  36. *> =============
  37. *>
  38. *> Two kinds of test matrix pairs
  39. *>
  40. *> (A, B) = inverse(YH) * (Da, Db) * inverse(X)
  41. *>
  42. *> are used in the tests:
  43. *>
  44. *> Type 1:
  45. *> Da = 1+a 0 0 0 0 Db = 1 0 0 0 0
  46. *> 0 2+a 0 0 0 0 1 0 0 0
  47. *> 0 0 3+a 0 0 0 0 1 0 0
  48. *> 0 0 0 4+a 0 0 0 0 1 0
  49. *> 0 0 0 0 5+a , 0 0 0 0 1 , and
  50. *>
  51. *> Type 2:
  52. *> Da = 1 -1 0 0 0 Db = 1 0 0 0 0
  53. *> 1 1 0 0 0 0 1 0 0 0
  54. *> 0 0 1 0 0 0 0 1 0 0
  55. *> 0 0 0 1+a 1+b 0 0 0 1 0
  56. *> 0 0 0 -1-b 1+a , 0 0 0 0 1 .
  57. *>
  58. *> In both cases the same inverse(YH) and inverse(X) are used to compute
  59. *> (A, B), giving the exact eigenvectors to (A,B) as (YH, X):
  60. *>
  61. *> YH: = 1 0 -y y -y X = 1 0 -x -x x
  62. *> 0 1 -y y -y 0 1 x -x -x
  63. *> 0 0 1 0 0 0 0 1 0 0
  64. *> 0 0 0 1 0 0 0 0 1 0
  65. *> 0 0 0 0 1, 0 0 0 0 1 ,
  66. *>
  67. *> where a, b, x and y will have all values independently of each other.
  68. *> \endverbatim
  69. *
  70. * Arguments:
  71. * ==========
  72. *
  73. *> \param[in] TYPE
  74. *> \verbatim
  75. *> TYPE is INTEGER
  76. *> Specifies the problem type (see futher details).
  77. *> \endverbatim
  78. *>
  79. *> \param[in] N
  80. *> \verbatim
  81. *> N is INTEGER
  82. *> Size of the matrices A and B.
  83. *> \endverbatim
  84. *>
  85. *> \param[out] A
  86. *> \verbatim
  87. *> A is DOUBLE PRECISION array, dimension (LDA, N).
  88. *> On exit A N-by-N is initialized according to TYPE.
  89. *> \endverbatim
  90. *>
  91. *> \param[in] LDA
  92. *> \verbatim
  93. *> LDA is INTEGER
  94. *> The leading dimension of A and of B.
  95. *> \endverbatim
  96. *>
  97. *> \param[out] B
  98. *> \verbatim
  99. *> B is DOUBLE PRECISION array, dimension (LDA, N).
  100. *> On exit B N-by-N is initialized according to TYPE.
  101. *> \endverbatim
  102. *>
  103. *> \param[out] X
  104. *> \verbatim
  105. *> X is DOUBLE PRECISION array, dimension (LDX, N).
  106. *> On exit X is the N-by-N matrix of right eigenvectors.
  107. *> \endverbatim
  108. *>
  109. *> \param[in] LDX
  110. *> \verbatim
  111. *> LDX is INTEGER
  112. *> The leading dimension of X.
  113. *> \endverbatim
  114. *>
  115. *> \param[out] Y
  116. *> \verbatim
  117. *> Y is DOUBLE PRECISION array, dimension (LDY, N).
  118. *> On exit Y is the N-by-N matrix of left eigenvectors.
  119. *> \endverbatim
  120. *>
  121. *> \param[in] LDY
  122. *> \verbatim
  123. *> LDY is INTEGER
  124. *> The leading dimension of Y.
  125. *> \endverbatim
  126. *>
  127. *> \param[in] ALPHA
  128. *> \verbatim
  129. *> ALPHA is DOUBLE PRECISION
  130. *> \endverbatim
  131. *>
  132. *> \param[in] BETA
  133. *> \verbatim
  134. *> BETA is DOUBLE PRECISION
  135. *>
  136. *> Weighting constants for matrix A.
  137. *> \endverbatim
  138. *>
  139. *> \param[in] WX
  140. *> \verbatim
  141. *> WX is DOUBLE PRECISION
  142. *> Constant for right eigenvector matrix.
  143. *> \endverbatim
  144. *>
  145. *> \param[in] WY
  146. *> \verbatim
  147. *> WY is DOUBLE PRECISION
  148. *> Constant for left eigenvector matrix.
  149. *> \endverbatim
  150. *>
  151. *> \param[out] S
  152. *> \verbatim
  153. *> S is DOUBLE PRECISION array, dimension (N)
  154. *> S(i) is the reciprocal condition number for eigenvalue i.
  155. *> \endverbatim
  156. *>
  157. *> \param[out] DIF
  158. *> \verbatim
  159. *> DIF is DOUBLE PRECISION array, dimension (N)
  160. *> DIF(i) is the reciprocal condition number for eigenvector i.
  161. *> \endverbatim
  162. *
  163. * Authors:
  164. * ========
  165. *
  166. *> \author Univ. of Tennessee
  167. *> \author Univ. of California Berkeley
  168. *> \author Univ. of Colorado Denver
  169. *> \author NAG Ltd.
  170. *
  171. *> \date November 2011
  172. *
  173. *> \ingroup double_matgen
  174. *
  175. * =====================================================================
  176. SUBROUTINE DLATM6( TYPE, N, A, LDA, B, X, LDX, Y, LDY, ALPHA,
  177. $ BETA, WX, WY, S, DIF )
  178. *
  179. * -- LAPACK computational routine (version 3.4.0) --
  180. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  181. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  182. * November 2011
  183. *
  184. * .. Scalar Arguments ..
  185. INTEGER LDA, LDX, LDY, N, TYPE
  186. DOUBLE PRECISION ALPHA, BETA, WX, WY
  187. * ..
  188. * .. Array Arguments ..
  189. DOUBLE PRECISION A( LDA, * ), B( LDA, * ), DIF( * ), S( * ),
  190. $ X( LDX, * ), Y( LDY, * )
  191. * ..
  192. *
  193. * =====================================================================
  194. *
  195. * .. Parameters ..
  196. DOUBLE PRECISION ZERO, ONE, TWO, THREE
  197. PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0, TWO = 2.0D+0,
  198. $ THREE = 3.0D+0 )
  199. * ..
  200. * .. Local Scalars ..
  201. INTEGER I, INFO, J
  202. * ..
  203. * .. Local Arrays ..
  204. DOUBLE PRECISION WORK( 100 ), Z( 12, 12 )
  205. * ..
  206. * .. Intrinsic Functions ..
  207. INTRINSIC DBLE, SQRT
  208. * ..
  209. * .. External Subroutines ..
  210. EXTERNAL DGESVD, DLACPY, DLAKF2
  211. * ..
  212. * .. Executable Statements ..
  213. *
  214. * Generate test problem ...
  215. * (Da, Db) ...
  216. *
  217. DO 20 I = 1, N
  218. DO 10 J = 1, N
  219. *
  220. IF( I.EQ.J ) THEN
  221. A( I, I ) = DBLE( I ) + ALPHA
  222. B( I, I ) = ONE
  223. ELSE
  224. A( I, J ) = ZERO
  225. B( I, J ) = ZERO
  226. END IF
  227. *
  228. 10 CONTINUE
  229. 20 CONTINUE
  230. *
  231. * Form X and Y
  232. *
  233. CALL DLACPY( 'F', N, N, B, LDA, Y, LDY )
  234. Y( 3, 1 ) = -WY
  235. Y( 4, 1 ) = WY
  236. Y( 5, 1 ) = -WY
  237. Y( 3, 2 ) = -WY
  238. Y( 4, 2 ) = WY
  239. Y( 5, 2 ) = -WY
  240. *
  241. CALL DLACPY( 'F', N, N, B, LDA, X, LDX )
  242. X( 1, 3 ) = -WX
  243. X( 1, 4 ) = -WX
  244. X( 1, 5 ) = WX
  245. X( 2, 3 ) = WX
  246. X( 2, 4 ) = -WX
  247. X( 2, 5 ) = -WX
  248. *
  249. * Form (A, B)
  250. *
  251. B( 1, 3 ) = WX + WY
  252. B( 2, 3 ) = -WX + WY
  253. B( 1, 4 ) = WX - WY
  254. B( 2, 4 ) = WX - WY
  255. B( 1, 5 ) = -WX + WY
  256. B( 2, 5 ) = WX + WY
  257. IF( TYPE.EQ.1 ) THEN
  258. A( 1, 3 ) = WX*A( 1, 1 ) + WY*A( 3, 3 )
  259. A( 2, 3 ) = -WX*A( 2, 2 ) + WY*A( 3, 3 )
  260. A( 1, 4 ) = WX*A( 1, 1 ) - WY*A( 4, 4 )
  261. A( 2, 4 ) = WX*A( 2, 2 ) - WY*A( 4, 4 )
  262. A( 1, 5 ) = -WX*A( 1, 1 ) + WY*A( 5, 5 )
  263. A( 2, 5 ) = WX*A( 2, 2 ) + WY*A( 5, 5 )
  264. ELSE IF( TYPE.EQ.2 ) THEN
  265. A( 1, 3 ) = TWO*WX + WY
  266. A( 2, 3 ) = WY
  267. A( 1, 4 ) = -WY*( TWO+ALPHA+BETA )
  268. A( 2, 4 ) = TWO*WX - WY*( TWO+ALPHA+BETA )
  269. A( 1, 5 ) = -TWO*WX + WY*( ALPHA-BETA )
  270. A( 2, 5 ) = WY*( ALPHA-BETA )
  271. A( 1, 1 ) = ONE
  272. A( 1, 2 ) = -ONE
  273. A( 2, 1 ) = ONE
  274. A( 2, 2 ) = A( 1, 1 )
  275. A( 3, 3 ) = ONE
  276. A( 4, 4 ) = ONE + ALPHA
  277. A( 4, 5 ) = ONE + BETA
  278. A( 5, 4 ) = -A( 4, 5 )
  279. A( 5, 5 ) = A( 4, 4 )
  280. END IF
  281. *
  282. * Compute condition numbers
  283. *
  284. IF( TYPE.EQ.1 ) THEN
  285. *
  286. S( 1 ) = ONE / SQRT( ( ONE+THREE*WY*WY ) /
  287. $ ( ONE+A( 1, 1 )*A( 1, 1 ) ) )
  288. S( 2 ) = ONE / SQRT( ( ONE+THREE*WY*WY ) /
  289. $ ( ONE+A( 2, 2 )*A( 2, 2 ) ) )
  290. S( 3 ) = ONE / SQRT( ( ONE+TWO*WX*WX ) /
  291. $ ( ONE+A( 3, 3 )*A( 3, 3 ) ) )
  292. S( 4 ) = ONE / SQRT( ( ONE+TWO*WX*WX ) /
  293. $ ( ONE+A( 4, 4 )*A( 4, 4 ) ) )
  294. S( 5 ) = ONE / SQRT( ( ONE+TWO*WX*WX ) /
  295. $ ( ONE+A( 5, 5 )*A( 5, 5 ) ) )
  296. *
  297. CALL DLAKF2( 1, 4, A, LDA, A( 2, 2 ), B, B( 2, 2 ), Z, 12 )
  298. CALL DGESVD( 'N', 'N', 8, 8, Z, 12, WORK, WORK( 9 ), 1,
  299. $ WORK( 10 ), 1, WORK( 11 ), 40, INFO )
  300. DIF( 1 ) = WORK( 8 )
  301. *
  302. CALL DLAKF2( 4, 1, A, LDA, A( 5, 5 ), B, B( 5, 5 ), Z, 12 )
  303. CALL DGESVD( 'N', 'N', 8, 8, Z, 12, WORK, WORK( 9 ), 1,
  304. $ WORK( 10 ), 1, WORK( 11 ), 40, INFO )
  305. DIF( 5 ) = WORK( 8 )
  306. *
  307. ELSE IF( TYPE.EQ.2 ) THEN
  308. *
  309. S( 1 ) = ONE / SQRT( ONE / THREE+WY*WY )
  310. S( 2 ) = S( 1 )
  311. S( 3 ) = ONE / SQRT( ONE / TWO+WX*WX )
  312. S( 4 ) = ONE / SQRT( ( ONE+TWO*WX*WX ) /
  313. $ ( ONE+( ONE+ALPHA )*( ONE+ALPHA )+( ONE+BETA )*( ONE+
  314. $ BETA ) ) )
  315. S( 5 ) = S( 4 )
  316. *
  317. CALL DLAKF2( 2, 3, A, LDA, A( 3, 3 ), B, B( 3, 3 ), Z, 12 )
  318. CALL DGESVD( 'N', 'N', 12, 12, Z, 12, WORK, WORK( 13 ), 1,
  319. $ WORK( 14 ), 1, WORK( 15 ), 60, INFO )
  320. DIF( 1 ) = WORK( 12 )
  321. *
  322. CALL DLAKF2( 3, 2, A, LDA, A( 4, 4 ), B, B( 4, 4 ), Z, 12 )
  323. CALL DGESVD( 'N', 'N', 12, 12, Z, 12, WORK, WORK( 13 ), 1,
  324. $ WORK( 14 ), 1, WORK( 15 ), 60, INFO )
  325. DIF( 5 ) = WORK( 12 )
  326. *
  327. END IF
  328. *
  329. RETURN
  330. *
  331. * End of DLATM6
  332. *
  333. END