|
39 | 39 | !> ( scl**2 )*smsq = x( 1 )**2 +...+ x( n )**2 + ( scale**2 )*sumsq, |
40 | 40 | !> |
41 | 41 | !> where x( i ) = X( 1 + ( i - 1 )*INCX ). The value of sumsq is |
42 | | -!> assumed to be non-negative and scl returns the value |
43 | | -!> |
44 | | -!> scl = max( scale, abs( x( i ) ) ). |
| 42 | +!> assumed to be non-negative. |
45 | 43 | !> |
46 | 44 | !> scale and sumsq must be supplied in SCALE and SUMSQ and |
47 | 45 | !> scl and smsq are overwritten on SCALE and SUMSQ respectively. |
48 | 46 | !> |
| 47 | +!> If scale * sqrt( sumsq ) > tbig then |
| 48 | +!> we require: scale >= sqrt( TINY*EPS ) / sbig on entry, |
| 49 | +!> and if scale * sqrt( sumsq ) < tsml then |
| 50 | +!> we require: scale <= sqrt( HUGE ) / ssml on entry, |
| 51 | +!> where |
| 52 | +!> tbig -- upper threshold for values whose square is representable; |
| 53 | +!> sbig -- scaling constant for big numbers; \see la_constants.f90 |
| 54 | +!> tsml -- lower threshold for values whose square is representable; |
| 55 | +!> ssml -- scaling constant for small numbers; \see la_constants.f90 |
| 56 | +!> and |
| 57 | +!> TINY*EPS -- tiniest representable number; |
| 58 | +!> HUGE -- biggest representable number. |
| 59 | +!> |
49 | 60 | !> \endverbatim |
50 | 61 | ! |
51 | 62 | ! Arguments: |
@@ -198,12 +209,14 @@ subroutine CLASSQ( n, x, incx, scl, sumsq ) |
198 | 209 | if( sumsq > zero ) then |
199 | 210 | ax = scl*sqrt( sumsq ) |
200 | 211 | if (ax > tbig) then |
201 | | - abig = abig + (ax*sbig)**2 |
| 212 | +! We assume scl >= sqrt( TINY*EPS ) / sbig |
| 213 | + abig = abig + (scl*sbig)**2 * sumsq |
202 | 214 | notbig = .false. |
203 | 215 | else if (ax < tsml) then |
204 | | - if (notbig) asml = asml + (ax*ssml)**2 |
| 216 | +! We assume scl <= sqrt( HUGE ) / ssml |
| 217 | + if (notbig) asml = asml + (scl*ssml)**2 * sumsq |
205 | 218 | else |
206 | | - amed = amed + ax**2 |
| 219 | + amed = amed + scl**2 * sumsq |
207 | 220 | end if |
208 | 221 | end if |
209 | 222 | ! |
|
0 commit comments