135 SUBROUTINE dlaic1( JOB, J, X, SEST, W, GAMMA, SESTPR, S, C )
144 DOUBLE PRECISION c, gamma, s, sest, sestpr
147 DOUBLE PRECISION w( j ), x( j )
153 DOUBLE PRECISION zero, one, two
154 parameter( zero = 0.0d0, one = 1.0d0, two = 2.0d0 )
155 DOUBLE PRECISION half, four
156 parameter( half = 0.5d0, four = 4.0d0 )
159 DOUBLE PRECISION absalp, absest, absgam, alpha, b, cosine, eps,
160 $ norma, s1, s2, sine, t, test, tmp, zeta1, zeta2
163 INTRINSIC abs, max, sign, sqrt
172 alpha =
ddot( j, x, 1, w, 1 )
174 absalp = abs( alpha )
175 absgam = abs( gamma )
184 IF( sest.EQ.zero )
THEN
185 s1 = max( absgam, absalp )
186 IF( s1.EQ.zero )
THEN
193 tmp = sqrt( s*s+c*c )
199 ELSE IF( absgam.LE.eps*absest )
THEN
202 tmp = max( absest, absalp )
205 sestpr = tmp*sqrt( s1*s1+s2*s2 )
207 ELSE IF( absalp.LE.eps*absest )
THEN
220 ELSE IF( absest.LE.eps*absalp .OR. absest.LE.eps*absgam )
THEN
225 s = sqrt( one+tmp*tmp )
227 c = ( gamma / s2 ) / s
228 s = sign( one, alpha ) / s
231 c = sqrt( one+tmp*tmp )
233 s = ( alpha / s1 ) / c
234 c = sign( one, gamma ) / c
241 zeta1 = alpha / absest
242 zeta2 = gamma / absest
244 b = ( one-zeta1*zeta1-zeta2*zeta2 )*half
247 t = c / ( b+sqrt( b*b+c ) )
249 t = sqrt( b*b+c ) - b
253 cosine = -zeta2 / ( one+t )
254 tmp = sqrt( sine*sine+cosine*cosine )
257 sestpr = sqrt( t+one )*absest
261 ELSE IF( job.EQ.2 )
THEN
267 IF( sest.EQ.zero )
THEN
269 IF( max( absgam, absalp ).EQ.zero )
THEN
276 s1 = max( abs( sine ), abs( cosine ) )
279 tmp = sqrt( s*s+c*c )
283 ELSE IF( absgam.LE.eps*absest )
THEN
288 ELSE IF( absalp.LE.eps*absest )
THEN
301 ELSE IF( absest.LE.eps*absalp .OR. absest.LE.eps*absgam )
THEN
306 c = sqrt( one+tmp*tmp )
307 sestpr = absest*( tmp / c )
308 s = -( gamma / s2 ) / c
309 c = sign( one, alpha ) / c
312 s = sqrt( one+tmp*tmp )
314 c = ( alpha / s1 ) / s
315 s = -sign( one, gamma ) / s
322 zeta1 = alpha / absest
323 zeta2 = gamma / absest
325 norma = max( one+zeta1*zeta1+abs( zeta1*zeta2 ),
326 $ abs( zeta1*zeta2 )+zeta2*zeta2 )
330 test = one + two*( zeta1-zeta2 )*( zeta1+zeta2 )
331 IF( test.GE.zero )
THEN
335 b = ( zeta1*zeta1+zeta2*zeta2+one )*half
337 t = c / ( b+sqrt( abs( b*b-c ) ) )
338 sine = zeta1 / ( one-t )
340 sestpr = sqrt( t+four*eps*eps*norma )*absest
345 b = ( zeta2*zeta2+zeta1*zeta1-one )*half
348 t = -c / ( b+sqrt( b*b+c ) )
350 t = b - sqrt( b*b+c )
353 cosine = -zeta2 / ( one+t )
354 sestpr = sqrt( one+t+four*eps*eps*norma )*absest
356 tmp = sqrt( sine*sine+cosine*cosine )