numeric-linalg
Educational material on the SciPy implementation of numerical linear algebra algorithms
Name | Size | Mode | |
.. | |||
lapack/SRC/dlasyf_aa.f | 14543B | -rw-r--r-- |
001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031 032 033 034 035 036 037 038 039 040 041 042 043 044 045 046 047 048 049 050 051 052 053 054 055 056 057 058 059 060 061 062 063 064 065 066 067 068 069 070 071 072 073 074 075 076 077 078 079 080 081 082 083 084 085 086 087 088 089 090 091 092 093 094 095 096 097 098 099 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497
*> \brief \b DLASYF_AA * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * *> \htmlonly *> Download DLASYF_AA + dependencies *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlasyf_aa.f"> *> [TGZ]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlasyf_aa.f"> *> [ZIP]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlasyf_aa.f"> *> [TXT]</a> *> \endhtmlonly * * Definition: * =========== * * SUBROUTINE DLASYF_AA( UPLO, J1, M, NB, A, LDA, IPIV, * H, LDH, WORK ) * * .. Scalar Arguments .. * CHARACTER UPLO * INTEGER J1, M, NB, LDA, LDH * .. * .. Array Arguments .. * INTEGER IPIV( * ) * DOUBLE PRECISION A( LDA, * ), H( LDH, * ), WORK( * ) * .. * * *> \par Purpose: * ============= *> *> \verbatim *> *> DLATRF_AA factorizes a panel of a real symmetric matrix A using *> the Aasen's algorithm. The panel consists of a set of NB rows of A *> when UPLO is U, or a set of NB columns when UPLO is L. *> *> In order to factorize the panel, the Aasen's algorithm requires the *> last row, or column, of the previous panel. The first row, or column, *> of A is set to be the first row, or column, of an identity matrix, *> which is used to factorize the first panel. *> *> The resulting J-th row of U, or J-th column of L, is stored in the *> (J-1)-th row, or column, of A (without the unit diagonals), while *> the diagonal and subdiagonal of A are overwritten by those of T. *> *> \endverbatim * * Arguments: * ========== * *> \param[in] UPLO *> \verbatim *> UPLO is CHARACTER*1 *> = 'U': Upper triangle of A is stored; *> = 'L': Lower triangle of A is stored. *> \endverbatim *> *> \param[in] J1 *> \verbatim *> J1 is INTEGER *> The location of the first row, or column, of the panel *> within the submatrix of A, passed to this routine, e.g., *> when called by DSYTRF_AA, for the first panel, J1 is 1, *> while for the remaining panels, J1 is 2. *> \endverbatim *> *> \param[in] M *> \verbatim *> M is INTEGER *> The dimension of the submatrix. M >= 0. *> \endverbatim *> *> \param[in] NB *> \verbatim *> NB is INTEGER *> The dimension of the panel to be facotorized. *> \endverbatim *> *> \param[in,out] A *> \verbatim *> A is DOUBLE PRECISION array, dimension (LDA,M) for *> the first panel, while dimension (LDA,M+1) for the *> remaining panels. *> *> On entry, A contains the last row, or column, of *> the previous panel, and the trailing submatrix of A *> to be factorized, except for the first panel, only *> the panel is passed. *> *> On exit, the leading panel is factorized. *> \endverbatim *> *> \param[in] LDA *> \verbatim *> LDA is INTEGER *> The leading dimension of the array A. LDA >= max(1,M). *> \endverbatim *> *> \param[out] IPIV *> \verbatim *> IPIV is INTEGER array, dimension (M) *> Details of the row and column interchanges, *> the row and column k were interchanged with the row and *> column IPIV(k). *> \endverbatim *> *> \param[in,out] H *> \verbatim *> H is DOUBLE PRECISION workspace, dimension (LDH,NB). *> *> \endverbatim *> *> \param[in] LDH *> \verbatim *> LDH is INTEGER *> The leading dimension of the workspace H. LDH >= max(1,M). *> \endverbatim *> *> \param[out] WORK *> \verbatim *> WORK is DOUBLE PRECISION workspace, dimension (M). *> \endverbatim *> * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \ingroup lahef_aa * * ===================================================================== SUBROUTINE DLASYF_AA( UPLO, J1, M, NB, A, LDA, IPIV, $ H, LDH, WORK ) * * -- LAPACK computational routine -- * -- LAPACK is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * IMPLICIT NONE * * .. Scalar Arguments .. CHARACTER UPLO INTEGER M, NB, J1, LDA, LDH * .. * .. Array Arguments .. INTEGER IPIV( * ) DOUBLE PRECISION A( LDA, * ), H( LDH, * ), WORK( * ) * .. * * ===================================================================== * .. Parameters .. DOUBLE PRECISION ZERO, ONE PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 ) * * .. Local Scalars .. INTEGER J, K, K1, I1, I2, MJ DOUBLE PRECISION PIV, ALPHA * .. * .. External Functions .. LOGICAL LSAME INTEGER IDAMAX, ILAENV EXTERNAL LSAME, ILAENV, IDAMAX * .. * .. External Subroutines .. EXTERNAL DGEMV, DAXPY, DCOPY, DSWAP, DSCAL, $ DLASET, $ XERBLA * .. * .. Intrinsic Functions .. INTRINSIC MAX * .. * .. Executable Statements .. * J = 1 * * K1 is the first column of the panel to be factorized * i.e., K1 is 2 for the first block column, and 1 for the rest of the blocks * K1 = (2-J1)+1 * IF( LSAME( UPLO, 'U' ) ) THEN * * ..................................................... * Factorize A as U**T*D*U using the upper triangle of A * ..................................................... * 10 CONTINUE IF ( J.GT.MIN(M, NB) ) $ GO TO 20 * * K is the column to be factorized * when being called from DSYTRF_AA, * > for the first block column, J1 is 1, hence J1+J-1 is J, * > for the rest of the columns, J1 is 2, and J1+J-1 is J+1, * K = J1+J-1 IF( J.EQ.M ) THEN * * Only need to compute T(J, J) * MJ = 1 ELSE MJ = M-J+1 END IF * * H(J:M, J) := A(J, J:M) - H(J:M, 1:(J-1)) * L(J1:(J-1), J), * where H(J:M, J) has been initialized to be A(J, J:M) * IF( K.GT.2 ) THEN * * K is the column to be factorized * > for the first block column, K is J, skipping the first two * columns * > for the rest of the columns, K is J+1, skipping only the * first column * CALL DGEMV( 'No transpose', MJ, J-K1, $ -ONE, H( J, K1 ), LDH, $ A( 1, J ), 1, $ ONE, H( J, J ), 1 ) END IF * * Copy H(i:M, i) into WORK * CALL DCOPY( MJ, H( J, J ), 1, WORK( 1 ), 1 ) * IF( J.GT.K1 ) THEN * * Compute WORK := WORK - L(J-1, J:M) * T(J-1,J), * where A(J-1, J) stores T(J-1, J) and A(J-2, J:M) stores U(J-1, J:M) * ALPHA = -A( K-1, J ) CALL DAXPY( MJ, ALPHA, A( K-2, J ), LDA, WORK( 1 ), 1 ) END IF * * Set A(J, J) = T(J, J) * A( K, J ) = WORK( 1 ) * IF( J.LT.M ) THEN * * Compute WORK(2:M) = T(J, J) L(J, (J+1):M) * where A(J, J) stores T(J, J) and A(J-1, (J+1):M) stores U(J, (J+1):M) * IF( K.GT.1 ) THEN ALPHA = -A( K, J ) CALL DAXPY( M-J, ALPHA, A( K-1, J+1 ), LDA, $ WORK( 2 ), 1 ) ENDIF * * Find max(|WORK(2:M)|) * I2 = IDAMAX( M-J, WORK( 2 ), 1 ) + 1 PIV = WORK( I2 ) * * Apply symmetric pivot * IF( (I2.NE.2) .AND. (PIV.NE.0) ) THEN * * Swap WORK(I1) and WORK(I2) * I1 = 2 WORK( I2 ) = WORK( I1 ) WORK( I1 ) = PIV * * Swap A(I1, I1+1:M) with A(I1+1:M, I2) * I1 = I1+J-1 I2 = I2+J-1 CALL DSWAP( I2-I1-1, A( J1+I1-1, I1+1 ), LDA, $ A( J1+I1, I2 ), 1 ) * * Swap A(I1, I2+1:M) with A(I2, I2+1:M) * IF( I2.LT.M ) $ CALL DSWAP( M-I2, A( J1+I1-1, I2+1 ), LDA, $ A( J1+I2-1, I2+1 ), LDA ) * * Swap A(I1, I1) with A(I2,I2) * PIV = A( I1+J1-1, I1 ) A( J1+I1-1, I1 ) = A( J1+I2-1, I2 ) A( J1+I2-1, I2 ) = PIV * * Swap H(I1, 1:J1) with H(I2, 1:J1) * CALL DSWAP( I1-1, H( I1, 1 ), LDH, H( I2, 1 ), LDH ) IPIV( I1 ) = I2 * IF( I1.GT.(K1-1) ) THEN * * Swap L(1:I1-1, I1) with L(1:I1-1, I2), * skipping the first column * CALL DSWAP( I1-K1+1, A( 1, I1 ), 1, $ A( 1, I2 ), 1 ) END IF ELSE IPIV( J+1 ) = J+1 ENDIF * * Set A(J, J+1) = T(J, J+1) * A( K, J+1 ) = WORK( 2 ) * IF( J.LT.NB ) THEN * * Copy A(J+1:M, J+1) into H(J:M, J), * CALL DCOPY( M-J, A( K+1, J+1 ), LDA, $ H( J+1, J+1 ), 1 ) END IF * * Compute L(J+2, J+1) = WORK( 3:M ) / T(J, J+1), * where A(J, J+1) = T(J, J+1) and A(J+2:M, J) = L(J+2:M, J+1) * IF( J.LT.(M-1) ) THEN IF( A( K, J+1 ).NE.ZERO ) THEN ALPHA = ONE / A( K, J+1 ) CALL DCOPY( M-J-1, WORK( 3 ), 1, A( K, J+2 ), LDA ) CALL DSCAL( M-J-1, ALPHA, A( K, J+2 ), LDA ) ELSE CALL DLASET( 'Full', 1, M-J-1, ZERO, ZERO, $ A( K, J+2 ), LDA) END IF END IF END IF J = J + 1 GO TO 10 20 CONTINUE * ELSE * * ..................................................... * Factorize A as L*D*L**T using the lower triangle of A * ..................................................... * 30 CONTINUE IF( J.GT.MIN( M, NB ) ) $ GO TO 40 * * K is the column to be factorized * when being called from DSYTRF_AA, * > for the first block column, J1 is 1, hence J1+J-1 is J, * > for the rest of the columns, J1 is 2, and J1+J-1 is J+1, * K = J1+J-1 IF( J.EQ.M ) THEN * * Only need to compute T(J, J) * MJ = 1 ELSE MJ = M-J+1 END IF * * H(J:M, J) := A(J:M, J) - H(J:M, 1:(J-1)) * L(J, J1:(J-1))^T, * where H(J:M, J) has been initialized to be A(J:M, J) * IF( K.GT.2 ) THEN * * K is the column to be factorized * > for the first block column, K is J, skipping the first two * columns * > for the rest of the columns, K is J+1, skipping only the * first column * CALL DGEMV( 'No transpose', MJ, J-K1, $ -ONE, H( J, K1 ), LDH, $ A( J, 1 ), LDA, $ ONE, H( J, J ), 1 ) END IF * * Copy H(J:M, J) into WORK * CALL DCOPY( MJ, H( J, J ), 1, WORK( 1 ), 1 ) * IF( J.GT.K1 ) THEN * * Compute WORK := WORK - L(J:M, J-1) * T(J-1,J), * where A(J-1, J) = T(J-1, J) and A(J, J-2) = L(J, J-1) * ALPHA = -A( J, K-1 ) CALL DAXPY( MJ, ALPHA, A( J, K-2 ), 1, WORK( 1 ), 1 ) END IF * * Set A(J, J) = T(J, J) * A( J, K ) = WORK( 1 ) * IF( J.LT.M ) THEN * * Compute WORK(2:M) = T(J, J) L((J+1):M, J) * where A(J, J) = T(J, J) and A((J+1):M, J-1) = L((J+1):M, J) * IF( K.GT.1 ) THEN ALPHA = -A( J, K ) CALL DAXPY( M-J, ALPHA, A( J+1, K-1 ), 1, $ WORK( 2 ), 1 ) ENDIF * * Find max(|WORK(2:M)|) * I2 = IDAMAX( M-J, WORK( 2 ), 1 ) + 1 PIV = WORK( I2 ) * * Apply symmetric pivot * IF( (I2.NE.2) .AND. (PIV.NE.0) ) THEN * * Swap WORK(I1) and WORK(I2) * I1 = 2 WORK( I2 ) = WORK( I1 ) WORK( I1 ) = PIV * * Swap A(I1+1:M, I1) with A(I2, I1+1:M) * I1 = I1+J-1 I2 = I2+J-1 CALL DSWAP( I2-I1-1, A( I1+1, J1+I1-1 ), 1, $ A( I2, J1+I1 ), LDA ) * * Swap A(I2+1:M, I1) with A(I2+1:M, I2) * IF( I2.LT.M ) $ CALL DSWAP( M-I2, A( I2+1, J1+I1-1 ), 1, $ A( I2+1, J1+I2-1 ), 1 ) * * Swap A(I1, I1) with A(I2, I2) * PIV = A( I1, J1+I1-1 ) A( I1, J1+I1-1 ) = A( I2, J1+I2-1 ) A( I2, J1+I2-1 ) = PIV * * Swap H(I1, I1:J1) with H(I2, I2:J1) * CALL DSWAP( I1-1, H( I1, 1 ), LDH, H( I2, 1 ), LDH ) IPIV( I1 ) = I2 * IF( I1.GT.(K1-1) ) THEN * * Swap L(1:I1-1, I1) with L(1:I1-1, I2), * skipping the first column * CALL DSWAP( I1-K1+1, A( I1, 1 ), LDA, $ A( I2, 1 ), LDA ) END IF ELSE IPIV( J+1 ) = J+1 ENDIF * * Set A(J+1, J) = T(J+1, J) * A( J+1, K ) = WORK( 2 ) * IF( J.LT.NB ) THEN * * Copy A(J+1:M, J+1) into H(J+1:M, J), * CALL DCOPY( M-J, A( J+1, K+1 ), 1, $ H( J+1, J+1 ), 1 ) END IF * * Compute L(J+2, J+1) = WORK( 3:M ) / T(J, J+1), * where A(J, J+1) = T(J, J+1) and A(J+2:M, J) = L(J+2:M, J+1) * IF( J.LT.(M-1) ) THEN IF( A( J+1, K ).NE.ZERO ) THEN ALPHA = ONE / A( J+1, K ) CALL DCOPY( M-J-1, WORK( 3 ), 1, A( J+2, K ), 1 ) CALL DSCAL( M-J-1, ALPHA, A( J+2, K ), 1 ) ELSE CALL DLASET( 'Full', M-J-1, 1, ZERO, ZERO, $ A( J+2, K ), LDA ) END IF END IF END IF J = J + 1 GO TO 30 40 CONTINUE END IF RETURN * * End of DLASYF_AA * END