LAPACK  3.10.0
LAPACK: Linear Algebra PACKage
clange.f
Go to the documentation of this file.
1 *> \brief \b CLANGE returns the value of the 1-norm, Frobenius norm, infinity-norm, or the largest absolute value of any element of a general rectangular matrix.
2 *
3 * =========== DOCUMENTATION ===========
4 *
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
7 *
8 *> \htmlonly
9 *> Download CLANGE + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/clange.f">
11 *> [TGZ]</a>
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/clange.f">
13 *> [ZIP]</a>
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/clange.f">
15 *> [TXT]</a>
16 *> \endhtmlonly
17 *
18 * Definition:
19 * ===========
20 *
21 * REAL FUNCTION CLANGE( NORM, M, N, A, LDA, WORK )
22 *
23 * .. Scalar Arguments ..
24 * CHARACTER NORM
25 * INTEGER LDA, M, N
26 * ..
27 * .. Array Arguments ..
28 * REAL WORK( * )
29 * COMPLEX A( LDA, * )
30 * ..
31 *
32 *
33 *> \par Purpose:
34 * =============
35 *>
36 *> \verbatim
37 *>
38 *> CLANGE returns the value of the one norm, or the Frobenius norm, or
39 *> the infinity norm, or the element of largest absolute value of a
40 *> complex matrix A.
41 *> \endverbatim
42 *>
43 *> \return CLANGE
44 *> \verbatim
45 *>
46 *> CLANGE = ( max(abs(A(i,j))), NORM = 'M' or 'm'
47 *> (
48 *> ( norm1(A), NORM = '1', 'O' or 'o'
49 *> (
50 *> ( normI(A), NORM = 'I' or 'i'
51 *> (
52 *> ( normF(A), NORM = 'F', 'f', 'E' or 'e'
53 *>
54 *> where norm1 denotes the one norm of a matrix (maximum column sum),
55 *> normI denotes the infinity norm of a matrix (maximum row sum) and
56 *> normF denotes the Frobenius norm of a matrix (square root of sum of
57 *> squares). Note that max(abs(A(i,j))) is not a consistent matrix norm.
58 *> \endverbatim
59 *
60 * Arguments:
61 * ==========
62 *
63 *> \param[in] NORM
64 *> \verbatim
65 *> NORM is CHARACTER*1
66 *> Specifies the value to be returned in CLANGE as described
67 *> above.
68 *> \endverbatim
69 *>
70 *> \param[in] M
71 *> \verbatim
72 *> M is INTEGER
73 *> The number of rows of the matrix A. M >= 0. When M = 0,
74 *> CLANGE is set to zero.
75 *> \endverbatim
76 *>
77 *> \param[in] N
78 *> \verbatim
79 *> N is INTEGER
80 *> The number of columns of the matrix A. N >= 0. When N = 0,
81 *> CLANGE is set to zero.
82 *> \endverbatim
83 *>
84 *> \param[in] A
85 *> \verbatim
86 *> A is COMPLEX array, dimension (LDA,N)
87 *> The m by n matrix A.
88 *> \endverbatim
89 *>
90 *> \param[in] LDA
91 *> \verbatim
92 *> LDA is INTEGER
93 *> The leading dimension of the array A. LDA >= max(M,1).
94 *> \endverbatim
95 *>
96 *> \param[out] WORK
97 *> \verbatim
98 *> WORK is REAL array, dimension (MAX(1,LWORK)),
99 *> where LWORK >= M when NORM = 'I'; otherwise, WORK is not
100 *> referenced.
101 *> \endverbatim
102 *
103 * Authors:
104 * ========
105 *
106 *> \author Univ. of Tennessee
107 *> \author Univ. of California Berkeley
108 *> \author Univ. of Colorado Denver
109 *> \author NAG Ltd.
110 *
111 *> \ingroup complexGEauxiliary
112 *
113 * =====================================================================
114  REAL function clange( norm, m, n, a, lda, work )
115 *
116 * -- LAPACK auxiliary routine --
117 * -- LAPACK is a software package provided by Univ. of Tennessee, --
118 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
119 *
120  IMPLICIT NONE
121 * .. Scalar Arguments ..
122  CHARACTER norm
123  INTEGER lda, m, n
124 * ..
125 * .. Array Arguments ..
126  REAL work( * )
127  COMPLEX a( lda, * )
128 * ..
129 *
130 * =====================================================================
131 *
132 * .. Parameters ..
133  REAL one, zero
134  parameter( one = 1.0e+0, zero = 0.0e+0 )
135 * ..
136 * .. Local Scalars ..
137  INTEGER i, j
138  REAL sum, VALUE, temp
139 * ..
140 * .. Local Arrays ..
141  REAL ssq( 2 ), colssq( 2 )
142 * ..
143 * .. External Functions ..
144  LOGICAL lsame, sisnan
145  EXTERNAL lsame, sisnan
146 * ..
147 * .. External Subroutines ..
148  EXTERNAL classq, scombssq
149 * ..
150 * .. Intrinsic Functions ..
151  INTRINSIC abs, min, sqrt
152 * ..
153 * .. Executable Statements ..
154 *
155  IF( min( m, n ).EQ.0 ) THEN
156  VALUE = zero
157  ELSE IF( lsame( norm, 'M' ) ) THEN
158 *
159 * Find max(abs(A(i,j))).
160 *
161  VALUE = zero
162  DO 20 j = 1, n
163  DO 10 i = 1, m
164  temp = abs( a( i, j ) )
165  IF( VALUE.LT.temp .OR. sisnan( temp ) ) VALUE = temp
166  10 CONTINUE
167  20 CONTINUE
168  ELSE IF( ( lsame( norm, 'O' ) ) .OR. ( norm.EQ.'1' ) ) THEN
169 *
170 * Find norm1(A).
171 *
172  VALUE = zero
173  DO 40 j = 1, n
174  sum = zero
175  DO 30 i = 1, m
176  sum = sum + abs( a( i, j ) )
177  30 CONTINUE
178  IF( VALUE.LT.sum .OR. sisnan( sum ) ) VALUE = sum
179  40 CONTINUE
180  ELSE IF( lsame( norm, 'I' ) ) THEN
181 *
182 * Find normI(A).
183 *
184  DO 50 i = 1, m
185  work( i ) = zero
186  50 CONTINUE
187  DO 70 j = 1, n
188  DO 60 i = 1, m
189  work( i ) = work( i ) + abs( a( i, j ) )
190  60 CONTINUE
191  70 CONTINUE
192  VALUE = zero
193  DO 80 i = 1, m
194  temp = work( i )
195  IF( VALUE.LT.temp .OR. sisnan( temp ) ) VALUE = temp
196  80 CONTINUE
197  ELSE IF( ( lsame( norm, 'F' ) ) .OR. ( lsame( norm, 'E' ) ) ) THEN
198 *
199 * Find normF(A).
200 * SSQ(1) is scale
201 * SSQ(2) is sum-of-squares
202 * For better accuracy, sum each column separately.
203 *
204  ssq( 1 ) = zero
205  ssq( 2 ) = one
206  DO 90 j = 1, n
207  colssq( 1 ) = zero
208  colssq( 2 ) = one
209  CALL classq( m, a( 1, j ), 1, colssq( 1 ), colssq( 2 ) )
210  CALL scombssq( ssq, colssq )
211  90 CONTINUE
212  VALUE = ssq( 1 )*sqrt( ssq( 2 ) )
213  END IF
214 *
215  clange = VALUE
216  RETURN
217 *
218 * End of CLANGE
219 *
220  END
subroutine scombssq(V1, V2)
SCOMBSSQ adds two scaled sum of squares quantities
Definition: scombssq.f:60
subroutine classq(n, x, incx, scl, sumsq)
CLASSQ updates a sum of squares represented in scaled form.
Definition: classq.f90:126
logical function sisnan(SIN)
SISNAN tests input for NaN.
Definition: sisnan.f:59
logical function lsame(CA, CB)
LSAME
Definition: lsame.f:53
real function clange(NORM, M, N, A, LDA, WORK)
CLANGE returns the value of the 1-norm, Frobenius norm, infinity-norm, or the largest absolute value ...
Definition: clange.f:115