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