170 SUBROUTINE slasy2( LTRANL, LTRANR, ISGN, N1, N2, TL, LDTL, TR,
171 $ LDTR, B, LDB, SCALE, X, LDX, XNORM, INFO )
178 LOGICAL LTRANL, LTRANR
179 INTEGER INFO, ISGN, LDB, LDTL, LDTR, LDX, N1, N2
183 REAL B( LDB, * ), TL( LDTL, * ), TR( LDTR, * ),
191 parameter( zero = 0.0e+0, one = 1.0e+0 )
192 REAL TWO, HALF, EIGHT
193 parameter( two = 2.0e+0, half = 0.5e+0, eight = 8.0e+0 )
197 INTEGER I, IP, IPIV, IPSV, J, JP, JPSV, K
198 REAL BET, EPS, GAM, L21, SGN, SMIN, SMLNUM, TAU1,
199 $ temp, u11, u12, u22, xmax
202 LOGICAL BSWPIV( 4 ), XSWPIV( 4 )
203 INTEGER JPIV( 4 ), LOCL21( 4 ), LOCU12( 4 ),
205 REAL BTMP( 4 ), T16( 4, 4 ), TMP( 4 ), X2( 2 )
210 EXTERNAL isamax, slamch
219 DATA locu12 / 3, 4, 1, 2 / , locl21 / 2, 1, 4, 3 / ,
220 $ locu22 / 4, 3, 2, 1 /
221 DATA xswpiv / .false., .false., .true., .true. /
222 DATA bswpiv / .false., .true., .false., .true. /
232 IF( n1.EQ.0 .OR. n2.EQ.0 )
238 smlnum = slamch(
'S' ) / eps
242 GO TO ( 10, 20, 30, 50 )k
247 tau1 = tl( 1, 1 ) + sgn*tr( 1, 1 )
249 IF( bet.LE.smlnum )
THEN
256 gam = abs( b( 1, 1 ) )
257 IF( smlnum*gam.GT.bet )
260 x( 1, 1 ) = ( b( 1, 1 )*scale ) / tau1
261 xnorm = abs( x( 1, 1 ) )
270 smin = max( eps*max( abs( tl( 1, 1 ) ), abs( tr( 1, 1 ) ),
271 $ abs( tr( 1, 2 ) ), abs( tr( 2, 1 ) ), abs( tr( 2, 2 ) ) ),
273 tmp( 1 ) = tl( 1, 1 ) + sgn*tr( 1, 1 )
274 tmp( 4 ) = tl( 1, 1 ) + sgn*tr( 2, 2 )
276 tmp( 2 ) = sgn*tr( 2, 1 )
277 tmp( 3 ) = sgn*tr( 1, 2 )
279 tmp( 2 ) = sgn*tr( 1, 2 )
280 tmp( 3 ) = sgn*tr( 2, 1 )
282 btmp( 1 ) = b( 1, 1 )
283 btmp( 2 ) = b( 1, 2 )
291 smin = max( eps*max( abs( tr( 1, 1 ) ), abs( tl( 1, 1 ) ),
292 $ abs( tl( 1, 2 ) ), abs( tl( 2, 1 ) ), abs( tl( 2, 2 ) ) ),
294 tmp( 1 ) = tl( 1, 1 ) + sgn*tr( 1, 1 )
295 tmp( 4 ) = tl( 2, 2 ) + sgn*tr( 1, 1 )
297 tmp( 2 ) = tl( 1, 2 )
298 tmp( 3 ) = tl( 2, 1 )
300 tmp( 2 ) = tl( 2, 1 )
301 tmp( 3 ) = tl( 1, 2 )
303 btmp( 1 ) = b( 1, 1 )
304 btmp( 2 ) = b( 2, 1 )
310 ipiv = isamax( 4, tmp, 1 )
312 IF( abs( u11 ).LE.smin )
THEN
316 u12 = tmp( locu12( ipiv ) )
317 l21 = tmp( locl21( ipiv ) ) / u11
318 u22 = tmp( locu22( ipiv ) ) - u12*l21
319 xswap = xswpiv( ipiv )
320 bswap = bswpiv( ipiv )
321 IF( abs( u22 ).LE.smin )
THEN
327 btmp( 2 ) = btmp( 1 ) - l21*temp
330 btmp( 2 ) = btmp( 2 ) - l21*btmp( 1 )
333 IF( ( two*smlnum )*abs( btmp( 2 ) ).GT.abs( u22 ) .OR.
334 $ ( two*smlnum )*abs( btmp( 1 ) ).GT.abs( u11 ) )
THEN
335 scale = half / max( abs( btmp( 1 ) ), abs( btmp( 2 ) ) )
336 btmp( 1 ) = btmp( 1 )*scale
337 btmp( 2 ) = btmp( 2 )*scale
339 x2( 2 ) = btmp( 2 ) / u22
340 x2( 1 ) = btmp( 1 ) / u11 - ( u12 / u11 )*x2( 2 )
349 xnorm = abs( x( 1, 1 ) ) + abs( x( 1, 2 ) )
352 xnorm = max( abs( x( 1, 1 ) ), abs( x( 2, 1 ) ) )
364 smin = max( abs( tr( 1, 1 ) ), abs( tr( 1, 2 ) ),
365 $ abs( tr( 2, 1 ) ), abs( tr( 2, 2 ) ) )
366 smin = max( smin, abs( tl( 1, 1 ) ), abs( tl( 1, 2 ) ),
367 $ abs( tl( 2, 1 ) ), abs( tl( 2, 2 ) ) )
368 smin = max( eps*smin, smlnum )
370 CALL scopy( 16, btmp, 0, t16, 1 )
371 t16( 1, 1 ) = tl( 1, 1 ) + sgn*tr( 1, 1 )
372 t16( 2, 2 ) = tl( 2, 2 ) + sgn*tr( 1, 1 )
373 t16( 3, 3 ) = tl( 1, 1 ) + sgn*tr( 2, 2 )
374 t16( 4, 4 ) = tl( 2, 2 ) + sgn*tr( 2, 2 )
376 t16( 1, 2 ) = tl( 2, 1 )
377 t16( 2, 1 ) = tl( 1, 2 )
378 t16( 3, 4 ) = tl( 2, 1 )
379 t16( 4, 3 ) = tl( 1, 2 )
381 t16( 1, 2 ) = tl( 1, 2 )
382 t16( 2, 1 ) = tl( 2, 1 )
383 t16( 3, 4 ) = tl( 1, 2 )
384 t16( 4, 3 ) = tl( 2, 1 )
387 t16( 1, 3 ) = sgn*tr( 1, 2 )
388 t16( 2, 4 ) = sgn*tr( 1, 2 )
389 t16( 3, 1 ) = sgn*tr( 2, 1 )
390 t16( 4, 2 ) = sgn*tr( 2, 1 )
392 t16( 1, 3 ) = sgn*tr( 2, 1 )
393 t16( 2, 4 ) = sgn*tr( 2, 1 )
394 t16( 3, 1 ) = sgn*tr( 1, 2 )
395 t16( 4, 2 ) = sgn*tr( 1, 2 )
397 btmp( 1 ) = b( 1, 1 )
398 btmp( 2 ) = b( 2, 1 )
399 btmp( 3 ) = b( 1, 2 )
400 btmp( 4 ) = b( 2, 2 )
408 IF( abs( t16( ip, jp ) ).GE.xmax )
THEN
409 xmax = abs( t16( ip, jp ) )
416 CALL sswap( 4, t16( ipsv, 1 ), 4, t16( i, 1 ), 4 )
418 btmp( i ) = btmp( ipsv )
422 $
CALL sswap( 4, t16( 1, jpsv ), 1, t16( 1, i ), 1 )
424 IF( abs( t16( i, i ) ).LT.smin )
THEN
429 t16( j, i ) = t16( j, i ) / t16( i, i )
430 btmp( j ) = btmp( j ) - t16( j, i )*btmp( i )
432 t16( j, k ) = t16( j, k ) - t16( j, i )*t16( i, k )
436 IF( abs( t16( 4, 4 ) ).LT.smin )
THEN
441 IF( ( eight*smlnum )*abs( btmp( 1 ) ).GT.abs( t16( 1, 1 ) ) .OR.
442 $ ( eight*smlnum )*abs( btmp( 2 ) ).GT.abs( t16( 2, 2 ) ) .OR.
443 $ ( eight*smlnum )*abs( btmp( 3 ) ).GT.abs( t16( 3, 3 ) ) .OR.
444 $ ( eight*smlnum )*abs( btmp( 4 ) ).GT.abs( t16( 4, 4 ) ) )
THEN
445 scale = ( one / eight ) / max( abs( btmp( 1 ) ),
446 $ abs( btmp( 2 ) ), abs( btmp( 3 ) ), abs( btmp( 4 ) ) )
447 btmp( 1 ) = btmp( 1 )*scale
448 btmp( 2 ) = btmp( 2 )*scale
449 btmp( 3 ) = btmp( 3 )*scale
450 btmp( 4 ) = btmp( 4 )*scale
454 temp = one / t16( k, k )
455 tmp( k ) = btmp( k )*temp
457 tmp( k ) = tmp( k ) - ( temp*t16( k, j ) )*tmp( j )
461 IF( jpiv( 4-i ).NE.4-i )
THEN
463 tmp( 4-i ) = tmp( jpiv( 4-i ) )
464 tmp( jpiv( 4-i ) ) = temp
471 xnorm = max( abs( tmp( 1 ) )+abs( tmp( 3 ) ),
472 $ abs( tmp( 2 ) )+abs( tmp( 4 ) ) )