228 SUBROUTINE clatrs3( UPLO, TRANS, DIAG, NORMIN, N, NRHS, A, LDA,
229 $ X, LDX, SCALE, CNORM, WORK, LWORK, INFO )
233 CHARACTER DIAG, TRANS, NORMIN, UPLO
234 INTEGER INFO, LDA, LWORK, LDX, N, NRHS
237 COMPLEX A( LDA, * ), X( LDX, * )
238 REAL CNORM( * ), SCALE( * ), WORK( * )
245 parameter( zero = 0.0e+0, one = 1.0e+0 )
247 parameter( czero = ( 0.0e+0, 0.0e+0 ) )
248 parameter( cone = ( 1.0e+0, 0.0e+0 ) )
249 INTEGER NBMAX, NBMIN, NBRHS, NRHSMIN
250 parameter( nrhsmin = 2, nbrhs = 32 )
251 parameter( nbmin = 8, nbmax = 64 )
254 REAL W( NBMAX ), XNRM( NBRHS )
257 LOGICAL LQUERY, NOTRAN, NOUNIT, UPPER
258 INTEGER AWRK, I, IFIRST, IINC, ILAST, II, I1, I2, J,
259 $ jfirst, jinc, jlast, j1, j2, k, kk, k1, k2,
260 $ lanrm, lds, lscale, nb, nba, nbx, rhs
261 REAL ANRM, BIGNUM, BNRM, RSCAL, SCAL, SCALOC,
262 $ scamin, smlnum, tmax
267 REAL SLAMCH, CLANGE, SLARMM
268 EXTERNAL ilaenv, lsame, slamch, clange, slarmm
274 INTRINSIC abs, max, min
279 upper = lsame( uplo,
'U' )
280 notran = lsame( trans,
'N' )
281 nounit = lsame( diag,
'N' )
282 lquery = ( lwork.EQ.-1 )
286 nb = max( nbmin, ilaenv( 1,
'CLATRS',
'', n, n, -1, -1 ) )
287 nb = min( nbmax, nb )
288 nba = max( 1, (n + nb - 1) / nb )
289 nbx = max( 1, (nrhs + nbrhs - 1) / nbrhs )
299 lscale = nba * max( nba, min( nrhs, nbrhs ) )
307 work( 1 ) = lscale + lanrm
311 IF( .NOT.upper .AND. .NOT.lsame( uplo,
'L' ) )
THEN
313 ELSE IF( .NOT.notran .AND. .NOT.lsame( trans,
'T' ) .AND. .NOT.
314 $ lsame( trans,
'C' ) )
THEN
316 ELSE IF( .NOT.nounit .AND. .NOT.lsame( diag,
'U' ) )
THEN
318 ELSE IF( .NOT.lsame( normin,
'Y' ) .AND. .NOT.
319 $ lsame( normin,
'N' ) )
THEN
321 ELSE IF( n.LT.0 )
THEN
323 ELSE IF( nrhs.LT.0 )
THEN
325 ELSE IF( lda.LT.max( 1, n ) )
THEN
327 ELSE IF( ldx.LT.max( 1, n ) )
THEN
329 ELSE IF( .NOT.lquery .AND. lwork.LT.work( 1 ) )
THEN
333 CALL xerbla(
'CLATRS3', -info )
335 ELSE IF( lquery )
THEN
347 IF( min( n, nrhs ).EQ.0 )
352 bignum = slamch(
'Overflow' )
353 smlnum = slamch(
'Safe Minimum' )
357 IF( nrhs.LT.nrhsmin )
THEN
358 CALL clatrs( uplo, trans, diag, normin, n, a, lda, x( 1, 1 ),
359 $ scale( 1 ), cnorm, info )
361 CALL clatrs( uplo, trans, diag,
'Y', n, a, lda, x( 1, k ),
362 $ scale( k ), cnorm, info )
373 j2 = min( j*nb, n ) + 1
383 i2 = min( i*nb, n ) + 1
388 anrm = clange(
'I', i2-i1, j2-j1, a( i1, j1 ), lda, w )
389 work( awrk + i+(j-1)*nba ) = anrm
391 anrm = clange(
'1', i2-i1, j2-j1, a( i1, j1 ), lda, w )
392 work( awrk + j+(i-1)*nba ) = anrm
394 tmax = max( tmax, anrm )
398 IF( .NOT. tmax.LE.slamch(
'Overflow') )
THEN
408 CALL clatrs( uplo, trans, diag,
'N', n, a, lda, x( 1, k ),
409 $ scale( k ), cnorm, info )
425 k2 = min( k*nbrhs, nrhs ) + 1
431 work( i+kk*lds ) = one
464 DO j = jfirst, jlast, jinc
469 j2 = min( j*nb, n ) + 1
476 CALL clatrs( uplo, trans, diag,
'N', j2-j1,
477 $ a( j1, j1 ), lda, x( j1, rhs ),
478 $ scaloc, cnorm, info )
480 CALL clatrs( uplo, trans, diag,
'Y', j2-j1,
481 $ a( j1, j1 ), lda, x( j1, rhs ),
482 $ scaloc, cnorm, info )
487 xnrm( kk ) = clange(
'I', j2-j1, 1, x( j1, rhs ),
490 IF( scaloc .EQ. zero )
THEN
504 work( ii+kk*lds ) = one
507 ELSE IF( scaloc*work( j+kk*lds ) .EQ. zero )
THEN
514 scal = work( j+kk*lds ) / smlnum
515 scaloc = scaloc * scal
516 work( j+kk*lds ) = smlnum
521 IF( xnrm( kk )*rscal .LE. bignum )
THEN
522 xnrm( kk ) = xnrm( kk ) * rscal
523 CALL csscal( j2-j1, rscal, x( j1, rhs ), 1 )
537 work( ii+kk*lds ) = one
542 scaloc = scaloc * work( j+kk*lds )
543 work( j+kk*lds ) = scaloc
570 DO i = ifirst, ilast, iinc
575 i2 = min( i*nb, n ) + 1
586 scamin = min( work( i+kk*lds), work( j+kk*lds ) )
591 bnrm = clange(
'I', i2-i1, 1, x( i1, rhs ), ldx, w )
592 bnrm = bnrm*( scamin / work( i+kk*lds ) )
593 xnrm( kk ) = xnrm( kk )*( scamin / work( j+kk*lds) )
594 anrm = work( awrk + i+(j-1)*nba )
595 scaloc = slarmm( anrm, xnrm( kk ), bnrm )
600 scal = ( scamin / work( i+kk*lds) )*scaloc
601 IF( scal.NE.one )
THEN
602 CALL csscal( i2-i1, scal, x( i1, rhs ), 1 )
603 work( i+kk*lds ) = scamin*scaloc
606 scal = ( scamin / work( j+kk*lds ) )*scaloc
607 IF( scal.NE.one )
THEN
608 CALL csscal( j2-j1, scal, x( j1, rhs ), 1 )
609 work( j+kk*lds ) = scamin*scaloc
617 CALL cgemm(
'N',
'N', i2-i1, k2-k1, j2-j1, -cone,
618 $ a( i1, j1 ), lda, x( j1, k1 ), ldx,
619 $ cone, x( i1, k1 ), ldx )
620 ELSE IF( lsame( trans,
'T' ) )
THEN
624 CALL cgemm(
'T',
'N', i2-i1, k2-k1, j2-j1, -cone,
625 $ a( j1, i1 ), lda, x( j1, k1 ), ldx,
626 $ cone, x( i1, k1 ), ldx )
631 CALL cgemm(
'C',
'N', i2-i1, k2-k1, j2-j1, -cone,
632 $ a( j1, i1 ), lda, x( j1, k1 ), ldx,
633 $ cone, x( i1, k1 ), ldx )
643 scale( rhs ) = min( scale( rhs ), work( i+kk*lds ) )
651 IF( scale( rhs ).NE.one .AND. scale( rhs ).NE. zero )
THEN
654 i2 = min( i*nb, n ) + 1
655 scal = scale( rhs ) / work( i+kk*lds )
657 $
CALL csscal( i2-i1, scal, x( i1, rhs ), 1 )
subroutine xerbla(srname, info)
subroutine cgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
CGEMM
subroutine clatrs3(uplo, trans, diag, normin, n, nrhs, a, lda, x, ldx, scale, cnorm, work, lwork, info)
CLATRS3 solves a triangular system of equations with the scale factors set to prevent overflow.
subroutine clatrs(uplo, trans, diag, normin, n, a, lda, x, scale, cnorm, info)
CLATRS solves a triangular system of equations with the scale factor set to prevent overflow.
subroutine csscal(n, sa, cx, incx)
CSSCAL