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.

zlasyf_aa.f 15 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  1. *> \brief \b ZLASYF_AA
  2. *
  3. * =========== DOCUMENTATION ===========
  4. *
  5. * Online html documentation available at
  6. * http://www.netlib.org/lapack/explore-html/
  7. *
  8. *> \htmlonly
  9. *> Download ZLASYF_AA + dependencies
  10. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlasyf_aa.f">
  11. *> [TGZ]</a>
  12. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlasyf_aa.f">
  13. *> [ZIP]</a>
  14. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlasyf_aa.f">
  15. *> [TXT]</a>
  16. *> \endhtmlonly
  17. *
  18. * Definition:
  19. * ===========
  20. *
  21. * SUBROUTINE ZLASYF_AA( UPLO, J1, M, NB, A, LDA, IPIV,
  22. * H, LDH, WORK, INFO )
  23. *
  24. * .. Scalar Arguments ..
  25. * CHARACTER UPLO
  26. * INTEGER J1, M, NB, LDA, LDH, INFO
  27. * ..
  28. * .. Array Arguments ..
  29. * INTEGER IPIV( * )
  30. * COMPLEX*16 A( LDA, * ), H( LDH, * ), WORK( * )
  31. * ..
  32. *
  33. *
  34. *> \par Purpose:
  35. * =============
  36. *>
  37. *> \verbatim
  38. *>
  39. *> DLATRF_AA factorizes a panel of a complex symmetric matrix A using
  40. *> the Aasen's algorithm. The panel consists of a set of NB rows of A
  41. *> when UPLO is U, or a set of NB columns when UPLO is L.
  42. *>
  43. *> In order to factorize the panel, the Aasen's algorithm requires the
  44. *> last row, or column, of the previous panel. The first row, or column,
  45. *> of A is set to be the first row, or column, of an identity matrix,
  46. *> which is used to factorize the first panel.
  47. *>
  48. *> The resulting J-th row of U, or J-th column of L, is stored in the
  49. *> (J-1)-th row, or column, of A (without the unit diagonals), while
  50. *> the diagonal and subdiagonal of A are overwritten by those of T.
  51. *>
  52. *> \endverbatim
  53. *
  54. * Arguments:
  55. * ==========
  56. *
  57. *> \param[in] UPLO
  58. *> \verbatim
  59. *> UPLO is CHARACTER*1
  60. *> = 'U': Upper triangle of A is stored;
  61. *> = 'L': Lower triangle of A is stored.
  62. *> \endverbatim
  63. *>
  64. *> \param[in] J1
  65. *> \verbatim
  66. *> J1 is INTEGER
  67. *> The location of the first row, or column, of the panel
  68. *> within the submatrix of A, passed to this routine, e.g.,
  69. *> when called by ZSYTRF_AA, for the first panel, J1 is 1,
  70. *> while for the remaining panels, J1 is 2.
  71. *> \endverbatim
  72. *>
  73. *> \param[in] M
  74. *> \verbatim
  75. *> M is INTEGER
  76. *> The dimension of the submatrix. M >= 0.
  77. *> \endverbatim
  78. *>
  79. *> \param[in] NB
  80. *> \verbatim
  81. *> NB is INTEGER
  82. *> The dimension of the panel to be facotorized.
  83. *> \endverbatim
  84. *>
  85. *> \param[in,out] A
  86. *> \verbatim
  87. *> A is COMPLEX*16 array, dimension (LDA,M) for
  88. *> the first panel, while dimension (LDA,M+1) for the
  89. *> remaining panels.
  90. *>
  91. *> On entry, A contains the last row, or column, of
  92. *> the previous panel, and the trailing submatrix of A
  93. *> to be factorized, except for the first panel, only
  94. *> the panel is passed.
  95. *>
  96. *> On exit, the leading panel is factorized.
  97. *> \endverbatim
  98. *>
  99. *> \param[in] LDA
  100. *> \verbatim
  101. *> LDA is INTEGER
  102. *> The leading dimension of the array A. LDA >= max(1,N).
  103. *> \endverbatim
  104. *>
  105. *> \param[out] IPIV
  106. *> \verbatim
  107. *> IPIV is INTEGER array, dimension (N)
  108. *> Details of the row and column interchanges,
  109. *> the row and column k were interchanged with the row and
  110. *> column IPIV(k).
  111. *> \endverbatim
  112. *>
  113. *> \param[in,out] H
  114. *> \verbatim
  115. *> H is COMPLEX*16 workspace, dimension (LDH,NB).
  116. *>
  117. *> \endverbatim
  118. *>
  119. *> \param[in] LDH
  120. *> \verbatim
  121. *> LDH is INTEGER
  122. *> The leading dimension of the workspace H. LDH >= max(1,M).
  123. *> \endverbatim
  124. *>
  125. *> \param[out] WORK
  126. *> \verbatim
  127. *> WORK is COMPLEX*16 workspace, dimension (M).
  128. *> \endverbatim
  129. *>
  130. *> \param[out] INFO
  131. *> \verbatim
  132. *> INFO is INTEGER
  133. *> = 0: successful exit
  134. *> < 0: if INFO = -i, the i-th argument had an illegal value
  135. *> > 0: if INFO = i, D(i,i) is exactly zero. The factorization
  136. *> has been completed, but the block diagonal matrix D is
  137. *> exactly singular, and division by zero will occur if it
  138. *> is used to solve a system of equations.
  139. *> \endverbatim
  140. *
  141. * Authors:
  142. * ========
  143. *
  144. *> \author Univ. of Tennessee
  145. *> \author Univ. of California Berkeley
  146. *> \author Univ. of Colorado Denver
  147. *> \author NAG Ltd.
  148. *
  149. *> \date December 2016
  150. *
  151. *> \ingroup complex16SYcomputational
  152. *
  153. * =====================================================================
  154. SUBROUTINE ZLASYF_AA( UPLO, J1, M, NB, A, LDA, IPIV,
  155. $ H, LDH, WORK, INFO )
  156. *
  157. * -- LAPACK computational routine (version 3.7.0) --
  158. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  159. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  160. * December 2016
  161. *
  162. IMPLICIT NONE
  163. *
  164. * .. Scalar Arguments ..
  165. CHARACTER UPLO
  166. INTEGER M, NB, J1, LDA, LDH, INFO
  167. * ..
  168. * .. Array Arguments ..
  169. INTEGER IPIV( * )
  170. COMPLEX*16 A( LDA, * ), H( LDH, * ), WORK( * )
  171. * ..
  172. *
  173. * =====================================================================
  174. * .. Parameters ..
  175. COMPLEX*16 ZERO, ONE
  176. PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )
  177. *
  178. * .. Local Scalars ..
  179. INTEGER J, K, K1, I1, I2
  180. COMPLEX*16 PIV, ALPHA
  181. * ..
  182. * .. External Functions ..
  183. LOGICAL LSAME
  184. INTEGER IZAMAX, ILAENV
  185. EXTERNAL LSAME, ILAENV, IZAMAX
  186. * ..
  187. * .. External Subroutines ..
  188. EXTERNAL XERBLA
  189. * ..
  190. * .. Intrinsic Functions ..
  191. INTRINSIC MAX
  192. * ..
  193. * .. Executable Statements ..
  194. *
  195. INFO = 0
  196. J = 1
  197. *
  198. * K1 is the first column of the panel to be factorized
  199. * i.e., K1 is 2 for the first block column, and 1 for the rest of the blocks
  200. *
  201. K1 = (2-J1)+1
  202. *
  203. IF( LSAME( UPLO, 'U' ) ) THEN
  204. *
  205. * .....................................................
  206. * Factorize A as U**T*D*U using the upper triangle of A
  207. * .....................................................
  208. *
  209. 10 CONTINUE
  210. IF ( J.GT.MIN(M, NB) )
  211. $ GO TO 20
  212. *
  213. * K is the column to be factorized
  214. * when being called from ZSYTRF_AA,
  215. * > for the first block column, J1 is 1, hence J1+J-1 is J,
  216. * > for the rest of the columns, J1 is 2, and J1+J-1 is J+1,
  217. *
  218. K = J1+J-1
  219. *
  220. * H(J:N, J) := A(J, J:N) - H(J:N, 1:(J-1)) * L(J1:(J-1), J),
  221. * where H(J:N, J) has been initialized to be A(J, J:N)
  222. *
  223. IF( K.GT.2 ) THEN
  224. *
  225. * K is the column to be factorized
  226. * > for the first block column, K is J, skipping the first two
  227. * columns
  228. * > for the rest of the columns, K is J+1, skipping only the
  229. * first column
  230. *
  231. CALL ZGEMV( 'No transpose', M-J+1, J-K1,
  232. $ -ONE, H( J, K1 ), LDH,
  233. $ A( 1, J ), 1,
  234. $ ONE, H( J, J ), 1 )
  235. END IF
  236. *
  237. * Copy H(i:n, i) into WORK
  238. *
  239. CALL ZCOPY( M-J+1, H( J, J ), 1, WORK( 1 ), 1 )
  240. *
  241. IF( J.GT.K1 ) THEN
  242. *
  243. * Compute WORK := WORK - L(J-1, J:N) * T(J-1,J),
  244. * where A(J-1, J) stores T(J-1, J) and A(J-2, J:N) stores U(J-1, J:N)
  245. *
  246. ALPHA = -A( K-1, J )
  247. CALL ZAXPY( M-J+1, ALPHA, A( K-2, J ), LDA, WORK( 1 ), 1 )
  248. END IF
  249. *
  250. * Set A(J, J) = T(J, J)
  251. *
  252. A( K, J ) = WORK( 1 )
  253. *
  254. IF( J.LT.M ) THEN
  255. *
  256. * Compute WORK(2:N) = T(J, J) L(J, (J+1):N)
  257. * where A(J, J) stores T(J, J) and A(J-1, (J+1):N) stores U(J, (J+1):N)
  258. *
  259. IF( K.GT.1 ) THEN
  260. ALPHA = -A( K, J )
  261. CALL ZAXPY( M-J, ALPHA, A( K-1, J+1 ), LDA,
  262. $ WORK( 2 ), 1 )
  263. ENDIF
  264. *
  265. * Find max(|WORK(2:n)|)
  266. *
  267. I2 = IZAMAX( M-J, WORK( 2 ), 1 ) + 1
  268. PIV = WORK( I2 )
  269. *
  270. * Apply symmetric pivot
  271. *
  272. IF( (I2.NE.2) .AND. (PIV.NE.0) ) THEN
  273. *
  274. * Swap WORK(I1) and WORK(I2)
  275. *
  276. I1 = 2
  277. WORK( I2 ) = WORK( I1 )
  278. WORK( I1 ) = PIV
  279. *
  280. * Swap A(I1, I1+1:N) with A(I1+1:N, I2)
  281. *
  282. I1 = I1+J-1
  283. I2 = I2+J-1
  284. CALL ZSWAP( I2-I1-1, A( J1+I1-1, I1+1 ), LDA,
  285. $ A( J1+I1, I2 ), 1 )
  286. *
  287. * Swap A(I1, I2+1:N) with A(I2, I2+1:N)
  288. *
  289. CALL ZSWAP( M-I2, A( J1+I1-1, I2+1 ), LDA,
  290. $ A( J1+I2-1, I2+1 ), LDA )
  291. *
  292. * Swap A(I1, I1) with A(I2,I2)
  293. *
  294. PIV = A( I1+J1-1, I1 )
  295. A( J1+I1-1, I1 ) = A( J1+I2-1, I2 )
  296. A( J1+I2-1, I2 ) = PIV
  297. *
  298. * Swap H(I1, 1:J1) with H(I2, 1:J1)
  299. *
  300. CALL ZSWAP( I1-1, H( I1, 1 ), LDH, H( I2, 1 ), LDH )
  301. IPIV( I1 ) = I2
  302. *
  303. IF( I1.GT.(K1-1) ) THEN
  304. *
  305. * Swap L(1:I1-1, I1) with L(1:I1-1, I2),
  306. * skipping the first column
  307. *
  308. CALL ZSWAP( I1-K1+1, A( 1, I1 ), 1,
  309. $ A( 1, I2 ), 1 )
  310. END IF
  311. ELSE
  312. IPIV( J+1 ) = J+1
  313. ENDIF
  314. *
  315. * Set A(J, J+1) = T(J, J+1)
  316. *
  317. A( K, J+1 ) = WORK( 2 )
  318. IF( (A( K, J ).EQ.ZERO ) .AND.
  319. $ ( (J.EQ.M) .OR. (A( K, J+1 ).EQ.ZERO))) THEN
  320. IF(INFO .EQ. 0) THEN
  321. INFO = J
  322. ENDIF
  323. END IF
  324. *
  325. IF( J.LT.NB ) THEN
  326. *
  327. * Copy A(J+1:N, J+1) into H(J:N, J),
  328. *
  329. CALL ZCOPY( M-J, A( K+1, J+1 ), LDA,
  330. $ H( J+1, J+1 ), 1 )
  331. END IF
  332. *
  333. * Compute L(J+2, J+1) = WORK( 3:N ) / T(J, J+1),
  334. * where A(J, J+1) = T(J, J+1) and A(J+2:N, J) = L(J+2:N, J+1)
  335. *
  336. IF( A( K, J+1 ).NE.ZERO ) THEN
  337. ALPHA = ONE / A( K, J+1 )
  338. CALL ZCOPY( M-J-1, WORK( 3 ), 1, A( K, J+2 ), LDA )
  339. CALL ZSCAL( M-J-1, ALPHA, A( K, J+2 ), LDA )
  340. ELSE
  341. CALL ZLASET( 'Full', 1, M-J-1, ZERO, ZERO,
  342. $ A( K, J+2 ), LDA)
  343. END IF
  344. ELSE
  345. IF( (A( K, J ).EQ.ZERO) .AND. (INFO.EQ.0) ) THEN
  346. INFO = J
  347. END IF
  348. END IF
  349. J = J + 1
  350. GO TO 10
  351. 20 CONTINUE
  352. *
  353. ELSE
  354. *
  355. * .....................................................
  356. * Factorize A as L*D*L**T using the lower triangle of A
  357. * .....................................................
  358. *
  359. 30 CONTINUE
  360. IF( J.GT.MIN( M, NB ) )
  361. $ GO TO 40
  362. *
  363. * K is the column to be factorized
  364. * when being called from ZSYTRF_AA,
  365. * > for the first block column, J1 is 1, hence J1+J-1 is J,
  366. * > for the rest of the columns, J1 is 2, and J1+J-1 is J+1,
  367. *
  368. K = J1+J-1
  369. *
  370. * H(J:N, J) := A(J:N, J) - H(J:N, 1:(J-1)) * L(J, J1:(J-1))^T,
  371. * where H(J:N, J) has been initialized to be A(J:N, J)
  372. *
  373. IF( K.GT.2 ) THEN
  374. *
  375. * K is the column to be factorized
  376. * > for the first block column, K is J, skipping the first two
  377. * columns
  378. * > for the rest of the columns, K is J+1, skipping only the
  379. * first column
  380. *
  381. CALL ZGEMV( 'No transpose', M-J+1, J-K1,
  382. $ -ONE, H( J, K1 ), LDH,
  383. $ A( J, 1 ), LDA,
  384. $ ONE, H( J, J ), 1 )
  385. END IF
  386. *
  387. * Copy H(J:N, J) into WORK
  388. *
  389. CALL ZCOPY( M-J+1, H( J, J ), 1, WORK( 1 ), 1 )
  390. *
  391. IF( J.GT.K1 ) THEN
  392. *
  393. * Compute WORK := WORK - L(J:N, J-1) * T(J-1,J),
  394. * where A(J-1, J) = T(J-1, J) and A(J, J-2) = L(J, J-1)
  395. *
  396. ALPHA = -A( J, K-1 )
  397. CALL ZAXPY( M-J+1, ALPHA, A( J, K-2 ), 1, WORK( 1 ), 1 )
  398. END IF
  399. *
  400. * Set A(J, J) = T(J, J)
  401. *
  402. A( J, K ) = WORK( 1 )
  403. *
  404. IF( J.LT.M ) THEN
  405. *
  406. * Compute WORK(2:N) = T(J, J) L((J+1):N, J)
  407. * where A(J, J) = T(J, J) and A((J+1):N, J-1) = L((J+1):N, J)
  408. *
  409. IF( K.GT.1 ) THEN
  410. ALPHA = -A( J, K )
  411. CALL ZAXPY( M-J, ALPHA, A( J+1, K-1 ), 1,
  412. $ WORK( 2 ), 1 )
  413. ENDIF
  414. *
  415. * Find max(|WORK(2:n)|)
  416. *
  417. I2 = IZAMAX( M-J, WORK( 2 ), 1 ) + 1
  418. PIV = WORK( I2 )
  419. *
  420. * Apply symmetric pivot
  421. *
  422. IF( (I2.NE.2) .AND. (PIV.NE.0) ) THEN
  423. *
  424. * Swap WORK(I1) and WORK(I2)
  425. *
  426. I1 = 2
  427. WORK( I2 ) = WORK( I1 )
  428. WORK( I1 ) = PIV
  429. *
  430. * Swap A(I1+1:N, I1) with A(I2, I1+1:N)
  431. *
  432. I1 = I1+J-1
  433. I2 = I2+J-1
  434. CALL ZSWAP( I2-I1-1, A( I1+1, J1+I1-1 ), 1,
  435. $ A( I2, J1+I1 ), LDA )
  436. *
  437. * Swap A(I2+1:N, I1) with A(I2+1:N, I2)
  438. *
  439. CALL ZSWAP( M-I2, A( I2+1, J1+I1-1 ), 1,
  440. $ A( I2+1, J1+I2-1 ), 1 )
  441. *
  442. * Swap A(I1, I1) with A(I2, I2)
  443. *
  444. PIV = A( I1, J1+I1-1 )
  445. A( I1, J1+I1-1 ) = A( I2, J1+I2-1 )
  446. A( I2, J1+I2-1 ) = PIV
  447. *
  448. * Swap H(I1, I1:J1) with H(I2, I2:J1)
  449. *
  450. CALL ZSWAP( I1-1, H( I1, 1 ), LDH, H( I2, 1 ), LDH )
  451. IPIV( I1 ) = I2
  452. *
  453. IF( I1.GT.(K1-1) ) THEN
  454. *
  455. * Swap L(1:I1-1, I1) with L(1:I1-1, I2),
  456. * skipping the first column
  457. *
  458. CALL ZSWAP( I1-K1+1, A( I1, 1 ), LDA,
  459. $ A( I2, 1 ), LDA )
  460. END IF
  461. ELSE
  462. IPIV( J+1 ) = J+1
  463. ENDIF
  464. *
  465. * Set A(J+1, J) = T(J+1, J)
  466. *
  467. A( J+1, K ) = WORK( 2 )
  468. IF( (A( J, K ).EQ.ZERO) .AND.
  469. $ ( (J.EQ.M) .OR. (A( J+1, K ).EQ.ZERO)) ) THEN
  470. IF (INFO .EQ. 0)
  471. $ INFO = J
  472. END IF
  473. *
  474. IF( J.LT.NB ) THEN
  475. *
  476. * Copy A(J+1:N, J+1) into H(J+1:N, J),
  477. *
  478. CALL ZCOPY( M-J, A( J+1, K+1 ), 1,
  479. $ H( J+1, J+1 ), 1 )
  480. END IF
  481. *
  482. * Compute L(J+2, J+1) = WORK( 3:N ) / T(J, J+1),
  483. * where A(J, J+1) = T(J, J+1) and A(J+2:N, J) = L(J+2:N, J+1)
  484. *
  485. IF( A( J+1, K ).NE.ZERO ) THEN
  486. ALPHA = ONE / A( J+1, K )
  487. CALL ZCOPY( M-J-1, WORK( 3 ), 1, A( J+2, K ), 1 )
  488. CALL ZSCAL( M-J-1, ALPHA, A( J+2, K ), 1 )
  489. ELSE
  490. CALL ZLASET( 'Full', M-J-1, 1, ZERO, ZERO,
  491. $ A( J+2, K ), LDA )
  492. END IF
  493. ELSE
  494. IF( (A( J, K ).EQ.ZERO) .AND. (INFO.EQ.0) ) THEN
  495. INFO = J
  496. END IF
  497. END IF
  498. J = J + 1
  499. GO TO 30
  500. 40 CONTINUE
  501. END IF
  502. RETURN
  503. *
  504. * End of ZLASYF_AA
  505. *
  506. END