154 SUBROUTINE dlag2( A, LDA, B, LDB, SAFMIN, SCALE1, SCALE2, WR1,
163 DOUBLE PRECISION SAFMIN, SCALE1, SCALE2, WI, WR1, WR2
166 DOUBLE PRECISION A( LDA, * ), B( LDB, * )
172 DOUBLE PRECISION ZERO, ONE, TWO
173 parameter( zero = 0.0d+0, one = 1.0d+0, two = 2.0d+0 )
174 DOUBLE PRECISION HALF
175 parameter( half = one / two )
176 DOUBLE PRECISION FUZZY1
177 parameter( fuzzy1 = one+1.0d-5 )
180 DOUBLE PRECISION A11, A12, A21, A22, ABI22, ANORM, AS11, AS12,
181 $ as22, ascale, b11, b12, b22, binv11, binv22,
182 $ bmin, bnorm, bscale, bsize, c1, c2, c3, c4, c5,
183 $ diff, discr, pp, qq, r, rtmax, rtmin, s1, s2,
184 $ safmax, shift, ss, sum, wabs, wbig, wdet,
185 $ wscale, wsize, wsmall
188 INTRINSIC abs, max, min, sign, sqrt
192 rtmin = sqrt( safmin )
194 safmax = one / safmin
198 anorm = max( abs( a( 1, 1 ) )+abs( a( 2, 1 ) ),
199 $ abs( a( 1, 2 ) )+abs( a( 2, 2 ) ), safmin )
201 a11 = ascale*a( 1, 1 )
202 a21 = ascale*a( 2, 1 )
203 a12 = ascale*a( 1, 2 )
204 a22 = ascale*a( 2, 2 )
211 bmin = rtmin*max( abs( b11 ), abs( b12 ), abs( b22 ), rtmin )
212 IF( abs( b11 ).LT.bmin )
213 $ b11 = sign( bmin, b11 )
214 IF( abs( b22 ).LT.bmin )
215 $ b22 = sign( bmin, b22 )
219 bnorm = max( abs( b11 ), abs( b12 )+abs( b22 ), safmin )
220 bsize = max( abs( b11 ), abs( b22 ) )
234 IF( abs( s1 ).LE.abs( s2 ) )
THEN
237 ss = a21*( binv11*binv22 )
238 abi22 = as22*binv22 - ss*b12
244 ss = a21*( binv11*binv22 )
246 pp = half*( as11*binv11+abi22 )
250 IF( abs( pp*rtmin ).GE.one )
THEN
251 discr = ( rtmin*pp )**2 + qq*safmin
252 r = sqrt( abs( discr ) )*rtmax
254 IF( pp**2+abs( qq ).LE.safmin )
THEN
255 discr = ( rtmax*pp )**2 + qq*safmax
256 r = sqrt( abs( discr ) )*rtmin
259 r = sqrt( abs( discr ) )
269 IF( discr.GE.zero .OR. r.EQ.zero )
THEN
270 sum = pp + sign( r, pp )
271 diff = pp - sign( r, pp )
276 wsmall = shift + diff
277 IF( half*abs( wbig ).GT.max( abs( wsmall ), safmin ) )
THEN
278 wdet = ( a11*a22-a12*a21 )*( binv11*binv22 )
285 IF( pp.GT.abi22 )
THEN
286 wr1 = min( wbig, wsmall )
287 wr2 = max( wbig, wsmall )
289 wr1 = max( wbig, wsmall )
290 wr2 = min( wbig, wsmall )
314 c1 = bsize*( safmin*max( one, ascale ) )
315 c2 = safmin*max( one, bnorm )
317 IF( ascale.LE.one .AND. bsize.LE.one )
THEN
318 c4 = min( one, ( ascale / safmin )*bsize )
322 IF( ascale.LE.one .OR. bsize.LE.one )
THEN
323 c5 = min( one, ascale*bsize )
330 wabs = abs( wr1 ) + abs( wi )
331 wsize = max( safmin, c1, fuzzy1*( wabs*c2+c3 ),
332 $ min( c4, half*max( wabs, c5 ) ) )
333 IF( wsize.NE.one )
THEN
335 IF( wsize.GT.one )
THEN
336 scale1 = ( max( ascale, bsize )*wscale )*
337 $ min( ascale, bsize )
339 scale1 = ( min( ascale, bsize )*wscale )*
340 $ max( ascale, bsize )
343 IF( wi.NE.zero )
THEN
349 scale1 = ascale*bsize
355 IF( wi.EQ.zero )
THEN
356 wsize = max( safmin, c1, fuzzy1*( abs( wr2 )*c2+c3 ),
357 $ min( c4, half*max( abs( wr2 ), c5 ) ) )
358 IF( wsize.NE.one )
THEN
360 IF( wsize.GT.one )
THEN
361 scale2 = ( max( ascale, bsize )*wscale )*
362 $ min( ascale, bsize )
364 scale2 = ( min( ascale, bsize )*wscale )*
365 $ max( ascale, bsize )
369 scale2 = ascale*bsize
subroutine dlag2(a, lda, b, ldb, safmin, scale1, scale2, wr1, wr2, wi)
DLAG2 computes the eigenvalues of a 2-by-2 generalized eigenvalue problem, with scaling as necessary ...