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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559
  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 coverts in place details of
  42. *> the intechanges 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 coverts in place details of
  51. *> the intechanges 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. *> \date November 2017
  193. *
  194. *> \ingroup doubleSYcomputational
  195. *
  196. *> \par Contributors:
  197. * ==================
  198. *>
  199. *> \verbatim
  200. *>
  201. *> November 2017, Igor Kozachenko,
  202. *> Computer Science Division,
  203. *> University of California, Berkeley
  204. *>
  205. *> \endverbatim
  206. * =====================================================================
  207. SUBROUTINE DSYCONVF( UPLO, WAY, N, A, LDA, E, IPIV, INFO )
  208. *
  209. * -- LAPACK computational routine (version 3.8.0) --
  210. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  211. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  212. * November 2017
  213. *
  214. * .. Scalar Arguments ..
  215. CHARACTER UPLO, WAY
  216. INTEGER INFO, LDA, N
  217. * ..
  218. * .. Array Arguments ..
  219. INTEGER IPIV( * )
  220. DOUBLE PRECISION A( LDA, * ), E( * )
  221. * ..
  222. *
  223. * =====================================================================
  224. *
  225. * .. Parameters ..
  226. DOUBLE PRECISION ZERO
  227. PARAMETER ( ZERO = 0.0D+0 )
  228. * ..
  229. * .. External Functions ..
  230. LOGICAL LSAME
  231. EXTERNAL LSAME
  232. *
  233. * .. External Subroutines ..
  234. EXTERNAL DSWAP, XERBLA
  235. * .. Local Scalars ..
  236. LOGICAL UPPER, CONVERT
  237. INTEGER I, IP
  238. * ..
  239. * .. Executable Statements ..
  240. *
  241. INFO = 0
  242. UPPER = LSAME( UPLO, 'U' )
  243. CONVERT = LSAME( WAY, 'C' )
  244. IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
  245. INFO = -1
  246. ELSE IF( .NOT.CONVERT .AND. .NOT.LSAME( WAY, 'R' ) ) THEN
  247. INFO = -2
  248. ELSE IF( N.LT.0 ) THEN
  249. INFO = -3
  250. ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
  251. INFO = -5
  252. END IF
  253. IF( INFO.NE.0 ) THEN
  254. CALL XERBLA( 'DSYCONVF', -INFO )
  255. RETURN
  256. END IF
  257. *
  258. * Quick return if possible
  259. *
  260. IF( N.EQ.0 )
  261. $ RETURN
  262. *
  263. IF( UPPER ) THEN
  264. *
  265. * Begin A is UPPER
  266. *
  267. IF ( CONVERT ) THEN
  268. *
  269. * Convert A (A is upper)
  270. *
  271. *
  272. * Convert VALUE
  273. *
  274. * Assign superdiagonal entries of D to array E and zero out
  275. * corresponding entries in input storage A
  276. *
  277. I = N
  278. E( 1 ) = ZERO
  279. DO WHILE ( I.GT.1 )
  280. IF( IPIV( I ).LT.0 ) THEN
  281. E( I ) = A( I-1, I )
  282. E( I-1 ) = ZERO
  283. A( I-1, I ) = ZERO
  284. I = I - 1
  285. ELSE
  286. E( I ) = ZERO
  287. END IF
  288. I = I - 1
  289. END DO
  290. *
  291. * Convert PERMUTATIONS and IPIV
  292. *
  293. * Apply permutations to submatrices of upper part of A
  294. * in factorization order where i decreases from N to 1
  295. *
  296. I = N
  297. DO WHILE ( I.GE.1 )
  298. IF( IPIV( I ).GT.0 ) THEN
  299. *
  300. * 1-by-1 pivot interchange
  301. *
  302. * Swap rows i and IPIV(i) in A(1:i,N-i:N)
  303. *
  304. IP = IPIV( I )
  305. IF( I.LT.N ) THEN
  306. IF( IP.NE.I ) THEN
  307. CALL DSWAP( N-I, A( I, I+1 ), LDA,
  308. $ A( IP, I+1 ), LDA )
  309. END IF
  310. END IF
  311. *
  312. ELSE
  313. *
  314. * 2-by-2 pivot interchange
  315. *
  316. * Swap rows i-1 and IPIV(i) in A(1:i,N-i:N)
  317. *
  318. IP = -IPIV( I )
  319. IF( I.LT.N ) THEN
  320. IF( IP.NE.(I-1) ) THEN
  321. CALL DSWAP( N-I, A( I-1, I+1 ), LDA,
  322. $ A( IP, I+1 ), LDA )
  323. END IF
  324. END IF
  325. *
  326. * Convert IPIV
  327. * There is no interchnge of rows i and and IPIV(i),
  328. * so this should be reflected in IPIV format for
  329. * *SYTRF_RK ( or *SYTRF_BK)
  330. *
  331. IPIV( I ) = I
  332. *
  333. I = I - 1
  334. *
  335. END IF
  336. I = I - 1
  337. END DO
  338. *
  339. ELSE
  340. *
  341. * Revert A (A is upper)
  342. *
  343. *
  344. * Revert PERMUTATIONS and IPIV
  345. *
  346. * Apply permutations to submatrices of upper part of A
  347. * in reverse factorization order where i increases from 1 to N
  348. *
  349. I = 1
  350. DO WHILE ( I.LE.N )
  351. IF( IPIV( I ).GT.0 ) THEN
  352. *
  353. * 1-by-1 pivot interchange
  354. *
  355. * Swap rows i and IPIV(i) in A(1:i,N-i:N)
  356. *
  357. IP = IPIV( I )
  358. IF( I.LT.N ) THEN
  359. IF( IP.NE.I ) THEN
  360. CALL DSWAP( N-I, A( IP, I+1 ), LDA,
  361. $ A( I, I+1 ), LDA )
  362. END IF
  363. END IF
  364. *
  365. ELSE
  366. *
  367. * 2-by-2 pivot interchange
  368. *
  369. * Swap rows i-1 and IPIV(i) in A(1:i,N-i:N)
  370. *
  371. I = I + 1
  372. IP = -IPIV( I )
  373. IF( I.LT.N ) THEN
  374. IF( IP.NE.(I-1) ) THEN
  375. CALL DSWAP( N-I, A( IP, I+1 ), LDA,
  376. $ A( I-1, I+1 ), LDA )
  377. END IF
  378. END IF
  379. *
  380. * Convert IPIV
  381. * There is one interchange of rows i-1 and IPIV(i-1),
  382. * so this should be recorded in two consecutive entries
  383. * in IPIV format for *SYTRF
  384. *
  385. IPIV( I ) = IPIV( I-1 )
  386. *
  387. END IF
  388. I = I + 1
  389. END DO
  390. *
  391. * Revert VALUE
  392. * Assign superdiagonal entries of D from array E to
  393. * superdiagonal entries of A.
  394. *
  395. I = N
  396. DO WHILE ( I.GT.1 )
  397. IF( IPIV( I ).LT.0 ) THEN
  398. A( I-1, I ) = E( I )
  399. I = I - 1
  400. END IF
  401. I = I - 1
  402. END DO
  403. *
  404. * End A is UPPER
  405. *
  406. END IF
  407. *
  408. ELSE
  409. *
  410. * Begin A is LOWER
  411. *
  412. IF ( CONVERT ) THEN
  413. *
  414. * Convert A (A is lower)
  415. *
  416. *
  417. * Convert VALUE
  418. * Assign subdiagonal entries of D to array E and zero out
  419. * corresponding entries in input storage A
  420. *
  421. I = 1
  422. E( N ) = ZERO
  423. DO WHILE ( I.LE.N )
  424. IF( I.LT.N .AND. IPIV(I).LT.0 ) THEN
  425. E( I ) = A( I+1, I )
  426. E( I+1 ) = ZERO
  427. A( I+1, I ) = ZERO
  428. I = I + 1
  429. ELSE
  430. E( I ) = ZERO
  431. END IF
  432. I = I + 1
  433. END DO
  434. *
  435. * Convert PERMUTATIONS and IPIV
  436. *
  437. * Apply permutations to submatrices of lower part of A
  438. * in factorization order where k increases from 1 to N
  439. *
  440. I = 1
  441. DO WHILE ( I.LE.N )
  442. IF( IPIV( I ).GT.0 ) THEN
  443. *
  444. * 1-by-1 pivot interchange
  445. *
  446. * Swap rows i and IPIV(i) in A(i:N,1:i-1)
  447. *
  448. IP = IPIV( I )
  449. IF ( I.GT.1 ) THEN
  450. IF( IP.NE.I ) THEN
  451. CALL DSWAP( I-1, A( I, 1 ), LDA,
  452. $ A( IP, 1 ), LDA )
  453. END IF
  454. END IF
  455. *
  456. ELSE
  457. *
  458. * 2-by-2 pivot interchange
  459. *
  460. * Swap rows i+1 and IPIV(i) in A(i:N,1:i-1)
  461. *
  462. IP = -IPIV( I )
  463. IF ( I.GT.1 ) THEN
  464. IF( IP.NE.(I+1) ) THEN
  465. CALL DSWAP( I-1, A( I+1, 1 ), LDA,
  466. $ A( IP, 1 ), LDA )
  467. END IF
  468. END IF
  469. *
  470. * Convert IPIV
  471. * There is no interchnge of rows i and and IPIV(i),
  472. * so this should be reflected in IPIV format for
  473. * *SYTRF_RK ( or *SYTRF_BK)
  474. *
  475. IPIV( I ) = I
  476. *
  477. I = I + 1
  478. *
  479. END IF
  480. I = I + 1
  481. END DO
  482. *
  483. ELSE
  484. *
  485. * Revert A (A is lower)
  486. *
  487. *
  488. * Revert PERMUTATIONS and IPIV
  489. *
  490. * Apply permutations to submatrices of lower part of A
  491. * in reverse factorization order where i decreases from N to 1
  492. *
  493. I = N
  494. DO WHILE ( I.GE.1 )
  495. IF( IPIV( I ).GT.0 ) THEN
  496. *
  497. * 1-by-1 pivot interchange
  498. *
  499. * Swap rows i and IPIV(i) in A(i:N,1:i-1)
  500. *
  501. IP = IPIV( I )
  502. IF ( I.GT.1 ) THEN
  503. IF( IP.NE.I ) THEN
  504. CALL DSWAP( I-1, A( IP, 1 ), LDA,
  505. $ A( I, 1 ), LDA )
  506. END IF
  507. END IF
  508. *
  509. ELSE
  510. *
  511. * 2-by-2 pivot interchange
  512. *
  513. * Swap rows i+1 and IPIV(i) in A(i:N,1:i-1)
  514. *
  515. I = I - 1
  516. IP = -IPIV( I )
  517. IF ( I.GT.1 ) THEN
  518. IF( IP.NE.(I+1) ) THEN
  519. CALL DSWAP( I-1, A( IP, 1 ), LDA,
  520. $ A( I+1, 1 ), LDA )
  521. END IF
  522. END IF
  523. *
  524. * Convert IPIV
  525. * There is one interchange of rows i+1 and IPIV(i+1),
  526. * so this should be recorded in consecutive entries
  527. * in IPIV format for *SYTRF
  528. *
  529. IPIV( I ) = IPIV( I+1 )
  530. *
  531. END IF
  532. I = I - 1
  533. END DO
  534. *
  535. * Revert VALUE
  536. * Assign subdiagonal entries of D from array E to
  537. * subgiagonal entries of A.
  538. *
  539. I = 1
  540. DO WHILE ( I.LE.N-1 )
  541. IF( IPIV( I ).LT.0 ) THEN
  542. A( I + 1, I ) = E( I )
  543. I = I + 1
  544. END IF
  545. I = I + 1
  546. END DO
  547. *
  548. END IF
  549. *
  550. * End A is LOWER
  551. *
  552. END IF
  553. RETURN
  554. *
  555. * End of DSYCONVF
  556. *
  557. END