root / src / lapack / double / dlasd7.f @ 2
Historique | Voir | Annoter | Télécharger (13,96 ko)
| 1 | 1 | pfleura2 | SUBROUTINE DLASD7( ICOMPQ, NL, NR, SQRE, K, D, Z, ZW, VF, VFW, VL, |
|---|---|---|---|
| 2 | 1 | pfleura2 | $ VLW, ALPHA, BETA, DSIGMA, IDX, IDXP, IDXQ, |
| 3 | 1 | pfleura2 | $ PERM, GIVPTR, GIVCOL, LDGCOL, GIVNUM, LDGNUM, |
| 4 | 1 | pfleura2 | $ C, S, INFO ) |
| 5 | 1 | pfleura2 | * |
| 6 | 1 | pfleura2 | * -- LAPACK auxiliary routine (version 3.2) -- |
| 7 | 1 | pfleura2 | * -- LAPACK is a software package provided by Univ. of Tennessee, -- |
| 8 | 1 | pfleura2 | * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- |
| 9 | 1 | pfleura2 | * November 2006 |
| 10 | 1 | pfleura2 | * |
| 11 | 1 | pfleura2 | * .. Scalar Arguments .. |
| 12 | 1 | pfleura2 | INTEGER GIVPTR, ICOMPQ, INFO, K, LDGCOL, LDGNUM, NL, |
| 13 | 1 | pfleura2 | $ NR, SQRE |
| 14 | 1 | pfleura2 | DOUBLE PRECISION ALPHA, BETA, C, S |
| 15 | 1 | pfleura2 | * .. |
| 16 | 1 | pfleura2 | * .. Array Arguments .. |
| 17 | 1 | pfleura2 | INTEGER GIVCOL( LDGCOL, * ), IDX( * ), IDXP( * ), |
| 18 | 1 | pfleura2 | $ IDXQ( * ), PERM( * ) |
| 19 | 1 | pfleura2 | DOUBLE PRECISION D( * ), DSIGMA( * ), GIVNUM( LDGNUM, * ), |
| 20 | 1 | pfleura2 | $ VF( * ), VFW( * ), VL( * ), VLW( * ), Z( * ), |
| 21 | 1 | pfleura2 | $ ZW( * ) |
| 22 | 1 | pfleura2 | * .. |
| 23 | 1 | pfleura2 | * |
| 24 | 1 | pfleura2 | * Purpose |
| 25 | 1 | pfleura2 | * ======= |
| 26 | 1 | pfleura2 | * |
| 27 | 1 | pfleura2 | * DLASD7 merges the two sets of singular values together into a single |
| 28 | 1 | pfleura2 | * sorted set. Then it tries to deflate the size of the problem. There |
| 29 | 1 | pfleura2 | * are two ways in which deflation can occur: when two or more singular |
| 30 | 1 | pfleura2 | * values are close together or if there is a tiny entry in the Z |
| 31 | 1 | pfleura2 | * vector. For each such occurrence the order of the related |
| 32 | 1 | pfleura2 | * secular equation problem is reduced by one. |
| 33 | 1 | pfleura2 | * |
| 34 | 1 | pfleura2 | * DLASD7 is called from DLASD6. |
| 35 | 1 | pfleura2 | * |
| 36 | 1 | pfleura2 | * Arguments |
| 37 | 1 | pfleura2 | * ========= |
| 38 | 1 | pfleura2 | * |
| 39 | 1 | pfleura2 | * ICOMPQ (input) INTEGER |
| 40 | 1 | pfleura2 | * Specifies whether singular vectors are to be computed |
| 41 | 1 | pfleura2 | * in compact form, as follows: |
| 42 | 1 | pfleura2 | * = 0: Compute singular values only. |
| 43 | 1 | pfleura2 | * = 1: Compute singular vectors of upper |
| 44 | 1 | pfleura2 | * bidiagonal matrix in compact form. |
| 45 | 1 | pfleura2 | * |
| 46 | 1 | pfleura2 | * NL (input) INTEGER |
| 47 | 1 | pfleura2 | * The row dimension of the upper block. NL >= 1. |
| 48 | 1 | pfleura2 | * |
| 49 | 1 | pfleura2 | * NR (input) INTEGER |
| 50 | 1 | pfleura2 | * The row dimension of the lower block. NR >= 1. |
| 51 | 1 | pfleura2 | * |
| 52 | 1 | pfleura2 | * SQRE (input) INTEGER |
| 53 | 1 | pfleura2 | * = 0: the lower block is an NR-by-NR square matrix. |
| 54 | 1 | pfleura2 | * = 1: the lower block is an NR-by-(NR+1) rectangular matrix. |
| 55 | 1 | pfleura2 | * |
| 56 | 1 | pfleura2 | * The bidiagonal matrix has |
| 57 | 1 | pfleura2 | * N = NL + NR + 1 rows and |
| 58 | 1 | pfleura2 | * M = N + SQRE >= N columns. |
| 59 | 1 | pfleura2 | * |
| 60 | 1 | pfleura2 | * K (output) INTEGER |
| 61 | 1 | pfleura2 | * Contains the dimension of the non-deflated matrix, this is |
| 62 | 1 | pfleura2 | * the order of the related secular equation. 1 <= K <=N. |
| 63 | 1 | pfleura2 | * |
| 64 | 1 | pfleura2 | * D (input/output) DOUBLE PRECISION array, dimension ( N ) |
| 65 | 1 | pfleura2 | * On entry D contains the singular values of the two submatrices |
| 66 | 1 | pfleura2 | * to be combined. On exit D contains the trailing (N-K) updated |
| 67 | 1 | pfleura2 | * singular values (those which were deflated) sorted into |
| 68 | 1 | pfleura2 | * increasing order. |
| 69 | 1 | pfleura2 | * |
| 70 | 1 | pfleura2 | * Z (output) DOUBLE PRECISION array, dimension ( M ) |
| 71 | 1 | pfleura2 | * On exit Z contains the updating row vector in the secular |
| 72 | 1 | pfleura2 | * equation. |
| 73 | 1 | pfleura2 | * |
| 74 | 1 | pfleura2 | * ZW (workspace) DOUBLE PRECISION array, dimension ( M ) |
| 75 | 1 | pfleura2 | * Workspace for Z. |
| 76 | 1 | pfleura2 | * |
| 77 | 1 | pfleura2 | * VF (input/output) DOUBLE PRECISION array, dimension ( M ) |
| 78 | 1 | pfleura2 | * On entry, VF(1:NL+1) contains the first components of all |
| 79 | 1 | pfleura2 | * right singular vectors of the upper block; and VF(NL+2:M) |
| 80 | 1 | pfleura2 | * contains the first components of all right singular vectors |
| 81 | 1 | pfleura2 | * of the lower block. On exit, VF contains the first components |
| 82 | 1 | pfleura2 | * of all right singular vectors of the bidiagonal matrix. |
| 83 | 1 | pfleura2 | * |
| 84 | 1 | pfleura2 | * VFW (workspace) DOUBLE PRECISION array, dimension ( M ) |
| 85 | 1 | pfleura2 | * Workspace for VF. |
| 86 | 1 | pfleura2 | * |
| 87 | 1 | pfleura2 | * VL (input/output) DOUBLE PRECISION array, dimension ( M ) |
| 88 | 1 | pfleura2 | * On entry, VL(1:NL+1) contains the last components of all |
| 89 | 1 | pfleura2 | * right singular vectors of the upper block; and VL(NL+2:M) |
| 90 | 1 | pfleura2 | * contains the last components of all right singular vectors |
| 91 | 1 | pfleura2 | * of the lower block. On exit, VL contains the last components |
| 92 | 1 | pfleura2 | * of all right singular vectors of the bidiagonal matrix. |
| 93 | 1 | pfleura2 | * |
| 94 | 1 | pfleura2 | * VLW (workspace) DOUBLE PRECISION array, dimension ( M ) |
| 95 | 1 | pfleura2 | * Workspace for VL. |
| 96 | 1 | pfleura2 | * |
| 97 | 1 | pfleura2 | * ALPHA (input) DOUBLE PRECISION |
| 98 | 1 | pfleura2 | * Contains the diagonal element associated with the added row. |
| 99 | 1 | pfleura2 | * |
| 100 | 1 | pfleura2 | * BETA (input) DOUBLE PRECISION |
| 101 | 1 | pfleura2 | * Contains the off-diagonal element associated with the added |
| 102 | 1 | pfleura2 | * row. |
| 103 | 1 | pfleura2 | * |
| 104 | 1 | pfleura2 | * DSIGMA (output) DOUBLE PRECISION array, dimension ( N ) |
| 105 | 1 | pfleura2 | * Contains a copy of the diagonal elements (K-1 singular values |
| 106 | 1 | pfleura2 | * and one zero) in the secular equation. |
| 107 | 1 | pfleura2 | * |
| 108 | 1 | pfleura2 | * IDX (workspace) INTEGER array, dimension ( N ) |
| 109 | 1 | pfleura2 | * This will contain the permutation used to sort the contents of |
| 110 | 1 | pfleura2 | * D into ascending order. |
| 111 | 1 | pfleura2 | * |
| 112 | 1 | pfleura2 | * IDXP (workspace) INTEGER array, dimension ( N ) |
| 113 | 1 | pfleura2 | * This will contain the permutation used to place deflated |
| 114 | 1 | pfleura2 | * values of D at the end of the array. On output IDXP(2:K) |
| 115 | 1 | pfleura2 | * points to the nondeflated D-values and IDXP(K+1:N) |
| 116 | 1 | pfleura2 | * points to the deflated singular values. |
| 117 | 1 | pfleura2 | * |
| 118 | 1 | pfleura2 | * IDXQ (input) INTEGER array, dimension ( N ) |
| 119 | 1 | pfleura2 | * This contains the permutation which separately sorts the two |
| 120 | 1 | pfleura2 | * sub-problems in D into ascending order. Note that entries in |
| 121 | 1 | pfleura2 | * the first half of this permutation must first be moved one |
| 122 | 1 | pfleura2 | * position backward; and entries in the second half |
| 123 | 1 | pfleura2 | * must first have NL+1 added to their values. |
| 124 | 1 | pfleura2 | * |
| 125 | 1 | pfleura2 | * PERM (output) INTEGER array, dimension ( N ) |
| 126 | 1 | pfleura2 | * The permutations (from deflation and sorting) to be applied |
| 127 | 1 | pfleura2 | * to each singular block. Not referenced if ICOMPQ = 0. |
| 128 | 1 | pfleura2 | * |
| 129 | 1 | pfleura2 | * GIVPTR (output) INTEGER |
| 130 | 1 | pfleura2 | * The number of Givens rotations which took place in this |
| 131 | 1 | pfleura2 | * subproblem. Not referenced if ICOMPQ = 0. |
| 132 | 1 | pfleura2 | * |
| 133 | 1 | pfleura2 | * GIVCOL (output) INTEGER array, dimension ( LDGCOL, 2 ) |
| 134 | 1 | pfleura2 | * Each pair of numbers indicates a pair of columns to take place |
| 135 | 1 | pfleura2 | * in a Givens rotation. Not referenced if ICOMPQ = 0. |
| 136 | 1 | pfleura2 | * |
| 137 | 1 | pfleura2 | * LDGCOL (input) INTEGER |
| 138 | 1 | pfleura2 | * The leading dimension of GIVCOL, must be at least N. |
| 139 | 1 | pfleura2 | * |
| 140 | 1 | pfleura2 | * GIVNUM (output) DOUBLE PRECISION array, dimension ( LDGNUM, 2 ) |
| 141 | 1 | pfleura2 | * Each number indicates the C or S value to be used in the |
| 142 | 1 | pfleura2 | * corresponding Givens rotation. Not referenced if ICOMPQ = 0. |
| 143 | 1 | pfleura2 | * |
| 144 | 1 | pfleura2 | * LDGNUM (input) INTEGER |
| 145 | 1 | pfleura2 | * The leading dimension of GIVNUM, must be at least N. |
| 146 | 1 | pfleura2 | * |
| 147 | 1 | pfleura2 | * C (output) DOUBLE PRECISION |
| 148 | 1 | pfleura2 | * C contains garbage if SQRE =0 and the C-value of a Givens |
| 149 | 1 | pfleura2 | * rotation related to the right null space if SQRE = 1. |
| 150 | 1 | pfleura2 | * |
| 151 | 1 | pfleura2 | * S (output) DOUBLE PRECISION |
| 152 | 1 | pfleura2 | * S contains garbage if SQRE =0 and the S-value of a Givens |
| 153 | 1 | pfleura2 | * rotation related to the right null space if SQRE = 1. |
| 154 | 1 | pfleura2 | * |
| 155 | 1 | pfleura2 | * INFO (output) INTEGER |
| 156 | 1 | pfleura2 | * = 0: successful exit. |
| 157 | 1 | pfleura2 | * < 0: if INFO = -i, the i-th argument had an illegal value. |
| 158 | 1 | pfleura2 | * |
| 159 | 1 | pfleura2 | * Further Details |
| 160 | 1 | pfleura2 | * =============== |
| 161 | 1 | pfleura2 | * |
| 162 | 1 | pfleura2 | * Based on contributions by |
| 163 | 1 | pfleura2 | * Ming Gu and Huan Ren, Computer Science Division, University of |
| 164 | 1 | pfleura2 | * California at Berkeley, USA |
| 165 | 1 | pfleura2 | * |
| 166 | 1 | pfleura2 | * ===================================================================== |
| 167 | 1 | pfleura2 | * |
| 168 | 1 | pfleura2 | * .. Parameters .. |
| 169 | 1 | pfleura2 | DOUBLE PRECISION ZERO, ONE, TWO, EIGHT |
| 170 | 1 | pfleura2 | PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0, TWO = 2.0D+0, |
| 171 | 1 | pfleura2 | $ EIGHT = 8.0D+0 ) |
| 172 | 1 | pfleura2 | * .. |
| 173 | 1 | pfleura2 | * .. Local Scalars .. |
| 174 | 1 | pfleura2 | * |
| 175 | 1 | pfleura2 | INTEGER I, IDXI, IDXJ, IDXJP, J, JP, JPREV, K2, M, N, |
| 176 | 1 | pfleura2 | $ NLP1, NLP2 |
| 177 | 1 | pfleura2 | DOUBLE PRECISION EPS, HLFTOL, TAU, TOL, Z1 |
| 178 | 1 | pfleura2 | * .. |
| 179 | 1 | pfleura2 | * .. External Subroutines .. |
| 180 | 1 | pfleura2 | EXTERNAL DCOPY, DLAMRG, DROT, XERBLA |
| 181 | 1 | pfleura2 | * .. |
| 182 | 1 | pfleura2 | * .. External Functions .. |
| 183 | 1 | pfleura2 | DOUBLE PRECISION DLAMCH, DLAPY2 |
| 184 | 1 | pfleura2 | EXTERNAL DLAMCH, DLAPY2 |
| 185 | 1 | pfleura2 | * .. |
| 186 | 1 | pfleura2 | * .. Intrinsic Functions .. |
| 187 | 1 | pfleura2 | INTRINSIC ABS, MAX |
| 188 | 1 | pfleura2 | * .. |
| 189 | 1 | pfleura2 | * .. Executable Statements .. |
| 190 | 1 | pfleura2 | * |
| 191 | 1 | pfleura2 | * Test the input parameters. |
| 192 | 1 | pfleura2 | * |
| 193 | 1 | pfleura2 | INFO = 0 |
| 194 | 1 | pfleura2 | N = NL + NR + 1 |
| 195 | 1 | pfleura2 | M = N + SQRE |
| 196 | 1 | pfleura2 | * |
| 197 | 1 | pfleura2 | IF( ( ICOMPQ.LT.0 ) .OR. ( ICOMPQ.GT.1 ) ) THEN |
| 198 | 1 | pfleura2 | INFO = -1 |
| 199 | 1 | pfleura2 | ELSE IF( NL.LT.1 ) THEN |
| 200 | 1 | pfleura2 | INFO = -2 |
| 201 | 1 | pfleura2 | ELSE IF( NR.LT.1 ) THEN |
| 202 | 1 | pfleura2 | INFO = -3 |
| 203 | 1 | pfleura2 | ELSE IF( ( SQRE.LT.0 ) .OR. ( SQRE.GT.1 ) ) THEN |
| 204 | 1 | pfleura2 | INFO = -4 |
| 205 | 1 | pfleura2 | ELSE IF( LDGCOL.LT.N ) THEN |
| 206 | 1 | pfleura2 | INFO = -22 |
| 207 | 1 | pfleura2 | ELSE IF( LDGNUM.LT.N ) THEN |
| 208 | 1 | pfleura2 | INFO = -24 |
| 209 | 1 | pfleura2 | END IF |
| 210 | 1 | pfleura2 | IF( INFO.NE.0 ) THEN |
| 211 | 1 | pfleura2 | CALL XERBLA( 'DLASD7', -INFO ) |
| 212 | 1 | pfleura2 | RETURN |
| 213 | 1 | pfleura2 | END IF |
| 214 | 1 | pfleura2 | * |
| 215 | 1 | pfleura2 | NLP1 = NL + 1 |
| 216 | 1 | pfleura2 | NLP2 = NL + 2 |
| 217 | 1 | pfleura2 | IF( ICOMPQ.EQ.1 ) THEN |
| 218 | 1 | pfleura2 | GIVPTR = 0 |
| 219 | 1 | pfleura2 | END IF |
| 220 | 1 | pfleura2 | * |
| 221 | 1 | pfleura2 | * Generate the first part of the vector Z and move the singular |
| 222 | 1 | pfleura2 | * values in the first part of D one position backward. |
| 223 | 1 | pfleura2 | * |
| 224 | 1 | pfleura2 | Z1 = ALPHA*VL( NLP1 ) |
| 225 | 1 | pfleura2 | VL( NLP1 ) = ZERO |
| 226 | 1 | pfleura2 | TAU = VF( NLP1 ) |
| 227 | 1 | pfleura2 | DO 10 I = NL, 1, -1 |
| 228 | 1 | pfleura2 | Z( I+1 ) = ALPHA*VL( I ) |
| 229 | 1 | pfleura2 | VL( I ) = ZERO |
| 230 | 1 | pfleura2 | VF( I+1 ) = VF( I ) |
| 231 | 1 | pfleura2 | D( I+1 ) = D( I ) |
| 232 | 1 | pfleura2 | IDXQ( I+1 ) = IDXQ( I ) + 1 |
| 233 | 1 | pfleura2 | 10 CONTINUE |
| 234 | 1 | pfleura2 | VF( 1 ) = TAU |
| 235 | 1 | pfleura2 | * |
| 236 | 1 | pfleura2 | * Generate the second part of the vector Z. |
| 237 | 1 | pfleura2 | * |
| 238 | 1 | pfleura2 | DO 20 I = NLP2, M |
| 239 | 1 | pfleura2 | Z( I ) = BETA*VF( I ) |
| 240 | 1 | pfleura2 | VF( I ) = ZERO |
| 241 | 1 | pfleura2 | 20 CONTINUE |
| 242 | 1 | pfleura2 | * |
| 243 | 1 | pfleura2 | * Sort the singular values into increasing order |
| 244 | 1 | pfleura2 | * |
| 245 | 1 | pfleura2 | DO 30 I = NLP2, N |
| 246 | 1 | pfleura2 | IDXQ( I ) = IDXQ( I ) + NLP1 |
| 247 | 1 | pfleura2 | 30 CONTINUE |
| 248 | 1 | pfleura2 | * |
| 249 | 1 | pfleura2 | * DSIGMA, IDXC, IDXC, and ZW are used as storage space. |
| 250 | 1 | pfleura2 | * |
| 251 | 1 | pfleura2 | DO 40 I = 2, N |
| 252 | 1 | pfleura2 | DSIGMA( I ) = D( IDXQ( I ) ) |
| 253 | 1 | pfleura2 | ZW( I ) = Z( IDXQ( I ) ) |
| 254 | 1 | pfleura2 | VFW( I ) = VF( IDXQ( I ) ) |
| 255 | 1 | pfleura2 | VLW( I ) = VL( IDXQ( I ) ) |
| 256 | 1 | pfleura2 | 40 CONTINUE |
| 257 | 1 | pfleura2 | * |
| 258 | 1 | pfleura2 | CALL DLAMRG( NL, NR, DSIGMA( 2 ), 1, 1, IDX( 2 ) ) |
| 259 | 1 | pfleura2 | * |
| 260 | 1 | pfleura2 | DO 50 I = 2, N |
| 261 | 1 | pfleura2 | IDXI = 1 + IDX( I ) |
| 262 | 1 | pfleura2 | D( I ) = DSIGMA( IDXI ) |
| 263 | 1 | pfleura2 | Z( I ) = ZW( IDXI ) |
| 264 | 1 | pfleura2 | VF( I ) = VFW( IDXI ) |
| 265 | 1 | pfleura2 | VL( I ) = VLW( IDXI ) |
| 266 | 1 | pfleura2 | 50 CONTINUE |
| 267 | 1 | pfleura2 | * |
| 268 | 1 | pfleura2 | * Calculate the allowable deflation tolerence |
| 269 | 1 | pfleura2 | * |
| 270 | 1 | pfleura2 | EPS = DLAMCH( 'Epsilon' ) |
| 271 | 1 | pfleura2 | TOL = MAX( ABS( ALPHA ), ABS( BETA ) ) |
| 272 | 1 | pfleura2 | TOL = EIGHT*EIGHT*EPS*MAX( ABS( D( N ) ), TOL ) |
| 273 | 1 | pfleura2 | * |
| 274 | 1 | pfleura2 | * There are 2 kinds of deflation -- first a value in the z-vector |
| 275 | 1 | pfleura2 | * is small, second two (or more) singular values are very close |
| 276 | 1 | pfleura2 | * together (their difference is small). |
| 277 | 1 | pfleura2 | * |
| 278 | 1 | pfleura2 | * If the value in the z-vector is small, we simply permute the |
| 279 | 1 | pfleura2 | * array so that the corresponding singular value is moved to the |
| 280 | 1 | pfleura2 | * end. |
| 281 | 1 | pfleura2 | * |
| 282 | 1 | pfleura2 | * If two values in the D-vector are close, we perform a two-sided |
| 283 | 1 | pfleura2 | * rotation designed to make one of the corresponding z-vector |
| 284 | 1 | pfleura2 | * entries zero, and then permute the array so that the deflated |
| 285 | 1 | pfleura2 | * singular value is moved to the end. |
| 286 | 1 | pfleura2 | * |
| 287 | 1 | pfleura2 | * If there are multiple singular values then the problem deflates. |
| 288 | 1 | pfleura2 | * Here the number of equal singular values are found. As each equal |
| 289 | 1 | pfleura2 | * singular value is found, an elementary reflector is computed to |
| 290 | 1 | pfleura2 | * rotate the corresponding singular subspace so that the |
| 291 | 1 | pfleura2 | * corresponding components of Z are zero in this new basis. |
| 292 | 1 | pfleura2 | * |
| 293 | 1 | pfleura2 | K = 1 |
| 294 | 1 | pfleura2 | K2 = N + 1 |
| 295 | 1 | pfleura2 | DO 60 J = 2, N |
| 296 | 1 | pfleura2 | IF( ABS( Z( J ) ).LE.TOL ) THEN |
| 297 | 1 | pfleura2 | * |
| 298 | 1 | pfleura2 | * Deflate due to small z component. |
| 299 | 1 | pfleura2 | * |
| 300 | 1 | pfleura2 | K2 = K2 - 1 |
| 301 | 1 | pfleura2 | IDXP( K2 ) = J |
| 302 | 1 | pfleura2 | IF( J.EQ.N ) |
| 303 | 1 | pfleura2 | $ GO TO 100 |
| 304 | 1 | pfleura2 | ELSE |
| 305 | 1 | pfleura2 | JPREV = J |
| 306 | 1 | pfleura2 | GO TO 70 |
| 307 | 1 | pfleura2 | END IF |
| 308 | 1 | pfleura2 | 60 CONTINUE |
| 309 | 1 | pfleura2 | 70 CONTINUE |
| 310 | 1 | pfleura2 | J = JPREV |
| 311 | 1 | pfleura2 | 80 CONTINUE |
| 312 | 1 | pfleura2 | J = J + 1 |
| 313 | 1 | pfleura2 | IF( J.GT.N ) |
| 314 | 1 | pfleura2 | $ GO TO 90 |
| 315 | 1 | pfleura2 | IF( ABS( Z( J ) ).LE.TOL ) THEN |
| 316 | 1 | pfleura2 | * |
| 317 | 1 | pfleura2 | * Deflate due to small z component. |
| 318 | 1 | pfleura2 | * |
| 319 | 1 | pfleura2 | K2 = K2 - 1 |
| 320 | 1 | pfleura2 | IDXP( K2 ) = J |
| 321 | 1 | pfleura2 | ELSE |
| 322 | 1 | pfleura2 | * |
| 323 | 1 | pfleura2 | * Check if singular values are close enough to allow deflation. |
| 324 | 1 | pfleura2 | * |
| 325 | 1 | pfleura2 | IF( ABS( D( J )-D( JPREV ) ).LE.TOL ) THEN |
| 326 | 1 | pfleura2 | * |
| 327 | 1 | pfleura2 | * Deflation is possible. |
| 328 | 1 | pfleura2 | * |
| 329 | 1 | pfleura2 | S = Z( JPREV ) |
| 330 | 1 | pfleura2 | C = Z( J ) |
| 331 | 1 | pfleura2 | * |
| 332 | 1 | pfleura2 | * Find sqrt(a**2+b**2) without overflow or |
| 333 | 1 | pfleura2 | * destructive underflow. |
| 334 | 1 | pfleura2 | * |
| 335 | 1 | pfleura2 | TAU = DLAPY2( C, S ) |
| 336 | 1 | pfleura2 | Z( J ) = TAU |
| 337 | 1 | pfleura2 | Z( JPREV ) = ZERO |
| 338 | 1 | pfleura2 | C = C / TAU |
| 339 | 1 | pfleura2 | S = -S / TAU |
| 340 | 1 | pfleura2 | * |
| 341 | 1 | pfleura2 | * Record the appropriate Givens rotation |
| 342 | 1 | pfleura2 | * |
| 343 | 1 | pfleura2 | IF( ICOMPQ.EQ.1 ) THEN |
| 344 | 1 | pfleura2 | GIVPTR = GIVPTR + 1 |
| 345 | 1 | pfleura2 | IDXJP = IDXQ( IDX( JPREV )+1 ) |
| 346 | 1 | pfleura2 | IDXJ = IDXQ( IDX( J )+1 ) |
| 347 | 1 | pfleura2 | IF( IDXJP.LE.NLP1 ) THEN |
| 348 | 1 | pfleura2 | IDXJP = IDXJP - 1 |
| 349 | 1 | pfleura2 | END IF |
| 350 | 1 | pfleura2 | IF( IDXJ.LE.NLP1 ) THEN |
| 351 | 1 | pfleura2 | IDXJ = IDXJ - 1 |
| 352 | 1 | pfleura2 | END IF |
| 353 | 1 | pfleura2 | GIVCOL( GIVPTR, 2 ) = IDXJP |
| 354 | 1 | pfleura2 | GIVCOL( GIVPTR, 1 ) = IDXJ |
| 355 | 1 | pfleura2 | GIVNUM( GIVPTR, 2 ) = C |
| 356 | 1 | pfleura2 | GIVNUM( GIVPTR, 1 ) = S |
| 357 | 1 | pfleura2 | END IF |
| 358 | 1 | pfleura2 | CALL DROT( 1, VF( JPREV ), 1, VF( J ), 1, C, S ) |
| 359 | 1 | pfleura2 | CALL DROT( 1, VL( JPREV ), 1, VL( J ), 1, C, S ) |
| 360 | 1 | pfleura2 | K2 = K2 - 1 |
| 361 | 1 | pfleura2 | IDXP( K2 ) = JPREV |
| 362 | 1 | pfleura2 | JPREV = J |
| 363 | 1 | pfleura2 | ELSE |
| 364 | 1 | pfleura2 | K = K + 1 |
| 365 | 1 | pfleura2 | ZW( K ) = Z( JPREV ) |
| 366 | 1 | pfleura2 | DSIGMA( K ) = D( JPREV ) |
| 367 | 1 | pfleura2 | IDXP( K ) = JPREV |
| 368 | 1 | pfleura2 | JPREV = J |
| 369 | 1 | pfleura2 | END IF |
| 370 | 1 | pfleura2 | END IF |
| 371 | 1 | pfleura2 | GO TO 80 |
| 372 | 1 | pfleura2 | 90 CONTINUE |
| 373 | 1 | pfleura2 | * |
| 374 | 1 | pfleura2 | * Record the last singular value. |
| 375 | 1 | pfleura2 | * |
| 376 | 1 | pfleura2 | K = K + 1 |
| 377 | 1 | pfleura2 | ZW( K ) = Z( JPREV ) |
| 378 | 1 | pfleura2 | DSIGMA( K ) = D( JPREV ) |
| 379 | 1 | pfleura2 | IDXP( K ) = JPREV |
| 380 | 1 | pfleura2 | * |
| 381 | 1 | pfleura2 | 100 CONTINUE |
| 382 | 1 | pfleura2 | * |
| 383 | 1 | pfleura2 | * Sort the singular values into DSIGMA. The singular values which |
| 384 | 1 | pfleura2 | * were not deflated go into the first K slots of DSIGMA, except |
| 385 | 1 | pfleura2 | * that DSIGMA(1) is treated separately. |
| 386 | 1 | pfleura2 | * |
| 387 | 1 | pfleura2 | DO 110 J = 2, N |
| 388 | 1 | pfleura2 | JP = IDXP( J ) |
| 389 | 1 | pfleura2 | DSIGMA( J ) = D( JP ) |
| 390 | 1 | pfleura2 | VFW( J ) = VF( JP ) |
| 391 | 1 | pfleura2 | VLW( J ) = VL( JP ) |
| 392 | 1 | pfleura2 | 110 CONTINUE |
| 393 | 1 | pfleura2 | IF( ICOMPQ.EQ.1 ) THEN |
| 394 | 1 | pfleura2 | DO 120 J = 2, N |
| 395 | 1 | pfleura2 | JP = IDXP( J ) |
| 396 | 1 | pfleura2 | PERM( J ) = IDXQ( IDX( JP )+1 ) |
| 397 | 1 | pfleura2 | IF( PERM( J ).LE.NLP1 ) THEN |
| 398 | 1 | pfleura2 | PERM( J ) = PERM( J ) - 1 |
| 399 | 1 | pfleura2 | END IF |
| 400 | 1 | pfleura2 | 120 CONTINUE |
| 401 | 1 | pfleura2 | END IF |
| 402 | 1 | pfleura2 | * |
| 403 | 1 | pfleura2 | * The deflated singular values go back into the last N - K slots of |
| 404 | 1 | pfleura2 | * D. |
| 405 | 1 | pfleura2 | * |
| 406 | 1 | pfleura2 | CALL DCOPY( N-K, DSIGMA( K+1 ), 1, D( K+1 ), 1 ) |
| 407 | 1 | pfleura2 | * |
| 408 | 1 | pfleura2 | * Determine DSIGMA(1), DSIGMA(2), Z(1), VF(1), VL(1), VF(M), and |
| 409 | 1 | pfleura2 | * VL(M). |
| 410 | 1 | pfleura2 | * |
| 411 | 1 | pfleura2 | DSIGMA( 1 ) = ZERO |
| 412 | 1 | pfleura2 | HLFTOL = TOL / TWO |
| 413 | 1 | pfleura2 | IF( ABS( DSIGMA( 2 ) ).LE.HLFTOL ) |
| 414 | 1 | pfleura2 | $ DSIGMA( 2 ) = HLFTOL |
| 415 | 1 | pfleura2 | IF( M.GT.N ) THEN |
| 416 | 1 | pfleura2 | Z( 1 ) = DLAPY2( Z1, Z( M ) ) |
| 417 | 1 | pfleura2 | IF( Z( 1 ).LE.TOL ) THEN |
| 418 | 1 | pfleura2 | C = ONE |
| 419 | 1 | pfleura2 | S = ZERO |
| 420 | 1 | pfleura2 | Z( 1 ) = TOL |
| 421 | 1 | pfleura2 | ELSE |
| 422 | 1 | pfleura2 | C = Z1 / Z( 1 ) |
| 423 | 1 | pfleura2 | S = -Z( M ) / Z( 1 ) |
| 424 | 1 | pfleura2 | END IF |
| 425 | 1 | pfleura2 | CALL DROT( 1, VF( M ), 1, VF( 1 ), 1, C, S ) |
| 426 | 1 | pfleura2 | CALL DROT( 1, VL( M ), 1, VL( 1 ), 1, C, S ) |
| 427 | 1 | pfleura2 | ELSE |
| 428 | 1 | pfleura2 | IF( ABS( Z1 ).LE.TOL ) THEN |
| 429 | 1 | pfleura2 | Z( 1 ) = TOL |
| 430 | 1 | pfleura2 | ELSE |
| 431 | 1 | pfleura2 | Z( 1 ) = Z1 |
| 432 | 1 | pfleura2 | END IF |
| 433 | 1 | pfleura2 | END IF |
| 434 | 1 | pfleura2 | * |
| 435 | 1 | pfleura2 | * Restore Z, VF, and VL. |
| 436 | 1 | pfleura2 | * |
| 437 | 1 | pfleura2 | CALL DCOPY( K-1, ZW( 2 ), 1, Z( 2 ), 1 ) |
| 438 | 1 | pfleura2 | CALL DCOPY( N-1, VFW( 2 ), 1, VF( 2 ), 1 ) |
| 439 | 1 | pfleura2 | CALL DCOPY( N-1, VLW( 2 ), 1, VL( 2 ), 1 ) |
| 440 | 1 | pfleura2 | * |
| 441 | 1 | pfleura2 | RETURN |
| 442 | 1 | pfleura2 | * |
| 443 | 1 | pfleura2 | * End of DLASD7 |
| 444 | 1 | pfleura2 | * |
| 445 | 1 | pfleura2 | END |