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