00001 SUBROUTINE DLATDF( IJOB, N, Z, LDZ, RHS, RDSUM, RDSCAL, IPIV, 00002 $ JPIV ) 00003 * 00004 * -- LAPACK auxiliary routine (version 3.2.2) -- 00005 * -- LAPACK is a software package provided by Univ. of Tennessee, -- 00006 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 00007 * June 2010 00008 * 00009 * .. Scalar Arguments .. 00010 INTEGER IJOB, LDZ, N 00011 DOUBLE PRECISION RDSCAL, RDSUM 00012 * .. 00013 * .. Array Arguments .. 00014 INTEGER IPIV( * ), JPIV( * ) 00015 DOUBLE PRECISION RHS( * ), Z( LDZ, * ) 00016 * .. 00017 * 00018 * Purpose 00019 * ======= 00020 * 00021 * DLATDF uses the LU factorization of the n-by-n matrix Z computed by 00022 * DGETC2 and computes a contribution to the reciprocal Dif-estimate 00023 * by solving Z * x = b for x, and choosing the r.h.s. b such that 00024 * the norm of x is as large as possible. On entry RHS = b holds the 00025 * contribution from earlier solved sub-systems, and on return RHS = x. 00026 * 00027 * The factorization of Z returned by DGETC2 has the form Z = P*L*U*Q, 00028 * where P and Q are permutation matrices. L is lower triangular with 00029 * unit diagonal elements and U is upper triangular. 00030 * 00031 * Arguments 00032 * ========= 00033 * 00034 * IJOB (input) INTEGER 00035 * IJOB = 2: First compute an approximative null-vector e 00036 * of Z using DGECON, e is normalized and solve for 00037 * Zx = +-e - f with the sign giving the greater value 00038 * of 2-norm(x). About 5 times as expensive as Default. 00039 * IJOB .ne. 2: Local look ahead strategy where all entries of 00040 * the r.h.s. b is choosen as either +1 or -1 (Default). 00041 * 00042 * N (input) INTEGER 00043 * The number of columns of the matrix Z. 00044 * 00045 * Z (input) DOUBLE PRECISION array, dimension (LDZ, N) 00046 * On entry, the LU part of the factorization of the n-by-n 00047 * matrix Z computed by DGETC2: Z = P * L * U * Q 00048 * 00049 * LDZ (input) INTEGER 00050 * The leading dimension of the array Z. LDA >= max(1, N). 00051 * 00052 * RHS (input/output) DOUBLE PRECISION array, dimension (N) 00053 * On entry, RHS contains contributions from other subsystems. 00054 * On exit, RHS contains the solution of the subsystem with 00055 * entries acoording to the value of IJOB (see above). 00056 * 00057 * RDSUM (input/output) DOUBLE PRECISION 00058 * On entry, the sum of squares of computed contributions to 00059 * the Dif-estimate under computation by DTGSYL, where the 00060 * scaling factor RDSCAL (see below) has been factored out. 00061 * On exit, the corresponding sum of squares updated with the 00062 * contributions from the current sub-system. 00063 * If TRANS = 'T' RDSUM is not touched. 00064 * NOTE: RDSUM only makes sense when DTGSY2 is called by STGSYL. 00065 * 00066 * RDSCAL (input/output) DOUBLE PRECISION 00067 * On entry, scaling factor used to prevent overflow in RDSUM. 00068 * On exit, RDSCAL is updated w.r.t. the current contributions 00069 * in RDSUM. 00070 * If TRANS = 'T', RDSCAL is not touched. 00071 * NOTE: RDSCAL only makes sense when DTGSY2 is called by 00072 * DTGSYL. 00073 * 00074 * IPIV (input) INTEGER array, dimension (N). 00075 * The pivot indices; for 1 <= i <= N, row i of the 00076 * matrix has been interchanged with row IPIV(i). 00077 * 00078 * JPIV (input) INTEGER array, dimension (N). 00079 * The pivot indices; for 1 <= j <= N, column j of the 00080 * matrix has been interchanged with column JPIV(j). 00081 * 00082 * Further Details 00083 * =============== 00084 * 00085 * Based on contributions by 00086 * Bo Kagstrom and Peter Poromaa, Department of Computing Science, 00087 * Umea University, S-901 87 Umea, Sweden. 00088 * 00089 * This routine is a further developed implementation of algorithm 00090 * BSOLVE in [1] using complete pivoting in the LU factorization. 00091 * 00092 * [1] Bo Kagstrom and Lars Westin, 00093 * Generalized Schur Methods with Condition Estimators for 00094 * Solving the Generalized Sylvester Equation, IEEE Transactions 00095 * on Automatic Control, Vol. 34, No. 7, July 1989, pp 745-751. 00096 * 00097 * [2] Peter Poromaa, 00098 * On Efficient and Robust Estimators for the Separation 00099 * between two Regular Matrix Pairs with Applications in 00100 * Condition Estimation. Report IMINF-95.05, Departement of 00101 * Computing Science, Umea University, S-901 87 Umea, Sweden, 1995. 00102 * 00103 * ===================================================================== 00104 * 00105 * .. Parameters .. 00106 INTEGER MAXDIM 00107 PARAMETER ( MAXDIM = 8 ) 00108 DOUBLE PRECISION ZERO, ONE 00109 PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 ) 00110 * .. 00111 * .. Local Scalars .. 00112 INTEGER I, INFO, J, K 00113 DOUBLE PRECISION BM, BP, PMONE, SMINU, SPLUS, TEMP 00114 * .. 00115 * .. Local Arrays .. 00116 INTEGER IWORK( MAXDIM ) 00117 DOUBLE PRECISION WORK( 4*MAXDIM ), XM( MAXDIM ), XP( MAXDIM ) 00118 * .. 00119 * .. External Subroutines .. 00120 EXTERNAL DAXPY, DCOPY, DGECON, DGESC2, DLASSQ, DLASWP, 00121 $ DSCAL 00122 * .. 00123 * .. External Functions .. 00124 DOUBLE PRECISION DASUM, DDOT 00125 EXTERNAL DASUM, DDOT 00126 * .. 00127 * .. Intrinsic Functions .. 00128 INTRINSIC ABS, SQRT 00129 * .. 00130 * .. Executable Statements .. 00131 * 00132 IF( IJOB.NE.2 ) THEN 00133 * 00134 * Apply permutations IPIV to RHS 00135 * 00136 CALL DLASWP( 1, RHS, LDZ, 1, N-1, IPIV, 1 ) 00137 * 00138 * Solve for L-part choosing RHS either to +1 or -1. 00139 * 00140 PMONE = -ONE 00141 * 00142 DO 10 J = 1, N - 1 00143 BP = RHS( J ) + ONE 00144 BM = RHS( J ) - ONE 00145 SPLUS = ONE 00146 * 00147 * Look-ahead for L-part RHS(1:N-1) = + or -1, SPLUS and 00148 * SMIN computed more efficiently than in BSOLVE [1]. 00149 * 00150 SPLUS = SPLUS + DDOT( N-J, Z( J+1, J ), 1, Z( J+1, J ), 1 ) 00151 SMINU = DDOT( N-J, Z( J+1, J ), 1, RHS( J+1 ), 1 ) 00152 SPLUS = SPLUS*RHS( J ) 00153 IF( SPLUS.GT.SMINU ) THEN 00154 RHS( J ) = BP 00155 ELSE IF( SMINU.GT.SPLUS ) THEN 00156 RHS( J ) = BM 00157 ELSE 00158 * 00159 * In this case the updating sums are equal and we can 00160 * choose RHS(J) +1 or -1. The first time this happens 00161 * we choose -1, thereafter +1. This is a simple way to 00162 * get good estimates of matrices like Byers well-known 00163 * example (see [1]). (Not done in BSOLVE.) 00164 * 00165 RHS( J ) = RHS( J ) + PMONE 00166 PMONE = ONE 00167 END IF 00168 * 00169 * Compute the remaining r.h.s. 00170 * 00171 TEMP = -RHS( J ) 00172 CALL DAXPY( N-J, TEMP, Z( J+1, J ), 1, RHS( J+1 ), 1 ) 00173 * 00174 10 CONTINUE 00175 * 00176 * Solve for U-part, look-ahead for RHS(N) = +-1. This is not done 00177 * in BSOLVE and will hopefully give us a better estimate because 00178 * any ill-conditioning of the original matrix is transfered to U 00179 * and not to L. U(N, N) is an approximation to sigma_min(LU). 00180 * 00181 CALL DCOPY( N-1, RHS, 1, XP, 1 ) 00182 XP( N ) = RHS( N ) + ONE 00183 RHS( N ) = RHS( N ) - ONE 00184 SPLUS = ZERO 00185 SMINU = ZERO 00186 DO 30 I = N, 1, -1 00187 TEMP = ONE / Z( I, I ) 00188 XP( I ) = XP( I )*TEMP 00189 RHS( I ) = RHS( I )*TEMP 00190 DO 20 K = I + 1, N 00191 XP( I ) = XP( I ) - XP( K )*( Z( I, K )*TEMP ) 00192 RHS( I ) = RHS( I ) - RHS( K )*( Z( I, K )*TEMP ) 00193 20 CONTINUE 00194 SPLUS = SPLUS + ABS( XP( I ) ) 00195 SMINU = SMINU + ABS( RHS( I ) ) 00196 30 CONTINUE 00197 IF( SPLUS.GT.SMINU ) 00198 $ CALL DCOPY( N, XP, 1, RHS, 1 ) 00199 * 00200 * Apply the permutations JPIV to the computed solution (RHS) 00201 * 00202 CALL DLASWP( 1, RHS, LDZ, 1, N-1, JPIV, -1 ) 00203 * 00204 * Compute the sum of squares 00205 * 00206 CALL DLASSQ( N, RHS, 1, RDSCAL, RDSUM ) 00207 * 00208 ELSE 00209 * 00210 * IJOB = 2, Compute approximate nullvector XM of Z 00211 * 00212 CALL DGECON( 'I', N, Z, LDZ, ONE, TEMP, WORK, IWORK, INFO ) 00213 CALL DCOPY( N, WORK( N+1 ), 1, XM, 1 ) 00214 * 00215 * Compute RHS 00216 * 00217 CALL DLASWP( 1, XM, LDZ, 1, N-1, IPIV, -1 ) 00218 TEMP = ONE / SQRT( DDOT( N, XM, 1, XM, 1 ) ) 00219 CALL DSCAL( N, TEMP, XM, 1 ) 00220 CALL DCOPY( N, XM, 1, XP, 1 ) 00221 CALL DAXPY( N, ONE, RHS, 1, XP, 1 ) 00222 CALL DAXPY( N, -ONE, XM, 1, RHS, 1 ) 00223 CALL DGESC2( N, Z, LDZ, RHS, IPIV, JPIV, TEMP ) 00224 CALL DGESC2( N, Z, LDZ, XP, IPIV, JPIV, TEMP ) 00225 IF( DASUM( N, XP, 1 ).GT.DASUM( N, RHS, 1 ) ) 00226 $ CALL DCOPY( N, XP, 1, RHS, 1 ) 00227 * 00228 * Compute the sum of squares 00229 * 00230 CALL DLASSQ( N, RHS, 1, RDSCAL, RDSUM ) 00231 * 00232 END IF 00233 * 00234 RETURN 00235 * 00236 * End of DLATDF 00237 * 00238 END