LAPACK 3.3.0

cla_hercond_x.f

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