comparison libcruft/lapack/dgeesx.f @ 7034:68db500cb558

[project @ 2007-10-16 18:54:19 by jwe]
author jwe
date Tue, 16 Oct 2007 18:54:23 +0000
parents 15cddaacbc2d
children
comparison
equal deleted inserted replaced
7033:f0142f2afdc6 7034:68db500cb558
1 SUBROUTINE DGEESX( JOBVS, SORT, SELECT, SENSE, N, A, LDA, SDIM, 1 SUBROUTINE DGEESX( JOBVS, SORT, SELECT, SENSE, N, A, LDA, SDIM,
2 $ WR, WI, VS, LDVS, RCONDE, RCONDV, WORK, LWORK, 2 $ WR, WI, VS, LDVS, RCONDE, RCONDV, WORK, LWORK,
3 $ IWORK, LIWORK, BWORK, INFO ) 3 $ IWORK, LIWORK, BWORK, INFO )
4 * 4 *
5 * -- LAPACK driver routine (version 3.0) -- 5 * -- LAPACK driver routine (version 3.1) --
6 * Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd., 6 * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
7 * Courant Institute, Argonne National Lab, and Rice University 7 * November 2006
8 * June 30, 1999
9 * 8 *
10 * .. Scalar Arguments .. 9 * .. Scalar Arguments ..
11 CHARACTER JOBVS, SENSE, SORT 10 CHARACTER JOBVS, SENSE, SORT
12 INTEGER INFO, LDA, LDVS, LIWORK, LWORK, N, SDIM 11 INTEGER INFO, LDA, LDVS, LIWORK, LWORK, N, SDIM
13 DOUBLE PRECISION RCONDE, RCONDV 12 DOUBLE PRECISION RCONDE, RCONDV
61 * Specifies whether or not to order the eigenvalues on the 60 * Specifies whether or not to order the eigenvalues on the
62 * diagonal of the Schur form. 61 * diagonal of the Schur form.
63 * = 'N': Eigenvalues are not ordered; 62 * = 'N': Eigenvalues are not ordered;
64 * = 'S': Eigenvalues are ordered (see SELECT). 63 * = 'S': Eigenvalues are ordered (see SELECT).
65 * 64 *
66 * SELECT (input) LOGICAL FUNCTION of two DOUBLE PRECISION arguments 65 * SELECT (external procedure) LOGICAL FUNCTION of two DOUBLE PRECISION arguments
67 * SELECT must be declared EXTERNAL in the calling subroutine. 66 * SELECT must be declared EXTERNAL in the calling subroutine.
68 * If SORT = 'S', SELECT is used to select eigenvalues to sort 67 * If SORT = 'S', SELECT is used to select eigenvalues to sort
69 * to the top left of the Schur form. 68 * to the top left of the Schur form.
70 * If SORT = 'N', SELECT is not referenced. 69 * If SORT = 'N', SELECT is not referenced.
71 * An eigenvalue WR(j)+sqrt(-1)*WI(j) is selected if 70 * An eigenvalue WR(j)+sqrt(-1)*WI(j) is selected if
127 * RCONDV (output) DOUBLE PRECISION 126 * RCONDV (output) DOUBLE PRECISION
128 * If SENSE = 'V' or 'B', RCONDV contains the reciprocal 127 * If SENSE = 'V' or 'B', RCONDV contains the reciprocal
129 * condition number for the selected right invariant subspace. 128 * condition number for the selected right invariant subspace.
130 * Not referenced if SENSE = 'N' or 'E'. 129 * Not referenced if SENSE = 'N' or 'E'.
131 * 130 *
132 * WORK (workspace/output) DOUBLE PRECISION array, dimension (LWORK) 131 * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
133 * On exit, if INFO = 0, WORK(1) returns the optimal LWORK. 132 * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
134 * 133 *
135 * LWORK (input) INTEGER 134 * LWORK (input) INTEGER
136 * The dimension of the array WORK. LWORK >= max(1,3*N). 135 * The dimension of the array WORK. LWORK >= max(1,3*N).
137 * Also, if SENSE = 'E' or 'V' or 'B', 136 * Also, if SENSE = 'E' or 'V' or 'B',
138 * LWORK >= N+2*SDIM*(N-SDIM), where SDIM is the number of 137 * LWORK >= N+2*SDIM*(N-SDIM), where SDIM is the number of
139 * selected eigenvalues computed by this routine. Note that 138 * selected eigenvalues computed by this routine. Note that
140 * N+2*SDIM*(N-SDIM) <= N+N*N/2. 139 * N+2*SDIM*(N-SDIM) <= N+N*N/2. Note also that an error is only
140 * returned if LWORK < max(1,3*N), but if SENSE = 'E' or 'V' or
141 * 'B' this may not be large enough.
141 * For good performance, LWORK must generally be larger. 142 * For good performance, LWORK must generally be larger.
142 * 143 *
143 * IWORK (workspace/output) INTEGER array, dimension (LIWORK) 144 * If LWORK = -1, then a workspace query is assumed; the routine
144 * Not referenced if SENSE = 'N' or 'E'. 145 * only calculates upper bounds on the optimal sizes of the
146 * arrays WORK and IWORK, returns these values as the first
147 * entries of the WORK and IWORK arrays, and no error messages
148 * related to LWORK or LIWORK are issued by XERBLA.
149 *
150 * IWORK (workspace/output) INTEGER array, dimension (MAX(1,LIWORK))
145 * On exit, if INFO = 0, IWORK(1) returns the optimal LIWORK. 151 * On exit, if INFO = 0, IWORK(1) returns the optimal LIWORK.
146 * 152 *
147 * LIWORK (input) INTEGER 153 * LIWORK (input) INTEGER
148 * The dimension of the array IWORK. 154 * The dimension of the array IWORK.
149 * LIWORK >= 1; if SENSE = 'V' or 'B', LIWORK >= SDIM*(N-SDIM). 155 * LIWORK >= 1; if SENSE = 'V' or 'B', LIWORK >= SDIM*(N-SDIM).
156 * Note that SDIM*(N-SDIM) <= N*N/4. Note also that an error is
157 * only returned if LIWORK < 1, but if SENSE = 'V' or 'B' this
158 * may not be large enough.
159 *
160 * If LIWORK = -1, then a workspace query is assumed; the
161 * routine only calculates upper bounds on the optimal sizes of
162 * the arrays WORK and IWORK, returns these values as the first
163 * entries of the WORK and IWORK arrays, and no error messages
164 * related to LWORK or LIWORK are issued by XERBLA.
150 * 165 *
151 * BWORK (workspace) LOGICAL array, dimension (N) 166 * BWORK (workspace) LOGICAL array, dimension (N)
152 * Not referenced if SORT = 'N'. 167 * Not referenced if SORT = 'N'.
153 * 168 *
154 * INFO (output) INTEGER 169 * INFO (output) INTEGER
173 * .. Parameters .. 188 * .. Parameters ..
174 DOUBLE PRECISION ZERO, ONE 189 DOUBLE PRECISION ZERO, ONE
175 PARAMETER ( ZERO = 0.0D0, ONE = 1.0D0 ) 190 PARAMETER ( ZERO = 0.0D0, ONE = 1.0D0 )
176 * .. 191 * ..
177 * .. Local Scalars .. 192 * .. Local Scalars ..
178 LOGICAL CURSL, LASTSL, LST2SL, SCALEA, WANTSB, WANTSE, 193 LOGICAL CURSL, LASTSL, LQUERY, LST2SL, SCALEA, WANTSB,
179 $ WANTSN, WANTST, WANTSV, WANTVS 194 $ WANTSE, WANTSN, WANTST, WANTSV, WANTVS
180 INTEGER HSWORK, I, I1, I2, IBAL, ICOND, IERR, IEVAL, 195 INTEGER HSWORK, I, I1, I2, IBAL, ICOND, IERR, IEVAL,
181 $ IHI, ILO, INXT, IP, ITAU, IWRK, K, MAXB, 196 $ IHI, ILO, INXT, IP, ITAU, IWRK, LIWRK, LWRK,
182 $ MAXWRK, MINWRK 197 $ MAXWRK, MINWRK
183 DOUBLE PRECISION ANRM, BIGNUM, CSCALE, EPS, SMLNUM 198 DOUBLE PRECISION ANRM, BIGNUM, CSCALE, EPS, SMLNUM
184 * .. 199 * ..
185 * .. Local Arrays .. 200 * .. Local Arrays ..
186 DOUBLE PRECISION DUM( 1 ) 201 DOUBLE PRECISION DUM( 1 )
191 * .. 206 * ..
192 * .. External Functions .. 207 * .. External Functions ..
193 LOGICAL LSAME 208 LOGICAL LSAME
194 INTEGER ILAENV 209 INTEGER ILAENV
195 DOUBLE PRECISION DLAMCH, DLANGE 210 DOUBLE PRECISION DLAMCH, DLANGE
196 EXTERNAL LSAME, ILAENV, DLAMCH, DLANGE 211 EXTERNAL LSAME, ILAENV, DLABAD, DLAMCH, DLANGE
197 * .. 212 * ..
198 * .. Intrinsic Functions .. 213 * .. Intrinsic Functions ..
199 INTRINSIC MAX, MIN, SQRT 214 INTRINSIC MAX, SQRT
200 * .. 215 * ..
201 * .. Executable Statements .. 216 * .. Executable Statements ..
202 * 217 *
203 * Test the input arguments 218 * Test the input arguments
204 * 219 *
207 WANTST = LSAME( SORT, 'S' ) 222 WANTST = LSAME( SORT, 'S' )
208 WANTSN = LSAME( SENSE, 'N' ) 223 WANTSN = LSAME( SENSE, 'N' )
209 WANTSE = LSAME( SENSE, 'E' ) 224 WANTSE = LSAME( SENSE, 'E' )
210 WANTSV = LSAME( SENSE, 'V' ) 225 WANTSV = LSAME( SENSE, 'V' )
211 WANTSB = LSAME( SENSE, 'B' ) 226 WANTSB = LSAME( SENSE, 'B' )
227 LQUERY = ( LWORK.EQ.-1 .OR. LIWORK.EQ.-1 )
212 IF( ( .NOT.WANTVS ) .AND. ( .NOT.LSAME( JOBVS, 'N' ) ) ) THEN 228 IF( ( .NOT.WANTVS ) .AND. ( .NOT.LSAME( JOBVS, 'N' ) ) ) THEN
213 INFO = -1 229 INFO = -1
214 ELSE IF( ( .NOT.WANTST ) .AND. ( .NOT.LSAME( SORT, 'N' ) ) ) THEN 230 ELSE IF( ( .NOT.WANTST ) .AND. ( .NOT.LSAME( SORT, 'N' ) ) ) THEN
215 INFO = -2 231 INFO = -2
216 ELSE IF( .NOT.( WANTSN .OR. WANTSE .OR. WANTSV .OR. WANTSB ) .OR. 232 ELSE IF( .NOT.( WANTSN .OR. WANTSE .OR. WANTSV .OR. WANTSB ) .OR.
236 * the worst case. 252 * the worst case.
237 * If SENSE = 'E', 'V' or 'B', then the amount of workspace needed 253 * If SENSE = 'E', 'V' or 'B', then the amount of workspace needed
238 * depends on SDIM, which is computed by the routine DTRSEN later 254 * depends on SDIM, which is computed by the routine DTRSEN later
239 * in the code.) 255 * in the code.)
240 * 256 *
241 MINWRK = 1 257 IF( INFO.EQ.0 ) THEN
242 IF( INFO.EQ.0 .AND. LWORK.GE.1 ) THEN 258 LIWRK = 1
243 MAXWRK = 2*N + N*ILAENV( 1, 'DGEHRD', ' ', N, 1, N, 0 ) 259 IF( N.EQ.0 ) THEN
244 MINWRK = MAX( 1, 3*N ) 260 MINWRK = 1
245 IF( .NOT.WANTVS ) THEN 261 LWRK = 1
246 MAXB = MAX( ILAENV( 8, 'DHSEQR', 'SN', N, 1, N, -1 ), 2 )
247 K = MIN( MAXB, N, MAX( 2, ILAENV( 4, 'DHSEQR', 'SN', N, 1,
248 $ N, -1 ) ) )
249 HSWORK = MAX( K*( K+2 ), 2*N )
250 MAXWRK = MAX( MAXWRK, N+HSWORK, 1 )
251 ELSE 262 ELSE
252 MAXWRK = MAX( MAXWRK, 2*N+( N-1 )* 263 MAXWRK = 2*N + N*ILAENV( 1, 'DGEHRD', ' ', N, 1, N, 0 )
253 $ ILAENV( 1, 'DORGHR', ' ', N, 1, N, -1 ) ) 264 MINWRK = 3*N
254 MAXB = MAX( ILAENV( 8, 'DHSEQR', 'SV', N, 1, N, -1 ), 2 ) 265 *
255 K = MIN( MAXB, N, MAX( 2, ILAENV( 4, 'DHSEQR', 'SV', N, 1, 266 CALL DHSEQR( 'S', JOBVS, N, 1, N, A, LDA, WR, WI, VS, LDVS,
256 $ N, -1 ) ) ) 267 $ WORK, -1, IEVAL )
257 HSWORK = MAX( K*( K+2 ), 2*N ) 268 HSWORK = WORK( 1 )
258 MAXWRK = MAX( MAXWRK, N+HSWORK, 1 ) 269 *
270 IF( .NOT.WANTVS ) THEN
271 MAXWRK = MAX( MAXWRK, N + HSWORK )
272 ELSE
273 MAXWRK = MAX( MAXWRK, 2*N + ( N - 1 )*ILAENV( 1,
274 $ 'DORGHR', ' ', N, 1, N, -1 ) )
275 MAXWRK = MAX( MAXWRK, N + HSWORK )
276 END IF
277 LWRK = MAXWRK
278 IF( .NOT.WANTSN )
279 $ LWRK = MAX( LWRK, N + ( N*N )/2 )
280 IF( WANTSV .OR. WANTSB )
281 $ LIWRK = ( N*N )/4
259 END IF 282 END IF
260 WORK( 1 ) = MAXWRK 283 IWORK( 1 ) = LIWRK
261 END IF 284 WORK( 1 ) = LWRK
262 IF( LWORK.LT.MINWRK ) THEN 285 *
263 INFO = -16 286 IF( LWORK.LT.MINWRK .AND. .NOT.LQUERY ) THEN
264 END IF 287 INFO = -16
265 IF( LIWORK.LT.1 ) THEN 288 ELSE IF( LIWORK.LT.1 .AND. .NOT.LQUERY ) THEN
266 INFO = -18 289 INFO = -18
267 END IF 290 END IF
291 END IF
292 *
268 IF( INFO.NE.0 ) THEN 293 IF( INFO.NE.0 ) THEN
269 CALL XERBLA( 'DGEESX', -INFO ) 294 CALL XERBLA( 'DGEESX', -INFO )
270 RETURN 295 RETURN
271 END IF 296 END IF
272 * 297 *
488 30 CONTINUE 513 30 CONTINUE
489 END IF 514 END IF
490 * 515 *
491 WORK( 1 ) = MAXWRK 516 WORK( 1 ) = MAXWRK
492 IF( WANTSV .OR. WANTSB ) THEN 517 IF( WANTSV .OR. WANTSB ) THEN
493 IWORK( 1 ) = SDIM*( N-SDIM ) 518 IWORK( 1 ) = MAX( 1, SDIM*( N-SDIM ) )
494 ELSE 519 ELSE
495 IWORK( 1 ) = 1 520 IWORK( 1 ) = 1
496 END IF 521 END IF
497 * 522 *
498 RETURN 523 RETURN