KTH framework for Nek5000 toolboxes; testing version  0.0.1
dlange.f
Go to the documentation of this file.
1  DOUBLE PRECISION FUNCTION dlange( NORM, M, N, A, LDA, WORK )
2 *
3 * -- LAPACK auxiliary routine (version 3.0) --
4 * Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
5 * Courant Institute, Argonne National Lab, and Rice University
6 * October 31, 1992
7 *
8 * .. Scalar Arguments ..
9  CHARACTER norm
10  INTEGER lda, m, n
11 * ..
12 * .. Array Arguments ..
13  DOUBLE PRECISION a( lda, * ), work( * )
14 * ..
15 *
16 * Purpose
17 * =======
18 *
19 * DLANGE returns the value of the one norm, or the Frobenius norm, or
20 * the infinity norm, or the element of largest absolute value of a
21 * real matrix A.
22 *
23 * Description
24 * ===========
25 *
26 * DLANGE returns the value
27 *
28 * DLANGE = ( max(abs(A(i,j))), NORM = 'M' or 'm'
29 * (
30 * ( norm1(A), NORM = '1', 'O' or 'o'
31 * (
32 * ( normI(A), NORM = 'I' or 'i'
33 * (
34 * ( normF(A), NORM = 'F', 'f', 'E' or 'e'
35 *
36 * where norm1 denotes the one norm of a matrix (maximum column sum),
37 * normI denotes the infinity norm of a matrix (maximum row sum) and
38 * normF denotes the Frobenius norm of a matrix (square root of sum of
39 * squares). Note that max(abs(A(i,j))) is not a matrix norm.
40 *
41 * Arguments
42 * =========
43 *
44 * NORM (input) CHARACTER*1
45 * Specifies the value to be returned in DLANGE as described
46 * above.
47 *
48 * M (input) INTEGER
49 * The number of rows of the matrix A. M >= 0. When M = 0,
50 * DLANGE is set to zero.
51 *
52 * N (input) INTEGER
53 * The number of columns of the matrix A. N >= 0. When N = 0,
54 * DLANGE is set to zero.
55 *
56 * A (input) DOUBLE PRECISION array, dimension (LDA,N)
57 * The m by n matrix A.
58 *
59 * LDA (input) INTEGER
60 * The leading dimension of the array A. LDA >= max(M,1).
61 *
62 * WORK (workspace) DOUBLE PRECISION array, dimension (LWORK),
63 * where LWORK >= M when NORM = 'I'; otherwise, WORK is not
64 * referenced.
65 *
66 * =====================================================================
67 *
68 * .. Parameters ..
69  DOUBLE PRECISION one, zero
70  parameter( one = 1.0d+0, zero = 0.0d+0 )
71 * ..
72 * .. Local Scalars ..
73  INTEGER i, j
74  DOUBLE PRECISION scale, sum, value
75 * ..
76 * .. External Subroutines ..
77  EXTERNAL dlassq
78 * ..
79 * .. External Functions ..
80  LOGICAL lsame
81  EXTERNAL lsame
82 * ..
83 * .. Intrinsic Functions ..
84  INTRINSIC abs, max, min, sqrt
85 * ..
86 * .. Executable Statements ..
87 *
88  IF( min( m, n ).EQ.0 ) THEN
89  VALUE = zero
90  ELSE IF( lsame( norm, 'M' ) ) THEN
91 *
92 * Find max(abs(A(i,j))).
93 *
94  VALUE = zero
95  DO 20 j = 1, n
96  DO 10 i = 1, m
97  VALUE = max( VALUE, abs( a( i, j ) ) )
98  10 CONTINUE
99  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
subroutine scale(xyzl, nl)
Definition: connect2.f:602
double precision function dlange(NORM, M, N, A, LDA, WORK)
Definition: dlange.f:2
subroutine dlassq(N, X, INCX, SCALE, SUMSQ)
Definition: dlassq.f:2
logical function lsame(CA, CB)
Definition: lsame.f:2