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