001:       DOUBLE PRECISION FUNCTION ZLANHP( NORM, UPLO, N, AP, WORK )
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          NORM, UPLO
010:       INTEGER            N
011: *     ..
012: *     .. Array Arguments ..
013:       DOUBLE PRECISION   WORK( * )
014:       COMPLEX*16         AP( * )
015: *     ..
016: *
017: *  Purpose
018: *  =======
019: *
020: *  ZLANHP  returns the value of the one norm,  or the Frobenius norm, or
021: *  the  infinity norm,  or the  element of  largest absolute value  of a
022: *  complex hermitian matrix A,  supplied in packed form.
023: *
024: *  Description
025: *  ===========
026: *
027: *  ZLANHP returns the value
028: *
029: *     ZLANHP = ( max(abs(A(i,j))), NORM = 'M' or 'm'
030: *              (
031: *              ( norm1(A),         NORM = '1', 'O' or 'o'
032: *              (
033: *              ( normI(A),         NORM = 'I' or 'i'
034: *              (
035: *              ( normF(A),         NORM = 'F', 'f', 'E' or 'e'
036: *
037: *  where  norm1  denotes the  one norm of a matrix (maximum column sum),
038: *  normI  denotes the  infinity norm  of a matrix  (maximum row sum) and
039: *  normF  denotes the  Frobenius norm of a matrix (square root of sum of
040: *  squares).  Note that  max(abs(A(i,j)))  is not a consistent matrix norm.
041: *
042: *  Arguments
043: *  =========
044: *
045: *  NORM    (input) CHARACTER*1
046: *          Specifies the value to be returned in ZLANHP as described
047: *          above.
048: *
049: *  UPLO    (input) CHARACTER*1
050: *          Specifies whether the upper or lower triangular part of the
051: *          hermitian matrix A is supplied.
052: *          = 'U':  Upper triangular part of A is supplied
053: *          = 'L':  Lower triangular part of A is supplied
054: *
055: *  N       (input) INTEGER
056: *          The order of the matrix A.  N >= 0.  When N = 0, ZLANHP is
057: *          set to zero.
058: *
059: *  AP      (input) COMPLEX*16 array, dimension (N*(N+1)/2)
060: *          The upper or lower triangle of the hermitian matrix A, packed
061: *          columnwise in a linear array.  The j-th column of A is stored
062: *          in the array AP as follows:
063: *          if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
064: *          if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n.
065: *          Note that the  imaginary parts of the diagonal elements need
066: *          not be set and are assumed to be zero.
067: *
068: *  WORK    (workspace) DOUBLE PRECISION array, dimension (MAX(1,LWORK)),
069: *          where LWORK >= N when NORM = 'I' or '1' or 'O'; otherwise,
070: *          WORK is not referenced.
071: *
072: * =====================================================================
073: *
074: *     .. Parameters ..
075:       DOUBLE PRECISION   ONE, ZERO
076:       PARAMETER          ( ONE = 1.0D+0, ZERO = 0.0D+0 )
077: *     ..
078: *     .. Local Scalars ..
079:       INTEGER            I, J, K
080:       DOUBLE PRECISION   ABSA, SCALE, SUM, VALUE
081: *     ..
082: *     .. External Functions ..
083:       LOGICAL            LSAME
084:       EXTERNAL           LSAME
085: *     ..
086: *     .. External Subroutines ..
087:       EXTERNAL           ZLASSQ
088: *     ..
089: *     .. Intrinsic Functions ..
090:       INTRINSIC          ABS, DBLE, MAX, SQRT
091: *     ..
092: *     .. Executable Statements ..
093: *
094:       IF( N.EQ.0 ) THEN
095:          VALUE = ZERO
096:       ELSE IF( LSAME( NORM, 'M' ) ) THEN
097: *
098: *        Find max(abs(A(i,j))).
099: *
100:          VALUE = ZERO
101:          IF( LSAME( UPLO, 'U' ) ) THEN
102:             K = 0
103:             DO 20 J = 1, N
104:                DO 10 I = K + 1, K + J - 1
105:                   VALUE = MAX( VALUE, ABS( AP( I ) ) )
106:    10          CONTINUE
107:                K = K + J
108:                VALUE = MAX( VALUE, ABS( DBLE( AP( K ) ) ) )
109:    20       CONTINUE
110:          ELSE
111:             K = 1
112:             DO 40 J = 1, N
113:                VALUE = MAX( VALUE, ABS( DBLE( AP( K ) ) ) )
114:                DO 30 I = K + 1, K + N - J
115:                   VALUE = MAX( VALUE, ABS( AP( I ) ) )
116:    30          CONTINUE
117:                K = K + N - J + 1
118:    40       CONTINUE
119:          END IF
120:       ELSE IF( ( LSAME( NORM, 'I' ) ) .OR. ( LSAME( NORM, 'O' ) ) .OR.
121:      $         ( NORM.EQ.'1' ) ) THEN
122: *
123: *        Find normI(A) ( = norm1(A), since A is hermitian).
124: *
125:          VALUE = ZERO
126:          K = 1
127:          IF( LSAME( UPLO, 'U' ) ) THEN
128:             DO 60 J = 1, N
129:                SUM = ZERO
130:                DO 50 I = 1, J - 1
131:                   ABSA = ABS( AP( K ) )
132:                   SUM = SUM + ABSA
133:                   WORK( I ) = WORK( I ) + ABSA
134:                   K = K + 1
135:    50          CONTINUE
136:                WORK( J ) = SUM + ABS( DBLE( AP( K ) ) )
137:                K = K + 1
138:    60       CONTINUE
139:             DO 70 I = 1, N
140:                VALUE = MAX( VALUE, WORK( I ) )
141:    70       CONTINUE
142:          ELSE
143:             DO 80 I = 1, N
144:                WORK( I ) = ZERO
145:    80       CONTINUE
146:             DO 100 J = 1, N
147:                SUM = WORK( J ) + ABS( DBLE( AP( K ) ) )
148:                K = K + 1
149:                DO 90 I = J + 1, N
150:                   ABSA = ABS( AP( K ) )
151:                   SUM = SUM + ABSA
152:                   WORK( I ) = WORK( I ) + ABSA
153:                   K = K + 1
154:    90          CONTINUE
155:                VALUE = MAX( VALUE, SUM )
156:   100       CONTINUE
157:          END IF
158:       ELSE IF( ( LSAME( NORM, 'F' ) ) .OR. ( LSAME( NORM, 'E' ) ) ) THEN
159: *
160: *        Find normF(A).
161: *
162:          SCALE = ZERO
163:          SUM = ONE
164:          K = 2
165:          IF( LSAME( UPLO, 'U' ) ) THEN
166:             DO 110 J = 2, N
167:                CALL ZLASSQ( J-1, AP( K ), 1, SCALE, SUM )
168:                K = K + J
169:   110       CONTINUE
170:          ELSE
171:             DO 120 J = 1, N - 1
172:                CALL ZLASSQ( N-J, AP( K ), 1, SCALE, SUM )
173:                K = K + N - J + 1
174:   120       CONTINUE
175:          END IF
176:          SUM = 2*SUM
177:          K = 1
178:          DO 130 I = 1, N
179:             IF( DBLE( AP( K ) ).NE.ZERO ) THEN
180:                ABSA = ABS( DBLE( AP( K ) ) )
181:                IF( SCALE.LT.ABSA ) THEN
182:                   SUM = ONE + SUM*( SCALE / ABSA )**2
183:                   SCALE = ABSA
184:                ELSE
185:                   SUM = SUM + ( ABSA / SCALE )**2
186:                END IF
187:             END IF
188:             IF( LSAME( UPLO, 'U' ) ) THEN
189:                K = K + I + 1
190:             ELSE
191:                K = K + N - I + 1
192:             END IF
193:   130    CONTINUE
194:          VALUE = SCALE*SQRT( SUM )
195:       END IF
196: *
197:       ZLANHP = VALUE
198:       RETURN
199: *
200: *     End of ZLANHP
201: *
202:       END
203: