LAPACK  3.10.0
LAPACK: Linear Algebra PACKage

◆ slantr()

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

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

Purpose:
 SLANTR  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
SLANTR
    SLANTR = ( 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 SLANTR 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, SLANTR 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, SLANTR is set to zero.
[in]A
          A is REAL 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 139 of file slantr.f.

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