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.

dsyconvf.f 17 kB

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