3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download SLASYF_AA + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/slasyf_aa.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/slasyf_aa.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/slasyf_aa.f">
21 * SUBROUTINE SLASYF_AA( UPLO, J1, M, NB, A, LDA, IPIV,
22 * H, LDH, WORK, INFO )
24 * .. Scalar Arguments ..
26 * INTEGER J1, M, NB, LDA, LDH, INFO
28 * .. Array Arguments ..
30 * REAL A( LDA, * ), H( LDH, * ), WORK( * )
39 *> DLATRF_AA factorizes a panel of a real symmetric matrix A using
40 *> the Aasen's algorithm. The panel consists of a set of NB rows of A
41 *> when UPLO is U, or a set of NB columns when UPLO is L.
43 *> In order to factorize the panel, the Aasen's algorithm requires the
44 *> last row, or column, of the previous panel. The first row, or column,
45 *> of A is set to be the first row, or column, of an identity matrix,
46 *> which is used to factorize the first panel.
48 *> The resulting J-th row of U, or J-th column of L, is stored in the
49 *> (J-1)-th row, or column, of A (without the unit diagonals), while
50 *> the diagonal and subdiagonal of A are overwritten by those of T.
59 *> UPLO is CHARACTER*1
60 *> = 'U': Upper triangle of A is stored;
61 *> = 'L': Lower triangle of A is stored.
67 *> The location of the first row, or column, of the panel
68 *> within the submatrix of A, passed to this routine, e.g.,
69 *> when called by SSYTRF_AA, for the first panel, J1 is 1,
70 *> while for the remaining panels, J1 is 2.
76 *> The dimension of the submatrix. M >= 0.
82 *> The dimension of the panel to be facotorized.
87 *> A is REAL array, dimension (LDA,M) for
88 *> the first panel, while dimension (LDA,M+1) for the
91 *> On entry, A contains the last row, or column, of
92 *> the previous panel, and the trailing submatrix of A
93 *> to be factorized, except for the first panel, only
94 *> the panel is passed.
96 *> On exit, the leading panel is factorized.
102 *> The leading dimension of the array A. LDA >= max(1,M).
107 *> IPIV is INTEGER array, dimension (M)
108 *> Details of the row and column interchanges,
109 *> the row and column k were interchanged with the row and
115 *> H is REAL workspace, dimension (LDH,NB).
122 *> The leading dimension of the workspace H. LDH >= max(1,M).
127 *> WORK is REAL workspace, dimension (M).
133 *> = 0: successful exit
134 *> < 0: if INFO = -i, the i-th argument had an illegal value
135 *> > 0: if INFO = i, D(i,i) is exactly zero. The factorization
136 *> has been completed, but the block diagonal matrix D is
137 *> exactly singular, and division by zero will occur if it
138 *> is used to solve a system of equations.
144 *> \author Univ. of Tennessee
145 *> \author Univ. of California Berkeley
146 *> \author Univ. of Colorado Denver
149 *> \date December 2016
151 *> \ingroup realSYcomputational
153 * =====================================================================
154 SUBROUTINE SLASYF_AA( UPLO, J1, M, NB, A, LDA, IPIV,
155 $ H, LDH, WORK, INFO )
157 * -- LAPACK computational routine (version 3.7.0) --
158 * -- LAPACK is a software package provided by Univ. of Tennessee, --
159 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
164 * .. Scalar Arguments ..
166 INTEGER M, NB, J1, LDA, LDH, INFO
168 * .. Array Arguments ..
170 REAL A( LDA, * ), H( LDH, * ), WORK( * )
173 * =====================================================================
176 PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 )
178 * .. Local Scalars ..
179 INTEGER J, K, K1, I1, I2
182 * .. External Functions ..
184 INTEGER ISAMAX, ILAENV
185 EXTERNAL LSAME, ILAENV, ISAMAX
187 * .. External Subroutines ..
190 * .. Intrinsic Functions ..
193 * .. Executable Statements ..
198 * K1 is the first column of the panel to be factorized
199 * i.e., K1 is 2 for the first block column, and 1 for the rest of the blocks
203 IF( LSAME( UPLO, 'U' ) ) THEN
205 * .....................................................
206 * Factorize A as U**T*D*U using the upper triangle of A
207 * .....................................................
210 IF ( J.GT.MIN(M, NB) )
213 * K is the column to be factorized
214 * when being called from SSYTRF_AA,
215 * > for the first block column, J1 is 1, hence J1+J-1 is J,
216 * > for the rest of the columns, J1 is 2, and J1+J-1 is J+1,
220 * H(J:M, J) := A(J, J:M) - H(J:M, 1:(J-1)) * L(J1:(J-1), J),
221 * where H(J:M, J) has been initialized to be A(J, J:M)
225 * K is the column to be factorized
226 * > for the first block column, K is J, skipping the first two
228 * > for the rest of the columns, K is J+1, skipping only the
231 CALL SGEMV( 'No transpose', M-J+1, J-K1,
232 $ -ONE, H( J, K1 ), LDH,
234 $ ONE, H( J, J ), 1 )
237 * Copy H(i:M, i) into WORK
239 CALL SCOPY( M-J+1, H( J, J ), 1, WORK( 1 ), 1 )
243 * Compute WORK := WORK - L(J-1, J:M) * T(J-1,J),
244 * where A(J-1, J) stores T(J-1, J) and A(J-2, J:M) stores U(J-1, J:M)
247 CALL SAXPY( M-J+1, ALPHA, A( K-2, J ), LDA, WORK( 1 ), 1 )
250 * Set A(J, J) = T(J, J)
252 A( K, J ) = WORK( 1 )
256 * Compute WORK(2:M) = T(J, J) L(J, (J+1):M)
257 * where A(J, J) stores T(J, J) and A(J-1, (J+1):M) stores U(J, (J+1):M)
261 CALL SAXPY( M-J, ALPHA, A( K-1, J+1 ), LDA,
265 * Find max(|WORK(2:M)|)
267 I2 = ISAMAX( M-J, WORK( 2 ), 1 ) + 1
270 * Apply symmetric pivot
272 IF( (I2.NE.2) .AND. (PIV.NE.0) ) THEN
274 * Swap WORK(I1) and WORK(I2)
277 WORK( I2 ) = WORK( I1 )
280 * Swap A(I1, I1+1:M) with A(I1+1:M, I2)
284 CALL SSWAP( I2-I1-1, A( J1+I1-1, I1+1 ), LDA,
285 $ A( J1+I1, I2 ), 1 )
287 * Swap A(I1, I2+1:M) with A(I2, I2+1:M)
289 CALL SSWAP( M-I2, A( J1+I1-1, I2+1 ), LDA,
290 $ A( J1+I2-1, I2+1 ), LDA )
292 * Swap A(I1, I1) with A(I2,I2)
294 PIV = A( I1+J1-1, I1 )
295 A( J1+I1-1, I1 ) = A( J1+I2-1, I2 )
296 A( J1+I2-1, I2 ) = PIV
298 * Swap H(I1, 1:J1) with H(I2, 1:J1)
300 CALL SSWAP( I1-1, H( I1, 1 ), LDH, H( I2, 1 ), LDH )
303 IF( I1.GT.(K1-1) ) THEN
305 * Swap L(1:I1-1, I1) with L(1:I1-1, I2),
306 * skipping the first column
308 CALL SSWAP( I1-K1+1, A( 1, I1 ), 1,
315 * Set A(J, J+1) = T(J, J+1)
317 A( K, J+1 ) = WORK( 2 )
318 IF( (A( K, J ).EQ.ZERO ) .AND. (A( K, J+1 ).EQ.ZERO) .AND.
319 $ ((K.EQ.1) .OR. (A( K-1, J ).EQ.ZERO)) ) THEN
327 * Copy A(J+1:M, J+1) into H(J:M, J),
329 CALL SCOPY( M-J, A( K+1, J+1 ), LDA,
333 * Compute L(J+2, J+1) = WORK( 3:M ) / T(J, J+1),
334 * where A(J, J+1) = T(J, J+1) and A(J+2:M, J) = L(J+2:M, J+1)
336 IF( A( K, J+1 ).NE.ZERO ) THEN
337 ALPHA = ONE / A( K, J+1 )
338 CALL SCOPY( M-J-1, WORK( 3 ), 1, A( K, J+2 ), LDA )
339 CALL SSCAL( M-J-1, ALPHA, A( K, J+2 ), LDA )
341 CALL SLASET( 'Full', 1, M-J-1, ZERO, ZERO,
345 IF( (A( K, J ).EQ.ZERO) .AND.
346 $ ((K.EQ.1) .OR. (A( J-1, J ).EQ.ZERO)) ) THEN
358 * .....................................................
359 * Factorize A as L*D*L**T using the lower triangle of A
360 * .....................................................
363 IF( J.GT.MIN( M, NB ) )
366 * K is the column to be factorized
367 * when being called from SSYTRF_AA,
368 * > for the first block column, J1 is 1, hence J1+J-1 is J,
369 * > for the rest of the columns, J1 is 2, and J1+J-1 is J+1,
373 * H(J:M, J) := A(J:M, J) - H(J:M, 1:(J-1)) * L(J, J1:(J-1))^T,
374 * where H(J:M, J) has been initialized to be A(J:M, J)
378 * K is the column to be factorized
379 * > for the first block column, K is J, skipping the first two
381 * > for the rest of the columns, K is J+1, skipping only the
384 CALL SGEMV( 'No transpose', M-J+1, J-K1,
385 $ -ONE, H( J, K1 ), LDH,
387 $ ONE, H( J, J ), 1 )
390 * Copy H(J:M, J) into WORK
392 CALL SCOPY( M-J+1, H( J, J ), 1, WORK( 1 ), 1 )
396 * Compute WORK := WORK - L(J:M, J-1) * T(J-1,J),
397 * where A(J-1, J) = T(J-1, J) and A(J, J-2) = L(J, J-1)
400 CALL SAXPY( M-J+1, ALPHA, A( J, K-2 ), 1, WORK( 1 ), 1 )
403 * Set A(J, J) = T(J, J)
405 A( J, K ) = WORK( 1 )
409 * Compute WORK(2:M) = T(J, J) L((J+1):M, J)
410 * where A(J, J) = T(J, J) and A((J+1):M, J-1) = L((J+1):M, J)
414 CALL SAXPY( M-J, ALPHA, A( J+1, K-1 ), 1,
418 * Find max(|WORK(2:M)|)
420 I2 = ISAMAX( M-J, WORK( 2 ), 1 ) + 1
423 * Apply symmetric pivot
425 IF( (I2.NE.2) .AND. (PIV.NE.0) ) THEN
427 * Swap WORK(I1) and WORK(I2)
430 WORK( I2 ) = WORK( I1 )
433 * Swap A(I1+1:M, I1) with A(I2, I1+1:M)
437 CALL SSWAP( I2-I1-1, A( I1+1, J1+I1-1 ), 1,
438 $ A( I2, J1+I1 ), LDA )
440 * Swap A(I2+1:M, I1) with A(I2+1:M, I2)
442 CALL SSWAP( M-I2, A( I2+1, J1+I1-1 ), 1,
443 $ A( I2+1, J1+I2-1 ), 1 )
445 * Swap A(I1, I1) with A(I2, I2)
447 PIV = A( I1, J1+I1-1 )
448 A( I1, J1+I1-1 ) = A( I2, J1+I2-1 )
449 A( I2, J1+I2-1 ) = PIV
451 * Swap H(I1, I1:J1) with H(I2, I2:J1)
453 CALL SSWAP( I1-1, H( I1, 1 ), LDH, H( I2, 1 ), LDH )
456 IF( I1.GT.(K1-1) ) THEN
458 * Swap L(1:I1-1, I1) with L(1:I1-1, I2),
459 * skipping the first column
461 CALL SSWAP( I1-K1+1, A( I1, 1 ), LDA,
468 * Set A(J+1, J) = T(J+1, J)
470 A( J+1, K ) = WORK( 2 )
471 IF( (A( J, K ).EQ.ZERO) .AND. (A( J+1, K ).EQ.ZERO) .AND.
472 $ ((K.EQ.1) .OR. (A( J, K-1 ).EQ.ZERO)) ) THEN
479 * Copy A(J+1:M, J+1) into H(J+1:M, J),
481 CALL SCOPY( M-J, A( J+1, K+1 ), 1,
485 * Compute L(J+2, J+1) = WORK( 3:M ) / T(J, J+1),
486 * where A(J, J+1) = T(J, J+1) and A(J+2:M, J) = L(J+2:M, J+1)
488 IF( A( J+1, K ).NE.ZERO ) THEN
489 ALPHA = ONE / A( J+1, K )
490 CALL SCOPY( M-J-1, WORK( 3 ), 1, A( J+2, K ), 1 )
491 CALL SSCAL( M-J-1, ALPHA, A( J+2, K ), 1 )
493 CALL SLASET( 'Full', M-J-1, 1, ZERO, ZERO,
497 IF( (A( J, K ).EQ.ZERO) .AND.
498 $ ((K.EQ.1) .OR. (A( J, K-1 ).EQ.ZERO)) ) THEN