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.f 17 kB

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