LAPACK  3.9.0
LAPACK: Linear Algebra PACKage

◆ 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.
Date
December 2016

Definition at line 124 of file slansy.f.

124 *
125 * -- LAPACK auxiliary routine (version 3.7.0) --
126 * -- LAPACK is a software package provided by Univ. of Tennessee, --
127 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
128 * December 2016
129 *
130  IMPLICIT NONE
131 * .. Scalar Arguments ..
132  CHARACTER NORM, UPLO
133  INTEGER LDA, N
134 * ..
135 * .. Array Arguments ..
136  REAL A( LDA, * ), WORK( * )
137 * ..
138 *
139 * =====================================================================
140 *
141 * .. Parameters ..
142  REAL ONE, ZERO
143  parameter( one = 1.0e+0, zero = 0.0e+0 )
144 * ..
145 * .. Local Scalars ..
146  INTEGER I, J
147  REAL ABSA, 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  VALUE = zero
171  IF( lsame( uplo, 'U' ) ) THEN
172  DO 20 j = 1, n
173  DO 10 i = 1, j
174  sum = abs( a( i, j ) )
175  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
176  10 CONTINUE
177  20 CONTINUE
178  ELSE
179  DO 40 j = 1, n
180  DO 30 i = j, n
181  sum = abs( a( i, j ) )
182  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
183  30 CONTINUE
184  40 CONTINUE
185  END IF
186  ELSE IF( ( lsame( norm, 'I' ) ) .OR. ( lsame( norm, 'O' ) ) .OR.
187  $ ( norm.EQ.'1' ) ) THEN
188 *
189 * Find normI(A) ( = norm1(A), since A is symmetric).
190 *
191  VALUE = zero
192  IF( lsame( uplo, 'U' ) ) THEN
193  DO 60 j = 1, n
194  sum = zero
195  DO 50 i = 1, j - 1
196  absa = abs( a( i, j ) )
197  sum = sum + absa
198  work( i ) = work( i ) + absa
199  50 CONTINUE
200  work( j ) = sum + abs( a( j, j ) )
201  60 CONTINUE
202  DO 70 i = 1, n
203  sum = work( i )
204  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
205  70 CONTINUE
206  ELSE
207  DO 80 i = 1, n
208  work( i ) = zero
209  80 CONTINUE
210  DO 100 j = 1, n
211  sum = work( j ) + abs( a( j, j ) )
212  DO 90 i = j + 1, n
213  absa = abs( a( i, j ) )
214  sum = sum + absa
215  work( i ) = work( i ) + absa
216  90 CONTINUE
217  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
218  100 CONTINUE
219  END IF
220  ELSE IF( ( lsame( norm, 'F' ) ) .OR. ( lsame( norm, 'E' ) ) ) THEN
221 *
222 * Find normF(A).
223 * SSQ(1) is scale
224 * SSQ(2) is sum-of-squares
225 * For better accuracy, sum each column separately.
226 *
227  ssq( 1 ) = zero
228  ssq( 2 ) = one
229 *
230 * Sum off-diagonals
231 *
232  IF( lsame( uplo, 'U' ) ) THEN
233  DO 110 j = 2, n
234  colssq( 1 ) = zero
235  colssq( 2 ) = one
236  CALL slassq( j-1, a( 1, j ), 1, colssq(1), colssq(2) )
237  CALL scombssq( ssq, colssq )
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, a( j+1, j ), 1, colssq(1), colssq(2) )
244  CALL scombssq( ssq, colssq )
245  120 CONTINUE
246  END IF
247  ssq( 2 ) = 2*ssq( 2 )
248 *
249 * Sum diagonal
250 *
251  colssq( 1 ) = zero
252  colssq( 2 ) = one
253  CALL slassq( n, a, lda+1, colssq( 1 ), colssq( 2 ) )
254  CALL scombssq( ssq, colssq )
255  VALUE = ssq( 1 )*sqrt( ssq( 2 ) )
256  END IF
257 *
258  slansy = VALUE
259  RETURN
260 *
261 * End of SLANSY
262 *
Here is the call graph for this function:
Here is the caller graph for this function:
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
slansy
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:124
scombssq
subroutine scombssq(V1, V2)
SCOMBSSQ adds two scaled sum of squares quantities
Definition: scombssq.f:62