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.

zsyconvf_rook.f 16 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  1. *> \brief \b ZSYCONVF_ROOK
  2. *
  3. * =========== DOCUMENTATION ===========
  4. *
  5. * Online html documentation available at
  6. * http://www.netlib.org/lapack/explore-html/
  7. *
  8. *> \htmlonly
  9. *> Download ZSYCONVF_ROOK + dependencies
  10. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zsyconvf_rook.f">
  11. *> [TGZ]</a>
  12. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zsyconvf_rook.f">
  13. *> [ZIP]</a>
  14. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zsyconvf_rook.f">
  15. *> [TXT]</a>
  16. *> \endhtmlonly
  17. *
  18. * Definition:
  19. * ===========
  20. *
  21. * SUBROUTINE ZSYCONVF_ROOK( UPLO, WAY, N, A, LDA, E, IPIV, INFO )
  22. *
  23. * .. Scalar Arguments ..
  24. * CHARACTER UPLO, WAY
  25. * INTEGER INFO, LDA, N
  26. * ..
  27. * .. Array Arguments ..
  28. * INTEGER IPIV( * )
  29. * COMPLEX*16 A( LDA, * ), E( * )
  30. * ..
  31. *
  32. *
  33. *> \par Purpose:
  34. * =============
  35. *>
  36. *> \verbatim
  37. *> If parameter WAY = 'C':
  38. *> ZSYCONVF_ROOK converts the factorization output format used in
  39. *> ZSYTRF_ROOK provided on entry in parameter A into the factorization
  40. *> output format used in ZSYTRF_RK (or ZSYTRF_BK) that is stored
  41. *> on exit in parameters A and E. IPIV format for ZSYTRF_ROOK and
  42. *> ZSYTRF_RK (or ZSYTRF_BK) is the same and is not converted.
  43. *>
  44. *> If parameter WAY = 'R':
  45. *> ZSYCONVF_ROOK performs the conversion in reverse direction, i.e.
  46. *> converts the factorization output format used in ZSYTRF_RK
  47. *> (or ZSYTRF_BK) provided on entry in parameters A and E into
  48. *> the factorization output format used in ZSYTRF_ROOK that is stored
  49. *> on exit in parameter A. IPIV format for ZSYTRF_ROOK and
  50. *> ZSYTRF_RK (or ZSYTRF_BK) is the same and is not converted.
  51. *>
  52. *> ZSYCONVF_ROOK can also convert in Hermitian matrix case, i.e. between
  53. *> formats used in ZHETRF_ROOK and ZHETRF_RK (or ZHETRF_BK).
  54. *> \endverbatim
  55. *
  56. * Arguments:
  57. * ==========
  58. *
  59. *> \param[in] UPLO
  60. *> \verbatim
  61. *> UPLO is CHARACTER*1
  62. *> Specifies whether the details of the factorization are
  63. *> stored as an upper or lower triangular matrix A.
  64. *> = 'U': Upper triangular
  65. *> = 'L': Lower triangular
  66. *> \endverbatim
  67. *>
  68. *> \param[in] WAY
  69. *> \verbatim
  70. *> WAY is CHARACTER*1
  71. *> = 'C': Convert
  72. *> = 'R': Revert
  73. *> \endverbatim
  74. *>
  75. *> \param[in] N
  76. *> \verbatim
  77. *> N is INTEGER
  78. *> The order of the matrix A. N >= 0.
  79. *> \endverbatim
  80. *>
  81. *> \param[in,out] A
  82. *> \verbatim
  83. *> A is COMPLEX*16 array, dimension (LDA,N)
  84. *>
  85. *> 1) If WAY ='C':
  86. *>
  87. *> On entry, contains factorization details in format used in
  88. *> ZSYTRF_ROOK:
  89. *> a) all elements of the symmetric block diagonal
  90. *> matrix D on the diagonal of A and on superdiagonal
  91. *> (or subdiagonal) of A, and
  92. *> b) If UPLO = 'U': multipliers used to obtain factor U
  93. *> in the superdiagonal part of A.
  94. *> If UPLO = 'L': multipliers used to obtain factor L
  95. *> in the superdiagonal part of A.
  96. *>
  97. *> On exit, contains factorization details in format used in
  98. *> ZSYTRF_RK or ZSYTRF_BK:
  99. *> a) ONLY diagonal elements of the symmetric block diagonal
  100. *> matrix D on the diagonal of A, i.e. D(k,k) = A(k,k);
  101. *> (superdiagonal (or subdiagonal) elements of D
  102. *> are stored on exit in array E), and
  103. *> b) If UPLO = 'U': factor U in the superdiagonal part of A.
  104. *> If UPLO = 'L': factor L in the subdiagonal part of A.
  105. *>
  106. *> 2) If WAY = 'R':
  107. *>
  108. *> On entry, contains factorization details in format used in
  109. *> ZSYTRF_RK or ZSYTRF_BK:
  110. *> a) ONLY diagonal elements of the symmetric block diagonal
  111. *> matrix D on the diagonal of A, i.e. D(k,k) = A(k,k);
  112. *> (superdiagonal (or subdiagonal) elements of D
  113. *> are stored on exit in array E), and
  114. *> b) If UPLO = 'U': factor U in the superdiagonal part of A.
  115. *> If UPLO = 'L': factor L in the subdiagonal part of A.
  116. *>
  117. *> On exit, contains factorization details in format used in
  118. *> ZSYTRF_ROOK:
  119. *> a) all elements of the symmetric block diagonal
  120. *> matrix D on the diagonal of A and on superdiagonal
  121. *> (or subdiagonal) of A, and
  122. *> b) If UPLO = 'U': multipliers used to obtain factor U
  123. *> in the superdiagonal part of A.
  124. *> If UPLO = 'L': multipliers used to obtain factor L
  125. *> in the superdiagonal part of A.
  126. *> \endverbatim
  127. *>
  128. *> \param[in] LDA
  129. *> \verbatim
  130. *> LDA is INTEGER
  131. *> The leading dimension of the array A. LDA >= max(1,N).
  132. *> \endverbatim
  133. *>
  134. *> \param[in,out] E
  135. *> \verbatim
  136. *> E is COMPLEX*16 array, dimension (N)
  137. *>
  138. *> 1) If WAY ='C':
  139. *>
  140. *> On entry, just a workspace.
  141. *>
  142. *> On exit, contains the superdiagonal (or subdiagonal)
  143. *> elements of the symmetric block diagonal matrix D
  144. *> with 1-by-1 or 2-by-2 diagonal blocks, where
  145. *> If UPLO = 'U': E(i) = D(i-1,i), i=2:N, E(1) is set to 0;
  146. *> If UPLO = 'L': E(i) = D(i+1,i), i=1:N-1, E(N) is set to 0.
  147. *>
  148. *> 2) If WAY = 'R':
  149. *>
  150. *> On entry, contains the superdiagonal (or subdiagonal)
  151. *> elements of the symmetric block diagonal matrix D
  152. *> with 1-by-1 or 2-by-2 diagonal blocks, where
  153. *> If UPLO = 'U': E(i) = D(i-1,i),i=2:N, E(1) not referenced;
  154. *> If UPLO = 'L': E(i) = D(i+1,i),i=1:N-1, E(N) not referenced.
  155. *>
  156. *> On exit, is not changed
  157. *> \endverbatim
  158. *.
  159. *> \param[in] IPIV
  160. *> \verbatim
  161. *> IPIV is INTEGER array, dimension (N)
  162. *> On entry, details of the interchanges and the block
  163. *> structure of D as determined:
  164. *> 1) by ZSYTRF_ROOK, if WAY ='C';
  165. *> 2) by ZSYTRF_RK (or ZSYTRF_BK), if WAY ='R'.
  166. *> The IPIV format is the same for all these routines.
  167. *>
  168. *> On exit, is not changed.
  169. *> \endverbatim
  170. *>
  171. *> \param[out] INFO
  172. *> \verbatim
  173. *> INFO is INTEGER
  174. *> = 0: successful exit
  175. *> < 0: if INFO = -i, the i-th argument had an illegal value
  176. *> \endverbatim
  177. *
  178. * Authors:
  179. * ========
  180. *
  181. *> \author Univ. of Tennessee
  182. *> \author Univ. of California Berkeley
  183. *> \author Univ. of Colorado Denver
  184. *> \author NAG Ltd.
  185. *
  186. *> \date November 2017
  187. *
  188. *> \ingroup complex16SYcomputational
  189. *
  190. *> \par Contributors:
  191. * ==================
  192. *>
  193. *> \verbatim
  194. *>
  195. *> November 2017, Igor Kozachenko,
  196. *> Computer Science Division,
  197. *> University of California, Berkeley
  198. *>
  199. *> \endverbatim
  200. * =====================================================================
  201. SUBROUTINE ZSYCONVF_ROOK( UPLO, WAY, N, A, LDA, E, IPIV, INFO )
  202. *
  203. * -- LAPACK computational routine (version 3.8.0) --
  204. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  205. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  206. * November 2017
  207. *
  208. * .. Scalar Arguments ..
  209. CHARACTER UPLO, WAY
  210. INTEGER INFO, LDA, N
  211. * ..
  212. * .. Array Arguments ..
  213. INTEGER IPIV( * )
  214. COMPLEX*16 A( LDA, * ), E( * )
  215. * ..
  216. *
  217. * =====================================================================
  218. *
  219. * .. Parameters ..
  220. COMPLEX*16 ZERO
  221. PARAMETER ( ZERO = ( 0.0D+0, 0.0D+0 ) )
  222. * ..
  223. * .. External Functions ..
  224. LOGICAL LSAME
  225. EXTERNAL LSAME
  226. *
  227. * .. External Subroutines ..
  228. EXTERNAL ZSWAP, XERBLA
  229. * .. Local Scalars ..
  230. LOGICAL UPPER, CONVERT
  231. INTEGER I, IP, IP2
  232. * ..
  233. * .. Executable Statements ..
  234. *
  235. INFO = 0
  236. UPPER = LSAME( UPLO, 'U' )
  237. CONVERT = LSAME( WAY, 'C' )
  238. IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
  239. INFO = -1
  240. ELSE IF( .NOT.CONVERT .AND. .NOT.LSAME( WAY, 'R' ) ) THEN
  241. INFO = -2
  242. ELSE IF( N.LT.0 ) THEN
  243. INFO = -3
  244. ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
  245. INFO = -5
  246. END IF
  247. IF( INFO.NE.0 ) THEN
  248. CALL XERBLA( 'ZSYCONVF_ROOK', -INFO )
  249. RETURN
  250. END IF
  251. *
  252. * Quick return if possible
  253. *
  254. IF( N.EQ.0 )
  255. $ RETURN
  256. *
  257. IF( UPPER ) THEN
  258. *
  259. * Begin A is UPPER
  260. *
  261. IF ( CONVERT ) THEN
  262. *
  263. * Convert A (A is upper)
  264. *
  265. *
  266. * Convert VALUE
  267. *
  268. * Assign superdiagonal entries of D to array E and zero out
  269. * corresponding entries in input storage A
  270. *
  271. I = N
  272. E( 1 ) = ZERO
  273. DO WHILE ( I.GT.1 )
  274. IF( IPIV( I ).LT.0 ) THEN
  275. E( I ) = A( I-1, I )
  276. E( I-1 ) = ZERO
  277. A( I-1, I ) = ZERO
  278. I = I - 1
  279. ELSE
  280. E( I ) = ZERO
  281. END IF
  282. I = I - 1
  283. END DO
  284. *
  285. * Convert PERMUTATIONS
  286. *
  287. * Apply permutaions to submatrices of upper part of A
  288. * in factorization order where i decreases from N to 1
  289. *
  290. I = N
  291. DO WHILE ( I.GE.1 )
  292. IF( IPIV( I ).GT.0 ) THEN
  293. *
  294. * 1-by-1 pivot interchange
  295. *
  296. * Swap rows i and IPIV(i) in A(1:i,N-i:N)
  297. *
  298. IP = IPIV( I )
  299. IF( I.LT.N ) THEN
  300. IF( IP.NE.I ) THEN
  301. CALL ZSWAP( N-I, A( I, I+1 ), LDA,
  302. $ A( IP, I+1 ), LDA )
  303. END IF
  304. END IF
  305. *
  306. ELSE
  307. *
  308. * 2-by-2 pivot interchange
  309. *
  310. * Swap rows i and IPIV(i) and i-1 and IPIV(i-1)
  311. * in A(1:i,N-i:N)
  312. *
  313. IP = -IPIV( I )
  314. IP2 = -IPIV( I-1 )
  315. IF( I.LT.N ) THEN
  316. IF( IP.NE.I ) THEN
  317. CALL ZSWAP( N-I, A( I, I+1 ), LDA,
  318. $ A( IP, I+1 ), LDA )
  319. END IF
  320. IF( IP2.NE.(I-1) ) THEN
  321. CALL ZSWAP( N-I, A( I-1, I+1 ), LDA,
  322. $ A( IP2, I+1 ), LDA )
  323. END IF
  324. END IF
  325. I = I - 1
  326. *
  327. END IF
  328. I = I - 1
  329. END DO
  330. *
  331. ELSE
  332. *
  333. * Revert A (A is upper)
  334. *
  335. *
  336. * Revert PERMUTATIONS
  337. *
  338. * Apply permutaions to submatrices of upper part of A
  339. * in reverse factorization order where i increases from 1 to N
  340. *
  341. I = 1
  342. DO WHILE ( I.LE.N )
  343. IF( IPIV( I ).GT.0 ) THEN
  344. *
  345. * 1-by-1 pivot interchange
  346. *
  347. * Swap rows i and IPIV(i) in A(1:i,N-i:N)
  348. *
  349. IP = IPIV( I )
  350. IF( I.LT.N ) THEN
  351. IF( IP.NE.I ) THEN
  352. CALL ZSWAP( N-I, A( IP, I+1 ), LDA,
  353. $ A( I, I+1 ), LDA )
  354. END IF
  355. END IF
  356. *
  357. ELSE
  358. *
  359. * 2-by-2 pivot interchange
  360. *
  361. * Swap rows i-1 and IPIV(i-1) and i and IPIV(i)
  362. * in A(1:i,N-i:N)
  363. *
  364. I = I + 1
  365. IP = -IPIV( I )
  366. IP2 = -IPIV( I-1 )
  367. IF( I.LT.N ) THEN
  368. IF( IP2.NE.(I-1) ) THEN
  369. CALL ZSWAP( N-I, A( IP2, I+1 ), LDA,
  370. $ A( I-1, I+1 ), LDA )
  371. END IF
  372. IF( IP.NE.I ) THEN
  373. CALL ZSWAP( N-I, A( IP, I+1 ), LDA,
  374. $ A( I, I+1 ), LDA )
  375. END IF
  376. END IF
  377. *
  378. END IF
  379. I = I + 1
  380. END DO
  381. *
  382. * Revert VALUE
  383. * Assign superdiagonal entries of D from array E to
  384. * superdiagonal entries of A.
  385. *
  386. I = N
  387. DO WHILE ( I.GT.1 )
  388. IF( IPIV( I ).LT.0 ) THEN
  389. A( I-1, I ) = E( I )
  390. I = I - 1
  391. END IF
  392. I = I - 1
  393. END DO
  394. *
  395. * End A is UPPER
  396. *
  397. END IF
  398. *
  399. ELSE
  400. *
  401. * Begin A is LOWER
  402. *
  403. IF ( CONVERT ) THEN
  404. *
  405. * Convert A (A is lower)
  406. *
  407. *
  408. * Convert VALUE
  409. * Assign subdiagonal entries of D to array E and zero out
  410. * corresponding entries in input storage A
  411. *
  412. I = 1
  413. E( N ) = ZERO
  414. DO WHILE ( I.LE.N )
  415. IF( I.LT.N .AND. IPIV(I).LT.0 ) THEN
  416. E( I ) = A( I+1, I )
  417. E( I+1 ) = ZERO
  418. A( I+1, I ) = ZERO
  419. I = I + 1
  420. ELSE
  421. E( I ) = ZERO
  422. END IF
  423. I = I + 1
  424. END DO
  425. *
  426. * Convert PERMUTATIONS
  427. *
  428. * Apply permutaions to submatrices of lower part of A
  429. * in factorization order where i increases from 1 to N
  430. *
  431. I = 1
  432. DO WHILE ( I.LE.N )
  433. IF( IPIV( I ).GT.0 ) THEN
  434. *
  435. * 1-by-1 pivot interchange
  436. *
  437. * Swap rows i and IPIV(i) in A(i:N,1:i-1)
  438. *
  439. IP = IPIV( I )
  440. IF ( I.GT.1 ) THEN
  441. IF( IP.NE.I ) THEN
  442. CALL ZSWAP( I-1, A( I, 1 ), LDA,
  443. $ A( IP, 1 ), LDA )
  444. END IF
  445. END IF
  446. *
  447. ELSE
  448. *
  449. * 2-by-2 pivot interchange
  450. *
  451. * Swap rows i and IPIV(i) and i+1 and IPIV(i+1)
  452. * in A(i:N,1:i-1)
  453. *
  454. IP = -IPIV( I )
  455. IP2 = -IPIV( I+1 )
  456. IF ( I.GT.1 ) THEN
  457. IF( IP.NE.I ) THEN
  458. CALL ZSWAP( I-1, A( I, 1 ), LDA,
  459. $ A( IP, 1 ), LDA )
  460. END IF
  461. IF( IP2.NE.(I+1) ) THEN
  462. CALL ZSWAP( I-1, A( I+1, 1 ), LDA,
  463. $ A( IP2, 1 ), LDA )
  464. END IF
  465. END IF
  466. I = I + 1
  467. *
  468. END IF
  469. I = I + 1
  470. END DO
  471. *
  472. ELSE
  473. *
  474. * Revert A (A is lower)
  475. *
  476. *
  477. * Revert PERMUTATIONS
  478. *
  479. * Apply permutaions to submatrices of lower part of A
  480. * in reverse factorization order where i decreases from N to 1
  481. *
  482. I = N
  483. DO WHILE ( I.GE.1 )
  484. IF( IPIV( I ).GT.0 ) THEN
  485. *
  486. * 1-by-1 pivot interchange
  487. *
  488. * Swap rows i and IPIV(i) in A(i:N,1:i-1)
  489. *
  490. IP = IPIV( I )
  491. IF ( I.GT.1 ) THEN
  492. IF( IP.NE.I ) THEN
  493. CALL ZSWAP( I-1, A( IP, 1 ), LDA,
  494. $ A( I, 1 ), LDA )
  495. END IF
  496. END IF
  497. *
  498. ELSE
  499. *
  500. * 2-by-2 pivot interchange
  501. *
  502. * Swap rows i+1 and IPIV(i+1) and i and IPIV(i)
  503. * in A(i:N,1:i-1)
  504. *
  505. I = I - 1
  506. IP = -IPIV( I )
  507. IP2 = -IPIV( I+1 )
  508. IF ( I.GT.1 ) THEN
  509. IF( IP2.NE.(I+1) ) THEN
  510. CALL ZSWAP( I-1, A( IP2, 1 ), LDA,
  511. $ A( I+1, 1 ), LDA )
  512. END IF
  513. IF( IP.NE.I ) THEN
  514. CALL ZSWAP( I-1, A( IP, 1 ), LDA,
  515. $ A( I, 1 ), LDA )
  516. END IF
  517. END IF
  518. *
  519. END IF
  520. I = I - 1
  521. END DO
  522. *
  523. * Revert VALUE
  524. * Assign subdiagonal entries of D from array E to
  525. * subgiagonal entries of A.
  526. *
  527. I = 1
  528. DO WHILE ( I.LE.N-1 )
  529. IF( IPIV( I ).LT.0 ) THEN
  530. A( I + 1, I ) = E( I )
  531. I = I + 1
  532. END IF
  533. I = I + 1
  534. END DO
  535. *
  536. END IF
  537. *
  538. * End A is LOWER
  539. *
  540. END IF
  541. RETURN
  542. *
  543. * End of ZSYCONVF_ROOK
  544. *
  545. END