LAPACK 3.3.0

zla_hercond_x.f

Go to the documentation of this file.
00001       DOUBLE PRECISION FUNCTION ZLA_HERCOND_X( UPLO, 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          UPLO
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_HERCOND_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 *     UPLO    (input) CHARACTER*1
00035 *       = 'U':  Upper triangle of A is stored;
00036 *       = 'L':  Lower triangle of A is stored.
00037 *
00038 *     N       (input) INTEGER
00039 *     The number of linear equations, i.e., the order of the
00040 *     matrix A.  N >= 0.
00041 *
00042 *     A       (input) COMPLEX*16 array, dimension (LDA,N)
00043 *     On entry, the N-by-N matrix A.
00044 *
00045 *     LDA     (input) INTEGER
00046 *     The leading dimension of the array A.  LDA >= max(1,N).
00047 *
00048 *     AF      (input) COMPLEX*16 array, dimension (LDAF,N)
00049 *     The block diagonal matrix D and the multipliers used to
00050 *     obtain the factor U or L as computed by ZHETRF.
00051 *
00052 *     LDAF    (input) INTEGER
00053 *     The leading dimension of the array AF.  LDAF >= max(1,N).
00054 *
00055 *     IPIV    (input) INTEGER array, dimension (N)
00056 *     Details of the interchanges and the block structure of D
00057 *     as determined by CHETRF.
00058 *
00059 *     X       (input) COMPLEX*16 array, dimension (N)
00060 *     The vector X in the formula op(A) * diag(X).
00061 *
00062 *     INFO    (output) INTEGER
00063 *       = 0:  Successful exit.
00064 *     i > 0:  The ith argument is invalid.
00065 *
00066 *     WORK    (input) COMPLEX*16 array, dimension (2*N).
00067 *     Workspace.
00068 *
00069 *     RWORK   (input) DOUBLE PRECISION array, dimension (N).
00070 *     Workspace.
00071 *
00072 *  =====================================================================
00073 *
00074 *     .. Local Scalars ..
00075       INTEGER            KASE, I, J
00076       DOUBLE PRECISION   AINVNM, ANORM, TMP
00077       LOGICAL            UP
00078       COMPLEX*16         ZDUM
00079 *     ..
00080 *     .. Local Arrays ..
00081       INTEGER            ISAVE( 3 )
00082 *     ..
00083 *     .. External Functions ..
00084       LOGICAL            LSAME
00085       EXTERNAL           LSAME
00086 *     ..
00087 *     .. External Subroutines ..
00088       EXTERNAL           ZLACN2, ZHETRS, XERBLA
00089 *     ..
00090 *     .. Intrinsic Functions ..
00091       INTRINSIC          ABS, MAX
00092 *     ..
00093 *     .. Statement Functions ..
00094       DOUBLE PRECISION CABS1
00095 *     ..
00096 *     .. Statement Function Definitions ..
00097       CABS1( ZDUM ) = ABS( DBLE( ZDUM ) ) + ABS( DIMAG( ZDUM ) )
00098 *     ..
00099 *     .. Executable Statements ..
00100 *
00101       ZLA_HERCOND_X = 0.0D+0
00102 *
00103       INFO = 0
00104       IF( N.LT.0 ) THEN
00105          INFO = -2
00106       END IF
00107       IF( INFO.NE.0 ) THEN
00108          CALL XERBLA( 'ZLA_HERCOND_X', -INFO )
00109          RETURN
00110       END IF
00111       UP = .FALSE.
00112       IF ( LSAME( UPLO, 'U' ) ) UP = .TRUE.
00113 *
00114 *     Compute norm of op(A)*op2(C).
00115 *
00116       ANORM = 0.0D+0
00117       IF ( UP ) THEN
00118          DO I = 1, N
00119             TMP = 0.0D+0
00120             DO J = 1, I
00121                TMP = TMP + CABS1( A( J, I ) * X( J ) )
00122             END DO
00123             DO J = I+1, N
00124                TMP = TMP + CABS1( A( I, J ) * X( J ) )
00125             END DO
00126             RWORK( I ) = TMP
00127             ANORM = MAX( ANORM, TMP )
00128          END DO
00129       ELSE
00130          DO I = 1, N
00131             TMP = 0.0D+0
00132             DO J = 1, I
00133                TMP = TMP + CABS1( A( I, J ) * X( J ) )
00134             END DO
00135             DO J = I+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_HERCOND_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 *
00162 *           Multiply by R.
00163 *
00164             DO I = 1, N
00165                WORK( I ) = WORK( I ) * RWORK( I )
00166             END DO
00167 *
00168             IF ( UP ) THEN
00169                CALL ZHETRS( 'U', N, 1, AF, LDAF, IPIV,
00170      $            WORK, N, INFO )
00171             ELSE
00172                CALL ZHETRS( 'L', N, 1, AF, LDAF, IPIV,
00173      $            WORK, N, INFO )
00174             ENDIF
00175 *
00176 *           Multiply by inv(X).
00177 *
00178             DO I = 1, N
00179                WORK( I ) = WORK( I ) / X( I )
00180             END DO
00181          ELSE
00182 *
00183 *           Multiply by inv(X').
00184 *
00185             DO I = 1, N
00186                WORK( I ) = WORK( I ) / X( I )
00187             END DO
00188 *
00189             IF ( UP ) THEN
00190                CALL ZHETRS( 'U', N, 1, AF, LDAF, IPIV,
00191      $            WORK, N, INFO )
00192             ELSE
00193                CALL ZHETRS( 'L', N, 1, AF, LDAF, IPIV,
00194      $            WORK, N, INFO )
00195             END IF
00196 *
00197 *           Multiply by R.
00198 *
00199             DO I = 1, N
00200                WORK( I ) = WORK( I ) * RWORK( I )
00201             END DO
00202          END IF
00203          GO TO 10
00204       END IF
00205 *
00206 *     Compute the estimate of the reciprocal condition number.
00207 *
00208       IF( AINVNM .NE. 0.0D+0 )
00209      $   ZLA_HERCOND_X = 1.0D+0 / AINVNM
00210 *
00211       RETURN
00212 *
00213       END
 All Files Functions