001:       SUBROUTINE SLAQSY( UPLO, N, A, LDA, 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            LDA, N
011:       REAL               AMAX, SCOND
012: *     ..
013: *     .. Array Arguments ..
014:       REAL               A( LDA, * ), S( * )
015: *     ..
016: *
017: *  Purpose
018: *  =======
019: *
020: *  SLAQSY equilibrates a symmetric matrix A using the scaling factors
021: *  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: *  A       (input/output) REAL array, dimension (LDA,N)
036: *          On entry, the symmetric matrix A.  If UPLO = 'U', the leading
037: *          n by n upper triangular part of A contains the upper
038: *          triangular part of the matrix A, and the strictly lower
039: *          triangular part of A is not referenced.  If UPLO = 'L', the
040: *          leading n by n lower triangular part of A contains the lower
041: *          triangular part of the matrix A, and the strictly upper
042: *          triangular part of A is not referenced.
043: *
044: *          On exit, if EQUED = 'Y', the equilibrated matrix:
045: *          diag(S) * A * diag(S).
046: *
047: *  LDA     (input) INTEGER
048: *          The leading dimension of the array A.  LDA >= max(N,1).
049: *
050: *  S       (input) REAL array, dimension (N)
051: *          The scale factors for A.
052: *
053: *  SCOND   (input) REAL
054: *          Ratio of the smallest S(i) to the largest S(i).
055: *
056: *  AMAX    (input) REAL
057: *          Absolute value of largest matrix entry.
058: *
059: *  EQUED   (output) CHARACTER*1
060: *          Specifies whether or not equilibration was done.
061: *          = 'N':  No equilibration.
062: *          = 'Y':  Equilibration was done, i.e., A has been replaced by
063: *                  diag(S) * A * diag(S).
064: *
065: *  Internal Parameters
066: *  ===================
067: *
068: *  THRESH is a threshold value used to decide if scaling should be done
069: *  based on the ratio of the scaling factors.  If SCOND < THRESH,
070: *  scaling is done.
071: *
072: *  LARGE and SMALL are threshold values used to decide if scaling should
073: *  be done based on the absolute size of the largest matrix element.
074: *  If AMAX > LARGE or AMAX < SMALL, scaling is done.
075: *
076: *  =====================================================================
077: *
078: *     .. Parameters ..
079:       REAL               ONE, THRESH
080:       PARAMETER          ( ONE = 1.0E+0, THRESH = 0.1E+0 )
081: *     ..
082: *     .. Local Scalars ..
083:       INTEGER            I, J
084:       REAL               CJ, LARGE, SMALL
085: *     ..
086: *     .. External Functions ..
087:       LOGICAL            LSAME
088:       REAL               SLAMCH
089:       EXTERNAL           LSAME, SLAMCH
090: *     ..
091: *     .. Executable Statements ..
092: *
093: *     Quick return if possible
094: *
095:       IF( N.LE.0 ) THEN
096:          EQUED = 'N'
097:          RETURN
098:       END IF
099: *
100: *     Initialize LARGE and SMALL.
101: *
102:       SMALL = SLAMCH( 'Safe minimum' ) / SLAMCH( 'Precision' )
103:       LARGE = ONE / SMALL
104: *
105:       IF( SCOND.GE.THRESH .AND. AMAX.GE.SMALL .AND. AMAX.LE.LARGE ) THEN
106: *
107: *        No equilibration
108: *
109:          EQUED = 'N'
110:       ELSE
111: *
112: *        Replace A by diag(S) * A * diag(S).
113: *
114:          IF( LSAME( UPLO, 'U' ) ) THEN
115: *
116: *           Upper triangle of A is stored.
117: *
118:             DO 20 J = 1, N
119:                CJ = S( J )
120:                DO 10 I = 1, J
121:                   A( I, J ) = CJ*S( I )*A( I, J )
122:    10          CONTINUE
123:    20       CONTINUE
124:          ELSE
125: *
126: *           Lower triangle of A is stored.
127: *
128:             DO 40 J = 1, N
129:                CJ = S( J )
130:                DO 30 I = J, N
131:                   A( I, J ) = CJ*S( I )*A( I, J )
132:    30          CONTINUE
133:    40       CONTINUE
134:          END IF
135:          EQUED = 'Y'
136:       END IF
137: *
138:       RETURN
139: *
140: *     End of SLAQSY
141: *
142:       END
143: