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

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