LAPACK  3.10.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.

Definition at line 121 of file slansy.f.

122 *
123 * -- LAPACK auxiliary routine --
124 * -- LAPACK is a software package provided by Univ. of Tennessee, --
125 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
126 *
127  IMPLICIT NONE
128 * .. Scalar Arguments ..
129  CHARACTER NORM, UPLO
130  INTEGER LDA, N
131 * ..
132 * .. Array Arguments ..
133  REAL A( LDA, * ), WORK( * )
134 * ..
135 *
136 * =====================================================================
137 *
138 * .. Parameters ..
139  REAL ONE, ZERO
140  parameter( one = 1.0e+0, zero = 0.0e+0 )
141 * ..
142 * .. Local Scalars ..
143  INTEGER I, J
144  REAL ABSA, SUM, VALUE
145 * ..
146 * .. Local Arrays ..
147  REAL SSQ( 2 ), COLSSQ( 2 )
148 * ..
149 * .. External Functions ..
150  LOGICAL LSAME, SISNAN
151  EXTERNAL lsame, sisnan
152 * ..
153 * .. External Subroutines ..
154  EXTERNAL slassq, scombssq
155 * ..
156 * .. Intrinsic Functions ..
157  INTRINSIC abs, sqrt
158 * ..
159 * .. Executable Statements ..
160 *
161  IF( n.EQ.0 ) THEN
162  VALUE = zero
163  ELSE IF( lsame( norm, 'M' ) ) THEN
164 *
165 * Find max(abs(A(i,j))).
166 *
167  VALUE = zero
168  IF( lsame( uplo, 'U' ) ) THEN
169  DO 20 j = 1, n
170  DO 10 i = 1, j
171  sum = abs( a( i, j ) )
172  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
173  10 CONTINUE
174  20 CONTINUE
175  ELSE
176  DO 40 j = 1, n
177  DO 30 i = j, n
178  sum = abs( a( i, j ) )
179  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
180  30 CONTINUE
181  40 CONTINUE
182  END IF
183  ELSE IF( ( lsame( norm, 'I' ) ) .OR. ( lsame( norm, 'O' ) ) .OR.
184  $ ( norm.EQ.'1' ) ) THEN
185 *
186 * Find normI(A) ( = norm1(A), since A is symmetric).
187 *
188  VALUE = zero
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( a( i, j ) )
194  sum = sum + absa
195  work( i ) = work( i ) + absa
196  50 CONTINUE
197  work( j ) = sum + abs( a( j, j ) )
198  60 CONTINUE
199  DO 70 i = 1, n
200  sum = work( i )
201  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
202  70 CONTINUE
203  ELSE
204  DO 80 i = 1, n
205  work( i ) = zero
206  80 CONTINUE
207  DO 100 j = 1, n
208  sum = work( j ) + abs( a( j, j ) )
209  DO 90 i = j + 1, n
210  absa = abs( a( i, j ) )
211  sum = sum + absa
212  work( i ) = work( i ) + absa
213  90 CONTINUE
214  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
215  100 CONTINUE
216  END IF
217  ELSE IF( ( lsame( norm, 'F' ) ) .OR. ( lsame( norm, 'E' ) ) ) THEN
218 *
219 * Find normF(A).
220 * SSQ(1) is scale
221 * SSQ(2) is sum-of-squares
222 * For better accuracy, sum each column separately.
223 *
224  ssq( 1 ) = zero
225  ssq( 2 ) = one
226 *
227 * Sum off-diagonals
228 *
229  IF( lsame( uplo, 'U' ) ) THEN
230  DO 110 j = 2, n
231  colssq( 1 ) = zero
232  colssq( 2 ) = one
233  CALL slassq( j-1, a( 1, j ), 1, colssq(1), colssq(2) )
234  CALL scombssq( ssq, colssq )
235  110 CONTINUE
236  ELSE
237  DO 120 j = 1, n - 1
238  colssq( 1 ) = zero
239  colssq( 2 ) = one
240  CALL slassq( n-j, a( j+1, j ), 1, colssq(1), colssq(2) )
241  CALL scombssq( ssq, colssq )
242  120 CONTINUE
243  END IF
244  ssq( 2 ) = 2*ssq( 2 )
245 *
246 * Sum diagonal
247 *
248  colssq( 1 ) = zero
249  colssq( 2 ) = one
250  CALL slassq( n, a, lda+1, colssq( 1 ), colssq( 2 ) )
251  CALL scombssq( ssq, colssq )
252  VALUE = ssq( 1 )*sqrt( ssq( 2 ) )
253  END IF
254 *
255  slansy = VALUE
256  RETURN
257 *
258 * End of SLANSY
259 *
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 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:122
Here is the call graph for this function:
Here is the caller graph for this function: