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.

dlaqz4.f 17 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  1. *> \brief \b DLAQZ4
  2. *
  3. * =========== DOCUMENTATION ===========
  4. *
  5. * Online html documentation available at
  6. * http://www.netlib.org/lapack/explore-html/
  7. *
  8. *> \htmlonly
  9. *> Download DLAQZ4 + dependencies
  10. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlaqz4.f">
  11. *> [TGZ]</a>
  12. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlaqz4.f">
  13. *> [ZIP]</a>
  14. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlaqz4.f">
  15. *> [TXT]</a>
  16. *> \endhtmlonly
  17. *
  18. * Definition:
  19. * ===========
  20. *
  21. * SUBROUTINE DLAQZ4( ILSCHUR, ILQ, ILZ, N, ILO, IHI, NSHIFTS,
  22. * $ NBLOCK_DESIRED, SR, SI, SS, A, LDA, B, LDB, Q, LDQ, Z, LDZ,
  23. * $ QC, LDQC, ZC, LDZC, WORK, LWORK, INFO )
  24. * IMPLICIT NONE
  25. *
  26. * Function arguments
  27. * LOGICAL, INTENT( IN ) :: ILSCHUR, ILQ, ILZ
  28. * INTEGER, INTENT( IN ) :: N, ILO, IHI, LDA, LDB, LDQ, LDZ, LWORK,
  29. * $ NSHIFTS, NBLOCK_DESIRED, LDQC, LDZC
  30. *
  31. * DOUBLE PRECISION, INTENT( INOUT ) :: A( LDA, * ), B( LDB, * ),
  32. * $ Q( LDQ, * ), Z( LDZ, * ), QC( LDQC, * ), ZC( LDZC, * ),
  33. * $ WORK( * ), SR( * ), SI( * ), SS( * )
  34. *
  35. * INTEGER, INTENT( OUT ) :: INFO
  36. * ..
  37. *
  38. *
  39. *> \par Purpose:
  40. * =============
  41. *>
  42. *> \verbatim
  43. *>
  44. *> DLAQZ4 Executes a single multishift QZ sweep
  45. *> \endverbatim
  46. *
  47. * Arguments:
  48. * ==========
  49. *
  50. *> \param[in] ILSCHUR
  51. *> \verbatim
  52. *> ILSCHUR is LOGICAL
  53. *> Determines whether or not to update the full Schur form
  54. *> \endverbatim
  55. *> \param[in] ILQ
  56. *> \verbatim
  57. *> ILQ is LOGICAL
  58. *> Determines whether or not to update the matrix Q
  59. *> \endverbatim
  60. *>
  61. *> \param[in] ILZ
  62. *> \verbatim
  63. *> ILZ is LOGICAL
  64. *> Determines whether or not to update the matrix Z
  65. *> \endverbatim
  66. *>
  67. *> \param[in] N
  68. *> \verbatim
  69. *> N is INTEGER
  70. *> The order of the matrices A, B, Q, and Z. N >= 0.
  71. *> \endverbatim
  72. *>
  73. *> \param[in] ILO
  74. *> \verbatim
  75. *> ILO is INTEGER
  76. *> \endverbatim
  77. *>
  78. *> \param[in] IHI
  79. *> \verbatim
  80. *> IHI is INTEGER
  81. *> \endverbatim
  82. *>
  83. *> \param[in] NSHIFTS
  84. *> \verbatim
  85. *> NSHIFTS is INTEGER
  86. *> The desired number of shifts to use
  87. *> \endverbatim
  88. *>
  89. *> \param[in] NBLOCK_DESIRED
  90. *> \verbatim
  91. *> NBLOCK_DESIRED is INTEGER
  92. *> The desired size of the computational windows
  93. *> \endverbatim
  94. *>
  95. *> \param[in] SR
  96. *> \verbatim
  97. *> SR is DOUBLE PRECISION array. SR contains
  98. *> the real parts of the shifts to use.
  99. *> \endverbatim
  100. *>
  101. *> \param[in] SI
  102. *> \verbatim
  103. *> SI is DOUBLE PRECISION array. SI contains
  104. *> the imaginary parts of the shifts to use.
  105. *> \endverbatim
  106. *>
  107. *> \param[in] SS
  108. *> \verbatim
  109. *> SS is DOUBLE PRECISION array. SS contains
  110. *> the scale of the shifts to use.
  111. *> \endverbatim
  112. *>
  113. *> \param[in,out] A
  114. *> \verbatim
  115. *> A is DOUBLE PRECISION array, dimension (LDA, N)
  116. *> \endverbatim
  117. *>
  118. *> \param[in] LDA
  119. *> \verbatim
  120. *> LDA is INTEGER
  121. *> The leading dimension of the array A. LDA >= max( 1, N ).
  122. *> \endverbatim
  123. *>
  124. *> \param[in,out] B
  125. *> \verbatim
  126. *> B is DOUBLE PRECISION array, dimension (LDB, N)
  127. *> \endverbatim
  128. *>
  129. *> \param[in] LDB
  130. *> \verbatim
  131. *> LDB is INTEGER
  132. *> The leading dimension of the array B. LDB >= max( 1, N ).
  133. *> \endverbatim
  134. *>
  135. *> \param[in,out] Q
  136. *> \verbatim
  137. *> Q is DOUBLE PRECISION array, dimension (LDQ, N)
  138. *> \endverbatim
  139. *>
  140. *> \param[in] LDQ
  141. *> \verbatim
  142. *> LDQ is INTEGER
  143. *> \endverbatim
  144. *>
  145. *> \param[in,out] Z
  146. *> \verbatim
  147. *> Z is DOUBLE PRECISION array, dimension (LDZ, N)
  148. *> \endverbatim
  149. *>
  150. *> \param[in] LDZ
  151. *> \verbatim
  152. *> LDZ is INTEGER
  153. *> \endverbatim
  154. *>
  155. *> \param[in,out] QC
  156. *> \verbatim
  157. *> QC is DOUBLE PRECISION array, dimension (LDQC, NBLOCK_DESIRED)
  158. *> \endverbatim
  159. *>
  160. *> \param[in] LDQC
  161. *> \verbatim
  162. *> LDQC is INTEGER
  163. *> \endverbatim
  164. *>
  165. *> \param[in,out] ZC
  166. *> \verbatim
  167. *> ZC is DOUBLE PRECISION array, dimension (LDZC, NBLOCK_DESIRED)
  168. *> \endverbatim
  169. *>
  170. *> \param[in] LDZC
  171. *> \verbatim
  172. *> LDZ is INTEGER
  173. *> \endverbatim
  174. *>
  175. *> \param[out] WORK
  176. *> \verbatim
  177. *> WORK is DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  178. *> On exit, if INFO >= 0, WORK(1) returns the optimal LWORK.
  179. *> \endverbatim
  180. *>
  181. *> \param[in] LWORK
  182. *> \verbatim
  183. *> LWORK is INTEGER
  184. *> The dimension of the array WORK. LWORK >= max(1,N).
  185. *>
  186. *> If LWORK = -1, then a workspace query is assumed; the routine
  187. *> only calculates the optimal size of the WORK array, returns
  188. *> this value as the first entry of the WORK array, and no error
  189. *> message related to LWORK is issued by XERBLA.
  190. *> \endverbatim
  191. *>
  192. *> \param[out] INFO
  193. *> \verbatim
  194. *> INFO is INTEGER
  195. *> = 0: successful exit
  196. *> < 0: if INFO = -i, the i-th argument had an illegal value
  197. *> \endverbatim
  198. *
  199. * Authors:
  200. * ========
  201. *
  202. *> \author Thijs Steel, KU Leuven
  203. *
  204. *> \date May 2020
  205. *
  206. *> \ingroup doubleGEcomputational
  207. *>
  208. * =====================================================================
  209. SUBROUTINE DLAQZ4( ILSCHUR, ILQ, ILZ, N, ILO, IHI, NSHIFTS,
  210. $ NBLOCK_DESIRED, SR, SI, SS, A, LDA, B, LDB, Q,
  211. $ LDQ, Z, LDZ, QC, LDQC, ZC, LDZC, WORK, LWORK,
  212. $ INFO )
  213. IMPLICIT NONE
  214. * Function arguments
  215. LOGICAL, INTENT( IN ) :: ILSCHUR, ILQ, ILZ
  216. INTEGER, INTENT( IN ) :: N, ILO, IHI, LDA, LDB, LDQ, LDZ, LWORK,
  217. $ NSHIFTS, NBLOCK_DESIRED, LDQC, LDZC
  218. DOUBLE PRECISION, INTENT( INOUT ) :: A( LDA, * ), B( LDB, * ),
  219. $ Q( LDQ, * ), Z( LDZ, * ), QC( LDQC, * ),
  220. $ ZC( LDZC, * ), WORK( * ), SR( * ), SI( * ),
  221. $ SS( * )
  222. INTEGER, INTENT( OUT ) :: INFO
  223. * Parameters
  224. DOUBLE PRECISION :: ZERO, ONE, HALF
  225. PARAMETER( ZERO = 0.0D0, ONE = 1.0D0, HALF = 0.5D0 )
  226. * Local scalars
  227. INTEGER :: I, J, NS, ISTARTM, ISTOPM, SHEIGHT, SWIDTH, K, NP,
  228. $ ISTARTB, ISTOPB, ISHIFT, NBLOCK, NPOS
  229. DOUBLE PRECISION :: TEMP, V( 3 ), C1, S1, C2, S2, SWAP
  230. *
  231. * External functions
  232. EXTERNAL :: XERBLA, DGEMM, DLAQZ1, DLAQZ2, DLASET, DLARTG, DROT,
  233. $ DLACPY
  234. INFO = 0
  235. IF ( NBLOCK_DESIRED .LT. NSHIFTS+1 ) THEN
  236. INFO = -8
  237. END IF
  238. IF ( LWORK .EQ.-1 ) THEN
  239. * workspace query, quick return
  240. WORK( 1 ) = N*NBLOCK_DESIRED
  241. RETURN
  242. ELSE IF ( LWORK .LT. N*NBLOCK_DESIRED ) THEN
  243. INFO = -25
  244. END IF
  245. IF( INFO.NE.0 ) THEN
  246. CALL XERBLA( 'DLAQZ4', -INFO )
  247. RETURN
  248. END IF
  249. * Executable statements
  250. IF ( NSHIFTS .LT. 2 ) THEN
  251. RETURN
  252. END IF
  253. IF ( ILO .GE. IHI ) THEN
  254. RETURN
  255. END IF
  256. IF ( ILSCHUR ) THEN
  257. ISTARTM = 1
  258. ISTOPM = N
  259. ELSE
  260. ISTARTM = ILO
  261. ISTOPM = IHI
  262. END IF
  263. * Shuffle shifts into pairs of real shifts and pairs
  264. * of complex conjugate shifts assuming complex
  265. * conjugate shifts are already adjacent to one
  266. * another
  267. DO I = 1, NSHIFTS-2, 2
  268. IF( SI( I ).NE.-SI( I+1 ) ) THEN
  269. *
  270. SWAP = SR( I )
  271. SR( I ) = SR( I+1 )
  272. SR( I+1 ) = SR( I+2 )
  273. SR( I+2 ) = SWAP
  274. SWAP = SI( I )
  275. SI( I ) = SI( I+1 )
  276. SI( I+1 ) = SI( I+2 )
  277. SI( I+2 ) = SWAP
  278. SWAP = SS( I )
  279. SS( I ) = SS( I+1 )
  280. SS( I+1 ) = SS( I+2 )
  281. SS( I+2 ) = SWAP
  282. END IF
  283. END DO
  284. * NSHFTS is supposed to be even, but if it is odd,
  285. * then simply reduce it by one. The shuffle above
  286. * ensures that the dropped shift is real and that
  287. * the remaining shifts are paired.
  288. NS = NSHIFTS-MOD( NSHIFTS, 2 )
  289. NPOS = MAX( NBLOCK_DESIRED-NS, 1 )
  290. * The following block introduces the shifts and chases
  291. * them down one by one just enough to make space for
  292. * the other shifts. The near-the-diagonal block is
  293. * of size (ns+1) x ns.
  294. CALL DLASET( 'FULL', NS+1, NS+1, ZERO, ONE, QC, LDQC )
  295. CALL DLASET( 'FULL', NS, NS, ZERO, ONE, ZC, LDZC )
  296. DO I = 1, NS, 2
  297. * Introduce the shift
  298. CALL DLAQZ1( A( ILO, ILO ), LDA, B( ILO, ILO ), LDB, SR( I ),
  299. $ SR( I+1 ), SI( I ), SS( I ), SS( I+1 ), V )
  300. TEMP = V( 2 )
  301. CALL DLARTG( TEMP, V( 3 ), C1, S1, V( 2 ) )
  302. CALL DLARTG( V( 1 ), V( 2 ), C2, S2, TEMP )
  303. CALL DROT( NS, A( ILO+1, ILO ), LDA, A( ILO+2, ILO ), LDA, C1,
  304. $ S1 )
  305. CALL DROT( NS, A( ILO, ILO ), LDA, A( ILO+1, ILO ), LDA, C2,
  306. $ S2 )
  307. CALL DROT( NS, B( ILO+1, ILO ), LDB, B( ILO+2, ILO ), LDB, C1,
  308. $ S1 )
  309. CALL DROT( NS, B( ILO, ILO ), LDB, B( ILO+1, ILO ), LDB, C2,
  310. $ S2 )
  311. CALL DROT( NS+1, QC( 1, 2 ), 1, QC( 1, 3 ), 1, C1, S1 )
  312. CALL DROT( NS+1, QC( 1, 1 ), 1, QC( 1, 2 ), 1, C2, S2 )
  313. * Chase the shift down
  314. DO J = 1, NS-1-I
  315. CALL DLAQZ2( .TRUE., .TRUE., J, 1, NS, IHI-ILO+1, A( ILO,
  316. $ ILO ), LDA, B( ILO, ILO ), LDB, NS+1, 1, QC,
  317. $ LDQC, NS, 1, ZC, LDZC )
  318. END DO
  319. END DO
  320. * Update the rest of the pencil
  321. * Update A(ilo:ilo+ns,ilo+ns:istopm) and B(ilo:ilo+ns,ilo+ns:istopm)
  322. * from the left with Qc(1:ns+1,1:ns+1)'
  323. SHEIGHT = NS+1
  324. SWIDTH = ISTOPM-( ILO+NS )+1
  325. IF ( SWIDTH > 0 ) THEN
  326. CALL DGEMM( 'T', 'N', SHEIGHT, SWIDTH, SHEIGHT, ONE, QC, LDQC,
  327. $ A( ILO, ILO+NS ), LDA, ZERO, WORK, SHEIGHT )
  328. CALL DLACPY( 'ALL', SHEIGHT, SWIDTH, WORK, SHEIGHT, A( ILO,
  329. $ ILO+NS ), LDA )
  330. CALL DGEMM( 'T', 'N', SHEIGHT, SWIDTH, SHEIGHT, ONE, QC, LDQC,
  331. $ B( ILO, ILO+NS ), LDB, ZERO, WORK, SHEIGHT )
  332. CALL DLACPY( 'ALL', SHEIGHT, SWIDTH, WORK, SHEIGHT, B( ILO,
  333. $ ILO+NS ), LDB )
  334. END IF
  335. IF ( ILQ ) THEN
  336. CALL DGEMM( 'N', 'N', N, SHEIGHT, SHEIGHT, ONE, Q( 1, ILO ),
  337. $ LDQ, QC, LDQC, ZERO, WORK, N )
  338. CALL DLACPY( 'ALL', N, SHEIGHT, WORK, N, Q( 1, ILO ), LDQ )
  339. END IF
  340. * Update A(istartm:ilo-1,ilo:ilo+ns-1) and B(istartm:ilo-1,ilo:ilo+ns-1)
  341. * from the right with Zc(1:ns,1:ns)
  342. SHEIGHT = ILO-1-ISTARTM+1
  343. SWIDTH = NS
  344. IF ( SHEIGHT > 0 ) THEN
  345. CALL DGEMM( 'N', 'N', SHEIGHT, SWIDTH, SWIDTH, ONE, A( ISTARTM,
  346. $ ILO ), LDA, ZC, LDZC, ZERO, WORK, SHEIGHT )
  347. CALL DLACPY( 'ALL', SHEIGHT, SWIDTH, WORK, SHEIGHT, A( ISTARTM,
  348. $ ILO ), LDA )
  349. CALL DGEMM( 'N', 'N', SHEIGHT, SWIDTH, SWIDTH, ONE, B( ISTARTM,
  350. $ ILO ), LDB, ZC, LDZC, ZERO, WORK, SHEIGHT )
  351. CALL DLACPY( 'ALL', SHEIGHT, SWIDTH, WORK, SHEIGHT, B( ISTARTM,
  352. $ ILO ), LDB )
  353. END IF
  354. IF ( ILZ ) THEN
  355. CALL DGEMM( 'N', 'N', N, SWIDTH, SWIDTH, ONE, Z( 1, ILO ), LDZ,
  356. $ ZC, LDZC, ZERO, WORK, N )
  357. CALL DLACPY( 'ALL', N, SWIDTH, WORK, N, Z( 1, ILO ), LDZ )
  358. END IF
  359. * The following block chases the shifts down to the bottom
  360. * right block. If possible, a shift is moved down npos
  361. * positions at a time
  362. K = ILO
  363. DO WHILE ( K < IHI-NS )
  364. NP = MIN( IHI-NS-K, NPOS )
  365. * Size of the near-the-diagonal block
  366. NBLOCK = NS+NP
  367. * istartb points to the first row we will be updating
  368. ISTARTB = K+1
  369. * istopb points to the last column we will be updating
  370. ISTOPB = K+NBLOCK-1
  371. CALL DLASET( 'FULL', NS+NP, NS+NP, ZERO, ONE, QC, LDQC )
  372. CALL DLASET( 'FULL', NS+NP, NS+NP, ZERO, ONE, ZC, LDZC )
  373. * Near the diagonal shift chase
  374. DO I = NS-1, 0, -2
  375. DO J = 0, NP-1
  376. * Move down the block with index k+i+j-1, updating
  377. * the (ns+np x ns+np) block:
  378. * (k:k+ns+np,k:k+ns+np-1)
  379. CALL DLAQZ2( .TRUE., .TRUE., K+I+J-1, ISTARTB, ISTOPB,
  380. $ IHI, A, LDA, B, LDB, NBLOCK, K+1, QC, LDQC,
  381. $ NBLOCK, K, ZC, LDZC )
  382. END DO
  383. END DO
  384. * Update rest of the pencil
  385. * Update A(k+1:k+ns+np, k+ns+np:istopm) and
  386. * B(k+1:k+ns+np, k+ns+np:istopm)
  387. * from the left with Qc(1:ns+np,1:ns+np)'
  388. SHEIGHT = NS+NP
  389. SWIDTH = ISTOPM-( K+NS+NP )+1
  390. IF ( SWIDTH > 0 ) THEN
  391. CALL DGEMM( 'T', 'N', SHEIGHT, SWIDTH, SHEIGHT, ONE, QC,
  392. $ LDQC, A( K+1, K+NS+NP ), LDA, ZERO, WORK,
  393. $ SHEIGHT )
  394. CALL DLACPY( 'ALL', SHEIGHT, SWIDTH, WORK, SHEIGHT, A( K+1,
  395. $ K+NS+NP ), LDA )
  396. CALL DGEMM( 'T', 'N', SHEIGHT, SWIDTH, SHEIGHT, ONE, QC,
  397. $ LDQC, B( K+1, K+NS+NP ), LDB, ZERO, WORK,
  398. $ SHEIGHT )
  399. CALL DLACPY( 'ALL', SHEIGHT, SWIDTH, WORK, SHEIGHT, B( K+1,
  400. $ K+NS+NP ), LDB )
  401. END IF
  402. IF ( ILQ ) THEN
  403. CALL DGEMM( 'N', 'N', N, NBLOCK, NBLOCK, ONE, Q( 1, K+1 ),
  404. $ LDQ, QC, LDQC, ZERO, WORK, N )
  405. CALL DLACPY( 'ALL', N, NBLOCK, WORK, N, Q( 1, K+1 ), LDQ )
  406. END IF
  407. * Update A(istartm:k,k:k+ns+npos-1) and B(istartm:k,k:k+ns+npos-1)
  408. * from the right with Zc(1:ns+np,1:ns+np)
  409. SHEIGHT = K-ISTARTM+1
  410. SWIDTH = NBLOCK
  411. IF ( SHEIGHT > 0 ) THEN
  412. CALL DGEMM( 'N', 'N', SHEIGHT, SWIDTH, SWIDTH, ONE,
  413. $ A( ISTARTM, K ), LDA, ZC, LDZC, ZERO, WORK,
  414. $ SHEIGHT )
  415. CALL DLACPY( 'ALL', SHEIGHT, SWIDTH, WORK, SHEIGHT,
  416. $ A( ISTARTM, K ), LDA )
  417. CALL DGEMM( 'N', 'N', SHEIGHT, SWIDTH, SWIDTH, ONE,
  418. $ B( ISTARTM, K ), LDB, ZC, LDZC, ZERO, WORK,
  419. $ SHEIGHT )
  420. CALL DLACPY( 'ALL', SHEIGHT, SWIDTH, WORK, SHEIGHT,
  421. $ B( ISTARTM, K ), LDB )
  422. END IF
  423. IF ( ILZ ) THEN
  424. CALL DGEMM( 'N', 'N', N, NBLOCK, NBLOCK, ONE, Z( 1, K ),
  425. $ LDZ, ZC, LDZC, ZERO, WORK, N )
  426. CALL DLACPY( 'ALL', N, NBLOCK, WORK, N, Z( 1, K ), LDZ )
  427. END IF
  428. K = K+NP
  429. END DO
  430. * The following block removes the shifts from the bottom right corner
  431. * one by one. Updates are initially applied to A(ihi-ns+1:ihi,ihi-ns:ihi).
  432. CALL DLASET( 'FULL', NS, NS, ZERO, ONE, QC, LDQC )
  433. CALL DLASET( 'FULL', NS+1, NS+1, ZERO, ONE, ZC, LDZC )
  434. * istartb points to the first row we will be updating
  435. ISTARTB = IHI-NS+1
  436. * istopb points to the last column we will be updating
  437. ISTOPB = IHI
  438. DO I = 1, NS, 2
  439. * Chase the shift down to the bottom right corner
  440. DO ISHIFT = IHI-I-1, IHI-2
  441. CALL DLAQZ2( .TRUE., .TRUE., ISHIFT, ISTARTB, ISTOPB, IHI,
  442. $ A, LDA, B, LDB, NS, IHI-NS+1, QC, LDQC, NS+1,
  443. $ IHI-NS, ZC, LDZC )
  444. END DO
  445. END DO
  446. * Update rest of the pencil
  447. * Update A(ihi-ns+1:ihi, ihi+1:istopm)
  448. * from the left with Qc(1:ns,1:ns)'
  449. SHEIGHT = NS
  450. SWIDTH = ISTOPM-( IHI+1 )+1
  451. IF ( SWIDTH > 0 ) THEN
  452. CALL DGEMM( 'T', 'N', SHEIGHT, SWIDTH, SHEIGHT, ONE, QC, LDQC,
  453. $ A( IHI-NS+1, IHI+1 ), LDA, ZERO, WORK, SHEIGHT )
  454. CALL DLACPY( 'ALL', SHEIGHT, SWIDTH, WORK, SHEIGHT,
  455. $ A( IHI-NS+1, IHI+1 ), LDA )
  456. CALL DGEMM( 'T', 'N', SHEIGHT, SWIDTH, SHEIGHT, ONE, QC, LDQC,
  457. $ B( IHI-NS+1, IHI+1 ), LDB, ZERO, WORK, SHEIGHT )
  458. CALL DLACPY( 'ALL', SHEIGHT, SWIDTH, WORK, SHEIGHT,
  459. $ B( IHI-NS+1, IHI+1 ), LDB )
  460. END IF
  461. IF ( ILQ ) THEN
  462. CALL DGEMM( 'N', 'N', N, NS, NS, ONE, Q( 1, IHI-NS+1 ), LDQ,
  463. $ QC, LDQC, ZERO, WORK, N )
  464. CALL DLACPY( 'ALL', N, NS, WORK, N, Q( 1, IHI-NS+1 ), LDQ )
  465. END IF
  466. * Update A(istartm:ihi-ns,ihi-ns:ihi)
  467. * from the right with Zc(1:ns+1,1:ns+1)
  468. SHEIGHT = IHI-NS-ISTARTM+1
  469. SWIDTH = NS+1
  470. IF ( SHEIGHT > 0 ) THEN
  471. CALL DGEMM( 'N', 'N', SHEIGHT, SWIDTH, SWIDTH, ONE, A( ISTARTM,
  472. $ IHI-NS ), LDA, ZC, LDZC, ZERO, WORK, SHEIGHT )
  473. CALL DLACPY( 'ALL', SHEIGHT, SWIDTH, WORK, SHEIGHT, A( ISTARTM,
  474. $ IHI-NS ), LDA )
  475. CALL DGEMM( 'N', 'N', SHEIGHT, SWIDTH, SWIDTH, ONE, B( ISTARTM,
  476. $ IHI-NS ), LDB, ZC, LDZC, ZERO, WORK, SHEIGHT )
  477. CALL DLACPY( 'ALL', SHEIGHT, SWIDTH, WORK, SHEIGHT, B( ISTARTM,
  478. $ IHI-NS ), LDB )
  479. END IF
  480. IF ( ILZ ) THEN
  481. CALL DGEMM( 'N', 'N', N, NS+1, NS+1, ONE, Z( 1, IHI-NS ), LDZ,
  482. $ ZC, LDZC, ZERO, WORK, N )
  483. CALL DLACPY( 'ALL', N, NS+1, WORK, N, Z( 1, IHI-NS ), LDZ )
  484. END IF
  485. END SUBROUTINE