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.

ssyconvf_rook.f 16 kB

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