root / src / lapack / double / dlaic1.f @ 2
Historique | Voir | Annoter | Télécharger (8,17 ko)
| 1 | 1 | pfleura2 | SUBROUTINE DLAIC1( JOB, J, X, SEST, W, GAMMA, SESTPR, S, C ) |
|---|---|---|---|
| 2 | 1 | pfleura2 | * |
| 3 | 1 | pfleura2 | * -- LAPACK auxiliary routine (version 3.2) -- |
| 4 | 1 | pfleura2 | * -- LAPACK is a software package provided by Univ. of Tennessee, -- |
| 5 | 1 | pfleura2 | * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- |
| 6 | 1 | pfleura2 | * November 2006 |
| 7 | 1 | pfleura2 | * |
| 8 | 1 | pfleura2 | * .. Scalar Arguments .. |
| 9 | 1 | pfleura2 | INTEGER J, JOB |
| 10 | 1 | pfleura2 | DOUBLE PRECISION C, GAMMA, S, SEST, SESTPR |
| 11 | 1 | pfleura2 | * .. |
| 12 | 1 | pfleura2 | * .. Array Arguments .. |
| 13 | 1 | pfleura2 | DOUBLE PRECISION W( J ), X( J ) |
| 14 | 1 | pfleura2 | * .. |
| 15 | 1 | pfleura2 | * |
| 16 | 1 | pfleura2 | * Purpose |
| 17 | 1 | pfleura2 | * ======= |
| 18 | 1 | pfleura2 | * |
| 19 | 1 | pfleura2 | * DLAIC1 applies one step of incremental condition estimation in |
| 20 | 1 | pfleura2 | * its simplest version: |
| 21 | 1 | pfleura2 | * |
| 22 | 1 | pfleura2 | * Let x, twonorm(x) = 1, be an approximate singular vector of an j-by-j |
| 23 | 1 | pfleura2 | * lower triangular matrix L, such that |
| 24 | 1 | pfleura2 | * twonorm(L*x) = sest |
| 25 | 1 | pfleura2 | * Then DLAIC1 computes sestpr, s, c such that |
| 26 | 1 | pfleura2 | * the vector |
| 27 | 1 | pfleura2 | * [ s*x ] |
| 28 | 1 | pfleura2 | * xhat = [ c ] |
| 29 | 1 | pfleura2 | * is an approximate singular vector of |
| 30 | 1 | pfleura2 | * [ L 0 ] |
| 31 | 1 | pfleura2 | * Lhat = [ w' gamma ] |
| 32 | 1 | pfleura2 | * in the sense that |
| 33 | 1 | pfleura2 | * twonorm(Lhat*xhat) = sestpr. |
| 34 | 1 | pfleura2 | * |
| 35 | 1 | pfleura2 | * Depending on JOB, an estimate for the largest or smallest singular |
| 36 | 1 | pfleura2 | * value is computed. |
| 37 | 1 | pfleura2 | * |
| 38 | 1 | pfleura2 | * Note that [s c]' and sestpr**2 is an eigenpair of the system |
| 39 | 1 | pfleura2 | * |
| 40 | 1 | pfleura2 | * diag(sest*sest, 0) + [alpha gamma] * [ alpha ] |
| 41 | 1 | pfleura2 | * [ gamma ] |
| 42 | 1 | pfleura2 | * |
| 43 | 1 | pfleura2 | * where alpha = x'*w. |
| 44 | 1 | pfleura2 | * |
| 45 | 1 | pfleura2 | * Arguments |
| 46 | 1 | pfleura2 | * ========= |
| 47 | 1 | pfleura2 | * |
| 48 | 1 | pfleura2 | * JOB (input) INTEGER |
| 49 | 1 | pfleura2 | * = 1: an estimate for the largest singular value is computed. |
| 50 | 1 | pfleura2 | * = 2: an estimate for the smallest singular value is computed. |
| 51 | 1 | pfleura2 | * |
| 52 | 1 | pfleura2 | * J (input) INTEGER |
| 53 | 1 | pfleura2 | * Length of X and W |
| 54 | 1 | pfleura2 | * |
| 55 | 1 | pfleura2 | * X (input) DOUBLE PRECISION array, dimension (J) |
| 56 | 1 | pfleura2 | * The j-vector x. |
| 57 | 1 | pfleura2 | * |
| 58 | 1 | pfleura2 | * SEST (input) DOUBLE PRECISION |
| 59 | 1 | pfleura2 | * Estimated singular value of j by j matrix L |
| 60 | 1 | pfleura2 | * |
| 61 | 1 | pfleura2 | * W (input) DOUBLE PRECISION array, dimension (J) |
| 62 | 1 | pfleura2 | * The j-vector w. |
| 63 | 1 | pfleura2 | * |
| 64 | 1 | pfleura2 | * GAMMA (input) DOUBLE PRECISION |
| 65 | 1 | pfleura2 | * The diagonal element gamma. |
| 66 | 1 | pfleura2 | * |
| 67 | 1 | pfleura2 | * SESTPR (output) DOUBLE PRECISION |
| 68 | 1 | pfleura2 | * Estimated singular value of (j+1) by (j+1) matrix Lhat. |
| 69 | 1 | pfleura2 | * |
| 70 | 1 | pfleura2 | * S (output) DOUBLE PRECISION |
| 71 | 1 | pfleura2 | * Sine needed in forming xhat. |
| 72 | 1 | pfleura2 | * |
| 73 | 1 | pfleura2 | * C (output) DOUBLE PRECISION |
| 74 | 1 | pfleura2 | * Cosine needed in forming xhat. |
| 75 | 1 | pfleura2 | * |
| 76 | 1 | pfleura2 | * ===================================================================== |
| 77 | 1 | pfleura2 | * |
| 78 | 1 | pfleura2 | * .. Parameters .. |
| 79 | 1 | pfleura2 | DOUBLE PRECISION ZERO, ONE, TWO |
| 80 | 1 | pfleura2 | PARAMETER ( ZERO = 0.0D0, ONE = 1.0D0, TWO = 2.0D0 ) |
| 81 | 1 | pfleura2 | DOUBLE PRECISION HALF, FOUR |
| 82 | 1 | pfleura2 | PARAMETER ( HALF = 0.5D0, FOUR = 4.0D0 ) |
| 83 | 1 | pfleura2 | * .. |
| 84 | 1 | pfleura2 | * .. Local Scalars .. |
| 85 | 1 | pfleura2 | DOUBLE PRECISION ABSALP, ABSEST, ABSGAM, ALPHA, B, COSINE, EPS, |
| 86 | 1 | pfleura2 | $ NORMA, S1, S2, SINE, T, TEST, TMP, ZETA1, ZETA2 |
| 87 | 1 | pfleura2 | * .. |
| 88 | 1 | pfleura2 | * .. Intrinsic Functions .. |
| 89 | 1 | pfleura2 | INTRINSIC ABS, MAX, SIGN, SQRT |
| 90 | 1 | pfleura2 | * .. |
| 91 | 1 | pfleura2 | * .. External Functions .. |
| 92 | 1 | pfleura2 | DOUBLE PRECISION DDOT, DLAMCH |
| 93 | 1 | pfleura2 | EXTERNAL DDOT, DLAMCH |
| 94 | 1 | pfleura2 | * .. |
| 95 | 1 | pfleura2 | * .. Executable Statements .. |
| 96 | 1 | pfleura2 | * |
| 97 | 1 | pfleura2 | EPS = DLAMCH( 'Epsilon' ) |
| 98 | 1 | pfleura2 | ALPHA = DDOT( J, X, 1, W, 1 ) |
| 99 | 1 | pfleura2 | * |
| 100 | 1 | pfleura2 | ABSALP = ABS( ALPHA ) |
| 101 | 1 | pfleura2 | ABSGAM = ABS( GAMMA ) |
| 102 | 1 | pfleura2 | ABSEST = ABS( SEST ) |
| 103 | 1 | pfleura2 | * |
| 104 | 1 | pfleura2 | IF( JOB.EQ.1 ) THEN |
| 105 | 1 | pfleura2 | * |
| 106 | 1 | pfleura2 | * Estimating largest singular value |
| 107 | 1 | pfleura2 | * |
| 108 | 1 | pfleura2 | * special cases |
| 109 | 1 | pfleura2 | * |
| 110 | 1 | pfleura2 | IF( SEST.EQ.ZERO ) THEN |
| 111 | 1 | pfleura2 | S1 = MAX( ABSGAM, ABSALP ) |
| 112 | 1 | pfleura2 | IF( S1.EQ.ZERO ) THEN |
| 113 | 1 | pfleura2 | S = ZERO |
| 114 | 1 | pfleura2 | C = ONE |
| 115 | 1 | pfleura2 | SESTPR = ZERO |
| 116 | 1 | pfleura2 | ELSE |
| 117 | 1 | pfleura2 | S = ALPHA / S1 |
| 118 | 1 | pfleura2 | C = GAMMA / S1 |
| 119 | 1 | pfleura2 | TMP = SQRT( S*S+C*C ) |
| 120 | 1 | pfleura2 | S = S / TMP |
| 121 | 1 | pfleura2 | C = C / TMP |
| 122 | 1 | pfleura2 | SESTPR = S1*TMP |
| 123 | 1 | pfleura2 | END IF |
| 124 | 1 | pfleura2 | RETURN |
| 125 | 1 | pfleura2 | ELSE IF( ABSGAM.LE.EPS*ABSEST ) THEN |
| 126 | 1 | pfleura2 | S = ONE |
| 127 | 1 | pfleura2 | C = ZERO |
| 128 | 1 | pfleura2 | TMP = MAX( ABSEST, ABSALP ) |
| 129 | 1 | pfleura2 | S1 = ABSEST / TMP |
| 130 | 1 | pfleura2 | S2 = ABSALP / TMP |
| 131 | 1 | pfleura2 | SESTPR = TMP*SQRT( S1*S1+S2*S2 ) |
| 132 | 1 | pfleura2 | RETURN |
| 133 | 1 | pfleura2 | ELSE IF( ABSALP.LE.EPS*ABSEST ) THEN |
| 134 | 1 | pfleura2 | S1 = ABSGAM |
| 135 | 1 | pfleura2 | S2 = ABSEST |
| 136 | 1 | pfleura2 | IF( S1.LE.S2 ) THEN |
| 137 | 1 | pfleura2 | S = ONE |
| 138 | 1 | pfleura2 | C = ZERO |
| 139 | 1 | pfleura2 | SESTPR = S2 |
| 140 | 1 | pfleura2 | ELSE |
| 141 | 1 | pfleura2 | S = ZERO |
| 142 | 1 | pfleura2 | C = ONE |
| 143 | 1 | pfleura2 | SESTPR = S1 |
| 144 | 1 | pfleura2 | END IF |
| 145 | 1 | pfleura2 | RETURN |
| 146 | 1 | pfleura2 | ELSE IF( ABSEST.LE.EPS*ABSALP .OR. ABSEST.LE.EPS*ABSGAM ) THEN |
| 147 | 1 | pfleura2 | S1 = ABSGAM |
| 148 | 1 | pfleura2 | S2 = ABSALP |
| 149 | 1 | pfleura2 | IF( S1.LE.S2 ) THEN |
| 150 | 1 | pfleura2 | TMP = S1 / S2 |
| 151 | 1 | pfleura2 | S = SQRT( ONE+TMP*TMP ) |
| 152 | 1 | pfleura2 | SESTPR = S2*S |
| 153 | 1 | pfleura2 | C = ( GAMMA / S2 ) / S |
| 154 | 1 | pfleura2 | S = SIGN( ONE, ALPHA ) / S |
| 155 | 1 | pfleura2 | ELSE |
| 156 | 1 | pfleura2 | TMP = S2 / S1 |
| 157 | 1 | pfleura2 | C = SQRT( ONE+TMP*TMP ) |
| 158 | 1 | pfleura2 | SESTPR = S1*C |
| 159 | 1 | pfleura2 | S = ( ALPHA / S1 ) / C |
| 160 | 1 | pfleura2 | C = SIGN( ONE, GAMMA ) / C |
| 161 | 1 | pfleura2 | END IF |
| 162 | 1 | pfleura2 | RETURN |
| 163 | 1 | pfleura2 | ELSE |
| 164 | 1 | pfleura2 | * |
| 165 | 1 | pfleura2 | * normal case |
| 166 | 1 | pfleura2 | * |
| 167 | 1 | pfleura2 | ZETA1 = ALPHA / ABSEST |
| 168 | 1 | pfleura2 | ZETA2 = GAMMA / ABSEST |
| 169 | 1 | pfleura2 | * |
| 170 | 1 | pfleura2 | B = ( ONE-ZETA1*ZETA1-ZETA2*ZETA2 )*HALF |
| 171 | 1 | pfleura2 | C = ZETA1*ZETA1 |
| 172 | 1 | pfleura2 | IF( B.GT.ZERO ) THEN |
| 173 | 1 | pfleura2 | T = C / ( B+SQRT( B*B+C ) ) |
| 174 | 1 | pfleura2 | ELSE |
| 175 | 1 | pfleura2 | T = SQRT( B*B+C ) - B |
| 176 | 1 | pfleura2 | END IF |
| 177 | 1 | pfleura2 | * |
| 178 | 1 | pfleura2 | SINE = -ZETA1 / T |
| 179 | 1 | pfleura2 | COSINE = -ZETA2 / ( ONE+T ) |
| 180 | 1 | pfleura2 | TMP = SQRT( SINE*SINE+COSINE*COSINE ) |
| 181 | 1 | pfleura2 | S = SINE / TMP |
| 182 | 1 | pfleura2 | C = COSINE / TMP |
| 183 | 1 | pfleura2 | SESTPR = SQRT( T+ONE )*ABSEST |
| 184 | 1 | pfleura2 | RETURN |
| 185 | 1 | pfleura2 | END IF |
| 186 | 1 | pfleura2 | * |
| 187 | 1 | pfleura2 | ELSE IF( JOB.EQ.2 ) THEN |
| 188 | 1 | pfleura2 | * |
| 189 | 1 | pfleura2 | * Estimating smallest singular value |
| 190 | 1 | pfleura2 | * |
| 191 | 1 | pfleura2 | * special cases |
| 192 | 1 | pfleura2 | * |
| 193 | 1 | pfleura2 | IF( SEST.EQ.ZERO ) THEN |
| 194 | 1 | pfleura2 | SESTPR = ZERO |
| 195 | 1 | pfleura2 | IF( MAX( ABSGAM, ABSALP ).EQ.ZERO ) THEN |
| 196 | 1 | pfleura2 | SINE = ONE |
| 197 | 1 | pfleura2 | COSINE = ZERO |
| 198 | 1 | pfleura2 | ELSE |
| 199 | 1 | pfleura2 | SINE = -GAMMA |
| 200 | 1 | pfleura2 | COSINE = ALPHA |
| 201 | 1 | pfleura2 | END IF |
| 202 | 1 | pfleura2 | S1 = MAX( ABS( SINE ), ABS( COSINE ) ) |
| 203 | 1 | pfleura2 | S = SINE / S1 |
| 204 | 1 | pfleura2 | C = COSINE / S1 |
| 205 | 1 | pfleura2 | TMP = SQRT( S*S+C*C ) |
| 206 | 1 | pfleura2 | S = S / TMP |
| 207 | 1 | pfleura2 | C = C / TMP |
| 208 | 1 | pfleura2 | RETURN |
| 209 | 1 | pfleura2 | ELSE IF( ABSGAM.LE.EPS*ABSEST ) THEN |
| 210 | 1 | pfleura2 | S = ZERO |
| 211 | 1 | pfleura2 | C = ONE |
| 212 | 1 | pfleura2 | SESTPR = ABSGAM |
| 213 | 1 | pfleura2 | RETURN |
| 214 | 1 | pfleura2 | ELSE IF( ABSALP.LE.EPS*ABSEST ) THEN |
| 215 | 1 | pfleura2 | S1 = ABSGAM |
| 216 | 1 | pfleura2 | S2 = ABSEST |
| 217 | 1 | pfleura2 | IF( S1.LE.S2 ) THEN |
| 218 | 1 | pfleura2 | S = ZERO |
| 219 | 1 | pfleura2 | C = ONE |
| 220 | 1 | pfleura2 | SESTPR = S1 |
| 221 | 1 | pfleura2 | ELSE |
| 222 | 1 | pfleura2 | S = ONE |
| 223 | 1 | pfleura2 | C = ZERO |
| 224 | 1 | pfleura2 | SESTPR = S2 |
| 225 | 1 | pfleura2 | END IF |
| 226 | 1 | pfleura2 | RETURN |
| 227 | 1 | pfleura2 | ELSE IF( ABSEST.LE.EPS*ABSALP .OR. ABSEST.LE.EPS*ABSGAM ) THEN |
| 228 | 1 | pfleura2 | S1 = ABSGAM |
| 229 | 1 | pfleura2 | S2 = ABSALP |
| 230 | 1 | pfleura2 | IF( S1.LE.S2 ) THEN |
| 231 | 1 | pfleura2 | TMP = S1 / S2 |
| 232 | 1 | pfleura2 | C = SQRT( ONE+TMP*TMP ) |
| 233 | 1 | pfleura2 | SESTPR = ABSEST*( TMP / C ) |
| 234 | 1 | pfleura2 | S = -( GAMMA / S2 ) / C |
| 235 | 1 | pfleura2 | C = SIGN( ONE, ALPHA ) / C |
| 236 | 1 | pfleura2 | ELSE |
| 237 | 1 | pfleura2 | TMP = S2 / S1 |
| 238 | 1 | pfleura2 | S = SQRT( ONE+TMP*TMP ) |
| 239 | 1 | pfleura2 | SESTPR = ABSEST / S |
| 240 | 1 | pfleura2 | C = ( ALPHA / S1 ) / S |
| 241 | 1 | pfleura2 | S = -SIGN( ONE, GAMMA ) / S |
| 242 | 1 | pfleura2 | END IF |
| 243 | 1 | pfleura2 | RETURN |
| 244 | 1 | pfleura2 | ELSE |
| 245 | 1 | pfleura2 | * |
| 246 | 1 | pfleura2 | * normal case |
| 247 | 1 | pfleura2 | * |
| 248 | 1 | pfleura2 | ZETA1 = ALPHA / ABSEST |
| 249 | 1 | pfleura2 | ZETA2 = GAMMA / ABSEST |
| 250 | 1 | pfleura2 | * |
| 251 | 1 | pfleura2 | NORMA = MAX( ONE+ZETA1*ZETA1+ABS( ZETA1*ZETA2 ), |
| 252 | 1 | pfleura2 | $ ABS( ZETA1*ZETA2 )+ZETA2*ZETA2 ) |
| 253 | 1 | pfleura2 | * |
| 254 | 1 | pfleura2 | * See if root is closer to zero or to ONE |
| 255 | 1 | pfleura2 | * |
| 256 | 1 | pfleura2 | TEST = ONE + TWO*( ZETA1-ZETA2 )*( ZETA1+ZETA2 ) |
| 257 | 1 | pfleura2 | IF( TEST.GE.ZERO ) THEN |
| 258 | 1 | pfleura2 | * |
| 259 | 1 | pfleura2 | * root is close to zero, compute directly |
| 260 | 1 | pfleura2 | * |
| 261 | 1 | pfleura2 | B = ( ZETA1*ZETA1+ZETA2*ZETA2+ONE )*HALF |
| 262 | 1 | pfleura2 | C = ZETA2*ZETA2 |
| 263 | 1 | pfleura2 | T = C / ( B+SQRT( ABS( B*B-C ) ) ) |
| 264 | 1 | pfleura2 | SINE = ZETA1 / ( ONE-T ) |
| 265 | 1 | pfleura2 | COSINE = -ZETA2 / T |
| 266 | 1 | pfleura2 | SESTPR = SQRT( T+FOUR*EPS*EPS*NORMA )*ABSEST |
| 267 | 1 | pfleura2 | ELSE |
| 268 | 1 | pfleura2 | * |
| 269 | 1 | pfleura2 | * root is closer to ONE, shift by that amount |
| 270 | 1 | pfleura2 | * |
| 271 | 1 | pfleura2 | B = ( ZETA2*ZETA2+ZETA1*ZETA1-ONE )*HALF |
| 272 | 1 | pfleura2 | C = ZETA1*ZETA1 |
| 273 | 1 | pfleura2 | IF( B.GE.ZERO ) THEN |
| 274 | 1 | pfleura2 | T = -C / ( B+SQRT( B*B+C ) ) |
| 275 | 1 | pfleura2 | ELSE |
| 276 | 1 | pfleura2 | T = B - SQRT( B*B+C ) |
| 277 | 1 | pfleura2 | END IF |
| 278 | 1 | pfleura2 | SINE = -ZETA1 / T |
| 279 | 1 | pfleura2 | COSINE = -ZETA2 / ( ONE+T ) |
| 280 | 1 | pfleura2 | SESTPR = SQRT( ONE+T+FOUR*EPS*EPS*NORMA )*ABSEST |
| 281 | 1 | pfleura2 | END IF |
| 282 | 1 | pfleura2 | TMP = SQRT( SINE*SINE+COSINE*COSINE ) |
| 283 | 1 | pfleura2 | S = SINE / TMP |
| 284 | 1 | pfleura2 | C = COSINE / TMP |
| 285 | 1 | pfleura2 | RETURN |
| 286 | 1 | pfleura2 | * |
| 287 | 1 | pfleura2 | END IF |
| 288 | 1 | pfleura2 | END IF |
| 289 | 1 | pfleura2 | RETURN |
| 290 | 1 | pfleura2 | * |
| 291 | 1 | pfleura2 | * End of DLAIC1 |
| 292 | 1 | pfleura2 | * |
| 293 | 1 | pfleura2 | END |