265 SUBROUTINE zlals0( ICOMPQ, NL, NR, SQRE, NRHS, B, LDB, BX,
267 $ PERM, GIVPTR, GIVCOL, LDGCOL, GIVNUM, LDGNUM,
268 $ POLES, DIFL, DIFR, Z, K, C, S, RWORK, INFO )
275 INTEGER GIVPTR, ICOMPQ, INFO, K, LDB, LDBX, LDGCOL,
276 $ LDGNUM, NL, NR, NRHS, SQRE
277 DOUBLE PRECISION C, S
280 INTEGER GIVCOL( LDGCOL, * ), PERM( * )
281 DOUBLE PRECISION DIFL( * ), DIFR( LDGNUM, * ),
282 $ GIVNUM( LDGNUM, * ), POLES( LDGNUM, * ),
284 COMPLEX*16 B( LDB, * ), BX( LDBX, * )
290 DOUBLE PRECISION ONE, ZERO, NEGONE
291 PARAMETER ( ONE = 1.0d0, zero = 0.0d0, negone = -1.0d0 )
294 INTEGER I, J, JCOL, JROW, M, N, NLP1
295 DOUBLE PRECISION DIFLJ, DIFRJ, DJ, DSIGJ, DSIGJP, TEMP
303 DOUBLE PRECISION DLAMC3, DNRM2
304 EXTERNAL DLAMC3, DNRM2
307 INTRINSIC dble, dcmplx, dimag, max
316 IF( ( icompq.LT.0 ) .OR. ( icompq.GT.1 ) )
THEN
318 ELSE IF( nl.LT.1 )
THEN
320 ELSE IF( nr.LT.1 )
THEN
322 ELSE IF( ( sqre.LT.0 ) .OR. ( sqre.GT.1 ) )
THEN
324 ELSE IF( nrhs.LT.1 )
THEN
326 ELSE IF( ldb.LT.n )
THEN
328 ELSE IF( ldbx.LT.n )
THEN
330 ELSE IF( givptr.LT.0 )
THEN
332 ELSE IF( ldgcol.LT.n )
THEN
334 ELSE IF( ldgnum.LT.n )
THEN
336 ELSE IF( k.LT.1 )
THEN
340 CALL xerbla(
'ZLALS0', -info )
347 IF( icompq.EQ.0 )
THEN
354 CALL zdrot( nrhs, b( givcol( i, 2 ), 1 ), ldb,
355 $ b( givcol( i, 1 ), 1 ), ldb, givnum( i, 2 ),
361 CALL zcopy( nrhs, b( nlp1, 1 ), ldb, bx( 1, 1 ), ldbx )
363 CALL zcopy( nrhs, b( perm( i ), 1 ), ldb, bx( i, 1 ),
371 CALL zcopy( nrhs, bx, ldbx, b, ldb )
372 IF( z( 1 ).LT.zero )
THEN
373 CALL zdscal( nrhs, negone, b, ldb )
379 dsigj = -poles( j, 2 )
381 difrj = -difr( j, 1 )
382 dsigjp = -poles( j+1, 2 )
384 IF( ( z( j ).EQ.zero ) .OR. ( poles( j, 2 ).EQ.zero ) )
388 rwork( j ) = -poles( j, 2 )*z( j ) / diflj /
389 $ ( poles( j, 2 )+dj )
392 IF( ( z( i ).EQ.zero ) .OR.
393 $ ( poles( i, 2 ).EQ.zero ) )
THEN
401 rwork( i ) = poles( i, 2 )*z( i ) /
402 $ ( dlamc3( poles( i, 2 ), dsigj )-
403 $ diflj ) / ( poles( i, 2 )+dj )
407 IF( ( z( i ).EQ.zero ) .OR.
408 $ ( poles( i, 2 ).EQ.zero ) )
THEN
411 rwork( i ) = poles( i, 2 )*z( i ) /
412 $ ( dlamc3( poles( i, 2 ), dsigjp )+
413 $ difrj ) / ( poles( i, 2 )+dj )
417 temp = dnrm2( k, rwork, 1 )
429 rwork( i ) = dble( bx( jrow, jcol ) )
432 CALL dgemv(
'T', k, nrhs, one, rwork( 1+k+nrhs*2 ), k,
433 $ rwork( 1 ), 1, zero, rwork( 1+k ), 1 )
438 rwork( i ) = dimag( bx( jrow, jcol ) )
441 CALL dgemv(
'T', k, nrhs, one, rwork( 1+k+nrhs*2 ), k,
442 $ rwork( 1 ), 1, zero, rwork( 1+k+nrhs ), 1 )
444 b( j, jcol ) = dcmplx( rwork( jcol+k ),
445 $ rwork( jcol+k+nrhs ) )
447 CALL zlascl(
'G', 0, 0, temp, one, 1, nrhs, b( j, 1 ),
454 IF( k.LT.max( m, n ) )
455 $
CALL zlacpy(
'A', n-k, nrhs, bx( k+1, 1 ), ldbx,
465 CALL zcopy( nrhs, b, ldb, bx, ldbx )
468 dsigj = poles( j, 2 )
469 IF( z( j ).EQ.zero )
THEN
472 rwork( j ) = -z( j ) / difl( j ) /
473 $ ( dsigj+poles( j, 1 ) ) / difr( j, 2 )
476 IF( z( j ).EQ.zero )
THEN
484 rwork( i ) = z( j ) / ( dlamc3( dsigj,
486 $ 2 ) )-difr( i, 1 ) ) /
487 $ ( dsigj+poles( i, 1 ) ) / difr( i, 2 )
491 IF( z( j ).EQ.zero )
THEN
494 rwork( i ) = z( j ) / ( dlamc3( dsigj,
496 $ 2 ) )-difl( i ) ) /
497 $ ( dsigj+poles( i, 1 ) ) / difr( i, 2 )
508 DO 140 jcol = 1, nrhs
511 rwork( i ) = dble( b( jrow, jcol ) )
514 CALL dgemv(
'T', k, nrhs, one, rwork( 1+k+nrhs*2 ), k,
515 $ rwork( 1 ), 1, zero, rwork( 1+k ), 1 )
517 DO 160 jcol = 1, nrhs
520 rwork( i ) = dimag( b( jrow, jcol ) )
523 CALL dgemv(
'T', k, nrhs, one, rwork( 1+k+nrhs*2 ), k,
524 $ rwork( 1 ), 1, zero, rwork( 1+k+nrhs ), 1 )
525 DO 170 jcol = 1, nrhs
526 bx( j, jcol ) = dcmplx( rwork( jcol+k ),
527 $ rwork( jcol+k+nrhs ) )
536 CALL zcopy( nrhs, b( m, 1 ), ldb, bx( m, 1 ), ldbx )
537 CALL zdrot( nrhs, bx( 1, 1 ), ldbx, bx( m, 1 ), ldbx, c,
540 IF( k.LT.max( m, n ) )
541 $
CALL zlacpy(
'A', n-k, nrhs, b( k+1, 1 ), ldb, bx( k+1,
547 CALL zcopy( nrhs, bx( 1, 1 ), ldbx, b( nlp1, 1 ), ldb )
549 CALL zcopy( nrhs, bx( m, 1 ), ldbx, b( m, 1 ), ldb )
552 CALL zcopy( nrhs, bx( i, 1 ), ldbx, b( perm( i ), 1 ),
558 DO 200 i = givptr, 1, -1
559 CALL zdrot( nrhs, b( givcol( i, 2 ), 1 ), ldb,
560 $ b( givcol( i, 1 ), 1 ), ldb, givnum( i, 2 ),