LAPACK  3.10.0
LAPACK: Linear Algebra PACKage
clantr.f
Go to the documentation of this file.
1 *> \brief \b CLANTR returns the value of the 1-norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a trapezoidal or triangular matrix.
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 *> \ingroup complexOTHERauxiliary
138 *
139 * =====================================================================
140  REAL function clantr( norm, uplo, diag, m, n, a, lda,
141  $ work )
142 *
143 * -- LAPACK auxiliary routine --
144 * -- LAPACK is a software package provided by Univ. of Tennessee, --
145 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
146 *
147  IMPLICIT NONE
148 * .. Scalar Arguments ..
149  CHARACTER diag, norm, uplo
150  INTEGER lda, m, n
151 * ..
152 * .. Array Arguments ..
153  REAL work( * )
154  COMPLEX a( lda, * )
155 * ..
156 *
157 * =====================================================================
158 *
159 * .. Parameters ..
160  REAL one, zero
161  parameter( one = 1.0e+0, zero = 0.0e+0 )
162 * ..
163 * .. Local Scalars ..
164  LOGICAL udiag
165  INTEGER i, j
166  REAL sum, value
167 * ..
168 * .. Local Arrays ..
169  REAL ssq( 2 ), colssq( 2 )
170 * ..
171 * .. External Functions ..
172  LOGICAL lsame, sisnan
173  EXTERNAL lsame, sisnan
174 * ..
175 * .. External Subroutines ..
176  EXTERNAL classq, scombssq
177 * ..
178 * .. Intrinsic Functions ..
179  INTRINSIC abs, min, sqrt
180 * ..
181 * .. Executable Statements ..
182 *
183  IF( min( m, n ).EQ.0 ) THEN
184  VALUE = zero
185  ELSE IF( lsame( norm, 'M' ) ) THEN
186 *
187 * Find max(abs(A(i,j))).
188 *
189  IF( lsame( diag, 'U' ) ) THEN
190  VALUE = one
191  IF( lsame( uplo, 'U' ) ) THEN
192  DO 20 j = 1, n
193  DO 10 i = 1, min( m, j-1 )
194  sum = abs( a( i, j ) )
195  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
196  10 CONTINUE
197  20 CONTINUE
198  ELSE
199  DO 40 j = 1, n
200  DO 30 i = j + 1, m
201  sum = abs( a( i, j ) )
202  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
203  30 CONTINUE
204  40 CONTINUE
205  END IF
206  ELSE
207  VALUE = zero
208  IF( lsame( uplo, 'U' ) ) THEN
209  DO 60 j = 1, n
210  DO 50 i = 1, min( m, j )
211  sum = abs( a( i, j ) )
212  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
213  50 CONTINUE
214  60 CONTINUE
215  ELSE
216  DO 80 j = 1, n
217  DO 70 i = j, m
218  sum = abs( a( i, j ) )
219  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
220  70 CONTINUE
221  80 CONTINUE
222  END IF
223  END IF
224  ELSE IF( ( lsame( norm, 'O' ) ) .OR. ( norm.EQ.'1' ) ) THEN
225 *
226 * Find norm1(A).
227 *
228  VALUE = zero
229  udiag = lsame( diag, 'U' )
230  IF( lsame( uplo, 'U' ) ) THEN
231  DO 110 j = 1, n
232  IF( ( udiag ) .AND. ( j.LE.m ) ) THEN
233  sum = one
234  DO 90 i = 1, j - 1
235  sum = sum + abs( a( i, j ) )
236  90 CONTINUE
237  ELSE
238  sum = zero
239  DO 100 i = 1, min( m, j )
240  sum = sum + abs( a( i, j ) )
241  100 CONTINUE
242  END IF
243  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
244  110 CONTINUE
245  ELSE
246  DO 140 j = 1, n
247  IF( udiag ) THEN
248  sum = one
249  DO 120 i = j + 1, m
250  sum = sum + abs( a( i, j ) )
251  120 CONTINUE
252  ELSE
253  sum = zero
254  DO 130 i = j, m
255  sum = sum + abs( a( i, j ) )
256  130 CONTINUE
257  END IF
258  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
259  140 CONTINUE
260  END IF
261  ELSE IF( lsame( norm, 'I' ) ) THEN
262 *
263 * Find normI(A).
264 *
265  IF( lsame( uplo, 'U' ) ) THEN
266  IF( lsame( diag, 'U' ) ) THEN
267  DO 150 i = 1, m
268  work( i ) = one
269  150 CONTINUE
270  DO 170 j = 1, n
271  DO 160 i = 1, min( m, j-1 )
272  work( i ) = work( i ) + abs( a( i, j ) )
273  160 CONTINUE
274  170 CONTINUE
275  ELSE
276  DO 180 i = 1, m
277  work( i ) = zero
278  180 CONTINUE
279  DO 200 j = 1, n
280  DO 190 i = 1, min( m, j )
281  work( i ) = work( i ) + abs( a( i, j ) )
282  190 CONTINUE
283  200 CONTINUE
284  END IF
285  ELSE
286  IF( lsame( diag, 'U' ) ) THEN
287  DO 210 i = 1, min( m, n )
288  work( i ) = one
289  210 CONTINUE
290  DO 220 i = n + 1, m
291  work( i ) = zero
292  220 CONTINUE
293  DO 240 j = 1, n
294  DO 230 i = j + 1, m
295  work( i ) = work( i ) + abs( a( i, j ) )
296  230 CONTINUE
297  240 CONTINUE
298  ELSE
299  DO 250 i = 1, m
300  work( i ) = zero
301  250 CONTINUE
302  DO 270 j = 1, n
303  DO 260 i = j, m
304  work( i ) = work( i ) + abs( a( i, j ) )
305  260 CONTINUE
306  270 CONTINUE
307  END IF
308  END IF
309  VALUE = zero
310  DO 280 i = 1, m
311  sum = work( i )
312  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
313  280 CONTINUE
314  ELSE IF( ( lsame( norm, 'F' ) ) .OR. ( lsame( norm, 'E' ) ) ) THEN
315 *
316 * Find normF(A).
317 * SSQ(1) is scale
318 * SSQ(2) is sum-of-squares
319 * For better accuracy, sum each column separately.
320 *
321  IF( lsame( uplo, 'U' ) ) THEN
322  IF( lsame( diag, 'U' ) ) THEN
323  ssq( 1 ) = one
324  ssq( 2 ) = min( m, n )
325  DO 290 j = 2, n
326  colssq( 1 ) = zero
327  colssq( 2 ) = one
328  CALL classq( min( m, j-1 ), a( 1, j ), 1,
329  $ colssq( 1 ), colssq( 2 ) )
330  CALL scombssq( ssq, colssq )
331  290 CONTINUE
332  ELSE
333  ssq( 1 ) = zero
334  ssq( 2 ) = one
335  DO 300 j = 1, n
336  colssq( 1 ) = zero
337  colssq( 2 ) = one
338  CALL classq( min( m, j ), a( 1, j ), 1,
339  $ colssq( 1 ), colssq( 2 ) )
340  CALL scombssq( ssq, colssq )
341  300 CONTINUE
342  END IF
343  ELSE
344  IF( lsame( diag, 'U' ) ) THEN
345  ssq( 1 ) = one
346  ssq( 2 ) = min( m, n )
347  DO 310 j = 1, n
348  colssq( 1 ) = zero
349  colssq( 2 ) = one
350  CALL classq( m-j, a( min( m, j+1 ), j ), 1,
351  $ colssq( 1 ), colssq( 2 ) )
352  CALL scombssq( ssq, colssq )
353  310 CONTINUE
354  ELSE
355  ssq( 1 ) = zero
356  ssq( 2 ) = one
357  DO 320 j = 1, n
358  colssq( 1 ) = zero
359  colssq( 2 ) = one
360  CALL classq( m-j+1, a( j, j ), 1,
361  $ colssq( 1 ), colssq( 2 ) )
362  CALL scombssq( ssq, colssq )
363  320 CONTINUE
364  END IF
365  END IF
366  VALUE = ssq( 1 )*sqrt( ssq( 2 ) )
367  END IF
368 *
369  clantr = VALUE
370  RETURN
371 *
372 * End of CLANTR
373 *
374  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 clantr(NORM, UPLO, DIAG, M, N, A, LDA, WORK)
CLANTR returns the value of the 1-norm, or the Frobenius norm, or the infinity norm,...
Definition: clantr.f:142