Télécharger dgehrd.eso

Retour à la liste

Numérotation des lignes :

dgehrd
  1. C DGEHRD SOURCE FANDEUR 22/05/02 21:15:05 11359
  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,
  204. * ..
  205. * .. Intrinsic Functions ..
  206. * INTRINSIC MAX, MIN
  207. * ..
  208. * .. External Functions ..
  209. INTEGER ILAENV
  210. EXTERNAL ILAENV
  211. * ..
  212. * .. Executable Statements ..
  213. *
  214. * Test the input parameters
  215. *
  216. INFO = 0
  217. LQUERY = ( LWORK.EQ.-1 )
  218. IF( N.LT.0 ) THEN
  219. INFO = -1
  220. ELSE IF( ILO.LT.1 .OR. ILO.GT.MAX( 1, N ) ) THEN
  221. INFO = -2
  222. ELSE IF( IHI.LT.MIN( ILO, N ) .OR. IHI.GT.N ) THEN
  223. INFO = -3
  224. ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
  225. INFO = -5
  226. ELSE IF( LWORK.LT.MAX( 1, N ) .AND. .NOT.LQUERY ) THEN
  227. INFO = -8
  228. END IF
  229. *
  230. IF( INFO.EQ.0 ) THEN
  231. *
  232. * Compute the workspace requirements
  233. *
  234. NB = ILAENV( 1, 'DGEHRD', ' ', N, ILO, IHI, -1 )
  235. NB = MIN( NBMAX, NB )
  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 = ILAENV( 1, 'DGEHRD', ' ', N, ILO, IHI, -1 )
  267. NB = MIN( NBMAX, NB )
  268. NBMIN = 2
  269. IF( NB.GT.1 .AND. NB.LT.NH ) THEN
  270. *
  271. * Determine when to cross over from blocked to unblocked code
  272. * (last block is always handled by unblocked code)
  273. *
  274. NX = MAX( NB, ILAENV( 3, 'DGEHRD', ' ', N, ILO, IHI, -1 ) )
  275. IF( NX.LT.NH ) THEN
  276. *
  277. * Determine if workspace is large enough for blocked code
  278. *
  279. IF( LWORK.LT.N*NB+TSIZE ) THEN
  280. *
  281. * Not enough workspace to use optimal NB: determine the
  282. * minimum value of NB, and reduce NB or force use of
  283. * unblocked code
  284. *
  285. NBMIN = MAX( 2, ILAENV( 2, 'DGEHRD', ' ',
  286. $ N, ILO, IHI, -1 ) )
  287. IF( LWORK.GE.(N*NBMIN + TSIZE) ) THEN
  288. NB = (LWORK-TSIZE) / N
  289. ELSE
  290. NB = 1
  291. END IF
  292. END IF
  293. END IF
  294. END IF
  295. LDWORK = N
  296. *
  297. IF( NB.LT.NBMIN .OR. NB.GE.NH ) THEN
  298. *
  299. * Use unblocked code below
  300. *
  301. I = ILO
  302. *
  303. ELSE
  304. *
  305. * Use blocked code
  306. *
  307. IWT = 1 + N*NB
  308. DO 40 I = ILO, IHI - 1 - NX, NB
  309. IB = MIN( NB, IHI-I )
  310. *
  311. * Reduce columns i:i+ib-1 to Hessenberg form, returning the
  312. * matrices V and T of the block reflector H = I - V*T*V**T
  313. * which performs the reduction, and also the matrix Y = A*V*T
  314. *
  315. CALL DLAHR2( IHI, I, IB, A( 1, I ), LDA, TAU( I ),
  316. $ WORK( IWT ), LDT, WORK, LDWORK )
  317. *
  318. * Apply the block reflector H to A(1:ihi,i+ib:ihi) from the
  319. * right, computing A := A - Y * V**T. V(i+ib,ib-1) must be set
  320. * to 1
  321. *
  322. EI = A( I+IB, I+IB-1 )
  323. A( I+IB, I+IB-1 ) = ONE
  324. CALL DGEMM( 'No transpose', 'Transpose',
  325. $ IHI, IHI-I-IB+1,
  326. $ IB, -ONE, WORK, LDWORK, A( I+IB, I ), LDA, ONE,
  327. $ A( 1, I+IB ), LDA )
  328. A( I+IB, I+IB-1 ) = EI
  329. *
  330. * Apply the block reflector H to A(1:i,i+1:i+ib-1) from the
  331. * right
  332. *
  333. CALL DTRMM( 'Right', 'Lower', 'Transpose',
  334. $ 'Unit', I, IB-1,
  335. $ ONE, A( I+1, I ), LDA, WORK, LDWORK )
  336. DO 30 J = 0, IB-2
  337. CALL DAXPY( I, -ONE, WORK( LDWORK*J+1 ), 1,
  338. $ A( 1, I+J+1 ), 1 )
  339. 30 CONTINUE
  340. *
  341. * Apply the block reflector H to A(i+1:ihi,i+ib:n) from the
  342. * left
  343. *
  344. CALL DLARFB( 'Left', 'Transpose', 'Forward',
  345. $ 'Columnwise',
  346. $ IHI-I, N-I-IB+1, IB, A( I+1, I ), LDA,
  347. $ WORK( IWT ), LDT, A( I+1, I+IB ), LDA,
  348. $ WORK, LDWORK )
  349. 40 CONTINUE
  350. END IF
  351. *
  352. * Use unblocked code to reduce the rest of the matrix
  353. *
  354. CALL DGEHD2( N, I, IHI, A, LDA, TAU, WORK, IINFO )
  355. WORK( 1 ) = LWKOPT
  356. *
  357. RETURN
  358. *
  359. * End of DGEHRD
  360. *
  361. END
  362.  
  363.  
  364.  
  365.  

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