LAPACK  3.10.0
LAPACK: Linear Algebra PACKage

◆ 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 113 of file slansp.f.

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