LAPACK  3.9.0
LAPACK: Linear Algebra PACKage

◆ clansp()

real function clansp ( character  NORM,
character  UPLO,
integer  N,
complex, dimension( * )  AP,
real, dimension( * )  WORK 
)

CLANSP 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 CLANSP + dependencies [TGZ] [ZIP] [TXT]

Purpose:
 CLANSP  returns the value of the one norm,  or the Frobenius norm, or
 the  infinity norm,  or the  element of  largest absolute value  of a
 complex symmetric matrix A,  supplied in packed form.
Returns
CLANSP
    CLANSP = ( 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 CLANSP 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, CLANSP is
          set to zero.
[in]AP
          AP is COMPLEX 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.
Date
December 2016

Definition at line 117 of file clansp.f.

117 *
118 * -- LAPACK auxiliary routine (version 3.7.0) --
119 * -- LAPACK is a software package provided by Univ. of Tennessee, --
120 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
121 * December 2016
122 *
123  IMPLICIT NONE
124 * .. Scalar Arguments ..
125  CHARACTER NORM, UPLO
126  INTEGER N
127 * ..
128 * .. Array Arguments ..
129  REAL WORK( * )
130  COMPLEX AP( * )
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, K
141  REAL ABSA, SUM, VALUE
142 * ..
143 * .. Local Arrays ..
144  REAL SSQ( 2 ), COLSSQ( 2 )
145 * ..
146 * .. External Functions ..
147  LOGICAL LSAME, SISNAN
148  EXTERNAL lsame, sisnan
149 * ..
150 * .. External Subroutines ..
151  EXTERNAL classq, scombssq
152 * ..
153 * .. Intrinsic Functions ..
154  INTRINSIC abs, aimag, real, sqrt
155 * ..
156 * .. Executable Statements ..
157 *
158  IF( n.EQ.0 ) THEN
159  VALUE = zero
160  ELSE IF( lsame( norm, 'M' ) ) THEN
161 *
162 * Find max(abs(A(i,j))).
163 *
164  VALUE = zero
165  IF( lsame( uplo, 'U' ) ) THEN
166  k = 1
167  DO 20 j = 1, n
168  DO 10 i = k, k + j - 1
169  sum = abs( ap( i ) )
170  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
171  10 CONTINUE
172  k = k + j
173  20 CONTINUE
174  ELSE
175  k = 1
176  DO 40 j = 1, n
177  DO 30 i = k, k + n - j
178  sum = abs( ap( i ) )
179  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
180  30 CONTINUE
181  k = k + n - j + 1
182  40 CONTINUE
183  END IF
184  ELSE IF( ( lsame( norm, 'I' ) ) .OR. ( lsame( norm, 'O' ) ) .OR.
185  $ ( norm.EQ.'1' ) ) THEN
186 *
187 * Find normI(A) ( = norm1(A), since A is symmetric).
188 *
189  VALUE = zero
190  k = 1
191  IF( lsame( uplo, 'U' ) ) THEN
192  DO 60 j = 1, n
193  sum = zero
194  DO 50 i = 1, j - 1
195  absa = abs( ap( k ) )
196  sum = sum + absa
197  work( i ) = work( i ) + absa
198  k = k + 1
199  50 CONTINUE
200  work( j ) = sum + abs( ap( k ) )
201  k = k + 1
202  60 CONTINUE
203  DO 70 i = 1, n
204  sum = work( i )
205  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
206  70 CONTINUE
207  ELSE
208  DO 80 i = 1, n
209  work( i ) = zero
210  80 CONTINUE
211  DO 100 j = 1, n
212  sum = work( j ) + abs( ap( k ) )
213  k = k + 1
214  DO 90 i = j + 1, n
215  absa = abs( ap( k ) )
216  sum = sum + absa
217  work( i ) = work( i ) + absa
218  k = k + 1
219  90 CONTINUE
220  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
221  100 CONTINUE
222  END IF
223  ELSE IF( ( lsame( norm, 'F' ) ) .OR. ( lsame( norm, 'E' ) ) ) THEN
224 *
225 * Find normF(A).
226 * SSQ(1) is scale
227 * SSQ(2) is sum-of-squares
228 * For better accuracy, sum each column separately.
229 *
230  ssq( 1 ) = zero
231  ssq( 2 ) = one
232 *
233 * Sum off-diagonals
234 *
235  k = 2
236  IF( lsame( uplo, 'U' ) ) THEN
237  DO 110 j = 2, n
238  colssq( 1 ) = zero
239  colssq( 2 ) = one
240  CALL classq( j-1, ap( k ), 1, colssq( 1 ), colssq( 2 ) )
241  CALL scombssq( ssq, colssq )
242  k = k + j
243  110 CONTINUE
244  ELSE
245  DO 120 j = 1, n - 1
246  colssq( 1 ) = zero
247  colssq( 2 ) = one
248  CALL classq( n-j, ap( k ), 1, colssq( 1 ), colssq( 2 ) )
249  CALL scombssq( ssq, colssq )
250  k = k + n - j + 1
251  120 CONTINUE
252  END IF
253  ssq( 2 ) = 2*ssq( 2 )
254 *
255 * Sum diagonal
256 *
257  k = 1
258  colssq( 1 ) = zero
259  colssq( 2 ) = one
260  DO 130 i = 1, n
261  IF( real( ap( k ) ).NE.zero ) THEN
262  absa = abs( real( ap( k ) ) )
263  IF( colssq( 1 ).LT.absa ) THEN
264  colssq( 2 ) = one + colssq(2)*( colssq(1) / absa )**2
265  colssq( 1 ) = absa
266  ELSE
267  colssq( 2 ) = colssq( 2 ) + ( absa / colssq( 1 ) )**2
268  END IF
269  END IF
270  IF( aimag( ap( k ) ).NE.zero ) THEN
271  absa = abs( aimag( ap( k ) ) )
272  IF( colssq( 1 ).LT.absa ) THEN
273  colssq( 2 ) = one + colssq(2)*( colssq(1) / absa )**2
274  colssq( 1 ) = absa
275  ELSE
276  colssq( 2 ) = colssq( 2 ) + ( absa / colssq( 1 ) )**2
277  END IF
278  END IF
279  IF( lsame( uplo, 'U' ) ) THEN
280  k = k + i + 1
281  ELSE
282  k = k + n - i + 1
283  END IF
284  130 CONTINUE
285  CALL scombssq( ssq, colssq )
286  VALUE = ssq( 1 )*sqrt( ssq( 2 ) )
287  END IF
288 *
289  clansp = VALUE
290  RETURN
291 *
292 * End of CLANSP
293 *
Here is the call graph for this function:
classq
subroutine classq(N, X, INCX, SCALE, SUMSQ)
CLASSQ updates a sum of squares represented in scaled form.
Definition: classq.f:108
sisnan
logical function sisnan(SIN)
SISNAN tests input for NaN.
Definition: sisnan.f:61
clansp
real function clansp(NORM, UPLO, N, AP, WORK)
CLANSP returns the value of the 1-norm, or the Frobenius norm, or the infinity norm,...
Definition: clansp.f:117
lsame
logical function lsame(CA, CB)
LSAME
Definition: lsame.f:55
scombssq
subroutine scombssq(V1, V2)
SCOMBSSQ adds two scaled sum of squares quantities
Definition: scombssq.f:62