LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
cpoequ.f
Go to the documentation of this file.
00001 *> \brief \b CPOEQU
00002 *
00003 *  =========== DOCUMENTATION ===========
00004 *
00005 * Online html documentation available at 
00006 *            http://www.netlib.org/lapack/explore-html/ 
00007 *
00008 *> \htmlonly
00009 *> Download CPOEQU + dependencies 
00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cpoequ.f"> 
00011 *> [TGZ]</a> 
00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cpoequ.f"> 
00013 *> [ZIP]</a> 
00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cpoequ.f"> 
00015 *> [TXT]</a>
00016 *> \endhtmlonly 
00017 *
00018 *  Definition:
00019 *  ===========
00020 *
00021 *       SUBROUTINE CPOEQU( N, A, LDA, S, SCOND, AMAX, INFO )
00022 * 
00023 *       .. Scalar Arguments ..
00024 *       INTEGER            INFO, LDA, N
00025 *       REAL               AMAX, SCOND
00026 *       ..
00027 *       .. Array Arguments ..
00028 *       REAL               S( * )
00029 *       COMPLEX            A( LDA, * )
00030 *       ..
00031 *  
00032 *
00033 *> \par Purpose:
00034 *  =============
00035 *>
00036 *> \verbatim
00037 *>
00038 *> CPOEQU computes row and column scalings intended to equilibrate a
00039 *> Hermitian positive definite matrix A and reduce its condition number
00040 *> (with respect to the two-norm).  S contains the scale factors,
00041 *> S(i) = 1/sqrt(A(i,i)), chosen so that the scaled matrix B with
00042 *> elements B(i,j) = S(i)*A(i,j)*S(j) has ones on the diagonal.  This
00043 *> choice of S puts the condition number of B within a factor N of the
00044 *> smallest possible condition number over all possible diagonal
00045 *> scalings.
00046 *> \endverbatim
00047 *
00048 *  Arguments:
00049 *  ==========
00050 *
00051 *> \param[in] N
00052 *> \verbatim
00053 *>          N is INTEGER
00054 *>          The order of the matrix A.  N >= 0.
00055 *> \endverbatim
00056 *>
00057 *> \param[in] A
00058 *> \verbatim
00059 *>          A is COMPLEX array, dimension (LDA,N)
00060 *>          The N-by-N Hermitian positive definite matrix whose scaling
00061 *>          factors are to be computed.  Only the diagonal elements of A
00062 *>          are referenced.
00063 *> \endverbatim
00064 *>
00065 *> \param[in] LDA
00066 *> \verbatim
00067 *>          LDA is INTEGER
00068 *>          The leading dimension of the array A.  LDA >= max(1,N).
00069 *> \endverbatim
00070 *>
00071 *> \param[out] S
00072 *> \verbatim
00073 *>          S is REAL array, dimension (N)
00074 *>          If INFO = 0, S contains the scale factors for A.
00075 *> \endverbatim
00076 *>
00077 *> \param[out] SCOND
00078 *> \verbatim
00079 *>          SCOND is REAL
00080 *>          If INFO = 0, S contains the ratio of the smallest S(i) to
00081 *>          the largest S(i).  If SCOND >= 0.1 and AMAX is neither too
00082 *>          large nor too small, it is not worth scaling by S.
00083 *> \endverbatim
00084 *>
00085 *> \param[out] AMAX
00086 *> \verbatim
00087 *>          AMAX is REAL
00088 *>          Absolute value of largest matrix element.  If AMAX is very
00089 *>          close to overflow or very close to underflow, the matrix
00090 *>          should be scaled.
00091 *> \endverbatim
00092 *>
00093 *> \param[out] INFO
00094 *> \verbatim
00095 *>          INFO is INTEGER
00096 *>          = 0:  successful exit
00097 *>          < 0:  if INFO = -i, the i-th argument had an illegal value
00098 *>          > 0:  if INFO = i, the i-th diagonal element is nonpositive.
00099 *> \endverbatim
00100 *
00101 *  Authors:
00102 *  ========
00103 *
00104 *> \author Univ. of Tennessee 
00105 *> \author Univ. of California Berkeley 
00106 *> \author Univ. of Colorado Denver 
00107 *> \author NAG Ltd. 
00108 *
00109 *> \date November 2011
00110 *
00111 *> \ingroup complexPOcomputational
00112 *
00113 *  =====================================================================
00114       SUBROUTINE CPOEQU( N, A, LDA, S, SCOND, AMAX, INFO )
00115 *
00116 *  -- LAPACK computational routine (version 3.4.0) --
00117 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00118 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00119 *     November 2011
00120 *
00121 *     .. Scalar Arguments ..
00122       INTEGER            INFO, LDA, N
00123       REAL               AMAX, SCOND
00124 *     ..
00125 *     .. Array Arguments ..
00126       REAL               S( * )
00127       COMPLEX            A( LDA, * )
00128 *     ..
00129 *
00130 *  =====================================================================
00131 *
00132 *     .. Parameters ..
00133       REAL               ZERO, ONE
00134       PARAMETER          ( ZERO = 0.0E+0, ONE = 1.0E+0 )
00135 *     ..
00136 *     .. Local Scalars ..
00137       INTEGER            I
00138       REAL               SMIN
00139 *     ..
00140 *     .. External Subroutines ..
00141       EXTERNAL           XERBLA
00142 *     ..
00143 *     .. Intrinsic Functions ..
00144       INTRINSIC          MAX, MIN, REAL, SQRT
00145 *     ..
00146 *     .. Executable Statements ..
00147 *
00148 *     Test the input parameters.
00149 *
00150       INFO = 0
00151       IF( N.LT.0 ) THEN
00152          INFO = -1
00153       ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
00154          INFO = -3
00155       END IF
00156       IF( INFO.NE.0 ) THEN
00157          CALL XERBLA( 'CPOEQU', -INFO )
00158          RETURN
00159       END IF
00160 *
00161 *     Quick return if possible
00162 *
00163       IF( N.EQ.0 ) THEN
00164          SCOND = ONE
00165          AMAX = ZERO
00166          RETURN
00167       END IF
00168 *
00169 *     Find the minimum and maximum diagonal elements.
00170 *
00171       S( 1 ) = REAL( A( 1, 1 ) )
00172       SMIN = S( 1 )
00173       AMAX = S( 1 )
00174       DO 10 I = 2, N
00175          S( I ) = REAL( A( I, I ) )
00176          SMIN = MIN( SMIN, S( I ) )
00177          AMAX = MAX( AMAX, S( I ) )
00178    10 CONTINUE
00179 *
00180       IF( SMIN.LE.ZERO ) THEN
00181 *
00182 *        Find the first non-positive diagonal element and return.
00183 *
00184          DO 20 I = 1, N
00185             IF( S( I ).LE.ZERO ) THEN
00186                INFO = I
00187                RETURN
00188             END IF
00189    20    CONTINUE
00190       ELSE
00191 *
00192 *        Set the scale factors to the reciprocals
00193 *        of the diagonal elements.
00194 *
00195          DO 30 I = 1, N
00196             S( I ) = ONE / SQRT( S( I ) )
00197    30    CONTINUE
00198 *
00199 *        Compute SCOND = min(S(I)) / max(S(I))
00200 *
00201          SCOND = SQRT( SMIN ) / SQRT( AMAX )
00202       END IF
00203       RETURN
00204 *
00205 *     End of CPOEQU
00206 *
00207       END
 All Files Functions