LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ slansp()

real function slansp ( character norm,
character uplo,
integer n,
real, dimension( * ) ap,
real, dimension( * ) work )

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.

Download SLANSP + dependencies [TGZ] [ZIP] [TXT]

Purpose:
!>
!> SLANSP  returns the value of the one norm,  or the Frobenius norm, or
!> the  infinity norm,  or the  element of  largest absolute value  of a
!> real symmetric matrix A,  supplied in packed form.
!> 
Returns
SLANSP
!>
!>    SLANSP = ( max(abs(A(i,j))), NORM = 'M' or 'm'
!>             (
!>             ( norm1(A),         NORM = '1', 'O' or 'o'
!>             (
!>             ( normI(A),         NORM = 'I' or 'i'
!>             (
!>             ( normF(A),         NORM = 'F', 'f', 'E' or 'e'
!>
!> where  norm1  denotes the  one norm of a matrix (maximum column sum),
!> normI  denotes the  infinity norm  of a matrix  (maximum row sum) and
!> normF  denotes the  Frobenius norm of a matrix (square root of sum of
!> squares).  Note that  max(abs(A(i,j)))  is not a consistent matrix norm.
!> 
Parameters
[in]NORM
!>          NORM is CHARACTER*1
!>          Specifies the value to be returned in SLANSP as described
!>          above.
!> 
[in]UPLO
!>          UPLO is CHARACTER*1
!>          Specifies whether the upper or lower triangular part of the
!>          symmetric matrix A is supplied.
!>          = 'U':  Upper triangular part of A is supplied
!>          = 'L':  Lower triangular part of A is supplied
!> 
[in]N
!>          N is INTEGER
!>          The order of the matrix A.  N >= 0.  When N = 0, SLANSP is
!>          set to zero.
!> 
[in]AP
!>          AP is REAL array, dimension (N*(N+1)/2)
!>          The upper or lower triangle of the symmetric matrix A, packed
!>          columnwise in a linear array.  The j-th column of A is stored
!>          in the array AP as follows:
!>          if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
!>          if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n.
!> 
[out]WORK
!>          WORK is REAL array, dimension (MAX(1,LWORK)),
!>          where LWORK >= N when NORM = 'I' or '1' or 'O'; otherwise,
!>          WORK is not referenced.
!> 
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.

Definition at line 111 of file slansp.f.

112*
113* -- LAPACK auxiliary routine --
114* -- LAPACK is a software package provided by Univ. of Tennessee, --
115* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
116*
117* .. Scalar Arguments ..
118 CHARACTER NORM, UPLO
119 INTEGER N
120* ..
121* .. Array Arguments ..
122 REAL AP( * ), WORK( * )
123* ..
124*
125* =====================================================================
126*
127* .. Parameters ..
128 REAL ONE, ZERO
129 parameter( one = 1.0e+0, zero = 0.0e+0 )
130* ..
131* .. Local Scalars ..
132 INTEGER I, J, K
133 REAL ABSA, SCALE, SUM, VALUE
134* ..
135* .. External Subroutines ..
136 EXTERNAL slassq
137* ..
138* .. External Functions ..
139 LOGICAL LSAME, SISNAN
140 EXTERNAL lsame, sisnan
141* ..
142* .. Intrinsic Functions ..
143 INTRINSIC abs, sqrt
144* ..
145* .. Executable Statements ..
146*
147 IF( n.EQ.0 ) THEN
148 VALUE = zero
149 ELSE IF( lsame( norm, 'M' ) ) THEN
150*
151* Find max(abs(A(i,j))).
152*
153 VALUE = zero
154 IF( lsame( uplo, 'U' ) ) THEN
155 k = 1
156 DO 20 j = 1, n
157 DO 10 i = k, k + j - 1
158 sum = abs( ap( i ) )
159 IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
160 10 CONTINUE
161 k = k + j
162 20 CONTINUE
163 ELSE
164 k = 1
165 DO 40 j = 1, n
166 DO 30 i = k, k + n - j
167 sum = abs( ap( i ) )
168 IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
169 30 CONTINUE
170 k = k + n - j + 1
171 40 CONTINUE
172 END IF
173 ELSE IF( ( lsame( norm, 'I' ) ) .OR.
174 $ ( lsame( norm, 'O' ) ) .OR.
175 $ ( norm.EQ.'1' ) ) THEN
176*
177* Find normI(A) ( = norm1(A), since A is symmetric).
178*
179 VALUE = zero
180 k = 1
181 IF( lsame( uplo, 'U' ) ) THEN
182 DO 60 j = 1, n
183 sum = zero
184 DO 50 i = 1, j - 1
185 absa = abs( ap( k ) )
186 sum = sum + absa
187 work( i ) = work( i ) + absa
188 k = k + 1
189 50 CONTINUE
190 work( j ) = sum + abs( ap( k ) )
191 k = k + 1
192 60 CONTINUE
193 DO 70 i = 1, n
194 sum = work( i )
195 IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
196 70 CONTINUE
197 ELSE
198 DO 80 i = 1, n
199 work( i ) = zero
200 80 CONTINUE
201 DO 100 j = 1, n
202 sum = work( j ) + abs( ap( k ) )
203 k = k + 1
204 DO 90 i = j + 1, n
205 absa = abs( ap( k ) )
206 sum = sum + absa
207 work( i ) = work( i ) + absa
208 k = k + 1
209 90 CONTINUE
210 IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
211 100 CONTINUE
212 END IF
213 ELSE IF( ( lsame( norm, 'F' ) ) .OR.
214 $ ( lsame( norm, 'E' ) ) ) THEN
215*
216* Find normF(A).
217*
218 scale = zero
219 sum = one
220 k = 2
221 IF( lsame( uplo, 'U' ) ) THEN
222 DO 110 j = 2, n
223 CALL slassq( j-1, ap( k ), 1, scale, sum )
224 k = k + j
225 110 CONTINUE
226 ELSE
227 DO 120 j = 1, n - 1
228 CALL slassq( n-j, ap( k ), 1, scale, sum )
229 k = k + n - j + 1
230 120 CONTINUE
231 END IF
232 sum = 2*sum
233 k = 1
234 DO 130 i = 1, n
235 IF( ap( k ).NE.zero ) THEN
236 absa = abs( ap( k ) )
237 IF( scale.LT.absa ) THEN
238 sum = one + sum*( scale / absa )**2
239 scale = absa
240 ELSE
241 sum = sum + ( absa / scale )**2
242 END IF
243 END IF
244 IF( lsame( uplo, 'U' ) ) THEN
245 k = k + i + 1
246 ELSE
247 k = k + n - i + 1
248 END IF
249 130 CONTINUE
250 VALUE = scale*sqrt( sum )
251 END IF
252*
253 slansp = VALUE
254 RETURN
255*
256* End of SLANSP
257*
logical function sisnan(sin)
SISNAN tests input for NaN.
Definition sisnan.f:57
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:112
subroutine slassq(n, x, incx, scale, sumsq)
SLASSQ updates a sum of squares represented in scaled form.
Definition slassq.f90:122
logical function lsame(ca, cb)
LSAME
Definition lsame.f:48
Here is the call graph for this function:
Here is the caller graph for this function: