265 SUBROUTINE clals0( 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
280 INTEGER GIVCOL( LDGCOL, * ), PERM( * )
281 REAL DIFL( * ), DIFR( LDGNUM, * ),
282 $ GIVNUM( LDGNUM, * ), POLES( LDGNUM, * ),
284 COMPLEX B( LDB, * ), BX( LDBX, * )
290 REAL ONE, ZERO, NEGONE
291 PARAMETER ( ONE = 1.0e0, zero = 0.0e0, negone = -1.0e0 )
294 INTEGER I, J, JCOL, JROW, M, N, NLP1
295 REAL DIFLJ, DIFRJ, DJ, DSIGJ, DSIGJP, TEMP
304 EXTERNAL SLAMC3, SNRM2
307 INTRINSIC aimag, cmplx, max, real
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(
'CLALS0', -info )
347 IF( icompq.EQ.0 )
THEN
354 CALL csrot( nrhs, b( givcol( i, 2 ), 1 ), ldb,
355 $ b( givcol( i, 1 ), 1 ), ldb, givnum( i, 2 ),
361 CALL ccopy( nrhs, b( nlp1, 1 ), ldb, bx( 1, 1 ), ldbx )
363 CALL ccopy( nrhs, b( perm( i ), 1 ), ldb, bx( i, 1 ),
371 CALL ccopy( nrhs, bx, ldbx, b, ldb )
372 IF( z( 1 ).LT.zero )
THEN
373 CALL csscal( 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 $ ( slamc3( 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 $ ( slamc3( poles( i, 2 ), dsigjp )+
413 $ difrj ) / ( poles( i, 2 )+dj )
417 temp = snrm2( k, rwork, 1 )
429 rwork( i ) = real( bx( jrow, jcol ) )
432 CALL sgemv(
'T', k, nrhs, one, rwork( 1+k+nrhs*2 ), k,
433 $ rwork( 1 ), 1, zero, rwork( 1+k ), 1 )
438 rwork( i ) = aimag( bx( jrow, jcol ) )
441 CALL sgemv(
'T', k, nrhs, one, rwork( 1+k+nrhs*2 ), k,
442 $ rwork( 1 ), 1, zero, rwork( 1+k+nrhs ), 1 )
444 b( j, jcol ) = cmplx( rwork( jcol+k ),
445 $ rwork( jcol+k+nrhs ) )
447 CALL clascl(
'G', 0, 0, temp, one, 1, nrhs, b( j, 1 ),
454 IF( k.LT.max( m, n ) )
455 $
CALL clacpy(
'A', n-k, nrhs, bx( k+1, 1 ), ldbx,
465 CALL ccopy( 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 ) / ( slamc3( 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 ) / ( slamc3( dsigj,
496 $ 2 ) )-difl( i ) ) /
497 $ ( dsigj+poles( i, 1 ) ) / difr( i, 2 )
508 DO 140 jcol = 1, nrhs
511 rwork( i ) = real( b( jrow, jcol ) )
514 CALL sgemv(
'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 ) = aimag( b( jrow, jcol ) )
523 CALL sgemv(
'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 ) = cmplx( rwork( jcol+k ),
527 $ rwork( jcol+k+nrhs ) )
536 CALL ccopy( nrhs, b( m, 1 ), ldb, bx( m, 1 ), ldbx )
537 CALL csrot( nrhs, bx( 1, 1 ), ldbx, bx( m, 1 ), ldbx, c,
540 IF( k.LT.max( m, n ) )
541 $
CALL clacpy(
'A', n-k, nrhs, b( k+1, 1 ), ldb,
542 $ bx( k+1, 1 ), ldbx )
546 CALL ccopy( nrhs, bx( 1, 1 ), ldbx, b( nlp1, 1 ), ldb )
548 CALL ccopy( nrhs, bx( m, 1 ), ldbx, b( m, 1 ), ldb )
551 CALL ccopy( nrhs, bx( i, 1 ), ldbx, b( perm( i ), 1 ),
557 DO 200 i = givptr, 1, -1
558 CALL csrot( nrhs, b( givcol( i, 2 ), 1 ), ldb,
559 $ b( givcol( i, 1 ), 1 ), ldb, givnum( i, 2 ),