LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
 All Files Functions Groups
clantr.f
Go to the documentation of this file.
1 *> \brief \b CLANTR
2 *
3 * =========== DOCUMENTATION ===========
4 *
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
7 *
8 *> \htmlonly
9 *> Download CLANTR + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/clantr.f">
11 *> [TGZ]</a>
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/clantr.f">
13 *> [ZIP]</a>
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/clantr.f">
15 *> [TXT]</a>
16 *> \endhtmlonly
17 *
18 * Definition:
19 * ===========
20 *
21 * REAL FUNCTION CLANTR( NORM, UPLO, DIAG, M, N, A, LDA,
22 * WORK )
23 *
24 * .. Scalar Arguments ..
25 * CHARACTER DIAG, NORM, UPLO
26 * INTEGER LDA, M, N
27 * ..
28 * .. Array Arguments ..
29 * REAL WORK( * )
30 * COMPLEX A( LDA, * )
31 * ..
32 *
33 *
34 *> \par Purpose:
35 * =============
36 *>
37 *> \verbatim
38 *>
39 *> CLANTR returns the value of the one norm, or the Frobenius norm, or
40 *> the infinity norm, or the element of largest absolute value of a
41 *> trapezoidal or triangular matrix A.
42 *> \endverbatim
43 *>
44 *> \return CLANTR
45 *> \verbatim
46 *>
47 *> CLANTR = ( max(abs(A(i,j))), NORM = 'M' or 'm'
48 *> (
49 *> ( norm1(A), NORM = '1', 'O' or 'o'
50 *> (
51 *> ( normI(A), NORM = 'I' or 'i'
52 *> (
53 *> ( normF(A), NORM = 'F', 'f', 'E' or 'e'
54 *>
55 *> where norm1 denotes the one norm of a matrix (maximum column sum),
56 *> normI denotes the infinity norm of a matrix (maximum row sum) and
57 *> normF denotes the Frobenius norm of a matrix (square root of sum of
58 *> squares). Note that max(abs(A(i,j))) is not a consistent matrix norm.
59 *> \endverbatim
60 *
61 * Arguments:
62 * ==========
63 *
64 *> \param[in] NORM
65 *> \verbatim
66 *> NORM is CHARACTER*1
67 *> Specifies the value to be returned in CLANTR as described
68 *> above.
69 *> \endverbatim
70 *>
71 *> \param[in] UPLO
72 *> \verbatim
73 *> UPLO is CHARACTER*1
74 *> Specifies whether the matrix A is upper or lower trapezoidal.
75 *> = 'U': Upper trapezoidal
76 *> = 'L': Lower trapezoidal
77 *> Note that A is triangular instead of trapezoidal if M = N.
78 *> \endverbatim
79 *>
80 *> \param[in] DIAG
81 *> \verbatim
82 *> DIAG is CHARACTER*1
83 *> Specifies whether or not the matrix A has unit diagonal.
84 *> = 'N': Non-unit diagonal
85 *> = 'U': Unit diagonal
86 *> \endverbatim
87 *>
88 *> \param[in] M
89 *> \verbatim
90 *> M is INTEGER
91 *> The number of rows of the matrix A. M >= 0, and if
92 *> UPLO = 'U', M <= N. When M = 0, CLANTR is set to zero.
93 *> \endverbatim
94 *>
95 *> \param[in] N
96 *> \verbatim
97 *> N is INTEGER
98 *> The number of columns of the matrix A. N >= 0, and if
99 *> UPLO = 'L', N <= M. When N = 0, CLANTR is set to zero.
100 *> \endverbatim
101 *>
102 *> \param[in] A
103 *> \verbatim
104 *> A is COMPLEX array, dimension (LDA,N)
105 *> The trapezoidal matrix A (A is triangular if M = N).
106 *> If UPLO = 'U', the leading m by n upper trapezoidal part of
107 *> the array A contains the upper trapezoidal matrix, and the
108 *> strictly lower triangular part of A is not referenced.
109 *> If UPLO = 'L', the leading m by n lower trapezoidal part of
110 *> the array A contains the lower trapezoidal matrix, and the
111 *> strictly upper triangular part of A is not referenced. Note
112 *> that when DIAG = 'U', the diagonal elements of A are not
113 *> referenced and are assumed to be one.
114 *> \endverbatim
115 *>
116 *> \param[in] LDA
117 *> \verbatim
118 *> LDA is INTEGER
119 *> The leading dimension of the array A. LDA >= max(M,1).
120 *> \endverbatim
121 *>
122 *> \param[out] WORK
123 *> \verbatim
124 *> WORK is REAL array, dimension (MAX(1,LWORK)),
125 *> where LWORK >= M when NORM = 'I'; otherwise, WORK is not
126 *> referenced.
127 *> \endverbatim
128 *
129 * Authors:
130 * ========
131 *
132 *> \author Univ. of Tennessee
133 *> \author Univ. of California Berkeley
134 *> \author Univ. of Colorado Denver
135 *> \author NAG Ltd.
136 *
137 *> \date November 2011
138 *
139 *> \ingroup complexOTHERauxiliary
140 *
141 * =====================================================================
142  REAL FUNCTION clantr( NORM, UPLO, DIAG, M, N, A, LDA,
143  $ work )
144 *
145 * -- LAPACK auxiliary routine (version 3.4.0) --
146 * -- LAPACK is a software package provided by Univ. of Tennessee, --
147 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
148 * November 2011
149 *
150 * .. Scalar Arguments ..
151  CHARACTER diag, norm, uplo
152  INTEGER lda, m, n
153 * ..
154 * .. Array Arguments ..
155  REAL work( * )
156  COMPLEX a( lda, * )
157 * ..
158 *
159 * =====================================================================
160 *
161 * .. Parameters ..
162  REAL one, zero
163  parameter( one = 1.0e+0, zero = 0.0e+0 )
164 * ..
165 * .. Local Scalars ..
166  LOGICAL udiag
167  INTEGER i, j
168  REAL scale, sum, value
169 * ..
170 * .. External Functions ..
171  LOGICAL lsame
172  EXTERNAL lsame
173 * ..
174 * .. External Subroutines ..
175  EXTERNAL classq
176 * ..
177 * .. Intrinsic Functions ..
178  INTRINSIC abs, max, min, sqrt
179 * ..
180 * .. Executable Statements ..
181 *
182  IF( min( m, n ).EQ.0 ) THEN
183  value = zero
184  ELSE IF( lsame( norm, 'M' ) ) THEN
185 *
186 * Find max(abs(A(i,j))).
187 *
188  IF( lsame( diag, 'U' ) ) THEN
189  value = one
190  IF( lsame( uplo, 'U' ) ) THEN
191  DO 20 j = 1, n
192  DO 10 i = 1, min( m, j-1 )
193  value = max( value, abs( a( i, j ) ) )
194  10 CONTINUE
195  20 CONTINUE
196  ELSE
197  DO 40 j = 1, n
198  DO 30 i = j + 1, m
199  value = max( value, abs( a( i, j ) ) )
200  30 CONTINUE
201  40 CONTINUE
202  END IF
203  ELSE
204  value = zero
205  IF( lsame( uplo, 'U' ) ) THEN
206  DO 60 j = 1, n
207  DO 50 i = 1, min( m, j )
208  value = max( value, abs( a( i, j ) ) )
209  50 CONTINUE
210  60 CONTINUE
211  ELSE
212  DO 80 j = 1, n
213  DO 70 i = j, m
214  value = max( value, abs( a( i, j ) ) )
215  70 CONTINUE
216  80 CONTINUE
217  END IF
218  END IF
219  ELSE IF( ( lsame( norm, 'O' ) ) .OR. ( norm.EQ.'1' ) ) THEN
220 *
221 * Find norm1(A).
222 *
223  value = zero
224  udiag = lsame( diag, 'U' )
225  IF( lsame( uplo, 'U' ) ) THEN
226  DO 110 j = 1, n
227  IF( ( udiag ) .AND. ( j.LE.m ) ) THEN
228  sum = one
229  DO 90 i = 1, j - 1
230  sum = sum + abs( a( i, j ) )
231  90 CONTINUE
232  ELSE
233  sum = zero
234  DO 100 i = 1, min( m, j )
235  sum = sum + abs( a( i, j ) )
236  100 CONTINUE
237  END IF
238  value = max( value, sum )
239  110 CONTINUE
240  ELSE
241  DO 140 j = 1, n
242  IF( udiag ) THEN
243  sum = one
244  DO 120 i = j + 1, m
245  sum = sum + abs( a( i, j ) )
246  120 CONTINUE
247  ELSE
248  sum = zero
249  DO 130 i = j, m
250  sum = sum + abs( a( i, j ) )
251  130 CONTINUE
252  END IF
253  value = max( value, sum )
254  140 CONTINUE
255  END IF
256  ELSE IF( lsame( norm, 'I' ) ) THEN
257 *
258 * Find normI(A).
259 *
260  IF( lsame( uplo, 'U' ) ) THEN
261  IF( lsame( diag, 'U' ) ) THEN
262  DO 150 i = 1, m
263  work( i ) = one
264  150 CONTINUE
265  DO 170 j = 1, n
266  DO 160 i = 1, min( m, j-1 )
267  work( i ) = work( i ) + abs( a( i, j ) )
268  160 CONTINUE
269  170 CONTINUE
270  ELSE
271  DO 180 i = 1, m
272  work( i ) = zero
273  180 CONTINUE
274  DO 200 j = 1, n
275  DO 190 i = 1, min( m, j )
276  work( i ) = work( i ) + abs( a( i, j ) )
277  190 CONTINUE
278  200 CONTINUE
279  END IF
280  ELSE
281  IF( lsame( diag, 'U' ) ) THEN
282  DO 210 i = 1, n
283  work( i ) = one
284  210 CONTINUE
285  DO 220 i = n + 1, m
286  work( i ) = zero
287  220 CONTINUE
288  DO 240 j = 1, n
289  DO 230 i = j + 1, m
290  work( i ) = work( i ) + abs( a( i, j ) )
291  230 CONTINUE
292  240 CONTINUE
293  ELSE
294  DO 250 i = 1, m
295  work( i ) = zero
296  250 CONTINUE
297  DO 270 j = 1, n
298  DO 260 i = j, m
299  work( i ) = work( i ) + abs( a( i, j ) )
300  260 CONTINUE
301  270 CONTINUE
302  END IF
303  END IF
304  value = zero
305  DO 280 i = 1, m
306  value = max( value, work( i ) )
307  280 CONTINUE
308  ELSE IF( ( lsame( norm, 'F' ) ) .OR. ( lsame( norm, 'E' ) ) ) THEN
309 *
310 * Find normF(A).
311 *
312  IF( lsame( uplo, 'U' ) ) THEN
313  IF( lsame( diag, 'U' ) ) THEN
314  scale = one
315  sum = min( m, n )
316  DO 290 j = 2, n
317  CALL classq( min( m, j-1 ), a( 1, j ), 1, scale, sum )
318  290 CONTINUE
319  ELSE
320  scale = zero
321  sum = one
322  DO 300 j = 1, n
323  CALL classq( min( m, j ), a( 1, j ), 1, scale, sum )
324  300 CONTINUE
325  END IF
326  ELSE
327  IF( lsame( diag, 'U' ) ) THEN
328  scale = one
329  sum = min( m, n )
330  DO 310 j = 1, n
331  CALL classq( m-j, a( min( m, j+1 ), j ), 1, scale,
332  $ sum )
333  310 CONTINUE
334  ELSE
335  scale = zero
336  sum = one
337  DO 320 j = 1, n
338  CALL classq( m-j+1, a( j, j ), 1, scale, sum )
339  320 CONTINUE
340  END IF
341  END IF
342  value = scale*sqrt( sum )
343  END IF
344 *
345  clantr = value
346  RETURN
347 *
348 * End of CLANTR
349 *
350  END