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