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