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