3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download ZLAHEF_AA + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlahef_aa.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlahef_aa.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlahef_aa.f">
21 * SUBROUTINE ZLAHEF_AA( UPLO, J1, M, NB, A, LDA, IPIV,
24 * .. Scalar Arguments ..
26 * INTEGER J1, M, NB, LDA, LDH
28 * .. Array Arguments ..
30 * COMPLEX*16 A( LDA, * ), H( LDH, * ), WORK( * )
39 *> DLAHEF_AA factorizes a panel of a complex hermitian 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 ZHETRF_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 COMPLEX*16 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,N).
107 *> IPIV is INTEGER array, dimension (N)
108 *> Details of the row and column interchanges,
109 *> the row and column k were interchanged with the row and
115 *> H is COMPLEX*16 workspace, dimension (LDH,NB).
122 *> The leading dimension of the workspace H. LDH >= max(1,M).
127 *> WORK is COMPLEX*16 workspace, dimension (M).
134 *> \author Univ. of Tennessee
135 *> \author Univ. of California Berkeley
136 *> \author Univ. of Colorado Denver
139 *> \date December 2016
141 *> \ingroup complex16HEcomputational
143 * =====================================================================
144 SUBROUTINE ZLAHEF_AA( UPLO, J1, M, NB, A, LDA, IPIV,
147 * -- LAPACK computational routine (version 3.7.0) --
148 * -- LAPACK is a software package provided by Univ. of Tennessee, --
149 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
154 * .. Scalar Arguments ..
156 INTEGER M, NB, J1, LDA, LDH
158 * .. Array Arguments ..
160 COMPLEX*16 A( LDA, * ), H( LDH, * ), WORK( * )
163 * =====================================================================
166 PARAMETER ( ZERO = (0.0D+0, 0.0D+0), ONE = (1.0D+0, 0.0D+0) )
168 * .. Local Scalars ..
169 INTEGER J, K, K1, I1, I2
170 COMPLEX*16 PIV, ALPHA
172 * .. External Functions ..
174 INTEGER IZAMAX, ILAENV
175 EXTERNAL LSAME, ILAENV, IZAMAX
177 * .. External Subroutines ..
180 * .. Intrinsic Functions ..
181 INTRINSIC DBLE, DCONJG, MAX
183 * .. Executable Statements ..
187 * K1 is the first column of the panel to be factorized
188 * i.e., K1 is 2 for the first block column, and 1 for the rest of the blocks
192 IF( LSAME( UPLO, 'U' ) ) THEN
194 * .....................................................
195 * Factorize A as U**T*D*U using the upper triangle of A
196 * .....................................................
199 IF ( J.GT.MIN(M, NB) )
202 * K is the column to be factorized
203 * when being called from ZHETRF_AA,
204 * > for the first block column, J1 is 1, hence J1+J-1 is J,
205 * > for the rest of the columns, J1 is 2, and J1+J-1 is J+1,
209 * H(J:N, J) := A(J, J:N) - H(J:N, 1:(J-1)) * L(J1:(J-1), J),
210 * where H(J:N, J) has been initialized to be A(J, J:N)
214 * K is the column to be factorized
215 * > for the first block column, K is J, skipping the first two
217 * > for the rest of the columns, K is J+1, skipping only the
220 CALL ZLACGV( J-K1, A( 1, J ), 1 )
221 CALL ZGEMV( 'No transpose', M-J+1, J-K1,
222 $ -ONE, H( J, K1 ), LDH,
224 $ ONE, H( J, J ), 1 )
225 CALL ZLACGV( J-K1, A( 1, J ), 1 )
228 * Copy H(i:n, i) into WORK
230 CALL ZCOPY( M-J+1, H( J, J ), 1, WORK( 1 ), 1 )
234 * Compute WORK := WORK - L(J-1, J:N) * T(J-1,J),
235 * where A(J-1, J) stores T(J-1, J) and A(J-2, J:N) stores U(J-1, J:N)
237 ALPHA = -DCONJG( A( K-1, J ) )
238 CALL ZAXPY( M-J+1, ALPHA, A( K-2, J ), LDA, WORK( 1 ), 1 )
241 * Set A(J, J) = T(J, J)
243 A( K, J ) = DBLE( WORK( 1 ) )
247 * Compute WORK(2:N) = T(J, J) L(J, (J+1):N)
248 * where A(J, J) stores T(J, J) and A(J-1, (J+1):N) stores U(J, (J+1):N)
252 CALL ZAXPY( M-J, ALPHA, A( K-1, J+1 ), LDA,
256 * Find max(|WORK(2:n)|)
258 I2 = IZAMAX( M-J, WORK( 2 ), 1 ) + 1
261 * Apply hermitian pivot
263 IF( (I2.NE.2) .AND. (PIV.NE.0) ) THEN
265 * Swap WORK(I1) and WORK(I2)
268 WORK( I2 ) = WORK( I1 )
271 * Swap A(I1, I1+1:N) with A(I1+1:N, I2)
275 CALL ZSWAP( I2-I1-1, A( J1+I1-1, I1+1 ), LDA,
276 $ A( J1+I1, I2 ), 1 )
277 CALL ZLACGV( I2-I1, A( J1+I1-1, I1+1 ), LDA )
278 CALL ZLACGV( I2-I1-1, A( J1+I1, I2 ), 1 )
280 * Swap A(I1, I2+1:N) with A(I2, I2+1:N)
282 CALL ZSWAP( M-I2, A( J1+I1-1, I2+1 ), LDA,
283 $ A( J1+I2-1, I2+1 ), LDA )
285 * Swap A(I1, I1) with A(I2,I2)
287 PIV = A( I1+J1-1, I1 )
288 A( J1+I1-1, I1 ) = A( J1+I2-1, I2 )
289 A( J1+I2-1, I2 ) = PIV
291 * Swap H(I1, 1:J1) with H(I2, 1:J1)
293 CALL ZSWAP( I1-1, H( I1, 1 ), LDH, H( I2, 1 ), LDH )
296 IF( I1.GT.(K1-1) ) THEN
298 * Swap L(1:I1-1, I1) with L(1:I1-1, I2),
299 * skipping the first column
301 CALL ZSWAP( I1-K1+1, A( 1, I1 ), 1,
308 * Set A(J, J+1) = T(J, J+1)
310 A( K, J+1 ) = WORK( 2 )
314 * Copy A(J+1:N, J+1) into H(J:N, J),
316 CALL ZCOPY( M-J, A( K+1, J+1 ), LDA,
320 * Compute L(J+2, J+1) = WORK( 3:N ) / T(J, J+1),
321 * where A(J, J+1) = T(J, J+1) and A(J+2:N, J) = L(J+2:N, J+1)
323 IF( A( K, J+1 ).NE.ZERO ) THEN
324 ALPHA = ONE / A( K, J+1 )
325 CALL ZCOPY( M-J-1, WORK( 3 ), 1, A( K, J+2 ), LDA )
326 CALL ZSCAL( M-J-1, ALPHA, A( K, J+2 ), LDA )
328 CALL ZLASET( 'Full', 1, M-J-1, ZERO, ZERO,
338 * .....................................................
339 * Factorize A as L*D*L**T using the lower triangle of A
340 * .....................................................
343 IF( J.GT.MIN( M, NB ) )
346 * K is the column to be factorized
347 * when being called from ZHETRF_AA,
348 * > for the first block column, J1 is 1, hence J1+J-1 is J,
349 * > for the rest of the columns, J1 is 2, and J1+J-1 is J+1,
353 * H(J:N, J) := A(J:N, J) - H(J:N, 1:(J-1)) * L(J, J1:(J-1))^T,
354 * where H(J:N, J) has been initialized to be A(J:N, J)
358 * K is the column to be factorized
359 * > for the first block column, K is J, skipping the first two
361 * > for the rest of the columns, K is J+1, skipping only the
364 CALL ZLACGV( J-K1, A( J, 1 ), LDA )
365 CALL ZGEMV( 'No transpose', M-J+1, J-K1,
366 $ -ONE, H( J, K1 ), LDH,
368 $ ONE, H( J, J ), 1 )
369 CALL ZLACGV( J-K1, A( J, 1 ), LDA )
372 * Copy H(J:N, J) into WORK
374 CALL ZCOPY( M-J+1, H( J, J ), 1, WORK( 1 ), 1 )
378 * Compute WORK := WORK - L(J:N, J-1) * T(J-1,J),
379 * where A(J-1, J) = T(J-1, J) and A(J, J-2) = L(J, J-1)
381 ALPHA = -DCONJG( A( J, K-1 ) )
382 CALL ZAXPY( M-J+1, ALPHA, A( J, K-2 ), 1, WORK( 1 ), 1 )
385 * Set A(J, J) = T(J, J)
387 A( J, K ) = DBLE( WORK( 1 ) )
391 * Compute WORK(2:N) = T(J, J) L((J+1):N, J)
392 * where A(J, J) = T(J, J) and A((J+1):N, J-1) = L((J+1):N, J)
396 CALL ZAXPY( M-J, ALPHA, A( J+1, K-1 ), 1,
400 * Find max(|WORK(2:n)|)
402 I2 = IZAMAX( M-J, WORK( 2 ), 1 ) + 1
405 * Apply hermitian pivot
407 IF( (I2.NE.2) .AND. (PIV.NE.0) ) THEN
409 * Swap WORK(I1) and WORK(I2)
412 WORK( I2 ) = WORK( I1 )
415 * Swap A(I1+1:N, I1) with A(I2, I1+1:N)
419 CALL ZSWAP( I2-I1-1, A( I1+1, J1+I1-1 ), 1,
420 $ A( I2, J1+I1 ), LDA )
421 CALL ZLACGV( I2-I1, A( I1+1, J1+I1-1 ), 1 )
422 CALL ZLACGV( I2-I1-1, A( I2, J1+I1 ), LDA )
424 * Swap A(I2+1:N, I1) with A(I2+1:N, I2)
426 CALL ZSWAP( M-I2, A( I2+1, J1+I1-1 ), 1,
427 $ A( I2+1, J1+I2-1 ), 1 )
429 * Swap A(I1, I1) with A(I2, I2)
431 PIV = A( I1, J1+I1-1 )
432 A( I1, J1+I1-1 ) = A( I2, J1+I2-1 )
433 A( I2, J1+I2-1 ) = PIV
435 * Swap H(I1, I1:J1) with H(I2, I2:J1)
437 CALL ZSWAP( I1-1, H( I1, 1 ), LDH, H( I2, 1 ), LDH )
440 IF( I1.GT.(K1-1) ) THEN
442 * Swap L(1:I1-1, I1) with L(1:I1-1, I2),
443 * skipping the first column
445 CALL ZSWAP( I1-K1+1, A( I1, 1 ), LDA,
452 * Set A(J+1, J) = T(J+1, J)
454 A( J+1, K ) = WORK( 2 )
458 * Copy A(J+1:N, J+1) into H(J+1:N, J),
460 CALL ZCOPY( M-J, A( J+1, K+1 ), 1,
464 * Compute L(J+2, J+1) = WORK( 3:N ) / T(J, J+1),
465 * where A(J, J+1) = T(J, J+1) and A(J+2:N, J) = L(J+2:N, J+1)
467 IF( A( J+1, K ).NE.ZERO ) THEN
468 ALPHA = ONE / A( J+1, K )
469 CALL ZCOPY( M-J-1, WORK( 3 ), 1, A( J+2, K ), 1 )
470 CALL ZSCAL( M-J-1, ALPHA, A( J+2, K ), 1 )
472 CALL ZLASET( 'Full', M-J-1, 1, ZERO, ZERO,