LAPACK 3.3.0

cla_syrcond_x.f

Go to the documentation of this file.
00001       REAL FUNCTION CLA_SYRCOND_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_SYRCOND_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 CSYTRF.
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 CSYTRF.
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
00075       REAL               AINVNM, ANORM, TMP
00076       INTEGER            I, J
00077       LOGICAL            UP
00078       COMPLEX            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           CLACN2, CSYTRS, XERBLA
00089 *     ..
00090 *     .. Intrinsic Functions ..
00091       INTRINSIC          ABS, MAX
00092 *     ..
00093 *     .. Statement Functions ..
00094       REAL               CABS1
00095 *     ..
00096 *     .. Statement Function Definitions ..
00097       CABS1( ZDUM ) = ABS( REAL( ZDUM ) ) + ABS( AIMAG( ZDUM ) )
00098 *     ..
00099 *     .. Executable Statements ..
00100 *
00101       CLA_SYRCOND_X = 0.0E+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( 'CLA_SYRCOND_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.0
00117       IF ( UP ) THEN
00118          DO I = 1, N
00119             TMP = 0.0E+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.0E+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          CLA_SYRCOND_X = 1.0E+0
00147          RETURN
00148       ELSE IF( ANORM .EQ. 0.0E+0 ) THEN
00149          RETURN
00150       END IF
00151 *
00152 *     Estimate the norm of inv(op(A)).
00153 *
00154       AINVNM = 0.0E+0
00155 *
00156       KASE = 0
00157    10 CONTINUE
00158       CALL CLACN2( 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 CSYTRS( 'U', N, 1, AF, LDAF, IPIV,
00170      $            WORK, N, INFO )
00171             ELSE
00172                CALL CSYTRS( '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 CSYTRS( 'U', N, 1, AF, LDAF, IPIV,
00191      $            WORK, N, INFO )
00192             ELSE
00193                CALL CSYTRS( '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.0E+0 )
00209      $   CLA_SYRCOND_X = 1.0E+0 / AINVNM
00210 *
00211       RETURN
00212 *
00213       END
 All Files Functions