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.

clatm6.f 8.8 kB

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