LAPACK 3.3.1 Linear Algebra PACKage

# cla_syrcond_c.f

Go to the documentation of this file.
```00001       REAL FUNCTION CLA_SYRCOND_C( UPLO, N, A, LDA, AF, LDAF, IPIV, C,
00002      \$                             CAPPLY, 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       LOGICAL            CAPPLY
00017       INTEGER            N, LDA, LDAF, INFO
00018 *     ..
00019 *     .. Array Arguments ..
00020       INTEGER            IPIV( * )
00021       COMPLEX            A( LDA, * ), AF( LDAF, * ), WORK( * )
00022       REAL               C( * ), RWORK( * )
00023 *     ..
00024 *
00025 *  Purpose
00026 *  =======
00027 *
00028 *     CLA_SYRCOND_C Computes the infinity norm condition number of
00029 *     op(A) * inv(diag(C)) where C is a REAL 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 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 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 CSYTRF.
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 CSYTRF.
00058 *
00059 *     C       (input) REAL array, dimension (N)
00060 *     The vector C in the formula op(A) * inv(diag(C)).
00061 *
00062 *     CAPPLY  (input) LOGICAL
00063 *     If .TRUE. then access the vector C in the formula above.
00064 *
00065 *     INFO    (output) INTEGER
00066 *       = 0:  Successful exit.
00067 *     i > 0:  The ith argument is invalid.
00068 *
00069 *     WORK    (input) COMPLEX array, dimension (2*N).
00070 *     Workspace.
00071 *
00072 *     RWORK   (input) REAL array, dimension (N).
00073 *     Workspace.
00074 *
00075 *  =====================================================================
00076 *
00077 *     .. Local Scalars ..
00078       INTEGER            KASE
00079       REAL               AINVNM, ANORM, TMP
00080       INTEGER            I, J
00081       LOGICAL            UP
00082       COMPLEX            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           CLACN2, CSYTRS, XERBLA
00093 *     ..
00094 *     .. Intrinsic Functions ..
00095       INTRINSIC          ABS, MAX
00096 *     ..
00097 *     .. Statement Functions ..
00098       REAL CABS1
00099 *     ..
00100 *     .. Statement Function Definitions ..
00101       CABS1( ZDUM ) = ABS( REAL( ZDUM ) ) + ABS( AIMAG( ZDUM ) )
00102 *     ..
00103 *     .. Executable Statements ..
00104 *
00105       CLA_SYRCOND_C = 0.0E+0
00106 *
00107       INFO = 0
00108       IF( N.LT.0 ) THEN
00109          INFO = -2
00110       END IF
00111       IF( INFO.NE.0 ) THEN
00112          CALL XERBLA( 'CLA_SYRCOND_C', -INFO )
00113          RETURN
00114       END IF
00115       UP = .FALSE.
00116       IF ( LSAME( UPLO, 'U' ) ) UP = .TRUE.
00117 *
00118 *     Compute norm of op(A)*op2(C).
00119 *
00120       ANORM = 0.0E+0
00121       IF ( UP ) THEN
00122          DO I = 1, N
00123             TMP = 0.0E+0
00124             IF ( CAPPLY ) THEN
00125                DO J = 1, I
00126                   TMP = TMP + CABS1( A( J, I ) ) / C( J )
00127                END DO
00128                DO J = I+1, N
00129                   TMP = TMP + CABS1( A( I, J ) ) / C( J )
00130                END DO
00131             ELSE
00132                DO J = 1, I
00133                   TMP = TMP + CABS1( A( J, I ) )
00134                END DO
00135                DO J = I+1, N
00136                   TMP = TMP + CABS1( A( I, J ) )
00137                END DO
00138             END IF
00139             RWORK( I ) = TMP
00140             ANORM = MAX( ANORM, TMP )
00141          END DO
00142       ELSE
00143          DO I = 1, N
00144             TMP = 0.0E+0
00145             IF ( CAPPLY ) THEN
00146                DO J = 1, I
00147                   TMP = TMP + CABS1( A( I, J ) ) / C( J )
00148                END DO
00149                DO J = I+1, N
00150                   TMP = TMP + CABS1( A( J, I ) ) / C( J )
00151                END DO
00152             ELSE
00153                DO J = 1, I
00154                   TMP = TMP + CABS1( A( I, J ) )
00155                END DO
00156                DO J = I+1, N
00157                   TMP = TMP + CABS1( A( J, I ) )
00158                END DO
00159             END IF
00160             RWORK( I ) = TMP
00161             ANORM = MAX( ANORM, TMP )
00162          END DO
00163       END IF
00164 *
00165 *     Quick return if possible.
00166 *
00167       IF( N.EQ.0 ) THEN
00168          CLA_SYRCOND_C = 1.0E+0
00169          RETURN
00170       ELSE IF( ANORM .EQ. 0.0E+0 ) THEN
00171          RETURN
00172       END IF
00173 *
00174 *     Estimate the norm of inv(op(A)).
00175 *
00176       AINVNM = 0.0E+0
00177 *
00178       KASE = 0
00179    10 CONTINUE
00180       CALL CLACN2( N, WORK( N+1 ), WORK, AINVNM, KASE, ISAVE )
00181       IF( KASE.NE.0 ) THEN
00182          IF( KASE.EQ.2 ) THEN
00183 *
00184 *           Multiply by R.
00185 *
00186             DO I = 1, N
00187                WORK( I ) = WORK( I ) * RWORK( I )
00188             END DO
00189 *
00190             IF ( UP ) THEN
00191                CALL CSYTRS( 'U', N, 1, AF, LDAF, IPIV,
00192      \$            WORK, N, INFO )
00193             ELSE
00194                CALL CSYTRS( 'L', N, 1, AF, LDAF, IPIV,
00195      \$            WORK, N, INFO )
00196             ENDIF
00197 *
00198 *           Multiply by inv(C).
00199 *
00200             IF ( CAPPLY ) THEN
00201                DO I = 1, N
00202                   WORK( I ) = WORK( I ) * C( I )
00203                END DO
00204             END IF
00205          ELSE
00206 *
00207 *           Multiply by inv(C**T).
00208 *
00209             IF ( CAPPLY ) THEN
00210                DO I = 1, N
00211                   WORK( I ) = WORK( I ) * C( I )
00212                END DO
00213             END IF
00214 *
00215             IF ( UP ) THEN
00216                CALL CSYTRS( 'U', N, 1, AF, LDAF, IPIV,
00217      \$            WORK, N, INFO )
00218             ELSE
00219                CALL CSYTRS( 'L', N, 1, AF, LDAF, IPIV,
00220      \$            WORK, N, INFO )
00221             END IF
00222 *
00223 *           Multiply by R.
00224 *
00225             DO I = 1, N
00226                WORK( I ) = WORK( I ) * RWORK( I )
00227             END DO
00228          END IF
00229          GO TO 10
00230       END IF
00231 *
00232 *     Compute the estimate of the reciprocal condition number.
00233 *
00234       IF( AINVNM .NE. 0.0E+0 )
00235      \$   CLA_SYRCOND_C = 1.0E+0 / AINVNM
00236 *
00237       RETURN
00238 *
00239       END
```