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