![]() |
LAPACK
3.4.1
LAPACK: Linear Algebra PACKage
|
00001 *> \brief \b SPOEQU 00002 * 00003 * =========== DOCUMENTATION =========== 00004 * 00005 * Online html documentation available at 00006 * http://www.netlib.org/lapack/explore-html/ 00007 * 00008 *> \htmlonly 00009 *> Download SPOEQU + dependencies 00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/spoequ.f"> 00011 *> [TGZ]</a> 00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/spoequ.f"> 00013 *> [ZIP]</a> 00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/spoequ.f"> 00015 *> [TXT]</a> 00016 *> \endhtmlonly 00017 * 00018 * Definition: 00019 * =========== 00020 * 00021 * SUBROUTINE SPOEQU( 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 SPOEQU( 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 00137 * .. 00138 * .. External Subroutines .. 00139 EXTERNAL XERBLA 00140 * .. 00141 * .. Intrinsic Functions .. 00142 INTRINSIC MAX, MIN, SQRT 00143 * .. 00144 * .. Executable Statements .. 00145 * 00146 * Test the input parameters. 00147 * 00148 INFO = 0 00149 IF( N.LT.0 ) THEN 00150 INFO = -1 00151 ELSE IF( LDA.LT.MAX( 1, N ) ) THEN 00152 INFO = -3 00153 END IF 00154 IF( INFO.NE.0 ) THEN 00155 CALL XERBLA( 'SPOEQU', -INFO ) 00156 RETURN 00157 END IF 00158 * 00159 * Quick return if possible 00160 * 00161 IF( N.EQ.0 ) THEN 00162 SCOND = ONE 00163 AMAX = ZERO 00164 RETURN 00165 END IF 00166 * 00167 * Find the minimum and maximum diagonal elements. 00168 * 00169 S( 1 ) = A( 1, 1 ) 00170 SMIN = S( 1 ) 00171 AMAX = S( 1 ) 00172 DO 10 I = 2, N 00173 S( I ) = A( I, I ) 00174 SMIN = MIN( SMIN, S( I ) ) 00175 AMAX = MAX( AMAX, S( I ) ) 00176 10 CONTINUE 00177 * 00178 IF( SMIN.LE.ZERO ) THEN 00179 * 00180 * Find the first non-positive diagonal element and return. 00181 * 00182 DO 20 I = 1, N 00183 IF( S( I ).LE.ZERO ) THEN 00184 INFO = I 00185 RETURN 00186 END IF 00187 20 CONTINUE 00188 ELSE 00189 * 00190 * Set the scale factors to the reciprocals 00191 * of the diagonal elements. 00192 * 00193 DO 30 I = 1, N 00194 S( I ) = ONE / SQRT( S( I ) ) 00195 30 CONTINUE 00196 * 00197 * Compute SCOND = min(S(I)) / max(S(I)) 00198 * 00199 SCOND = SQRT( SMIN ) / SQRT( AMAX ) 00200 END IF 00201 RETURN 00202 * 00203 * End of SPOEQU 00204 * 00205 END