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.

ssytf2.f 18 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  1. *> \brief \b SSYTF2 computes the factorization of a real symmetric indefinite matrix, using the diagonal pivoting method (unblocked algorithm).
  2. *
  3. * =========== DOCUMENTATION ===========
  4. *
  5. * Online html documentation available at
  6. * http://www.netlib.org/lapack/explore-html/
  7. *
  8. *> \htmlonly
  9. *> Download SSYTF2 + dependencies
  10. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ssytf2.f">
  11. *> [TGZ]</a>
  12. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ssytf2.f">
  13. *> [ZIP]</a>
  14. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ssytf2.f">
  15. *> [TXT]</a>
  16. *> \endhtmlonly
  17. *
  18. * Definition:
  19. * ===========
  20. *
  21. * SUBROUTINE SSYTF2( UPLO, N, A, LDA, IPIV, INFO )
  22. *
  23. * .. Scalar Arguments ..
  24. * CHARACTER UPLO
  25. * INTEGER INFO, LDA, N
  26. * ..
  27. * .. Array Arguments ..
  28. * INTEGER IPIV( * )
  29. * REAL A( LDA, * )
  30. * ..
  31. *
  32. *
  33. *> \par Purpose:
  34. * =============
  35. *>
  36. *> \verbatim
  37. *>
  38. *> SSYTF2 computes the factorization of a real symmetric matrix A using
  39. *> the Bunch-Kaufman diagonal pivoting method:
  40. *>
  41. *> A = U*D*U**T or A = L*D*L**T
  42. *>
  43. *> where U (or L) is a product of permutation and unit upper (lower)
  44. *> triangular matrices, U**T is the transpose of U, and D is symmetric and
  45. *> block diagonal with 1-by-1 and 2-by-2 diagonal blocks.
  46. *>
  47. *> This is the unblocked version of the algorithm, calling Level 2 BLAS.
  48. *> \endverbatim
  49. *
  50. * Arguments:
  51. * ==========
  52. *
  53. *> \param[in] UPLO
  54. *> \verbatim
  55. *> UPLO is CHARACTER*1
  56. *> Specifies whether the upper or lower triangular part of the
  57. *> symmetric matrix A is stored:
  58. *> = 'U': Upper triangular
  59. *> = 'L': Lower triangular
  60. *> \endverbatim
  61. *>
  62. *> \param[in] N
  63. *> \verbatim
  64. *> N is INTEGER
  65. *> The order of the matrix A. N >= 0.
  66. *> \endverbatim
  67. *>
  68. *> \param[in,out] A
  69. *> \verbatim
  70. *> A is REAL array, dimension (LDA,N)
  71. *> On entry, the symmetric matrix A. If UPLO = 'U', the leading
  72. *> n-by-n upper triangular part of A contains the upper
  73. *> triangular part of the matrix A, and the strictly lower
  74. *> triangular part of A is not referenced. If UPLO = 'L', the
  75. *> leading n-by-n lower triangular part of A contains the lower
  76. *> triangular part of the matrix A, and the strictly upper
  77. *> triangular part of A is not referenced.
  78. *>
  79. *> On exit, the block diagonal matrix D and the multipliers used
  80. *> to obtain the factor U or L (see below for further details).
  81. *> \endverbatim
  82. *>
  83. *> \param[in] LDA
  84. *> \verbatim
  85. *> LDA is INTEGER
  86. *> The leading dimension of the array A. LDA >= max(1,N).
  87. *> \endverbatim
  88. *>
  89. *> \param[out] IPIV
  90. *> \verbatim
  91. *> IPIV is INTEGER array, dimension (N)
  92. *> Details of the interchanges and the block structure of D.
  93. *>
  94. *> If UPLO = 'U':
  95. *> If IPIV(k) > 0, then rows and columns k and IPIV(k) were
  96. *> interchanged and D(k,k) is a 1-by-1 diagonal block.
  97. *>
  98. *> If IPIV(k) = IPIV(k-1) < 0, then rows and columns
  99. *> k-1 and -IPIV(k) were interchanged and D(k-1:k,k-1:k)
  100. *> is a 2-by-2 diagonal block.
  101. *>
  102. *> If UPLO = 'L':
  103. *> If IPIV(k) > 0, then rows and columns k and IPIV(k) were
  104. *> interchanged and D(k,k) is a 1-by-1 diagonal block.
  105. *>
  106. *> If IPIV(k) = IPIV(k+1) < 0, then rows and columns
  107. *> k+1 and -IPIV(k) were interchanged and D(k:k+1,k:k+1)
  108. *> is a 2-by-2 diagonal block.
  109. *> \endverbatim
  110. *>
  111. *> \param[out] INFO
  112. *> \verbatim
  113. *> INFO is INTEGER
  114. *> = 0: successful exit
  115. *> < 0: if INFO = -k, the k-th argument had an illegal value
  116. *> > 0: if INFO = k, D(k,k) is exactly zero. The factorization
  117. *> has been completed, but the block diagonal matrix D is
  118. *> exactly singular, and division by zero will occur if it
  119. *> is used to solve a system of equations.
  120. *> \endverbatim
  121. *
  122. * Authors:
  123. * ========
  124. *
  125. *> \author Univ. of Tennessee
  126. *> \author Univ. of California Berkeley
  127. *> \author Univ. of Colorado Denver
  128. *> \author NAG Ltd.
  129. *
  130. *> \ingroup realSYcomputational
  131. *
  132. *> \par Further Details:
  133. * =====================
  134. *>
  135. *> \verbatim
  136. *>
  137. *> If UPLO = 'U', then A = U*D*U**T, where
  138. *> U = P(n)*U(n)* ... *P(k)U(k)* ...,
  139. *> i.e., U is a product of terms P(k)*U(k), where k decreases from n to
  140. *> 1 in steps of 1 or 2, and D is a block diagonal matrix with 1-by-1
  141. *> and 2-by-2 diagonal blocks D(k). P(k) is a permutation matrix as
  142. *> defined by IPIV(k), and U(k) is a unit upper triangular matrix, such
  143. *> that if the diagonal block D(k) is of order s (s = 1 or 2), then
  144. *>
  145. *> ( I v 0 ) k-s
  146. *> U(k) = ( 0 I 0 ) s
  147. *> ( 0 0 I ) n-k
  148. *> k-s s n-k
  149. *>
  150. *> If s = 1, D(k) overwrites A(k,k), and v overwrites A(1:k-1,k).
  151. *> If s = 2, the upper triangle of D(k) overwrites A(k-1,k-1), A(k-1,k),
  152. *> and A(k,k), and v overwrites A(1:k-2,k-1:k).
  153. *>
  154. *> If UPLO = 'L', then A = L*D*L**T, where
  155. *> L = P(1)*L(1)* ... *P(k)*L(k)* ...,
  156. *> i.e., L is a product of terms P(k)*L(k), where k increases from 1 to
  157. *> n in steps of 1 or 2, and D is a block diagonal matrix with 1-by-1
  158. *> and 2-by-2 diagonal blocks D(k). P(k) is a permutation matrix as
  159. *> defined by IPIV(k), and L(k) is a unit lower triangular matrix, such
  160. *> that if the diagonal block D(k) is of order s (s = 1 or 2), then
  161. *>
  162. *> ( I 0 0 ) k-1
  163. *> L(k) = ( 0 I 0 ) s
  164. *> ( 0 v I ) n-k-s+1
  165. *> k-1 s n-k-s+1
  166. *>
  167. *> If s = 1, D(k) overwrites A(k,k), and v overwrites A(k+1:n,k).
  168. *> If s = 2, the lower triangle of D(k) overwrites A(k,k), A(k+1,k),
  169. *> and A(k+1,k+1), and v overwrites A(k+2:n,k:k+1).
  170. *> \endverbatim
  171. *
  172. *> \par Contributors:
  173. * ==================
  174. *>
  175. *> \verbatim
  176. *>
  177. *> 09-29-06 - patch from
  178. *> Bobby Cheng, MathWorks
  179. *>
  180. *> Replace l.204 and l.372
  181. *> IF( MAX( ABSAKK, COLMAX ).EQ.ZERO ) THEN
  182. *> by
  183. *> IF( (MAX( ABSAKK, COLMAX ).EQ.ZERO) .OR. SISNAN(ABSAKK) ) THEN
  184. *>
  185. *> 01-01-96 - Based on modifications by
  186. *> J. Lewis, Boeing Computer Services Company
  187. *> A. Petitet, Computer Science Dept., Univ. of Tenn., Knoxville, USA
  188. *> 1-96 - Based on modifications by J. Lewis, Boeing Computer Services
  189. *> Company
  190. *>
  191. *> \endverbatim
  192. *
  193. * =====================================================================
  194. SUBROUTINE SSYTF2( UPLO, N, A, LDA, IPIV, INFO )
  195. *
  196. * -- LAPACK computational routine --
  197. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  198. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  199. *
  200. * .. Scalar Arguments ..
  201. CHARACTER UPLO
  202. INTEGER INFO, LDA, N
  203. * ..
  204. * .. Array Arguments ..
  205. INTEGER IPIV( * )
  206. REAL A( LDA, * )
  207. * ..
  208. *
  209. * =====================================================================
  210. *
  211. * .. Parameters ..
  212. REAL ZERO, ONE
  213. PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 )
  214. REAL EIGHT, SEVTEN
  215. PARAMETER ( EIGHT = 8.0E+0, SEVTEN = 17.0E+0 )
  216. * ..
  217. * .. Local Scalars ..
  218. LOGICAL UPPER
  219. INTEGER I, IMAX, J, JMAX, K, KK, KP, KSTEP
  220. REAL ABSAKK, ALPHA, COLMAX, D11, D12, D21, D22, R1,
  221. $ ROWMAX, T, WK, WKM1, WKP1
  222. * ..
  223. * .. External Functions ..
  224. LOGICAL LSAME, SISNAN
  225. INTEGER ISAMAX
  226. EXTERNAL LSAME, ISAMAX, SISNAN
  227. * ..
  228. * .. External Subroutines ..
  229. EXTERNAL SSCAL, SSWAP, SSYR, XERBLA
  230. * ..
  231. * .. Intrinsic Functions ..
  232. INTRINSIC ABS, MAX, SQRT
  233. * ..
  234. * .. Executable Statements ..
  235. *
  236. * Test the input parameters.
  237. *
  238. INFO = 0
  239. UPPER = LSAME( UPLO, 'U' )
  240. IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
  241. INFO = -1
  242. ELSE IF( N.LT.0 ) THEN
  243. INFO = -2
  244. ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
  245. INFO = -4
  246. END IF
  247. IF( INFO.NE.0 ) THEN
  248. CALL XERBLA( 'SSYTF2', -INFO )
  249. RETURN
  250. END IF
  251. *
  252. * Initialize ALPHA for use in choosing pivot block size.
  253. *
  254. ALPHA = ( ONE+SQRT( SEVTEN ) ) / EIGHT
  255. *
  256. IF( UPPER ) THEN
  257. *
  258. * Factorize A as U*D*U**T using the upper triangle of A
  259. *
  260. * K is the main loop index, decreasing from N to 1 in steps of
  261. * 1 or 2
  262. *
  263. K = N
  264. 10 CONTINUE
  265. *
  266. * If K < 1, exit from loop
  267. *
  268. IF( K.LT.1 )
  269. $ GO TO 70
  270. KSTEP = 1
  271. *
  272. * Determine rows and columns to be interchanged and whether
  273. * a 1-by-1 or 2-by-2 pivot block will be used
  274. *
  275. ABSAKK = ABS( A( K, K ) )
  276. *
  277. * IMAX is the row-index of the largest off-diagonal element in
  278. * column K, and COLMAX is its absolute value.
  279. * Determine both COLMAX and IMAX.
  280. *
  281. IF( K.GT.1 ) THEN
  282. IMAX = ISAMAX( K-1, A( 1, K ), 1 )
  283. COLMAX = ABS( A( IMAX, K ) )
  284. ELSE
  285. COLMAX = ZERO
  286. END IF
  287. *
  288. IF( (MAX( ABSAKK, COLMAX ).EQ.ZERO) .OR. SISNAN(ABSAKK) ) THEN
  289. *
  290. * Column K is zero or underflow, or contains a NaN:
  291. * set INFO and continue
  292. *
  293. IF( INFO.EQ.0 )
  294. $ INFO = K
  295. KP = K
  296. ELSE
  297. IF( ABSAKK.GE.ALPHA*COLMAX ) THEN
  298. *
  299. * no interchange, use 1-by-1 pivot block
  300. *
  301. KP = K
  302. ELSE
  303. *
  304. * JMAX is the column-index of the largest off-diagonal
  305. * element in row IMAX, and ROWMAX is its absolute value
  306. *
  307. JMAX = IMAX + ISAMAX( K-IMAX, A( IMAX, IMAX+1 ), LDA )
  308. ROWMAX = ABS( A( IMAX, JMAX ) )
  309. IF( IMAX.GT.1 ) THEN
  310. JMAX = ISAMAX( IMAX-1, A( 1, IMAX ), 1 )
  311. ROWMAX = MAX( ROWMAX, ABS( A( JMAX, IMAX ) ) )
  312. END IF
  313. *
  314. IF( ABSAKK.GE.ALPHA*COLMAX*( COLMAX / ROWMAX ) ) THEN
  315. *
  316. * no interchange, use 1-by-1 pivot block
  317. *
  318. KP = K
  319. ELSE IF( ABS( A( IMAX, IMAX ) ).GE.ALPHA*ROWMAX ) THEN
  320. *
  321. * interchange rows and columns K and IMAX, use 1-by-1
  322. * pivot block
  323. *
  324. KP = IMAX
  325. ELSE
  326. *
  327. * interchange rows and columns K-1 and IMAX, use 2-by-2
  328. * pivot block
  329. *
  330. KP = IMAX
  331. KSTEP = 2
  332. END IF
  333. END IF
  334. *
  335. KK = K - KSTEP + 1
  336. IF( KP.NE.KK ) THEN
  337. *
  338. * Interchange rows and columns KK and KP in the leading
  339. * submatrix A(1:k,1:k)
  340. *
  341. CALL SSWAP( KP-1, A( 1, KK ), 1, A( 1, KP ), 1 )
  342. CALL SSWAP( KK-KP-1, A( KP+1, KK ), 1, A( KP, KP+1 ),
  343. $ LDA )
  344. T = A( KK, KK )
  345. A( KK, KK ) = A( KP, KP )
  346. A( KP, KP ) = T
  347. IF( KSTEP.EQ.2 ) THEN
  348. T = A( K-1, K )
  349. A( K-1, K ) = A( KP, K )
  350. A( KP, K ) = T
  351. END IF
  352. END IF
  353. *
  354. * Update the leading submatrix
  355. *
  356. IF( KSTEP.EQ.1 ) THEN
  357. *
  358. * 1-by-1 pivot block D(k): column k now holds
  359. *
  360. * W(k) = U(k)*D(k)
  361. *
  362. * where U(k) is the k-th column of U
  363. *
  364. * Perform a rank-1 update of A(1:k-1,1:k-1) as
  365. *
  366. * A := A - U(k)*D(k)*U(k)**T = A - W(k)*1/D(k)*W(k)**T
  367. *
  368. R1 = ONE / A( K, K )
  369. CALL SSYR( UPLO, K-1, -R1, A( 1, K ), 1, A, LDA )
  370. *
  371. * Store U(k) in column k
  372. *
  373. CALL SSCAL( K-1, R1, A( 1, K ), 1 )
  374. ELSE
  375. *
  376. * 2-by-2 pivot block D(k): columns k and k-1 now hold
  377. *
  378. * ( W(k-1) W(k) ) = ( U(k-1) U(k) )*D(k)
  379. *
  380. * where U(k) and U(k-1) are the k-th and (k-1)-th columns
  381. * of U
  382. *
  383. * Perform a rank-2 update of A(1:k-2,1:k-2) as
  384. *
  385. * A := A - ( U(k-1) U(k) )*D(k)*( U(k-1) U(k) )**T
  386. * = A - ( W(k-1) W(k) )*inv(D(k))*( W(k-1) W(k) )**T
  387. *
  388. IF( K.GT.2 ) THEN
  389. *
  390. D12 = A( K-1, K )
  391. D22 = A( K-1, K-1 ) / D12
  392. D11 = A( K, K ) / D12
  393. T = ONE / ( D11*D22-ONE )
  394. D12 = T / D12
  395. *
  396. DO 30 J = K - 2, 1, -1
  397. WKM1 = D12*( D11*A( J, K-1 )-A( J, K ) )
  398. WK = D12*( D22*A( J, K )-A( J, K-1 ) )
  399. DO 20 I = J, 1, -1
  400. A( I, J ) = A( I, J ) - A( I, K )*WK -
  401. $ A( I, K-1 )*WKM1
  402. 20 CONTINUE
  403. A( J, K ) = WK
  404. A( J, K-1 ) = WKM1
  405. 30 CONTINUE
  406. *
  407. END IF
  408. *
  409. END IF
  410. END IF
  411. *
  412. * Store details of the interchanges in IPIV
  413. *
  414. IF( KSTEP.EQ.1 ) THEN
  415. IPIV( K ) = KP
  416. ELSE
  417. IPIV( K ) = -KP
  418. IPIV( K-1 ) = -KP
  419. END IF
  420. *
  421. * Decrease K and return to the start of the main loop
  422. *
  423. K = K - KSTEP
  424. GO TO 10
  425. *
  426. ELSE
  427. *
  428. * Factorize A as L*D*L**T using the lower triangle of A
  429. *
  430. * K is the main loop index, increasing from 1 to N in steps of
  431. * 1 or 2
  432. *
  433. K = 1
  434. 40 CONTINUE
  435. *
  436. * If K > N, exit from loop
  437. *
  438. IF( K.GT.N )
  439. $ GO TO 70
  440. KSTEP = 1
  441. *
  442. * Determine rows and columns to be interchanged and whether
  443. * a 1-by-1 or 2-by-2 pivot block will be used
  444. *
  445. ABSAKK = ABS( A( K, K ) )
  446. *
  447. * IMAX is the row-index of the largest off-diagonal element in
  448. * column K, and COLMAX is its absolute value.
  449. * Determine both COLMAX and IMAX.
  450. *
  451. IF( K.LT.N ) THEN
  452. IMAX = K + ISAMAX( N-K, A( K+1, K ), 1 )
  453. COLMAX = ABS( A( IMAX, K ) )
  454. ELSE
  455. COLMAX = ZERO
  456. END IF
  457. *
  458. IF( (MAX( ABSAKK, COLMAX ).EQ.ZERO) .OR. SISNAN(ABSAKK) ) THEN
  459. *
  460. * Column K is zero or underflow, or contains a NaN:
  461. * set INFO and continue
  462. *
  463. IF( INFO.EQ.0 )
  464. $ INFO = K
  465. KP = K
  466. ELSE
  467. IF( ABSAKK.GE.ALPHA*COLMAX ) THEN
  468. *
  469. * no interchange, use 1-by-1 pivot block
  470. *
  471. KP = K
  472. ELSE
  473. *
  474. * JMAX is the column-index of the largest off-diagonal
  475. * element in row IMAX, and ROWMAX is its absolute value
  476. *
  477. JMAX = K - 1 + ISAMAX( IMAX-K, A( IMAX, K ), LDA )
  478. ROWMAX = ABS( A( IMAX, JMAX ) )
  479. IF( IMAX.LT.N ) THEN
  480. JMAX = IMAX + ISAMAX( N-IMAX, A( IMAX+1, IMAX ), 1 )
  481. ROWMAX = MAX( ROWMAX, ABS( A( JMAX, IMAX ) ) )
  482. END IF
  483. *
  484. IF( ABSAKK.GE.ALPHA*COLMAX*( COLMAX / ROWMAX ) ) THEN
  485. *
  486. * no interchange, use 1-by-1 pivot block
  487. *
  488. KP = K
  489. ELSE IF( ABS( A( IMAX, IMAX ) ).GE.ALPHA*ROWMAX ) THEN
  490. *
  491. * interchange rows and columns K and IMAX, use 1-by-1
  492. * pivot block
  493. *
  494. KP = IMAX
  495. ELSE
  496. *
  497. * interchange rows and columns K+1 and IMAX, use 2-by-2
  498. * pivot block
  499. *
  500. KP = IMAX
  501. KSTEP = 2
  502. END IF
  503. END IF
  504. *
  505. KK = K + KSTEP - 1
  506. IF( KP.NE.KK ) THEN
  507. *
  508. * Interchange rows and columns KK and KP in the trailing
  509. * submatrix A(k:n,k:n)
  510. *
  511. IF( KP.LT.N )
  512. $ CALL SSWAP( N-KP, A( KP+1, KK ), 1, A( KP+1, KP ), 1 )
  513. CALL SSWAP( KP-KK-1, A( KK+1, KK ), 1, A( KP, KK+1 ),
  514. $ LDA )
  515. T = A( KK, KK )
  516. A( KK, KK ) = A( KP, KP )
  517. A( KP, KP ) = T
  518. IF( KSTEP.EQ.2 ) THEN
  519. T = A( K+1, K )
  520. A( K+1, K ) = A( KP, K )
  521. A( KP, K ) = T
  522. END IF
  523. END IF
  524. *
  525. * Update the trailing submatrix
  526. *
  527. IF( KSTEP.EQ.1 ) THEN
  528. *
  529. * 1-by-1 pivot block D(k): column k now holds
  530. *
  531. * W(k) = L(k)*D(k)
  532. *
  533. * where L(k) is the k-th column of L
  534. *
  535. IF( K.LT.N ) THEN
  536. *
  537. * Perform a rank-1 update of A(k+1:n,k+1:n) as
  538. *
  539. * A := A - L(k)*D(k)*L(k)**T = A - W(k)*(1/D(k))*W(k)**T
  540. *
  541. D11 = ONE / A( K, K )
  542. CALL SSYR( UPLO, N-K, -D11, A( K+1, K ), 1,
  543. $ A( K+1, K+1 ), LDA )
  544. *
  545. * Store L(k) in column K
  546. *
  547. CALL SSCAL( N-K, D11, A( K+1, K ), 1 )
  548. END IF
  549. ELSE
  550. *
  551. * 2-by-2 pivot block D(k)
  552. *
  553. IF( K.LT.N-1 ) THEN
  554. *
  555. * Perform a rank-2 update of A(k+2:n,k+2:n) as
  556. *
  557. * A := A - ( (A(k) A(k+1))*D(k)**(-1) ) * (A(k) A(k+1))**T
  558. *
  559. * where L(k) and L(k+1) are the k-th and (k+1)-th
  560. * columns of L
  561. *
  562. D21 = A( K+1, K )
  563. D11 = A( K+1, K+1 ) / D21
  564. D22 = A( K, K ) / D21
  565. T = ONE / ( D11*D22-ONE )
  566. D21 = T / D21
  567. *
  568. DO 60 J = K + 2, N
  569. *
  570. WK = D21*( D11*A( J, K )-A( J, K+1 ) )
  571. WKP1 = D21*( D22*A( J, K+1 )-A( J, K ) )
  572. *
  573. DO 50 I = J, N
  574. A( I, J ) = A( I, J ) - A( I, K )*WK -
  575. $ A( I, K+1 )*WKP1
  576. 50 CONTINUE
  577. *
  578. A( J, K ) = WK
  579. A( J, K+1 ) = WKP1
  580. *
  581. 60 CONTINUE
  582. END IF
  583. END IF
  584. END IF
  585. *
  586. * Store details of the interchanges in IPIV
  587. *
  588. IF( KSTEP.EQ.1 ) THEN
  589. IPIV( K ) = KP
  590. ELSE
  591. IPIV( K ) = -KP
  592. IPIV( K+1 ) = -KP
  593. END IF
  594. *
  595. * Increase K and return to the start of the main loop
  596. *
  597. K = K + KSTEP
  598. GO TO 40
  599. *
  600. END IF
  601. *
  602. 70 CONTINUE
  603. *
  604. RETURN
  605. *
  606. * End of SSYTF2
  607. *
  608. END