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