269 SUBROUTINE clals0( ICOMPQ, NL, NR, SQRE, NRHS, B, LDB, BX, LDBX,
270 $ perm, givptr, givcol, ldgcol, givnum, ldgnum,
271 $ poles, difl, difr, z, k, c, s, rwork, info )
279 INTEGER GIVPTR, ICOMPQ, INFO, K, LDB, LDBX, LDGCOL,
280 $ ldgnum, nl, nr, nrhs, sqre
284 INTEGER GIVCOL( ldgcol, * ), PERM( * )
285 REAL DIFL( * ), DIFR( ldgnum, * ),
286 $ givnum( ldgnum, * ), poles( ldgnum, * ),
288 COMPLEX B( ldb, * ), BX( ldbx, * )
294 REAL ONE, ZERO, NEGONE
295 parameter ( one = 1.0e0, zero = 0.0e0, negone = -1.0e0 )
298 INTEGER I, J, JCOL, JROW, M, N, NLP1
299 REAL DIFLJ, DIFRJ, DJ, DSIGJ, DSIGJP, TEMP
307 EXTERNAL slamc3, snrm2
310 INTRINSIC aimag, cmplx, max, real
319 IF( ( icompq.LT.0 ) .OR. ( icompq.GT.1 ) )
THEN
321 ELSE IF( nl.LT.1 )
THEN
323 ELSE IF( nr.LT.1 )
THEN
325 ELSE IF( ( sqre.LT.0 ) .OR. ( sqre.GT.1 ) )
THEN
327 ELSE IF( nrhs.LT.1 )
THEN
329 ELSE IF( ldb.LT.n )
THEN
331 ELSE IF( ldbx.LT.n )
THEN
333 ELSE IF( givptr.LT.0 )
THEN
335 ELSE IF( ldgcol.LT.n )
THEN
337 ELSE IF( ldgnum.LT.n )
THEN
339 ELSE IF( k.LT.1 )
THEN
343 CALL xerbla(
'CLALS0', -info )
350 IF( icompq.EQ.0 )
THEN
357 CALL csrot( nrhs, b( givcol( i, 2 ), 1 ), ldb,
358 $ b( givcol( i, 1 ), 1 ), ldb, givnum( i, 2 ),
364 CALL ccopy( nrhs, b( nlp1, 1 ), ldb, bx( 1, 1 ), ldbx )
366 CALL ccopy( nrhs, b( perm( i ), 1 ), ldb, bx( i, 1 ), ldbx )
373 CALL ccopy( nrhs, bx, ldbx, b, ldb )
374 IF( z( 1 ).LT.zero )
THEN
375 CALL csscal( nrhs, negone, b, ldb )
381 dsigj = -poles( j, 2 )
383 difrj = -difr( j, 1 )
384 dsigjp = -poles( j+1, 2 )
386 IF( ( z( j ).EQ.zero ) .OR. ( poles( j, 2 ).EQ.zero ) )
390 rwork( j ) = -poles( j, 2 )*z( j ) / diflj /
391 $ ( poles( j, 2 )+dj )
394 IF( ( z( i ).EQ.zero ) .OR.
395 $ ( poles( i, 2 ).EQ.zero ) )
THEN
398 rwork( i ) = poles( i, 2 )*z( i ) /
399 $ ( slamc3( poles( i, 2 ), dsigj )-
400 $ diflj ) / ( poles( i, 2 )+dj )
404 IF( ( z( i ).EQ.zero ) .OR.
405 $ ( poles( i, 2 ).EQ.zero ) )
THEN
408 rwork( i ) = poles( i, 2 )*z( i ) /
409 $ ( slamc3( poles( i, 2 ), dsigjp )+
410 $ difrj ) / ( poles( i, 2 )+dj )
414 temp = snrm2( k, rwork, 1 )
426 rwork( i ) =
REAL( BX( JROW, JCOL ) )
429 CALL sgemv(
'T', k, nrhs, one, rwork( 1+k+nrhs*2 ), k,
430 $ rwork( 1 ), 1, zero, rwork( 1+k ), 1 )
435 rwork( i ) = aimag( bx( jrow, jcol ) )
438 CALL sgemv(
'T', k, nrhs, one, rwork( 1+k+nrhs*2 ), k,
439 $ rwork( 1 ), 1, zero, rwork( 1+k+nrhs ), 1 )
441 b( j, jcol ) = cmplx( rwork( jcol+k ),
442 $ rwork( jcol+k+nrhs ) )
444 CALL clascl(
'G', 0, 0, temp, one, 1, nrhs, b( j, 1 ),
451 IF( k.LT.max( m, n ) )
452 $
CALL clacpy(
'A', n-k, nrhs, bx( k+1, 1 ), ldbx,
462 CALL ccopy( nrhs, b, ldb, bx, ldbx )
465 dsigj = poles( j, 2 )
466 IF( z( j ).EQ.zero )
THEN
469 rwork( j ) = -z( j ) / difl( j ) /
470 $ ( dsigj+poles( j, 1 ) ) / difr( j, 2 )
473 IF( z( j ).EQ.zero )
THEN
476 rwork( i ) = z( j ) / ( slamc3( dsigj, -poles( i+1,
477 $ 2 ) )-difr( i, 1 ) ) /
478 $ ( dsigj+poles( i, 1 ) ) / difr( i, 2 )
482 IF( z( j ).EQ.zero )
THEN
485 rwork( i ) = z( j ) / ( slamc3( dsigj, -poles( i,
486 $ 2 ) )-difl( i ) ) /
487 $ ( dsigj+poles( i, 1 ) ) / difr( i, 2 )
498 DO 140 jcol = 1, nrhs
501 rwork( i ) =
REAL( B( JROW, JCOL ) )
504 CALL sgemv(
'T', k, nrhs, one, rwork( 1+k+nrhs*2 ), k,
505 $ rwork( 1 ), 1, zero, rwork( 1+k ), 1 )
507 DO 160 jcol = 1, nrhs
510 rwork( i ) = aimag( b( jrow, jcol ) )
513 CALL sgemv(
'T', k, nrhs, one, rwork( 1+k+nrhs*2 ), k,
514 $ rwork( 1 ), 1, zero, rwork( 1+k+nrhs ), 1 )
515 DO 170 jcol = 1, nrhs
516 bx( j, jcol ) = cmplx( rwork( jcol+k ),
517 $ rwork( jcol+k+nrhs ) )
526 CALL ccopy( nrhs, b( m, 1 ), ldb, bx( m, 1 ), ldbx )
527 CALL csrot( nrhs, bx( 1, 1 ), ldbx, bx( m, 1 ), ldbx, c, s )
529 IF( k.LT.max( m, n ) )
530 $
CALL clacpy(
'A', n-k, nrhs, b( k+1, 1 ), ldb,
531 $ bx( k+1, 1 ), ldbx )
535 CALL ccopy( nrhs, bx( 1, 1 ), ldbx, b( nlp1, 1 ), ldb )
537 CALL ccopy( nrhs, bx( m, 1 ), ldbx, b( m, 1 ), ldb )
540 CALL ccopy( nrhs, bx( i, 1 ), ldbx, b( perm( i ), 1 ), ldb )
545 DO 200 i = givptr, 1, -1
546 CALL csrot( nrhs, b( givcol( i, 2 ), 1 ), ldb,
547 $ b( givcol( i, 1 ), 1 ), ldb, givnum( i, 2 ),
subroutine clascl(TYPE, KL, KU, CFROM, CTO, M, N, A, LDA, INFO)
CLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
subroutine xerbla(SRNAME, INFO)
XERBLA
subroutine sgemv(TRANS, M, N, ALPHA, A, LDA, X, INCX, BETA, Y, INCY)
SGEMV
subroutine clals0(ICOMPQ, NL, NR, SQRE, NRHS, B, LDB, BX, LDBX, PERM, GIVPTR, GIVCOL, LDGCOL, GIVNUM, LDGNUM, POLES, DIFL, DIFR, Z, K, C, S, RWORK, INFO)
CLALS0 applies back multiplying factors in solving the least squares problem using divide and conquer...
subroutine clacpy(UPLO, M, N, A, LDA, B, LDB)
CLACPY copies all or part of one two-dimensional array to another.
subroutine csrot(N, CX, INCX, CY, INCY, C, S)
CSROT
subroutine ccopy(N, CX, INCX, CY, INCY)
CCOPY
subroutine csscal(N, SA, CX, INCX)
CSSCAL