Télécharger dormqr.eso

Retour à la liste

Numérotation des lignes :

  1. C DORMQR SOURCE BP208322 20/09/18 21:16:11 10718
  2. *> \brief \b DORMQR
  3. *
  4. * =========== DOCUMENTATION ===========
  5. *
  6. * Online html documentation available at
  7. * http://www.netlib.org/lapack/explore-html/
  8. *
  9. *> \htmlonly
  10. *> Download DORMQR + dependencies
  11. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dormqr.f">
  12. *> [TGZ]</a>
  13. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dormqr.f">
  14. *> [ZIP]</a>
  15. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dormqr.f">
  16. *> [TXT]</a>
  17. *> \endhtmlonly
  18. *
  19. * Definition:
  20. * ===========
  21. *
  22. * SUBROUTINE DORMQR( SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC,
  23. * WORK, LWORK, INFO )
  24. *
  25. * .. Scalar Arguments ..
  26. * CHARACTER SIDE, TRANS
  27. * INTEGER INFO, K, LDA, LDC, LWORK, M, N
  28. * ..
  29. * .. Array Arguments ..
  30. * REAL*8 A( LDA, * ), C( LDC, * ), TAU( * ), WORK( * )
  31. * ..
  32. *
  33. *
  34. *> \par Purpose:
  35. * =============
  36. *>
  37. *> \verbatim
  38. *>
  39. *> DORMQR overwrites the general real M-by-N matrix C with
  40. *>
  41. *> SIDE = 'L' SIDE = 'R'
  42. *> TRANS = 'N': Q * C C * Q
  43. *> TRANS = 'T': Q**T * C C * Q**T
  44. *>
  45. *> where Q is a real orthogonal matrix defined as the product of k
  46. *> elementary reflectors
  47. *>
  48. *> Q = H(1) H(2) . . . H(k)
  49. *>
  50. *> as returned by DGEQRF. Q is of order M if SIDE = 'L' and of order N
  51. *> if SIDE = 'R'.
  52. *> \endverbatim
  53. *
  54. * Arguments:
  55. * ==========
  56. *
  57. *> \param[in] SIDE
  58. *> \verbatim
  59. *> SIDE is CHARACTER*1
  60. *> = 'L': apply Q or Q**T from the Left;
  61. *> = 'R': apply Q or Q**T from the Right.
  62. *> \endverbatim
  63. *>
  64. *> \param[in] TRANS
  65. *> \verbatim
  66. *> TRANS is CHARACTER*1
  67. *> = 'N': No transpose, apply Q;
  68. *> = 'T': Transpose, apply Q**T.
  69. *> \endverbatim
  70. *>
  71. *> \param[in] M
  72. *> \verbatim
  73. *> M is INTEGER
  74. *> The number of rows of the matrix C. M >= 0.
  75. *> \endverbatim
  76. *>
  77. *> \param[in] N
  78. *> \verbatim
  79. *> N is INTEGER
  80. *> The number of columns of the matrix C. N >= 0.
  81. *> \endverbatim
  82. *>
  83. *> \param[in] K
  84. *> \verbatim
  85. *> K is INTEGER
  86. *> The number of elementary reflectors whose product defines
  87. *> the matrix Q.
  88. *> If SIDE = 'L', M >= K >= 0;
  89. *> if SIDE = 'R', N >= K >= 0.
  90. *> \endverbatim
  91. *>
  92. *> \param[in] A
  93. *> \verbatim
  94. *> A is REAL*8 array, dimension (LDA,K)
  95. *> The i-th column must contain the vector which defines the
  96. *> elementary reflector H(i), for i = 1,2,...,k, as returned by
  97. *> DGEQRF in the first k columns of its array argument A.
  98. *> \endverbatim
  99. *>
  100. *> \param[in] LDA
  101. *> \verbatim
  102. *> LDA is INTEGER
  103. *> The leading dimension of the array A.
  104. *> If SIDE = 'L', LDA >= max(1,M);
  105. *> if SIDE = 'R', LDA >= max(1,N).
  106. *> \endverbatim
  107. *>
  108. *> \param[in] TAU
  109. *> \verbatim
  110. *> TAU is REAL*8 array, dimension (K)
  111. *> TAU(i) must contain the scalar factor of the elementary
  112. *> reflector H(i), as returned by DGEQRF.
  113. *> \endverbatim
  114. *>
  115. *> \param[in,out] C
  116. *> \verbatim
  117. *> C is REAL*8 array, dimension (LDC,N)
  118. *> On entry, the M-by-N matrix C.
  119. *> On exit, C is overwritten by Q*C or Q**T*C or C*Q**T or C*Q.
  120. *> \endverbatim
  121. *>
  122. *> \param[in] LDC
  123. *> \verbatim
  124. *> LDC is INTEGER
  125. *> The leading dimension of the array C. LDC >= max(1,M).
  126. *> \endverbatim
  127. *>
  128. *> \param[out] WORK
  129. *> \verbatim
  130. *> WORK is REAL*8 array, dimension (MAX(1,LWORK))
  131. *> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  132. *> \endverbatim
  133. *>
  134. *> \param[in] LWORK
  135. *> \verbatim
  136. *> LWORK is INTEGER
  137. *> The dimension of the array WORK.
  138. *> If SIDE = 'L', LWORK >= max(1,N);
  139. *> if SIDE = 'R', LWORK >= max(1,M).
  140. *> For good performance, LWORK should generally be larger.
  141. *>
  142. *> If LWORK = -1, then a workspace query is assumed; the routine
  143. *> only calculates the optimal size of the WORK array, returns
  144. *> this value as the first entry of the WORK array, and no error
  145. *> message related to LWORK is issued by XERBLA.
  146. *> \endverbatim
  147. *>
  148. *> \param[out] INFO
  149. *> \verbatim
  150. *> INFO is INTEGER
  151. *> = 0: successful exit
  152. *> < 0: if INFO = -i, the i-th argument had an illegal value
  153. *> \endverbatim
  154. *
  155. * Authors:
  156. * ========
  157. *
  158. *> \author Univ. of Tennessee
  159. *> \author Univ. of California Berkeley
  160. *> \author Univ. of Colorado Denver
  161. *> \author NAG Ltd.
  162. *
  163. *> \date December 2016
  164. *
  165. *> \ingroup doubleOTHERcomputational
  166. *
  167. * =====================================================================
  168. SUBROUTINE DORMQR( SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC,
  169. $ 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. CHARACTER SIDE, TRANS
  181. INTEGER INFO, K, LDA, LDC, LWORK, M, N
  182. * ..
  183. * .. Array Arguments ..
  184. REAL*8 A( LDA, * ), C( LDC, * ), TAU( * ), WORK( * )
  185. * ..
  186. *
  187. * =====================================================================
  188. *
  189. * .. Parameters ..
  190. INTEGER NBMAX, LDT, TSIZE
  191. PARAMETER ( NBMAX = 64, LDT = NBMAX+1,
  192. $ TSIZE = LDT*NBMAX )
  193. * ..
  194. * .. Local Scalars ..
  195. LOGICAL LEFT, LQUERY, NOTRAN
  196. INTEGER I, I1, I2, I3, IB, IC, IINFO, IWT, JC, LDWORK,
  197. $ LWKOPT, MI, NB, NBMIN, NI, NQ, NW
  198. * ..
  199. * .. External Functions ..
  200. LOGICAL LSAME
  201. INTEGER ILAENV
  202. * EXTERNAL LSAME, ILAENV
  203. * ..
  204. * .. External Subroutines ..
  205. * EXTERNAL DLARFB, DLARFT, DORM2R, XERBLA
  206. * ..
  207. * .. Intrinsic Functions ..
  208. * INTRINSIC MAX, MIN
  209. * ..
  210. * .. Executable Statements ..
  211. *
  212. * Test the input arguments
  213. *
  214. INFO = 0
  215. LEFT = LSAME( SIDE, 'L' )
  216. NOTRAN = LSAME( TRANS, 'N' )
  217. LQUERY = ( LWORK.EQ.-1 )
  218. *
  219. * NQ is the order of Q and NW is the minimum dimension of WORK
  220. *
  221. IF( LEFT ) THEN
  222. NQ = M
  223. NW = N
  224. ELSE
  225. NQ = N
  226. NW = M
  227. END IF
  228. IF( .NOT.LEFT .AND. .NOT.LSAME( SIDE, 'R' ) ) THEN
  229. INFO = -1
  230. ELSE IF( .NOT.NOTRAN .AND. .NOT.LSAME( TRANS, 'T' ) ) THEN
  231. INFO = -2
  232. ELSE IF( M.LT.0 ) THEN
  233. INFO = -3
  234. ELSE IF( N.LT.0 ) THEN
  235. INFO = -4
  236. ELSE IF( K.LT.0 .OR. K.GT.NQ ) THEN
  237. INFO = -5
  238. ELSE IF( LDA.LT.MAX( 1, NQ ) ) THEN
  239. INFO = -7
  240. ELSE IF( LDC.LT.MAX( 1, M ) ) THEN
  241. INFO = -10
  242. ELSE IF( LWORK.LT.MAX( 1, NW ) .AND. .NOT.LQUERY ) THEN
  243. INFO = -12
  244. END IF
  245. *
  246. IF( INFO.EQ.0 ) THEN
  247. *
  248. * Compute the workspace requirements
  249. *
  250. NB = MIN( NBMAX, ILAENV( 1, 'DORMQR', SIDE // TRANS, M, N, K,
  251. $ -1 ) )
  252. LWKOPT = MAX( 1, NW )*NB + TSIZE
  253. WORK( 1 ) = LWKOPT
  254. END IF
  255. *
  256. IF( INFO.NE.0 ) THEN
  257. CALL XERBLA( 'DORMQR', -INFO )
  258. RETURN
  259. ELSE IF( LQUERY ) THEN
  260. RETURN
  261. END IF
  262. *
  263. * Quick return if possible
  264. *
  265. IF( M.EQ.0 .OR. N.EQ.0 .OR. K.EQ.0 ) THEN
  266. WORK( 1 ) = 1
  267. RETURN
  268. END IF
  269. *
  270. NBMIN = 2
  271. LDWORK = NW
  272. IF( NB.GT.1 .AND. NB.LT.K ) THEN
  273. IF( LWORK.LT.NW*NB+TSIZE ) THEN
  274. NB = (LWORK-TSIZE) / LDWORK
  275. NBMIN = MAX( 2, ILAENV( 2, 'DORMQR', SIDE // TRANS, M, N, K,
  276. $ -1 ) )
  277. END IF
  278. END IF
  279. *
  280. IF( NB.LT.NBMIN .OR. NB.GE.K ) THEN
  281. *
  282. * Use unblocked code
  283. *
  284. CALL DORM2R( SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC, WORK,
  285. $ IINFO )
  286. ELSE
  287. *
  288. * Use blocked code
  289. *
  290. IWT = 1 + NW*NB
  291. IF( ( LEFT .AND. .NOT.NOTRAN ) .OR.
  292. $ ( .NOT.LEFT .AND. NOTRAN ) ) THEN
  293. I1 = 1
  294. I2 = K
  295. I3 = NB
  296. ELSE
  297. I1 = ( ( K-1 ) / NB )*NB + 1
  298. I2 = 1
  299. I3 = -NB
  300. END IF
  301. *
  302. IF( LEFT ) THEN
  303. NI = N
  304. JC = 1
  305. ELSE
  306. MI = M
  307. IC = 1
  308. END IF
  309. *
  310. DO 10 I = I1, I2, I3
  311. IB = MIN( NB, K-I+1 )
  312. *
  313. * Form the triangular factor of the block reflector
  314. * H = H(i) H(i+1) . . . H(i+ib-1)
  315. *
  316. CALL DLARFT( 'Forward', 'Columnwise', NQ-I+1, IB, A( I, I ),
  317. $ LDA, TAU( I ), WORK( IWT ), LDT )
  318. IF( LEFT ) THEN
  319. *
  320. * H or H**T is applied to C(i:m,1:n)
  321. *
  322. MI = M - I + 1
  323. IC = I
  324. ELSE
  325. *
  326. * H or H**T is applied to C(1:m,i:n)
  327. *
  328. NI = N - I + 1
  329. JC = I
  330. END IF
  331. *
  332. * Apply H or H**T
  333. *
  334. CALL DLARFB( SIDE, TRANS, 'Forward', 'Columnwise', MI, NI,
  335. $ IB, A( I, I ), LDA, WORK( IWT ), LDT,
  336. $ C( IC, JC ), LDC, WORK, LDWORK )
  337. 10 CONTINUE
  338. END IF
  339. WORK( 1 ) = LWKOPT
  340. RETURN
  341. *
  342. * End of DORMQR
  343. *
  344. END
  345.  
  346.  
  347.  

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