LAPACK 3.3.0

clansb.f

Go to the documentation of this file.
00001       REAL             FUNCTION CLANSB( NORM, UPLO, N, K, AB, LDAB,
00002      $                 WORK )
00003 *
00004 *  -- LAPACK auxiliary routine (version 3.2) --
00005 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00006 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00007 *     November 2006
00008 *
00009 *     .. Scalar Arguments ..
00010       CHARACTER          NORM, UPLO
00011       INTEGER            K, LDAB, N
00012 *     ..
00013 *     .. Array Arguments ..
00014       REAL               WORK( * )
00015       COMPLEX            AB( LDAB, * )
00016 *     ..
00017 *
00018 *  Purpose
00019 *  =======
00020 *
00021 *  CLANSB  returns the value of the one norm,  or the Frobenius norm, or
00022 *  the  infinity norm,  or the element of  largest absolute value  of an
00023 *  n by n symmetric band matrix A,  with k super-diagonals.
00024 *
00025 *  Description
00026 *  ===========
00027 *
00028 *  CLANSB returns the value
00029 *
00030 *     CLANSB = ( max(abs(A(i,j))), NORM = 'M' or 'm'
00031 *              (
00032 *              ( norm1(A),         NORM = '1', 'O' or 'o'
00033 *              (
00034 *              ( normI(A),         NORM = 'I' or 'i'
00035 *              (
00036 *              ( normF(A),         NORM = 'F', 'f', 'E' or 'e'
00037 *
00038 *  where  norm1  denotes the  one norm of a matrix (maximum column sum),
00039 *  normI  denotes the  infinity norm  of a matrix  (maximum row sum) and
00040 *  normF  denotes the  Frobenius norm of a matrix (square root of sum of
00041 *  squares).  Note that  max(abs(A(i,j)))  is not a consistent matrix norm.
00042 *
00043 *  Arguments
00044 *  =========
00045 *
00046 *  NORM    (input) CHARACTER*1
00047 *          Specifies the value to be returned in CLANSB as described
00048 *          above.
00049 *
00050 *  UPLO    (input) CHARACTER*1
00051 *          Specifies whether the upper or lower triangular part of the
00052 *          band matrix A is supplied.
00053 *          = 'U':  Upper triangular part is supplied
00054 *          = 'L':  Lower triangular part is supplied
00055 *
00056 *  N       (input) INTEGER
00057 *          The order of the matrix A.  N >= 0.  When N = 0, CLANSB is
00058 *          set to zero.
00059 *
00060 *  K       (input) INTEGER
00061 *          The number of super-diagonals or sub-diagonals of the
00062 *          band matrix A.  K >= 0.
00063 *
00064 *  AB      (input) COMPLEX array, dimension (LDAB,N)
00065 *          The upper or lower triangle of the symmetric band matrix A,
00066 *          stored in the first K+1 rows of AB.  The j-th column of A is
00067 *          stored in the j-th column of the array AB as follows:
00068 *          if UPLO = 'U', AB(k+1+i-j,j) = A(i,j) for max(1,j-k)<=i<=j;
00069 *          if UPLO = 'L', AB(1+i-j,j)   = A(i,j) for j<=i<=min(n,j+k).
00070 *
00071 *  LDAB    (input) INTEGER
00072 *          The leading dimension of the array AB.  LDAB >= K+1.
00073 *
00074 *  WORK    (workspace) REAL array, dimension (MAX(1,LWORK)),
00075 *          where LWORK >= N when NORM = 'I' or '1' or 'O'; otherwise,
00076 *          WORK is not referenced.
00077 *
00078 * =====================================================================
00079 *
00080 *     .. Parameters ..
00081       REAL               ONE, ZERO
00082       PARAMETER          ( ONE = 1.0E+0, ZERO = 0.0E+0 )
00083 *     ..
00084 *     .. Local Scalars ..
00085       INTEGER            I, J, L
00086       REAL               ABSA, SCALE, SUM, VALUE
00087 *     ..
00088 *     .. External Functions ..
00089       LOGICAL            LSAME
00090       EXTERNAL           LSAME
00091 *     ..
00092 *     .. External Subroutines ..
00093       EXTERNAL           CLASSQ
00094 *     ..
00095 *     .. Intrinsic Functions ..
00096       INTRINSIC          ABS, MAX, MIN, SQRT
00097 *     ..
00098 *     .. Executable Statements ..
00099 *
00100       IF( N.EQ.0 ) THEN
00101          VALUE = ZERO
00102       ELSE IF( LSAME( NORM, 'M' ) ) THEN
00103 *
00104 *        Find max(abs(A(i,j))).
00105 *
00106          VALUE = ZERO
00107          IF( LSAME( UPLO, 'U' ) ) THEN
00108             DO 20 J = 1, N
00109                DO 10 I = MAX( K+2-J, 1 ), K + 1
00110                   VALUE = MAX( VALUE, ABS( AB( I, J ) ) )
00111    10          CONTINUE
00112    20       CONTINUE
00113          ELSE
00114             DO 40 J = 1, N
00115                DO 30 I = 1, MIN( N+1-J, K+1 )
00116                   VALUE = MAX( VALUE, ABS( AB( I, J ) ) )
00117    30          CONTINUE
00118    40       CONTINUE
00119          END IF
00120       ELSE IF( ( LSAME( NORM, 'I' ) ) .OR. ( LSAME( NORM, 'O' ) ) .OR.
00121      $         ( NORM.EQ.'1' ) ) THEN
00122 *
00123 *        Find normI(A) ( = norm1(A), since A is symmetric).
00124 *
00125          VALUE = ZERO
00126          IF( LSAME( UPLO, 'U' ) ) THEN
00127             DO 60 J = 1, N
00128                SUM = ZERO
00129                L = K + 1 - J
00130                DO 50 I = MAX( 1, J-K ), J - 1
00131                   ABSA = ABS( AB( L+I, J ) )
00132                   SUM = SUM + ABSA
00133                   WORK( I ) = WORK( I ) + ABSA
00134    50          CONTINUE
00135                WORK( J ) = SUM + ABS( AB( K+1, J ) )
00136    60       CONTINUE
00137             DO 70 I = 1, N
00138                VALUE = MAX( VALUE, WORK( I ) )
00139    70       CONTINUE
00140          ELSE
00141             DO 80 I = 1, N
00142                WORK( I ) = ZERO
00143    80       CONTINUE
00144             DO 100 J = 1, N
00145                SUM = WORK( J ) + ABS( AB( 1, J ) )
00146                L = 1 - J
00147                DO 90 I = J + 1, MIN( N, J+K )
00148                   ABSA = ABS( AB( L+I, J ) )
00149                   SUM = SUM + ABSA
00150                   WORK( I ) = WORK( I ) + ABSA
00151    90          CONTINUE
00152                VALUE = MAX( VALUE, SUM )
00153   100       CONTINUE
00154          END IF
00155       ELSE IF( ( LSAME( NORM, 'F' ) ) .OR. ( LSAME( NORM, 'E' ) ) ) THEN
00156 *
00157 *        Find normF(A).
00158 *
00159          SCALE = ZERO
00160          SUM = ONE
00161          IF( K.GT.0 ) THEN
00162             IF( LSAME( UPLO, 'U' ) ) THEN
00163                DO 110 J = 2, N
00164                   CALL CLASSQ( MIN( J-1, K ), AB( MAX( K+2-J, 1 ), J ),
00165      $                         1, SCALE, SUM )
00166   110          CONTINUE
00167                L = K + 1
00168             ELSE
00169                DO 120 J = 1, N - 1
00170                   CALL CLASSQ( MIN( N-J, K ), AB( 2, J ), 1, SCALE,
00171      $                         SUM )
00172   120          CONTINUE
00173                L = 1
00174             END IF
00175             SUM = 2*SUM
00176          ELSE
00177             L = 1
00178          END IF
00179          CALL CLASSQ( N, AB( L, 1 ), LDAB, SCALE, SUM )
00180          VALUE = SCALE*SQRT( SUM )
00181       END IF
00182 *
00183       CLANSB = VALUE
00184       RETURN
00185 *
00186 *     End of CLANSB
00187 *
00188       END
 All Files Functions