LAPACK 3.3.0

dtrcon.f

Go to the documentation of this file.
00001       SUBROUTINE DTRCON( NORM, UPLO, DIAG, N, A, LDA, RCOND, WORK,
00002      $                   IWORK, 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 DLACN2 in place of DLACON, 5 Feb 03, SJH.
00010 *
00011 *     .. Scalar Arguments ..
00012       CHARACTER          DIAG, NORM, UPLO
00013       INTEGER            INFO, LDA, N
00014       DOUBLE PRECISION   RCOND
00015 *     ..
00016 *     .. Array Arguments ..
00017       INTEGER            IWORK( * )
00018       DOUBLE PRECISION   A( LDA, * ), WORK( * )
00019 *     ..
00020 *
00021 *  Purpose
00022 *  =======
00023 *
00024 *  DTRCON estimates the reciprocal of the condition number of a
00025 *  triangular 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 *  A       (input) DOUBLE PRECISION array, dimension (LDA,N)
00053 *          The triangular matrix A.  If UPLO = 'U', the leading N-by-N
00054 *          upper triangular part of the array A contains the upper
00055 *          triangular matrix, and the strictly lower triangular part of
00056 *          A is not referenced.  If UPLO = 'L', the leading N-by-N lower
00057 *          triangular part of the array A contains the lower triangular
00058 *          matrix, and the strictly upper triangular part of A is not
00059 *          referenced.  If DIAG = 'U', the diagonal elements of A are
00060 *          also not referenced and are assumed to be 1.
00061 *
00062 *  LDA     (input) INTEGER
00063 *          The leading dimension of the array A.  LDA >= max(1,N).
00064 *
00065 *  RCOND   (output) DOUBLE PRECISION
00066 *          The reciprocal of the condition number of the matrix A,
00067 *          computed as RCOND = 1/(norm(A) * norm(inv(A))).
00068 *
00069 *  WORK    (workspace) DOUBLE PRECISION array, dimension (3*N)
00070 *
00071 *  IWORK   (workspace) INTEGER array, dimension (N)
00072 *
00073 *  INFO    (output) INTEGER
00074 *          = 0:  successful exit
00075 *          < 0:  if INFO = -i, the i-th argument had an illegal value
00076 *
00077 *  =====================================================================
00078 *
00079 *     .. Parameters ..
00080       DOUBLE PRECISION   ONE, ZERO
00081       PARAMETER          ( ONE = 1.0D+0, ZERO = 0.0D+0 )
00082 *     ..
00083 *     .. Local Scalars ..
00084       LOGICAL            NOUNIT, ONENRM, UPPER
00085       CHARACTER          NORMIN
00086       INTEGER            IX, KASE, KASE1
00087       DOUBLE PRECISION   AINVNM, ANORM, SCALE, SMLNUM, XNORM
00088 *     ..
00089 *     .. Local Arrays ..
00090       INTEGER            ISAVE( 3 )
00091 *     ..
00092 *     .. External Functions ..
00093       LOGICAL            LSAME
00094       INTEGER            IDAMAX
00095       DOUBLE PRECISION   DLAMCH, DLANTR
00096       EXTERNAL           LSAME, IDAMAX, DLAMCH, DLANTR
00097 *     ..
00098 *     .. External Subroutines ..
00099       EXTERNAL           DLACN2, DLATRS, DRSCL, XERBLA
00100 *     ..
00101 *     .. Intrinsic Functions ..
00102       INTRINSIC          ABS, DBLE, MAX
00103 *     ..
00104 *     .. Executable Statements ..
00105 *
00106 *     Test the input parameters.
00107 *
00108       INFO = 0
00109       UPPER = LSAME( UPLO, 'U' )
00110       ONENRM = NORM.EQ.'1' .OR. LSAME( NORM, 'O' )
00111       NOUNIT = LSAME( DIAG, 'N' )
00112 *
00113       IF( .NOT.ONENRM .AND. .NOT.LSAME( NORM, 'I' ) ) THEN
00114          INFO = -1
00115       ELSE IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
00116          INFO = -2
00117       ELSE IF( .NOT.NOUNIT .AND. .NOT.LSAME( DIAG, 'U' ) ) THEN
00118          INFO = -3
00119       ELSE IF( N.LT.0 ) THEN
00120          INFO = -4
00121       ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
00122          INFO = -6
00123       END IF
00124       IF( INFO.NE.0 ) THEN
00125          CALL XERBLA( 'DTRCON', -INFO )
00126          RETURN
00127       END IF
00128 *
00129 *     Quick return if possible
00130 *
00131       IF( N.EQ.0 ) THEN
00132          RCOND = ONE
00133          RETURN
00134       END IF
00135 *
00136       RCOND = ZERO
00137       SMLNUM = DLAMCH( 'Safe minimum' )*DBLE( MAX( 1, N ) )
00138 *
00139 *     Compute the norm of the triangular matrix A.
00140 *
00141       ANORM = DLANTR( NORM, UPLO, DIAG, N, N, A, LDA, WORK )
00142 *
00143 *     Continue only if ANORM > 0.
00144 *
00145       IF( ANORM.GT.ZERO ) THEN
00146 *
00147 *        Estimate the norm of the inverse of A.
00148 *
00149          AINVNM = ZERO
00150          NORMIN = 'N'
00151          IF( ONENRM ) THEN
00152             KASE1 = 1
00153          ELSE
00154             KASE1 = 2
00155          END IF
00156          KASE = 0
00157    10    CONTINUE
00158          CALL DLACN2( N, WORK( N+1 ), WORK, IWORK, AINVNM, KASE, ISAVE )
00159          IF( KASE.NE.0 ) THEN
00160             IF( KASE.EQ.KASE1 ) THEN
00161 *
00162 *              Multiply by inv(A).
00163 *
00164                CALL DLATRS( UPLO, 'No transpose', DIAG, NORMIN, N, A,
00165      $                      LDA, WORK, SCALE, WORK( 2*N+1 ), INFO )
00166             ELSE
00167 *
00168 *              Multiply by inv(A').
00169 *
00170                CALL DLATRS( UPLO, 'Transpose', DIAG, NORMIN, N, A, LDA,
00171      $                      WORK, SCALE, WORK( 2*N+1 ), INFO )
00172             END IF
00173             NORMIN = 'Y'
00174 *
00175 *           Multiply by 1/SCALE if doing so will not cause overflow.
00176 *
00177             IF( SCALE.NE.ONE ) THEN
00178                IX = IDAMAX( N, WORK, 1 )
00179                XNORM = ABS( WORK( IX ) )
00180                IF( SCALE.LT.XNORM*SMLNUM .OR. SCALE.EQ.ZERO )
00181      $            GO TO 20
00182                CALL DRSCL( N, SCALE, WORK, 1 )
00183             END IF
00184             GO TO 10
00185          END IF
00186 *
00187 *        Compute the estimate of the reciprocal condition number.
00188 *
00189          IF( AINVNM.NE.ZERO )
00190      $      RCOND = ( ONE / ANORM ) / AINVNM
00191       END IF
00192 *
00193    20 CONTINUE
00194       RETURN
00195 *
00196 *     End of DTRCON
00197 *
00198       END
 All Files Functions