34
34
! >
35
35
! > \verbatim
36
36
! >
37
- ! > DLASSQ returns the values scl and smsq such that
37
+ ! > DLASSQ returns the values scale_out and sumsq_out such that
38
38
! >
39
- ! > ( scl **2 )*smsq = x( 1 )**2 +...+ x( n )**2 + ( scale**2 )*sumsq,
39
+ ! > (scale_out **2)*sumsq_out = x( 1 )**2 +...+ x( n )**2 + (scale**2)*sumsq,
40
40
! >
41
- ! > where x( i ) = X( 1 + ( i - 1 )*INCX ). The value of sumsq is
41
+ ! > where x( i ) = X( 1 + ( i - 1 )*INCX ). The value of sumsq is
42
42
! > assumed to be non-negative.
43
43
! >
44
44
! > scale and sumsq must be supplied in SCALE and SUMSQ and
45
- ! > scl and smsq are overwritten on SCALE and SUMSQ respectively.
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.
45
+ ! > scale_out and sumsq_out are overwritten on SCALE and SUMSQ respectively.
59
46
! >
60
47
! > \endverbatim
61
48
!
72
59
! > \verbatim
73
60
! > X is DOUBLE PRECISION array, dimension (1+(N-1)*abs(INCX))
74
61
! > The vector for which a scaled sum of squares is computed.
75
- ! > x( i ) = X( 1 + ( i - 1 )*INCX ), 1 <= i <= n.
62
+ ! > x( i ) = X( 1 + ( i - 1 )*INCX ), 1 <= i <= n.
76
63
! > \endverbatim
77
64
! >
78
65
! > \param[in] INCX
82
69
! > If INCX > 0, X(1+(i-1)*INCX) = x(i) for 1 <= i <= n
83
70
! > If INCX < 0, X(1-(n-i)*INCX) = x(i) for 1 <= i <= n
84
71
! > If INCX = 0, x isn't a vector so there is no need to call
85
- ! > this subroutine. If you call it anyway, it will count x(1)
72
+ ! > this subroutine. If you call it anyway, it will count x(1)
86
73
! > in the vector norm N times.
87
74
! > \endverbatim
88
75
! >
89
76
! > \param[in,out] SCALE
90
77
! > \verbatim
91
78
! > SCALE is DOUBLE PRECISION
92
- ! > On entry, the value scale in the equation above.
93
- ! > On exit, SCALE is overwritten with scl , the scaling factor
79
+ ! > On entry, the value scale in the equation above.
80
+ ! > On exit, SCALE is overwritten by scale_out , the scaling factor
94
81
! > for the sum of squares.
95
82
! > \endverbatim
96
83
! >
97
84
! > \param[in,out] SUMSQ
98
85
! > \verbatim
99
86
! > SUMSQ is DOUBLE PRECISION
100
- ! > On entry, the value sumsq in the equation above.
101
- ! > On exit, SUMSQ is overwritten with smsq , the basic sum of
102
- ! > squares from which scl has been factored out.
87
+ ! > On entry, the value sumsq in the equation above.
88
+ ! > On exit, SUMSQ is overwritten by sumsq_out , the basic sum of
89
+ ! > squares from which scale_out has been factored out.
103
90
! > \endverbatim
104
91
!
105
92
! Authors:
130
117
! >
131
118
! > \endverbatim
132
119
!
133
- ! > \ingroup OTHERauxiliary
120
+ ! > \ingroup lassq
134
121
!
135
122
! =====================================================================
136
- subroutine DLASSQ ( n , x , incx , scl , sumsq )
123
+ subroutine DLASSQ ( n , x , incx , scale , sumsq )
137
124
use LA_CONSTANTS, &
138
125
only: wp= >dp, zero= >dzero, one= >done, &
139
126
sbig= >dsbig, ssml= >dssml, tbig= >dtbig, tsml= >dtsml
@@ -145,7 +132,7 @@ subroutine DLASSQ( n, x, incx, scl, sumsq )
145
132
!
146
133
! .. Scalar Arguments ..
147
134
integer :: incx, n
148
- real (wp) :: scl , sumsq
135
+ real (wp) :: scale , sumsq
149
136
! ..
150
137
! .. Array Arguments ..
151
138
real (wp) :: x(* )
@@ -158,10 +145,10 @@ subroutine DLASSQ( n, x, incx, scl, sumsq )
158
145
!
159
146
! Quick return if possible
160
147
!
161
- if ( LA_ISNAN(scl ) .or. LA_ISNAN(sumsq) ) return
162
- if ( sumsq == zero ) scl = one
163
- if ( scl == zero ) then
164
- scl = one
148
+ if ( LA_ISNAN(scale ) .or. LA_ISNAN(sumsq) ) return
149
+ if ( sumsq == zero ) scale = one
150
+ if ( scale == zero ) then
151
+ scale = one
165
152
sumsq = zero
166
153
end if
167
154
if (n <= 0 ) then
@@ -198,15 +185,27 @@ subroutine DLASSQ( n, x, incx, scl, sumsq )
198
185
! Put the existing sum of squares into one of the accumulators
199
186
!
200
187
if ( sumsq > zero ) then
201
- ax = scl * sqrt ( sumsq )
188
+ ax = scale * sqrt ( sumsq )
202
189
if (ax > tbig) then
203
- ! We assume scl >= sqrt( TINY*EPS ) / sbig
204
- abig = abig + (scl* sbig)** 2 * sumsq
190
+ if (scale > one) then
191
+ scale = scale * sbig
192
+ abig = abig + scale * (scale * sumsq)
193
+ else
194
+ ! sumsq > tbig^2 => (sbig * (sbig * sumsq)) is representable
195
+ abig = abig + scale * (scale * (sbig * (sbig * sumsq)))
196
+ end if
205
197
else if (ax < tsml) then
206
- ! We assume scl <= sqrt( HUGE ) / ssml
207
- if (notbig) asml = asml + (scl* ssml)** 2 * sumsq
198
+ if (notbig) then
199
+ if (scale < one) then
200
+ scale = scale * ssml
201
+ asml = asml + scale * (scale * sumsq)
202
+ else
203
+ ! sumsq < tsml^2 => (ssml * (ssml * sumsq)) is representable
204
+ asml = asml + scale * (scale * (ssml * (ssml * sumsq)))
205
+ end if
206
+ end if
208
207
else
209
- amed = amed + scl ** 2 * sumsq
208
+ amed = amed + scale * (scale * sumsq)
210
209
end if
211
210
end if
212
211
!
@@ -220,7 +219,7 @@ subroutine DLASSQ( n, x, incx, scl, sumsq )
220
219
if (amed > zero .or. LA_ISNAN(amed)) then
221
220
abig = abig + (amed* sbig)* sbig
222
221
end if
223
- scl = one / sbig
222
+ scale = one / sbig
224
223
sumsq = abig
225
224
else if (asml > zero) then
226
225
!
@@ -236,17 +235,17 @@ subroutine DLASSQ( n, x, incx, scl, sumsq )
236
235
ymin = asml
237
236
ymax = amed
238
237
end if
239
- scl = one
238
+ scale = one
240
239
sumsq = ymax** 2 * ( one + (ymin/ ymax)** 2 )
241
240
else
242
- scl = one / ssml
241
+ scale = one / ssml
243
242
sumsq = asml
244
243
end if
245
244
else
246
245
!
247
246
! Otherwise all values are mid-range or zero
248
247
!
249
- scl = one
248
+ scale = one
250
249
sumsq = amed
251
250
end if
252
251
return
0 commit comments