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

◆ slansy()

real function slansy ( character norm,
character uplo,
integer n,
real, dimension( lda, * ) a,
integer lda,
real, dimension( * ) work )

SLANSY returns the value of the 1-norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a real symmetric matrix.

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

Purpose:
!>
!> SLANSY  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.
!> 
Returns
SLANSY
!>
!>    SLANSY = ( 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 SLANSY as described
!>          above.
!> 
[in]UPLO
!>          UPLO is CHARACTER*1
!>          Specifies whether the upper or lower triangular part of the
!>          symmetric matrix A is to be referenced.
!>          = 'U':  Upper triangular part of A is referenced
!>          = 'L':  Lower triangular part of A is referenced
!> 
[in]N
!>          N is INTEGER
!>          The order of the matrix A.  N >= 0.  When N = 0, SLANSY is
!>          set to zero.
!> 
[in]A
!>          A is REAL array, dimension (LDA,N)
!>          The symmetric matrix A.  If UPLO = 'U', the leading n by n
!>          upper triangular part of A contains the upper triangular part
!>          of the matrix A, and the strictly lower triangular part of A
!>          is not referenced.  If UPLO = 'L', the leading n by n lower
!>          triangular part of A contains the lower triangular part of
!>          the matrix A, and the strictly upper triangular part of A is
!>          not referenced.
!> 
[in]LDA
!>          LDA is INTEGER
!>          The leading dimension of the array A.  LDA >= max(N,1).
!> 
[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 119 of file slansy.f.

120*
121* -- LAPACK auxiliary routine --
122* -- LAPACK is a software package provided by Univ. of Tennessee, --
123* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
124*
125* .. Scalar Arguments ..
126 CHARACTER NORM, UPLO
127 INTEGER LDA, N
128* ..
129* .. Array Arguments ..
130 REAL A( LDA, * ), WORK( * )
131* ..
132*
133* =====================================================================
134*
135* .. Parameters ..
136 REAL ONE, ZERO
137 parameter( one = 1.0e+0, zero = 0.0e+0 )
138* ..
139* .. Local Scalars ..
140 INTEGER I, J
141 REAL ABSA, SCALE, SUM, VALUE
142* ..
143* .. External Subroutines ..
144 EXTERNAL slassq
145* ..
146* .. External Functions ..
147 LOGICAL LSAME, SISNAN
148 EXTERNAL lsame, sisnan
149* ..
150* .. Intrinsic Functions ..
151 INTRINSIC abs, sqrt
152* ..
153* .. Executable Statements ..
154*
155 IF( n.EQ.0 ) THEN
156 VALUE = zero
157 ELSE IF( lsame( norm, 'M' ) ) THEN
158*
159* Find max(abs(A(i,j))).
160*
161 VALUE = zero
162 IF( lsame( uplo, 'U' ) ) THEN
163 DO 20 j = 1, n
164 DO 10 i = 1, j
165 sum = abs( a( i, j ) )
166 IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
167 10 CONTINUE
168 20 CONTINUE
169 ELSE
170 DO 40 j = 1, n
171 DO 30 i = j, n
172 sum = abs( a( i, j ) )
173 IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
174 30 CONTINUE
175 40 CONTINUE
176 END IF
177 ELSE IF( ( lsame( norm, 'I' ) ) .OR.
178 $ ( lsame( norm, 'O' ) ) .OR.
179 $ ( norm.EQ.'1' ) ) THEN
180*
181* Find normI(A) ( = norm1(A), since A is symmetric).
182*
183 VALUE = zero
184 IF( lsame( uplo, 'U' ) ) THEN
185 DO 60 j = 1, n
186 sum = zero
187 DO 50 i = 1, j - 1
188 absa = abs( a( i, j ) )
189 sum = sum + absa
190 work( i ) = work( i ) + absa
191 50 CONTINUE
192 work( j ) = sum + abs( a( j, j ) )
193 60 CONTINUE
194 DO 70 i = 1, n
195 sum = work( i )
196 IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
197 70 CONTINUE
198 ELSE
199 DO 80 i = 1, n
200 work( i ) = zero
201 80 CONTINUE
202 DO 100 j = 1, n
203 sum = work( j ) + abs( a( j, j ) )
204 DO 90 i = j + 1, n
205 absa = abs( a( i, j ) )
206 sum = sum + absa
207 work( i ) = work( i ) + absa
208 90 CONTINUE
209 IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
210 100 CONTINUE
211 END IF
212 ELSE IF( ( lsame( norm, 'F' ) ) .OR.
213 $ ( lsame( norm, 'E' ) ) ) THEN
214*
215* Find normF(A).
216*
217 scale = zero
218 sum = one
219 IF( lsame( uplo, 'U' ) ) THEN
220 DO 110 j = 2, n
221 CALL slassq( j-1, a( 1, j ), 1, scale, sum )
222 110 CONTINUE
223 ELSE
224 DO 120 j = 1, n - 1
225 CALL slassq( n-j, a( j+1, j ), 1, scale, sum )
226 120 CONTINUE
227 END IF
228 sum = 2*sum
229 CALL slassq( n, a, lda+1, scale, sum )
230 VALUE = scale*sqrt( sum )
231 END IF
232*
233 slansy = VALUE
234 RETURN
235*
236* End of SLANSY
237*
logical function sisnan(sin)
SISNAN tests input for NaN.
Definition sisnan.f:57
real function slansy(norm, uplo, n, a, lda, work)
SLANSY returns the value of the 1-norm, or the Frobenius norm, or the infinity norm,...
Definition slansy.f:120
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: