You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

slaswlq.f 8.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. *> \brief \b SLASWLQ
  2. *
  3. * Definition:
  4. * ===========
  5. *
  6. * SUBROUTINE SLASWLQ( M, N, MB, NB, A, LDA, T, LDT, WORK,
  7. * LWORK, INFO)
  8. *
  9. * .. Scalar Arguments ..
  10. * INTEGER INFO, LDA, M, N, MB, NB, LDT, LWORK
  11. * ..
  12. * .. Array Arguments ..
  13. * REAL A( LDA, * ), T( LDT, * ), WORK( * )
  14. * ..
  15. *
  16. *
  17. *> \par Purpose:
  18. * =============
  19. *>
  20. *> \verbatim
  21. *>
  22. *> SLASWLQ computes a blocked Tall-Skinny LQ factorization of
  23. *> a real M-by-N matrix A for M <= N:
  24. *>
  25. *> A = ( L 0 ) * Q,
  26. *>
  27. *> where:
  28. *>
  29. *> Q is a n-by-N orthogonal matrix, stored on exit in an implicit
  30. *> form in the elements above the diagonal of the array A and in
  31. *> the elements of the array T;
  32. *> L is a lower-triangular M-by-M matrix stored on exit in
  33. *> the elements on and below the diagonal of the array A.
  34. *> 0 is a M-by-(N-M) zero matrix, if M < N, and is not stored.
  35. *>
  36. *> \endverbatim
  37. *
  38. * Arguments:
  39. * ==========
  40. *
  41. *> \param[in] M
  42. *> \verbatim
  43. *> M is INTEGER
  44. *> The number of rows of the matrix A. M >= 0.
  45. *> \endverbatim
  46. *>
  47. *> \param[in] N
  48. *> \verbatim
  49. *> N is INTEGER
  50. *> The number of columns of the matrix A. N >= M >= 0.
  51. *> \endverbatim
  52. *>
  53. *> \param[in] MB
  54. *> \verbatim
  55. *> MB is INTEGER
  56. *> The row block size to be used in the blocked QR.
  57. *> M >= MB >= 1
  58. *> \endverbatim
  59. *> \param[in] NB
  60. *> \verbatim
  61. *> NB is INTEGER
  62. *> The column block size to be used in the blocked QR.
  63. *> NB > 0.
  64. *> \endverbatim
  65. *>
  66. *> \param[in,out] A
  67. *> \verbatim
  68. *> A is REAL array, dimension (LDA,N)
  69. *> On entry, the M-by-N matrix A.
  70. *> On exit, the elements on and below the diagonal
  71. *> of the array contain the N-by-N lower triangular matrix L;
  72. *> the elements above the diagonal represent Q by the rows
  73. *> of blocked V (see Further Details).
  74. *>
  75. *> \endverbatim
  76. *>
  77. *> \param[in] LDA
  78. *> \verbatim
  79. *> LDA is INTEGER
  80. *> The leading dimension of the array A. LDA >= max(1,M).
  81. *> \endverbatim
  82. *>
  83. *> \param[out] T
  84. *> \verbatim
  85. *> T is REAL array,
  86. *> dimension (LDT, N * Number_of_row_blocks)
  87. *> where Number_of_row_blocks = CEIL((N-M)/(NB-M))
  88. *> The blocked upper triangular block reflectors stored in compact form
  89. *> as a sequence of upper triangular blocks.
  90. *> See Further Details below.
  91. *> \endverbatim
  92. *>
  93. *> \param[in] LDT
  94. *> \verbatim
  95. *> LDT is INTEGER
  96. *> The leading dimension of the array T. LDT >= MB.
  97. *> \endverbatim
  98. *>
  99. *> \param[out] WORK
  100. *> \verbatim
  101. *> (workspace) REAL array, dimension (MAX(1,LWORK))
  102. *> On exit, if INFO = 0, WORK(1) returns the minimal LWORK.
  103. *> \endverbatim
  104. *>
  105. *> \param[in] LWORK
  106. *> \verbatim
  107. *> LWORK is INTEGER
  108. *> The dimension of the array WORK.
  109. *> LWORK >= 1, if MIN(M,N) = 0, and LWORK >= MB*M, otherwise.
  110. *>
  111. *> If LWORK = -1, then a workspace query is assumed; the routine
  112. *> only calculates the minimal size of the WORK array, returns
  113. *> this value as the first entry of the WORK array, and no error
  114. *> message related to LWORK is issued by XERBLA.
  115. *> \endverbatim
  116. *> \param[out] INFO
  117. *> \verbatim
  118. *> INFO is INTEGER
  119. *> = 0: successful exit
  120. *> < 0: if INFO = -i, the i-th argument had an illegal value
  121. *> \endverbatim
  122. *
  123. * Authors:
  124. * ========
  125. *
  126. *> \author Univ. of Tennessee
  127. *> \author Univ. of California Berkeley
  128. *> \author Univ. of Colorado Denver
  129. *> \author NAG Ltd.
  130. *
  131. *> \par Further Details:
  132. * =====================
  133. *>
  134. *> \verbatim
  135. *> Short-Wide LQ (SWLQ) performs LQ by a sequence of orthogonal transformations,
  136. *> representing Q as a product of other orthogonal matrices
  137. *> Q = Q(1) * Q(2) * . . . * Q(k)
  138. *> where each Q(i) zeros out upper diagonal entries of a block of NB rows of A:
  139. *> Q(1) zeros out the upper diagonal entries of rows 1:NB of A
  140. *> Q(2) zeros out the bottom MB-N rows of rows [1:M,NB+1:2*NB-M] of A
  141. *> Q(3) zeros out the bottom MB-N rows of rows [1:M,2*NB-M+1:3*NB-2*M] of A
  142. *> . . .
  143. *>
  144. *> Q(1) is computed by GELQT, which represents Q(1) by Householder vectors
  145. *> stored under the diagonal of rows 1:MB of A, and by upper triangular
  146. *> block reflectors, stored in array T(1:LDT,1:N).
  147. *> For more information see Further Details in GELQT.
  148. *>
  149. *> Q(i) for i>1 is computed by TPLQT, which represents Q(i) by Householder vectors
  150. *> stored in columns [(i-1)*(NB-M)+M+1:i*(NB-M)+M] of A, and by upper triangular
  151. *> block reflectors, stored in array T(1:LDT,(i-1)*M+1:i*M).
  152. *> The last Q(k) may use fewer rows.
  153. *> For more information see Further Details in TPQRT.
  154. *>
  155. *> For more details of the overall algorithm, see the description of
  156. *> Sequential TSQR in Section 2.2 of [1].
  157. *>
  158. *> [1] “Communication-Optimal Parallel and Sequential QR and LU Factorizations,”
  159. *> J. Demmel, L. Grigori, M. Hoemmen, J. Langou,
  160. *> SIAM J. Sci. Comput, vol. 34, no. 1, 2012
  161. *> \endverbatim
  162. *>
  163. *> \ingroup laswlq
  164. *>
  165. * =====================================================================
  166. SUBROUTINE SLASWLQ( M, N, MB, NB, A, LDA, T, LDT, WORK, LWORK,
  167. $ INFO )
  168. *
  169. * -- LAPACK computational routine --
  170. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  171. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd. --
  172. *
  173. * .. Scalar Arguments ..
  174. INTEGER INFO, LDA, M, N, MB, NB, LWORK, LDT
  175. * ..
  176. * .. Array Arguments ..
  177. REAL A( LDA, * ), WORK( * ), T( LDT, * )
  178. * ..
  179. *
  180. * =====================================================================
  181. *
  182. * ..
  183. * .. Local Scalars ..
  184. LOGICAL LQUERY
  185. INTEGER I, II, KK, CTR, MINMN, LWMIN
  186. * ..
  187. * .. EXTERNAL FUNCTIONS ..
  188. LOGICAL LSAME
  189. EXTERNAL LSAME
  190. REAL SROUNDUP_LWORK
  191. EXTERNAL SROUNDUP_LWORK
  192. * ..
  193. * .. EXTERNAL SUBROUTINES ..
  194. EXTERNAL SGELQT, SGEQRT, STPLQT, STPQRT, XERBLA
  195. * ..
  196. * .. INTRINSIC FUNCTIONS ..
  197. INTRINSIC MAX, MIN, MOD
  198. * ..
  199. * .. EXECUTABLE STATEMENTS ..
  200. *
  201. * TEST THE INPUT ARGUMENTS
  202. *
  203. INFO = 0
  204. *
  205. LQUERY = ( LWORK.EQ.-1 )
  206. *
  207. MINMN = MIN( M, N )
  208. IF( MINMN.EQ.0 ) THEN
  209. LWMIN = 1
  210. ELSE
  211. LWMIN = M*MB
  212. END IF
  213. *
  214. IF( M.LT.0 ) THEN
  215. INFO = -1
  216. ELSE IF( N.LT.0 .OR. N.LT.M ) THEN
  217. INFO = -2
  218. ELSE IF( MB.LT.1 .OR. ( MB.GT.M .AND. M.GT.0 ) ) THEN
  219. INFO = -3
  220. ELSE IF( NB.LE.0 ) THEN
  221. INFO = -4
  222. ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
  223. INFO = -6
  224. ELSE IF( LDT.LT.MB ) THEN
  225. INFO = -8
  226. ELSE IF( LWORK.LT.LWMIN .AND. (.NOT.LQUERY) ) THEN
  227. INFO = -10
  228. END IF
  229. IF( INFO.EQ.0 ) THEN
  230. WORK( 1 ) = SROUNDUP_LWORK( LWMIN )
  231. END IF
  232. *
  233. IF( INFO.NE.0 ) THEN
  234. CALL XERBLA( 'SLASWLQ', -INFO )
  235. RETURN
  236. ELSE IF( LQUERY ) THEN
  237. RETURN
  238. END IF
  239. *
  240. * Quick return if possible
  241. *
  242. IF( MINMN.EQ.0 ) THEN
  243. RETURN
  244. END IF
  245. *
  246. * The LQ Decomposition
  247. *
  248. IF( (M.GE.N) .OR. (NB.LE.M) .OR. (NB.GE.N) ) THEN
  249. CALL SGELQT( M, N, MB, A, LDA, T, LDT, WORK, INFO )
  250. RETURN
  251. END IF
  252. *
  253. KK = MOD((N-M),(NB-M))
  254. II = N-KK+1
  255. *
  256. * Compute the LQ factorization of the first block A(1:M,1:NB)
  257. *
  258. CALL SGELQT( M, NB, MB, A(1,1), LDA, T, LDT, WORK, INFO )
  259. CTR = 1
  260. *
  261. DO I = NB+1, II-NB+M, (NB-M)
  262. *
  263. * Compute the QR factorization of the current block A(1:M,I:I+NB-M)
  264. *
  265. CALL STPLQT( M, NB-M, 0, MB, A(1,1), LDA, A( 1, I ),
  266. $ LDA, T(1, CTR * M + 1),
  267. $ LDT, WORK, INFO )
  268. CTR = CTR + 1
  269. END DO
  270. *
  271. * Compute the QR factorization of the last block A(1:M,II:N)
  272. *
  273. IF( II.LE.N ) THEN
  274. CALL STPLQT( M, KK, 0, MB, A(1,1), LDA, A( 1, II ),
  275. $ LDA, T(1, CTR * M + 1), LDT,
  276. $ WORK, INFO )
  277. END IF
  278. *
  279. WORK( 1 ) = SROUNDUP_LWORK( LWMIN )
  280. RETURN
  281. *
  282. * End of SLASWLQ
  283. *
  284. END