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.

ctplqt2.f 8.6 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. *> \brief \b CTPLQT2
  2. *
  3. * Definition:
  4. * ===========
  5. *
  6. * SUBROUTINE CTPLQT2( M, N, L, A, LDA, B, LDB, T, LDT, INFO )
  7. *
  8. * .. Scalar Arguments ..
  9. * INTEGER INFO, LDA, LDB, LDT, N, M, L
  10. * ..
  11. * .. Array Arguments ..
  12. * COMPLEX A( LDA, * ), B( LDB, * ), T( LDT, * )
  13. * ..
  14. *
  15. *
  16. *> \par Purpose:
  17. * =============
  18. *>
  19. *> \verbatim
  20. *>
  21. *> CTPLQT2 computes a LQ a factorization of a complex "triangular-pentagonal"
  22. *> matrix C, which is composed of a triangular block A and pentagonal block B,
  23. *> using the compact WY representation for Q.
  24. *> \endverbatim
  25. *
  26. * Arguments:
  27. * ==========
  28. *
  29. *> \param[in] M
  30. *> \verbatim
  31. *> M is INTEGER
  32. *> The total number of rows of the matrix B.
  33. *> M >= 0.
  34. *> \endverbatim
  35. *>
  36. *> \param[in] N
  37. *> \verbatim
  38. *> N is INTEGER
  39. *> The number of columns of the matrix B, and the order of
  40. *> the triangular matrix A.
  41. *> N >= 0.
  42. *> \endverbatim
  43. *>
  44. *> \param[in] L
  45. *> \verbatim
  46. *> L is INTEGER
  47. *> The number of rows of the lower trapezoidal part of B.
  48. *> MIN(M,N) >= L >= 0. See Further Details.
  49. *> \endverbatim
  50. *>
  51. *> \param[in,out] A
  52. *> \verbatim
  53. *> A is COMPLEX array, dimension (LDA,M)
  54. *> On entry, the lower triangular M-by-M matrix A.
  55. *> On exit, the elements on and below the diagonal of the array
  56. *> contain the lower triangular matrix L.
  57. *> \endverbatim
  58. *>
  59. *> \param[in] LDA
  60. *> \verbatim
  61. *> LDA is INTEGER
  62. *> The leading dimension of the array A. LDA >= max(1,M).
  63. *> \endverbatim
  64. *>
  65. *> \param[in,out] B
  66. *> \verbatim
  67. *> B is COMPLEX array, dimension (LDB,N)
  68. *> On entry, the pentagonal M-by-N matrix B. The first N-L columns
  69. *> are rectangular, and the last L columns are lower trapezoidal.
  70. *> On exit, B contains the pentagonal matrix V. See Further Details.
  71. *> \endverbatim
  72. *>
  73. *> \param[in] LDB
  74. *> \verbatim
  75. *> LDB is INTEGER
  76. *> The leading dimension of the array B. LDB >= max(1,M).
  77. *> \endverbatim
  78. *>
  79. *> \param[out] T
  80. *> \verbatim
  81. *> T is COMPLEX array, dimension (LDT,M)
  82. *> The N-by-N upper triangular factor T of the block reflector.
  83. *> See Further Details.
  84. *> \endverbatim
  85. *>
  86. *> \param[in] LDT
  87. *> \verbatim
  88. *> LDT is INTEGER
  89. *> The leading dimension of the array T. LDT >= max(1,M)
  90. *> \endverbatim
  91. *>
  92. *> \param[out] INFO
  93. *> \verbatim
  94. *> INFO is INTEGER
  95. *> = 0: successful exit
  96. *> < 0: if INFO = -i, the i-th argument had an illegal value
  97. *> \endverbatim
  98. *
  99. * Authors:
  100. * ========
  101. *
  102. *> \author Univ. of Tennessee
  103. *> \author Univ. of California Berkeley
  104. *> \author Univ. of Colorado Denver
  105. *> \author NAG Ltd.
  106. *
  107. *> \date June 2017
  108. *
  109. *> \ingroup doubleOTHERcomputational
  110. *
  111. *> \par Further Details:
  112. * =====================
  113. *>
  114. *> \verbatim
  115. *>
  116. *> The input matrix C is a M-by-(M+N) matrix
  117. *>
  118. *> C = [ A ][ B ]
  119. *>
  120. *>
  121. *> where A is an lower triangular M-by-M matrix, and B is M-by-N pentagonal
  122. *> matrix consisting of a M-by-(N-L) rectangular matrix B1 left of a M-by-L
  123. *> upper trapezoidal matrix B2:
  124. *>
  125. *> B = [ B1 ][ B2 ]
  126. *> [ B1 ] <- M-by-(N-L) rectangular
  127. *> [ B2 ] <- M-by-L lower trapezoidal.
  128. *>
  129. *> The lower trapezoidal matrix B2 consists of the first L columns of a
  130. *> N-by-N lower triangular matrix, where 0 <= L <= MIN(M,N). If L=0,
  131. *> B is rectangular M-by-N; if M=L=N, B is lower triangular.
  132. *>
  133. *> The matrix W stores the elementary reflectors H(i) in the i-th row
  134. *> above the diagonal (of A) in the M-by-(M+N) input matrix C
  135. *>
  136. *> C = [ A ][ B ]
  137. *> [ A ] <- lower triangular M-by-M
  138. *> [ B ] <- M-by-N pentagonal
  139. *>
  140. *> so that W can be represented as
  141. *>
  142. *> W = [ I ][ V ]
  143. *> [ I ] <- identity, M-by-M
  144. *> [ V ] <- M-by-N, same form as B.
  145. *>
  146. *> Thus, all of information needed for W is contained on exit in B, which
  147. *> we call V above. Note that V has the same form as B; that is,
  148. *>
  149. *> W = [ V1 ][ V2 ]
  150. *> [ V1 ] <- M-by-(N-L) rectangular
  151. *> [ V2 ] <- M-by-L lower trapezoidal.
  152. *>
  153. *> The rows of V represent the vectors which define the H(i)'s.
  154. *> The (M+N)-by-(M+N) block reflector H is then given by
  155. *>
  156. *> H = I - W**T * T * W
  157. *>
  158. *> where W^H is the conjugate transpose of W and T is the upper triangular
  159. *> factor of the block reflector.
  160. *> \endverbatim
  161. *>
  162. * =====================================================================
  163. SUBROUTINE CTPLQT2( M, N, L, A, LDA, B, LDB, T, LDT, INFO )
  164. *
  165. * -- LAPACK computational routine (version 3.7.1) --
  166. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  167. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  168. * June 2017
  169. *
  170. * .. Scalar Arguments ..
  171. INTEGER INFO, LDA, LDB, LDT, N, M, L
  172. * ..
  173. * .. Array Arguments ..
  174. COMPLEX A( LDA, * ), B( LDB, * ), T( LDT, * )
  175. * ..
  176. *
  177. * =====================================================================
  178. *
  179. * .. Parameters ..
  180. COMPLEX ONE, ZERO
  181. PARAMETER( ZERO = ( 0.0E+0, 0.0E+0 ),ONE = ( 1.0E+0, 0.0E+0 ) )
  182. * ..
  183. * .. Local Scalars ..
  184. INTEGER I, J, P, MP, NP
  185. COMPLEX ALPHA
  186. * ..
  187. * .. External Subroutines ..
  188. EXTERNAL CLARFG, CGEMV, CGERC, CTRMV, XERBLA
  189. * ..
  190. * .. Intrinsic Functions ..
  191. INTRINSIC MAX, MIN
  192. * ..
  193. * .. Executable Statements ..
  194. *
  195. * Test the input arguments
  196. *
  197. INFO = 0
  198. IF( M.LT.0 ) THEN
  199. INFO = -1
  200. ELSE IF( N.LT.0 ) THEN
  201. INFO = -2
  202. ELSE IF( L.LT.0 .OR. L.GT.MIN(M,N) ) THEN
  203. INFO = -3
  204. ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
  205. INFO = -5
  206. ELSE IF( LDB.LT.MAX( 1, M ) ) THEN
  207. INFO = -7
  208. ELSE IF( LDT.LT.MAX( 1, M ) ) THEN
  209. INFO = -9
  210. END IF
  211. IF( INFO.NE.0 ) THEN
  212. CALL XERBLA( 'CTPLQT2', -INFO )
  213. RETURN
  214. END IF
  215. *
  216. * Quick return if possible
  217. *
  218. IF( N.EQ.0 .OR. M.EQ.0 ) RETURN
  219. *
  220. DO I = 1, M
  221. *
  222. * Generate elementary reflector H(I) to annihilate B(I,:)
  223. *
  224. P = N-L+MIN( L, I )
  225. CALL CLARFG( P+1, A( I, I ), B( I, 1 ), LDB, T( 1, I ) )
  226. T(1,I)=CONJG(T(1,I))
  227. IF( I.LT.M ) THEN
  228. DO J = 1, P
  229. B( I, J ) = CONJG(B(I,J))
  230. END DO
  231. *
  232. * W(M-I:1) := C(I+1:M,I:N) * C(I,I:N) [use W = T(M,:)]
  233. *
  234. DO J = 1, M-I
  235. T( M, J ) = (A( I+J, I ))
  236. END DO
  237. CALL CGEMV( 'N', M-I, P, ONE, B( I+1, 1 ), LDB,
  238. $ B( I, 1 ), LDB, ONE, T( M, 1 ), LDT )
  239. *
  240. * C(I+1:M,I:N) = C(I+1:M,I:N) + alpha * C(I,I:N)*W(M-1:1)^H
  241. *
  242. ALPHA = -(T( 1, I ))
  243. DO J = 1, M-I
  244. A( I+J, I ) = A( I+J, I ) + ALPHA*(T( M, J ))
  245. END DO
  246. CALL CGERC( M-I, P, (ALPHA), T( M, 1 ), LDT,
  247. $ B( I, 1 ), LDB, B( I+1, 1 ), LDB )
  248. DO J = 1, P
  249. B( I, J ) = CONJG(B(I,J))
  250. END DO
  251. END IF
  252. END DO
  253. *
  254. DO I = 2, M
  255. *
  256. * T(I,1:I-1) := C(I:I-1,1:N)**H * (alpha * C(I,I:N))
  257. *
  258. ALPHA = -(T( 1, I ))
  259. DO J = 1, I-1
  260. T( I, J ) = ZERO
  261. END DO
  262. P = MIN( I-1, L )
  263. NP = MIN( N-L+1, N )
  264. MP = MIN( P+1, M )
  265. DO J = 1, N-L+P
  266. B(I,J)=CONJG(B(I,J))
  267. END DO
  268. *
  269. * Triangular part of B2
  270. *
  271. DO J = 1, P
  272. T( I, J ) = (ALPHA*B( I, N-L+J ))
  273. END DO
  274. CALL CTRMV( 'L', 'N', 'N', P, B( 1, NP ), LDB,
  275. $ T( I, 1 ), LDT )
  276. *
  277. * Rectangular part of B2
  278. *
  279. CALL CGEMV( 'N', I-1-P, L, ALPHA, B( MP, NP ), LDB,
  280. $ B( I, NP ), LDB, ZERO, T( I,MP ), LDT )
  281. *
  282. * B1
  283. *
  284. CALL CGEMV( 'N', I-1, N-L, ALPHA, B, LDB, B( I, 1 ), LDB,
  285. $ ONE, T( I, 1 ), LDT )
  286. *
  287. *
  288. * T(1:I-1,I) := T(1:I-1,1:I-1) * T(I,1:I-1)
  289. *
  290. DO J = 1, I-1
  291. T(I,J)=CONJG(T(I,J))
  292. END DO
  293. CALL CTRMV( 'L', 'C', 'N', I-1, T, LDT, T( I, 1 ), LDT )
  294. DO J = 1, I-1
  295. T(I,J)=CONJG(T(I,J))
  296. END DO
  297. DO J = 1, N-L+P
  298. B(I,J)=CONJG(B(I,J))
  299. END DO
  300. *
  301. * T(I,I) = tau(I)
  302. *
  303. T( I, I ) = T( 1, I )
  304. T( 1, I ) = ZERO
  305. END DO
  306. DO I=1,M
  307. DO J= I+1,M
  308. T(I,J)=(T(J,I))
  309. T(J,I)=ZERO
  310. END DO
  311. END DO
  312. *
  313. * End of CTPLQT2
  314. *
  315. END