LAPACK  3.10.0
LAPACK: Linear Algebra PACKage
slansp.f
Go to the documentation of this file.
1 *> \brief \b SLANSP returns the value of the 1-norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a symmetric 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 SLANSP + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/slansp.f">
11 *> [TGZ]</a>
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/slansp.f">
13 *> [ZIP]</a>
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/slansp.f">
15 *> [TXT]</a>
16 *> \endhtmlonly
17 *
18 * Definition:
19 * ===========
20 *
21 * REAL FUNCTION SLANSP( NORM, UPLO, N, AP, WORK )
22 *
23 * .. Scalar Arguments ..
24 * CHARACTER 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 *> SLANSP 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 *> real symmetric matrix A, supplied in packed form.
40 *> \endverbatim
41 *>
42 *> \return SLANSP
43 *> \verbatim
44 *>
45 *> SLANSP = ( 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 SLANSP as described
66 *> above.
67 *> \endverbatim
68 *>
69 *> \param[in] UPLO
70 *> \verbatim
71 *> UPLO is CHARACTER*1
72 *> Specifies whether the upper or lower triangular part of the
73 *> symmetric matrix A is supplied.
74 *> = 'U': Upper triangular part of A is supplied
75 *> = 'L': Lower triangular part of A is supplied
76 *> \endverbatim
77 *>
78 *> \param[in] N
79 *> \verbatim
80 *> N is INTEGER
81 *> The order of the matrix A. N >= 0. When N = 0, SLANSP is
82 *> set to zero.
83 *> \endverbatim
84 *>
85 *> \param[in] AP
86 *> \verbatim
87 *> AP is REAL array, dimension (N*(N+1)/2)
88 *> The upper or lower triangle of the symmetric matrix A, packed
89 *> columnwise in a linear array. The j-th column of A is stored
90 *> in the array AP as follows:
91 *> if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
92 *> if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n.
93 *> \endverbatim
94 *>
95 *> \param[out] WORK
96 *> \verbatim
97 *> WORK is REAL array, dimension (MAX(1,LWORK)),
98 *> where LWORK >= N when NORM = 'I' or '1' or 'O'; otherwise,
99 *> WORK is not referenced.
100 *> \endverbatim
101 *
102 * Authors:
103 * ========
104 *
105 *> \author Univ. of Tennessee
106 *> \author Univ. of California Berkeley
107 *> \author Univ. of Colorado Denver
108 *> \author NAG Ltd.
109 *
110 *> \ingroup realOTHERauxiliary
111 *
112 * =====================================================================
113  REAL function slansp( norm, uplo, n, ap, work )
114 *
115 * -- LAPACK auxiliary routine --
116 * -- LAPACK is a software package provided by Univ. of Tennessee, --
117 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
118 *
119  IMPLICIT NONE
120 * .. Scalar Arguments ..
121  CHARACTER norm, uplo
122  INTEGER n
123 * ..
124 * .. Array Arguments ..
125  REAL ap( * ), work( * )
126 * ..
127 *
128 * =====================================================================
129 *
130 * .. Parameters ..
131  REAL one, zero
132  parameter( one = 1.0e+0, zero = 0.0e+0 )
133 * ..
134 * .. Local Scalars ..
135  INTEGER i, j, k
136  REAL absa, sum, value
137 * ..
138 * .. Local Arrays ..
139  REAL ssq( 2 ), colssq( 2 )
140 * ..
141 * .. External Functions ..
142  LOGICAL lsame, sisnan
143  EXTERNAL lsame, sisnan
144 * ..
145 * .. External Subroutines ..
146  EXTERNAL slassq, scombssq
147 * ..
148 * .. Intrinsic Functions ..
149  INTRINSIC abs, sqrt
150 * ..
151 * .. Executable Statements ..
152 *
153  IF( n.EQ.0 ) THEN
154  VALUE = zero
155  ELSE IF( lsame( norm, 'M' ) ) THEN
156 *
157 * Find max(abs(A(i,j))).
158 *
159  VALUE = zero
160  IF( lsame( uplo, 'U' ) ) THEN
161  k = 1
162  DO 20 j = 1, n
163  DO 10 i = k, k + j - 1
164  sum = abs( ap( i ) )
165  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
166  10 CONTINUE
167  k = k + j
168  20 CONTINUE
169  ELSE
170  k = 1
171  DO 40 j = 1, n
172  DO 30 i = k, k + n - j
173  sum = abs( ap( i ) )
174  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
175  30 CONTINUE
176  k = k + n - j + 1
177  40 CONTINUE
178  END IF
179  ELSE IF( ( lsame( norm, 'I' ) ) .OR. ( lsame( norm, 'O' ) ) .OR.
180  $ ( norm.EQ.'1' ) ) THEN
181 *
182 * Find normI(A) ( = norm1(A), since A is symmetric).
183 *
184  VALUE = zero
185  k = 1
186  IF( lsame( uplo, 'U' ) ) THEN
187  DO 60 j = 1, n
188  sum = zero
189  DO 50 i = 1, j - 1
190  absa = abs( ap( k ) )
191  sum = sum + absa
192  work( i ) = work( i ) + absa
193  k = k + 1
194  50 CONTINUE
195  work( j ) = sum + abs( ap( k ) )
196  k = k + 1
197  60 CONTINUE
198  DO 70 i = 1, n
199  sum = work( i )
200  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
201  70 CONTINUE
202  ELSE
203  DO 80 i = 1, n
204  work( i ) = zero
205  80 CONTINUE
206  DO 100 j = 1, n
207  sum = work( j ) + abs( ap( k ) )
208  k = k + 1
209  DO 90 i = j + 1, n
210  absa = abs( ap( k ) )
211  sum = sum + absa
212  work( i ) = work( i ) + absa
213  k = k + 1
214  90 CONTINUE
215  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
216  100 CONTINUE
217  END IF
218  ELSE IF( ( lsame( norm, 'F' ) ) .OR. ( lsame( norm, 'E' ) ) ) THEN
219 *
220 * Find normF(A).
221 * SSQ(1) is scale
222 * SSQ(2) is sum-of-squares
223 * For better accuracy, sum each column separately.
224 *
225  ssq( 1 ) = zero
226  ssq( 2 ) = one
227 *
228 * Sum off-diagonals
229 *
230  k = 2
231  IF( lsame( uplo, 'U' ) ) THEN
232  DO 110 j = 2, n
233  colssq( 1 ) = zero
234  colssq( 2 ) = one
235  CALL slassq( j-1, ap( k ), 1, colssq( 1 ), colssq( 2 ) )
236  CALL scombssq( ssq, colssq )
237  k = k + j
238  110 CONTINUE
239  ELSE
240  DO 120 j = 1, n - 1
241  colssq( 1 ) = zero
242  colssq( 2 ) = one
243  CALL slassq( n-j, ap( k ), 1, colssq( 1 ), colssq( 2 ) )
244  CALL scombssq( ssq, colssq )
245  k = k + n - j + 1
246  120 CONTINUE
247  END IF
248  ssq( 2 ) = 2*ssq( 2 )
249 *
250 * Sum diagonal
251 *
252  k = 1
253  colssq( 1 ) = zero
254  colssq( 2 ) = one
255  DO 130 i = 1, n
256  IF( ap( k ).NE.zero ) THEN
257  absa = abs( ap( k ) )
258  IF( colssq( 1 ).LT.absa ) THEN
259  colssq( 2 ) = one + colssq(2)*( colssq(1) / absa )**2
260  colssq( 1 ) = absa
261  ELSE
262  colssq( 2 ) = colssq( 2 ) + ( absa / colssq( 1 ) )**2
263  END IF
264  END IF
265  IF( lsame( uplo, 'U' ) ) THEN
266  k = k + i + 1
267  ELSE
268  k = k + n - i + 1
269  END IF
270  130 CONTINUE
271  CALL scombssq( ssq, colssq )
272  VALUE = ssq( 1 )*sqrt( ssq( 2 ) )
273  END IF
274 *
275  slansp = VALUE
276  RETURN
277 *
278 * End of SLANSP
279 *
280  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 slansp(NORM, UPLO, N, AP, WORK)
SLANSP returns the value of the 1-norm, or the Frobenius norm, or the infinity norm,...
Definition: slansp.f:114