Télécharger dsytd2.eso

Retour à la liste

Numérotation des lignes :

dsytd2
  1. C DSYTD2 SOURCE BP208322 22/09/16 21:15:08 11454
  2. *> \brief \b DSYTD2 reduces a symmetric matrix to real symmetric tridiagonal form by an orthogonal similarity transformation (unblocked algorithm).
  3. *
  4. * =========== DOCUMENTATION ===========
  5. *
  6. * Online html documentation available at
  7. * http://www.netlib.org/lapack/explore-html/
  8. *
  9. *> \htmlonly
  10. *> Download DSYTD2 + dependencies
  11. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dsytd2.f">
  12. *> [TGZ]</a>
  13. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dsytd2.f">
  14. *> [ZIP]</a>
  15. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dsytd2.f">
  16. *> [TXT]</a>
  17. *> \endhtmlonly
  18. *
  19. * Definition:
  20. * ===========
  21. *
  22. * SUBROUTINE DSYTD2( UPLO, N, A, LDA, D, E, TAU, INFO )
  23. *
  24. * .. Scalar Arguments ..
  25. * CHARACTER UPLO
  26. * INTEGER INFO, LDA, N
  27. * ..
  28. * .. Array Arguments ..
  29. * REAL*8 A( LDA, * ), D( * ), E( * ), TAU( * )
  30. * ..
  31. *
  32. *
  33. *> \par Purpose:
  34. * =============
  35. *>
  36. *> \verbatim
  37. *>
  38. *> DSYTD2 reduces a real symmetric matrix A to symmetric tridiagonal
  39. *> form T by an orthogonal similarity transformation: Q**T * A * Q = T.
  40. *> \endverbatim
  41. *
  42. * Arguments:
  43. * ==========
  44. *
  45. *> \param[in] UPLO
  46. *> \verbatim
  47. *> UPLO is CHARACTER*1
  48. *> Specifies whether the upper or lower triangular part of the
  49. *> symmetric matrix A is stored:
  50. *> = 'U': Upper triangular
  51. *> = 'L': Lower triangular
  52. *> \endverbatim
  53. *>
  54. *> \param[in] N
  55. *> \verbatim
  56. *> N is INTEGER
  57. *> The order of the matrix A. N >= 0.
  58. *> \endverbatim
  59. *>
  60. *> \param[in,out] A
  61. *> \verbatim
  62. *> A is REAL*8 array, dimension (LDA,N)
  63. *> On entry, the symmetric matrix A. If UPLO = 'U', the leading
  64. *> n-by-n upper triangular part of A contains the upper
  65. *> triangular part of the matrix A, and the strictly lower
  66. *> triangular part of A is not referenced. If UPLO = 'L', the
  67. *> leading n-by-n lower triangular part of A contains the lower
  68. *> triangular part of the matrix A, and the strictly upper
  69. *> triangular part of A is not referenced.
  70. *> On exit, if UPLO = 'U', the diagonal and first superdiagonal
  71. *> of A are overwritten by the corresponding elements of the
  72. *> tridiagonal matrix T, and the elements above the first
  73. *> superdiagonal, with the array TAU, represent the orthogonal
  74. *> matrix Q as a product of elementary reflectors; if UPLO
  75. *> = 'L', the diagonal and first subdiagonal of A are over-
  76. *> written by the corresponding elements of the tridiagonal
  77. *> matrix T, and the elements below the first subdiagonal, with
  78. *> the array TAU, represent the orthogonal matrix Q as a product
  79. *> of elementary reflectors. See Further Details.
  80. *> \endverbatim
  81. *>
  82. *> \param[in] LDA
  83. *> \verbatim
  84. *> LDA is INTEGER
  85. *> The leading dimension of the array A. LDA >= max(1,N).
  86. *> \endverbatim
  87. *>
  88. *> \param[out] D
  89. *> \verbatim
  90. *> D is REAL*8 array, dimension (N)
  91. *> The diagonal elements of the tridiagonal matrix T:
  92. *> D(i) = A(i,i).
  93. *> \endverbatim
  94. *>
  95. *> \param[out] E
  96. *> \verbatim
  97. *> E is REAL*8 array, dimension (N-1)
  98. *> The off-diagonal elements of the tridiagonal matrix T:
  99. *> E(i) = A(i,i+1) if UPLO = 'U', E(i) = A(i+1,i) if UPLO = 'L'.
  100. *> \endverbatim
  101. *>
  102. *> \param[out] TAU
  103. *> \verbatim
  104. *> TAU is REAL*8 array, dimension (N-1)
  105. *> The scalar factors of the elementary reflectors (see Further
  106. *> Details).
  107. *> \endverbatim
  108. *>
  109. *> \param[out] INFO
  110. *> \verbatim
  111. *> INFO is INTEGER
  112. *> = 0: successful exit
  113. *> < 0: if INFO = -i, the i-th argument had an illegal value.
  114. *> \endverbatim
  115. *
  116. * Authors:
  117. * ========
  118. *
  119. *> \author Univ. of Tennessee
  120. *> \author Univ. of California Berkeley
  121. *> \author Univ. of Colorado Denver
  122. *> \author NAG Ltd.
  123. *
  124. *> \ingroup doubleSYcomputational
  125. *
  126. *> \par Further Details:
  127. * =====================
  128. *>
  129. *> \verbatim
  130. *>
  131. *> If UPLO = 'U', the matrix Q is represented as a product of elementary
  132. *> reflectors
  133. *>
  134. *> Q = H(n-1) . . . H(2) H(1).
  135. *>
  136. *> Each H(i) has the form
  137. *>
  138. *> H(i) = I - tau * v * v**T
  139. *>
  140. *> where tau is a real scalar, and v is a real vector with
  141. *> v(i+1:n) = 0 and v(i) = 1; v(1:i-1) is stored on exit in
  142. *> A(1:i-1,i+1), and tau in TAU(i).
  143. *>
  144. *> If UPLO = 'L', the matrix Q is represented as a product of elementary
  145. *> reflectors
  146. *>
  147. *> Q = H(1) H(2) . . . H(n-1).
  148. *>
  149. *> Each H(i) has the form
  150. *>
  151. *> H(i) = I - tau * v * v**T
  152. *>
  153. *> where tau is a real scalar, and v is a real vector with
  154. *> v(1:i) = 0 and v(i+1) = 1; v(i+2:n) is stored on exit in A(i+2:n,i),
  155. *> and tau in TAU(i).
  156. *>
  157. *> The contents of A on exit are illustrated by the following examples
  158. *> with n = 5:
  159. *>
  160. *> if UPLO = 'U': if UPLO = 'L':
  161. *>
  162. *> ( d e v2 v3 v4 ) ( d )
  163. *> ( d e v3 v4 ) ( e d )
  164. *> ( d e v4 ) ( v1 e d )
  165. *> ( d e ) ( v1 v2 e d )
  166. *> ( d ) ( v1 v2 v3 e d )
  167. *>
  168. *> where d and e denote diagonal and off-diagonal elements of T, and vi
  169. *> denotes an element of the vector defining H(i).
  170. *> \endverbatim
  171. *>
  172. * =====================================================================
  173. SUBROUTINE DSYTD2( UPLO, N, A, LDA, D, E, TAU, INFO )
  174. *
  175. * -- LAPACK computational routine --
  176. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  177. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  178. *
  179. * .. Scalar Arguments ..
  180. CHARACTER UPLO
  181. INTEGER INFO, LDA, N
  182. * ..
  183. * .. Array Arguments ..
  184. REAL*8 A( LDA, * ), D( * ), E( * ), TAU( * )
  185. * ..
  186. *
  187. * =====================================================================
  188. *
  189. * .. Parameters ..
  190. REAL*8 ONE, ZERO, HALF
  191. PARAMETER ( ONE = 1.0D0, ZERO = 0.0D0,
  192. $ HALF = 1.0D0 / 2.0D0 )
  193. * ..
  194. * .. Local Scalars ..
  195. LOGICAL UPPER
  196. INTEGER I
  197. REAL*8 ALPHA, TAUI
  198. * ..
  199. * .. External Subroutines ..
  200. EXTERNAL DAXPY, DLARFG, DSYMV, DSYR2, XERBLA
  201. * ..
  202. * .. External Functions ..
  203. LOGICAL LSAME
  204. REAL*8 DDOT
  205. EXTERNAL LSAME, DDOT
  206. * ..
  207. * .. Intrinsic Functions ..
  208. * INTRINSIC MAX, MIN
  209. * ..
  210. * .. Executable Statements ..
  211. *
  212. * Test the input parameters
  213. *
  214. INFO = 0
  215. UPPER = LSAME( UPLO, 'U' )
  216. IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
  217. INFO = -1
  218. ELSE IF( N.LT.0 ) THEN
  219. INFO = -2
  220. ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
  221. INFO = -4
  222. END IF
  223. IF( INFO.NE.0 ) THEN
  224. CALL XERBLA( 'DSYTD2', -INFO )
  225. RETURN
  226. END IF
  227. *
  228. * Quick return if possible
  229. *
  230. IF( N.LE.0 )
  231. $ RETURN
  232. *
  233. IF( UPPER ) THEN
  234. *
  235. * Reduce the upper triangle of A
  236. *
  237. DO 10 I = N - 1, 1, -1
  238. *
  239. * Generate elementary reflector H(i) = I - tau * v * v**T
  240. * to annihilate A(1:i-1,i+1)
  241. *
  242. CALL DLARFG( I, A( I, I+1 ), A( 1, I+1 ), 1, TAUI )
  243. E( I ) = A( I, I+1 )
  244. *
  245. IF( TAUI.NE.ZERO ) THEN
  246. *
  247. * Apply H(i) from both sides to A(1:i,1:i)
  248. *
  249. A( I, I+1 ) = ONE
  250. *
  251. * Compute x := tau * A * v storing x in TAU(1:i)
  252. *
  253. CALL DSYMV( UPLO, I, TAUI, A, LDA, A( 1, I+1 ), 1, ZERO,
  254. $ TAU, 1 )
  255. *
  256. * Compute w := x - 1/2 * tau * (x**T * v) * v
  257. *
  258. ALPHA = -HALF*TAUI*DDOT( I, TAU, 1, A( 1, I+1 ), 1 )
  259. CALL DAXPY( I, ALPHA, A( 1, I+1 ), 1, TAU, 1 )
  260. *
  261. * Apply the transformation as a rank-2 update:
  262. * A := A - v * w**T - w * v**T
  263. *
  264. CALL DSYR2( UPLO, I, -ONE, A( 1, I+1 ), 1, TAU, 1, A,
  265. $ LDA )
  266. *
  267. A( I, I+1 ) = E( I )
  268. END IF
  269. D( I+1 ) = A( I+1, I+1 )
  270. TAU( I ) = TAUI
  271. 10 CONTINUE
  272. D( 1 ) = A( 1, 1 )
  273. ELSE
  274. *
  275. * Reduce the lower triangle of A
  276. *
  277. DO 20 I = 1, N - 1
  278. *
  279. * Generate elementary reflector H(i) = I - tau * v * v**T
  280. * to annihilate A(i+2:n,i)
  281. *
  282. CALL DLARFG( N-I, A( I+1, I ), A( MIN( I+2, N ), I ), 1,
  283. $ TAUI )
  284. E( I ) = A( I+1, I )
  285. *
  286. IF( TAUI.NE.ZERO ) THEN
  287. *
  288. * Apply H(i) from both sides to A(i+1:n,i+1:n)
  289. *
  290. A( I+1, I ) = ONE
  291. *
  292. * Compute x := tau * A * v storing y in TAU(i:n-1)
  293. *
  294. CALL DSYMV( UPLO, N-I, TAUI, A( I+1, I+1 ), LDA,
  295. $ A( I+1, I ), 1, ZERO, TAU( I ), 1 )
  296. *
  297. * Compute w := x - 1/2 * tau * (x**T * v) * v
  298. *
  299. ALPHA = -HALF*TAUI*DDOT( N-I, TAU( I ), 1, A( I+1, I ),
  300. $ 1 )
  301. CALL DAXPY( N-I, ALPHA, A( I+1, I ), 1, TAU( I ), 1 )
  302. *
  303. * Apply the transformation as a rank-2 update:
  304. * A := A - v * w**T - w * v**T
  305. *
  306. CALL DSYR2( UPLO, N-I, -ONE, A( I+1, I ), 1, TAU( I ), 1,
  307. $ A( I+1, I+1 ), LDA )
  308. *
  309. A( I+1, I ) = E( I )
  310. END IF
  311. D( I ) = A( I, I )
  312. TAU( I ) = TAUI
  313. 20 CONTINUE
  314. D( N ) = A( N, N )
  315. END IF
  316. *
  317. RETURN
  318. *
  319. * End of DSYTD2
  320. *
  321. END
  322.  
  323.  

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