131 SUBROUTINE slaic1( JOB, J, X, SEST, W, GAMMA, SESTPR, S, C )
139 REAL C, GAMMA, S, SEST, SESTPR
149 parameter( zero = 0.0e0, one = 1.0e0, two = 2.0e0 )
151 parameter( half = 0.5e0, four = 4.0e0 )
154 REAL ABSALP, ABSEST, ABSGAM, ALPHA, B, COSINE, EPS,
155 $ NORMA, S1, S2, SINE, T, TEST, TMP, ZETA1, ZETA2
158 INTRINSIC abs, max, sign, sqrt
162 EXTERNAL sdot, slamch
166 eps = slamch(
'Epsilon' )
167 alpha = sdot( j, x, 1, w, 1 )
169 absalp = abs( alpha )
170 absgam = abs( gamma )
179 IF( sest.EQ.zero )
THEN
180 s1 = max( absgam, absalp )
181 IF( s1.EQ.zero )
THEN
188 tmp = sqrt( s*s+c*c )
194 ELSE IF( absgam.LE.eps*absest )
THEN
197 tmp = max( absest, absalp )
200 sestpr = tmp*sqrt( s1*s1+s2*s2 )
202 ELSE IF( absalp.LE.eps*absest )
THEN
215 ELSE IF( absest.LE.eps*absalp .OR. absest.LE.eps*absgam )
THEN
220 s = sqrt( one+tmp*tmp )
222 c = ( gamma / s2 ) / s
223 s = sign( one, alpha ) / s
226 c = sqrt( one+tmp*tmp )
228 s = ( alpha / s1 ) / c
229 c = sign( one, gamma ) / c
236 zeta1 = alpha / absest
237 zeta2 = gamma / absest
239 b = ( one-zeta1*zeta1-zeta2*zeta2 )*half
242 t = c / ( b+sqrt( b*b+c ) )
244 t = sqrt( b*b+c ) - b
248 cosine = -zeta2 / ( one+t )
249 tmp = sqrt( sine*sine+cosine*cosine )
252 sestpr = sqrt( t+one )*absest
256 ELSE IF( job.EQ.2 )
THEN
262 IF( sest.EQ.zero )
THEN
264 IF( max( absgam, absalp ).EQ.zero )
THEN
271 s1 = max( abs( sine ), abs( cosine ) )
274 tmp = sqrt( s*s+c*c )
278 ELSE IF( absgam.LE.eps*absest )
THEN
283 ELSE IF( absalp.LE.eps*absest )
THEN
296 ELSE IF( absest.LE.eps*absalp .OR. absest.LE.eps*absgam )
THEN
301 c = sqrt( one+tmp*tmp )
302 sestpr = absest*( tmp / c )
303 s = -( gamma / s2 ) / c
304 c = sign( one, alpha ) / c
307 s = sqrt( one+tmp*tmp )
309 c = ( alpha / s1 ) / s
310 s = -sign( one, gamma ) / s
317 zeta1 = alpha / absest
318 zeta2 = gamma / absest
320 norma = max( one+zeta1*zeta1+abs( zeta1*zeta2 ),
321 $ abs( zeta1*zeta2 )+zeta2*zeta2 )
325 test = one + two*( zeta1-zeta2 )*( zeta1+zeta2 )
326 IF( test.GE.zero )
THEN
330 b = ( zeta1*zeta1+zeta2*zeta2+one )*half
332 t = c / ( b+sqrt( abs( b*b-c ) ) )
333 sine = zeta1 / ( one-t )
335 sestpr = sqrt( t+four*eps*eps*norma )*absest
340 b = ( zeta2*zeta2+zeta1*zeta1-one )*half
343 t = -c / ( b+sqrt( b*b+c ) )
345 t = b - sqrt( b*b+c )
348 cosine = -zeta2 / ( one+t )
349 sestpr = sqrt( one+t+four*eps*eps*norma )*absest
351 tmp = sqrt( sine*sine+cosine*cosine )
subroutine slaic1(job, j, x, sest, w, gamma, sestpr, s, c)
SLAIC1 applies one step of incremental condition estimation.