LAPACK  3.10.0
LAPACK: Linear Algebra PACKage

◆ clantr()

real function clantr ( character  NORM,
character  UPLO,
character  DIAG,
integer  M,
integer  N,
complex, dimension( lda, * )  A,
integer  LDA,
real, dimension( * )  WORK 
)

CLANTR returns the value of the 1-norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a trapezoidal or triangular matrix.

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

Purpose:
 CLANTR  returns the value of the one norm,  or the Frobenius norm, or
 the  infinity norm,  or the  element of  largest absolute value  of a
 trapezoidal or triangular matrix A.
Returns
CLANTR
    CLANTR = ( 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 CLANTR as described
          above.
[in]UPLO
          UPLO is CHARACTER*1
          Specifies whether the matrix A is upper or lower trapezoidal.
          = 'U':  Upper trapezoidal
          = 'L':  Lower trapezoidal
          Note that A is triangular instead of trapezoidal if M = N.
[in]DIAG
          DIAG is CHARACTER*1
          Specifies whether or not the matrix A has unit diagonal.
          = 'N':  Non-unit diagonal
          = 'U':  Unit diagonal
[in]M
          M is INTEGER
          The number of rows of the matrix A.  M >= 0, and if
          UPLO = 'U', M <= N.  When M = 0, CLANTR is set to zero.
[in]N
          N is INTEGER
          The number of columns of the matrix A.  N >= 0, and if
          UPLO = 'L', N <= M.  When N = 0, CLANTR is set to zero.
[in]A
          A is COMPLEX array, dimension (LDA,N)
          The trapezoidal matrix A (A is triangular if M = N).
          If UPLO = 'U', the leading m by n upper trapezoidal part of
          the array A contains the upper trapezoidal matrix, and the
          strictly lower triangular part of A is not referenced.
          If UPLO = 'L', the leading m by n lower trapezoidal part of
          the array A contains the lower trapezoidal matrix, and the
          strictly upper triangular part of A is not referenced.  Note
          that when DIAG = 'U', the diagonal elements of A are not
          referenced and are assumed to be one.
[in]LDA
          LDA is INTEGER
          The leading dimension of the array A.  LDA >= max(M,1).
[out]WORK
          WORK is REAL array, dimension (MAX(1,LWORK)),
          where LWORK >= M when NORM = 'I'; otherwise, WORK is not
          referenced.
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.

Definition at line 140 of file clantr.f.

142 *
143 * -- LAPACK auxiliary routine --
144 * -- LAPACK is a software package provided by Univ. of Tennessee, --
145 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
146 *
147  IMPLICIT NONE
148 * .. Scalar Arguments ..
149  CHARACTER DIAG, NORM, UPLO
150  INTEGER LDA, M, N
151 * ..
152 * .. Array Arguments ..
153  REAL WORK( * )
154  COMPLEX A( LDA, * )
155 * ..
156 *
157 * =====================================================================
158 *
159 * .. Parameters ..
160  REAL ONE, ZERO
161  parameter( one = 1.0e+0, zero = 0.0e+0 )
162 * ..
163 * .. Local Scalars ..
164  LOGICAL UDIAG
165  INTEGER I, J
166  REAL SUM, VALUE
167 * ..
168 * .. Local Arrays ..
169  REAL SSQ( 2 ), COLSSQ( 2 )
170 * ..
171 * .. External Functions ..
172  LOGICAL LSAME, SISNAN
173  EXTERNAL lsame, sisnan
174 * ..
175 * .. External Subroutines ..
176  EXTERNAL classq, scombssq
177 * ..
178 * .. Intrinsic Functions ..
179  INTRINSIC abs, min, sqrt
180 * ..
181 * .. Executable Statements ..
182 *
183  IF( min( m, n ).EQ.0 ) THEN
184  VALUE = zero
185  ELSE IF( lsame( norm, 'M' ) ) THEN
186 *
187 * Find max(abs(A(i,j))).
188 *
189  IF( lsame( diag, 'U' ) ) THEN
190  VALUE = one
191  IF( lsame( uplo, 'U' ) ) THEN
192  DO 20 j = 1, n
193  DO 10 i = 1, min( m, j-1 )
194  sum = abs( a( i, j ) )
195  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
196  10 CONTINUE
197  20 CONTINUE
198  ELSE
199  DO 40 j = 1, n
200  DO 30 i = j + 1, m
201  sum = abs( a( i, j ) )
202  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
203  30 CONTINUE
204  40 CONTINUE
205  END IF
206  ELSE
207  VALUE = zero
208  IF( lsame( uplo, 'U' ) ) THEN
209  DO 60 j = 1, n
210  DO 50 i = 1, min( m, j )
211  sum = abs( a( i, j ) )
212  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
213  50 CONTINUE
214  60 CONTINUE
215  ELSE
216  DO 80 j = 1, n
217  DO 70 i = j, m
218  sum = abs( a( i, j ) )
219  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
220  70 CONTINUE
221  80 CONTINUE
222  END IF
223  END IF
224  ELSE IF( ( lsame( norm, 'O' ) ) .OR. ( norm.EQ.'1' ) ) THEN
225 *
226 * Find norm1(A).
227 *
228  VALUE = zero
229  udiag = lsame( diag, 'U' )
230  IF( lsame( uplo, 'U' ) ) THEN
231  DO 110 j = 1, n
232  IF( ( udiag ) .AND. ( j.LE.m ) ) THEN
233  sum = one
234  DO 90 i = 1, j - 1
235  sum = sum + abs( a( i, j ) )
236  90 CONTINUE
237  ELSE
238  sum = zero
239  DO 100 i = 1, min( m, j )
240  sum = sum + abs( a( i, j ) )
241  100 CONTINUE
242  END IF
243  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
244  110 CONTINUE
245  ELSE
246  DO 140 j = 1, n
247  IF( udiag ) THEN
248  sum = one
249  DO 120 i = j + 1, m
250  sum = sum + abs( a( i, j ) )
251  120 CONTINUE
252  ELSE
253  sum = zero
254  DO 130 i = j, m
255  sum = sum + abs( a( i, j ) )
256  130 CONTINUE
257  END IF
258  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
259  140 CONTINUE
260  END IF
261  ELSE IF( lsame( norm, 'I' ) ) THEN
262 *
263 * Find normI(A).
264 *
265  IF( lsame( uplo, 'U' ) ) THEN
266  IF( lsame( diag, 'U' ) ) THEN
267  DO 150 i = 1, m
268  work( i ) = one
269  150 CONTINUE
270  DO 170 j = 1, n
271  DO 160 i = 1, min( m, j-1 )
272  work( i ) = work( i ) + abs( a( i, j ) )
273  160 CONTINUE
274  170 CONTINUE
275  ELSE
276  DO 180 i = 1, m
277  work( i ) = zero
278  180 CONTINUE
279  DO 200 j = 1, n
280  DO 190 i = 1, min( m, j )
281  work( i ) = work( i ) + abs( a( i, j ) )
282  190 CONTINUE
283  200 CONTINUE
284  END IF
285  ELSE
286  IF( lsame( diag, 'U' ) ) THEN
287  DO 210 i = 1, min( m, n )
288  work( i ) = one
289  210 CONTINUE
290  DO 220 i = n + 1, m
291  work( i ) = zero
292  220 CONTINUE
293  DO 240 j = 1, n
294  DO 230 i = j + 1, m
295  work( i ) = work( i ) + abs( a( i, j ) )
296  230 CONTINUE
297  240 CONTINUE
298  ELSE
299  DO 250 i = 1, m
300  work( i ) = zero
301  250 CONTINUE
302  DO 270 j = 1, n
303  DO 260 i = j, m
304  work( i ) = work( i ) + abs( a( i, j ) )
305  260 CONTINUE
306  270 CONTINUE
307  END IF
308  END IF
309  VALUE = zero
310  DO 280 i = 1, m
311  sum = work( i )
312  IF( VALUE .LT. sum .OR. sisnan( sum ) ) VALUE = sum
313  280 CONTINUE
314  ELSE IF( ( lsame( norm, 'F' ) ) .OR. ( lsame( norm, 'E' ) ) ) THEN
315 *
316 * Find normF(A).
317 * SSQ(1) is scale
318 * SSQ(2) is sum-of-squares
319 * For better accuracy, sum each column separately.
320 *
321  IF( lsame( uplo, 'U' ) ) THEN
322  IF( lsame( diag, 'U' ) ) THEN
323  ssq( 1 ) = one
324  ssq( 2 ) = min( m, n )
325  DO 290 j = 2, n
326  colssq( 1 ) = zero
327  colssq( 2 ) = one
328  CALL classq( min( m, j-1 ), a( 1, j ), 1,
329  $ colssq( 1 ), colssq( 2 ) )
330  CALL scombssq( ssq, colssq )
331  290 CONTINUE
332  ELSE
333  ssq( 1 ) = zero
334  ssq( 2 ) = one
335  DO 300 j = 1, n
336  colssq( 1 ) = zero
337  colssq( 2 ) = one
338  CALL classq( min( m, j ), a( 1, j ), 1,
339  $ colssq( 1 ), colssq( 2 ) )
340  CALL scombssq( ssq, colssq )
341  300 CONTINUE
342  END IF
343  ELSE
344  IF( lsame( diag, 'U' ) ) THEN
345  ssq( 1 ) = one
346  ssq( 2 ) = min( m, n )
347  DO 310 j = 1, n
348  colssq( 1 ) = zero
349  colssq( 2 ) = one
350  CALL classq( m-j, a( min( m, j+1 ), j ), 1,
351  $ colssq( 1 ), colssq( 2 ) )
352  CALL scombssq( ssq, colssq )
353  310 CONTINUE
354  ELSE
355  ssq( 1 ) = zero
356  ssq( 2 ) = one
357  DO 320 j = 1, n
358  colssq( 1 ) = zero
359  colssq( 2 ) = one
360  CALL classq( m-j+1, a( j, j ), 1,
361  $ colssq( 1 ), colssq( 2 ) )
362  CALL scombssq( ssq, colssq )
363  320 CONTINUE
364  END IF
365  END IF
366  VALUE = ssq( 1 )*sqrt( ssq( 2 ) )
367  END IF
368 *
369  clantr = VALUE
370  RETURN
371 *
372 * End of CLANTR
373 *
subroutine scombssq(V1, V2)
SCOMBSSQ adds two scaled sum of squares quantities
Definition: scombssq.f:60
subroutine classq(n, x, incx, scl, sumsq)
CLASSQ updates a sum of squares represented in scaled form.
Definition: classq.f90:126
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 clantr(NORM, UPLO, DIAG, M, N, A, LDA, WORK)
CLANTR returns the value of the 1-norm, or the Frobenius norm, or the infinity norm,...
Definition: clantr.f:142
Here is the call graph for this function: