LAPACK 3.3.0

sgecon.f

Go to the documentation of this file.
00001       SUBROUTINE SGECON( NORM, N, A, LDA, ANORM, RCOND, WORK, IWORK,
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 SLACN2 in place of SLACON, 7 Feb 03, SJH.
00010 *
00011 *     .. Scalar Arguments ..
00012       CHARACTER          NORM
00013       INTEGER            INFO, LDA, N
00014       REAL               ANORM, RCOND
00015 *     ..
00016 *     .. Array Arguments ..
00017       INTEGER            IWORK( * )
00018       REAL               A( LDA, * ), WORK( * )
00019 *     ..
00020 *
00021 *  Purpose
00022 *  =======
00023 *
00024 *  SGECON estimates the reciprocal of the condition number of a general
00025 *  real matrix A, in either the 1-norm or the infinity-norm, using
00026 *  the LU factorization computed by SGETRF.
00027 *
00028 *  An estimate is obtained for norm(inv(A)), and the reciprocal of the
00029 *  condition number is 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 *  N       (input) INTEGER
00042 *          The order of the matrix A.  N >= 0.
00043 *
00044 *  A       (input) REAL array, dimension (LDA,N)
00045 *          The factors L and U from the factorization A = P*L*U
00046 *          as computed by SGETRF.
00047 *
00048 *  LDA     (input) INTEGER
00049 *          The leading dimension of the array A.  LDA >= max(1,N).
00050 *
00051 *  ANORM   (input) REAL
00052 *          If NORM = '1' or 'O', the 1-norm of the original matrix A.
00053 *          If NORM = 'I', the infinity-norm of the original matrix A.
00054 *
00055 *  RCOND   (output) REAL
00056 *          The reciprocal of the condition number of the matrix A,
00057 *          computed as RCOND = 1/(norm(A) * norm(inv(A))).
00058 *
00059 *  WORK    (workspace) REAL array, dimension (4*N)
00060 *
00061 *  IWORK   (workspace) INTEGER array, dimension (N)
00062 *
00063 *  INFO    (output) INTEGER
00064 *          = 0:  successful exit
00065 *          < 0:  if INFO = -i, the i-th argument had an illegal value
00066 *
00067 *  =====================================================================
00068 *
00069 *     .. Parameters ..
00070       REAL               ONE, ZERO
00071       PARAMETER          ( ONE = 1.0E+0, ZERO = 0.0E+0 )
00072 *     ..
00073 *     .. Local Scalars ..
00074       LOGICAL            ONENRM
00075       CHARACTER          NORMIN
00076       INTEGER            IX, KASE, KASE1
00077       REAL               AINVNM, SCALE, SL, SMLNUM, SU
00078 *     ..
00079 *     .. Local Arrays ..
00080       INTEGER            ISAVE( 3 )
00081 *     ..
00082 *     .. External Functions ..
00083       LOGICAL            LSAME
00084       INTEGER            ISAMAX
00085       REAL               SLAMCH
00086       EXTERNAL           LSAME, ISAMAX, SLAMCH
00087 *     ..
00088 *     .. External Subroutines ..
00089       EXTERNAL           SLACN2, SLATRS, SRSCL, XERBLA
00090 *     ..
00091 *     .. Intrinsic Functions ..
00092       INTRINSIC          ABS, MAX
00093 *     ..
00094 *     .. Executable Statements ..
00095 *
00096 *     Test the input parameters.
00097 *
00098       INFO = 0
00099       ONENRM = NORM.EQ.'1' .OR. LSAME( NORM, 'O' )
00100       IF( .NOT.ONENRM .AND. .NOT.LSAME( NORM, 'I' ) ) THEN
00101          INFO = -1
00102       ELSE IF( N.LT.0 ) THEN
00103          INFO = -2
00104       ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
00105          INFO = -4
00106       ELSE IF( ANORM.LT.ZERO ) THEN
00107          INFO = -5
00108       END IF
00109       IF( INFO.NE.0 ) THEN
00110          CALL XERBLA( 'SGECON', -INFO )
00111          RETURN
00112       END IF
00113 *
00114 *     Quick return if possible
00115 *
00116       RCOND = ZERO
00117       IF( N.EQ.0 ) THEN
00118          RCOND = ONE
00119          RETURN
00120       ELSE IF( ANORM.EQ.ZERO ) THEN
00121          RETURN
00122       END IF
00123 *
00124       SMLNUM = SLAMCH( 'Safe minimum' )
00125 *
00126 *     Estimate the norm of inv(A).
00127 *
00128       AINVNM = ZERO
00129       NORMIN = 'N'
00130       IF( ONENRM ) THEN
00131          KASE1 = 1
00132       ELSE
00133          KASE1 = 2
00134       END IF
00135       KASE = 0
00136    10 CONTINUE
00137       CALL SLACN2( N, WORK( N+1 ), WORK, IWORK, AINVNM, KASE, ISAVE )
00138       IF( KASE.NE.0 ) THEN
00139          IF( KASE.EQ.KASE1 ) THEN
00140 *
00141 *           Multiply by inv(L).
00142 *
00143             CALL SLATRS( 'Lower', 'No transpose', 'Unit', NORMIN, N, A,
00144      $                   LDA, WORK, SL, WORK( 2*N+1 ), INFO )
00145 *
00146 *           Multiply by inv(U).
00147 *
00148             CALL SLATRS( 'Upper', 'No transpose', 'Non-unit', NORMIN, N,
00149      $                   A, LDA, WORK, SU, WORK( 3*N+1 ), INFO )
00150          ELSE
00151 *
00152 *           Multiply by inv(U').
00153 *
00154             CALL SLATRS( 'Upper', 'Transpose', 'Non-unit', NORMIN, N, A,
00155      $                   LDA, WORK, SU, WORK( 3*N+1 ), INFO )
00156 *
00157 *           Multiply by inv(L').
00158 *
00159             CALL SLATRS( 'Lower', 'Transpose', 'Unit', NORMIN, N, A,
00160      $                   LDA, WORK, SL, WORK( 2*N+1 ), INFO )
00161          END IF
00162 *
00163 *        Divide X by 1/(SL*SU) if doing so will not cause overflow.
00164 *
00165          SCALE = SL*SU
00166          NORMIN = 'Y'
00167          IF( SCALE.NE.ONE ) THEN
00168             IX = ISAMAX( N, WORK, 1 )
00169             IF( SCALE.LT.ABS( WORK( IX ) )*SMLNUM .OR. SCALE.EQ.ZERO )
00170      $         GO TO 20
00171             CALL SRSCL( N, SCALE, WORK, 1 )
00172          END IF
00173          GO TO 10
00174       END IF
00175 *
00176 *     Compute the estimate of the reciprocal condition number.
00177 *
00178       IF( AINVNM.NE.ZERO )
00179      $   RCOND = ( ONE / AINVNM ) / ANORM
00180 *
00181    20 CONTINUE
00182       RETURN
00183 *
00184 *     End of SGECON
00185 *
00186       END
 All Files Functions