LAPACK 3.3.1
Linear Algebra PACKage

ctpcon.f

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