001:       SUBROUTINE CLAQHB( UPLO, N, KD, AB, LDAB, S, SCOND, AMAX, EQUED )
002: *
003: *  -- LAPACK auxiliary routine (version 3.2) --
004: *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
005: *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
006: *     November 2006
007: *
008: *     .. Scalar Arguments ..
009:       CHARACTER          EQUED, UPLO
010:       INTEGER            KD, LDAB, N
011:       REAL               AMAX, SCOND
012: *     ..
013: *     .. Array Arguments ..
014:       REAL               S( * )
015:       COMPLEX            AB( LDAB, * )
016: *     ..
017: *
018: *  Purpose
019: *  =======
020: *
021: *  CLAQHB equilibrates an Hermitian band matrix A using the scaling
022: *  factors in the vector S.
023: *
024: *  Arguments
025: *  =========
026: *
027: *  UPLO    (input) CHARACTER*1
028: *          Specifies whether the upper or lower triangular part of the
029: *          symmetric matrix A is stored.
030: *          = 'U':  Upper triangular
031: *          = 'L':  Lower triangular
032: *
033: *  N       (input) INTEGER
034: *          The order of the matrix A.  N >= 0.
035: *
036: *  KD      (input) INTEGER
037: *          The number of super-diagonals of the matrix A if UPLO = 'U',
038: *          or the number of sub-diagonals if UPLO = 'L'.  KD >= 0.
039: *
040: *  AB      (input/output) COMPLEX array, dimension (LDAB,N)
041: *          On entry, the upper or lower triangle of the symmetric band
042: *          matrix A, stored in the first KD+1 rows of the array.  The
043: *          j-th column of A is stored in the j-th column of the array AB
044: *          as follows:
045: *          if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j;
046: *          if UPLO = 'L', AB(1+i-j,j)    = A(i,j) for j<=i<=min(n,j+kd).
047: *
048: *          On exit, if INFO = 0, the triangular factor U or L from the
049: *          Cholesky factorization A = U'*U or A = L*L' of the band
050: *          matrix A, in the same storage format as A.
051: *
052: *  LDAB    (input) INTEGER
053: *          The leading dimension of the array AB.  LDAB >= KD+1.
054: *
055: *  S       (output) REAL array, dimension (N)
056: *          The scale factors for A.
057: *
058: *  SCOND   (input) REAL
059: *          Ratio of the smallest S(i) to the largest S(i).
060: *
061: *  AMAX    (input) REAL
062: *          Absolute value of largest matrix entry.
063: *
064: *  EQUED   (output) CHARACTER*1
065: *          Specifies whether or not equilibration was done.
066: *          = 'N':  No equilibration.
067: *          = 'Y':  Equilibration was done, i.e., A has been replaced by
068: *                  diag(S) * A * diag(S).
069: *
070: *  Internal Parameters
071: *  ===================
072: *
073: *  THRESH is a threshold value used to decide if scaling should be done
074: *  based on the ratio of the scaling factors.  If SCOND < THRESH,
075: *  scaling is done.
076: *
077: *  LARGE and SMALL are threshold values used to decide if scaling should
078: *  be done based on the absolute size of the largest matrix element.
079: *  If AMAX > LARGE or AMAX < SMALL, scaling is done.
080: *
081: *  =====================================================================
082: *
083: *     .. Parameters ..
084:       REAL               ONE, THRESH
085:       PARAMETER          ( ONE = 1.0E+0, THRESH = 0.1E+0 )
086: *     ..
087: *     .. Local Scalars ..
088:       INTEGER            I, J
089:       REAL               CJ, LARGE, SMALL
090: *     ..
091: *     .. External Functions ..
092:       LOGICAL            LSAME
093:       REAL               SLAMCH
094:       EXTERNAL           LSAME, SLAMCH
095: *     ..
096: *     .. Intrinsic Functions ..
097:       INTRINSIC          MAX, MIN, REAL
098: *     ..
099: *     .. Executable Statements ..
100: *
101: *     Quick return if possible
102: *
103:       IF( N.LE.0 ) THEN
104:          EQUED = 'N'
105:          RETURN
106:       END IF
107: *
108: *     Initialize LARGE and SMALL.
109: *
110:       SMALL = SLAMCH( 'Safe minimum' ) / SLAMCH( 'Precision' )
111:       LARGE = ONE / SMALL
112: *
113:       IF( SCOND.GE.THRESH .AND. AMAX.GE.SMALL .AND. AMAX.LE.LARGE ) THEN
114: *
115: *        No equilibration
116: *
117:          EQUED = 'N'
118:       ELSE
119: *
120: *        Replace A by diag(S) * A * diag(S).
121: *
122:          IF( LSAME( UPLO, 'U' ) ) THEN
123: *
124: *           Upper triangle of A is stored in band format.
125: *
126:             DO 20 J = 1, N
127:                CJ = S( J )
128:                DO 10 I = MAX( 1, J-KD ), J - 1
129:                   AB( KD+1+I-J, J ) = CJ*S( I )*AB( KD+1+I-J, J )
130:    10          CONTINUE
131:                AB( KD+1, J ) = CJ*CJ*REAL( AB( KD+1, J ) )
132:    20       CONTINUE
133:          ELSE
134: *
135: *           Lower triangle of A is stored.
136: *
137:             DO 40 J = 1, N
138:                CJ = S( J )
139:                AB( 1, J ) = CJ*CJ*REAL( AB( 1, J ) )
140:                DO 30 I = J + 1, MIN( N, J+KD )
141:                   AB( 1+I-J, J ) = CJ*S( I )*AB( 1+I-J, J )
142:    30          CONTINUE
143:    40       CONTINUE
144:          END IF
145:          EQUED = 'Y'
146:       END IF
147: *
148:       RETURN
149: *
150: *     End of CLAQHB
151: *
152:       END
153: