LAPACK 3.3.0

ctbcon.f

Go to the documentation of this file.
00001       SUBROUTINE CTBCON( NORM, UPLO, DIAG, N, KD, AB, LDAB, RCOND, WORK,
00002      $                   RWORK, INFO )
00003 *
00004 *  -- LAPACK 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 *     Modified to call CLACN2 in place of CLACON, 10 Feb 03, SJH.
00010 *
00011 *     .. Scalar Arguments ..
00012       CHARACTER          DIAG, NORM, UPLO
00013       INTEGER            INFO, KD, LDAB, N
00014       REAL               RCOND
00015 *     ..
00016 *     .. Array Arguments ..
00017       REAL               RWORK( * )
00018       COMPLEX            AB( LDAB, * ), WORK( * )
00019 *     ..
00020 *
00021 *  Purpose
00022 *  =======
00023 *
00024 *  CTBCON estimates the reciprocal of the condition number of a
00025 *  triangular band matrix A, in either the 1-norm or the infinity-norm.
00026 *
00027 *  The norm of A is computed and an estimate is obtained for
00028 *  norm(inv(A)), then the reciprocal of the condition number is
00029 *  computed as
00030 *     RCOND = 1 / ( norm(A) * norm(inv(A)) ).
00031 *
00032 *  Arguments
00033 *  =========
00034 *
00035 *  NORM    (input) CHARACTER*1
00036 *          Specifies whether the 1-norm condition number or the
00037 *          infinity-norm condition number is required:
00038 *          = '1' or 'O':  1-norm;
00039 *          = 'I':         Infinity-norm.
00040 *
00041 *  UPLO    (input) CHARACTER*1
00042 *          = 'U':  A is upper triangular;
00043 *          = 'L':  A is lower triangular.
00044 *
00045 *  DIAG    (input) CHARACTER*1
00046 *          = 'N':  A is non-unit triangular;
00047 *          = 'U':  A is unit triangular.
00048 *
00049 *  N       (input) INTEGER
00050 *          The order of the matrix A.  N >= 0.
00051 *
00052 *  KD      (input) INTEGER
00053 *          The number of superdiagonals or subdiagonals of the
00054 *          triangular band matrix A.  KD >= 0.
00055 *
00056 *  AB      (input) COMPLEX array, dimension (LDAB,N)
00057 *          The upper or lower triangular band matrix A, stored in the
00058 *          first kd+1 rows of the array. The j-th column of A is stored
00059 *          in the j-th column of the array AB as follows:
00060 *          if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j;
00061 *          if UPLO = 'L', AB(1+i-j,j)    = A(i,j) for j<=i<=min(n,j+kd).
00062 *          If DIAG = 'U', the diagonal elements of A are not referenced
00063 *          and are assumed to be 1.
00064 *
00065 *  LDAB    (input) INTEGER
00066 *          The leading dimension of the array AB.  LDAB >= KD+1.
00067 *
00068 *  RCOND   (output) REAL
00069 *          The reciprocal of the condition number of the matrix A,
00070 *          computed as RCOND = 1/(norm(A) * norm(inv(A))).
00071 *
00072 *  WORK    (workspace) COMPLEX array, dimension (2*N)
00073 *
00074 *  RWORK   (workspace) REAL array, dimension (N)
00075 *
00076 *  INFO    (output) INTEGER
00077 *          = 0:  successful exit
00078 *          < 0:  if INFO = -i, the i-th argument had an illegal value
00079 *
00080 *  =====================================================================
00081 *
00082 *     .. Parameters ..
00083       REAL               ONE, ZERO
00084       PARAMETER          ( ONE = 1.0E+0, ZERO = 0.0E+0 )
00085 *     ..
00086 *     .. Local Scalars ..
00087       LOGICAL            NOUNIT, ONENRM, UPPER
00088       CHARACTER          NORMIN
00089       INTEGER            IX, KASE, KASE1
00090       REAL               AINVNM, ANORM, SCALE, SMLNUM, XNORM
00091       COMPLEX            ZDUM
00092 *     ..
00093 *     .. Local Arrays ..
00094       INTEGER            ISAVE( 3 )
00095 *     ..
00096 *     .. External Functions ..
00097       LOGICAL            LSAME
00098       INTEGER            ICAMAX
00099       REAL               CLANTB, SLAMCH
00100       EXTERNAL           LSAME, ICAMAX, CLANTB, SLAMCH
00101 *     ..
00102 *     .. External Subroutines ..
00103       EXTERNAL           CLACN2, CLATBS, CSRSCL, XERBLA
00104 *     ..
00105 *     .. Intrinsic Functions ..
00106       INTRINSIC          ABS, AIMAG, MAX, REAL
00107 *     ..
00108 *     .. Statement Functions ..
00109       REAL               CABS1
00110 *     ..
00111 *     .. Statement Function definitions ..
00112       CABS1( ZDUM ) = ABS( REAL( ZDUM ) ) + ABS( AIMAG( ZDUM ) )
00113 *     ..
00114 *     .. Executable Statements ..
00115 *
00116 *     Test the input parameters.
00117 *
00118       INFO = 0
00119       UPPER = LSAME( UPLO, 'U' )
00120       ONENRM = NORM.EQ.'1' .OR. LSAME( NORM, 'O' )
00121       NOUNIT = LSAME( DIAG, 'N' )
00122 *
00123       IF( .NOT.ONENRM .AND. .NOT.LSAME( NORM, 'I' ) ) THEN
00124          INFO = -1
00125       ELSE IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
00126          INFO = -2
00127       ELSE IF( .NOT.NOUNIT .AND. .NOT.LSAME( DIAG, 'U' ) ) THEN
00128          INFO = -3
00129       ELSE IF( N.LT.0 ) THEN
00130          INFO = -4
00131       ELSE IF( KD.LT.0 ) THEN
00132          INFO = -5
00133       ELSE IF( LDAB.LT.KD+1 ) THEN
00134          INFO = -7
00135       END IF
00136       IF( INFO.NE.0 ) THEN
00137          CALL XERBLA( 'CTBCON', -INFO )
00138          RETURN
00139       END IF
00140 *
00141 *     Quick return if possible
00142 *
00143       IF( N.EQ.0 ) THEN
00144          RCOND = ONE
00145          RETURN
00146       END IF
00147 *
00148       RCOND = ZERO
00149       SMLNUM = SLAMCH( 'Safe minimum' )*REAL( MAX( N, 1 ) )
00150 *
00151 *     Compute the 1-norm of the triangular matrix A or A'.
00152 *
00153       ANORM = CLANTB( NORM, UPLO, DIAG, N, KD, AB, LDAB, RWORK )
00154 *
00155 *     Continue only if ANORM > 0.
00156 *
00157       IF( ANORM.GT.ZERO ) THEN
00158 *
00159 *        Estimate the 1-norm of the inverse of A.
00160 *
00161          AINVNM = ZERO
00162          NORMIN = 'N'
00163          IF( ONENRM ) THEN
00164             KASE1 = 1
00165          ELSE
00166             KASE1 = 2
00167          END IF
00168          KASE = 0
00169    10    CONTINUE
00170          CALL CLACN2( N, WORK( N+1 ), WORK, AINVNM, KASE, ISAVE )
00171          IF( KASE.NE.0 ) THEN
00172             IF( KASE.EQ.KASE1 ) THEN
00173 *
00174 *              Multiply by inv(A).
00175 *
00176                CALL CLATBS( UPLO, 'No transpose', DIAG, NORMIN, N, KD,
00177      $                      AB, LDAB, WORK, SCALE, RWORK, INFO )
00178             ELSE
00179 *
00180 *              Multiply by inv(A').
00181 *
00182                CALL CLATBS( UPLO, 'Conjugate transpose', DIAG, NORMIN,
00183      $                      N, KD, AB, LDAB, WORK, SCALE, RWORK, INFO )
00184             END IF
00185             NORMIN = 'Y'
00186 *
00187 *           Multiply by 1/SCALE if doing so will not cause overflow.
00188 *
00189             IF( SCALE.NE.ONE ) THEN
00190                IX = ICAMAX( N, WORK, 1 )
00191                XNORM = CABS1( WORK( IX ) )
00192                IF( SCALE.LT.XNORM*SMLNUM .OR. SCALE.EQ.ZERO )
00193      $            GO TO 20
00194                CALL CSRSCL( N, SCALE, WORK, 1 )
00195             END IF
00196             GO TO 10
00197          END IF
00198 *
00199 *        Compute the estimate of the reciprocal condition number.
00200 *
00201          IF( AINVNM.NE.ZERO )
00202      $      RCOND = ( ONE / ANORM ) / AINVNM
00203       END IF
00204 *
00205    20 CONTINUE
00206       RETURN
00207 *
00208 *     End of CTBCON
00209 *
00210       END
 All Files Functions