Télécharger dorgql.eso

Retour à la liste

Numérotation des lignes :

dorgql
  1. C DORGQL SOURCE BP208322 22/09/16 21:15:04 11454
  2. *> \brief \b DORGQL
  3. *
  4. * =========== DOCUMENTATION ===========
  5. *
  6. * Online html documentation available at
  7. * http://www.netlib.org/lapack/explore-html/
  8. *
  9. *> \htmlonly
  10. *> Download DORGQL + dependencies
  11. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dorgql.f">
  12. *> [TGZ]</a>
  13. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dorgql.f">
  14. *> [ZIP]</a>
  15. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dorgql.f">
  16. *> [TXT]</a>
  17. *> \endhtmlonly
  18. *
  19. * Definition:
  20. * ===========
  21. *
  22. * SUBROUTINE DORGQL( 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. *> DORGQL generates an M-by-N real matrix Q with orthonormal columns,
  38. *> which is defined as the last N columns of a product of K elementary
  39. *> reflectors of order M
  40. *>
  41. *> Q = H(k) . . . H(2) H(1)
  42. *>
  43. *> as returned by DGEQLF.
  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 (n-k+i)-th column must contain the vector which
  72. *> defines the elementary reflector H(i), for i = 1,2,...,k, as
  73. *> returned by DGEQLF in the last 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 DGEQLF.
  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. *> \ingroup doubleOTHERcomputational
  126. *
  127. * =====================================================================
  128. SUBROUTINE DORGQL( M, N, K, A, LDA, TAU, WORK, LWORK, INFO )
  129. *
  130. * -- LAPACK computational routine --
  131. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  132. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  133. *
  134. * .. Scalar Arguments ..
  135. INTEGER INFO, K, LDA, LWORK, M, N
  136. * ..
  137. * .. Array Arguments ..
  138. REAL*8 A( LDA, * ), TAU( * ), WORK( * )
  139. * ..
  140. *
  141. * =====================================================================
  142. *
  143. * .. Parameters ..
  144. REAL*8 ZERO
  145. PARAMETER ( ZERO = 0.0D+0 )
  146. * ..
  147. * .. Local Scalars ..
  148. LOGICAL LQUERY
  149. INTEGER I, IB, IINFO, IWS, J, KK, L, LDWORK, LWKOPT,
  150. $ NB, NBMIN, NX
  151. * ..
  152. * .. External Subroutines ..
  153. EXTERNAL DLARFB, DLARFT, DORG2L, XERBLA
  154. * ..
  155. * .. Intrinsic Functions ..
  156. * INTRINSIC MAX, MIN
  157. * ..
  158. * .. External Functions ..
  159. INTEGER ILAENV
  160. EXTERNAL ILAENV
  161. * ..
  162. * .. Executable Statements ..
  163. *
  164. * Test the input arguments
  165. *
  166. INFO = 0
  167. LQUERY = ( LWORK.EQ.-1 )
  168. IF( M.LT.0 ) THEN
  169. INFO = -1
  170. ELSE IF( N.LT.0 .OR. N.GT.M ) THEN
  171. INFO = -2
  172. ELSE IF( K.LT.0 .OR. K.GT.N ) THEN
  173. INFO = -3
  174. ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
  175. INFO = -5
  176. END IF
  177. *
  178. IF( INFO.EQ.0 ) THEN
  179. IF( N.EQ.0 ) THEN
  180. LWKOPT = 1
  181. ELSE
  182. NB = ILAENV( 1, 'DORGQL', ' ', M, N, K, -1 )
  183. LWKOPT = N*NB
  184. END IF
  185. WORK( 1 ) = LWKOPT
  186. *
  187. IF( LWORK.LT.MAX( 1, N ) .AND. .NOT.LQUERY ) THEN
  188. INFO = -8
  189. END IF
  190. END IF
  191. *
  192. IF( INFO.NE.0 ) THEN
  193. CALL XERBLA( 'DORGQL', -INFO )
  194. RETURN
  195. ELSE IF( LQUERY ) THEN
  196. RETURN
  197. END IF
  198. *
  199. * Quick return if possible
  200. *
  201. IF( N.LE.0 ) THEN
  202. RETURN
  203. END IF
  204. *
  205. NBMIN = 2
  206. NX = 0
  207. IWS = N
  208. IF( NB.GT.1 .AND. NB.LT.K ) THEN
  209. *
  210. * Determine when to cross over from blocked to unblocked code.
  211. *
  212. NX = MAX( 0, ILAENV( 3, 'DORGQL', ' ', M, N, K, -1 ) )
  213. IF( NX.LT.K ) THEN
  214. *
  215. * Determine if workspace is large enough for blocked code.
  216. *
  217. LDWORK = N
  218. IWS = LDWORK*NB
  219. IF( LWORK.LT.IWS ) THEN
  220. *
  221. * Not enough workspace to use optimal NB: reduce NB and
  222. * determine the minimum value of NB.
  223. *
  224. NB = LWORK / LDWORK
  225. NBMIN = MAX( 2, ILAENV( 2, 'DORGQL', ' ', M, N, K, -1 ) )
  226. END IF
  227. END IF
  228. END IF
  229. *
  230. IF( NB.GE.NBMIN .AND. NB.LT.K .AND. NX.LT.K ) THEN
  231. *
  232. * Use blocked code after the first block.
  233. * The last kk columns are handled by the block method.
  234. *
  235. KK = MIN( K, ( ( K-NX+NB-1 ) / NB )*NB )
  236. *
  237. * Set A(m-kk+1:m,1:n-kk) to zero.
  238. *
  239. DO 20 J = 1, N - KK
  240. DO 10 I = M - KK + 1, M
  241. A( I, J ) = ZERO
  242. 10 CONTINUE
  243. 20 CONTINUE
  244. ELSE
  245. KK = 0
  246. END IF
  247. *
  248. * Use unblocked code for the first or only block.
  249. *
  250. CALL DORG2L( M-KK, N-KK, K-KK, A, LDA, TAU, WORK, IINFO )
  251. *
  252. IF( KK.GT.0 ) THEN
  253. *
  254. * Use blocked code
  255. *
  256. DO 50 I = K - KK + 1, K, NB
  257. IB = MIN( NB, K-I+1 )
  258. IF( N-K+I.GT.1 ) THEN
  259. *
  260. * Form the triangular factor of the block reflector
  261. * H = H(i+ib-1) . . . H(i+1) H(i)
  262. *
  263. CALL DLARFT( 'Backward', 'Columnwise', M-K+I+IB-1, IB,
  264. $ A( 1, N-K+I ), LDA, TAU( I ), WORK, LDWORK )
  265. *
  266. * Apply H to A(1:m-k+i+ib-1,1:n-k+i-1) from the left
  267. *
  268. CALL DLARFB( 'Left', 'No transpose', 'Backward',
  269. $ 'Columnwise', M-K+I+IB-1, N-K+I-1, IB,
  270. $ A( 1, N-K+I ), LDA, WORK, LDWORK, A, LDA,
  271. $ WORK( IB+1 ), LDWORK )
  272. END IF
  273. *
  274. * Apply H to rows 1:m-k+i+ib-1 of current block
  275. *
  276. CALL DORG2L( M-K+I+IB-1, IB, IB, A( 1, N-K+I ), LDA,
  277. $ TAU( I ), WORK, IINFO )
  278. *
  279. * Set rows m-k+i+ib:m of current block to zero
  280. *
  281. DO 40 J = N - K + I, N - K + I + IB - 1
  282. DO 30 L = M - K + I + IB, M
  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 DORGQL
  293. *
  294. END
  295.  
  296.  

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