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