Télécharger dgehrd.eso

Retour à la liste

Numérotation des lignes :

  1. C DGEHRD SOURCE BP208322 20/09/18 21:15:50 10718
  2. *> \brief \b DGEHRD
  3. *
  4. * =========== DOCUMENTATION ===========
  5. *
  6. * Online html documentation available at
  7. * http://www.netlib.org/lapack/explore-html/
  8. *
  9. *> \htmlonly
  10. *> Download DGEHRD + dependencies
  11. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dgehrd.f">
  12. *> [TGZ]</a>
  13. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dgehrd.f">
  14. *> [ZIP]</a>
  15. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dgehrd.f">
  16. *> [TXT]</a>
  17. *> \endhtmlonly
  18. *
  19. * Definition:
  20. * ===========
  21. *
  22. * SUBROUTINE DGEHRD( N, ILO, IHI, A, LDA, TAU, WORK, LWORK, INFO )
  23. *
  24. * .. Scalar Arguments ..
  25. * INTEGER IHI, ILO, INFO, LDA, LWORK, N
  26. * ..
  27. * .. Array Arguments ..
  28. * REAL*8 A( LDA, * ), TAU( * ), WORK( * )
  29. * ..
  30. *
  31. *
  32. *> \par Purpose:
  33. * =============
  34. *>
  35. *> \verbatim
  36. *>
  37. *> DGEHRD reduces a real general matrix A to upper Hessenberg form H by
  38. *> an orthogonal similarity transformation: Q**T * A * Q = H .
  39. *> \endverbatim
  40. *
  41. * Arguments:
  42. * ==========
  43. *
  44. *> \param[in] N
  45. *> \verbatim
  46. *> N is INTEGER
  47. *> The order of the matrix A. N >= 0.
  48. *> \endverbatim
  49. *>
  50. *> \param[in] ILO
  51. *> \verbatim
  52. *> ILO is INTEGER
  53. *> \endverbatim
  54. *>
  55. *> \param[in] IHI
  56. *> \verbatim
  57. *> IHI is INTEGER
  58. *>
  59. *> It is assumed that A is already upper triangular in rows
  60. *> and columns 1:ILO-1 and IHI+1:N. ILO and IHI are normally
  61. *> set by a previous call to DGEBAL; otherwise they should be
  62. *> set to 1 and N respectively. See Further Details.
  63. *> 1 <= ILO <= IHI <= N, if N > 0; ILO=1 and IHI=0, if N=0.
  64. *> \endverbatim
  65. *>
  66. *> \param[in,out] A
  67. *> \verbatim
  68. *> A is REAL*8 array, dimension (LDA,N)
  69. *> On entry, the N-by-N general matrix to be reduced.
  70. *> On exit, the upper triangle and the first subdiagonal of A
  71. *> are overwritten with the upper Hessenberg matrix H, and the
  72. *> elements below the first subdiagonal, with the array TAU,
  73. *> represent the orthogonal matrix Q as a product of elementary
  74. *> reflectors. See Further Details.
  75. *> \endverbatim
  76. *>
  77. *> \param[in] LDA
  78. *> \verbatim
  79. *> LDA is INTEGER
  80. *> The leading dimension of the array A. LDA >= max(1,N).
  81. *> \endverbatim
  82. *>
  83. *> \param[out] TAU
  84. *> \verbatim
  85. *> TAU is REAL*8 array, dimension (N-1)
  86. *> The scalar factors of the elementary reflectors (see Further
  87. *> Details). Elements 1:ILO-1 and IHI:N-1 of TAU are set to
  88. *> zero.
  89. *> \endverbatim
  90. *>
  91. *> \param[out] WORK
  92. *> \verbatim
  93. *> WORK is REAL*8 array, dimension (LWORK)
  94. *> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  95. *> \endverbatim
  96. *>
  97. *> \param[in] LWORK
  98. *> \verbatim
  99. *> LWORK is INTEGER
  100. *> The length of the array WORK. LWORK >= max(1,N).
  101. *> For good performance, LWORK should generally be larger.
  102. *>
  103. *> If LWORK = -1, then a workspace query is assumed; the routine
  104. *> only calculates the optimal size of the WORK array, returns
  105. *> this value as the first entry of the WORK array, and no error
  106. *> message related to LWORK is issued by XERBLA.
  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. *> \date December 2016
  125. *
  126. *> \ingroup doubleGEcomputational
  127. *
  128. *> \par Further Details:
  129. * =====================
  130. *>
  131. *> \verbatim
  132. *>
  133. *> The matrix Q is represented as a product of (ihi-ilo) elementary
  134. *> reflectors
  135. *>
  136. *> Q = H(ilo) H(ilo+1) . . . H(ihi-1).
  137. *>
  138. *> Each H(i) has the form
  139. *>
  140. *> H(i) = I - tau * v * v**T
  141. *>
  142. *> where tau is a real scalar, and v is a real vector with
  143. *> v(1:i) = 0, v(i+1) = 1 and v(ihi+1:n) = 0; v(i+2:ihi) is stored on
  144. *> exit in A(i+2:ihi,i), and tau in TAU(i).
  145. *>
  146. *> The contents of A are illustrated by the following example, with
  147. *> n = 7, ilo = 2 and ihi = 6:
  148. *>
  149. *> on entry, on exit,
  150. *>
  151. *> ( a a a a a a a ) ( a a h h h h a )
  152. *> ( a a a a a a ) ( a h h h h a )
  153. *> ( a a a a a a ) ( h h h h h h )
  154. *> ( a a a a a a ) ( v2 h h h h h )
  155. *> ( a a a a a a ) ( v2 v3 h h h h )
  156. *> ( a a a a a a ) ( v2 v3 v4 h h h )
  157. *> ( a ) ( a )
  158. *>
  159. *> where a denotes an element of the original matrix A, h denotes a
  160. *> modified element of the upper Hessenberg matrix H, and vi denotes an
  161. *> element of the vector defining H(i).
  162. *>
  163. *> This file is a slight modification of LAPACK-3.0's DGEHRD
  164. *> subroutine incorporating improvements proposed by Quintana-Orti and
  165. *> Van de Geijn (2006). (See DLAHR2.)
  166. *> \endverbatim
  167. *>
  168. * =====================================================================
  169. SUBROUTINE DGEHRD( N, ILO, IHI, A, LDA, TAU, WORK, LWORK, INFO )
  170. *
  171. * -- LAPACK computational routine (version 3.7.0) --
  172. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  173. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  174. * December 2016
  175.  
  176. IMPLICIT INTEGER(I-N)
  177. IMPLICIT REAL*8(A-H,O-Z)
  178. *
  179. * .. Scalar Arguments ..
  180. INTEGER IHI, ILO, INFO, LDA, LWORK, N
  181. * ..
  182. * .. Array Arguments ..
  183. REAL*8 A( LDA, * ), TAU( * ), WORK( * )
  184. * ..
  185. *
  186. * =====================================================================
  187. *
  188. * .. Parameters ..
  189. INTEGER NBMAX, LDT, TSIZE
  190. PARAMETER ( NBMAX = 64, LDT = NBMAX+1,
  191. $ TSIZE = LDT*NBMAX )
  192. REAL*8 ZERO, ONE
  193. PARAMETER ( ZERO = 0.0D+0,
  194. $ ONE = 1.0D+0 )
  195. * ..
  196. * .. Local Scalars ..
  197. LOGICAL LQUERY
  198. INTEGER I, IB, IINFO, IWT, J, LDWORK, LWKOPT, NB,
  199. $ NBMIN, NH, NX
  200. REAL*8 EI
  201. * ..
  202. * .. External Subroutines ..
  203. * EXTERNAL DAXPY, DGEHD2, DGEMM, DLAHR2, DLARFB, DTRMM,
  204. * $ XERBLA
  205. * ..
  206. * .. Intrinsic Functions ..
  207. * INTRINSIC MAX, MIN
  208. * ..
  209. * .. External Functions ..
  210. INTEGER ILAENV
  211. * EXTERNAL ILAENV
  212. * ..
  213. * .. Executable Statements ..
  214. *
  215. * Test the input parameters
  216. *
  217. INFO = 0
  218. LQUERY = ( LWORK.EQ.-1 )
  219. IF( N.LT.0 ) THEN
  220. INFO = -1
  221. ELSE IF( ILO.LT.1 .OR. ILO.GT.MAX( 1, N ) ) THEN
  222. INFO = -2
  223. ELSE IF( IHI.LT.MIN( ILO, N ) .OR. IHI.GT.N ) THEN
  224. INFO = -3
  225. ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
  226. INFO = -5
  227. ELSE IF( LWORK.LT.MAX( 1, N ) .AND. .NOT.LQUERY ) THEN
  228. INFO = -8
  229. END IF
  230. *
  231. IF( INFO.EQ.0 ) THEN
  232. *
  233. * Compute the workspace requirements
  234. *
  235. NB = MIN( NBMAX, ILAENV( 1, 'DGEHRD', ' ', N, ILO, IHI, -1 ) )
  236. LWKOPT = N*NB + TSIZE
  237. WORK( 1 ) = LWKOPT
  238. END IF
  239. *
  240. IF( INFO.NE.0 ) THEN
  241. CALL XERBLA( 'DGEHRD', -INFO )
  242. RETURN
  243. ELSE IF( LQUERY ) THEN
  244. RETURN
  245. END IF
  246. *
  247. * Set elements 1:ILO-1 and IHI:N-1 of TAU to zero
  248. *
  249. DO 10 I = 1, ILO - 1
  250. TAU( I ) = ZERO
  251. 10 CONTINUE
  252. DO 20 I = MAX( 1, IHI ), N - 1
  253. TAU( I ) = ZERO
  254. 20 CONTINUE
  255. *
  256. * Quick return if possible
  257. *
  258. NH = IHI - ILO + 1
  259. IF( NH.LE.1 ) THEN
  260. WORK( 1 ) = 1
  261. RETURN
  262. END IF
  263. *
  264. * Determine the block size
  265. *
  266. NB = MIN( NBMAX, ILAENV( 1, 'DGEHRD', ' ', N, ILO, IHI, -1 ) )
  267. NBMIN = 2
  268. IF( NB.GT.1 .AND. NB.LT.NH ) THEN
  269. *
  270. * Determine when to cross over from blocked to unblocked code
  271. * (last block is always handled by unblocked code)
  272. *
  273. NX = MAX( NB, ILAENV( 3, 'DGEHRD', ' ', N, ILO, IHI, -1 ) )
  274. IF( NX.LT.NH ) THEN
  275. *
  276. * Determine if workspace is large enough for blocked code
  277. *
  278. IF( LWORK.LT.N*NB+TSIZE ) THEN
  279. *
  280. * Not enough workspace to use optimal NB: determine the
  281. * minimum value of NB, and reduce NB or force use of
  282. * unblocked code
  283. *
  284. NBMIN = MAX( 2, ILAENV( 2, 'DGEHRD', ' ', N, ILO, IHI,
  285. $ -1 ) )
  286. IF( LWORK.GE.(N*NBMIN + TSIZE) ) THEN
  287. NB = (LWORK-TSIZE) / N
  288. ELSE
  289. NB = 1
  290. END IF
  291. END IF
  292. END IF
  293. END IF
  294. LDWORK = N
  295. *
  296. IF( NB.LT.NBMIN .OR. NB.GE.NH ) THEN
  297. *
  298. * Use unblocked code below
  299. *
  300. I = ILO
  301. *
  302. ELSE
  303. *
  304. * Use blocked code
  305. *
  306. IWT = 1 + N*NB
  307. DO 40 I = ILO, IHI - 1 - NX, NB
  308. IB = MIN( NB, IHI-I )
  309. *
  310. * Reduce columns i:i+ib-1 to Hessenberg form, returning the
  311. * matrices V and T of the block reflector H = I - V*T*V**T
  312. * which performs the reduction, and also the matrix Y = A*V*T
  313. *
  314. CALL DLAHR2( IHI, I, IB, A( 1, I ), LDA, TAU( I ),
  315. $ WORK( IWT ), LDT, WORK, LDWORK )
  316. *
  317. * Apply the block reflector H to A(1:ihi,i+ib:ihi) from the
  318. * right, computing A := A - Y * V**T. V(i+ib,ib-1) must be set
  319. * to 1
  320. *
  321. EI = A( I+IB, I+IB-1 )
  322. A( I+IB, I+IB-1 ) = ONE
  323. CALL DGEMM( 'No transpose', 'Transpose',
  324. $ IHI, IHI-I-IB+1,
  325. $ IB, -ONE, WORK, LDWORK, A( I+IB, I ), LDA, ONE,
  326. $ A( 1, I+IB ), LDA )
  327. A( I+IB, I+IB-1 ) = EI
  328. *
  329. * Apply the block reflector H to A(1:i,i+1:i+ib-1) from the
  330. * right
  331. *
  332. CALL DTRMM( 'Right', 'Lower', 'Transpose',
  333. $ 'Unit', I, IB-1,
  334. $ ONE, A( I+1, I ), LDA, WORK, LDWORK )
  335. DO 30 J = 0, IB-2
  336. CALL DAXPY( I, -ONE, WORK( LDWORK*J+1 ), 1,
  337. $ A( 1, I+J+1 ), 1 )
  338. 30 CONTINUE
  339. *
  340. * Apply the block reflector H to A(i+1:ihi,i+ib:n) from the
  341. * left
  342. *
  343. CALL DLARFB( 'Left', 'Transpose', 'Forward',
  344. $ 'Columnwise',
  345. $ IHI-I, N-I-IB+1, IB, A( I+1, I ), LDA,
  346. $ WORK( IWT ), LDT, A( I+1, I+IB ), LDA,
  347. $ WORK, LDWORK )
  348. 40 CONTINUE
  349. END IF
  350. *
  351. * Use unblocked code to reduce the rest of the matrix
  352. *
  353. CALL DGEHD2( N, I, IHI, A, LDA, TAU, WORK, IINFO )
  354. WORK( 1 ) = LWKOPT
  355. *
  356. RETURN
  357. *
  358. * End of DGEHRD
  359. *
  360. END
  361.  
  362.  
  363.  

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