214 SUBROUTINE slaln2( LTRANS, NA, NW, SMIN, CA, A, LDA, D1, D2, B,
215 $ LDB, WR, WI, X, LDX, SCALE, XNORM, INFO )
223 INTEGER INFO, LDA, LDB, LDX, NA, NW
224 REAL CA, D1, D2, SCALE, SMIN, WI, WR, XNORM
227 REAL A( LDA, * ), B( LDB, * ), X( LDX, * )
234 parameter( zero = 0.0e0, one = 1.0e0 )
236 parameter( two = 2.0e0 )
240 REAL BBND, BI1, BI2, BIGNUM, BNORM, BR1, BR2, CI21,
241 $ ci22, cmax, cnorm, cr21, cr22, csi, csr, li21,
242 $ lr21, smini, smlnum, temp, u22abs, ui11, ui11r,
243 $ ui12, ui12s, ui22, ur11, ur11r, ur12, ur12s,
244 $ ur22, xi1, xi2, xr1, xr2
247 LOGICAL CSWAP( 4 ), RSWAP( 4 )
248 INTEGER IPIVOT( 4, 4 )
249 REAL CI( 2, 2 ), CIV( 4 ), CR( 2, 2 ), CRV( 4 )
262 equivalence( ci( 1, 1 ), civ( 1 ) ),
263 $ ( cr( 1, 1 ), crv( 1 ) )
266 DATA cswap / .false., .false., .true., .true. /
267 DATA rswap / .false., .true., .false., .true. /
268 DATA ipivot / 1, 2, 3, 4, 2, 1, 4, 3, 3, 4, 1, 2, 4,
275 smlnum = two*slamch(
'Safe minimum' )
276 bignum = one / smlnum
277 smini = max( smin, smlnum )
297 csr = ca*a( 1, 1 ) - wr*d1
302 IF( cnorm.LT.smini )
THEN
310 bnorm = abs( b( 1, 1 ) )
311 IF( cnorm.LT.one .AND. bnorm.GT.one )
THEN
312 IF( bnorm.GT.bignum*cnorm )
313 $ scale = one / bnorm
318 x( 1, 1 ) = ( b( 1, 1 )*scale ) / csr
319 xnorm = abs( x( 1, 1 ) )
326 csr = ca*a( 1, 1 ) - wr*d1
328 cnorm = abs( csr ) + abs( csi )
332 IF( cnorm.LT.smini )
THEN
341 bnorm = abs( b( 1, 1 ) ) + abs( b( 1, 2 ) )
342 IF( cnorm.LT.one .AND. bnorm.GT.one )
THEN
343 IF( bnorm.GT.bignum*cnorm )
344 $ scale = one / bnorm
349 CALL sladiv( scale*b( 1, 1 ), scale*b( 1, 2 ), csr, csi,
350 $ x( 1, 1 ), x( 1, 2 ) )
351 xnorm = abs( x( 1, 1 ) ) + abs( x( 1, 2 ) )
360 cr( 1, 1 ) = ca*a( 1, 1 ) - wr*d1
361 cr( 2, 2 ) = ca*a( 2, 2 ) - wr*d2
363 cr( 1, 2 ) = ca*a( 2, 1 )
364 cr( 2, 1 ) = ca*a( 1, 2 )
366 cr( 2, 1 ) = ca*a( 2, 1 )
367 cr( 1, 2 ) = ca*a( 1, 2 )
380 IF( abs( crv( j ) ).GT.cmax )
THEN
381 cmax = abs( crv( j ) )
388 IF( cmax.LT.smini )
THEN
389 bnorm = max( abs( b( 1, 1 ) ), abs( b( 2, 1 ) ) )
390 IF( smini.LT.one .AND. bnorm.GT.one )
THEN
391 IF( bnorm.GT.bignum*smini )
392 $ scale = one / bnorm
395 x( 1, 1 ) = temp*b( 1, 1 )
396 x( 2, 1 ) = temp*b( 2, 1 )
405 cr21 = crv( ipivot( 2, icmax ) )
406 ur12 = crv( ipivot( 3, icmax ) )
407 cr22 = crv( ipivot( 4, icmax ) )
410 ur22 = cr22 - ur12*lr21
414 IF( abs( ur22 ).LT.smini )
THEN
418 IF( rswap( icmax ) )
THEN
426 bbnd = max( abs( br1*( ur22*ur11r ) ), abs( br2 ) )
427 IF( bbnd.GT.one .AND. abs( ur22 ).LT.one )
THEN
428 IF( bbnd.GE.bignum*abs( ur22 ) )
432 xr2 = ( br2*scale ) / ur22
433 xr1 = ( scale*br1 )*ur11r - xr2*( ur11r*ur12 )
434 IF( cswap( icmax ) )
THEN
441 xnorm = max( abs( xr1 ), abs( xr2 ) )
445 IF( xnorm.GT.one .AND. cmax.GT.one )
THEN
446 IF( xnorm.GT.bignum / cmax )
THEN
448 x( 1, 1 ) = temp*x( 1, 1 )
449 x( 2, 1 ) = temp*x( 2, 1 )
468 IF( abs( crv( j ) )+abs( civ( j ) ).GT.cmax )
THEN
469 cmax = abs( crv( j ) ) + abs( civ( j ) )
476 IF( cmax.LT.smini )
THEN
477 bnorm = max( abs( b( 1, 1 ) )+abs( b( 1, 2 ) ),
478 $ abs( b( 2, 1 ) )+abs( b( 2, 2 ) ) )
479 IF( smini.LT.one .AND. bnorm.GT.one )
THEN
480 IF( bnorm.GT.bignum*smini )
481 $ scale = one / bnorm
484 x( 1, 1 ) = temp*b( 1, 1 )
485 x( 2, 1 ) = temp*b( 2, 1 )
486 x( 1, 2 ) = temp*b( 1, 2 )
487 x( 2, 2 ) = temp*b( 2, 2 )
497 cr21 = crv( ipivot( 2, icmax ) )
498 ci21 = civ( ipivot( 2, icmax ) )
499 ur12 = crv( ipivot( 3, icmax ) )
500 ui12 = civ( ipivot( 3, icmax ) )
501 cr22 = crv( ipivot( 4, icmax ) )
502 ci22 = civ( ipivot( 4, icmax ) )
503 IF( icmax.EQ.1 .OR. icmax.EQ.4 )
THEN
507 IF( abs( ur11 ).GT.abs( ui11 ) )
THEN
509 ur11r = one / ( ur11*( one+temp**2 ) )
513 ui11r = -one / ( ui11*( one+temp**2 ) )
520 ur22 = cr22 - ur12*lr21
521 ui22 = ci22 - ur12*li21
532 ur22 = cr22 - ur12*lr21 + ui12*li21
533 ui22 = -ur12*li21 - ui12*lr21
535 u22abs = abs( ur22 ) + abs( ui22 )
539 IF( u22abs.LT.smini )
THEN
544 IF( rswap( icmax ) )
THEN
555 br2 = br2 - lr21*br1 + li21*bi1
556 bi2 = bi2 - li21*br1 - lr21*bi1
557 bbnd = max( ( abs( br1 )+abs( bi1 ) )*
558 $ ( u22abs*( abs( ur11r )+abs( ui11r ) ) ),
559 $ abs( br2 )+abs( bi2 ) )
560 IF( bbnd.GT.one .AND. u22abs.LT.one )
THEN
561 IF( bbnd.GE.bignum*u22abs )
THEN
570 CALL sladiv( br2, bi2, ur22, ui22, xr2, xi2 )
571 xr1 = ur11r*br1 - ui11r*bi1 - ur12s*xr2 + ui12s*xi2
572 xi1 = ui11r*br1 + ur11r*bi1 - ui12s*xr2 - ur12s*xi2
573 IF( cswap( icmax ) )
THEN
584 xnorm = max( abs( xr1 )+abs( xi1 ), abs( xr2 )+abs( xi2 ) )
588 IF( xnorm.GT.one .AND. cmax.GT.one )
THEN
589 IF( xnorm.GT.bignum / cmax )
THEN
591 x( 1, 1 ) = temp*x( 1, 1 )
592 x( 2, 1 ) = temp*x( 2, 1 )
593 x( 1, 2 ) = temp*x( 1, 2 )
594 x( 2, 2 ) = temp*x( 2, 2 )