LAPACK  3.9.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 *> \date December 2016
111 *
112 *> \ingroup realOTHERauxiliary
113 *
114 * =====================================================================
115  REAL FUNCTION SLANSP( NORM, UPLO, N, AP, WORK )
116 *
117 * -- LAPACK auxiliary routine (version 3.7.0) --
118 * -- LAPACK is a software package provided by Univ. of Tennessee, --
119 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
120 * December 2016
121 *
122  IMPLICIT NONE
123 * .. Scalar Arguments ..
124  CHARACTER norm, uplo
125  INTEGER n
126 * ..
127 * .. Array Arguments ..
128  REAL ap( * ), work( * )
129 * ..
130 *
131 * =====================================================================
132 *
133 * .. Parameters ..
134  REAL one, zero
135  parameter( one = 1.0e+0, zero = 0.0e+0 )
136 * ..
137 * .. Local Scalars ..
138  INTEGER i, j, k
139  REAL absa, sum, value
140 * ..
141 * .. Local Arrays ..
142  REAL ssq( 2 ), colssq( 2 )
143 * ..
144 * .. External Functions ..
145  LOGICAL lsame, sisnan
146  EXTERNAL lsame, sisnan
147 * ..
148 * .. External Subroutines ..
149  EXTERNAL slassq, scombssq
150 * ..
151 * .. Intrinsic Functions ..
152  INTRINSIC abs, sqrt
153 * ..
154 * .. Executable Statements ..
155 *
156  IF( n.EQ.0 ) THEN
157  VALUE = zero
158  ELSE IF( lsame( norm, 'M' ) ) THEN
159 *
160 * Find max(abs(A(i,j))).
161 *
162  VALUE = zero
163  IF( lsame( uplo, 'U' ) ) THEN
164  k = 1
165  DO 20 j = 1, n
166  DO 10 i = k, k + j - 1
167  sum = abs( ap( i ) )
168  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
169  10 CONTINUE
170  k = k + j
171  20 CONTINUE
172  ELSE
173  k = 1
174  DO 40 j = 1, n
175  DO 30 i = k, k + n - j
176  sum = abs( ap( i ) )
177  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
178  30 CONTINUE
179  k = k + n - j + 1
180  40 CONTINUE
181  END IF
182  ELSE IF( ( lsame( norm, 'I' ) ) .OR. ( lsame( norm, 'O' ) ) .OR.
183  $ ( norm.EQ.'1' ) ) THEN
184 *
185 * Find normI(A) ( = norm1(A), since A is symmetric).
186 *
187  VALUE = zero
188  k = 1
189  IF( lsame( uplo, 'U' ) ) THEN
190  DO 60 j = 1, n
191  sum = zero
192  DO 50 i = 1, j - 1
193  absa = abs( ap( k ) )
194  sum = sum + absa
195  work( i ) = work( i ) + absa
196  k = k + 1
197  50 CONTINUE
198  work( j ) = sum + abs( ap( k ) )
199  k = k + 1
200  60 CONTINUE
201  DO 70 i = 1, n
202  sum = work( i )
203  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
204  70 CONTINUE
205  ELSE
206  DO 80 i = 1, n
207  work( i ) = zero
208  80 CONTINUE
209  DO 100 j = 1, n
210  sum = work( j ) + abs( ap( k ) )
211  k = k + 1
212  DO 90 i = j + 1, n
213  absa = abs( ap( k ) )
214  sum = sum + absa
215  work( i ) = work( i ) + absa
216  k = k + 1
217  90 CONTINUE
218  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
219  100 CONTINUE
220  END IF
221  ELSE IF( ( lsame( norm, 'F' ) ) .OR. ( lsame( norm, 'E' ) ) ) THEN
222 *
223 * Find normF(A).
224 * SSQ(1) is scale
225 * SSQ(2) is sum-of-squares
226 * For better accuracy, sum each column separately.
227 *
228  ssq( 1 ) = zero
229  ssq( 2 ) = one
230 *
231 * Sum off-diagonals
232 *
233  k = 2
234  IF( lsame( uplo, 'U' ) ) THEN
235  DO 110 j = 2, n
236  colssq( 1 ) = zero
237  colssq( 2 ) = one
238  CALL slassq( j-1, ap( k ), 1, colssq( 1 ), colssq( 2 ) )
239  CALL scombssq( ssq, colssq )
240  k = k + j
241  110 CONTINUE
242  ELSE
243  DO 120 j = 1, n - 1
244  colssq( 1 ) = zero
245  colssq( 2 ) = one
246  CALL slassq( n-j, ap( k ), 1, colssq( 1 ), colssq( 2 ) )
247  CALL scombssq( ssq, colssq )
248  k = k + n - j + 1
249  120 CONTINUE
250  END IF
251  ssq( 2 ) = 2*ssq( 2 )
252 *
253 * Sum diagonal
254 *
255  k = 1
256  colssq( 1 ) = zero
257  colssq( 2 ) = one
258  DO 130 i = 1, n
259  IF( ap( k ).NE.zero ) THEN
260  absa = abs( ap( k ) )
261  IF( colssq( 1 ).LT.absa ) THEN
262  colssq( 2 ) = one + colssq(2)*( colssq(1) / absa )**2
263  colssq( 1 ) = absa
264  ELSE
265  colssq( 2 ) = colssq( 2 ) + ( absa / colssq( 1 ) )**2
266  END IF
267  END IF
268  IF( lsame( uplo, 'U' ) ) THEN
269  k = k + i + 1
270  ELSE
271  k = k + n - i + 1
272  END IF
273  130 CONTINUE
274  CALL scombssq( ssq, colssq )
275  VALUE = ssq( 1 )*sqrt( ssq( 2 ) )
276  END IF
277 *
278  slansp = VALUE
279  RETURN
280 *
281 * End of SLANSP
282 *
283  END
slansp
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:116
slassq
subroutine slassq(N, X, INCX, SCALE, SUMSQ)
SLASSQ updates a sum of squares represented in scaled form.
Definition: slassq.f:105
sisnan
logical function sisnan(SIN)
SISNAN tests input for NaN.
Definition: sisnan.f:61
lsame
logical function lsame(CA, CB)
LSAME
Definition: lsame.f:55
scombssq
subroutine scombssq(V1, V2)
SCOMBSSQ adds two scaled sum of squares quantities
Definition: scombssq.f:62