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