```001:       DOUBLE PRECISION FUNCTION ZLANHS( NORM, 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
009:       INTEGER            LDA, N
010: *     ..
011: *     .. Array Arguments ..
012:       DOUBLE PRECISION   WORK( * )
013:       COMPLEX*16         A( LDA, * )
014: *     ..
015: *
016: *  Purpose
017: *  =======
018: *
019: *  ZLANHS  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: *  Hessenberg matrix A.
022: *
023: *  Description
024: *  ===========
025: *
026: *  ZLANHS returns the value
027: *
028: *     ZLANHS = ( 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 ZLANHS as described
046: *          above.
047: *
048: *  N       (input) INTEGER
049: *          The order of the matrix A.  N >= 0.  When N = 0, ZLANHS is
050: *          set to zero.
051: *
052: *  A       (input) COMPLEX*16 array, dimension (LDA,N)
053: *          The n by n upper Hessenberg matrix A; the part of A below the
054: *          first sub-diagonal is not referenced.
055: *
056: *  LDA     (input) INTEGER
057: *          The leading dimension of the array A.  LDA >= max(N,1).
058: *
059: *  WORK    (workspace) DOUBLE PRECISION array, dimension (MAX(1,LWORK)),
060: *          where LWORK >= N when NORM = 'I'; otherwise, WORK is not
061: *          referenced.
062: *
063: * =====================================================================
064: *
065: *     .. Parameters ..
066:       DOUBLE PRECISION   ONE, ZERO
067:       PARAMETER          ( ONE = 1.0D+0, ZERO = 0.0D+0 )
068: *     ..
069: *     .. Local Scalars ..
070:       INTEGER            I, J
071:       DOUBLE PRECISION   SCALE, SUM, VALUE
072: *     ..
073: *     .. External Functions ..
074:       LOGICAL            LSAME
075:       EXTERNAL           LSAME
076: *     ..
077: *     .. External Subroutines ..
078:       EXTERNAL           ZLASSQ
079: *     ..
080: *     .. Intrinsic Functions ..
081:       INTRINSIC          ABS, MAX, MIN, SQRT
082: *     ..
083: *     .. Executable Statements ..
084: *
085:       IF( N.EQ.0 ) THEN
086:          VALUE = ZERO
087:       ELSE IF( LSAME( NORM, 'M' ) ) THEN
088: *
089: *        Find max(abs(A(i,j))).
090: *
091:          VALUE = ZERO
092:          DO 20 J = 1, N
093:             DO 10 I = 1, MIN( N, J+1 )
094:                VALUE = MAX( VALUE, ABS( A( I, J ) ) )
095:    10       CONTINUE
096:    20    CONTINUE
097:       ELSE IF( ( LSAME( NORM, 'O' ) ) .OR. ( NORM.EQ.'1' ) ) THEN
098: *
099: *        Find norm1(A).
100: *
101:          VALUE = ZERO
102:          DO 40 J = 1, N
103:             SUM = ZERO
104:             DO 30 I = 1, MIN( N, J+1 )
105:                SUM = SUM + ABS( A( I, J ) )
106:    30       CONTINUE
107:             VALUE = MAX( VALUE, SUM )
108:    40    CONTINUE
109:       ELSE IF( LSAME( NORM, 'I' ) ) THEN
110: *
111: *        Find normI(A).
112: *
113:          DO 50 I = 1, N
114:             WORK( I ) = ZERO
115:    50    CONTINUE
116:          DO 70 J = 1, N
117:             DO 60 I = 1, MIN( N, J+1 )
118:                WORK( I ) = WORK( I ) + ABS( A( I, J ) )
119:    60       CONTINUE
120:    70    CONTINUE
121:          VALUE = ZERO
122:          DO 80 I = 1, N
123:             VALUE = MAX( VALUE, WORK( I ) )
124:    80    CONTINUE
125:       ELSE IF( ( LSAME( NORM, 'F' ) ) .OR. ( LSAME( NORM, 'E' ) ) ) THEN
126: *
127: *        Find normF(A).
128: *
129:          SCALE = ZERO
130:          SUM = ONE
131:          DO 90 J = 1, N
132:             CALL ZLASSQ( MIN( N, J+1 ), A( 1, J ), 1, SCALE, SUM )
133:    90    CONTINUE
134:          VALUE = SCALE*SQRT( SUM )
135:       END IF
136: *
137:       ZLANHS = VALUE
138:       RETURN
139: *
140: *     End of ZLANHS
141: *
142:       END
143: ```