LAPACK 3.3.0

spoequ.f

Go to the documentation of this file.
00001       SUBROUTINE SPOEQU( N, A, LDA, S, SCOND, AMAX, INFO )
00002 *
00003 *  -- LAPACK routine (version 3.2) --
00004 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00005 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00006 *     November 2006
00007 *
00008 *     .. Scalar Arguments ..
00009       INTEGER            INFO, LDA, N
00010       REAL               AMAX, SCOND
00011 *     ..
00012 *     .. Array Arguments ..
00013       REAL               A( LDA, * ), S( * )
00014 *     ..
00015 *
00016 *  Purpose
00017 *  =======
00018 *
00019 *  SPOEQU computes row and column scalings intended to equilibrate a
00020 *  symmetric positive definite matrix A and reduce its condition number
00021 *  (with respect to the two-norm).  S contains the scale factors,
00022 *  S(i) = 1/sqrt(A(i,i)), chosen so that the scaled matrix B with
00023 *  elements B(i,j) = S(i)*A(i,j)*S(j) has ones on the diagonal.  This
00024 *  choice of S puts the condition number of B within a factor N of the
00025 *  smallest possible condition number over all possible diagonal
00026 *  scalings.
00027 *
00028 *  Arguments
00029 *  =========
00030 *
00031 *  N       (input) INTEGER
00032 *          The order of the matrix A.  N >= 0.
00033 *
00034 *  A       (input) REAL array, dimension (LDA,N)
00035 *          The N-by-N symmetric positive definite matrix whose scaling
00036 *          factors are to be computed.  Only the diagonal elements of A
00037 *          are referenced.
00038 *
00039 *  LDA     (input) INTEGER
00040 *          The leading dimension of the array A.  LDA >= max(1,N).
00041 *
00042 *  S       (output) REAL array, dimension (N)
00043 *          If INFO = 0, S contains the scale factors for A.
00044 *
00045 *  SCOND   (output) REAL
00046 *          If INFO = 0, S contains the ratio of the smallest S(i) to
00047 *          the largest S(i).  If SCOND >= 0.1 and AMAX is neither too
00048 *          large nor too small, it is not worth scaling by S.
00049 *
00050 *  AMAX    (output) REAL
00051 *          Absolute value of largest matrix element.  If AMAX is very
00052 *          close to overflow or very close to underflow, the matrix
00053 *          should be scaled.
00054 *
00055 *  INFO    (output) INTEGER
00056 *          = 0:  successful exit
00057 *          < 0:  if INFO = -i, the i-th argument had an illegal value
00058 *          > 0:  if INFO = i, the i-th diagonal element is nonpositive.
00059 *
00060 *  =====================================================================
00061 *
00062 *     .. Parameters ..
00063       REAL               ZERO, ONE
00064       PARAMETER          ( ZERO = 0.0E+0, ONE = 1.0E+0 )
00065 *     ..
00066 *     .. Local Scalars ..
00067       INTEGER            I
00068       REAL               SMIN
00069 *     ..
00070 *     .. External Subroutines ..
00071       EXTERNAL           XERBLA
00072 *     ..
00073 *     .. Intrinsic Functions ..
00074       INTRINSIC          MAX, MIN, SQRT
00075 *     ..
00076 *     .. Executable Statements ..
00077 *
00078 *     Test the input parameters.
00079 *
00080       INFO = 0
00081       IF( N.LT.0 ) THEN
00082          INFO = -1
00083       ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
00084          INFO = -3
00085       END IF
00086       IF( INFO.NE.0 ) THEN
00087          CALL XERBLA( 'SPOEQU', -INFO )
00088          RETURN
00089       END IF
00090 *
00091 *     Quick return if possible
00092 *
00093       IF( N.EQ.0 ) THEN
00094          SCOND = ONE
00095          AMAX = ZERO
00096          RETURN
00097       END IF
00098 *
00099 *     Find the minimum and maximum diagonal elements.
00100 *
00101       S( 1 ) = A( 1, 1 )
00102       SMIN = S( 1 )
00103       AMAX = S( 1 )
00104       DO 10 I = 2, N
00105          S( I ) = A( I, I )
00106          SMIN = MIN( SMIN, S( I ) )
00107          AMAX = MAX( AMAX, S( I ) )
00108    10 CONTINUE
00109 *
00110       IF( SMIN.LE.ZERO ) THEN
00111 *
00112 *        Find the first non-positive diagonal element and return.
00113 *
00114          DO 20 I = 1, N
00115             IF( S( I ).LE.ZERO ) THEN
00116                INFO = I
00117                RETURN
00118             END IF
00119    20    CONTINUE
00120       ELSE
00121 *
00122 *        Set the scale factors to the reciprocals
00123 *        of the diagonal elements.
00124 *
00125          DO 30 I = 1, N
00126             S( I ) = ONE / SQRT( S( I ) )
00127    30    CONTINUE
00128 *
00129 *        Compute SCOND = min(S(I)) / max(S(I))
00130 *
00131          SCOND = SQRT( SMIN ) / SQRT( AMAX )
00132       END IF
00133       RETURN
00134 *
00135 *     End of SPOEQU
00136 *
00137       END
 All Files Functions