Télécharger dsytrd.eso

Retour à la liste

Numérotation des lignes :

dsytrd
  1. C DSYTRD SOURCE BP208322 22/09/16 21:15:09 11454
  2. *> \brief \b DSYTRD
  3. *
  4. * =========== DOCUMENTATION ===========
  5. *
  6. * Online html documentation available at
  7. * http://www.netlib.org/lapack/explore-html/
  8. *
  9. *> \htmlonly
  10. *> Download DSYTRD + dependencies
  11. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dsytrd.f">
  12. *> [TGZ]</a>
  13. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dsytrd.f">
  14. *> [ZIP]</a>
  15. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dsytrd.f">
  16. *> [TXT]</a>
  17. *> \endhtmlonly
  18. *
  19. * Definition:
  20. * ===========
  21. *
  22. * SUBROUTINE DSYTRD( UPLO, N, A, LDA, D, E, TAU, WORK, LWORK, INFO )
  23. *
  24. * .. Scalar Arguments ..
  25. * CHARACTER UPLO
  26. * INTEGER INFO, LDA, LWORK, N
  27. * ..
  28. * .. Array Arguments ..
  29. * REAL*8 A( LDA, * ), D( * ), E( * ), TAU( * ),
  30. * $ WORK( * )
  31. * ..
  32. *
  33. *
  34. *> \par Purpose:
  35. * =============
  36. *>
  37. *> \verbatim
  38. *>
  39. *> DSYTRD reduces a real symmetric matrix A to real symmetric
  40. *> tridiagonal form T by an orthogonal similarity transformation:
  41. *> Q**T * A * Q = T.
  42. *> \endverbatim
  43. *
  44. * Arguments:
  45. * ==========
  46. *
  47. *> \param[in] UPLO
  48. *> \verbatim
  49. *> UPLO is CHARACTER*1
  50. *> = 'U': Upper triangle of A is stored;
  51. *> = 'L': Lower triangle of A is stored.
  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] WORK
  110. *> \verbatim
  111. *> WORK is REAL*8 array, dimension (MAX(1,LWORK))
  112. *> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  113. *> \endverbatim
  114. *>
  115. *> \param[in] LWORK
  116. *> \verbatim
  117. *> LWORK is INTEGER
  118. *> The dimension of the array WORK. LWORK >= 1.
  119. *> For optimum performance LWORK >= N*NB, where NB is the
  120. *> optimal blocksize.
  121. *>
  122. *> If LWORK = -1, then a workspace query is assumed; the routine
  123. *> only calculates the optimal size of the WORK array, returns
  124. *> this value as the first entry of the WORK array, and no error
  125. *> message related to LWORK is issued by XERBLA.
  126. *> \endverbatim
  127. *>
  128. *> \param[out] INFO
  129. *> \verbatim
  130. *> INFO is INTEGER
  131. *> = 0: successful exit
  132. *> < 0: if INFO = -i, the i-th argument had an illegal value
  133. *> \endverbatim
  134. *
  135. * Authors:
  136. * ========
  137. *
  138. *> \author Univ. of Tennessee
  139. *> \author Univ. of California Berkeley
  140. *> \author Univ. of Colorado Denver
  141. *> \author NAG Ltd.
  142. *
  143. *> \ingroup doubleSYcomputational
  144. *
  145. *> \par Further Details:
  146. * =====================
  147. *>
  148. *> \verbatim
  149. *>
  150. *> If UPLO = 'U', the matrix Q is represented as a product of elementary
  151. *> reflectors
  152. *>
  153. *> Q = H(n-1) . . . H(2) H(1).
  154. *>
  155. *> Each H(i) has the form
  156. *>
  157. *> H(i) = I - tau * v * v**T
  158. *>
  159. *> where tau is a real scalar, and v is a real vector with
  160. *> v(i+1:n) = 0 and v(i) = 1; v(1:i-1) is stored on exit in
  161. *> A(1:i-1,i+1), and tau in TAU(i).
  162. *>
  163. *> If UPLO = 'L', the matrix Q is represented as a product of elementary
  164. *> reflectors
  165. *>
  166. *> Q = H(1) H(2) . . . H(n-1).
  167. *>
  168. *> Each H(i) has the form
  169. *>
  170. *> H(i) = I - tau * v * v**T
  171. *>
  172. *> where tau is a real scalar, and v is a real vector with
  173. *> v(1:i) = 0 and v(i+1) = 1; v(i+2:n) is stored on exit in A(i+2:n,i),
  174. *> and tau in TAU(i).
  175. *>
  176. *> The contents of A on exit are illustrated by the following examples
  177. *> with n = 5:
  178. *>
  179. *> if UPLO = 'U': if UPLO = 'L':
  180. *>
  181. *> ( d e v2 v3 v4 ) ( d )
  182. *> ( d e v3 v4 ) ( e d )
  183. *> ( d e v4 ) ( v1 e d )
  184. *> ( d e ) ( v1 v2 e d )
  185. *> ( d ) ( v1 v2 v3 e d )
  186. *>
  187. *> where d and e denote diagonal and off-diagonal elements of T, and vi
  188. *> denotes an element of the vector defining H(i).
  189. *> \endverbatim
  190. *>
  191. * =====================================================================
  192. SUBROUTINE DSYTRD( UPLO, N, A, LDA, D, E, TAU, WORK, LWORK, INFO )
  193. *
  194. * -- LAPACK computational routine --
  195. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  196. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  197. *
  198. * .. Scalar Arguments ..
  199. CHARACTER UPLO
  200. INTEGER INFO, LDA, LWORK, N
  201. * ..
  202. * .. Array Arguments ..
  203. REAL*8 A( LDA, * ), D( * ), E( * ), TAU( * ),
  204. $ WORK( * )
  205. * ..
  206. *
  207. * =====================================================================
  208. *
  209. * .. Parameters ..
  210. REAL*8 ONE
  211. PARAMETER ( ONE = 1.0D+0 )
  212. * ..
  213. * .. Local Scalars ..
  214. LOGICAL LQUERY, UPPER
  215. INTEGER I, IINFO, IWS, J, KK, LDWORK, LWKOPT, NB,
  216. $ NBMIN, NX
  217. * ..
  218. * .. External Subroutines ..
  219. EXTERNAL DLATRD, DSYR2K, DSYTD2, XERBLA
  220. * ..
  221. * .. Intrinsic Functions ..
  222. * INTRINSIC MAX
  223. * ..
  224. * .. External Functions ..
  225. LOGICAL LSAME
  226. INTEGER ILAENV
  227. EXTERNAL LSAME, ILAENV
  228. * ..
  229. * .. Executable Statements ..
  230. *
  231. * Test the input parameters
  232. *
  233. INFO = 0
  234. UPPER = LSAME( UPLO, 'U' )
  235. LQUERY = ( LWORK.EQ.-1 )
  236. IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
  237. INFO = -1
  238. ELSE IF( N.LT.0 ) THEN
  239. INFO = -2
  240. ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
  241. INFO = -4
  242. ELSE IF( LWORK.LT.1 .AND. .NOT.LQUERY ) THEN
  243. INFO = -9
  244. END IF
  245. *
  246. IF( INFO.EQ.0 ) THEN
  247. *
  248. * Determine the block size.
  249. *
  250. NB = ILAENV( 1, 'DSYTRD', UPLO, N, -1, -1, -1 )
  251. LWKOPT = N*NB
  252. WORK( 1 ) = LWKOPT
  253. END IF
  254. *
  255. IF( INFO.NE.0 ) THEN
  256. CALL XERBLA( 'DSYTRD', -INFO )
  257. RETURN
  258. ELSE IF( LQUERY ) THEN
  259. RETURN
  260. END IF
  261. *
  262. * Quick return if possible
  263. *
  264. IF( N.EQ.0 ) THEN
  265. WORK( 1 ) = 1
  266. RETURN
  267. END IF
  268. *
  269. NX = N
  270. IWS = 1
  271. IF( NB.GT.1 .AND. NB.LT.N ) THEN
  272. *
  273. * Determine when to cross over from blocked to unblocked code
  274. * (last block is always handled by unblocked code).
  275. *
  276. NX = MAX( NB, ILAENV( 3, 'DSYTRD', UPLO, N, -1, -1, -1 ) )
  277. IF( NX.LT.N ) THEN
  278. *
  279. * Determine if workspace is large enough for blocked code.
  280. *
  281. LDWORK = N
  282. IWS = LDWORK*NB
  283. IF( LWORK.LT.IWS ) THEN
  284. *
  285. * Not enough workspace to use optimal NB: determine the
  286. * minimum value of NB, and reduce NB or force use of
  287. * unblocked code by setting NX = N.
  288. *
  289. NB = MAX( LWORK / LDWORK, 1 )
  290. NBMIN = ILAENV( 2, 'DSYTRD', UPLO, N, -1, -1, -1 )
  291. IF( NB.LT.NBMIN )
  292. $ NX = N
  293. END IF
  294. ELSE
  295. NX = N
  296. END IF
  297. ELSE
  298. NB = 1
  299. END IF
  300. *
  301. IF( UPPER ) THEN
  302. *
  303. * Reduce the upper triangle of A.
  304. * Columns 1:kk are handled by the unblocked method.
  305. *
  306. KK = N - ( ( N-NX+NB-1 ) / NB )*NB
  307. DO 20 I = N - NB + 1, KK + 1, -NB
  308. *
  309. * Reduce columns i:i+nb-1 to tridiagonal form and form the
  310. * matrix W which is needed to update the unreduced part of
  311. * the matrix
  312. *
  313. CALL DLATRD( UPLO, I+NB-1, NB, A, LDA, E, TAU, WORK,
  314. $ LDWORK )
  315. *
  316. * Update the unreduced submatrix A(1:i-1,1:i-1), using an
  317. * update of the form: A := A - V*W**T - W*V**T
  318. *
  319. CALL DSYR2K( UPLO, 'No transpose', I-1, NB, -ONE, A( 1, I ),
  320. $ LDA, WORK, LDWORK, ONE, A, LDA )
  321. *
  322. * Copy superdiagonal elements back into A, and diagonal
  323. * elements into D
  324. *
  325. DO 10 J = I, I + NB - 1
  326. A( J-1, J ) = E( J-1 )
  327. D( J ) = A( J, J )
  328. 10 CONTINUE
  329. 20 CONTINUE
  330. *
  331. * Use unblocked code to reduce the last or only block
  332. *
  333. CALL DSYTD2( UPLO, KK, A, LDA, D, E, TAU, IINFO )
  334. ELSE
  335. *
  336. * Reduce the lower triangle of A
  337. *
  338. DO 40 I = 1, N - NX, NB
  339. *
  340. * Reduce columns i:i+nb-1 to tridiagonal form and form the
  341. * matrix W which is needed to update the unreduced part of
  342. * the matrix
  343. *
  344. CALL DLATRD( UPLO, N-I+1, NB, A( I, I ), LDA, E( I ),
  345. $ TAU( I ), WORK, LDWORK )
  346. *
  347. * Update the unreduced submatrix A(i+ib:n,i+ib:n), using
  348. * an update of the form: A := A - V*W**T - W*V**T
  349. *
  350. CALL DSYR2K( UPLO, 'No transpose', N-I-NB+1, NB, -ONE,
  351. $ A( I+NB, I ), LDA, WORK( NB+1 ), LDWORK, ONE,
  352. $ A( I+NB, I+NB ), LDA )
  353. *
  354. * Copy subdiagonal elements back into A, and diagonal
  355. * elements into D
  356. *
  357. DO 30 J = I, I + NB - 1
  358. A( J+1, J ) = E( J )
  359. D( J ) = A( J, J )
  360. 30 CONTINUE
  361. 40 CONTINUE
  362. *
  363. * Use unblocked code to reduce the last or only block
  364. *
  365. CALL DSYTD2( UPLO, N-I+1, A( I, I ), LDA, D( I ), E( I ),
  366. $ TAU( I ), IINFO )
  367. END IF
  368. *
  369. WORK( 1 ) = LWKOPT
  370. RETURN
  371. *
  372. * End of DSYTRD
  373. *
  374. END
  375.  
  376.  

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