Télécharger dorgqr.eso

Retour à la liste

Numérotation des lignes :

dorgqr
  1. C DORGQR SOURCE BP208322 22/09/16 21:15:05 11454
  2. *> \brief \b DORGQR
  3. *
  4. * =========== DOCUMENTATION ===========
  5. *
  6. * Online html documentation available at
  7. * http://www.netlib.org/lapack/explore-html/
  8. *
  9. *> \htmlonly
  10. *> Download DORGQR + dependencies
  11. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dorgqr.f">
  12. *> [TGZ]</a>
  13. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dorgqr.f">
  14. *> [ZIP]</a>
  15. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dorgqr.f">
  16. *> [TXT]</a>
  17. *> \endhtmlonly
  18. *
  19. * Definition:
  20. * ===========
  21. *
  22. * SUBROUTINE DORGQR( M, N, K, A, LDA, TAU, WORK, LWORK, INFO )
  23. *
  24. * .. Scalar Arguments ..
  25. * INTEGER INFO, K, LDA, LWORK, M, N
  26. * ..
  27. * .. Array Arguments ..
  28. * REAL*8 A( LDA, * ), TAU( * ), WORK( * )
  29. * ..
  30. *
  31. *
  32. *> \par Purpose:
  33. * =============
  34. *>
  35. *> \verbatim
  36. *>
  37. *> DORGQR generates an M-by-N real matrix Q with orthonormal columns,
  38. *> which is defined as the first N columns of a product of K elementary
  39. *> reflectors of order M
  40. *>
  41. *> Q = H(1) H(2) . . . H(k)
  42. *>
  43. *> as returned by DGEQRF.
  44. *> \endverbatim
  45. *
  46. * Arguments:
  47. * ==========
  48. *
  49. *> \param[in] M
  50. *> \verbatim
  51. *> M is INTEGER
  52. *> The number of rows of the matrix Q. M >= 0.
  53. *> \endverbatim
  54. *>
  55. *> \param[in] N
  56. *> \verbatim
  57. *> N is INTEGER
  58. *> The number of columns of the matrix Q. M >= N >= 0.
  59. *> \endverbatim
  60. *>
  61. *> \param[in] K
  62. *> \verbatim
  63. *> K is INTEGER
  64. *> The number of elementary reflectors whose product defines the
  65. *> matrix Q. N >= K >= 0.
  66. *> \endverbatim
  67. *>
  68. *> \param[in,out] A
  69. *> \verbatim
  70. *> A is REAL*8 array, dimension (LDA,N)
  71. *> On entry, the i-th column must contain the vector which
  72. *> defines the elementary reflector H(i), for i = 1,2,...,k, as
  73. *> returned by DGEQRF in the first k columns of its array
  74. *> argument A.
  75. *> On exit, the M-by-N matrix Q.
  76. *> \endverbatim
  77. *>
  78. *> \param[in] LDA
  79. *> \verbatim
  80. *> LDA is INTEGER
  81. *> The first dimension of the array A. LDA >= max(1,M).
  82. *> \endverbatim
  83. *>
  84. *> \param[in] TAU
  85. *> \verbatim
  86. *> TAU is REAL*8 array, dimension (K)
  87. *> TAU(i) must contain the scalar factor of the elementary
  88. *> reflector H(i), as returned by DGEQRF.
  89. *> \endverbatim
  90. *>
  91. *> \param[out] WORK
  92. *> \verbatim
  93. *> WORK is REAL*8 array, dimension (MAX(1,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 dimension of the array WORK. LWORK >= max(1,N).
  101. *> For optimum performance LWORK >= N*NB, where NB is the
  102. *> optimal blocksize.
  103. *>
  104. *> If LWORK = -1, then a workspace query is assumed; the routine
  105. *> only calculates the optimal size of the WORK array, returns
  106. *> this value as the first entry of the WORK array, and no error
  107. *> message related to LWORK is issued by XERBLA.
  108. *> \endverbatim
  109. *>
  110. *> \param[out] INFO
  111. *> \verbatim
  112. *> INFO is INTEGER
  113. *> = 0: successful exit
  114. *> < 0: if INFO = -i, the i-th argument has an illegal value
  115. *> \endverbatim
  116. *
  117. * Authors:
  118. * ========
  119. *
  120. *> \author Univ. of Tennessee
  121. *> \author Univ. of California Berkeley
  122. *> \author Univ. of Colorado Denver
  123. *> \author NAG Ltd.
  124. *
  125. *> \date December 2016
  126. *
  127. *> \ingroup doubleOTHERcomputational
  128. *
  129. * =====================================================================
  130. SUBROUTINE DORGQR( M, N, K, A, LDA, TAU, WORK, LWORK, INFO )
  131. *
  132. * -- LAPACK computational routine (version 3.7.0) --
  133. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  134. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  135. * December 2016
  136.  
  137. IMPLICIT INTEGER(I-N)
  138. IMPLICIT REAL*8(A-H,O-Z)
  139. *
  140. * .. Scalar Arguments ..
  141. INTEGER INFO, K, LDA, LWORK, M, N
  142. * ..
  143. * .. Array Arguments ..
  144. REAL*8 A( LDA, * ), TAU( * ), WORK( * )
  145. * ..
  146. *
  147. * =====================================================================
  148. *
  149. * .. Parameters ..
  150. REAL*8 ZERO
  151. PARAMETER ( ZERO = 0.0D+0 )
  152. * ..
  153. * .. Local Scalars ..
  154. LOGICAL LQUERY
  155. INTEGER I, IB, IINFO, IWS, J, KI, KK, L, LDWORK,
  156. $ LWKOPT, NB, NBMIN, NX
  157. * ..
  158. * .. External Subroutines ..
  159. * EXTERNAL DLARFB, DLARFT, DORG2R, XERBLA
  160. * ..
  161. * .. Intrinsic Functions ..
  162. * INTRINSIC MAX, MIN
  163. * ..
  164. * .. External Functions ..
  165. INTEGER ILAENV
  166. * EXTERNAL ILAENV
  167. * ..
  168. * .. Executable Statements ..
  169. *
  170. * Test the input arguments
  171. *
  172. INFO = 0
  173. NB = ILAENV( 1, 'DORGQR', ' ', M, N, K, -1 )
  174. LWKOPT = MAX( 1, N )*NB
  175. WORK( 1 ) = LWKOPT
  176. LQUERY = ( LWORK.EQ.-1 )
  177. IF( M.LT.0 ) THEN
  178. INFO = -1
  179. ELSE IF( N.LT.0 .OR. N.GT.M ) THEN
  180. INFO = -2
  181. ELSE IF( K.LT.0 .OR. K.GT.N ) THEN
  182. INFO = -3
  183. ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
  184. INFO = -5
  185. ELSE IF( LWORK.LT.MAX( 1, N ) .AND. .NOT.LQUERY ) THEN
  186. INFO = -8
  187. END IF
  188. IF( INFO.NE.0 ) THEN
  189. CALL XERBLA( 'DORGQR', -INFO )
  190. RETURN
  191. ELSE IF( LQUERY ) THEN
  192. RETURN
  193. END IF
  194. *
  195. * Quick return if possible
  196. *
  197. IF( N.LE.0 ) THEN
  198. WORK( 1 ) = 1
  199. RETURN
  200. END IF
  201. *
  202. NBMIN = 2
  203. NX = 0
  204. IWS = N
  205. IF( NB.GT.1 .AND. NB.LT.K ) THEN
  206. *
  207. * Determine when to cross over from blocked to unblocked code.
  208. *
  209. NX = MAX( 0, ILAENV( 3, 'DORGQR', ' ', M, N, K, -1 ) )
  210. IF( NX.LT.K ) THEN
  211. *
  212. * Determine if workspace is large enough for blocked code.
  213. *
  214. LDWORK = N
  215. IWS = LDWORK*NB
  216. IF( LWORK.LT.IWS ) THEN
  217. *
  218. * Not enough workspace to use optimal NB: reduce NB and
  219. * determine the minimum value of NB.
  220. *
  221. NB = LWORK / LDWORK
  222. NBMIN = MAX( 2, ILAENV( 2, 'DORGQR', ' ', M, N, K, -1 ) )
  223. END IF
  224. END IF
  225. END IF
  226. *
  227. IF( NB.GE.NBMIN .AND. NB.LT.K .AND. NX.LT.K ) THEN
  228. *
  229. * Use blocked code after the last block.
  230. * The first kk columns are handled by the block method.
  231. *
  232. KI = ( ( K-NX-1 ) / NB )*NB
  233. KK = MIN( K, KI+NB )
  234. *
  235. * Set A(1:kk,kk+1:n) to zero.
  236. *
  237. DO 20 J = KK + 1, N
  238. DO 10 I = 1, KK
  239. A( I, J ) = ZERO
  240. 10 CONTINUE
  241. 20 CONTINUE
  242. ELSE
  243. KK = 0
  244. END IF
  245. *
  246. * Use unblocked code for the last or only block.
  247. *
  248. IF( KK.LT.N )
  249. $ CALL DORG2R( M-KK, N-KK, K-KK, A( KK+1, KK+1 ), LDA,
  250. $ TAU( KK+1 ), WORK, IINFO )
  251. *
  252. IF( KK.GT.0 ) THEN
  253. *
  254. * Use blocked code
  255. *
  256. DO 50 I = KI + 1, 1, -NB
  257. IB = MIN( NB, K-I+1 )
  258. IF( I+IB.LE.N ) THEN
  259. *
  260. * Form the triangular factor of the block reflector
  261. * H = H(i) H(i+1) . . . H(i+ib-1)
  262. *
  263. CALL DLARFT( 'Forward', 'Columnwise', M-I+1, IB,
  264. $ A( I, I ), LDA, TAU( I ), WORK, LDWORK )
  265. *
  266. * Apply H to A(i:m,i+ib:n) from the left
  267. *
  268. CALL DLARFB( 'Left', 'No transpose', 'Forward',
  269. $ 'Columnwise', M-I+1, N-I-IB+1, IB,
  270. $ A( I, I ), LDA, WORK, LDWORK, A( I, I+IB ),
  271. $ LDA, WORK( IB+1 ), LDWORK )
  272. END IF
  273. *
  274. * Apply H to rows i:m of current block
  275. *
  276. CALL DORG2R( M-I+1, IB, IB, A( I, I ), LDA, TAU( I ), WORK,
  277. $ IINFO )
  278. *
  279. * Set rows 1:i-1 of current block to zero
  280. *
  281. DO 40 J = I, I + IB - 1
  282. DO 30 L = 1, I - 1
  283. A( L, J ) = ZERO
  284. 30 CONTINUE
  285. 40 CONTINUE
  286. 50 CONTINUE
  287. END IF
  288. *
  289. WORK( 1 ) = IWS
  290. RETURN
  291. *
  292. * End of DORGQR
  293. *
  294. END
  295.  
  296.  
  297.  
  298.  
  299.  

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