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.

dlaed3.f 9.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. *> \brief \b DLAED3 used by DSTEDC. Finds the roots of the secular equation and updates the eigenvectors. Used when the original matrix is tridiagonal.
  2. *
  3. * =========== DOCUMENTATION ===========
  4. *
  5. * Online html documentation available at
  6. * http://www.netlib.org/lapack/explore-html/
  7. *
  8. *> \htmlonly
  9. *> Download DLAED3 + dependencies
  10. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlaed3.f">
  11. *> [TGZ]</a>
  12. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlaed3.f">
  13. *> [ZIP]</a>
  14. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlaed3.f">
  15. *> [TXT]</a>
  16. *> \endhtmlonly
  17. *
  18. * Definition:
  19. * ===========
  20. *
  21. * SUBROUTINE DLAED3( K, N, N1, D, Q, LDQ, RHO, DLAMBDA, Q2, INDX,
  22. * CTOT, W, S, INFO )
  23. *
  24. * .. Scalar Arguments ..
  25. * INTEGER INFO, K, LDQ, N, N1
  26. * DOUBLE PRECISION RHO
  27. * ..
  28. * .. Array Arguments ..
  29. * INTEGER CTOT( * ), INDX( * )
  30. * DOUBLE PRECISION D( * ), DLAMBDA( * ), Q( LDQ, * ), Q2( * ),
  31. * $ S( * ), W( * )
  32. * ..
  33. *
  34. *
  35. *> \par Purpose:
  36. * =============
  37. *>
  38. *> \verbatim
  39. *>
  40. *> DLAED3 finds the roots of the secular equation, as defined by the
  41. *> values in D, W, and RHO, between 1 and K. It makes the
  42. *> appropriate calls to DLAED4 and then updates the eigenvectors by
  43. *> multiplying the matrix of eigenvectors of the pair of eigensystems
  44. *> being combined by the matrix of eigenvectors of the K-by-K system
  45. *> which is solved here.
  46. *>
  47. *> \endverbatim
  48. *
  49. * Arguments:
  50. * ==========
  51. *
  52. *> \param[in] K
  53. *> \verbatim
  54. *> K is INTEGER
  55. *> The number of terms in the rational function to be solved by
  56. *> DLAED4. K >= 0.
  57. *> \endverbatim
  58. *>
  59. *> \param[in] N
  60. *> \verbatim
  61. *> N is INTEGER
  62. *> The number of rows and columns in the Q matrix.
  63. *> N >= K (deflation may result in N>K).
  64. *> \endverbatim
  65. *>
  66. *> \param[in] N1
  67. *> \verbatim
  68. *> N1 is INTEGER
  69. *> The location of the last eigenvalue in the leading submatrix.
  70. *> min(1,N) <= N1 <= N/2.
  71. *> \endverbatim
  72. *>
  73. *> \param[out] D
  74. *> \verbatim
  75. *> D is DOUBLE PRECISION array, dimension (N)
  76. *> D(I) contains the updated eigenvalues for
  77. *> 1 <= I <= K.
  78. *> \endverbatim
  79. *>
  80. *> \param[out] Q
  81. *> \verbatim
  82. *> Q is DOUBLE PRECISION array, dimension (LDQ,N)
  83. *> Initially the first K columns are used as workspace.
  84. *> On output the columns 1 to K contain
  85. *> the updated eigenvectors.
  86. *> \endverbatim
  87. *>
  88. *> \param[in] LDQ
  89. *> \verbatim
  90. *> LDQ is INTEGER
  91. *> The leading dimension of the array Q. LDQ >= max(1,N).
  92. *> \endverbatim
  93. *>
  94. *> \param[in] RHO
  95. *> \verbatim
  96. *> RHO is DOUBLE PRECISION
  97. *> The value of the parameter in the rank one update equation.
  98. *> RHO >= 0 required.
  99. *> \endverbatim
  100. *>
  101. *> \param[in] DLAMBDA
  102. *> \verbatim
  103. *> DLAMBDA is DOUBLE PRECISION array, dimension (K)
  104. *> The first K elements of this array contain the old roots
  105. *> of the deflated updating problem. These are the poles
  106. *> of the secular equation.
  107. *> \endverbatim
  108. *>
  109. *> \param[in] Q2
  110. *> \verbatim
  111. *> Q2 is DOUBLE PRECISION array, dimension (LDQ2*N)
  112. *> The first K columns of this matrix contain the non-deflated
  113. *> eigenvectors for the split problem.
  114. *> \endverbatim
  115. *>
  116. *> \param[in] INDX
  117. *> \verbatim
  118. *> INDX is INTEGER array, dimension (N)
  119. *> The permutation used to arrange the columns of the deflated
  120. *> Q matrix into three groups (see DLAED2).
  121. *> The rows of the eigenvectors found by DLAED4 must be likewise
  122. *> permuted before the matrix multiply can take place.
  123. *> \endverbatim
  124. *>
  125. *> \param[in] CTOT
  126. *> \verbatim
  127. *> CTOT is INTEGER array, dimension (4)
  128. *> A count of the total number of the various types of columns
  129. *> in Q, as described in INDX. The fourth column type is any
  130. *> column which has been deflated.
  131. *> \endverbatim
  132. *>
  133. *> \param[in,out] W
  134. *> \verbatim
  135. *> W is DOUBLE PRECISION array, dimension (K)
  136. *> The first K elements of this array contain the components
  137. *> of the deflation-adjusted updating vector. Destroyed on
  138. *> output.
  139. *> \endverbatim
  140. *>
  141. *> \param[out] S
  142. *> \verbatim
  143. *> S is DOUBLE PRECISION array, dimension (N1 + 1)*K
  144. *> Will contain the eigenvectors of the repaired matrix which
  145. *> will be multiplied by the previously accumulated eigenvectors
  146. *> to update the system.
  147. *> \endverbatim
  148. *>
  149. *> \param[out] INFO
  150. *> \verbatim
  151. *> INFO is INTEGER
  152. *> = 0: successful exit.
  153. *> < 0: if INFO = -i, the i-th argument had an illegal value.
  154. *> > 0: if INFO = 1, an eigenvalue did not converge
  155. *> \endverbatim
  156. *
  157. * Authors:
  158. * ========
  159. *
  160. *> \author Univ. of Tennessee
  161. *> \author Univ. of California Berkeley
  162. *> \author Univ. of Colorado Denver
  163. *> \author NAG Ltd.
  164. *
  165. *> \ingroup auxOTHERcomputational
  166. *
  167. *> \par Contributors:
  168. * ==================
  169. *>
  170. *> Jeff Rutter, Computer Science Division, University of California
  171. *> at Berkeley, USA \n
  172. *> Modified by Francoise Tisseur, University of Tennessee
  173. *>
  174. * =====================================================================
  175. SUBROUTINE DLAED3( K, N, N1, D, Q, LDQ, RHO, DLAMBDA, Q2, INDX,
  176. $ CTOT, W, S, INFO )
  177. *
  178. * -- LAPACK computational routine --
  179. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  180. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  181. *
  182. * .. Scalar Arguments ..
  183. INTEGER INFO, K, LDQ, N, N1
  184. DOUBLE PRECISION RHO
  185. * ..
  186. * .. Array Arguments ..
  187. INTEGER CTOT( * ), INDX( * )
  188. DOUBLE PRECISION D( * ), DLAMBDA( * ), Q( LDQ, * ), Q2( * ),
  189. $ S( * ), W( * )
  190. * ..
  191. *
  192. * =====================================================================
  193. *
  194. * .. Parameters ..
  195. DOUBLE PRECISION ONE, ZERO
  196. PARAMETER ( ONE = 1.0D0, ZERO = 0.0D0 )
  197. * ..
  198. * .. Local Scalars ..
  199. INTEGER I, II, IQ2, J, N12, N2, N23
  200. DOUBLE PRECISION TEMP
  201. * ..
  202. * .. External Functions ..
  203. DOUBLE PRECISION DNRM2
  204. EXTERNAL DNRM2
  205. * ..
  206. * .. External Subroutines ..
  207. EXTERNAL DCOPY, DGEMM, DLACPY, DLAED4, DLASET, XERBLA
  208. * ..
  209. * .. Intrinsic Functions ..
  210. INTRINSIC MAX, SIGN, SQRT
  211. * ..
  212. * .. Executable Statements ..
  213. *
  214. * Test the input parameters.
  215. *
  216. INFO = 0
  217. *
  218. IF( K.LT.0 ) THEN
  219. INFO = -1
  220. ELSE IF( N.LT.K ) THEN
  221. INFO = -2
  222. ELSE IF( LDQ.LT.MAX( 1, N ) ) THEN
  223. INFO = -6
  224. END IF
  225. IF( INFO.NE.0 ) THEN
  226. CALL XERBLA( 'DLAED3', -INFO )
  227. RETURN
  228. END IF
  229. *
  230. * Quick return if possible
  231. *
  232. IF( K.EQ.0 )
  233. $ RETURN
  234. *
  235. *
  236. DO 20 J = 1, K
  237. CALL DLAED4( K, J, DLAMBDA, W, Q( 1, J ), RHO, D( J ), INFO )
  238. *
  239. * If the zero finder fails, the computation is terminated.
  240. *
  241. IF( INFO.NE.0 )
  242. $ GO TO 120
  243. 20 CONTINUE
  244. *
  245. IF( K.EQ.1 )
  246. $ GO TO 110
  247. IF( K.EQ.2 ) THEN
  248. DO 30 J = 1, K
  249. W( 1 ) = Q( 1, J )
  250. W( 2 ) = Q( 2, J )
  251. II = INDX( 1 )
  252. Q( 1, J ) = W( II )
  253. II = INDX( 2 )
  254. Q( 2, J ) = W( II )
  255. 30 CONTINUE
  256. GO TO 110
  257. END IF
  258. *
  259. * Compute updated W.
  260. *
  261. CALL DCOPY( K, W, 1, S, 1 )
  262. *
  263. * Initialize W(I) = Q(I,I)
  264. *
  265. CALL DCOPY( K, Q, LDQ+1, W, 1 )
  266. DO 60 J = 1, K
  267. DO 40 I = 1, J - 1
  268. W( I ) = W( I )*( Q( I, J )/( DLAMBDA( I )-DLAMBDA( J ) ) )
  269. 40 CONTINUE
  270. DO 50 I = J + 1, K
  271. W( I ) = W( I )*( Q( I, J )/( DLAMBDA( I )-DLAMBDA( J ) ) )
  272. 50 CONTINUE
  273. 60 CONTINUE
  274. DO 70 I = 1, K
  275. W( I ) = SIGN( SQRT( -W( I ) ), S( I ) )
  276. 70 CONTINUE
  277. *
  278. * Compute eigenvectors of the modified rank-1 modification.
  279. *
  280. DO 100 J = 1, K
  281. DO 80 I = 1, K
  282. S( I ) = W( I ) / Q( I, J )
  283. 80 CONTINUE
  284. TEMP = DNRM2( K, S, 1 )
  285. DO 90 I = 1, K
  286. II = INDX( I )
  287. Q( I, J ) = S( II ) / TEMP
  288. 90 CONTINUE
  289. 100 CONTINUE
  290. *
  291. * Compute the updated eigenvectors.
  292. *
  293. 110 CONTINUE
  294. *
  295. N2 = N - N1
  296. N12 = CTOT( 1 ) + CTOT( 2 )
  297. N23 = CTOT( 2 ) + CTOT( 3 )
  298. *
  299. CALL DLACPY( 'A', N23, K, Q( CTOT( 1 )+1, 1 ), LDQ, S, N23 )
  300. IQ2 = N1*N12 + 1
  301. IF( N23.NE.0 ) THEN
  302. CALL DGEMM( 'N', 'N', N2, K, N23, ONE, Q2( IQ2 ), N2, S, N23,
  303. $ ZERO, Q( N1+1, 1 ), LDQ )
  304. ELSE
  305. CALL DLASET( 'A', N2, K, ZERO, ZERO, Q( N1+1, 1 ), LDQ )
  306. END IF
  307. *
  308. CALL DLACPY( 'A', N12, K, Q, LDQ, S, N12 )
  309. IF( N12.NE.0 ) THEN
  310. CALL DGEMM( 'N', 'N', N1, K, N12, ONE, Q2, N1, S, N12, ZERO, Q,
  311. $ LDQ )
  312. ELSE
  313. CALL DLASET( 'A', N1, K, ZERO, ZERO, Q( 1, 1 ), LDQ )
  314. END IF
  315. *
  316. *
  317. 120 CONTINUE
  318. RETURN
  319. *
  320. * End of DLAED3
  321. *
  322. END