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.

zunmbr.f 11 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. *> \brief \b ZUNMBR
  2. *
  3. * =========== DOCUMENTATION ===========
  4. *
  5. * Online html documentation available at
  6. * http://www.netlib.org/lapack/explore-html/
  7. *
  8. *> \htmlonly
  9. *> Download ZUNMBR + dependencies
  10. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zunmbr.f">
  11. *> [TGZ]</a>
  12. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zunmbr.f">
  13. *> [ZIP]</a>
  14. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zunmbr.f">
  15. *> [TXT]</a>
  16. *> \endhtmlonly
  17. *
  18. * Definition:
  19. * ===========
  20. *
  21. * SUBROUTINE ZUNMBR( VECT, SIDE, TRANS, M, N, K, A, LDA, TAU, C,
  22. * LDC, WORK, LWORK, INFO )
  23. *
  24. * .. Scalar Arguments ..
  25. * CHARACTER SIDE, TRANS, VECT
  26. * INTEGER INFO, K, LDA, LDC, LWORK, M, N
  27. * ..
  28. * .. Array Arguments ..
  29. * COMPLEX*16 A( LDA, * ), C( LDC, * ), TAU( * ), WORK( * )
  30. * ..
  31. *
  32. *
  33. *> \par Purpose:
  34. * =============
  35. *>
  36. *> \verbatim
  37. *>
  38. *> If VECT = 'Q', ZUNMBR overwrites the general complex M-by-N matrix C
  39. *> with
  40. *> SIDE = 'L' SIDE = 'R'
  41. *> TRANS = 'N': Q * C C * Q
  42. *> TRANS = 'C': Q**H * C C * Q**H
  43. *>
  44. *> If VECT = 'P', ZUNMBR overwrites the general complex M-by-N matrix C
  45. *> with
  46. *> SIDE = 'L' SIDE = 'R'
  47. *> TRANS = 'N': P * C C * P
  48. *> TRANS = 'C': P**H * C C * P**H
  49. *>
  50. *> Here Q and P**H are the unitary matrices determined by ZGEBRD when
  51. *> reducing a complex matrix A to bidiagonal form: A = Q * B * P**H. Q
  52. *> and P**H are defined as products of elementary reflectors H(i) and
  53. *> G(i) respectively.
  54. *>
  55. *> Let nq = m if SIDE = 'L' and nq = n if SIDE = 'R'. Thus nq is the
  56. *> order of the unitary matrix Q or P**H that is applied.
  57. *>
  58. *> If VECT = 'Q', A is assumed to have been an NQ-by-K matrix:
  59. *> if nq >= k, Q = H(1) H(2) . . . H(k);
  60. *> if nq < k, Q = H(1) H(2) . . . H(nq-1).
  61. *>
  62. *> If VECT = 'P', A is assumed to have been a K-by-NQ matrix:
  63. *> if k < nq, P = G(1) G(2) . . . G(k);
  64. *> if k >= nq, P = G(1) G(2) . . . G(nq-1).
  65. *> \endverbatim
  66. *
  67. * Arguments:
  68. * ==========
  69. *
  70. *> \param[in] VECT
  71. *> \verbatim
  72. *> VECT is CHARACTER*1
  73. *> = 'Q': apply Q or Q**H;
  74. *> = 'P': apply P or P**H.
  75. *> \endverbatim
  76. *>
  77. *> \param[in] SIDE
  78. *> \verbatim
  79. *> SIDE is CHARACTER*1
  80. *> = 'L': apply Q, Q**H, P or P**H from the Left;
  81. *> = 'R': apply Q, Q**H, P or P**H from the Right.
  82. *> \endverbatim
  83. *>
  84. *> \param[in] TRANS
  85. *> \verbatim
  86. *> TRANS is CHARACTER*1
  87. *> = 'N': No transpose, apply Q or P;
  88. *> = 'C': Conjugate transpose, apply Q**H or P**H.
  89. *> \endverbatim
  90. *>
  91. *> \param[in] M
  92. *> \verbatim
  93. *> M is INTEGER
  94. *> The number of rows of the matrix C. M >= 0.
  95. *> \endverbatim
  96. *>
  97. *> \param[in] N
  98. *> \verbatim
  99. *> N is INTEGER
  100. *> The number of columns of the matrix C. N >= 0.
  101. *> \endverbatim
  102. *>
  103. *> \param[in] K
  104. *> \verbatim
  105. *> K is INTEGER
  106. *> If VECT = 'Q', the number of columns in the original
  107. *> matrix reduced by ZGEBRD.
  108. *> If VECT = 'P', the number of rows in the original
  109. *> matrix reduced by ZGEBRD.
  110. *> K >= 0.
  111. *> \endverbatim
  112. *>
  113. *> \param[in] A
  114. *> \verbatim
  115. *> A is COMPLEX*16 array, dimension
  116. *> (LDA,min(nq,K)) if VECT = 'Q'
  117. *> (LDA,nq) if VECT = 'P'
  118. *> The vectors which define the elementary reflectors H(i) and
  119. *> G(i), whose products determine the matrices Q and P, as
  120. *> returned by ZGEBRD.
  121. *> \endverbatim
  122. *>
  123. *> \param[in] LDA
  124. *> \verbatim
  125. *> LDA is INTEGER
  126. *> The leading dimension of the array A.
  127. *> If VECT = 'Q', LDA >= max(1,nq);
  128. *> if VECT = 'P', LDA >= max(1,min(nq,K)).
  129. *> \endverbatim
  130. *>
  131. *> \param[in] TAU
  132. *> \verbatim
  133. *> TAU is COMPLEX*16 array, dimension (min(nq,K))
  134. *> TAU(i) must contain the scalar factor of the elementary
  135. *> reflector H(i) or G(i) which determines Q or P, as returned
  136. *> by ZGEBRD in the array argument TAUQ or TAUP.
  137. *> \endverbatim
  138. *>
  139. *> \param[in,out] C
  140. *> \verbatim
  141. *> C is COMPLEX*16 array, dimension (LDC,N)
  142. *> On entry, the M-by-N matrix C.
  143. *> On exit, C is overwritten by Q*C or Q**H*C or C*Q**H or C*Q
  144. *> or P*C or P**H*C or C*P or C*P**H.
  145. *> \endverbatim
  146. *>
  147. *> \param[in] LDC
  148. *> \verbatim
  149. *> LDC is INTEGER
  150. *> The leading dimension of the array C. LDC >= max(1,M).
  151. *> \endverbatim
  152. *>
  153. *> \param[out] WORK
  154. *> \verbatim
  155. *> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))
  156. *> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  157. *> \endverbatim
  158. *>
  159. *> \param[in] LWORK
  160. *> \verbatim
  161. *> LWORK is INTEGER
  162. *> The dimension of the array WORK.
  163. *> If SIDE = 'L', LWORK >= max(1,N);
  164. *> if SIDE = 'R', LWORK >= max(1,M);
  165. *> if N = 0 or M = 0, LWORK >= 1.
  166. *> For optimum performance LWORK >= max(1,N*NB) if SIDE = 'L',
  167. *> and LWORK >= max(1,M*NB) if SIDE = 'R', where NB is the
  168. *> optimal blocksize. (NB = 0 if M = 0 or N = 0.)
  169. *>
  170. *> If LWORK = -1, then a workspace query is assumed; the routine
  171. *> only calculates the optimal size of the WORK array, returns
  172. *> this value as the first entry of the WORK array, and no error
  173. *> message related to LWORK is issued by XERBLA.
  174. *> \endverbatim
  175. *>
  176. *> \param[out] INFO
  177. *> \verbatim
  178. *> INFO is INTEGER
  179. *> = 0: successful exit
  180. *> < 0: if INFO = -i, the i-th argument had an illegal value
  181. *> \endverbatim
  182. *
  183. * Authors:
  184. * ========
  185. *
  186. *> \author Univ. of Tennessee
  187. *> \author Univ. of California Berkeley
  188. *> \author Univ. of Colorado Denver
  189. *> \author NAG Ltd.
  190. *
  191. *> \ingroup complex16OTHERcomputational
  192. *
  193. * =====================================================================
  194. SUBROUTINE ZUNMBR( VECT, SIDE, TRANS, M, N, K, A, LDA, TAU, C,
  195. $ LDC, WORK, LWORK, INFO )
  196. *
  197. * -- LAPACK computational routine --
  198. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  199. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  200. *
  201. * .. Scalar Arguments ..
  202. CHARACTER SIDE, TRANS, VECT
  203. INTEGER INFO, K, LDA, LDC, LWORK, M, N
  204. * ..
  205. * .. Array Arguments ..
  206. COMPLEX*16 A( LDA, * ), C( LDC, * ), TAU( * ), WORK( * )
  207. * ..
  208. *
  209. * =====================================================================
  210. *
  211. * .. Local Scalars ..
  212. LOGICAL APPLYQ, LEFT, LQUERY, NOTRAN
  213. CHARACTER TRANST
  214. INTEGER I1, I2, IINFO, LWKOPT, MI, NB, NI, NQ, NW
  215. * ..
  216. * .. External Functions ..
  217. LOGICAL LSAME
  218. INTEGER ILAENV
  219. EXTERNAL LSAME, ILAENV
  220. * ..
  221. * .. External Subroutines ..
  222. EXTERNAL XERBLA, ZUNMLQ, ZUNMQR
  223. * ..
  224. * .. Intrinsic Functions ..
  225. INTRINSIC MAX, MIN
  226. * ..
  227. * .. Executable Statements ..
  228. *
  229. * Test the input arguments
  230. *
  231. INFO = 0
  232. APPLYQ = LSAME( VECT, 'Q' )
  233. LEFT = LSAME( SIDE, 'L' )
  234. NOTRAN = LSAME( TRANS, 'N' )
  235. LQUERY = ( LWORK.EQ.-1 )
  236. *
  237. * NQ is the order of Q or P and NW is the minimum dimension of WORK
  238. *
  239. IF( LEFT ) THEN
  240. NQ = M
  241. NW = MAX( 1, N )
  242. ELSE
  243. NQ = N
  244. NW = MAX( 1, M )
  245. END IF
  246. IF( .NOT.APPLYQ .AND. .NOT.LSAME( VECT, 'P' ) ) THEN
  247. INFO = -1
  248. ELSE IF( .NOT.LEFT .AND. .NOT.LSAME( SIDE, 'R' ) ) THEN
  249. INFO = -2
  250. ELSE IF( .NOT.NOTRAN .AND. .NOT.LSAME( TRANS, 'C' ) ) THEN
  251. INFO = -3
  252. ELSE IF( M.LT.0 ) THEN
  253. INFO = -4
  254. ELSE IF( N.LT.0 ) THEN
  255. INFO = -5
  256. ELSE IF( K.LT.0 ) THEN
  257. INFO = -6
  258. ELSE IF( ( APPLYQ .AND. LDA.LT.MAX( 1, NQ ) ) .OR.
  259. $ ( .NOT.APPLYQ .AND. LDA.LT.MAX( 1, MIN( NQ, K ) ) ) )
  260. $ THEN
  261. INFO = -8
  262. ELSE IF( LDC.LT.MAX( 1, M ) ) THEN
  263. INFO = -11
  264. ELSE IF( LWORK.LT.NW .AND. .NOT.LQUERY ) THEN
  265. INFO = -13
  266. END IF
  267. *
  268. IF( INFO.EQ.0 ) THEN
  269. IF( M.GT.0 .AND. N.GT.0 ) THEN
  270. IF( APPLYQ ) THEN
  271. IF( LEFT ) THEN
  272. NB = ILAENV( 1, 'ZUNMQR', SIDE // TRANS, M-1, N, M-1,
  273. $ -1 )
  274. ELSE
  275. NB = ILAENV( 1, 'ZUNMQR', SIDE // TRANS, M, N-1, N-1,
  276. $ -1 )
  277. END IF
  278. ELSE
  279. IF( LEFT ) THEN
  280. NB = ILAENV( 1, 'ZUNMLQ', SIDE // TRANS, M-1, N, M-1,
  281. $ -1 )
  282. ELSE
  283. NB = ILAENV( 1, 'ZUNMLQ', SIDE // TRANS, M, N-1, N-1,
  284. $ -1 )
  285. END IF
  286. END IF
  287. LWKOPT = NW*NB
  288. ELSE
  289. LWKOPT = 1
  290. END IF
  291. WORK( 1 ) = LWKOPT
  292. END IF
  293. *
  294. IF( INFO.NE.0 ) THEN
  295. CALL XERBLA( 'ZUNMBR', -INFO )
  296. RETURN
  297. ELSE IF( LQUERY ) THEN
  298. RETURN
  299. END IF
  300. *
  301. * Quick return if possible
  302. *
  303. IF( M.EQ.0 .OR. N.EQ.0 )
  304. $ RETURN
  305. *
  306. IF( APPLYQ ) THEN
  307. *
  308. * Apply Q
  309. *
  310. IF( NQ.GE.K ) THEN
  311. *
  312. * Q was determined by a call to ZGEBRD with nq >= k
  313. *
  314. CALL ZUNMQR( SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC,
  315. $ WORK, LWORK, IINFO )
  316. ELSE IF( NQ.GT.1 ) THEN
  317. *
  318. * Q was determined by a call to ZGEBRD with nq < k
  319. *
  320. IF( LEFT ) THEN
  321. MI = M - 1
  322. NI = N
  323. I1 = 2
  324. I2 = 1
  325. ELSE
  326. MI = M
  327. NI = N - 1
  328. I1 = 1
  329. I2 = 2
  330. END IF
  331. CALL ZUNMQR( SIDE, TRANS, MI, NI, NQ-1, A( 2, 1 ), LDA, TAU,
  332. $ C( I1, I2 ), LDC, WORK, LWORK, IINFO )
  333. END IF
  334. ELSE
  335. *
  336. * Apply P
  337. *
  338. IF( NOTRAN ) THEN
  339. TRANST = 'C'
  340. ELSE
  341. TRANST = 'N'
  342. END IF
  343. IF( NQ.GT.K ) THEN
  344. *
  345. * P was determined by a call to ZGEBRD with nq > k
  346. *
  347. CALL ZUNMLQ( SIDE, TRANST, M, N, K, A, LDA, TAU, C, LDC,
  348. $ WORK, LWORK, IINFO )
  349. ELSE IF( NQ.GT.1 ) THEN
  350. *
  351. * P was determined by a call to ZGEBRD with nq <= k
  352. *
  353. IF( LEFT ) THEN
  354. MI = M - 1
  355. NI = N
  356. I1 = 2
  357. I2 = 1
  358. ELSE
  359. MI = M
  360. NI = N - 1
  361. I1 = 1
  362. I2 = 2
  363. END IF
  364. CALL ZUNMLQ( SIDE, TRANST, MI, NI, NQ-1, A( 1, 2 ), LDA,
  365. $ TAU, C( I1, I2 ), LDC, WORK, LWORK, IINFO )
  366. END IF
  367. END IF
  368. WORK( 1 ) = LWKOPT
  369. RETURN
  370. *
  371. * End of ZUNMBR
  372. *
  373. END