1 *> \brief \b SLATDF uses the LU factorization of the n-by-n matrix computed by sgetc2 and computes a contribution to the reciprocal Dif-estimate.
3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download SLATDF + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/slatdf.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/slatdf.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/slatdf.f">
21 * SUBROUTINE SLATDF( IJOB, N, Z, LDZ, RHS, RDSUM, RDSCAL, IPIV,
24 * .. Scalar Arguments ..
25 * INTEGER IJOB, LDZ, N
28 * .. Array Arguments ..
29 * INTEGER IPIV( * ), JPIV( * )
30 * REAL RHS( * ), Z( LDZ, * )
39 *> SLATDF uses the LU factorization of the n-by-n matrix Z computed by
40 *> SGETC2 and computes a contribution to the reciprocal Dif-estimate
41 *> by solving Z * x = b for x, and choosing the r.h.s. b such that
42 *> the norm of x is as large as possible. On entry RHS = b holds the
43 *> contribution from earlier solved sub-systems, and on return RHS = x.
45 *> The factorization of Z returned by SGETC2 has the form Z = P*L*U*Q,
46 *> where P and Q are permutation matrices. L is lower triangular with
47 *> unit diagonal elements and U is upper triangular.
56 *> IJOB = 2: First compute an approximative null-vector e
57 *> of Z using SGECON, e is normalized and solve for
58 *> Zx = +-e - f with the sign giving the greater value
59 *> of 2-norm(x). About 5 times as expensive as Default.
60 *> IJOB .ne. 2: Local look ahead strategy where all entries of
61 *> the r.h.s. b is chosen as either +1 or -1 (Default).
67 *> The number of columns of the matrix Z.
72 *> Z is REAL array, dimension (LDZ, N)
73 *> On entry, the LU part of the factorization of the n-by-n
74 *> matrix Z computed by SGETC2: Z = P * L * U * Q
80 *> The leading dimension of the array Z. LDA >= max(1, N).
85 *> RHS is REAL array, dimension N.
86 *> On entry, RHS contains contributions from other subsystems.
87 *> On exit, RHS contains the solution of the subsystem with
88 *> entries acoording to the value of IJOB (see above).
91 *> \param[in,out] RDSUM
94 *> On entry, the sum of squares of computed contributions to
95 *> the Dif-estimate under computation by STGSYL, where the
96 *> scaling factor RDSCAL (see below) has been factored out.
97 *> On exit, the corresponding sum of squares updated with the
98 *> contributions from the current sub-system.
99 *> If TRANS = 'T' RDSUM is not touched.
100 *> NOTE: RDSUM only makes sense when STGSY2 is called by STGSYL.
103 *> \param[in,out] RDSCAL
106 *> On entry, scaling factor used to prevent overflow in RDSUM.
107 *> On exit, RDSCAL is updated w.r.t. the current contributions
109 *> If TRANS = 'T', RDSCAL is not touched.
110 *> NOTE: RDSCAL only makes sense when STGSY2 is called by
116 *> IPIV is INTEGER array, dimension (N).
117 *> The pivot indices; for 1 <= i <= N, row i of the
118 *> matrix has been interchanged with row IPIV(i).
123 *> JPIV is INTEGER array, dimension (N).
124 *> The pivot indices; for 1 <= j <= N, column j of the
125 *> matrix has been interchanged with column JPIV(j).
131 *> \author Univ. of Tennessee
132 *> \author Univ. of California Berkeley
133 *> \author Univ. of Colorado Denver
138 *> \ingroup realOTHERauxiliary
140 *> \par Further Details:
141 * =====================
143 *> This routine is a further developed implementation of algorithm
144 *> BSOLVE in [1] using complete pivoting in the LU factorization.
146 *> \par Contributors:
149 *> Bo Kagstrom and Peter Poromaa, Department of Computing Science,
150 *> Umea University, S-901 87 Umea, Sweden.
158 *> [1] Bo Kagstrom and Lars Westin,
159 *> Generalized Schur Methods with Condition Estimators for
160 *> Solving the Generalized Sylvester Equation, IEEE Transactions
161 *> on Automatic Control, Vol. 34, No. 7, July 1989, pp 745-751.
163 *> [2] Peter Poromaa,
164 *> On Efficient and Robust Estimators for the Separation
165 *> between two Regular Matrix Pairs with Applications in
166 *> Condition Estimation. Report IMINF-95.05, Departement of
167 *> Computing Science, Umea University, S-901 87 Umea, Sweden, 1995.
170 * =====================================================================
171 SUBROUTINE SLATDF( IJOB, N, Z, LDZ, RHS, RDSUM, RDSCAL, IPIV,
174 * -- LAPACK auxiliary routine (version 3.6.1) --
175 * -- LAPACK is a software package provided by Univ. of Tennessee, --
176 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
179 * .. Scalar Arguments ..
183 * .. Array Arguments ..
184 INTEGER IPIV( * ), JPIV( * )
185 REAL RHS( * ), Z( LDZ, * )
188 * =====================================================================
192 PARAMETER ( MAXDIM = 8 )
194 PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 )
196 * .. Local Scalars ..
197 INTEGER I, INFO, J, K
198 REAL BM, BP, PMONE, SMINU, SPLUS, TEMP
201 INTEGER IWORK( MAXDIM )
202 REAL WORK( 4*MAXDIM ), XM( MAXDIM ), XP( MAXDIM )
204 * .. External Subroutines ..
205 EXTERNAL SAXPY, SCOPY, SGECON, SGESC2, SLASSQ, SLASWP,
208 * .. External Functions ..
212 * .. Intrinsic Functions ..
215 * .. Executable Statements ..
219 * Apply permutations IPIV to RHS
221 CALL SLASWP( 1, RHS, LDZ, 1, N-1, IPIV, 1 )
223 * Solve for L-part choosing RHS either to +1 or -1.
232 * Look-ahead for L-part RHS(1:N-1) = + or -1, SPLUS and
233 * SMIN computed more efficiently than in BSOLVE [1].
235 SPLUS = SPLUS + SDOT( N-J, Z( J+1, J ), 1, Z( J+1, J ), 1 )
236 SMINU = SDOT( N-J, Z( J+1, J ), 1, RHS( J+1 ), 1 )
237 SPLUS = SPLUS*RHS( J )
238 IF( SPLUS.GT.SMINU ) THEN
240 ELSE IF( SMINU.GT.SPLUS ) THEN
244 * In this case the updating sums are equal and we can
245 * choose RHS(J) +1 or -1. The first time this happens
246 * we choose -1, thereafter +1. This is a simple way to
247 * get good estimates of matrices like Byers well-known
248 * example (see [1]). (Not done in BSOLVE.)
250 RHS( J ) = RHS( J ) + PMONE
254 * Compute the remaining r.h.s.
257 CALL SAXPY( N-J, TEMP, Z( J+1, J ), 1, RHS( J+1 ), 1 )
261 * Solve for U-part, look-ahead for RHS(N) = +-1. This is not done
262 * in BSOLVE and will hopefully give us a better estimate because
263 * any ill-conditioning of the original matrix is transfered to U
264 * and not to L. U(N, N) is an approximation to sigma_min(LU).
266 CALL SCOPY( N-1, RHS, 1, XP, 1 )
267 XP( N ) = RHS( N ) + ONE
268 RHS( N ) = RHS( N ) - ONE
272 TEMP = ONE / Z( I, I )
273 XP( I ) = XP( I )*TEMP
274 RHS( I ) = RHS( I )*TEMP
276 XP( I ) = XP( I ) - XP( K )*( Z( I, K )*TEMP )
277 RHS( I ) = RHS( I ) - RHS( K )*( Z( I, K )*TEMP )
279 SPLUS = SPLUS + ABS( XP( I ) )
280 SMINU = SMINU + ABS( RHS( I ) )
283 $ CALL SCOPY( N, XP, 1, RHS, 1 )
285 * Apply the permutations JPIV to the computed solution (RHS)
287 CALL SLASWP( 1, RHS, LDZ, 1, N-1, JPIV, -1 )
289 * Compute the sum of squares
291 CALL SLASSQ( N, RHS, 1, RDSCAL, RDSUM )
295 * IJOB = 2, Compute approximate nullvector XM of Z
297 CALL SGECON( 'I', N, Z, LDZ, ONE, TEMP, WORK, IWORK, INFO )
298 CALL SCOPY( N, WORK( N+1 ), 1, XM, 1 )
302 CALL SLASWP( 1, XM, LDZ, 1, N-1, IPIV, -1 )
303 TEMP = ONE / SQRT( SDOT( N, XM, 1, XM, 1 ) )
304 CALL SSCAL( N, TEMP, XM, 1 )
305 CALL SCOPY( N, XM, 1, XP, 1 )
306 CALL SAXPY( N, ONE, RHS, 1, XP, 1 )
307 CALL SAXPY( N, -ONE, XM, 1, RHS, 1 )
308 CALL SGESC2( N, Z, LDZ, RHS, IPIV, JPIV, TEMP )
309 CALL SGESC2( N, Z, LDZ, XP, IPIV, JPIV, TEMP )
310 IF( SASUM( N, XP, 1 ).GT.SASUM( N, RHS, 1 ) )
311 $ CALL SCOPY( N, XP, 1, RHS, 1 )
313 * Compute the sum of squares
315 CALL SLASSQ( N, RHS, 1, RDSCAL, RDSUM )