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

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