LAPACK  3.4.0
LAPACK: Linear Algebra PACKage
cla_porcond_c.f
Go to the documentation of this file.
00001 *> \brief \b CLA_PORCOND_C
00002 *
00003 *  =========== DOCUMENTATION ===========
00004 *
00005 * Online html documentation available at 
00006 *            http://www.netlib.org/lapack/explore-html/ 
00007 *
00008 *> \htmlonly
00009 *> Download CLA_PORCOND_C + dependencies 
00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cla_porcond_c.f"> 
00011 *> [TGZ]</a> 
00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cla_porcond_c.f"> 
00013 *> [ZIP]</a> 
00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cla_porcond_c.f"> 
00015 *> [TXT]</a>
00016 *> \endhtmlonly 
00017 *
00018 *  Definition:
00019 *  ===========
00020 *
00021 *       REAL FUNCTION CLA_PORCOND_C( UPLO, N, A, LDA, AF, LDAF, C, CAPPLY,
00022 *                                    INFO, WORK, RWORK )
00023 * 
00024 *       .. Scalar Arguments ..
00025 *       CHARACTER          UPLO
00026 *       LOGICAL            CAPPLY
00027 *       INTEGER            N, LDA, LDAF, INFO
00028 *       ..
00029 *       .. Array Arguments ..
00030 *       COMPLEX            A( LDA, * ), AF( LDAF, * ), WORK( * )
00031 *       REAL               C( * ), RWORK( * )
00032 *       ..
00033 *  
00034 *
00035 *> \par Purpose:
00036 *  =============
00037 *>
00038 *> \verbatim
00039 *>
00040 *>    CLA_PORCOND_C Computes the infinity norm condition number of
00041 *>    op(A) * inv(diag(C)) where C is a DOUBLE PRECISION vector
00042 *> \endverbatim
00043 *
00044 *  Arguments:
00045 *  ==========
00046 *
00047 *> \param[in] UPLO
00048 *> \verbatim
00049 *>          UPLO is CHARACTER*1
00050 *>       = 'U':  Upper triangle of A is stored;
00051 *>       = 'L':  Lower triangle of A is stored.
00052 *> \endverbatim
00053 *>
00054 *> \param[in] N
00055 *> \verbatim
00056 *>          N is INTEGER
00057 *>     The number of linear equations, i.e., the order of the
00058 *>     matrix A.  N >= 0.
00059 *> \endverbatim
00060 *>
00061 *> \param[in] A
00062 *> \verbatim
00063 *>          A is COMPLEX array, dimension (LDA,N)
00064 *>     On entry, the N-by-N matrix A
00065 *> \endverbatim
00066 *>
00067 *> \param[in] LDA
00068 *> \verbatim
00069 *>          LDA is INTEGER
00070 *>     The leading dimension of the array A.  LDA >= max(1,N).
00071 *> \endverbatim
00072 *>
00073 *> \param[in] AF
00074 *> \verbatim
00075 *>          AF is COMPLEX array, dimension (LDAF,N)
00076 *>     The triangular factor U or L from the Cholesky factorization
00077 *>     A = U**H*U or A = L*L**H, as computed by CPOTRF.
00078 *> \endverbatim
00079 *>
00080 *> \param[in] LDAF
00081 *> \verbatim
00082 *>          LDAF is INTEGER
00083 *>     The leading dimension of the array AF.  LDAF >= max(1,N).
00084 *> \endverbatim
00085 *>
00086 *> \param[in] C
00087 *> \verbatim
00088 *>          C is REAL array, dimension (N)
00089 *>     The vector C in the formula op(A) * inv(diag(C)).
00090 *> \endverbatim
00091 *>
00092 *> \param[in] CAPPLY
00093 *> \verbatim
00094 *>          CAPPLY is LOGICAL
00095 *>     If .TRUE. then access the vector C in the formula above.
00096 *> \endverbatim
00097 *>
00098 *> \param[out] INFO
00099 *> \verbatim
00100 *>          INFO is INTEGER
00101 *>       = 0:  Successful exit.
00102 *>     i > 0:  The ith argument is invalid.
00103 *> \endverbatim
00104 *>
00105 *> \param[in] WORK
00106 *> \verbatim
00107 *>          WORK is COMPLEX array, dimension (2*N).
00108 *>     Workspace.
00109 *> \endverbatim
00110 *>
00111 *> \param[in] RWORK
00112 *> \verbatim
00113 *>          RWORK is REAL array, dimension (N).
00114 *>     Workspace.
00115 *> \endverbatim
00116 *
00117 *  Authors:
00118 *  ========
00119 *
00120 *> \author Univ. of Tennessee 
00121 *> \author Univ. of California Berkeley 
00122 *> \author Univ. of Colorado Denver 
00123 *> \author NAG Ltd. 
00124 *
00125 *> \date November 2011
00126 *
00127 *> \ingroup complexPOcomputational
00128 *
00129 *  =====================================================================
00130       REAL FUNCTION CLA_PORCOND_C( UPLO, N, A, LDA, AF, LDAF, C, CAPPLY,
00131      $                             INFO, WORK, RWORK )
00132 *
00133 *  -- LAPACK computational routine (version 3.4.0) --
00134 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00135 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00136 *     November 2011
00137 *
00138 *     .. Scalar Arguments ..
00139       CHARACTER          UPLO
00140       LOGICAL            CAPPLY
00141       INTEGER            N, LDA, LDAF, INFO
00142 *     ..
00143 *     .. Array Arguments ..
00144       COMPLEX            A( LDA, * ), AF( LDAF, * ), WORK( * )
00145       REAL               C( * ), RWORK( * )
00146 *     ..
00147 *
00148 *  =====================================================================
00149 *
00150 *     .. Local Scalars ..
00151       INTEGER            KASE
00152       REAL               AINVNM, ANORM, TMP
00153       INTEGER            I, J
00154       LOGICAL            UP
00155       COMPLEX            ZDUM
00156 *     ..
00157 *     .. Local Arrays ..
00158       INTEGER            ISAVE( 3 )
00159 *     ..
00160 *     .. External Functions ..
00161       LOGICAL            LSAME
00162       EXTERNAL           LSAME
00163 *     ..
00164 *     .. External Subroutines ..
00165       EXTERNAL           CLACN2, CPOTRS, XERBLA
00166 *     ..
00167 *     .. Intrinsic Functions ..
00168       INTRINSIC          ABS, MAX, REAL, AIMAG
00169 *     ..
00170 *     .. Statement Functions ..
00171       REAL CABS1
00172 *     ..
00173 *     .. Statement Function Definitions ..
00174       CABS1( ZDUM ) = ABS( REAL( ZDUM ) ) + ABS( AIMAG( ZDUM ) )
00175 *     ..
00176 *     .. Executable Statements ..
00177 *
00178       CLA_PORCOND_C = 0.0E+0
00179 *
00180       INFO = 0
00181       IF( N.LT.0 ) THEN
00182          INFO = -2
00183       END IF
00184       IF( INFO.NE.0 ) THEN
00185          CALL XERBLA( 'CLA_PORCOND_C', -INFO )
00186          RETURN
00187       END IF
00188       UP = .FALSE.
00189       IF ( LSAME( UPLO, 'U' ) ) UP = .TRUE.
00190 *
00191 *     Compute norm of op(A)*op2(C).
00192 *
00193       ANORM = 0.0E+0
00194       IF ( UP ) THEN
00195          DO I = 1, N
00196             TMP = 0.0E+0
00197             IF ( CAPPLY ) THEN
00198                DO J = 1, I
00199                   TMP = TMP + CABS1( A( J, I ) ) / C( J )
00200                END DO
00201                DO J = I+1, N
00202                   TMP = TMP + CABS1( A( I, J ) ) / C( J )
00203                END DO
00204             ELSE
00205                DO J = 1, I
00206                   TMP = TMP + CABS1( A( J, I ) )
00207                END DO
00208                DO J = I+1, N
00209                   TMP = TMP + CABS1( A( I, J ) )
00210                END DO
00211             END IF
00212             RWORK( I ) = TMP
00213             ANORM = MAX( ANORM, TMP )
00214          END DO
00215       ELSE
00216          DO I = 1, N
00217             TMP = 0.0E+0
00218             IF ( CAPPLY ) THEN
00219                DO J = 1, I
00220                   TMP = TMP + CABS1( A( I, J ) ) / C( J )
00221                END DO
00222                DO J = I+1, N
00223                   TMP = TMP + CABS1( A( J, I ) ) / C( J )
00224                END DO
00225             ELSE
00226                DO J = 1, I
00227                   TMP = TMP + CABS1( A( I, J ) )
00228                END DO
00229                DO J = I+1, N
00230                   TMP = TMP + CABS1( A( J, I ) )
00231                END DO
00232             END IF
00233             RWORK( I ) = TMP
00234             ANORM = MAX( ANORM, TMP )
00235          END DO
00236       END IF
00237 *
00238 *     Quick return if possible.
00239 *
00240       IF( N.EQ.0 ) THEN
00241          CLA_PORCOND_C = 1.0E+0
00242          RETURN
00243       ELSE IF( ANORM .EQ. 0.0E+0 ) THEN
00244          RETURN
00245       END IF
00246 *
00247 *     Estimate the norm of inv(op(A)).
00248 *
00249       AINVNM = 0.0E+0
00250 *
00251       KASE = 0
00252    10 CONTINUE
00253       CALL CLACN2( N, WORK( N+1 ), WORK, AINVNM, KASE, ISAVE )
00254       IF( KASE.NE.0 ) THEN
00255          IF( KASE.EQ.2 ) THEN
00256 *
00257 *           Multiply by R.
00258 *
00259             DO I = 1, N
00260                WORK( I ) = WORK( I ) * RWORK( I )
00261             END DO
00262 *
00263             IF ( UP ) THEN
00264                CALL CPOTRS( 'U', N, 1, AF, LDAF,
00265      $            WORK, N, INFO )
00266             ELSE
00267                CALL CPOTRS( 'L', N, 1, AF, LDAF,
00268      $            WORK, N, INFO )
00269             ENDIF
00270 *
00271 *           Multiply by inv(C).
00272 *
00273             IF ( CAPPLY ) THEN
00274                DO I = 1, N
00275                   WORK( I ) = WORK( I ) * C( I )
00276                END DO
00277             END IF
00278          ELSE
00279 *
00280 *           Multiply by inv(C**H).
00281 *
00282             IF ( CAPPLY ) THEN
00283                DO I = 1, N
00284                   WORK( I ) = WORK( I ) * C( I )
00285                END DO
00286             END IF
00287 *
00288             IF ( UP ) THEN
00289                CALL CPOTRS( 'U', N, 1, AF, LDAF,
00290      $            WORK, N, INFO )
00291             ELSE
00292                CALL CPOTRS( 'L', N, 1, AF, LDAF,
00293      $            WORK, N, INFO )
00294             END IF
00295 *
00296 *           Multiply by R.
00297 *
00298             DO I = 1, N
00299                WORK( I ) = WORK( I ) * RWORK( I )
00300             END DO
00301          END IF
00302          GO TO 10
00303       END IF
00304 *
00305 *     Compute the estimate of the reciprocal condition number.
00306 *
00307       IF( AINVNM .NE. 0.0E+0 )
00308      $   CLA_PORCOND_C = 1.0E+0 / AINVNM
00309 *
00310       RETURN
00311 *
00312       END
 All Files Functions