LAPACK 3.3.1
Linear Algebra PACKage

zla_gercond_x.f

Go to the documentation of this file.
00001       DOUBLE PRECISION FUNCTION ZLA_GERCOND_X( TRANS, N, A, LDA, AF,
00002      $                                         LDAF, IPIV, X, INFO,
00003      $                                         WORK, RWORK )
00004 *
00005 *     -- LAPACK routine (version 3.2.1)                                 --
00006 *     -- Contributed by James Demmel, Deaglan Halligan, Yozo Hida and --
00007 *     -- Jason Riedy of Univ. of California Berkeley.                 --
00008 *     -- April 2009                                                   --
00009 *
00010 *     -- LAPACK is a software package provided by Univ. of Tennessee, --
00011 *     -- Univ. of California Berkeley and NAG Ltd.                    --
00012 *
00013       IMPLICIT NONE
00014 *     ..
00015 *     .. Scalar Arguments ..
00016       CHARACTER          TRANS
00017       INTEGER            N, LDA, LDAF, INFO
00018 *     ..
00019 *     .. Array Arguments ..
00020       INTEGER            IPIV( * )
00021       COMPLEX*16         A( LDA, * ), AF( LDAF, * ), WORK( * ), X( * )
00022       DOUBLE PRECISION   RWORK( * )
00023 *     ..
00024 *
00025 *  Purpose
00026 *  =======
00027 *
00028 *     ZLA_GERCOND_X computes the infinity norm condition number of
00029 *     op(A) * diag(X) where X is a COMPLEX*16 vector.
00030 *
00031 *  Arguments
00032 *  =========
00033 *
00034 *     TRANS   (input) CHARACTER*1
00035 *     Specifies the form of the system of equations:
00036 *       = 'N':  A * X = B     (No transpose)
00037 *       = 'T':  A**T * X = B  (Transpose)
00038 *       = 'C':  A**H * X = B  (Conjugate Transpose = Transpose)
00039 *
00040 *     N       (input) INTEGER
00041 *     The number of linear equations, i.e., the order of the
00042 *     matrix A.  N >= 0.
00043 *
00044 *     A       (input) COMPLEX*16 array, dimension (LDA,N)
00045 *     On entry, the N-by-N matrix A.
00046 *
00047 *     LDA     (input) INTEGER
00048 *     The leading dimension of the array A.  LDA >= max(1,N).
00049 *
00050 *     AF      (input) COMPLEX*16 array, dimension (LDAF,N)
00051 *     The factors L and U from the factorization
00052 *     A = P*L*U as computed by ZGETRF.
00053 *
00054 *     LDAF    (input) INTEGER
00055 *     The leading dimension of the array AF.  LDAF >= max(1,N).
00056 *
00057 *     IPIV    (input) INTEGER array, dimension (N)
00058 *     The pivot indices from the factorization A = P*L*U
00059 *     as computed by ZGETRF; row i of the matrix was interchanged
00060 *     with row IPIV(i).
00061 *
00062 *     X       (input) COMPLEX*16 array, dimension (N)
00063 *     The vector X in the formula op(A) * diag(X).
00064 *
00065 *     INFO    (output) INTEGER
00066 *       = 0:  Successful exit.
00067 *     i > 0:  The ith argument is invalid.
00068 *
00069 *     WORK    (input) COMPLEX*16 array, dimension (2*N).
00070 *     Workspace.
00071 *
00072 *     RWORK   (input) DOUBLE PRECISION array, dimension (N).
00073 *     Workspace.
00074 *
00075 *  =====================================================================
00076 *
00077 *     .. Local Scalars ..
00078       LOGICAL            NOTRANS
00079       INTEGER            KASE
00080       DOUBLE PRECISION   AINVNM, ANORM, TMP
00081       INTEGER            I, J
00082       COMPLEX*16         ZDUM
00083 *     ..
00084 *     .. Local Arrays ..
00085       INTEGER            ISAVE( 3 )
00086 *     ..
00087 *     .. External Functions ..
00088       LOGICAL            LSAME
00089       EXTERNAL           LSAME
00090 *     ..
00091 *     .. External Subroutines ..
00092       EXTERNAL           ZLACN2, ZGETRS, XERBLA
00093 *     ..
00094 *     .. Intrinsic Functions ..
00095       INTRINSIC          ABS, MAX, REAL, DIMAG
00096 *     ..
00097 *     .. Statement Functions ..
00098       DOUBLE PRECISION   CABS1
00099 *     ..
00100 *     .. Statement Function Definitions ..
00101       CABS1( ZDUM ) = ABS( DBLE( ZDUM ) ) + ABS( DIMAG( ZDUM ) )
00102 *     ..
00103 *     .. Executable Statements ..
00104 *
00105       ZLA_GERCOND_X = 0.0D+0
00106 *
00107       INFO = 0
00108       NOTRANS = LSAME( TRANS, 'N' )
00109       IF ( .NOT. NOTRANS .AND. .NOT. LSAME( TRANS, 'T' ) .AND. .NOT.
00110      $     LSAME( TRANS, 'C' ) ) THEN
00111          INFO = -1
00112       ELSE IF( N.LT.0 ) THEN
00113          INFO = -2
00114       END IF
00115       IF( INFO.NE.0 ) THEN
00116          CALL XERBLA( 'ZLA_GERCOND_X', -INFO )
00117          RETURN
00118       END IF
00119 *
00120 *     Compute norm of op(A)*op2(C).
00121 *
00122       ANORM = 0.0D+0
00123       IF ( NOTRANS ) THEN
00124          DO I = 1, N
00125             TMP = 0.0D+0
00126             DO J = 1, N
00127                TMP = TMP + CABS1( A( I, J ) * X( J ) )
00128             END DO
00129             RWORK( I ) = TMP
00130             ANORM = MAX( ANORM, TMP )
00131          END DO
00132       ELSE
00133          DO I = 1, N
00134             TMP = 0.0D+0
00135             DO J = 1, N
00136                TMP = TMP + CABS1( A( J, I ) * X( J ) )
00137             END DO
00138             RWORK( I ) = TMP
00139             ANORM = MAX( ANORM, TMP )
00140          END DO
00141       END IF
00142 *
00143 *     Quick return if possible.
00144 *
00145       IF( N.EQ.0 ) THEN
00146          ZLA_GERCOND_X = 1.0D+0
00147          RETURN
00148       ELSE IF( ANORM .EQ. 0.0D+0 ) THEN
00149          RETURN
00150       END IF
00151 *
00152 *     Estimate the norm of inv(op(A)).
00153 *
00154       AINVNM = 0.0D+0
00155 *
00156       KASE = 0
00157    10 CONTINUE
00158       CALL ZLACN2( N, WORK( N+1 ), WORK, AINVNM, KASE, ISAVE )
00159       IF( KASE.NE.0 ) THEN
00160          IF( KASE.EQ.2 ) THEN
00161 *           Multiply by R.
00162             DO I = 1, N
00163                WORK( I ) = WORK( I ) * RWORK( I )
00164             END DO
00165 *
00166             IF ( NOTRANS ) THEN
00167                CALL ZGETRS( 'No transpose', N, 1, AF, LDAF, IPIV,
00168      $            WORK, N, INFO )
00169             ELSE
00170                CALL ZGETRS( 'Conjugate transpose', N, 1, AF, LDAF, IPIV,
00171      $            WORK, N, INFO )
00172             ENDIF
00173 *
00174 *           Multiply by inv(X).
00175 *
00176             DO I = 1, N
00177                WORK( I ) = WORK( I ) / X( I )
00178             END DO
00179          ELSE
00180 *
00181 *           Multiply by inv(X**H).
00182 *
00183             DO I = 1, N
00184                WORK( I ) = WORK( I ) / X( I )
00185             END DO
00186 *
00187             IF ( NOTRANS ) THEN
00188                CALL ZGETRS( 'Conjugate transpose', N, 1, AF, LDAF, IPIV,
00189      $            WORK, N, INFO )
00190             ELSE
00191                CALL ZGETRS( 'No transpose', N, 1, AF, LDAF, IPIV,
00192      $            WORK, N, INFO )
00193             END IF
00194 *
00195 *           Multiply by R.
00196 *
00197             DO I = 1, N
00198                WORK( I ) = WORK( I ) * RWORK( I )
00199             END DO
00200          END IF
00201          GO TO 10
00202       END IF
00203 *
00204 *     Compute the estimate of the reciprocal condition number.
00205 *
00206       IF( AINVNM .NE. 0.0D+0 )
00207      $   ZLA_GERCOND_X = 1.0D+0 / AINVNM
00208 *
00209       RETURN
00210 *
00211       END
 All Files Functions