|
44 | 44 | !> scale and sumsq must be supplied in SCALE and SUMSQ and |
45 | 45 | !> scale_out and sumsq_out are overwritten on SCALE and SUMSQ respectively. |
46 | 46 | !> |
47 | | -!> If scale * sqrt( sumsq ) > tbig then |
48 | | -!> we require: scale >= sqrt( TINY*EPS ) / sbig on entry, |
49 | | -!> and if 0 < 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 | | -!> |
60 | 47 | !> \endverbatim |
61 | 48 | ! |
62 | 49 | ! Arguments: |
@@ -209,13 +196,25 @@ subroutine CLASSQ( n, x, incx, scale, sumsq ) |
209 | 196 | if( sumsq > zero ) then |
210 | 197 | ax = scale*sqrt( sumsq ) |
211 | 198 | if (ax > tbig) then |
212 | | -! We assume scale >= sqrt( TINY*EPS ) / sbig |
213 | | - abig = abig + (scale*sbig)**2 * sumsq |
| 199 | + if (scale > one) then |
| 200 | + scale = scale * sbig |
| 201 | + abig = abig + scale * (scale * sumsq) |
| 202 | + else |
| 203 | + ! sumsq > tbig^2 => (sbig * (sbig * sumsq)) is representable |
| 204 | + abig = abig + scale * (scale * (sbig * (sbig * sumsq))) |
| 205 | + end if |
214 | 206 | else if (ax < tsml) then |
215 | | -! We assume scale <= sqrt( HUGE ) / ssml |
216 | | - if (notbig) asml = asml + (scale*ssml)**2 * sumsq |
| 207 | + if (notbig) then |
| 208 | + if (scale < one) then |
| 209 | + scale = scale * ssml |
| 210 | + asml = asml + scale * (scale * sumsq) |
| 211 | + else |
| 212 | + ! sumsq < tsml^2 => (ssml * (ssml * sumsq)) is representable |
| 213 | + asml = asml + scale * (scale * (ssml * (ssml * sumsq))) |
| 214 | + end if |
| 215 | + end if |
217 | 216 | else |
218 | | - amed = amed + scale**2 * sumsq |
| 217 | + amed = amed + scale * (scale * sumsq) |
219 | 218 | end if |
220 | 219 | end if |
221 | 220 | ! |
|
0 commit comments