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