Télécharger dsterf.eso

Retour à la liste

Numérotation des lignes :

dsterf
  1. C DSTERF SOURCE BP208322 22/09/16 21:15:06 11454
  2. *> \brief \b DSTERF
  3. *
  4. * =========== DOCUMENTATION ===========
  5. *
  6. * Online html documentation available at
  7. * http://www.netlib.org/lapack/explore-html/
  8. *
  9. *> \htmlonly
  10. *> Download DSTERF + dependencies
  11. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dsterf.f">
  12. *> [TGZ]</a>
  13. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dsterf.f">
  14. *> [ZIP]</a>
  15. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dsterf.f">
  16. *> [TXT]</a>
  17. *> \endhtmlonly
  18. *
  19. * Definition:
  20. * ===========
  21. *
  22. * SUBROUTINE DSTERF( N, D, E, INFO )
  23. *
  24. * .. Scalar Arguments ..
  25. * INTEGER INFO, N
  26. * ..
  27. * .. Array Arguments ..
  28. * REAL*8 D( * ), E( * )
  29. * ..
  30. *
  31. *
  32. *> \par Purpose:
  33. * =============
  34. *>
  35. *> \verbatim
  36. *>
  37. *> DSTERF computes all eigenvalues of a symmetric tridiagonal matrix
  38. *> using the Pal-Walker-Kahan variant of the QL or QR algorithm.
  39. *> \endverbatim
  40. *
  41. * Arguments:
  42. * ==========
  43. *
  44. *> \param[in] N
  45. *> \verbatim
  46. *> N is INTEGER
  47. *> The order of the matrix. N >= 0.
  48. *> \endverbatim
  49. *>
  50. *> \param[in,out] D
  51. *> \verbatim
  52. *> D is REAL*8 array, dimension (N)
  53. *> On entry, the n diagonal elements of the tridiagonal matrix.
  54. *> On exit, if INFO = 0, the eigenvalues in ascending order.
  55. *> \endverbatim
  56. *>
  57. *> \param[in,out] E
  58. *> \verbatim
  59. *> E is REAL*8 array, dimension (N-1)
  60. *> On entry, the (n-1) subdiagonal elements of the tridiagonal
  61. *> matrix.
  62. *> On exit, E has been destroyed.
  63. *> \endverbatim
  64. *>
  65. *> \param[out] INFO
  66. *> \verbatim
  67. *> INFO is INTEGER
  68. *> = 0: successful exit
  69. *> < 0: if INFO = -i, the i-th argument had an illegal value
  70. *> > 0: the algorithm failed to find all of the eigenvalues in
  71. *> a total of 30*N iterations; if INFO = i, then i
  72. *> elements of E have not converged to zero.
  73. *> \endverbatim
  74. *
  75. * Authors:
  76. * ========
  77. *
  78. *> \author Univ. of Tennessee
  79. *> \author Univ. of California Berkeley
  80. *> \author Univ. of Colorado Denver
  81. *> \author NAG Ltd.
  82. *
  83. *> \ingroup auxOTHERcomputational
  84. *
  85. * =====================================================================
  86. SUBROUTINE DSTERF( N, D, E, INFO )
  87. *
  88. * -- LAPACK computational routine --
  89. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  90. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  91. *
  92. * .. Scalar Arguments ..
  93. INTEGER INFO, N
  94. * ..
  95. * .. Array Arguments ..
  96. REAL*8 D( * ), E( * )
  97. * ..
  98. *
  99. * =====================================================================
  100. *
  101. * .. Parameters ..
  102. REAL*8 ZERO, ONE, TWO, THREE
  103. PARAMETER ( ZERO = 0.0D0, ONE = 1.0D0, TWO = 2.0D0,
  104. $ THREE = 3.0D0 )
  105. INTEGER MAXIT
  106. PARAMETER ( MAXIT = 30 )
  107. * ..
  108. * .. Local Scalars ..
  109. INTEGER I, ISCALE, JTOT, L, L1, LEND, LENDSV, LSV, M,
  110. $ NMAXIT
  111. REAL*8 ALPHA, ANORM, BB, C, EPS, EPS2, GAMMA, OLDC,
  112. $ OLDGAM, P, R, RT1, RT2, RTE, S, SAFMAX, SAFMIN,
  113. $ SIGMA, SSFMAX, SSFMIN, RMAX
  114. * ..
  115. * .. External Functions ..
  116. REAL*8 DLAMCH, DLANST, DLAPY2
  117. EXTERNAL DLAMCH, DLANST, DLAPY2
  118. * ..
  119. * .. External Subroutines ..
  120. EXTERNAL DLAE2, DLASCL, DLASRT, XERBLA
  121. * ..
  122. * .. Intrinsic Functions ..
  123. * INTRINSIC ABS, SIGN, SQRT
  124. * ..
  125. * .. Executable Statements ..
  126. *
  127. * Test the input parameters.
  128. *
  129. INFO = 0
  130. *
  131. * Quick return if possible
  132. *
  133. IF( N.LT.0 ) THEN
  134. INFO = -1
  135. CALL XERBLA( 'DSTERF', -INFO )
  136. RETURN
  137. END IF
  138. IF( N.LE.1 )
  139. $ RETURN
  140. *
  141. * Determine the unit roundoff for this environment.
  142. *
  143. EPS = DLAMCH( 'E' )
  144. EPS2 = EPS**2
  145. SAFMIN = DLAMCH( 'S' )
  146. SAFMAX = ONE / SAFMIN
  147. SSFMAX = SQRT( SAFMAX ) / THREE
  148. SSFMIN = SQRT( SAFMIN ) / EPS2
  149. RMAX = DLAMCH( 'O' )
  150. *
  151. * Compute the eigenvalues of the tridiagonal matrix.
  152. *
  153. NMAXIT = N*MAXIT
  154. JTOT = 0
  155. *
  156. * Determine where the matrix splits and choose QL or QR iteration
  157. * for each block, according to whether top or bottom diagonal
  158. * element is smaller.
  159. *
  160. L1 = 1
  161. *
  162. 10 CONTINUE
  163. IF( L1.GT.N )
  164. $ GO TO 170
  165. IF( L1.GT.1 )
  166. $ E( L1-1 ) = ZERO
  167. DO 20 M = L1, N - 1
  168. IF( ABS( E( M ) ).LE.( SQRT( ABS( D( M ) ) )*SQRT( ABS( D( M+
  169. $ 1 ) ) ) )*EPS ) THEN
  170. E( M ) = ZERO
  171. GO TO 30
  172. END IF
  173. 20 CONTINUE
  174. M = N
  175. *
  176. 30 CONTINUE
  177. L = L1
  178. LSV = L
  179. LEND = M
  180. LENDSV = LEND
  181. L1 = M + 1
  182. IF( LEND.EQ.L )
  183. $ GO TO 10
  184. *
  185. * Scale submatrix in rows and columns L to LEND
  186. *
  187. ANORM = DLANST( 'M', LEND-L+1, D( L ), E( L ) )
  188. ISCALE = 0
  189. IF( ANORM.EQ.ZERO )
  190. $ GO TO 10
  191. IF( (ANORM.GT.SSFMAX) ) THEN
  192. ISCALE = 1
  193. CALL DLASCL( 'G', 0, 0, ANORM, SSFMAX, LEND-L+1, 1, D( L ), N,
  194. $ INFO )
  195. CALL DLASCL( 'G', 0, 0, ANORM, SSFMAX, LEND-L, 1, E( L ), N,
  196. $ INFO )
  197. ELSE IF( ANORM.LT.SSFMIN ) THEN
  198. ISCALE = 2
  199. CALL DLASCL( 'G', 0, 0, ANORM, SSFMIN, LEND-L+1, 1, D( L ), N,
  200. $ INFO )
  201. CALL DLASCL( 'G', 0, 0, ANORM, SSFMIN, LEND-L, 1, E( L ), N,
  202. $ INFO )
  203. END IF
  204. *
  205. DO 40 I = L, LEND - 1
  206. E( I ) = E( I )**2
  207. 40 CONTINUE
  208. *
  209. * Choose between QL and QR iteration
  210. *
  211. IF( ABS( D( LEND ) ).LT.ABS( D( L ) ) ) THEN
  212. LEND = LSV
  213. L = LENDSV
  214. END IF
  215. *
  216. IF( LEND.GE.L ) THEN
  217. *
  218. * QL Iteration
  219. *
  220. * Look for small subdiagonal element.
  221. *
  222. 50 CONTINUE
  223. IF( L.NE.LEND ) THEN
  224. DO 60 M = L, LEND - 1
  225. IF( ABS( E( M ) ).LE.EPS2*ABS( D( M )*D( M+1 ) ) )
  226. $ GO TO 70
  227. 60 CONTINUE
  228. END IF
  229. M = LEND
  230. *
  231. 70 CONTINUE
  232. IF( M.LT.LEND )
  233. $ E( M ) = ZERO
  234. P = D( L )
  235. IF( M.EQ.L )
  236. $ GO TO 90
  237. *
  238. * If remaining matrix is 2 by 2, use DLAE2 to compute its
  239. * eigenvalues.
  240. *
  241. IF( M.EQ.L+1 ) THEN
  242. RTE = SQRT( E( L ) )
  243. CALL DLAE2( D( L ), RTE, D( L+1 ), RT1, RT2 )
  244. D( L ) = RT1
  245. D( L+1 ) = RT2
  246. E( L ) = ZERO
  247. L = L + 2
  248. IF( L.LE.LEND )
  249. $ GO TO 50
  250. GO TO 150
  251. END IF
  252. *
  253. IF( JTOT.EQ.NMAXIT )
  254. $ GO TO 150
  255. JTOT = JTOT + 1
  256. *
  257. * Form shift.
  258. *
  259. RTE = SQRT( E( L ) )
  260. SIGMA = ( D( L+1 )-P ) / ( TWO*RTE )
  261. R = DLAPY2( SIGMA, ONE )
  262. SIGMA = P - ( RTE / ( SIGMA+SIGN( R, SIGMA ) ) )
  263. *
  264. C = ONE
  265. S = ZERO
  266. GAMMA = D( M ) - SIGMA
  267. *
  268. * Inner loop
  269. *
  270. DO 80 I = M - 1, L, -1
  271. BB = E( I )
  272. R = P + BB
  273. IF( I.NE.M-1 )
  274. $ E( I+1 ) = S*R
  275. OLDC = C
  276. C = P / R
  277. S = BB / R
  278. OLDGAM = GAMMA
  279. ALPHA = D( I )
  280. GAMMA = C*( ALPHA-SIGMA ) - S*OLDGAM
  281. D( I+1 ) = OLDGAM + ( ALPHA-GAMMA )
  282. IF( C.NE.ZERO ) THEN
  283. P = ( GAMMA*GAMMA ) / C
  284. ELSE
  285. P = OLDC*BB
  286. END IF
  287. 80 CONTINUE
  288. *
  289. E( L ) = S*P
  290. D( L ) = SIGMA + GAMMA
  291. GO TO 50
  292. *
  293. * Eigenvalue found.
  294. *
  295. 90 CONTINUE
  296. D( L ) = P
  297. *
  298. L = L + 1
  299. IF( L.LE.LEND )
  300. $ GO TO 50
  301. GO TO 150
  302. *
  303. ELSE
  304. *
  305. * QR Iteration
  306. *
  307. * Look for small superdiagonal element.
  308. *
  309. 100 CONTINUE
  310. DO 110 M = L, LEND + 1, -1
  311. IF( ABS( E( M-1 ) ).LE.EPS2*ABS( D( M )*D( M-1 ) ) )
  312. $ GO TO 120
  313. 110 CONTINUE
  314. M = LEND
  315. *
  316. 120 CONTINUE
  317. IF( M.GT.LEND )
  318. $ E( M-1 ) = ZERO
  319. P = D( L )
  320. IF( M.EQ.L )
  321. $ GO TO 140
  322. *
  323. * If remaining matrix is 2 by 2, use DLAE2 to compute its
  324. * eigenvalues.
  325. *
  326. IF( M.EQ.L-1 ) THEN
  327. RTE = SQRT( E( L-1 ) )
  328. CALL DLAE2( D( L ), RTE, D( L-1 ), RT1, RT2 )
  329. D( L ) = RT1
  330. D( L-1 ) = RT2
  331. E( L-1 ) = ZERO
  332. L = L - 2
  333. IF( L.GE.LEND )
  334. $ GO TO 100
  335. GO TO 150
  336. END IF
  337. *
  338. IF( JTOT.EQ.NMAXIT )
  339. $ GO TO 150
  340. JTOT = JTOT + 1
  341. *
  342. * Form shift.
  343. *
  344. RTE = SQRT( E( L-1 ) )
  345. SIGMA = ( D( L-1 )-P ) / ( TWO*RTE )
  346. R = DLAPY2( SIGMA, ONE )
  347. SIGMA = P - ( RTE / ( SIGMA+SIGN( R, SIGMA ) ) )
  348. *
  349. C = ONE
  350. S = ZERO
  351. GAMMA = D( M ) - SIGMA
  352. *
  353. * Inner loop
  354. *
  355. DO 130 I = M, L - 1
  356. BB = E( I )
  357. R = P + BB
  358. IF( I.NE.M )
  359. $ E( I-1 ) = S*R
  360. OLDC = C
  361. C = P / R
  362. S = BB / R
  363. OLDGAM = GAMMA
  364. ALPHA = D( I+1 )
  365. GAMMA = C*( ALPHA-SIGMA ) - S*OLDGAM
  366. D( I ) = OLDGAM + ( ALPHA-GAMMA )
  367. IF( C.NE.ZERO ) THEN
  368. P = ( GAMMA*GAMMA ) / C
  369. ELSE
  370. P = OLDC*BB
  371. END IF
  372. 130 CONTINUE
  373. *
  374. E( L-1 ) = S*P
  375. D( L ) = SIGMA + GAMMA
  376. GO TO 100
  377. *
  378. * Eigenvalue found.
  379. *
  380. 140 CONTINUE
  381. D( L ) = P
  382. *
  383. L = L - 1
  384. IF( L.GE.LEND )
  385. $ GO TO 100
  386. GO TO 150
  387. *
  388. END IF
  389. *
  390. * Undo scaling if necessary
  391. *
  392. 150 CONTINUE
  393. IF( ISCALE.EQ.1 )
  394. $ CALL DLASCL( 'G', 0, 0, SSFMAX, ANORM, LENDSV-LSV+1, 1,
  395. $ D( LSV ), N, INFO )
  396. IF( ISCALE.EQ.2 )
  397. $ CALL DLASCL( 'G', 0, 0, SSFMIN, ANORM, LENDSV-LSV+1, 1,
  398. $ D( LSV ), N, INFO )
  399. *
  400. * Check for no convergence to an eigenvalue after a total
  401. * of N*MAXIT iterations.
  402. *
  403. IF( JTOT.LT.NMAXIT )
  404. $ GO TO 10
  405. DO 160 I = 1, N - 1
  406. IF( E( I ).NE.ZERO )
  407. $ INFO = INFO + 1
  408. 160 CONTINUE
  409. GO TO 180
  410. *
  411. * Sort eigenvalues in increasing order.
  412. *
  413. 170 CONTINUE
  414. CALL DLASRT( 'I', N, D, INFO )
  415. *
  416. 180 CONTINUE
  417. RETURN
  418. *
  419. * End of DSTERF
  420. *
  421. END
  422.  
  423.  

© Cast3M 2003 - Tous droits réservés.
Mentions légales