| 1 |
#include "clapack.h" |
| 2 |
#include "f2cP.h" |
| 3 |
|
| 4 |
double dla_gbrcond__(const char *trans, integer *n, integer *kl, integer *ku, |
| 5 |
double *ab, integer *ldab, double *afb, integer *ldafb, |
| 6 |
integer *ipiv, integer *cmode, double *c__, integer *info, |
| 7 |
double *work, integer *iwork, integer trans_len) |
| 8 |
{ |
| 9 |
/* Table of constant values */ |
| 10 |
static integer c__1 = 1; |
| 11 |
|
| 12 |
/* System generated locals */ |
| 13 |
integer ab_dim1, ab_offset, afb_dim1, afb_offset, i__1, i__2, i__3, i__4; |
| 14 |
double ret_val, d__1; |
| 15 |
|
| 16 |
/* Local variables */ |
| 17 |
integer i__, j, kd, ke; |
| 18 |
double tmp; |
| 19 |
integer kase; |
| 20 |
integer isave[3]; |
| 21 |
double ainvnm; |
| 22 |
bool notrans; |
| 23 |
|
| 24 |
|
| 25 |
/* -- LAPACK routine (version 3.2.1) -- */ |
| 26 |
/* -- Contributed by James Demmel, Deaglan Halligan, Yozo Hida and -- */ |
| 27 |
/* -- Jason Riedy of Univ. of California Berkeley. -- */ |
| 28 |
/* -- April 2009 -- */ |
| 29 |
|
| 30 |
/* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ |
| 31 |
/* -- Univ. of California Berkeley and NAG Ltd. -- */ |
| 32 |
|
| 33 |
/* .. */ |
| 34 |
/* .. Scalar Arguments .. */ |
| 35 |
/* .. */ |
| 36 |
/* .. Array Arguments .. */ |
| 37 |
/* .. */ |
| 38 |
|
| 39 |
/* Purpose */ |
| 40 |
/* ======= */ |
| 41 |
|
| 42 |
/* DLA_GERCOND Estimates the Skeel condition number of op(A) * op2(C) */ |
| 43 |
/* where op2 is determined by CMODE as follows */ |
| 44 |
/* CMODE = 1 op2(C) = C */ |
| 45 |
/* CMODE = 0 op2(C) = I */ |
| 46 |
/* CMODE = -1 op2(C) = inv(C) */ |
| 47 |
/* The Skeel condition number cond(A) = norminf( |inv(A)||A| ) */ |
| 48 |
/* is computed by computing scaling factors R such that */ |
| 49 |
/* diag(R)*A*op2(C) is row equilibrated and computing the standard */ |
| 50 |
/* infinity-norm condition number. */ |
| 51 |
|
| 52 |
/* Arguments */ |
| 53 |
/* ========= */ |
| 54 |
|
| 55 |
/* TRANS (input) CHARACTER*1 */ |
| 56 |
/* Specifies the form of the system of equations: */ |
| 57 |
/* = 'N': A * X = B (No transpose) */ |
| 58 |
/* = 'T': A**T * X = B (Transpose) */ |
| 59 |
/* = 'C': A**H * X = B (Conjugate Transpose = Transpose) */ |
| 60 |
|
| 61 |
/* N (input) INTEGER */ |
| 62 |
/* The number of linear equations, i.e., the order of the */ |
| 63 |
/* matrix A. N >= 0. */ |
| 64 |
|
| 65 |
/* KL (input) INTEGER */ |
| 66 |
/* The number of subdiagonals within the band of A. KL >= 0. */ |
| 67 |
|
| 68 |
/* KU (input) INTEGER */ |
| 69 |
/* The number of superdiagonals within the band of A. KU >= 0. */ |
| 70 |
|
| 71 |
/* AB (input) DOUBLE PRECISION array, dimension (LDAB,N) */ |
| 72 |
/* On entry, the matrix A in band storage, in rows 1 to KL+KU+1. */ |
| 73 |
/* The j-th column of A is stored in the j-th column of the */ |
| 74 |
/* array AB as follows: */ |
| 75 |
/* AB(KU+1+i-j,j) = A(i,j) for max(1,j-KU)<=i<=min(N,j+kl) */ |
| 76 |
|
| 77 |
/* LDAB (input) INTEGER */ |
| 78 |
/* The leading dimension of the array AB. LDAB >= KL+KU+1. */ |
| 79 |
|
| 80 |
/* AFB (input) DOUBLE PRECISION array, dimension (LDAFB,N) */ |
| 81 |
/* Details of the LU factorization of the band matrix A, as */ |
| 82 |
/* computed by DGBTRF. U is stored as an upper triangular */ |
| 83 |
/* band matrix with KL+KU superdiagonals in rows 1 to KL+KU+1, */ |
| 84 |
/* and the multipliers used during the factorization are stored */ |
| 85 |
/* in rows KL+KU+2 to 2*KL+KU+1. */ |
| 86 |
|
| 87 |
/* LDAFB (input) INTEGER */ |
| 88 |
/* The leading dimension of the array AFB. LDAFB >= 2*KL+KU+1. */ |
| 89 |
|
| 90 |
/* IPIV (input) INTEGER array, dimension (N) */ |
| 91 |
/* The pivot indices from the factorization A = P*L*U */ |
| 92 |
/* as computed by DGBTRF; row i of the matrix was interchanged */ |
| 93 |
/* with row IPIV(i). */ |
| 94 |
|
| 95 |
/* CMODE (input) INTEGER */ |
| 96 |
/* Determines op2(C) in the formula op(A) * op2(C) as follows: */ |
| 97 |
/* CMODE = 1 op2(C) = C */ |
| 98 |
/* CMODE = 0 op2(C) = I */ |
| 99 |
/* CMODE = -1 op2(C) = inv(C) */ |
| 100 |
|
| 101 |
/* C (input) DOUBLE PRECISION array, dimension (N) */ |
| 102 |
/* The vector C in the formula op(A) * op2(C). */ |
| 103 |
|
| 104 |
/* INFO (output) INTEGER */ |
| 105 |
/* = 0: Successful exit. */ |
| 106 |
/* i > 0: The ith argument is invalid. */ |
| 107 |
|
| 108 |
/* WORK (input) DOUBLE PRECISION array, dimension (5*N). */ |
| 109 |
/* Workspace. */ |
| 110 |
|
| 111 |
/* IWORK (input) INTEGER array, dimension (N). */ |
| 112 |
/* Workspace. */ |
| 113 |
|
| 114 |
/* ===================================================================== */ |
| 115 |
|
| 116 |
/* .. Local Scalars .. */ |
| 117 |
/* .. */ |
| 118 |
/* .. Local Arrays .. */ |
| 119 |
/* .. */ |
| 120 |
/* .. External Functions .. */ |
| 121 |
/* .. */ |
| 122 |
/* .. External Subroutines .. */ |
| 123 |
/* .. */ |
| 124 |
/* .. Intrinsic Functions .. */ |
| 125 |
/* .. */ |
| 126 |
/* .. Executable Statements .. */ |
| 127 |
|
| 128 |
/* Parameter adjustments */ |
| 129 |
ab_dim1 = *ldab; |
| 130 |
ab_offset = 1 + ab_dim1; |
| 131 |
ab -= ab_offset; |
| 132 |
afb_dim1 = *ldafb; |
| 133 |
afb_offset = 1 + afb_dim1; |
| 134 |
afb -= afb_offset; |
| 135 |
--ipiv; |
| 136 |
--c__; |
| 137 |
--work; |
| 138 |
--iwork; |
| 139 |
|
| 140 |
/* Function Body */ |
| 141 |
ret_val = 0.; |
| 142 |
|
| 143 |
*info = 0; |
| 144 |
notrans = lsame_(trans, "N"); |
| 145 |
if (! notrans && ! lsame_(trans, "T") && ! lsame_(trans, "C")) { |
| 146 |
*info = -1; |
| 147 |
} else if (*n < 0) { |
| 148 |
*info = -2; |
| 149 |
} else if (*kl < 0 || *kl > *n - 1) { |
| 150 |
*info = -3; |
| 151 |
} else if (*ku < 0 || *ku > *n - 1) { |
| 152 |
*info = -4; |
| 153 |
} else if (*ldab < *kl + *ku + 1) { |
| 154 |
*info = -6; |
| 155 |
} else if (*ldafb < (*kl << 1) + *ku + 1) { |
| 156 |
*info = -8; |
| 157 |
} |
| 158 |
if (*info != 0) { |
| 159 |
i__1 = -(*info); |
| 160 |
xerbla_("DLA_GBRCOND", &i__1); |
| 161 |
return ret_val; |
| 162 |
} |
| 163 |
if (*n == 0) { |
| 164 |
ret_val = 1.; |
| 165 |
return ret_val; |
| 166 |
} |
| 167 |
|
| 168 |
/* Compute the equilibration matrix R such that */ |
| 169 |
/* inv(R)*A*C has unit 1-norm. */ |
| 170 |
|
| 171 |
kd = *ku + 1; |
| 172 |
ke = *kl + 1; |
| 173 |
if (notrans) { |
| 174 |
i__1 = *n; |
| 175 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 176 |
tmp = 0.; |
| 177 |
if (*cmode == 1) { |
| 178 |
/* Computing MAX */ |
| 179 |
i__2 = i__ - *kl; |
| 180 |
/* Computing MIN */ |
| 181 |
i__4 = i__ + *ku; |
| 182 |
i__3 = std::min(i__4,*n); |
| 183 |
for (j = std::max(i__2,1_integer); j <= i__3; ++j) { |
| 184 |
tmp += (d__1 = ab[kd + i__ - j + j * ab_dim1] * c__[j], |
| 185 |
abs(d__1)); |
| 186 |
} |
| 187 |
} else if (*cmode == 0) { |
| 188 |
/* Computing MAX */ |
| 189 |
i__3 = i__ - *kl; |
| 190 |
/* Computing MIN */ |
| 191 |
i__4 = i__ + *ku; |
| 192 |
i__2 = std::min(i__4,*n); |
| 193 |
for (j = std::max(i__3,1_integer); j <= i__2; ++j) { |
| 194 |
tmp += (d__1 = ab[kd + i__ - j + j * ab_dim1], abs(d__1)); |
| 195 |
} |
| 196 |
} else { |
| 197 |
/* Computing MAX */ |
| 198 |
i__2 = i__ - *kl; |
| 199 |
/* Computing MIN */ |
| 200 |
i__4 = i__ + *ku; |
| 201 |
i__3 = std::min(i__4,*n); |
| 202 |
for (j = std::max(i__2,1_integer); j <= i__3; ++j) { |
| 203 |
tmp += (d__1 = ab[kd + i__ - j + j * ab_dim1] / c__[j], |
| 204 |
abs(d__1)); |
| 205 |
} |
| 206 |
} |
| 207 |
work[(*n << 1) + i__] = tmp; |
| 208 |
} |
| 209 |
} else { |
| 210 |
i__1 = *n; |
| 211 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 212 |
tmp = 0.; |
| 213 |
if (*cmode == 1) { |
| 214 |
/* Computing MAX */ |
| 215 |
i__3 = i__ - *kl; |
| 216 |
/* Computing MIN */ |
| 217 |
i__4 = i__ + *ku; |
| 218 |
i__2 = std::min(i__4,*n); |
| 219 |
for (j = std::max(i__3,1_integer); j <= i__2; ++j) { |
| 220 |
tmp += (d__1 = ab[ke - i__ + j + i__ * ab_dim1] * c__[j], |
| 221 |
abs(d__1)); |
| 222 |
} |
| 223 |
} else if (*cmode == 0) { |
| 224 |
/* Computing MAX */ |
| 225 |
i__2 = i__ - *kl; |
| 226 |
/* Computing MIN */ |
| 227 |
i__4 = i__ + *ku; |
| 228 |
i__3 = std::min(i__4,*n); |
| 229 |
for (j = std::max(i__2,1_integer); j <= i__3; ++j) { |
| 230 |
tmp += (d__1 = ab[ke - i__ + j + i__ * ab_dim1], abs(d__1) |
| 231 |
); |
| 232 |
} |
| 233 |
} else { |
| 234 |
/* Computing MAX */ |
| 235 |
i__3 = i__ - *kl; |
| 236 |
/* Computing MIN */ |
| 237 |
i__4 = i__ + *ku; |
| 238 |
i__2 = std::min(i__4,*n); |
| 239 |
for (j = std::max(i__3,1_integer); j <= i__2; ++j) { |
| 240 |
tmp += (d__1 = ab[ke - i__ + j + i__ * ab_dim1] / c__[j], |
| 241 |
abs(d__1)); |
| 242 |
} |
| 243 |
} |
| 244 |
work[(*n << 1) + i__] = tmp; |
| 245 |
} |
| 246 |
} |
| 247 |
|
| 248 |
/* Estimate the norm of inv(op(A)). */ |
| 249 |
|
| 250 |
ainvnm = 0.; |
| 251 |
kase = 0; |
| 252 |
L10: |
| 253 |
dlacn2_(n, &work[*n + 1], &work[1], &iwork[1], &ainvnm, &kase, isave); |
| 254 |
if (kase != 0) { |
| 255 |
if (kase == 2) { |
| 256 |
|
| 257 |
/* Multiply by R. */ |
| 258 |
|
| 259 |
i__1 = *n; |
| 260 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 261 |
work[i__] *= work[(*n << 1) + i__]; |
| 262 |
} |
| 263 |
if (notrans) { |
| 264 |
dgbtrs_("No transpose", n, kl, ku, &c__1, &afb[afb_offset], |
| 265 |
ldafb, &ipiv[1], &work[1], n, info); |
| 266 |
} else { |
| 267 |
dgbtrs_("Transpose", n, kl, ku, &c__1, &afb[afb_offset], |
| 268 |
ldafb, &ipiv[1], &work[1], n, info); |
| 269 |
} |
| 270 |
|
| 271 |
/* Multiply by inv(C). */ |
| 272 |
|
| 273 |
if (*cmode == 1) { |
| 274 |
i__1 = *n; |
| 275 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 276 |
work[i__] /= c__[i__]; |
| 277 |
} |
| 278 |
} else if (*cmode == -1) { |
| 279 |
i__1 = *n; |
| 280 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 281 |
work[i__] *= c__[i__]; |
| 282 |
} |
| 283 |
} |
| 284 |
} else { |
| 285 |
|
| 286 |
/* Multiply by inv(C'). */ |
| 287 |
|
| 288 |
if (*cmode == 1) { |
| 289 |
i__1 = *n; |
| 290 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 291 |
work[i__] /= c__[i__]; |
| 292 |
} |
| 293 |
} else if (*cmode == -1) { |
| 294 |
i__1 = *n; |
| 295 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 296 |
work[i__] *= c__[i__]; |
| 297 |
} |
| 298 |
} |
| 299 |
if (notrans) { |
| 300 |
dgbtrs_("Transpose", n, kl, ku, &c__1, &afb[afb_offset], |
| 301 |
ldafb, &ipiv[1], &work[1], n, info); |
| 302 |
} else { |
| 303 |
dgbtrs_("No transpose", n, kl, ku, &c__1, &afb[afb_offset], |
| 304 |
ldafb, &ipiv[1], &work[1], n, info); |
| 305 |
} |
| 306 |
|
| 307 |
/* Multiply by R. */ |
| 308 |
|
| 309 |
i__1 = *n; |
| 310 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 311 |
work[i__] *= work[(*n << 1) + i__]; |
| 312 |
} |
| 313 |
} |
| 314 |
goto L10; |
| 315 |
} |
| 316 |
|
| 317 |
/* Compute the estimate of the reciprocal condition number. */ |
| 318 |
|
| 319 |
if (ainvnm != 0.) { |
| 320 |
ret_val = 1. / ainvnm; |
| 321 |
} |
| 322 |
|
| 323 |
return ret_val; |
| 324 |
|
| 325 |
} /* dla_gbrcond__ */ |
| 326 |
|
| 327 |
#if 0 |
| 328 |
/* Subroutine */ int dla_gbrfsx_extended__(integer *prec_type__, integer * |
| 329 |
trans_type__, integer *n, integer *kl, integer *ku, integer *nrhs, |
| 330 |
double *ab, integer *ldab, double *afb, integer *ldafb, |
| 331 |
integer *ipiv, bool *colequ, double *c__, double *b, |
| 332 |
integer *ldb, double *y, integer *ldy, double *berr_out__, |
| 333 |
integer *n_norms__, double *err_bnds_norm__, double * |
| 334 |
err_bnds_comp__, double *res, double *ayb, double *dy, |
| 335 |
double *y_tail__, double *rcond, integer *ithresh, double |
| 336 |
*rthresh, double *dz_ub__, bool *ignore_cwise__, integer *info) |
| 337 |
{ |
| 338 |
/* Table of constant values */ |
| 339 |
static integer c__1 = 1; |
| 340 |
static double c_b6 = -1.; |
| 341 |
static double c_b8 = 1.; |
| 342 |
|
| 343 |
/* System generated locals */ |
| 344 |
integer ab_dim1, ab_offset, afb_dim1, afb_offset, b_dim1, b_offset, |
| 345 |
y_dim1, y_offset, err_bnds_norm_dim1, err_bnds_norm_offset, |
| 346 |
err_bnds_comp_dim1, err_bnds_comp_offset, i__1, i__2, i__3; |
| 347 |
double d__1, d__2; |
| 348 |
char ch__1[1]; |
| 349 |
|
| 350 |
/* Local variables */ |
| 351 |
double dxratmax, dzratmax; |
| 352 |
integer i__, j, m; |
| 353 |
bool incr_prec__; |
| 354 |
double prev_dz_z__, yk, final_dx_x__; |
| 355 |
double final_dz_z__, prevnormdx; |
| 356 |
integer cnt; |
| 357 |
double dyk, eps, incr_thresh__, dx_x__, dz_z__; |
| 358 |
double ymin; |
| 359 |
integer y_prec_state__; |
| 360 |
double dxrat, dzrat; |
| 361 |
char trans[1]; |
| 362 |
double normx, normy; |
| 363 |
double normdx; |
| 364 |
double hugeval; |
| 365 |
integer x_state__, z_state__; |
| 366 |
|
| 367 |
|
| 368 |
/* -- LAPACK routine (version 3.2.1) -- */ |
| 369 |
/* -- Contributed by James Demmel, Deaglan Halligan, Yozo Hida and -- */ |
| 370 |
/* -- Jason Riedy of Univ. of California Berkeley. -- */ |
| 371 |
/* -- April 2009 -- */ |
| 372 |
|
| 373 |
/* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ |
| 374 |
/* -- Univ. of California Berkeley and NAG Ltd. -- */ |
| 375 |
|
| 376 |
/* .. */ |
| 377 |
/* .. Scalar Arguments .. */ |
| 378 |
/* .. */ |
| 379 |
/* .. Array Arguments .. */ |
| 380 |
/* .. */ |
| 381 |
|
| 382 |
/* Purpose */ |
| 383 |
/* ======= */ |
| 384 |
|
| 385 |
/* DLA_GBRFSX_EXTENDED improves the computed solution to a system of */ |
| 386 |
/* linear equations by performing extra-precise iterative refinement */ |
| 387 |
/* and provides error bounds and backward error estimates for the solution. */ |
| 388 |
/* This subroutine is called by DGBRFSX to perform iterative refinement. */ |
| 389 |
/* In addition to normwise error bound, the code provides maximum */ |
| 390 |
/* componentwise error bound if possible. See comments for ERR_BNDS_NORM */ |
| 391 |
/* and ERR_BNDS_COMP for details of the error bounds. Note that this */ |
| 392 |
/* subroutine is only resonsible for setting the second fields of */ |
| 393 |
/* ERR_BNDS_NORM and ERR_BNDS_COMP. */ |
| 394 |
|
| 395 |
/* Arguments */ |
| 396 |
/* ========= */ |
| 397 |
|
| 398 |
/* PREC_TYPE (input) INTEGER */ |
| 399 |
/* Specifies the intermediate precision to be used in refinement. */ |
| 400 |
/* The value is defined by ILAPREC(P) where P is a CHARACTER and */ |
| 401 |
/* P = 'S': Single */ |
| 402 |
/* = 'D': Double */ |
| 403 |
/* = 'I': Indigenous */ |
| 404 |
/* = 'X', 'E': Extra */ |
| 405 |
|
| 406 |
/* TRANS_TYPE (input) INTEGER */ |
| 407 |
/* Specifies the transposition operation on A. */ |
| 408 |
/* The value is defined by ILATRANS(T) where T is a CHARACTER and */ |
| 409 |
/* T = 'N': No transpose */ |
| 410 |
/* = 'T': Transpose */ |
| 411 |
/* = 'C': Conjugate transpose */ |
| 412 |
|
| 413 |
/* N (input) INTEGER */ |
| 414 |
/* The number of linear equations, i.e., the order of the */ |
| 415 |
/* matrix A. N >= 0. */ |
| 416 |
|
| 417 |
/* KL (input) INTEGER */ |
| 418 |
/* The number of subdiagonals within the band of A. KL >= 0. */ |
| 419 |
|
| 420 |
/* KU (input) INTEGER */ |
| 421 |
/* The number of superdiagonals within the band of A. KU >= 0 */ |
| 422 |
|
| 423 |
/* NRHS (input) INTEGER */ |
| 424 |
/* The number of right-hand-sides, i.e., the number of columns of the */ |
| 425 |
/* matrix B. */ |
| 426 |
|
| 427 |
/* A (input) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 428 |
/* On entry, the N-by-N matrix A. */ |
| 429 |
|
| 430 |
/* LDA (input) INTEGER */ |
| 431 |
/* The leading dimension of the array A. LDA >= max(1,N). */ |
| 432 |
|
| 433 |
/* AF (input) DOUBLE PRECISION array, dimension (LDAF,N) */ |
| 434 |
/* The factors L and U from the factorization */ |
| 435 |
/* A = P*L*U as computed by DGBTRF. */ |
| 436 |
|
| 437 |
/* LDAF (input) INTEGER */ |
| 438 |
/* The leading dimension of the array AF. LDAF >= max(1,N). */ |
| 439 |
|
| 440 |
/* IPIV (input) INTEGER array, dimension (N) */ |
| 441 |
/* The pivot indices from the factorization A = P*L*U */ |
| 442 |
/* as computed by DGBTRF; row i of the matrix was interchanged */ |
| 443 |
/* with row IPIV(i). */ |
| 444 |
|
| 445 |
/* COLEQU (input) LOGICAL */ |
| 446 |
/* If .TRUE. then column equilibration was done to A before calling */ |
| 447 |
/* this routine. This is needed to compute the solution and error */ |
| 448 |
/* bounds correctly. */ |
| 449 |
|
| 450 |
/* C (input) DOUBLE PRECISION array, dimension (N) */ |
| 451 |
/* The column scale factors for A. If COLEQU = .FALSE., C */ |
| 452 |
/* is not accessed. If C is input, each element of C should be a power */ |
| 453 |
/* of the radix to ensure a reliable solution and error estimates. */ |
| 454 |
/* Scaling by powers of the radix does not cause rounding errors unless */ |
| 455 |
/* the result underflows or overflows. Rounding errors during scaling */ |
| 456 |
/* lead to refining with a matrix that is not equivalent to the */ |
| 457 |
/* input matrix, producing error estimates that may not be */ |
| 458 |
/* reliable. */ |
| 459 |
|
| 460 |
/* B (input) DOUBLE PRECISION array, dimension (LDB,NRHS) */ |
| 461 |
/* The right-hand-side matrix B. */ |
| 462 |
|
| 463 |
/* LDB (input) INTEGER */ |
| 464 |
/* The leading dimension of the array B. LDB >= max(1,N). */ |
| 465 |
|
| 466 |
/* Y (input/output) DOUBLE PRECISION array, dimension */ |
| 467 |
/* (LDY,NRHS) */ |
| 468 |
/* On entry, the solution matrix X, as computed by DGBTRS. */ |
| 469 |
/* On exit, the improved solution matrix Y. */ |
| 470 |
|
| 471 |
/* LDY (input) INTEGER */ |
| 472 |
/* The leading dimension of the array Y. LDY >= max(1,N). */ |
| 473 |
|
| 474 |
/* BERR_OUT (output) DOUBLE PRECISION array, dimension (NRHS) */ |
| 475 |
/* On exit, BERR_OUT(j) contains the componentwise relative backward */ |
| 476 |
/* error for right-hand-side j from the formula */ |
| 477 |
/* max(i) ( abs(RES(i)) / ( abs(op(A_s))*abs(Y) + abs(B_s) )(i) ) */ |
| 478 |
/* where abs(Z) is the componentwise absolute value of the matrix */ |
| 479 |
/* or vector Z. This is computed by DLA_LIN_BERR. */ |
| 480 |
|
| 481 |
/* N_NORMS (input) INTEGER */ |
| 482 |
/* Determines which error bounds to return (see ERR_BNDS_NORM */ |
| 483 |
/* and ERR_BNDS_COMP). */ |
| 484 |
/* If N_NORMS >= 1 return normwise error bounds. */ |
| 485 |
/* If N_NORMS >= 2 return componentwise error bounds. */ |
| 486 |
|
| 487 |
/* ERR_BNDS_NORM (input/output) DOUBLE PRECISION array, dimension */ |
| 488 |
/* (NRHS, N_ERR_BNDS) */ |
| 489 |
/* For each right-hand side, this array contains information about */ |
| 490 |
/* various error bounds and condition numbers corresponding to the */ |
| 491 |
/* normwise relative error, which is defined as follows: */ |
| 492 |
|
| 493 |
/* Normwise relative error in the ith solution vector: */ |
| 494 |
/* max_j (abs(XTRUE(j,i) - X(j,i))) */ |
| 495 |
/* ------------------------------ */ |
| 496 |
/* max_j abs(X(j,i)) */ |
| 497 |
|
| 498 |
/* The array is indexed by the type of error information as described */ |
| 499 |
/* below. There currently are up to three pieces of information */ |
| 500 |
/* returned. */ |
| 501 |
|
| 502 |
/* The first index in ERR_BNDS_NORM(i,:) corresponds to the ith */ |
| 503 |
/* right-hand side. */ |
| 504 |
|
| 505 |
/* The second index in ERR_BNDS_NORM(:,err) contains the following */ |
| 506 |
/* three fields: */ |
| 507 |
/* err = 1 "Trust/don't trust" boolean. Trust the answer if the */ |
| 508 |
/* reciprocal condition number is less than the threshold */ |
| 509 |
/* sqrt(n) * slamch('Epsilon'). */ |
| 510 |
|
| 511 |
/* err = 2 "Guaranteed" error bound: The estimated forward error, */ |
| 512 |
/* almost certainly within a factor of 10 of the true error */ |
| 513 |
/* so long as the next entry is greater than the threshold */ |
| 514 |
/* sqrt(n) * slamch('Epsilon'). This error bound should only */ |
| 515 |
/* be trusted if the previous boolean is true. */ |
| 516 |
|
| 517 |
/* err = 3 Reciprocal condition number: Estimated normwise */ |
| 518 |
/* reciprocal condition number. Compared with the threshold */ |
| 519 |
/* sqrt(n) * slamch('Epsilon') to determine if the error */ |
| 520 |
/* estimate is "guaranteed". These reciprocal condition */ |
| 521 |
/* numbers are 1 / (norm(Z^{-1},inf) * norm(Z,inf)) for some */ |
| 522 |
/* appropriately scaled matrix Z. */ |
| 523 |
/* Let Z = S*A, where S scales each row by a power of the */ |
| 524 |
/* radix so all absolute row sums of Z are approximately 1. */ |
| 525 |
|
| 526 |
/* This subroutine is only responsible for setting the second field */ |
| 527 |
/* above. */ |
| 528 |
/* See Lapack Working Note 165 for further details and extra */ |
| 529 |
/* cautions. */ |
| 530 |
|
| 531 |
/* ERR_BNDS_COMP (input/output) DOUBLE PRECISION array, dimension */ |
| 532 |
/* (NRHS, N_ERR_BNDS) */ |
| 533 |
/* For each right-hand side, this array contains information about */ |
| 534 |
/* various error bounds and condition numbers corresponding to the */ |
| 535 |
/* componentwise relative error, which is defined as follows: */ |
| 536 |
|
| 537 |
/* Componentwise relative error in the ith solution vector: */ |
| 538 |
/* abs(XTRUE(j,i) - X(j,i)) */ |
| 539 |
/* max_j ---------------------- */ |
| 540 |
/* abs(X(j,i)) */ |
| 541 |
|
| 542 |
/* The array is indexed by the right-hand side i (on which the */ |
| 543 |
/* componentwise relative error depends), and the type of error */ |
| 544 |
/* information as described below. There currently are up to three */ |
| 545 |
/* pieces of information returned for each right-hand side. If */ |
| 546 |
/* componentwise accuracy is not requested (PARAMS(3) = 0.0), then */ |
| 547 |
/* ERR_BNDS_COMP is not accessed. If N_ERR_BNDS .LT. 3, then at most */ |
| 548 |
/* the first (:,N_ERR_BNDS) entries are returned. */ |
| 549 |
|
| 550 |
/* The first index in ERR_BNDS_COMP(i,:) corresponds to the ith */ |
| 551 |
/* right-hand side. */ |
| 552 |
|
| 553 |
/* The second index in ERR_BNDS_COMP(:,err) contains the following */ |
| 554 |
/* three fields: */ |
| 555 |
/* err = 1 "Trust/don't trust" boolean. Trust the answer if the */ |
| 556 |
/* reciprocal condition number is less than the threshold */ |
| 557 |
/* sqrt(n) * slamch('Epsilon'). */ |
| 558 |
|
| 559 |
/* err = 2 "Guaranteed" error bound: The estimated forward error, */ |
| 560 |
/* almost certainly within a factor of 10 of the true error */ |
| 561 |
/* so long as the next entry is greater than the threshold */ |
| 562 |
/* sqrt(n) * slamch('Epsilon'). This error bound should only */ |
| 563 |
/* be trusted if the previous boolean is true. */ |
| 564 |
|
| 565 |
/* err = 3 Reciprocal condition number: Estimated componentwise */ |
| 566 |
/* reciprocal condition number. Compared with the threshold */ |
| 567 |
/* sqrt(n) * slamch('Epsilon') to determine if the error */ |
| 568 |
/* estimate is "guaranteed". These reciprocal condition */ |
| 569 |
/* numbers are 1 / (norm(Z^{-1},inf) * norm(Z,inf)) for some */ |
| 570 |
/* appropriately scaled matrix Z. */ |
| 571 |
/* Let Z = S*(A*diag(x)), where x is the solution for the */ |
| 572 |
/* current right-hand side and S scales each row of */ |
| 573 |
/* A*diag(x) by a power of the radix so all absolute row */ |
| 574 |
/* sums of Z are approximately 1. */ |
| 575 |
|
| 576 |
/* This subroutine is only responsible for setting the second field */ |
| 577 |
/* above. */ |
| 578 |
/* See Lapack Working Note 165 for further details and extra */ |
| 579 |
/* cautions. */ |
| 580 |
|
| 581 |
/* RES (input) DOUBLE PRECISION array, dimension (N) */ |
| 582 |
/* Workspace to hold the intermediate residual. */ |
| 583 |
|
| 584 |
/* AYB (input) DOUBLE PRECISION array, dimension (N) */ |
| 585 |
/* Workspace. This can be the same workspace passed for Y_TAIL. */ |
| 586 |
|
| 587 |
/* DY (input) DOUBLE PRECISION array, dimension (N) */ |
| 588 |
/* Workspace to hold the intermediate solution. */ |
| 589 |
|
| 590 |
/* Y_TAIL (input) DOUBLE PRECISION array, dimension (N) */ |
| 591 |
/* Workspace to hold the trailing bits of the intermediate solution. */ |
| 592 |
|
| 593 |
/* RCOND (input) DOUBLE PRECISION */ |
| 594 |
/* Reciprocal scaled condition number. This is an estimate of the */ |
| 595 |
/* reciprocal Skeel condition number of the matrix A after */ |
| 596 |
/* equilibration (if done). If this is less than the machine */ |
| 597 |
/* precision (in particular, if it is zero), the matrix is singular */ |
| 598 |
/* to working precision. Note that the error may still be small even */ |
| 599 |
/* if this number is very small and the matrix appears ill- */ |
| 600 |
/* conditioned. */ |
| 601 |
|
| 602 |
/* ITHRESH (input) INTEGER */ |
| 603 |
/* The maximum number of residual computations allowed for */ |
| 604 |
/* refinement. The default is 10. For 'aggressive' set to 100 to */ |
| 605 |
/* permit convergence using approximate factorizations or */ |
| 606 |
/* factorizations other than LU. If the factorization uses a */ |
| 607 |
/* technique other than Gaussian elimination, the guarantees in */ |
| 608 |
/* ERR_BNDS_NORM and ERR_BNDS_COMP may no longer be trustworthy. */ |
| 609 |
|
| 610 |
/* RTHRESH (input) DOUBLE PRECISION */ |
| 611 |
/* Determines when to stop refinement if the error estimate stops */ |
| 612 |
/* decreasing. Refinement will stop when the next solution no longer */ |
| 613 |
/* satisfies norm(dx_{i+1}) < RTHRESH * norm(dx_i) where norm(Z) is */ |
| 614 |
/* the infinity norm of Z. RTHRESH satisfies 0 < RTHRESH <= 1. The */ |
| 615 |
/* default value is 0.5. For 'aggressive' set to 0.9 to permit */ |
| 616 |
/* convergence on extremely ill-conditioned matrices. See LAWN 165 */ |
| 617 |
/* for more details. */ |
| 618 |
|
| 619 |
/* DZ_UB (input) DOUBLE PRECISION */ |
| 620 |
/* Determines when to start considering componentwise convergence. */ |
| 621 |
/* Componentwise convergence is only considered after each component */ |
| 622 |
/* of the solution Y is stable, which we definte as the relative */ |
| 623 |
/* change in each component being less than DZ_UB. The default value */ |
| 624 |
/* is 0.25, requiring the first bit to be stable. See LAWN 165 for */ |
| 625 |
/* more details. */ |
| 626 |
|
| 627 |
/* IGNORE_CWISE (input) LOGICAL */ |
| 628 |
/* If .TRUE. then ignore componentwise convergence. Default value */ |
| 629 |
/* is .FALSE.. */ |
| 630 |
|
| 631 |
/* INFO (output) INTEGER */ |
| 632 |
/* = 0: Successful exit. */ |
| 633 |
/* < 0: if INFO = -i, the ith argument to DGBTRS had an illegal */ |
| 634 |
/* value */ |
| 635 |
|
| 636 |
/* ===================================================================== */ |
| 637 |
|
| 638 |
/* .. Local Scalars .. */ |
| 639 |
/* .. */ |
| 640 |
/* .. Parameters .. */ |
| 641 |
/* .. */ |
| 642 |
/* .. External Subroutines .. */ |
| 643 |
/* .. */ |
| 644 |
/* .. Intrinsic Functions .. */ |
| 645 |
/* .. */ |
| 646 |
/* .. Executable Statements .. */ |
| 647 |
|
| 648 |
/* Parameter adjustments */ |
| 649 |
err_bnds_comp_dim1 = *nrhs; |
| 650 |
err_bnds_comp_offset = 1 + err_bnds_comp_dim1; |
| 651 |
err_bnds_comp__ -= err_bnds_comp_offset; |
| 652 |
err_bnds_norm_dim1 = *nrhs; |
| 653 |
err_bnds_norm_offset = 1 + err_bnds_norm_dim1; |
| 654 |
err_bnds_norm__ -= err_bnds_norm_offset; |
| 655 |
ab_dim1 = *ldab; |
| 656 |
ab_offset = 1 + ab_dim1; |
| 657 |
ab -= ab_offset; |
| 658 |
afb_dim1 = *ldafb; |
| 659 |
afb_offset = 1 + afb_dim1; |
| 660 |
afb -= afb_offset; |
| 661 |
--ipiv; |
| 662 |
--c__; |
| 663 |
b_dim1 = *ldb; |
| 664 |
b_offset = 1 + b_dim1; |
| 665 |
b -= b_offset; |
| 666 |
y_dim1 = *ldy; |
| 667 |
y_offset = 1 + y_dim1; |
| 668 |
y -= y_offset; |
| 669 |
--berr_out__; |
| 670 |
--res; |
| 671 |
--ayb; |
| 672 |
--dy; |
| 673 |
--y_tail__; |
| 674 |
|
| 675 |
/* Function Body */ |
| 676 |
if (*info != 0) { |
| 677 |
return 0; |
| 678 |
} |
| 679 |
chla_transtype__(ch__1, 1_integer, trans_type__); |
| 680 |
*(unsigned char *)trans = *(unsigned char *)&ch__1[0]; |
| 681 |
eps = dlamch_("Epsilon"); |
| 682 |
hugeval = dlamch_("Overflow"); |
| 683 |
/* Force HUGEVAL to Inf */ |
| 684 |
hugeval *= hugeval; |
| 685 |
/* Using HUGEVAL may lead to spurious underflows. */ |
| 686 |
incr_thresh__ = (double) (*n) * eps; |
| 687 |
m = *kl + *ku + 1; |
| 688 |
i__1 = *nrhs; |
| 689 |
for (j = 1; j <= i__1; ++j) { |
| 690 |
y_prec_state__ = 1; |
| 691 |
if (y_prec_state__ == 2) { |
| 692 |
i__2 = *n; |
| 693 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 694 |
y_tail__[i__] = 0.; |
| 695 |
} |
| 696 |
} |
| 697 |
dxrat = 0.; |
| 698 |
dxratmax = 0.; |
| 699 |
dzrat = 0.; |
| 700 |
dzratmax = 0.; |
| 701 |
final_dx_x__ = hugeval; |
| 702 |
final_dz_z__ = hugeval; |
| 703 |
prevnormdx = hugeval; |
| 704 |
prev_dz_z__ = hugeval; |
| 705 |
dz_z__ = hugeval; |
| 706 |
dx_x__ = hugeval; |
| 707 |
x_state__ = 1; |
| 708 |
z_state__ = 0; |
| 709 |
incr_prec__ = false; |
| 710 |
i__2 = *ithresh; |
| 711 |
for (cnt = 1; cnt <= i__2; ++cnt) { |
| 712 |
|
| 713 |
/* Compute residual RES = B_s - op(A_s) * Y, */ |
| 714 |
/* op(A) = A, A**T, or A**H depending on TRANS (and type). */ |
| 715 |
|
| 716 |
dcopy_(n, &b[j * b_dim1 + 1], &c__1, &res[1], &c__1); |
| 717 |
if (y_prec_state__ == 0) { |
| 718 |
dgbmv_(trans, &m, n, kl, ku, &c_b6, &ab[ab_offset], ldab, &y[ |
| 719 |
j * y_dim1 + 1], &c__1, &c_b8, &res[1], &c__1); |
| 720 |
} else if (y_prec_state__ == 1) { |
| 721 |
blas_dgbmv_x__(trans_type__, n, n, kl, ku, &c_b6, &ab[ |
| 722 |
ab_offset], ldab, &y[j * y_dim1 + 1], &c__1, &c_b8, & |
| 723 |
res[1], &c__1, prec_type__); |
| 724 |
} else { |
| 725 |
blas_dgbmv2_x__(trans_type__, n, n, kl, ku, &c_b6, &ab[ |
| 726 |
ab_offset], ldab, &y[j * y_dim1 + 1], &y_tail__[1], & |
| 727 |
c__1, &c_b8, &res[1], &c__1, prec_type__); |
| 728 |
} |
| 729 |
/* XXX: RES is no longer needed. */ |
| 730 |
dcopy_(n, &res[1], &c__1, &dy[1], &c__1); |
| 731 |
dgbtrs_(trans, n, kl, ku, &c__1, &afb[afb_offset], ldafb, &ipiv[1] |
| 732 |
, &dy[1], n, info); |
| 733 |
|
| 734 |
/* Calculate relative changes DX_X, DZ_Z and ratios DXRAT, DZRAT. */ |
| 735 |
|
| 736 |
normx = 0.; |
| 737 |
normy = 0.; |
| 738 |
normdx = 0.; |
| 739 |
dz_z__ = 0.; |
| 740 |
ymin = hugeval; |
| 741 |
i__3 = *n; |
| 742 |
for (i__ = 1; i__ <= i__3; ++i__) { |
| 743 |
yk = (d__1 = y[i__ + j * y_dim1], abs(d__1)); |
| 744 |
dyk = (d__1 = dy[i__], abs(d__1)); |
| 745 |
if (yk != 0.) { |
| 746 |
/* Computing MAX */ |
| 747 |
d__1 = dz_z__, d__2 = dyk / yk; |
| 748 |
dz_z__ = std::max(d__1,d__2); |
| 749 |
} else if (dyk != 0.) { |
| 750 |
dz_z__ = hugeval; |
| 751 |
} |
| 752 |
ymin = std::min(ymin,yk); |
| 753 |
normy = std::max(normy,yk); |
| 754 |
if (*colequ) { |
| 755 |
/* Computing MAX */ |
| 756 |
d__1 = normx, d__2 = yk * c__[i__]; |
| 757 |
normx = std::max(d__1,d__2); |
| 758 |
/* Computing MAX */ |
| 759 |
d__1 = normdx, d__2 = dyk * c__[i__]; |
| 760 |
normdx = std::max(d__1,d__2); |
| 761 |
} else { |
| 762 |
normx = normy; |
| 763 |
normdx = std::max(normdx,dyk); |
| 764 |
} |
| 765 |
} |
| 766 |
if (normx != 0.) { |
| 767 |
dx_x__ = normdx / normx; |
| 768 |
} else if (normdx == 0.) { |
| 769 |
dx_x__ = 0.; |
| 770 |
} else { |
| 771 |
dx_x__ = hugeval; |
| 772 |
} |
| 773 |
dxrat = normdx / prevnormdx; |
| 774 |
dzrat = dz_z__ / prev_dz_z__; |
| 775 |
|
| 776 |
/* Check termination criteria. */ |
| 777 |
|
| 778 |
if (! (*ignore_cwise__) && ymin * *rcond < incr_thresh__ * normy |
| 779 |
&& y_prec_state__ < 2) { |
| 780 |
incr_prec__ = true; |
| 781 |
} |
| 782 |
if (x_state__ == 3 && dxrat <= *rthresh) { |
| 783 |
x_state__ = 1; |
| 784 |
} |
| 785 |
if (x_state__ == 1) { |
| 786 |
if (dx_x__ <= eps) { |
| 787 |
x_state__ = 2; |
| 788 |
} else if (dxrat > *rthresh) { |
| 789 |
if (y_prec_state__ != 2) { |
| 790 |
incr_prec__ = true; |
| 791 |
} else { |
| 792 |
x_state__ = 3; |
| 793 |
} |
| 794 |
} else { |
| 795 |
if (dxrat > dxratmax) { |
| 796 |
dxratmax = dxrat; |
| 797 |
} |
| 798 |
} |
| 799 |
if (x_state__ > 1) { |
| 800 |
final_dx_x__ = dx_x__; |
| 801 |
} |
| 802 |
} |
| 803 |
if (z_state__ == 0 && dz_z__ <= *dz_ub__) { |
| 804 |
z_state__ = 1; |
| 805 |
} |
| 806 |
if (z_state__ == 3 && dzrat <= *rthresh) { |
| 807 |
z_state__ = 1; |
| 808 |
} |
| 809 |
if (z_state__ == 1) { |
| 810 |
if (dz_z__ <= eps) { |
| 811 |
z_state__ = 2; |
| 812 |
} else if (dz_z__ > *dz_ub__) { |
| 813 |
z_state__ = 0; |
| 814 |
dzratmax = 0.; |
| 815 |
final_dz_z__ = hugeval; |
| 816 |
} else if (dzrat > *rthresh) { |
| 817 |
if (y_prec_state__ != 2) { |
| 818 |
incr_prec__ = true; |
| 819 |
} else { |
| 820 |
z_state__ = 3; |
| 821 |
} |
| 822 |
} else { |
| 823 |
if (dzrat > dzratmax) { |
| 824 |
dzratmax = dzrat; |
| 825 |
} |
| 826 |
} |
| 827 |
if (z_state__ > 1) { |
| 828 |
final_dz_z__ = dz_z__; |
| 829 |
} |
| 830 |
} |
| 831 |
|
| 832 |
/* Exit if both normwise and componentwise stopped working, */ |
| 833 |
/* but if componentwise is unstable, let it go at least two */ |
| 834 |
/* iterations. */ |
| 835 |
|
| 836 |
if (x_state__ != 1) { |
| 837 |
if (*ignore_cwise__) { |
| 838 |
goto L666; |
| 839 |
} |
| 840 |
if (z_state__ == 3 || z_state__ == 2) { |
| 841 |
goto L666; |
| 842 |
} |
| 843 |
if (z_state__ == 0 && cnt > 1) { |
| 844 |
goto L666; |
| 845 |
} |
| 846 |
} |
| 847 |
if (incr_prec__) { |
| 848 |
incr_prec__ = false; |
| 849 |
++y_prec_state__; |
| 850 |
i__3 = *n; |
| 851 |
for (i__ = 1; i__ <= i__3; ++i__) { |
| 852 |
y_tail__[i__] = 0.; |
| 853 |
} |
| 854 |
} |
| 855 |
prevnormdx = normdx; |
| 856 |
prev_dz_z__ = dz_z__; |
| 857 |
|
| 858 |
/* Update soluton. */ |
| 859 |
|
| 860 |
if (y_prec_state__ < 2) { |
| 861 |
daxpy_(n, &c_b8, &dy[1], &c__1, &y[j * y_dim1 + 1], &c__1); |
| 862 |
} else { |
| 863 |
dla_wwaddw__(n, &y[j * y_dim1 + 1], &y_tail__[1], &dy[1]); |
| 864 |
} |
| 865 |
} |
| 866 |
/* Target of "IF (Z_STOP .AND. X_STOP)". Sun's f77 won't EXIT. */ |
| 867 |
L666: |
| 868 |
|
| 869 |
/* Set final_* when cnt hits ithresh. */ |
| 870 |
|
| 871 |
if (x_state__ == 1) { |
| 872 |
final_dx_x__ = dx_x__; |
| 873 |
} |
| 874 |
if (z_state__ == 1) { |
| 875 |
final_dz_z__ = dz_z__; |
| 876 |
} |
| 877 |
|
| 878 |
/* Compute error bounds. */ |
| 879 |
|
| 880 |
if (*n_norms__ >= 1) { |
| 881 |
err_bnds_norm__[j + (err_bnds_norm_dim1 << 1)] = final_dx_x__ / ( |
| 882 |
1 - dxratmax); |
| 883 |
} |
| 884 |
if (*n_norms__ >= 2) { |
| 885 |
err_bnds_comp__[j + (err_bnds_comp_dim1 << 1)] = final_dz_z__ / ( |
| 886 |
1 - dzratmax); |
| 887 |
} |
| 888 |
|
| 889 |
/* Compute componentwise relative backward error from formula */ |
| 890 |
/* max(i) ( abs(R(i)) / ( abs(op(A_s))*abs(Y) + abs(B_s) )(i) ) */ |
| 891 |
/* where abs(Z) is the componentwise absolute value of the matrix */ |
| 892 |
/* or vector Z. */ |
| 893 |
|
| 894 |
/* Compute residual RES = B_s - op(A_s) * Y, */ |
| 895 |
/* op(A) = A, A**T, or A**H depending on TRANS (and type). */ |
| 896 |
|
| 897 |
dcopy_(n, &b[j * b_dim1 + 1], &c__1, &res[1], &c__1); |
| 898 |
dgbmv_(trans, n, n, kl, ku, &c_b6, &ab[ab_offset], ldab, &y[j * |
| 899 |
y_dim1 + 1], &c__1, &c_b8, &res[1], &c__1); |
| 900 |
i__2 = *n; |
| 901 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 902 |
ayb[i__] = (d__1 = b[i__ + j * b_dim1], abs(d__1)); |
| 903 |
} |
| 904 |
|
| 905 |
/* Compute abs(op(A_s))*abs(Y) + abs(B_s). */ |
| 906 |
|
| 907 |
dla_gbamv__(trans_type__, n, n, kl, ku, &c_b8, &ab[ab_offset], ldab, & |
| 908 |
y[j * y_dim1 + 1], &c__1, &c_b8, &ayb[1], &c__1); |
| 909 |
dla_lin_berr__(n, n, &c__1, &res[1], &ayb[1], &berr_out__[j]); |
| 910 |
|
| 911 |
/* End of loop for each RHS */ |
| 912 |
|
| 913 |
} |
| 914 |
|
| 915 |
return 0; |
| 916 |
} /* dla_gbrfsx_extended__ */ |
| 917 |
#endif |
| 918 |
|
| 919 |
double dla_gbrpvgrw__(integer *n, integer *kl, integer *ku, integer * |
| 920 |
ncols, double *ab, integer *ldab, double *afb, integer *ldafb) |
| 921 |
{ |
| 922 |
/* System generated locals */ |
| 923 |
integer ab_dim1, ab_offset, afb_dim1, afb_offset, i__1, i__2, i__3, i__4; |
| 924 |
double ret_val, d__1, d__2; |
| 925 |
|
| 926 |
/* Local variables */ |
| 927 |
integer i__, j, kd; |
| 928 |
double amax, umax, rpvgrw; |
| 929 |
|
| 930 |
|
| 931 |
/* -- LAPACK routine (version 3.2.1) -- */ |
| 932 |
/* -- Contributed by James Demmel, Deaglan Halligan, Yozo Hida and -- */ |
| 933 |
/* -- Jason Riedy of Univ. of California Berkeley. -- */ |
| 934 |
/* -- April 2009 -- */ |
| 935 |
|
| 936 |
/* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ |
| 937 |
/* -- Univ. of California Berkeley and NAG Ltd. -- */ |
| 938 |
|
| 939 |
/* .. */ |
| 940 |
/* .. Scalar Arguments .. */ |
| 941 |
/* .. */ |
| 942 |
/* .. Array Arguments .. */ |
| 943 |
/* .. */ |
| 944 |
|
| 945 |
/* Purpose */ |
| 946 |
/* ======= */ |
| 947 |
|
| 948 |
/* DLA_GBRPVGRW computes the reciprocal pivot growth factor */ |
| 949 |
/* norm(A)/norm(U). The "max absolute element" norm is used. If this is */ |
| 950 |
/* much less than 1, the stability of the LU factorization of the */ |
| 951 |
/* (equilibrated) matrix A could be poor. This also means that the */ |
| 952 |
/* solution X, estimated condition numbers, and error bounds could be */ |
| 953 |
/* unreliable. */ |
| 954 |
|
| 955 |
/* Arguments */ |
| 956 |
/* ========= */ |
| 957 |
|
| 958 |
/* N (input) INTEGER */ |
| 959 |
/* The number of linear equations, i.e., the order of the */ |
| 960 |
/* matrix A. N >= 0. */ |
| 961 |
|
| 962 |
/* KL (input) INTEGER */ |
| 963 |
/* The number of subdiagonals within the band of A. KL >= 0. */ |
| 964 |
|
| 965 |
/* KU (input) INTEGER */ |
| 966 |
/* The number of superdiagonals within the band of A. KU >= 0. */ |
| 967 |
|
| 968 |
/* NCOLS (input) INTEGER */ |
| 969 |
/* The number of columns of the matrix A. NCOLS >= 0. */ |
| 970 |
|
| 971 |
/* AB (input) DOUBLE PRECISION array, dimension (LDAB,N) */ |
| 972 |
/* On entry, the matrix A in band storage, in rows 1 to KL+KU+1. */ |
| 973 |
/* The j-th column of A is stored in the j-th column of the */ |
| 974 |
/* array AB as follows: */ |
| 975 |
/* AB(KU+1+i-j,j) = A(i,j) for max(1,j-KU)<=i<=min(N,j+kl) */ |
| 976 |
|
| 977 |
/* LDAB (input) INTEGER */ |
| 978 |
/* The leading dimension of the array AB. LDAB >= KL+KU+1. */ |
| 979 |
|
| 980 |
/* AFB (input) DOUBLE PRECISION array, dimension (LDAFB,N) */ |
| 981 |
/* Details of the LU factorization of the band matrix A, as */ |
| 982 |
/* computed by DGBTRF. U is stored as an upper triangular */ |
| 983 |
/* band matrix with KL+KU superdiagonals in rows 1 to KL+KU+1, */ |
| 984 |
/* and the multipliers used during the factorization are stored */ |
| 985 |
/* in rows KL+KU+2 to 2*KL+KU+1. */ |
| 986 |
|
| 987 |
/* LDAFB (input) INTEGER */ |
| 988 |
/* The leading dimension of the array AFB. LDAFB >= 2*KL+KU+1. */ |
| 989 |
|
| 990 |
/* ===================================================================== */ |
| 991 |
|
| 992 |
/* .. Local Scalars .. */ |
| 993 |
/* .. */ |
| 994 |
/* .. Intrinsic Functions .. */ |
| 995 |
/* .. */ |
| 996 |
/* .. Executable Statements .. */ |
| 997 |
|
| 998 |
/* Parameter adjustments */ |
| 999 |
ab_dim1 = *ldab; |
| 1000 |
ab_offset = 1 + ab_dim1; |
| 1001 |
ab -= ab_offset; |
| 1002 |
afb_dim1 = *ldafb; |
| 1003 |
afb_offset = 1 + afb_dim1; |
| 1004 |
afb -= afb_offset; |
| 1005 |
|
| 1006 |
/* Function Body */ |
| 1007 |
rpvgrw = 1.; |
| 1008 |
kd = *ku + 1; |
| 1009 |
i__1 = *ncols; |
| 1010 |
for (j = 1; j <= i__1; ++j) { |
| 1011 |
amax = 0.; |
| 1012 |
umax = 0.; |
| 1013 |
/* Computing MAX */ |
| 1014 |
i__2 = j - *ku; |
| 1015 |
/* Computing MIN */ |
| 1016 |
i__4 = j + *kl; |
| 1017 |
i__3 = std::min(i__4,*n); |
| 1018 |
for (i__ = std::max(i__2,1_integer); i__ <= i__3; ++i__) { |
| 1019 |
/* Computing MAX */ |
| 1020 |
d__2 = (d__1 = ab[kd + i__ - j + j * ab_dim1], abs(d__1)); |
| 1021 |
amax = std::max(d__2,amax); |
| 1022 |
} |
| 1023 |
/* Computing MAX */ |
| 1024 |
i__3 = j - *ku; |
| 1025 |
i__2 = j; |
| 1026 |
for (i__ = std::max(i__3,1_integer); i__ <= i__2; ++i__) { |
| 1027 |
/* Computing MAX */ |
| 1028 |
d__2 = (d__1 = afb[kd + i__ - j + j * afb_dim1], abs(d__1)); |
| 1029 |
umax = std::max(d__2,umax); |
| 1030 |
} |
| 1031 |
if (umax != 0.) { |
| 1032 |
/* Computing MIN */ |
| 1033 |
d__1 = amax / umax; |
| 1034 |
rpvgrw = std::min(d__1,rpvgrw); |
| 1035 |
} |
| 1036 |
} |
| 1037 |
ret_val = rpvgrw; |
| 1038 |
return ret_val; |
| 1039 |
} /* dla_gbrpvgrw__ */ |
| 1040 |
|
| 1041 |
double dla_porcond__(const char *uplo, integer *n, double *a, integer *lda, |
| 1042 |
double *af, integer *ldaf, integer *cmode, double *c__, |
| 1043 |
integer *info, double *work, integer *iwork, integer uplo_len) |
| 1044 |
{ |
| 1045 |
/* Table of constant values */ |
| 1046 |
static integer c__1 = 1; |
| 1047 |
|
| 1048 |
/* System generated locals */ |
| 1049 |
integer a_dim1, a_offset, af_dim1, af_offset, i__1, i__2; |
| 1050 |
double ret_val, d__1; |
| 1051 |
|
| 1052 |
/* Local variables */ |
| 1053 |
integer i__, j; |
| 1054 |
bool up; |
| 1055 |
double tmp; |
| 1056 |
integer kase; |
| 1057 |
integer isave[3]; |
| 1058 |
double ainvnm; |
| 1059 |
|
| 1060 |
|
| 1061 |
/* -- LAPACK routine (version 3.2.1) -- */ |
| 1062 |
/* -- Contributed by James Demmel, Deaglan Halligan, Yozo Hida and -- */ |
| 1063 |
/* -- Jason Riedy of Univ. of California Berkeley. -- */ |
| 1064 |
/* -- April 2009 -- */ |
| 1065 |
|
| 1066 |
/* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ |
| 1067 |
/* -- Univ. of California Berkeley and NAG Ltd. -- */ |
| 1068 |
|
| 1069 |
/* .. */ |
| 1070 |
/* .. Scalar Arguments .. */ |
| 1071 |
/* .. */ |
| 1072 |
/* .. Array Arguments .. */ |
| 1073 |
/* .. */ |
| 1074 |
|
| 1075 |
/* Purpose */ |
| 1076 |
/* ======= */ |
| 1077 |
|
| 1078 |
/* DLA_PORCOND Estimates the Skeel condition number of op(A) * op2(C) */ |
| 1079 |
/* where op2 is determined by CMODE as follows */ |
| 1080 |
/* CMODE = 1 op2(C) = C */ |
| 1081 |
/* CMODE = 0 op2(C) = I */ |
| 1082 |
/* CMODE = -1 op2(C) = inv(C) */ |
| 1083 |
/* The Skeel condition number cond(A) = norminf( |inv(A)||A| ) */ |
| 1084 |
/* is computed by computing scaling factors R such that */ |
| 1085 |
/* diag(R)*A*op2(C) is row equilibrated and computing the standard */ |
| 1086 |
/* infinity-norm condition number. */ |
| 1087 |
|
| 1088 |
/* Arguments */ |
| 1089 |
/* ========== */ |
| 1090 |
|
| 1091 |
/* UPLO (input) CHARACTER*1 */ |
| 1092 |
/* = 'U': Upper triangle of A is stored; */ |
| 1093 |
/* = 'L': Lower triangle of A is stored. */ |
| 1094 |
|
| 1095 |
/* N (input) INTEGER */ |
| 1096 |
/* The number of linear equations, i.e., the order of the */ |
| 1097 |
/* matrix A. N >= 0. */ |
| 1098 |
|
| 1099 |
/* A (input) REAL array, dimension (LDA,N) */ |
| 1100 |
/* On entry, the N-by-N matrix A. */ |
| 1101 |
|
| 1102 |
/* LDA (input) INTEGER */ |
| 1103 |
/* The leading dimension of the array A. LDA >= max(1,N). */ |
| 1104 |
|
| 1105 |
/* AF (input) DOUBLE PRECISION array, dimension (LDAF,N) */ |
| 1106 |
/* The triangular factor U or L from the Cholesky factorization */ |
| 1107 |
/* A = U**T*U or A = L*L**T, as computed by DPOTRF. */ |
| 1108 |
|
| 1109 |
/* LDAF (input) INTEGER */ |
| 1110 |
/* The leading dimension of the array AF. LDAF >= max(1,N). */ |
| 1111 |
|
| 1112 |
/* CMODE (input) INTEGER */ |
| 1113 |
/* Determines op2(C) in the formula op(A) * op2(C) as follows: */ |
| 1114 |
/* CMODE = 1 op2(C) = C */ |
| 1115 |
/* CMODE = 0 op2(C) = I */ |
| 1116 |
/* CMODE = -1 op2(C) = inv(C) */ |
| 1117 |
|
| 1118 |
/* C (input) DOUBLE PRECISION array, dimension (N) */ |
| 1119 |
/* The vector C in the formula op(A) * op2(C). */ |
| 1120 |
|
| 1121 |
/* INFO (output) INTEGER */ |
| 1122 |
/* = 0: Successful exit. */ |
| 1123 |
/* i > 0: The ith argument is invalid. */ |
| 1124 |
|
| 1125 |
/* WORK (input) DOUBLE PRECISION array, dimension (3*N). */ |
| 1126 |
/* Workspace. */ |
| 1127 |
|
| 1128 |
/* IWORK (input) INTEGER array, dimension (N). */ |
| 1129 |
/* Workspace. */ |
| 1130 |
|
| 1131 |
/* ===================================================================== */ |
| 1132 |
|
| 1133 |
/* .. Local Scalars .. */ |
| 1134 |
/* .. */ |
| 1135 |
/* .. Array Arguments .. */ |
| 1136 |
/* .. */ |
| 1137 |
/* .. External Functions .. */ |
| 1138 |
/* .. */ |
| 1139 |
/* .. External Subroutines .. */ |
| 1140 |
/* .. */ |
| 1141 |
/* .. Intrinsic Functions .. */ |
| 1142 |
/* .. */ |
| 1143 |
/* .. Executable Statements .. */ |
| 1144 |
|
| 1145 |
/* Parameter adjustments */ |
| 1146 |
a_dim1 = *lda; |
| 1147 |
a_offset = 1 + a_dim1; |
| 1148 |
a -= a_offset; |
| 1149 |
af_dim1 = *ldaf; |
| 1150 |
af_offset = 1 + af_dim1; |
| 1151 |
af -= af_offset; |
| 1152 |
--c__; |
| 1153 |
--work; |
| 1154 |
--iwork; |
| 1155 |
|
| 1156 |
/* Function Body */ |
| 1157 |
ret_val = 0.; |
| 1158 |
|
| 1159 |
*info = 0; |
| 1160 |
if (*n < 0) { |
| 1161 |
*info = -2; |
| 1162 |
} |
| 1163 |
if (*info != 0) { |
| 1164 |
i__1 = -(*info); |
| 1165 |
xerbla_("DLA_PORCOND", &i__1); |
| 1166 |
return ret_val; |
| 1167 |
} |
| 1168 |
if (*n == 0) { |
| 1169 |
ret_val = 1.; |
| 1170 |
return ret_val; |
| 1171 |
} |
| 1172 |
up = false; |
| 1173 |
if (lsame_(uplo, "U")) { |
| 1174 |
up = true; |
| 1175 |
} |
| 1176 |
|
| 1177 |
/* Compute the equilibration matrix R such that */ |
| 1178 |
/* inv(R)*A*C has unit 1-norm. */ |
| 1179 |
|
| 1180 |
if (up) { |
| 1181 |
i__1 = *n; |
| 1182 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 1183 |
tmp = 0.; |
| 1184 |
if (*cmode == 1) { |
| 1185 |
i__2 = i__; |
| 1186 |
for (j = 1; j <= i__2; ++j) { |
| 1187 |
tmp += (d__1 = a[j + i__ * a_dim1] * c__[j], abs(d__1)); |
| 1188 |
} |
| 1189 |
i__2 = *n; |
| 1190 |
for (j = i__ + 1; j <= i__2; ++j) { |
| 1191 |
tmp += (d__1 = a[i__ + j * a_dim1] * c__[j], abs(d__1)); |
| 1192 |
} |
| 1193 |
} else if (*cmode == 0) { |
| 1194 |
i__2 = i__; |
| 1195 |
for (j = 1; j <= i__2; ++j) { |
| 1196 |
tmp += (d__1 = a[j + i__ * a_dim1], abs(d__1)); |
| 1197 |
} |
| 1198 |
i__2 = *n; |
| 1199 |
for (j = i__ + 1; j <= i__2; ++j) { |
| 1200 |
tmp += (d__1 = a[i__ + j * a_dim1], abs(d__1)); |
| 1201 |
} |
| 1202 |
} else { |
| 1203 |
i__2 = i__; |
| 1204 |
for (j = 1; j <= i__2; ++j) { |
| 1205 |
tmp += (d__1 = a[j + i__ * a_dim1] / c__[j], abs(d__1)); |
| 1206 |
} |
| 1207 |
i__2 = *n; |
| 1208 |
for (j = i__ + 1; j <= i__2; ++j) { |
| 1209 |
tmp += (d__1 = a[i__ + j * a_dim1] / c__[j], abs(d__1)); |
| 1210 |
} |
| 1211 |
} |
| 1212 |
work[(*n << 1) + i__] = tmp; |
| 1213 |
} |
| 1214 |
} else { |
| 1215 |
i__1 = *n; |
| 1216 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 1217 |
tmp = 0.; |
| 1218 |
if (*cmode == 1) { |
| 1219 |
i__2 = i__; |
| 1220 |
for (j = 1; j <= i__2; ++j) { |
| 1221 |
tmp += (d__1 = a[i__ + j * a_dim1] * c__[j], abs(d__1)); |
| 1222 |
} |
| 1223 |
i__2 = *n; |
| 1224 |
for (j = i__ + 1; j <= i__2; ++j) { |
| 1225 |
tmp += (d__1 = a[j + i__ * a_dim1] * c__[j], abs(d__1)); |
| 1226 |
} |
| 1227 |
} else if (*cmode == 0) { |
| 1228 |
i__2 = i__; |
| 1229 |
for (j = 1; j <= i__2; ++j) { |
| 1230 |
tmp += (d__1 = a[i__ + j * a_dim1], abs(d__1)); |
| 1231 |
} |
| 1232 |
i__2 = *n; |
| 1233 |
for (j = i__ + 1; j <= i__2; ++j) { |
| 1234 |
tmp += (d__1 = a[j + i__ * a_dim1], abs(d__1)); |
| 1235 |
} |
| 1236 |
} else { |
| 1237 |
i__2 = i__; |
| 1238 |
for (j = 1; j <= i__2; ++j) { |
| 1239 |
tmp += (d__1 = a[i__ + j * a_dim1] / c__[j], abs(d__1)); |
| 1240 |
} |
| 1241 |
i__2 = *n; |
| 1242 |
for (j = i__ + 1; j <= i__2; ++j) { |
| 1243 |
tmp += (d__1 = a[j + i__ * a_dim1] / c__[j], abs(d__1)); |
| 1244 |
} |
| 1245 |
} |
| 1246 |
work[(*n << 1) + i__] = tmp; |
| 1247 |
} |
| 1248 |
} |
| 1249 |
|
| 1250 |
/* Estimate the norm of inv(op(A)). */ |
| 1251 |
|
| 1252 |
ainvnm = 0.; |
| 1253 |
kase = 0; |
| 1254 |
L10: |
| 1255 |
dlacn2_(n, &work[*n + 1], &work[1], &iwork[1], &ainvnm, &kase, isave); |
| 1256 |
if (kase != 0) { |
| 1257 |
if (kase == 2) { |
| 1258 |
|
| 1259 |
/* Multiply by R. */ |
| 1260 |
|
| 1261 |
i__1 = *n; |
| 1262 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 1263 |
work[i__] *= work[(*n << 1) + i__]; |
| 1264 |
} |
| 1265 |
if (up) { |
| 1266 |
dpotrs_("Upper", n, &c__1, &af[af_offset], ldaf, &work[1], n, |
| 1267 |
info); |
| 1268 |
} else { |
| 1269 |
dpotrs_("Lower", n, &c__1, &af[af_offset], ldaf, &work[1], n, |
| 1270 |
info); |
| 1271 |
} |
| 1272 |
|
| 1273 |
/* Multiply by inv(C). */ |
| 1274 |
|
| 1275 |
if (*cmode == 1) { |
| 1276 |
i__1 = *n; |
| 1277 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 1278 |
work[i__] /= c__[i__]; |
| 1279 |
} |
| 1280 |
} else if (*cmode == -1) { |
| 1281 |
i__1 = *n; |
| 1282 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 1283 |
work[i__] *= c__[i__]; |
| 1284 |
} |
| 1285 |
} |
| 1286 |
} else { |
| 1287 |
|
| 1288 |
/* Multiply by inv(C'). */ |
| 1289 |
|
| 1290 |
if (*cmode == 1) { |
| 1291 |
i__1 = *n; |
| 1292 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 1293 |
work[i__] /= c__[i__]; |
| 1294 |
} |
| 1295 |
} else if (*cmode == -1) { |
| 1296 |
i__1 = *n; |
| 1297 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 1298 |
work[i__] *= c__[i__]; |
| 1299 |
} |
| 1300 |
} |
| 1301 |
if (up) { |
| 1302 |
dpotrs_("Upper", n, &c__1, &af[af_offset], ldaf, &work[1], n, |
| 1303 |
info); |
| 1304 |
} else { |
| 1305 |
dpotrs_("Lower", n, &c__1, &af[af_offset], ldaf, &work[1], n, |
| 1306 |
info); |
| 1307 |
} |
| 1308 |
|
| 1309 |
/* Multiply by R. */ |
| 1310 |
|
| 1311 |
i__1 = *n; |
| 1312 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 1313 |
work[i__] *= work[(*n << 1) + i__]; |
| 1314 |
} |
| 1315 |
} |
| 1316 |
goto L10; |
| 1317 |
} |
| 1318 |
|
| 1319 |
/* Compute the estimate of the reciprocal condition number. */ |
| 1320 |
|
| 1321 |
if (ainvnm != 0.) { |
| 1322 |
ret_val = 1. / ainvnm; |
| 1323 |
} |
| 1324 |
|
| 1325 |
return ret_val; |
| 1326 |
|
| 1327 |
} /* dla_porcond__ */ |
| 1328 |
|
| 1329 |
int dla_wwaddw__(integer *n, double *x, double *y, double *w) |
| 1330 |
{ |
| 1331 |
/* System generated locals */ |
| 1332 |
integer i__1; |
| 1333 |
|
| 1334 |
/* Local variables */ |
| 1335 |
integer i__; |
| 1336 |
double s; |
| 1337 |
|
| 1338 |
|
| 1339 |
/* -- LAPACK routine (version 3.2) -- */ |
| 1340 |
/* -- Contributed by James Demmel, Deaglan Halligan, Yozo Hida and -- */ |
| 1341 |
/* -- Jason Riedy of Univ. of California Berkeley. -- */ |
| 1342 |
/* -- November 2008 -- */ |
| 1343 |
|
| 1344 |
/* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ |
| 1345 |
/* -- Univ. of California Berkeley and NAG Ltd. -- */ |
| 1346 |
|
| 1347 |
/* .. */ |
| 1348 |
/* .. Scalar Arguments .. */ |
| 1349 |
/* .. */ |
| 1350 |
/* .. Array Arguments .. */ |
| 1351 |
/* .. */ |
| 1352 |
|
| 1353 |
/* Purpose */ |
| 1354 |
/* ======= */ |
| 1355 |
|
| 1356 |
/* DLA_WWADDW adds a vector W into a doubled-single vector (X, Y). */ |
| 1357 |
|
| 1358 |
/* This works for all extant IBM's hex and binary floating point */ |
| 1359 |
/* arithmetics, but not for decimal. */ |
| 1360 |
|
| 1361 |
/* Arguments */ |
| 1362 |
/* ========= */ |
| 1363 |
|
| 1364 |
/* N (input) INTEGER */ |
| 1365 |
/* The length of vectors X, Y, and W. */ |
| 1366 |
|
| 1367 |
/* X, Y (input/output) DOUBLE PRECISION array, length N */ |
| 1368 |
/* The doubled-single accumulation vector. */ |
| 1369 |
|
| 1370 |
/* W (input) DOUBLE PRECISION array, length N */ |
| 1371 |
/* The vector to be added. */ |
| 1372 |
/* .. */ |
| 1373 |
/* .. Local Scalars .. */ |
| 1374 |
/* .. */ |
| 1375 |
/* .. Executable Statements .. */ |
| 1376 |
|
| 1377 |
/* Parameter adjustments */ |
| 1378 |
--w; |
| 1379 |
--y; |
| 1380 |
--x; |
| 1381 |
|
| 1382 |
/* Function Body */ |
| 1383 |
i__1 = *n; |
| 1384 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 1385 |
s = x[i__] + w[i__]; |
| 1386 |
s = s + s - s; |
| 1387 |
y[i__] = x[i__] - s + w[i__] + y[i__]; |
| 1388 |
x[i__] = s; |
| 1389 |
/* L10: */ |
| 1390 |
} |
| 1391 |
return 0; |
| 1392 |
} /* dla_wwaddw__ */ |
| 1393 |
|
| 1394 |
/* Subroutine */ int dlabad_(double *small, double *large) |
| 1395 |
{ |
| 1396 |
/* Builtin functions |
| 1397 |
double d_lg10(double *), sqrt(double);*/ |
| 1398 |
|
| 1399 |
|
| 1400 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 1401 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 1402 |
/* November 2006 */ |
| 1403 |
|
| 1404 |
/* .. Scalar Arguments .. */ |
| 1405 |
/* .. */ |
| 1406 |
|
| 1407 |
/* Purpose */ |
| 1408 |
/* ======= */ |
| 1409 |
|
| 1410 |
/* DLABAD takes as input the values computed by DLAMCH for underflow and */ |
| 1411 |
/* overflow, and returns the square root of each of these values if the */ |
| 1412 |
/* log of LARGE is sufficiently large. This subroutine is intended to */ |
| 1413 |
/* identify machines with a large exponent range, such as the Crays, and */ |
| 1414 |
/* redefine the underflow and overflow limits to be the square roots of */ |
| 1415 |
/* the values computed by DLAMCH. This subroutine is needed because */ |
| 1416 |
/* DLAMCH does not compensate for poor arithmetic in the upper half of */ |
| 1417 |
/* the exponent range, as is found on a Cray. */ |
| 1418 |
|
| 1419 |
/* Arguments */ |
| 1420 |
/* ========= */ |
| 1421 |
|
| 1422 |
/* SMALL (input/output) DOUBLE PRECISION */ |
| 1423 |
/* On entry, the underflow threshold as computed by DLAMCH. */ |
| 1424 |
/* On exit, if LOG10(LARGE) is sufficiently large, the square */ |
| 1425 |
/* root of SMALL, otherwise unchanged. */ |
| 1426 |
|
| 1427 |
/* LARGE (input/output) DOUBLE PRECISION */ |
| 1428 |
/* On entry, the overflow threshold as computed by DLAMCH. */ |
| 1429 |
/* On exit, if LOG10(LARGE) is sufficiently large, the square */ |
| 1430 |
/* root of LARGE, otherwise unchanged. */ |
| 1431 |
|
| 1432 |
/* ===================================================================== */ |
| 1433 |
|
| 1434 |
/* .. Intrinsic Functions .. */ |
| 1435 |
/* .. */ |
| 1436 |
/* .. Executable Statements .. */ |
| 1437 |
|
| 1438 |
/* If it looks like we're on a Cray, take the square root of */ |
| 1439 |
/* SMALL and LARGE to avoid overflow and underflow problems. */ |
| 1440 |
|
| 1441 |
if (d_lg10(large) > 2e3) { |
| 1442 |
*small = sqrt(*small); |
| 1443 |
*large = sqrt(*large); |
| 1444 |
} |
| 1445 |
|
| 1446 |
return 0; |
| 1447 |
|
| 1448 |
/* End of DLABAD */ |
| 1449 |
|
| 1450 |
} /* dlabad_ */ |
| 1451 |
|
| 1452 |
/* Subroutine */ int dlabrd_(integer *m, integer *n, integer *nb, double * |
| 1453 |
a, integer *lda, double *d__, double *e, double *tauq, |
| 1454 |
double *taup, double *x, integer *ldx, double *y, integer |
| 1455 |
*ldy) |
| 1456 |
{ |
| 1457 |
/* Table of constant values */ |
| 1458 |
static double c_b4 = -1.; |
| 1459 |
static double c_b5 = 1.; |
| 1460 |
static integer c__1 = 1; |
| 1461 |
static double c_b16 = 0.; |
| 1462 |
|
| 1463 |
/* System generated locals */ |
| 1464 |
integer a_dim1, a_offset, x_dim1, x_offset, y_dim1, y_offset, i__1, i__2, |
| 1465 |
i__3; |
| 1466 |
|
| 1467 |
/* Local variables */ |
| 1468 |
integer i__; |
| 1469 |
|
| 1470 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 1471 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 1472 |
/* November 2006 */ |
| 1473 |
|
| 1474 |
/* .. Scalar Arguments .. */ |
| 1475 |
/* .. */ |
| 1476 |
/* .. Array Arguments .. */ |
| 1477 |
/* .. */ |
| 1478 |
|
| 1479 |
/* Purpose */ |
| 1480 |
/* ======= */ |
| 1481 |
|
| 1482 |
/* DLABRD reduces the first NB rows and columns of a real general */ |
| 1483 |
/* m by n matrix A to upper or lower bidiagonal form by an orthogonal */ |
| 1484 |
/* transformation Q' * A * P, and returns the matrices X and Y which */ |
| 1485 |
/* are needed to apply the transformation to the unreduced part of A. */ |
| 1486 |
|
| 1487 |
/* If m >= n, A is reduced to upper bidiagonal form; if m < n, to lower */ |
| 1488 |
/* bidiagonal form. */ |
| 1489 |
|
| 1490 |
/* This is an auxiliary routine called by DGEBRD */ |
| 1491 |
|
| 1492 |
/* Arguments */ |
| 1493 |
/* ========= */ |
| 1494 |
|
| 1495 |
/* M (input) INTEGER */ |
| 1496 |
/* The number of rows in the matrix A. */ |
| 1497 |
|
| 1498 |
/* N (input) INTEGER */ |
| 1499 |
/* The number of columns in the matrix A. */ |
| 1500 |
|
| 1501 |
/* NB (input) INTEGER */ |
| 1502 |
/* The number of leading rows and columns of A to be reduced. */ |
| 1503 |
|
| 1504 |
/* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 1505 |
/* On entry, the m by n general matrix to be reduced. */ |
| 1506 |
/* On exit, the first NB rows and columns of the matrix are */ |
| 1507 |
/* overwritten; the rest of the array is unchanged. */ |
| 1508 |
/* If m >= n, elements on and below the diagonal in the first NB */ |
| 1509 |
/* columns, with the array TAUQ, represent the orthogonal */ |
| 1510 |
/* matrix Q as a product of elementary reflectors; and */ |
| 1511 |
/* elements above the diagonal in the first NB rows, with the */ |
| 1512 |
/* array TAUP, represent the orthogonal matrix P as a product */ |
| 1513 |
/* of elementary reflectors. */ |
| 1514 |
/* If m < n, elements below the diagonal in the first NB */ |
| 1515 |
/* columns, with the array TAUQ, represent the orthogonal */ |
| 1516 |
/* matrix Q as a product of elementary reflectors, and */ |
| 1517 |
/* elements on and above the diagonal in the first NB rows, */ |
| 1518 |
/* with the array TAUP, represent the orthogonal matrix P as */ |
| 1519 |
/* a product of elementary reflectors. */ |
| 1520 |
/* See Further Details. */ |
| 1521 |
|
| 1522 |
/* LDA (input) INTEGER */ |
| 1523 |
/* The leading dimension of the array A. LDA >= max(1,M). */ |
| 1524 |
|
| 1525 |
/* D (output) DOUBLE PRECISION array, dimension (NB) */ |
| 1526 |
/* The diagonal elements of the first NB rows and columns of */ |
| 1527 |
/* the reduced matrix. D(i) = A(i,i). */ |
| 1528 |
|
| 1529 |
/* E (output) DOUBLE PRECISION array, dimension (NB) */ |
| 1530 |
/* The off-diagonal elements of the first NB rows and columns of */ |
| 1531 |
/* the reduced matrix. */ |
| 1532 |
|
| 1533 |
/* TAUQ (output) DOUBLE PRECISION array dimension (NB) */ |
| 1534 |
/* The scalar factors of the elementary reflectors which */ |
| 1535 |
/* represent the orthogonal matrix Q. See Further Details. */ |
| 1536 |
|
| 1537 |
/* TAUP (output) DOUBLE PRECISION array, dimension (NB) */ |
| 1538 |
/* The scalar factors of the elementary reflectors which */ |
| 1539 |
/* represent the orthogonal matrix P. See Further Details. */ |
| 1540 |
|
| 1541 |
/* X (output) DOUBLE PRECISION array, dimension (LDX,NB) */ |
| 1542 |
/* The m-by-nb matrix X required to update the unreduced part */ |
| 1543 |
/* of A. */ |
| 1544 |
|
| 1545 |
/* LDX (input) INTEGER */ |
| 1546 |
/* The leading dimension of the array X. LDX >= M. */ |
| 1547 |
|
| 1548 |
/* Y (output) DOUBLE PRECISION array, dimension (LDY,NB) */ |
| 1549 |
/* The n-by-nb matrix Y required to update the unreduced part */ |
| 1550 |
/* of A. */ |
| 1551 |
|
| 1552 |
/* LDY (input) INTEGER */ |
| 1553 |
/* The leading dimension of the array Y. LDY >= N. */ |
| 1554 |
|
| 1555 |
/* Further Details */ |
| 1556 |
/* =============== */ |
| 1557 |
|
| 1558 |
/* The matrices Q and P are represented as products of elementary */ |
| 1559 |
/* reflectors: */ |
| 1560 |
|
| 1561 |
/* Q = H(1) H(2) . . . H(nb) and P = G(1) G(2) . . . G(nb) */ |
| 1562 |
|
| 1563 |
/* Each H(i) and G(i) has the form: */ |
| 1564 |
|
| 1565 |
/* H(i) = I - tauq * v * v' and G(i) = I - taup * u * u' */ |
| 1566 |
|
| 1567 |
/* where tauq and taup are real scalars, and v and u are real vectors. */ |
| 1568 |
|
| 1569 |
/* If m >= n, v(1:i-1) = 0, v(i) = 1, and v(i:m) is stored on exit in */ |
| 1570 |
/* A(i:m,i); u(1:i) = 0, u(i+1) = 1, and u(i+1:n) is stored on exit in */ |
| 1571 |
/* A(i,i+1:n); tauq is stored in TAUQ(i) and taup in TAUP(i). */ |
| 1572 |
|
| 1573 |
/* If m < n, v(1:i) = 0, v(i+1) = 1, and v(i+1:m) is stored on exit in */ |
| 1574 |
/* A(i+2:m,i); u(1:i-1) = 0, u(i) = 1, and u(i:n) is stored on exit in */ |
| 1575 |
/* A(i,i+1:n); tauq is stored in TAUQ(i) and taup in TAUP(i). */ |
| 1576 |
|
| 1577 |
/* The elements of the vectors v and u together form the m-by-nb matrix */ |
| 1578 |
/* V and the nb-by-n matrix U' which are needed, with X and Y, to apply */ |
| 1579 |
/* the transformation to the unreduced part of the matrix, using a block */ |
| 1580 |
/* update of the form: A := A - V*Y' - X*U'. */ |
| 1581 |
|
| 1582 |
/* The contents of A on exit are illustrated by the following examples */ |
| 1583 |
/* with nb = 2: */ |
| 1584 |
|
| 1585 |
/* m = 6 and n = 5 (m > n): m = 5 and n = 6 (m < n): */ |
| 1586 |
|
| 1587 |
/* ( 1 1 u1 u1 u1 ) ( 1 u1 u1 u1 u1 u1 ) */ |
| 1588 |
/* ( v1 1 1 u2 u2 ) ( 1 1 u2 u2 u2 u2 ) */ |
| 1589 |
/* ( v1 v2 a a a ) ( v1 1 a a a a ) */ |
| 1590 |
/* ( v1 v2 a a a ) ( v1 v2 a a a a ) */ |
| 1591 |
/* ( v1 v2 a a a ) ( v1 v2 a a a a ) */ |
| 1592 |
/* ( v1 v2 a a a ) */ |
| 1593 |
|
| 1594 |
/* where a denotes an element of the original matrix which is unchanged, */ |
| 1595 |
/* vi denotes an element of the vector defining H(i), and ui an element */ |
| 1596 |
/* of the vector defining G(i). */ |
| 1597 |
|
| 1598 |
/* ===================================================================== */ |
| 1599 |
|
| 1600 |
/* .. Parameters .. */ |
| 1601 |
/* .. */ |
| 1602 |
/* .. Local Scalars .. */ |
| 1603 |
/* .. */ |
| 1604 |
/* .. External Subroutines .. */ |
| 1605 |
/* .. */ |
| 1606 |
/* .. Intrinsic Functions .. */ |
| 1607 |
/* .. */ |
| 1608 |
/* .. Executable Statements .. */ |
| 1609 |
|
| 1610 |
/* Quick return if possible */ |
| 1611 |
|
| 1612 |
/* Parameter adjustments */ |
| 1613 |
a_dim1 = *lda; |
| 1614 |
a_offset = 1 + a_dim1; |
| 1615 |
a -= a_offset; |
| 1616 |
--d__; |
| 1617 |
--e; |
| 1618 |
--tauq; |
| 1619 |
--taup; |
| 1620 |
x_dim1 = *ldx; |
| 1621 |
x_offset = 1 + x_dim1; |
| 1622 |
x -= x_offset; |
| 1623 |
y_dim1 = *ldy; |
| 1624 |
y_offset = 1 + y_dim1; |
| 1625 |
y -= y_offset; |
| 1626 |
|
| 1627 |
/* Function Body */ |
| 1628 |
if (*m <= 0 || *n <= 0) { |
| 1629 |
return 0; |
| 1630 |
} |
| 1631 |
|
| 1632 |
if (*m >= *n) { |
| 1633 |
|
| 1634 |
/* Reduce to upper bidiagonal form */ |
| 1635 |
|
| 1636 |
i__1 = *nb; |
| 1637 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 1638 |
|
| 1639 |
/* Update A(i:m,i) */ |
| 1640 |
|
| 1641 |
i__2 = *m - i__ + 1; |
| 1642 |
i__3 = i__ - 1; |
| 1643 |
dgemv_("No transpose", &i__2, &i__3, &c_b4, &a[i__ + a_dim1], lda, |
| 1644 |
&y[i__ + y_dim1], ldy, &c_b5, &a[i__ + i__ * a_dim1], & |
| 1645 |
c__1); |
| 1646 |
i__2 = *m - i__ + 1; |
| 1647 |
i__3 = i__ - 1; |
| 1648 |
dgemv_("No transpose", &i__2, &i__3, &c_b4, &x[i__ + x_dim1], ldx, |
| 1649 |
&a[i__ * a_dim1 + 1], &c__1, &c_b5, &a[i__ + i__ * |
| 1650 |
a_dim1], &c__1); |
| 1651 |
|
| 1652 |
/* Generate reflection Q(i) to annihilate A(i+1:m,i) */ |
| 1653 |
|
| 1654 |
i__2 = *m - i__ + 1; |
| 1655 |
/* Computing MIN */ |
| 1656 |
i__3 = i__ + 1; |
| 1657 |
dlarfg_(&i__2, &a[i__ + i__ * a_dim1], &a[std::min(i__3, *m)+ i__ * |
| 1658 |
a_dim1], &c__1, &tauq[i__]); |
| 1659 |
d__[i__] = a[i__ + i__ * a_dim1]; |
| 1660 |
if (i__ < *n) { |
| 1661 |
a[i__ + i__ * a_dim1] = 1.; |
| 1662 |
|
| 1663 |
/* Compute Y(i+1:n,i) */ |
| 1664 |
|
| 1665 |
i__2 = *m - i__ + 1; |
| 1666 |
i__3 = *n - i__; |
| 1667 |
dgemv_("Transpose", &i__2, &i__3, &c_b5, &a[i__ + (i__ + 1) * |
| 1668 |
a_dim1], lda, &a[i__ + i__ * a_dim1], &c__1, &c_b16, & |
| 1669 |
y[i__ + 1 + i__ * y_dim1], &c__1); |
| 1670 |
i__2 = *m - i__ + 1; |
| 1671 |
i__3 = i__ - 1; |
| 1672 |
dgemv_("Transpose", &i__2, &i__3, &c_b5, &a[i__ + a_dim1], |
| 1673 |
lda, &a[i__ + i__ * a_dim1], &c__1, &c_b16, &y[i__ * |
| 1674 |
y_dim1 + 1], &c__1); |
| 1675 |
i__2 = *n - i__; |
| 1676 |
i__3 = i__ - 1; |
| 1677 |
dgemv_("No transpose", &i__2, &i__3, &c_b4, &y[i__ + 1 + |
| 1678 |
y_dim1], ldy, &y[i__ * y_dim1 + 1], &c__1, &c_b5, &y[ |
| 1679 |
i__ + 1 + i__ * y_dim1], &c__1); |
| 1680 |
i__2 = *m - i__ + 1; |
| 1681 |
i__3 = i__ - 1; |
| 1682 |
dgemv_("Transpose", &i__2, &i__3, &c_b5, &x[i__ + x_dim1], |
| 1683 |
ldx, &a[i__ + i__ * a_dim1], &c__1, &c_b16, &y[i__ * |
| 1684 |
y_dim1 + 1], &c__1); |
| 1685 |
i__2 = i__ - 1; |
| 1686 |
i__3 = *n - i__; |
| 1687 |
dgemv_("Transpose", &i__2, &i__3, &c_b4, &a[(i__ + 1) * |
| 1688 |
a_dim1 + 1], lda, &y[i__ * y_dim1 + 1], &c__1, &c_b5, |
| 1689 |
&y[i__ + 1 + i__ * y_dim1], &c__1); |
| 1690 |
i__2 = *n - i__; |
| 1691 |
dscal_(&i__2, &tauq[i__], &y[i__ + 1 + i__ * y_dim1], &c__1); |
| 1692 |
|
| 1693 |
/* Update A(i,i+1:n) */ |
| 1694 |
|
| 1695 |
i__2 = *n - i__; |
| 1696 |
dgemv_("No transpose", &i__2, &i__, &c_b4, &y[i__ + 1 + |
| 1697 |
y_dim1], ldy, &a[i__ + a_dim1], lda, &c_b5, &a[i__ + ( |
| 1698 |
i__ + 1) * a_dim1], lda); |
| 1699 |
i__2 = i__ - 1; |
| 1700 |
i__3 = *n - i__; |
| 1701 |
dgemv_("Transpose", &i__2, &i__3, &c_b4, &a[(i__ + 1) * |
| 1702 |
a_dim1 + 1], lda, &x[i__ + x_dim1], ldx, &c_b5, &a[ |
| 1703 |
i__ + (i__ + 1) * a_dim1], lda); |
| 1704 |
|
| 1705 |
/* Generate reflection P(i) to annihilate A(i,i+2:n) */ |
| 1706 |
|
| 1707 |
i__2 = *n - i__; |
| 1708 |
/* Computing MIN */ |
| 1709 |
i__3 = i__ + 2; |
| 1710 |
dlarfg_(&i__2, &a[i__ + (i__ + 1) * a_dim1], &a[i__ + std::min( |
| 1711 |
i__3, *n)* a_dim1], lda, &taup[i__]); |
| 1712 |
e[i__] = a[i__ + (i__ + 1) * a_dim1]; |
| 1713 |
a[i__ + (i__ + 1) * a_dim1] = 1.; |
| 1714 |
|
| 1715 |
/* Compute X(i+1:m,i) */ |
| 1716 |
|
| 1717 |
i__2 = *m - i__; |
| 1718 |
i__3 = *n - i__; |
| 1719 |
dgemv_("No transpose", &i__2, &i__3, &c_b5, &a[i__ + 1 + (i__ |
| 1720 |
+ 1) * a_dim1], lda, &a[i__ + (i__ + 1) * a_dim1], |
| 1721 |
lda, &c_b16, &x[i__ + 1 + i__ * x_dim1], &c__1); |
| 1722 |
i__2 = *n - i__; |
| 1723 |
dgemv_("Transpose", &i__2, &i__, &c_b5, &y[i__ + 1 + y_dim1], |
| 1724 |
ldy, &a[i__ + (i__ + 1) * a_dim1], lda, &c_b16, &x[ |
| 1725 |
i__ * x_dim1 + 1], &c__1); |
| 1726 |
i__2 = *m - i__; |
| 1727 |
dgemv_("No transpose", &i__2, &i__, &c_b4, &a[i__ + 1 + |
| 1728 |
a_dim1], lda, &x[i__ * x_dim1 + 1], &c__1, &c_b5, &x[ |
| 1729 |
i__ + 1 + i__ * x_dim1], &c__1); |
| 1730 |
i__2 = i__ - 1; |
| 1731 |
i__3 = *n - i__; |
| 1732 |
dgemv_("No transpose", &i__2, &i__3, &c_b5, &a[(i__ + 1) * |
| 1733 |
a_dim1 + 1], lda, &a[i__ + (i__ + 1) * a_dim1], lda, & |
| 1734 |
c_b16, &x[i__ * x_dim1 + 1], &c__1); |
| 1735 |
i__2 = *m - i__; |
| 1736 |
i__3 = i__ - 1; |
| 1737 |
dgemv_("No transpose", &i__2, &i__3, &c_b4, &x[i__ + 1 + |
| 1738 |
x_dim1], ldx, &x[i__ * x_dim1 + 1], &c__1, &c_b5, &x[ |
| 1739 |
i__ + 1 + i__ * x_dim1], &c__1); |
| 1740 |
i__2 = *m - i__; |
| 1741 |
dscal_(&i__2, &taup[i__], &x[i__ + 1 + i__ * x_dim1], &c__1); |
| 1742 |
} |
| 1743 |
/* L10: */ |
| 1744 |
} |
| 1745 |
} else { |
| 1746 |
|
| 1747 |
/* Reduce to lower bidiagonal form */ |
| 1748 |
|
| 1749 |
i__1 = *nb; |
| 1750 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 1751 |
|
| 1752 |
/* Update A(i,i:n) */ |
| 1753 |
|
| 1754 |
i__2 = *n - i__ + 1; |
| 1755 |
i__3 = i__ - 1; |
| 1756 |
dgemv_("No transpose", &i__2, &i__3, &c_b4, &y[i__ + y_dim1], ldy, |
| 1757 |
&a[i__ + a_dim1], lda, &c_b5, &a[i__ + i__ * a_dim1], |
| 1758 |
lda); |
| 1759 |
i__2 = i__ - 1; |
| 1760 |
i__3 = *n - i__ + 1; |
| 1761 |
dgemv_("Transpose", &i__2, &i__3, &c_b4, &a[i__ * a_dim1 + 1], |
| 1762 |
lda, &x[i__ + x_dim1], ldx, &c_b5, &a[i__ + i__ * a_dim1], |
| 1763 |
lda); |
| 1764 |
|
| 1765 |
/* Generate reflection P(i) to annihilate A(i,i+1:n) */ |
| 1766 |
|
| 1767 |
i__2 = *n - i__ + 1; |
| 1768 |
/* Computing MIN */ |
| 1769 |
i__3 = i__ + 1; |
| 1770 |
dlarfg_(&i__2, &a[i__ + i__ * a_dim1], &a[i__ + std::min(i__3, *n)* |
| 1771 |
a_dim1], lda, &taup[i__]); |
| 1772 |
d__[i__] = a[i__ + i__ * a_dim1]; |
| 1773 |
if (i__ < *m) { |
| 1774 |
a[i__ + i__ * a_dim1] = 1.; |
| 1775 |
|
| 1776 |
/* Compute X(i+1:m,i) */ |
| 1777 |
|
| 1778 |
i__2 = *m - i__; |
| 1779 |
i__3 = *n - i__ + 1; |
| 1780 |
dgemv_("No transpose", &i__2, &i__3, &c_b5, &a[i__ + 1 + i__ * |
| 1781 |
a_dim1], lda, &a[i__ + i__ * a_dim1], lda, &c_b16, & |
| 1782 |
x[i__ + 1 + i__ * x_dim1], &c__1); |
| 1783 |
i__2 = *n - i__ + 1; |
| 1784 |
i__3 = i__ - 1; |
| 1785 |
dgemv_("Transpose", &i__2, &i__3, &c_b5, &y[i__ + y_dim1], |
| 1786 |
ldy, &a[i__ + i__ * a_dim1], lda, &c_b16, &x[i__ * |
| 1787 |
x_dim1 + 1], &c__1); |
| 1788 |
i__2 = *m - i__; |
| 1789 |
i__3 = i__ - 1; |
| 1790 |
dgemv_("No transpose", &i__2, &i__3, &c_b4, &a[i__ + 1 + |
| 1791 |
a_dim1], lda, &x[i__ * x_dim1 + 1], &c__1, &c_b5, &x[ |
| 1792 |
i__ + 1 + i__ * x_dim1], &c__1); |
| 1793 |
i__2 = i__ - 1; |
| 1794 |
i__3 = *n - i__ + 1; |
| 1795 |
dgemv_("No transpose", &i__2, &i__3, &c_b5, &a[i__ * a_dim1 + |
| 1796 |
1], lda, &a[i__ + i__ * a_dim1], lda, &c_b16, &x[i__ * |
| 1797 |
x_dim1 + 1], &c__1); |
| 1798 |
i__2 = *m - i__; |
| 1799 |
i__3 = i__ - 1; |
| 1800 |
dgemv_("No transpose", &i__2, &i__3, &c_b4, &x[i__ + 1 + |
| 1801 |
x_dim1], ldx, &x[i__ * x_dim1 + 1], &c__1, &c_b5, &x[ |
| 1802 |
i__ + 1 + i__ * x_dim1], &c__1); |
| 1803 |
i__2 = *m - i__; |
| 1804 |
dscal_(&i__2, &taup[i__], &x[i__ + 1 + i__ * x_dim1], &c__1); |
| 1805 |
|
| 1806 |
/* Update A(i+1:m,i) */ |
| 1807 |
|
| 1808 |
i__2 = *m - i__; |
| 1809 |
i__3 = i__ - 1; |
| 1810 |
dgemv_("No transpose", &i__2, &i__3, &c_b4, &a[i__ + 1 + |
| 1811 |
a_dim1], lda, &y[i__ + y_dim1], ldy, &c_b5, &a[i__ + |
| 1812 |
1 + i__ * a_dim1], &c__1); |
| 1813 |
i__2 = *m - i__; |
| 1814 |
dgemv_("No transpose", &i__2, &i__, &c_b4, &x[i__ + 1 + |
| 1815 |
x_dim1], ldx, &a[i__ * a_dim1 + 1], &c__1, &c_b5, &a[ |
| 1816 |
i__ + 1 + i__ * a_dim1], &c__1); |
| 1817 |
|
| 1818 |
/* Generate reflection Q(i) to annihilate A(i+2:m,i) */ |
| 1819 |
|
| 1820 |
i__2 = *m - i__; |
| 1821 |
/* Computing MIN */ |
| 1822 |
i__3 = i__ + 2; |
| 1823 |
dlarfg_(&i__2, &a[i__ + 1 + i__ * a_dim1], &a[std::min(i__3, *m)+ |
| 1824 |
i__ * a_dim1], &c__1, &tauq[i__]); |
| 1825 |
e[i__] = a[i__ + 1 + i__ * a_dim1]; |
| 1826 |
a[i__ + 1 + i__ * a_dim1] = 1.; |
| 1827 |
|
| 1828 |
/* Compute Y(i+1:n,i) */ |
| 1829 |
|
| 1830 |
i__2 = *m - i__; |
| 1831 |
i__3 = *n - i__; |
| 1832 |
dgemv_("Transpose", &i__2, &i__3, &c_b5, &a[i__ + 1 + (i__ + |
| 1833 |
1) * a_dim1], lda, &a[i__ + 1 + i__ * a_dim1], &c__1, |
| 1834 |
&c_b16, &y[i__ + 1 + i__ * y_dim1], &c__1); |
| 1835 |
i__2 = *m - i__; |
| 1836 |
i__3 = i__ - 1; |
| 1837 |
dgemv_("Transpose", &i__2, &i__3, &c_b5, &a[i__ + 1 + a_dim1], |
| 1838 |
lda, &a[i__ + 1 + i__ * a_dim1], &c__1, &c_b16, &y[ |
| 1839 |
i__ * y_dim1 + 1], &c__1); |
| 1840 |
i__2 = *n - i__; |
| 1841 |
i__3 = i__ - 1; |
| 1842 |
dgemv_("No transpose", &i__2, &i__3, &c_b4, &y[i__ + 1 + |
| 1843 |
y_dim1], ldy, &y[i__ * y_dim1 + 1], &c__1, &c_b5, &y[ |
| 1844 |
i__ + 1 + i__ * y_dim1], &c__1); |
| 1845 |
i__2 = *m - i__; |
| 1846 |
dgemv_("Transpose", &i__2, &i__, &c_b5, &x[i__ + 1 + x_dim1], |
| 1847 |
ldx, &a[i__ + 1 + i__ * a_dim1], &c__1, &c_b16, &y[ |
| 1848 |
i__ * y_dim1 + 1], &c__1); |
| 1849 |
i__2 = *n - i__; |
| 1850 |
dgemv_("Transpose", &i__, &i__2, &c_b4, &a[(i__ + 1) * a_dim1 |
| 1851 |
+ 1], lda, &y[i__ * y_dim1 + 1], &c__1, &c_b5, &y[i__ |
| 1852 |
+ 1 + i__ * y_dim1], &c__1); |
| 1853 |
i__2 = *n - i__; |
| 1854 |
dscal_(&i__2, &tauq[i__], &y[i__ + 1 + i__ * y_dim1], &c__1); |
| 1855 |
} |
| 1856 |
/* L20: */ |
| 1857 |
} |
| 1858 |
} |
| 1859 |
return 0; |
| 1860 |
|
| 1861 |
/* End of DLABRD */ |
| 1862 |
|
| 1863 |
} /* dlabrd_ */ |
| 1864 |
|
| 1865 |
/* Subroutine */ int dlacn2_(integer *n, double *v, double *x, |
| 1866 |
integer *isgn, double *est, integer *kase, integer *isave) |
| 1867 |
{ |
| 1868 |
/* Table of constant values */ |
| 1869 |
static integer c__1 = 1; |
| 1870 |
static double c_b11 = 1.; |
| 1871 |
|
| 1872 |
/* System generated locals */ |
| 1873 |
integer i__1; |
| 1874 |
double d__1; |
| 1875 |
|
| 1876 |
/* Local variables */ |
| 1877 |
integer i__; |
| 1878 |
double temp; |
| 1879 |
integer jlast; |
| 1880 |
double altsgn, estold; |
| 1881 |
|
| 1882 |
|
| 1883 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 1884 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 1885 |
/* November 2006 */ |
| 1886 |
|
| 1887 |
/* .. Scalar Arguments .. */ |
| 1888 |
/* .. */ |
| 1889 |
/* .. Array Arguments .. */ |
| 1890 |
/* .. */ |
| 1891 |
|
| 1892 |
/* Purpose */ |
| 1893 |
/* ======= */ |
| 1894 |
|
| 1895 |
/* DLACN2 estimates the 1-norm of a square, real matrix A. */ |
| 1896 |
/* Reverse communication is used for evaluating matrix-vector products. */ |
| 1897 |
|
| 1898 |
/* Arguments */ |
| 1899 |
/* ========= */ |
| 1900 |
|
| 1901 |
/* N (input) INTEGER */ |
| 1902 |
/* The order of the matrix. N >= 1. */ |
| 1903 |
|
| 1904 |
/* V (workspace) DOUBLE PRECISION array, dimension (N) */ |
| 1905 |
/* On the final return, V = A*W, where EST = norm(V)/norm(W) */ |
| 1906 |
/* (W is not returned). */ |
| 1907 |
|
| 1908 |
/* X (input/output) DOUBLE PRECISION array, dimension (N) */ |
| 1909 |
/* On an intermediate return, X should be overwritten by */ |
| 1910 |
/* A * X, if KASE=1, */ |
| 1911 |
/* A' * X, if KASE=2, */ |
| 1912 |
/* and DLACN2 must be re-called with all the other parameters */ |
| 1913 |
/* unchanged. */ |
| 1914 |
|
| 1915 |
/* ISGN (workspace) INTEGER array, dimension (N) */ |
| 1916 |
|
| 1917 |
/* EST (input/output) DOUBLE PRECISION */ |
| 1918 |
/* On entry with KASE = 1 or 2 and ISAVE(1) = 3, EST should be */ |
| 1919 |
/* unchanged from the previous call to DLACN2. */ |
| 1920 |
/* On exit, EST is an estimate (a lower bound) for norm(A). */ |
| 1921 |
|
| 1922 |
/* KASE (input/output) INTEGER */ |
| 1923 |
/* On the initial call to DLACN2, KASE should be 0. */ |
| 1924 |
/* On an intermediate return, KASE will be 1 or 2, indicating */ |
| 1925 |
/* whether X should be overwritten by A * X or A' * X. */ |
| 1926 |
/* On the final return from DLACN2, KASE will again be 0. */ |
| 1927 |
|
| 1928 |
/* ISAVE (input/output) INTEGER array, dimension (3) */ |
| 1929 |
/* ISAVE is used to save variables between calls to DLACN2 */ |
| 1930 |
|
| 1931 |
/* Further Details */ |
| 1932 |
/* ======= ======= */ |
| 1933 |
|
| 1934 |
/* Contributed by Nick Higham, University of Manchester. */ |
| 1935 |
/* Originally named SONEST, dated March 16, 1988. */ |
| 1936 |
|
| 1937 |
/* Reference: N.J. Higham, "FORTRAN codes for estimating the one-norm of */ |
| 1938 |
/* a real or complex matrix, with applications to condition estimation", */ |
| 1939 |
/* ACM Trans. Math. Soft., vol. 14, no. 4, pp. 381-396, December 1988. */ |
| 1940 |
|
| 1941 |
/* This is a thread safe version of DLACON, which uses the array ISAVE */ |
| 1942 |
/* in place of a SAVE statement, as follows: */ |
| 1943 |
|
| 1944 |
/* DLACON DLACN2 */ |
| 1945 |
/* JUMP ISAVE(1) */ |
| 1946 |
/* J ISAVE(2) */ |
| 1947 |
/* ITER ISAVE(3) */ |
| 1948 |
|
| 1949 |
/* ===================================================================== */ |
| 1950 |
|
| 1951 |
/* .. Parameters .. */ |
| 1952 |
/* .. */ |
| 1953 |
/* .. Local Scalars .. */ |
| 1954 |
/* .. */ |
| 1955 |
/* .. External Functions .. */ |
| 1956 |
/* .. */ |
| 1957 |
/* .. External Subroutines .. */ |
| 1958 |
/* .. */ |
| 1959 |
/* .. Intrinsic Functions .. */ |
| 1960 |
/* .. */ |
| 1961 |
/* .. Executable Statements .. */ |
| 1962 |
|
| 1963 |
/* Parameter adjustments */ |
| 1964 |
--isave; |
| 1965 |
--isgn; |
| 1966 |
--x; |
| 1967 |
--v; |
| 1968 |
|
| 1969 |
/* Function Body */ |
| 1970 |
if (*kase == 0) { |
| 1971 |
i__1 = *n; |
| 1972 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 1973 |
x[i__] = 1. / (double) (*n); |
| 1974 |
/* L10: */ |
| 1975 |
} |
| 1976 |
*kase = 1; |
| 1977 |
isave[1] = 1; |
| 1978 |
return 0; |
| 1979 |
} |
| 1980 |
|
| 1981 |
switch (isave[1]) { |
| 1982 |
case 1: goto L20; |
| 1983 |
case 2: goto L40; |
| 1984 |
case 3: goto L70; |
| 1985 |
case 4: goto L110; |
| 1986 |
case 5: goto L140; |
| 1987 |
} |
| 1988 |
|
| 1989 |
/* ................ ENTRY (ISAVE( 1 ) = 1) */ |
| 1990 |
/* FIRST ITERATION. X HAS BEEN OVERWRITTEN BY A*X. */ |
| 1991 |
|
| 1992 |
L20: |
| 1993 |
if (*n == 1) { |
| 1994 |
v[1] = x[1]; |
| 1995 |
*est = abs(v[1]); |
| 1996 |
/* ... QUIT */ |
| 1997 |
goto L150; |
| 1998 |
} |
| 1999 |
*est = dasum_(n, &x[1], &c__1); |
| 2000 |
|
| 2001 |
i__1 = *n; |
| 2002 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 2003 |
x[i__] = d_sign(&c_b11, &x[i__]); |
| 2004 |
isgn[i__] = i_dnnt(&x[i__]); |
| 2005 |
/* L30: */ |
| 2006 |
} |
| 2007 |
*kase = 2; |
| 2008 |
isave[1] = 2; |
| 2009 |
return 0; |
| 2010 |
|
| 2011 |
/* ................ ENTRY (ISAVE( 1 ) = 2) */ |
| 2012 |
/* FIRST ITERATION. X HAS BEEN OVERWRITTEN BY TRANSPOSE(A)*X. */ |
| 2013 |
|
| 2014 |
L40: |
| 2015 |
isave[2] = idamax_(n, &x[1], &c__1); |
| 2016 |
isave[3] = 2; |
| 2017 |
|
| 2018 |
/* MAIN LOOP - ITERATIONS 2,3,...,ITMAX. */ |
| 2019 |
|
| 2020 |
L50: |
| 2021 |
i__1 = *n; |
| 2022 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 2023 |
x[i__] = 0.; |
| 2024 |
/* L60: */ |
| 2025 |
} |
| 2026 |
x[isave[2]] = 1.; |
| 2027 |
*kase = 1; |
| 2028 |
isave[1] = 3; |
| 2029 |
return 0; |
| 2030 |
|
| 2031 |
/* ................ ENTRY (ISAVE( 1 ) = 3) */ |
| 2032 |
/* X HAS BEEN OVERWRITTEN BY A*X. */ |
| 2033 |
|
| 2034 |
L70: |
| 2035 |
dcopy_(n, &x[1], &c__1, &v[1], &c__1); |
| 2036 |
estold = *est; |
| 2037 |
*est = dasum_(n, &v[1], &c__1); |
| 2038 |
i__1 = *n; |
| 2039 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 2040 |
d__1 = d_sign(&c_b11, &x[i__]); |
| 2041 |
if (i_dnnt(&d__1) != isgn[i__]) { |
| 2042 |
goto L90; |
| 2043 |
} |
| 2044 |
/* L80: */ |
| 2045 |
} |
| 2046 |
/* REPEATED SIGN VECTOR DETECTED, HENCE ALGORITHM HAS CONVERGED. */ |
| 2047 |
goto L120; |
| 2048 |
|
| 2049 |
L90: |
| 2050 |
/* TEST FOR CYCLING. */ |
| 2051 |
if (*est <= estold) { |
| 2052 |
goto L120; |
| 2053 |
} |
| 2054 |
|
| 2055 |
i__1 = *n; |
| 2056 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 2057 |
x[i__] = d_sign(&c_b11, &x[i__]); |
| 2058 |
isgn[i__] = i_dnnt(&x[i__]); |
| 2059 |
/* L100: */ |
| 2060 |
} |
| 2061 |
*kase = 2; |
| 2062 |
isave[1] = 4; |
| 2063 |
return 0; |
| 2064 |
|
| 2065 |
/* ................ ENTRY (ISAVE( 1 ) = 4) */ |
| 2066 |
/* X HAS BEEN OVERWRITTEN BY TRANSPOSE(A)*X. */ |
| 2067 |
|
| 2068 |
L110: |
| 2069 |
jlast = isave[2]; |
| 2070 |
isave[2] = idamax_(n, &x[1], &c__1); |
| 2071 |
if (x[jlast] != (d__1 = x[isave[2]], abs(d__1)) && isave[3] < 5) { |
| 2072 |
++isave[3]; |
| 2073 |
goto L50; |
| 2074 |
} |
| 2075 |
|
| 2076 |
/* ITERATION COMPLETE. FINAL STAGE. */ |
| 2077 |
|
| 2078 |
L120: |
| 2079 |
altsgn = 1.; |
| 2080 |
i__1 = *n; |
| 2081 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 2082 |
x[i__] = altsgn * ((double) (i__ - 1) / (double) (*n - 1) + |
| 2083 |
1.); |
| 2084 |
altsgn = -altsgn; |
| 2085 |
/* L130: */ |
| 2086 |
} |
| 2087 |
*kase = 1; |
| 2088 |
isave[1] = 5; |
| 2089 |
return 0; |
| 2090 |
|
| 2091 |
/* ................ ENTRY (ISAVE( 1 ) = 5) */ |
| 2092 |
/* X HAS BEEN OVERWRITTEN BY A*X. */ |
| 2093 |
|
| 2094 |
L140: |
| 2095 |
temp = dasum_(n, &x[1], &c__1) / (double) (*n * 3) * 2.; |
| 2096 |
if (temp > *est) { |
| 2097 |
dcopy_(n, &x[1], &c__1, &v[1], &c__1); |
| 2098 |
*est = temp; |
| 2099 |
} |
| 2100 |
|
| 2101 |
L150: |
| 2102 |
*kase = 0; |
| 2103 |
return 0; |
| 2104 |
|
| 2105 |
/* End of DLACN2 */ |
| 2106 |
|
| 2107 |
} /* dlacn2_ */ |
| 2108 |
|
| 2109 |
/* Subroutine */ int dlacon_(integer *n, double *v, double *x, |
| 2110 |
integer *isgn, double *est, integer *kase) |
| 2111 |
{ |
| 2112 |
/* Table of constant values */ |
| 2113 |
static integer c__1 = 1; |
| 2114 |
static double c_b11 = 1.; |
| 2115 |
|
| 2116 |
/* System generated locals */ |
| 2117 |
integer i__1; |
| 2118 |
double d__1; |
| 2119 |
|
| 2120 |
/* Builtin functions |
| 2121 |
double d_sign(double *, double *); |
| 2122 |
integer i_dnnt(double *); */ |
| 2123 |
|
| 2124 |
/* Local variables */ |
| 2125 |
static integer i__, j, iter; |
| 2126 |
static double temp; |
| 2127 |
static integer jump; |
| 2128 |
static integer jlast; |
| 2129 |
static double altsgn, estold; |
| 2130 |
|
| 2131 |
|
| 2132 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 2133 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 2134 |
/* November 2006 */ |
| 2135 |
|
| 2136 |
/* .. Scalar Arguments .. */ |
| 2137 |
/* .. */ |
| 2138 |
/* .. Array Arguments .. */ |
| 2139 |
/* .. */ |
| 2140 |
|
| 2141 |
/* Purpose */ |
| 2142 |
/* ======= */ |
| 2143 |
|
| 2144 |
/* DLACON estimates the 1-norm of a square, real matrix A. */ |
| 2145 |
/* Reverse communication is used for evaluating matrix-vector products. */ |
| 2146 |
|
| 2147 |
/* Arguments */ |
| 2148 |
/* ========= */ |
| 2149 |
|
| 2150 |
/* N (input) INTEGER */ |
| 2151 |
/* The order of the matrix. N >= 1. */ |
| 2152 |
|
| 2153 |
/* V (workspace) DOUBLE PRECISION array, dimension (N) */ |
| 2154 |
/* On the final return, V = A*W, where EST = norm(V)/norm(W) */ |
| 2155 |
/* (W is not returned). */ |
| 2156 |
|
| 2157 |
/* X (input/output) DOUBLE PRECISION array, dimension (N) */ |
| 2158 |
/* On an intermediate return, X should be overwritten by */ |
| 2159 |
/* A * X, if KASE=1, */ |
| 2160 |
/* A' * X, if KASE=2, */ |
| 2161 |
/* and DLACON must be re-called with all the other parameters */ |
| 2162 |
/* unchanged. */ |
| 2163 |
|
| 2164 |
/* ISGN (workspace) INTEGER array, dimension (N) */ |
| 2165 |
|
| 2166 |
/* EST (input/output) DOUBLE PRECISION */ |
| 2167 |
/* On entry with KASE = 1 or 2 and JUMP = 3, EST should be */ |
| 2168 |
/* unchanged from the previous call to DLACON. */ |
| 2169 |
/* On exit, EST is an estimate (a lower bound) for norm(A). */ |
| 2170 |
|
| 2171 |
/* KASE (input/output) INTEGER */ |
| 2172 |
/* On the initial call to DLACON, KASE should be 0. */ |
| 2173 |
/* On an intermediate return, KASE will be 1 or 2, indicating */ |
| 2174 |
/* whether X should be overwritten by A * X or A' * X. */ |
| 2175 |
/* On the final return from DLACON, KASE will again be 0. */ |
| 2176 |
|
| 2177 |
/* Further Details */ |
| 2178 |
/* ======= ======= */ |
| 2179 |
|
| 2180 |
/* Contributed by Nick Higham, University of Manchester. */ |
| 2181 |
/* Originally named SONEST, dated March 16, 1988. */ |
| 2182 |
|
| 2183 |
/* Reference: N.J. Higham, "FORTRAN codes for estimating the one-norm of */ |
| 2184 |
/* a real or complex matrix, with applications to condition estimation", */ |
| 2185 |
/* ACM Trans. Math. Soft., vol. 14, no. 4, pp. 381-396, December 1988. */ |
| 2186 |
|
| 2187 |
/* ===================================================================== */ |
| 2188 |
|
| 2189 |
/* .. Parameters .. */ |
| 2190 |
/* .. */ |
| 2191 |
/* .. Local Scalars .. */ |
| 2192 |
/* .. */ |
| 2193 |
/* .. External Functions .. */ |
| 2194 |
/* .. */ |
| 2195 |
/* .. External Subroutines .. */ |
| 2196 |
/* .. */ |
| 2197 |
/* .. Intrinsic Functions .. */ |
| 2198 |
/* .. */ |
| 2199 |
/* .. Save statement .. */ |
| 2200 |
/* .. */ |
| 2201 |
/* .. Executable Statements .. */ |
| 2202 |
|
| 2203 |
/* Parameter adjustments */ |
| 2204 |
--isgn; |
| 2205 |
--x; |
| 2206 |
--v; |
| 2207 |
|
| 2208 |
/* Function Body */ |
| 2209 |
if (*kase == 0) { |
| 2210 |
i__1 = *n; |
| 2211 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 2212 |
x[i__] = 1. / (double) (*n); |
| 2213 |
/* L10: */ |
| 2214 |
} |
| 2215 |
*kase = 1; |
| 2216 |
jump = 1; |
| 2217 |
return 0; |
| 2218 |
} |
| 2219 |
|
| 2220 |
switch (jump) { |
| 2221 |
case 1: goto L20; |
| 2222 |
case 2: goto L40; |
| 2223 |
case 3: goto L70; |
| 2224 |
case 4: goto L110; |
| 2225 |
case 5: goto L140; |
| 2226 |
} |
| 2227 |
|
| 2228 |
/* ................ ENTRY (JUMP = 1) */ |
| 2229 |
/* FIRST ITERATION. X HAS BEEN OVERWRITTEN BY A*X. */ |
| 2230 |
|
| 2231 |
L20: |
| 2232 |
if (*n == 1) { |
| 2233 |
v[1] = x[1]; |
| 2234 |
*est = abs(v[1]); |
| 2235 |
/* ... QUIT */ |
| 2236 |
goto L150; |
| 2237 |
} |
| 2238 |
*est = dasum_(n, &x[1], &c__1); |
| 2239 |
|
| 2240 |
i__1 = *n; |
| 2241 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 2242 |
x[i__] = d_sign(&c_b11, &x[i__]); |
| 2243 |
isgn[i__] = i_dnnt(&x[i__]); |
| 2244 |
/* L30: */ |
| 2245 |
} |
| 2246 |
*kase = 2; |
| 2247 |
jump = 2; |
| 2248 |
return 0; |
| 2249 |
|
| 2250 |
/* ................ ENTRY (JUMP = 2) */ |
| 2251 |
/* FIRST ITERATION. X HAS BEEN OVERWRITTEN BY TRANSPOSE(A)*X. */ |
| 2252 |
|
| 2253 |
L40: |
| 2254 |
j = idamax_(n, &x[1], &c__1); |
| 2255 |
iter = 2; |
| 2256 |
|
| 2257 |
/* MAIN LOOP - ITERATIONS 2,3,...,ITMAX. */ |
| 2258 |
|
| 2259 |
L50: |
| 2260 |
i__1 = *n; |
| 2261 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 2262 |
x[i__] = 0.; |
| 2263 |
/* L60: */ |
| 2264 |
} |
| 2265 |
x[j] = 1.; |
| 2266 |
*kase = 1; |
| 2267 |
jump = 3; |
| 2268 |
return 0; |
| 2269 |
|
| 2270 |
/* ................ ENTRY (JUMP = 3) */ |
| 2271 |
/* X HAS BEEN OVERWRITTEN BY A*X. */ |
| 2272 |
|
| 2273 |
L70: |
| 2274 |
dcopy_(n, &x[1], &c__1, &v[1], &c__1); |
| 2275 |
estold = *est; |
| 2276 |
*est = dasum_(n, &v[1], &c__1); |
| 2277 |
i__1 = *n; |
| 2278 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 2279 |
d__1 = d_sign(&c_b11, &x[i__]); |
| 2280 |
if (i_dnnt(&d__1) != isgn[i__]) { |
| 2281 |
goto L90; |
| 2282 |
} |
| 2283 |
/* L80: */ |
| 2284 |
} |
| 2285 |
/* REPEATED SIGN VECTOR DETECTED, HENCE ALGORITHM HAS CONVERGED. */ |
| 2286 |
goto L120; |
| 2287 |
|
| 2288 |
L90: |
| 2289 |
/* TEST FOR CYCLING. */ |
| 2290 |
if (*est <= estold) { |
| 2291 |
goto L120; |
| 2292 |
} |
| 2293 |
|
| 2294 |
i__1 = *n; |
| 2295 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 2296 |
x[i__] = d_sign(&c_b11, &x[i__]); |
| 2297 |
isgn[i__] = i_dnnt(&x[i__]); |
| 2298 |
/* L100: */ |
| 2299 |
} |
| 2300 |
*kase = 2; |
| 2301 |
jump = 4; |
| 2302 |
return 0; |
| 2303 |
|
| 2304 |
/* ................ ENTRY (JUMP = 4) */ |
| 2305 |
/* X HAS BEEN OVERWRITTEN BY TRANSPOSE(A)*X. */ |
| 2306 |
|
| 2307 |
L110: |
| 2308 |
jlast = j; |
| 2309 |
j = idamax_(n, &x[1], &c__1); |
| 2310 |
if (x[jlast] != (d__1 = x[j], abs(d__1)) && iter < 5) { |
| 2311 |
++iter; |
| 2312 |
goto L50; |
| 2313 |
} |
| 2314 |
|
| 2315 |
/* ITERATION COMPLETE. FINAL STAGE. */ |
| 2316 |
|
| 2317 |
L120: |
| 2318 |
altsgn = 1.; |
| 2319 |
i__1 = *n; |
| 2320 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 2321 |
x[i__] = altsgn * ((double) (i__ - 1) / (double) (*n - 1) + |
| 2322 |
1.); |
| 2323 |
altsgn = -altsgn; |
| 2324 |
/* L130: */ |
| 2325 |
} |
| 2326 |
*kase = 1; |
| 2327 |
jump = 5; |
| 2328 |
return 0; |
| 2329 |
|
| 2330 |
/* ................ ENTRY (JUMP = 5) */ |
| 2331 |
/* X HAS BEEN OVERWRITTEN BY A*X. */ |
| 2332 |
|
| 2333 |
L140: |
| 2334 |
temp = dasum_(n, &x[1], &c__1) / (double) (*n * 3) * 2.; |
| 2335 |
if (temp > *est) { |
| 2336 |
dcopy_(n, &x[1], &c__1, &v[1], &c__1); |
| 2337 |
*est = temp; |
| 2338 |
} |
| 2339 |
|
| 2340 |
L150: |
| 2341 |
*kase = 0; |
| 2342 |
return 0; |
| 2343 |
|
| 2344 |
/* End of DLACON */ |
| 2345 |
|
| 2346 |
} /* dlacon_ */ |
| 2347 |
|
| 2348 |
/* Subroutine */ int dlacpy_(const char *uplo, integer *m, integer *n, double * |
| 2349 |
a, integer *lda, double *b, integer *ldb) |
| 2350 |
{ |
| 2351 |
/* System generated locals */ |
| 2352 |
integer a_dim1, a_offset, b_dim1, b_offset, i__1, i__2; |
| 2353 |
|
| 2354 |
/* Local variables */ |
| 2355 |
integer i__, j; |
| 2356 |
|
| 2357 |
|
| 2358 |
|
| 2359 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 2360 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 2361 |
/* November 2006 */ |
| 2362 |
|
| 2363 |
/* .. Scalar Arguments .. */ |
| 2364 |
/* .. */ |
| 2365 |
/* .. Array Arguments .. */ |
| 2366 |
/* .. */ |
| 2367 |
|
| 2368 |
/* Purpose */ |
| 2369 |
/* ======= */ |
| 2370 |
|
| 2371 |
/* DLACPY copies all or part of a two-dimensional matrix A to another */ |
| 2372 |
/* matrix B. */ |
| 2373 |
|
| 2374 |
/* Arguments */ |
| 2375 |
/* ========= */ |
| 2376 |
|
| 2377 |
/* UPLO (input) CHARACTER*1 */ |
| 2378 |
/* Specifies the part of the matrix A to be copied to B. */ |
| 2379 |
/* = 'U': Upper triangular part */ |
| 2380 |
/* = 'L': Lower triangular part */ |
| 2381 |
/* Otherwise: All of the matrix A */ |
| 2382 |
|
| 2383 |
/* M (input) INTEGER */ |
| 2384 |
/* The number of rows of the matrix A. M >= 0. */ |
| 2385 |
|
| 2386 |
/* N (input) INTEGER */ |
| 2387 |
/* The number of columns of the matrix A. N >= 0. */ |
| 2388 |
|
| 2389 |
/* A (input) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 2390 |
/* The m by n matrix A. If UPLO = 'U', only the upper triangle */ |
| 2391 |
/* or trapezoid is accessed; if UPLO = 'L', only the lower */ |
| 2392 |
/* triangle or trapezoid is accessed. */ |
| 2393 |
|
| 2394 |
/* LDA (input) INTEGER */ |
| 2395 |
/* The leading dimension of the array A. LDA >= max(1,M). */ |
| 2396 |
|
| 2397 |
/* B (output) DOUBLE PRECISION array, dimension (LDB,N) */ |
| 2398 |
/* On exit, B = A in the locations specified by UPLO. */ |
| 2399 |
|
| 2400 |
/* LDB (input) INTEGER */ |
| 2401 |
/* The leading dimension of the array B. LDB >= max(1,M). */ |
| 2402 |
|
| 2403 |
/* ===================================================================== */ |
| 2404 |
|
| 2405 |
/* .. Local Scalars .. */ |
| 2406 |
/* .. */ |
| 2407 |
/* .. External Functions .. */ |
| 2408 |
/* .. */ |
| 2409 |
/* .. Intrinsic Functions .. */ |
| 2410 |
/* .. */ |
| 2411 |
/* .. Executable Statements .. */ |
| 2412 |
|
| 2413 |
/* Parameter adjustments */ |
| 2414 |
a_dim1 = *lda; |
| 2415 |
a_offset = 1 + a_dim1; |
| 2416 |
a -= a_offset; |
| 2417 |
b_dim1 = *ldb; |
| 2418 |
b_offset = 1 + b_dim1; |
| 2419 |
b -= b_offset; |
| 2420 |
|
| 2421 |
/* Function Body */ |
| 2422 |
if (lsame_(uplo, "U")) { |
| 2423 |
i__1 = *n; |
| 2424 |
for (j = 1; j <= i__1; ++j) { |
| 2425 |
i__2 = std::min(j,*m); |
| 2426 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 2427 |
b[i__ + j * b_dim1] = a[i__ + j * a_dim1]; |
| 2428 |
/* L10: */ |
| 2429 |
} |
| 2430 |
/* L20: */ |
| 2431 |
} |
| 2432 |
} else if (lsame_(uplo, "L")) { |
| 2433 |
i__1 = *n; |
| 2434 |
for (j = 1; j <= i__1; ++j) { |
| 2435 |
i__2 = *m; |
| 2436 |
for (i__ = j; i__ <= i__2; ++i__) { |
| 2437 |
b[i__ + j * b_dim1] = a[i__ + j * a_dim1]; |
| 2438 |
/* L30: */ |
| 2439 |
} |
| 2440 |
/* L40: */ |
| 2441 |
} |
| 2442 |
} else { |
| 2443 |
i__1 = *n; |
| 2444 |
for (j = 1; j <= i__1; ++j) { |
| 2445 |
i__2 = *m; |
| 2446 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 2447 |
b[i__ + j * b_dim1] = a[i__ + j * a_dim1]; |
| 2448 |
/* L50: */ |
| 2449 |
} |
| 2450 |
/* L60: */ |
| 2451 |
} |
| 2452 |
} |
| 2453 |
return 0; |
| 2454 |
|
| 2455 |
/* End of DLACPY */ |
| 2456 |
|
| 2457 |
} /* dlacpy_ */ |
| 2458 |
|
| 2459 |
/* Subroutine */ int dladiv_(double *a, double *b, double *c__, |
| 2460 |
double *d__, double *p, double *q) |
| 2461 |
{ |
| 2462 |
double e, f; |
| 2463 |
|
| 2464 |
|
| 2465 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 2466 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 2467 |
/* November 2006 */ |
| 2468 |
|
| 2469 |
/* .. Scalar Arguments .. */ |
| 2470 |
/* .. */ |
| 2471 |
|
| 2472 |
/* Purpose */ |
| 2473 |
/* ======= */ |
| 2474 |
|
| 2475 |
/* DLADIV performs complex division in real arithmetic */ |
| 2476 |
|
| 2477 |
/* a + i*b */ |
| 2478 |
/* p + i*q = --------- */ |
| 2479 |
/* c + i*d */ |
| 2480 |
|
| 2481 |
/* The algorithm is due to Robert L. Smith and can be found */ |
| 2482 |
/* in D. Knuth, The art of Computer Programming, Vol.2, p.195 */ |
| 2483 |
|
| 2484 |
/* Arguments */ |
| 2485 |
/* ========= */ |
| 2486 |
|
| 2487 |
/* A (input) DOUBLE PRECISION */ |
| 2488 |
/* B (input) DOUBLE PRECISION */ |
| 2489 |
/* C (input) DOUBLE PRECISION */ |
| 2490 |
/* D (input) DOUBLE PRECISION */ |
| 2491 |
/* The scalars a, b, c, and d in the above expression. */ |
| 2492 |
|
| 2493 |
/* P (output) DOUBLE PRECISION */ |
| 2494 |
/* Q (output) DOUBLE PRECISION */ |
| 2495 |
/* The scalars p and q in the above expression. */ |
| 2496 |
|
| 2497 |
/* ===================================================================== */ |
| 2498 |
|
| 2499 |
/* .. Local Scalars .. */ |
| 2500 |
/* .. */ |
| 2501 |
/* .. Intrinsic Functions .. */ |
| 2502 |
/* .. */ |
| 2503 |
/* .. Executable Statements .. */ |
| 2504 |
|
| 2505 |
if (abs(*d__) < abs(*c__)) { |
| 2506 |
e = *d__ / *c__; |
| 2507 |
f = *c__ + *d__ * e; |
| 2508 |
*p = (*a + *b * e) / f; |
| 2509 |
*q = (*b - *a * e) / f; |
| 2510 |
} else { |
| 2511 |
e = *c__ / *d__; |
| 2512 |
f = *d__ + *c__ * e; |
| 2513 |
*p = (*b + *a * e) / f; |
| 2514 |
*q = (-(*a) + *b * e) / f; |
| 2515 |
} |
| 2516 |
|
| 2517 |
return 0; |
| 2518 |
|
| 2519 |
/* End of DLADIV */ |
| 2520 |
|
| 2521 |
} /* dladiv_ */ |
| 2522 |
|
| 2523 |
/* Subroutine */ int dlae2_(double *a, double *b, double *c__, |
| 2524 |
double *rt1, double *rt2) |
| 2525 |
{ |
| 2526 |
/* System generated locals */ |
| 2527 |
double d__1; |
| 2528 |
|
| 2529 |
/* Builtin functions |
| 2530 |
double sqrt(double);*/ |
| 2531 |
|
| 2532 |
/* Local variables */ |
| 2533 |
double ab, df, tb, sm, rt, adf, acmn, acmx; |
| 2534 |
|
| 2535 |
|
| 2536 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 2537 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 2538 |
/* November 2006 */ |
| 2539 |
|
| 2540 |
/* .. Scalar Arguments .. */ |
| 2541 |
/* .. */ |
| 2542 |
|
| 2543 |
/* Purpose */ |
| 2544 |
/* ======= */ |
| 2545 |
|
| 2546 |
/* DLAE2 computes the eigenvalues of a 2-by-2 symmetric matrix */ |
| 2547 |
/* [ A B ] */ |
| 2548 |
/* [ B C ]. */ |
| 2549 |
/* On return, RT1 is the eigenvalue of larger absolute value, and RT2 */ |
| 2550 |
/* is the eigenvalue of smaller absolute value. */ |
| 2551 |
|
| 2552 |
/* Arguments */ |
| 2553 |
/* ========= */ |
| 2554 |
|
| 2555 |
/* A (input) DOUBLE PRECISION */ |
| 2556 |
/* The (1,1) element of the 2-by-2 matrix. */ |
| 2557 |
|
| 2558 |
/* B (input) DOUBLE PRECISION */ |
| 2559 |
/* The (1,2) and (2,1) elements of the 2-by-2 matrix. */ |
| 2560 |
|
| 2561 |
/* C (input) DOUBLE PRECISION */ |
| 2562 |
/* The (2,2) element of the 2-by-2 matrix. */ |
| 2563 |
|
| 2564 |
/* RT1 (output) DOUBLE PRECISION */ |
| 2565 |
/* The eigenvalue of larger absolute value. */ |
| 2566 |
|
| 2567 |
/* RT2 (output) DOUBLE PRECISION */ |
| 2568 |
/* The eigenvalue of smaller absolute value. */ |
| 2569 |
|
| 2570 |
/* Further Details */ |
| 2571 |
/* =============== */ |
| 2572 |
|
| 2573 |
/* RT1 is accurate to a few ulps barring over/underflow. */ |
| 2574 |
|
| 2575 |
/* RT2 may be inaccurate if there is massive cancellation in the */ |
| 2576 |
/* determinant A*C-B*B; higher precision or correctly rounded or */ |
| 2577 |
/* correctly truncated arithmetic would be needed to compute RT2 */ |
| 2578 |
/* accurately in all cases. */ |
| 2579 |
|
| 2580 |
/* Overflow is possible only if RT1 is within a factor of 5 of overflow. */ |
| 2581 |
/* Underflow is harmless if the input data is 0 or exceeds */ |
| 2582 |
/* underflow_threshold / macheps. */ |
| 2583 |
|
| 2584 |
/* ===================================================================== */ |
| 2585 |
|
| 2586 |
/* .. Parameters .. */ |
| 2587 |
/* .. */ |
| 2588 |
/* .. Local Scalars .. */ |
| 2589 |
/* .. */ |
| 2590 |
/* .. Intrinsic Functions .. */ |
| 2591 |
/* .. */ |
| 2592 |
/* .. Executable Statements .. */ |
| 2593 |
|
| 2594 |
/* Compute the eigenvalues */ |
| 2595 |
|
| 2596 |
sm = *a + *c__; |
| 2597 |
df = *a - *c__; |
| 2598 |
adf = abs(df); |
| 2599 |
tb = *b + *b; |
| 2600 |
ab = abs(tb); |
| 2601 |
if (abs(*a) > abs(*c__)) { |
| 2602 |
acmx = *a; |
| 2603 |
acmn = *c__; |
| 2604 |
} else { |
| 2605 |
acmx = *c__; |
| 2606 |
acmn = *a; |
| 2607 |
} |
| 2608 |
if (adf > ab) { |
| 2609 |
/* Computing 2nd power */ |
| 2610 |
d__1 = ab / adf; |
| 2611 |
rt = adf * sqrt(d__1 * d__1 + 1.); |
| 2612 |
} else if (adf < ab) { |
| 2613 |
/* Computing 2nd power */ |
| 2614 |
d__1 = adf / ab; |
| 2615 |
rt = ab * sqrt(d__1 * d__1 + 1.); |
| 2616 |
} else { |
| 2617 |
|
| 2618 |
/* Includes case AB=ADF=0 */ |
| 2619 |
|
| 2620 |
rt = ab * sqrt(2.); |
| 2621 |
} |
| 2622 |
if (sm < 0.) { |
| 2623 |
*rt1 = (sm - rt) * .5; |
| 2624 |
|
| 2625 |
/* Order of execution important. */ |
| 2626 |
/* To get fully accurate smaller eigenvalue, */ |
| 2627 |
/* next line needs to be executed in higher precision. */ |
| 2628 |
|
| 2629 |
*rt2 = acmx / *rt1 * acmn - *b / *rt1 * *b; |
| 2630 |
} else if (sm > 0.) { |
| 2631 |
*rt1 = (sm + rt) * .5; |
| 2632 |
|
| 2633 |
/* Order of execution important. */ |
| 2634 |
/* To get fully accurate smaller eigenvalue, */ |
| 2635 |
/* next line needs to be executed in higher precision. */ |
| 2636 |
|
| 2637 |
*rt2 = acmx / *rt1 * acmn - *b / *rt1 * *b; |
| 2638 |
} else { |
| 2639 |
|
| 2640 |
/* Includes case RT1 = RT2 = 0 */ |
| 2641 |
|
| 2642 |
*rt1 = rt * .5; |
| 2643 |
*rt2 = rt * -.5; |
| 2644 |
} |
| 2645 |
return 0; |
| 2646 |
|
| 2647 |
/* End of DLAE2 */ |
| 2648 |
|
| 2649 |
} /* dlae2_ */ |
| 2650 |
|
| 2651 |
/* Subroutine */ int dlaebz_(integer *ijob, integer *nitmax, integer *n, |
| 2652 |
integer *mmax, integer *minp, integer *nbmin, double *abstol, |
| 2653 |
double *reltol, double *pivmin, double *d__, double * |
| 2654 |
e, double *e2, integer *nval, double *ab, double *c__, |
| 2655 |
integer *mout, integer *nab, double *work, integer *iwork, |
| 2656 |
integer *info) |
| 2657 |
{ |
| 2658 |
/* System generated locals */ |
| 2659 |
integer nab_dim1, nab_offset, ab_dim1, ab_offset, i__1, i__2, i__3, i__4, |
| 2660 |
i__5, i__6; |
| 2661 |
double d__1, d__2, d__3, d__4; |
| 2662 |
|
| 2663 |
/* Local variables */ |
| 2664 |
integer j, kf, ji, kl, jp, jit; |
| 2665 |
double tmp1, tmp2; |
| 2666 |
integer itmp1, itmp2, kfnew, klnew; |
| 2667 |
|
| 2668 |
|
| 2669 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 2670 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 2671 |
/* November 2006 */ |
| 2672 |
|
| 2673 |
/* .. Scalar Arguments .. */ |
| 2674 |
/* .. */ |
| 2675 |
/* .. Array Arguments .. */ |
| 2676 |
/* .. */ |
| 2677 |
|
| 2678 |
/* Purpose */ |
| 2679 |
/* ======= */ |
| 2680 |
|
| 2681 |
/* DLAEBZ contains the iteration loops which compute and use the */ |
| 2682 |
/* function N(w), which is the count of eigenvalues of a symmetric */ |
| 2683 |
/* tridiagonal matrix T less than or equal to its argument w. It */ |
| 2684 |
/* performs a choice of two types of loops: */ |
| 2685 |
|
| 2686 |
/* IJOB=1, followed by */ |
| 2687 |
/* IJOB=2: It takes as input a list of intervals and returns a list of */ |
| 2688 |
/* sufficiently small intervals whose union contains the same */ |
| 2689 |
/* eigenvalues as the union of the original intervals. */ |
| 2690 |
/* The input intervals are (AB(j,1),AB(j,2)], j=1,...,MINP. */ |
| 2691 |
/* The output interval (AB(j,1),AB(j,2)] will contain */ |
| 2692 |
/* eigenvalues NAB(j,1)+1,...,NAB(j,2), where 1 <= j <= MOUT. */ |
| 2693 |
|
| 2694 |
/* IJOB=3: It performs a binary search in each input interval */ |
| 2695 |
/* (AB(j,1),AB(j,2)] for a point w(j) such that */ |
| 2696 |
/* N(w(j))=NVAL(j), and uses C(j) as the starting point of */ |
| 2697 |
/* the search. If such a w(j) is found, then on output */ |
| 2698 |
/* AB(j,1)=AB(j,2)=w. If no such w(j) is found, then on output */ |
| 2699 |
/* (AB(j,1),AB(j,2)] will be a small interval containing the */ |
| 2700 |
/* point where N(w) jumps through NVAL(j), unless that point */ |
| 2701 |
/* lies outside the initial interval. */ |
| 2702 |
|
| 2703 |
/* Note that the intervals are in all cases half-open intervals, */ |
| 2704 |
/* i.e., of the form (a,b] , which includes b but not a . */ |
| 2705 |
|
| 2706 |
/* To avoid underflow, the matrix should be scaled so that its largest */ |
| 2707 |
/* element is no greater than overflow**(1/2) * underflow**(1/4) */ |
| 2708 |
/* in absolute value. To assure the most accurate computation */ |
| 2709 |
/* of small eigenvalues, the matrix should be scaled to be */ |
| 2710 |
/* not much smaller than that, either. */ |
| 2711 |
|
| 2712 |
/* See W. Kahan "Accurate Eigenvalues of a Symmetric Tridiagonal */ |
| 2713 |
/* Matrix", Report CS41, Computer Science Dept., Stanford */ |
| 2714 |
/* University, July 21, 1966 */ |
| 2715 |
|
| 2716 |
/* Note: the arguments are, in general, *not* checked for unreasonable */ |
| 2717 |
/* values. */ |
| 2718 |
|
| 2719 |
/* Arguments */ |
| 2720 |
/* ========= */ |
| 2721 |
|
| 2722 |
/* IJOB (input) INTEGER */ |
| 2723 |
/* Specifies what is to be done: */ |
| 2724 |
/* = 1: Compute NAB for the initial intervals. */ |
| 2725 |
/* = 2: Perform bisection iteration to find eigenvalues of T. */ |
| 2726 |
/* = 3: Perform bisection iteration to invert N(w), i.e., */ |
| 2727 |
/* to find a point which has a specified number of */ |
| 2728 |
/* eigenvalues of T to its left. */ |
| 2729 |
/* Other values will cause DLAEBZ to return with INFO=-1. */ |
| 2730 |
|
| 2731 |
/* NITMAX (input) INTEGER */ |
| 2732 |
/* The maximum number of "levels" of bisection to be */ |
| 2733 |
/* performed, i.e., an interval of width W will not be made */ |
| 2734 |
/* smaller than 2^(-NITMAX) * W. If not all intervals */ |
| 2735 |
/* have converged after NITMAX iterations, then INFO is set */ |
| 2736 |
/* to the number of non-converged intervals. */ |
| 2737 |
|
| 2738 |
/* N (input) INTEGER */ |
| 2739 |
/* The dimension n of the tridiagonal matrix T. It must be at */ |
| 2740 |
/* least 1. */ |
| 2741 |
|
| 2742 |
/* MMAX (input) INTEGER */ |
| 2743 |
/* The maximum number of intervals. If more than MMAX intervals */ |
| 2744 |
/* are generated, then DLAEBZ will quit with INFO=MMAX+1. */ |
| 2745 |
|
| 2746 |
/* MINP (input) INTEGER */ |
| 2747 |
/* The initial number of intervals. It may not be greater than */ |
| 2748 |
/* MMAX. */ |
| 2749 |
|
| 2750 |
/* NBMIN (input) INTEGER */ |
| 2751 |
/* The smallest number of intervals that should be processed */ |
| 2752 |
/* using a vector loop. If zero, then only the scalar loop */ |
| 2753 |
/* will be used. */ |
| 2754 |
|
| 2755 |
/* ABSTOL (input) DOUBLE PRECISION */ |
| 2756 |
/* The minimum (absolute) width of an interval. When an */ |
| 2757 |
/* interval is narrower than ABSTOL, or than RELTOL times the */ |
| 2758 |
/* larger (in magnitude) endpoint, then it is considered to be */ |
| 2759 |
/* sufficiently small, i.e., converged. This must be at least */ |
| 2760 |
/* zero. */ |
| 2761 |
|
| 2762 |
/* RELTOL (input) DOUBLE PRECISION */ |
| 2763 |
/* The minimum relative width of an interval. When an interval */ |
| 2764 |
/* is narrower than ABSTOL, or than RELTOL times the larger (in */ |
| 2765 |
/* magnitude) endpoint, then it is considered to be */ |
| 2766 |
/* sufficiently small, i.e., converged. Note: this should */ |
| 2767 |
/* always be at least radix*machine epsilon. */ |
| 2768 |
|
| 2769 |
/* PIVMIN (input) DOUBLE PRECISION */ |
| 2770 |
/* The minimum absolute value of a "pivot" in the Sturm */ |
| 2771 |
/* sequence loop. This *must* be at least max |e(j)**2| * */ |
| 2772 |
/* safe_min and at least safe_min, where safe_min is at least */ |
| 2773 |
/* the smallest number that can divide one without overflow. */ |
| 2774 |
|
| 2775 |
/* D (input) DOUBLE PRECISION array, dimension (N) */ |
| 2776 |
/* The diagonal elements of the tridiagonal matrix T. */ |
| 2777 |
|
| 2778 |
/* E (input) DOUBLE PRECISION array, dimension (N) */ |
| 2779 |
/* The offdiagonal elements of the tridiagonal matrix T in */ |
| 2780 |
/* positions 1 through N-1. E(N) is arbitrary. */ |
| 2781 |
|
| 2782 |
/* E2 (input) DOUBLE PRECISION array, dimension (N) */ |
| 2783 |
/* The squares of the offdiagonal elements of the tridiagonal */ |
| 2784 |
/* matrix T. E2(N) is ignored. */ |
| 2785 |
|
| 2786 |
/* NVAL (input/output) INTEGER array, dimension (MINP) */ |
| 2787 |
/* If IJOB=1 or 2, not referenced. */ |
| 2788 |
/* If IJOB=3, the desired values of N(w). The elements of NVAL */ |
| 2789 |
/* will be reordered to correspond with the intervals in AB. */ |
| 2790 |
/* Thus, NVAL(j) on output will not, in general be the same as */ |
| 2791 |
/* NVAL(j) on input, but it will correspond with the interval */ |
| 2792 |
/* (AB(j,1),AB(j,2)] on output. */ |
| 2793 |
|
| 2794 |
/* AB (input/output) DOUBLE PRECISION array, dimension (MMAX,2) */ |
| 2795 |
/* The endpoints of the intervals. AB(j,1) is a(j), the left */ |
| 2796 |
/* endpoint of the j-th interval, and AB(j,2) is b(j), the */ |
| 2797 |
/* right endpoint of the j-th interval. The input intervals */ |
| 2798 |
/* will, in general, be modified, split, and reordered by the */ |
| 2799 |
/* calculation. */ |
| 2800 |
|
| 2801 |
/* C (input/output) DOUBLE PRECISION array, dimension (MMAX) */ |
| 2802 |
/* If IJOB=1, ignored. */ |
| 2803 |
/* If IJOB=2, workspace. */ |
| 2804 |
/* If IJOB=3, then on input C(j) should be initialized to the */ |
| 2805 |
/* first search point in the binary search. */ |
| 2806 |
|
| 2807 |
/* MOUT (output) INTEGER */ |
| 2808 |
/* If IJOB=1, the number of eigenvalues in the intervals. */ |
| 2809 |
/* If IJOB=2 or 3, the number of intervals output. */ |
| 2810 |
/* If IJOB=3, MOUT will equal MINP. */ |
| 2811 |
|
| 2812 |
/* NAB (input/output) INTEGER array, dimension (MMAX,2) */ |
| 2813 |
/* If IJOB=1, then on output NAB(i,j) will be set to N(AB(i,j)). */ |
| 2814 |
/* If IJOB=2, then on input, NAB(i,j) should be set. It must */ |
| 2815 |
/* satisfy the condition: */ |
| 2816 |
/* N(AB(i,1)) <= NAB(i,1) <= NAB(i,2) <= N(AB(i,2)), */ |
| 2817 |
/* which means that in interval i only eigenvalues */ |
| 2818 |
/* NAB(i,1)+1,...,NAB(i,2) will be considered. Usually, */ |
| 2819 |
/* NAB(i,j)=N(AB(i,j)), from a previous call to DLAEBZ with */ |
| 2820 |
/* IJOB=1. */ |
| 2821 |
/* On output, NAB(i,j) will contain */ |
| 2822 |
/* max(na(k),min(nb(k),N(AB(i,j)))), where k is the index of */ |
| 2823 |
/* the input interval that the output interval */ |
| 2824 |
/* (AB(j,1),AB(j,2)] came from, and na(k) and nb(k) are the */ |
| 2825 |
/* the input values of NAB(k,1) and NAB(k,2). */ |
| 2826 |
/* If IJOB=3, then on output, NAB(i,j) contains N(AB(i,j)), */ |
| 2827 |
/* unless N(w) > NVAL(i) for all search points w , in which */ |
| 2828 |
/* case NAB(i,1) will not be modified, i.e., the output */ |
| 2829 |
/* value will be the same as the input value (modulo */ |
| 2830 |
/* reorderings -- see NVAL and AB), or unless N(w) < NVAL(i) */ |
| 2831 |
/* for all search points w , in which case NAB(i,2) will */ |
| 2832 |
/* not be modified. Normally, NAB should be set to some */ |
| 2833 |
/* distinctive value(s) before DLAEBZ is called. */ |
| 2834 |
|
| 2835 |
/* WORK (workspace) DOUBLE PRECISION array, dimension (MMAX) */ |
| 2836 |
/* Workspace. */ |
| 2837 |
|
| 2838 |
/* IWORK (workspace) INTEGER array, dimension (MMAX) */ |
| 2839 |
/* Workspace. */ |
| 2840 |
|
| 2841 |
/* INFO (output) INTEGER */ |
| 2842 |
/* = 0: All intervals converged. */ |
| 2843 |
/* = 1--MMAX: The last INFO intervals did not converge. */ |
| 2844 |
/* = MMAX+1: More than MMAX intervals were generated. */ |
| 2845 |
|
| 2846 |
/* Further Details */ |
| 2847 |
/* =============== */ |
| 2848 |
|
| 2849 |
/* This routine is intended to be called only by other LAPACK */ |
| 2850 |
/* routines, thus the interface is less user-friendly. It is intended */ |
| 2851 |
/* for two purposes: */ |
| 2852 |
|
| 2853 |
/* (a) finding eigenvalues. In this case, DLAEBZ should have one or */ |
| 2854 |
/* more initial intervals set up in AB, and DLAEBZ should be called */ |
| 2855 |
/* with IJOB=1. This sets up NAB, and also counts the eigenvalues. */ |
| 2856 |
/* Intervals with no eigenvalues would usually be thrown out at */ |
| 2857 |
/* this point. Also, if not all the eigenvalues in an interval i */ |
| 2858 |
/* are desired, NAB(i,1) can be increased or NAB(i,2) decreased. */ |
| 2859 |
/* For example, set NAB(i,1)=NAB(i,2)-1 to get the largest */ |
| 2860 |
/* eigenvalue. DLAEBZ is then called with IJOB=2 and MMAX */ |
| 2861 |
/* no smaller than the value of MOUT returned by the call with */ |
| 2862 |
/* IJOB=1. After this (IJOB=2) call, eigenvalues NAB(i,1)+1 */ |
| 2863 |
/* through NAB(i,2) are approximately AB(i,1) (or AB(i,2)) to the */ |
| 2864 |
/* tolerance specified by ABSTOL and RELTOL. */ |
| 2865 |
|
| 2866 |
/* (b) finding an interval (a',b'] containing eigenvalues w(f),...,w(l). */ |
| 2867 |
/* In this case, start with a Gershgorin interval (a,b). Set up */ |
| 2868 |
/* AB to contain 2 search intervals, both initially (a,b). One */ |
| 2869 |
/* NVAL element should contain f-1 and the other should contain l */ |
| 2870 |
/* , while C should contain a and b, resp. NAB(i,1) should be -1 */ |
| 2871 |
/* and NAB(i,2) should be N+1, to flag an error if the desired */ |
| 2872 |
/* interval does not lie in (a,b). DLAEBZ is then called with */ |
| 2873 |
/* IJOB=3. On exit, if w(f-1) < w(f), then one of the intervals -- */ |
| 2874 |
/* j -- will have AB(j,1)=AB(j,2) and NAB(j,1)=NAB(j,2)=f-1, while */ |
| 2875 |
/* if, to the specified tolerance, w(f-k)=...=w(f+r), k > 0 and r */ |
| 2876 |
/* >= 0, then the interval will have N(AB(j,1))=NAB(j,1)=f-k and */ |
| 2877 |
/* N(AB(j,2))=NAB(j,2)=f+r. The cases w(l) < w(l+1) and */ |
| 2878 |
/* w(l-r)=...=w(l+k) are handled similarly. */ |
| 2879 |
|
| 2880 |
/* ===================================================================== */ |
| 2881 |
|
| 2882 |
/* .. Parameters .. */ |
| 2883 |
/* .. */ |
| 2884 |
/* .. Local Scalars .. */ |
| 2885 |
/* .. */ |
| 2886 |
/* .. Intrinsic Functions .. */ |
| 2887 |
/* .. */ |
| 2888 |
/* .. Executable Statements .. */ |
| 2889 |
|
| 2890 |
/* Check for Errors */ |
| 2891 |
|
| 2892 |
/* Parameter adjustments */ |
| 2893 |
nab_dim1 = *mmax; |
| 2894 |
nab_offset = 1 + nab_dim1; |
| 2895 |
nab -= nab_offset; |
| 2896 |
ab_dim1 = *mmax; |
| 2897 |
ab_offset = 1 + ab_dim1; |
| 2898 |
ab -= ab_offset; |
| 2899 |
--d__; |
| 2900 |
--e; |
| 2901 |
--e2; |
| 2902 |
--nval; |
| 2903 |
--c__; |
| 2904 |
--work; |
| 2905 |
--iwork; |
| 2906 |
|
| 2907 |
/* Function Body */ |
| 2908 |
*info = 0; |
| 2909 |
if (*ijob < 1 || *ijob > 3) { |
| 2910 |
*info = -1; |
| 2911 |
return 0; |
| 2912 |
} |
| 2913 |
|
| 2914 |
/* Initialize NAB */ |
| 2915 |
|
| 2916 |
if (*ijob == 1) { |
| 2917 |
|
| 2918 |
/* Compute the number of eigenvalues in the initial intervals. */ |
| 2919 |
|
| 2920 |
*mout = 0; |
| 2921 |
/* DIR$ NOVECTOR */ |
| 2922 |
i__1 = *minp; |
| 2923 |
for (ji = 1; ji <= i__1; ++ji) { |
| 2924 |
for (jp = 1; jp <= 2; ++jp) { |
| 2925 |
tmp1 = d__[1] - ab[ji + jp * ab_dim1]; |
| 2926 |
if (abs(tmp1) < *pivmin) { |
| 2927 |
tmp1 = -(*pivmin); |
| 2928 |
} |
| 2929 |
nab[ji + jp * nab_dim1] = 0; |
| 2930 |
if (tmp1 <= 0.) { |
| 2931 |
nab[ji + jp * nab_dim1] = 1; |
| 2932 |
} |
| 2933 |
|
| 2934 |
i__2 = *n; |
| 2935 |
for (j = 2; j <= i__2; ++j) { |
| 2936 |
tmp1 = d__[j] - e2[j - 1] / tmp1 - ab[ji + jp * ab_dim1]; |
| 2937 |
if (abs(tmp1) < *pivmin) { |
| 2938 |
tmp1 = -(*pivmin); |
| 2939 |
} |
| 2940 |
if (tmp1 <= 0.) { |
| 2941 |
++nab[ji + jp * nab_dim1]; |
| 2942 |
} |
| 2943 |
/* L10: */ |
| 2944 |
} |
| 2945 |
/* L20: */ |
| 2946 |
} |
| 2947 |
*mout = *mout + nab[ji + (nab_dim1 << 1)] - nab[ji + nab_dim1]; |
| 2948 |
/* L30: */ |
| 2949 |
} |
| 2950 |
return 0; |
| 2951 |
} |
| 2952 |
|
| 2953 |
/* Initialize for loop */ |
| 2954 |
|
| 2955 |
/* KF and KL have the following meaning: */ |
| 2956 |
/* Intervals 1,...,KF-1 have converged. */ |
| 2957 |
/* Intervals KF,...,KL still need to be refined. */ |
| 2958 |
|
| 2959 |
kf = 1; |
| 2960 |
kl = *minp; |
| 2961 |
|
| 2962 |
/* If IJOB=2, initialize C. */ |
| 2963 |
/* If IJOB=3, use the user-supplied starting point. */ |
| 2964 |
|
| 2965 |
if (*ijob == 2) { |
| 2966 |
i__1 = *minp; |
| 2967 |
for (ji = 1; ji <= i__1; ++ji) { |
| 2968 |
c__[ji] = (ab[ji + ab_dim1] + ab[ji + (ab_dim1 << 1)]) * .5; |
| 2969 |
/* L40: */ |
| 2970 |
} |
| 2971 |
} |
| 2972 |
|
| 2973 |
/* Iteration loop */ |
| 2974 |
|
| 2975 |
i__1 = *nitmax; |
| 2976 |
for (jit = 1; jit <= i__1; ++jit) { |
| 2977 |
|
| 2978 |
/* Loop over intervals */ |
| 2979 |
|
| 2980 |
if (kl - kf + 1 >= *nbmin && *nbmin > 0) { |
| 2981 |
|
| 2982 |
/* Begin of Parallel Version of the loop */ |
| 2983 |
|
| 2984 |
i__2 = kl; |
| 2985 |
for (ji = kf; ji <= i__2; ++ji) { |
| 2986 |
|
| 2987 |
/* Compute N(c), the number of eigenvalues less than c */ |
| 2988 |
|
| 2989 |
work[ji] = d__[1] - c__[ji]; |
| 2990 |
iwork[ji] = 0; |
| 2991 |
if (work[ji] <= *pivmin) { |
| 2992 |
iwork[ji] = 1; |
| 2993 |
/* Computing MIN */ |
| 2994 |
d__1 = work[ji], d__2 = -(*pivmin); |
| 2995 |
work[ji] = std::min(d__1,d__2); |
| 2996 |
} |
| 2997 |
|
| 2998 |
i__3 = *n; |
| 2999 |
for (j = 2; j <= i__3; ++j) { |
| 3000 |
work[ji] = d__[j] - e2[j - 1] / work[ji] - c__[ji]; |
| 3001 |
if (work[ji] <= *pivmin) { |
| 3002 |
++iwork[ji]; |
| 3003 |
/* Computing MIN */ |
| 3004 |
d__1 = work[ji], d__2 = -(*pivmin); |
| 3005 |
work[ji] = std::min(d__1,d__2); |
| 3006 |
} |
| 3007 |
/* L50: */ |
| 3008 |
} |
| 3009 |
/* L60: */ |
| 3010 |
} |
| 3011 |
|
| 3012 |
if (*ijob <= 2) { |
| 3013 |
|
| 3014 |
/* IJOB=2: Choose all intervals containing eigenvalues. */ |
| 3015 |
|
| 3016 |
klnew = kl; |
| 3017 |
i__2 = kl; |
| 3018 |
for (ji = kf; ji <= i__2; ++ji) { |
| 3019 |
|
| 3020 |
/* Insure that N(w) is monotone */ |
| 3021 |
|
| 3022 |
/* Computing MIN */ |
| 3023 |
/* Computing MAX */ |
| 3024 |
i__5 = nab[ji + nab_dim1], i__6 = iwork[ji]; |
| 3025 |
i__3 = nab[ji + (nab_dim1 << 1)], i__4 = std::max(i__5,i__6); |
| 3026 |
iwork[ji] = std::min(i__3,i__4); |
| 3027 |
|
| 3028 |
/* Update the Queue -- add intervals if both halves */ |
| 3029 |
/* contain eigenvalues. */ |
| 3030 |
|
| 3031 |
if (iwork[ji] == nab[ji + (nab_dim1 << 1)]) { |
| 3032 |
|
| 3033 |
/* No eigenvalue in the upper interval: */ |
| 3034 |
/* just use the lower interval. */ |
| 3035 |
|
| 3036 |
ab[ji + (ab_dim1 << 1)] = c__[ji]; |
| 3037 |
|
| 3038 |
} else if (iwork[ji] == nab[ji + nab_dim1]) { |
| 3039 |
|
| 3040 |
/* No eigenvalue in the lower interval: */ |
| 3041 |
/* just use the upper interval. */ |
| 3042 |
|
| 3043 |
ab[ji + ab_dim1] = c__[ji]; |
| 3044 |
} else { |
| 3045 |
++klnew; |
| 3046 |
if (klnew <= *mmax) { |
| 3047 |
|
| 3048 |
/* Eigenvalue in both intervals -- add upper to */ |
| 3049 |
/* queue. */ |
| 3050 |
|
| 3051 |
ab[klnew + (ab_dim1 << 1)] = ab[ji + (ab_dim1 << |
| 3052 |
1)]; |
| 3053 |
nab[klnew + (nab_dim1 << 1)] = nab[ji + (nab_dim1 |
| 3054 |
<< 1)]; |
| 3055 |
ab[klnew + ab_dim1] = c__[ji]; |
| 3056 |
nab[klnew + nab_dim1] = iwork[ji]; |
| 3057 |
ab[ji + (ab_dim1 << 1)] = c__[ji]; |
| 3058 |
nab[ji + (nab_dim1 << 1)] = iwork[ji]; |
| 3059 |
} else { |
| 3060 |
*info = *mmax + 1; |
| 3061 |
} |
| 3062 |
} |
| 3063 |
/* L70: */ |
| 3064 |
} |
| 3065 |
if (*info != 0) { |
| 3066 |
return 0; |
| 3067 |
} |
| 3068 |
kl = klnew; |
| 3069 |
} else { |
| 3070 |
|
| 3071 |
/* IJOB=3: Binary search. Keep only the interval containing */ |
| 3072 |
/* w s.t. N(w) = NVAL */ |
| 3073 |
|
| 3074 |
i__2 = kl; |
| 3075 |
for (ji = kf; ji <= i__2; ++ji) { |
| 3076 |
if (iwork[ji] <= nval[ji]) { |
| 3077 |
ab[ji + ab_dim1] = c__[ji]; |
| 3078 |
nab[ji + nab_dim1] = iwork[ji]; |
| 3079 |
} |
| 3080 |
if (iwork[ji] >= nval[ji]) { |
| 3081 |
ab[ji + (ab_dim1 << 1)] = c__[ji]; |
| 3082 |
nab[ji + (nab_dim1 << 1)] = iwork[ji]; |
| 3083 |
} |
| 3084 |
/* L80: */ |
| 3085 |
} |
| 3086 |
} |
| 3087 |
|
| 3088 |
} else { |
| 3089 |
|
| 3090 |
/* End of Parallel Version of the loop */ |
| 3091 |
|
| 3092 |
/* Begin of Serial Version of the loop */ |
| 3093 |
|
| 3094 |
klnew = kl; |
| 3095 |
i__2 = kl; |
| 3096 |
for (ji = kf; ji <= i__2; ++ji) { |
| 3097 |
|
| 3098 |
/* Compute N(w), the number of eigenvalues less than w */ |
| 3099 |
|
| 3100 |
tmp1 = c__[ji]; |
| 3101 |
tmp2 = d__[1] - tmp1; |
| 3102 |
itmp1 = 0; |
| 3103 |
if (tmp2 <= *pivmin) { |
| 3104 |
itmp1 = 1; |
| 3105 |
/* Computing MIN */ |
| 3106 |
d__1 = tmp2, d__2 = -(*pivmin); |
| 3107 |
tmp2 = std::min(d__1,d__2); |
| 3108 |
} |
| 3109 |
|
| 3110 |
/* A series of compiler directives to defeat vectorization */ |
| 3111 |
/* for the next loop */ |
| 3112 |
|
| 3113 |
/* $PL$ CMCHAR=' ' */ |
| 3114 |
/* DIR$ NEXTSCALAR */ |
| 3115 |
/* $DIR SCALAR */ |
| 3116 |
/* DIR$ NEXT SCALAR */ |
| 3117 |
/* VD$L NOVECTOR */ |
| 3118 |
/* DEC$ NOVECTOR */ |
| 3119 |
/* VD$ NOVECTOR */ |
| 3120 |
/* VDIR NOVECTOR */ |
| 3121 |
/* VOCL LOOP,SCALAR */ |
| 3122 |
/* IBM PREFER SCALAR */ |
| 3123 |
/* $PL$ CMCHAR='*' */ |
| 3124 |
|
| 3125 |
i__3 = *n; |
| 3126 |
for (j = 2; j <= i__3; ++j) { |
| 3127 |
tmp2 = d__[j] - e2[j - 1] / tmp2 - tmp1; |
| 3128 |
if (tmp2 <= *pivmin) { |
| 3129 |
++itmp1; |
| 3130 |
/* Computing MIN */ |
| 3131 |
d__1 = tmp2, d__2 = -(*pivmin); |
| 3132 |
tmp2 = std::min(d__1,d__2); |
| 3133 |
} |
| 3134 |
/* L90: */ |
| 3135 |
} |
| 3136 |
|
| 3137 |
if (*ijob <= 2) { |
| 3138 |
|
| 3139 |
/* IJOB=2: Choose all intervals containing eigenvalues. */ |
| 3140 |
|
| 3141 |
/* Insure that N(w) is monotone */ |
| 3142 |
|
| 3143 |
/* Computing MIN */ |
| 3144 |
/* Computing MAX */ |
| 3145 |
i__5 = nab[ji + nab_dim1]; |
| 3146 |
i__3 = nab[ji + (nab_dim1 << 1)], i__4 = std::max(i__5,itmp1); |
| 3147 |
itmp1 = std::min(i__3,i__4); |
| 3148 |
|
| 3149 |
/* Update the Queue -- add intervals if both halves */ |
| 3150 |
/* contain eigenvalues. */ |
| 3151 |
|
| 3152 |
if (itmp1 == nab[ji + (nab_dim1 << 1)]) { |
| 3153 |
|
| 3154 |
/* No eigenvalue in the upper interval: */ |
| 3155 |
/* just use the lower interval. */ |
| 3156 |
|
| 3157 |
ab[ji + (ab_dim1 << 1)] = tmp1; |
| 3158 |
|
| 3159 |
} else if (itmp1 == nab[ji + nab_dim1]) { |
| 3160 |
|
| 3161 |
/* No eigenvalue in the lower interval: */ |
| 3162 |
/* just use the upper interval. */ |
| 3163 |
|
| 3164 |
ab[ji + ab_dim1] = tmp1; |
| 3165 |
} else if (klnew < *mmax) { |
| 3166 |
|
| 3167 |
/* Eigenvalue in both intervals -- add upper to queue. */ |
| 3168 |
|
| 3169 |
++klnew; |
| 3170 |
ab[klnew + (ab_dim1 << 1)] = ab[ji + (ab_dim1 << 1)]; |
| 3171 |
nab[klnew + (nab_dim1 << 1)] = nab[ji + (nab_dim1 << |
| 3172 |
1)]; |
| 3173 |
ab[klnew + ab_dim1] = tmp1; |
| 3174 |
nab[klnew + nab_dim1] = itmp1; |
| 3175 |
ab[ji + (ab_dim1 << 1)] = tmp1; |
| 3176 |
nab[ji + (nab_dim1 << 1)] = itmp1; |
| 3177 |
} else { |
| 3178 |
*info = *mmax + 1; |
| 3179 |
return 0; |
| 3180 |
} |
| 3181 |
} else { |
| 3182 |
|
| 3183 |
/* IJOB=3: Binary search. Keep only the interval */ |
| 3184 |
/* containing w s.t. N(w) = NVAL */ |
| 3185 |
|
| 3186 |
if (itmp1 <= nval[ji]) { |
| 3187 |
ab[ji + ab_dim1] = tmp1; |
| 3188 |
nab[ji + nab_dim1] = itmp1; |
| 3189 |
} |
| 3190 |
if (itmp1 >= nval[ji]) { |
| 3191 |
ab[ji + (ab_dim1 << 1)] = tmp1; |
| 3192 |
nab[ji + (nab_dim1 << 1)] = itmp1; |
| 3193 |
} |
| 3194 |
} |
| 3195 |
/* L100: */ |
| 3196 |
} |
| 3197 |
kl = klnew; |
| 3198 |
|
| 3199 |
/* End of Serial Version of the loop */ |
| 3200 |
|
| 3201 |
} |
| 3202 |
|
| 3203 |
/* Check for convergence */ |
| 3204 |
|
| 3205 |
kfnew = kf; |
| 3206 |
i__2 = kl; |
| 3207 |
for (ji = kf; ji <= i__2; ++ji) { |
| 3208 |
tmp1 = (d__1 = ab[ji + (ab_dim1 << 1)] - ab[ji + ab_dim1], abs( |
| 3209 |
d__1)); |
| 3210 |
/* Computing MAX */ |
| 3211 |
d__3 = (d__1 = ab[ji + (ab_dim1 << 1)], abs(d__1)), d__4 = (d__2 = |
| 3212 |
ab[ji + ab_dim1], abs(d__2)); |
| 3213 |
tmp2 = std::max(d__3,d__4); |
| 3214 |
/* Computing MAX */ |
| 3215 |
d__1 = std::max(*abstol,*pivmin), d__2 = *reltol * tmp2; |
| 3216 |
if (tmp1 < std::max(d__1,d__2) || nab[ji + nab_dim1] >= nab[ji + ( |
| 3217 |
nab_dim1 << 1)]) { |
| 3218 |
|
| 3219 |
/* Converged -- Swap with position KFNEW, */ |
| 3220 |
/* then increment KFNEW */ |
| 3221 |
|
| 3222 |
if (ji > kfnew) { |
| 3223 |
tmp1 = ab[ji + ab_dim1]; |
| 3224 |
tmp2 = ab[ji + (ab_dim1 << 1)]; |
| 3225 |
itmp1 = nab[ji + nab_dim1]; |
| 3226 |
itmp2 = nab[ji + (nab_dim1 << 1)]; |
| 3227 |
ab[ji + ab_dim1] = ab[kfnew + ab_dim1]; |
| 3228 |
ab[ji + (ab_dim1 << 1)] = ab[kfnew + (ab_dim1 << 1)]; |
| 3229 |
nab[ji + nab_dim1] = nab[kfnew + nab_dim1]; |
| 3230 |
nab[ji + (nab_dim1 << 1)] = nab[kfnew + (nab_dim1 << 1)]; |
| 3231 |
ab[kfnew + ab_dim1] = tmp1; |
| 3232 |
ab[kfnew + (ab_dim1 << 1)] = tmp2; |
| 3233 |
nab[kfnew + nab_dim1] = itmp1; |
| 3234 |
nab[kfnew + (nab_dim1 << 1)] = itmp2; |
| 3235 |
if (*ijob == 3) { |
| 3236 |
itmp1 = nval[ji]; |
| 3237 |
nval[ji] = nval[kfnew]; |
| 3238 |
nval[kfnew] = itmp1; |
| 3239 |
} |
| 3240 |
} |
| 3241 |
++kfnew; |
| 3242 |
} |
| 3243 |
/* L110: */ |
| 3244 |
} |
| 3245 |
kf = kfnew; |
| 3246 |
|
| 3247 |
/* Choose Midpoints */ |
| 3248 |
|
| 3249 |
i__2 = kl; |
| 3250 |
for (ji = kf; ji <= i__2; ++ji) { |
| 3251 |
c__[ji] = (ab[ji + ab_dim1] + ab[ji + (ab_dim1 << 1)]) * .5; |
| 3252 |
/* L120: */ |
| 3253 |
} |
| 3254 |
|
| 3255 |
/* If no more intervals to refine, quit. */ |
| 3256 |
|
| 3257 |
if (kf > kl) { |
| 3258 |
goto L140; |
| 3259 |
} |
| 3260 |
/* L130: */ |
| 3261 |
} |
| 3262 |
|
| 3263 |
/* Converged */ |
| 3264 |
|
| 3265 |
L140: |
| 3266 |
/* Computing MAX */ |
| 3267 |
i__1 = kl + 1 - kf; |
| 3268 |
*info = std::max(i__1,0_integer); |
| 3269 |
*mout = kl; |
| 3270 |
|
| 3271 |
return 0; |
| 3272 |
|
| 3273 |
/* End of DLAEBZ */ |
| 3274 |
|
| 3275 |
} /* dlaebz_ */ |
| 3276 |
|
| 3277 |
/* Subroutine */ int dlaed0_(integer *icompq, integer *qsiz, integer *n, |
| 3278 |
double *d__, double *e, double *q, integer *ldq, |
| 3279 |
double *qstore, integer *ldqs, double *work, integer *iwork, |
| 3280 |
integer *info) |
| 3281 |
{ |
| 3282 |
/* Table of constant values */ |
| 3283 |
static integer c__9 = 9; |
| 3284 |
static integer c__0 = 0; |
| 3285 |
static integer c__2 = 2; |
| 3286 |
static double c_b23 = 1.; |
| 3287 |
static double c_b24 = 0.; |
| 3288 |
static integer c__1 = 1; |
| 3289 |
|
| 3290 |
/* System generated locals */ |
| 3291 |
integer q_dim1, q_offset, qstore_dim1, qstore_offset, i__1, i__2; |
| 3292 |
double d__1; |
| 3293 |
|
| 3294 |
/* Local variables */ |
| 3295 |
integer i__, j, k, iq, lgn, msd2, smm1, spm1, spm2; |
| 3296 |
double temp; |
| 3297 |
integer curr; |
| 3298 |
integer iperm; |
| 3299 |
integer indxq, iwrem; |
| 3300 |
integer iqptr; |
| 3301 |
integer tlvls; |
| 3302 |
integer igivcl; |
| 3303 |
integer igivnm, submat, curprb, subpbs, igivpt; |
| 3304 |
integer curlvl, matsiz, iprmpt, smlsiz; |
| 3305 |
|
| 3306 |
|
| 3307 |
/* -- LAPACK routine (version 3.1) -- */ |
| 3308 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 3309 |
/* November 2006 */ |
| 3310 |
|
| 3311 |
/* .. Scalar Arguments .. */ |
| 3312 |
/* .. */ |
| 3313 |
/* .. Array Arguments .. */ |
| 3314 |
/* .. */ |
| 3315 |
|
| 3316 |
/* Purpose */ |
| 3317 |
/* ======= */ |
| 3318 |
|
| 3319 |
/* DLAED0 computes all eigenvalues and corresponding eigenvectors of a */ |
| 3320 |
/* symmetric tridiagonal matrix using the divide and conquer method. */ |
| 3321 |
|
| 3322 |
/* Arguments */ |
| 3323 |
/* ========= */ |
| 3324 |
|
| 3325 |
/* ICOMPQ (input) INTEGER */ |
| 3326 |
/* = 0: Compute eigenvalues only. */ |
| 3327 |
/* = 1: Compute eigenvectors of original dense symmetric matrix */ |
| 3328 |
/* also. On entry, Q contains the orthogonal matrix used */ |
| 3329 |
/* to reduce the original matrix to tridiagonal form. */ |
| 3330 |
/* = 2: Compute eigenvalues and eigenvectors of tridiagonal */ |
| 3331 |
/* matrix. */ |
| 3332 |
|
| 3333 |
/* QSIZ (input) INTEGER */ |
| 3334 |
/* The dimension of the orthogonal matrix used to reduce */ |
| 3335 |
/* the full matrix to tridiagonal form. QSIZ >= N if ICOMPQ = 1. */ |
| 3336 |
|
| 3337 |
/* N (input) INTEGER */ |
| 3338 |
/* The dimension of the symmetric tridiagonal matrix. N >= 0. */ |
| 3339 |
|
| 3340 |
/* D (input/output) DOUBLE PRECISION array, dimension (N) */ |
| 3341 |
/* On entry, the main diagonal of the tridiagonal matrix. */ |
| 3342 |
/* On exit, its eigenvalues. */ |
| 3343 |
|
| 3344 |
/* E (input) DOUBLE PRECISION array, dimension (N-1) */ |
| 3345 |
/* The off-diagonal elements of the tridiagonal matrix. */ |
| 3346 |
/* On exit, E has been destroyed. */ |
| 3347 |
|
| 3348 |
/* Q (input/output) DOUBLE PRECISION array, dimension (LDQ, N) */ |
| 3349 |
/* On entry, Q must contain an N-by-N orthogonal matrix. */ |
| 3350 |
/* If ICOMPQ = 0 Q is not referenced. */ |
| 3351 |
/* If ICOMPQ = 1 On entry, Q is a subset of the columns of the */ |
| 3352 |
/* orthogonal matrix used to reduce the full */ |
| 3353 |
/* matrix to tridiagonal form corresponding to */ |
| 3354 |
/* the subset of the full matrix which is being */ |
| 3355 |
/* decomposed at this time. */ |
| 3356 |
/* If ICOMPQ = 2 On entry, Q will be the identity matrix. */ |
| 3357 |
/* On exit, Q contains the eigenvectors of the */ |
| 3358 |
/* tridiagonal matrix. */ |
| 3359 |
|
| 3360 |
/* LDQ (input) INTEGER */ |
| 3361 |
/* The leading dimension of the array Q. If eigenvectors are */ |
| 3362 |
/* desired, then LDQ >= max(1,N). In any case, LDQ >= 1. */ |
| 3363 |
|
| 3364 |
/* QSTORE (workspace) DOUBLE PRECISION array, dimension (LDQS, N) */ |
| 3365 |
/* Referenced only when ICOMPQ = 1. Used to store parts of */ |
| 3366 |
/* the eigenvector matrix when the updating matrix multiplies */ |
| 3367 |
/* take place. */ |
| 3368 |
|
| 3369 |
/* LDQS (input) INTEGER */ |
| 3370 |
/* The leading dimension of the array QSTORE. If ICOMPQ = 1, */ |
| 3371 |
/* then LDQS >= max(1,N). In any case, LDQS >= 1. */ |
| 3372 |
|
| 3373 |
/* WORK (workspace) DOUBLE PRECISION array, */ |
| 3374 |
/* If ICOMPQ = 0 or 1, the dimension of WORK must be at least */ |
| 3375 |
/* 1 + 3*N + 2*N*lg N + 2*N**2 */ |
| 3376 |
/* ( lg( N ) = smallest integer k */ |
| 3377 |
/* such that 2^k >= N ) */ |
| 3378 |
/* If ICOMPQ = 2, the dimension of WORK must be at least */ |
| 3379 |
/* 4*N + N**2. */ |
| 3380 |
|
| 3381 |
/* IWORK (workspace) INTEGER array, */ |
| 3382 |
/* If ICOMPQ = 0 or 1, the dimension of IWORK must be at least */ |
| 3383 |
/* 6 + 6*N + 5*N*lg N. */ |
| 3384 |
/* ( lg( N ) = smallest integer k */ |
| 3385 |
/* such that 2^k >= N ) */ |
| 3386 |
/* If ICOMPQ = 2, the dimension of IWORK must be at least */ |
| 3387 |
/* 3 + 5*N. */ |
| 3388 |
|
| 3389 |
/* INFO (output) INTEGER */ |
| 3390 |
/* = 0: successful exit. */ |
| 3391 |
/* < 0: if INFO = -i, the i-th argument had an illegal value. */ |
| 3392 |
/* > 0: The algorithm failed to compute an eigenvalue while */ |
| 3393 |
/* working on the submatrix lying in rows and columns */ |
| 3394 |
/* INFO/(N+1) through mod(INFO,N+1). */ |
| 3395 |
|
| 3396 |
/* Further Details */ |
| 3397 |
/* =============== */ |
| 3398 |
|
| 3399 |
/* Based on contributions by */ |
| 3400 |
/* Jeff Rutter, Computer Science Division, University of California */ |
| 3401 |
/* at Berkeley, USA */ |
| 3402 |
|
| 3403 |
/* ===================================================================== */ |
| 3404 |
|
| 3405 |
/* .. Parameters .. */ |
| 3406 |
/* .. */ |
| 3407 |
/* .. Local Scalars .. */ |
| 3408 |
/* .. */ |
| 3409 |
/* .. External Subroutines .. */ |
| 3410 |
/* .. */ |
| 3411 |
/* .. External Functions .. */ |
| 3412 |
/* .. */ |
| 3413 |
/* .. Intrinsic Functions .. */ |
| 3414 |
/* .. */ |
| 3415 |
/* .. Executable Statements .. */ |
| 3416 |
|
| 3417 |
/* Test the input parameters. */ |
| 3418 |
|
| 3419 |
/* Parameter adjustments */ |
| 3420 |
--d__; |
| 3421 |
--e; |
| 3422 |
q_dim1 = *ldq; |
| 3423 |
q_offset = 1 + q_dim1; |
| 3424 |
q -= q_offset; |
| 3425 |
qstore_dim1 = *ldqs; |
| 3426 |
qstore_offset = 1 + qstore_dim1; |
| 3427 |
qstore -= qstore_offset; |
| 3428 |
--work; |
| 3429 |
--iwork; |
| 3430 |
|
| 3431 |
/* Function Body */ |
| 3432 |
*info = 0; |
| 3433 |
|
| 3434 |
if (*icompq < 0 || *icompq > 2) { |
| 3435 |
*info = -1; |
| 3436 |
} else if (*icompq == 1 && *qsiz < std::max(0_integer,*n)) { |
| 3437 |
*info = -2; |
| 3438 |
} else if (*n < 0) { |
| 3439 |
*info = -3; |
| 3440 |
} else if (*ldq < std::max(1_integer,*n)) { |
| 3441 |
*info = -7; |
| 3442 |
} else if (*ldqs < std::max(1_integer,*n)) { |
| 3443 |
*info = -9; |
| 3444 |
} |
| 3445 |
if (*info != 0) { |
| 3446 |
i__1 = -(*info); |
| 3447 |
xerbla_("DLAED0", &i__1); |
| 3448 |
return 0; |
| 3449 |
} |
| 3450 |
|
| 3451 |
/* Quick return if possible */ |
| 3452 |
|
| 3453 |
if (*n == 0) { |
| 3454 |
return 0; |
| 3455 |
} |
| 3456 |
|
| 3457 |
smlsiz = ilaenv_(&c__9, "DLAED0", " ", &c__0, &c__0, &c__0, &c__0); |
| 3458 |
|
| 3459 |
/* Determine the size and placement of the submatrices, and save in */ |
| 3460 |
/* the leading elements of IWORK. */ |
| 3461 |
|
| 3462 |
iwork[1] = *n; |
| 3463 |
subpbs = 1; |
| 3464 |
tlvls = 0; |
| 3465 |
L10: |
| 3466 |
if (iwork[subpbs] > smlsiz) { |
| 3467 |
for (j = subpbs; j >= 1; --j) { |
| 3468 |
iwork[j * 2] = (iwork[j] + 1) / 2; |
| 3469 |
iwork[(j << 1) - 1] = iwork[j] / 2; |
| 3470 |
/* L20: */ |
| 3471 |
} |
| 3472 |
++tlvls; |
| 3473 |
subpbs <<= 1; |
| 3474 |
goto L10; |
| 3475 |
} |
| 3476 |
i__1 = subpbs; |
| 3477 |
for (j = 2; j <= i__1; ++j) { |
| 3478 |
iwork[j] += iwork[j - 1]; |
| 3479 |
/* L30: */ |
| 3480 |
} |
| 3481 |
|
| 3482 |
/* Divide the matrix into SUBPBS submatrices of size at most SMLSIZ+1 */ |
| 3483 |
/* using rank-1 modifications (cuts). */ |
| 3484 |
|
| 3485 |
spm1 = subpbs - 1; |
| 3486 |
i__1 = spm1; |
| 3487 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 3488 |
submat = iwork[i__] + 1; |
| 3489 |
smm1 = submat - 1; |
| 3490 |
d__[smm1] -= (d__1 = e[smm1], abs(d__1)); |
| 3491 |
d__[submat] -= (d__1 = e[smm1], abs(d__1)); |
| 3492 |
/* L40: */ |
| 3493 |
} |
| 3494 |
|
| 3495 |
indxq = (*n << 2) + 3; |
| 3496 |
if (*icompq != 2) { |
| 3497 |
|
| 3498 |
/* Set up workspaces for eigenvalues only/accumulate new vectors */ |
| 3499 |
/* routine */ |
| 3500 |
|
| 3501 |
temp = log((double) (*n)) / log(2.); |
| 3502 |
lgn = (integer) temp; |
| 3503 |
if (pow_ii(&c__2, &lgn) < *n) { |
| 3504 |
++lgn; |
| 3505 |
} |
| 3506 |
if (pow_ii(&c__2, &lgn) < *n) { |
| 3507 |
++lgn; |
| 3508 |
} |
| 3509 |
iprmpt = indxq + *n + 1; |
| 3510 |
iperm = iprmpt + *n * lgn; |
| 3511 |
iqptr = iperm + *n * lgn; |
| 3512 |
igivpt = iqptr + *n + 2; |
| 3513 |
igivcl = igivpt + *n * lgn; |
| 3514 |
|
| 3515 |
igivnm = 1; |
| 3516 |
iq = igivnm + (*n << 1) * lgn; |
| 3517 |
/* Computing 2nd power */ |
| 3518 |
i__1 = *n; |
| 3519 |
iwrem = iq + i__1 * i__1 + 1; |
| 3520 |
|
| 3521 |
/* Initialize pointers */ |
| 3522 |
|
| 3523 |
i__1 = subpbs; |
| 3524 |
for (i__ = 0; i__ <= i__1; ++i__) { |
| 3525 |
iwork[iprmpt + i__] = 1; |
| 3526 |
iwork[igivpt + i__] = 1; |
| 3527 |
/* L50: */ |
| 3528 |
} |
| 3529 |
iwork[iqptr] = 1; |
| 3530 |
} |
| 3531 |
|
| 3532 |
/* Solve each submatrix eigenproblem at the bottom of the divide and */ |
| 3533 |
/* conquer tree. */ |
| 3534 |
|
| 3535 |
curr = 0; |
| 3536 |
i__1 = spm1; |
| 3537 |
for (i__ = 0; i__ <= i__1; ++i__) { |
| 3538 |
if (i__ == 0) { |
| 3539 |
submat = 1; |
| 3540 |
matsiz = iwork[1]; |
| 3541 |
} else { |
| 3542 |
submat = iwork[i__] + 1; |
| 3543 |
matsiz = iwork[i__ + 1] - iwork[i__]; |
| 3544 |
} |
| 3545 |
if (*icompq == 2) { |
| 3546 |
dsteqr_("I", &matsiz, &d__[submat], &e[submat], &q[submat + |
| 3547 |
submat * q_dim1], ldq, &work[1], info); |
| 3548 |
if (*info != 0) { |
| 3549 |
goto L130; |
| 3550 |
} |
| 3551 |
} else { |
| 3552 |
dsteqr_("I", &matsiz, &d__[submat], &e[submat], &work[iq - 1 + |
| 3553 |
iwork[iqptr + curr]], &matsiz, &work[1], info); |
| 3554 |
if (*info != 0) { |
| 3555 |
goto L130; |
| 3556 |
} |
| 3557 |
if (*icompq == 1) { |
| 3558 |
dgemm_("N", "N", qsiz, &matsiz, &matsiz, &c_b23, &q[submat * |
| 3559 |
q_dim1 + 1], ldq, &work[iq - 1 + iwork[iqptr + curr]], |
| 3560 |
&matsiz, &c_b24, &qstore[submat * qstore_dim1 + 1], |
| 3561 |
ldqs); |
| 3562 |
} |
| 3563 |
/* Computing 2nd power */ |
| 3564 |
i__2 = matsiz; |
| 3565 |
iwork[iqptr + curr + 1] = iwork[iqptr + curr] + i__2 * i__2; |
| 3566 |
++curr; |
| 3567 |
} |
| 3568 |
k = 1; |
| 3569 |
i__2 = iwork[i__ + 1]; |
| 3570 |
for (j = submat; j <= i__2; ++j) { |
| 3571 |
iwork[indxq + j] = k; |
| 3572 |
++k; |
| 3573 |
/* L60: */ |
| 3574 |
} |
| 3575 |
/* L70: */ |
| 3576 |
} |
| 3577 |
|
| 3578 |
/* Successively merge eigensystems of adjacent submatrices */ |
| 3579 |
/* into eigensystem for the corresponding larger matrix. */ |
| 3580 |
|
| 3581 |
/* while ( SUBPBS > 1 ) */ |
| 3582 |
|
| 3583 |
curlvl = 1; |
| 3584 |
L80: |
| 3585 |
if (subpbs > 1) { |
| 3586 |
spm2 = subpbs - 2; |
| 3587 |
i__1 = spm2; |
| 3588 |
for (i__ = 0; i__ <= i__1; i__ += 2) { |
| 3589 |
if (i__ == 0) { |
| 3590 |
submat = 1; |
| 3591 |
matsiz = iwork[2]; |
| 3592 |
msd2 = iwork[1]; |
| 3593 |
curprb = 0; |
| 3594 |
} else { |
| 3595 |
submat = iwork[i__] + 1; |
| 3596 |
matsiz = iwork[i__ + 2] - iwork[i__]; |
| 3597 |
msd2 = matsiz / 2; |
| 3598 |
++curprb; |
| 3599 |
} |
| 3600 |
|
| 3601 |
/* Merge lower order eigensystems (of size MSD2 and MATSIZ - MSD2) */ |
| 3602 |
/* into an eigensystem of size MATSIZ. */ |
| 3603 |
/* DLAED1 is used only for the full eigensystem of a tridiagonal */ |
| 3604 |
/* matrix. */ |
| 3605 |
/* DLAED7 handles the cases in which eigenvalues only or eigenvalues */ |
| 3606 |
/* and eigenvectors of a full symmetric matrix (which was reduced to */ |
| 3607 |
/* tridiagonal form) are desired. */ |
| 3608 |
|
| 3609 |
if (*icompq == 2) { |
| 3610 |
dlaed1_(&matsiz, &d__[submat], &q[submat + submat * q_dim1], |
| 3611 |
ldq, &iwork[indxq + submat], &e[submat + msd2 - 1], & |
| 3612 |
msd2, &work[1], &iwork[subpbs + 1], info); |
| 3613 |
} else { |
| 3614 |
dlaed7_(icompq, &matsiz, qsiz, &tlvls, &curlvl, &curprb, &d__[ |
| 3615 |
submat], &qstore[submat * qstore_dim1 + 1], ldqs, & |
| 3616 |
iwork[indxq + submat], &e[submat + msd2 - 1], &msd2, & |
| 3617 |
work[iq], &iwork[iqptr], &iwork[iprmpt], &iwork[iperm] |
| 3618 |
, &iwork[igivpt], &iwork[igivcl], &work[igivnm], & |
| 3619 |
work[iwrem], &iwork[subpbs + 1], info); |
| 3620 |
} |
| 3621 |
if (*info != 0) { |
| 3622 |
goto L130; |
| 3623 |
} |
| 3624 |
iwork[i__ / 2 + 1] = iwork[i__ + 2]; |
| 3625 |
/* L90: */ |
| 3626 |
} |
| 3627 |
subpbs /= 2; |
| 3628 |
++curlvl; |
| 3629 |
goto L80; |
| 3630 |
} |
| 3631 |
|
| 3632 |
/* end while */ |
| 3633 |
|
| 3634 |
/* Re-merge the eigenvalues/vectors which were deflated at the final */ |
| 3635 |
/* merge step. */ |
| 3636 |
|
| 3637 |
if (*icompq == 1) { |
| 3638 |
i__1 = *n; |
| 3639 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 3640 |
j = iwork[indxq + i__]; |
| 3641 |
work[i__] = d__[j]; |
| 3642 |
dcopy_(qsiz, &qstore[j * qstore_dim1 + 1], &c__1, &q[i__ * q_dim1 |
| 3643 |
+ 1], &c__1); |
| 3644 |
/* L100: */ |
| 3645 |
} |
| 3646 |
dcopy_(n, &work[1], &c__1, &d__[1], &c__1); |
| 3647 |
} else if (*icompq == 2) { |
| 3648 |
i__1 = *n; |
| 3649 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 3650 |
j = iwork[indxq + i__]; |
| 3651 |
work[i__] = d__[j]; |
| 3652 |
dcopy_(n, &q[j * q_dim1 + 1], &c__1, &work[*n * i__ + 1], &c__1); |
| 3653 |
/* L110: */ |
| 3654 |
} |
| 3655 |
dcopy_(n, &work[1], &c__1, &d__[1], &c__1); |
| 3656 |
dlacpy_("A", n, n, &work[*n + 1], n, &q[q_offset], ldq); |
| 3657 |
} else { |
| 3658 |
i__1 = *n; |
| 3659 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 3660 |
j = iwork[indxq + i__]; |
| 3661 |
work[i__] = d__[j]; |
| 3662 |
/* L120: */ |
| 3663 |
} |
| 3664 |
dcopy_(n, &work[1], &c__1, &d__[1], &c__1); |
| 3665 |
} |
| 3666 |
goto L140; |
| 3667 |
|
| 3668 |
L130: |
| 3669 |
*info = submat * (*n + 1) + submat + matsiz - 1; |
| 3670 |
|
| 3671 |
L140: |
| 3672 |
return 0; |
| 3673 |
|
| 3674 |
/* End of DLAED0 */ |
| 3675 |
|
| 3676 |
} /* dlaed0_ */ |
| 3677 |
|
| 3678 |
/* Subroutine */ int dlaed1_(integer *n, double *d__, double *q, |
| 3679 |
integer *ldq, integer *indxq, double *rho, integer *cutpnt, |
| 3680 |
double *work, integer *iwork, integer *info) |
| 3681 |
{ |
| 3682 |
/* Table of constant values */ |
| 3683 |
static integer c__1 = 1; |
| 3684 |
static integer c_n1 = -1; |
| 3685 |
|
| 3686 |
/* System generated locals */ |
| 3687 |
integer q_dim1, q_offset, i__1, i__2; |
| 3688 |
|
| 3689 |
/* Local variables */ |
| 3690 |
integer i__, k, n1, n2, is, iw, iz, iq2, zpp1, indx, indxc; |
| 3691 |
integer indxp; |
| 3692 |
integer idlmda; |
| 3693 |
integer coltyp; |
| 3694 |
|
| 3695 |
|
| 3696 |
/* -- LAPACK routine (version 3.1) -- */ |
| 3697 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 3698 |
/* November 2006 */ |
| 3699 |
|
| 3700 |
/* .. Scalar Arguments .. */ |
| 3701 |
/* .. */ |
| 3702 |
/* .. Array Arguments .. */ |
| 3703 |
/* .. */ |
| 3704 |
|
| 3705 |
/* Purpose */ |
| 3706 |
/* ======= */ |
| 3707 |
|
| 3708 |
/* DLAED1 computes the updated eigensystem of a diagonal */ |
| 3709 |
/* matrix after modification by a rank-one symmetric matrix. This */ |
| 3710 |
/* routine is used only for the eigenproblem which requires all */ |
| 3711 |
/* eigenvalues and eigenvectors of a tridiagonal matrix. DLAED7 handles */ |
| 3712 |
/* the case in which eigenvalues only or eigenvalues and eigenvectors */ |
| 3713 |
/* of a full symmetric matrix (which was reduced to tridiagonal form) */ |
| 3714 |
/* are desired. */ |
| 3715 |
|
| 3716 |
/* T = Q(in) ( D(in) + RHO * Z*Z' ) Q'(in) = Q(out) * D(out) * Q'(out) */ |
| 3717 |
|
| 3718 |
/* where Z = Q'u, u is a vector of length N with ones in the */ |
| 3719 |
/* CUTPNT and CUTPNT + 1 th elements and zeros elsewhere. */ |
| 3720 |
|
| 3721 |
/* The eigenvectors of the original matrix are stored in Q, and the */ |
| 3722 |
/* eigenvalues are in D. The algorithm consists of three stages: */ |
| 3723 |
|
| 3724 |
/* The first stage consists of deflating the size of the problem */ |
| 3725 |
/* when there are multiple eigenvalues or if there is a zero in */ |
| 3726 |
/* the Z vector. For each such occurrence the dimension of the */ |
| 3727 |
/* secular equation problem is reduced by one. This stage is */ |
| 3728 |
/* performed by the routine DLAED2. */ |
| 3729 |
|
| 3730 |
/* The second stage consists of calculating the updated */ |
| 3731 |
/* eigenvalues. This is done by finding the roots of the secular */ |
| 3732 |
/* equation via the routine DLAED4 (as called by DLAED3). */ |
| 3733 |
/* This routine also calculates the eigenvectors of the current */ |
| 3734 |
/* problem. */ |
| 3735 |
|
| 3736 |
/* The final stage consists of computing the updated eigenvectors */ |
| 3737 |
/* directly using the updated eigenvalues. The eigenvectors for */ |
| 3738 |
/* the current problem are multiplied with the eigenvectors from */ |
| 3739 |
/* the overall problem. */ |
| 3740 |
|
| 3741 |
/* Arguments */ |
| 3742 |
/* ========= */ |
| 3743 |
|
| 3744 |
/* N (input) INTEGER */ |
| 3745 |
/* The dimension of the symmetric tridiagonal matrix. N >= 0. */ |
| 3746 |
|
| 3747 |
/* D (input/output) DOUBLE PRECISION array, dimension (N) */ |
| 3748 |
/* On entry, the eigenvalues of the rank-1-perturbed matrix. */ |
| 3749 |
/* On exit, the eigenvalues of the repaired matrix. */ |
| 3750 |
|
| 3751 |
/* Q (input/output) DOUBLE PRECISION array, dimension (LDQ,N) */ |
| 3752 |
/* On entry, the eigenvectors of the rank-1-perturbed matrix. */ |
| 3753 |
/* On exit, the eigenvectors of the repaired tridiagonal matrix. */ |
| 3754 |
|
| 3755 |
/* LDQ (input) INTEGER */ |
| 3756 |
/* The leading dimension of the array Q. LDQ >= max(1,N). */ |
| 3757 |
|
| 3758 |
/* INDXQ (input/output) INTEGER array, dimension (N) */ |
| 3759 |
/* On entry, the permutation which separately sorts the two */ |
| 3760 |
/* subproblems in D into ascending order. */ |
| 3761 |
/* On exit, the permutation which will reintegrate the */ |
| 3762 |
/* subproblems back into sorted order, */ |
| 3763 |
/* i.e. D( INDXQ( I = 1, N ) ) will be in ascending order. */ |
| 3764 |
|
| 3765 |
/* RHO (input) DOUBLE PRECISION */ |
| 3766 |
/* The subdiagonal entry used to create the rank-1 modification. */ |
| 3767 |
|
| 3768 |
/* CUTPNT (input) INTEGER */ |
| 3769 |
/* The location of the last eigenvalue in the leading sub-matrix. */ |
| 3770 |
/* min(1,N) <= CUTPNT <= N/2. */ |
| 3771 |
|
| 3772 |
/* WORK (workspace) DOUBLE PRECISION array, dimension (4*N + N**2) */ |
| 3773 |
|
| 3774 |
/* IWORK (workspace) INTEGER array, dimension (4*N) */ |
| 3775 |
|
| 3776 |
/* INFO (output) INTEGER */ |
| 3777 |
/* = 0: successful exit. */ |
| 3778 |
/* < 0: if INFO = -i, the i-th argument had an illegal value. */ |
| 3779 |
/* > 0: if INFO = 1, an eigenvalue did not converge */ |
| 3780 |
|
| 3781 |
/* Further Details */ |
| 3782 |
/* =============== */ |
| 3783 |
|
| 3784 |
/* Based on contributions by */ |
| 3785 |
/* Jeff Rutter, Computer Science Division, University of California */ |
| 3786 |
/* at Berkeley, USA */ |
| 3787 |
/* Modified by Francoise Tisseur, University of Tennessee. */ |
| 3788 |
|
| 3789 |
/* ===================================================================== */ |
| 3790 |
|
| 3791 |
/* .. Local Scalars .. */ |
| 3792 |
/* .. */ |
| 3793 |
/* .. External Subroutines .. */ |
| 3794 |
/* .. */ |
| 3795 |
/* .. Intrinsic Functions .. */ |
| 3796 |
/* .. */ |
| 3797 |
/* .. Executable Statements .. */ |
| 3798 |
|
| 3799 |
/* Test the input parameters. */ |
| 3800 |
|
| 3801 |
/* Parameter adjustments */ |
| 3802 |
--d__; |
| 3803 |
q_dim1 = *ldq; |
| 3804 |
q_offset = 1 + q_dim1; |
| 3805 |
q -= q_offset; |
| 3806 |
--indxq; |
| 3807 |
--work; |
| 3808 |
--iwork; |
| 3809 |
|
| 3810 |
/* Function Body */ |
| 3811 |
*info = 0; |
| 3812 |
|
| 3813 |
if (*n < 0) { |
| 3814 |
*info = -1; |
| 3815 |
} else if (*ldq < std::max(1_integer,*n)) { |
| 3816 |
*info = -4; |
| 3817 |
} else /* if(complicated condition) */ { |
| 3818 |
/* Computing MIN */ |
| 3819 |
i__1 = 1, i__2 = *n / 2; |
| 3820 |
if (std::min(i__1,i__2) > *cutpnt || *n / 2 < *cutpnt) { |
| 3821 |
*info = -7; |
| 3822 |
} |
| 3823 |
} |
| 3824 |
if (*info != 0) { |
| 3825 |
i__1 = -(*info); |
| 3826 |
xerbla_("DLAED1", &i__1); |
| 3827 |
return 0; |
| 3828 |
} |
| 3829 |
|
| 3830 |
/* Quick return if possible */ |
| 3831 |
|
| 3832 |
if (*n == 0) { |
| 3833 |
return 0; |
| 3834 |
} |
| 3835 |
|
| 3836 |
/* The following values are integer pointers which indicate */ |
| 3837 |
/* the portion of the workspace */ |
| 3838 |
/* used by a particular array in DLAED2 and DLAED3. */ |
| 3839 |
|
| 3840 |
iz = 1; |
| 3841 |
idlmda = iz + *n; |
| 3842 |
iw = idlmda + *n; |
| 3843 |
iq2 = iw + *n; |
| 3844 |
|
| 3845 |
indx = 1; |
| 3846 |
indxc = indx + *n; |
| 3847 |
coltyp = indxc + *n; |
| 3848 |
indxp = coltyp + *n; |
| 3849 |
|
| 3850 |
|
| 3851 |
/* Form the z-vector which consists of the last row of Q_1 and the */ |
| 3852 |
/* first row of Q_2. */ |
| 3853 |
|
| 3854 |
dcopy_(cutpnt, &q[*cutpnt + q_dim1], ldq, &work[iz], &c__1); |
| 3855 |
zpp1 = *cutpnt + 1; |
| 3856 |
i__1 = *n - *cutpnt; |
| 3857 |
dcopy_(&i__1, &q[zpp1 + zpp1 * q_dim1], ldq, &work[iz + *cutpnt], &c__1); |
| 3858 |
|
| 3859 |
/* Deflate eigenvalues. */ |
| 3860 |
|
| 3861 |
dlaed2_(&k, n, cutpnt, &d__[1], &q[q_offset], ldq, &indxq[1], rho, &work[ |
| 3862 |
iz], &work[idlmda], &work[iw], &work[iq2], &iwork[indx], &iwork[ |
| 3863 |
indxc], &iwork[indxp], &iwork[coltyp], info); |
| 3864 |
|
| 3865 |
if (*info != 0) { |
| 3866 |
goto L20; |
| 3867 |
} |
| 3868 |
|
| 3869 |
/* Solve Secular Equation. */ |
| 3870 |
|
| 3871 |
if (k != 0) { |
| 3872 |
is = (iwork[coltyp] + iwork[coltyp + 1]) * *cutpnt + (iwork[coltyp + |
| 3873 |
1] + iwork[coltyp + 2]) * (*n - *cutpnt) + iq2; |
| 3874 |
dlaed3_(&k, n, cutpnt, &d__[1], &q[q_offset], ldq, rho, &work[idlmda], |
| 3875 |
&work[iq2], &iwork[indxc], &iwork[coltyp], &work[iw], &work[ |
| 3876 |
is], info); |
| 3877 |
if (*info != 0) { |
| 3878 |
goto L20; |
| 3879 |
} |
| 3880 |
|
| 3881 |
/* Prepare the INDXQ sorting permutation. */ |
| 3882 |
|
| 3883 |
n1 = k; |
| 3884 |
n2 = *n - k; |
| 3885 |
dlamrg_(&n1, &n2, &d__[1], &c__1, &c_n1, &indxq[1]); |
| 3886 |
} else { |
| 3887 |
i__1 = *n; |
| 3888 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 3889 |
indxq[i__] = i__; |
| 3890 |
/* L10: */ |
| 3891 |
} |
| 3892 |
} |
| 3893 |
|
| 3894 |
L20: |
| 3895 |
return 0; |
| 3896 |
|
| 3897 |
/* End of DLAED1 */ |
| 3898 |
|
| 3899 |
} /* dlaed1_ */ |
| 3900 |
|
| 3901 |
/* Subroutine */ int dlaed2_(integer *k, integer *n, integer *n1, double * |
| 3902 |
d__, double *q, integer *ldq, integer *indxq, double *rho, |
| 3903 |
double *z__, double *dlamda, double *w, double *q2, |
| 3904 |
integer *indx, integer *indxc, integer *indxp, integer *coltyp, |
| 3905 |
integer *info) |
| 3906 |
{ |
| 3907 |
/* Table of constant values */ |
| 3908 |
static double c_b3 = -1.; |
| 3909 |
static integer c__1 = 1; |
| 3910 |
|
| 3911 |
/* System generated locals */ |
| 3912 |
integer q_dim1, q_offset, i__1, i__2; |
| 3913 |
double d__1, d__2, d__3, d__4; |
| 3914 |
|
| 3915 |
/* Builtin functions |
| 3916 |
double sqrt(double);*/ |
| 3917 |
|
| 3918 |
/* Local variables */ |
| 3919 |
double c__; |
| 3920 |
integer i__, j; |
| 3921 |
double s, t; |
| 3922 |
integer k2, n2, ct, nj, pj, js, iq1, iq2, n1p1; |
| 3923 |
double eps, tau, tol; |
| 3924 |
integer psm[4], imax, jmax; |
| 3925 |
integer ctot[4]; |
| 3926 |
|
| 3927 |
|
| 3928 |
/* -- LAPACK routine (version 3.1) -- */ |
| 3929 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 3930 |
/* November 2006 */ |
| 3931 |
|
| 3932 |
/* .. Scalar Arguments .. */ |
| 3933 |
/* .. */ |
| 3934 |
/* .. Array Arguments .. */ |
| 3935 |
/* .. */ |
| 3936 |
|
| 3937 |
/* Purpose */ |
| 3938 |
/* ======= */ |
| 3939 |
|
| 3940 |
/* DLAED2 merges the two sets of eigenvalues together into a single */ |
| 3941 |
/* sorted set. Then it tries to deflate the size of the problem. */ |
| 3942 |
/* There are two ways in which deflation can occur: when two or more */ |
| 3943 |
/* eigenvalues are close together or if there is a tiny entry in the */ |
| 3944 |
/* Z vector. For each such occurrence the order of the related secular */ |
| 3945 |
/* equation problem is reduced by one. */ |
| 3946 |
|
| 3947 |
/* Arguments */ |
| 3948 |
/* ========= */ |
| 3949 |
|
| 3950 |
/* K (output) INTEGER */ |
| 3951 |
/* The number of non-deflated eigenvalues, and the order of the */ |
| 3952 |
/* related secular equation. 0 <= K <=N. */ |
| 3953 |
|
| 3954 |
/* N (input) INTEGER */ |
| 3955 |
/* The dimension of the symmetric tridiagonal matrix. N >= 0. */ |
| 3956 |
|
| 3957 |
/* N1 (input) INTEGER */ |
| 3958 |
/* The location of the last eigenvalue in the leading sub-matrix. */ |
| 3959 |
/* min(1,N) <= N1 <= N/2. */ |
| 3960 |
|
| 3961 |
/* D (input/output) DOUBLE PRECISION array, dimension (N) */ |
| 3962 |
/* On entry, D contains the eigenvalues of the two submatrices to */ |
| 3963 |
/* be combined. */ |
| 3964 |
/* On exit, D contains the trailing (N-K) updated eigenvalues */ |
| 3965 |
/* (those which were deflated) sorted into increasing order. */ |
| 3966 |
|
| 3967 |
/* Q (input/output) DOUBLE PRECISION array, dimension (LDQ, N) */ |
| 3968 |
/* On entry, Q contains the eigenvectors of two submatrices in */ |
| 3969 |
/* the two square blocks with corners at (1,1), (N1,N1) */ |
| 3970 |
/* and (N1+1, N1+1), (N,N). */ |
| 3971 |
/* On exit, Q contains the trailing (N-K) updated eigenvectors */ |
| 3972 |
/* (those which were deflated) in its last N-K columns. */ |
| 3973 |
|
| 3974 |
/* LDQ (input) INTEGER */ |
| 3975 |
/* The leading dimension of the array Q. LDQ >= max(1,N). */ |
| 3976 |
|
| 3977 |
/* INDXQ (input/output) INTEGER array, dimension (N) */ |
| 3978 |
/* The permutation which separately sorts the two sub-problems */ |
| 3979 |
/* in D into ascending order. Note that elements in the second */ |
| 3980 |
/* half of this permutation must first have N1 added to their */ |
| 3981 |
/* values. Destroyed on exit. */ |
| 3982 |
|
| 3983 |
/* RHO (input/output) DOUBLE PRECISION */ |
| 3984 |
/* On entry, the off-diagonal element associated with the rank-1 */ |
| 3985 |
/* cut which originally split the two submatrices which are now */ |
| 3986 |
/* being recombined. */ |
| 3987 |
/* On exit, RHO has been modified to the value required by */ |
| 3988 |
/* DLAED3. */ |
| 3989 |
|
| 3990 |
/* Z (input) DOUBLE PRECISION array, dimension (N) */ |
| 3991 |
/* On entry, Z contains the updating vector (the last */ |
| 3992 |
/* row of the first sub-eigenvector matrix and the first row of */ |
| 3993 |
/* the second sub-eigenvector matrix). */ |
| 3994 |
/* On exit, the contents of Z have been destroyed by the updating */ |
| 3995 |
/* process. */ |
| 3996 |
|
| 3997 |
/* DLAMDA (output) DOUBLE PRECISION array, dimension (N) */ |
| 3998 |
/* A copy of the first K eigenvalues which will be used by */ |
| 3999 |
/* DLAED3 to form the secular equation. */ |
| 4000 |
|
| 4001 |
/* W (output) DOUBLE PRECISION array, dimension (N) */ |
| 4002 |
/* The first k values of the final deflation-altered z-vector */ |
| 4003 |
/* which will be passed to DLAED3. */ |
| 4004 |
|
| 4005 |
/* Q2 (output) DOUBLE PRECISION array, dimension (N1**2+(N-N1)**2) */ |
| 4006 |
/* A copy of the first K eigenvectors which will be used by */ |
| 4007 |
/* DLAED3 in a matrix multiply (DGEMM) to solve for the new */ |
| 4008 |
/* eigenvectors. */ |
| 4009 |
|
| 4010 |
/* INDX (workspace) INTEGER array, dimension (N) */ |
| 4011 |
/* The permutation used to sort the contents of DLAMDA into */ |
| 4012 |
/* ascending order. */ |
| 4013 |
|
| 4014 |
/* INDXC (output) INTEGER array, dimension (N) */ |
| 4015 |
/* The permutation used to arrange the columns of the deflated */ |
| 4016 |
/* Q matrix into three groups: the first group contains non-zero */ |
| 4017 |
/* elements only at and above N1, the second contains */ |
| 4018 |
/* non-zero elements only below N1, and the third is dense. */ |
| 4019 |
|
| 4020 |
/* INDXP (workspace) INTEGER array, dimension (N) */ |
| 4021 |
/* The permutation used to place deflated values of D at the end */ |
| 4022 |
/* of the array. INDXP(1:K) points to the nondeflated D-values */ |
| 4023 |
/* and INDXP(K+1:N) points to the deflated eigenvalues. */ |
| 4024 |
|
| 4025 |
/* COLTYP (workspace/output) INTEGER array, dimension (N) */ |
| 4026 |
/* During execution, a label which will indicate which of the */ |
| 4027 |
/* following types a column in the Q2 matrix is: */ |
| 4028 |
/* 1 : non-zero in the upper half only; */ |
| 4029 |
/* 2 : dense; */ |
| 4030 |
/* 3 : non-zero in the lower half only; */ |
| 4031 |
/* 4 : deflated. */ |
| 4032 |
/* On exit, COLTYP(i) is the number of columns of type i, */ |
| 4033 |
/* for i=1 to 4 only. */ |
| 4034 |
|
| 4035 |
/* INFO (output) INTEGER */ |
| 4036 |
/* = 0: successful exit. */ |
| 4037 |
/* < 0: if INFO = -i, the i-th argument had an illegal value. */ |
| 4038 |
|
| 4039 |
/* Further Details */ |
| 4040 |
/* =============== */ |
| 4041 |
|
| 4042 |
/* Based on contributions by */ |
| 4043 |
/* Jeff Rutter, Computer Science Division, University of California */ |
| 4044 |
/* at Berkeley, USA */ |
| 4045 |
/* Modified by Francoise Tisseur, University of Tennessee. */ |
| 4046 |
|
| 4047 |
/* ===================================================================== */ |
| 4048 |
|
| 4049 |
/* .. Parameters .. */ |
| 4050 |
/* .. */ |
| 4051 |
/* .. Local Arrays .. */ |
| 4052 |
/* .. */ |
| 4053 |
/* .. Local Scalars .. */ |
| 4054 |
/* .. */ |
| 4055 |
/* .. External Functions .. */ |
| 4056 |
/* .. */ |
| 4057 |
/* .. External Subroutines .. */ |
| 4058 |
/* .. */ |
| 4059 |
/* .. Intrinsic Functions .. */ |
| 4060 |
/* .. */ |
| 4061 |
/* .. Executable Statements .. */ |
| 4062 |
|
| 4063 |
/* Test the input parameters. */ |
| 4064 |
|
| 4065 |
/* Parameter adjustments */ |
| 4066 |
--d__; |
| 4067 |
q_dim1 = *ldq; |
| 4068 |
q_offset = 1 + q_dim1; |
| 4069 |
q -= q_offset; |
| 4070 |
--indxq; |
| 4071 |
--z__; |
| 4072 |
--dlamda; |
| 4073 |
--w; |
| 4074 |
--q2; |
| 4075 |
--indx; |
| 4076 |
--indxc; |
| 4077 |
--indxp; |
| 4078 |
--coltyp; |
| 4079 |
|
| 4080 |
/* Function Body */ |
| 4081 |
*info = 0; |
| 4082 |
|
| 4083 |
if (*n < 0) { |
| 4084 |
*info = -2; |
| 4085 |
} else if (*ldq < std::max(1_integer,*n)) { |
| 4086 |
*info = -6; |
| 4087 |
} else /* if(complicated condition) */ { |
| 4088 |
/* Computing MIN */ |
| 4089 |
i__1 = 1, i__2 = *n / 2; |
| 4090 |
if (std::min(i__1,i__2) > *n1 || *n / 2 < *n1) { |
| 4091 |
*info = -3; |
| 4092 |
} |
| 4093 |
} |
| 4094 |
if (*info != 0) { |
| 4095 |
i__1 = -(*info); |
| 4096 |
xerbla_("DLAED2", &i__1); |
| 4097 |
return 0; |
| 4098 |
} |
| 4099 |
|
| 4100 |
/* Quick return if possible */ |
| 4101 |
|
| 4102 |
if (*n == 0) { |
| 4103 |
return 0; |
| 4104 |
} |
| 4105 |
|
| 4106 |
n2 = *n - *n1; |
| 4107 |
n1p1 = *n1 + 1; |
| 4108 |
|
| 4109 |
if (*rho < 0.) { |
| 4110 |
dscal_(&n2, &c_b3, &z__[n1p1], &c__1); |
| 4111 |
} |
| 4112 |
|
| 4113 |
/* Normalize z so that norm(z) = 1. Since z is the concatenation of */ |
| 4114 |
/* two normalized vectors, norm2(z) = sqrt(2). */ |
| 4115 |
|
| 4116 |
t = 1. / sqrt(2.); |
| 4117 |
dscal_(n, &t, &z__[1], &c__1); |
| 4118 |
|
| 4119 |
/* RHO = ABS( norm(z)**2 * RHO ) */ |
| 4120 |
|
| 4121 |
*rho = (d__1 = *rho * 2., abs(d__1)); |
| 4122 |
|
| 4123 |
/* Sort the eigenvalues into increasing order */ |
| 4124 |
|
| 4125 |
i__1 = *n; |
| 4126 |
for (i__ = n1p1; i__ <= i__1; ++i__) { |
| 4127 |
indxq[i__] += *n1; |
| 4128 |
/* L10: */ |
| 4129 |
} |
| 4130 |
|
| 4131 |
/* re-integrate the deflated parts from the last pass */ |
| 4132 |
|
| 4133 |
i__1 = *n; |
| 4134 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 4135 |
dlamda[i__] = d__[indxq[i__]]; |
| 4136 |
/* L20: */ |
| 4137 |
} |
| 4138 |
dlamrg_(n1, &n2, &dlamda[1], &c__1, &c__1, &indxc[1]); |
| 4139 |
i__1 = *n; |
| 4140 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 4141 |
indx[i__] = indxq[indxc[i__]]; |
| 4142 |
/* L30: */ |
| 4143 |
} |
| 4144 |
|
| 4145 |
/* Calculate the allowable deflation tolerance */ |
| 4146 |
|
| 4147 |
imax = idamax_(n, &z__[1], &c__1); |
| 4148 |
jmax = idamax_(n, &d__[1], &c__1); |
| 4149 |
eps = dlamch_("Epsilon"); |
| 4150 |
/* Computing MAX */ |
| 4151 |
d__3 = (d__1 = d__[jmax], abs(d__1)), d__4 = (d__2 = z__[imax], abs(d__2)) |
| 4152 |
; |
| 4153 |
tol = eps * 8. * std::max(d__3,d__4); |
| 4154 |
|
| 4155 |
/* If the rank-1 modifier is small enough, no more needs to be done */ |
| 4156 |
/* except to reorganize Q so that its columns correspond with the */ |
| 4157 |
/* elements in D. */ |
| 4158 |
|
| 4159 |
if (*rho * (d__1 = z__[imax], abs(d__1)) <= tol) { |
| 4160 |
*k = 0; |
| 4161 |
iq2 = 1; |
| 4162 |
i__1 = *n; |
| 4163 |
for (j = 1; j <= i__1; ++j) { |
| 4164 |
i__ = indx[j]; |
| 4165 |
dcopy_(n, &q[i__ * q_dim1 + 1], &c__1, &q2[iq2], &c__1); |
| 4166 |
dlamda[j] = d__[i__]; |
| 4167 |
iq2 += *n; |
| 4168 |
/* L40: */ |
| 4169 |
} |
| 4170 |
dlacpy_("A", n, n, &q2[1], n, &q[q_offset], ldq); |
| 4171 |
dcopy_(n, &dlamda[1], &c__1, &d__[1], &c__1); |
| 4172 |
goto L190; |
| 4173 |
} |
| 4174 |
|
| 4175 |
/* If there are multiple eigenvalues then the problem deflates. Here */ |
| 4176 |
/* the number of equal eigenvalues are found. As each equal */ |
| 4177 |
/* eigenvalue is found, an elementary reflector is computed to rotate */ |
| 4178 |
/* the corresponding eigensubspace so that the corresponding */ |
| 4179 |
/* components of Z are zero in this new basis. */ |
| 4180 |
|
| 4181 |
i__1 = *n1; |
| 4182 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 4183 |
coltyp[i__] = 1; |
| 4184 |
/* L50: */ |
| 4185 |
} |
| 4186 |
i__1 = *n; |
| 4187 |
for (i__ = n1p1; i__ <= i__1; ++i__) { |
| 4188 |
coltyp[i__] = 3; |
| 4189 |
/* L60: */ |
| 4190 |
} |
| 4191 |
|
| 4192 |
|
| 4193 |
*k = 0; |
| 4194 |
k2 = *n + 1; |
| 4195 |
i__1 = *n; |
| 4196 |
for (j = 1; j <= i__1; ++j) { |
| 4197 |
nj = indx[j]; |
| 4198 |
if (*rho * (d__1 = z__[nj], abs(d__1)) <= tol) { |
| 4199 |
|
| 4200 |
/* Deflate due to small z component. */ |
| 4201 |
|
| 4202 |
--k2; |
| 4203 |
coltyp[nj] = 4; |
| 4204 |
indxp[k2] = nj; |
| 4205 |
if (j == *n) { |
| 4206 |
goto L100; |
| 4207 |
} |
| 4208 |
} else { |
| 4209 |
pj = nj; |
| 4210 |
goto L80; |
| 4211 |
} |
| 4212 |
/* L70: */ |
| 4213 |
} |
| 4214 |
L80: |
| 4215 |
++j; |
| 4216 |
nj = indx[j]; |
| 4217 |
if (j > *n) { |
| 4218 |
goto L100; |
| 4219 |
} |
| 4220 |
if (*rho * (d__1 = z__[nj], abs(d__1)) <= tol) { |
| 4221 |
|
| 4222 |
/* Deflate due to small z component. */ |
| 4223 |
|
| 4224 |
--k2; |
| 4225 |
coltyp[nj] = 4; |
| 4226 |
indxp[k2] = nj; |
| 4227 |
} else { |
| 4228 |
|
| 4229 |
/* Check if eigenvalues are close enough to allow deflation. */ |
| 4230 |
|
| 4231 |
s = z__[pj]; |
| 4232 |
c__ = z__[nj]; |
| 4233 |
|
| 4234 |
/* Find sqrt(a**2+b**2) without overflow or */ |
| 4235 |
/* destructive underflow. */ |
| 4236 |
|
| 4237 |
tau = dlapy2_(&c__, &s); |
| 4238 |
t = d__[nj] - d__[pj]; |
| 4239 |
c__ /= tau; |
| 4240 |
s = -s / tau; |
| 4241 |
if ((d__1 = t * c__ * s, abs(d__1)) <= tol) { |
| 4242 |
|
| 4243 |
/* Deflation is possible. */ |
| 4244 |
|
| 4245 |
z__[nj] = tau; |
| 4246 |
z__[pj] = 0.; |
| 4247 |
if (coltyp[nj] != coltyp[pj]) { |
| 4248 |
coltyp[nj] = 2; |
| 4249 |
} |
| 4250 |
coltyp[pj] = 4; |
| 4251 |
drot_(n, &q[pj * q_dim1 + 1], &c__1, &q[nj * q_dim1 + 1], &c__1, & |
| 4252 |
c__, &s); |
| 4253 |
/* Computing 2nd power */ |
| 4254 |
d__1 = c__; |
| 4255 |
/* Computing 2nd power */ |
| 4256 |
d__2 = s; |
| 4257 |
t = d__[pj] * (d__1 * d__1) + d__[nj] * (d__2 * d__2); |
| 4258 |
/* Computing 2nd power */ |
| 4259 |
d__1 = s; |
| 4260 |
/* Computing 2nd power */ |
| 4261 |
d__2 = c__; |
| 4262 |
d__[nj] = d__[pj] * (d__1 * d__1) + d__[nj] * (d__2 * d__2); |
| 4263 |
d__[pj] = t; |
| 4264 |
--k2; |
| 4265 |
i__ = 1; |
| 4266 |
L90: |
| 4267 |
if (k2 + i__ <= *n) { |
| 4268 |
if (d__[pj] < d__[indxp[k2 + i__]]) { |
| 4269 |
indxp[k2 + i__ - 1] = indxp[k2 + i__]; |
| 4270 |
indxp[k2 + i__] = pj; |
| 4271 |
++i__; |
| 4272 |
goto L90; |
| 4273 |
} else { |
| 4274 |
indxp[k2 + i__ - 1] = pj; |
| 4275 |
} |
| 4276 |
} else { |
| 4277 |
indxp[k2 + i__ - 1] = pj; |
| 4278 |
} |
| 4279 |
pj = nj; |
| 4280 |
} else { |
| 4281 |
++(*k); |
| 4282 |
dlamda[*k] = d__[pj]; |
| 4283 |
w[*k] = z__[pj]; |
| 4284 |
indxp[*k] = pj; |
| 4285 |
pj = nj; |
| 4286 |
} |
| 4287 |
} |
| 4288 |
goto L80; |
| 4289 |
L100: |
| 4290 |
|
| 4291 |
/* Record the last eigenvalue. */ |
| 4292 |
|
| 4293 |
++(*k); |
| 4294 |
dlamda[*k] = d__[pj]; |
| 4295 |
w[*k] = z__[pj]; |
| 4296 |
indxp[*k] = pj; |
| 4297 |
|
| 4298 |
/* Count up the total number of the various types of columns, then */ |
| 4299 |
/* form a permutation which positions the four column types into */ |
| 4300 |
/* four uniform groups (although one or more of these groups may be */ |
| 4301 |
/* empty). */ |
| 4302 |
|
| 4303 |
for (j = 1; j <= 4; ++j) { |
| 4304 |
ctot[j - 1] = 0; |
| 4305 |
/* L110: */ |
| 4306 |
} |
| 4307 |
i__1 = *n; |
| 4308 |
for (j = 1; j <= i__1; ++j) { |
| 4309 |
ct = coltyp[j]; |
| 4310 |
++ctot[ct - 1]; |
| 4311 |
/* L120: */ |
| 4312 |
} |
| 4313 |
|
| 4314 |
/* PSM(*) = Position in SubMatrix (of types 1 through 4) */ |
| 4315 |
|
| 4316 |
psm[0] = 1; |
| 4317 |
psm[1] = ctot[0] + 1; |
| 4318 |
psm[2] = psm[1] + ctot[1]; |
| 4319 |
psm[3] = psm[2] + ctot[2]; |
| 4320 |
*k = *n - ctot[3]; |
| 4321 |
|
| 4322 |
/* Fill out the INDXC array so that the permutation which it induces */ |
| 4323 |
/* will place all type-1 columns first, all type-2 columns next, */ |
| 4324 |
/* then all type-3's, and finally all type-4's. */ |
| 4325 |
|
| 4326 |
i__1 = *n; |
| 4327 |
for (j = 1; j <= i__1; ++j) { |
| 4328 |
js = indxp[j]; |
| 4329 |
ct = coltyp[js]; |
| 4330 |
indx[psm[ct - 1]] = js; |
| 4331 |
indxc[psm[ct - 1]] = j; |
| 4332 |
++psm[ct - 1]; |
| 4333 |
/* L130: */ |
| 4334 |
} |
| 4335 |
|
| 4336 |
/* Sort the eigenvalues and corresponding eigenvectors into DLAMDA */ |
| 4337 |
/* and Q2 respectively. The eigenvalues/vectors which were not */ |
| 4338 |
/* deflated go into the first K slots of DLAMDA and Q2 respectively, */ |
| 4339 |
/* while those which were deflated go into the last N - K slots. */ |
| 4340 |
|
| 4341 |
i__ = 1; |
| 4342 |
iq1 = 1; |
| 4343 |
iq2 = (ctot[0] + ctot[1]) * *n1 + 1; |
| 4344 |
i__1 = ctot[0]; |
| 4345 |
for (j = 1; j <= i__1; ++j) { |
| 4346 |
js = indx[i__]; |
| 4347 |
dcopy_(n1, &q[js * q_dim1 + 1], &c__1, &q2[iq1], &c__1); |
| 4348 |
z__[i__] = d__[js]; |
| 4349 |
++i__; |
| 4350 |
iq1 += *n1; |
| 4351 |
/* L140: */ |
| 4352 |
} |
| 4353 |
|
| 4354 |
i__1 = ctot[1]; |
| 4355 |
for (j = 1; j <= i__1; ++j) { |
| 4356 |
js = indx[i__]; |
| 4357 |
dcopy_(n1, &q[js * q_dim1 + 1], &c__1, &q2[iq1], &c__1); |
| 4358 |
dcopy_(&n2, &q[*n1 + 1 + js * q_dim1], &c__1, &q2[iq2], &c__1); |
| 4359 |
z__[i__] = d__[js]; |
| 4360 |
++i__; |
| 4361 |
iq1 += *n1; |
| 4362 |
iq2 += n2; |
| 4363 |
/* L150: */ |
| 4364 |
} |
| 4365 |
|
| 4366 |
i__1 = ctot[2]; |
| 4367 |
for (j = 1; j <= i__1; ++j) { |
| 4368 |
js = indx[i__]; |
| 4369 |
dcopy_(&n2, &q[*n1 + 1 + js * q_dim1], &c__1, &q2[iq2], &c__1); |
| 4370 |
z__[i__] = d__[js]; |
| 4371 |
++i__; |
| 4372 |
iq2 += n2; |
| 4373 |
/* L160: */ |
| 4374 |
} |
| 4375 |
|
| 4376 |
iq1 = iq2; |
| 4377 |
i__1 = ctot[3]; |
| 4378 |
for (j = 1; j <= i__1; ++j) { |
| 4379 |
js = indx[i__]; |
| 4380 |
dcopy_(n, &q[js * q_dim1 + 1], &c__1, &q2[iq2], &c__1); |
| 4381 |
iq2 += *n; |
| 4382 |
z__[i__] = d__[js]; |
| 4383 |
++i__; |
| 4384 |
/* L170: */ |
| 4385 |
} |
| 4386 |
|
| 4387 |
/* The deflated eigenvalues and their corresponding vectors go back */ |
| 4388 |
/* into the last N - K slots of D and Q respectively. */ |
| 4389 |
|
| 4390 |
dlacpy_("A", n, &ctot[3], &q2[iq1], n, &q[(*k + 1) * q_dim1 + 1], ldq); |
| 4391 |
i__1 = *n - *k; |
| 4392 |
dcopy_(&i__1, &z__[*k + 1], &c__1, &d__[*k + 1], &c__1); |
| 4393 |
|
| 4394 |
/* Copy CTOT into COLTYP for referencing in DLAED3. */ |
| 4395 |
|
| 4396 |
for (j = 1; j <= 4; ++j) { |
| 4397 |
coltyp[j] = ctot[j - 1]; |
| 4398 |
/* L180: */ |
| 4399 |
} |
| 4400 |
|
| 4401 |
L190: |
| 4402 |
return 0; |
| 4403 |
|
| 4404 |
/* End of DLAED2 */ |
| 4405 |
|
| 4406 |
} /* dlaed2_ */ |
| 4407 |
|
| 4408 |
/* Subroutine */ int dlaed3_(integer *k, integer *n, integer *n1, double * |
| 4409 |
d__, double *q, integer *ldq, double *rho, double *dlamda, |
| 4410 |
double *q2, integer *indx, integer *ctot, double *w, |
| 4411 |
double *s, integer *info) |
| 4412 |
{ |
| 4413 |
/* Table of constant values */ |
| 4414 |
static integer c__1 = 1; |
| 4415 |
static double c_b22 = 1.; |
| 4416 |
static double c_b23 = 0.; |
| 4417 |
|
| 4418 |
/* System generated locals */ |
| 4419 |
integer q_dim1, q_offset, i__1, i__2; |
| 4420 |
double d__1; |
| 4421 |
|
| 4422 |
/* Builtin functions |
| 4423 |
double sqrt(double), d_sign(double *, double *);*/ |
| 4424 |
|
| 4425 |
/* Local variables */ |
| 4426 |
integer i__, j, n2, n12, ii, n23, iq2; |
| 4427 |
double temp; |
| 4428 |
|
| 4429 |
/* -- LAPACK routine (version 3.1) -- */ |
| 4430 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 4431 |
/* November 2006 */ |
| 4432 |
|
| 4433 |
/* .. Scalar Arguments .. */ |
| 4434 |
/* .. */ |
| 4435 |
/* .. Array Arguments .. */ |
| 4436 |
/* .. */ |
| 4437 |
|
| 4438 |
/* Purpose */ |
| 4439 |
/* ======= */ |
| 4440 |
|
| 4441 |
/* DLAED3 finds the roots of the secular equation, as defined by the */ |
| 4442 |
/* values in D, W, and RHO, between 1 and K. It makes the */ |
| 4443 |
/* appropriate calls to DLAED4 and then updates the eigenvectors by */ |
| 4444 |
/* multiplying the matrix of eigenvectors of the pair of eigensystems */ |
| 4445 |
/* being combined by the matrix of eigenvectors of the K-by-K system */ |
| 4446 |
/* which is solved here. */ |
| 4447 |
|
| 4448 |
/* This code makes very mild assumptions about floating point */ |
| 4449 |
/* arithmetic. It will work on machines with a guard digit in */ |
| 4450 |
/* add/subtract, or on those binary machines without guard digits */ |
| 4451 |
/* which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or Cray-2. */ |
| 4452 |
/* It could conceivably fail on hexadecimal or decimal machines */ |
| 4453 |
/* without guard digits, but we know of none. */ |
| 4454 |
|
| 4455 |
/* Arguments */ |
| 4456 |
/* ========= */ |
| 4457 |
|
| 4458 |
/* K (input) INTEGER */ |
| 4459 |
/* The number of terms in the rational function to be solved by */ |
| 4460 |
/* DLAED4. K >= 0. */ |
| 4461 |
|
| 4462 |
/* N (input) INTEGER */ |
| 4463 |
/* The number of rows and columns in the Q matrix. */ |
| 4464 |
/* N >= K (deflation may result in N>K). */ |
| 4465 |
|
| 4466 |
/* N1 (input) INTEGER */ |
| 4467 |
/* The location of the last eigenvalue in the leading submatrix. */ |
| 4468 |
/* min(1,N) <= N1 <= N/2. */ |
| 4469 |
|
| 4470 |
/* D (output) DOUBLE PRECISION array, dimension (N) */ |
| 4471 |
/* D(I) contains the updated eigenvalues for */ |
| 4472 |
/* 1 <= I <= K. */ |
| 4473 |
|
| 4474 |
/* Q (output) DOUBLE PRECISION array, dimension (LDQ,N) */ |
| 4475 |
/* Initially the first K columns are used as workspace. */ |
| 4476 |
/* On output the columns 1 to K contain */ |
| 4477 |
/* the updated eigenvectors. */ |
| 4478 |
|
| 4479 |
/* LDQ (input) INTEGER */ |
| 4480 |
/* The leading dimension of the array Q. LDQ >= max(1,N). */ |
| 4481 |
|
| 4482 |
/* RHO (input) DOUBLE PRECISION */ |
| 4483 |
/* The value of the parameter in the rank one update equation. */ |
| 4484 |
/* RHO >= 0 required. */ |
| 4485 |
|
| 4486 |
/* DLAMDA (input/output) DOUBLE PRECISION array, dimension (K) */ |
| 4487 |
/* The first K elements of this array contain the old roots */ |
| 4488 |
/* of the deflated updating problem. These are the poles */ |
| 4489 |
/* of the secular equation. May be changed on output by */ |
| 4490 |
/* having lowest order bit set to zero on Cray X-MP, Cray Y-MP, */ |
| 4491 |
/* Cray-2, or Cray C-90, as described above. */ |
| 4492 |
|
| 4493 |
/* Q2 (input) DOUBLE PRECISION array, dimension (LDQ2, N) */ |
| 4494 |
/* The first K columns of this matrix contain the non-deflated */ |
| 4495 |
/* eigenvectors for the split problem. */ |
| 4496 |
|
| 4497 |
/* INDX (input) INTEGER array, dimension (N) */ |
| 4498 |
/* The permutation used to arrange the columns of the deflated */ |
| 4499 |
/* Q matrix into three groups (see DLAED2). */ |
| 4500 |
/* The rows of the eigenvectors found by DLAED4 must be likewise */ |
| 4501 |
/* permuted before the matrix multiply can take place. */ |
| 4502 |
|
| 4503 |
/* CTOT (input) INTEGER array, dimension (4) */ |
| 4504 |
/* A count of the total number of the various types of columns */ |
| 4505 |
/* in Q, as described in INDX. The fourth column type is any */ |
| 4506 |
/* column which has been deflated. */ |
| 4507 |
|
| 4508 |
/* W (input/output) DOUBLE PRECISION array, dimension (K) */ |
| 4509 |
/* The first K elements of this array contain the components */ |
| 4510 |
/* of the deflation-adjusted updating vector. Destroyed on */ |
| 4511 |
/* output. */ |
| 4512 |
|
| 4513 |
/* S (workspace) DOUBLE PRECISION array, dimension (N1 + 1)*K */ |
| 4514 |
/* Will contain the eigenvectors of the repaired matrix which */ |
| 4515 |
/* will be multiplied by the previously accumulated eigenvectors */ |
| 4516 |
/* to update the system. */ |
| 4517 |
|
| 4518 |
/* LDS (input) INTEGER */ |
| 4519 |
/* The leading dimension of S. LDS >= max(1,K). */ |
| 4520 |
|
| 4521 |
/* INFO (output) INTEGER */ |
| 4522 |
/* = 0: successful exit. */ |
| 4523 |
/* < 0: if INFO = -i, the i-th argument had an illegal value. */ |
| 4524 |
/* > 0: if INFO = 1, an eigenvalue did not converge */ |
| 4525 |
|
| 4526 |
/* Further Details */ |
| 4527 |
/* =============== */ |
| 4528 |
|
| 4529 |
/* Based on contributions by */ |
| 4530 |
/* Jeff Rutter, Computer Science Division, University of California */ |
| 4531 |
/* at Berkeley, USA */ |
| 4532 |
/* Modified by Francoise Tisseur, University of Tennessee. */ |
| 4533 |
|
| 4534 |
/* ===================================================================== */ |
| 4535 |
|
| 4536 |
/* .. Parameters .. */ |
| 4537 |
/* .. */ |
| 4538 |
/* .. Local Scalars .. */ |
| 4539 |
/* .. */ |
| 4540 |
/* .. External Functions .. */ |
| 4541 |
/* .. */ |
| 4542 |
/* .. External Subroutines .. */ |
| 4543 |
/* .. */ |
| 4544 |
/* .. Intrinsic Functions .. */ |
| 4545 |
/* .. */ |
| 4546 |
/* .. Executable Statements .. */ |
| 4547 |
|
| 4548 |
/* Test the input parameters. */ |
| 4549 |
|
| 4550 |
/* Parameter adjustments */ |
| 4551 |
--d__; |
| 4552 |
q_dim1 = *ldq; |
| 4553 |
q_offset = 1 + q_dim1; |
| 4554 |
q -= q_offset; |
| 4555 |
--dlamda; |
| 4556 |
--q2; |
| 4557 |
--indx; |
| 4558 |
--ctot; |
| 4559 |
--w; |
| 4560 |
--s; |
| 4561 |
|
| 4562 |
/* Function Body */ |
| 4563 |
*info = 0; |
| 4564 |
|
| 4565 |
if (*k < 0) { |
| 4566 |
*info = -1; |
| 4567 |
} else if (*n < *k) { |
| 4568 |
*info = -2; |
| 4569 |
} else if (*ldq < std::max(1_integer,*n)) { |
| 4570 |
*info = -6; |
| 4571 |
} |
| 4572 |
if (*info != 0) { |
| 4573 |
i__1 = -(*info); |
| 4574 |
xerbla_("DLAED3", &i__1); |
| 4575 |
return 0; |
| 4576 |
} |
| 4577 |
|
| 4578 |
/* Quick return if possible */ |
| 4579 |
|
| 4580 |
if (*k == 0) { |
| 4581 |
return 0; |
| 4582 |
} |
| 4583 |
|
| 4584 |
/* Modify values DLAMDA(i) to make sure all DLAMDA(i)-DLAMDA(j) can */ |
| 4585 |
/* be computed with high relative accuracy (barring over/underflow). */ |
| 4586 |
/* This is a problem on machines without a guard digit in */ |
| 4587 |
/* add/subtract (Cray XMP, Cray YMP, Cray C 90 and Cray 2). */ |
| 4588 |
/* The following code replaces DLAMDA(I) by 2*DLAMDA(I)-DLAMDA(I), */ |
| 4589 |
/* which on any of these machines zeros out the bottommost */ |
| 4590 |
/* bit of DLAMDA(I) if it is 1; this makes the subsequent */ |
| 4591 |
/* subtractions DLAMDA(I)-DLAMDA(J) unproblematic when cancellation */ |
| 4592 |
/* occurs. On binary machines with a guard digit (almost all */ |
| 4593 |
/* machines) it does not change DLAMDA(I) at all. On hexadecimal */ |
| 4594 |
/* and decimal machines with a guard digit, it slightly */ |
| 4595 |
/* changes the bottommost bits of DLAMDA(I). It does not account */ |
| 4596 |
/* for hexadecimal or decimal machines without guard digits */ |
| 4597 |
/* (we know of none). We use a subroutine call to compute */ |
| 4598 |
/* 2*DLAMBDA(I) to prevent optimizing compilers from eliminating */ |
| 4599 |
/* this code. */ |
| 4600 |
|
| 4601 |
i__1 = *k; |
| 4602 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 4603 |
dlamda[i__] = dlamc3_(&dlamda[i__], &dlamda[i__]) - dlamda[i__]; |
| 4604 |
/* L10: */ |
| 4605 |
} |
| 4606 |
|
| 4607 |
i__1 = *k; |
| 4608 |
for (j = 1; j <= i__1; ++j) { |
| 4609 |
dlaed4_(k, &j, &dlamda[1], &w[1], &q[j * q_dim1 + 1], rho, &d__[j], |
| 4610 |
info); |
| 4611 |
|
| 4612 |
/* If the zero finder fails, the computation is terminated. */ |
| 4613 |
|
| 4614 |
if (*info != 0) { |
| 4615 |
goto L120; |
| 4616 |
} |
| 4617 |
/* L20: */ |
| 4618 |
} |
| 4619 |
|
| 4620 |
if (*k == 1) { |
| 4621 |
goto L110; |
| 4622 |
} |
| 4623 |
if (*k == 2) { |
| 4624 |
i__1 = *k; |
| 4625 |
for (j = 1; j <= i__1; ++j) { |
| 4626 |
w[1] = q[j * q_dim1 + 1]; |
| 4627 |
w[2] = q[j * q_dim1 + 2]; |
| 4628 |
ii = indx[1]; |
| 4629 |
q[j * q_dim1 + 1] = w[ii]; |
| 4630 |
ii = indx[2]; |
| 4631 |
q[j * q_dim1 + 2] = w[ii]; |
| 4632 |
/* L30: */ |
| 4633 |
} |
| 4634 |
goto L110; |
| 4635 |
} |
| 4636 |
|
| 4637 |
/* Compute updated W. */ |
| 4638 |
|
| 4639 |
dcopy_(k, &w[1], &c__1, &s[1], &c__1); |
| 4640 |
|
| 4641 |
/* Initialize W(I) = Q(I,I) */ |
| 4642 |
|
| 4643 |
i__1 = *ldq + 1; |
| 4644 |
dcopy_(k, &q[q_offset], &i__1, &w[1], &c__1); |
| 4645 |
i__1 = *k; |
| 4646 |
for (j = 1; j <= i__1; ++j) { |
| 4647 |
i__2 = j - 1; |
| 4648 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 4649 |
w[i__] *= q[i__ + j * q_dim1] / (dlamda[i__] - dlamda[j]); |
| 4650 |
/* L40: */ |
| 4651 |
} |
| 4652 |
i__2 = *k; |
| 4653 |
for (i__ = j + 1; i__ <= i__2; ++i__) { |
| 4654 |
w[i__] *= q[i__ + j * q_dim1] / (dlamda[i__] - dlamda[j]); |
| 4655 |
/* L50: */ |
| 4656 |
} |
| 4657 |
/* L60: */ |
| 4658 |
} |
| 4659 |
i__1 = *k; |
| 4660 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 4661 |
d__1 = sqrt(-w[i__]); |
| 4662 |
w[i__] = d_sign(&d__1, &s[i__]); |
| 4663 |
/* L70: */ |
| 4664 |
} |
| 4665 |
|
| 4666 |
/* Compute eigenvectors of the modified rank-1 modification. */ |
| 4667 |
|
| 4668 |
i__1 = *k; |
| 4669 |
for (j = 1; j <= i__1; ++j) { |
| 4670 |
i__2 = *k; |
| 4671 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 4672 |
s[i__] = w[i__] / q[i__ + j * q_dim1]; |
| 4673 |
/* L80: */ |
| 4674 |
} |
| 4675 |
temp = dnrm2_(k, &s[1], &c__1); |
| 4676 |
i__2 = *k; |
| 4677 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 4678 |
ii = indx[i__]; |
| 4679 |
q[i__ + j * q_dim1] = s[ii] / temp; |
| 4680 |
/* L90: */ |
| 4681 |
} |
| 4682 |
/* L100: */ |
| 4683 |
} |
| 4684 |
|
| 4685 |
/* Compute the updated eigenvectors. */ |
| 4686 |
|
| 4687 |
L110: |
| 4688 |
|
| 4689 |
n2 = *n - *n1; |
| 4690 |
n12 = ctot[1] + ctot[2]; |
| 4691 |
n23 = ctot[2] + ctot[3]; |
| 4692 |
|
| 4693 |
dlacpy_("A", &n23, k, &q[ctot[1] + 1 + q_dim1], ldq, &s[1], &n23); |
| 4694 |
iq2 = *n1 * n12 + 1; |
| 4695 |
if (n23 != 0) { |
| 4696 |
dgemm_("N", "N", &n2, k, &n23, &c_b22, &q2[iq2], &n2, &s[1], &n23, & |
| 4697 |
c_b23, &q[*n1 + 1 + q_dim1], ldq); |
| 4698 |
} else { |
| 4699 |
dlaset_("A", &n2, k, &c_b23, &c_b23, &q[*n1 + 1 + q_dim1], ldq); |
| 4700 |
} |
| 4701 |
|
| 4702 |
dlacpy_("A", &n12, k, &q[q_offset], ldq, &s[1], &n12); |
| 4703 |
if (n12 != 0) { |
| 4704 |
dgemm_("N", "N", n1, k, &n12, &c_b22, &q2[1], n1, &s[1], &n12, &c_b23, |
| 4705 |
&q[q_offset], ldq); |
| 4706 |
} else { |
| 4707 |
dlaset_("A", n1, k, &c_b23, &c_b23, &q[q_dim1 + 1], ldq); |
| 4708 |
} |
| 4709 |
|
| 4710 |
|
| 4711 |
L120: |
| 4712 |
return 0; |
| 4713 |
|
| 4714 |
/* End of DLAED3 */ |
| 4715 |
|
| 4716 |
} /* dlaed3_ */ |
| 4717 |
|
| 4718 |
/* Subroutine */ int dlaed4_(integer *n, integer *i__, double *d__, |
| 4719 |
double *z__, double *delta, double *rho, double *dlam, |
| 4720 |
integer *info) |
| 4721 |
{ |
| 4722 |
/* System generated locals */ |
| 4723 |
integer i__1; |
| 4724 |
double d__1; |
| 4725 |
|
| 4726 |
/* Local variables */ |
| 4727 |
double a, b, c__; |
| 4728 |
integer j; |
| 4729 |
double w; |
| 4730 |
integer ii; |
| 4731 |
double dw, zz[3]; |
| 4732 |
integer ip1; |
| 4733 |
double del, eta, phi, eps, tau, psi; |
| 4734 |
integer iim1, iip1; |
| 4735 |
double dphi, dpsi; |
| 4736 |
integer iter; |
| 4737 |
double temp, prew, temp1, dltlb, dltub, midpt; |
| 4738 |
integer niter; |
| 4739 |
bool swtch; |
| 4740 |
bool swtch3; |
| 4741 |
bool orgati; |
| 4742 |
double erretm, rhoinv; |
| 4743 |
|
| 4744 |
|
| 4745 |
/* -- LAPACK routine (version 3.1) -- */ |
| 4746 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 4747 |
/* November 2006 */ |
| 4748 |
|
| 4749 |
/* .. Scalar Arguments .. */ |
| 4750 |
/* .. */ |
| 4751 |
/* .. Array Arguments .. */ |
| 4752 |
/* .. */ |
| 4753 |
|
| 4754 |
/* Purpose */ |
| 4755 |
/* ======= */ |
| 4756 |
|
| 4757 |
/* This subroutine computes the I-th updated eigenvalue of a symmetric */ |
| 4758 |
/* rank-one modification to a diagonal matrix whose elements are */ |
| 4759 |
/* given in the array d, and that */ |
| 4760 |
|
| 4761 |
/* D(i) < D(j) for i < j */ |
| 4762 |
|
| 4763 |
/* and that RHO > 0. This is arranged by the calling routine, and is */ |
| 4764 |
/* no loss in generality. The rank-one modified system is thus */ |
| 4765 |
|
| 4766 |
/* diag( D ) + RHO * Z * Z_transpose. */ |
| 4767 |
|
| 4768 |
/* where we assume the Euclidean norm of Z is 1. */ |
| 4769 |
|
| 4770 |
/* The method consists of approximating the rational functions in the */ |
| 4771 |
/* secular equation by simpler interpolating rational functions. */ |
| 4772 |
|
| 4773 |
/* Arguments */ |
| 4774 |
/* ========= */ |
| 4775 |
|
| 4776 |
/* N (input) INTEGER */ |
| 4777 |
/* The length of all arrays. */ |
| 4778 |
|
| 4779 |
/* I (input) INTEGER */ |
| 4780 |
/* The index of the eigenvalue to be computed. 1 <= I <= N. */ |
| 4781 |
|
| 4782 |
/* D (input) DOUBLE PRECISION array, dimension (N) */ |
| 4783 |
/* The original eigenvalues. It is assumed that they are in */ |
| 4784 |
/* order, D(I) < D(J) for I < J. */ |
| 4785 |
|
| 4786 |
/* Z (input) DOUBLE PRECISION array, dimension (N) */ |
| 4787 |
/* The components of the updating vector. */ |
| 4788 |
|
| 4789 |
/* DELTA (output) DOUBLE PRECISION array, dimension (N) */ |
| 4790 |
/* If N .GT. 2, DELTA contains (D(j) - lambda_I) in its j-th */ |
| 4791 |
/* component. If N = 1, then DELTA(1) = 1. If N = 2, see DLAED5 */ |
| 4792 |
/* for detail. The vector DELTA contains the information necessary */ |
| 4793 |
/* to construct the eigenvectors by DLAED3 and DLAED9. */ |
| 4794 |
|
| 4795 |
/* RHO (input) DOUBLE PRECISION */ |
| 4796 |
/* The scalar in the symmetric updating formula. */ |
| 4797 |
|
| 4798 |
/* DLAM (output) DOUBLE PRECISION */ |
| 4799 |
/* The computed lambda_I, the I-th updated eigenvalue. */ |
| 4800 |
|
| 4801 |
/* INFO (output) INTEGER */ |
| 4802 |
/* = 0: successful exit */ |
| 4803 |
/* > 0: if INFO = 1, the updating process failed. */ |
| 4804 |
|
| 4805 |
/* Internal Parameters */ |
| 4806 |
/* =================== */ |
| 4807 |
|
| 4808 |
/* Logical variable ORGATI (origin-at-i?) is used for distinguishing */ |
| 4809 |
/* whether D(i) or D(i+1) is treated as the origin. */ |
| 4810 |
|
| 4811 |
/* ORGATI = .true. origin at i */ |
| 4812 |
/* ORGATI = .false. origin at i+1 */ |
| 4813 |
|
| 4814 |
/* Logical variable SWTCH3 (switch-for-3-poles?) is for noting */ |
| 4815 |
/* if we are working with THREE poles! */ |
| 4816 |
|
| 4817 |
/* MAXIT is the maximum number of iterations allowed for each */ |
| 4818 |
/* eigenvalue. */ |
| 4819 |
|
| 4820 |
/* Further Details */ |
| 4821 |
/* =============== */ |
| 4822 |
|
| 4823 |
/* Based on contributions by */ |
| 4824 |
/* Ren-Cang Li, Computer Science Division, University of California */ |
| 4825 |
/* at Berkeley, USA */ |
| 4826 |
|
| 4827 |
/* ===================================================================== */ |
| 4828 |
|
| 4829 |
/* .. Parameters .. */ |
| 4830 |
/* .. */ |
| 4831 |
/* .. Local Scalars .. */ |
| 4832 |
/* .. */ |
| 4833 |
/* .. Local Arrays .. */ |
| 4834 |
/* .. */ |
| 4835 |
/* .. External Functions .. */ |
| 4836 |
/* .. */ |
| 4837 |
/* .. External Subroutines .. */ |
| 4838 |
/* .. */ |
| 4839 |
/* .. Intrinsic Functions .. */ |
| 4840 |
/* .. */ |
| 4841 |
/* .. Executable Statements .. */ |
| 4842 |
|
| 4843 |
/* Since this routine is called in an inner loop, we do no argument */ |
| 4844 |
/* checking. */ |
| 4845 |
|
| 4846 |
/* Quick return for N=1 and 2. */ |
| 4847 |
|
| 4848 |
/* Parameter adjustments */ |
| 4849 |
--delta; |
| 4850 |
--z__; |
| 4851 |
--d__; |
| 4852 |
|
| 4853 |
/* Function Body */ |
| 4854 |
*info = 0; |
| 4855 |
if (*n == 1) { |
| 4856 |
|
| 4857 |
/* Presumably, I=1 upon entry */ |
| 4858 |
|
| 4859 |
*dlam = d__[1] + *rho * z__[1] * z__[1]; |
| 4860 |
delta[1] = 1.; |
| 4861 |
return 0; |
| 4862 |
} |
| 4863 |
if (*n == 2) { |
| 4864 |
dlaed5_(i__, &d__[1], &z__[1], &delta[1], rho, dlam); |
| 4865 |
return 0; |
| 4866 |
} |
| 4867 |
|
| 4868 |
/* Compute machine epsilon */ |
| 4869 |
|
| 4870 |
eps = dlamch_("Epsilon"); |
| 4871 |
rhoinv = 1. / *rho; |
| 4872 |
|
| 4873 |
/* The case I = N */ |
| 4874 |
|
| 4875 |
if (*i__ == *n) { |
| 4876 |
|
| 4877 |
/* Initialize some basic variables */ |
| 4878 |
|
| 4879 |
ii = *n - 1; |
| 4880 |
niter = 1; |
| 4881 |
|
| 4882 |
/* Calculate initial guess */ |
| 4883 |
|
| 4884 |
midpt = *rho / 2.; |
| 4885 |
|
| 4886 |
/* If ||Z||_2 is not one, then TEMP should be set to */ |
| 4887 |
/* RHO * ||Z||_2^2 / TWO */ |
| 4888 |
|
| 4889 |
i__1 = *n; |
| 4890 |
for (j = 1; j <= i__1; ++j) { |
| 4891 |
delta[j] = d__[j] - d__[*i__] - midpt; |
| 4892 |
/* L10: */ |
| 4893 |
} |
| 4894 |
|
| 4895 |
psi = 0.; |
| 4896 |
i__1 = *n - 2; |
| 4897 |
for (j = 1; j <= i__1; ++j) { |
| 4898 |
psi += z__[j] * z__[j] / delta[j]; |
| 4899 |
/* L20: */ |
| 4900 |
} |
| 4901 |
|
| 4902 |
c__ = rhoinv + psi; |
| 4903 |
w = c__ + z__[ii] * z__[ii] / delta[ii] + z__[*n] * z__[*n] / delta[* |
| 4904 |
n]; |
| 4905 |
|
| 4906 |
if (w <= 0.) { |
| 4907 |
temp = z__[*n - 1] * z__[*n - 1] / (d__[*n] - d__[*n - 1] + *rho) |
| 4908 |
+ z__[*n] * z__[*n] / *rho; |
| 4909 |
if (c__ <= temp) { |
| 4910 |
tau = *rho; |
| 4911 |
} else { |
| 4912 |
del = d__[*n] - d__[*n - 1]; |
| 4913 |
a = -c__ * del + z__[*n - 1] * z__[*n - 1] + z__[*n] * z__[*n] |
| 4914 |
; |
| 4915 |
b = z__[*n] * z__[*n] * del; |
| 4916 |
if (a < 0.) { |
| 4917 |
tau = b * 2. / (sqrt(a * a + b * 4. * c__) - a); |
| 4918 |
} else { |
| 4919 |
tau = (a + sqrt(a * a + b * 4. * c__)) / (c__ * 2.); |
| 4920 |
} |
| 4921 |
} |
| 4922 |
|
| 4923 |
/* It can be proved that */ |
| 4924 |
/* D(N)+RHO/2 <= LAMBDA(N) < D(N)+TAU <= D(N)+RHO */ |
| 4925 |
|
| 4926 |
dltlb = midpt; |
| 4927 |
dltub = *rho; |
| 4928 |
} else { |
| 4929 |
del = d__[*n] - d__[*n - 1]; |
| 4930 |
a = -c__ * del + z__[*n - 1] * z__[*n - 1] + z__[*n] * z__[*n]; |
| 4931 |
b = z__[*n] * z__[*n] * del; |
| 4932 |
if (a < 0.) { |
| 4933 |
tau = b * 2. / (sqrt(a * a + b * 4. * c__) - a); |
| 4934 |
} else { |
| 4935 |
tau = (a + sqrt(a * a + b * 4. * c__)) / (c__ * 2.); |
| 4936 |
} |
| 4937 |
|
| 4938 |
/* It can be proved that */ |
| 4939 |
/* D(N) < D(N)+TAU < LAMBDA(N) < D(N)+RHO/2 */ |
| 4940 |
|
| 4941 |
dltlb = 0.; |
| 4942 |
dltub = midpt; |
| 4943 |
} |
| 4944 |
|
| 4945 |
i__1 = *n; |
| 4946 |
for (j = 1; j <= i__1; ++j) { |
| 4947 |
delta[j] = d__[j] - d__[*i__] - tau; |
| 4948 |
/* L30: */ |
| 4949 |
} |
| 4950 |
|
| 4951 |
/* Evaluate PSI and the derivative DPSI */ |
| 4952 |
|
| 4953 |
dpsi = 0.; |
| 4954 |
psi = 0.; |
| 4955 |
erretm = 0.; |
| 4956 |
i__1 = ii; |
| 4957 |
for (j = 1; j <= i__1; ++j) { |
| 4958 |
temp = z__[j] / delta[j]; |
| 4959 |
psi += z__[j] * temp; |
| 4960 |
dpsi += temp * temp; |
| 4961 |
erretm += psi; |
| 4962 |
/* L40: */ |
| 4963 |
} |
| 4964 |
erretm = abs(erretm); |
| 4965 |
|
| 4966 |
/* Evaluate PHI and the derivative DPHI */ |
| 4967 |
|
| 4968 |
temp = z__[*n] / delta[*n]; |
| 4969 |
phi = z__[*n] * temp; |
| 4970 |
dphi = temp * temp; |
| 4971 |
erretm = (-phi - psi) * 8. + erretm - phi + rhoinv + abs(tau) * (dpsi |
| 4972 |
+ dphi); |
| 4973 |
|
| 4974 |
w = rhoinv + phi + psi; |
| 4975 |
|
| 4976 |
/* Test for convergence */ |
| 4977 |
|
| 4978 |
if (abs(w) <= eps * erretm) { |
| 4979 |
*dlam = d__[*i__] + tau; |
| 4980 |
goto L250; |
| 4981 |
} |
| 4982 |
|
| 4983 |
if (w <= 0.) { |
| 4984 |
dltlb = std::max(dltlb,tau); |
| 4985 |
} else { |
| 4986 |
dltub = std::min(dltub,tau); |
| 4987 |
} |
| 4988 |
|
| 4989 |
/* Calculate the new step */ |
| 4990 |
|
| 4991 |
++niter; |
| 4992 |
c__ = w - delta[*n - 1] * dpsi - delta[*n] * dphi; |
| 4993 |
a = (delta[*n - 1] + delta[*n]) * w - delta[*n - 1] * delta[*n] * ( |
| 4994 |
dpsi + dphi); |
| 4995 |
b = delta[*n - 1] * delta[*n] * w; |
| 4996 |
if (c__ < 0.) { |
| 4997 |
c__ = abs(c__); |
| 4998 |
} |
| 4999 |
if (c__ == 0.) { |
| 5000 |
/* ETA = B/A */ |
| 5001 |
/* ETA = RHO - TAU */ |
| 5002 |
eta = dltub - tau; |
| 5003 |
} else if (a >= 0.) { |
| 5004 |
eta = (a + sqrt((d__1 = a * a - b * 4. * c__, abs(d__1)))) / (c__ |
| 5005 |
* 2.); |
| 5006 |
} else { |
| 5007 |
eta = b * 2. / (a - sqrt((d__1 = a * a - b * 4. * c__, abs(d__1))) |
| 5008 |
); |
| 5009 |
} |
| 5010 |
|
| 5011 |
/* Note, eta should be positive if w is negative, and */ |
| 5012 |
/* eta should be negative otherwise. However, */ |
| 5013 |
/* if for some reason caused by roundoff, eta*w > 0, */ |
| 5014 |
/* we simply use one Newton step instead. This way */ |
| 5015 |
/* will guarantee eta*w < 0. */ |
| 5016 |
|
| 5017 |
if (w * eta > 0.) { |
| 5018 |
eta = -w / (dpsi + dphi); |
| 5019 |
} |
| 5020 |
temp = tau + eta; |
| 5021 |
if (temp > dltub || temp < dltlb) { |
| 5022 |
if (w < 0.) { |
| 5023 |
eta = (dltub - tau) / 2.; |
| 5024 |
} else { |
| 5025 |
eta = (dltlb - tau) / 2.; |
| 5026 |
} |
| 5027 |
} |
| 5028 |
i__1 = *n; |
| 5029 |
for (j = 1; j <= i__1; ++j) { |
| 5030 |
delta[j] -= eta; |
| 5031 |
/* L50: */ |
| 5032 |
} |
| 5033 |
|
| 5034 |
tau += eta; |
| 5035 |
|
| 5036 |
/* Evaluate PSI and the derivative DPSI */ |
| 5037 |
|
| 5038 |
dpsi = 0.; |
| 5039 |
psi = 0.; |
| 5040 |
erretm = 0.; |
| 5041 |
i__1 = ii; |
| 5042 |
for (j = 1; j <= i__1; ++j) { |
| 5043 |
temp = z__[j] / delta[j]; |
| 5044 |
psi += z__[j] * temp; |
| 5045 |
dpsi += temp * temp; |
| 5046 |
erretm += psi; |
| 5047 |
/* L60: */ |
| 5048 |
} |
| 5049 |
erretm = abs(erretm); |
| 5050 |
|
| 5051 |
/* Evaluate PHI and the derivative DPHI */ |
| 5052 |
|
| 5053 |
temp = z__[*n] / delta[*n]; |
| 5054 |
phi = z__[*n] * temp; |
| 5055 |
dphi = temp * temp; |
| 5056 |
erretm = (-phi - psi) * 8. + erretm - phi + rhoinv + abs(tau) * (dpsi |
| 5057 |
+ dphi); |
| 5058 |
|
| 5059 |
w = rhoinv + phi + psi; |
| 5060 |
|
| 5061 |
/* Main loop to update the values of the array DELTA */ |
| 5062 |
|
| 5063 |
iter = niter + 1; |
| 5064 |
|
| 5065 |
for (niter = iter; niter <= 30; ++niter) { |
| 5066 |
|
| 5067 |
/* Test for convergence */ |
| 5068 |
|
| 5069 |
if (abs(w) <= eps * erretm) { |
| 5070 |
*dlam = d__[*i__] + tau; |
| 5071 |
goto L250; |
| 5072 |
} |
| 5073 |
|
| 5074 |
if (w <= 0.) { |
| 5075 |
dltlb = std::max(dltlb,tau); |
| 5076 |
} else { |
| 5077 |
dltub = std::min(dltub,tau); |
| 5078 |
} |
| 5079 |
|
| 5080 |
/* Calculate the new step */ |
| 5081 |
|
| 5082 |
c__ = w - delta[*n - 1] * dpsi - delta[*n] * dphi; |
| 5083 |
a = (delta[*n - 1] + delta[*n]) * w - delta[*n - 1] * delta[*n] * |
| 5084 |
(dpsi + dphi); |
| 5085 |
b = delta[*n - 1] * delta[*n] * w; |
| 5086 |
if (a >= 0.) { |
| 5087 |
eta = (a + sqrt((d__1 = a * a - b * 4. * c__, abs(d__1)))) / ( |
| 5088 |
c__ * 2.); |
| 5089 |
} else { |
| 5090 |
eta = b * 2. / (a - sqrt((d__1 = a * a - b * 4. * c__, abs( |
| 5091 |
d__1)))); |
| 5092 |
} |
| 5093 |
|
| 5094 |
/* Note, eta should be positive if w is negative, and */ |
| 5095 |
/* eta should be negative otherwise. However, */ |
| 5096 |
/* if for some reason caused by roundoff, eta*w > 0, */ |
| 5097 |
/* we simply use one Newton step instead. This way */ |
| 5098 |
/* will guarantee eta*w < 0. */ |
| 5099 |
|
| 5100 |
if (w * eta > 0.) { |
| 5101 |
eta = -w / (dpsi + dphi); |
| 5102 |
} |
| 5103 |
temp = tau + eta; |
| 5104 |
if (temp > dltub || temp < dltlb) { |
| 5105 |
if (w < 0.) { |
| 5106 |
eta = (dltub - tau) / 2.; |
| 5107 |
} else { |
| 5108 |
eta = (dltlb - tau) / 2.; |
| 5109 |
} |
| 5110 |
} |
| 5111 |
i__1 = *n; |
| 5112 |
for (j = 1; j <= i__1; ++j) { |
| 5113 |
delta[j] -= eta; |
| 5114 |
/* L70: */ |
| 5115 |
} |
| 5116 |
|
| 5117 |
tau += eta; |
| 5118 |
|
| 5119 |
/* Evaluate PSI and the derivative DPSI */ |
| 5120 |
|
| 5121 |
dpsi = 0.; |
| 5122 |
psi = 0.; |
| 5123 |
erretm = 0.; |
| 5124 |
i__1 = ii; |
| 5125 |
for (j = 1; j <= i__1; ++j) { |
| 5126 |
temp = z__[j] / delta[j]; |
| 5127 |
psi += z__[j] * temp; |
| 5128 |
dpsi += temp * temp; |
| 5129 |
erretm += psi; |
| 5130 |
/* L80: */ |
| 5131 |
} |
| 5132 |
erretm = abs(erretm); |
| 5133 |
|
| 5134 |
/* Evaluate PHI and the derivative DPHI */ |
| 5135 |
|
| 5136 |
temp = z__[*n] / delta[*n]; |
| 5137 |
phi = z__[*n] * temp; |
| 5138 |
dphi = temp * temp; |
| 5139 |
erretm = (-phi - psi) * 8. + erretm - phi + rhoinv + abs(tau) * ( |
| 5140 |
dpsi + dphi); |
| 5141 |
|
| 5142 |
w = rhoinv + phi + psi; |
| 5143 |
/* L90: */ |
| 5144 |
} |
| 5145 |
|
| 5146 |
/* Return with INFO = 1, NITER = MAXIT and not converged */ |
| 5147 |
|
| 5148 |
*info = 1; |
| 5149 |
*dlam = d__[*i__] + tau; |
| 5150 |
goto L250; |
| 5151 |
|
| 5152 |
/* End for the case I = N */ |
| 5153 |
|
| 5154 |
} else { |
| 5155 |
|
| 5156 |
/* The case for I < N */ |
| 5157 |
|
| 5158 |
niter = 1; |
| 5159 |
ip1 = *i__ + 1; |
| 5160 |
|
| 5161 |
/* Calculate initial guess */ |
| 5162 |
|
| 5163 |
del = d__[ip1] - d__[*i__]; |
| 5164 |
midpt = del / 2.; |
| 5165 |
i__1 = *n; |
| 5166 |
for (j = 1; j <= i__1; ++j) { |
| 5167 |
delta[j] = d__[j] - d__[*i__] - midpt; |
| 5168 |
/* L100: */ |
| 5169 |
} |
| 5170 |
|
| 5171 |
psi = 0.; |
| 5172 |
i__1 = *i__ - 1; |
| 5173 |
for (j = 1; j <= i__1; ++j) { |
| 5174 |
psi += z__[j] * z__[j] / delta[j]; |
| 5175 |
/* L110: */ |
| 5176 |
} |
| 5177 |
|
| 5178 |
phi = 0.; |
| 5179 |
i__1 = *i__ + 2; |
| 5180 |
for (j = *n; j >= i__1; --j) { |
| 5181 |
phi += z__[j] * z__[j] / delta[j]; |
| 5182 |
/* L120: */ |
| 5183 |
} |
| 5184 |
c__ = rhoinv + psi + phi; |
| 5185 |
w = c__ + z__[*i__] * z__[*i__] / delta[*i__] + z__[ip1] * z__[ip1] / |
| 5186 |
delta[ip1]; |
| 5187 |
|
| 5188 |
if (w > 0.) { |
| 5189 |
|
| 5190 |
/* d(i)< the ith eigenvalue < (d(i)+d(i+1))/2 */ |
| 5191 |
|
| 5192 |
/* We choose d(i) as origin. */ |
| 5193 |
|
| 5194 |
orgati = true; |
| 5195 |
a = c__ * del + z__[*i__] * z__[*i__] + z__[ip1] * z__[ip1]; |
| 5196 |
b = z__[*i__] * z__[*i__] * del; |
| 5197 |
if (a > 0.) { |
| 5198 |
tau = b * 2. / (a + sqrt((d__1 = a * a - b * 4. * c__, abs( |
| 5199 |
d__1)))); |
| 5200 |
} else { |
| 5201 |
tau = (a - sqrt((d__1 = a * a - b * 4. * c__, abs(d__1)))) / ( |
| 5202 |
c__ * 2.); |
| 5203 |
} |
| 5204 |
dltlb = 0.; |
| 5205 |
dltub = midpt; |
| 5206 |
} else { |
| 5207 |
|
| 5208 |
/* (d(i)+d(i+1))/2 <= the ith eigenvalue < d(i+1) */ |
| 5209 |
|
| 5210 |
/* We choose d(i+1) as origin. */ |
| 5211 |
|
| 5212 |
orgati = false; |
| 5213 |
a = c__ * del - z__[*i__] * z__[*i__] - z__[ip1] * z__[ip1]; |
| 5214 |
b = z__[ip1] * z__[ip1] * del; |
| 5215 |
if (a < 0.) { |
| 5216 |
tau = b * 2. / (a - sqrt((d__1 = a * a + b * 4. * c__, abs( |
| 5217 |
d__1)))); |
| 5218 |
} else { |
| 5219 |
tau = -(a + sqrt((d__1 = a * a + b * 4. * c__, abs(d__1)))) / |
| 5220 |
(c__ * 2.); |
| 5221 |
} |
| 5222 |
dltlb = -midpt; |
| 5223 |
dltub = 0.; |
| 5224 |
} |
| 5225 |
|
| 5226 |
if (orgati) { |
| 5227 |
i__1 = *n; |
| 5228 |
for (j = 1; j <= i__1; ++j) { |
| 5229 |
delta[j] = d__[j] - d__[*i__] - tau; |
| 5230 |
/* L130: */ |
| 5231 |
} |
| 5232 |
} else { |
| 5233 |
i__1 = *n; |
| 5234 |
for (j = 1; j <= i__1; ++j) { |
| 5235 |
delta[j] = d__[j] - d__[ip1] - tau; |
| 5236 |
/* L140: */ |
| 5237 |
} |
| 5238 |
} |
| 5239 |
if (orgati) { |
| 5240 |
ii = *i__; |
| 5241 |
} else { |
| 5242 |
ii = *i__ + 1; |
| 5243 |
} |
| 5244 |
iim1 = ii - 1; |
| 5245 |
iip1 = ii + 1; |
| 5246 |
|
| 5247 |
/* Evaluate PSI and the derivative DPSI */ |
| 5248 |
|
| 5249 |
dpsi = 0.; |
| 5250 |
psi = 0.; |
| 5251 |
erretm = 0.; |
| 5252 |
i__1 = iim1; |
| 5253 |
for (j = 1; j <= i__1; ++j) { |
| 5254 |
temp = z__[j] / delta[j]; |
| 5255 |
psi += z__[j] * temp; |
| 5256 |
dpsi += temp * temp; |
| 5257 |
erretm += psi; |
| 5258 |
/* L150: */ |
| 5259 |
} |
| 5260 |
erretm = abs(erretm); |
| 5261 |
|
| 5262 |
/* Evaluate PHI and the derivative DPHI */ |
| 5263 |
|
| 5264 |
dphi = 0.; |
| 5265 |
phi = 0.; |
| 5266 |
i__1 = iip1; |
| 5267 |
for (j = *n; j >= i__1; --j) { |
| 5268 |
temp = z__[j] / delta[j]; |
| 5269 |
phi += z__[j] * temp; |
| 5270 |
dphi += temp * temp; |
| 5271 |
erretm += phi; |
| 5272 |
/* L160: */ |
| 5273 |
} |
| 5274 |
|
| 5275 |
w = rhoinv + phi + psi; |
| 5276 |
|
| 5277 |
/* W is the value of the secular function with */ |
| 5278 |
/* its ii-th element removed. */ |
| 5279 |
|
| 5280 |
swtch3 = false; |
| 5281 |
if (orgati) { |
| 5282 |
if (w < 0.) { |
| 5283 |
swtch3 = true; |
| 5284 |
} |
| 5285 |
} else { |
| 5286 |
if (w > 0.) { |
| 5287 |
swtch3 = true; |
| 5288 |
} |
| 5289 |
} |
| 5290 |
if (ii == 1 || ii == *n) { |
| 5291 |
swtch3 = false; |
| 5292 |
} |
| 5293 |
|
| 5294 |
temp = z__[ii] / delta[ii]; |
| 5295 |
dw = dpsi + dphi + temp * temp; |
| 5296 |
temp = z__[ii] * temp; |
| 5297 |
w += temp; |
| 5298 |
erretm = (phi - psi) * 8. + erretm + rhoinv * 2. + abs(temp) * 3. + |
| 5299 |
abs(tau) * dw; |
| 5300 |
|
| 5301 |
/* Test for convergence */ |
| 5302 |
|
| 5303 |
if (abs(w) <= eps * erretm) { |
| 5304 |
if (orgati) { |
| 5305 |
*dlam = d__[*i__] + tau; |
| 5306 |
} else { |
| 5307 |
*dlam = d__[ip1] + tau; |
| 5308 |
} |
| 5309 |
goto L250; |
| 5310 |
} |
| 5311 |
|
| 5312 |
if (w <= 0.) { |
| 5313 |
dltlb = std::max(dltlb,tau); |
| 5314 |
} else { |
| 5315 |
dltub = std::min(dltub,tau); |
| 5316 |
} |
| 5317 |
|
| 5318 |
/* Calculate the new step */ |
| 5319 |
|
| 5320 |
++niter; |
| 5321 |
if (! swtch3) { |
| 5322 |
if (orgati) { |
| 5323 |
/* Computing 2nd power */ |
| 5324 |
d__1 = z__[*i__] / delta[*i__]; |
| 5325 |
c__ = w - delta[ip1] * dw - (d__[*i__] - d__[ip1]) * (d__1 * |
| 5326 |
d__1); |
| 5327 |
} else { |
| 5328 |
/* Computing 2nd power */ |
| 5329 |
d__1 = z__[ip1] / delta[ip1]; |
| 5330 |
c__ = w - delta[*i__] * dw - (d__[ip1] - d__[*i__]) * (d__1 * |
| 5331 |
d__1); |
| 5332 |
} |
| 5333 |
a = (delta[*i__] + delta[ip1]) * w - delta[*i__] * delta[ip1] * |
| 5334 |
dw; |
| 5335 |
b = delta[*i__] * delta[ip1] * w; |
| 5336 |
if (c__ == 0.) { |
| 5337 |
if (a == 0.) { |
| 5338 |
if (orgati) { |
| 5339 |
a = z__[*i__] * z__[*i__] + delta[ip1] * delta[ip1] * |
| 5340 |
(dpsi + dphi); |
| 5341 |
} else { |
| 5342 |
a = z__[ip1] * z__[ip1] + delta[*i__] * delta[*i__] * |
| 5343 |
(dpsi + dphi); |
| 5344 |
} |
| 5345 |
} |
| 5346 |
eta = b / a; |
| 5347 |
} else if (a <= 0.) { |
| 5348 |
eta = (a - sqrt((d__1 = a * a - b * 4. * c__, abs(d__1)))) / ( |
| 5349 |
c__ * 2.); |
| 5350 |
} else { |
| 5351 |
eta = b * 2. / (a + sqrt((d__1 = a * a - b * 4. * c__, abs( |
| 5352 |
d__1)))); |
| 5353 |
} |
| 5354 |
} else { |
| 5355 |
|
| 5356 |
/* Interpolation using THREE most relevant poles */ |
| 5357 |
|
| 5358 |
temp = rhoinv + psi + phi; |
| 5359 |
if (orgati) { |
| 5360 |
temp1 = z__[iim1] / delta[iim1]; |
| 5361 |
temp1 *= temp1; |
| 5362 |
c__ = temp - delta[iip1] * (dpsi + dphi) - (d__[iim1] - d__[ |
| 5363 |
iip1]) * temp1; |
| 5364 |
zz[0] = z__[iim1] * z__[iim1]; |
| 5365 |
zz[2] = delta[iip1] * delta[iip1] * (dpsi - temp1 + dphi); |
| 5366 |
} else { |
| 5367 |
temp1 = z__[iip1] / delta[iip1]; |
| 5368 |
temp1 *= temp1; |
| 5369 |
c__ = temp - delta[iim1] * (dpsi + dphi) - (d__[iip1] - d__[ |
| 5370 |
iim1]) * temp1; |
| 5371 |
zz[0] = delta[iim1] * delta[iim1] * (dpsi + (dphi - temp1)); |
| 5372 |
zz[2] = z__[iip1] * z__[iip1]; |
| 5373 |
} |
| 5374 |
zz[1] = z__[ii] * z__[ii]; |
| 5375 |
dlaed6_(&niter, &orgati, &c__, &delta[iim1], zz, &w, &eta, info); |
| 5376 |
if (*info != 0) { |
| 5377 |
goto L250; |
| 5378 |
} |
| 5379 |
} |
| 5380 |
|
| 5381 |
/* Note, eta should be positive if w is negative, and */ |
| 5382 |
/* eta should be negative otherwise. However, */ |
| 5383 |
/* if for some reason caused by roundoff, eta*w > 0, */ |
| 5384 |
/* we simply use one Newton step instead. This way */ |
| 5385 |
/* will guarantee eta*w < 0. */ |
| 5386 |
|
| 5387 |
if (w * eta >= 0.) { |
| 5388 |
eta = -w / dw; |
| 5389 |
} |
| 5390 |
temp = tau + eta; |
| 5391 |
if (temp > dltub || temp < dltlb) { |
| 5392 |
if (w < 0.) { |
| 5393 |
eta = (dltub - tau) / 2.; |
| 5394 |
} else { |
| 5395 |
eta = (dltlb - tau) / 2.; |
| 5396 |
} |
| 5397 |
} |
| 5398 |
|
| 5399 |
prew = w; |
| 5400 |
|
| 5401 |
i__1 = *n; |
| 5402 |
for (j = 1; j <= i__1; ++j) { |
| 5403 |
delta[j] -= eta; |
| 5404 |
/* L180: */ |
| 5405 |
} |
| 5406 |
|
| 5407 |
/* Evaluate PSI and the derivative DPSI */ |
| 5408 |
|
| 5409 |
dpsi = 0.; |
| 5410 |
psi = 0.; |
| 5411 |
erretm = 0.; |
| 5412 |
i__1 = iim1; |
| 5413 |
for (j = 1; j <= i__1; ++j) { |
| 5414 |
temp = z__[j] / delta[j]; |
| 5415 |
psi += z__[j] * temp; |
| 5416 |
dpsi += temp * temp; |
| 5417 |
erretm += psi; |
| 5418 |
/* L190: */ |
| 5419 |
} |
| 5420 |
erretm = abs(erretm); |
| 5421 |
|
| 5422 |
/* Evaluate PHI and the derivative DPHI */ |
| 5423 |
|
| 5424 |
dphi = 0.; |
| 5425 |
phi = 0.; |
| 5426 |
i__1 = iip1; |
| 5427 |
for (j = *n; j >= i__1; --j) { |
| 5428 |
temp = z__[j] / delta[j]; |
| 5429 |
phi += z__[j] * temp; |
| 5430 |
dphi += temp * temp; |
| 5431 |
erretm += phi; |
| 5432 |
/* L200: */ |
| 5433 |
} |
| 5434 |
|
| 5435 |
temp = z__[ii] / delta[ii]; |
| 5436 |
dw = dpsi + dphi + temp * temp; |
| 5437 |
temp = z__[ii] * temp; |
| 5438 |
w = rhoinv + phi + psi + temp; |
| 5439 |
erretm = (phi - psi) * 8. + erretm + rhoinv * 2. + abs(temp) * 3. + ( |
| 5440 |
d__1 = tau + eta, abs(d__1)) * dw; |
| 5441 |
|
| 5442 |
swtch = false; |
| 5443 |
if (orgati) { |
| 5444 |
if (-w > abs(prew) / 10.) { |
| 5445 |
swtch = true; |
| 5446 |
} |
| 5447 |
} else { |
| 5448 |
if (w > abs(prew) / 10.) { |
| 5449 |
swtch = true; |
| 5450 |
} |
| 5451 |
} |
| 5452 |
|
| 5453 |
tau += eta; |
| 5454 |
|
| 5455 |
/* Main loop to update the values of the array DELTA */ |
| 5456 |
|
| 5457 |
iter = niter + 1; |
| 5458 |
|
| 5459 |
for (niter = iter; niter <= 30; ++niter) { |
| 5460 |
|
| 5461 |
/* Test for convergence */ |
| 5462 |
|
| 5463 |
if (abs(w) <= eps * erretm) { |
| 5464 |
if (orgati) { |
| 5465 |
*dlam = d__[*i__] + tau; |
| 5466 |
} else { |
| 5467 |
*dlam = d__[ip1] + tau; |
| 5468 |
} |
| 5469 |
goto L250; |
| 5470 |
} |
| 5471 |
|
| 5472 |
if (w <= 0.) { |
| 5473 |
dltlb = std::max(dltlb,tau); |
| 5474 |
} else { |
| 5475 |
dltub = std::min(dltub,tau); |
| 5476 |
} |
| 5477 |
|
| 5478 |
/* Calculate the new step */ |
| 5479 |
|
| 5480 |
if (! swtch3) { |
| 5481 |
if (! swtch) { |
| 5482 |
if (orgati) { |
| 5483 |
/* Computing 2nd power */ |
| 5484 |
d__1 = z__[*i__] / delta[*i__]; |
| 5485 |
c__ = w - delta[ip1] * dw - (d__[*i__] - d__[ip1]) * ( |
| 5486 |
d__1 * d__1); |
| 5487 |
} else { |
| 5488 |
/* Computing 2nd power */ |
| 5489 |
d__1 = z__[ip1] / delta[ip1]; |
| 5490 |
c__ = w - delta[*i__] * dw - (d__[ip1] - d__[*i__]) * |
| 5491 |
(d__1 * d__1); |
| 5492 |
} |
| 5493 |
} else { |
| 5494 |
temp = z__[ii] / delta[ii]; |
| 5495 |
if (orgati) { |
| 5496 |
dpsi += temp * temp; |
| 5497 |
} else { |
| 5498 |
dphi += temp * temp; |
| 5499 |
} |
| 5500 |
c__ = w - delta[*i__] * dpsi - delta[ip1] * dphi; |
| 5501 |
} |
| 5502 |
a = (delta[*i__] + delta[ip1]) * w - delta[*i__] * delta[ip1] |
| 5503 |
* dw; |
| 5504 |
b = delta[*i__] * delta[ip1] * w; |
| 5505 |
if (c__ == 0.) { |
| 5506 |
if (a == 0.) { |
| 5507 |
if (! swtch) { |
| 5508 |
if (orgati) { |
| 5509 |
a = z__[*i__] * z__[*i__] + delta[ip1] * |
| 5510 |
delta[ip1] * (dpsi + dphi); |
| 5511 |
} else { |
| 5512 |
a = z__[ip1] * z__[ip1] + delta[*i__] * delta[ |
| 5513 |
*i__] * (dpsi + dphi); |
| 5514 |
} |
| 5515 |
} else { |
| 5516 |
a = delta[*i__] * delta[*i__] * dpsi + delta[ip1] |
| 5517 |
* delta[ip1] * dphi; |
| 5518 |
} |
| 5519 |
} |
| 5520 |
eta = b / a; |
| 5521 |
} else if (a <= 0.) { |
| 5522 |
eta = (a - sqrt((d__1 = a * a - b * 4. * c__, abs(d__1)))) |
| 5523 |
/ (c__ * 2.); |
| 5524 |
} else { |
| 5525 |
eta = b * 2. / (a + sqrt((d__1 = a * a - b * 4. * c__, |
| 5526 |
abs(d__1)))); |
| 5527 |
} |
| 5528 |
} else { |
| 5529 |
|
| 5530 |
/* Interpolation using THREE most relevant poles */ |
| 5531 |
|
| 5532 |
temp = rhoinv + psi + phi; |
| 5533 |
if (swtch) { |
| 5534 |
c__ = temp - delta[iim1] * dpsi - delta[iip1] * dphi; |
| 5535 |
zz[0] = delta[iim1] * delta[iim1] * dpsi; |
| 5536 |
zz[2] = delta[iip1] * delta[iip1] * dphi; |
| 5537 |
} else { |
| 5538 |
if (orgati) { |
| 5539 |
temp1 = z__[iim1] / delta[iim1]; |
| 5540 |
temp1 *= temp1; |
| 5541 |
c__ = temp - delta[iip1] * (dpsi + dphi) - (d__[iim1] |
| 5542 |
- d__[iip1]) * temp1; |
| 5543 |
zz[0] = z__[iim1] * z__[iim1]; |
| 5544 |
zz[2] = delta[iip1] * delta[iip1] * (dpsi - temp1 + |
| 5545 |
dphi); |
| 5546 |
} else { |
| 5547 |
temp1 = z__[iip1] / delta[iip1]; |
| 5548 |
temp1 *= temp1; |
| 5549 |
c__ = temp - delta[iim1] * (dpsi + dphi) - (d__[iip1] |
| 5550 |
- d__[iim1]) * temp1; |
| 5551 |
zz[0] = delta[iim1] * delta[iim1] * (dpsi + (dphi - |
| 5552 |
temp1)); |
| 5553 |
zz[2] = z__[iip1] * z__[iip1]; |
| 5554 |
} |
| 5555 |
} |
| 5556 |
dlaed6_(&niter, &orgati, &c__, &delta[iim1], zz, &w, &eta, |
| 5557 |
info); |
| 5558 |
if (*info != 0) { |
| 5559 |
goto L250; |
| 5560 |
} |
| 5561 |
} |
| 5562 |
|
| 5563 |
/* Note, eta should be positive if w is negative, and */ |
| 5564 |
/* eta should be negative otherwise. However, */ |
| 5565 |
/* if for some reason caused by roundoff, eta*w > 0, */ |
| 5566 |
/* we simply use one Newton step instead. This way */ |
| 5567 |
/* will guarantee eta*w < 0. */ |
| 5568 |
|
| 5569 |
if (w * eta >= 0.) { |
| 5570 |
eta = -w / dw; |
| 5571 |
} |
| 5572 |
temp = tau + eta; |
| 5573 |
if (temp > dltub || temp < dltlb) { |
| 5574 |
if (w < 0.) { |
| 5575 |
eta = (dltub - tau) / 2.; |
| 5576 |
} else { |
| 5577 |
eta = (dltlb - tau) / 2.; |
| 5578 |
} |
| 5579 |
} |
| 5580 |
|
| 5581 |
i__1 = *n; |
| 5582 |
for (j = 1; j <= i__1; ++j) { |
| 5583 |
delta[j] -= eta; |
| 5584 |
/* L210: */ |
| 5585 |
} |
| 5586 |
|
| 5587 |
tau += eta; |
| 5588 |
prew = w; |
| 5589 |
|
| 5590 |
/* Evaluate PSI and the derivative DPSI */ |
| 5591 |
|
| 5592 |
dpsi = 0.; |
| 5593 |
psi = 0.; |
| 5594 |
erretm = 0.; |
| 5595 |
i__1 = iim1; |
| 5596 |
for (j = 1; j <= i__1; ++j) { |
| 5597 |
temp = z__[j] / delta[j]; |
| 5598 |
psi += z__[j] * temp; |
| 5599 |
dpsi += temp * temp; |
| 5600 |
erretm += psi; |
| 5601 |
/* L220: */ |
| 5602 |
} |
| 5603 |
erretm = abs(erretm); |
| 5604 |
|
| 5605 |
/* Evaluate PHI and the derivative DPHI */ |
| 5606 |
|
| 5607 |
dphi = 0.; |
| 5608 |
phi = 0.; |
| 5609 |
i__1 = iip1; |
| 5610 |
for (j = *n; j >= i__1; --j) { |
| 5611 |
temp = z__[j] / delta[j]; |
| 5612 |
phi += z__[j] * temp; |
| 5613 |
dphi += temp * temp; |
| 5614 |
erretm += phi; |
| 5615 |
/* L230: */ |
| 5616 |
} |
| 5617 |
|
| 5618 |
temp = z__[ii] / delta[ii]; |
| 5619 |
dw = dpsi + dphi + temp * temp; |
| 5620 |
temp = z__[ii] * temp; |
| 5621 |
w = rhoinv + phi + psi + temp; |
| 5622 |
erretm = (phi - psi) * 8. + erretm + rhoinv * 2. + abs(temp) * 3. |
| 5623 |
+ abs(tau) * dw; |
| 5624 |
if (w * prew > 0. && abs(w) > abs(prew) / 10.) { |
| 5625 |
swtch = ! swtch; |
| 5626 |
} |
| 5627 |
|
| 5628 |
/* L240: */ |
| 5629 |
} |
| 5630 |
|
| 5631 |
/* Return with INFO = 1, NITER = MAXIT and not converged */ |
| 5632 |
|
| 5633 |
*info = 1; |
| 5634 |
if (orgati) { |
| 5635 |
*dlam = d__[*i__] + tau; |
| 5636 |
} else { |
| 5637 |
*dlam = d__[ip1] + tau; |
| 5638 |
} |
| 5639 |
|
| 5640 |
} |
| 5641 |
|
| 5642 |
L250: |
| 5643 |
|
| 5644 |
return 0; |
| 5645 |
|
| 5646 |
/* End of DLAED4 */ |
| 5647 |
|
| 5648 |
} /* dlaed4_ */ |
| 5649 |
|
| 5650 |
/* Subroutine */ int dlaed5_(integer *i__, double *d__, double *z__, |
| 5651 |
double *delta, double *rho, double *dlam) |
| 5652 |
{ |
| 5653 |
/* System generated locals */ |
| 5654 |
double d__1; |
| 5655 |
|
| 5656 |
/* Builtin functions |
| 5657 |
double sqrt(double); */ |
| 5658 |
|
| 5659 |
/* Local variables */ |
| 5660 |
double b, c__, w, del, tau, temp; |
| 5661 |
|
| 5662 |
|
| 5663 |
/* -- LAPACK routine (version 3.1) -- */ |
| 5664 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 5665 |
/* November 2006 */ |
| 5666 |
|
| 5667 |
/* .. Scalar Arguments .. */ |
| 5668 |
/* .. */ |
| 5669 |
/* .. Array Arguments .. */ |
| 5670 |
/* .. */ |
| 5671 |
|
| 5672 |
/* Purpose */ |
| 5673 |
/* ======= */ |
| 5674 |
|
| 5675 |
/* This subroutine computes the I-th eigenvalue of a symmetric rank-one */ |
| 5676 |
/* modification of a 2-by-2 diagonal matrix */ |
| 5677 |
|
| 5678 |
/* diag( D ) + RHO * Z * transpose(Z) . */ |
| 5679 |
|
| 5680 |
/* The diagonal elements in the array D are assumed to satisfy */ |
| 5681 |
|
| 5682 |
/* D(i) < D(j) for i < j . */ |
| 5683 |
|
| 5684 |
/* We also assume RHO > 0 and that the Euclidean norm of the vector */ |
| 5685 |
/* Z is one. */ |
| 5686 |
|
| 5687 |
/* Arguments */ |
| 5688 |
/* ========= */ |
| 5689 |
|
| 5690 |
/* I (input) INTEGER */ |
| 5691 |
/* The index of the eigenvalue to be computed. I = 1 or I = 2. */ |
| 5692 |
|
| 5693 |
/* D (input) DOUBLE PRECISION array, dimension (2) */ |
| 5694 |
/* The original eigenvalues. We assume D(1) < D(2). */ |
| 5695 |
|
| 5696 |
/* Z (input) DOUBLE PRECISION array, dimension (2) */ |
| 5697 |
/* The components of the updating vector. */ |
| 5698 |
|
| 5699 |
/* DELTA (output) DOUBLE PRECISION array, dimension (2) */ |
| 5700 |
/* The vector DELTA contains the information necessary */ |
| 5701 |
/* to construct the eigenvectors. */ |
| 5702 |
|
| 5703 |
/* RHO (input) DOUBLE PRECISION */ |
| 5704 |
/* The scalar in the symmetric updating formula. */ |
| 5705 |
|
| 5706 |
/* DLAM (output) DOUBLE PRECISION */ |
| 5707 |
/* The computed lambda_I, the I-th updated eigenvalue. */ |
| 5708 |
|
| 5709 |
/* Further Details */ |
| 5710 |
/* =============== */ |
| 5711 |
|
| 5712 |
/* Based on contributions by */ |
| 5713 |
/* Ren-Cang Li, Computer Science Division, University of California */ |
| 5714 |
/* at Berkeley, USA */ |
| 5715 |
|
| 5716 |
/* ===================================================================== */ |
| 5717 |
|
| 5718 |
/* .. Parameters .. */ |
| 5719 |
/* .. */ |
| 5720 |
/* .. Local Scalars .. */ |
| 5721 |
/* .. */ |
| 5722 |
/* .. Intrinsic Functions .. */ |
| 5723 |
/* .. */ |
| 5724 |
/* .. Executable Statements .. */ |
| 5725 |
|
| 5726 |
/* Parameter adjustments */ |
| 5727 |
--delta; |
| 5728 |
--z__; |
| 5729 |
--d__; |
| 5730 |
|
| 5731 |
/* Function Body */ |
| 5732 |
del = d__[2] - d__[1]; |
| 5733 |
if (*i__ == 1) { |
| 5734 |
w = *rho * 2. * (z__[2] * z__[2] - z__[1] * z__[1]) / del + 1.; |
| 5735 |
if (w > 0.) { |
| 5736 |
b = del + *rho * (z__[1] * z__[1] + z__[2] * z__[2]); |
| 5737 |
c__ = *rho * z__[1] * z__[1] * del; |
| 5738 |
|
| 5739 |
/* B > ZERO, always */ |
| 5740 |
|
| 5741 |
tau = c__ * 2. / (b + sqrt((d__1 = b * b - c__ * 4., abs(d__1)))); |
| 5742 |
*dlam = d__[1] + tau; |
| 5743 |
delta[1] = -z__[1] / tau; |
| 5744 |
delta[2] = z__[2] / (del - tau); |
| 5745 |
} else { |
| 5746 |
b = -del + *rho * (z__[1] * z__[1] + z__[2] * z__[2]); |
| 5747 |
c__ = *rho * z__[2] * z__[2] * del; |
| 5748 |
if (b > 0.) { |
| 5749 |
tau = c__ * -2. / (b + sqrt(b * b + c__ * 4.)); |
| 5750 |
} else { |
| 5751 |
tau = (b - sqrt(b * b + c__ * 4.)) / 2.; |
| 5752 |
} |
| 5753 |
*dlam = d__[2] + tau; |
| 5754 |
delta[1] = -z__[1] / (del + tau); |
| 5755 |
delta[2] = -z__[2] / tau; |
| 5756 |
} |
| 5757 |
temp = sqrt(delta[1] * delta[1] + delta[2] * delta[2]); |
| 5758 |
delta[1] /= temp; |
| 5759 |
delta[2] /= temp; |
| 5760 |
} else { |
| 5761 |
|
| 5762 |
/* Now I=2 */ |
| 5763 |
|
| 5764 |
b = -del + *rho * (z__[1] * z__[1] + z__[2] * z__[2]); |
| 5765 |
c__ = *rho * z__[2] * z__[2] * del; |
| 5766 |
if (b > 0.) { |
| 5767 |
tau = (b + sqrt(b * b + c__ * 4.)) / 2.; |
| 5768 |
} else { |
| 5769 |
tau = c__ * 2. / (-b + sqrt(b * b + c__ * 4.)); |
| 5770 |
} |
| 5771 |
*dlam = d__[2] + tau; |
| 5772 |
delta[1] = -z__[1] / (del + tau); |
| 5773 |
delta[2] = -z__[2] / tau; |
| 5774 |
temp = sqrt(delta[1] * delta[1] + delta[2] * delta[2]); |
| 5775 |
delta[1] /= temp; |
| 5776 |
delta[2] /= temp; |
| 5777 |
} |
| 5778 |
return 0; |
| 5779 |
|
| 5780 |
/* End OF DLAED5 */ |
| 5781 |
|
| 5782 |
} /* dlaed5_ */ |
| 5783 |
|
| 5784 |
/* Subroutine */ int dlaed6_(integer *kniter, bool *orgati, double * |
| 5785 |
rho, double *d__, double *z__, double *finit, double * |
| 5786 |
tau, integer *info) |
| 5787 |
{ |
| 5788 |
/* System generated locals */ |
| 5789 |
integer i__1; |
| 5790 |
double d__1, d__2, d__3, d__4; |
| 5791 |
|
| 5792 |
/* Local variables */ |
| 5793 |
double a, b, c__, f; |
| 5794 |
integer i__; |
| 5795 |
double fc, df, ddf, lbd, eta, ubd, eps, base; |
| 5796 |
integer iter; |
| 5797 |
double temp, temp1, temp2, temp3, temp4; |
| 5798 |
bool scale; |
| 5799 |
integer niter; |
| 5800 |
double small1, small2, sminv1, sminv2; |
| 5801 |
|
| 5802 |
double dscale[3], sclfac, zscale[3], erretm, sclinv; |
| 5803 |
|
| 5804 |
|
| 5805 |
/* -- LAPACK routine (version 3.1.1) -- */ |
| 5806 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 5807 |
/* February 2007 */ |
| 5808 |
|
| 5809 |
/* .. Scalar Arguments .. */ |
| 5810 |
/* .. */ |
| 5811 |
/* .. Array Arguments .. */ |
| 5812 |
/* .. */ |
| 5813 |
|
| 5814 |
/* Purpose */ |
| 5815 |
/* ======= */ |
| 5816 |
|
| 5817 |
/* DLAED6 computes the positive or negative root (closest to the origin) */ |
| 5818 |
/* of */ |
| 5819 |
/* z(1) z(2) z(3) */ |
| 5820 |
/* f(x) = rho + --------- + ---------- + --------- */ |
| 5821 |
/* d(1)-x d(2)-x d(3)-x */ |
| 5822 |
|
| 5823 |
/* It is assumed that */ |
| 5824 |
|
| 5825 |
/* if ORGATI = .true. the root is between d(2) and d(3); */ |
| 5826 |
/* otherwise it is between d(1) and d(2) */ |
| 5827 |
|
| 5828 |
/* This routine will be called by DLAED4 when necessary. In most cases, */ |
| 5829 |
/* the root sought is the smallest in magnitude, though it might not be */ |
| 5830 |
/* in some extremely rare situations. */ |
| 5831 |
|
| 5832 |
/* Arguments */ |
| 5833 |
/* ========= */ |
| 5834 |
|
| 5835 |
/* KNITER (input) INTEGER */ |
| 5836 |
/* Refer to DLAED4 for its significance. */ |
| 5837 |
|
| 5838 |
/* ORGATI (input) LOGICAL */ |
| 5839 |
/* If ORGATI is true, the needed root is between d(2) and */ |
| 5840 |
/* d(3); otherwise it is between d(1) and d(2). See */ |
| 5841 |
/* DLAED4 for further details. */ |
| 5842 |
|
| 5843 |
/* RHO (input) DOUBLE PRECISION */ |
| 5844 |
/* Refer to the equation f(x) above. */ |
| 5845 |
|
| 5846 |
/* D (input) DOUBLE PRECISION array, dimension (3) */ |
| 5847 |
/* D satisfies d(1) < d(2) < d(3). */ |
| 5848 |
|
| 5849 |
/* Z (input) DOUBLE PRECISION array, dimension (3) */ |
| 5850 |
/* Each of the elements in z must be positive. */ |
| 5851 |
|
| 5852 |
/* FINIT (input) DOUBLE PRECISION */ |
| 5853 |
/* The value of f at 0. It is more accurate than the one */ |
| 5854 |
/* evaluated inside this routine (if someone wants to do */ |
| 5855 |
/* so). */ |
| 5856 |
|
| 5857 |
/* TAU (output) DOUBLE PRECISION */ |
| 5858 |
/* The root of the equation f(x). */ |
| 5859 |
|
| 5860 |
/* INFO (output) INTEGER */ |
| 5861 |
/* = 0: successful exit */ |
| 5862 |
/* > 0: if INFO = 1, failure to converge */ |
| 5863 |
|
| 5864 |
/* Further Details */ |
| 5865 |
/* =============== */ |
| 5866 |
|
| 5867 |
/* 30/06/99: Based on contributions by */ |
| 5868 |
/* Ren-Cang Li, Computer Science Division, University of California */ |
| 5869 |
/* at Berkeley, USA */ |
| 5870 |
|
| 5871 |
/* 10/02/03: This version has a few statements commented out for thread */ |
| 5872 |
/* safety (machine parameters are computed on each entry). SJH. */ |
| 5873 |
|
| 5874 |
/* 05/10/06: Modified from a new version of Ren-Cang Li, use */ |
| 5875 |
/* Gragg-Thornton-Warner cubic convergent scheme for better stability. */ |
| 5876 |
|
| 5877 |
/* ===================================================================== */ |
| 5878 |
|
| 5879 |
/* .. Parameters .. */ |
| 5880 |
/* .. */ |
| 5881 |
/* .. External Functions .. */ |
| 5882 |
/* .. */ |
| 5883 |
/* .. Local Arrays .. */ |
| 5884 |
/* .. */ |
| 5885 |
/* .. Local Scalars .. */ |
| 5886 |
/* .. */ |
| 5887 |
/* .. Intrinsic Functions .. */ |
| 5888 |
/* .. */ |
| 5889 |
/* .. Executable Statements .. */ |
| 5890 |
|
| 5891 |
/* Parameter adjustments */ |
| 5892 |
--z__; |
| 5893 |
--d__; |
| 5894 |
|
| 5895 |
/* Function Body */ |
| 5896 |
*info = 0; |
| 5897 |
|
| 5898 |
if (*orgati) { |
| 5899 |
lbd = d__[2]; |
| 5900 |
ubd = d__[3]; |
| 5901 |
} else { |
| 5902 |
lbd = d__[1]; |
| 5903 |
ubd = d__[2]; |
| 5904 |
} |
| 5905 |
if (*finit < 0.) { |
| 5906 |
lbd = 0.; |
| 5907 |
} else { |
| 5908 |
ubd = 0.; |
| 5909 |
} |
| 5910 |
|
| 5911 |
niter = 1; |
| 5912 |
*tau = 0.; |
| 5913 |
if (*kniter == 2) { |
| 5914 |
if (*orgati) { |
| 5915 |
temp = (d__[3] - d__[2]) / 2.; |
| 5916 |
c__ = *rho + z__[1] / (d__[1] - d__[2] - temp); |
| 5917 |
a = c__ * (d__[2] + d__[3]) + z__[2] + z__[3]; |
| 5918 |
b = c__ * d__[2] * d__[3] + z__[2] * d__[3] + z__[3] * d__[2]; |
| 5919 |
} else { |
| 5920 |
temp = (d__[1] - d__[2]) / 2.; |
| 5921 |
c__ = *rho + z__[3] / (d__[3] - d__[2] - temp); |
| 5922 |
a = c__ * (d__[1] + d__[2]) + z__[1] + z__[2]; |
| 5923 |
b = c__ * d__[1] * d__[2] + z__[1] * d__[2] + z__[2] * d__[1]; |
| 5924 |
} |
| 5925 |
/* Computing MAX */ |
| 5926 |
d__1 = abs(a), d__2 = abs(b), d__1 = std::max(d__1,d__2), d__2 = abs(c__); |
| 5927 |
temp = std::max(d__1,d__2); |
| 5928 |
a /= temp; |
| 5929 |
b /= temp; |
| 5930 |
c__ /= temp; |
| 5931 |
if (c__ == 0.) { |
| 5932 |
*tau = b / a; |
| 5933 |
} else if (a <= 0.) { |
| 5934 |
*tau = (a - sqrt((d__1 = a * a - b * 4. * c__, abs(d__1)))) / ( |
| 5935 |
c__ * 2.); |
| 5936 |
} else { |
| 5937 |
*tau = b * 2. / (a + sqrt((d__1 = a * a - b * 4. * c__, abs(d__1)) |
| 5938 |
)); |
| 5939 |
} |
| 5940 |
if (*tau < lbd || *tau > ubd) { |
| 5941 |
*tau = (lbd + ubd) / 2.; |
| 5942 |
} |
| 5943 |
if (d__[1] == *tau || d__[2] == *tau || d__[3] == *tau) { |
| 5944 |
*tau = 0.; |
| 5945 |
} else { |
| 5946 |
temp = *finit + *tau * z__[1] / (d__[1] * (d__[1] - *tau)) + *tau |
| 5947 |
* z__[2] / (d__[2] * (d__[2] - *tau)) + *tau * z__[3] / ( |
| 5948 |
d__[3] * (d__[3] - *tau)); |
| 5949 |
if (temp <= 0.) { |
| 5950 |
lbd = *tau; |
| 5951 |
} else { |
| 5952 |
ubd = *tau; |
| 5953 |
} |
| 5954 |
if (abs(*finit) <= abs(temp)) { |
| 5955 |
*tau = 0.; |
| 5956 |
} |
| 5957 |
} |
| 5958 |
} |
| 5959 |
|
| 5960 |
/* get machine parameters for possible scaling to avoid overflow */ |
| 5961 |
|
| 5962 |
/* modified by Sven: parameters SMALL1, SMINV1, SMALL2, */ |
| 5963 |
/* SMINV2, EPS are not SAVEd anymore between one call to the */ |
| 5964 |
/* others but recomputed at each call */ |
| 5965 |
|
| 5966 |
eps = dlamch_("Epsilon"); |
| 5967 |
base = dlamch_("Base"); |
| 5968 |
i__1 = (integer) (log(dlamch_("SafMin")) / log(base) / 3.); |
| 5969 |
small1 = pow_di(&base, &i__1); |
| 5970 |
sminv1 = 1. / small1; |
| 5971 |
small2 = small1 * small1; |
| 5972 |
sminv2 = sminv1 * sminv1; |
| 5973 |
|
| 5974 |
/* Determine if scaling of inputs necessary to avoid overflow */ |
| 5975 |
/* when computing 1/TEMP**3 */ |
| 5976 |
|
| 5977 |
if (*orgati) { |
| 5978 |
/* Computing MIN */ |
| 5979 |
d__3 = (d__1 = d__[2] - *tau, abs(d__1)), d__4 = (d__2 = d__[3] - * |
| 5980 |
tau, abs(d__2)); |
| 5981 |
temp = std::min(d__3,d__4); |
| 5982 |
} else { |
| 5983 |
/* Computing MIN */ |
| 5984 |
d__3 = (d__1 = d__[1] - *tau, abs(d__1)), d__4 = (d__2 = d__[2] - * |
| 5985 |
tau, abs(d__2)); |
| 5986 |
temp = std::min(d__3,d__4); |
| 5987 |
} |
| 5988 |
scale = false; |
| 5989 |
if (temp <= small1) { |
| 5990 |
scale = true; |
| 5991 |
if (temp <= small2) { |
| 5992 |
|
| 5993 |
/* Scale up by power of radix nearest 1/SAFMIN**(2/3) */ |
| 5994 |
|
| 5995 |
sclfac = sminv2; |
| 5996 |
sclinv = small2; |
| 5997 |
} else { |
| 5998 |
|
| 5999 |
/* Scale up by power of radix nearest 1/SAFMIN**(1/3) */ |
| 6000 |
|
| 6001 |
sclfac = sminv1; |
| 6002 |
sclinv = small1; |
| 6003 |
} |
| 6004 |
|
| 6005 |
/* Scaling up safe because D, Z, TAU scaled elsewhere to be O(1) */ |
| 6006 |
|
| 6007 |
for (i__ = 1; i__ <= 3; ++i__) { |
| 6008 |
dscale[i__ - 1] = d__[i__] * sclfac; |
| 6009 |
zscale[i__ - 1] = z__[i__] * sclfac; |
| 6010 |
/* L10: */ |
| 6011 |
} |
| 6012 |
*tau *= sclfac; |
| 6013 |
lbd *= sclfac; |
| 6014 |
ubd *= sclfac; |
| 6015 |
} else { |
| 6016 |
|
| 6017 |
/* Copy D and Z to DSCALE and ZSCALE */ |
| 6018 |
|
| 6019 |
for (i__ = 1; i__ <= 3; ++i__) { |
| 6020 |
dscale[i__ - 1] = d__[i__]; |
| 6021 |
zscale[i__ - 1] = z__[i__]; |
| 6022 |
/* L20: */ |
| 6023 |
} |
| 6024 |
} |
| 6025 |
|
| 6026 |
fc = 0.; |
| 6027 |
df = 0.; |
| 6028 |
ddf = 0.; |
| 6029 |
for (i__ = 1; i__ <= 3; ++i__) { |
| 6030 |
temp = 1. / (dscale[i__ - 1] - *tau); |
| 6031 |
temp1 = zscale[i__ - 1] * temp; |
| 6032 |
temp2 = temp1 * temp; |
| 6033 |
temp3 = temp2 * temp; |
| 6034 |
fc += temp1 / dscale[i__ - 1]; |
| 6035 |
df += temp2; |
| 6036 |
ddf += temp3; |
| 6037 |
/* L30: */ |
| 6038 |
} |
| 6039 |
f = *finit + *tau * fc; |
| 6040 |
|
| 6041 |
if (abs(f) <= 0.) { |
| 6042 |
goto L60; |
| 6043 |
} |
| 6044 |
if (f <= 0.) { |
| 6045 |
lbd = *tau; |
| 6046 |
} else { |
| 6047 |
ubd = *tau; |
| 6048 |
} |
| 6049 |
|
| 6050 |
/* Iteration begins -- Use Gragg-Thornton-Warner cubic convergent */ |
| 6051 |
/* scheme */ |
| 6052 |
|
| 6053 |
/* It is not hard to see that */ |
| 6054 |
|
| 6055 |
/* 1) Iterations will go up monotonically */ |
| 6056 |
/* if FINIT < 0; */ |
| 6057 |
|
| 6058 |
/* 2) Iterations will go down monotonically */ |
| 6059 |
/* if FINIT > 0. */ |
| 6060 |
|
| 6061 |
iter = niter + 1; |
| 6062 |
|
| 6063 |
for (niter = iter; niter <= 40; ++niter) { |
| 6064 |
|
| 6065 |
if (*orgati) { |
| 6066 |
temp1 = dscale[1] - *tau; |
| 6067 |
temp2 = dscale[2] - *tau; |
| 6068 |
} else { |
| 6069 |
temp1 = dscale[0] - *tau; |
| 6070 |
temp2 = dscale[1] - *tau; |
| 6071 |
} |
| 6072 |
a = (temp1 + temp2) * f - temp1 * temp2 * df; |
| 6073 |
b = temp1 * temp2 * f; |
| 6074 |
c__ = f - (temp1 + temp2) * df + temp1 * temp2 * ddf; |
| 6075 |
/* Computing MAX */ |
| 6076 |
d__1 = abs(a), d__2 = abs(b), d__1 = std::max(d__1,d__2), d__2 = abs(c__); |
| 6077 |
temp = std::max(d__1,d__2); |
| 6078 |
a /= temp; |
| 6079 |
b /= temp; |
| 6080 |
c__ /= temp; |
| 6081 |
if (c__ == 0.) { |
| 6082 |
eta = b / a; |
| 6083 |
} else if (a <= 0.) { |
| 6084 |
eta = (a - sqrt((d__1 = a * a - b * 4. * c__, abs(d__1)))) / (c__ |
| 6085 |
* 2.); |
| 6086 |
} else { |
| 6087 |
eta = b * 2. / (a + sqrt((d__1 = a * a - b * 4. * c__, abs(d__1))) |
| 6088 |
); |
| 6089 |
} |
| 6090 |
if (f * eta >= 0.) { |
| 6091 |
eta = -f / df; |
| 6092 |
} |
| 6093 |
|
| 6094 |
*tau += eta; |
| 6095 |
if (*tau < lbd || *tau > ubd) { |
| 6096 |
*tau = (lbd + ubd) / 2.; |
| 6097 |
} |
| 6098 |
|
| 6099 |
fc = 0.; |
| 6100 |
erretm = 0.; |
| 6101 |
df = 0.; |
| 6102 |
ddf = 0.; |
| 6103 |
for (i__ = 1; i__ <= 3; ++i__) { |
| 6104 |
temp = 1. / (dscale[i__ - 1] - *tau); |
| 6105 |
temp1 = zscale[i__ - 1] * temp; |
| 6106 |
temp2 = temp1 * temp; |
| 6107 |
temp3 = temp2 * temp; |
| 6108 |
temp4 = temp1 / dscale[i__ - 1]; |
| 6109 |
fc += temp4; |
| 6110 |
erretm += abs(temp4); |
| 6111 |
df += temp2; |
| 6112 |
ddf += temp3; |
| 6113 |
/* L40: */ |
| 6114 |
} |
| 6115 |
f = *finit + *tau * fc; |
| 6116 |
erretm = (abs(*finit) + abs(*tau) * erretm) * 8. + abs(*tau) * df; |
| 6117 |
if (abs(f) <= eps * erretm) { |
| 6118 |
goto L60; |
| 6119 |
} |
| 6120 |
if (f <= 0.) { |
| 6121 |
lbd = *tau; |
| 6122 |
} else { |
| 6123 |
ubd = *tau; |
| 6124 |
} |
| 6125 |
/* L50: */ |
| 6126 |
} |
| 6127 |
*info = 1; |
| 6128 |
L60: |
| 6129 |
|
| 6130 |
/* Undo scaling */ |
| 6131 |
|
| 6132 |
if (scale) { |
| 6133 |
*tau *= sclinv; |
| 6134 |
} |
| 6135 |
return 0; |
| 6136 |
|
| 6137 |
/* End of DLAED6 */ |
| 6138 |
|
| 6139 |
} /* dlaed6_ */ |
| 6140 |
|
| 6141 |
/* Subroutine */ int dlaed7_(integer *icompq, integer *n, integer *qsiz, |
| 6142 |
integer *tlvls, integer *curlvl, integer *curpbm, double *d__, |
| 6143 |
double *q, integer *ldq, integer *indxq, double *rho, integer |
| 6144 |
*cutpnt, double *qstore, integer *qptr, integer *prmptr, integer * |
| 6145 |
perm, integer *givptr, integer *givcol, double *givnum, |
| 6146 |
double *work, integer *iwork, integer *info) |
| 6147 |
{ |
| 6148 |
/* Table of constant values */ |
| 6149 |
static integer c__2 = 2; |
| 6150 |
static integer c__1 = 1; |
| 6151 |
static double c_b10 = 1.; |
| 6152 |
static double c_b11 = 0.; |
| 6153 |
static integer c_n1 = -1; |
| 6154 |
|
| 6155 |
/* System generated locals */ |
| 6156 |
integer q_dim1, q_offset, i__1, i__2; |
| 6157 |
|
| 6158 |
/* Local variables */ |
| 6159 |
integer i__, k, n1, n2, is, iw, iz, iq2, ptr, ldq2, indx, curr; |
| 6160 |
integer indxc, indxp; |
| 6161 |
integer idlmda; |
| 6162 |
integer coltyp; |
| 6163 |
|
| 6164 |
|
| 6165 |
/* -- LAPACK routine (version 3.1) -- */ |
| 6166 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 6167 |
/* November 2006 */ |
| 6168 |
|
| 6169 |
/* .. Scalar Arguments .. */ |
| 6170 |
/* .. */ |
| 6171 |
/* .. Array Arguments .. */ |
| 6172 |
/* .. */ |
| 6173 |
|
| 6174 |
/* Purpose */ |
| 6175 |
/* ======= */ |
| 6176 |
|
| 6177 |
/* DLAED7 computes the updated eigensystem of a diagonal */ |
| 6178 |
/* matrix after modification by a rank-one symmetric matrix. This */ |
| 6179 |
/* routine is used only for the eigenproblem which requires all */ |
| 6180 |
/* eigenvalues and optionally eigenvectors of a dense symmetric matrix */ |
| 6181 |
/* that has been reduced to tridiagonal form. DLAED1 handles */ |
| 6182 |
/* the case in which all eigenvalues and eigenvectors of a symmetric */ |
| 6183 |
/* tridiagonal matrix are desired. */ |
| 6184 |
|
| 6185 |
/* T = Q(in) ( D(in) + RHO * Z*Z' ) Q'(in) = Q(out) * D(out) * Q'(out) */ |
| 6186 |
|
| 6187 |
/* where Z = Q'u, u is a vector of length N with ones in the */ |
| 6188 |
/* CUTPNT and CUTPNT + 1 th elements and zeros elsewhere. */ |
| 6189 |
|
| 6190 |
/* The eigenvectors of the original matrix are stored in Q, and the */ |
| 6191 |
/* eigenvalues are in D. The algorithm consists of three stages: */ |
| 6192 |
|
| 6193 |
/* The first stage consists of deflating the size of the problem */ |
| 6194 |
/* when there are multiple eigenvalues or if there is a zero in */ |
| 6195 |
/* the Z vector. For each such occurrence the dimension of the */ |
| 6196 |
/* secular equation problem is reduced by one. This stage is */ |
| 6197 |
/* performed by the routine DLAED8. */ |
| 6198 |
|
| 6199 |
/* The second stage consists of calculating the updated */ |
| 6200 |
/* eigenvalues. This is done by finding the roots of the secular */ |
| 6201 |
/* equation via the routine DLAED4 (as called by DLAED9). */ |
| 6202 |
/* This routine also calculates the eigenvectors of the current */ |
| 6203 |
/* problem. */ |
| 6204 |
|
| 6205 |
/* The final stage consists of computing the updated eigenvectors */ |
| 6206 |
/* directly using the updated eigenvalues. The eigenvectors for */ |
| 6207 |
/* the current problem are multiplied with the eigenvectors from */ |
| 6208 |
/* the overall problem. */ |
| 6209 |
|
| 6210 |
/* Arguments */ |
| 6211 |
/* ========= */ |
| 6212 |
|
| 6213 |
/* ICOMPQ (input) INTEGER */ |
| 6214 |
/* = 0: Compute eigenvalues only. */ |
| 6215 |
/* = 1: Compute eigenvectors of original dense symmetric matrix */ |
| 6216 |
/* also. On entry, Q contains the orthogonal matrix used */ |
| 6217 |
/* to reduce the original matrix to tridiagonal form. */ |
| 6218 |
|
| 6219 |
/* N (input) INTEGER */ |
| 6220 |
/* The dimension of the symmetric tridiagonal matrix. N >= 0. */ |
| 6221 |
|
| 6222 |
/* QSIZ (input) INTEGER */ |
| 6223 |
/* The dimension of the orthogonal matrix used to reduce */ |
| 6224 |
/* the full matrix to tridiagonal form. QSIZ >= N if ICOMPQ = 1. */ |
| 6225 |
|
| 6226 |
/* TLVLS (input) INTEGER */ |
| 6227 |
/* The total number of merging levels in the overall divide and */ |
| 6228 |
/* conquer tree. */ |
| 6229 |
|
| 6230 |
/* CURLVL (input) INTEGER */ |
| 6231 |
/* The current level in the overall merge routine, */ |
| 6232 |
/* 0 <= CURLVL <= TLVLS. */ |
| 6233 |
|
| 6234 |
/* CURPBM (input) INTEGER */ |
| 6235 |
/* The current problem in the current level in the overall */ |
| 6236 |
/* merge routine (counting from upper left to lower right). */ |
| 6237 |
|
| 6238 |
/* D (input/output) DOUBLE PRECISION array, dimension (N) */ |
| 6239 |
/* On entry, the eigenvalues of the rank-1-perturbed matrix. */ |
| 6240 |
/* On exit, the eigenvalues of the repaired matrix. */ |
| 6241 |
|
| 6242 |
/* Q (input/output) DOUBLE PRECISION array, dimension (LDQ, N) */ |
| 6243 |
/* On entry, the eigenvectors of the rank-1-perturbed matrix. */ |
| 6244 |
/* On exit, the eigenvectors of the repaired tridiagonal matrix. */ |
| 6245 |
|
| 6246 |
/* LDQ (input) INTEGER */ |
| 6247 |
/* The leading dimension of the array Q. LDQ >= max(1,N). */ |
| 6248 |
|
| 6249 |
/* INDXQ (output) INTEGER array, dimension (N) */ |
| 6250 |
/* The permutation which will reintegrate the subproblem just */ |
| 6251 |
/* solved back into sorted order, i.e., D( INDXQ( I = 1, N ) ) */ |
| 6252 |
/* will be in ascending order. */ |
| 6253 |
|
| 6254 |
/* RHO (input) DOUBLE PRECISION */ |
| 6255 |
/* The subdiagonal element used to create the rank-1 */ |
| 6256 |
/* modification. */ |
| 6257 |
|
| 6258 |
/* CUTPNT (input) INTEGER */ |
| 6259 |
/* Contains the location of the last eigenvalue in the leading */ |
| 6260 |
/* sub-matrix. min(1,N) <= CUTPNT <= N. */ |
| 6261 |
|
| 6262 |
/* QSTORE (input/output) DOUBLE PRECISION array, dimension (N**2+1) */ |
| 6263 |
/* Stores eigenvectors of submatrices encountered during */ |
| 6264 |
/* divide and conquer, packed together. QPTR points to */ |
| 6265 |
/* beginning of the submatrices. */ |
| 6266 |
|
| 6267 |
/* QPTR (input/output) INTEGER array, dimension (N+2) */ |
| 6268 |
/* List of indices pointing to beginning of submatrices stored */ |
| 6269 |
/* in QSTORE. The submatrices are numbered starting at the */ |
| 6270 |
/* bottom left of the divide and conquer tree, from left to */ |
| 6271 |
/* right and bottom to top. */ |
| 6272 |
|
| 6273 |
/* PRMPTR (input) INTEGER array, dimension (N lg N) */ |
| 6274 |
/* Contains a list of pointers which indicate where in PERM a */ |
| 6275 |
/* level's permutation is stored. PRMPTR(i+1) - PRMPTR(i) */ |
| 6276 |
/* indicates the size of the permutation and also the size of */ |
| 6277 |
/* the full, non-deflated problem. */ |
| 6278 |
|
| 6279 |
/* PERM (input) INTEGER array, dimension (N lg N) */ |
| 6280 |
/* Contains the permutations (from deflation and sorting) to be */ |
| 6281 |
/* applied to each eigenblock. */ |
| 6282 |
|
| 6283 |
/* GIVPTR (input) INTEGER array, dimension (N lg N) */ |
| 6284 |
/* Contains a list of pointers which indicate where in GIVCOL a */ |
| 6285 |
/* level's Givens rotations are stored. GIVPTR(i+1) - GIVPTR(i) */ |
| 6286 |
/* indicates the number of Givens rotations. */ |
| 6287 |
|
| 6288 |
/* GIVCOL (input) INTEGER array, dimension (2, N lg N) */ |
| 6289 |
/* Each pair of numbers indicates a pair of columns to take place */ |
| 6290 |
/* in a Givens rotation. */ |
| 6291 |
|
| 6292 |
/* GIVNUM (input) DOUBLE PRECISION array, dimension (2, N lg N) */ |
| 6293 |
/* Each number indicates the S value to be used in the */ |
| 6294 |
/* corresponding Givens rotation. */ |
| 6295 |
|
| 6296 |
/* WORK (workspace) DOUBLE PRECISION array, dimension (3*N+QSIZ*N) */ |
| 6297 |
|
| 6298 |
/* IWORK (workspace) INTEGER array, dimension (4*N) */ |
| 6299 |
|
| 6300 |
/* INFO (output) INTEGER */ |
| 6301 |
/* = 0: successful exit. */ |
| 6302 |
/* < 0: if INFO = -i, the i-th argument had an illegal value. */ |
| 6303 |
/* > 0: if INFO = 1, an eigenvalue did not converge */ |
| 6304 |
|
| 6305 |
/* Further Details */ |
| 6306 |
/* =============== */ |
| 6307 |
|
| 6308 |
/* Based on contributions by */ |
| 6309 |
/* Jeff Rutter, Computer Science Division, University of California */ |
| 6310 |
/* at Berkeley, USA */ |
| 6311 |
|
| 6312 |
/* ===================================================================== */ |
| 6313 |
|
| 6314 |
/* .. Parameters .. */ |
| 6315 |
/* .. */ |
| 6316 |
/* .. Local Scalars .. */ |
| 6317 |
/* .. */ |
| 6318 |
/* .. External Subroutines .. */ |
| 6319 |
/* .. */ |
| 6320 |
/* .. Intrinsic Functions .. */ |
| 6321 |
/* .. */ |
| 6322 |
/* .. Executable Statements .. */ |
| 6323 |
|
| 6324 |
/* Test the input parameters. */ |
| 6325 |
|
| 6326 |
/* Parameter adjustments */ |
| 6327 |
--d__; |
| 6328 |
q_dim1 = *ldq; |
| 6329 |
q_offset = 1 + q_dim1; |
| 6330 |
q -= q_offset; |
| 6331 |
--indxq; |
| 6332 |
--qstore; |
| 6333 |
--qptr; |
| 6334 |
--prmptr; |
| 6335 |
--perm; |
| 6336 |
--givptr; |
| 6337 |
givcol -= 3; |
| 6338 |
givnum -= 3; |
| 6339 |
--work; |
| 6340 |
--iwork; |
| 6341 |
|
| 6342 |
/* Function Body */ |
| 6343 |
*info = 0; |
| 6344 |
|
| 6345 |
if (*icompq < 0 || *icompq > 1) { |
| 6346 |
*info = -1; |
| 6347 |
} else if (*n < 0) { |
| 6348 |
*info = -2; |
| 6349 |
} else if (*icompq == 1 && *qsiz < *n) { |
| 6350 |
*info = -4; |
| 6351 |
} else if (*ldq < std::max(1_integer,*n)) { |
| 6352 |
*info = -9; |
| 6353 |
} else if (std::min(1_integer,*n) > *cutpnt || *n < *cutpnt) { |
| 6354 |
*info = -12; |
| 6355 |
} |
| 6356 |
if (*info != 0) { |
| 6357 |
i__1 = -(*info); |
| 6358 |
xerbla_("DLAED7", &i__1); |
| 6359 |
return 0; |
| 6360 |
} |
| 6361 |
|
| 6362 |
/* Quick return if possible */ |
| 6363 |
|
| 6364 |
if (*n == 0) { |
| 6365 |
return 0; |
| 6366 |
} |
| 6367 |
|
| 6368 |
/* The following values are for bookkeeping purposes only. They are */ |
| 6369 |
/* integer pointers which indicate the portion of the workspace */ |
| 6370 |
/* used by a particular array in DLAED8 and DLAED9. */ |
| 6371 |
|
| 6372 |
if (*icompq == 1) { |
| 6373 |
ldq2 = *qsiz; |
| 6374 |
} else { |
| 6375 |
ldq2 = *n; |
| 6376 |
} |
| 6377 |
|
| 6378 |
iz = 1; |
| 6379 |
idlmda = iz + *n; |
| 6380 |
iw = idlmda + *n; |
| 6381 |
iq2 = iw + *n; |
| 6382 |
is = iq2 + *n * ldq2; |
| 6383 |
|
| 6384 |
indx = 1; |
| 6385 |
indxc = indx + *n; |
| 6386 |
coltyp = indxc + *n; |
| 6387 |
indxp = coltyp + *n; |
| 6388 |
|
| 6389 |
/* Form the z-vector which consists of the last row of Q_1 and the */ |
| 6390 |
/* first row of Q_2. */ |
| 6391 |
|
| 6392 |
ptr = pow_ii(&c__2, tlvls) + 1; |
| 6393 |
i__1 = *curlvl - 1; |
| 6394 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 6395 |
i__2 = *tlvls - i__; |
| 6396 |
ptr += pow_ii(&c__2, &i__2); |
| 6397 |
/* L10: */ |
| 6398 |
} |
| 6399 |
curr = ptr + *curpbm; |
| 6400 |
dlaeda_(n, tlvls, curlvl, curpbm, &prmptr[1], &perm[1], &givptr[1], & |
| 6401 |
givcol[3], &givnum[3], &qstore[1], &qptr[1], &work[iz], &work[iz |
| 6402 |
+ *n], info); |
| 6403 |
|
| 6404 |
/* When solving the final problem, we no longer need the stored data, */ |
| 6405 |
/* so we will overwrite the data from this level onto the previously */ |
| 6406 |
/* used storage space. */ |
| 6407 |
|
| 6408 |
if (*curlvl == *tlvls) { |
| 6409 |
qptr[curr] = 1; |
| 6410 |
prmptr[curr] = 1; |
| 6411 |
givptr[curr] = 1; |
| 6412 |
} |
| 6413 |
|
| 6414 |
/* Sort and Deflate eigenvalues. */ |
| 6415 |
|
| 6416 |
dlaed8_(icompq, &k, n, qsiz, &d__[1], &q[q_offset], ldq, &indxq[1], rho, |
| 6417 |
cutpnt, &work[iz], &work[idlmda], &work[iq2], &ldq2, &work[iw], & |
| 6418 |
perm[prmptr[curr]], &givptr[curr + 1], &givcol[(givptr[curr] << 1) |
| 6419 |
+ 1], &givnum[(givptr[curr] << 1) + 1], &iwork[indxp], &iwork[ |
| 6420 |
indx], info); |
| 6421 |
prmptr[curr + 1] = prmptr[curr] + *n; |
| 6422 |
givptr[curr + 1] += givptr[curr]; |
| 6423 |
|
| 6424 |
/* Solve Secular Equation. */ |
| 6425 |
|
| 6426 |
if (k != 0) { |
| 6427 |
dlaed9_(&k, &c__1, &k, n, &d__[1], &work[is], &k, rho, &work[idlmda], |
| 6428 |
&work[iw], &qstore[qptr[curr]], &k, info); |
| 6429 |
if (*info != 0) { |
| 6430 |
goto L30; |
| 6431 |
} |
| 6432 |
if (*icompq == 1) { |
| 6433 |
dgemm_("N", "N", qsiz, &k, &k, &c_b10, &work[iq2], &ldq2, &qstore[ |
| 6434 |
qptr[curr]], &k, &c_b11, &q[q_offset], ldq); |
| 6435 |
} |
| 6436 |
/* Computing 2nd power */ |
| 6437 |
i__1 = k; |
| 6438 |
qptr[curr + 1] = qptr[curr] + i__1 * i__1; |
| 6439 |
|
| 6440 |
/* Prepare the INDXQ sorting permutation. */ |
| 6441 |
|
| 6442 |
n1 = k; |
| 6443 |
n2 = *n - k; |
| 6444 |
dlamrg_(&n1, &n2, &d__[1], &c__1, &c_n1, &indxq[1]); |
| 6445 |
} else { |
| 6446 |
qptr[curr + 1] = qptr[curr]; |
| 6447 |
i__1 = *n; |
| 6448 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 6449 |
indxq[i__] = i__; |
| 6450 |
/* L20: */ |
| 6451 |
} |
| 6452 |
} |
| 6453 |
|
| 6454 |
L30: |
| 6455 |
return 0; |
| 6456 |
|
| 6457 |
/* End of DLAED7 */ |
| 6458 |
|
| 6459 |
} /* dlaed7_ */ |
| 6460 |
|
| 6461 |
/* Subroutine */ int dlaed8_(integer *icompq, integer *k, integer *n, integer |
| 6462 |
*qsiz, double *d__, double *q, integer *ldq, integer *indxq, |
| 6463 |
double *rho, integer *cutpnt, double *z__, double *dlamda, |
| 6464 |
double *q2, integer *ldq2, double *w, integer *perm, integer |
| 6465 |
*givptr, integer *givcol, double *givnum, integer *indxp, integer |
| 6466 |
*indx, integer *info) |
| 6467 |
{ |
| 6468 |
/* Table of constant values */ |
| 6469 |
static double c_b3 = -1.; |
| 6470 |
static integer c__1 = 1; |
| 6471 |
|
| 6472 |
/* System generated locals */ |
| 6473 |
integer q_dim1, q_offset, q2_dim1, q2_offset, i__1; |
| 6474 |
double d__1; |
| 6475 |
|
| 6476 |
/* Local variables */ |
| 6477 |
double c__; |
| 6478 |
integer i__, j; |
| 6479 |
double s, t; |
| 6480 |
integer k2, n1, n2, jp, n1p1; |
| 6481 |
double eps, tau, tol; |
| 6482 |
integer jlam, imax, jmax; |
| 6483 |
|
| 6484 |
/* -- LAPACK routine (version 3.1) -- */ |
| 6485 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 6486 |
/* November 2006 */ |
| 6487 |
|
| 6488 |
/* .. Scalar Arguments .. */ |
| 6489 |
/* .. */ |
| 6490 |
/* .. Array Arguments .. */ |
| 6491 |
/* .. */ |
| 6492 |
|
| 6493 |
/* Purpose */ |
| 6494 |
/* ======= */ |
| 6495 |
|
| 6496 |
/* DLAED8 merges the two sets of eigenvalues together into a single */ |
| 6497 |
/* sorted set. Then it tries to deflate the size of the problem. */ |
| 6498 |
/* There are two ways in which deflation can occur: when two or more */ |
| 6499 |
/* eigenvalues are close together or if there is a tiny element in the */ |
| 6500 |
/* Z vector. For each such occurrence the order of the related secular */ |
| 6501 |
/* equation problem is reduced by one. */ |
| 6502 |
|
| 6503 |
/* Arguments */ |
| 6504 |
/* ========= */ |
| 6505 |
|
| 6506 |
/* ICOMPQ (input) INTEGER */ |
| 6507 |
/* = 0: Compute eigenvalues only. */ |
| 6508 |
/* = 1: Compute eigenvectors of original dense symmetric matrix */ |
| 6509 |
/* also. On entry, Q contains the orthogonal matrix used */ |
| 6510 |
/* to reduce the original matrix to tridiagonal form. */ |
| 6511 |
|
| 6512 |
/* K (output) INTEGER */ |
| 6513 |
/* The number of non-deflated eigenvalues, and the order of the */ |
| 6514 |
/* related secular equation. */ |
| 6515 |
|
| 6516 |
/* N (input) INTEGER */ |
| 6517 |
/* The dimension of the symmetric tridiagonal matrix. N >= 0. */ |
| 6518 |
|
| 6519 |
/* QSIZ (input) INTEGER */ |
| 6520 |
/* The dimension of the orthogonal matrix used to reduce */ |
| 6521 |
/* the full matrix to tridiagonal form. QSIZ >= N if ICOMPQ = 1. */ |
| 6522 |
|
| 6523 |
/* D (input/output) DOUBLE PRECISION array, dimension (N) */ |
| 6524 |
/* On entry, the eigenvalues of the two submatrices to be */ |
| 6525 |
/* combined. On exit, the trailing (N-K) updated eigenvalues */ |
| 6526 |
/* (those which were deflated) sorted into increasing order. */ |
| 6527 |
|
| 6528 |
/* Q (input/output) DOUBLE PRECISION array, dimension (LDQ,N) */ |
| 6529 |
/* If ICOMPQ = 0, Q is not referenced. Otherwise, */ |
| 6530 |
/* on entry, Q contains the eigenvectors of the partially solved */ |
| 6531 |
/* system which has been previously updated in matrix */ |
| 6532 |
/* multiplies with other partially solved eigensystems. */ |
| 6533 |
/* On exit, Q contains the trailing (N-K) updated eigenvectors */ |
| 6534 |
/* (those which were deflated) in its last N-K columns. */ |
| 6535 |
|
| 6536 |
/* LDQ (input) INTEGER */ |
| 6537 |
/* The leading dimension of the array Q. LDQ >= max(1,N). */ |
| 6538 |
|
| 6539 |
/* INDXQ (input) INTEGER array, dimension (N) */ |
| 6540 |
/* The permutation which separately sorts the two sub-problems */ |
| 6541 |
/* in D into ascending order. Note that elements in the second */ |
| 6542 |
/* half of this permutation must first have CUTPNT added to */ |
| 6543 |
/* their values in order to be accurate. */ |
| 6544 |
|
| 6545 |
/* RHO (input/output) DOUBLE PRECISION */ |
| 6546 |
/* On entry, the off-diagonal element associated with the rank-1 */ |
| 6547 |
/* cut which originally split the two submatrices which are now */ |
| 6548 |
/* being recombined. */ |
| 6549 |
/* On exit, RHO has been modified to the value required by */ |
| 6550 |
/* DLAED3. */ |
| 6551 |
|
| 6552 |
/* CUTPNT (input) INTEGER */ |
| 6553 |
/* The location of the last eigenvalue in the leading */ |
| 6554 |
/* sub-matrix. min(1,N) <= CUTPNT <= N. */ |
| 6555 |
|
| 6556 |
/* Z (input) DOUBLE PRECISION array, dimension (N) */ |
| 6557 |
/* On entry, Z contains the updating vector (the last row of */ |
| 6558 |
/* the first sub-eigenvector matrix and the first row of the */ |
| 6559 |
/* second sub-eigenvector matrix). */ |
| 6560 |
/* On exit, the contents of Z are destroyed by the updating */ |
| 6561 |
/* process. */ |
| 6562 |
|
| 6563 |
/* DLAMDA (output) DOUBLE PRECISION array, dimension (N) */ |
| 6564 |
/* A copy of the first K eigenvalues which will be used by */ |
| 6565 |
/* DLAED3 to form the secular equation. */ |
| 6566 |
|
| 6567 |
/* Q2 (output) DOUBLE PRECISION array, dimension (LDQ2,N) */ |
| 6568 |
/* If ICOMPQ = 0, Q2 is not referenced. Otherwise, */ |
| 6569 |
/* a copy of the first K eigenvectors which will be used by */ |
| 6570 |
/* DLAED7 in a matrix multiply (DGEMM) to update the new */ |
| 6571 |
/* eigenvectors. */ |
| 6572 |
|
| 6573 |
/* LDQ2 (input) INTEGER */ |
| 6574 |
/* The leading dimension of the array Q2. LDQ2 >= max(1,N). */ |
| 6575 |
|
| 6576 |
/* W (output) DOUBLE PRECISION array, dimension (N) */ |
| 6577 |
/* The first k values of the final deflation-altered z-vector and */ |
| 6578 |
/* will be passed to DLAED3. */ |
| 6579 |
|
| 6580 |
/* PERM (output) INTEGER array, dimension (N) */ |
| 6581 |
/* The permutations (from deflation and sorting) to be applied */ |
| 6582 |
/* to each eigenblock. */ |
| 6583 |
|
| 6584 |
/* GIVPTR (output) INTEGER */ |
| 6585 |
/* The number of Givens rotations which took place in this */ |
| 6586 |
/* subproblem. */ |
| 6587 |
|
| 6588 |
/* GIVCOL (output) INTEGER array, dimension (2, N) */ |
| 6589 |
/* Each pair of numbers indicates a pair of columns to take place */ |
| 6590 |
/* in a Givens rotation. */ |
| 6591 |
|
| 6592 |
/* GIVNUM (output) DOUBLE PRECISION array, dimension (2, N) */ |
| 6593 |
/* Each number indicates the S value to be used in the */ |
| 6594 |
/* corresponding Givens rotation. */ |
| 6595 |
|
| 6596 |
/* INDXP (workspace) INTEGER array, dimension (N) */ |
| 6597 |
/* The permutation used to place deflated values of D at the end */ |
| 6598 |
/* of the array. INDXP(1:K) points to the nondeflated D-values */ |
| 6599 |
/* and INDXP(K+1:N) points to the deflated eigenvalues. */ |
| 6600 |
|
| 6601 |
/* INDX (workspace) INTEGER array, dimension (N) */ |
| 6602 |
/* The permutation used to sort the contents of D into ascending */ |
| 6603 |
/* order. */ |
| 6604 |
|
| 6605 |
/* INFO (output) INTEGER */ |
| 6606 |
/* = 0: successful exit. */ |
| 6607 |
/* < 0: if INFO = -i, the i-th argument had an illegal value. */ |
| 6608 |
|
| 6609 |
/* Further Details */ |
| 6610 |
/* =============== */ |
| 6611 |
|
| 6612 |
/* Based on contributions by */ |
| 6613 |
/* Jeff Rutter, Computer Science Division, University of California */ |
| 6614 |
/* at Berkeley, USA */ |
| 6615 |
|
| 6616 |
/* ===================================================================== */ |
| 6617 |
|
| 6618 |
/* .. Parameters .. */ |
| 6619 |
/* .. */ |
| 6620 |
/* .. Local Scalars .. */ |
| 6621 |
|
| 6622 |
/* .. */ |
| 6623 |
/* .. External Functions .. */ |
| 6624 |
/* .. */ |
| 6625 |
/* .. External Subroutines .. */ |
| 6626 |
/* .. */ |
| 6627 |
/* .. Intrinsic Functions .. */ |
| 6628 |
/* .. */ |
| 6629 |
/* .. Executable Statements .. */ |
| 6630 |
|
| 6631 |
/* Test the input parameters. */ |
| 6632 |
|
| 6633 |
/* Parameter adjustments */ |
| 6634 |
--d__; |
| 6635 |
q_dim1 = *ldq; |
| 6636 |
q_offset = 1 + q_dim1; |
| 6637 |
q -= q_offset; |
| 6638 |
--indxq; |
| 6639 |
--z__; |
| 6640 |
--dlamda; |
| 6641 |
q2_dim1 = *ldq2; |
| 6642 |
q2_offset = 1 + q2_dim1; |
| 6643 |
q2 -= q2_offset; |
| 6644 |
--w; |
| 6645 |
--perm; |
| 6646 |
givcol -= 3; |
| 6647 |
givnum -= 3; |
| 6648 |
--indxp; |
| 6649 |
--indx; |
| 6650 |
|
| 6651 |
/* Function Body */ |
| 6652 |
*info = 0; |
| 6653 |
|
| 6654 |
if (*icompq < 0 || *icompq > 1) { |
| 6655 |
*info = -1; |
| 6656 |
} else if (*n < 0) { |
| 6657 |
*info = -3; |
| 6658 |
} else if (*icompq == 1 && *qsiz < *n) { |
| 6659 |
*info = -4; |
| 6660 |
} else if (*ldq < std::max(1_integer,*n)) { |
| 6661 |
*info = -7; |
| 6662 |
} else if (*cutpnt < std::min(1_integer,*n) || *cutpnt > *n) { |
| 6663 |
*info = -10; |
| 6664 |
} else if (*ldq2 < std::max(1_integer,*n)) { |
| 6665 |
*info = -14; |
| 6666 |
} |
| 6667 |
if (*info != 0) { |
| 6668 |
i__1 = -(*info); |
| 6669 |
xerbla_("DLAED8", &i__1); |
| 6670 |
return 0; |
| 6671 |
} |
| 6672 |
|
| 6673 |
/* Quick return if possible */ |
| 6674 |
|
| 6675 |
if (*n == 0) { |
| 6676 |
return 0; |
| 6677 |
} |
| 6678 |
|
| 6679 |
n1 = *cutpnt; |
| 6680 |
n2 = *n - n1; |
| 6681 |
n1p1 = n1 + 1; |
| 6682 |
|
| 6683 |
if (*rho < 0.) { |
| 6684 |
dscal_(&n2, &c_b3, &z__[n1p1], &c__1); |
| 6685 |
} |
| 6686 |
|
| 6687 |
/* Normalize z so that norm(z) = 1 */ |
| 6688 |
|
| 6689 |
t = 1. / sqrt(2.); |
| 6690 |
i__1 = *n; |
| 6691 |
for (j = 1; j <= i__1; ++j) { |
| 6692 |
indx[j] = j; |
| 6693 |
/* L10: */ |
| 6694 |
} |
| 6695 |
dscal_(n, &t, &z__[1], &c__1); |
| 6696 |
*rho = (d__1 = *rho * 2., abs(d__1)); |
| 6697 |
|
| 6698 |
/* Sort the eigenvalues into increasing order */ |
| 6699 |
|
| 6700 |
i__1 = *n; |
| 6701 |
for (i__ = *cutpnt + 1; i__ <= i__1; ++i__) { |
| 6702 |
indxq[i__] += *cutpnt; |
| 6703 |
/* L20: */ |
| 6704 |
} |
| 6705 |
i__1 = *n; |
| 6706 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 6707 |
dlamda[i__] = d__[indxq[i__]]; |
| 6708 |
w[i__] = z__[indxq[i__]]; |
| 6709 |
/* L30: */ |
| 6710 |
} |
| 6711 |
i__ = 1; |
| 6712 |
j = *cutpnt + 1; |
| 6713 |
dlamrg_(&n1, &n2, &dlamda[1], &c__1, &c__1, &indx[1]); |
| 6714 |
i__1 = *n; |
| 6715 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 6716 |
d__[i__] = dlamda[indx[i__]]; |
| 6717 |
z__[i__] = w[indx[i__]]; |
| 6718 |
/* L40: */ |
| 6719 |
} |
| 6720 |
|
| 6721 |
/* Calculate the allowable deflation tolerence */ |
| 6722 |
|
| 6723 |
imax = idamax_(n, &z__[1], &c__1); |
| 6724 |
jmax = idamax_(n, &d__[1], &c__1); |
| 6725 |
eps = dlamch_("Epsilon"); |
| 6726 |
tol = eps * 8. * (d__1 = d__[jmax], abs(d__1)); |
| 6727 |
|
| 6728 |
/* If the rank-1 modifier is small enough, no more needs to be done */ |
| 6729 |
/* except to reorganize Q so that its columns correspond with the */ |
| 6730 |
/* elements in D. */ |
| 6731 |
|
| 6732 |
if (*rho * (d__1 = z__[imax], abs(d__1)) <= tol) { |
| 6733 |
*k = 0; |
| 6734 |
if (*icompq == 0) { |
| 6735 |
i__1 = *n; |
| 6736 |
for (j = 1; j <= i__1; ++j) { |
| 6737 |
perm[j] = indxq[indx[j]]; |
| 6738 |
/* L50: */ |
| 6739 |
} |
| 6740 |
} else { |
| 6741 |
i__1 = *n; |
| 6742 |
for (j = 1; j <= i__1; ++j) { |
| 6743 |
perm[j] = indxq[indx[j]]; |
| 6744 |
dcopy_(qsiz, &q[perm[j] * q_dim1 + 1], &c__1, &q2[j * q2_dim1 |
| 6745 |
+ 1], &c__1); |
| 6746 |
/* L60: */ |
| 6747 |
} |
| 6748 |
dlacpy_("A", qsiz, n, &q2[q2_dim1 + 1], ldq2, &q[q_dim1 + 1], ldq); |
| 6749 |
} |
| 6750 |
return 0; |
| 6751 |
} |
| 6752 |
|
| 6753 |
/* If there are multiple eigenvalues then the problem deflates. Here */ |
| 6754 |
/* the number of equal eigenvalues are found. As each equal */ |
| 6755 |
/* eigenvalue is found, an elementary reflector is computed to rotate */ |
| 6756 |
/* the corresponding eigensubspace so that the corresponding */ |
| 6757 |
/* components of Z are zero in this new basis. */ |
| 6758 |
|
| 6759 |
*k = 0; |
| 6760 |
*givptr = 0; |
| 6761 |
k2 = *n + 1; |
| 6762 |
i__1 = *n; |
| 6763 |
for (j = 1; j <= i__1; ++j) { |
| 6764 |
if (*rho * (d__1 = z__[j], abs(d__1)) <= tol) { |
| 6765 |
|
| 6766 |
/* Deflate due to small z component. */ |
| 6767 |
|
| 6768 |
--k2; |
| 6769 |
indxp[k2] = j; |
| 6770 |
if (j == *n) { |
| 6771 |
goto L110; |
| 6772 |
} |
| 6773 |
} else { |
| 6774 |
jlam = j; |
| 6775 |
goto L80; |
| 6776 |
} |
| 6777 |
/* L70: */ |
| 6778 |
} |
| 6779 |
L80: |
| 6780 |
++j; |
| 6781 |
if (j > *n) { |
| 6782 |
goto L100; |
| 6783 |
} |
| 6784 |
if (*rho * (d__1 = z__[j], abs(d__1)) <= tol) { |
| 6785 |
|
| 6786 |
/* Deflate due to small z component. */ |
| 6787 |
|
| 6788 |
--k2; |
| 6789 |
indxp[k2] = j; |
| 6790 |
} else { |
| 6791 |
|
| 6792 |
/* Check if eigenvalues are close enough to allow deflation. */ |
| 6793 |
|
| 6794 |
s = z__[jlam]; |
| 6795 |
c__ = z__[j]; |
| 6796 |
|
| 6797 |
/* Find sqrt(a**2+b**2) without overflow or */ |
| 6798 |
/* destructive underflow. */ |
| 6799 |
|
| 6800 |
tau = dlapy2_(&c__, &s); |
| 6801 |
t = d__[j] - d__[jlam]; |
| 6802 |
c__ /= tau; |
| 6803 |
s = -s / tau; |
| 6804 |
if ((d__1 = t * c__ * s, abs(d__1)) <= tol) { |
| 6805 |
|
| 6806 |
/* Deflation is possible. */ |
| 6807 |
|
| 6808 |
z__[j] = tau; |
| 6809 |
z__[jlam] = 0.; |
| 6810 |
|
| 6811 |
/* Record the appropriate Givens rotation */ |
| 6812 |
|
| 6813 |
++(*givptr); |
| 6814 |
givcol[(*givptr << 1) + 1] = indxq[indx[jlam]]; |
| 6815 |
givcol[(*givptr << 1) + 2] = indxq[indx[j]]; |
| 6816 |
givnum[(*givptr << 1) + 1] = c__; |
| 6817 |
givnum[(*givptr << 1) + 2] = s; |
| 6818 |
if (*icompq == 1) { |
| 6819 |
drot_(qsiz, &q[indxq[indx[jlam]] * q_dim1 + 1], &c__1, &q[ |
| 6820 |
indxq[indx[j]] * q_dim1 + 1], &c__1, &c__, &s); |
| 6821 |
} |
| 6822 |
t = d__[jlam] * c__ * c__ + d__[j] * s * s; |
| 6823 |
d__[j] = d__[jlam] * s * s + d__[j] * c__ * c__; |
| 6824 |
d__[jlam] = t; |
| 6825 |
--k2; |
| 6826 |
i__ = 1; |
| 6827 |
L90: |
| 6828 |
if (k2 + i__ <= *n) { |
| 6829 |
if (d__[jlam] < d__[indxp[k2 + i__]]) { |
| 6830 |
indxp[k2 + i__ - 1] = indxp[k2 + i__]; |
| 6831 |
indxp[k2 + i__] = jlam; |
| 6832 |
++i__; |
| 6833 |
goto L90; |
| 6834 |
} else { |
| 6835 |
indxp[k2 + i__ - 1] = jlam; |
| 6836 |
} |
| 6837 |
} else { |
| 6838 |
indxp[k2 + i__ - 1] = jlam; |
| 6839 |
} |
| 6840 |
jlam = j; |
| 6841 |
} else { |
| 6842 |
++(*k); |
| 6843 |
w[*k] = z__[jlam]; |
| 6844 |
dlamda[*k] = d__[jlam]; |
| 6845 |
indxp[*k] = jlam; |
| 6846 |
jlam = j; |
| 6847 |
} |
| 6848 |
} |
| 6849 |
goto L80; |
| 6850 |
L100: |
| 6851 |
|
| 6852 |
/* Record the last eigenvalue. */ |
| 6853 |
|
| 6854 |
++(*k); |
| 6855 |
w[*k] = z__[jlam]; |
| 6856 |
dlamda[*k] = d__[jlam]; |
| 6857 |
indxp[*k] = jlam; |
| 6858 |
|
| 6859 |
L110: |
| 6860 |
|
| 6861 |
/* Sort the eigenvalues and corresponding eigenvectors into DLAMDA */ |
| 6862 |
/* and Q2 respectively. The eigenvalues/vectors which were not */ |
| 6863 |
/* deflated go into the first K slots of DLAMDA and Q2 respectively, */ |
| 6864 |
/* while those which were deflated go into the last N - K slots. */ |
| 6865 |
|
| 6866 |
if (*icompq == 0) { |
| 6867 |
i__1 = *n; |
| 6868 |
for (j = 1; j <= i__1; ++j) { |
| 6869 |
jp = indxp[j]; |
| 6870 |
dlamda[j] = d__[jp]; |
| 6871 |
perm[j] = indxq[indx[jp]]; |
| 6872 |
/* L120: */ |
| 6873 |
} |
| 6874 |
} else { |
| 6875 |
i__1 = *n; |
| 6876 |
for (j = 1; j <= i__1; ++j) { |
| 6877 |
jp = indxp[j]; |
| 6878 |
dlamda[j] = d__[jp]; |
| 6879 |
perm[j] = indxq[indx[jp]]; |
| 6880 |
dcopy_(qsiz, &q[perm[j] * q_dim1 + 1], &c__1, &q2[j * q2_dim1 + 1] |
| 6881 |
, &c__1); |
| 6882 |
/* L130: */ |
| 6883 |
} |
| 6884 |
} |
| 6885 |
|
| 6886 |
/* The deflated eigenvalues and their corresponding vectors go back */ |
| 6887 |
/* into the last N - K slots of D and Q respectively. */ |
| 6888 |
|
| 6889 |
if (*k < *n) { |
| 6890 |
if (*icompq == 0) { |
| 6891 |
i__1 = *n - *k; |
| 6892 |
dcopy_(&i__1, &dlamda[*k + 1], &c__1, &d__[*k + 1], &c__1); |
| 6893 |
} else { |
| 6894 |
i__1 = *n - *k; |
| 6895 |
dcopy_(&i__1, &dlamda[*k + 1], &c__1, &d__[*k + 1], &c__1); |
| 6896 |
i__1 = *n - *k; |
| 6897 |
dlacpy_("A", qsiz, &i__1, &q2[(*k + 1) * q2_dim1 + 1], ldq2, &q[(* |
| 6898 |
k + 1) * q_dim1 + 1], ldq); |
| 6899 |
} |
| 6900 |
} |
| 6901 |
|
| 6902 |
return 0; |
| 6903 |
|
| 6904 |
/* End of DLAED8 */ |
| 6905 |
|
| 6906 |
} /* dlaed8_ */ |
| 6907 |
|
| 6908 |
/* Subroutine */ int dlaed9_(integer *k, integer *kstart, integer *kstop, |
| 6909 |
integer *n, double *d__, double *q, integer *ldq, double * |
| 6910 |
rho, double *dlamda, double *w, double *s, integer *lds, |
| 6911 |
integer *info) |
| 6912 |
{ |
| 6913 |
/* Table of constant values */ |
| 6914 |
static integer c__1 = 1; |
| 6915 |
|
| 6916 |
/* System generated locals */ |
| 6917 |
integer q_dim1, q_offset, s_dim1, s_offset, i__1, i__2; |
| 6918 |
double d__1; |
| 6919 |
|
| 6920 |
/* Local variables */ |
| 6921 |
integer i__, j; |
| 6922 |
double temp; |
| 6923 |
|
| 6924 |
|
| 6925 |
/* -- LAPACK routine (version 3.1) -- */ |
| 6926 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 6927 |
/* November 2006 */ |
| 6928 |
|
| 6929 |
/* .. Scalar Arguments .. */ |
| 6930 |
/* .. */ |
| 6931 |
/* .. Array Arguments .. */ |
| 6932 |
/* .. */ |
| 6933 |
|
| 6934 |
/* Purpose */ |
| 6935 |
/* ======= */ |
| 6936 |
|
| 6937 |
/* DLAED9 finds the roots of the secular equation, as defined by the */ |
| 6938 |
/* values in D, Z, and RHO, between KSTART and KSTOP. It makes the */ |
| 6939 |
/* appropriate calls to DLAED4 and then stores the new matrix of */ |
| 6940 |
/* eigenvectors for use in calculating the next level of Z vectors. */ |
| 6941 |
|
| 6942 |
/* Arguments */ |
| 6943 |
/* ========= */ |
| 6944 |
|
| 6945 |
/* K (input) INTEGER */ |
| 6946 |
/* The number of terms in the rational function to be solved by */ |
| 6947 |
/* DLAED4. K >= 0. */ |
| 6948 |
|
| 6949 |
/* KSTART (input) INTEGER */ |
| 6950 |
/* KSTOP (input) INTEGER */ |
| 6951 |
/* The updated eigenvalues Lambda(I), KSTART <= I <= KSTOP */ |
| 6952 |
/* are to be computed. 1 <= KSTART <= KSTOP <= K. */ |
| 6953 |
|
| 6954 |
/* N (input) INTEGER */ |
| 6955 |
/* The number of rows and columns in the Q matrix. */ |
| 6956 |
/* N >= K (delation may result in N > K). */ |
| 6957 |
|
| 6958 |
/* D (output) DOUBLE PRECISION array, dimension (N) */ |
| 6959 |
/* D(I) contains the updated eigenvalues */ |
| 6960 |
/* for KSTART <= I <= KSTOP. */ |
| 6961 |
|
| 6962 |
/* Q (workspace) DOUBLE PRECISION array, dimension (LDQ,N) */ |
| 6963 |
|
| 6964 |
/* LDQ (input) INTEGER */ |
| 6965 |
/* The leading dimension of the array Q. LDQ >= max( 1, N ). */ |
| 6966 |
|
| 6967 |
/* RHO (input) DOUBLE PRECISION */ |
| 6968 |
/* The value of the parameter in the rank one update equation. */ |
| 6969 |
/* RHO >= 0 required. */ |
| 6970 |
|
| 6971 |
/* DLAMDA (input) DOUBLE PRECISION array, dimension (K) */ |
| 6972 |
/* The first K elements of this array contain the old roots */ |
| 6973 |
/* of the deflated updating problem. These are the poles */ |
| 6974 |
/* of the secular equation. */ |
| 6975 |
|
| 6976 |
/* W (input) DOUBLE PRECISION array, dimension (K) */ |
| 6977 |
/* The first K elements of this array contain the components */ |
| 6978 |
/* of the deflation-adjusted updating vector. */ |
| 6979 |
|
| 6980 |
/* S (output) DOUBLE PRECISION array, dimension (LDS, K) */ |
| 6981 |
/* Will contain the eigenvectors of the repaired matrix which */ |
| 6982 |
/* will be stored for subsequent Z vector calculation and */ |
| 6983 |
/* multiplied by the previously accumulated eigenvectors */ |
| 6984 |
/* to update the system. */ |
| 6985 |
|
| 6986 |
/* LDS (input) INTEGER */ |
| 6987 |
/* The leading dimension of S. LDS >= max( 1, K ). */ |
| 6988 |
|
| 6989 |
/* INFO (output) INTEGER */ |
| 6990 |
/* = 0: successful exit. */ |
| 6991 |
/* < 0: if INFO = -i, the i-th argument had an illegal value. */ |
| 6992 |
/* > 0: if INFO = 1, an eigenvalue did not converge */ |
| 6993 |
|
| 6994 |
/* Further Details */ |
| 6995 |
/* =============== */ |
| 6996 |
|
| 6997 |
/* Based on contributions by */ |
| 6998 |
/* Jeff Rutter, Computer Science Division, University of California */ |
| 6999 |
/* at Berkeley, USA */ |
| 7000 |
|
| 7001 |
/* ===================================================================== */ |
| 7002 |
|
| 7003 |
/* .. Local Scalars .. */ |
| 7004 |
/* .. */ |
| 7005 |
/* .. External Functions .. */ |
| 7006 |
/* .. */ |
| 7007 |
/* .. External Subroutines .. */ |
| 7008 |
/* .. */ |
| 7009 |
/* .. Intrinsic Functions .. */ |
| 7010 |
/* .. */ |
| 7011 |
/* .. Executable Statements .. */ |
| 7012 |
|
| 7013 |
/* Test the input parameters. */ |
| 7014 |
|
| 7015 |
/* Parameter adjustments */ |
| 7016 |
--d__; |
| 7017 |
q_dim1 = *ldq; |
| 7018 |
q_offset = 1 + q_dim1; |
| 7019 |
q -= q_offset; |
| 7020 |
--dlamda; |
| 7021 |
--w; |
| 7022 |
s_dim1 = *lds; |
| 7023 |
s_offset = 1 + s_dim1; |
| 7024 |
s -= s_offset; |
| 7025 |
|
| 7026 |
/* Function Body */ |
| 7027 |
*info = 0; |
| 7028 |
|
| 7029 |
if (*k < 0) { |
| 7030 |
*info = -1; |
| 7031 |
} else if (*kstart < 1 || *kstart > std::max(1_integer,*k)) { |
| 7032 |
*info = -2; |
| 7033 |
} else if (std::max(1_integer,*kstop) < *kstart || *kstop > std::max(1_integer,*k)) { |
| 7034 |
*info = -3; |
| 7035 |
} else if (*n < *k) { |
| 7036 |
*info = -4; |
| 7037 |
} else if (*ldq < std::max(1_integer,*k)) { |
| 7038 |
*info = -7; |
| 7039 |
} else if (*lds < std::max(1_integer,*k)) { |
| 7040 |
*info = -12; |
| 7041 |
} |
| 7042 |
if (*info != 0) { |
| 7043 |
i__1 = -(*info); |
| 7044 |
xerbla_("DLAED9", &i__1); |
| 7045 |
return 0; |
| 7046 |
} |
| 7047 |
|
| 7048 |
/* Quick return if possible */ |
| 7049 |
|
| 7050 |
if (*k == 0) { |
| 7051 |
return 0; |
| 7052 |
} |
| 7053 |
|
| 7054 |
/* Modify values DLAMDA(i) to make sure all DLAMDA(i)-DLAMDA(j) can */ |
| 7055 |
/* be computed with high relative accuracy (barring over/underflow). */ |
| 7056 |
/* This is a problem on machines without a guard digit in */ |
| 7057 |
/* add/subtract (Cray XMP, Cray YMP, Cray C 90 and Cray 2). */ |
| 7058 |
/* The following code replaces DLAMDA(I) by 2*DLAMDA(I)-DLAMDA(I), */ |
| 7059 |
/* which on any of these machines zeros out the bottommost */ |
| 7060 |
/* bit of DLAMDA(I) if it is 1; this makes the subsequent */ |
| 7061 |
/* subtractions DLAMDA(I)-DLAMDA(J) unproblematic when cancellation */ |
| 7062 |
/* occurs. On binary machines with a guard digit (almost all */ |
| 7063 |
/* machines) it does not change DLAMDA(I) at all. On hexadecimal */ |
| 7064 |
/* and decimal machines with a guard digit, it slightly */ |
| 7065 |
/* changes the bottommost bits of DLAMDA(I). It does not account */ |
| 7066 |
/* for hexadecimal or decimal machines without guard digits */ |
| 7067 |
/* (we know of none). We use a subroutine call to compute */ |
| 7068 |
/* 2*DLAMBDA(I) to prevent optimizing compilers from eliminating */ |
| 7069 |
/* this code. */ |
| 7070 |
|
| 7071 |
i__1 = *n; |
| 7072 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 7073 |
dlamda[i__] = dlamc3_(&dlamda[i__], &dlamda[i__]) - dlamda[i__]; |
| 7074 |
/* L10: */ |
| 7075 |
} |
| 7076 |
|
| 7077 |
i__1 = *kstop; |
| 7078 |
for (j = *kstart; j <= i__1; ++j) { |
| 7079 |
dlaed4_(k, &j, &dlamda[1], &w[1], &q[j * q_dim1 + 1], rho, &d__[j], |
| 7080 |
info); |
| 7081 |
|
| 7082 |
/* If the zero finder fails, the computation is terminated. */ |
| 7083 |
|
| 7084 |
if (*info != 0) { |
| 7085 |
goto L120; |
| 7086 |
} |
| 7087 |
/* L20: */ |
| 7088 |
} |
| 7089 |
|
| 7090 |
if (*k == 1 || *k == 2) { |
| 7091 |
i__1 = *k; |
| 7092 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 7093 |
i__2 = *k; |
| 7094 |
for (j = 1; j <= i__2; ++j) { |
| 7095 |
s[j + i__ * s_dim1] = q[j + i__ * q_dim1]; |
| 7096 |
/* L30: */ |
| 7097 |
} |
| 7098 |
/* L40: */ |
| 7099 |
} |
| 7100 |
goto L120; |
| 7101 |
} |
| 7102 |
|
| 7103 |
/* Compute updated W. */ |
| 7104 |
|
| 7105 |
dcopy_(k, &w[1], &c__1, &s[s_offset], &c__1); |
| 7106 |
|
| 7107 |
/* Initialize W(I) = Q(I,I) */ |
| 7108 |
|
| 7109 |
i__1 = *ldq + 1; |
| 7110 |
dcopy_(k, &q[q_offset], &i__1, &w[1], &c__1); |
| 7111 |
i__1 = *k; |
| 7112 |
for (j = 1; j <= i__1; ++j) { |
| 7113 |
i__2 = j - 1; |
| 7114 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 7115 |
w[i__] *= q[i__ + j * q_dim1] / (dlamda[i__] - dlamda[j]); |
| 7116 |
/* L50: */ |
| 7117 |
} |
| 7118 |
i__2 = *k; |
| 7119 |
for (i__ = j + 1; i__ <= i__2; ++i__) { |
| 7120 |
w[i__] *= q[i__ + j * q_dim1] / (dlamda[i__] - dlamda[j]); |
| 7121 |
/* L60: */ |
| 7122 |
} |
| 7123 |
/* L70: */ |
| 7124 |
} |
| 7125 |
i__1 = *k; |
| 7126 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 7127 |
d__1 = sqrt(-w[i__]); |
| 7128 |
w[i__] = d_sign(&d__1, &s[i__ + s_dim1]); |
| 7129 |
/* L80: */ |
| 7130 |
} |
| 7131 |
|
| 7132 |
/* Compute eigenvectors of the modified rank-1 modification. */ |
| 7133 |
|
| 7134 |
i__1 = *k; |
| 7135 |
for (j = 1; j <= i__1; ++j) { |
| 7136 |
i__2 = *k; |
| 7137 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 7138 |
q[i__ + j * q_dim1] = w[i__] / q[i__ + j * q_dim1]; |
| 7139 |
/* L90: */ |
| 7140 |
} |
| 7141 |
temp = dnrm2_(k, &q[j * q_dim1 + 1], &c__1); |
| 7142 |
i__2 = *k; |
| 7143 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 7144 |
s[i__ + j * s_dim1] = q[i__ + j * q_dim1] / temp; |
| 7145 |
/* L100: */ |
| 7146 |
} |
| 7147 |
/* L110: */ |
| 7148 |
} |
| 7149 |
|
| 7150 |
L120: |
| 7151 |
return 0; |
| 7152 |
|
| 7153 |
/* End of DLAED9 */ |
| 7154 |
|
| 7155 |
} /* dlaed9_ */ |
| 7156 |
|
| 7157 |
/* Subroutine */ int dlaeda_(integer *n, integer *tlvls, integer *curlvl, |
| 7158 |
integer *curpbm, integer *prmptr, integer *perm, integer *givptr, |
| 7159 |
integer *givcol, double *givnum, double *q, integer *qptr, |
| 7160 |
double *z__, double *ztemp, integer *info) |
| 7161 |
{ |
| 7162 |
/* Table of constant values */ |
| 7163 |
static integer c__2 = 2; |
| 7164 |
static integer c__1 = 1; |
| 7165 |
static double c_b24 = 1.; |
| 7166 |
static double c_b26 = 0.; |
| 7167 |
|
| 7168 |
/* System generated locals */ |
| 7169 |
integer i__1, i__2, i__3; |
| 7170 |
|
| 7171 |
/* Local variables */ |
| 7172 |
integer i__, k, mid, ptr; |
| 7173 |
integer curr, bsiz1, bsiz2, psiz1, psiz2, zptr1; |
| 7174 |
|
| 7175 |
|
| 7176 |
/* -- LAPACK routine (version 3.1) -- */ |
| 7177 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 7178 |
/* November 2006 */ |
| 7179 |
|
| 7180 |
/* .. Scalar Arguments .. */ |
| 7181 |
/* .. */ |
| 7182 |
/* .. Array Arguments .. */ |
| 7183 |
/* .. */ |
| 7184 |
|
| 7185 |
/* Purpose */ |
| 7186 |
/* ======= */ |
| 7187 |
|
| 7188 |
/* DLAEDA computes the Z vector corresponding to the merge step in the */ |
| 7189 |
/* CURLVLth step of the merge process with TLVLS steps for the CURPBMth */ |
| 7190 |
/* problem. */ |
| 7191 |
|
| 7192 |
/* Arguments */ |
| 7193 |
/* ========= */ |
| 7194 |
|
| 7195 |
/* N (input) INTEGER */ |
| 7196 |
/* The dimension of the symmetric tridiagonal matrix. N >= 0. */ |
| 7197 |
|
| 7198 |
/* TLVLS (input) INTEGER */ |
| 7199 |
/* The total number of merging levels in the overall divide and */ |
| 7200 |
/* conquer tree. */ |
| 7201 |
|
| 7202 |
/* CURLVL (input) INTEGER */ |
| 7203 |
/* The current level in the overall merge routine, */ |
| 7204 |
/* 0 <= curlvl <= tlvls. */ |
| 7205 |
|
| 7206 |
/* CURPBM (input) INTEGER */ |
| 7207 |
/* The current problem in the current level in the overall */ |
| 7208 |
/* merge routine (counting from upper left to lower right). */ |
| 7209 |
|
| 7210 |
/* PRMPTR (input) INTEGER array, dimension (N lg N) */ |
| 7211 |
/* Contains a list of pointers which indicate where in PERM a */ |
| 7212 |
/* level's permutation is stored. PRMPTR(i+1) - PRMPTR(i) */ |
| 7213 |
/* indicates the size of the permutation and incidentally the */ |
| 7214 |
/* size of the full, non-deflated problem. */ |
| 7215 |
|
| 7216 |
/* PERM (input) INTEGER array, dimension (N lg N) */ |
| 7217 |
/* Contains the permutations (from deflation and sorting) to be */ |
| 7218 |
/* applied to each eigenblock. */ |
| 7219 |
|
| 7220 |
/* GIVPTR (input) INTEGER array, dimension (N lg N) */ |
| 7221 |
/* Contains a list of pointers which indicate where in GIVCOL a */ |
| 7222 |
/* level's Givens rotations are stored. GIVPTR(i+1) - GIVPTR(i) */ |
| 7223 |
/* indicates the number of Givens rotations. */ |
| 7224 |
|
| 7225 |
/* GIVCOL (input) INTEGER array, dimension (2, N lg N) */ |
| 7226 |
/* Each pair of numbers indicates a pair of columns to take place */ |
| 7227 |
/* in a Givens rotation. */ |
| 7228 |
|
| 7229 |
/* GIVNUM (input) DOUBLE PRECISION array, dimension (2, N lg N) */ |
| 7230 |
/* Each number indicates the S value to be used in the */ |
| 7231 |
/* corresponding Givens rotation. */ |
| 7232 |
|
| 7233 |
/* Q (input) DOUBLE PRECISION array, dimension (N**2) */ |
| 7234 |
/* Contains the square eigenblocks from previous levels, the */ |
| 7235 |
/* starting positions for blocks are given by QPTR. */ |
| 7236 |
|
| 7237 |
/* QPTR (input) INTEGER array, dimension (N+2) */ |
| 7238 |
/* Contains a list of pointers which indicate where in Q an */ |
| 7239 |
/* eigenblock is stored. SQRT( QPTR(i+1) - QPTR(i) ) indicates */ |
| 7240 |
/* the size of the block. */ |
| 7241 |
|
| 7242 |
/* Z (output) DOUBLE PRECISION array, dimension (N) */ |
| 7243 |
/* On output this vector contains the updating vector (the last */ |
| 7244 |
/* row of the first sub-eigenvector matrix and the first row of */ |
| 7245 |
/* the second sub-eigenvector matrix). */ |
| 7246 |
|
| 7247 |
/* ZTEMP (workspace) DOUBLE PRECISION array, dimension (N) */ |
| 7248 |
|
| 7249 |
/* INFO (output) INTEGER */ |
| 7250 |
/* = 0: successful exit. */ |
| 7251 |
/* < 0: if INFO = -i, the i-th argument had an illegal value. */ |
| 7252 |
|
| 7253 |
/* Further Details */ |
| 7254 |
/* =============== */ |
| 7255 |
|
| 7256 |
/* Based on contributions by */ |
| 7257 |
/* Jeff Rutter, Computer Science Division, University of California */ |
| 7258 |
/* at Berkeley, USA */ |
| 7259 |
|
| 7260 |
/* ===================================================================== */ |
| 7261 |
|
| 7262 |
/* .. Parameters .. */ |
| 7263 |
/* .. */ |
| 7264 |
/* .. Local Scalars .. */ |
| 7265 |
/* .. */ |
| 7266 |
/* .. External Subroutines .. */ |
| 7267 |
/* .. */ |
| 7268 |
/* .. Intrinsic Functions .. */ |
| 7269 |
/* .. */ |
| 7270 |
/* .. Executable Statements .. */ |
| 7271 |
|
| 7272 |
/* Test the input parameters. */ |
| 7273 |
|
| 7274 |
/* Parameter adjustments */ |
| 7275 |
--ztemp; |
| 7276 |
--z__; |
| 7277 |
--qptr; |
| 7278 |
--q; |
| 7279 |
givnum -= 3; |
| 7280 |
givcol -= 3; |
| 7281 |
--givptr; |
| 7282 |
--perm; |
| 7283 |
--prmptr; |
| 7284 |
|
| 7285 |
/* Function Body */ |
| 7286 |
*info = 0; |
| 7287 |
|
| 7288 |
if (*n < 0) { |
| 7289 |
*info = -1; |
| 7290 |
} |
| 7291 |
if (*info != 0) { |
| 7292 |
i__1 = -(*info); |
| 7293 |
xerbla_("DLAEDA", &i__1); |
| 7294 |
return 0; |
| 7295 |
} |
| 7296 |
|
| 7297 |
/* Quick return if possible */ |
| 7298 |
|
| 7299 |
if (*n == 0) { |
| 7300 |
return 0; |
| 7301 |
} |
| 7302 |
|
| 7303 |
/* Determine location of first number in second half. */ |
| 7304 |
|
| 7305 |
mid = *n / 2 + 1; |
| 7306 |
|
| 7307 |
/* Gather last/first rows of appropriate eigenblocks into center of Z */ |
| 7308 |
|
| 7309 |
ptr = 1; |
| 7310 |
|
| 7311 |
/* Determine location of lowest level subproblem in the full storage */ |
| 7312 |
/* scheme */ |
| 7313 |
|
| 7314 |
i__1 = *curlvl - 1; |
| 7315 |
curr = ptr + *curpbm * pow_ii(&c__2, curlvl) + pow_ii(&c__2, &i__1) - 1; |
| 7316 |
|
| 7317 |
/* Determine size of these matrices. We add HALF to the value of */ |
| 7318 |
/* the SQRT in case the machine underestimates one of these square */ |
| 7319 |
/* roots. */ |
| 7320 |
|
| 7321 |
bsiz1 = (integer) (sqrt((double) (qptr[curr + 1] - qptr[curr])) + .5); |
| 7322 |
bsiz2 = (integer) (sqrt((double) (qptr[curr + 2] - qptr[curr + 1])) + |
| 7323 |
.5); |
| 7324 |
i__1 = mid - bsiz1 - 1; |
| 7325 |
for (k = 1; k <= i__1; ++k) { |
| 7326 |
z__[k] = 0.; |
| 7327 |
/* L10: */ |
| 7328 |
} |
| 7329 |
dcopy_(&bsiz1, &q[qptr[curr] + bsiz1 - 1], &bsiz1, &z__[mid - bsiz1], & |
| 7330 |
c__1); |
| 7331 |
dcopy_(&bsiz2, &q[qptr[curr + 1]], &bsiz2, &z__[mid], &c__1); |
| 7332 |
i__1 = *n; |
| 7333 |
for (k = mid + bsiz2; k <= i__1; ++k) { |
| 7334 |
z__[k] = 0.; |
| 7335 |
/* L20: */ |
| 7336 |
} |
| 7337 |
|
| 7338 |
/* Loop thru remaining levels 1 -> CURLVL applying the Givens */ |
| 7339 |
/* rotations and permutation and then multiplying the center matrices */ |
| 7340 |
/* against the current Z. */ |
| 7341 |
|
| 7342 |
ptr = pow_ii(&c__2, tlvls) + 1; |
| 7343 |
i__1 = *curlvl - 1; |
| 7344 |
for (k = 1; k <= i__1; ++k) { |
| 7345 |
i__2 = *curlvl - k; |
| 7346 |
i__3 = *curlvl - k - 1; |
| 7347 |
curr = ptr + *curpbm * pow_ii(&c__2, &i__2) + pow_ii(&c__2, &i__3) - |
| 7348 |
1; |
| 7349 |
psiz1 = prmptr[curr + 1] - prmptr[curr]; |
| 7350 |
psiz2 = prmptr[curr + 2] - prmptr[curr + 1]; |
| 7351 |
zptr1 = mid - psiz1; |
| 7352 |
|
| 7353 |
/* Apply Givens at CURR and CURR+1 */ |
| 7354 |
|
| 7355 |
i__2 = givptr[curr + 1] - 1; |
| 7356 |
for (i__ = givptr[curr]; i__ <= i__2; ++i__) { |
| 7357 |
drot_(&c__1, &z__[zptr1 + givcol[(i__ << 1) + 1] - 1], &c__1, & |
| 7358 |
z__[zptr1 + givcol[(i__ << 1) + 2] - 1], &c__1, &givnum[( |
| 7359 |
i__ << 1) + 1], &givnum[(i__ << 1) + 2]); |
| 7360 |
/* L30: */ |
| 7361 |
} |
| 7362 |
i__2 = givptr[curr + 2] - 1; |
| 7363 |
for (i__ = givptr[curr + 1]; i__ <= i__2; ++i__) { |
| 7364 |
drot_(&c__1, &z__[mid - 1 + givcol[(i__ << 1) + 1]], &c__1, &z__[ |
| 7365 |
mid - 1 + givcol[(i__ << 1) + 2]], &c__1, &givnum[(i__ << |
| 7366 |
1) + 1], &givnum[(i__ << 1) + 2]); |
| 7367 |
/* L40: */ |
| 7368 |
} |
| 7369 |
psiz1 = prmptr[curr + 1] - prmptr[curr]; |
| 7370 |
psiz2 = prmptr[curr + 2] - prmptr[curr + 1]; |
| 7371 |
i__2 = psiz1 - 1; |
| 7372 |
for (i__ = 0; i__ <= i__2; ++i__) { |
| 7373 |
ztemp[i__ + 1] = z__[zptr1 + perm[prmptr[curr] + i__] - 1]; |
| 7374 |
/* L50: */ |
| 7375 |
} |
| 7376 |
i__2 = psiz2 - 1; |
| 7377 |
for (i__ = 0; i__ <= i__2; ++i__) { |
| 7378 |
ztemp[psiz1 + i__ + 1] = z__[mid + perm[prmptr[curr + 1] + i__] - |
| 7379 |
1]; |
| 7380 |
/* L60: */ |
| 7381 |
} |
| 7382 |
|
| 7383 |
/* Multiply Blocks at CURR and CURR+1 */ |
| 7384 |
|
| 7385 |
/* Determine size of these matrices. We add HALF to the value of */ |
| 7386 |
/* the SQRT in case the machine underestimates one of these */ |
| 7387 |
/* square roots. */ |
| 7388 |
|
| 7389 |
bsiz1 = (integer) (sqrt((double) (qptr[curr + 1] - qptr[curr])) + |
| 7390 |
.5); |
| 7391 |
bsiz2 = (integer) (sqrt((double) (qptr[curr + 2] - qptr[curr + 1]) |
| 7392 |
) + .5); |
| 7393 |
if (bsiz1 > 0) { |
| 7394 |
dgemv_("T", &bsiz1, &bsiz1, &c_b24, &q[qptr[curr]], &bsiz1, & |
| 7395 |
ztemp[1], &c__1, &c_b26, &z__[zptr1], &c__1); |
| 7396 |
} |
| 7397 |
i__2 = psiz1 - bsiz1; |
| 7398 |
dcopy_(&i__2, &ztemp[bsiz1 + 1], &c__1, &z__[zptr1 + bsiz1], &c__1); |
| 7399 |
if (bsiz2 > 0) { |
| 7400 |
dgemv_("T", &bsiz2, &bsiz2, &c_b24, &q[qptr[curr + 1]], &bsiz2, & |
| 7401 |
ztemp[psiz1 + 1], &c__1, &c_b26, &z__[mid], &c__1); |
| 7402 |
} |
| 7403 |
i__2 = psiz2 - bsiz2; |
| 7404 |
dcopy_(&i__2, &ztemp[psiz1 + bsiz2 + 1], &c__1, &z__[mid + bsiz2], & |
| 7405 |
c__1); |
| 7406 |
|
| 7407 |
i__2 = *tlvls - k; |
| 7408 |
ptr += pow_ii(&c__2, &i__2); |
| 7409 |
/* L70: */ |
| 7410 |
} |
| 7411 |
|
| 7412 |
return 0; |
| 7413 |
|
| 7414 |
/* End of DLAEDA */ |
| 7415 |
|
| 7416 |
} /* dlaeda_ */ |
| 7417 |
|
| 7418 |
/* Subroutine */ int dlaein_(bool *rightv, bool *noinit, integer *n, |
| 7419 |
double *h__, integer *ldh, double *wr, double *wi, |
| 7420 |
double *vr, double *vi, double *b, integer *ldb, |
| 7421 |
double *work, double *eps3, double *smlnum, double * |
| 7422 |
bignum, integer *info) |
| 7423 |
{ |
| 7424 |
/* Table of constant values */ |
| 7425 |
static integer c__1 = 1; |
| 7426 |
|
| 7427 |
/* System generated locals */ |
| 7428 |
integer b_dim1, b_offset, h_dim1, h_offset, i__1, i__2, i__3, i__4; |
| 7429 |
double d__1, d__2, d__3, d__4; |
| 7430 |
|
| 7431 |
/* Local variables */ |
| 7432 |
integer i__, j; |
| 7433 |
double w, x, y; |
| 7434 |
integer i1, i2, i3; |
| 7435 |
double w1, ei, ej, xi, xr, rec; |
| 7436 |
integer its, ierr; |
| 7437 |
double temp, norm, vmax; |
| 7438 |
double scale; |
| 7439 |
char trans[1]; |
| 7440 |
double vcrit, rootn, vnorm; |
| 7441 |
double absbii, absbjj; |
| 7442 |
char normin[1]; |
| 7443 |
double nrmsml, growto; |
| 7444 |
|
| 7445 |
|
| 7446 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 7447 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 7448 |
/* November 2006 */ |
| 7449 |
|
| 7450 |
/* .. Scalar Arguments .. */ |
| 7451 |
/* .. */ |
| 7452 |
/* .. Array Arguments .. */ |
| 7453 |
/* .. */ |
| 7454 |
|
| 7455 |
/* Purpose */ |
| 7456 |
/* ======= */ |
| 7457 |
|
| 7458 |
/* DLAEIN uses inverse iteration to find a right or left eigenvector */ |
| 7459 |
/* corresponding to the eigenvalue (WR,WI) of a real upper Hessenberg */ |
| 7460 |
/* matrix H. */ |
| 7461 |
|
| 7462 |
/* Arguments */ |
| 7463 |
/* ========= */ |
| 7464 |
|
| 7465 |
/* RIGHTV (input) LOGICAL */ |
| 7466 |
/* = .TRUE. : compute right eigenvector; */ |
| 7467 |
/* = .FALSE.: compute left eigenvector. */ |
| 7468 |
|
| 7469 |
/* NOINIT (input) LOGICAL */ |
| 7470 |
/* = .TRUE. : no initial vector supplied in (VR,VI). */ |
| 7471 |
/* = .FALSE.: initial vector supplied in (VR,VI). */ |
| 7472 |
|
| 7473 |
/* N (input) INTEGER */ |
| 7474 |
/* The order of the matrix H. N >= 0. */ |
| 7475 |
|
| 7476 |
/* H (input) DOUBLE PRECISION array, dimension (LDH,N) */ |
| 7477 |
/* The upper Hessenberg matrix H. */ |
| 7478 |
|
| 7479 |
/* LDH (input) INTEGER */ |
| 7480 |
/* The leading dimension of the array H. LDH >= max(1,N). */ |
| 7481 |
|
| 7482 |
/* WR (input) DOUBLE PRECISION */ |
| 7483 |
/* WI (input) DOUBLE PRECISION */ |
| 7484 |
/* The real and imaginary parts of the eigenvalue of H whose */ |
| 7485 |
/* corresponding right or left eigenvector is to be computed. */ |
| 7486 |
|
| 7487 |
/* VR (input/output) DOUBLE PRECISION array, dimension (N) */ |
| 7488 |
/* VI (input/output) DOUBLE PRECISION array, dimension (N) */ |
| 7489 |
/* On entry, if NOINIT = .FALSE. and WI = 0.0, VR must contain */ |
| 7490 |
/* a real starting vector for inverse iteration using the real */ |
| 7491 |
/* eigenvalue WR; if NOINIT = .FALSE. and WI.ne.0.0, VR and VI */ |
| 7492 |
/* must contain the real and imaginary parts of a complex */ |
| 7493 |
/* starting vector for inverse iteration using the complex */ |
| 7494 |
/* eigenvalue (WR,WI); otherwise VR and VI need not be set. */ |
| 7495 |
/* On exit, if WI = 0.0 (real eigenvalue), VR contains the */ |
| 7496 |
/* computed real eigenvector; if WI.ne.0.0 (complex eigenvalue), */ |
| 7497 |
/* VR and VI contain the real and imaginary parts of the */ |
| 7498 |
/* computed complex eigenvector. The eigenvector is normalized */ |
| 7499 |
/* so that the component of largest magnitude has magnitude 1; */ |
| 7500 |
/* here the magnitude of a complex number (x,y) is taken to be */ |
| 7501 |
/* |x| + |y|. */ |
| 7502 |
/* VI is not referenced if WI = 0.0. */ |
| 7503 |
|
| 7504 |
/* B (workspace) DOUBLE PRECISION array, dimension (LDB,N) */ |
| 7505 |
|
| 7506 |
/* LDB (input) INTEGER */ |
| 7507 |
/* The leading dimension of the array B. LDB >= N+1. */ |
| 7508 |
|
| 7509 |
/* WORK (workspace) DOUBLE PRECISION array, dimension (N) */ |
| 7510 |
|
| 7511 |
/* EPS3 (input) DOUBLE PRECISION */ |
| 7512 |
/* A small machine-dependent value which is used to perturb */ |
| 7513 |
/* close eigenvalues, and to replace zero pivots. */ |
| 7514 |
|
| 7515 |
/* SMLNUM (input) DOUBLE PRECISION */ |
| 7516 |
/* A machine-dependent value close to the underflow threshold. */ |
| 7517 |
|
| 7518 |
/* BIGNUM (input) DOUBLE PRECISION */ |
| 7519 |
/* A machine-dependent value close to the overflow threshold. */ |
| 7520 |
|
| 7521 |
/* INFO (output) INTEGER */ |
| 7522 |
/* = 0: successful exit */ |
| 7523 |
/* = 1: inverse iteration did not converge; VR is set to the */ |
| 7524 |
/* last iterate, and so is VI if WI.ne.0.0. */ |
| 7525 |
|
| 7526 |
/* ===================================================================== */ |
| 7527 |
|
| 7528 |
/* .. Parameters .. */ |
| 7529 |
/* .. */ |
| 7530 |
/* .. Local Scalars .. */ |
| 7531 |
/* .. */ |
| 7532 |
/* .. External Functions .. */ |
| 7533 |
/* .. */ |
| 7534 |
/* .. External Subroutines .. */ |
| 7535 |
/* .. */ |
| 7536 |
/* .. Intrinsic Functions .. */ |
| 7537 |
/* .. */ |
| 7538 |
/* .. Executable Statements .. */ |
| 7539 |
|
| 7540 |
/* Parameter adjustments */ |
| 7541 |
h_dim1 = *ldh; |
| 7542 |
h_offset = 1 + h_dim1; |
| 7543 |
h__ -= h_offset; |
| 7544 |
--vr; |
| 7545 |
--vi; |
| 7546 |
b_dim1 = *ldb; |
| 7547 |
b_offset = 1 + b_dim1; |
| 7548 |
b -= b_offset; |
| 7549 |
--work; |
| 7550 |
|
| 7551 |
/* Function Body */ |
| 7552 |
*info = 0; |
| 7553 |
|
| 7554 |
/* GROWTO is the threshold used in the acceptance test for an */ |
| 7555 |
/* eigenvector. */ |
| 7556 |
|
| 7557 |
rootn = sqrt((double) (*n)); |
| 7558 |
growto = .1 / rootn; |
| 7559 |
/* Computing MAX */ |
| 7560 |
d__1 = 1., d__2 = *eps3 * rootn; |
| 7561 |
nrmsml = std::max(d__1,d__2) * *smlnum; |
| 7562 |
|
| 7563 |
/* Form B = H - (WR,WI)*I (except that the subdiagonal elements and */ |
| 7564 |
/* the imaginary parts of the diagonal elements are not stored). */ |
| 7565 |
|
| 7566 |
i__1 = *n; |
| 7567 |
for (j = 1; j <= i__1; ++j) { |
| 7568 |
i__2 = j - 1; |
| 7569 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 7570 |
b[i__ + j * b_dim1] = h__[i__ + j * h_dim1]; |
| 7571 |
/* L10: */ |
| 7572 |
} |
| 7573 |
b[j + j * b_dim1] = h__[j + j * h_dim1] - *wr; |
| 7574 |
/* L20: */ |
| 7575 |
} |
| 7576 |
|
| 7577 |
if (*wi == 0.) { |
| 7578 |
|
| 7579 |
/* Real eigenvalue. */ |
| 7580 |
|
| 7581 |
if (*noinit) { |
| 7582 |
|
| 7583 |
/* Set initial vector. */ |
| 7584 |
|
| 7585 |
i__1 = *n; |
| 7586 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 7587 |
vr[i__] = *eps3; |
| 7588 |
/* L30: */ |
| 7589 |
} |
| 7590 |
} else { |
| 7591 |
|
| 7592 |
/* Scale supplied initial vector. */ |
| 7593 |
|
| 7594 |
vnorm = dnrm2_(n, &vr[1], &c__1); |
| 7595 |
d__1 = *eps3 * rootn / std::max(vnorm,nrmsml); |
| 7596 |
dscal_(n, &d__1, &vr[1], &c__1); |
| 7597 |
} |
| 7598 |
|
| 7599 |
if (*rightv) { |
| 7600 |
|
| 7601 |
/* LU decomposition with partial pivoting of B, replacing zero */ |
| 7602 |
/* pivots by EPS3. */ |
| 7603 |
|
| 7604 |
i__1 = *n - 1; |
| 7605 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 7606 |
ei = h__[i__ + 1 + i__ * h_dim1]; |
| 7607 |
if ((d__1 = b[i__ + i__ * b_dim1], abs(d__1)) < abs(ei)) { |
| 7608 |
|
| 7609 |
/* Interchange rows and eliminate. */ |
| 7610 |
|
| 7611 |
x = b[i__ + i__ * b_dim1] / ei; |
| 7612 |
b[i__ + i__ * b_dim1] = ei; |
| 7613 |
i__2 = *n; |
| 7614 |
for (j = i__ + 1; j <= i__2; ++j) { |
| 7615 |
temp = b[i__ + 1 + j * b_dim1]; |
| 7616 |
b[i__ + 1 + j * b_dim1] = b[i__ + j * b_dim1] - x * |
| 7617 |
temp; |
| 7618 |
b[i__ + j * b_dim1] = temp; |
| 7619 |
/* L40: */ |
| 7620 |
} |
| 7621 |
} else { |
| 7622 |
|
| 7623 |
/* Eliminate without interchange. */ |
| 7624 |
|
| 7625 |
if (b[i__ + i__ * b_dim1] == 0.) { |
| 7626 |
b[i__ + i__ * b_dim1] = *eps3; |
| 7627 |
} |
| 7628 |
x = ei / b[i__ + i__ * b_dim1]; |
| 7629 |
if (x != 0.) { |
| 7630 |
i__2 = *n; |
| 7631 |
for (j = i__ + 1; j <= i__2; ++j) { |
| 7632 |
b[i__ + 1 + j * b_dim1] -= x * b[i__ + j * b_dim1] |
| 7633 |
; |
| 7634 |
/* L50: */ |
| 7635 |
} |
| 7636 |
} |
| 7637 |
} |
| 7638 |
/* L60: */ |
| 7639 |
} |
| 7640 |
if (b[*n + *n * b_dim1] == 0.) { |
| 7641 |
b[*n + *n * b_dim1] = *eps3; |
| 7642 |
} |
| 7643 |
|
| 7644 |
*(unsigned char *)trans = 'N'; |
| 7645 |
|
| 7646 |
} else { |
| 7647 |
|
| 7648 |
/* UL decomposition with partial pivoting of B, replacing zero */ |
| 7649 |
/* pivots by EPS3. */ |
| 7650 |
|
| 7651 |
for (j = *n; j >= 2; --j) { |
| 7652 |
ej = h__[j + (j - 1) * h_dim1]; |
| 7653 |
if ((d__1 = b[j + j * b_dim1], abs(d__1)) < abs(ej)) { |
| 7654 |
|
| 7655 |
/* Interchange columns and eliminate. */ |
| 7656 |
|
| 7657 |
x = b[j + j * b_dim1] / ej; |
| 7658 |
b[j + j * b_dim1] = ej; |
| 7659 |
i__1 = j - 1; |
| 7660 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 7661 |
temp = b[i__ + (j - 1) * b_dim1]; |
| 7662 |
b[i__ + (j - 1) * b_dim1] = b[i__ + j * b_dim1] - x * |
| 7663 |
temp; |
| 7664 |
b[i__ + j * b_dim1] = temp; |
| 7665 |
/* L70: */ |
| 7666 |
} |
| 7667 |
} else { |
| 7668 |
|
| 7669 |
/* Eliminate without interchange. */ |
| 7670 |
|
| 7671 |
if (b[j + j * b_dim1] == 0.) { |
| 7672 |
b[j + j * b_dim1] = *eps3; |
| 7673 |
} |
| 7674 |
x = ej / b[j + j * b_dim1]; |
| 7675 |
if (x != 0.) { |
| 7676 |
i__1 = j - 1; |
| 7677 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 7678 |
b[i__ + (j - 1) * b_dim1] -= x * b[i__ + j * |
| 7679 |
b_dim1]; |
| 7680 |
/* L80: */ |
| 7681 |
} |
| 7682 |
} |
| 7683 |
} |
| 7684 |
/* L90: */ |
| 7685 |
} |
| 7686 |
if (b[b_dim1 + 1] == 0.) { |
| 7687 |
b[b_dim1 + 1] = *eps3; |
| 7688 |
} |
| 7689 |
|
| 7690 |
*(unsigned char *)trans = 'T'; |
| 7691 |
|
| 7692 |
} |
| 7693 |
|
| 7694 |
*(unsigned char *)normin = 'N'; |
| 7695 |
i__1 = *n; |
| 7696 |
for (its = 1; its <= i__1; ++its) { |
| 7697 |
|
| 7698 |
/* Solve U*x = scale*v for a right eigenvector */ |
| 7699 |
/* or U'*x = scale*v for a left eigenvector, */ |
| 7700 |
/* overwriting x on v. */ |
| 7701 |
|
| 7702 |
dlatrs_("Upper", trans, "Nonunit", normin, n, &b[b_offset], ldb, & |
| 7703 |
vr[1], &scale, &work[1], &ierr); |
| 7704 |
*(unsigned char *)normin = 'Y'; |
| 7705 |
|
| 7706 |
/* Test for sufficient growth in the norm of v. */ |
| 7707 |
|
| 7708 |
vnorm = dasum_(n, &vr[1], &c__1); |
| 7709 |
if (vnorm >= growto * scale) { |
| 7710 |
goto L120; |
| 7711 |
} |
| 7712 |
|
| 7713 |
/* Choose new orthogonal starting vector and try again. */ |
| 7714 |
|
| 7715 |
temp = *eps3 / (rootn + 1.); |
| 7716 |
vr[1] = *eps3; |
| 7717 |
i__2 = *n; |
| 7718 |
for (i__ = 2; i__ <= i__2; ++i__) { |
| 7719 |
vr[i__] = temp; |
| 7720 |
/* L100: */ |
| 7721 |
} |
| 7722 |
vr[*n - its + 1] -= *eps3 * rootn; |
| 7723 |
/* L110: */ |
| 7724 |
} |
| 7725 |
|
| 7726 |
/* Failure to find eigenvector in N iterations. */ |
| 7727 |
|
| 7728 |
*info = 1; |
| 7729 |
|
| 7730 |
L120: |
| 7731 |
|
| 7732 |
/* Normalize eigenvector. */ |
| 7733 |
|
| 7734 |
i__ = idamax_(n, &vr[1], &c__1); |
| 7735 |
d__2 = 1. / (d__1 = vr[i__], abs(d__1)); |
| 7736 |
dscal_(n, &d__2, &vr[1], &c__1); |
| 7737 |
} else { |
| 7738 |
|
| 7739 |
/* Complex eigenvalue. */ |
| 7740 |
|
| 7741 |
if (*noinit) { |
| 7742 |
|
| 7743 |
/* Set initial vector. */ |
| 7744 |
|
| 7745 |
i__1 = *n; |
| 7746 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 7747 |
vr[i__] = *eps3; |
| 7748 |
vi[i__] = 0.; |
| 7749 |
/* L130: */ |
| 7750 |
} |
| 7751 |
} else { |
| 7752 |
|
| 7753 |
/* Scale supplied initial vector. */ |
| 7754 |
|
| 7755 |
d__1 = dnrm2_(n, &vr[1], &c__1); |
| 7756 |
d__2 = dnrm2_(n, &vi[1], &c__1); |
| 7757 |
norm = dlapy2_(&d__1, &d__2); |
| 7758 |
rec = *eps3 * rootn / std::max(norm,nrmsml); |
| 7759 |
dscal_(n, &rec, &vr[1], &c__1); |
| 7760 |
dscal_(n, &rec, &vi[1], &c__1); |
| 7761 |
} |
| 7762 |
|
| 7763 |
if (*rightv) { |
| 7764 |
|
| 7765 |
/* LU decomposition with partial pivoting of B, replacing zero */ |
| 7766 |
/* pivots by EPS3. */ |
| 7767 |
|
| 7768 |
/* The imaginary part of the (i,j)-th element of U is stored in */ |
| 7769 |
/* B(j+1,i). */ |
| 7770 |
|
| 7771 |
b[b_dim1 + 2] = -(*wi); |
| 7772 |
i__1 = *n; |
| 7773 |
for (i__ = 2; i__ <= i__1; ++i__) { |
| 7774 |
b[i__ + 1 + b_dim1] = 0.; |
| 7775 |
/* L140: */ |
| 7776 |
} |
| 7777 |
|
| 7778 |
i__1 = *n - 1; |
| 7779 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 7780 |
absbii = dlapy2_(&b[i__ + i__ * b_dim1], &b[i__ + 1 + i__ * |
| 7781 |
b_dim1]); |
| 7782 |
ei = h__[i__ + 1 + i__ * h_dim1]; |
| 7783 |
if (absbii < abs(ei)) { |
| 7784 |
|
| 7785 |
/* Interchange rows and eliminate. */ |
| 7786 |
|
| 7787 |
xr = b[i__ + i__ * b_dim1] / ei; |
| 7788 |
xi = b[i__ + 1 + i__ * b_dim1] / ei; |
| 7789 |
b[i__ + i__ * b_dim1] = ei; |
| 7790 |
b[i__ + 1 + i__ * b_dim1] = 0.; |
| 7791 |
i__2 = *n; |
| 7792 |
for (j = i__ + 1; j <= i__2; ++j) { |
| 7793 |
temp = b[i__ + 1 + j * b_dim1]; |
| 7794 |
b[i__ + 1 + j * b_dim1] = b[i__ + j * b_dim1] - xr * |
| 7795 |
temp; |
| 7796 |
b[j + 1 + (i__ + 1) * b_dim1] = b[j + 1 + i__ * |
| 7797 |
b_dim1] - xi * temp; |
| 7798 |
b[i__ + j * b_dim1] = temp; |
| 7799 |
b[j + 1 + i__ * b_dim1] = 0.; |
| 7800 |
/* L150: */ |
| 7801 |
} |
| 7802 |
b[i__ + 2 + i__ * b_dim1] = -(*wi); |
| 7803 |
b[i__ + 1 + (i__ + 1) * b_dim1] -= xi * *wi; |
| 7804 |
b[i__ + 2 + (i__ + 1) * b_dim1] += xr * *wi; |
| 7805 |
} else { |
| 7806 |
|
| 7807 |
/* Eliminate without interchanging rows. */ |
| 7808 |
|
| 7809 |
if (absbii == 0.) { |
| 7810 |
b[i__ + i__ * b_dim1] = *eps3; |
| 7811 |
b[i__ + 1 + i__ * b_dim1] = 0.; |
| 7812 |
absbii = *eps3; |
| 7813 |
} |
| 7814 |
ei = ei / absbii / absbii; |
| 7815 |
xr = b[i__ + i__ * b_dim1] * ei; |
| 7816 |
xi = -b[i__ + 1 + i__ * b_dim1] * ei; |
| 7817 |
i__2 = *n; |
| 7818 |
for (j = i__ + 1; j <= i__2; ++j) { |
| 7819 |
b[i__ + 1 + j * b_dim1] = b[i__ + 1 + j * b_dim1] - |
| 7820 |
xr * b[i__ + j * b_dim1] + xi * b[j + 1 + i__ |
| 7821 |
* b_dim1]; |
| 7822 |
b[j + 1 + (i__ + 1) * b_dim1] = -xr * b[j + 1 + i__ * |
| 7823 |
b_dim1] - xi * b[i__ + j * b_dim1]; |
| 7824 |
/* L160: */ |
| 7825 |
} |
| 7826 |
b[i__ + 2 + (i__ + 1) * b_dim1] -= *wi; |
| 7827 |
} |
| 7828 |
|
| 7829 |
/* Compute 1-norm of offdiagonal elements of i-th row. */ |
| 7830 |
|
| 7831 |
i__2 = *n - i__; |
| 7832 |
i__3 = *n - i__; |
| 7833 |
work[i__] = dasum_(&i__2, &b[i__ + (i__ + 1) * b_dim1], ldb) |
| 7834 |
+ dasum_(&i__3, &b[i__ + 2 + i__ * b_dim1], &c__1); |
| 7835 |
/* L170: */ |
| 7836 |
} |
| 7837 |
if (b[*n + *n * b_dim1] == 0. && b[*n + 1 + *n * b_dim1] == 0.) { |
| 7838 |
b[*n + *n * b_dim1] = *eps3; |
| 7839 |
} |
| 7840 |
work[*n] = 0.; |
| 7841 |
|
| 7842 |
i1 = *n; |
| 7843 |
i2 = 1; |
| 7844 |
i3 = -1; |
| 7845 |
} else { |
| 7846 |
|
| 7847 |
/* UL decomposition with partial pivoting of conjg(B), */ |
| 7848 |
/* replacing zero pivots by EPS3. */ |
| 7849 |
|
| 7850 |
/* The imaginary part of the (i,j)-th element of U is stored in */ |
| 7851 |
/* B(j+1,i). */ |
| 7852 |
|
| 7853 |
b[*n + 1 + *n * b_dim1] = *wi; |
| 7854 |
i__1 = *n - 1; |
| 7855 |
for (j = 1; j <= i__1; ++j) { |
| 7856 |
b[*n + 1 + j * b_dim1] = 0.; |
| 7857 |
/* L180: */ |
| 7858 |
} |
| 7859 |
|
| 7860 |
for (j = *n; j >= 2; --j) { |
| 7861 |
ej = h__[j + (j - 1) * h_dim1]; |
| 7862 |
absbjj = dlapy2_(&b[j + j * b_dim1], &b[j + 1 + j * b_dim1]); |
| 7863 |
if (absbjj < abs(ej)) { |
| 7864 |
|
| 7865 |
/* Interchange columns and eliminate */ |
| 7866 |
|
| 7867 |
xr = b[j + j * b_dim1] / ej; |
| 7868 |
xi = b[j + 1 + j * b_dim1] / ej; |
| 7869 |
b[j + j * b_dim1] = ej; |
| 7870 |
b[j + 1 + j * b_dim1] = 0.; |
| 7871 |
i__1 = j - 1; |
| 7872 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 7873 |
temp = b[i__ + (j - 1) * b_dim1]; |
| 7874 |
b[i__ + (j - 1) * b_dim1] = b[i__ + j * b_dim1] - xr * |
| 7875 |
temp; |
| 7876 |
b[j + i__ * b_dim1] = b[j + 1 + i__ * b_dim1] - xi * |
| 7877 |
temp; |
| 7878 |
b[i__ + j * b_dim1] = temp; |
| 7879 |
b[j + 1 + i__ * b_dim1] = 0.; |
| 7880 |
/* L190: */ |
| 7881 |
} |
| 7882 |
b[j + 1 + (j - 1) * b_dim1] = *wi; |
| 7883 |
b[j - 1 + (j - 1) * b_dim1] += xi * *wi; |
| 7884 |
b[j + (j - 1) * b_dim1] -= xr * *wi; |
| 7885 |
} else { |
| 7886 |
|
| 7887 |
/* Eliminate without interchange. */ |
| 7888 |
|
| 7889 |
if (absbjj == 0.) { |
| 7890 |
b[j + j * b_dim1] = *eps3; |
| 7891 |
b[j + 1 + j * b_dim1] = 0.; |
| 7892 |
absbjj = *eps3; |
| 7893 |
} |
| 7894 |
ej = ej / absbjj / absbjj; |
| 7895 |
xr = b[j + j * b_dim1] * ej; |
| 7896 |
xi = -b[j + 1 + j * b_dim1] * ej; |
| 7897 |
i__1 = j - 1; |
| 7898 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 7899 |
b[i__ + (j - 1) * b_dim1] = b[i__ + (j - 1) * b_dim1] |
| 7900 |
- xr * b[i__ + j * b_dim1] + xi * b[j + 1 + |
| 7901 |
i__ * b_dim1]; |
| 7902 |
b[j + i__ * b_dim1] = -xr * b[j + 1 + i__ * b_dim1] - |
| 7903 |
xi * b[i__ + j * b_dim1]; |
| 7904 |
/* L200: */ |
| 7905 |
} |
| 7906 |
b[j + (j - 1) * b_dim1] += *wi; |
| 7907 |
} |
| 7908 |
|
| 7909 |
/* Compute 1-norm of offdiagonal elements of j-th column. */ |
| 7910 |
|
| 7911 |
i__1 = j - 1; |
| 7912 |
i__2 = j - 1; |
| 7913 |
work[j] = dasum_(&i__1, &b[j * b_dim1 + 1], &c__1) + dasum_(& |
| 7914 |
i__2, &b[j + 1 + b_dim1], ldb); |
| 7915 |
/* L210: */ |
| 7916 |
} |
| 7917 |
if (b[b_dim1 + 1] == 0. && b[b_dim1 + 2] == 0.) { |
| 7918 |
b[b_dim1 + 1] = *eps3; |
| 7919 |
} |
| 7920 |
work[1] = 0.; |
| 7921 |
|
| 7922 |
i1 = 1; |
| 7923 |
i2 = *n; |
| 7924 |
i3 = 1; |
| 7925 |
} |
| 7926 |
|
| 7927 |
i__1 = *n; |
| 7928 |
for (its = 1; its <= i__1; ++its) { |
| 7929 |
scale = 1.; |
| 7930 |
vmax = 1.; |
| 7931 |
vcrit = *bignum; |
| 7932 |
|
| 7933 |
/* Solve U*(xr,xi) = scale*(vr,vi) for a right eigenvector, */ |
| 7934 |
/* or U'*(xr,xi) = scale*(vr,vi) for a left eigenvector, */ |
| 7935 |
/* overwriting (xr,xi) on (vr,vi). */ |
| 7936 |
|
| 7937 |
i__2 = i2; |
| 7938 |
i__3 = i3; |
| 7939 |
for (i__ = i1; i__3 < 0 ? i__ >= i__2 : i__ <= i__2; i__ += i__3) |
| 7940 |
{ |
| 7941 |
|
| 7942 |
if (work[i__] > vcrit) { |
| 7943 |
rec = 1. / vmax; |
| 7944 |
dscal_(n, &rec, &vr[1], &c__1); |
| 7945 |
dscal_(n, &rec, &vi[1], &c__1); |
| 7946 |
scale *= rec; |
| 7947 |
vmax = 1.; |
| 7948 |
vcrit = *bignum; |
| 7949 |
} |
| 7950 |
|
| 7951 |
xr = vr[i__]; |
| 7952 |
xi = vi[i__]; |
| 7953 |
if (*rightv) { |
| 7954 |
i__4 = *n; |
| 7955 |
for (j = i__ + 1; j <= i__4; ++j) { |
| 7956 |
xr = xr - b[i__ + j * b_dim1] * vr[j] + b[j + 1 + i__ |
| 7957 |
* b_dim1] * vi[j]; |
| 7958 |
xi = xi - b[i__ + j * b_dim1] * vi[j] - b[j + 1 + i__ |
| 7959 |
* b_dim1] * vr[j]; |
| 7960 |
/* L220: */ |
| 7961 |
} |
| 7962 |
} else { |
| 7963 |
i__4 = i__ - 1; |
| 7964 |
for (j = 1; j <= i__4; ++j) { |
| 7965 |
xr = xr - b[j + i__ * b_dim1] * vr[j] + b[i__ + 1 + j |
| 7966 |
* b_dim1] * vi[j]; |
| 7967 |
xi = xi - b[j + i__ * b_dim1] * vi[j] - b[i__ + 1 + j |
| 7968 |
* b_dim1] * vr[j]; |
| 7969 |
/* L230: */ |
| 7970 |
} |
| 7971 |
} |
| 7972 |
|
| 7973 |
w = (d__1 = b[i__ + i__ * b_dim1], abs(d__1)) + (d__2 = b[i__ |
| 7974 |
+ 1 + i__ * b_dim1], abs(d__2)); |
| 7975 |
if (w > *smlnum) { |
| 7976 |
if (w < 1.) { |
| 7977 |
w1 = abs(xr) + abs(xi); |
| 7978 |
if (w1 > w * *bignum) { |
| 7979 |
rec = 1. / w1; |
| 7980 |
dscal_(n, &rec, &vr[1], &c__1); |
| 7981 |
dscal_(n, &rec, &vi[1], &c__1); |
| 7982 |
xr = vr[i__]; |
| 7983 |
xi = vi[i__]; |
| 7984 |
scale *= rec; |
| 7985 |
vmax *= rec; |
| 7986 |
} |
| 7987 |
} |
| 7988 |
|
| 7989 |
/* Divide by diagonal element of B. */ |
| 7990 |
|
| 7991 |
dladiv_(&xr, &xi, &b[i__ + i__ * b_dim1], &b[i__ + 1 + |
| 7992 |
i__ * b_dim1], &vr[i__], &vi[i__]); |
| 7993 |
/* Computing MAX */ |
| 7994 |
d__3 = (d__1 = vr[i__], abs(d__1)) + (d__2 = vi[i__], abs( |
| 7995 |
d__2)); |
| 7996 |
vmax = std::max(d__3,vmax); |
| 7997 |
vcrit = *bignum / vmax; |
| 7998 |
} else { |
| 7999 |
i__4 = *n; |
| 8000 |
for (j = 1; j <= i__4; ++j) { |
| 8001 |
vr[j] = 0.; |
| 8002 |
vi[j] = 0.; |
| 8003 |
/* L240: */ |
| 8004 |
} |
| 8005 |
vr[i__] = 1.; |
| 8006 |
vi[i__] = 1.; |
| 8007 |
scale = 0.; |
| 8008 |
vmax = 1.; |
| 8009 |
vcrit = *bignum; |
| 8010 |
} |
| 8011 |
/* L250: */ |
| 8012 |
} |
| 8013 |
|
| 8014 |
/* Test for sufficient growth in the norm of (VR,VI). */ |
| 8015 |
|
| 8016 |
vnorm = dasum_(n, &vr[1], &c__1) + dasum_(n, &vi[1], &c__1); |
| 8017 |
if (vnorm >= growto * scale) { |
| 8018 |
goto L280; |
| 8019 |
} |
| 8020 |
|
| 8021 |
/* Choose a new orthogonal starting vector and try again. */ |
| 8022 |
|
| 8023 |
y = *eps3 / (rootn + 1.); |
| 8024 |
vr[1] = *eps3; |
| 8025 |
vi[1] = 0.; |
| 8026 |
|
| 8027 |
i__3 = *n; |
| 8028 |
for (i__ = 2; i__ <= i__3; ++i__) { |
| 8029 |
vr[i__] = y; |
| 8030 |
vi[i__] = 0.; |
| 8031 |
/* L260: */ |
| 8032 |
} |
| 8033 |
vr[*n - its + 1] -= *eps3 * rootn; |
| 8034 |
/* L270: */ |
| 8035 |
} |
| 8036 |
|
| 8037 |
/* Failure to find eigenvector in N iterations */ |
| 8038 |
|
| 8039 |
*info = 1; |
| 8040 |
|
| 8041 |
L280: |
| 8042 |
|
| 8043 |
/* Normalize eigenvector. */ |
| 8044 |
|
| 8045 |
vnorm = 0.; |
| 8046 |
i__1 = *n; |
| 8047 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 8048 |
/* Computing MAX */ |
| 8049 |
d__3 = vnorm, d__4 = (d__1 = vr[i__], abs(d__1)) + (d__2 = vi[i__] |
| 8050 |
, abs(d__2)); |
| 8051 |
vnorm = std::max(d__3,d__4); |
| 8052 |
/* L290: */ |
| 8053 |
} |
| 8054 |
d__1 = 1. / vnorm; |
| 8055 |
dscal_(n, &d__1, &vr[1], &c__1); |
| 8056 |
d__1 = 1. / vnorm; |
| 8057 |
dscal_(n, &d__1, &vi[1], &c__1); |
| 8058 |
|
| 8059 |
} |
| 8060 |
|
| 8061 |
return 0; |
| 8062 |
|
| 8063 |
/* End of DLAEIN */ |
| 8064 |
|
| 8065 |
} /* dlaein_ */ |
| 8066 |
|
| 8067 |
/* Subroutine */ int dlaev2_(double *a, double *b, double *c__, |
| 8068 |
double *rt1, double *rt2, double *cs1, double *sn1) |
| 8069 |
{ |
| 8070 |
/* System generated locals */ |
| 8071 |
double d__1; |
| 8072 |
|
| 8073 |
/* Builtin functions |
| 8074 |
double sqrt(double); */ |
| 8075 |
|
| 8076 |
/* Local variables */ |
| 8077 |
double ab, df, cs, ct, tb, sm, tn, rt, adf, acs; |
| 8078 |
integer sgn1, sgn2; |
| 8079 |
double acmn, acmx; |
| 8080 |
|
| 8081 |
|
| 8082 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 8083 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 8084 |
/* November 2006 */ |
| 8085 |
|
| 8086 |
/* .. Scalar Arguments .. */ |
| 8087 |
/* .. */ |
| 8088 |
|
| 8089 |
/* Purpose */ |
| 8090 |
/* ======= */ |
| 8091 |
|
| 8092 |
/* DLAEV2 computes the eigendecomposition of a 2-by-2 symmetric matrix */ |
| 8093 |
/* [ A B ] */ |
| 8094 |
/* [ B C ]. */ |
| 8095 |
/* On return, RT1 is the eigenvalue of larger absolute value, RT2 is the */ |
| 8096 |
/* eigenvalue of smaller absolute value, and (CS1,SN1) is the unit right */ |
| 8097 |
/* eigenvector for RT1, giving the decomposition */ |
| 8098 |
|
| 8099 |
/* [ CS1 SN1 ] [ A B ] [ CS1 -SN1 ] = [ RT1 0 ] */ |
| 8100 |
/* [-SN1 CS1 ] [ B C ] [ SN1 CS1 ] [ 0 RT2 ]. */ |
| 8101 |
|
| 8102 |
/* Arguments */ |
| 8103 |
/* ========= */ |
| 8104 |
|
| 8105 |
/* A (input) DOUBLE PRECISION */ |
| 8106 |
/* The (1,1) element of the 2-by-2 matrix. */ |
| 8107 |
|
| 8108 |
/* B (input) DOUBLE PRECISION */ |
| 8109 |
/* The (1,2) element and the conjugate of the (2,1) element of */ |
| 8110 |
/* the 2-by-2 matrix. */ |
| 8111 |
|
| 8112 |
/* C (input) DOUBLE PRECISION */ |
| 8113 |
/* The (2,2) element of the 2-by-2 matrix. */ |
| 8114 |
|
| 8115 |
/* RT1 (output) DOUBLE PRECISION */ |
| 8116 |
/* The eigenvalue of larger absolute value. */ |
| 8117 |
|
| 8118 |
/* RT2 (output) DOUBLE PRECISION */ |
| 8119 |
/* The eigenvalue of smaller absolute value. */ |
| 8120 |
|
| 8121 |
/* CS1 (output) DOUBLE PRECISION */ |
| 8122 |
/* SN1 (output) DOUBLE PRECISION */ |
| 8123 |
/* The vector (CS1, SN1) is a unit right eigenvector for RT1. */ |
| 8124 |
|
| 8125 |
/* Further Details */ |
| 8126 |
/* =============== */ |
| 8127 |
|
| 8128 |
/* RT1 is accurate to a few ulps barring over/underflow. */ |
| 8129 |
|
| 8130 |
/* RT2 may be inaccurate if there is massive cancellation in the */ |
| 8131 |
/* determinant A*C-B*B; higher precision or correctly rounded or */ |
| 8132 |
/* correctly truncated arithmetic would be needed to compute RT2 */ |
| 8133 |
/* accurately in all cases. */ |
| 8134 |
|
| 8135 |
/* CS1 and SN1 are accurate to a few ulps barring over/underflow. */ |
| 8136 |
|
| 8137 |
/* Overflow is possible only if RT1 is within a factor of 5 of overflow. */ |
| 8138 |
/* Underflow is harmless if the input data is 0 or exceeds */ |
| 8139 |
/* underflow_threshold / macheps. */ |
| 8140 |
|
| 8141 |
/* ===================================================================== */ |
| 8142 |
|
| 8143 |
/* .. Parameters .. */ |
| 8144 |
/* .. */ |
| 8145 |
/* .. Local Scalars .. */ |
| 8146 |
/* .. */ |
| 8147 |
/* .. Intrinsic Functions .. */ |
| 8148 |
/* .. */ |
| 8149 |
/* .. Executable Statements .. */ |
| 8150 |
|
| 8151 |
/* Compute the eigenvalues */ |
| 8152 |
|
| 8153 |
sm = *a + *c__; |
| 8154 |
df = *a - *c__; |
| 8155 |
adf = abs(df); |
| 8156 |
tb = *b + *b; |
| 8157 |
ab = abs(tb); |
| 8158 |
if (abs(*a) > abs(*c__)) { |
| 8159 |
acmx = *a; |
| 8160 |
acmn = *c__; |
| 8161 |
} else { |
| 8162 |
acmx = *c__; |
| 8163 |
acmn = *a; |
| 8164 |
} |
| 8165 |
if (adf > ab) { |
| 8166 |
/* Computing 2nd power */ |
| 8167 |
d__1 = ab / adf; |
| 8168 |
rt = adf * sqrt(d__1 * d__1 + 1.); |
| 8169 |
} else if (adf < ab) { |
| 8170 |
/* Computing 2nd power */ |
| 8171 |
d__1 = adf / ab; |
| 8172 |
rt = ab * sqrt(d__1 * d__1 + 1.); |
| 8173 |
} else { |
| 8174 |
|
| 8175 |
/* Includes case AB=ADF=0 */ |
| 8176 |
|
| 8177 |
rt = ab * sqrt(2.); |
| 8178 |
} |
| 8179 |
if (sm < 0.) { |
| 8180 |
*rt1 = (sm - rt) * .5; |
| 8181 |
sgn1 = -1; |
| 8182 |
|
| 8183 |
/* Order of execution important. */ |
| 8184 |
/* To get fully accurate smaller eigenvalue, */ |
| 8185 |
/* next line needs to be executed in higher precision. */ |
| 8186 |
|
| 8187 |
*rt2 = acmx / *rt1 * acmn - *b / *rt1 * *b; |
| 8188 |
} else if (sm > 0.) { |
| 8189 |
*rt1 = (sm + rt) * .5; |
| 8190 |
sgn1 = 1; |
| 8191 |
|
| 8192 |
/* Order of execution important. */ |
| 8193 |
/* To get fully accurate smaller eigenvalue, */ |
| 8194 |
/* next line needs to be executed in higher precision. */ |
| 8195 |
|
| 8196 |
*rt2 = acmx / *rt1 * acmn - *b / *rt1 * *b; |
| 8197 |
} else { |
| 8198 |
|
| 8199 |
/* Includes case RT1 = RT2 = 0 */ |
| 8200 |
|
| 8201 |
*rt1 = rt * .5; |
| 8202 |
*rt2 = rt * -.5; |
| 8203 |
sgn1 = 1; |
| 8204 |
} |
| 8205 |
|
| 8206 |
/* Compute the eigenvector */ |
| 8207 |
|
| 8208 |
if (df >= 0.) { |
| 8209 |
cs = df + rt; |
| 8210 |
sgn2 = 1; |
| 8211 |
} else { |
| 8212 |
cs = df - rt; |
| 8213 |
sgn2 = -1; |
| 8214 |
} |
| 8215 |
acs = abs(cs); |
| 8216 |
if (acs > ab) { |
| 8217 |
ct = -tb / cs; |
| 8218 |
*sn1 = 1. / sqrt(ct * ct + 1.); |
| 8219 |
*cs1 = ct * *sn1; |
| 8220 |
} else { |
| 8221 |
if (ab == 0.) { |
| 8222 |
*cs1 = 1.; |
| 8223 |
*sn1 = 0.; |
| 8224 |
} else { |
| 8225 |
tn = -cs / tb; |
| 8226 |
*cs1 = 1. / sqrt(tn * tn + 1.); |
| 8227 |
*sn1 = tn * *cs1; |
| 8228 |
} |
| 8229 |
} |
| 8230 |
if (sgn1 == sgn2) { |
| 8231 |
tn = *cs1; |
| 8232 |
*cs1 = -(*sn1); |
| 8233 |
*sn1 = tn; |
| 8234 |
} |
| 8235 |
return 0; |
| 8236 |
|
| 8237 |
/* End of DLAEV2 */ |
| 8238 |
|
| 8239 |
} /* dlaev2_ */ |
| 8240 |
|
| 8241 |
/* Subroutine */ int dlaexc_(bool *wantq, integer *n, double *t, |
| 8242 |
integer *ldt, double *q, integer *ldq, integer *j1, integer *n1, |
| 8243 |
integer *n2, double *work, integer *info) |
| 8244 |
{ |
| 8245 |
/* Table of constant values */ |
| 8246 |
static integer c__1 = 1; |
| 8247 |
static integer c__4 = 4; |
| 8248 |
static bool c_false = false; |
| 8249 |
static integer c_n1 = -1; |
| 8250 |
static integer c__2 = 2; |
| 8251 |
static integer c__3 = 3; |
| 8252 |
|
| 8253 |
/* System generated locals */ |
| 8254 |
integer q_dim1, q_offset, t_dim1, t_offset, i__1; |
| 8255 |
double d__1, d__2, d__3; |
| 8256 |
|
| 8257 |
/* Local variables */ |
| 8258 |
double d__[16] /* was [4][4] */; |
| 8259 |
integer k; |
| 8260 |
double u[3], x[4] /* was [2][2] */; |
| 8261 |
integer j2, j3, j4; |
| 8262 |
double u1[3], u2[3]; |
| 8263 |
integer nd; |
| 8264 |
double cs, t11, t22, t33, sn, wi1, wi2, wr1, wr2, eps, tau, tau1, |
| 8265 |
tau2; |
| 8266 |
integer ierr; |
| 8267 |
double temp; |
| 8268 |
double scale, dnorm, xnorm; |
| 8269 |
double thresh, smlnum; |
| 8270 |
|
| 8271 |
|
| 8272 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 8273 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 8274 |
/* November 2006 */ |
| 8275 |
|
| 8276 |
/* .. Scalar Arguments .. */ |
| 8277 |
/* .. */ |
| 8278 |
/* .. Array Arguments .. */ |
| 8279 |
/* .. */ |
| 8280 |
|
| 8281 |
/* Purpose */ |
| 8282 |
/* ======= */ |
| 8283 |
|
| 8284 |
/* DLAEXC swaps adjacent diagonal blocks T11 and T22 of order 1 or 2 in */ |
| 8285 |
/* an upper quasi-triangular matrix T by an orthogonal similarity */ |
| 8286 |
/* transformation. */ |
| 8287 |
|
| 8288 |
/* T must be in Schur canonical form, that is, block upper triangular */ |
| 8289 |
/* with 1-by-1 and 2-by-2 diagonal blocks; each 2-by-2 diagonal block */ |
| 8290 |
/* has its diagonal elemnts equal and its off-diagonal elements of */ |
| 8291 |
/* opposite sign. */ |
| 8292 |
|
| 8293 |
/* Arguments */ |
| 8294 |
/* ========= */ |
| 8295 |
|
| 8296 |
/* WANTQ (input) LOGICAL */ |
| 8297 |
/* = .TRUE. : accumulate the transformation in the matrix Q; */ |
| 8298 |
/* = .FALSE.: do not accumulate the transformation. */ |
| 8299 |
|
| 8300 |
/* N (input) INTEGER */ |
| 8301 |
/* The order of the matrix T. N >= 0. */ |
| 8302 |
|
| 8303 |
/* T (input/output) DOUBLE PRECISION array, dimension (LDT,N) */ |
| 8304 |
/* On entry, the upper quasi-triangular matrix T, in Schur */ |
| 8305 |
/* canonical form. */ |
| 8306 |
/* On exit, the updated matrix T, again in Schur canonical form. */ |
| 8307 |
|
| 8308 |
/* LDT (input) INTEGER */ |
| 8309 |
/* The leading dimension of the array T. LDT >= max(1,N). */ |
| 8310 |
|
| 8311 |
/* Q (input/output) DOUBLE PRECISION array, dimension (LDQ,N) */ |
| 8312 |
/* On entry, if WANTQ is .TRUE., the orthogonal matrix Q. */ |
| 8313 |
/* On exit, if WANTQ is .TRUE., the updated matrix Q. */ |
| 8314 |
/* If WANTQ is .FALSE., Q is not referenced. */ |
| 8315 |
|
| 8316 |
/* LDQ (input) INTEGER */ |
| 8317 |
/* The leading dimension of the array Q. */ |
| 8318 |
/* LDQ >= 1; and if WANTQ is .TRUE., LDQ >= N. */ |
| 8319 |
|
| 8320 |
/* J1 (input) INTEGER */ |
| 8321 |
/* The index of the first row of the first block T11. */ |
| 8322 |
|
| 8323 |
/* N1 (input) INTEGER */ |
| 8324 |
/* The order of the first block T11. N1 = 0, 1 or 2. */ |
| 8325 |
|
| 8326 |
/* N2 (input) INTEGER */ |
| 8327 |
/* The order of the second block T22. N2 = 0, 1 or 2. */ |
| 8328 |
|
| 8329 |
/* WORK (workspace) DOUBLE PRECISION array, dimension (N) */ |
| 8330 |
|
| 8331 |
/* INFO (output) INTEGER */ |
| 8332 |
/* = 0: successful exit */ |
| 8333 |
/* = 1: the transformed matrix T would be too far from Schur */ |
| 8334 |
/* form; the blocks are not swapped and T and Q are */ |
| 8335 |
/* unchanged. */ |
| 8336 |
|
| 8337 |
/* ===================================================================== */ |
| 8338 |
|
| 8339 |
/* .. Parameters .. */ |
| 8340 |
/* .. */ |
| 8341 |
/* .. Local Scalars .. */ |
| 8342 |
/* .. */ |
| 8343 |
/* .. Local Arrays .. */ |
| 8344 |
/* .. */ |
| 8345 |
/* .. External Functions .. */ |
| 8346 |
/* .. */ |
| 8347 |
/* .. External Subroutines .. */ |
| 8348 |
/* .. */ |
| 8349 |
/* .. Intrinsic Functions .. */ |
| 8350 |
/* .. */ |
| 8351 |
/* .. Executable Statements .. */ |
| 8352 |
|
| 8353 |
/* Parameter adjustments */ |
| 8354 |
t_dim1 = *ldt; |
| 8355 |
t_offset = 1 + t_dim1; |
| 8356 |
t -= t_offset; |
| 8357 |
q_dim1 = *ldq; |
| 8358 |
q_offset = 1 + q_dim1; |
| 8359 |
q -= q_offset; |
| 8360 |
--work; |
| 8361 |
|
| 8362 |
/* Function Body */ |
| 8363 |
*info = 0; |
| 8364 |
|
| 8365 |
/* Quick return if possible */ |
| 8366 |
|
| 8367 |
if (*n == 0 || *n1 == 0 || *n2 == 0) { |
| 8368 |
return 0; |
| 8369 |
} |
| 8370 |
if (*j1 + *n1 > *n) { |
| 8371 |
return 0; |
| 8372 |
} |
| 8373 |
|
| 8374 |
j2 = *j1 + 1; |
| 8375 |
j3 = *j1 + 2; |
| 8376 |
j4 = *j1 + 3; |
| 8377 |
|
| 8378 |
if (*n1 == 1 && *n2 == 1) { |
| 8379 |
|
| 8380 |
/* Swap two 1-by-1 blocks. */ |
| 8381 |
|
| 8382 |
t11 = t[*j1 + *j1 * t_dim1]; |
| 8383 |
t22 = t[j2 + j2 * t_dim1]; |
| 8384 |
|
| 8385 |
/* Determine the transformation to perform the interchange. */ |
| 8386 |
|
| 8387 |
d__1 = t22 - t11; |
| 8388 |
dlartg_(&t[*j1 + j2 * t_dim1], &d__1, &cs, &sn, &temp); |
| 8389 |
|
| 8390 |
/* Apply transformation to the matrix T. */ |
| 8391 |
|
| 8392 |
if (j3 <= *n) { |
| 8393 |
i__1 = *n - *j1 - 1; |
| 8394 |
drot_(&i__1, &t[*j1 + j3 * t_dim1], ldt, &t[j2 + j3 * t_dim1], |
| 8395 |
ldt, &cs, &sn); |
| 8396 |
} |
| 8397 |
i__1 = *j1 - 1; |
| 8398 |
drot_(&i__1, &t[*j1 * t_dim1 + 1], &c__1, &t[j2 * t_dim1 + 1], &c__1, |
| 8399 |
&cs, &sn); |
| 8400 |
|
| 8401 |
t[*j1 + *j1 * t_dim1] = t22; |
| 8402 |
t[j2 + j2 * t_dim1] = t11; |
| 8403 |
|
| 8404 |
if (*wantq) { |
| 8405 |
|
| 8406 |
/* Accumulate transformation in the matrix Q. */ |
| 8407 |
|
| 8408 |
drot_(n, &q[*j1 * q_dim1 + 1], &c__1, &q[j2 * q_dim1 + 1], &c__1, |
| 8409 |
&cs, &sn); |
| 8410 |
} |
| 8411 |
|
| 8412 |
} else { |
| 8413 |
|
| 8414 |
/* Swapping involves at least one 2-by-2 block. */ |
| 8415 |
|
| 8416 |
/* Copy the diagonal block of order N1+N2 to the local array D */ |
| 8417 |
/* and compute its norm. */ |
| 8418 |
|
| 8419 |
nd = *n1 + *n2; |
| 8420 |
dlacpy_("Full", &nd, &nd, &t[*j1 + *j1 * t_dim1], ldt, d__, &c__4); |
| 8421 |
dnorm = dlange_("Max", &nd, &nd, d__, &c__4, &work[1]); |
| 8422 |
|
| 8423 |
/* Compute machine-dependent threshold for test for accepting */ |
| 8424 |
/* swap. */ |
| 8425 |
|
| 8426 |
eps = dlamch_("P"); |
| 8427 |
smlnum = dlamch_("S") / eps; |
| 8428 |
/* Computing MAX */ |
| 8429 |
d__1 = eps * 10. * dnorm; |
| 8430 |
thresh = std::max(d__1,smlnum); |
| 8431 |
|
| 8432 |
/* Solve T11*X - X*T22 = scale*T12 for X. */ |
| 8433 |
|
| 8434 |
dlasy2_(&c_false, &c_false, &c_n1, n1, n2, d__, &c__4, &d__[*n1 + 1 + |
| 8435 |
(*n1 + 1 << 2) - 5], &c__4, &d__[(*n1 + 1 << 2) - 4], &c__4, & |
| 8436 |
scale, x, &c__2, &xnorm, &ierr); |
| 8437 |
|
| 8438 |
/* Swap the adjacent diagonal blocks. */ |
| 8439 |
|
| 8440 |
k = *n1 + *n1 + *n2 - 3; |
| 8441 |
switch (k) { |
| 8442 |
case 1: goto L10; |
| 8443 |
case 2: goto L20; |
| 8444 |
case 3: goto L30; |
| 8445 |
} |
| 8446 |
|
| 8447 |
L10: |
| 8448 |
|
| 8449 |
/* N1 = 1, N2 = 2: generate elementary reflector H so that: */ |
| 8450 |
|
| 8451 |
/* ( scale, X11, X12 ) H = ( 0, 0, * ) */ |
| 8452 |
|
| 8453 |
u[0] = scale; |
| 8454 |
u[1] = x[0]; |
| 8455 |
u[2] = x[2]; |
| 8456 |
dlarfg_(&c__3, &u[2], u, &c__1, &tau); |
| 8457 |
u[2] = 1.; |
| 8458 |
t11 = t[*j1 + *j1 * t_dim1]; |
| 8459 |
|
| 8460 |
/* Perform swap provisionally on diagonal block in D. */ |
| 8461 |
|
| 8462 |
dlarfx_("L", &c__3, &c__3, u, &tau, d__, &c__4, &work[1]); |
| 8463 |
dlarfx_("R", &c__3, &c__3, u, &tau, d__, &c__4, &work[1]); |
| 8464 |
|
| 8465 |
/* Test whether to reject swap. */ |
| 8466 |
|
| 8467 |
/* Computing MAX */ |
| 8468 |
d__2 = abs(d__[2]), d__3 = abs(d__[6]), d__2 = std::max(d__2,d__3), d__3 = |
| 8469 |
(d__1 = d__[10] - t11, abs(d__1)); |
| 8470 |
if (std::max(d__2,d__3) > thresh) { |
| 8471 |
goto L50; |
| 8472 |
} |
| 8473 |
|
| 8474 |
/* Accept swap: apply transformation to the entire matrix T. */ |
| 8475 |
|
| 8476 |
i__1 = *n - *j1 + 1; |
| 8477 |
dlarfx_("L", &c__3, &i__1, u, &tau, &t[*j1 + *j1 * t_dim1], ldt, & |
| 8478 |
work[1]); |
| 8479 |
dlarfx_("R", &j2, &c__3, u, &tau, &t[*j1 * t_dim1 + 1], ldt, &work[1]); |
| 8480 |
|
| 8481 |
t[j3 + *j1 * t_dim1] = 0.; |
| 8482 |
t[j3 + j2 * t_dim1] = 0.; |
| 8483 |
t[j3 + j3 * t_dim1] = t11; |
| 8484 |
|
| 8485 |
if (*wantq) { |
| 8486 |
|
| 8487 |
/* Accumulate transformation in the matrix Q. */ |
| 8488 |
|
| 8489 |
dlarfx_("R", n, &c__3, u, &tau, &q[*j1 * q_dim1 + 1], ldq, &work[ |
| 8490 |
1]); |
| 8491 |
} |
| 8492 |
goto L40; |
| 8493 |
|
| 8494 |
L20: |
| 8495 |
|
| 8496 |
/* N1 = 2, N2 = 1: generate elementary reflector H so that: */ |
| 8497 |
|
| 8498 |
/* H ( -X11 ) = ( * ) */ |
| 8499 |
/* ( -X21 ) = ( 0 ) */ |
| 8500 |
/* ( scale ) = ( 0 ) */ |
| 8501 |
|
| 8502 |
u[0] = -x[0]; |
| 8503 |
u[1] = -x[1]; |
| 8504 |
u[2] = scale; |
| 8505 |
dlarfg_(&c__3, u, &u[1], &c__1, &tau); |
| 8506 |
u[0] = 1.; |
| 8507 |
t33 = t[j3 + j3 * t_dim1]; |
| 8508 |
|
| 8509 |
/* Perform swap provisionally on diagonal block in D. */ |
| 8510 |
|
| 8511 |
dlarfx_("L", &c__3, &c__3, u, &tau, d__, &c__4, &work[1]); |
| 8512 |
dlarfx_("R", &c__3, &c__3, u, &tau, d__, &c__4, &work[1]); |
| 8513 |
|
| 8514 |
/* Test whether to reject swap. */ |
| 8515 |
|
| 8516 |
/* Computing MAX */ |
| 8517 |
d__2 = abs(d__[1]), d__3 = abs(d__[2]), d__2 = std::max(d__2,d__3), d__3 = |
| 8518 |
(d__1 = d__[0] - t33, abs(d__1)); |
| 8519 |
if (std::max(d__2,d__3) > thresh) { |
| 8520 |
goto L50; |
| 8521 |
} |
| 8522 |
|
| 8523 |
/* Accept swap: apply transformation to the entire matrix T. */ |
| 8524 |
|
| 8525 |
dlarfx_("R", &j3, &c__3, u, &tau, &t[*j1 * t_dim1 + 1], ldt, &work[1]); |
| 8526 |
i__1 = *n - *j1; |
| 8527 |
dlarfx_("L", &c__3, &i__1, u, &tau, &t[*j1 + j2 * t_dim1], ldt, &work[ |
| 8528 |
1]); |
| 8529 |
|
| 8530 |
t[*j1 + *j1 * t_dim1] = t33; |
| 8531 |
t[j2 + *j1 * t_dim1] = 0.; |
| 8532 |
t[j3 + *j1 * t_dim1] = 0.; |
| 8533 |
|
| 8534 |
if (*wantq) { |
| 8535 |
|
| 8536 |
/* Accumulate transformation in the matrix Q. */ |
| 8537 |
|
| 8538 |
dlarfx_("R", n, &c__3, u, &tau, &q[*j1 * q_dim1 + 1], ldq, &work[ |
| 8539 |
1]); |
| 8540 |
} |
| 8541 |
goto L40; |
| 8542 |
|
| 8543 |
L30: |
| 8544 |
|
| 8545 |
/* N1 = 2, N2 = 2: generate elementary reflectors H(1) and H(2) so */ |
| 8546 |
/* that: */ |
| 8547 |
|
| 8548 |
/* H(2) H(1) ( -X11 -X12 ) = ( * * ) */ |
| 8549 |
/* ( -X21 -X22 ) ( 0 * ) */ |
| 8550 |
/* ( scale 0 ) ( 0 0 ) */ |
| 8551 |
/* ( 0 scale ) ( 0 0 ) */ |
| 8552 |
|
| 8553 |
u1[0] = -x[0]; |
| 8554 |
u1[1] = -x[1]; |
| 8555 |
u1[2] = scale; |
| 8556 |
dlarfg_(&c__3, u1, &u1[1], &c__1, &tau1); |
| 8557 |
u1[0] = 1.; |
| 8558 |
|
| 8559 |
temp = -tau1 * (x[2] + u1[1] * x[3]); |
| 8560 |
u2[0] = -temp * u1[1] - x[3]; |
| 8561 |
u2[1] = -temp * u1[2]; |
| 8562 |
u2[2] = scale; |
| 8563 |
dlarfg_(&c__3, u2, &u2[1], &c__1, &tau2); |
| 8564 |
u2[0] = 1.; |
| 8565 |
|
| 8566 |
/* Perform swap provisionally on diagonal block in D. */ |
| 8567 |
|
| 8568 |
dlarfx_("L", &c__3, &c__4, u1, &tau1, d__, &c__4, &work[1]) |
| 8569 |
; |
| 8570 |
dlarfx_("R", &c__4, &c__3, u1, &tau1, d__, &c__4, &work[1]) |
| 8571 |
; |
| 8572 |
dlarfx_("L", &c__3, &c__4, u2, &tau2, &d__[1], &c__4, &work[1]); |
| 8573 |
dlarfx_("R", &c__4, &c__3, u2, &tau2, &d__[4], &c__4, &work[1]); |
| 8574 |
|
| 8575 |
/* Test whether to reject swap. */ |
| 8576 |
|
| 8577 |
/* Computing MAX */ |
| 8578 |
d__1 = abs(d__[2]), d__2 = abs(d__[6]), d__1 = std::max(d__1,d__2), d__2 = |
| 8579 |
abs(d__[3]), d__1 = std::max(d__1,d__2), d__2 = abs(d__[7]); |
| 8580 |
if (std::max(d__1,d__2) > thresh) { |
| 8581 |
goto L50; |
| 8582 |
} |
| 8583 |
|
| 8584 |
/* Accept swap: apply transformation to the entire matrix T. */ |
| 8585 |
|
| 8586 |
i__1 = *n - *j1 + 1; |
| 8587 |
dlarfx_("L", &c__3, &i__1, u1, &tau1, &t[*j1 + *j1 * t_dim1], ldt, & |
| 8588 |
work[1]); |
| 8589 |
dlarfx_("R", &j4, &c__3, u1, &tau1, &t[*j1 * t_dim1 + 1], ldt, &work[ |
| 8590 |
1]); |
| 8591 |
i__1 = *n - *j1 + 1; |
| 8592 |
dlarfx_("L", &c__3, &i__1, u2, &tau2, &t[j2 + *j1 * t_dim1], ldt, & |
| 8593 |
work[1]); |
| 8594 |
dlarfx_("R", &j4, &c__3, u2, &tau2, &t[j2 * t_dim1 + 1], ldt, &work[1] |
| 8595 |
); |
| 8596 |
|
| 8597 |
t[j3 + *j1 * t_dim1] = 0.; |
| 8598 |
t[j3 + j2 * t_dim1] = 0.; |
| 8599 |
t[j4 + *j1 * t_dim1] = 0.; |
| 8600 |
t[j4 + j2 * t_dim1] = 0.; |
| 8601 |
|
| 8602 |
if (*wantq) { |
| 8603 |
|
| 8604 |
/* Accumulate transformation in the matrix Q. */ |
| 8605 |
|
| 8606 |
dlarfx_("R", n, &c__3, u1, &tau1, &q[*j1 * q_dim1 + 1], ldq, & |
| 8607 |
work[1]); |
| 8608 |
dlarfx_("R", n, &c__3, u2, &tau2, &q[j2 * q_dim1 + 1], ldq, &work[ |
| 8609 |
1]); |
| 8610 |
} |
| 8611 |
|
| 8612 |
L40: |
| 8613 |
|
| 8614 |
if (*n2 == 2) { |
| 8615 |
|
| 8616 |
/* Standardize new 2-by-2 block T11 */ |
| 8617 |
|
| 8618 |
dlanv2_(&t[*j1 + *j1 * t_dim1], &t[*j1 + j2 * t_dim1], &t[j2 + * |
| 8619 |
j1 * t_dim1], &t[j2 + j2 * t_dim1], &wr1, &wi1, &wr2, & |
| 8620 |
wi2, &cs, &sn); |
| 8621 |
i__1 = *n - *j1 - 1; |
| 8622 |
drot_(&i__1, &t[*j1 + (*j1 + 2) * t_dim1], ldt, &t[j2 + (*j1 + 2) |
| 8623 |
* t_dim1], ldt, &cs, &sn); |
| 8624 |
i__1 = *j1 - 1; |
| 8625 |
drot_(&i__1, &t[*j1 * t_dim1 + 1], &c__1, &t[j2 * t_dim1 + 1], & |
| 8626 |
c__1, &cs, &sn); |
| 8627 |
if (*wantq) { |
| 8628 |
drot_(n, &q[*j1 * q_dim1 + 1], &c__1, &q[j2 * q_dim1 + 1], & |
| 8629 |
c__1, &cs, &sn); |
| 8630 |
} |
| 8631 |
} |
| 8632 |
|
| 8633 |
if (*n1 == 2) { |
| 8634 |
|
| 8635 |
/* Standardize new 2-by-2 block T22 */ |
| 8636 |
|
| 8637 |
j3 = *j1 + *n2; |
| 8638 |
j4 = j3 + 1; |
| 8639 |
dlanv2_(&t[j3 + j3 * t_dim1], &t[j3 + j4 * t_dim1], &t[j4 + j3 * |
| 8640 |
t_dim1], &t[j4 + j4 * t_dim1], &wr1, &wi1, &wr2, &wi2, & |
| 8641 |
cs, &sn); |
| 8642 |
if (j3 + 2 <= *n) { |
| 8643 |
i__1 = *n - j3 - 1; |
| 8644 |
drot_(&i__1, &t[j3 + (j3 + 2) * t_dim1], ldt, &t[j4 + (j3 + 2) |
| 8645 |
* t_dim1], ldt, &cs, &sn); |
| 8646 |
} |
| 8647 |
i__1 = j3 - 1; |
| 8648 |
drot_(&i__1, &t[j3 * t_dim1 + 1], &c__1, &t[j4 * t_dim1 + 1], & |
| 8649 |
c__1, &cs, &sn); |
| 8650 |
if (*wantq) { |
| 8651 |
drot_(n, &q[j3 * q_dim1 + 1], &c__1, &q[j4 * q_dim1 + 1], & |
| 8652 |
c__1, &cs, &sn); |
| 8653 |
} |
| 8654 |
} |
| 8655 |
|
| 8656 |
} |
| 8657 |
return 0; |
| 8658 |
|
| 8659 |
/* Exit with INFO = 1 if swap was rejected. */ |
| 8660 |
|
| 8661 |
L50: |
| 8662 |
*info = 1; |
| 8663 |
return 0; |
| 8664 |
|
| 8665 |
/* End of DLAEXC */ |
| 8666 |
|
| 8667 |
} /* dlaexc_ */ |
| 8668 |
|
| 8669 |
/* Subroutine */ int dlag2_(double *a, integer *lda, double *b, |
| 8670 |
integer *ldb, double *safmin, double *scale1, double * |
| 8671 |
scale2, double *wr1, double *wr2, double *wi) |
| 8672 |
{ |
| 8673 |
/* System generated locals */ |
| 8674 |
integer a_dim1, a_offset, b_dim1, b_offset; |
| 8675 |
double d__1, d__2, d__3, d__4, d__5, d__6; |
| 8676 |
|
| 8677 |
/* Builtin functions |
| 8678 |
double sqrt(double), d_sign(double *, double *); */ |
| 8679 |
|
| 8680 |
/* Local variables */ |
| 8681 |
double r__, c1, c2, c3, c4, c5, s1, s2, a11, a12, a21, a22, b11, b12, |
| 8682 |
b22, pp, qq, ss, as11, as12, as22, sum, abi22, diff, bmin, wbig, |
| 8683 |
wabs, wdet, binv11, binv22, discr, anorm, bnorm, bsize, shift, |
| 8684 |
rtmin, rtmax, wsize, ascale, bscale, wscale, safmax, wsmall; |
| 8685 |
|
| 8686 |
|
| 8687 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 8688 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 8689 |
/* November 2006 */ |
| 8690 |
|
| 8691 |
/* .. Scalar Arguments .. */ |
| 8692 |
/* .. */ |
| 8693 |
/* .. Array Arguments .. */ |
| 8694 |
/* .. */ |
| 8695 |
|
| 8696 |
/* Purpose */ |
| 8697 |
/* ======= */ |
| 8698 |
|
| 8699 |
/* DLAG2 computes the eigenvalues of a 2 x 2 generalized eigenvalue */ |
| 8700 |
/* problem A - w B, with scaling as necessary to avoid over-/underflow. */ |
| 8701 |
|
| 8702 |
/* The scaling factor "s" results in a modified eigenvalue equation */ |
| 8703 |
|
| 8704 |
/* s A - w B */ |
| 8705 |
|
| 8706 |
/* where s is a non-negative scaling factor chosen so that w, w B, */ |
| 8707 |
/* and s A do not overflow and, if possible, do not underflow, either. */ |
| 8708 |
|
| 8709 |
/* Arguments */ |
| 8710 |
/* ========= */ |
| 8711 |
|
| 8712 |
/* A (input) DOUBLE PRECISION array, dimension (LDA, 2) */ |
| 8713 |
/* On entry, the 2 x 2 matrix A. It is assumed that its 1-norm */ |
| 8714 |
/* is less than 1/SAFMIN. Entries less than */ |
| 8715 |
/* sqrt(SAFMIN)*norm(A) are subject to being treated as zero. */ |
| 8716 |
|
| 8717 |
/* LDA (input) INTEGER */ |
| 8718 |
/* The leading dimension of the array A. LDA >= 2. */ |
| 8719 |
|
| 8720 |
/* B (input) DOUBLE PRECISION array, dimension (LDB, 2) */ |
| 8721 |
/* On entry, the 2 x 2 upper triangular matrix B. It is */ |
| 8722 |
/* assumed that the one-norm of B is less than 1/SAFMIN. The */ |
| 8723 |
/* diagonals should be at least sqrt(SAFMIN) times the largest */ |
| 8724 |
/* element of B (in absolute value); if a diagonal is smaller */ |
| 8725 |
/* than that, then +/- sqrt(SAFMIN) will be used instead of */ |
| 8726 |
/* that diagonal. */ |
| 8727 |
|
| 8728 |
/* LDB (input) INTEGER */ |
| 8729 |
/* The leading dimension of the array B. LDB >= 2. */ |
| 8730 |
|
| 8731 |
/* SAFMIN (input) DOUBLE PRECISION */ |
| 8732 |
/* The smallest positive number s.t. 1/SAFMIN does not */ |
| 8733 |
/* overflow. (This should always be DLAMCH('S') -- it is an */ |
| 8734 |
/* argument in order to avoid having to call DLAMCH frequently.) */ |
| 8735 |
|
| 8736 |
/* SCALE1 (output) DOUBLE PRECISION */ |
| 8737 |
/* A scaling factor used to avoid over-/underflow in the */ |
| 8738 |
/* eigenvalue equation which defines the first eigenvalue. If */ |
| 8739 |
/* the eigenvalues are complex, then the eigenvalues are */ |
| 8740 |
/* ( WR1 +/- WI i ) / SCALE1 (which may lie outside the */ |
| 8741 |
/* exponent range of the machine), SCALE1=SCALE2, and SCALE1 */ |
| 8742 |
/* will always be positive. If the eigenvalues are real, then */ |
| 8743 |
/* the first (real) eigenvalue is WR1 / SCALE1 , but this may */ |
| 8744 |
/* overflow or underflow, and in fact, SCALE1 may be zero or */ |
| 8745 |
/* less than the underflow threshhold if the exact eigenvalue */ |
| 8746 |
/* is sufficiently large. */ |
| 8747 |
|
| 8748 |
/* SCALE2 (output) DOUBLE PRECISION */ |
| 8749 |
/* A scaling factor used to avoid over-/underflow in the */ |
| 8750 |
/* eigenvalue equation which defines the second eigenvalue. If */ |
| 8751 |
/* the eigenvalues are complex, then SCALE2=SCALE1. If the */ |
| 8752 |
/* eigenvalues are real, then the second (real) eigenvalue is */ |
| 8753 |
/* WR2 / SCALE2 , but this may overflow or underflow, and in */ |
| 8754 |
/* fact, SCALE2 may be zero or less than the underflow */ |
| 8755 |
/* threshhold if the exact eigenvalue is sufficiently large. */ |
| 8756 |
|
| 8757 |
/* WR1 (output) DOUBLE PRECISION */ |
| 8758 |
/* If the eigenvalue is real, then WR1 is SCALE1 times the */ |
| 8759 |
/* eigenvalue closest to the (2,2) element of A B**(-1). If the */ |
| 8760 |
/* eigenvalue is complex, then WR1=WR2 is SCALE1 times the real */ |
| 8761 |
/* part of the eigenvalues. */ |
| 8762 |
|
| 8763 |
/* WR2 (output) DOUBLE PRECISION */ |
| 8764 |
/* If the eigenvalue is real, then WR2 is SCALE2 times the */ |
| 8765 |
/* other eigenvalue. If the eigenvalue is complex, then */ |
| 8766 |
/* WR1=WR2 is SCALE1 times the real part of the eigenvalues. */ |
| 8767 |
|
| 8768 |
/* WI (output) DOUBLE PRECISION */ |
| 8769 |
/* If the eigenvalue is real, then WI is zero. If the */ |
| 8770 |
/* eigenvalue is complex, then WI is SCALE1 times the imaginary */ |
| 8771 |
/* part of the eigenvalues. WI will always be non-negative. */ |
| 8772 |
|
| 8773 |
/* ===================================================================== */ |
| 8774 |
|
| 8775 |
/* .. Parameters .. */ |
| 8776 |
/* .. */ |
| 8777 |
/* .. Local Scalars .. */ |
| 8778 |
/* .. */ |
| 8779 |
/* .. Intrinsic Functions .. */ |
| 8780 |
/* .. */ |
| 8781 |
/* .. Executable Statements .. */ |
| 8782 |
|
| 8783 |
/* Parameter adjustments */ |
| 8784 |
a_dim1 = *lda; |
| 8785 |
a_offset = 1 + a_dim1; |
| 8786 |
a -= a_offset; |
| 8787 |
b_dim1 = *ldb; |
| 8788 |
b_offset = 1 + b_dim1; |
| 8789 |
b -= b_offset; |
| 8790 |
|
| 8791 |
/* Function Body */ |
| 8792 |
rtmin = sqrt(*safmin); |
| 8793 |
rtmax = 1. / rtmin; |
| 8794 |
safmax = 1. / *safmin; |
| 8795 |
|
| 8796 |
/* Scale A */ |
| 8797 |
|
| 8798 |
/* Computing MAX */ |
| 8799 |
d__5 = (d__1 = a[a_dim1 + 1], abs(d__1)) + (d__2 = a[a_dim1 + 2], abs( |
| 8800 |
d__2)), d__6 = (d__3 = a[(a_dim1 << 1) + 1], abs(d__3)) + (d__4 = |
| 8801 |
a[(a_dim1 << 1) + 2], abs(d__4)), d__5 = std::max(d__5,d__6); |
| 8802 |
anorm = std::max(d__5,*safmin); |
| 8803 |
ascale = 1. / anorm; |
| 8804 |
a11 = ascale * a[a_dim1 + 1]; |
| 8805 |
a21 = ascale * a[a_dim1 + 2]; |
| 8806 |
a12 = ascale * a[(a_dim1 << 1) + 1]; |
| 8807 |
a22 = ascale * a[(a_dim1 << 1) + 2]; |
| 8808 |
|
| 8809 |
/* Perturb B if necessary to insure non-singularity */ |
| 8810 |
|
| 8811 |
b11 = b[b_dim1 + 1]; |
| 8812 |
b12 = b[(b_dim1 << 1) + 1]; |
| 8813 |
b22 = b[(b_dim1 << 1) + 2]; |
| 8814 |
/* Computing MAX */ |
| 8815 |
d__1 = abs(b11), d__2 = abs(b12), d__1 = std::max(d__1,d__2), d__2 = abs(b22), |
| 8816 |
d__1 = std::max(d__1,d__2); |
| 8817 |
bmin = rtmin * std::max(d__1,rtmin); |
| 8818 |
if (abs(b11) < bmin) { |
| 8819 |
b11 = d_sign(&bmin, &b11); |
| 8820 |
} |
| 8821 |
if (abs(b22) < bmin) { |
| 8822 |
b22 = d_sign(&bmin, &b22); |
| 8823 |
} |
| 8824 |
|
| 8825 |
/* Scale B */ |
| 8826 |
|
| 8827 |
/* Computing MAX */ |
| 8828 |
d__1 = abs(b11), d__2 = abs(b12) + abs(b22), d__1 = std::max(d__1,d__2); |
| 8829 |
bnorm = std::max(d__1,*safmin); |
| 8830 |
/* Computing MAX */ |
| 8831 |
d__1 = abs(b11), d__2 = abs(b22); |
| 8832 |
bsize = std::max(d__1,d__2); |
| 8833 |
bscale = 1. / bsize; |
| 8834 |
b11 *= bscale; |
| 8835 |
b12 *= bscale; |
| 8836 |
b22 *= bscale; |
| 8837 |
|
| 8838 |
/* Compute larger eigenvalue by method described by C. van Loan */ |
| 8839 |
|
| 8840 |
/* ( AS is A shifted by -SHIFT*B ) */ |
| 8841 |
|
| 8842 |
binv11 = 1. / b11; |
| 8843 |
binv22 = 1. / b22; |
| 8844 |
s1 = a11 * binv11; |
| 8845 |
s2 = a22 * binv22; |
| 8846 |
if (abs(s1) <= abs(s2)) { |
| 8847 |
as12 = a12 - s1 * b12; |
| 8848 |
as22 = a22 - s1 * b22; |
| 8849 |
ss = a21 * (binv11 * binv22); |
| 8850 |
abi22 = as22 * binv22 - ss * b12; |
| 8851 |
pp = abi22 * .5; |
| 8852 |
shift = s1; |
| 8853 |
} else { |
| 8854 |
as12 = a12 - s2 * b12; |
| 8855 |
as11 = a11 - s2 * b11; |
| 8856 |
ss = a21 * (binv11 * binv22); |
| 8857 |
abi22 = -ss * b12; |
| 8858 |
pp = (as11 * binv11 + abi22) * .5; |
| 8859 |
shift = s2; |
| 8860 |
} |
| 8861 |
qq = ss * as12; |
| 8862 |
if ((d__1 = pp * rtmin, abs(d__1)) >= 1.) { |
| 8863 |
/* Computing 2nd power */ |
| 8864 |
d__1 = rtmin * pp; |
| 8865 |
discr = d__1 * d__1 + qq * *safmin; |
| 8866 |
r__ = sqrt((abs(discr))) * rtmax; |
| 8867 |
} else { |
| 8868 |
/* Computing 2nd power */ |
| 8869 |
d__1 = pp; |
| 8870 |
if (d__1 * d__1 + abs(qq) <= *safmin) { |
| 8871 |
/* Computing 2nd power */ |
| 8872 |
d__1 = rtmax * pp; |
| 8873 |
discr = d__1 * d__1 + qq * safmax; |
| 8874 |
r__ = sqrt((abs(discr))) * rtmin; |
| 8875 |
} else { |
| 8876 |
/* Computing 2nd power */ |
| 8877 |
d__1 = pp; |
| 8878 |
discr = d__1 * d__1 + qq; |
| 8879 |
r__ = sqrt((abs(discr))); |
| 8880 |
} |
| 8881 |
} |
| 8882 |
|
| 8883 |
/* Note: the test of R in the following IF is to cover the case when */ |
| 8884 |
/* DISCR is small and negative and is flushed to zero during */ |
| 8885 |
/* the calculation of R. On machines which have a consistent */ |
| 8886 |
/* flush-to-zero threshhold and handle numbers above that */ |
| 8887 |
/* threshhold correctly, it would not be necessary. */ |
| 8888 |
|
| 8889 |
if (discr >= 0. || r__ == 0.) { |
| 8890 |
sum = pp + d_sign(&r__, &pp); |
| 8891 |
diff = pp - d_sign(&r__, &pp); |
| 8892 |
wbig = shift + sum; |
| 8893 |
|
| 8894 |
/* Compute smaller eigenvalue */ |
| 8895 |
|
| 8896 |
wsmall = shift + diff; |
| 8897 |
/* Computing MAX */ |
| 8898 |
d__1 = abs(wsmall); |
| 8899 |
if (abs(wbig) * .5 > std::max(d__1,*safmin)) { |
| 8900 |
wdet = (a11 * a22 - a12 * a21) * (binv11 * binv22); |
| 8901 |
wsmall = wdet / wbig; |
| 8902 |
} |
| 8903 |
|
| 8904 |
/* Choose (real) eigenvalue closest to 2,2 element of A*B**(-1) */ |
| 8905 |
/* for WR1. */ |
| 8906 |
|
| 8907 |
if (pp > abi22) { |
| 8908 |
*wr1 = std::min(wbig,wsmall); |
| 8909 |
*wr2 = std::max(wbig,wsmall); |
| 8910 |
} else { |
| 8911 |
*wr1 = std::max(wbig,wsmall); |
| 8912 |
*wr2 = std::min(wbig,wsmall); |
| 8913 |
} |
| 8914 |
*wi = 0.; |
| 8915 |
} else { |
| 8916 |
|
| 8917 |
/* Complex eigenvalues */ |
| 8918 |
|
| 8919 |
*wr1 = shift + pp; |
| 8920 |
*wr2 = *wr1; |
| 8921 |
*wi = r__; |
| 8922 |
} |
| 8923 |
|
| 8924 |
/* Further scaling to avoid underflow and overflow in computing */ |
| 8925 |
/* SCALE1 and overflow in computing w*B. */ |
| 8926 |
|
| 8927 |
/* This scale factor (WSCALE) is bounded from above using C1 and C2, */ |
| 8928 |
/* and from below using C3 and C4. */ |
| 8929 |
/* C1 implements the condition s A must never overflow. */ |
| 8930 |
/* C2 implements the condition w B must never overflow. */ |
| 8931 |
/* C3, with C2, */ |
| 8932 |
/* implement the condition that s A - w B must never overflow. */ |
| 8933 |
/* C4 implements the condition s should not underflow. */ |
| 8934 |
/* C5 implements the condition max(s,|w|) should be at least 2. */ |
| 8935 |
|
| 8936 |
c1 = bsize * (*safmin * std::max(1.,ascale)); |
| 8937 |
c2 = *safmin * std::max(1.,bnorm); |
| 8938 |
c3 = bsize * *safmin; |
| 8939 |
if (ascale <= 1. && bsize <= 1.) { |
| 8940 |
/* Computing MIN */ |
| 8941 |
d__1 = 1., d__2 = ascale / *safmin * bsize; |
| 8942 |
c4 = std::min(d__1,d__2); |
| 8943 |
} else { |
| 8944 |
c4 = 1.; |
| 8945 |
} |
| 8946 |
if (ascale <= 1. || bsize <= 1.) { |
| 8947 |
/* Computing MIN */ |
| 8948 |
d__1 = 1., d__2 = ascale * bsize; |
| 8949 |
c5 = std::min(d__1,d__2); |
| 8950 |
} else { |
| 8951 |
c5 = 1.; |
| 8952 |
} |
| 8953 |
|
| 8954 |
/* Scale first eigenvalue */ |
| 8955 |
|
| 8956 |
wabs = abs(*wr1) + abs(*wi); |
| 8957 |
/* Computing MAX */ |
| 8958 |
/* Computing MIN */ |
| 8959 |
d__3 = c4, d__4 = std::max(wabs,c5) * .5; |
| 8960 |
d__1 = std::max(*safmin,c1), d__2 = (wabs * c2 + c3) * 1.0000100000000001, |
| 8961 |
d__1 = std::max(d__1,d__2), d__2 = std::min(d__3,d__4); |
| 8962 |
wsize = std::max(d__1,d__2); |
| 8963 |
if (wsize != 1.) { |
| 8964 |
wscale = 1. / wsize; |
| 8965 |
if (wsize > 1.) { |
| 8966 |
*scale1 = std::max(ascale,bsize) * wscale * std::min(ascale,bsize); |
| 8967 |
} else { |
| 8968 |
*scale1 = std::min(ascale,bsize) * wscale * std::max(ascale,bsize); |
| 8969 |
} |
| 8970 |
*wr1 *= wscale; |
| 8971 |
if (*wi != 0.) { |
| 8972 |
*wi *= wscale; |
| 8973 |
*wr2 = *wr1; |
| 8974 |
*scale2 = *scale1; |
| 8975 |
} |
| 8976 |
} else { |
| 8977 |
*scale1 = ascale * bsize; |
| 8978 |
*scale2 = *scale1; |
| 8979 |
} |
| 8980 |
|
| 8981 |
/* Scale second eigenvalue (if real) */ |
| 8982 |
|
| 8983 |
if (*wi == 0.) { |
| 8984 |
/* Computing MAX */ |
| 8985 |
/* Computing MIN */ |
| 8986 |
/* Computing MAX */ |
| 8987 |
d__5 = abs(*wr2); |
| 8988 |
d__3 = c4, d__4 = std::max(d__5,c5) * .5; |
| 8989 |
d__1 = std::max(*safmin,c1), d__2 = (abs(*wr2) * c2 + c3) * |
| 8990 |
1.0000100000000001, d__1 = std::max(d__1,d__2), d__2 = std::min(d__3, |
| 8991 |
d__4); |
| 8992 |
wsize = std::max(d__1,d__2); |
| 8993 |
if (wsize != 1.) { |
| 8994 |
wscale = 1. / wsize; |
| 8995 |
if (wsize > 1.) { |
| 8996 |
*scale2 = std::max(ascale,bsize) * wscale * std::min(ascale,bsize); |
| 8997 |
} else { |
| 8998 |
*scale2 = std::min(ascale,bsize) * wscale * std::max(ascale,bsize); |
| 8999 |
} |
| 9000 |
*wr2 *= wscale; |
| 9001 |
} else { |
| 9002 |
*scale2 = ascale * bsize; |
| 9003 |
} |
| 9004 |
} |
| 9005 |
|
| 9006 |
/* End of DLAG2 */ |
| 9007 |
|
| 9008 |
return 0; |
| 9009 |
} /* dlag2_ */ |
| 9010 |
|
| 9011 |
/* Subroutine */ int dlag2s_(integer *m, integer *n, double *a, integer *lda, float *sa, integer *ldsa, integer *info) |
| 9012 |
{ |
| 9013 |
/* System generated locals */ |
| 9014 |
integer sa_dim1, sa_offset, a_dim1, a_offset, i__1, i__2; |
| 9015 |
|
| 9016 |
/* Local variables */ |
| 9017 |
integer i__, j; |
| 9018 |
double rmax; |
| 9019 |
|
| 9020 |
|
| 9021 |
/* -- LAPACK PROTOTYPE auxiliary routine (version 3.1.2) -- */ |
| 9022 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 9023 |
/* August 2007 */ |
| 9024 |
|
| 9025 |
/* .. */ |
| 9026 |
|
| 9027 |
/* .. Scalar Arguments .. */ |
| 9028 |
/* .. */ |
| 9029 |
/* .. Array Arguments .. */ |
| 9030 |
/* .. */ |
| 9031 |
|
| 9032 |
/* Purpose */ |
| 9033 |
/* ======= */ |
| 9034 |
|
| 9035 |
/* DLAG2S converts a DOUBLE PRECISION matrix, SA, to a SINGLE */ |
| 9036 |
/* PRECISION matrix, A. */ |
| 9037 |
|
| 9038 |
/* RMAX is the overflow for the SINGLE PRECISION arithmetic */ |
| 9039 |
/* DLAG2S checks that all the entries of A are between -RMAX and */ |
| 9040 |
/* RMAX. If not the convertion is aborted and a flag is raised. */ |
| 9041 |
|
| 9042 |
/* This is an auxiliary routine so there is no argument checking. */ |
| 9043 |
|
| 9044 |
/* Arguments */ |
| 9045 |
/* ========= */ |
| 9046 |
|
| 9047 |
/* M (input) INTEGER */ |
| 9048 |
/* The number of lines of the matrix A. M >= 0. */ |
| 9049 |
|
| 9050 |
/* N (input) INTEGER */ |
| 9051 |
/* The number of columns of the matrix A. N >= 0. */ |
| 9052 |
|
| 9053 |
/* A (input) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 9054 |
/* On entry, the M-by-N coefficient matrix A. */ |
| 9055 |
|
| 9056 |
/* LDA (input) INTEGER */ |
| 9057 |
/* The leading dimension of the array A. LDA >= max(1,M). */ |
| 9058 |
|
| 9059 |
/* SA (output) REAL array, dimension (LDSA,N) */ |
| 9060 |
/* On exit, if INFO=0, the M-by-N coefficient matrix SA; if */ |
| 9061 |
/* INFO>0, the content of SA is unspecified. */ |
| 9062 |
|
| 9063 |
/* LDSA (input) INTEGER */ |
| 9064 |
/* The leading dimension of the array SA. LDSA >= max(1,M). */ |
| 9065 |
|
| 9066 |
/* INFO (output) INTEGER */ |
| 9067 |
/* = 0: successful exit */ |
| 9068 |
/* = 1: an entry of the matrix A is greater than the SINGLE */ |
| 9069 |
/* PRECISION overflow threshold, in this case, the content */ |
| 9070 |
/* of SA in exit is unspecified. */ |
| 9071 |
|
| 9072 |
/* ========= */ |
| 9073 |
|
| 9074 |
/* .. Local Scalars .. */ |
| 9075 |
/* .. */ |
| 9076 |
/* .. External Functions .. */ |
| 9077 |
/* .. */ |
| 9078 |
/* .. Executable Statements .. */ |
| 9079 |
|
| 9080 |
/* Parameter adjustments */ |
| 9081 |
a_dim1 = *lda; |
| 9082 |
a_offset = 1 + a_dim1; |
| 9083 |
a -= a_offset; |
| 9084 |
sa_dim1 = *ldsa; |
| 9085 |
sa_offset = 1 + sa_dim1; |
| 9086 |
sa -= sa_offset; |
| 9087 |
|
| 9088 |
/* Function Body */ |
| 9089 |
rmax = slamch_("O"); |
| 9090 |
i__1 = *n; |
| 9091 |
for (j = 1; j <= i__1; ++j) { |
| 9092 |
i__2 = *m; |
| 9093 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 9094 |
if (a[i__ + j * a_dim1] < -rmax || a[i__ + j * a_dim1] > rmax) { |
| 9095 |
*info = 1; |
| 9096 |
goto L30; |
| 9097 |
} |
| 9098 |
sa[i__ + j * sa_dim1] = a[i__ + j * a_dim1]; |
| 9099 |
/* L10: */ |
| 9100 |
} |
| 9101 |
/* L20: */ |
| 9102 |
} |
| 9103 |
*info = 0; |
| 9104 |
L30: |
| 9105 |
return 0; |
| 9106 |
|
| 9107 |
/* End of DLAG2S */ |
| 9108 |
|
| 9109 |
} /* dlag2s_ */ |
| 9110 |
|
| 9111 |
/* Subroutine */ int dlags2_(bool *upper, double *a1, double *a2, |
| 9112 |
double *a3, double *b1, double *b2, double *b3, |
| 9113 |
double *csu, double *snu, double *csv, double *snv, |
| 9114 |
double *csq, double *snq) |
| 9115 |
{ |
| 9116 |
/* System generated locals */ |
| 9117 |
double d__1; |
| 9118 |
|
| 9119 |
/* Local variables */ |
| 9120 |
double a, b, c__, d__, r__, s1, s2, ua11, ua12, ua21, ua22, vb11, |
| 9121 |
vb12, vb21, vb22, csl, csr, snl, snr, aua11, aua12, aua21, aua22, |
| 9122 |
avb11, avb12, avb21, avb22, ua11r, ua22r, vb11r, vb22r; |
| 9123 |
|
| 9124 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 9125 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 9126 |
/* November 2006 */ |
| 9127 |
|
| 9128 |
/* .. Scalar Arguments .. */ |
| 9129 |
/* .. */ |
| 9130 |
|
| 9131 |
/* Purpose */ |
| 9132 |
/* ======= */ |
| 9133 |
|
| 9134 |
/* DLAGS2 computes 2-by-2 orthogonal matrices U, V and Q, such */ |
| 9135 |
/* that if ( UPPER ) then */ |
| 9136 |
|
| 9137 |
/* U'*A*Q = U'*( A1 A2 )*Q = ( x 0 ) */ |
| 9138 |
/* ( 0 A3 ) ( x x ) */ |
| 9139 |
/* and */ |
| 9140 |
/* V'*B*Q = V'*( B1 B2 )*Q = ( x 0 ) */ |
| 9141 |
/* ( 0 B3 ) ( x x ) */ |
| 9142 |
|
| 9143 |
/* or if ( .NOT.UPPER ) then */ |
| 9144 |
|
| 9145 |
/* U'*A*Q = U'*( A1 0 )*Q = ( x x ) */ |
| 9146 |
/* ( A2 A3 ) ( 0 x ) */ |
| 9147 |
/* and */ |
| 9148 |
/* V'*B*Q = V'*( B1 0 )*Q = ( x x ) */ |
| 9149 |
/* ( B2 B3 ) ( 0 x ) */ |
| 9150 |
|
| 9151 |
/* The rows of the transformed A and B are parallel, where */ |
| 9152 |
|
| 9153 |
/* U = ( CSU SNU ), V = ( CSV SNV ), Q = ( CSQ SNQ ) */ |
| 9154 |
/* ( -SNU CSU ) ( -SNV CSV ) ( -SNQ CSQ ) */ |
| 9155 |
|
| 9156 |
/* Z' denotes the transpose of Z. */ |
| 9157 |
|
| 9158 |
|
| 9159 |
/* Arguments */ |
| 9160 |
/* ========= */ |
| 9161 |
|
| 9162 |
/* UPPER (input) LOGICAL */ |
| 9163 |
/* = .TRUE.: the input matrices A and B are upper triangular. */ |
| 9164 |
/* = .FALSE.: the input matrices A and B are lower triangular. */ |
| 9165 |
|
| 9166 |
/* A1 (input) DOUBLE PRECISION */ |
| 9167 |
/* A2 (input) DOUBLE PRECISION */ |
| 9168 |
/* A3 (input) DOUBLE PRECISION */ |
| 9169 |
/* On entry, A1, A2 and A3 are elements of the input 2-by-2 */ |
| 9170 |
/* upper (lower) triangular matrix A. */ |
| 9171 |
|
| 9172 |
/* B1 (input) DOUBLE PRECISION */ |
| 9173 |
/* B2 (input) DOUBLE PRECISION */ |
| 9174 |
/* B3 (input) DOUBLE PRECISION */ |
| 9175 |
/* On entry, B1, B2 and B3 are elements of the input 2-by-2 */ |
| 9176 |
/* upper (lower) triangular matrix B. */ |
| 9177 |
|
| 9178 |
/* CSU (output) DOUBLE PRECISION */ |
| 9179 |
/* SNU (output) DOUBLE PRECISION */ |
| 9180 |
/* The desired orthogonal matrix U. */ |
| 9181 |
|
| 9182 |
/* CSV (output) DOUBLE PRECISION */ |
| 9183 |
/* SNV (output) DOUBLE PRECISION */ |
| 9184 |
/* The desired orthogonal matrix V. */ |
| 9185 |
|
| 9186 |
/* CSQ (output) DOUBLE PRECISION */ |
| 9187 |
/* SNQ (output) DOUBLE PRECISION */ |
| 9188 |
/* The desired orthogonal matrix Q. */ |
| 9189 |
|
| 9190 |
/* ===================================================================== */ |
| 9191 |
|
| 9192 |
/* .. Parameters .. */ |
| 9193 |
/* .. */ |
| 9194 |
/* .. Local Scalars .. */ |
| 9195 |
/* .. */ |
| 9196 |
/* .. External Subroutines .. */ |
| 9197 |
/* .. */ |
| 9198 |
/* .. Intrinsic Functions .. */ |
| 9199 |
/* .. */ |
| 9200 |
/* .. Executable Statements .. */ |
| 9201 |
|
| 9202 |
if (*upper) { |
| 9203 |
|
| 9204 |
/* Input matrices A and B are upper triangular matrices */ |
| 9205 |
|
| 9206 |
/* Form matrix C = A*adj(B) = ( a b ) */ |
| 9207 |
/* ( 0 d ) */ |
| 9208 |
|
| 9209 |
a = *a1 * *b3; |
| 9210 |
d__ = *a3 * *b1; |
| 9211 |
b = *a2 * *b1 - *a1 * *b2; |
| 9212 |
|
| 9213 |
/* The SVD of real 2-by-2 triangular C */ |
| 9214 |
|
| 9215 |
/* ( CSL -SNL )*( A B )*( CSR SNR ) = ( R 0 ) */ |
| 9216 |
/* ( SNL CSL ) ( 0 D ) ( -SNR CSR ) ( 0 T ) */ |
| 9217 |
|
| 9218 |
dlasv2_(&a, &b, &d__, &s1, &s2, &snr, &csr, &snl, &csl); |
| 9219 |
|
| 9220 |
if (abs(csl) >= abs(snl) || abs(csr) >= abs(snr)) { |
| 9221 |
|
| 9222 |
/* Compute the (1,1) and (1,2) elements of U'*A and V'*B, */ |
| 9223 |
/* and (1,2) element of |U|'*|A| and |V|'*|B|. */ |
| 9224 |
|
| 9225 |
ua11r = csl * *a1; |
| 9226 |
ua12 = csl * *a2 + snl * *a3; |
| 9227 |
|
| 9228 |
vb11r = csr * *b1; |
| 9229 |
vb12 = csr * *b2 + snr * *b3; |
| 9230 |
|
| 9231 |
aua12 = abs(csl) * abs(*a2) + abs(snl) * abs(*a3); |
| 9232 |
avb12 = abs(csr) * abs(*b2) + abs(snr) * abs(*b3); |
| 9233 |
|
| 9234 |
/* zero (1,2) elements of U'*A and V'*B */ |
| 9235 |
|
| 9236 |
if (abs(ua11r) + abs(ua12) != 0.) { |
| 9237 |
if (aua12 / (abs(ua11r) + abs(ua12)) <= avb12 / (abs(vb11r) + |
| 9238 |
abs(vb12))) { |
| 9239 |
d__1 = -ua11r; |
| 9240 |
dlartg_(&d__1, &ua12, csq, snq, &r__); |
| 9241 |
} else { |
| 9242 |
d__1 = -vb11r; |
| 9243 |
dlartg_(&d__1, &vb12, csq, snq, &r__); |
| 9244 |
} |
| 9245 |
} else { |
| 9246 |
d__1 = -vb11r; |
| 9247 |
dlartg_(&d__1, &vb12, csq, snq, &r__); |
| 9248 |
} |
| 9249 |
|
| 9250 |
*csu = csl; |
| 9251 |
*snu = -snl; |
| 9252 |
*csv = csr; |
| 9253 |
*snv = -snr; |
| 9254 |
|
| 9255 |
} else { |
| 9256 |
|
| 9257 |
/* Compute the (2,1) and (2,2) elements of U'*A and V'*B, */ |
| 9258 |
/* and (2,2) element of |U|'*|A| and |V|'*|B|. */ |
| 9259 |
|
| 9260 |
ua21 = -snl * *a1; |
| 9261 |
ua22 = -snl * *a2 + csl * *a3; |
| 9262 |
|
| 9263 |
vb21 = -snr * *b1; |
| 9264 |
vb22 = -snr * *b2 + csr * *b3; |
| 9265 |
|
| 9266 |
aua22 = abs(snl) * abs(*a2) + abs(csl) * abs(*a3); |
| 9267 |
avb22 = abs(snr) * abs(*b2) + abs(csr) * abs(*b3); |
| 9268 |
|
| 9269 |
/* zero (2,2) elements of U'*A and V'*B, and then swap. */ |
| 9270 |
|
| 9271 |
if (abs(ua21) + abs(ua22) != 0.) { |
| 9272 |
if (aua22 / (abs(ua21) + abs(ua22)) <= avb22 / (abs(vb21) + |
| 9273 |
abs(vb22))) { |
| 9274 |
d__1 = -ua21; |
| 9275 |
dlartg_(&d__1, &ua22, csq, snq, &r__); |
| 9276 |
} else { |
| 9277 |
d__1 = -vb21; |
| 9278 |
dlartg_(&d__1, &vb22, csq, snq, &r__); |
| 9279 |
} |
| 9280 |
} else { |
| 9281 |
d__1 = -vb21; |
| 9282 |
dlartg_(&d__1, &vb22, csq, snq, &r__); |
| 9283 |
} |
| 9284 |
|
| 9285 |
*csu = snl; |
| 9286 |
*snu = csl; |
| 9287 |
*csv = snr; |
| 9288 |
*snv = csr; |
| 9289 |
|
| 9290 |
} |
| 9291 |
|
| 9292 |
} else { |
| 9293 |
|
| 9294 |
/* Input matrices A and B are lower triangular matrices */ |
| 9295 |
|
| 9296 |
/* Form matrix C = A*adj(B) = ( a 0 ) */ |
| 9297 |
/* ( c d ) */ |
| 9298 |
|
| 9299 |
a = *a1 * *b3; |
| 9300 |
d__ = *a3 * *b1; |
| 9301 |
c__ = *a2 * *b3 - *a3 * *b2; |
| 9302 |
|
| 9303 |
/* The SVD of real 2-by-2 triangular C */ |
| 9304 |
|
| 9305 |
/* ( CSL -SNL )*( A 0 )*( CSR SNR ) = ( R 0 ) */ |
| 9306 |
/* ( SNL CSL ) ( C D ) ( -SNR CSR ) ( 0 T ) */ |
| 9307 |
|
| 9308 |
dlasv2_(&a, &c__, &d__, &s1, &s2, &snr, &csr, &snl, &csl); |
| 9309 |
|
| 9310 |
if (abs(csr) >= abs(snr) || abs(csl) >= abs(snl)) { |
| 9311 |
|
| 9312 |
/* Compute the (2,1) and (2,2) elements of U'*A and V'*B, */ |
| 9313 |
/* and (2,1) element of |U|'*|A| and |V|'*|B|. */ |
| 9314 |
|
| 9315 |
ua21 = -snr * *a1 + csr * *a2; |
| 9316 |
ua22r = csr * *a3; |
| 9317 |
|
| 9318 |
vb21 = -snl * *b1 + csl * *b2; |
| 9319 |
vb22r = csl * *b3; |
| 9320 |
|
| 9321 |
aua21 = abs(snr) * abs(*a1) + abs(csr) * abs(*a2); |
| 9322 |
avb21 = abs(snl) * abs(*b1) + abs(csl) * abs(*b2); |
| 9323 |
|
| 9324 |
/* zero (2,1) elements of U'*A and V'*B. */ |
| 9325 |
|
| 9326 |
if (abs(ua21) + abs(ua22r) != 0.) { |
| 9327 |
if (aua21 / (abs(ua21) + abs(ua22r)) <= avb21 / (abs(vb21) + |
| 9328 |
abs(vb22r))) { |
| 9329 |
dlartg_(&ua22r, &ua21, csq, snq, &r__); |
| 9330 |
} else { |
| 9331 |
dlartg_(&vb22r, &vb21, csq, snq, &r__); |
| 9332 |
} |
| 9333 |
} else { |
| 9334 |
dlartg_(&vb22r, &vb21, csq, snq, &r__); |
| 9335 |
} |
| 9336 |
|
| 9337 |
*csu = csr; |
| 9338 |
*snu = -snr; |
| 9339 |
*csv = csl; |
| 9340 |
*snv = -snl; |
| 9341 |
|
| 9342 |
} else { |
| 9343 |
|
| 9344 |
/* Compute the (1,1) and (1,2) elements of U'*A and V'*B, */ |
| 9345 |
/* and (1,1) element of |U|'*|A| and |V|'*|B|. */ |
| 9346 |
|
| 9347 |
ua11 = csr * *a1 + snr * *a2; |
| 9348 |
ua12 = snr * *a3; |
| 9349 |
|
| 9350 |
vb11 = csl * *b1 + snl * *b2; |
| 9351 |
vb12 = snl * *b3; |
| 9352 |
|
| 9353 |
aua11 = abs(csr) * abs(*a1) + abs(snr) * abs(*a2); |
| 9354 |
avb11 = abs(csl) * abs(*b1) + abs(snl) * abs(*b2); |
| 9355 |
|
| 9356 |
/* zero (1,1) elements of U'*A and V'*B, and then swap. */ |
| 9357 |
|
| 9358 |
if (abs(ua11) + abs(ua12) != 0.) { |
| 9359 |
if (aua11 / (abs(ua11) + abs(ua12)) <= avb11 / (abs(vb11) + |
| 9360 |
abs(vb12))) { |
| 9361 |
dlartg_(&ua12, &ua11, csq, snq, &r__); |
| 9362 |
} else { |
| 9363 |
dlartg_(&vb12, &vb11, csq, snq, &r__); |
| 9364 |
} |
| 9365 |
} else { |
| 9366 |
dlartg_(&vb12, &vb11, csq, snq, &r__); |
| 9367 |
} |
| 9368 |
|
| 9369 |
*csu = snr; |
| 9370 |
*snu = csr; |
| 9371 |
*csv = snl; |
| 9372 |
*snv = csl; |
| 9373 |
|
| 9374 |
} |
| 9375 |
|
| 9376 |
} |
| 9377 |
|
| 9378 |
return 0; |
| 9379 |
|
| 9380 |
/* End of DLAGS2 */ |
| 9381 |
|
| 9382 |
} /* dlags2_ */ |
| 9383 |
|
| 9384 |
/* Subroutine */ int dlagtf_(integer *n, double *a, double *lambda, |
| 9385 |
double *b, double *c__, double *tol, double *d__, |
| 9386 |
integer *in, integer *info) |
| 9387 |
{ |
| 9388 |
/* System generated locals */ |
| 9389 |
integer i__1; |
| 9390 |
double d__1, d__2; |
| 9391 |
|
| 9392 |
/* Local variables */ |
| 9393 |
integer k; |
| 9394 |
double tl, eps, piv1, piv2, temp, mult, scale1, scale2; |
| 9395 |
|
| 9396 |
|
| 9397 |
|
| 9398 |
|
| 9399 |
/* -- LAPACK routine (version 3.1) -- */ |
| 9400 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 9401 |
/* November 2006 */ |
| 9402 |
|
| 9403 |
/* .. Scalar Arguments .. */ |
| 9404 |
/* .. */ |
| 9405 |
/* .. Array Arguments .. */ |
| 9406 |
/* .. */ |
| 9407 |
|
| 9408 |
/* Purpose */ |
| 9409 |
/* ======= */ |
| 9410 |
|
| 9411 |
/* DLAGTF factorizes the matrix (T - lambda*I), where T is an n by n */ |
| 9412 |
/* tridiagonal matrix and lambda is a scalar, as */ |
| 9413 |
|
| 9414 |
/* T - lambda*I = PLU, */ |
| 9415 |
|
| 9416 |
/* where P is a permutation matrix, L is a unit lower tridiagonal matrix */ |
| 9417 |
/* with at most one non-zero sub-diagonal elements per column and U is */ |
| 9418 |
/* an upper triangular matrix with at most two non-zero super-diagonal */ |
| 9419 |
/* elements per column. */ |
| 9420 |
|
| 9421 |
/* The factorization is obtained by Gaussian elimination with partial */ |
| 9422 |
/* pivoting and implicit row scaling. */ |
| 9423 |
|
| 9424 |
/* The parameter LAMBDA is included in the routine so that DLAGTF may */ |
| 9425 |
/* be used, in conjunction with DLAGTS, to obtain eigenvectors of T by */ |
| 9426 |
/* inverse iteration. */ |
| 9427 |
|
| 9428 |
/* Arguments */ |
| 9429 |
/* ========= */ |
| 9430 |
|
| 9431 |
/* N (input) INTEGER */ |
| 9432 |
/* The order of the matrix T. */ |
| 9433 |
|
| 9434 |
/* A (input/output) DOUBLE PRECISION array, dimension (N) */ |
| 9435 |
/* On entry, A must contain the diagonal elements of T. */ |
| 9436 |
|
| 9437 |
/* On exit, A is overwritten by the n diagonal elements of the */ |
| 9438 |
/* upper triangular matrix U of the factorization of T. */ |
| 9439 |
|
| 9440 |
/* LAMBDA (input) DOUBLE PRECISION */ |
| 9441 |
/* On entry, the scalar lambda. */ |
| 9442 |
|
| 9443 |
/* B (input/output) DOUBLE PRECISION array, dimension (N-1) */ |
| 9444 |
/* On entry, B must contain the (n-1) super-diagonal elements of */ |
| 9445 |
/* T. */ |
| 9446 |
|
| 9447 |
/* On exit, B is overwritten by the (n-1) super-diagonal */ |
| 9448 |
/* elements of the matrix U of the factorization of T. */ |
| 9449 |
|
| 9450 |
/* C (input/output) DOUBLE PRECISION array, dimension (N-1) */ |
| 9451 |
/* On entry, C must contain the (n-1) sub-diagonal elements of */ |
| 9452 |
/* T. */ |
| 9453 |
|
| 9454 |
/* On exit, C is overwritten by the (n-1) sub-diagonal elements */ |
| 9455 |
/* of the matrix L of the factorization of T. */ |
| 9456 |
|
| 9457 |
/* TOL (input) DOUBLE PRECISION */ |
| 9458 |
/* On entry, a relative tolerance used to indicate whether or */ |
| 9459 |
/* not the matrix (T - lambda*I) is nearly singular. TOL should */ |
| 9460 |
/* normally be chose as approximately the largest relative error */ |
| 9461 |
/* in the elements of T. For example, if the elements of T are */ |
| 9462 |
/* correct to about 4 significant figures, then TOL should be */ |
| 9463 |
/* set to about 5*10**(-4). If TOL is supplied as less than eps, */ |
| 9464 |
/* where eps is the relative machine precision, then the value */ |
| 9465 |
/* eps is used in place of TOL. */ |
| 9466 |
|
| 9467 |
/* D (output) DOUBLE PRECISION array, dimension (N-2) */ |
| 9468 |
/* On exit, D is overwritten by the (n-2) second super-diagonal */ |
| 9469 |
/* elements of the matrix U of the factorization of T. */ |
| 9470 |
|
| 9471 |
/* IN (output) INTEGER array, dimension (N) */ |
| 9472 |
/* On exit, IN contains details of the permutation matrix P. If */ |
| 9473 |
/* an interchange occurred at the kth step of the elimination, */ |
| 9474 |
/* then IN(k) = 1, otherwise IN(k) = 0. The element IN(n) */ |
| 9475 |
/* returns the smallest positive integer j such that */ |
| 9476 |
|
| 9477 |
/* abs( u(j,j) ).le. norm( (T - lambda*I)(j) )*TOL, */ |
| 9478 |
|
| 9479 |
/* where norm( A(j) ) denotes the sum of the absolute values of */ |
| 9480 |
/* the jth row of the matrix A. If no such j exists then IN(n) */ |
| 9481 |
/* is returned as zero. If IN(n) is returned as positive, then a */ |
| 9482 |
/* diagonal element of U is small, indicating that */ |
| 9483 |
/* (T - lambda*I) is singular or nearly singular, */ |
| 9484 |
|
| 9485 |
/* INFO (output) INTEGER */ |
| 9486 |
/* = 0 : successful exit */ |
| 9487 |
/* .lt. 0: if INFO = -k, the kth argument had an illegal value */ |
| 9488 |
|
| 9489 |
/* ===================================================================== */ |
| 9490 |
|
| 9491 |
/* .. Parameters .. */ |
| 9492 |
/* .. */ |
| 9493 |
/* .. Local Scalars .. */ |
| 9494 |
/* .. */ |
| 9495 |
/* .. Intrinsic Functions .. */ |
| 9496 |
/* .. */ |
| 9497 |
/* .. External Functions .. */ |
| 9498 |
/* .. */ |
| 9499 |
/* .. External Subroutines .. */ |
| 9500 |
/* .. */ |
| 9501 |
/* .. Executable Statements .. */ |
| 9502 |
|
| 9503 |
/* Parameter adjustments */ |
| 9504 |
--in; |
| 9505 |
--d__; |
| 9506 |
--c__; |
| 9507 |
--b; |
| 9508 |
--a; |
| 9509 |
|
| 9510 |
/* Function Body */ |
| 9511 |
*info = 0; |
| 9512 |
if (*n < 0) { |
| 9513 |
*info = -1; |
| 9514 |
i__1 = -(*info); |
| 9515 |
xerbla_("DLAGTF", &i__1); |
| 9516 |
return 0; |
| 9517 |
} |
| 9518 |
|
| 9519 |
if (*n == 0) { |
| 9520 |
return 0; |
| 9521 |
} |
| 9522 |
|
| 9523 |
a[1] -= *lambda; |
| 9524 |
in[*n] = 0; |
| 9525 |
if (*n == 1) { |
| 9526 |
if (a[1] == 0.) { |
| 9527 |
in[1] = 1; |
| 9528 |
} |
| 9529 |
return 0; |
| 9530 |
} |
| 9531 |
|
| 9532 |
eps = dlamch_("Epsilon"); |
| 9533 |
|
| 9534 |
tl = std::max(*tol,eps); |
| 9535 |
scale1 = abs(a[1]) + abs(b[1]); |
| 9536 |
i__1 = *n - 1; |
| 9537 |
for (k = 1; k <= i__1; ++k) { |
| 9538 |
a[k + 1] -= *lambda; |
| 9539 |
scale2 = (d__1 = c__[k], abs(d__1)) + (d__2 = a[k + 1], abs(d__2)); |
| 9540 |
if (k < *n - 1) { |
| 9541 |
scale2 += (d__1 = b[k + 1], abs(d__1)); |
| 9542 |
} |
| 9543 |
if (a[k] == 0.) { |
| 9544 |
piv1 = 0.; |
| 9545 |
} else { |
| 9546 |
piv1 = (d__1 = a[k], abs(d__1)) / scale1; |
| 9547 |
} |
| 9548 |
if (c__[k] == 0.) { |
| 9549 |
in[k] = 0; |
| 9550 |
piv2 = 0.; |
| 9551 |
scale1 = scale2; |
| 9552 |
if (k < *n - 1) { |
| 9553 |
d__[k] = 0.; |
| 9554 |
} |
| 9555 |
} else { |
| 9556 |
piv2 = (d__1 = c__[k], abs(d__1)) / scale2; |
| 9557 |
if (piv2 <= piv1) { |
| 9558 |
in[k] = 0; |
| 9559 |
scale1 = scale2; |
| 9560 |
c__[k] /= a[k]; |
| 9561 |
a[k + 1] -= c__[k] * b[k]; |
| 9562 |
if (k < *n - 1) { |
| 9563 |
d__[k] = 0.; |
| 9564 |
} |
| 9565 |
} else { |
| 9566 |
in[k] = 1; |
| 9567 |
mult = a[k] / c__[k]; |
| 9568 |
a[k] = c__[k]; |
| 9569 |
temp = a[k + 1]; |
| 9570 |
a[k + 1] = b[k] - mult * temp; |
| 9571 |
if (k < *n - 1) { |
| 9572 |
d__[k] = b[k + 1]; |
| 9573 |
b[k + 1] = -mult * d__[k]; |
| 9574 |
} |
| 9575 |
b[k] = temp; |
| 9576 |
c__[k] = mult; |
| 9577 |
} |
| 9578 |
} |
| 9579 |
if (std::max(piv1,piv2) <= tl && in[*n] == 0) { |
| 9580 |
in[*n] = k; |
| 9581 |
} |
| 9582 |
/* L10: */ |
| 9583 |
} |
| 9584 |
if ((d__1 = a[*n], abs(d__1)) <= scale1 * tl && in[*n] == 0) { |
| 9585 |
in[*n] = *n; |
| 9586 |
} |
| 9587 |
|
| 9588 |
return 0; |
| 9589 |
|
| 9590 |
/* End of DLAGTF */ |
| 9591 |
|
| 9592 |
} /* dlagtf_ */ |
| 9593 |
|
| 9594 |
/* Subroutine */ int dlagtm_(const char *trans, integer *n, integer *nrhs, |
| 9595 |
double *alpha, double *dl, double *d__, double *du, |
| 9596 |
double *x, integer *ldx, double *beta, double *b, integer |
| 9597 |
*ldb) |
| 9598 |
{ |
| 9599 |
/* System generated locals */ |
| 9600 |
integer b_dim1, b_offset, x_dim1, x_offset, i__1, i__2; |
| 9601 |
|
| 9602 |
/* Local variables */ |
| 9603 |
integer i__, j; |
| 9604 |
|
| 9605 |
|
| 9606 |
|
| 9607 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 9608 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 9609 |
/* November 2006 */ |
| 9610 |
|
| 9611 |
/* .. Scalar Arguments .. */ |
| 9612 |
/* .. */ |
| 9613 |
/* .. Array Arguments .. */ |
| 9614 |
/* .. */ |
| 9615 |
|
| 9616 |
/* Purpose */ |
| 9617 |
/* ======= */ |
| 9618 |
|
| 9619 |
/* DLAGTM performs a matrix-vector product of the form */ |
| 9620 |
|
| 9621 |
/* B := alpha * A * X + beta * B */ |
| 9622 |
|
| 9623 |
/* where A is a tridiagonal matrix of order N, B and X are N by NRHS */ |
| 9624 |
/* matrices, and alpha and beta are real scalars, each of which may be */ |
| 9625 |
/* 0., 1., or -1. */ |
| 9626 |
|
| 9627 |
/* Arguments */ |
| 9628 |
/* ========= */ |
| 9629 |
|
| 9630 |
/* TRANS (input) CHARACTER*1 */ |
| 9631 |
/* Specifies the operation applied to A. */ |
| 9632 |
/* = 'N': No transpose, B := alpha * A * X + beta * B */ |
| 9633 |
/* = 'T': Transpose, B := alpha * A'* X + beta * B */ |
| 9634 |
/* = 'C': Conjugate transpose = Transpose */ |
| 9635 |
|
| 9636 |
/* N (input) INTEGER */ |
| 9637 |
/* The order of the matrix A. N >= 0. */ |
| 9638 |
|
| 9639 |
/* NRHS (input) INTEGER */ |
| 9640 |
/* The number of right hand sides, i.e., the number of columns */ |
| 9641 |
/* of the matrices X and B. */ |
| 9642 |
|
| 9643 |
/* ALPHA (input) DOUBLE PRECISION */ |
| 9644 |
/* The scalar alpha. ALPHA must be 0., 1., or -1.; otherwise, */ |
| 9645 |
/* it is assumed to be 0. */ |
| 9646 |
|
| 9647 |
/* DL (input) DOUBLE PRECISION array, dimension (N-1) */ |
| 9648 |
/* The (n-1) sub-diagonal elements of T. */ |
| 9649 |
|
| 9650 |
/* D (input) DOUBLE PRECISION array, dimension (N) */ |
| 9651 |
/* The diagonal elements of T. */ |
| 9652 |
|
| 9653 |
/* DU (input) DOUBLE PRECISION array, dimension (N-1) */ |
| 9654 |
/* The (n-1) super-diagonal elements of T. */ |
| 9655 |
|
| 9656 |
/* X (input) DOUBLE PRECISION array, dimension (LDX,NRHS) */ |
| 9657 |
/* The N by NRHS matrix X. */ |
| 9658 |
/* LDX (input) INTEGER */ |
| 9659 |
/* The leading dimension of the array X. LDX >= max(N,1). */ |
| 9660 |
|
| 9661 |
/* BETA (input) DOUBLE PRECISION */ |
| 9662 |
/* The scalar beta. BETA must be 0., 1., or -1.; otherwise, */ |
| 9663 |
/* it is assumed to be 1. */ |
| 9664 |
|
| 9665 |
/* B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */ |
| 9666 |
/* On entry, the N by NRHS matrix B. */ |
| 9667 |
/* On exit, B is overwritten by the matrix expression */ |
| 9668 |
/* B := alpha * A * X + beta * B. */ |
| 9669 |
|
| 9670 |
/* LDB (input) INTEGER */ |
| 9671 |
/* The leading dimension of the array B. LDB >= max(N,1). */ |
| 9672 |
|
| 9673 |
/* ===================================================================== */ |
| 9674 |
|
| 9675 |
/* .. Parameters .. */ |
| 9676 |
/* .. */ |
| 9677 |
/* .. Local Scalars .. */ |
| 9678 |
/* .. */ |
| 9679 |
/* .. External Functions .. */ |
| 9680 |
/* .. */ |
| 9681 |
/* .. Executable Statements .. */ |
| 9682 |
|
| 9683 |
/* Parameter adjustments */ |
| 9684 |
--dl; |
| 9685 |
--d__; |
| 9686 |
--du; |
| 9687 |
x_dim1 = *ldx; |
| 9688 |
x_offset = 1 + x_dim1; |
| 9689 |
x -= x_offset; |
| 9690 |
b_dim1 = *ldb; |
| 9691 |
b_offset = 1 + b_dim1; |
| 9692 |
b -= b_offset; |
| 9693 |
|
| 9694 |
/* Function Body */ |
| 9695 |
if (*n == 0) { |
| 9696 |
return 0; |
| 9697 |
} |
| 9698 |
|
| 9699 |
/* Multiply B by BETA if BETA.NE.1. */ |
| 9700 |
|
| 9701 |
if (*beta == 0.) { |
| 9702 |
i__1 = *nrhs; |
| 9703 |
for (j = 1; j <= i__1; ++j) { |
| 9704 |
i__2 = *n; |
| 9705 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 9706 |
b[i__ + j * b_dim1] = 0.; |
| 9707 |
/* L10: */ |
| 9708 |
} |
| 9709 |
/* L20: */ |
| 9710 |
} |
| 9711 |
} else if (*beta == -1.) { |
| 9712 |
i__1 = *nrhs; |
| 9713 |
for (j = 1; j <= i__1; ++j) { |
| 9714 |
i__2 = *n; |
| 9715 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 9716 |
b[i__ + j * b_dim1] = -b[i__ + j * b_dim1]; |
| 9717 |
/* L30: */ |
| 9718 |
} |
| 9719 |
/* L40: */ |
| 9720 |
} |
| 9721 |
} |
| 9722 |
|
| 9723 |
if (*alpha == 1.) { |
| 9724 |
if (lsame_(trans, "N")) { |
| 9725 |
|
| 9726 |
/* Compute B := B + A*X */ |
| 9727 |
|
| 9728 |
i__1 = *nrhs; |
| 9729 |
for (j = 1; j <= i__1; ++j) { |
| 9730 |
if (*n == 1) { |
| 9731 |
b[j * b_dim1 + 1] += d__[1] * x[j * x_dim1 + 1]; |
| 9732 |
} else { |
| 9733 |
b[j * b_dim1 + 1] = b[j * b_dim1 + 1] + d__[1] * x[j * |
| 9734 |
x_dim1 + 1] + du[1] * x[j * x_dim1 + 2]; |
| 9735 |
b[*n + j * b_dim1] = b[*n + j * b_dim1] + dl[*n - 1] * x[* |
| 9736 |
n - 1 + j * x_dim1] + d__[*n] * x[*n + j * x_dim1] |
| 9737 |
; |
| 9738 |
i__2 = *n - 1; |
| 9739 |
for (i__ = 2; i__ <= i__2; ++i__) { |
| 9740 |
b[i__ + j * b_dim1] = b[i__ + j * b_dim1] + dl[i__ - |
| 9741 |
1] * x[i__ - 1 + j * x_dim1] + d__[i__] * x[ |
| 9742 |
i__ + j * x_dim1] + du[i__] * x[i__ + 1 + j * |
| 9743 |
x_dim1]; |
| 9744 |
/* L50: */ |
| 9745 |
} |
| 9746 |
} |
| 9747 |
/* L60: */ |
| 9748 |
} |
| 9749 |
} else { |
| 9750 |
|
| 9751 |
/* Compute B := B + A'*X */ |
| 9752 |
|
| 9753 |
i__1 = *nrhs; |
| 9754 |
for (j = 1; j <= i__1; ++j) { |
| 9755 |
if (*n == 1) { |
| 9756 |
b[j * b_dim1 + 1] += d__[1] * x[j * x_dim1 + 1]; |
| 9757 |
} else { |
| 9758 |
b[j * b_dim1 + 1] = b[j * b_dim1 + 1] + d__[1] * x[j * |
| 9759 |
x_dim1 + 1] + dl[1] * x[j * x_dim1 + 2]; |
| 9760 |
b[*n + j * b_dim1] = b[*n + j * b_dim1] + du[*n - 1] * x[* |
| 9761 |
n - 1 + j * x_dim1] + d__[*n] * x[*n + j * x_dim1] |
| 9762 |
; |
| 9763 |
i__2 = *n - 1; |
| 9764 |
for (i__ = 2; i__ <= i__2; ++i__) { |
| 9765 |
b[i__ + j * b_dim1] = b[i__ + j * b_dim1] + du[i__ - |
| 9766 |
1] * x[i__ - 1 + j * x_dim1] + d__[i__] * x[ |
| 9767 |
i__ + j * x_dim1] + dl[i__] * x[i__ + 1 + j * |
| 9768 |
x_dim1]; |
| 9769 |
/* L70: */ |
| 9770 |
} |
| 9771 |
} |
| 9772 |
/* L80: */ |
| 9773 |
} |
| 9774 |
} |
| 9775 |
} else if (*alpha == -1.) { |
| 9776 |
if (lsame_(trans, "N")) { |
| 9777 |
|
| 9778 |
/* Compute B := B - A*X */ |
| 9779 |
|
| 9780 |
i__1 = *nrhs; |
| 9781 |
for (j = 1; j <= i__1; ++j) { |
| 9782 |
if (*n == 1) { |
| 9783 |
b[j * b_dim1 + 1] -= d__[1] * x[j * x_dim1 + 1]; |
| 9784 |
} else { |
| 9785 |
b[j * b_dim1 + 1] = b[j * b_dim1 + 1] - d__[1] * x[j * |
| 9786 |
x_dim1 + 1] - du[1] * x[j * x_dim1 + 2]; |
| 9787 |
b[*n + j * b_dim1] = b[*n + j * b_dim1] - dl[*n - 1] * x[* |
| 9788 |
n - 1 + j * x_dim1] - d__[*n] * x[*n + j * x_dim1] |
| 9789 |
; |
| 9790 |
i__2 = *n - 1; |
| 9791 |
for (i__ = 2; i__ <= i__2; ++i__) { |
| 9792 |
b[i__ + j * b_dim1] = b[i__ + j * b_dim1] - dl[i__ - |
| 9793 |
1] * x[i__ - 1 + j * x_dim1] - d__[i__] * x[ |
| 9794 |
i__ + j * x_dim1] - du[i__] * x[i__ + 1 + j * |
| 9795 |
x_dim1]; |
| 9796 |
/* L90: */ |
| 9797 |
} |
| 9798 |
} |
| 9799 |
/* L100: */ |
| 9800 |
} |
| 9801 |
} else { |
| 9802 |
|
| 9803 |
/* Compute B := B - A'*X */ |
| 9804 |
|
| 9805 |
i__1 = *nrhs; |
| 9806 |
for (j = 1; j <= i__1; ++j) { |
| 9807 |
if (*n == 1) { |
| 9808 |
b[j * b_dim1 + 1] -= d__[1] * x[j * x_dim1 + 1]; |
| 9809 |
} else { |
| 9810 |
b[j * b_dim1 + 1] = b[j * b_dim1 + 1] - d__[1] * x[j * |
| 9811 |
x_dim1 + 1] - dl[1] * x[j * x_dim1 + 2]; |
| 9812 |
b[*n + j * b_dim1] = b[*n + j * b_dim1] - du[*n - 1] * x[* |
| 9813 |
n - 1 + j * x_dim1] - d__[*n] * x[*n + j * x_dim1] |
| 9814 |
; |
| 9815 |
i__2 = *n - 1; |
| 9816 |
for (i__ = 2; i__ <= i__2; ++i__) { |
| 9817 |
b[i__ + j * b_dim1] = b[i__ + j * b_dim1] - du[i__ - |
| 9818 |
1] * x[i__ - 1 + j * x_dim1] - d__[i__] * x[ |
| 9819 |
i__ + j * x_dim1] - dl[i__] * x[i__ + 1 + j * |
| 9820 |
x_dim1]; |
| 9821 |
/* L110: */ |
| 9822 |
} |
| 9823 |
} |
| 9824 |
/* L120: */ |
| 9825 |
} |
| 9826 |
} |
| 9827 |
} |
| 9828 |
return 0; |
| 9829 |
|
| 9830 |
/* End of DLAGTM */ |
| 9831 |
|
| 9832 |
} /* dlagtm_ */ |
| 9833 |
|
| 9834 |
/* Subroutine */ int dlagts_(integer *job, integer *n, double *a, |
| 9835 |
double *b, double *c__, double *d__, integer *in, |
| 9836 |
double *y, double *tol, integer *info) |
| 9837 |
{ |
| 9838 |
/* System generated locals */ |
| 9839 |
integer i__1; |
| 9840 |
double d__1, d__2, d__3, d__4, d__5; |
| 9841 |
|
| 9842 |
/* Local variables */ |
| 9843 |
integer k; |
| 9844 |
double ak, eps, temp, pert, absak, sfmin; |
| 9845 |
|
| 9846 |
|
| 9847 |
double bignum; |
| 9848 |
|
| 9849 |
|
| 9850 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 9851 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 9852 |
/* November 2006 */ |
| 9853 |
|
| 9854 |
/* .. Scalar Arguments .. */ |
| 9855 |
/* .. */ |
| 9856 |
/* .. Array Arguments .. */ |
| 9857 |
/* .. */ |
| 9858 |
|
| 9859 |
/* Purpose */ |
| 9860 |
/* ======= */ |
| 9861 |
|
| 9862 |
/* DLAGTS may be used to solve one of the systems of equations */ |
| 9863 |
|
| 9864 |
/* (T - lambda*I)*x = y or (T - lambda*I)'*x = y, */ |
| 9865 |
|
| 9866 |
/* where T is an n by n tridiagonal matrix, for x, following the */ |
| 9867 |
/* factorization of (T - lambda*I) as */ |
| 9868 |
|
| 9869 |
/* (T - lambda*I) = P*L*U , */ |
| 9870 |
|
| 9871 |
/* by routine DLAGTF. The choice of equation to be solved is */ |
| 9872 |
/* controlled by the argument JOB, and in each case there is an option */ |
| 9873 |
/* to perturb zero or very small diagonal elements of U, this option */ |
| 9874 |
/* being intended for use in applications such as inverse iteration. */ |
| 9875 |
|
| 9876 |
/* Arguments */ |
| 9877 |
/* ========= */ |
| 9878 |
|
| 9879 |
/* JOB (input) INTEGER */ |
| 9880 |
/* Specifies the job to be performed by DLAGTS as follows: */ |
| 9881 |
/* = 1: The equations (T - lambda*I)x = y are to be solved, */ |
| 9882 |
/* but diagonal elements of U are not to be perturbed. */ |
| 9883 |
/* = -1: The equations (T - lambda*I)x = y are to be solved */ |
| 9884 |
/* and, if overflow would otherwise occur, the diagonal */ |
| 9885 |
/* elements of U are to be perturbed. See argument TOL */ |
| 9886 |
/* below. */ |
| 9887 |
/* = 2: The equations (T - lambda*I)'x = y are to be solved, */ |
| 9888 |
/* but diagonal elements of U are not to be perturbed. */ |
| 9889 |
/* = -2: The equations (T - lambda*I)'x = y are to be solved */ |
| 9890 |
/* and, if overflow would otherwise occur, the diagonal */ |
| 9891 |
/* elements of U are to be perturbed. See argument TOL */ |
| 9892 |
/* below. */ |
| 9893 |
|
| 9894 |
/* N (input) INTEGER */ |
| 9895 |
/* The order of the matrix T. */ |
| 9896 |
|
| 9897 |
/* A (input) DOUBLE PRECISION array, dimension (N) */ |
| 9898 |
/* On entry, A must contain the diagonal elements of U as */ |
| 9899 |
/* returned from DLAGTF. */ |
| 9900 |
|
| 9901 |
/* B (input) DOUBLE PRECISION array, dimension (N-1) */ |
| 9902 |
/* On entry, B must contain the first super-diagonal elements of */ |
| 9903 |
/* U as returned from DLAGTF. */ |
| 9904 |
|
| 9905 |
/* C (input) DOUBLE PRECISION array, dimension (N-1) */ |
| 9906 |
/* On entry, C must contain the sub-diagonal elements of L as */ |
| 9907 |
/* returned from DLAGTF. */ |
| 9908 |
|
| 9909 |
/* D (input) DOUBLE PRECISION array, dimension (N-2) */ |
| 9910 |
/* On entry, D must contain the second super-diagonal elements */ |
| 9911 |
/* of U as returned from DLAGTF. */ |
| 9912 |
|
| 9913 |
/* IN (input) INTEGER array, dimension (N) */ |
| 9914 |
/* On entry, IN must contain details of the matrix P as returned */ |
| 9915 |
/* from DLAGTF. */ |
| 9916 |
|
| 9917 |
/* Y (input/output) DOUBLE PRECISION array, dimension (N) */ |
| 9918 |
/* On entry, the right hand side vector y. */ |
| 9919 |
/* On exit, Y is overwritten by the solution vector x. */ |
| 9920 |
|
| 9921 |
/* TOL (input/output) DOUBLE PRECISION */ |
| 9922 |
/* On entry, with JOB .lt. 0, TOL should be the minimum */ |
| 9923 |
/* perturbation to be made to very small diagonal elements of U. */ |
| 9924 |
/* TOL should normally be chosen as about eps*norm(U), where eps */ |
| 9925 |
/* is the relative machine precision, but if TOL is supplied as */ |
| 9926 |
/* non-positive, then it is reset to eps*max( abs( u(i,j) ) ). */ |
| 9927 |
/* If JOB .gt. 0 then TOL is not referenced. */ |
| 9928 |
|
| 9929 |
/* On exit, TOL is changed as described above, only if TOL is */ |
| 9930 |
/* non-positive on entry. Otherwise TOL is unchanged. */ |
| 9931 |
|
| 9932 |
/* INFO (output) INTEGER */ |
| 9933 |
/* = 0 : successful exit */ |
| 9934 |
/* .lt. 0: if INFO = -i, the i-th argument had an illegal value */ |
| 9935 |
/* .gt. 0: overflow would occur when computing the INFO(th) */ |
| 9936 |
/* element of the solution vector x. This can only occur */ |
| 9937 |
/* when JOB is supplied as positive and either means */ |
| 9938 |
/* that a diagonal element of U is very small, or that */ |
| 9939 |
/* the elements of the right-hand side vector y are very */ |
| 9940 |
/* large. */ |
| 9941 |
|
| 9942 |
/* ===================================================================== */ |
| 9943 |
|
| 9944 |
/* .. Parameters .. */ |
| 9945 |
/* .. */ |
| 9946 |
/* .. Local Scalars .. */ |
| 9947 |
/* .. */ |
| 9948 |
/* .. Intrinsic Functions .. */ |
| 9949 |
/* .. */ |
| 9950 |
/* .. External Functions .. */ |
| 9951 |
/* .. */ |
| 9952 |
/* .. External Subroutines .. */ |
| 9953 |
/* .. */ |
| 9954 |
/* .. Executable Statements .. */ |
| 9955 |
|
| 9956 |
/* Parameter adjustments */ |
| 9957 |
--y; |
| 9958 |
--in; |
| 9959 |
--d__; |
| 9960 |
--c__; |
| 9961 |
--b; |
| 9962 |
--a; |
| 9963 |
|
| 9964 |
/* Function Body */ |
| 9965 |
*info = 0; |
| 9966 |
if (abs(*job) > 2 || *job == 0) { |
| 9967 |
*info = -1; |
| 9968 |
} else if (*n < 0) { |
| 9969 |
*info = -2; |
| 9970 |
} |
| 9971 |
if (*info != 0) { |
| 9972 |
i__1 = -(*info); |
| 9973 |
xerbla_("DLAGTS", &i__1); |
| 9974 |
return 0; |
| 9975 |
} |
| 9976 |
|
| 9977 |
if (*n == 0) { |
| 9978 |
return 0; |
| 9979 |
} |
| 9980 |
|
| 9981 |
eps = dlamch_("Epsilon"); |
| 9982 |
sfmin = dlamch_("Safe minimum"); |
| 9983 |
bignum = 1. / sfmin; |
| 9984 |
|
| 9985 |
if (*job < 0) { |
| 9986 |
if (*tol <= 0.) { |
| 9987 |
*tol = abs(a[1]); |
| 9988 |
if (*n > 1) { |
| 9989 |
/* Computing MAX */ |
| 9990 |
d__1 = *tol, d__2 = abs(a[2]), d__1 = std::max(d__1,d__2), d__2 = |
| 9991 |
abs(b[1]); |
| 9992 |
*tol = std::max(d__1,d__2); |
| 9993 |
} |
| 9994 |
i__1 = *n; |
| 9995 |
for (k = 3; k <= i__1; ++k) { |
| 9996 |
/* Computing MAX */ |
| 9997 |
d__4 = *tol, d__5 = (d__1 = a[k], abs(d__1)), d__4 = std::max(d__4, |
| 9998 |
d__5), d__5 = (d__2 = b[k - 1], abs(d__2)), d__4 = |
| 9999 |
std::max(d__4,d__5), d__5 = (d__3 = d__[k - 2], abs(d__3)); |
| 10000 |
*tol = std::max(d__4,d__5); |
| 10001 |
/* L10: */ |
| 10002 |
} |
| 10003 |
*tol *= eps; |
| 10004 |
if (*tol == 0.) { |
| 10005 |
*tol = eps; |
| 10006 |
} |
| 10007 |
} |
| 10008 |
} |
| 10009 |
|
| 10010 |
if (abs(*job) == 1) { |
| 10011 |
i__1 = *n; |
| 10012 |
for (k = 2; k <= i__1; ++k) { |
| 10013 |
if (in[k - 1] == 0) { |
| 10014 |
y[k] -= c__[k - 1] * y[k - 1]; |
| 10015 |
} else { |
| 10016 |
temp = y[k - 1]; |
| 10017 |
y[k - 1] = y[k]; |
| 10018 |
y[k] = temp - c__[k - 1] * y[k]; |
| 10019 |
} |
| 10020 |
/* L20: */ |
| 10021 |
} |
| 10022 |
if (*job == 1) { |
| 10023 |
for (k = *n; k >= 1; --k) { |
| 10024 |
if (k <= *n - 2) { |
| 10025 |
temp = y[k] - b[k] * y[k + 1] - d__[k] * y[k + 2]; |
| 10026 |
} else if (k == *n - 1) { |
| 10027 |
temp = y[k] - b[k] * y[k + 1]; |
| 10028 |
} else { |
| 10029 |
temp = y[k]; |
| 10030 |
} |
| 10031 |
ak = a[k]; |
| 10032 |
absak = abs(ak); |
| 10033 |
if (absak < 1.) { |
| 10034 |
if (absak < sfmin) { |
| 10035 |
if (absak == 0. || abs(temp) * sfmin > absak) { |
| 10036 |
*info = k; |
| 10037 |
return 0; |
| 10038 |
} else { |
| 10039 |
temp *= bignum; |
| 10040 |
ak *= bignum; |
| 10041 |
} |
| 10042 |
} else if (abs(temp) > absak * bignum) { |
| 10043 |
*info = k; |
| 10044 |
return 0; |
| 10045 |
} |
| 10046 |
} |
| 10047 |
y[k] = temp / ak; |
| 10048 |
/* L30: */ |
| 10049 |
} |
| 10050 |
} else { |
| 10051 |
for (k = *n; k >= 1; --k) { |
| 10052 |
if (k <= *n - 2) { |
| 10053 |
temp = y[k] - b[k] * y[k + 1] - d__[k] * y[k + 2]; |
| 10054 |
} else if (k == *n - 1) { |
| 10055 |
temp = y[k] - b[k] * y[k + 1]; |
| 10056 |
} else { |
| 10057 |
temp = y[k]; |
| 10058 |
} |
| 10059 |
ak = a[k]; |
| 10060 |
pert = d_sign(tol, &ak); |
| 10061 |
L40: |
| 10062 |
absak = abs(ak); |
| 10063 |
if (absak < 1.) { |
| 10064 |
if (absak < sfmin) { |
| 10065 |
if (absak == 0. || abs(temp) * sfmin > absak) { |
| 10066 |
ak += pert; |
| 10067 |
pert *= 2; |
| 10068 |
goto L40; |
| 10069 |
} else { |
| 10070 |
temp *= bignum; |
| 10071 |
ak *= bignum; |
| 10072 |
} |
| 10073 |
} else if (abs(temp) > absak * bignum) { |
| 10074 |
ak += pert; |
| 10075 |
pert *= 2; |
| 10076 |
goto L40; |
| 10077 |
} |
| 10078 |
} |
| 10079 |
y[k] = temp / ak; |
| 10080 |
/* L50: */ |
| 10081 |
} |
| 10082 |
} |
| 10083 |
} else { |
| 10084 |
|
| 10085 |
/* Come to here if JOB = 2 or -2 */ |
| 10086 |
|
| 10087 |
if (*job == 2) { |
| 10088 |
i__1 = *n; |
| 10089 |
for (k = 1; k <= i__1; ++k) { |
| 10090 |
if (k >= 3) { |
| 10091 |
temp = y[k] - b[k - 1] * y[k - 1] - d__[k - 2] * y[k - 2]; |
| 10092 |
} else if (k == 2) { |
| 10093 |
temp = y[k] - b[k - 1] * y[k - 1]; |
| 10094 |
} else { |
| 10095 |
temp = y[k]; |
| 10096 |
} |
| 10097 |
ak = a[k]; |
| 10098 |
absak = abs(ak); |
| 10099 |
if (absak < 1.) { |
| 10100 |
if (absak < sfmin) { |
| 10101 |
if (absak == 0. || abs(temp) * sfmin > absak) { |
| 10102 |
*info = k; |
| 10103 |
return 0; |
| 10104 |
} else { |
| 10105 |
temp *= bignum; |
| 10106 |
ak *= bignum; |
| 10107 |
} |
| 10108 |
} else if (abs(temp) > absak * bignum) { |
| 10109 |
*info = k; |
| 10110 |
return 0; |
| 10111 |
} |
| 10112 |
} |
| 10113 |
y[k] = temp / ak; |
| 10114 |
/* L60: */ |
| 10115 |
} |
| 10116 |
} else { |
| 10117 |
i__1 = *n; |
| 10118 |
for (k = 1; k <= i__1; ++k) { |
| 10119 |
if (k >= 3) { |
| 10120 |
temp = y[k] - b[k - 1] * y[k - 1] - d__[k - 2] * y[k - 2]; |
| 10121 |
} else if (k == 2) { |
| 10122 |
temp = y[k] - b[k - 1] * y[k - 1]; |
| 10123 |
} else { |
| 10124 |
temp = y[k]; |
| 10125 |
} |
| 10126 |
ak = a[k]; |
| 10127 |
pert = d_sign(tol, &ak); |
| 10128 |
L70: |
| 10129 |
absak = abs(ak); |
| 10130 |
if (absak < 1.) { |
| 10131 |
if (absak < sfmin) { |
| 10132 |
if (absak == 0. || abs(temp) * sfmin > absak) { |
| 10133 |
ak += pert; |
| 10134 |
pert *= 2; |
| 10135 |
goto L70; |
| 10136 |
} else { |
| 10137 |
temp *= bignum; |
| 10138 |
ak *= bignum; |
| 10139 |
} |
| 10140 |
} else if (abs(temp) > absak * bignum) { |
| 10141 |
ak += pert; |
| 10142 |
pert *= 2; |
| 10143 |
goto L70; |
| 10144 |
} |
| 10145 |
} |
| 10146 |
y[k] = temp / ak; |
| 10147 |
/* L80: */ |
| 10148 |
} |
| 10149 |
} |
| 10150 |
|
| 10151 |
for (k = *n; k >= 2; --k) { |
| 10152 |
if (in[k - 1] == 0) { |
| 10153 |
y[k - 1] -= c__[k - 1] * y[k]; |
| 10154 |
} else { |
| 10155 |
temp = y[k - 1]; |
| 10156 |
y[k - 1] = y[k]; |
| 10157 |
y[k] = temp - c__[k - 1] * y[k]; |
| 10158 |
} |
| 10159 |
/* L90: */ |
| 10160 |
} |
| 10161 |
} |
| 10162 |
|
| 10163 |
/* End of DLAGTS */ |
| 10164 |
|
| 10165 |
return 0; |
| 10166 |
} /* dlagts_ */ |
| 10167 |
|
| 10168 |
/* Subroutine */ int dlagv2_(double *a, integer *lda, double *b, |
| 10169 |
integer *ldb, double *alphar, double *alphai, double * |
| 10170 |
beta, double *csl, double *snl, double *csr, double * |
| 10171 |
snr) |
| 10172 |
{ |
| 10173 |
/* Table of constant values */ |
| 10174 |
static integer c__2 = 2; |
| 10175 |
static integer c__1 = 1; |
| 10176 |
|
| 10177 |
/* System generated locals */ |
| 10178 |
integer a_dim1, a_offset, b_dim1, b_offset; |
| 10179 |
double d__1, d__2, d__3, d__4, d__5, d__6; |
| 10180 |
|
| 10181 |
/* Local variables */ |
| 10182 |
double r__, t, h1, h2, h3, wi, qq, rr, wr1, wr2, ulp; |
| 10183 |
double anorm, bnorm, scale1, scale2; |
| 10184 |
double ascale, bscale; |
| 10185 |
double safmin; |
| 10186 |
|
| 10187 |
|
| 10188 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 10189 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 10190 |
/* November 2006 */ |
| 10191 |
|
| 10192 |
/* .. Scalar Arguments .. */ |
| 10193 |
/* .. */ |
| 10194 |
/* .. Array Arguments .. */ |
| 10195 |
/* .. */ |
| 10196 |
|
| 10197 |
/* Purpose */ |
| 10198 |
/* ======= */ |
| 10199 |
|
| 10200 |
/* DLAGV2 computes the Generalized Schur factorization of a real 2-by-2 */ |
| 10201 |
/* matrix pencil (A,B) where B is upper triangular. This routine */ |
| 10202 |
/* computes orthogonal (rotation) matrices given by CSL, SNL and CSR, */ |
| 10203 |
/* SNR such that */ |
| 10204 |
|
| 10205 |
/* 1) if the pencil (A,B) has two real eigenvalues (include 0/0 or 1/0 */ |
| 10206 |
/* types), then */ |
| 10207 |
|
| 10208 |
/* [ a11 a12 ] := [ CSL SNL ] [ a11 a12 ] [ CSR -SNR ] */ |
| 10209 |
/* [ 0 a22 ] [ -SNL CSL ] [ a21 a22 ] [ SNR CSR ] */ |
| 10210 |
|
| 10211 |
/* [ b11 b12 ] := [ CSL SNL ] [ b11 b12 ] [ CSR -SNR ] */ |
| 10212 |
/* [ 0 b22 ] [ -SNL CSL ] [ 0 b22 ] [ SNR CSR ], */ |
| 10213 |
|
| 10214 |
/* 2) if the pencil (A,B) has a pair of complex conjugate eigenvalues, */ |
| 10215 |
/* then */ |
| 10216 |
|
| 10217 |
/* [ a11 a12 ] := [ CSL SNL ] [ a11 a12 ] [ CSR -SNR ] */ |
| 10218 |
/* [ a21 a22 ] [ -SNL CSL ] [ a21 a22 ] [ SNR CSR ] */ |
| 10219 |
|
| 10220 |
/* [ b11 0 ] := [ CSL SNL ] [ b11 b12 ] [ CSR -SNR ] */ |
| 10221 |
/* [ 0 b22 ] [ -SNL CSL ] [ 0 b22 ] [ SNR CSR ] */ |
| 10222 |
|
| 10223 |
/* where b11 >= b22 > 0. */ |
| 10224 |
|
| 10225 |
|
| 10226 |
/* Arguments */ |
| 10227 |
/* ========= */ |
| 10228 |
|
| 10229 |
/* A (input/output) DOUBLE PRECISION array, dimension (LDA, 2) */ |
| 10230 |
/* On entry, the 2 x 2 matrix A. */ |
| 10231 |
/* On exit, A is overwritten by the ``A-part'' of the */ |
| 10232 |
/* generalized Schur form. */ |
| 10233 |
|
| 10234 |
/* LDA (input) INTEGER */ |
| 10235 |
/* THe leading dimension of the array A. LDA >= 2. */ |
| 10236 |
|
| 10237 |
/* B (input/output) DOUBLE PRECISION array, dimension (LDB, 2) */ |
| 10238 |
/* On entry, the upper triangular 2 x 2 matrix B. */ |
| 10239 |
/* On exit, B is overwritten by the ``B-part'' of the */ |
| 10240 |
/* generalized Schur form. */ |
| 10241 |
|
| 10242 |
/* LDB (input) INTEGER */ |
| 10243 |
/* THe leading dimension of the array B. LDB >= 2. */ |
| 10244 |
|
| 10245 |
/* ALPHAR (output) DOUBLE PRECISION array, dimension (2) */ |
| 10246 |
/* ALPHAI (output) DOUBLE PRECISION array, dimension (2) */ |
| 10247 |
/* BETA (output) DOUBLE PRECISION array, dimension (2) */ |
| 10248 |
/* (ALPHAR(k)+i*ALPHAI(k))/BETA(k) are the eigenvalues of the */ |
| 10249 |
/* pencil (A,B), k=1,2, i = sqrt(-1). Note that BETA(k) may */ |
| 10250 |
/* be zero. */ |
| 10251 |
|
| 10252 |
/* CSL (output) DOUBLE PRECISION */ |
| 10253 |
/* The cosine of the left rotation matrix. */ |
| 10254 |
|
| 10255 |
/* SNL (output) DOUBLE PRECISION */ |
| 10256 |
/* The sine of the left rotation matrix. */ |
| 10257 |
|
| 10258 |
/* CSR (output) DOUBLE PRECISION */ |
| 10259 |
/* The cosine of the right rotation matrix. */ |
| 10260 |
|
| 10261 |
/* SNR (output) DOUBLE PRECISION */ |
| 10262 |
/* The sine of the right rotation matrix. */ |
| 10263 |
|
| 10264 |
/* Further Details */ |
| 10265 |
/* =============== */ |
| 10266 |
|
| 10267 |
/* Based on contributions by */ |
| 10268 |
/* Mark Fahey, Department of Mathematics, Univ. of Kentucky, USA */ |
| 10269 |
|
| 10270 |
/* ===================================================================== */ |
| 10271 |
|
| 10272 |
/* .. Parameters .. */ |
| 10273 |
/* .. */ |
| 10274 |
/* .. Local Scalars .. */ |
| 10275 |
/* .. */ |
| 10276 |
/* .. External Subroutines .. */ |
| 10277 |
/* .. */ |
| 10278 |
/* .. External Functions .. */ |
| 10279 |
/* .. */ |
| 10280 |
/* .. Intrinsic Functions .. */ |
| 10281 |
/* .. */ |
| 10282 |
/* .. Executable Statements .. */ |
| 10283 |
|
| 10284 |
/* Parameter adjustments */ |
| 10285 |
a_dim1 = *lda; |
| 10286 |
a_offset = 1 + a_dim1; |
| 10287 |
a -= a_offset; |
| 10288 |
b_dim1 = *ldb; |
| 10289 |
b_offset = 1 + b_dim1; |
| 10290 |
b -= b_offset; |
| 10291 |
--alphar; |
| 10292 |
--alphai; |
| 10293 |
--beta; |
| 10294 |
|
| 10295 |
/* Function Body */ |
| 10296 |
safmin = dlamch_("S"); |
| 10297 |
ulp = dlamch_("P"); |
| 10298 |
|
| 10299 |
/* Scale A */ |
| 10300 |
|
| 10301 |
/* Computing MAX */ |
| 10302 |
d__5 = (d__1 = a[a_dim1 + 1], abs(d__1)) + (d__2 = a[a_dim1 + 2], abs( |
| 10303 |
d__2)), d__6 = (d__3 = a[(a_dim1 << 1) + 1], abs(d__3)) + (d__4 = |
| 10304 |
a[(a_dim1 << 1) + 2], abs(d__4)), d__5 = std::max(d__5,d__6); |
| 10305 |
anorm = std::max(d__5,safmin); |
| 10306 |
ascale = 1. / anorm; |
| 10307 |
a[a_dim1 + 1] = ascale * a[a_dim1 + 1]; |
| 10308 |
a[(a_dim1 << 1) + 1] = ascale * a[(a_dim1 << 1) + 1]; |
| 10309 |
a[a_dim1 + 2] = ascale * a[a_dim1 + 2]; |
| 10310 |
a[(a_dim1 << 1) + 2] = ascale * a[(a_dim1 << 1) + 2]; |
| 10311 |
|
| 10312 |
/* Scale B */ |
| 10313 |
|
| 10314 |
/* Computing MAX */ |
| 10315 |
d__4 = (d__3 = b[b_dim1 + 1], abs(d__3)), d__5 = (d__1 = b[(b_dim1 << 1) |
| 10316 |
+ 1], abs(d__1)) + (d__2 = b[(b_dim1 << 1) + 2], abs(d__2)), d__4 |
| 10317 |
= std::max(d__4,d__5); |
| 10318 |
bnorm = std::max(d__4,safmin); |
| 10319 |
bscale = 1. / bnorm; |
| 10320 |
b[b_dim1 + 1] = bscale * b[b_dim1 + 1]; |
| 10321 |
b[(b_dim1 << 1) + 1] = bscale * b[(b_dim1 << 1) + 1]; |
| 10322 |
b[(b_dim1 << 1) + 2] = bscale * b[(b_dim1 << 1) + 2]; |
| 10323 |
|
| 10324 |
/* Check if A can be deflated */ |
| 10325 |
|
| 10326 |
if ((d__1 = a[a_dim1 + 2], abs(d__1)) <= ulp) { |
| 10327 |
*csl = 1.; |
| 10328 |
*snl = 0.; |
| 10329 |
*csr = 1.; |
| 10330 |
*snr = 0.; |
| 10331 |
a[a_dim1 + 2] = 0.; |
| 10332 |
b[b_dim1 + 2] = 0.; |
| 10333 |
|
| 10334 |
/* Check if B is singular */ |
| 10335 |
|
| 10336 |
} else if ((d__1 = b[b_dim1 + 1], abs(d__1)) <= ulp) { |
| 10337 |
dlartg_(&a[a_dim1 + 1], &a[a_dim1 + 2], csl, snl, &r__); |
| 10338 |
*csr = 1.; |
| 10339 |
*snr = 0.; |
| 10340 |
drot_(&c__2, &a[a_dim1 + 1], lda, &a[a_dim1 + 2], lda, csl, snl); |
| 10341 |
drot_(&c__2, &b[b_dim1 + 1], ldb, &b[b_dim1 + 2], ldb, csl, snl); |
| 10342 |
a[a_dim1 + 2] = 0.; |
| 10343 |
b[b_dim1 + 1] = 0.; |
| 10344 |
b[b_dim1 + 2] = 0.; |
| 10345 |
|
| 10346 |
} else if ((d__1 = b[(b_dim1 << 1) + 2], abs(d__1)) <= ulp) { |
| 10347 |
dlartg_(&a[(a_dim1 << 1) + 2], &a[a_dim1 + 2], csr, snr, &t); |
| 10348 |
*snr = -(*snr); |
| 10349 |
drot_(&c__2, &a[a_dim1 + 1], &c__1, &a[(a_dim1 << 1) + 1], &c__1, csr, |
| 10350 |
snr); |
| 10351 |
drot_(&c__2, &b[b_dim1 + 1], &c__1, &b[(b_dim1 << 1) + 1], &c__1, csr, |
| 10352 |
snr); |
| 10353 |
*csl = 1.; |
| 10354 |
*snl = 0.; |
| 10355 |
a[a_dim1 + 2] = 0.; |
| 10356 |
b[b_dim1 + 2] = 0.; |
| 10357 |
b[(b_dim1 << 1) + 2] = 0.; |
| 10358 |
|
| 10359 |
} else { |
| 10360 |
|
| 10361 |
/* B is nonsingular, first compute the eigenvalues of (A,B) */ |
| 10362 |
|
| 10363 |
dlag2_(&a[a_offset], lda, &b[b_offset], ldb, &safmin, &scale1, & |
| 10364 |
scale2, &wr1, &wr2, &wi); |
| 10365 |
|
| 10366 |
if (wi == 0.) { |
| 10367 |
|
| 10368 |
/* two real eigenvalues, compute s*A-w*B */ |
| 10369 |
|
| 10370 |
h1 = scale1 * a[a_dim1 + 1] - wr1 * b[b_dim1 + 1]; |
| 10371 |
h2 = scale1 * a[(a_dim1 << 1) + 1] - wr1 * b[(b_dim1 << 1) + 1]; |
| 10372 |
h3 = scale1 * a[(a_dim1 << 1) + 2] - wr1 * b[(b_dim1 << 1) + 2]; |
| 10373 |
|
| 10374 |
rr = dlapy2_(&h1, &h2); |
| 10375 |
d__1 = scale1 * a[a_dim1 + 2]; |
| 10376 |
qq = dlapy2_(&d__1, &h3); |
| 10377 |
|
| 10378 |
if (rr > qq) { |
| 10379 |
|
| 10380 |
/* find right rotation matrix to zero 1,1 element of */ |
| 10381 |
/* (sA - wB) */ |
| 10382 |
|
| 10383 |
dlartg_(&h2, &h1, csr, snr, &t); |
| 10384 |
|
| 10385 |
} else { |
| 10386 |
|
| 10387 |
/* find right rotation matrix to zero 2,1 element of */ |
| 10388 |
/* (sA - wB) */ |
| 10389 |
|
| 10390 |
d__1 = scale1 * a[a_dim1 + 2]; |
| 10391 |
dlartg_(&h3, &d__1, csr, snr, &t); |
| 10392 |
|
| 10393 |
} |
| 10394 |
|
| 10395 |
*snr = -(*snr); |
| 10396 |
drot_(&c__2, &a[a_dim1 + 1], &c__1, &a[(a_dim1 << 1) + 1], &c__1, |
| 10397 |
csr, snr); |
| 10398 |
drot_(&c__2, &b[b_dim1 + 1], &c__1, &b[(b_dim1 << 1) + 1], &c__1, |
| 10399 |
csr, snr); |
| 10400 |
|
| 10401 |
/* compute inf norms of A and B */ |
| 10402 |
|
| 10403 |
/* Computing MAX */ |
| 10404 |
d__5 = (d__1 = a[a_dim1 + 1], abs(d__1)) + (d__2 = a[(a_dim1 << 1) |
| 10405 |
+ 1], abs(d__2)), d__6 = (d__3 = a[a_dim1 + 2], abs(d__3) |
| 10406 |
) + (d__4 = a[(a_dim1 << 1) + 2], abs(d__4)); |
| 10407 |
h1 = std::max(d__5,d__6); |
| 10408 |
/* Computing MAX */ |
| 10409 |
d__5 = (d__1 = b[b_dim1 + 1], abs(d__1)) + (d__2 = b[(b_dim1 << 1) |
| 10410 |
+ 1], abs(d__2)), d__6 = (d__3 = b[b_dim1 + 2], abs(d__3) |
| 10411 |
) + (d__4 = b[(b_dim1 << 1) + 2], abs(d__4)); |
| 10412 |
h2 = std::max(d__5,d__6); |
| 10413 |
|
| 10414 |
if (scale1 * h1 >= abs(wr1) * h2) { |
| 10415 |
|
| 10416 |
/* find left rotation matrix Q to zero out B(2,1) */ |
| 10417 |
|
| 10418 |
dlartg_(&b[b_dim1 + 1], &b[b_dim1 + 2], csl, snl, &r__); |
| 10419 |
|
| 10420 |
} else { |
| 10421 |
|
| 10422 |
/* find left rotation matrix Q to zero out A(2,1) */ |
| 10423 |
|
| 10424 |
dlartg_(&a[a_dim1 + 1], &a[a_dim1 + 2], csl, snl, &r__); |
| 10425 |
|
| 10426 |
} |
| 10427 |
|
| 10428 |
drot_(&c__2, &a[a_dim1 + 1], lda, &a[a_dim1 + 2], lda, csl, snl); |
| 10429 |
drot_(&c__2, &b[b_dim1 + 1], ldb, &b[b_dim1 + 2], ldb, csl, snl); |
| 10430 |
|
| 10431 |
a[a_dim1 + 2] = 0.; |
| 10432 |
b[b_dim1 + 2] = 0.; |
| 10433 |
|
| 10434 |
} else { |
| 10435 |
|
| 10436 |
/* a pair of complex conjugate eigenvalues */ |
| 10437 |
/* first compute the SVD of the matrix B */ |
| 10438 |
|
| 10439 |
dlasv2_(&b[b_dim1 + 1], &b[(b_dim1 << 1) + 1], &b[(b_dim1 << 1) + |
| 10440 |
2], &r__, &t, snr, csr, snl, csl); |
| 10441 |
|
| 10442 |
/* Form (A,B) := Q(A,B)Z' where Q is left rotation matrix and */ |
| 10443 |
/* Z is right rotation matrix computed from DLASV2 */ |
| 10444 |
|
| 10445 |
drot_(&c__2, &a[a_dim1 + 1], lda, &a[a_dim1 + 2], lda, csl, snl); |
| 10446 |
drot_(&c__2, &b[b_dim1 + 1], ldb, &b[b_dim1 + 2], ldb, csl, snl); |
| 10447 |
drot_(&c__2, &a[a_dim1 + 1], &c__1, &a[(a_dim1 << 1) + 1], &c__1, |
| 10448 |
csr, snr); |
| 10449 |
drot_(&c__2, &b[b_dim1 + 1], &c__1, &b[(b_dim1 << 1) + 1], &c__1, |
| 10450 |
csr, snr); |
| 10451 |
|
| 10452 |
b[b_dim1 + 2] = 0.; |
| 10453 |
b[(b_dim1 << 1) + 1] = 0.; |
| 10454 |
|
| 10455 |
} |
| 10456 |
|
| 10457 |
} |
| 10458 |
|
| 10459 |
/* Unscaling */ |
| 10460 |
|
| 10461 |
a[a_dim1 + 1] = anorm * a[a_dim1 + 1]; |
| 10462 |
a[a_dim1 + 2] = anorm * a[a_dim1 + 2]; |
| 10463 |
a[(a_dim1 << 1) + 1] = anorm * a[(a_dim1 << 1) + 1]; |
| 10464 |
a[(a_dim1 << 1) + 2] = anorm * a[(a_dim1 << 1) + 2]; |
| 10465 |
b[b_dim1 + 1] = bnorm * b[b_dim1 + 1]; |
| 10466 |
b[b_dim1 + 2] = bnorm * b[b_dim1 + 2]; |
| 10467 |
b[(b_dim1 << 1) + 1] = bnorm * b[(b_dim1 << 1) + 1]; |
| 10468 |
b[(b_dim1 << 1) + 2] = bnorm * b[(b_dim1 << 1) + 2]; |
| 10469 |
|
| 10470 |
if (wi == 0.) { |
| 10471 |
alphar[1] = a[a_dim1 + 1]; |
| 10472 |
alphar[2] = a[(a_dim1 << 1) + 2]; |
| 10473 |
alphai[1] = 0.; |
| 10474 |
alphai[2] = 0.; |
| 10475 |
beta[1] = b[b_dim1 + 1]; |
| 10476 |
beta[2] = b[(b_dim1 << 1) + 2]; |
| 10477 |
} else { |
| 10478 |
alphar[1] = anorm * wr1 / scale1 / bnorm; |
| 10479 |
alphai[1] = anorm * wi / scale1 / bnorm; |
| 10480 |
alphar[2] = alphar[1]; |
| 10481 |
alphai[2] = -alphai[1]; |
| 10482 |
beta[1] = 1.; |
| 10483 |
beta[2] = 1.; |
| 10484 |
} |
| 10485 |
|
| 10486 |
return 0; |
| 10487 |
|
| 10488 |
/* End of DLAGV2 */ |
| 10489 |
|
| 10490 |
} /* dlagv2_ */ |
| 10491 |
|
| 10492 |
/* Subroutine */ int dlahqr_(bool *wantt, bool *wantz, integer *n, |
| 10493 |
integer *ilo, integer *ihi, double *h__, integer *ldh, double |
| 10494 |
*wr, double *wi, integer *iloz, integer *ihiz, double *z__, |
| 10495 |
integer *ldz, integer *info) |
| 10496 |
{ |
| 10497 |
/* Table of constant values */ |
| 10498 |
static integer c__1 = 1; |
| 10499 |
|
| 10500 |
/* System generated locals */ |
| 10501 |
integer h_dim1, h_offset, z_dim1, z_offset, i__1, i__2, i__3; |
| 10502 |
double d__1, d__2, d__3, d__4; |
| 10503 |
|
| 10504 |
/* Local variables */ |
| 10505 |
integer i__, j, k, l, m; |
| 10506 |
double s, v[3]; |
| 10507 |
integer i1, i2; |
| 10508 |
double t1, t2, t3, v2, v3, aa, ab, ba, bb, h11, h12, h21, h22, cs; |
| 10509 |
integer nh; |
| 10510 |
double sn; |
| 10511 |
integer nr; |
| 10512 |
double tr; |
| 10513 |
integer nz; |
| 10514 |
double det, h21s; |
| 10515 |
integer its; |
| 10516 |
double ulp, sum, tst, rt1i, rt2i, rt1r, rt2r; |
| 10517 |
double safmin, safmax, rtdisc, smlnum; |
| 10518 |
|
| 10519 |
|
| 10520 |
/* -- LAPACK auxiliary routine (version 3.2.1) -- */ |
| 10521 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 10522 |
/* November 2006 */ |
| 10523 |
|
| 10524 |
/* .. Scalar Arguments .. */ |
| 10525 |
/* .. */ |
| 10526 |
/* .. Array Arguments .. */ |
| 10527 |
/* .. */ |
| 10528 |
|
| 10529 |
/* Purpose */ |
| 10530 |
/* ======= */ |
| 10531 |
|
| 10532 |
/* DLAHQR is an auxiliary routine called by DHSEQR to update the */ |
| 10533 |
/* eigenvalues and Schur decomposition already computed by DHSEQR, by */ |
| 10534 |
/* dealing with the Hessenberg submatrix in rows and columns ILO to */ |
| 10535 |
/* IHI. */ |
| 10536 |
|
| 10537 |
/* Arguments */ |
| 10538 |
/* ========= */ |
| 10539 |
|
| 10540 |
/* WANTT (input) LOGICAL */ |
| 10541 |
/* = .TRUE. : the full Schur form T is required; */ |
| 10542 |
/* = .FALSE.: only eigenvalues are required. */ |
| 10543 |
|
| 10544 |
/* WANTZ (input) LOGICAL */ |
| 10545 |
/* = .TRUE. : the matrix of Schur vectors Z is required; */ |
| 10546 |
/* = .FALSE.: Schur vectors are not required. */ |
| 10547 |
|
| 10548 |
/* N (input) INTEGER */ |
| 10549 |
/* The order of the matrix H. N >= 0. */ |
| 10550 |
|
| 10551 |
/* ILO (input) INTEGER */ |
| 10552 |
/* IHI (input) INTEGER */ |
| 10553 |
/* It is assumed that H is already upper quasi-triangular in */ |
| 10554 |
/* rows and columns IHI+1:N, and that H(ILO,ILO-1) = 0 (unless */ |
| 10555 |
/* ILO = 1). DLAHQR works primarily with the Hessenberg */ |
| 10556 |
/* submatrix in rows and columns ILO to IHI, but applies */ |
| 10557 |
/* transformations to all of H if WANTT is .TRUE.. */ |
| 10558 |
/* 1 <= ILO <= max(1,IHI); IHI <= N. */ |
| 10559 |
|
| 10560 |
/* H (input/output) DOUBLE PRECISION array, dimension (LDH,N) */ |
| 10561 |
/* On entry, the upper Hessenberg matrix H. */ |
| 10562 |
/* On exit, if INFO is zero and if WANTT is .TRUE., H is upper */ |
| 10563 |
/* quasi-triangular in rows and columns ILO:IHI, with any */ |
| 10564 |
/* 2-by-2 diagonal blocks in standard form. If INFO is zero */ |
| 10565 |
/* and WANTT is .FALSE., the contents of H are unspecified on */ |
| 10566 |
/* exit. The output state of H if INFO is nonzero is given */ |
| 10567 |
/* below under the description of INFO. */ |
| 10568 |
|
| 10569 |
/* LDH (input) INTEGER */ |
| 10570 |
/* The leading dimension of the array H. LDH >= max(1,N). */ |
| 10571 |
|
| 10572 |
/* WR (output) DOUBLE PRECISION array, dimension (N) */ |
| 10573 |
/* WI (output) DOUBLE PRECISION array, dimension (N) */ |
| 10574 |
/* The real and imaginary parts, respectively, of the computed */ |
| 10575 |
/* eigenvalues ILO to IHI are stored in the corresponding */ |
| 10576 |
/* elements of WR and WI. If two eigenvalues are computed as a */ |
| 10577 |
/* complex conjugate pair, they are stored in consecutive */ |
| 10578 |
/* elements of WR and WI, say the i-th and (i+1)th, with */ |
| 10579 |
/* WI(i) > 0 and WI(i+1) < 0. If WANTT is .TRUE., the */ |
| 10580 |
/* eigenvalues are stored in the same order as on the diagonal */ |
| 10581 |
/* of the Schur form returned in H, with WR(i) = H(i,i), and, if */ |
| 10582 |
/* H(i:i+1,i:i+1) is a 2-by-2 diagonal block, */ |
| 10583 |
/* WI(i) = sqrt(H(i+1,i)*H(i,i+1)) and WI(i+1) = -WI(i). */ |
| 10584 |
|
| 10585 |
/* ILOZ (input) INTEGER */ |
| 10586 |
/* IHIZ (input) INTEGER */ |
| 10587 |
/* Specify the rows of Z to which transformations must be */ |
| 10588 |
/* applied if WANTZ is .TRUE.. */ |
| 10589 |
/* 1 <= ILOZ <= ILO; IHI <= IHIZ <= N. */ |
| 10590 |
|
| 10591 |
/* Z (input/output) DOUBLE PRECISION array, dimension (LDZ,N) */ |
| 10592 |
/* If WANTZ is .TRUE., on entry Z must contain the current */ |
| 10593 |
/* matrix Z of transformations accumulated by DHSEQR, and on */ |
| 10594 |
/* exit Z has been updated; transformations are applied only to */ |
| 10595 |
/* the submatrix Z(ILOZ:IHIZ,ILO:IHI). */ |
| 10596 |
/* If WANTZ is .FALSE., Z is not referenced. */ |
| 10597 |
|
| 10598 |
/* LDZ (input) INTEGER */ |
| 10599 |
/* The leading dimension of the array Z. LDZ >= max(1,N). */ |
| 10600 |
|
| 10601 |
/* INFO (output) INTEGER */ |
| 10602 |
/* = 0: successful exit */ |
| 10603 |
/* .GT. 0: If INFO = i, DLAHQR failed to compute all the */ |
| 10604 |
/* eigenvalues ILO to IHI in a total of 30 iterations */ |
| 10605 |
/* per eigenvalue; elements i+1:ihi of WR and WI */ |
| 10606 |
/* contain those eigenvalues which have been */ |
| 10607 |
/* successfully computed. */ |
| 10608 |
|
| 10609 |
/* If INFO .GT. 0 and WANTT is .FALSE., then on exit, */ |
| 10610 |
/* the remaining unconverged eigenvalues are the */ |
| 10611 |
/* eigenvalues of the upper Hessenberg matrix rows */ |
| 10612 |
/* and columns ILO thorugh INFO of the final, output */ |
| 10613 |
/* value of H. */ |
| 10614 |
|
| 10615 |
/* If INFO .GT. 0 and WANTT is .TRUE., then on exit */ |
| 10616 |
/* (*) (initial value of H)*U = U*(final value of H) */ |
| 10617 |
/* where U is an orthognal matrix. The final */ |
| 10618 |
/* value of H is upper Hessenberg and triangular in */ |
| 10619 |
/* rows and columns INFO+1 through IHI. */ |
| 10620 |
|
| 10621 |
/* If INFO .GT. 0 and WANTZ is .TRUE., then on exit */ |
| 10622 |
/* (final value of Z) = (initial value of Z)*U */ |
| 10623 |
/* where U is the orthogonal matrix in (*) */ |
| 10624 |
/* (regardless of the value of WANTT.) */ |
| 10625 |
|
| 10626 |
/* Further Details */ |
| 10627 |
/* =============== */ |
| 10628 |
|
| 10629 |
/* 02-96 Based on modifications by */ |
| 10630 |
/* David Day, Sandia National Laboratory, USA */ |
| 10631 |
|
| 10632 |
/* 12-04 Further modifications by */ |
| 10633 |
/* Ralph Byers, University of Kansas, USA */ |
| 10634 |
|
| 10635 |
/* This is a modified version of DLAHQR from LAPACK version 3.0. */ |
| 10636 |
/* It is (1) more robust against overflow and underflow and */ |
| 10637 |
/* (2) adopts the more conservative Ahues & Tisseur stopping */ |
| 10638 |
/* criterion (LAWN 122, 1997). */ |
| 10639 |
|
| 10640 |
/* ========================================================= */ |
| 10641 |
|
| 10642 |
/* .. Parameters .. */ |
| 10643 |
/* .. */ |
| 10644 |
/* .. Local Scalars .. */ |
| 10645 |
/* .. */ |
| 10646 |
/* .. Local Arrays .. */ |
| 10647 |
/* .. */ |
| 10648 |
/* .. External Functions .. */ |
| 10649 |
/* .. */ |
| 10650 |
/* .. External Subroutines .. */ |
| 10651 |
/* .. */ |
| 10652 |
/* .. Intrinsic Functions .. */ |
| 10653 |
/* .. */ |
| 10654 |
/* .. Executable Statements .. */ |
| 10655 |
|
| 10656 |
/* Parameter adjustments */ |
| 10657 |
h_dim1 = *ldh; |
| 10658 |
h_offset = 1 + h_dim1; |
| 10659 |
h__ -= h_offset; |
| 10660 |
--wr; |
| 10661 |
--wi; |
| 10662 |
z_dim1 = *ldz; |
| 10663 |
z_offset = 1 + z_dim1; |
| 10664 |
z__ -= z_offset; |
| 10665 |
|
| 10666 |
/* Function Body */ |
| 10667 |
*info = 0; |
| 10668 |
|
| 10669 |
/* Quick return if possible */ |
| 10670 |
|
| 10671 |
if (*n == 0) { |
| 10672 |
return 0; |
| 10673 |
} |
| 10674 |
if (*ilo == *ihi) { |
| 10675 |
wr[*ilo] = h__[*ilo + *ilo * h_dim1]; |
| 10676 |
wi[*ilo] = 0.; |
| 10677 |
return 0; |
| 10678 |
} |
| 10679 |
|
| 10680 |
/* ==== clear out the trash ==== */ |
| 10681 |
i__1 = *ihi - 3; |
| 10682 |
for (j = *ilo; j <= i__1; ++j) { |
| 10683 |
h__[j + 2 + j * h_dim1] = 0.; |
| 10684 |
h__[j + 3 + j * h_dim1] = 0.; |
| 10685 |
/* L10: */ |
| 10686 |
} |
| 10687 |
if (*ilo <= *ihi - 2) { |
| 10688 |
h__[*ihi + (*ihi - 2) * h_dim1] = 0.; |
| 10689 |
} |
| 10690 |
|
| 10691 |
nh = *ihi - *ilo + 1; |
| 10692 |
nz = *ihiz - *iloz + 1; |
| 10693 |
|
| 10694 |
/* Set machine-dependent constants for the stopping criterion. */ |
| 10695 |
|
| 10696 |
safmin = dlamch_("SAFE MINIMUM"); |
| 10697 |
safmax = 1. / safmin; |
| 10698 |
dlabad_(&safmin, &safmax); |
| 10699 |
ulp = dlamch_("PRECISION"); |
| 10700 |
smlnum = safmin * ((double) nh / ulp); |
| 10701 |
|
| 10702 |
/* I1 and I2 are the indices of the first row and last column of H */ |
| 10703 |
/* to which transformations must be applied. If eigenvalues only are */ |
| 10704 |
/* being computed, I1 and I2 are set inside the main loop. */ |
| 10705 |
|
| 10706 |
if (*wantt) { |
| 10707 |
i1 = 1; |
| 10708 |
i2 = *n; |
| 10709 |
} |
| 10710 |
|
| 10711 |
/* The main loop begins here. I is the loop index and decreases from */ |
| 10712 |
/* IHI to ILO in steps of 1 or 2. Each iteration of the loop works */ |
| 10713 |
/* with the active submatrix in rows and columns L to I. */ |
| 10714 |
/* Eigenvalues I+1 to IHI have already converged. Either L = ILO or */ |
| 10715 |
/* H(L,L-1) is negligible so that the matrix splits. */ |
| 10716 |
|
| 10717 |
i__ = *ihi; |
| 10718 |
L20: |
| 10719 |
l = *ilo; |
| 10720 |
if (i__ < *ilo) { |
| 10721 |
goto L160; |
| 10722 |
} |
| 10723 |
|
| 10724 |
/* Perform QR iterations on rows and columns ILO to I until a */ |
| 10725 |
/* submatrix of order 1 or 2 splits off at the bottom because a */ |
| 10726 |
/* subdiagonal element has become negligible. */ |
| 10727 |
|
| 10728 |
for (its = 0; its <= 30; ++its) { |
| 10729 |
|
| 10730 |
/* Look for a single small subdiagonal element. */ |
| 10731 |
|
| 10732 |
i__1 = l + 1; |
| 10733 |
for (k = i__; k >= i__1; --k) { |
| 10734 |
if ((d__1 = h__[k + (k - 1) * h_dim1], abs(d__1)) <= smlnum) { |
| 10735 |
goto L40; |
| 10736 |
} |
| 10737 |
tst = (d__1 = h__[k - 1 + (k - 1) * h_dim1], abs(d__1)) + (d__2 = |
| 10738 |
h__[k + k * h_dim1], abs(d__2)); |
| 10739 |
if (tst == 0.) { |
| 10740 |
if (k - 2 >= *ilo) { |
| 10741 |
tst += (d__1 = h__[k - 1 + (k - 2) * h_dim1], abs(d__1)); |
| 10742 |
} |
| 10743 |
if (k + 1 <= *ihi) { |
| 10744 |
tst += (d__1 = h__[k + 1 + k * h_dim1], abs(d__1)); |
| 10745 |
} |
| 10746 |
} |
| 10747 |
/* ==== The following is a conservative small subdiagonal */ |
| 10748 |
/* . deflation criterion due to Ahues & Tisseur (LAWN 122, */ |
| 10749 |
/* . 1997). It has better mathematical foundation and */ |
| 10750 |
/* . improves accuracy in some cases. ==== */ |
| 10751 |
if ((d__1 = h__[k + (k - 1) * h_dim1], abs(d__1)) <= ulp * tst) { |
| 10752 |
/* Computing MAX */ |
| 10753 |
d__3 = (d__1 = h__[k + (k - 1) * h_dim1], abs(d__1)), d__4 = ( |
| 10754 |
d__2 = h__[k - 1 + k * h_dim1], abs(d__2)); |
| 10755 |
ab = std::max(d__3,d__4); |
| 10756 |
/* Computing MIN */ |
| 10757 |
d__3 = (d__1 = h__[k + (k - 1) * h_dim1], abs(d__1)), d__4 = ( |
| 10758 |
d__2 = h__[k - 1 + k * h_dim1], abs(d__2)); |
| 10759 |
ba = std::min(d__3,d__4); |
| 10760 |
/* Computing MAX */ |
| 10761 |
d__3 = (d__1 = h__[k + k * h_dim1], abs(d__1)), d__4 = (d__2 = |
| 10762 |
h__[k - 1 + (k - 1) * h_dim1] - h__[k + k * h_dim1], |
| 10763 |
abs(d__2)); |
| 10764 |
aa = std::max(d__3,d__4); |
| 10765 |
/* Computing MIN */ |
| 10766 |
d__3 = (d__1 = h__[k + k * h_dim1], abs(d__1)), d__4 = (d__2 = |
| 10767 |
h__[k - 1 + (k - 1) * h_dim1] - h__[k + k * h_dim1], |
| 10768 |
abs(d__2)); |
| 10769 |
bb = std::min(d__3,d__4); |
| 10770 |
s = aa + ab; |
| 10771 |
/* Computing MAX */ |
| 10772 |
d__1 = smlnum, d__2 = ulp * (bb * (aa / s)); |
| 10773 |
if (ba * (ab / s) <= std::max(d__1,d__2)) { |
| 10774 |
goto L40; |
| 10775 |
} |
| 10776 |
} |
| 10777 |
/* L30: */ |
| 10778 |
} |
| 10779 |
L40: |
| 10780 |
l = k; |
| 10781 |
if (l > *ilo) { |
| 10782 |
|
| 10783 |
/* H(L,L-1) is negligible */ |
| 10784 |
|
| 10785 |
h__[l + (l - 1) * h_dim1] = 0.; |
| 10786 |
} |
| 10787 |
|
| 10788 |
/* Exit from loop if a submatrix of order 1 or 2 has split off. */ |
| 10789 |
|
| 10790 |
if (l >= i__ - 1) { |
| 10791 |
goto L150; |
| 10792 |
} |
| 10793 |
|
| 10794 |
/* Now the active submatrix is in rows and columns L to I. If */ |
| 10795 |
/* eigenvalues only are being computed, only the active submatrix */ |
| 10796 |
/* need be transformed. */ |
| 10797 |
|
| 10798 |
if (! (*wantt)) { |
| 10799 |
i1 = l; |
| 10800 |
i2 = i__; |
| 10801 |
} |
| 10802 |
|
| 10803 |
if (its == 10) { |
| 10804 |
|
| 10805 |
/* Exceptional shift. */ |
| 10806 |
|
| 10807 |
s = (d__1 = h__[l + 1 + l * h_dim1], abs(d__1)) + (d__2 = h__[l + |
| 10808 |
2 + (l + 1) * h_dim1], abs(d__2)); |
| 10809 |
h11 = s * .75 + h__[l + l * h_dim1]; |
| 10810 |
h12 = s * -.4375; |
| 10811 |
h21 = s; |
| 10812 |
h22 = h11; |
| 10813 |
} else if (its == 20) { |
| 10814 |
|
| 10815 |
/* Exceptional shift. */ |
| 10816 |
|
| 10817 |
s = (d__1 = h__[i__ + (i__ - 1) * h_dim1], abs(d__1)) + (d__2 = |
| 10818 |
h__[i__ - 1 + (i__ - 2) * h_dim1], abs(d__2)); |
| 10819 |
h11 = s * .75 + h__[i__ + i__ * h_dim1]; |
| 10820 |
h12 = s * -.4375; |
| 10821 |
h21 = s; |
| 10822 |
h22 = h11; |
| 10823 |
} else { |
| 10824 |
|
| 10825 |
/* Prepare to use Francis' double shift */ |
| 10826 |
/* (i.e. 2nd degree generalized Rayleigh quotient) */ |
| 10827 |
h11 = h__[i__ - 1 + (i__ - 1) * h_dim1]; |
| 10828 |
h21 = h__[i__ + (i__ - 1) * h_dim1]; |
| 10829 |
h12 = h__[i__ - 1 + i__ * h_dim1]; |
| 10830 |
h22 = h__[i__ + i__ * h_dim1]; |
| 10831 |
} |
| 10832 |
s = abs(h11) + abs(h12) + abs(h21) + abs(h22); |
| 10833 |
if (s == 0.) { |
| 10834 |
rt1r = 0.; |
| 10835 |
rt1i = 0.; |
| 10836 |
rt2r = 0.; |
| 10837 |
rt2i = 0.; |
| 10838 |
} else { |
| 10839 |
h11 /= s; |
| 10840 |
h21 /= s; |
| 10841 |
h12 /= s; |
| 10842 |
h22 /= s; |
| 10843 |
tr = (h11 + h22) / 2.; |
| 10844 |
det = (h11 - tr) * (h22 - tr) - h12 * h21; |
| 10845 |
rtdisc = sqrt((abs(det))); |
| 10846 |
if (det >= 0.) { |
| 10847 |
|
| 10848 |
/* ==== complex conjugate shifts ==== */ |
| 10849 |
|
| 10850 |
rt1r = tr * s; |
| 10851 |
rt2r = rt1r; |
| 10852 |
rt1i = rtdisc * s; |
| 10853 |
rt2i = -rt1i; |
| 10854 |
} else { |
| 10855 |
|
| 10856 |
/* ==== real shifts (use only one of them) ==== */ |
| 10857 |
|
| 10858 |
rt1r = tr + rtdisc; |
| 10859 |
rt2r = tr - rtdisc; |
| 10860 |
if ((d__1 = rt1r - h22, abs(d__1)) <= (d__2 = rt2r - h22, abs( |
| 10861 |
d__2))) { |
| 10862 |
rt1r *= s; |
| 10863 |
rt2r = rt1r; |
| 10864 |
} else { |
| 10865 |
rt2r *= s; |
| 10866 |
rt1r = rt2r; |
| 10867 |
} |
| 10868 |
rt1i = 0.; |
| 10869 |
rt2i = 0.; |
| 10870 |
} |
| 10871 |
} |
| 10872 |
|
| 10873 |
/* Look for two consecutive small subdiagonal elements. */ |
| 10874 |
|
| 10875 |
i__1 = l; |
| 10876 |
for (m = i__ - 2; m >= i__1; --m) { |
| 10877 |
/* Determine the effect of starting the double-shift QR */ |
| 10878 |
/* iteration at row M, and see if this would make H(M,M-1) */ |
| 10879 |
/* negligible. (The following uses scaling to avoid */ |
| 10880 |
/* overflows and most underflows.) */ |
| 10881 |
|
| 10882 |
h21s = h__[m + 1 + m * h_dim1]; |
| 10883 |
s = (d__1 = h__[m + m * h_dim1] - rt2r, abs(d__1)) + abs(rt2i) + |
| 10884 |
abs(h21s); |
| 10885 |
h21s = h__[m + 1 + m * h_dim1] / s; |
| 10886 |
v[0] = h21s * h__[m + (m + 1) * h_dim1] + (h__[m + m * h_dim1] - |
| 10887 |
rt1r) * ((h__[m + m * h_dim1] - rt2r) / s) - rt1i * (rt2i |
| 10888 |
/ s); |
| 10889 |
v[1] = h21s * (h__[m + m * h_dim1] + h__[m + 1 + (m + 1) * h_dim1] |
| 10890 |
- rt1r - rt2r); |
| 10891 |
v[2] = h21s * h__[m + 2 + (m + 1) * h_dim1]; |
| 10892 |
s = abs(v[0]) + abs(v[1]) + abs(v[2]); |
| 10893 |
v[0] /= s; |
| 10894 |
v[1] /= s; |
| 10895 |
v[2] /= s; |
| 10896 |
if (m == l) { |
| 10897 |
goto L60; |
| 10898 |
} |
| 10899 |
if ((d__1 = h__[m + (m - 1) * h_dim1], abs(d__1)) * (abs(v[1]) + |
| 10900 |
abs(v[2])) <= ulp * abs(v[0]) * ((d__2 = h__[m - 1 + (m - |
| 10901 |
1) * h_dim1], abs(d__2)) + (d__3 = h__[m + m * h_dim1], |
| 10902 |
abs(d__3)) + (d__4 = h__[m + 1 + (m + 1) * h_dim1], abs( |
| 10903 |
d__4)))) { |
| 10904 |
goto L60; |
| 10905 |
} |
| 10906 |
/* L50: */ |
| 10907 |
} |
| 10908 |
L60: |
| 10909 |
|
| 10910 |
/* Double-shift QR step */ |
| 10911 |
|
| 10912 |
i__1 = i__ - 1; |
| 10913 |
for (k = m; k <= i__1; ++k) { |
| 10914 |
|
| 10915 |
/* The first iteration of this loop determines a reflection G */ |
| 10916 |
/* from the vector V and applies it from left and right to H, */ |
| 10917 |
/* thus creating a nonzero bulge below the subdiagonal. */ |
| 10918 |
|
| 10919 |
/* Each subsequent iteration determines a reflection G to */ |
| 10920 |
/* restore the Hessenberg form in the (K-1)th column, and thus */ |
| 10921 |
/* chases the bulge one step toward the bottom of the active */ |
| 10922 |
/* submatrix. NR is the order of G. */ |
| 10923 |
|
| 10924 |
/* Computing MIN */ |
| 10925 |
i__2 = 3, i__3 = i__ - k + 1; |
| 10926 |
nr = std::min(i__2,i__3); |
| 10927 |
if (k > m) { |
| 10928 |
dcopy_(&nr, &h__[k + (k - 1) * h_dim1], &c__1, v, &c__1); |
| 10929 |
} |
| 10930 |
dlarfg_(&nr, v, &v[1], &c__1, &t1); |
| 10931 |
if (k > m) { |
| 10932 |
h__[k + (k - 1) * h_dim1] = v[0]; |
| 10933 |
h__[k + 1 + (k - 1) * h_dim1] = 0.; |
| 10934 |
if (k < i__ - 1) { |
| 10935 |
h__[k + 2 + (k - 1) * h_dim1] = 0.; |
| 10936 |
} |
| 10937 |
} else if (m > l) { |
| 10938 |
/* ==== Use the following instead of */ |
| 10939 |
/* . H( K, K-1 ) = -H( K, K-1 ) to */ |
| 10940 |
/* . avoid a bug when v(2) and v(3) */ |
| 10941 |
/* . underflow. ==== */ |
| 10942 |
h__[k + (k - 1) * h_dim1] *= 1. - t1; |
| 10943 |
} |
| 10944 |
v2 = v[1]; |
| 10945 |
t2 = t1 * v2; |
| 10946 |
if (nr == 3) { |
| 10947 |
v3 = v[2]; |
| 10948 |
t3 = t1 * v3; |
| 10949 |
|
| 10950 |
/* Apply G from the left to transform the rows of the matrix */ |
| 10951 |
/* in columns K to I2. */ |
| 10952 |
|
| 10953 |
i__2 = i2; |
| 10954 |
for (j = k; j <= i__2; ++j) { |
| 10955 |
sum = h__[k + j * h_dim1] + v2 * h__[k + 1 + j * h_dim1] |
| 10956 |
+ v3 * h__[k + 2 + j * h_dim1]; |
| 10957 |
h__[k + j * h_dim1] -= sum * t1; |
| 10958 |
h__[k + 1 + j * h_dim1] -= sum * t2; |
| 10959 |
h__[k + 2 + j * h_dim1] -= sum * t3; |
| 10960 |
/* L70: */ |
| 10961 |
} |
| 10962 |
|
| 10963 |
/* Apply G from the right to transform the columns of the */ |
| 10964 |
/* matrix in rows I1 to min(K+3,I). */ |
| 10965 |
|
| 10966 |
/* Computing MIN */ |
| 10967 |
i__3 = k + 3; |
| 10968 |
i__2 = std::min(i__3,i__); |
| 10969 |
for (j = i1; j <= i__2; ++j) { |
| 10970 |
sum = h__[j + k * h_dim1] + v2 * h__[j + (k + 1) * h_dim1] |
| 10971 |
+ v3 * h__[j + (k + 2) * h_dim1]; |
| 10972 |
h__[j + k * h_dim1] -= sum * t1; |
| 10973 |
h__[j + (k + 1) * h_dim1] -= sum * t2; |
| 10974 |
h__[j + (k + 2) * h_dim1] -= sum * t3; |
| 10975 |
/* L80: */ |
| 10976 |
} |
| 10977 |
|
| 10978 |
if (*wantz) { |
| 10979 |
|
| 10980 |
/* Accumulate transformations in the matrix Z */ |
| 10981 |
|
| 10982 |
i__2 = *ihiz; |
| 10983 |
for (j = *iloz; j <= i__2; ++j) { |
| 10984 |
sum = z__[j + k * z_dim1] + v2 * z__[j + (k + 1) * |
| 10985 |
z_dim1] + v3 * z__[j + (k + 2) * z_dim1]; |
| 10986 |
z__[j + k * z_dim1] -= sum * t1; |
| 10987 |
z__[j + (k + 1) * z_dim1] -= sum * t2; |
| 10988 |
z__[j + (k + 2) * z_dim1] -= sum * t3; |
| 10989 |
/* L90: */ |
| 10990 |
} |
| 10991 |
} |
| 10992 |
} else if (nr == 2) { |
| 10993 |
|
| 10994 |
/* Apply G from the left to transform the rows of the matrix */ |
| 10995 |
/* in columns K to I2. */ |
| 10996 |
|
| 10997 |
i__2 = i2; |
| 10998 |
for (j = k; j <= i__2; ++j) { |
| 10999 |
sum = h__[k + j * h_dim1] + v2 * h__[k + 1 + j * h_dim1]; |
| 11000 |
h__[k + j * h_dim1] -= sum * t1; |
| 11001 |
h__[k + 1 + j * h_dim1] -= sum * t2; |
| 11002 |
/* L100: */ |
| 11003 |
} |
| 11004 |
|
| 11005 |
/* Apply G from the right to transform the columns of the */ |
| 11006 |
/* matrix in rows I1 to min(K+3,I). */ |
| 11007 |
|
| 11008 |
i__2 = i__; |
| 11009 |
for (j = i1; j <= i__2; ++j) { |
| 11010 |
sum = h__[j + k * h_dim1] + v2 * h__[j + (k + 1) * h_dim1] |
| 11011 |
; |
| 11012 |
h__[j + k * h_dim1] -= sum * t1; |
| 11013 |
h__[j + (k + 1) * h_dim1] -= sum * t2; |
| 11014 |
/* L110: */ |
| 11015 |
} |
| 11016 |
|
| 11017 |
if (*wantz) { |
| 11018 |
|
| 11019 |
/* Accumulate transformations in the matrix Z */ |
| 11020 |
|
| 11021 |
i__2 = *ihiz; |
| 11022 |
for (j = *iloz; j <= i__2; ++j) { |
| 11023 |
sum = z__[j + k * z_dim1] + v2 * z__[j + (k + 1) * |
| 11024 |
z_dim1]; |
| 11025 |
z__[j + k * z_dim1] -= sum * t1; |
| 11026 |
z__[j + (k + 1) * z_dim1] -= sum * t2; |
| 11027 |
/* L120: */ |
| 11028 |
} |
| 11029 |
} |
| 11030 |
} |
| 11031 |
/* L130: */ |
| 11032 |
} |
| 11033 |
|
| 11034 |
/* L140: */ |
| 11035 |
} |
| 11036 |
|
| 11037 |
/* Failure to converge in remaining number of iterations */ |
| 11038 |
|
| 11039 |
*info = i__; |
| 11040 |
return 0; |
| 11041 |
|
| 11042 |
L150: |
| 11043 |
|
| 11044 |
if (l == i__) { |
| 11045 |
|
| 11046 |
/* H(I,I-1) is negligible: one eigenvalue has converged. */ |
| 11047 |
|
| 11048 |
wr[i__] = h__[i__ + i__ * h_dim1]; |
| 11049 |
wi[i__] = 0.; |
| 11050 |
} else if (l == i__ - 1) { |
| 11051 |
|
| 11052 |
/* H(I-1,I-2) is negligible: a pair of eigenvalues have converged. */ |
| 11053 |
|
| 11054 |
/* Transform the 2-by-2 submatrix to standard Schur form, */ |
| 11055 |
/* and compute and store the eigenvalues. */ |
| 11056 |
|
| 11057 |
dlanv2_(&h__[i__ - 1 + (i__ - 1) * h_dim1], &h__[i__ - 1 + i__ * |
| 11058 |
h_dim1], &h__[i__ + (i__ - 1) * h_dim1], &h__[i__ + i__ * |
| 11059 |
h_dim1], &wr[i__ - 1], &wi[i__ - 1], &wr[i__], &wi[i__], &cs, |
| 11060 |
&sn); |
| 11061 |
|
| 11062 |
if (*wantt) { |
| 11063 |
|
| 11064 |
/* Apply the transformation to the rest of H. */ |
| 11065 |
|
| 11066 |
if (i2 > i__) { |
| 11067 |
i__1 = i2 - i__; |
| 11068 |
drot_(&i__1, &h__[i__ - 1 + (i__ + 1) * h_dim1], ldh, &h__[ |
| 11069 |
i__ + (i__ + 1) * h_dim1], ldh, &cs, &sn); |
| 11070 |
} |
| 11071 |
i__1 = i__ - i1 - 1; |
| 11072 |
drot_(&i__1, &h__[i1 + (i__ - 1) * h_dim1], &c__1, &h__[i1 + i__ * |
| 11073 |
h_dim1], &c__1, &cs, &sn); |
| 11074 |
} |
| 11075 |
if (*wantz) { |
| 11076 |
|
| 11077 |
/* Apply the transformation to Z. */ |
| 11078 |
|
| 11079 |
drot_(&nz, &z__[*iloz + (i__ - 1) * z_dim1], &c__1, &z__[*iloz + |
| 11080 |
i__ * z_dim1], &c__1, &cs, &sn); |
| 11081 |
} |
| 11082 |
} |
| 11083 |
|
| 11084 |
/* return to start of the main loop with new value of I. */ |
| 11085 |
|
| 11086 |
i__ = l - 1; |
| 11087 |
goto L20; |
| 11088 |
|
| 11089 |
L160: |
| 11090 |
return 0; |
| 11091 |
|
| 11092 |
/* End of DLAHQR */ |
| 11093 |
|
| 11094 |
} /* dlahqr_ */ |
| 11095 |
|
| 11096 |
/* Subroutine */ int dlahr2_(integer *n, integer *k, integer *nb, double * |
| 11097 |
a, integer *lda, double *tau, double *t, integer *ldt, |
| 11098 |
double *y, integer *ldy) |
| 11099 |
{ |
| 11100 |
/* Table of constant values */ |
| 11101 |
static double c_b4 = -1.; |
| 11102 |
static double c_b5 = 1.; |
| 11103 |
static integer c__1 = 1; |
| 11104 |
static double c_b38 = 0.; |
| 11105 |
|
| 11106 |
/* System generated locals */ |
| 11107 |
integer a_dim1, a_offset, t_dim1, t_offset, y_dim1, y_offset, i__1, i__2, |
| 11108 |
i__3; |
| 11109 |
double d__1; |
| 11110 |
|
| 11111 |
/* Local variables */ |
| 11112 |
integer i__; |
| 11113 |
double ei; |
| 11114 |
|
| 11115 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 11116 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 11117 |
/* November 2006 */ |
| 11118 |
|
| 11119 |
/* .. Scalar Arguments .. */ |
| 11120 |
/* .. */ |
| 11121 |
/* .. Array Arguments .. */ |
| 11122 |
/* .. */ |
| 11123 |
|
| 11124 |
/* Purpose */ |
| 11125 |
/* ======= */ |
| 11126 |
|
| 11127 |
/* DLAHR2 reduces the first NB columns of A real general n-BY-(n-k+1) */ |
| 11128 |
/* matrix A so that elements below the k-th subdiagonal are zero. The */ |
| 11129 |
/* reduction is performed by an orthogonal similarity transformation */ |
| 11130 |
/* Q' * A * Q. The routine returns the matrices V and T which determine */ |
| 11131 |
/* Q as a block reflector I - V*T*V', and also the matrix Y = A * V * T. */ |
| 11132 |
|
| 11133 |
/* This is an auxiliary routine called by DGEHRD. */ |
| 11134 |
|
| 11135 |
/* Arguments */ |
| 11136 |
/* ========= */ |
| 11137 |
|
| 11138 |
/* N (input) INTEGER */ |
| 11139 |
/* The order of the matrix A. */ |
| 11140 |
|
| 11141 |
/* K (input) INTEGER */ |
| 11142 |
/* The offset for the reduction. Elements below the k-th */ |
| 11143 |
/* subdiagonal in the first NB columns are reduced to zero. */ |
| 11144 |
/* K < N. */ |
| 11145 |
|
| 11146 |
/* NB (input) INTEGER */ |
| 11147 |
/* The number of columns to be reduced. */ |
| 11148 |
|
| 11149 |
/* A (input/output) DOUBLE PRECISION array, dimension (LDA,N-K+1) */ |
| 11150 |
/* On entry, the n-by-(n-k+1) general matrix A. */ |
| 11151 |
/* On exit, the elements on and above the k-th subdiagonal in */ |
| 11152 |
/* the first NB columns are overwritten with the corresponding */ |
| 11153 |
/* elements of the reduced matrix; the elements below the k-th */ |
| 11154 |
/* subdiagonal, with the array TAU, represent the matrix Q as a */ |
| 11155 |
/* product of elementary reflectors. The other columns of A are */ |
| 11156 |
/* unchanged. See Further Details. */ |
| 11157 |
|
| 11158 |
/* LDA (input) INTEGER */ |
| 11159 |
/* The leading dimension of the array A. LDA >= max(1,N). */ |
| 11160 |
|
| 11161 |
/* TAU (output) DOUBLE PRECISION array, dimension (NB) */ |
| 11162 |
/* The scalar factors of the elementary reflectors. See Further */ |
| 11163 |
/* Details. */ |
| 11164 |
|
| 11165 |
/* T (output) DOUBLE PRECISION array, dimension (LDT,NB) */ |
| 11166 |
/* The upper triangular matrix T. */ |
| 11167 |
|
| 11168 |
/* LDT (input) INTEGER */ |
| 11169 |
/* The leading dimension of the array T. LDT >= NB. */ |
| 11170 |
|
| 11171 |
/* Y (output) DOUBLE PRECISION array, dimension (LDY,NB) */ |
| 11172 |
/* The n-by-nb matrix Y. */ |
| 11173 |
|
| 11174 |
/* LDY (input) INTEGER */ |
| 11175 |
/* The leading dimension of the array Y. LDY >= N. */ |
| 11176 |
|
| 11177 |
/* Further Details */ |
| 11178 |
/* =============== */ |
| 11179 |
|
| 11180 |
/* The matrix Q is represented as a product of nb elementary reflectors */ |
| 11181 |
|
| 11182 |
/* Q = H(1) H(2) . . . H(nb). */ |
| 11183 |
|
| 11184 |
/* Each H(i) has the form */ |
| 11185 |
|
| 11186 |
/* H(i) = I - tau * v * v' */ |
| 11187 |
|
| 11188 |
/* where tau is a real scalar, and v is a real vector with */ |
| 11189 |
/* v(1:i+k-1) = 0, v(i+k) = 1; v(i+k+1:n) is stored on exit in */ |
| 11190 |
/* A(i+k+1:n,i), and tau in TAU(i). */ |
| 11191 |
|
| 11192 |
/* The elements of the vectors v together form the (n-k+1)-by-nb matrix */ |
| 11193 |
/* V which is needed, with T and Y, to apply the transformation to the */ |
| 11194 |
/* unreduced part of the matrix, using an update of the form: */ |
| 11195 |
/* A := (I - V*T*V') * (A - Y*V'). */ |
| 11196 |
|
| 11197 |
/* The contents of A on exit are illustrated by the following example */ |
| 11198 |
/* with n = 7, k = 3 and nb = 2: */ |
| 11199 |
|
| 11200 |
/* ( a a a a a ) */ |
| 11201 |
/* ( a a a a a ) */ |
| 11202 |
/* ( a a a a a ) */ |
| 11203 |
/* ( h h a a a ) */ |
| 11204 |
/* ( v1 h a a a ) */ |
| 11205 |
/* ( v1 v2 a a a ) */ |
| 11206 |
/* ( v1 v2 a a a ) */ |
| 11207 |
|
| 11208 |
/* where a denotes an element of the original matrix A, h denotes a */ |
| 11209 |
/* modified element of the upper Hessenberg matrix H, and vi denotes an */ |
| 11210 |
/* element of the vector defining H(i). */ |
| 11211 |
|
| 11212 |
/* This file is a slight modification of LAPACK-3.0's DLAHRD */ |
| 11213 |
/* incorporating improvements proposed by Quintana-Orti and Van de */ |
| 11214 |
/* Gejin. Note that the entries of A(1:K,2:NB) differ from those */ |
| 11215 |
/* returned by the original LAPACK routine. This function is */ |
| 11216 |
/* not backward compatible with LAPACK3.0. */ |
| 11217 |
|
| 11218 |
/* ===================================================================== */ |
| 11219 |
|
| 11220 |
/* .. Parameters .. */ |
| 11221 |
/* .. */ |
| 11222 |
/* .. Local Scalars .. */ |
| 11223 |
/* .. */ |
| 11224 |
/* .. External Subroutines .. */ |
| 11225 |
/* .. */ |
| 11226 |
/* .. Intrinsic Functions .. */ |
| 11227 |
/* .. */ |
| 11228 |
/* .. Executable Statements .. */ |
| 11229 |
|
| 11230 |
/* Quick return if possible */ |
| 11231 |
|
| 11232 |
/* Parameter adjustments */ |
| 11233 |
--tau; |
| 11234 |
a_dim1 = *lda; |
| 11235 |
a_offset = 1 + a_dim1; |
| 11236 |
a -= a_offset; |
| 11237 |
t_dim1 = *ldt; |
| 11238 |
t_offset = 1 + t_dim1; |
| 11239 |
t -= t_offset; |
| 11240 |
y_dim1 = *ldy; |
| 11241 |
y_offset = 1 + y_dim1; |
| 11242 |
y -= y_offset; |
| 11243 |
|
| 11244 |
/* Function Body */ |
| 11245 |
if (*n <= 1) { |
| 11246 |
return 0; |
| 11247 |
} |
| 11248 |
|
| 11249 |
i__1 = *nb; |
| 11250 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 11251 |
if (i__ > 1) { |
| 11252 |
|
| 11253 |
/* Update A(K+1:N,I) */ |
| 11254 |
|
| 11255 |
/* Update I-th column of A - Y * V' */ |
| 11256 |
|
| 11257 |
i__2 = *n - *k; |
| 11258 |
i__3 = i__ - 1; |
| 11259 |
dgemv_("NO TRANSPOSE", &i__2, &i__3, &c_b4, &y[*k + 1 + y_dim1], |
| 11260 |
ldy, &a[*k + i__ - 1 + a_dim1], lda, &c_b5, &a[*k + 1 + |
| 11261 |
i__ * a_dim1], &c__1); |
| 11262 |
|
| 11263 |
/* Apply I - V * T' * V' to this column (call it b) from the */ |
| 11264 |
/* left, using the last column of T as workspace */ |
| 11265 |
|
| 11266 |
/* Let V = ( V1 ) and b = ( b1 ) (first I-1 rows) */ |
| 11267 |
/* ( V2 ) ( b2 ) */ |
| 11268 |
|
| 11269 |
/* where V1 is unit lower triangular */ |
| 11270 |
|
| 11271 |
/* w := V1' * b1 */ |
| 11272 |
|
| 11273 |
i__2 = i__ - 1; |
| 11274 |
dcopy_(&i__2, &a[*k + 1 + i__ * a_dim1], &c__1, &t[*nb * t_dim1 + |
| 11275 |
1], &c__1); |
| 11276 |
i__2 = i__ - 1; |
| 11277 |
dtrmv_("Lower", "Transpose", "UNIT", &i__2, &a[*k + 1 + a_dim1], |
| 11278 |
lda, &t[*nb * t_dim1 + 1], &c__1); |
| 11279 |
|
| 11280 |
/* w := w + V2'*b2 */ |
| 11281 |
|
| 11282 |
i__2 = *n - *k - i__ + 1; |
| 11283 |
i__3 = i__ - 1; |
| 11284 |
dgemv_("Transpose", &i__2, &i__3, &c_b5, &a[*k + i__ + a_dim1], |
| 11285 |
lda, &a[*k + i__ + i__ * a_dim1], &c__1, &c_b5, &t[*nb * |
| 11286 |
t_dim1 + 1], &c__1); |
| 11287 |
|
| 11288 |
/* w := T'*w */ |
| 11289 |
|
| 11290 |
i__2 = i__ - 1; |
| 11291 |
dtrmv_("Upper", "Transpose", "NON-UNIT", &i__2, &t[t_offset], ldt, |
| 11292 |
&t[*nb * t_dim1 + 1], &c__1); |
| 11293 |
|
| 11294 |
/* b2 := b2 - V2*w */ |
| 11295 |
|
| 11296 |
i__2 = *n - *k - i__ + 1; |
| 11297 |
i__3 = i__ - 1; |
| 11298 |
dgemv_("NO TRANSPOSE", &i__2, &i__3, &c_b4, &a[*k + i__ + a_dim1], |
| 11299 |
lda, &t[*nb * t_dim1 + 1], &c__1, &c_b5, &a[*k + i__ + |
| 11300 |
i__ * a_dim1], &c__1); |
| 11301 |
|
| 11302 |
/* b1 := b1 - V1*w */ |
| 11303 |
|
| 11304 |
i__2 = i__ - 1; |
| 11305 |
dtrmv_("Lower", "NO TRANSPOSE", "UNIT", &i__2, &a[*k + 1 + a_dim1] |
| 11306 |
, lda, &t[*nb * t_dim1 + 1], &c__1); |
| 11307 |
i__2 = i__ - 1; |
| 11308 |
daxpy_(&i__2, &c_b4, &t[*nb * t_dim1 + 1], &c__1, &a[*k + 1 + i__ |
| 11309 |
* a_dim1], &c__1); |
| 11310 |
|
| 11311 |
a[*k + i__ - 1 + (i__ - 1) * a_dim1] = ei; |
| 11312 |
} |
| 11313 |
|
| 11314 |
/* Generate the elementary reflector H(I) to annihilate */ |
| 11315 |
/* A(K+I+1:N,I) */ |
| 11316 |
|
| 11317 |
i__2 = *n - *k - i__ + 1; |
| 11318 |
/* Computing MIN */ |
| 11319 |
i__3 = *k + i__ + 1; |
| 11320 |
dlarfg_(&i__2, &a[*k + i__ + i__ * a_dim1], &a[std::min(i__3, *n)+ i__ * |
| 11321 |
a_dim1], &c__1, &tau[i__]); |
| 11322 |
ei = a[*k + i__ + i__ * a_dim1]; |
| 11323 |
a[*k + i__ + i__ * a_dim1] = 1.; |
| 11324 |
|
| 11325 |
/* Compute Y(K+1:N,I) */ |
| 11326 |
|
| 11327 |
i__2 = *n - *k; |
| 11328 |
i__3 = *n - *k - i__ + 1; |
| 11329 |
dgemv_("NO TRANSPOSE", &i__2, &i__3, &c_b5, &a[*k + 1 + (i__ + 1) * |
| 11330 |
a_dim1], lda, &a[*k + i__ + i__ * a_dim1], &c__1, &c_b38, &y[* |
| 11331 |
k + 1 + i__ * y_dim1], &c__1); |
| 11332 |
i__2 = *n - *k - i__ + 1; |
| 11333 |
i__3 = i__ - 1; |
| 11334 |
dgemv_("Transpose", &i__2, &i__3, &c_b5, &a[*k + i__ + a_dim1], lda, & |
| 11335 |
a[*k + i__ + i__ * a_dim1], &c__1, &c_b38, &t[i__ * t_dim1 + |
| 11336 |
1], &c__1); |
| 11337 |
i__2 = *n - *k; |
| 11338 |
i__3 = i__ - 1; |
| 11339 |
dgemv_("NO TRANSPOSE", &i__2, &i__3, &c_b4, &y[*k + 1 + y_dim1], ldy, |
| 11340 |
&t[i__ * t_dim1 + 1], &c__1, &c_b5, &y[*k + 1 + i__ * y_dim1], |
| 11341 |
&c__1); |
| 11342 |
i__2 = *n - *k; |
| 11343 |
dscal_(&i__2, &tau[i__], &y[*k + 1 + i__ * y_dim1], &c__1); |
| 11344 |
|
| 11345 |
/* Compute T(1:I,I) */ |
| 11346 |
|
| 11347 |
i__2 = i__ - 1; |
| 11348 |
d__1 = -tau[i__]; |
| 11349 |
dscal_(&i__2, &d__1, &t[i__ * t_dim1 + 1], &c__1); |
| 11350 |
i__2 = i__ - 1; |
| 11351 |
dtrmv_("Upper", "No Transpose", "NON-UNIT", &i__2, &t[t_offset], ldt, |
| 11352 |
&t[i__ * t_dim1 + 1], &c__1) |
| 11353 |
; |
| 11354 |
t[i__ + i__ * t_dim1] = tau[i__]; |
| 11355 |
|
| 11356 |
/* L10: */ |
| 11357 |
} |
| 11358 |
a[*k + *nb + *nb * a_dim1] = ei; |
| 11359 |
|
| 11360 |
/* Compute Y(1:K,1:NB) */ |
| 11361 |
|
| 11362 |
dlacpy_("ALL", k, nb, &a[(a_dim1 << 1) + 1], lda, &y[y_offset], ldy); |
| 11363 |
dtrmm_("RIGHT", "Lower", "NO TRANSPOSE", "UNIT", k, nb, &c_b5, &a[*k + 1 |
| 11364 |
+ a_dim1], lda, &y[y_offset], ldy); |
| 11365 |
if (*n > *k + *nb) { |
| 11366 |
i__1 = *n - *k - *nb; |
| 11367 |
dgemm_("NO TRANSPOSE", "NO TRANSPOSE", k, nb, &i__1, &c_b5, &a[(*nb + |
| 11368 |
2) * a_dim1 + 1], lda, &a[*k + 1 + *nb + a_dim1], lda, &c_b5, |
| 11369 |
&y[y_offset], ldy); |
| 11370 |
} |
| 11371 |
dtrmm_("RIGHT", "Upper", "NO TRANSPOSE", "NON-UNIT", k, nb, &c_b5, &t[ |
| 11372 |
t_offset], ldt, &y[y_offset], ldy); |
| 11373 |
|
| 11374 |
return 0; |
| 11375 |
|
| 11376 |
/* End of DLAHR2 */ |
| 11377 |
|
| 11378 |
} /* dlahr2_ */ |
| 11379 |
|
| 11380 |
/* Subroutine */ int dlahrd_(integer *n, integer *k, integer *nb, double * |
| 11381 |
a, integer *lda, double *tau, double *t, integer *ldt, |
| 11382 |
double *y, integer *ldy) |
| 11383 |
{ |
| 11384 |
/* Table of constant values */ |
| 11385 |
static double c_b4 = -1.; |
| 11386 |
static double c_b5 = 1.; |
| 11387 |
static integer c__1 = 1; |
| 11388 |
static double c_b38 = 0.; |
| 11389 |
|
| 11390 |
/* System generated locals */ |
| 11391 |
integer a_dim1, a_offset, t_dim1, t_offset, y_dim1, y_offset, i__1, i__2, |
| 11392 |
i__3; |
| 11393 |
double d__1; |
| 11394 |
|
| 11395 |
/* Local variables */ |
| 11396 |
integer i__; |
| 11397 |
double ei; |
| 11398 |
|
| 11399 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 11400 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 11401 |
/* November 2006 */ |
| 11402 |
|
| 11403 |
/* .. Scalar Arguments .. */ |
| 11404 |
/* .. */ |
| 11405 |
/* .. Array Arguments .. */ |
| 11406 |
/* .. */ |
| 11407 |
|
| 11408 |
/* Purpose */ |
| 11409 |
/* ======= */ |
| 11410 |
|
| 11411 |
/* DLAHRD reduces the first NB columns of a real general n-by-(n-k+1) */ |
| 11412 |
/* matrix A so that elements below the k-th subdiagonal are zero. The */ |
| 11413 |
/* reduction is performed by an orthogonal similarity transformation */ |
| 11414 |
/* Q' * A * Q. The routine returns the matrices V and T which determine */ |
| 11415 |
/* Q as a block reflector I - V*T*V', and also the matrix Y = A * V * T. */ |
| 11416 |
|
| 11417 |
/* This is an OBSOLETE auxiliary routine. */ |
| 11418 |
/* This routine will be 'deprecated' in a future release. */ |
| 11419 |
/* Please use the new routine DLAHR2 instead. */ |
| 11420 |
|
| 11421 |
/* Arguments */ |
| 11422 |
/* ========= */ |
| 11423 |
|
| 11424 |
/* N (input) INTEGER */ |
| 11425 |
/* The order of the matrix A. */ |
| 11426 |
|
| 11427 |
/* K (input) INTEGER */ |
| 11428 |
/* The offset for the reduction. Elements below the k-th */ |
| 11429 |
/* subdiagonal in the first NB columns are reduced to zero. */ |
| 11430 |
|
| 11431 |
/* NB (input) INTEGER */ |
| 11432 |
/* The number of columns to be reduced. */ |
| 11433 |
|
| 11434 |
/* A (input/output) DOUBLE PRECISION array, dimension (LDA,N-K+1) */ |
| 11435 |
/* On entry, the n-by-(n-k+1) general matrix A. */ |
| 11436 |
/* On exit, the elements on and above the k-th subdiagonal in */ |
| 11437 |
/* the first NB columns are overwritten with the corresponding */ |
| 11438 |
/* elements of the reduced matrix; the elements below the k-th */ |
| 11439 |
/* subdiagonal, with the array TAU, represent the matrix Q as a */ |
| 11440 |
/* product of elementary reflectors. The other columns of A are */ |
| 11441 |
/* unchanged. See Further Details. */ |
| 11442 |
|
| 11443 |
/* LDA (input) INTEGER */ |
| 11444 |
/* The leading dimension of the array A. LDA >= max(1,N). */ |
| 11445 |
|
| 11446 |
/* TAU (output) DOUBLE PRECISION array, dimension (NB) */ |
| 11447 |
/* The scalar factors of the elementary reflectors. See Further */ |
| 11448 |
/* Details. */ |
| 11449 |
|
| 11450 |
/* T (output) DOUBLE PRECISION array, dimension (LDT,NB) */ |
| 11451 |
/* The upper triangular matrix T. */ |
| 11452 |
|
| 11453 |
/* LDT (input) INTEGER */ |
| 11454 |
/* The leading dimension of the array T. LDT >= NB. */ |
| 11455 |
|
| 11456 |
/* Y (output) DOUBLE PRECISION array, dimension (LDY,NB) */ |
| 11457 |
/* The n-by-nb matrix Y. */ |
| 11458 |
|
| 11459 |
/* LDY (input) INTEGER */ |
| 11460 |
/* The leading dimension of the array Y. LDY >= N. */ |
| 11461 |
|
| 11462 |
/* Further Details */ |
| 11463 |
/* =============== */ |
| 11464 |
|
| 11465 |
/* The matrix Q is represented as a product of nb elementary reflectors */ |
| 11466 |
|
| 11467 |
/* Q = H(1) H(2) . . . H(nb). */ |
| 11468 |
|
| 11469 |
/* Each H(i) has the form */ |
| 11470 |
|
| 11471 |
/* H(i) = I - tau * v * v' */ |
| 11472 |
|
| 11473 |
/* where tau is a real scalar, and v is a real vector with */ |
| 11474 |
/* v(1:i+k-1) = 0, v(i+k) = 1; v(i+k+1:n) is stored on exit in */ |
| 11475 |
/* A(i+k+1:n,i), and tau in TAU(i). */ |
| 11476 |
|
| 11477 |
/* The elements of the vectors v together form the (n-k+1)-by-nb matrix */ |
| 11478 |
/* V which is needed, with T and Y, to apply the transformation to the */ |
| 11479 |
/* unreduced part of the matrix, using an update of the form: */ |
| 11480 |
/* A := (I - V*T*V') * (A - Y*V'). */ |
| 11481 |
|
| 11482 |
/* The contents of A on exit are illustrated by the following example */ |
| 11483 |
/* with n = 7, k = 3 and nb = 2: */ |
| 11484 |
|
| 11485 |
/* ( a h a a a ) */ |
| 11486 |
/* ( a h a a a ) */ |
| 11487 |
/* ( a h a a a ) */ |
| 11488 |
/* ( h h a a a ) */ |
| 11489 |
/* ( v1 h a a a ) */ |
| 11490 |
/* ( v1 v2 a a a ) */ |
| 11491 |
/* ( v1 v2 a a a ) */ |
| 11492 |
|
| 11493 |
/* where a denotes an element of the original matrix A, h denotes a */ |
| 11494 |
/* modified element of the upper Hessenberg matrix H, and vi denotes an */ |
| 11495 |
/* element of the vector defining H(i). */ |
| 11496 |
|
| 11497 |
/* ===================================================================== */ |
| 11498 |
|
| 11499 |
/* .. Parameters .. */ |
| 11500 |
/* .. */ |
| 11501 |
/* .. Local Scalars .. */ |
| 11502 |
/* .. */ |
| 11503 |
/* .. External Subroutines .. */ |
| 11504 |
/* .. */ |
| 11505 |
/* .. Intrinsic Functions .. */ |
| 11506 |
/* .. */ |
| 11507 |
/* .. Executable Statements .. */ |
| 11508 |
|
| 11509 |
/* Quick return if possible */ |
| 11510 |
|
| 11511 |
/* Parameter adjustments */ |
| 11512 |
--tau; |
| 11513 |
a_dim1 = *lda; |
| 11514 |
a_offset = 1 + a_dim1; |
| 11515 |
a -= a_offset; |
| 11516 |
t_dim1 = *ldt; |
| 11517 |
t_offset = 1 + t_dim1; |
| 11518 |
t -= t_offset; |
| 11519 |
y_dim1 = *ldy; |
| 11520 |
y_offset = 1 + y_dim1; |
| 11521 |
y -= y_offset; |
| 11522 |
|
| 11523 |
/* Function Body */ |
| 11524 |
if (*n <= 1) { |
| 11525 |
return 0; |
| 11526 |
} |
| 11527 |
|
| 11528 |
i__1 = *nb; |
| 11529 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 11530 |
if (i__ > 1) { |
| 11531 |
|
| 11532 |
/* Update A(1:n,i) */ |
| 11533 |
|
| 11534 |
/* Compute i-th column of A - Y * V' */ |
| 11535 |
|
| 11536 |
i__2 = i__ - 1; |
| 11537 |
dgemv_("No transpose", n, &i__2, &c_b4, &y[y_offset], ldy, &a[*k |
| 11538 |
+ i__ - 1 + a_dim1], lda, &c_b5, &a[i__ * a_dim1 + 1], & |
| 11539 |
c__1); |
| 11540 |
|
| 11541 |
/* Apply I - V * T' * V' to this column (call it b) from the */ |
| 11542 |
/* left, using the last column of T as workspace */ |
| 11543 |
|
| 11544 |
/* Let V = ( V1 ) and b = ( b1 ) (first I-1 rows) */ |
| 11545 |
/* ( V2 ) ( b2 ) */ |
| 11546 |
|
| 11547 |
/* where V1 is unit lower triangular */ |
| 11548 |
|
| 11549 |
/* w := V1' * b1 */ |
| 11550 |
|
| 11551 |
i__2 = i__ - 1; |
| 11552 |
dcopy_(&i__2, &a[*k + 1 + i__ * a_dim1], &c__1, &t[*nb * t_dim1 + |
| 11553 |
1], &c__1); |
| 11554 |
i__2 = i__ - 1; |
| 11555 |
dtrmv_("Lower", "Transpose", "Unit", &i__2, &a[*k + 1 + a_dim1], |
| 11556 |
lda, &t[*nb * t_dim1 + 1], &c__1); |
| 11557 |
|
| 11558 |
/* w := w + V2'*b2 */ |
| 11559 |
|
| 11560 |
i__2 = *n - *k - i__ + 1; |
| 11561 |
i__3 = i__ - 1; |
| 11562 |
dgemv_("Transpose", &i__2, &i__3, &c_b5, &a[*k + i__ + a_dim1], |
| 11563 |
lda, &a[*k + i__ + i__ * a_dim1], &c__1, &c_b5, &t[*nb * |
| 11564 |
t_dim1 + 1], &c__1); |
| 11565 |
|
| 11566 |
/* w := T'*w */ |
| 11567 |
|
| 11568 |
i__2 = i__ - 1; |
| 11569 |
dtrmv_("Upper", "Transpose", "Non-unit", &i__2, &t[t_offset], ldt, |
| 11570 |
&t[*nb * t_dim1 + 1], &c__1); |
| 11571 |
|
| 11572 |
/* b2 := b2 - V2*w */ |
| 11573 |
|
| 11574 |
i__2 = *n - *k - i__ + 1; |
| 11575 |
i__3 = i__ - 1; |
| 11576 |
dgemv_("No transpose", &i__2, &i__3, &c_b4, &a[*k + i__ + a_dim1], |
| 11577 |
lda, &t[*nb * t_dim1 + 1], &c__1, &c_b5, &a[*k + i__ + |
| 11578 |
i__ * a_dim1], &c__1); |
| 11579 |
|
| 11580 |
/* b1 := b1 - V1*w */ |
| 11581 |
|
| 11582 |
i__2 = i__ - 1; |
| 11583 |
dtrmv_("Lower", "No transpose", "Unit", &i__2, &a[*k + 1 + a_dim1] |
| 11584 |
, lda, &t[*nb * t_dim1 + 1], &c__1); |
| 11585 |
i__2 = i__ - 1; |
| 11586 |
daxpy_(&i__2, &c_b4, &t[*nb * t_dim1 + 1], &c__1, &a[*k + 1 + i__ |
| 11587 |
* a_dim1], &c__1); |
| 11588 |
|
| 11589 |
a[*k + i__ - 1 + (i__ - 1) * a_dim1] = ei; |
| 11590 |
} |
| 11591 |
|
| 11592 |
/* Generate the elementary reflector H(i) to annihilate */ |
| 11593 |
/* A(k+i+1:n,i) */ |
| 11594 |
|
| 11595 |
i__2 = *n - *k - i__ + 1; |
| 11596 |
/* Computing MIN */ |
| 11597 |
i__3 = *k + i__ + 1; |
| 11598 |
dlarfg_(&i__2, &a[*k + i__ + i__ * a_dim1], &a[std::min(i__3, *n)+ i__ * |
| 11599 |
a_dim1], &c__1, &tau[i__]); |
| 11600 |
ei = a[*k + i__ + i__ * a_dim1]; |
| 11601 |
a[*k + i__ + i__ * a_dim1] = 1.; |
| 11602 |
|
| 11603 |
/* Compute Y(1:n,i) */ |
| 11604 |
|
| 11605 |
i__2 = *n - *k - i__ + 1; |
| 11606 |
dgemv_("No transpose", n, &i__2, &c_b5, &a[(i__ + 1) * a_dim1 + 1], |
| 11607 |
lda, &a[*k + i__ + i__ * a_dim1], &c__1, &c_b38, &y[i__ * |
| 11608 |
y_dim1 + 1], &c__1); |
| 11609 |
i__2 = *n - *k - i__ + 1; |
| 11610 |
i__3 = i__ - 1; |
| 11611 |
dgemv_("Transpose", &i__2, &i__3, &c_b5, &a[*k + i__ + a_dim1], lda, & |
| 11612 |
a[*k + i__ + i__ * a_dim1], &c__1, &c_b38, &t[i__ * t_dim1 + |
| 11613 |
1], &c__1); |
| 11614 |
i__2 = i__ - 1; |
| 11615 |
dgemv_("No transpose", n, &i__2, &c_b4, &y[y_offset], ldy, &t[i__ * |
| 11616 |
t_dim1 + 1], &c__1, &c_b5, &y[i__ * y_dim1 + 1], &c__1); |
| 11617 |
dscal_(n, &tau[i__], &y[i__ * y_dim1 + 1], &c__1); |
| 11618 |
|
| 11619 |
/* Compute T(1:i,i) */ |
| 11620 |
|
| 11621 |
i__2 = i__ - 1; |
| 11622 |
d__1 = -tau[i__]; |
| 11623 |
dscal_(&i__2, &d__1, &t[i__ * t_dim1 + 1], &c__1); |
| 11624 |
i__2 = i__ - 1; |
| 11625 |
dtrmv_("Upper", "No transpose", "Non-unit", &i__2, &t[t_offset], ldt, |
| 11626 |
&t[i__ * t_dim1 + 1], &c__1) |
| 11627 |
; |
| 11628 |
t[i__ + i__ * t_dim1] = tau[i__]; |
| 11629 |
|
| 11630 |
/* L10: */ |
| 11631 |
} |
| 11632 |
a[*k + *nb + *nb * a_dim1] = ei; |
| 11633 |
|
| 11634 |
return 0; |
| 11635 |
|
| 11636 |
/* End of DLAHRD */ |
| 11637 |
|
| 11638 |
} /* dlahrd_ */ |
| 11639 |
|
| 11640 |
/* Subroutine */ int dlaic1_(integer *job, integer *j, double *x, |
| 11641 |
double *sest, double *w, double *gamma, double * |
| 11642 |
sestpr, double *s, double *c__) |
| 11643 |
{ |
| 11644 |
/* Table of constant values */ |
| 11645 |
static integer c__1 = 1; |
| 11646 |
static double c_b5 = 1.; |
| 11647 |
|
| 11648 |
/* System generated locals */ |
| 11649 |
double d__1, d__2, d__3, d__4; |
| 11650 |
|
| 11651 |
/* Builtin functions |
| 11652 |
double sqrt(double), d_sign(double *, double *); */ |
| 11653 |
|
| 11654 |
/* Local variables */ |
| 11655 |
double b, t, s1, s2, eps, tmp; |
| 11656 |
double sine, test, zeta1, zeta2, alpha, norma; |
| 11657 |
double absgam, absalp, cosine, absest; |
| 11658 |
|
| 11659 |
|
| 11660 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 11661 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 11662 |
/* November 2006 */ |
| 11663 |
|
| 11664 |
/* .. Scalar Arguments .. */ |
| 11665 |
/* .. */ |
| 11666 |
/* .. Array Arguments .. */ |
| 11667 |
/* .. */ |
| 11668 |
|
| 11669 |
/* Purpose */ |
| 11670 |
/* ======= */ |
| 11671 |
|
| 11672 |
/* DLAIC1 applies one step of incremental condition estimation in */ |
| 11673 |
/* its simplest version: */ |
| 11674 |
|
| 11675 |
/* Let x, twonorm(x) = 1, be an approximate singular vector of an j-by-j */ |
| 11676 |
/* lower triangular matrix L, such that */ |
| 11677 |
/* twonorm(L*x) = sest */ |
| 11678 |
/* Then DLAIC1 computes sestpr, s, c such that */ |
| 11679 |
/* the vector */ |
| 11680 |
/* [ s*x ] */ |
| 11681 |
/* xhat = [ c ] */ |
| 11682 |
/* is an approximate singular vector of */ |
| 11683 |
/* [ L 0 ] */ |
| 11684 |
/* Lhat = [ w' gamma ] */ |
| 11685 |
/* in the sense that */ |
| 11686 |
/* twonorm(Lhat*xhat) = sestpr. */ |
| 11687 |
|
| 11688 |
/* Depending on JOB, an estimate for the largest or smallest singular */ |
| 11689 |
/* value is computed. */ |
| 11690 |
|
| 11691 |
/* Note that [s c]' and sestpr**2 is an eigenpair of the system */ |
| 11692 |
|
| 11693 |
/* diag(sest*sest, 0) + [alpha gamma] * [ alpha ] */ |
| 11694 |
/* [ gamma ] */ |
| 11695 |
|
| 11696 |
/* where alpha = x'*w. */ |
| 11697 |
|
| 11698 |
/* Arguments */ |
| 11699 |
/* ========= */ |
| 11700 |
|
| 11701 |
/* JOB (input) INTEGER */ |
| 11702 |
/* = 1: an estimate for the largest singular value is computed. */ |
| 11703 |
/* = 2: an estimate for the smallest singular value is computed. */ |
| 11704 |
|
| 11705 |
/* J (input) INTEGER */ |
| 11706 |
/* Length of X and W */ |
| 11707 |
|
| 11708 |
/* X (input) DOUBLE PRECISION array, dimension (J) */ |
| 11709 |
/* The j-vector x. */ |
| 11710 |
|
| 11711 |
/* SEST (input) DOUBLE PRECISION */ |
| 11712 |
/* Estimated singular value of j by j matrix L */ |
| 11713 |
|
| 11714 |
/* W (input) DOUBLE PRECISION array, dimension (J) */ |
| 11715 |
/* The j-vector w. */ |
| 11716 |
|
| 11717 |
/* GAMMA (input) DOUBLE PRECISION */ |
| 11718 |
/* The diagonal element gamma. */ |
| 11719 |
|
| 11720 |
/* SESTPR (output) DOUBLE PRECISION */ |
| 11721 |
/* Estimated singular value of (j+1) by (j+1) matrix Lhat. */ |
| 11722 |
|
| 11723 |
/* S (output) DOUBLE PRECISION */ |
| 11724 |
/* Sine needed in forming xhat. */ |
| 11725 |
|
| 11726 |
/* C (output) DOUBLE PRECISION */ |
| 11727 |
/* Cosine needed in forming xhat. */ |
| 11728 |
|
| 11729 |
/* ===================================================================== */ |
| 11730 |
|
| 11731 |
/* .. Parameters .. */ |
| 11732 |
/* .. */ |
| 11733 |
/* .. Local Scalars .. */ |
| 11734 |
/* .. */ |
| 11735 |
/* .. Intrinsic Functions .. */ |
| 11736 |
/* .. */ |
| 11737 |
/* .. External Functions .. */ |
| 11738 |
/* .. */ |
| 11739 |
/* .. Executable Statements .. */ |
| 11740 |
|
| 11741 |
/* Parameter adjustments */ |
| 11742 |
--w; |
| 11743 |
--x; |
| 11744 |
|
| 11745 |
/* Function Body */ |
| 11746 |
eps = dlamch_("Epsilon"); |
| 11747 |
alpha = ddot_(j, &x[1], &c__1, &w[1], &c__1); |
| 11748 |
|
| 11749 |
absalp = abs(alpha); |
| 11750 |
absgam = abs(*gamma); |
| 11751 |
absest = abs(*sest); |
| 11752 |
|
| 11753 |
if (*job == 1) { |
| 11754 |
|
| 11755 |
/* Estimating largest singular value */ |
| 11756 |
|
| 11757 |
/* special cases */ |
| 11758 |
|
| 11759 |
if (*sest == 0.) { |
| 11760 |
s1 = std::max(absgam,absalp); |
| 11761 |
if (s1 == 0.) { |
| 11762 |
*s = 0.; |
| 11763 |
*c__ = 1.; |
| 11764 |
*sestpr = 0.; |
| 11765 |
} else { |
| 11766 |
*s = alpha / s1; |
| 11767 |
*c__ = *gamma / s1; |
| 11768 |
tmp = sqrt(*s * *s + *c__ * *c__); |
| 11769 |
*s /= tmp; |
| 11770 |
*c__ /= tmp; |
| 11771 |
*sestpr = s1 * tmp; |
| 11772 |
} |
| 11773 |
return 0; |
| 11774 |
} else if (absgam <= eps * absest) { |
| 11775 |
*s = 1.; |
| 11776 |
*c__ = 0.; |
| 11777 |
tmp = std::max(absest,absalp); |
| 11778 |
s1 = absest / tmp; |
| 11779 |
s2 = absalp / tmp; |
| 11780 |
*sestpr = tmp * sqrt(s1 * s1 + s2 * s2); |
| 11781 |
return 0; |
| 11782 |
} else if (absalp <= eps * absest) { |
| 11783 |
s1 = absgam; |
| 11784 |
s2 = absest; |
| 11785 |
if (s1 <= s2) { |
| 11786 |
*s = 1.; |
| 11787 |
*c__ = 0.; |
| 11788 |
*sestpr = s2; |
| 11789 |
} else { |
| 11790 |
*s = 0.; |
| 11791 |
*c__ = 1.; |
| 11792 |
*sestpr = s1; |
| 11793 |
} |
| 11794 |
return 0; |
| 11795 |
} else if (absest <= eps * absalp || absest <= eps * absgam) { |
| 11796 |
s1 = absgam; |
| 11797 |
s2 = absalp; |
| 11798 |
if (s1 <= s2) { |
| 11799 |
tmp = s1 / s2; |
| 11800 |
*s = sqrt(tmp * tmp + 1.); |
| 11801 |
*sestpr = s2 * *s; |
| 11802 |
*c__ = *gamma / s2 / *s; |
| 11803 |
*s = d_sign(&c_b5, &alpha) / *s; |
| 11804 |
} else { |
| 11805 |
tmp = s2 / s1; |
| 11806 |
*c__ = sqrt(tmp * tmp + 1.); |
| 11807 |
*sestpr = s1 * *c__; |
| 11808 |
*s = alpha / s1 / *c__; |
| 11809 |
*c__ = d_sign(&c_b5, gamma) / *c__; |
| 11810 |
} |
| 11811 |
return 0; |
| 11812 |
} else { |
| 11813 |
|
| 11814 |
/* normal case */ |
| 11815 |
|
| 11816 |
zeta1 = alpha / absest; |
| 11817 |
zeta2 = *gamma / absest; |
| 11818 |
|
| 11819 |
b = (1. - zeta1 * zeta1 - zeta2 * zeta2) * .5; |
| 11820 |
*c__ = zeta1 * zeta1; |
| 11821 |
if (b > 0.) { |
| 11822 |
t = *c__ / (b + sqrt(b * b + *c__)); |
| 11823 |
} else { |
| 11824 |
t = sqrt(b * b + *c__) - b; |
| 11825 |
} |
| 11826 |
|
| 11827 |
sine = -zeta1 / t; |
| 11828 |
cosine = -zeta2 / (t + 1.); |
| 11829 |
tmp = sqrt(sine * sine + cosine * cosine); |
| 11830 |
*s = sine / tmp; |
| 11831 |
*c__ = cosine / tmp; |
| 11832 |
*sestpr = sqrt(t + 1.) * absest; |
| 11833 |
return 0; |
| 11834 |
} |
| 11835 |
|
| 11836 |
} else if (*job == 2) { |
| 11837 |
|
| 11838 |
/* Estimating smallest singular value */ |
| 11839 |
|
| 11840 |
/* special cases */ |
| 11841 |
|
| 11842 |
if (*sest == 0.) { |
| 11843 |
*sestpr = 0.; |
| 11844 |
if (std::max(absgam,absalp) == 0.) { |
| 11845 |
sine = 1.; |
| 11846 |
cosine = 0.; |
| 11847 |
} else { |
| 11848 |
sine = -(*gamma); |
| 11849 |
cosine = alpha; |
| 11850 |
} |
| 11851 |
/* Computing MAX */ |
| 11852 |
d__1 = abs(sine), d__2 = abs(cosine); |
| 11853 |
s1 = std::max(d__1,d__2); |
| 11854 |
*s = sine / s1; |
| 11855 |
*c__ = cosine / s1; |
| 11856 |
tmp = sqrt(*s * *s + *c__ * *c__); |
| 11857 |
*s /= tmp; |
| 11858 |
*c__ /= tmp; |
| 11859 |
return 0; |
| 11860 |
} else if (absgam <= eps * absest) { |
| 11861 |
*s = 0.; |
| 11862 |
*c__ = 1.; |
| 11863 |
*sestpr = absgam; |
| 11864 |
return 0; |
| 11865 |
} else if (absalp <= eps * absest) { |
| 11866 |
s1 = absgam; |
| 11867 |
s2 = absest; |
| 11868 |
if (s1 <= s2) { |
| 11869 |
*s = 0.; |
| 11870 |
*c__ = 1.; |
| 11871 |
*sestpr = s1; |
| 11872 |
} else { |
| 11873 |
*s = 1.; |
| 11874 |
*c__ = 0.; |
| 11875 |
*sestpr = s2; |
| 11876 |
} |
| 11877 |
return 0; |
| 11878 |
} else if (absest <= eps * absalp || absest <= eps * absgam) { |
| 11879 |
s1 = absgam; |
| 11880 |
s2 = absalp; |
| 11881 |
if (s1 <= s2) { |
| 11882 |
tmp = s1 / s2; |
| 11883 |
*c__ = sqrt(tmp * tmp + 1.); |
| 11884 |
*sestpr = absest * (tmp / *c__); |
| 11885 |
*s = -(*gamma / s2) / *c__; |
| 11886 |
*c__ = d_sign(&c_b5, &alpha) / *c__; |
| 11887 |
} else { |
| 11888 |
tmp = s2 / s1; |
| 11889 |
*s = sqrt(tmp * tmp + 1.); |
| 11890 |
*sestpr = absest / *s; |
| 11891 |
*c__ = alpha / s1 / *s; |
| 11892 |
*s = -d_sign(&c_b5, gamma) / *s; |
| 11893 |
} |
| 11894 |
return 0; |
| 11895 |
} else { |
| 11896 |
|
| 11897 |
/* normal case */ |
| 11898 |
|
| 11899 |
zeta1 = alpha / absest; |
| 11900 |
zeta2 = *gamma / absest; |
| 11901 |
|
| 11902 |
/* Computing MAX */ |
| 11903 |
d__3 = zeta1 * zeta1 + 1. + (d__1 = zeta1 * zeta2, abs(d__1)), |
| 11904 |
d__4 = (d__2 = zeta1 * zeta2, abs(d__2)) + zeta2 * zeta2; |
| 11905 |
norma = std::max(d__3,d__4); |
| 11906 |
|
| 11907 |
/* See if root is closer to zero or to ONE */ |
| 11908 |
|
| 11909 |
test = (zeta1 - zeta2) * 2. * (zeta1 + zeta2) + 1.; |
| 11910 |
if (test >= 0.) { |
| 11911 |
|
| 11912 |
/* root is close to zero, compute directly */ |
| 11913 |
|
| 11914 |
b = (zeta1 * zeta1 + zeta2 * zeta2 + 1.) * .5; |
| 11915 |
*c__ = zeta2 * zeta2; |
| 11916 |
t = *c__ / (b + sqrt((d__1 = b * b - *c__, abs(d__1)))); |
| 11917 |
sine = zeta1 / (1. - t); |
| 11918 |
cosine = -zeta2 / t; |
| 11919 |
*sestpr = sqrt(t + eps * 4. * eps * norma) * absest; |
| 11920 |
} else { |
| 11921 |
|
| 11922 |
/* root is closer to ONE, shift by that amount */ |
| 11923 |
|
| 11924 |
b = (zeta2 * zeta2 + zeta1 * zeta1 - 1.) * .5; |
| 11925 |
*c__ = zeta1 * zeta1; |
| 11926 |
if (b >= 0.) { |
| 11927 |
t = -(*c__) / (b + sqrt(b * b + *c__)); |
| 11928 |
} else { |
| 11929 |
t = b - sqrt(b * b + *c__); |
| 11930 |
} |
| 11931 |
sine = -zeta1 / t; |
| 11932 |
cosine = -zeta2 / (t + 1.); |
| 11933 |
*sestpr = sqrt(t + 1. + eps * 4. * eps * norma) * absest; |
| 11934 |
} |
| 11935 |
tmp = sqrt(sine * sine + cosine * cosine); |
| 11936 |
*s = sine / tmp; |
| 11937 |
*c__ = cosine / tmp; |
| 11938 |
return 0; |
| 11939 |
|
| 11940 |
} |
| 11941 |
} |
| 11942 |
return 0; |
| 11943 |
|
| 11944 |
/* End of DLAIC1 */ |
| 11945 |
|
| 11946 |
} /* dlaic1_ */ |
| 11947 |
|
| 11948 |
/* Subroutine */ bool dlaisnan_(double *din1, double *din2) |
| 11949 |
{ |
| 11950 |
/* System generated locals */ |
| 11951 |
bool ret_val; |
| 11952 |
|
| 11953 |
|
| 11954 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 11955 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 11956 |
/* November 2006 */ |
| 11957 |
|
| 11958 |
/* .. Scalar Arguments .. */ |
| 11959 |
/* .. */ |
| 11960 |
|
| 11961 |
/* Purpose */ |
| 11962 |
/* ======= */ |
| 11963 |
|
| 11964 |
/* This routine is not for general use. It exists solely to avoid */ |
| 11965 |
/* over-optimization in DISNAN. */ |
| 11966 |
|
| 11967 |
/* DLAISNAN checks for NaNs by comparing its two arguments for */ |
| 11968 |
/* inequality. NaN is the only floating-point value where NaN != NaN */ |
| 11969 |
/* returns .TRUE. To check for NaNs, pass the same variable as both */ |
| 11970 |
/* arguments. */ |
| 11971 |
|
| 11972 |
/* Strictly speaking, Fortran does not allow aliasing of function */ |
| 11973 |
/* arguments. So a compiler must assume that the two arguments are */ |
| 11974 |
/* not the same variable, and the test will not be optimized away. */ |
| 11975 |
/* Interprocedural or whole-program optimization may delete this */ |
| 11976 |
/* test. The ISNAN functions will be replaced by the correct */ |
| 11977 |
/* Fortran 03 intrinsic once the intrinsic is widely available. */ |
| 11978 |
|
| 11979 |
/* Arguments */ |
| 11980 |
/* ========= */ |
| 11981 |
|
| 11982 |
/* DIN1 (input) DOUBLE PRECISION */ |
| 11983 |
/* DIN2 (input) DOUBLE PRECISION */ |
| 11984 |
/* Two numbers to compare for inequality. */ |
| 11985 |
|
| 11986 |
/* ===================================================================== */ |
| 11987 |
|
| 11988 |
/* .. Executable Statements .. */ |
| 11989 |
ret_val = *din1 != *din2; |
| 11990 |
return ret_val; |
| 11991 |
} /* dlaisnan_ */ |
| 11992 |
|
| 11993 |
/* Subroutine */ int dlaln2_(bool *ltrans, integer *na, integer *nw, |
| 11994 |
double *smin, double *ca, double *a, integer *lda, |
| 11995 |
double *d1, double *d2, double *b, integer *ldb, |
| 11996 |
double *wr, double *wi, double *x, integer *ldx, |
| 11997 |
double *scale, double *xnorm, integer *info) |
| 11998 |
{ |
| 11999 |
/* Initialized data */ |
| 12000 |
|
| 12001 |
static bool zswap[4] = { false,false,true,true }; |
| 12002 |
static bool rswap[4] = { false,true,false,true }; |
| 12003 |
static integer ipivot[16] /* was [4][4] */ = { 1,2,3,4,2,1,4,3,3,4,1,2, |
| 12004 |
4,3,2,1 }; |
| 12005 |
|
| 12006 |
/* System generated locals */ |
| 12007 |
integer a_dim1, a_offset, b_dim1, b_offset, x_dim1, x_offset; |
| 12008 |
double d__1, d__2, d__3, d__4, d__5, d__6; |
| 12009 |
static double equiv_0[4], equiv_1[4]; |
| 12010 |
|
| 12011 |
/* Local variables */ |
| 12012 |
integer j; |
| 12013 |
#define ci (equiv_0) |
| 12014 |
#define cr (equiv_1) |
| 12015 |
double bi1, bi2, br1, br2, xi1, xi2, xr1, xr2, ci21, ci22, cr21, cr22, |
| 12016 |
li21, csi, ui11, lr21, ui12, ui22; |
| 12017 |
#define civ (equiv_0) |
| 12018 |
double csr, ur11, ur12, ur22; |
| 12019 |
#define crv (equiv_1) |
| 12020 |
double bbnd, cmax, ui11r, ui12s, temp, ur11r, ur12s, u22abs; |
| 12021 |
integer icmax; |
| 12022 |
double bnorm, cnorm, smini; |
| 12023 |
double bignum, smlnum; |
| 12024 |
|
| 12025 |
|
| 12026 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 12027 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 12028 |
/* November 2006 */ |
| 12029 |
|
| 12030 |
/* .. Scalar Arguments .. */ |
| 12031 |
/* .. */ |
| 12032 |
/* .. Array Arguments .. */ |
| 12033 |
/* .. */ |
| 12034 |
|
| 12035 |
/* Purpose */ |
| 12036 |
/* ======= */ |
| 12037 |
|
| 12038 |
/* DLALN2 solves a system of the form (ca A - w D ) X = s B */ |
| 12039 |
/* or (ca A' - w D) X = s B with possible scaling ("s") and */ |
| 12040 |
/* perturbation of A. (A' means A-transpose.) */ |
| 12041 |
|
| 12042 |
/* A is an NA x NA real matrix, ca is a real scalar, D is an NA x NA */ |
| 12043 |
/* real diagonal matrix, w is a real or complex value, and X and B are */ |
| 12044 |
/* NA x 1 matrices -- real if w is real, complex if w is complex. NA */ |
| 12045 |
/* may be 1 or 2. */ |
| 12046 |
|
| 12047 |
/* If w is complex, X and B are represented as NA x 2 matrices, */ |
| 12048 |
/* the first column of each being the real part and the second */ |
| 12049 |
/* being the imaginary part. */ |
| 12050 |
|
| 12051 |
/* "s" is a scaling factor (.LE. 1), computed by DLALN2, which is */ |
| 12052 |
/* so chosen that X can be computed without overflow. X is further */ |
| 12053 |
/* scaled if necessary to assure that norm(ca A - w D)*norm(X) is less */ |
| 12054 |
/* than overflow. */ |
| 12055 |
|
| 12056 |
/* If both singular values of (ca A - w D) are less than SMIN, */ |
| 12057 |
/* SMIN*identity will be used instead of (ca A - w D). If only one */ |
| 12058 |
/* singular value is less than SMIN, one element of (ca A - w D) will be */ |
| 12059 |
/* perturbed enough to make the smallest singular value roughly SMIN. */ |
| 12060 |
/* If both singular values are at least SMIN, (ca A - w D) will not be */ |
| 12061 |
/* perturbed. In any case, the perturbation will be at most some small */ |
| 12062 |
/* multiple of max( SMIN, ulp*norm(ca A - w D) ). The singular values */ |
| 12063 |
/* are computed by infinity-norm approximations, and thus will only be */ |
| 12064 |
/* correct to a factor of 2 or so. */ |
| 12065 |
|
| 12066 |
/* Note: all input quantities are assumed to be smaller than overflow */ |
| 12067 |
/* by a reasonable factor. (See BIGNUM.) */ |
| 12068 |
|
| 12069 |
/* Arguments */ |
| 12070 |
/* ========== */ |
| 12071 |
|
| 12072 |
/* LTRANS (input) LOGICAL */ |
| 12073 |
/* =.TRUE.: A-transpose will be used. */ |
| 12074 |
/* =.FALSE.: A will be used (not transposed.) */ |
| 12075 |
|
| 12076 |
/* NA (input) INTEGER */ |
| 12077 |
/* The size of the matrix A. It may (only) be 1 or 2. */ |
| 12078 |
|
| 12079 |
/* NW (input) INTEGER */ |
| 12080 |
/* 1 if "w" is real, 2 if "w" is complex. It may only be 1 */ |
| 12081 |
/* or 2. */ |
| 12082 |
|
| 12083 |
/* SMIN (input) DOUBLE PRECISION */ |
| 12084 |
/* The desired lower bound on the singular values of A. This */ |
| 12085 |
/* should be a safe distance away from underflow or overflow, */ |
| 12086 |
/* say, between (underflow/machine precision) and (machine */ |
| 12087 |
/* precision * overflow ). (See BIGNUM and ULP.) */ |
| 12088 |
|
| 12089 |
/* CA (input) DOUBLE PRECISION */ |
| 12090 |
/* The coefficient c, which A is multiplied by. */ |
| 12091 |
|
| 12092 |
/* A (input) DOUBLE PRECISION array, dimension (LDA,NA) */ |
| 12093 |
/* The NA x NA matrix A. */ |
| 12094 |
|
| 12095 |
/* LDA (input) INTEGER */ |
| 12096 |
/* The leading dimension of A. It must be at least NA. */ |
| 12097 |
|
| 12098 |
/* D1 (input) DOUBLE PRECISION */ |
| 12099 |
/* The 1,1 element in the diagonal matrix D. */ |
| 12100 |
|
| 12101 |
/* D2 (input) DOUBLE PRECISION */ |
| 12102 |
/* The 2,2 element in the diagonal matrix D. Not used if NW=1. */ |
| 12103 |
|
| 12104 |
/* B (input) DOUBLE PRECISION array, dimension (LDB,NW) */ |
| 12105 |
/* The NA x NW matrix B (right-hand side). If NW=2 ("w" is */ |
| 12106 |
/* complex), column 1 contains the real part of B and column 2 */ |
| 12107 |
/* contains the imaginary part. */ |
| 12108 |
|
| 12109 |
/* LDB (input) INTEGER */ |
| 12110 |
/* The leading dimension of B. It must be at least NA. */ |
| 12111 |
|
| 12112 |
/* WR (input) DOUBLE PRECISION */ |
| 12113 |
/* The real part of the scalar "w". */ |
| 12114 |
|
| 12115 |
/* WI (input) DOUBLE PRECISION */ |
| 12116 |
/* The imaginary part of the scalar "w". Not used if NW=1. */ |
| 12117 |
|
| 12118 |
/* X (output) DOUBLE PRECISION array, dimension (LDX,NW) */ |
| 12119 |
/* The NA x NW matrix X (unknowns), as computed by DLALN2. */ |
| 12120 |
/* If NW=2 ("w" is complex), on exit, column 1 will contain */ |
| 12121 |
/* the real part of X and column 2 will contain the imaginary */ |
| 12122 |
/* part. */ |
| 12123 |
|
| 12124 |
/* LDX (input) INTEGER */ |
| 12125 |
/* The leading dimension of X. It must be at least NA. */ |
| 12126 |
|
| 12127 |
/* SCALE (output) DOUBLE PRECISION */ |
| 12128 |
/* The scale factor that B must be multiplied by to insure */ |
| 12129 |
/* that overflow does not occur when computing X. Thus, */ |
| 12130 |
/* (ca A - w D) X will be SCALE*B, not B (ignoring */ |
| 12131 |
/* perturbations of A.) It will be at most 1. */ |
| 12132 |
|
| 12133 |
/* XNORM (output) DOUBLE PRECISION */ |
| 12134 |
/* The infinity-norm of X, when X is regarded as an NA x NW */ |
| 12135 |
/* real matrix. */ |
| 12136 |
|
| 12137 |
/* INFO (output) INTEGER */ |
| 12138 |
/* An error flag. It will be set to zero if no error occurs, */ |
| 12139 |
/* a negative number if an argument is in error, or a positive */ |
| 12140 |
/* number if ca A - w D had to be perturbed. */ |
| 12141 |
/* The possible values are: */ |
| 12142 |
/* = 0: No error occurred, and (ca A - w D) did not have to be */ |
| 12143 |
/* perturbed. */ |
| 12144 |
/* = 1: (ca A - w D) had to be perturbed to make its smallest */ |
| 12145 |
/* (or only) singular value greater than SMIN. */ |
| 12146 |
/* NOTE: In the interests of speed, this routine does not */ |
| 12147 |
/* check the inputs for errors. */ |
| 12148 |
|
| 12149 |
/* ===================================================================== */ |
| 12150 |
|
| 12151 |
/* .. Parameters .. */ |
| 12152 |
/* .. */ |
| 12153 |
/* .. Local Scalars .. */ |
| 12154 |
/* .. */ |
| 12155 |
/* .. Local Arrays .. */ |
| 12156 |
/* .. */ |
| 12157 |
/* .. External Functions .. */ |
| 12158 |
/* .. */ |
| 12159 |
/* .. External Subroutines .. */ |
| 12160 |
/* .. */ |
| 12161 |
/* .. Intrinsic Functions .. */ |
| 12162 |
/* .. */ |
| 12163 |
/* .. Equivalences .. */ |
| 12164 |
/* .. */ |
| 12165 |
/* .. Data statements .. */ |
| 12166 |
/* Parameter adjustments */ |
| 12167 |
a_dim1 = *lda; |
| 12168 |
a_offset = 1 + a_dim1; |
| 12169 |
a -= a_offset; |
| 12170 |
b_dim1 = *ldb; |
| 12171 |
b_offset = 1 + b_dim1; |
| 12172 |
b -= b_offset; |
| 12173 |
x_dim1 = *ldx; |
| 12174 |
x_offset = 1 + x_dim1; |
| 12175 |
x -= x_offset; |
| 12176 |
|
| 12177 |
/* Function Body */ |
| 12178 |
/* .. */ |
| 12179 |
/* .. Executable Statements .. */ |
| 12180 |
|
| 12181 |
/* Compute BIGNUM */ |
| 12182 |
|
| 12183 |
smlnum = 2. * dlamch_("Safe minimum"); |
| 12184 |
bignum = 1. / smlnum; |
| 12185 |
smini = std::max(*smin,smlnum); |
| 12186 |
|
| 12187 |
/* Don't check for input errors */ |
| 12188 |
|
| 12189 |
*info = 0; |
| 12190 |
|
| 12191 |
/* Standard Initializations */ |
| 12192 |
|
| 12193 |
*scale = 1.; |
| 12194 |
|
| 12195 |
if (*na == 1) { |
| 12196 |
|
| 12197 |
/* 1 x 1 (i.e., scalar) system C X = B */ |
| 12198 |
|
| 12199 |
if (*nw == 1) { |
| 12200 |
|
| 12201 |
/* Real 1x1 system. */ |
| 12202 |
|
| 12203 |
/* C = ca A - w D */ |
| 12204 |
|
| 12205 |
csr = *ca * a[a_dim1 + 1] - *wr * *d1; |
| 12206 |
cnorm = abs(csr); |
| 12207 |
|
| 12208 |
/* If | C | < SMINI, use C = SMINI */ |
| 12209 |
|
| 12210 |
if (cnorm < smini) { |
| 12211 |
csr = smini; |
| 12212 |
cnorm = smini; |
| 12213 |
*info = 1; |
| 12214 |
} |
| 12215 |
|
| 12216 |
/* Check scaling for X = B / C */ |
| 12217 |
|
| 12218 |
bnorm = (d__1 = b[b_dim1 + 1], abs(d__1)); |
| 12219 |
if (cnorm < 1. && bnorm > 1.) { |
| 12220 |
if (bnorm > bignum * cnorm) { |
| 12221 |
*scale = 1. / bnorm; |
| 12222 |
} |
| 12223 |
} |
| 12224 |
|
| 12225 |
/* Compute X */ |
| 12226 |
|
| 12227 |
x[x_dim1 + 1] = b[b_dim1 + 1] * *scale / csr; |
| 12228 |
*xnorm = (d__1 = x[x_dim1 + 1], abs(d__1)); |
| 12229 |
} else { |
| 12230 |
|
| 12231 |
/* Complex 1x1 system (w is complex) */ |
| 12232 |
|
| 12233 |
/* C = ca A - w D */ |
| 12234 |
|
| 12235 |
csr = *ca * a[a_dim1 + 1] - *wr * *d1; |
| 12236 |
csi = -(*wi) * *d1; |
| 12237 |
cnorm = abs(csr) + abs(csi); |
| 12238 |
|
| 12239 |
/* If | C | < SMINI, use C = SMINI */ |
| 12240 |
|
| 12241 |
if (cnorm < smini) { |
| 12242 |
csr = smini; |
| 12243 |
csi = 0.; |
| 12244 |
cnorm = smini; |
| 12245 |
*info = 1; |
| 12246 |
} |
| 12247 |
|
| 12248 |
/* Check scaling for X = B / C */ |
| 12249 |
|
| 12250 |
bnorm = (d__1 = b[b_dim1 + 1], abs(d__1)) + (d__2 = b[(b_dim1 << |
| 12251 |
1) + 1], abs(d__2)); |
| 12252 |
if (cnorm < 1. && bnorm > 1.) { |
| 12253 |
if (bnorm > bignum * cnorm) { |
| 12254 |
*scale = 1. / bnorm; |
| 12255 |
} |
| 12256 |
} |
| 12257 |
|
| 12258 |
/* Compute X */ |
| 12259 |
|
| 12260 |
d__1 = *scale * b[b_dim1 + 1]; |
| 12261 |
d__2 = *scale * b[(b_dim1 << 1) + 1]; |
| 12262 |
dladiv_(&d__1, &d__2, &csr, &csi, &x[x_dim1 + 1], &x[(x_dim1 << 1) |
| 12263 |
+ 1]); |
| 12264 |
*xnorm = (d__1 = x[x_dim1 + 1], abs(d__1)) + (d__2 = x[(x_dim1 << |
| 12265 |
1) + 1], abs(d__2)); |
| 12266 |
} |
| 12267 |
|
| 12268 |
} else { |
| 12269 |
|
| 12270 |
/* 2x2 System */ |
| 12271 |
|
| 12272 |
/* Compute the real part of C = ca A - w D (or ca A' - w D ) */ |
| 12273 |
|
| 12274 |
cr[0] = *ca * a[a_dim1 + 1] - *wr * *d1; |
| 12275 |
cr[3] = *ca * a[(a_dim1 << 1) + 2] - *wr * *d2; |
| 12276 |
if (*ltrans) { |
| 12277 |
cr[2] = *ca * a[a_dim1 + 2]; |
| 12278 |
cr[1] = *ca * a[(a_dim1 << 1) + 1]; |
| 12279 |
} else { |
| 12280 |
cr[1] = *ca * a[a_dim1 + 2]; |
| 12281 |
cr[2] = *ca * a[(a_dim1 << 1) + 1]; |
| 12282 |
} |
| 12283 |
|
| 12284 |
if (*nw == 1) { |
| 12285 |
|
| 12286 |
/* Real 2x2 system (w is real) */ |
| 12287 |
|
| 12288 |
/* Find the largest element in C */ |
| 12289 |
|
| 12290 |
cmax = 0.; |
| 12291 |
icmax = 0; |
| 12292 |
|
| 12293 |
for (j = 1; j <= 4; ++j) { |
| 12294 |
if ((d__1 = crv[j - 1], abs(d__1)) > cmax) { |
| 12295 |
cmax = (d__1 = crv[j - 1], abs(d__1)); |
| 12296 |
icmax = j; |
| 12297 |
} |
| 12298 |
/* L10: */ |
| 12299 |
} |
| 12300 |
|
| 12301 |
/* If norm(C) < SMINI, use SMINI*identity. */ |
| 12302 |
|
| 12303 |
if (cmax < smini) { |
| 12304 |
/* Computing MAX */ |
| 12305 |
d__3 = (d__1 = b[b_dim1 + 1], abs(d__1)), d__4 = (d__2 = b[ |
| 12306 |
b_dim1 + 2], abs(d__2)); |
| 12307 |
bnorm = std::max(d__3,d__4); |
| 12308 |
if (smini < 1. && bnorm > 1.) { |
| 12309 |
if (bnorm > bignum * smini) { |
| 12310 |
*scale = 1. / bnorm; |
| 12311 |
} |
| 12312 |
} |
| 12313 |
temp = *scale / smini; |
| 12314 |
x[x_dim1 + 1] = temp * b[b_dim1 + 1]; |
| 12315 |
x[x_dim1 + 2] = temp * b[b_dim1 + 2]; |
| 12316 |
*xnorm = temp * bnorm; |
| 12317 |
*info = 1; |
| 12318 |
return 0; |
| 12319 |
} |
| 12320 |
|
| 12321 |
/* Gaussian elimination with complete pivoting. */ |
| 12322 |
|
| 12323 |
ur11 = crv[icmax - 1]; |
| 12324 |
cr21 = crv[ipivot[(icmax << 2) - 3] - 1]; |
| 12325 |
ur12 = crv[ipivot[(icmax << 2) - 2] - 1]; |
| 12326 |
cr22 = crv[ipivot[(icmax << 2) - 1] - 1]; |
| 12327 |
ur11r = 1. / ur11; |
| 12328 |
lr21 = ur11r * cr21; |
| 12329 |
ur22 = cr22 - ur12 * lr21; |
| 12330 |
|
| 12331 |
/* If smaller pivot < SMINI, use SMINI */ |
| 12332 |
|
| 12333 |
if (abs(ur22) < smini) { |
| 12334 |
ur22 = smini; |
| 12335 |
*info = 1; |
| 12336 |
} |
| 12337 |
if (rswap[icmax - 1]) { |
| 12338 |
br1 = b[b_dim1 + 2]; |
| 12339 |
br2 = b[b_dim1 + 1]; |
| 12340 |
} else { |
| 12341 |
br1 = b[b_dim1 + 1]; |
| 12342 |
br2 = b[b_dim1 + 2]; |
| 12343 |
} |
| 12344 |
br2 -= lr21 * br1; |
| 12345 |
/* Computing MAX */ |
| 12346 |
d__2 = (d__1 = br1 * (ur22 * ur11r), abs(d__1)), d__3 = abs(br2); |
| 12347 |
bbnd = std::max(d__2,d__3); |
| 12348 |
if (bbnd > 1. && abs(ur22) < 1.) { |
| 12349 |
if (bbnd >= bignum * abs(ur22)) { |
| 12350 |
*scale = 1. / bbnd; |
| 12351 |
} |
| 12352 |
} |
| 12353 |
|
| 12354 |
xr2 = br2 * *scale / ur22; |
| 12355 |
xr1 = *scale * br1 * ur11r - xr2 * (ur11r * ur12); |
| 12356 |
if (zswap[icmax - 1]) { |
| 12357 |
x[x_dim1 + 1] = xr2; |
| 12358 |
x[x_dim1 + 2] = xr1; |
| 12359 |
} else { |
| 12360 |
x[x_dim1 + 1] = xr1; |
| 12361 |
x[x_dim1 + 2] = xr2; |
| 12362 |
} |
| 12363 |
/* Computing MAX */ |
| 12364 |
d__1 = abs(xr1), d__2 = abs(xr2); |
| 12365 |
*xnorm = std::max(d__1,d__2); |
| 12366 |
|
| 12367 |
/* Further scaling if norm(A) norm(X) > overflow */ |
| 12368 |
|
| 12369 |
if (*xnorm > 1. && cmax > 1.) { |
| 12370 |
if (*xnorm > bignum / cmax) { |
| 12371 |
temp = cmax / bignum; |
| 12372 |
x[x_dim1 + 1] = temp * x[x_dim1 + 1]; |
| 12373 |
x[x_dim1 + 2] = temp * x[x_dim1 + 2]; |
| 12374 |
*xnorm = temp * *xnorm; |
| 12375 |
*scale = temp * *scale; |
| 12376 |
} |
| 12377 |
} |
| 12378 |
} else { |
| 12379 |
|
| 12380 |
/* Complex 2x2 system (w is complex) */ |
| 12381 |
|
| 12382 |
/* Find the largest element in C */ |
| 12383 |
|
| 12384 |
ci[0] = -(*wi) * *d1; |
| 12385 |
ci[1] = 0.; |
| 12386 |
ci[2] = 0.; |
| 12387 |
ci[3] = -(*wi) * *d2; |
| 12388 |
cmax = 0.; |
| 12389 |
icmax = 0; |
| 12390 |
|
| 12391 |
for (j = 1; j <= 4; ++j) { |
| 12392 |
if ((d__1 = crv[j - 1], abs(d__1)) + (d__2 = civ[j - 1], abs( |
| 12393 |
d__2)) > cmax) { |
| 12394 |
cmax = (d__1 = crv[j - 1], abs(d__1)) + (d__2 = civ[j - 1] |
| 12395 |
, abs(d__2)); |
| 12396 |
icmax = j; |
| 12397 |
} |
| 12398 |
/* L20: */ |
| 12399 |
} |
| 12400 |
|
| 12401 |
/* If norm(C) < SMINI, use SMINI*identity. */ |
| 12402 |
|
| 12403 |
if (cmax < smini) { |
| 12404 |
/* Computing MAX */ |
| 12405 |
d__5 = (d__1 = b[b_dim1 + 1], abs(d__1)) + (d__2 = b[(b_dim1 |
| 12406 |
<< 1) + 1], abs(d__2)), d__6 = (d__3 = b[b_dim1 + 2], |
| 12407 |
abs(d__3)) + (d__4 = b[(b_dim1 << 1) + 2], abs(d__4)); |
| 12408 |
bnorm = std::max(d__5,d__6); |
| 12409 |
if (smini < 1. && bnorm > 1.) { |
| 12410 |
if (bnorm > bignum * smini) { |
| 12411 |
*scale = 1. / bnorm; |
| 12412 |
} |
| 12413 |
} |
| 12414 |
temp = *scale / smini; |
| 12415 |
x[x_dim1 + 1] = temp * b[b_dim1 + 1]; |
| 12416 |
x[x_dim1 + 2] = temp * b[b_dim1 + 2]; |
| 12417 |
x[(x_dim1 << 1) + 1] = temp * b[(b_dim1 << 1) + 1]; |
| 12418 |
x[(x_dim1 << 1) + 2] = temp * b[(b_dim1 << 1) + 2]; |
| 12419 |
*xnorm = temp * bnorm; |
| 12420 |
*info = 1; |
| 12421 |
return 0; |
| 12422 |
} |
| 12423 |
|
| 12424 |
/* Gaussian elimination with complete pivoting. */ |
| 12425 |
|
| 12426 |
ur11 = crv[icmax - 1]; |
| 12427 |
ui11 = civ[icmax - 1]; |
| 12428 |
cr21 = crv[ipivot[(icmax << 2) - 3] - 1]; |
| 12429 |
ci21 = civ[ipivot[(icmax << 2) - 3] - 1]; |
| 12430 |
ur12 = crv[ipivot[(icmax << 2) - 2] - 1]; |
| 12431 |
ui12 = civ[ipivot[(icmax << 2) - 2] - 1]; |
| 12432 |
cr22 = crv[ipivot[(icmax << 2) - 1] - 1]; |
| 12433 |
ci22 = civ[ipivot[(icmax << 2) - 1] - 1]; |
| 12434 |
if (icmax == 1 || icmax == 4) { |
| 12435 |
|
| 12436 |
/* Code when off-diagonals of pivoted C are real */ |
| 12437 |
|
| 12438 |
if (abs(ur11) > abs(ui11)) { |
| 12439 |
temp = ui11 / ur11; |
| 12440 |
/* Computing 2nd power */ |
| 12441 |
d__1 = temp; |
| 12442 |
ur11r = 1. / (ur11 * (d__1 * d__1 + 1.)); |
| 12443 |
ui11r = -temp * ur11r; |
| 12444 |
} else { |
| 12445 |
temp = ur11 / ui11; |
| 12446 |
/* Computing 2nd power */ |
| 12447 |
d__1 = temp; |
| 12448 |
ui11r = -1. / (ui11 * (d__1 * d__1 + 1.)); |
| 12449 |
ur11r = -temp * ui11r; |
| 12450 |
} |
| 12451 |
lr21 = cr21 * ur11r; |
| 12452 |
li21 = cr21 * ui11r; |
| 12453 |
ur12s = ur12 * ur11r; |
| 12454 |
ui12s = ur12 * ui11r; |
| 12455 |
ur22 = cr22 - ur12 * lr21; |
| 12456 |
ui22 = ci22 - ur12 * li21; |
| 12457 |
} else { |
| 12458 |
|
| 12459 |
/* Code when diagonals of pivoted C are real */ |
| 12460 |
|
| 12461 |
ur11r = 1. / ur11; |
| 12462 |
ui11r = 0.; |
| 12463 |
lr21 = cr21 * ur11r; |
| 12464 |
li21 = ci21 * ur11r; |
| 12465 |
ur12s = ur12 * ur11r; |
| 12466 |
ui12s = ui12 * ur11r; |
| 12467 |
ur22 = cr22 - ur12 * lr21 + ui12 * li21; |
| 12468 |
ui22 = -ur12 * li21 - ui12 * lr21; |
| 12469 |
} |
| 12470 |
u22abs = abs(ur22) + abs(ui22); |
| 12471 |
|
| 12472 |
/* If smaller pivot < SMINI, use SMINI */ |
| 12473 |
|
| 12474 |
if (u22abs < smini) { |
| 12475 |
ur22 = smini; |
| 12476 |
ui22 = 0.; |
| 12477 |
*info = 1; |
| 12478 |
} |
| 12479 |
if (rswap[icmax - 1]) { |
| 12480 |
br2 = b[b_dim1 + 1]; |
| 12481 |
br1 = b[b_dim1 + 2]; |
| 12482 |
bi2 = b[(b_dim1 << 1) + 1]; |
| 12483 |
bi1 = b[(b_dim1 << 1) + 2]; |
| 12484 |
} else { |
| 12485 |
br1 = b[b_dim1 + 1]; |
| 12486 |
br2 = b[b_dim1 + 2]; |
| 12487 |
bi1 = b[(b_dim1 << 1) + 1]; |
| 12488 |
bi2 = b[(b_dim1 << 1) + 2]; |
| 12489 |
} |
| 12490 |
br2 = br2 - lr21 * br1 + li21 * bi1; |
| 12491 |
bi2 = bi2 - li21 * br1 - lr21 * bi1; |
| 12492 |
/* Computing MAX */ |
| 12493 |
d__1 = (abs(br1) + abs(bi1)) * (u22abs * (abs(ur11r) + abs(ui11r)) |
| 12494 |
), d__2 = abs(br2) + abs(bi2); |
| 12495 |
bbnd = std::max(d__1,d__2); |
| 12496 |
if (bbnd > 1. && u22abs < 1.) { |
| 12497 |
if (bbnd >= bignum * u22abs) { |
| 12498 |
*scale = 1. / bbnd; |
| 12499 |
br1 = *scale * br1; |
| 12500 |
bi1 = *scale * bi1; |
| 12501 |
br2 = *scale * br2; |
| 12502 |
bi2 = *scale * bi2; |
| 12503 |
} |
| 12504 |
} |
| 12505 |
|
| 12506 |
dladiv_(&br2, &bi2, &ur22, &ui22, &xr2, &xi2); |
| 12507 |
xr1 = ur11r * br1 - ui11r * bi1 - ur12s * xr2 + ui12s * xi2; |
| 12508 |
xi1 = ui11r * br1 + ur11r * bi1 - ui12s * xr2 - ur12s * xi2; |
| 12509 |
if (zswap[icmax - 1]) { |
| 12510 |
x[x_dim1 + 1] = xr2; |
| 12511 |
x[x_dim1 + 2] = xr1; |
| 12512 |
x[(x_dim1 << 1) + 1] = xi2; |
| 12513 |
x[(x_dim1 << 1) + 2] = xi1; |
| 12514 |
} else { |
| 12515 |
x[x_dim1 + 1] = xr1; |
| 12516 |
x[x_dim1 + 2] = xr2; |
| 12517 |
x[(x_dim1 << 1) + 1] = xi1; |
| 12518 |
x[(x_dim1 << 1) + 2] = xi2; |
| 12519 |
} |
| 12520 |
/* Computing MAX */ |
| 12521 |
d__1 = abs(xr1) + abs(xi1), d__2 = abs(xr2) + abs(xi2); |
| 12522 |
*xnorm = std::max(d__1,d__2); |
| 12523 |
|
| 12524 |
/* Further scaling if norm(A) norm(X) > overflow */ |
| 12525 |
|
| 12526 |
if (*xnorm > 1. && cmax > 1.) { |
| 12527 |
if (*xnorm > bignum / cmax) { |
| 12528 |
temp = cmax / bignum; |
| 12529 |
x[x_dim1 + 1] = temp * x[x_dim1 + 1]; |
| 12530 |
x[x_dim1 + 2] = temp * x[x_dim1 + 2]; |
| 12531 |
x[(x_dim1 << 1) + 1] = temp * x[(x_dim1 << 1) + 1]; |
| 12532 |
x[(x_dim1 << 1) + 2] = temp * x[(x_dim1 << 1) + 2]; |
| 12533 |
*xnorm = temp * *xnorm; |
| 12534 |
*scale = temp * *scale; |
| 12535 |
} |
| 12536 |
} |
| 12537 |
} |
| 12538 |
} |
| 12539 |
|
| 12540 |
return 0; |
| 12541 |
|
| 12542 |
/* End of DLALN2 */ |
| 12543 |
|
| 12544 |
} /* dlaln2_ */ |
| 12545 |
|
| 12546 |
#undef crv |
| 12547 |
#undef civ |
| 12548 |
#undef cr |
| 12549 |
#undef ci |
| 12550 |
|
| 12551 |
/* Subroutine */ int dlals0_(integer *icompq, integer *nl, integer *nr, |
| 12552 |
integer *sqre, integer *nrhs, double *b, integer *ldb, double |
| 12553 |
*bx, integer *ldbx, integer *perm, integer *givptr, integer *givcol, |
| 12554 |
integer *ldgcol, double *givnum, integer *ldgnum, double * |
| 12555 |
poles, double *difl, double *difr, double *z__, integer * |
| 12556 |
k, double *c__, double *s, double *work, integer *info) |
| 12557 |
{ |
| 12558 |
/* Table of constant values */ |
| 12559 |
static double c_b5 = -1.; |
| 12560 |
static integer c__1 = 1; |
| 12561 |
static double c_b11 = 1.; |
| 12562 |
static double c_b13 = 0.; |
| 12563 |
static integer c__0 = 0; |
| 12564 |
|
| 12565 |
/* System generated locals */ |
| 12566 |
integer givcol_dim1, givcol_offset, b_dim1, b_offset, bx_dim1, bx_offset, |
| 12567 |
difr_dim1, difr_offset, givnum_dim1, givnum_offset, poles_dim1, |
| 12568 |
poles_offset, i__1, i__2; |
| 12569 |
double d__1; |
| 12570 |
|
| 12571 |
/* Local variables */ |
| 12572 |
integer i__, j, m, n; |
| 12573 |
double dj; |
| 12574 |
integer nlp1; |
| 12575 |
double temp; |
| 12576 |
double diflj, difrj, dsigj; |
| 12577 |
double dsigjp; |
| 12578 |
|
| 12579 |
|
| 12580 |
/* -- LAPACK routine (version 3.1) -- */ |
| 12581 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 12582 |
/* November 2006 */ |
| 12583 |
|
| 12584 |
/* .. Scalar Arguments .. */ |
| 12585 |
/* .. */ |
| 12586 |
/* .. Array Arguments .. */ |
| 12587 |
/* .. */ |
| 12588 |
|
| 12589 |
/* Purpose */ |
| 12590 |
/* ======= */ |
| 12591 |
|
| 12592 |
/* DLALS0 applies back the multiplying factors of either the left or the */ |
| 12593 |
/* right singular vector matrix of a diagonal matrix appended by a row */ |
| 12594 |
/* to the right hand side matrix B in solving the least squares problem */ |
| 12595 |
/* using the divide-and-conquer SVD approach. */ |
| 12596 |
|
| 12597 |
/* For the left singular vector matrix, three types of orthogonal */ |
| 12598 |
/* matrices are involved: */ |
| 12599 |
|
| 12600 |
/* (1L) Givens rotations: the number of such rotations is GIVPTR; the */ |
| 12601 |
/* pairs of columns/rows they were applied to are stored in GIVCOL; */ |
| 12602 |
/* and the C- and S-values of these rotations are stored in GIVNUM. */ |
| 12603 |
|
| 12604 |
/* (2L) Permutation. The (NL+1)-st row of B is to be moved to the first */ |
| 12605 |
/* row, and for J=2:N, PERM(J)-th row of B is to be moved to the */ |
| 12606 |
/* J-th row. */ |
| 12607 |
|
| 12608 |
/* (3L) The left singular vector matrix of the remaining matrix. */ |
| 12609 |
|
| 12610 |
/* For the right singular vector matrix, four types of orthogonal */ |
| 12611 |
/* matrices are involved: */ |
| 12612 |
|
| 12613 |
/* (1R) The right singular vector matrix of the remaining matrix. */ |
| 12614 |
|
| 12615 |
/* (2R) If SQRE = 1, one extra Givens rotation to generate the right */ |
| 12616 |
/* null space. */ |
| 12617 |
|
| 12618 |
/* (3R) The inverse transformation of (2L). */ |
| 12619 |
|
| 12620 |
/* (4R) The inverse transformation of (1L). */ |
| 12621 |
|
| 12622 |
/* Arguments */ |
| 12623 |
/* ========= */ |
| 12624 |
|
| 12625 |
/* ICOMPQ (input) INTEGER */ |
| 12626 |
/* Specifies whether singular vectors are to be computed in */ |
| 12627 |
/* factored form: */ |
| 12628 |
/* = 0: Left singular vector matrix. */ |
| 12629 |
/* = 1: Right singular vector matrix. */ |
| 12630 |
|
| 12631 |
/* NL (input) INTEGER */ |
| 12632 |
/* The row dimension of the upper block. NL >= 1. */ |
| 12633 |
|
| 12634 |
/* NR (input) INTEGER */ |
| 12635 |
/* The row dimension of the lower block. NR >= 1. */ |
| 12636 |
|
| 12637 |
/* SQRE (input) INTEGER */ |
| 12638 |
/* = 0: the lower block is an NR-by-NR square matrix. */ |
| 12639 |
/* = 1: the lower block is an NR-by-(NR+1) rectangular matrix. */ |
| 12640 |
|
| 12641 |
/* The bidiagonal matrix has row dimension N = NL + NR + 1, */ |
| 12642 |
/* and column dimension M = N + SQRE. */ |
| 12643 |
|
| 12644 |
/* NRHS (input) INTEGER */ |
| 12645 |
/* The number of columns of B and BX. NRHS must be at least 1. */ |
| 12646 |
|
| 12647 |
/* B (input/output) DOUBLE PRECISION array, dimension ( LDB, NRHS ) */ |
| 12648 |
/* On input, B contains the right hand sides of the least */ |
| 12649 |
/* squares problem in rows 1 through M. On output, B contains */ |
| 12650 |
/* the solution X in rows 1 through N. */ |
| 12651 |
|
| 12652 |
/* LDB (input) INTEGER */ |
| 12653 |
/* The leading dimension of B. LDB must be at least */ |
| 12654 |
/* max(1,MAX( M, N ) ). */ |
| 12655 |
|
| 12656 |
/* BX (workspace) DOUBLE PRECISION array, dimension ( LDBX, NRHS ) */ |
| 12657 |
|
| 12658 |
/* LDBX (input) INTEGER */ |
| 12659 |
/* The leading dimension of BX. */ |
| 12660 |
|
| 12661 |
/* PERM (input) INTEGER array, dimension ( N ) */ |
| 12662 |
/* The permutations (from deflation and sorting) applied */ |
| 12663 |
/* to the two blocks. */ |
| 12664 |
|
| 12665 |
/* GIVPTR (input) INTEGER */ |
| 12666 |
/* The number of Givens rotations which took place in this */ |
| 12667 |
/* subproblem. */ |
| 12668 |
|
| 12669 |
/* GIVCOL (input) INTEGER array, dimension ( LDGCOL, 2 ) */ |
| 12670 |
/* Each pair of numbers indicates a pair of rows/columns */ |
| 12671 |
/* involved in a Givens rotation. */ |
| 12672 |
|
| 12673 |
/* LDGCOL (input) INTEGER */ |
| 12674 |
/* The leading dimension of GIVCOL, must be at least N. */ |
| 12675 |
|
| 12676 |
/* GIVNUM (input) DOUBLE PRECISION array, dimension ( LDGNUM, 2 ) */ |
| 12677 |
/* Each number indicates the C or S value used in the */ |
| 12678 |
/* corresponding Givens rotation. */ |
| 12679 |
|
| 12680 |
/* LDGNUM (input) INTEGER */ |
| 12681 |
/* The leading dimension of arrays DIFR, POLES and */ |
| 12682 |
/* GIVNUM, must be at least K. */ |
| 12683 |
|
| 12684 |
/* POLES (input) DOUBLE PRECISION array, dimension ( LDGNUM, 2 ) */ |
| 12685 |
/* On entry, POLES(1:K, 1) contains the new singular */ |
| 12686 |
/* values obtained from solving the secular equation, and */ |
| 12687 |
/* POLES(1:K, 2) is an array containing the poles in the secular */ |
| 12688 |
/* equation. */ |
| 12689 |
|
| 12690 |
/* DIFL (input) DOUBLE PRECISION array, dimension ( K ). */ |
| 12691 |
/* On entry, DIFL(I) is the distance between I-th updated */ |
| 12692 |
/* (undeflated) singular value and the I-th (undeflated) old */ |
| 12693 |
/* singular value. */ |
| 12694 |
|
| 12695 |
/* DIFR (input) DOUBLE PRECISION array, dimension ( LDGNUM, 2 ). */ |
| 12696 |
/* On entry, DIFR(I, 1) contains the distances between I-th */ |
| 12697 |
/* updated (undeflated) singular value and the I+1-th */ |
| 12698 |
/* (undeflated) old singular value. And DIFR(I, 2) is the */ |
| 12699 |
/* normalizing factor for the I-th right singular vector. */ |
| 12700 |
|
| 12701 |
/* Z (input) DOUBLE PRECISION array, dimension ( K ) */ |
| 12702 |
/* Contain the components of the deflation-adjusted updating row */ |
| 12703 |
/* vector. */ |
| 12704 |
|
| 12705 |
/* K (input) INTEGER */ |
| 12706 |
/* Contains the dimension of the non-deflated matrix, */ |
| 12707 |
/* This is the order of the related secular equation. 1 <= K <=N. */ |
| 12708 |
|
| 12709 |
/* C (input) DOUBLE PRECISION */ |
| 12710 |
/* C contains garbage if SQRE =0 and the C-value of a Givens */ |
| 12711 |
/* rotation related to the right null space if SQRE = 1. */ |
| 12712 |
|
| 12713 |
/* S (input) DOUBLE PRECISION */ |
| 12714 |
/* S contains garbage if SQRE =0 and the S-value of a Givens */ |
| 12715 |
/* rotation related to the right null space if SQRE = 1. */ |
| 12716 |
|
| 12717 |
/* WORK (workspace) DOUBLE PRECISION array, dimension ( K ) */ |
| 12718 |
|
| 12719 |
/* INFO (output) INTEGER */ |
| 12720 |
/* = 0: successful exit. */ |
| 12721 |
/* < 0: if INFO = -i, the i-th argument had an illegal value. */ |
| 12722 |
|
| 12723 |
/* Further Details */ |
| 12724 |
/* =============== */ |
| 12725 |
|
| 12726 |
/* Based on contributions by */ |
| 12727 |
/* Ming Gu and Ren-Cang Li, Computer Science Division, University of */ |
| 12728 |
/* California at Berkeley, USA */ |
| 12729 |
/* Osni Marques, LBNL/NERSC, USA */ |
| 12730 |
|
| 12731 |
/* ===================================================================== */ |
| 12732 |
|
| 12733 |
/* .. Parameters .. */ |
| 12734 |
/* .. */ |
| 12735 |
/* .. Local Scalars .. */ |
| 12736 |
/* .. */ |
| 12737 |
/* .. External Subroutines .. */ |
| 12738 |
/* .. */ |
| 12739 |
/* .. External Functions .. */ |
| 12740 |
/* .. */ |
| 12741 |
/* .. Intrinsic Functions .. */ |
| 12742 |
/* .. */ |
| 12743 |
/* .. Executable Statements .. */ |
| 12744 |
|
| 12745 |
/* Test the input parameters. */ |
| 12746 |
|
| 12747 |
/* Parameter adjustments */ |
| 12748 |
b_dim1 = *ldb; |
| 12749 |
b_offset = 1 + b_dim1; |
| 12750 |
b -= b_offset; |
| 12751 |
bx_dim1 = *ldbx; |
| 12752 |
bx_offset = 1 + bx_dim1; |
| 12753 |
bx -= bx_offset; |
| 12754 |
--perm; |
| 12755 |
givcol_dim1 = *ldgcol; |
| 12756 |
givcol_offset = 1 + givcol_dim1; |
| 12757 |
givcol -= givcol_offset; |
| 12758 |
difr_dim1 = *ldgnum; |
| 12759 |
difr_offset = 1 + difr_dim1; |
| 12760 |
difr -= difr_offset; |
| 12761 |
poles_dim1 = *ldgnum; |
| 12762 |
poles_offset = 1 + poles_dim1; |
| 12763 |
poles -= poles_offset; |
| 12764 |
givnum_dim1 = *ldgnum; |
| 12765 |
givnum_offset = 1 + givnum_dim1; |
| 12766 |
givnum -= givnum_offset; |
| 12767 |
--difl; |
| 12768 |
--z__; |
| 12769 |
--work; |
| 12770 |
|
| 12771 |
/* Function Body */ |
| 12772 |
*info = 0; |
| 12773 |
|
| 12774 |
if (*icompq < 0 || *icompq > 1) { |
| 12775 |
*info = -1; |
| 12776 |
} else if (*nl < 1) { |
| 12777 |
*info = -2; |
| 12778 |
} else if (*nr < 1) { |
| 12779 |
*info = -3; |
| 12780 |
} else if (*sqre < 0 || *sqre > 1) { |
| 12781 |
*info = -4; |
| 12782 |
} |
| 12783 |
|
| 12784 |
n = *nl + *nr + 1; |
| 12785 |
|
| 12786 |
if (*nrhs < 1) { |
| 12787 |
*info = -5; |
| 12788 |
} else if (*ldb < n) { |
| 12789 |
*info = -7; |
| 12790 |
} else if (*ldbx < n) { |
| 12791 |
*info = -9; |
| 12792 |
} else if (*givptr < 0) { |
| 12793 |
*info = -11; |
| 12794 |
} else if (*ldgcol < n) { |
| 12795 |
*info = -13; |
| 12796 |
} else if (*ldgnum < n) { |
| 12797 |
*info = -15; |
| 12798 |
} else if (*k < 1) { |
| 12799 |
*info = -20; |
| 12800 |
} |
| 12801 |
if (*info != 0) { |
| 12802 |
i__1 = -(*info); |
| 12803 |
xerbla_("DLALS0", &i__1); |
| 12804 |
return 0; |
| 12805 |
} |
| 12806 |
|
| 12807 |
m = n + *sqre; |
| 12808 |
nlp1 = *nl + 1; |
| 12809 |
|
| 12810 |
if (*icompq == 0) { |
| 12811 |
|
| 12812 |
/* Apply back orthogonal transformations from the left. */ |
| 12813 |
|
| 12814 |
/* Step (1L): apply back the Givens rotations performed. */ |
| 12815 |
|
| 12816 |
i__1 = *givptr; |
| 12817 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 12818 |
drot_(nrhs, &b[givcol[i__ + (givcol_dim1 << 1)] + b_dim1], ldb, & |
| 12819 |
b[givcol[i__ + givcol_dim1] + b_dim1], ldb, &givnum[i__ + |
| 12820 |
(givnum_dim1 << 1)], &givnum[i__ + givnum_dim1]); |
| 12821 |
/* L10: */ |
| 12822 |
} |
| 12823 |
|
| 12824 |
/* Step (2L): permute rows of B. */ |
| 12825 |
|
| 12826 |
dcopy_(nrhs, &b[nlp1 + b_dim1], ldb, &bx[bx_dim1 + 1], ldbx); |
| 12827 |
i__1 = n; |
| 12828 |
for (i__ = 2; i__ <= i__1; ++i__) { |
| 12829 |
dcopy_(nrhs, &b[perm[i__] + b_dim1], ldb, &bx[i__ + bx_dim1], |
| 12830 |
ldbx); |
| 12831 |
/* L20: */ |
| 12832 |
} |
| 12833 |
|
| 12834 |
/* Step (3L): apply the inverse of the left singular vector */ |
| 12835 |
/* matrix to BX. */ |
| 12836 |
|
| 12837 |
if (*k == 1) { |
| 12838 |
dcopy_(nrhs, &bx[bx_offset], ldbx, &b[b_offset], ldb); |
| 12839 |
if (z__[1] < 0.) { |
| 12840 |
dscal_(nrhs, &c_b5, &b[b_offset], ldb); |
| 12841 |
} |
| 12842 |
} else { |
| 12843 |
i__1 = *k; |
| 12844 |
for (j = 1; j <= i__1; ++j) { |
| 12845 |
diflj = difl[j]; |
| 12846 |
dj = poles[j + poles_dim1]; |
| 12847 |
dsigj = -poles[j + (poles_dim1 << 1)]; |
| 12848 |
if (j < *k) { |
| 12849 |
difrj = -difr[j + difr_dim1]; |
| 12850 |
dsigjp = -poles[j + 1 + (poles_dim1 << 1)]; |
| 12851 |
} |
| 12852 |
if (z__[j] == 0. || poles[j + (poles_dim1 << 1)] == 0.) { |
| 12853 |
work[j] = 0.; |
| 12854 |
} else { |
| 12855 |
work[j] = -poles[j + (poles_dim1 << 1)] * z__[j] / diflj / |
| 12856 |
(poles[j + (poles_dim1 << 1)] + dj); |
| 12857 |
} |
| 12858 |
i__2 = j - 1; |
| 12859 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 12860 |
if (z__[i__] == 0. || poles[i__ + (poles_dim1 << 1)] == |
| 12861 |
0.) { |
| 12862 |
work[i__] = 0.; |
| 12863 |
} else { |
| 12864 |
work[i__] = poles[i__ + (poles_dim1 << 1)] * z__[i__] |
| 12865 |
/ (dlamc3_(&poles[i__ + (poles_dim1 << 1)], & |
| 12866 |
dsigj) - diflj) / (poles[i__ + (poles_dim1 << |
| 12867 |
1)] + dj); |
| 12868 |
} |
| 12869 |
/* L30: */ |
| 12870 |
} |
| 12871 |
i__2 = *k; |
| 12872 |
for (i__ = j + 1; i__ <= i__2; ++i__) { |
| 12873 |
if (z__[i__] == 0. || poles[i__ + (poles_dim1 << 1)] == |
| 12874 |
0.) { |
| 12875 |
work[i__] = 0.; |
| 12876 |
} else { |
| 12877 |
work[i__] = poles[i__ + (poles_dim1 << 1)] * z__[i__] |
| 12878 |
/ (dlamc3_(&poles[i__ + (poles_dim1 << 1)], & |
| 12879 |
dsigjp) + difrj) / (poles[i__ + (poles_dim1 << |
| 12880 |
1)] + dj); |
| 12881 |
} |
| 12882 |
/* L40: */ |
| 12883 |
} |
| 12884 |
work[1] = -1.; |
| 12885 |
temp = dnrm2_(k, &work[1], &c__1); |
| 12886 |
dgemv_("T", k, nrhs, &c_b11, &bx[bx_offset], ldbx, &work[1], & |
| 12887 |
c__1, &c_b13, &b[j + b_dim1], ldb); |
| 12888 |
dlascl_("G", &c__0, &c__0, &temp, &c_b11, &c__1, nrhs, &b[j + |
| 12889 |
b_dim1], ldb, info); |
| 12890 |
/* L50: */ |
| 12891 |
} |
| 12892 |
} |
| 12893 |
|
| 12894 |
/* Move the deflated rows of BX to B also. */ |
| 12895 |
|
| 12896 |
if (*k < std::max(m,n)) { |
| 12897 |
i__1 = n - *k; |
| 12898 |
dlacpy_("A", &i__1, nrhs, &bx[*k + 1 + bx_dim1], ldbx, &b[*k + 1 |
| 12899 |
+ b_dim1], ldb); |
| 12900 |
} |
| 12901 |
} else { |
| 12902 |
|
| 12903 |
/* Apply back the right orthogonal transformations. */ |
| 12904 |
|
| 12905 |
/* Step (1R): apply back the new right singular vector matrix */ |
| 12906 |
/* to B. */ |
| 12907 |
|
| 12908 |
if (*k == 1) { |
| 12909 |
dcopy_(nrhs, &b[b_offset], ldb, &bx[bx_offset], ldbx); |
| 12910 |
} else { |
| 12911 |
i__1 = *k; |
| 12912 |
for (j = 1; j <= i__1; ++j) { |
| 12913 |
dsigj = poles[j + (poles_dim1 << 1)]; |
| 12914 |
if (z__[j] == 0.) { |
| 12915 |
work[j] = 0.; |
| 12916 |
} else { |
| 12917 |
work[j] = -z__[j] / difl[j] / (dsigj + poles[j + |
| 12918 |
poles_dim1]) / difr[j + (difr_dim1 << 1)]; |
| 12919 |
} |
| 12920 |
i__2 = j - 1; |
| 12921 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 12922 |
if (z__[j] == 0.) { |
| 12923 |
work[i__] = 0.; |
| 12924 |
} else { |
| 12925 |
d__1 = -poles[i__ + 1 + (poles_dim1 << 1)]; |
| 12926 |
work[i__] = z__[j] / (dlamc3_(&dsigj, &d__1) - difr[ |
| 12927 |
i__ + difr_dim1]) / (dsigj + poles[i__ + |
| 12928 |
poles_dim1]) / difr[i__ + (difr_dim1 << 1)]; |
| 12929 |
} |
| 12930 |
/* L60: */ |
| 12931 |
} |
| 12932 |
i__2 = *k; |
| 12933 |
for (i__ = j + 1; i__ <= i__2; ++i__) { |
| 12934 |
if (z__[j] == 0.) { |
| 12935 |
work[i__] = 0.; |
| 12936 |
} else { |
| 12937 |
d__1 = -poles[i__ + (poles_dim1 << 1)]; |
| 12938 |
work[i__] = z__[j] / (dlamc3_(&dsigj, &d__1) - difl[ |
| 12939 |
i__]) / (dsigj + poles[i__ + poles_dim1]) / |
| 12940 |
difr[i__ + (difr_dim1 << 1)]; |
| 12941 |
} |
| 12942 |
/* L70: */ |
| 12943 |
} |
| 12944 |
dgemv_("T", k, nrhs, &c_b11, &b[b_offset], ldb, &work[1], & |
| 12945 |
c__1, &c_b13, &bx[j + bx_dim1], ldbx); |
| 12946 |
/* L80: */ |
| 12947 |
} |
| 12948 |
} |
| 12949 |
|
| 12950 |
/* Step (2R): if SQRE = 1, apply back the rotation that is */ |
| 12951 |
/* related to the right null space of the subproblem. */ |
| 12952 |
|
| 12953 |
if (*sqre == 1) { |
| 12954 |
dcopy_(nrhs, &b[m + b_dim1], ldb, &bx[m + bx_dim1], ldbx); |
| 12955 |
drot_(nrhs, &bx[bx_dim1 + 1], ldbx, &bx[m + bx_dim1], ldbx, c__, |
| 12956 |
s); |
| 12957 |
} |
| 12958 |
if (*k < std::max(m,n)) { |
| 12959 |
i__1 = n - *k; |
| 12960 |
dlacpy_("A", &i__1, nrhs, &b[*k + 1 + b_dim1], ldb, &bx[*k + 1 + |
| 12961 |
bx_dim1], ldbx); |
| 12962 |
} |
| 12963 |
|
| 12964 |
/* Step (3R): permute rows of B. */ |
| 12965 |
|
| 12966 |
dcopy_(nrhs, &bx[bx_dim1 + 1], ldbx, &b[nlp1 + b_dim1], ldb); |
| 12967 |
if (*sqre == 1) { |
| 12968 |
dcopy_(nrhs, &bx[m + bx_dim1], ldbx, &b[m + b_dim1], ldb); |
| 12969 |
} |
| 12970 |
i__1 = n; |
| 12971 |
for (i__ = 2; i__ <= i__1; ++i__) { |
| 12972 |
dcopy_(nrhs, &bx[i__ + bx_dim1], ldbx, &b[perm[i__] + b_dim1], |
| 12973 |
ldb); |
| 12974 |
/* L90: */ |
| 12975 |
} |
| 12976 |
|
| 12977 |
/* Step (4R): apply back the Givens rotations performed. */ |
| 12978 |
|
| 12979 |
for (i__ = *givptr; i__ >= 1; --i__) { |
| 12980 |
d__1 = -givnum[i__ + givnum_dim1]; |
| 12981 |
drot_(nrhs, &b[givcol[i__ + (givcol_dim1 << 1)] + b_dim1], ldb, & |
| 12982 |
b[givcol[i__ + givcol_dim1] + b_dim1], ldb, &givnum[i__ + |
| 12983 |
(givnum_dim1 << 1)], &d__1); |
| 12984 |
/* L100: */ |
| 12985 |
} |
| 12986 |
} |
| 12987 |
|
| 12988 |
return 0; |
| 12989 |
|
| 12990 |
/* End of DLALS0 */ |
| 12991 |
|
| 12992 |
} /* dlals0_ */ |
| 12993 |
|
| 12994 |
/* Subroutine */ int dlalsa_(integer *icompq, integer *smlsiz, integer *n, |
| 12995 |
integer *nrhs, double *b, integer *ldb, double *bx, integer * |
| 12996 |
ldbx, double *u, integer *ldu, double *vt, integer *k, |
| 12997 |
double *difl, double *difr, double *z__, double * |
| 12998 |
poles, integer *givptr, integer *givcol, integer *ldgcol, integer * |
| 12999 |
perm, double *givnum, double *c__, double *s, double * |
| 13000 |
work, integer *iwork, integer *info) |
| 13001 |
{ |
| 13002 |
/* Table of constant values */ |
| 13003 |
static double c_b7 = 1.; |
| 13004 |
static double c_b8 = 0.; |
| 13005 |
static integer c__2 = 2; |
| 13006 |
|
| 13007 |
/* System generated locals */ |
| 13008 |
integer givcol_dim1, givcol_offset, perm_dim1, perm_offset, b_dim1, |
| 13009 |
b_offset, bx_dim1, bx_offset, difl_dim1, difl_offset, difr_dim1, |
| 13010 |
difr_offset, givnum_dim1, givnum_offset, poles_dim1, poles_offset, |
| 13011 |
u_dim1, u_offset, vt_dim1, vt_offset, z_dim1, z_offset, i__1, |
| 13012 |
i__2; |
| 13013 |
|
| 13014 |
/* Local variables */ |
| 13015 |
integer i__, j, i1, ic, lf, nd, ll, nl, nr, im1, nlf, nrf, lvl, ndb1, |
| 13016 |
nlp1, lvl2, nrp1, nlvl, sqre; |
| 13017 |
integer inode, ndiml, ndimr; |
| 13018 |
|
| 13019 |
|
| 13020 |
/* -- LAPACK routine (version 3.1) -- */ |
| 13021 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 13022 |
/* November 2006 */ |
| 13023 |
|
| 13024 |
/* .. Scalar Arguments .. */ |
| 13025 |
/* .. */ |
| 13026 |
/* .. Array Arguments .. */ |
| 13027 |
/* .. */ |
| 13028 |
|
| 13029 |
/* Purpose */ |
| 13030 |
/* ======= */ |
| 13031 |
|
| 13032 |
/* DLALSA is an itermediate step in solving the least squares problem */ |
| 13033 |
/* by computing the SVD of the coefficient matrix in compact form (The */ |
| 13034 |
/* singular vectors are computed as products of simple orthorgonal */ |
| 13035 |
/* matrices.). */ |
| 13036 |
|
| 13037 |
/* If ICOMPQ = 0, DLALSA applies the inverse of the left singular vector */ |
| 13038 |
/* matrix of an upper bidiagonal matrix to the right hand side; and if */ |
| 13039 |
/* ICOMPQ = 1, DLALSA applies the right singular vector matrix to the */ |
| 13040 |
/* right hand side. The singular vector matrices were generated in */ |
| 13041 |
/* compact form by DLALSA. */ |
| 13042 |
|
| 13043 |
/* Arguments */ |
| 13044 |
/* ========= */ |
| 13045 |
|
| 13046 |
|
| 13047 |
/* ICOMPQ (input) INTEGER */ |
| 13048 |
/* Specifies whether the left or the right singular vector */ |
| 13049 |
/* matrix is involved. */ |
| 13050 |
/* = 0: Left singular vector matrix */ |
| 13051 |
/* = 1: Right singular vector matrix */ |
| 13052 |
|
| 13053 |
/* SMLSIZ (input) INTEGER */ |
| 13054 |
/* The maximum size of the subproblems at the bottom of the */ |
| 13055 |
/* computation tree. */ |
| 13056 |
|
| 13057 |
/* N (input) INTEGER */ |
| 13058 |
/* The row and column dimensions of the upper bidiagonal matrix. */ |
| 13059 |
|
| 13060 |
/* NRHS (input) INTEGER */ |
| 13061 |
/* The number of columns of B and BX. NRHS must be at least 1. */ |
| 13062 |
|
| 13063 |
/* B (input/output) DOUBLE PRECISION array, dimension ( LDB, NRHS ) */ |
| 13064 |
/* On input, B contains the right hand sides of the least */ |
| 13065 |
/* squares problem in rows 1 through M. */ |
| 13066 |
/* On output, B contains the solution X in rows 1 through N. */ |
| 13067 |
|
| 13068 |
/* LDB (input) INTEGER */ |
| 13069 |
/* The leading dimension of B in the calling subprogram. */ |
| 13070 |
/* LDB must be at least max(1,MAX( M, N ) ). */ |
| 13071 |
|
| 13072 |
/* BX (output) DOUBLE PRECISION array, dimension ( LDBX, NRHS ) */ |
| 13073 |
/* On exit, the result of applying the left or right singular */ |
| 13074 |
/* vector matrix to B. */ |
| 13075 |
|
| 13076 |
/* LDBX (input) INTEGER */ |
| 13077 |
/* The leading dimension of BX. */ |
| 13078 |
|
| 13079 |
/* U (input) DOUBLE PRECISION array, dimension ( LDU, SMLSIZ ). */ |
| 13080 |
/* On entry, U contains the left singular vector matrices of all */ |
| 13081 |
/* subproblems at the bottom level. */ |
| 13082 |
|
| 13083 |
/* LDU (input) INTEGER, LDU = > N. */ |
| 13084 |
/* The leading dimension of arrays U, VT, DIFL, DIFR, */ |
| 13085 |
/* POLES, GIVNUM, and Z. */ |
| 13086 |
|
| 13087 |
/* VT (input) DOUBLE PRECISION array, dimension ( LDU, SMLSIZ+1 ). */ |
| 13088 |
/* On entry, VT' contains the right singular vector matrices of */ |
| 13089 |
/* all subproblems at the bottom level. */ |
| 13090 |
|
| 13091 |
/* K (input) INTEGER array, dimension ( N ). */ |
| 13092 |
|
| 13093 |
/* DIFL (input) DOUBLE PRECISION array, dimension ( LDU, NLVL ). */ |
| 13094 |
/* where NLVL = INT(log_2 (N/(SMLSIZ+1))) + 1. */ |
| 13095 |
|
| 13096 |
/* DIFR (input) DOUBLE PRECISION array, dimension ( LDU, 2 * NLVL ). */ |
| 13097 |
/* On entry, DIFL(*, I) and DIFR(*, 2 * I -1) record */ |
| 13098 |
/* distances between singular values on the I-th level and */ |
| 13099 |
/* singular values on the (I -1)-th level, and DIFR(*, 2 * I) */ |
| 13100 |
/* record the normalizing factors of the right singular vectors */ |
| 13101 |
/* matrices of subproblems on I-th level. */ |
| 13102 |
|
| 13103 |
/* Z (input) DOUBLE PRECISION array, dimension ( LDU, NLVL ). */ |
| 13104 |
/* On entry, Z(1, I) contains the components of the deflation- */ |
| 13105 |
/* adjusted updating row vector for subproblems on the I-th */ |
| 13106 |
/* level. */ |
| 13107 |
|
| 13108 |
/* POLES (input) DOUBLE PRECISION array, dimension ( LDU, 2 * NLVL ). */ |
| 13109 |
/* On entry, POLES(*, 2 * I -1: 2 * I) contains the new and old */ |
| 13110 |
/* singular values involved in the secular equations on the I-th */ |
| 13111 |
/* level. */ |
| 13112 |
|
| 13113 |
/* GIVPTR (input) INTEGER array, dimension ( N ). */ |
| 13114 |
/* On entry, GIVPTR( I ) records the number of Givens */ |
| 13115 |
/* rotations performed on the I-th problem on the computation */ |
| 13116 |
/* tree. */ |
| 13117 |
|
| 13118 |
/* GIVCOL (input) INTEGER array, dimension ( LDGCOL, 2 * NLVL ). */ |
| 13119 |
/* On entry, for each I, GIVCOL(*, 2 * I - 1: 2 * I) records the */ |
| 13120 |
/* locations of Givens rotations performed on the I-th level on */ |
| 13121 |
/* the computation tree. */ |
| 13122 |
|
| 13123 |
/* LDGCOL (input) INTEGER, LDGCOL = > N. */ |
| 13124 |
/* The leading dimension of arrays GIVCOL and PERM. */ |
| 13125 |
|
| 13126 |
/* PERM (input) INTEGER array, dimension ( LDGCOL, NLVL ). */ |
| 13127 |
/* On entry, PERM(*, I) records permutations done on the I-th */ |
| 13128 |
/* level of the computation tree. */ |
| 13129 |
|
| 13130 |
/* GIVNUM (input) DOUBLE PRECISION array, dimension ( LDU, 2 * NLVL ). */ |
| 13131 |
/* On entry, GIVNUM(*, 2 *I -1 : 2 * I) records the C- and S- */ |
| 13132 |
/* values of Givens rotations performed on the I-th level on the */ |
| 13133 |
/* computation tree. */ |
| 13134 |
|
| 13135 |
/* C (input) DOUBLE PRECISION array, dimension ( N ). */ |
| 13136 |
/* On entry, if the I-th subproblem is not square, */ |
| 13137 |
/* C( I ) contains the C-value of a Givens rotation related to */ |
| 13138 |
/* the right null space of the I-th subproblem. */ |
| 13139 |
|
| 13140 |
/* S (input) DOUBLE PRECISION array, dimension ( N ). */ |
| 13141 |
/* On entry, if the I-th subproblem is not square, */ |
| 13142 |
/* S( I ) contains the S-value of a Givens rotation related to */ |
| 13143 |
/* the right null space of the I-th subproblem. */ |
| 13144 |
|
| 13145 |
/* WORK (workspace) DOUBLE PRECISION array. */ |
| 13146 |
/* The dimension must be at least N. */ |
| 13147 |
|
| 13148 |
/* IWORK (workspace) INTEGER array. */ |
| 13149 |
/* The dimension must be at least 3 * N */ |
| 13150 |
|
| 13151 |
/* INFO (output) INTEGER */ |
| 13152 |
/* = 0: successful exit. */ |
| 13153 |
/* < 0: if INFO = -i, the i-th argument had an illegal value. */ |
| 13154 |
|
| 13155 |
/* Further Details */ |
| 13156 |
/* =============== */ |
| 13157 |
|
| 13158 |
/* Based on contributions by */ |
| 13159 |
/* Ming Gu and Ren-Cang Li, Computer Science Division, University of */ |
| 13160 |
/* California at Berkeley, USA */ |
| 13161 |
/* Osni Marques, LBNL/NERSC, USA */ |
| 13162 |
|
| 13163 |
/* ===================================================================== */ |
| 13164 |
|
| 13165 |
/* .. Parameters .. */ |
| 13166 |
/* .. */ |
| 13167 |
/* .. Local Scalars .. */ |
| 13168 |
/* .. */ |
| 13169 |
/* .. External Subroutines .. */ |
| 13170 |
/* .. */ |
| 13171 |
/* .. Executable Statements .. */ |
| 13172 |
|
| 13173 |
/* Test the input parameters. */ |
| 13174 |
|
| 13175 |
/* Parameter adjustments */ |
| 13176 |
b_dim1 = *ldb; |
| 13177 |
b_offset = 1 + b_dim1; |
| 13178 |
b -= b_offset; |
| 13179 |
bx_dim1 = *ldbx; |
| 13180 |
bx_offset = 1 + bx_dim1; |
| 13181 |
bx -= bx_offset; |
| 13182 |
givnum_dim1 = *ldu; |
| 13183 |
givnum_offset = 1 + givnum_dim1; |
| 13184 |
givnum -= givnum_offset; |
| 13185 |
poles_dim1 = *ldu; |
| 13186 |
poles_offset = 1 + poles_dim1; |
| 13187 |
poles -= poles_offset; |
| 13188 |
z_dim1 = *ldu; |
| 13189 |
z_offset = 1 + z_dim1; |
| 13190 |
z__ -= z_offset; |
| 13191 |
difr_dim1 = *ldu; |
| 13192 |
difr_offset = 1 + difr_dim1; |
| 13193 |
difr -= difr_offset; |
| 13194 |
difl_dim1 = *ldu; |
| 13195 |
difl_offset = 1 + difl_dim1; |
| 13196 |
difl -= difl_offset; |
| 13197 |
vt_dim1 = *ldu; |
| 13198 |
vt_offset = 1 + vt_dim1; |
| 13199 |
vt -= vt_offset; |
| 13200 |
u_dim1 = *ldu; |
| 13201 |
u_offset = 1 + u_dim1; |
| 13202 |
u -= u_offset; |
| 13203 |
--k; |
| 13204 |
--givptr; |
| 13205 |
perm_dim1 = *ldgcol; |
| 13206 |
perm_offset = 1 + perm_dim1; |
| 13207 |
perm -= perm_offset; |
| 13208 |
givcol_dim1 = *ldgcol; |
| 13209 |
givcol_offset = 1 + givcol_dim1; |
| 13210 |
givcol -= givcol_offset; |
| 13211 |
--c__; |
| 13212 |
--s; |
| 13213 |
--work; |
| 13214 |
--iwork; |
| 13215 |
|
| 13216 |
/* Function Body */ |
| 13217 |
*info = 0; |
| 13218 |
|
| 13219 |
if (*icompq < 0 || *icompq > 1) { |
| 13220 |
*info = -1; |
| 13221 |
} else if (*smlsiz < 3) { |
| 13222 |
*info = -2; |
| 13223 |
} else if (*n < *smlsiz) { |
| 13224 |
*info = -3; |
| 13225 |
} else if (*nrhs < 1) { |
| 13226 |
*info = -4; |
| 13227 |
} else if (*ldb < *n) { |
| 13228 |
*info = -6; |
| 13229 |
} else if (*ldbx < *n) { |
| 13230 |
*info = -8; |
| 13231 |
} else if (*ldu < *n) { |
| 13232 |
*info = -10; |
| 13233 |
} else if (*ldgcol < *n) { |
| 13234 |
*info = -19; |
| 13235 |
} |
| 13236 |
if (*info != 0) { |
| 13237 |
i__1 = -(*info); |
| 13238 |
xerbla_("DLALSA", &i__1); |
| 13239 |
return 0; |
| 13240 |
} |
| 13241 |
|
| 13242 |
/* Book-keeping and setting up the computation tree. */ |
| 13243 |
|
| 13244 |
inode = 1; |
| 13245 |
ndiml = inode + *n; |
| 13246 |
ndimr = ndiml + *n; |
| 13247 |
|
| 13248 |
dlasdt_(n, &nlvl, &nd, &iwork[inode], &iwork[ndiml], &iwork[ndimr], |
| 13249 |
smlsiz); |
| 13250 |
|
| 13251 |
/* The following code applies back the left singular vector factors. */ |
| 13252 |
/* For applying back the right singular vector factors, go to 50. */ |
| 13253 |
|
| 13254 |
if (*icompq == 1) { |
| 13255 |
goto L50; |
| 13256 |
} |
| 13257 |
|
| 13258 |
/* The nodes on the bottom level of the tree were solved */ |
| 13259 |
/* by DLASDQ. The corresponding left and right singular vector */ |
| 13260 |
/* matrices are in explicit form. First apply back the left */ |
| 13261 |
/* singular vector matrices. */ |
| 13262 |
|
| 13263 |
ndb1 = (nd + 1) / 2; |
| 13264 |
i__1 = nd; |
| 13265 |
for (i__ = ndb1; i__ <= i__1; ++i__) { |
| 13266 |
|
| 13267 |
/* IC : center row of each node */ |
| 13268 |
/* NL : number of rows of left subproblem */ |
| 13269 |
/* NR : number of rows of right subproblem */ |
| 13270 |
/* NLF: starting row of the left subproblem */ |
| 13271 |
/* NRF: starting row of the right subproblem */ |
| 13272 |
|
| 13273 |
i1 = i__ - 1; |
| 13274 |
ic = iwork[inode + i1]; |
| 13275 |
nl = iwork[ndiml + i1]; |
| 13276 |
nr = iwork[ndimr + i1]; |
| 13277 |
nlf = ic - nl; |
| 13278 |
nrf = ic + 1; |
| 13279 |
dgemm_("T", "N", &nl, nrhs, &nl, &c_b7, &u[nlf + u_dim1], ldu, &b[nlf |
| 13280 |
+ b_dim1], ldb, &c_b8, &bx[nlf + bx_dim1], ldbx); |
| 13281 |
dgemm_("T", "N", &nr, nrhs, &nr, &c_b7, &u[nrf + u_dim1], ldu, &b[nrf |
| 13282 |
+ b_dim1], ldb, &c_b8, &bx[nrf + bx_dim1], ldbx); |
| 13283 |
/* L10: */ |
| 13284 |
} |
| 13285 |
|
| 13286 |
/* Next copy the rows of B that correspond to unchanged rows */ |
| 13287 |
/* in the bidiagonal matrix to BX. */ |
| 13288 |
|
| 13289 |
i__1 = nd; |
| 13290 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 13291 |
ic = iwork[inode + i__ - 1]; |
| 13292 |
dcopy_(nrhs, &b[ic + b_dim1], ldb, &bx[ic + bx_dim1], ldbx); |
| 13293 |
/* L20: */ |
| 13294 |
} |
| 13295 |
|
| 13296 |
/* Finally go through the left singular vector matrices of all */ |
| 13297 |
/* the other subproblems bottom-up on the tree. */ |
| 13298 |
|
| 13299 |
j = pow_ii(&c__2, &nlvl); |
| 13300 |
sqre = 0; |
| 13301 |
|
| 13302 |
for (lvl = nlvl; lvl >= 1; --lvl) { |
| 13303 |
lvl2 = (lvl << 1) - 1; |
| 13304 |
|
| 13305 |
/* find the first node LF and last node LL on */ |
| 13306 |
/* the current level LVL */ |
| 13307 |
|
| 13308 |
if (lvl == 1) { |
| 13309 |
lf = 1; |
| 13310 |
ll = 1; |
| 13311 |
} else { |
| 13312 |
i__1 = lvl - 1; |
| 13313 |
lf = pow_ii(&c__2, &i__1); |
| 13314 |
ll = (lf << 1) - 1; |
| 13315 |
} |
| 13316 |
i__1 = ll; |
| 13317 |
for (i__ = lf; i__ <= i__1; ++i__) { |
| 13318 |
im1 = i__ - 1; |
| 13319 |
ic = iwork[inode + im1]; |
| 13320 |
nl = iwork[ndiml + im1]; |
| 13321 |
nr = iwork[ndimr + im1]; |
| 13322 |
nlf = ic - nl; |
| 13323 |
nrf = ic + 1; |
| 13324 |
--j; |
| 13325 |
dlals0_(icompq, &nl, &nr, &sqre, nrhs, &bx[nlf + bx_dim1], ldbx, & |
| 13326 |
b[nlf + b_dim1], ldb, &perm[nlf + lvl * perm_dim1], & |
| 13327 |
givptr[j], &givcol[nlf + lvl2 * givcol_dim1], ldgcol, & |
| 13328 |
givnum[nlf + lvl2 * givnum_dim1], ldu, &poles[nlf + lvl2 * |
| 13329 |
poles_dim1], &difl[nlf + lvl * difl_dim1], &difr[nlf + |
| 13330 |
lvl2 * difr_dim1], &z__[nlf + lvl * z_dim1], &k[j], &c__[ |
| 13331 |
j], &s[j], &work[1], info); |
| 13332 |
/* L30: */ |
| 13333 |
} |
| 13334 |
/* L40: */ |
| 13335 |
} |
| 13336 |
goto L90; |
| 13337 |
|
| 13338 |
/* ICOMPQ = 1: applying back the right singular vector factors. */ |
| 13339 |
|
| 13340 |
L50: |
| 13341 |
|
| 13342 |
/* First now go through the right singular vector matrices of all */ |
| 13343 |
/* the tree nodes top-down. */ |
| 13344 |
|
| 13345 |
j = 0; |
| 13346 |
i__1 = nlvl; |
| 13347 |
for (lvl = 1; lvl <= i__1; ++lvl) { |
| 13348 |
lvl2 = (lvl << 1) - 1; |
| 13349 |
|
| 13350 |
/* Find the first node LF and last node LL on */ |
| 13351 |
/* the current level LVL. */ |
| 13352 |
|
| 13353 |
if (lvl == 1) { |
| 13354 |
lf = 1; |
| 13355 |
ll = 1; |
| 13356 |
} else { |
| 13357 |
i__2 = lvl - 1; |
| 13358 |
lf = pow_ii(&c__2, &i__2); |
| 13359 |
ll = (lf << 1) - 1; |
| 13360 |
} |
| 13361 |
i__2 = lf; |
| 13362 |
for (i__ = ll; i__ >= i__2; --i__) { |
| 13363 |
im1 = i__ - 1; |
| 13364 |
ic = iwork[inode + im1]; |
| 13365 |
nl = iwork[ndiml + im1]; |
| 13366 |
nr = iwork[ndimr + im1]; |
| 13367 |
nlf = ic - nl; |
| 13368 |
nrf = ic + 1; |
| 13369 |
if (i__ == ll) { |
| 13370 |
sqre = 0; |
| 13371 |
} else { |
| 13372 |
sqre = 1; |
| 13373 |
} |
| 13374 |
++j; |
| 13375 |
dlals0_(icompq, &nl, &nr, &sqre, nrhs, &b[nlf + b_dim1], ldb, &bx[ |
| 13376 |
nlf + bx_dim1], ldbx, &perm[nlf + lvl * perm_dim1], & |
| 13377 |
givptr[j], &givcol[nlf + lvl2 * givcol_dim1], ldgcol, & |
| 13378 |
givnum[nlf + lvl2 * givnum_dim1], ldu, &poles[nlf + lvl2 * |
| 13379 |
poles_dim1], &difl[nlf + lvl * difl_dim1], &difr[nlf + |
| 13380 |
lvl2 * difr_dim1], &z__[nlf + lvl * z_dim1], &k[j], &c__[ |
| 13381 |
j], &s[j], &work[1], info); |
| 13382 |
/* L60: */ |
| 13383 |
} |
| 13384 |
/* L70: */ |
| 13385 |
} |
| 13386 |
|
| 13387 |
/* The nodes on the bottom level of the tree were solved */ |
| 13388 |
/* by DLASDQ. The corresponding right singular vector */ |
| 13389 |
/* matrices are in explicit form. Apply them back. */ |
| 13390 |
|
| 13391 |
ndb1 = (nd + 1) / 2; |
| 13392 |
i__1 = nd; |
| 13393 |
for (i__ = ndb1; i__ <= i__1; ++i__) { |
| 13394 |
i1 = i__ - 1; |
| 13395 |
ic = iwork[inode + i1]; |
| 13396 |
nl = iwork[ndiml + i1]; |
| 13397 |
nr = iwork[ndimr + i1]; |
| 13398 |
nlp1 = nl + 1; |
| 13399 |
if (i__ == nd) { |
| 13400 |
nrp1 = nr; |
| 13401 |
} else { |
| 13402 |
nrp1 = nr + 1; |
| 13403 |
} |
| 13404 |
nlf = ic - nl; |
| 13405 |
nrf = ic + 1; |
| 13406 |
dgemm_("T", "N", &nlp1, nrhs, &nlp1, &c_b7, &vt[nlf + vt_dim1], ldu, & |
| 13407 |
b[nlf + b_dim1], ldb, &c_b8, &bx[nlf + bx_dim1], ldbx); |
| 13408 |
dgemm_("T", "N", &nrp1, nrhs, &nrp1, &c_b7, &vt[nrf + vt_dim1], ldu, & |
| 13409 |
b[nrf + b_dim1], ldb, &c_b8, &bx[nrf + bx_dim1], ldbx); |
| 13410 |
/* L80: */ |
| 13411 |
} |
| 13412 |
|
| 13413 |
L90: |
| 13414 |
|
| 13415 |
return 0; |
| 13416 |
|
| 13417 |
/* End of DLALSA */ |
| 13418 |
|
| 13419 |
} /* dlalsa_ */ |
| 13420 |
|
| 13421 |
/* Subroutine */ int dlalsd_(const char *uplo, integer *smlsiz, integer *n, integer |
| 13422 |
*nrhs, double *d__, double *e, double *b, integer *ldb, |
| 13423 |
double *rcond, integer *rank, double *work, integer *iwork, |
| 13424 |
integer *info) |
| 13425 |
{ |
| 13426 |
/* Table of constant values */ |
| 13427 |
static integer c__1 = 1; |
| 13428 |
static double c_b6 = 0.; |
| 13429 |
static integer c__0 = 0; |
| 13430 |
static double c_b11 = 1.; |
| 13431 |
|
| 13432 |
/* System generated locals */ |
| 13433 |
integer b_dim1, b_offset, i__1, i__2; |
| 13434 |
double d__1; |
| 13435 |
|
| 13436 |
/* Local variables */ |
| 13437 |
integer c__, i__, j, k; |
| 13438 |
double r__; |
| 13439 |
integer s, u, z__; |
| 13440 |
double cs; |
| 13441 |
integer bx; |
| 13442 |
double sn; |
| 13443 |
integer st, vt, nm1, st1; |
| 13444 |
double eps; |
| 13445 |
integer iwk; |
| 13446 |
double tol; |
| 13447 |
integer difl, difr; |
| 13448 |
double rcnd; |
| 13449 |
integer perm, nsub; |
| 13450 |
integer nlvl, sqre, bxst; |
| 13451 |
integer poles, sizei, nsize, nwork, icmpq1, icmpq2; |
| 13452 |
integer givcol; |
| 13453 |
double orgnrm; |
| 13454 |
integer givnum, givptr, smlszp; |
| 13455 |
|
| 13456 |
|
| 13457 |
/* -- LAPACK routine (version 3.1) -- */ |
| 13458 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 13459 |
/* November 2006 */ |
| 13460 |
|
| 13461 |
/* .. Scalar Arguments .. */ |
| 13462 |
/* .. */ |
| 13463 |
/* .. Array Arguments .. */ |
| 13464 |
/* .. */ |
| 13465 |
|
| 13466 |
/* Purpose */ |
| 13467 |
/* ======= */ |
| 13468 |
|
| 13469 |
/* DLALSD uses the singular value decomposition of A to solve the least */ |
| 13470 |
/* squares problem of finding X to minimize the Euclidean norm of each */ |
| 13471 |
/* column of A*X-B, where A is N-by-N upper bidiagonal, and X and B */ |
| 13472 |
/* are N-by-NRHS. The solution X overwrites B. */ |
| 13473 |
|
| 13474 |
/* The singular values of A smaller than RCOND times the largest */ |
| 13475 |
/* singular value are treated as zero in solving the least squares */ |
| 13476 |
/* problem; in this case a minimum norm solution is returned. */ |
| 13477 |
/* The actual singular values are returned in D in ascending order. */ |
| 13478 |
|
| 13479 |
/* This code makes very mild assumptions about floating point */ |
| 13480 |
/* arithmetic. It will work on machines with a guard digit in */ |
| 13481 |
/* add/subtract, or on those binary machines without guard digits */ |
| 13482 |
/* which subtract like the Cray XMP, Cray YMP, Cray C 90, or Cray 2. */ |
| 13483 |
/* It could conceivably fail on hexadecimal or decimal machines */ |
| 13484 |
/* without guard digits, but we know of none. */ |
| 13485 |
|
| 13486 |
/* Arguments */ |
| 13487 |
/* ========= */ |
| 13488 |
|
| 13489 |
/* UPLO (input) CHARACTER*1 */ |
| 13490 |
/* = 'U': D and E define an upper bidiagonal matrix. */ |
| 13491 |
/* = 'L': D and E define a lower bidiagonal matrix. */ |
| 13492 |
|
| 13493 |
/* SMLSIZ (input) INTEGER */ |
| 13494 |
/* The maximum size of the subproblems at the bottom of the */ |
| 13495 |
/* computation tree. */ |
| 13496 |
|
| 13497 |
/* N (input) INTEGER */ |
| 13498 |
/* The dimension of the bidiagonal matrix. N >= 0. */ |
| 13499 |
|
| 13500 |
/* NRHS (input) INTEGER */ |
| 13501 |
/* The number of columns of B. NRHS must be at least 1. */ |
| 13502 |
|
| 13503 |
/* D (input/output) DOUBLE PRECISION array, dimension (N) */ |
| 13504 |
/* On entry D contains the main diagonal of the bidiagonal */ |
| 13505 |
/* matrix. On exit, if INFO = 0, D contains its singular values. */ |
| 13506 |
|
| 13507 |
/* E (input/output) DOUBLE PRECISION array, dimension (N-1) */ |
| 13508 |
/* Contains the super-diagonal entries of the bidiagonal matrix. */ |
| 13509 |
/* On exit, E has been destroyed. */ |
| 13510 |
|
| 13511 |
/* B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */ |
| 13512 |
/* On input, B contains the right hand sides of the least */ |
| 13513 |
/* squares problem. On output, B contains the solution X. */ |
| 13514 |
|
| 13515 |
/* LDB (input) INTEGER */ |
| 13516 |
/* The leading dimension of B in the calling subprogram. */ |
| 13517 |
/* LDB must be at least max(1,N). */ |
| 13518 |
|
| 13519 |
/* RCOND (input) DOUBLE PRECISION */ |
| 13520 |
/* The singular values of A less than or equal to RCOND times */ |
| 13521 |
/* the largest singular value are treated as zero in solving */ |
| 13522 |
/* the least squares problem. If RCOND is negative, */ |
| 13523 |
/* machine precision is used instead. */ |
| 13524 |
/* For example, if diag(S)*X=B were the least squares problem, */ |
| 13525 |
/* where diag(S) is a diagonal matrix of singular values, the */ |
| 13526 |
/* solution would be X(i) = B(i) / S(i) if S(i) is greater than */ |
| 13527 |
/* RCOND*max(S), and X(i) = 0 if S(i) is less than or equal to */ |
| 13528 |
/* RCOND*max(S). */ |
| 13529 |
|
| 13530 |
/* RANK (output) INTEGER */ |
| 13531 |
/* The number of singular values of A greater than RCOND times */ |
| 13532 |
/* the largest singular value. */ |
| 13533 |
|
| 13534 |
/* WORK (workspace) DOUBLE PRECISION array, dimension at least */ |
| 13535 |
/* (9*N + 2*N*SMLSIZ + 8*N*NLVL + N*NRHS + (SMLSIZ+1)**2), */ |
| 13536 |
/* where NLVL = max(0, INT(log_2 (N/(SMLSIZ+1))) + 1). */ |
| 13537 |
|
| 13538 |
/* IWORK (workspace) INTEGER array, dimension at least */ |
| 13539 |
/* (3*N*NLVL + 11*N) */ |
| 13540 |
|
| 13541 |
/* INFO (output) INTEGER */ |
| 13542 |
/* = 0: successful exit. */ |
| 13543 |
/* < 0: if INFO = -i, the i-th argument had an illegal value. */ |
| 13544 |
/* > 0: The algorithm failed to compute an singular value while */ |
| 13545 |
/* working on the submatrix lying in rows and columns */ |
| 13546 |
/* INFO/(N+1) through MOD(INFO,N+1). */ |
| 13547 |
|
| 13548 |
/* Further Details */ |
| 13549 |
/* =============== */ |
| 13550 |
|
| 13551 |
/* Based on contributions by */ |
| 13552 |
/* Ming Gu and Ren-Cang Li, Computer Science Division, University of */ |
| 13553 |
/* California at Berkeley, USA */ |
| 13554 |
/* Osni Marques, LBNL/NERSC, USA */ |
| 13555 |
|
| 13556 |
/* ===================================================================== */ |
| 13557 |
|
| 13558 |
/* .. Parameters .. */ |
| 13559 |
/* .. */ |
| 13560 |
/* .. Local Scalars .. */ |
| 13561 |
/* .. */ |
| 13562 |
/* .. External Functions .. */ |
| 13563 |
/* .. */ |
| 13564 |
/* .. External Subroutines .. */ |
| 13565 |
/* .. */ |
| 13566 |
/* .. Intrinsic Functions .. */ |
| 13567 |
/* .. */ |
| 13568 |
/* .. Executable Statements .. */ |
| 13569 |
|
| 13570 |
/* Test the input parameters. */ |
| 13571 |
|
| 13572 |
/* Parameter adjustments */ |
| 13573 |
--d__; |
| 13574 |
--e; |
| 13575 |
b_dim1 = *ldb; |
| 13576 |
b_offset = 1 + b_dim1; |
| 13577 |
b -= b_offset; |
| 13578 |
--work; |
| 13579 |
--iwork; |
| 13580 |
|
| 13581 |
/* Function Body */ |
| 13582 |
*info = 0; |
| 13583 |
|
| 13584 |
if (*n < 0) { |
| 13585 |
*info = -3; |
| 13586 |
} else if (*nrhs < 1) { |
| 13587 |
*info = -4; |
| 13588 |
} else if (*ldb < 1 || *ldb < *n) { |
| 13589 |
*info = -8; |
| 13590 |
} |
| 13591 |
if (*info != 0) { |
| 13592 |
i__1 = -(*info); |
| 13593 |
xerbla_("DLALSD", &i__1); |
| 13594 |
return 0; |
| 13595 |
} |
| 13596 |
|
| 13597 |
eps = dlamch_("Epsilon"); |
| 13598 |
|
| 13599 |
/* Set up the tolerance. */ |
| 13600 |
|
| 13601 |
if (*rcond <= 0. || *rcond >= 1.) { |
| 13602 |
rcnd = eps; |
| 13603 |
} else { |
| 13604 |
rcnd = *rcond; |
| 13605 |
} |
| 13606 |
|
| 13607 |
*rank = 0; |
| 13608 |
|
| 13609 |
/* Quick return if possible. */ |
| 13610 |
|
| 13611 |
if (*n == 0) { |
| 13612 |
return 0; |
| 13613 |
} else if (*n == 1) { |
| 13614 |
if (d__[1] == 0.) { |
| 13615 |
dlaset_("A", &c__1, nrhs, &c_b6, &c_b6, &b[b_offset], ldb); |
| 13616 |
} else { |
| 13617 |
*rank = 1; |
| 13618 |
dlascl_("G", &c__0, &c__0, &d__[1], &c_b11, &c__1, nrhs, &b[ |
| 13619 |
b_offset], ldb, info); |
| 13620 |
d__[1] = abs(d__[1]); |
| 13621 |
} |
| 13622 |
return 0; |
| 13623 |
} |
| 13624 |
|
| 13625 |
/* Rotate the matrix if it is lower bidiagonal. */ |
| 13626 |
|
| 13627 |
if (*(unsigned char *)uplo == 'L') { |
| 13628 |
i__1 = *n - 1; |
| 13629 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 13630 |
dlartg_(&d__[i__], &e[i__], &cs, &sn, &r__); |
| 13631 |
d__[i__] = r__; |
| 13632 |
e[i__] = sn * d__[i__ + 1]; |
| 13633 |
d__[i__ + 1] = cs * d__[i__ + 1]; |
| 13634 |
if (*nrhs == 1) { |
| 13635 |
drot_(&c__1, &b[i__ + b_dim1], &c__1, &b[i__ + 1 + b_dim1], & |
| 13636 |
c__1, &cs, &sn); |
| 13637 |
} else { |
| 13638 |
work[(i__ << 1) - 1] = cs; |
| 13639 |
work[i__ * 2] = sn; |
| 13640 |
} |
| 13641 |
/* L10: */ |
| 13642 |
} |
| 13643 |
if (*nrhs > 1) { |
| 13644 |
i__1 = *nrhs; |
| 13645 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 13646 |
i__2 = *n - 1; |
| 13647 |
for (j = 1; j <= i__2; ++j) { |
| 13648 |
cs = work[(j << 1) - 1]; |
| 13649 |
sn = work[j * 2]; |
| 13650 |
drot_(&c__1, &b[j + i__ * b_dim1], &c__1, &b[j + 1 + i__ * |
| 13651 |
b_dim1], &c__1, &cs, &sn); |
| 13652 |
/* L20: */ |
| 13653 |
} |
| 13654 |
/* L30: */ |
| 13655 |
} |
| 13656 |
} |
| 13657 |
} |
| 13658 |
|
| 13659 |
/* Scale. */ |
| 13660 |
|
| 13661 |
nm1 = *n - 1; |
| 13662 |
orgnrm = dlanst_("M", n, &d__[1], &e[1]); |
| 13663 |
if (orgnrm == 0.) { |
| 13664 |
dlaset_("A", n, nrhs, &c_b6, &c_b6, &b[b_offset], ldb); |
| 13665 |
return 0; |
| 13666 |
} |
| 13667 |
|
| 13668 |
dlascl_("G", &c__0, &c__0, &orgnrm, &c_b11, n, &c__1, &d__[1], n, info); |
| 13669 |
dlascl_("G", &c__0, &c__0, &orgnrm, &c_b11, &nm1, &c__1, &e[1], &nm1, |
| 13670 |
info); |
| 13671 |
|
| 13672 |
/* If N is smaller than the minimum divide size SMLSIZ, then solve */ |
| 13673 |
/* the problem with another solver. */ |
| 13674 |
|
| 13675 |
if (*n <= *smlsiz) { |
| 13676 |
nwork = *n * *n + 1; |
| 13677 |
dlaset_("A", n, n, &c_b6, &c_b11, &work[1], n); |
| 13678 |
dlasdq_("U", &c__0, n, n, &c__0, nrhs, &d__[1], &e[1], &work[1], n, & |
| 13679 |
work[1], n, &b[b_offset], ldb, &work[nwork], info); |
| 13680 |
if (*info != 0) { |
| 13681 |
return 0; |
| 13682 |
} |
| 13683 |
tol = rcnd * (d__1 = d__[idamax_(n, &d__[1], &c__1)], abs(d__1)); |
| 13684 |
i__1 = *n; |
| 13685 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 13686 |
if (d__[i__] <= tol) { |
| 13687 |
dlaset_("A", &c__1, nrhs, &c_b6, &c_b6, &b[i__ + b_dim1], ldb); |
| 13688 |
} else { |
| 13689 |
dlascl_("G", &c__0, &c__0, &d__[i__], &c_b11, &c__1, nrhs, &b[ |
| 13690 |
i__ + b_dim1], ldb, info); |
| 13691 |
++(*rank); |
| 13692 |
} |
| 13693 |
/* L40: */ |
| 13694 |
} |
| 13695 |
dgemm_("T", "N", n, nrhs, n, &c_b11, &work[1], n, &b[b_offset], ldb, & |
| 13696 |
c_b6, &work[nwork], n); |
| 13697 |
dlacpy_("A", n, nrhs, &work[nwork], n, &b[b_offset], ldb); |
| 13698 |
|
| 13699 |
/* Unscale. */ |
| 13700 |
|
| 13701 |
dlascl_("G", &c__0, &c__0, &c_b11, &orgnrm, n, &c__1, &d__[1], n, |
| 13702 |
info); |
| 13703 |
dlasrt_("D", n, &d__[1], info); |
| 13704 |
dlascl_("G", &c__0, &c__0, &orgnrm, &c_b11, n, nrhs, &b[b_offset], |
| 13705 |
ldb, info); |
| 13706 |
|
| 13707 |
return 0; |
| 13708 |
} |
| 13709 |
|
| 13710 |
/* Book-keeping and setting up some constants. */ |
| 13711 |
|
| 13712 |
nlvl = (integer) (log((double) (*n) / (double) (*smlsiz + 1)) / |
| 13713 |
log(2.)) + 1; |
| 13714 |
|
| 13715 |
smlszp = *smlsiz + 1; |
| 13716 |
|
| 13717 |
u = 1; |
| 13718 |
vt = *smlsiz * *n + 1; |
| 13719 |
difl = vt + smlszp * *n; |
| 13720 |
difr = difl + nlvl * *n; |
| 13721 |
z__ = difr + (nlvl * *n << 1); |
| 13722 |
c__ = z__ + nlvl * *n; |
| 13723 |
s = c__ + *n; |
| 13724 |
poles = s + *n; |
| 13725 |
givnum = poles + (nlvl << 1) * *n; |
| 13726 |
bx = givnum + (nlvl << 1) * *n; |
| 13727 |
nwork = bx + *n * *nrhs; |
| 13728 |
|
| 13729 |
sizei = *n + 1; |
| 13730 |
k = sizei + *n; |
| 13731 |
givptr = k + *n; |
| 13732 |
perm = givptr + *n; |
| 13733 |
givcol = perm + nlvl * *n; |
| 13734 |
iwk = givcol + (nlvl * *n << 1); |
| 13735 |
|
| 13736 |
st = 1; |
| 13737 |
sqre = 0; |
| 13738 |
icmpq1 = 1; |
| 13739 |
icmpq2 = 0; |
| 13740 |
nsub = 0; |
| 13741 |
|
| 13742 |
i__1 = *n; |
| 13743 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 13744 |
if ((d__1 = d__[i__], abs(d__1)) < eps) { |
| 13745 |
d__[i__] = d_sign(&eps, &d__[i__]); |
| 13746 |
} |
| 13747 |
/* L50: */ |
| 13748 |
} |
| 13749 |
|
| 13750 |
i__1 = nm1; |
| 13751 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 13752 |
if ((d__1 = e[i__], abs(d__1)) < eps || i__ == nm1) { |
| 13753 |
++nsub; |
| 13754 |
iwork[nsub] = st; |
| 13755 |
|
| 13756 |
/* Subproblem found. First determine its size and then */ |
| 13757 |
/* apply divide and conquer on it. */ |
| 13758 |
|
| 13759 |
if (i__ < nm1) { |
| 13760 |
|
| 13761 |
/* A subproblem with E(I) small for I < NM1. */ |
| 13762 |
|
| 13763 |
nsize = i__ - st + 1; |
| 13764 |
iwork[sizei + nsub - 1] = nsize; |
| 13765 |
} else if ((d__1 = e[i__], abs(d__1)) >= eps) { |
| 13766 |
|
| 13767 |
/* A subproblem with E(NM1) not too small but I = NM1. */ |
| 13768 |
|
| 13769 |
nsize = *n - st + 1; |
| 13770 |
iwork[sizei + nsub - 1] = nsize; |
| 13771 |
} else { |
| 13772 |
|
| 13773 |
/* A subproblem with E(NM1) small. This implies an */ |
| 13774 |
/* 1-by-1 subproblem at D(N), which is not solved */ |
| 13775 |
/* explicitly. */ |
| 13776 |
|
| 13777 |
nsize = i__ - st + 1; |
| 13778 |
iwork[sizei + nsub - 1] = nsize; |
| 13779 |
++nsub; |
| 13780 |
iwork[nsub] = *n; |
| 13781 |
iwork[sizei + nsub - 1] = 1; |
| 13782 |
dcopy_(nrhs, &b[*n + b_dim1], ldb, &work[bx + nm1], n); |
| 13783 |
} |
| 13784 |
st1 = st - 1; |
| 13785 |
if (nsize == 1) { |
| 13786 |
|
| 13787 |
/* This is a 1-by-1 subproblem and is not solved */ |
| 13788 |
/* explicitly. */ |
| 13789 |
|
| 13790 |
dcopy_(nrhs, &b[st + b_dim1], ldb, &work[bx + st1], n); |
| 13791 |
} else if (nsize <= *smlsiz) { |
| 13792 |
|
| 13793 |
/* This is a small subproblem and is solved by DLASDQ. */ |
| 13794 |
|
| 13795 |
dlaset_("A", &nsize, &nsize, &c_b6, &c_b11, &work[vt + st1], |
| 13796 |
n); |
| 13797 |
dlasdq_("U", &c__0, &nsize, &nsize, &c__0, nrhs, &d__[st], &e[ |
| 13798 |
st], &work[vt + st1], n, &work[nwork], n, &b[st + |
| 13799 |
b_dim1], ldb, &work[nwork], info); |
| 13800 |
if (*info != 0) { |
| 13801 |
return 0; |
| 13802 |
} |
| 13803 |
dlacpy_("A", &nsize, nrhs, &b[st + b_dim1], ldb, &work[bx + |
| 13804 |
st1], n); |
| 13805 |
} else { |
| 13806 |
|
| 13807 |
/* A large problem. Solve it using divide and conquer. */ |
| 13808 |
|
| 13809 |
dlasda_(&icmpq1, smlsiz, &nsize, &sqre, &d__[st], &e[st], & |
| 13810 |
work[u + st1], n, &work[vt + st1], &iwork[k + st1], & |
| 13811 |
work[difl + st1], &work[difr + st1], &work[z__ + st1], |
| 13812 |
&work[poles + st1], &iwork[givptr + st1], &iwork[ |
| 13813 |
givcol + st1], n, &iwork[perm + st1], &work[givnum + |
| 13814 |
st1], &work[c__ + st1], &work[s + st1], &work[nwork], |
| 13815 |
&iwork[iwk], info); |
| 13816 |
if (*info != 0) { |
| 13817 |
return 0; |
| 13818 |
} |
| 13819 |
bxst = bx + st1; |
| 13820 |
dlalsa_(&icmpq2, smlsiz, &nsize, nrhs, &b[st + b_dim1], ldb, & |
| 13821 |
work[bxst], n, &work[u + st1], n, &work[vt + st1], & |
| 13822 |
iwork[k + st1], &work[difl + st1], &work[difr + st1], |
| 13823 |
&work[z__ + st1], &work[poles + st1], &iwork[givptr + |
| 13824 |
st1], &iwork[givcol + st1], n, &iwork[perm + st1], & |
| 13825 |
work[givnum + st1], &work[c__ + st1], &work[s + st1], |
| 13826 |
&work[nwork], &iwork[iwk], info); |
| 13827 |
if (*info != 0) { |
| 13828 |
return 0; |
| 13829 |
} |
| 13830 |
} |
| 13831 |
st = i__ + 1; |
| 13832 |
} |
| 13833 |
/* L60: */ |
| 13834 |
} |
| 13835 |
|
| 13836 |
/* Apply the singular values and treat the tiny ones as zero. */ |
| 13837 |
|
| 13838 |
tol = rcnd * (d__1 = d__[idamax_(n, &d__[1], &c__1)], abs(d__1)); |
| 13839 |
|
| 13840 |
i__1 = *n; |
| 13841 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 13842 |
|
| 13843 |
/* Some of the elements in D can be negative because 1-by-1 */ |
| 13844 |
/* subproblems were not solved explicitly. */ |
| 13845 |
|
| 13846 |
if ((d__1 = d__[i__], abs(d__1)) <= tol) { |
| 13847 |
dlaset_("A", &c__1, nrhs, &c_b6, &c_b6, &work[bx + i__ - 1], n); |
| 13848 |
} else { |
| 13849 |
++(*rank); |
| 13850 |
dlascl_("G", &c__0, &c__0, &d__[i__], &c_b11, &c__1, nrhs, &work[ |
| 13851 |
bx + i__ - 1], n, info); |
| 13852 |
} |
| 13853 |
d__[i__] = (d__1 = d__[i__], abs(d__1)); |
| 13854 |
/* L70: */ |
| 13855 |
} |
| 13856 |
|
| 13857 |
/* Now apply back the right singular vectors. */ |
| 13858 |
|
| 13859 |
icmpq2 = 1; |
| 13860 |
i__1 = nsub; |
| 13861 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 13862 |
st = iwork[i__]; |
| 13863 |
st1 = st - 1; |
| 13864 |
nsize = iwork[sizei + i__ - 1]; |
| 13865 |
bxst = bx + st1; |
| 13866 |
if (nsize == 1) { |
| 13867 |
dcopy_(nrhs, &work[bxst], n, &b[st + b_dim1], ldb); |
| 13868 |
} else if (nsize <= *smlsiz) { |
| 13869 |
dgemm_("T", "N", &nsize, nrhs, &nsize, &c_b11, &work[vt + st1], n, |
| 13870 |
&work[bxst], n, &c_b6, &b[st + b_dim1], ldb); |
| 13871 |
} else { |
| 13872 |
dlalsa_(&icmpq2, smlsiz, &nsize, nrhs, &work[bxst], n, &b[st + |
| 13873 |
b_dim1], ldb, &work[u + st1], n, &work[vt + st1], &iwork[ |
| 13874 |
k + st1], &work[difl + st1], &work[difr + st1], &work[z__ |
| 13875 |
+ st1], &work[poles + st1], &iwork[givptr + st1], &iwork[ |
| 13876 |
givcol + st1], n, &iwork[perm + st1], &work[givnum + st1], |
| 13877 |
&work[c__ + st1], &work[s + st1], &work[nwork], &iwork[ |
| 13878 |
iwk], info); |
| 13879 |
if (*info != 0) { |
| 13880 |
return 0; |
| 13881 |
} |
| 13882 |
} |
| 13883 |
/* L80: */ |
| 13884 |
} |
| 13885 |
|
| 13886 |
/* Unscale and sort the singular values. */ |
| 13887 |
|
| 13888 |
dlascl_("G", &c__0, &c__0, &c_b11, &orgnrm, n, &c__1, &d__[1], n, info); |
| 13889 |
dlasrt_("D", n, &d__[1], info); |
| 13890 |
dlascl_("G", &c__0, &c__0, &orgnrm, &c_b11, n, nrhs, &b[b_offset], ldb, |
| 13891 |
info); |
| 13892 |
|
| 13893 |
return 0; |
| 13894 |
|
| 13895 |
/* End of DLALSD */ |
| 13896 |
|
| 13897 |
} /* dlalsd_ */ |
| 13898 |
|
| 13899 |
double dlamch_(const char *cmach) |
| 13900 |
{ |
| 13901 |
/* Table of constant values |
| 13902 |
static double c_b32 = 0.;*/ |
| 13903 |
|
| 13904 |
/* Initialized data */ |
| 13905 |
static bool first = true; |
| 13906 |
|
| 13907 |
/* System generated locals */ |
| 13908 |
integer i__1; |
| 13909 |
double ret_val; |
| 13910 |
|
| 13911 |
/* Local variables */ |
| 13912 |
static double t; |
| 13913 |
integer it; |
| 13914 |
static double rnd, eps, base; |
| 13915 |
integer beta; |
| 13916 |
static double emin, prec, emax; |
| 13917 |
integer imin, imax; |
| 13918 |
bool lrnd; |
| 13919 |
static double rmin, rmax; |
| 13920 |
double rmach; |
| 13921 |
|
| 13922 |
double small; |
| 13923 |
static double sfmin; |
| 13924 |
|
| 13925 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 13926 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 13927 |
/* November 2006 */ |
| 13928 |
|
| 13929 |
/* .. Scalar Arguments .. */ |
| 13930 |
/* .. */ |
| 13931 |
|
| 13932 |
/* Purpose */ |
| 13933 |
/* ======= */ |
| 13934 |
|
| 13935 |
/* DLAMCH determines double precision machine parameters. */ |
| 13936 |
|
| 13937 |
/* Arguments */ |
| 13938 |
/* ========= */ |
| 13939 |
|
| 13940 |
/* CMACH (input) CHARACTER*1 */ |
| 13941 |
/* Specifies the value to be returned by DLAMCH: */ |
| 13942 |
/* = 'E' or 'e', DLAMCH := eps */ |
| 13943 |
/* = 'S' or 's , DLAMCH := sfmin */ |
| 13944 |
/* = 'B' or 'b', DLAMCH := base */ |
| 13945 |
/* = 'P' or 'p', DLAMCH := eps*base */ |
| 13946 |
/* = 'N' or 'n', DLAMCH := t */ |
| 13947 |
/* = 'R' or 'r', DLAMCH := rnd */ |
| 13948 |
/* = 'M' or 'm', DLAMCH := emin */ |
| 13949 |
/* = 'U' or 'u', DLAMCH := rmin */ |
| 13950 |
/* = 'L' or 'l', DLAMCH := emax */ |
| 13951 |
/* = 'O' or 'o', DLAMCH := rmax */ |
| 13952 |
|
| 13953 |
/* where */ |
| 13954 |
|
| 13955 |
/* eps = relative machine precision */ |
| 13956 |
/* sfmin = safe minimum, such that 1/sfmin does not overflow */ |
| 13957 |
/* base = base of the machine */ |
| 13958 |
/* prec = eps*base */ |
| 13959 |
/* t = number of (base) digits in the mantissa */ |
| 13960 |
/* rnd = 1.0 when rounding occurs in addition, 0.0 otherwise */ |
| 13961 |
/* emin = minimum exponent before (gradual) underflow */ |
| 13962 |
/* rmin = underflow threshold - base**(emin-1) */ |
| 13963 |
/* emax = largest exponent before overflow */ |
| 13964 |
/* rmax = overflow threshold - (base**emax)*(1-eps) */ |
| 13965 |
|
| 13966 |
/* ===================================================================== */ |
| 13967 |
|
| 13968 |
/* .. Parameters .. */ |
| 13969 |
/* .. */ |
| 13970 |
/* .. Local Scalars .. */ |
| 13971 |
/* .. */ |
| 13972 |
/* .. External Functions .. */ |
| 13973 |
/* .. */ |
| 13974 |
/* .. External Subroutines .. */ |
| 13975 |
/* .. */ |
| 13976 |
/* .. Save statement .. */ |
| 13977 |
/* .. */ |
| 13978 |
/* .. Data statements .. */ |
| 13979 |
/* .. */ |
| 13980 |
/* .. Executable Statements .. */ |
| 13981 |
|
| 13982 |
if (first) { |
| 13983 |
dlamc2_(&beta, &it, &lrnd, &eps, &imin, &rmin, &imax, &rmax); |
| 13984 |
base = (double) beta; |
| 13985 |
t = (double) it; |
| 13986 |
if (lrnd) { |
| 13987 |
rnd = 1.; |
| 13988 |
i__1 = 1 - it; |
| 13989 |
eps = pow_di(&base, &i__1) / 2; |
| 13990 |
} else { |
| 13991 |
rnd = 0.; |
| 13992 |
i__1 = 1 - it; |
| 13993 |
eps = pow_di(&base, &i__1); |
| 13994 |
} |
| 13995 |
prec = eps * base; |
| 13996 |
emin = (double) imin; |
| 13997 |
emax = (double) imax; |
| 13998 |
sfmin = rmin; |
| 13999 |
small = 1. / rmax; |
| 14000 |
if (small >= sfmin) { |
| 14001 |
|
| 14002 |
/* Use SMALL plus a bit, to avoid the possibility of rounding */ |
| 14003 |
/* causing overflow when computing 1/sfmin. */ |
| 14004 |
|
| 14005 |
sfmin = small * (eps + 1.); |
| 14006 |
} |
| 14007 |
} |
| 14008 |
|
| 14009 |
if (lsame_(cmach, "E")) { |
| 14010 |
rmach = eps; |
| 14011 |
} else if (lsame_(cmach, "S")) { |
| 14012 |
rmach = sfmin; |
| 14013 |
} else if (lsame_(cmach, "B")) { |
| 14014 |
rmach = base; |
| 14015 |
} else if (lsame_(cmach, "P")) { |
| 14016 |
rmach = prec; |
| 14017 |
} else if (lsame_(cmach, "N")) { |
| 14018 |
rmach = t; |
| 14019 |
} else if (lsame_(cmach, "R")) { |
| 14020 |
rmach = rnd; |
| 14021 |
} else if (lsame_(cmach, "M")) { |
| 14022 |
rmach = emin; |
| 14023 |
} else if (lsame_(cmach, "U")) { |
| 14024 |
rmach = rmin; |
| 14025 |
} else if (lsame_(cmach, "L")) { |
| 14026 |
rmach = emax; |
| 14027 |
} else if (lsame_(cmach, "O")) { |
| 14028 |
rmach = rmax; |
| 14029 |
} |
| 14030 |
|
| 14031 |
ret_val = rmach; |
| 14032 |
first = false; |
| 14033 |
return ret_val; |
| 14034 |
|
| 14035 |
/* End of DLAMCH */ |
| 14036 |
|
| 14037 |
} /* dlamch_ */ |
| 14038 |
|
| 14039 |
|
| 14040 |
/* *********************************************************************** */ |
| 14041 |
|
| 14042 |
/* Subroutine */ int dlamc1_(integer *beta, integer *t, bool *rnd, bool |
| 14043 |
*ieee1) |
| 14044 |
{ |
| 14045 |
/* Initialized data */ |
| 14046 |
|
| 14047 |
static bool first = true; |
| 14048 |
|
| 14049 |
/* System generated locals */ |
| 14050 |
double d__1, d__2; |
| 14051 |
|
| 14052 |
/* Local variables */ |
| 14053 |
double a, b, c__, f, t1, t2; |
| 14054 |
static integer lt; |
| 14055 |
double one, qtr; |
| 14056 |
static bool lrnd; |
| 14057 |
static integer lbeta; |
| 14058 |
double savec; |
| 14059 |
|
| 14060 |
static bool lieee1; |
| 14061 |
|
| 14062 |
|
| 14063 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 14064 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 14065 |
/* November 2006 */ |
| 14066 |
|
| 14067 |
/* .. Scalar Arguments .. */ |
| 14068 |
/* .. */ |
| 14069 |
|
| 14070 |
/* Purpose */ |
| 14071 |
/* ======= */ |
| 14072 |
|
| 14073 |
/* DLAMC1 determines the machine parameters given by BETA, T, RND, and */ |
| 14074 |
/* IEEE1. */ |
| 14075 |
|
| 14076 |
/* Arguments */ |
| 14077 |
/* ========= */ |
| 14078 |
|
| 14079 |
/* BETA (output) INTEGER */ |
| 14080 |
/* The base of the machine. */ |
| 14081 |
|
| 14082 |
/* T (output) INTEGER */ |
| 14083 |
/* The number of ( BETA ) digits in the mantissa. */ |
| 14084 |
|
| 14085 |
/* RND (output) LOGICAL */ |
| 14086 |
/* Specifies whether proper rounding ( RND = .TRUE. ) or */ |
| 14087 |
/* chopping ( RND = .FALSE. ) occurs in addition. This may not */ |
| 14088 |
/* be a reliable guide to the way in which the machine performs */ |
| 14089 |
/* its arithmetic. */ |
| 14090 |
|
| 14091 |
/* IEEE1 (output) LOGICAL */ |
| 14092 |
/* Specifies whether rounding appears to be done in the IEEE */ |
| 14093 |
/* 'round to nearest' style. */ |
| 14094 |
|
| 14095 |
/* Further Details */ |
| 14096 |
/* =============== */ |
| 14097 |
|
| 14098 |
/* The routine is based on the routine ENVRON by Malcolm and */ |
| 14099 |
/* incorporates suggestions by Gentleman and Marovich. See */ |
| 14100 |
|
| 14101 |
/* Malcolm M. A. (1972) Algorithms to reveal properties of */ |
| 14102 |
/* floating-point arithmetic. Comms. of the ACM, 15, 949-951. */ |
| 14103 |
|
| 14104 |
/* Gentleman W. M. and Marovich S. B. (1974) More on algorithms */ |
| 14105 |
/* that reveal properties of floating point arithmetic units. */ |
| 14106 |
/* Comms. of the ACM, 17, 276-277. */ |
| 14107 |
|
| 14108 |
/* ===================================================================== */ |
| 14109 |
|
| 14110 |
/* .. Local Scalars .. */ |
| 14111 |
/* .. */ |
| 14112 |
/* .. External Functions .. */ |
| 14113 |
/* .. */ |
| 14114 |
/* .. Save statement .. */ |
| 14115 |
/* .. */ |
| 14116 |
/* .. Data statements .. */ |
| 14117 |
/* .. */ |
| 14118 |
/* .. Executable Statements .. */ |
| 14119 |
|
| 14120 |
if (first) { |
| 14121 |
one = 1.; |
| 14122 |
|
| 14123 |
/* LBETA, LIEEE1, LT and LRND are the local values of BETA, */ |
| 14124 |
/* IEEE1, T and RND. */ |
| 14125 |
|
| 14126 |
/* Throughout this routine we use the function DLAMC3 to ensure */ |
| 14127 |
/* that relevant values are stored and not held in registers, or */ |
| 14128 |
/* are not affected by optimizers. */ |
| 14129 |
|
| 14130 |
/* Compute a = 2.0**m with the smallest positive integer m such */ |
| 14131 |
/* that */ |
| 14132 |
|
| 14133 |
/* fl( a + 1.0 ) = a. */ |
| 14134 |
|
| 14135 |
a = 1.; |
| 14136 |
c__ = 1.; |
| 14137 |
|
| 14138 |
/* + WHILE( C.EQ.ONE )LOOP */ |
| 14139 |
L10: |
| 14140 |
if (c__ == one) { |
| 14141 |
a *= 2; |
| 14142 |
c__ = dlamc3_(&a, &one); |
| 14143 |
d__1 = -a; |
| 14144 |
c__ = dlamc3_(&c__, &d__1); |
| 14145 |
goto L10; |
| 14146 |
} |
| 14147 |
/* + END WHILE */ |
| 14148 |
|
| 14149 |
/* Now compute b = 2.0**m with the smallest positive integer m */ |
| 14150 |
/* such that */ |
| 14151 |
|
| 14152 |
/* fl( a + b ) .gt. a. */ |
| 14153 |
|
| 14154 |
b = 1.; |
| 14155 |
c__ = dlamc3_(&a, &b); |
| 14156 |
|
| 14157 |
/* + WHILE( C.EQ.A )LOOP */ |
| 14158 |
L20: |
| 14159 |
if (c__ == a) { |
| 14160 |
b *= 2; |
| 14161 |
c__ = dlamc3_(&a, &b); |
| 14162 |
goto L20; |
| 14163 |
} |
| 14164 |
/* + END WHILE */ |
| 14165 |
|
| 14166 |
/* Now compute the base. a and c are neighbouring floating point */ |
| 14167 |
/* numbers in the interval ( beta**t, beta**( t + 1 ) ) and so */ |
| 14168 |
/* their difference is beta. Adding 0.25 to c is to ensure that it */ |
| 14169 |
/* is truncated to beta and not ( beta - 1 ). */ |
| 14170 |
|
| 14171 |
qtr = one / 4; |
| 14172 |
savec = c__; |
| 14173 |
d__1 = -a; |
| 14174 |
c__ = dlamc3_(&c__, &d__1); |
| 14175 |
lbeta = (integer) (c__ + qtr); |
| 14176 |
|
| 14177 |
/* Now determine whether rounding or chopping occurs, by adding a */ |
| 14178 |
/* bit less than beta/2 and a bit more than beta/2 to a. */ |
| 14179 |
|
| 14180 |
b = (double) lbeta; |
| 14181 |
d__1 = b / 2; |
| 14182 |
d__2 = -b / 100; |
| 14183 |
f = dlamc3_(&d__1, &d__2); |
| 14184 |
c__ = dlamc3_(&f, &a); |
| 14185 |
if (c__ == a) { |
| 14186 |
lrnd = true; |
| 14187 |
} else { |
| 14188 |
lrnd = false; |
| 14189 |
} |
| 14190 |
d__1 = b / 2; |
| 14191 |
d__2 = b / 100; |
| 14192 |
f = dlamc3_(&d__1, &d__2); |
| 14193 |
c__ = dlamc3_(&f, &a); |
| 14194 |
if (lrnd && c__ == a) { |
| 14195 |
lrnd = false; |
| 14196 |
} |
| 14197 |
|
| 14198 |
/* Try and decide whether rounding is done in the IEEE 'round to */ |
| 14199 |
/* nearest' style. B/2 is half a unit in the last place of the two */ |
| 14200 |
/* numbers A and SAVEC. Furthermore, A is even, i.e. has last bit */ |
| 14201 |
/* zero, and SAVEC is odd. Thus adding B/2 to A should not change */ |
| 14202 |
/* A, but adding B/2 to SAVEC should change SAVEC. */ |
| 14203 |
|
| 14204 |
d__1 = b / 2; |
| 14205 |
t1 = dlamc3_(&d__1, &a); |
| 14206 |
d__1 = b / 2; |
| 14207 |
t2 = dlamc3_(&d__1, &savec); |
| 14208 |
lieee1 = t1 == a && t2 > savec && lrnd; |
| 14209 |
|
| 14210 |
/* Now find the mantissa, t. It should be the integer part of */ |
| 14211 |
/* log to the base beta of a, however it is safer to determine t */ |
| 14212 |
/* by powering. So we find t as the smallest positive integer for */ |
| 14213 |
/* which */ |
| 14214 |
|
| 14215 |
/* fl( beta**t + 1.0 ) = 1.0. */ |
| 14216 |
|
| 14217 |
lt = 0; |
| 14218 |
a = 1.; |
| 14219 |
c__ = 1.; |
| 14220 |
|
| 14221 |
/* + WHILE( C.EQ.ONE )LOOP */ |
| 14222 |
L30: |
| 14223 |
if (c__ == one) { |
| 14224 |
++lt; |
| 14225 |
a *= lbeta; |
| 14226 |
c__ = dlamc3_(&a, &one); |
| 14227 |
d__1 = -a; |
| 14228 |
c__ = dlamc3_(&c__, &d__1); |
| 14229 |
goto L30; |
| 14230 |
} |
| 14231 |
/* + END WHILE */ |
| 14232 |
|
| 14233 |
} |
| 14234 |
|
| 14235 |
*beta = lbeta; |
| 14236 |
*t = lt; |
| 14237 |
*rnd = lrnd; |
| 14238 |
*ieee1 = lieee1; |
| 14239 |
first = false; |
| 14240 |
return 0; |
| 14241 |
|
| 14242 |
/* End of DLAMC1 */ |
| 14243 |
|
| 14244 |
} /* dlamc1_ */ |
| 14245 |
|
| 14246 |
|
| 14247 |
/* *********************************************************************** */ |
| 14248 |
|
| 14249 |
/* Subroutine */ int dlamc2_(integer *beta, integer *t, bool *rnd, |
| 14250 |
double *eps, integer *emin, double *rmin, integer *emax, |
| 14251 |
double *rmax) |
| 14252 |
{ |
| 14253 |
/* Initialized data */ |
| 14254 |
|
| 14255 |
static bool first = true; |
| 14256 |
static bool iwarn = false; |
| 14257 |
|
| 14258 |
/* System generated locals */ |
| 14259 |
integer i__1; |
| 14260 |
double d__1, d__2, d__3, d__4, d__5; |
| 14261 |
|
| 14262 |
/* Local variables */ |
| 14263 |
double a, b, c__; |
| 14264 |
integer i__; |
| 14265 |
static integer lt; |
| 14266 |
double one, two; |
| 14267 |
bool ieee; |
| 14268 |
double half; |
| 14269 |
bool lrnd; |
| 14270 |
static double leps; |
| 14271 |
double zero; |
| 14272 |
static integer lbeta; |
| 14273 |
double rbase; |
| 14274 |
static integer lemin, lemax; |
| 14275 |
integer gnmin; |
| 14276 |
double small; |
| 14277 |
integer gpmin; |
| 14278 |
double third; |
| 14279 |
static double lrmin, lrmax; |
| 14280 |
double sixth; |
| 14281 |
bool lieee1; |
| 14282 |
integer ngnmin, ngpmin; |
| 14283 |
|
| 14284 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 14285 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 14286 |
/* November 2006 */ |
| 14287 |
|
| 14288 |
/* .. Scalar Arguments .. */ |
| 14289 |
/* .. */ |
| 14290 |
|
| 14291 |
/* Purpose */ |
| 14292 |
/* ======= */ |
| 14293 |
|
| 14294 |
/* DLAMC2 determines the machine parameters specified in its argument */ |
| 14295 |
/* list. */ |
| 14296 |
|
| 14297 |
/* Arguments */ |
| 14298 |
/* ========= */ |
| 14299 |
|
| 14300 |
/* BETA (output) INTEGER */ |
| 14301 |
/* The base of the machine. */ |
| 14302 |
|
| 14303 |
/* T (output) INTEGER */ |
| 14304 |
/* The number of ( BETA ) digits in the mantissa. */ |
| 14305 |
|
| 14306 |
/* RND (output) LOGICAL */ |
| 14307 |
/* Specifies whether proper rounding ( RND = .TRUE. ) or */ |
| 14308 |
/* chopping ( RND = .FALSE. ) occurs in addition. This may not */ |
| 14309 |
/* be a reliable guide to the way in which the machine performs */ |
| 14310 |
/* its arithmetic. */ |
| 14311 |
|
| 14312 |
/* EPS (output) DOUBLE PRECISION */ |
| 14313 |
/* The smallest positive number such that */ |
| 14314 |
|
| 14315 |
/* fl( 1.0 - EPS ) .LT. 1.0, */ |
| 14316 |
|
| 14317 |
/* where fl denotes the computed value. */ |
| 14318 |
|
| 14319 |
/* EMIN (output) INTEGER */ |
| 14320 |
/* The minimum exponent before (gradual) underflow occurs. */ |
| 14321 |
|
| 14322 |
/* RMIN (output) DOUBLE PRECISION */ |
| 14323 |
/* The smallest normalized number for the machine, given by */ |
| 14324 |
/* BASE**( EMIN - 1 ), where BASE is the floating point value */ |
| 14325 |
/* of BETA. */ |
| 14326 |
|
| 14327 |
/* EMAX (output) INTEGER */ |
| 14328 |
/* The maximum exponent before overflow occurs. */ |
| 14329 |
|
| 14330 |
/* RMAX (output) DOUBLE PRECISION */ |
| 14331 |
/* The largest positive number for the machine, given by */ |
| 14332 |
/* BASE**EMAX * ( 1 - EPS ), where BASE is the floating point */ |
| 14333 |
/* value of BETA. */ |
| 14334 |
|
| 14335 |
/* Further Details */ |
| 14336 |
/* =============== */ |
| 14337 |
|
| 14338 |
/* The computation of EPS is based on a routine PARANOIA by */ |
| 14339 |
/* W. Kahan of the University of California at Berkeley. */ |
| 14340 |
|
| 14341 |
/* ===================================================================== */ |
| 14342 |
|
| 14343 |
/* .. Local Scalars .. */ |
| 14344 |
/* .. */ |
| 14345 |
/* .. External Functions .. */ |
| 14346 |
/* .. */ |
| 14347 |
/* .. External Subroutines .. */ |
| 14348 |
/* .. */ |
| 14349 |
/* .. Intrinsic Functions .. */ |
| 14350 |
/* .. */ |
| 14351 |
/* .. Save statement .. */ |
| 14352 |
/* .. */ |
| 14353 |
/* .. Data statements .. */ |
| 14354 |
/* .. */ |
| 14355 |
/* .. Executable Statements .. */ |
| 14356 |
|
| 14357 |
if (first) { |
| 14358 |
zero = 0.; |
| 14359 |
one = 1.; |
| 14360 |
two = 2.; |
| 14361 |
|
| 14362 |
/* LBETA, LT, LRND, LEPS, LEMIN and LRMIN are the local values of */ |
| 14363 |
/* BETA, T, RND, EPS, EMIN and RMIN. */ |
| 14364 |
|
| 14365 |
/* Throughout this routine we use the function DLAMC3 to ensure */ |
| 14366 |
/* that relevant values are stored and not held in registers, or */ |
| 14367 |
/* are not affected by optimizers. */ |
| 14368 |
|
| 14369 |
/* DLAMC1 returns the parameters LBETA, LT, LRND and LIEEE1. */ |
| 14370 |
|
| 14371 |
dlamc1_(&lbeta, <, &lrnd, &lieee1); |
| 14372 |
|
| 14373 |
/* Start to find EPS. */ |
| 14374 |
|
| 14375 |
b = (double) lbeta; |
| 14376 |
i__1 = -lt; |
| 14377 |
a = pow_di(&b, &i__1); |
| 14378 |
leps = a; |
| 14379 |
|
| 14380 |
/* Try some tricks to see whether or not this is the correct EPS. */ |
| 14381 |
|
| 14382 |
b = two / 3; |
| 14383 |
half = one / 2; |
| 14384 |
d__1 = -half; |
| 14385 |
sixth = dlamc3_(&b, &d__1); |
| 14386 |
third = dlamc3_(&sixth, &sixth); |
| 14387 |
d__1 = -half; |
| 14388 |
b = dlamc3_(&third, &d__1); |
| 14389 |
b = dlamc3_(&b, &sixth); |
| 14390 |
b = abs(b); |
| 14391 |
if (b < leps) { |
| 14392 |
b = leps; |
| 14393 |
} |
| 14394 |
|
| 14395 |
leps = 1.; |
| 14396 |
|
| 14397 |
/* + WHILE( ( LEPS.GT.B ).AND.( B.GT.ZERO ) )LOOP */ |
| 14398 |
L10: |
| 14399 |
if (leps > b && b > zero) { |
| 14400 |
leps = b; |
| 14401 |
d__1 = half * leps; |
| 14402 |
/* Computing 5th power */ |
| 14403 |
d__3 = two, d__4 = d__3, d__3 *= d__3; |
| 14404 |
/* Computing 2nd power */ |
| 14405 |
d__5 = leps; |
| 14406 |
d__2 = d__4 * (d__3 * d__3) * (d__5 * d__5); |
| 14407 |
c__ = dlamc3_(&d__1, &d__2); |
| 14408 |
d__1 = -c__; |
| 14409 |
c__ = dlamc3_(&half, &d__1); |
| 14410 |
b = dlamc3_(&half, &c__); |
| 14411 |
d__1 = -b; |
| 14412 |
c__ = dlamc3_(&half, &d__1); |
| 14413 |
b = dlamc3_(&half, &c__); |
| 14414 |
goto L10; |
| 14415 |
} |
| 14416 |
/* + END WHILE */ |
| 14417 |
|
| 14418 |
if (a < leps) { |
| 14419 |
leps = a; |
| 14420 |
} |
| 14421 |
|
| 14422 |
/* Computation of EPS complete. */ |
| 14423 |
|
| 14424 |
/* Now find EMIN. Let A = + or - 1, and + or - (1 + BASE**(-3)). */ |
| 14425 |
/* Keep dividing A by BETA until (gradual) underflow occurs. This */ |
| 14426 |
/* is detected when we cannot recover the previous A. */ |
| 14427 |
|
| 14428 |
rbase = one / lbeta; |
| 14429 |
small = one; |
| 14430 |
for (i__ = 1; i__ <= 3; ++i__) { |
| 14431 |
d__1 = small * rbase; |
| 14432 |
small = dlamc3_(&d__1, &zero); |
| 14433 |
/* L20: */ |
| 14434 |
} |
| 14435 |
a = dlamc3_(&one, &small); |
| 14436 |
dlamc4_(&ngpmin, &one, &lbeta); |
| 14437 |
d__1 = -one; |
| 14438 |
dlamc4_(&ngnmin, &d__1, &lbeta); |
| 14439 |
dlamc4_(&gpmin, &a, &lbeta); |
| 14440 |
d__1 = -a; |
| 14441 |
dlamc4_(&gnmin, &d__1, &lbeta); |
| 14442 |
ieee = false; |
| 14443 |
|
| 14444 |
if (ngpmin == ngnmin && gpmin == gnmin) { |
| 14445 |
if (ngpmin == gpmin) { |
| 14446 |
lemin = ngpmin; |
| 14447 |
/* ( Non twos-complement machines, no gradual underflow; */ |
| 14448 |
/* e.g., VAX ) */ |
| 14449 |
} else if (gpmin - ngpmin == 3) { |
| 14450 |
lemin = ngpmin - 1 + lt; |
| 14451 |
ieee = true; |
| 14452 |
/* ( Non twos-complement machines, with gradual underflow; */ |
| 14453 |
/* e.g., IEEE standard followers ) */ |
| 14454 |
} else { |
| 14455 |
lemin = std::min(ngpmin,gpmin); |
| 14456 |
/* ( A guess; no known machine ) */ |
| 14457 |
iwarn = true; |
| 14458 |
} |
| 14459 |
|
| 14460 |
} else if (ngpmin == gpmin && ngnmin == gnmin) { |
| 14461 |
if ((i__1 = ngpmin - ngnmin, abs(i__1)) == 1) { |
| 14462 |
lemin = std::max(ngpmin,ngnmin); |
| 14463 |
/* ( Twos-complement machines, no gradual underflow; */ |
| 14464 |
/* e.g., CYBER 205 ) */ |
| 14465 |
} else { |
| 14466 |
lemin = std::min(ngpmin,ngnmin); |
| 14467 |
/* ( A guess; no known machine ) */ |
| 14468 |
iwarn = true; |
| 14469 |
} |
| 14470 |
|
| 14471 |
} else if ((i__1 = ngpmin - ngnmin, abs(i__1)) == 1 && gpmin == gnmin) |
| 14472 |
{ |
| 14473 |
if (gpmin - std::min(ngpmin,ngnmin) == 3) { |
| 14474 |
lemin = std::max(ngpmin,ngnmin) - 1 + lt; |
| 14475 |
/* ( Twos-complement machines with gradual underflow; */ |
| 14476 |
/* no known machine ) */ |
| 14477 |
} else { |
| 14478 |
lemin = std::min(ngpmin,ngnmin); |
| 14479 |
/* ( A guess; no known machine ) */ |
| 14480 |
iwarn = true; |
| 14481 |
} |
| 14482 |
|
| 14483 |
} else { |
| 14484 |
/* Computing MIN */ |
| 14485 |
i__1 = std::min(ngpmin,ngnmin), i__1 = std::min(i__1,gpmin); |
| 14486 |
lemin = std::min(i__1,gnmin); |
| 14487 |
/* ( A guess; no known machine ) */ |
| 14488 |
iwarn = true; |
| 14489 |
} |
| 14490 |
first = false; |
| 14491 |
/* ** */ |
| 14492 |
/* Comment out this if block if EMIN is ok */ |
| 14493 |
if (iwarn) { |
| 14494 |
first = true; |
| 14495 |
Melder_warning (U"DLAMC2 WARNING. The value EMIN may be incorrect:- ", lemin); |
| 14496 |
} |
| 14497 |
/* ** */ |
| 14498 |
|
| 14499 |
/* Assume IEEE arithmetic if we found denormalised numbers above, */ |
| 14500 |
/* or if arithmetic seems to round in the IEEE style, determined */ |
| 14501 |
/* in routine DLAMC1. A true IEEE machine should have both things */ |
| 14502 |
/* true; however, faulty machines may have one or the other. */ |
| 14503 |
|
| 14504 |
ieee = ieee || lieee1; |
| 14505 |
|
| 14506 |
/* Compute RMIN by successive division by BETA. We could compute */ |
| 14507 |
/* RMIN as BASE**( EMIN - 1 ), but some machines underflow during */ |
| 14508 |
/* this computation. */ |
| 14509 |
|
| 14510 |
lrmin = 1.; |
| 14511 |
i__1 = 1 - lemin; |
| 14512 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 14513 |
d__1 = lrmin * rbase; |
| 14514 |
lrmin = dlamc3_(&d__1, &zero); |
| 14515 |
/* L30: */ |
| 14516 |
} |
| 14517 |
|
| 14518 |
/* Finally, call DLAMC5 to compute EMAX and RMAX. */ |
| 14519 |
|
| 14520 |
dlamc5_(&lbeta, <, &lemin, &ieee, &lemax, &lrmax); |
| 14521 |
} |
| 14522 |
|
| 14523 |
*beta = lbeta; |
| 14524 |
*t = lt; |
| 14525 |
*rnd = lrnd; |
| 14526 |
*eps = leps; |
| 14527 |
*emin = lemin; |
| 14528 |
*rmin = lrmin; |
| 14529 |
*emax = lemax; |
| 14530 |
*rmax = lrmax; |
| 14531 |
|
| 14532 |
return 0; |
| 14533 |
|
| 14534 |
|
| 14535 |
/* End of DLAMC2 */ |
| 14536 |
|
| 14537 |
} /* dlamc2_ */ |
| 14538 |
|
| 14539 |
|
| 14540 |
/* *********************************************************************** */ |
| 14541 |
|
| 14542 |
double dlamc3_(double *a, double *b) |
| 14543 |
{ |
| 14544 |
/* |
| 14545 |
FIX by Paul Boersma 20200418: |
| 14546 |
Some optimizers can optimize away the whole call to this function if ret_val is not declared volatile. |
| 14547 |
In case this function is optimized away, |
| 14548 |
the floating-point epsilon may be estimated (by dlamch) not as 2.2e-16 |
| 14549 |
but as 2048 times lower on i386 gcc (using an 80-bit register rather than a 64-bit memory position), |
| 14550 |
so that an iterative procedure used in our discriminant analysis did not converge on 32-bit Windows |
| 14551 |
and on 32-bit i386 Linux. |
| 14552 |
*/ |
| 14553 |
volatile double ret_val; |
| 14554 |
|
| 14555 |
|
| 14556 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 14557 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 14558 |
/* November 2006 */ |
| 14559 |
|
| 14560 |
/* .. Scalar Arguments .. */ |
| 14561 |
/* .. */ |
| 14562 |
|
| 14563 |
/* Purpose */ |
| 14564 |
/* ======= */ |
| 14565 |
|
| 14566 |
/* DLAMC3 is intended to force A and B to be stored prior to doing */ |
| 14567 |
/* the addition of A and B , for use in situations where optimizers */ |
| 14568 |
/* might hold one of these in a register. */ |
| 14569 |
|
| 14570 |
/* Arguments */ |
| 14571 |
/* ========= */ |
| 14572 |
|
| 14573 |
/* A (input) DOUBLE PRECISION */ |
| 14574 |
/* B (input) DOUBLE PRECISION */ |
| 14575 |
/* The values A and B. */ |
| 14576 |
|
| 14577 |
/* ===================================================================== */ |
| 14578 |
|
| 14579 |
/* .. Executable Statements .. */ |
| 14580 |
|
| 14581 |
ret_val = *a + *b; |
| 14582 |
|
| 14583 |
return ret_val; |
| 14584 |
|
| 14585 |
/* End of DLAMC3 */ |
| 14586 |
|
| 14587 |
} /* dlamc3_ */ |
| 14588 |
|
| 14589 |
|
| 14590 |
/* *********************************************************************** */ |
| 14591 |
|
| 14592 |
/* Subroutine */ int dlamc4_(integer *emin, double *start, integer *base) |
| 14593 |
{ |
| 14594 |
/* System generated locals */ |
| 14595 |
integer i__1; |
| 14596 |
double d__1; |
| 14597 |
|
| 14598 |
/* Local variables */ |
| 14599 |
double a; |
| 14600 |
integer i__; |
| 14601 |
double b1, b2, c1, c2, d1, d2, one, zero, rbase; |
| 14602 |
|
| 14603 |
|
| 14604 |
|
| 14605 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 14606 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 14607 |
/* November 2006 */ |
| 14608 |
|
| 14609 |
/* .. Scalar Arguments .. */ |
| 14610 |
/* .. */ |
| 14611 |
|
| 14612 |
/* Purpose */ |
| 14613 |
/* ======= */ |
| 14614 |
|
| 14615 |
/* DLAMC4 is a service routine for DLAMC2. */ |
| 14616 |
|
| 14617 |
/* Arguments */ |
| 14618 |
/* ========= */ |
| 14619 |
|
| 14620 |
/* EMIN (output) INTEGER */ |
| 14621 |
/* The minimum exponent before (gradual) underflow, computed by */ |
| 14622 |
/* setting A = START and dividing by BASE until the previous A */ |
| 14623 |
/* can not be recovered. */ |
| 14624 |
|
| 14625 |
/* START (input) DOUBLE PRECISION */ |
| 14626 |
/* The starting point for determining EMIN. */ |
| 14627 |
|
| 14628 |
/* BASE (input) INTEGER */ |
| 14629 |
/* The base of the machine. */ |
| 14630 |
|
| 14631 |
/* ===================================================================== */ |
| 14632 |
|
| 14633 |
/* .. Local Scalars .. */ |
| 14634 |
/* .. */ |
| 14635 |
/* .. External Functions .. */ |
| 14636 |
/* .. */ |
| 14637 |
/* .. Executable Statements .. */ |
| 14638 |
|
| 14639 |
a = *start; |
| 14640 |
one = 1.; |
| 14641 |
rbase = one / *base; |
| 14642 |
zero = 0.; |
| 14643 |
*emin = 1; |
| 14644 |
d__1 = a * rbase; |
| 14645 |
b1 = dlamc3_(&d__1, &zero); |
| 14646 |
c1 = a; |
| 14647 |
c2 = a; |
| 14648 |
d1 = a; |
| 14649 |
d2 = a; |
| 14650 |
/* + WHILE( ( C1.EQ.A ).AND.( C2.EQ.A ).AND. */ |
| 14651 |
/* $ ( D1.EQ.A ).AND.( D2.EQ.A ) )LOOP */ |
| 14652 |
L10: |
| 14653 |
if (c1 == a && c2 == a && d1 == a && d2 == a) { |
| 14654 |
--(*emin); |
| 14655 |
a = b1; |
| 14656 |
d__1 = a / *base; |
| 14657 |
b1 = dlamc3_(&d__1, &zero); |
| 14658 |
d__1 = b1 * *base; |
| 14659 |
c1 = dlamc3_(&d__1, &zero); |
| 14660 |
d1 = zero; |
| 14661 |
i__1 = *base; |
| 14662 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 14663 |
d1 += b1; |
| 14664 |
/* L20: */ |
| 14665 |
} |
| 14666 |
d__1 = a * rbase; |
| 14667 |
b2 = dlamc3_(&d__1, &zero); |
| 14668 |
d__1 = b2 / rbase; |
| 14669 |
c2 = dlamc3_(&d__1, &zero); |
| 14670 |
d2 = zero; |
| 14671 |
i__1 = *base; |
| 14672 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 14673 |
d2 += b2; |
| 14674 |
/* L30: */ |
| 14675 |
} |
| 14676 |
goto L10; |
| 14677 |
} |
| 14678 |
/* + END WHILE */ |
| 14679 |
|
| 14680 |
return 0; |
| 14681 |
|
| 14682 |
/* End of DLAMC4 */ |
| 14683 |
|
| 14684 |
} /* dlamc4_ */ |
| 14685 |
|
| 14686 |
|
| 14687 |
/* *********************************************************************** */ |
| 14688 |
|
| 14689 |
/* Subroutine */ int dlamc5_(integer *beta, integer *p, integer *emin, |
| 14690 |
bool *ieee, integer *emax, double *rmax) |
| 14691 |
{ |
| 14692 |
/* Table of constant values */ |
| 14693 |
static double c_b32 = 0.; |
| 14694 |
|
| 14695 |
/* System generated locals */ |
| 14696 |
integer i__1; |
| 14697 |
double d__1; |
| 14698 |
|
| 14699 |
/* Local variables */ |
| 14700 |
integer i__; |
| 14701 |
double y, z__; |
| 14702 |
integer try__, lexp; |
| 14703 |
double oldy; |
| 14704 |
integer uexp, nbits; |
| 14705 |
|
| 14706 |
double recbas; |
| 14707 |
integer exbits, expsum; |
| 14708 |
|
| 14709 |
|
| 14710 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 14711 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 14712 |
/* November 2006 */ |
| 14713 |
|
| 14714 |
/* .. Scalar Arguments .. */ |
| 14715 |
/* .. */ |
| 14716 |
|
| 14717 |
/* Purpose */ |
| 14718 |
/* ======= */ |
| 14719 |
|
| 14720 |
/* DLAMC5 attempts to compute RMAX, the largest machine floating-point */ |
| 14721 |
/* number, without overflow. It assumes that EMAX + abs(EMIN) sum */ |
| 14722 |
/* approximately to a power of 2. It will fail on machines where this */ |
| 14723 |
/* assumption does not hold, for example, the Cyber 205 (EMIN = -28625, */ |
| 14724 |
/* EMAX = 28718). It will also fail if the value supplied for EMIN is */ |
| 14725 |
/* too large (i.e. too close to zero), probably with overflow. */ |
| 14726 |
|
| 14727 |
/* Arguments */ |
| 14728 |
/* ========= */ |
| 14729 |
|
| 14730 |
/* BETA (input) INTEGER */ |
| 14731 |
/* The base of floating-point arithmetic. */ |
| 14732 |
|
| 14733 |
/* P (input) INTEGER */ |
| 14734 |
/* The number of base BETA digits in the mantissa of a */ |
| 14735 |
/* floating-point value. */ |
| 14736 |
|
| 14737 |
/* EMIN (input) INTEGER */ |
| 14738 |
/* The minimum exponent before (gradual) underflow. */ |
| 14739 |
|
| 14740 |
/* IEEE (input) LOGICAL */ |
| 14741 |
/* A logical flag specifying whether or not the arithmetic */ |
| 14742 |
/* system is thought to comply with the IEEE standard. */ |
| 14743 |
|
| 14744 |
/* EMAX (output) INTEGER */ |
| 14745 |
/* The largest exponent before overflow */ |
| 14746 |
|
| 14747 |
/* RMAX (output) DOUBLE PRECISION */ |
| 14748 |
/* The largest machine floating-point number. */ |
| 14749 |
|
| 14750 |
/* ===================================================================== */ |
| 14751 |
|
| 14752 |
/* .. Parameters .. */ |
| 14753 |
/* .. */ |
| 14754 |
/* .. Local Scalars .. */ |
| 14755 |
/* .. */ |
| 14756 |
/* .. External Functions .. */ |
| 14757 |
/* .. */ |
| 14758 |
/* .. Intrinsic Functions .. */ |
| 14759 |
/* .. */ |
| 14760 |
/* .. Executable Statements .. */ |
| 14761 |
|
| 14762 |
/* First compute LEXP and UEXP, two powers of 2 that bound */ |
| 14763 |
/* abs(EMIN). We then assume that EMAX + abs(EMIN) will sum */ |
| 14764 |
/* approximately to the bound that is closest to abs(EMIN). */ |
| 14765 |
/* (EMAX is the exponent of the required number RMAX). */ |
| 14766 |
|
| 14767 |
lexp = 1; |
| 14768 |
exbits = 1; |
| 14769 |
L10: |
| 14770 |
try__ = lexp << 1; |
| 14771 |
if (try__ <= -(*emin)) { |
| 14772 |
lexp = try__; |
| 14773 |
++exbits; |
| 14774 |
goto L10; |
| 14775 |
} |
| 14776 |
if (lexp == -(*emin)) { |
| 14777 |
uexp = lexp; |
| 14778 |
} else { |
| 14779 |
uexp = try__; |
| 14780 |
++exbits; |
| 14781 |
} |
| 14782 |
|
| 14783 |
/* Now -LEXP is less than or equal to EMIN, and -UEXP is greater */ |
| 14784 |
/* than or equal to EMIN. EXBITS is the number of bits needed to */ |
| 14785 |
/* store the exponent. */ |
| 14786 |
|
| 14787 |
if (uexp + *emin > -lexp - *emin) { |
| 14788 |
expsum = lexp << 1; |
| 14789 |
} else { |
| 14790 |
expsum = uexp << 1; |
| 14791 |
} |
| 14792 |
|
| 14793 |
/* EXPSUM is the exponent range, approximately equal to */ |
| 14794 |
/* EMAX - EMIN + 1 . */ |
| 14795 |
|
| 14796 |
*emax = expsum + *emin - 1; |
| 14797 |
nbits = exbits + 1 + *p; |
| 14798 |
|
| 14799 |
/* NBITS is the total number of bits needed to store a */ |
| 14800 |
/* floating-point number. */ |
| 14801 |
|
| 14802 |
if (nbits % 2 == 1 && *beta == 2) { |
| 14803 |
|
| 14804 |
/* Either there are an odd number of bits used to store a */ |
| 14805 |
/* floating-point number, which is unlikely, or some bits are */ |
| 14806 |
/* not used in the representation of numbers, which is possible, */ |
| 14807 |
/* (e.g. Cray machines) or the mantissa has an implicit bit, */ |
| 14808 |
/* (e.g. IEEE machines, Dec Vax machines), which is perhaps the */ |
| 14809 |
/* most likely. We have to assume the last alternative. */ |
| 14810 |
/* If this is true, then we need to reduce EMAX by one because */ |
| 14811 |
/* there must be some way of representing zero in an implicit-bit */ |
| 14812 |
/* system. On machines like Cray, we are reducing EMAX by one */ |
| 14813 |
/* unnecessarily. */ |
| 14814 |
|
| 14815 |
--(*emax); |
| 14816 |
} |
| 14817 |
|
| 14818 |
if (*ieee) { |
| 14819 |
|
| 14820 |
/* Assume we are on an IEEE machine which reserves one exponent */ |
| 14821 |
/* for infinity and NaN. */ |
| 14822 |
|
| 14823 |
--(*emax); |
| 14824 |
} |
| 14825 |
|
| 14826 |
/* Now create RMAX, the largest machine number, which should */ |
| 14827 |
/* be equal to (1.0 - BETA**(-P)) * BETA**EMAX . */ |
| 14828 |
|
| 14829 |
/* First compute 1.0 - BETA**(-P), being careful that the */ |
| 14830 |
/* result is less than 1.0 . */ |
| 14831 |
|
| 14832 |
recbas = 1. / *beta; |
| 14833 |
z__ = *beta - 1.; |
| 14834 |
y = 0.; |
| 14835 |
i__1 = *p; |
| 14836 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 14837 |
z__ *= recbas; |
| 14838 |
if (y < 1.) { |
| 14839 |
oldy = y; |
| 14840 |
} |
| 14841 |
y = dlamc3_(&y, &z__); |
| 14842 |
/* L20: */ |
| 14843 |
} |
| 14844 |
if (y >= 1.) { |
| 14845 |
y = oldy; |
| 14846 |
} |
| 14847 |
|
| 14848 |
/* Now multiply by BETA**EMAX to get RMAX. */ |
| 14849 |
|
| 14850 |
i__1 = *emax; |
| 14851 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 14852 |
d__1 = y * *beta; |
| 14853 |
y = dlamc3_(&d__1, &c_b32); |
| 14854 |
/* L30: */ |
| 14855 |
} |
| 14856 |
|
| 14857 |
*rmax = y; |
| 14858 |
return 0; |
| 14859 |
|
| 14860 |
/* End of DLAMC5 */ |
| 14861 |
|
| 14862 |
} /* dlamc5_ */ |
| 14863 |
|
| 14864 |
/* Subroutine */ int dlamrg_(integer *n1, integer *n2, double *a, integer |
| 14865 |
*dtrd1, integer *dtrd2, integer *index) |
| 14866 |
{ |
| 14867 |
/* System generated locals */ |
| 14868 |
integer i__1; |
| 14869 |
|
| 14870 |
/* Local variables */ |
| 14871 |
integer i__, ind1, ind2, n1sv, n2sv; |
| 14872 |
|
| 14873 |
|
| 14874 |
/* -- LAPACK routine (version 3.1) -- */ |
| 14875 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 14876 |
/* November 2006 */ |
| 14877 |
|
| 14878 |
/* .. Scalar Arguments .. */ |
| 14879 |
/* .. */ |
| 14880 |
/* .. Array Arguments .. */ |
| 14881 |
/* .. */ |
| 14882 |
|
| 14883 |
/* Purpose */ |
| 14884 |
/* ======= */ |
| 14885 |
|
| 14886 |
/* DLAMRG will create a permutation list which will merge the elements */ |
| 14887 |
/* of A (which is composed of two independently sorted sets) into a */ |
| 14888 |
/* single set which is sorted in ascending order. */ |
| 14889 |
|
| 14890 |
/* Arguments */ |
| 14891 |
/* ========= */ |
| 14892 |
|
| 14893 |
/* N1 (input) INTEGER */ |
| 14894 |
/* N2 (input) INTEGER */ |
| 14895 |
/* These arguements contain the respective lengths of the two */ |
| 14896 |
/* sorted lists to be merged. */ |
| 14897 |
|
| 14898 |
/* A (input) DOUBLE PRECISION array, dimension (N1+N2) */ |
| 14899 |
/* The first N1 elements of A contain a list of numbers which */ |
| 14900 |
/* are sorted in either ascending or descending order. Likewise */ |
| 14901 |
/* for the final N2 elements. */ |
| 14902 |
|
| 14903 |
/* DTRD1 (input) INTEGER */ |
| 14904 |
/* DTRD2 (input) INTEGER */ |
| 14905 |
/* These are the strides to be taken through the array A. */ |
| 14906 |
/* Allowable strides are 1 and -1. They indicate whether a */ |
| 14907 |
/* subset of A is sorted in ascending (DTRDx = 1) or descending */ |
| 14908 |
/* (DTRDx = -1) order. */ |
| 14909 |
|
| 14910 |
/* INDEX (output) INTEGER array, dimension (N1+N2) */ |
| 14911 |
/* On exit this array will contain a permutation such that */ |
| 14912 |
/* if B( I ) = A( INDEX( I ) ) for I=1,N1+N2, then B will be */ |
| 14913 |
/* sorted in ascending order. */ |
| 14914 |
|
| 14915 |
/* ===================================================================== */ |
| 14916 |
|
| 14917 |
/* .. Local Scalars .. */ |
| 14918 |
/* .. */ |
| 14919 |
/* .. Executable Statements .. */ |
| 14920 |
|
| 14921 |
/* Parameter adjustments */ |
| 14922 |
--index; |
| 14923 |
--a; |
| 14924 |
|
| 14925 |
/* Function Body */ |
| 14926 |
n1sv = *n1; |
| 14927 |
n2sv = *n2; |
| 14928 |
if (*dtrd1 > 0) { |
| 14929 |
ind1 = 1; |
| 14930 |
} else { |
| 14931 |
ind1 = *n1; |
| 14932 |
} |
| 14933 |
if (*dtrd2 > 0) { |
| 14934 |
ind2 = *n1 + 1; |
| 14935 |
} else { |
| 14936 |
ind2 = *n1 + *n2; |
| 14937 |
} |
| 14938 |
i__ = 1; |
| 14939 |
/* while ( (N1SV > 0) & (N2SV > 0) ) */ |
| 14940 |
L10: |
| 14941 |
if (n1sv > 0 && n2sv > 0) { |
| 14942 |
if (a[ind1] <= a[ind2]) { |
| 14943 |
index[i__] = ind1; |
| 14944 |
++i__; |
| 14945 |
ind1 += *dtrd1; |
| 14946 |
--n1sv; |
| 14947 |
} else { |
| 14948 |
index[i__] = ind2; |
| 14949 |
++i__; |
| 14950 |
ind2 += *dtrd2; |
| 14951 |
--n2sv; |
| 14952 |
} |
| 14953 |
goto L10; |
| 14954 |
} |
| 14955 |
/* end while */ |
| 14956 |
if (n1sv == 0) { |
| 14957 |
i__1 = n2sv; |
| 14958 |
for (n1sv = 1; n1sv <= i__1; ++n1sv) { |
| 14959 |
index[i__] = ind2; |
| 14960 |
++i__; |
| 14961 |
ind2 += *dtrd2; |
| 14962 |
/* L20: */ |
| 14963 |
} |
| 14964 |
} else { |
| 14965 |
/* N2SV .EQ. 0 */ |
| 14966 |
i__1 = n1sv; |
| 14967 |
for (n2sv = 1; n2sv <= i__1; ++n2sv) { |
| 14968 |
index[i__] = ind1; |
| 14969 |
++i__; |
| 14970 |
ind1 += *dtrd1; |
| 14971 |
/* L30: */ |
| 14972 |
} |
| 14973 |
} |
| 14974 |
|
| 14975 |
return 0; |
| 14976 |
|
| 14977 |
/* End of DLAMRG */ |
| 14978 |
|
| 14979 |
} /* dlamrg_ */ |
| 14980 |
|
| 14981 |
/* Subroutine */ integer dlaneg_(integer *n, double *d__, double *lld, double * |
| 14982 |
sigma, double *pivmin, integer *r__) |
| 14983 |
{ |
| 14984 |
/* System generated locals */ |
| 14985 |
integer ret_val, i__1, i__2, i__3, i__4; |
| 14986 |
|
| 14987 |
/* Local variables */ |
| 14988 |
integer j; |
| 14989 |
double p, t; |
| 14990 |
integer bj; |
| 14991 |
double tmp; |
| 14992 |
integer neg1, neg2; |
| 14993 |
double bsav, gamma, dplus; |
| 14994 |
|
| 14995 |
integer negcnt; |
| 14996 |
bool sawnan; |
| 14997 |
double dminus; |
| 14998 |
|
| 14999 |
|
| 15000 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 15001 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 15002 |
/* November 2006 */ |
| 15003 |
|
| 15004 |
/* .. Scalar Arguments .. */ |
| 15005 |
/* .. */ |
| 15006 |
/* .. Array Arguments .. */ |
| 15007 |
/* .. */ |
| 15008 |
|
| 15009 |
/* Purpose */ |
| 15010 |
/* ======= */ |
| 15011 |
|
| 15012 |
/* DLANEG computes the Sturm count, the number of negative pivots */ |
| 15013 |
/* encountered while factoring tridiagonal T - sigma I = L D L^T. */ |
| 15014 |
/* This implementation works directly on the factors without forming */ |
| 15015 |
/* the tridiagonal matrix T. The Sturm count is also the number of */ |
| 15016 |
/* eigenvalues of T less than sigma. */ |
| 15017 |
|
| 15018 |
/* This routine is called from DLARRB. */ |
| 15019 |
|
| 15020 |
/* The current routine does not use the PIVMIN parameter but rather */ |
| 15021 |
/* requires IEEE-754 propagation of Infinities and NaNs. This */ |
| 15022 |
/* routine also has no input range restrictions but does require */ |
| 15023 |
/* default exception handling such that x/0 produces Inf when x is */ |
| 15024 |
/* non-zero, and Inf/Inf produces NaN. For more information, see: */ |
| 15025 |
|
| 15026 |
/* Marques, Riedy, and Voemel, "Benefits of IEEE-754 Features in */ |
| 15027 |
/* Modern Symmetric Tridiagonal Eigensolvers," SIAM Journal on */ |
| 15028 |
/* Scientific Computing, v28, n5, 2006. DOI 10.1137/050641624 */ |
| 15029 |
/* (Tech report version in LAWN 172 with the same title.) */ |
| 15030 |
|
| 15031 |
/* Arguments */ |
| 15032 |
/* ========= */ |
| 15033 |
|
| 15034 |
/* N (input) INTEGER */ |
| 15035 |
/* The order of the matrix. */ |
| 15036 |
|
| 15037 |
/* D (input) DOUBLE PRECISION array, dimension (N) */ |
| 15038 |
/* The N diagonal elements of the diagonal matrix D. */ |
| 15039 |
|
| 15040 |
/* LLD (input) DOUBLE PRECISION array, dimension (N-1) */ |
| 15041 |
/* The (N-1) elements L(i)*L(i)*D(i). */ |
| 15042 |
|
| 15043 |
/* SIGMA (input) DOUBLE PRECISION */ |
| 15044 |
/* Shift amount in T - sigma I = L D L^T. */ |
| 15045 |
|
| 15046 |
/* PIVMIN (input) DOUBLE PRECISION */ |
| 15047 |
/* The minimum pivot in the Sturm sequence. May be used */ |
| 15048 |
/* when zero pivots are encountered on non-IEEE-754 */ |
| 15049 |
/* architectures. */ |
| 15050 |
|
| 15051 |
/* R (input) INTEGER */ |
| 15052 |
/* The twist index for the twisted factorization that is used */ |
| 15053 |
/* for the negcount. */ |
| 15054 |
|
| 15055 |
/* Further Details */ |
| 15056 |
/* =============== */ |
| 15057 |
|
| 15058 |
/* Based on contributions by */ |
| 15059 |
/* Osni Marques, LBNL/NERSC, USA */ |
| 15060 |
/* Christof Voemel, University of California, Berkeley, USA */ |
| 15061 |
/* Jason Riedy, University of California, Berkeley, USA */ |
| 15062 |
|
| 15063 |
/* ===================================================================== */ |
| 15064 |
|
| 15065 |
/* .. Parameters .. */ |
| 15066 |
/* Some architectures propagate Infinities and NaNs very slowly, so */ |
| 15067 |
/* the code computes counts in BLKLEN chunks. Then a NaN can */ |
| 15068 |
/* propagate at most BLKLEN columns before being detected. This is */ |
| 15069 |
/* not a general tuning parameter; it needs only to be just large */ |
| 15070 |
/* enough that the overhead is tiny in common cases. */ |
| 15071 |
/* .. */ |
| 15072 |
/* .. Local Scalars .. */ |
| 15073 |
/* .. */ |
| 15074 |
/* .. Intrinsic Functions .. */ |
| 15075 |
/* .. */ |
| 15076 |
/* .. External Functions .. */ |
| 15077 |
/* .. */ |
| 15078 |
/* .. Executable Statements .. */ |
| 15079 |
/* Parameter adjustments */ |
| 15080 |
--lld; |
| 15081 |
--d__; |
| 15082 |
|
| 15083 |
/* Function Body */ |
| 15084 |
negcnt = 0; |
| 15085 |
/* I) upper part: L D L^T - SIGMA I = L+ D+ L+^T */ |
| 15086 |
t = -(*sigma); |
| 15087 |
i__1 = *r__ - 1; |
| 15088 |
for (bj = 1; bj <= i__1; bj += 128) { |
| 15089 |
neg1 = 0; |
| 15090 |
bsav = t; |
| 15091 |
/* Computing MIN */ |
| 15092 |
i__3 = bj + 127, i__4 = *r__ - 1; |
| 15093 |
i__2 = std::min(i__3,i__4); |
| 15094 |
for (j = bj; j <= i__2; ++j) { |
| 15095 |
dplus = d__[j] + t; |
| 15096 |
if (dplus < 0.) { |
| 15097 |
++neg1; |
| 15098 |
} |
| 15099 |
tmp = t / dplus; |
| 15100 |
t = tmp * lld[j] - *sigma; |
| 15101 |
/* L21: */ |
| 15102 |
} |
| 15103 |
sawnan = disnan_(&t); |
| 15104 |
/* Run a slower version of the above loop if a NaN is detected. */ |
| 15105 |
/* A NaN should occur only with a zero pivot after an infinite */ |
| 15106 |
/* pivot. In that case, substituting 1 for T/DPLUS is the */ |
| 15107 |
/* correct limit. */ |
| 15108 |
if (sawnan) { |
| 15109 |
neg1 = 0; |
| 15110 |
t = bsav; |
| 15111 |
/* Computing MIN */ |
| 15112 |
i__3 = bj + 127, i__4 = *r__ - 1; |
| 15113 |
i__2 = std::min(i__3,i__4); |
| 15114 |
for (j = bj; j <= i__2; ++j) { |
| 15115 |
dplus = d__[j] + t; |
| 15116 |
if (dplus < 0.) { |
| 15117 |
++neg1; |
| 15118 |
} |
| 15119 |
tmp = t / dplus; |
| 15120 |
if (disnan_(&tmp)) { |
| 15121 |
tmp = 1.; |
| 15122 |
} |
| 15123 |
t = tmp * lld[j] - *sigma; |
| 15124 |
/* L22: */ |
| 15125 |
} |
| 15126 |
} |
| 15127 |
negcnt += neg1; |
| 15128 |
/* L210: */ |
| 15129 |
} |
| 15130 |
|
| 15131 |
/* II) lower part: L D L^T - SIGMA I = U- D- U-^T */ |
| 15132 |
p = d__[*n] - *sigma; |
| 15133 |
i__1 = *r__; |
| 15134 |
for (bj = *n - 1; bj >= i__1; bj += -128) { |
| 15135 |
neg2 = 0; |
| 15136 |
bsav = p; |
| 15137 |
/* Computing MAX */ |
| 15138 |
i__3 = bj - 127; |
| 15139 |
i__2 = std::max(i__3,*r__); |
| 15140 |
for (j = bj; j >= i__2; --j) { |
| 15141 |
dminus = lld[j] + p; |
| 15142 |
if (dminus < 0.) { |
| 15143 |
++neg2; |
| 15144 |
} |
| 15145 |
tmp = p / dminus; |
| 15146 |
p = tmp * d__[j] - *sigma; |
| 15147 |
/* L23: */ |
| 15148 |
} |
| 15149 |
sawnan = disnan_(&p); |
| 15150 |
/* As above, run a slower version that substitutes 1 for Inf/Inf. */ |
| 15151 |
|
| 15152 |
if (sawnan) { |
| 15153 |
neg2 = 0; |
| 15154 |
p = bsav; |
| 15155 |
/* Computing MAX */ |
| 15156 |
i__3 = bj - 127; |
| 15157 |
i__2 = std::max(i__3,*r__); |
| 15158 |
for (j = bj; j >= i__2; --j) { |
| 15159 |
dminus = lld[j] + p; |
| 15160 |
if (dminus < 0.) { |
| 15161 |
++neg2; |
| 15162 |
} |
| 15163 |
tmp = p / dminus; |
| 15164 |
if (disnan_(&tmp)) { |
| 15165 |
tmp = 1.; |
| 15166 |
} |
| 15167 |
p = tmp * d__[j] - *sigma; |
| 15168 |
/* L24: */ |
| 15169 |
} |
| 15170 |
} |
| 15171 |
negcnt += neg2; |
| 15172 |
/* L230: */ |
| 15173 |
} |
| 15174 |
|
| 15175 |
/* III) Twist index */ |
| 15176 |
/* T was shifted by SIGMA initially. */ |
| 15177 |
gamma = t + *sigma + p; |
| 15178 |
if (gamma < 0.) { |
| 15179 |
++negcnt; |
| 15180 |
} |
| 15181 |
ret_val = negcnt; |
| 15182 |
return ret_val; |
| 15183 |
} /* dlaneg_ */ |
| 15184 |
|
| 15185 |
/* Subroutine */ double dlangb_(const char *norm, integer *n, integer *kl, integer *ku, |
| 15186 |
double *ab, integer *ldab, double *work) |
| 15187 |
{ |
| 15188 |
/* Table of constant values */ |
| 15189 |
static integer c__1 = 1; |
| 15190 |
|
| 15191 |
/* System generated locals */ |
| 15192 |
integer ab_dim1, ab_offset, i__1, i__2, i__3, i__4, i__5, i__6; |
| 15193 |
double ret_val, d__1, d__2, d__3; |
| 15194 |
|
| 15195 |
/* Builtin functions |
| 15196 |
double sqrt(double); */ |
| 15197 |
|
| 15198 |
/* Local variables */ |
| 15199 |
integer i__, j, k, l; |
| 15200 |
double sum, scale; |
| 15201 |
double value; |
| 15202 |
|
| 15203 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 15204 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 15205 |
/* November 2006 */ |
| 15206 |
|
| 15207 |
/* .. Scalar Arguments .. */ |
| 15208 |
/* .. */ |
| 15209 |
/* .. Array Arguments .. */ |
| 15210 |
/* .. */ |
| 15211 |
|
| 15212 |
/* Purpose */ |
| 15213 |
/* ======= */ |
| 15214 |
|
| 15215 |
/* DLANGB returns the value of the one norm, or the Frobenius norm, or */ |
| 15216 |
/* the infinity norm, or the element of largest absolute value of an */ |
| 15217 |
/* n by n band matrix A, with kl sub-diagonals and ku super-diagonals. */ |
| 15218 |
|
| 15219 |
/* Description */ |
| 15220 |
/* =========== */ |
| 15221 |
|
| 15222 |
/* DLANGB returns the value */ |
| 15223 |
|
| 15224 |
/* DLANGB = ( max(abs(A(i,j))), NORM = 'M' or 'm' */ |
| 15225 |
/* ( */ |
| 15226 |
/* ( norm1(A), NORM = '1', 'O' or 'o' */ |
| 15227 |
/* ( */ |
| 15228 |
/* ( normI(A), NORM = 'I' or 'i' */ |
| 15229 |
/* ( */ |
| 15230 |
/* ( normF(A), NORM = 'F', 'f', 'E' or 'e' */ |
| 15231 |
|
| 15232 |
/* where norm1 denotes the one norm of a matrix (maximum column sum), */ |
| 15233 |
/* normI denotes the infinity norm of a matrix (maximum row sum) and */ |
| 15234 |
/* normF denotes the Frobenius norm of a matrix (square root of sum of */ |
| 15235 |
/* squares). Note that max(abs(A(i,j))) is not a consistent matrix norm. */ |
| 15236 |
|
| 15237 |
/* Arguments */ |
| 15238 |
/* ========= */ |
| 15239 |
|
| 15240 |
/* NORM (input) CHARACTER*1 */ |
| 15241 |
/* Specifies the value to be returned in DLANGB as described */ |
| 15242 |
/* above. */ |
| 15243 |
|
| 15244 |
/* N (input) INTEGER */ |
| 15245 |
/* The order of the matrix A. N >= 0. When N = 0, DLANGB is */ |
| 15246 |
/* set to zero. */ |
| 15247 |
|
| 15248 |
/* KL (input) INTEGER */ |
| 15249 |
/* The number of sub-diagonals of the matrix A. KL >= 0. */ |
| 15250 |
|
| 15251 |
/* KU (input) INTEGER */ |
| 15252 |
/* The number of super-diagonals of the matrix A. KU >= 0. */ |
| 15253 |
|
| 15254 |
/* AB (input) DOUBLE PRECISION array, dimension (LDAB,N) */ |
| 15255 |
/* The band matrix A, stored in rows 1 to KL+KU+1. The j-th */ |
| 15256 |
/* column of A is stored in the j-th column of the array AB as */ |
| 15257 |
/* follows: */ |
| 15258 |
/* AB(ku+1+i-j,j) = A(i,j) for max(1,j-ku)<=i<=min(n,j+kl). */ |
| 15259 |
|
| 15260 |
/* LDAB (input) INTEGER */ |
| 15261 |
/* The leading dimension of the array AB. LDAB >= KL+KU+1. */ |
| 15262 |
|
| 15263 |
/* WORK (workspace) DOUBLE PRECISION array, dimension (MAX(1,LWORK)), */ |
| 15264 |
/* where LWORK >= N when NORM = 'I'; otherwise, WORK is not */ |
| 15265 |
/* referenced. */ |
| 15266 |
|
| 15267 |
/* ===================================================================== */ |
| 15268 |
|
| 15269 |
|
| 15270 |
/* .. Parameters .. */ |
| 15271 |
/* .. */ |
| 15272 |
/* .. Local Scalars .. */ |
| 15273 |
/* .. */ |
| 15274 |
/* .. External Subroutines .. */ |
| 15275 |
/* .. */ |
| 15276 |
/* .. External Functions .. */ |
| 15277 |
/* .. */ |
| 15278 |
/* .. Intrinsic Functions .. */ |
| 15279 |
/* .. */ |
| 15280 |
/* .. Executable Statements .. */ |
| 15281 |
|
| 15282 |
/* Parameter adjustments */ |
| 15283 |
ab_dim1 = *ldab; |
| 15284 |
ab_offset = 1 + ab_dim1; |
| 15285 |
ab -= ab_offset; |
| 15286 |
--work; |
| 15287 |
|
| 15288 |
/* Function Body */ |
| 15289 |
if (*n == 0) { |
| 15290 |
value = 0.; |
| 15291 |
} else if (lsame_(norm, "M")) { |
| 15292 |
|
| 15293 |
/* Find max(abs(A(i,j))). */ |
| 15294 |
|
| 15295 |
value = 0.; |
| 15296 |
i__1 = *n; |
| 15297 |
for (j = 1; j <= i__1; ++j) { |
| 15298 |
/* Computing MAX */ |
| 15299 |
i__2 = *ku + 2 - j; |
| 15300 |
/* Computing MIN */ |
| 15301 |
i__4 = *n + *ku + 1 - j, i__5 = *kl + *ku + 1; |
| 15302 |
i__3 = std::min(i__4,i__5); |
| 15303 |
for (i__ = std::max(i__2,1_integer); i__ <= i__3; ++i__) { |
| 15304 |
/* Computing MAX */ |
| 15305 |
d__2 = value, d__3 = (d__1 = ab[i__ + j * ab_dim1], abs(d__1)) |
| 15306 |
; |
| 15307 |
value = std::max(d__2,d__3); |
| 15308 |
/* L10: */ |
| 15309 |
} |
| 15310 |
/* L20: */ |
| 15311 |
} |
| 15312 |
} else if (lsame_(norm, "O") || *(unsigned char *) |
| 15313 |
norm == '1') { |
| 15314 |
|
| 15315 |
/* Find norm1(A). */ |
| 15316 |
|
| 15317 |
value = 0.; |
| 15318 |
i__1 = *n; |
| 15319 |
for (j = 1; j <= i__1; ++j) { |
| 15320 |
sum = 0.; |
| 15321 |
/* Computing MAX */ |
| 15322 |
i__3 = *ku + 2 - j; |
| 15323 |
/* Computing MIN */ |
| 15324 |
i__4 = *n + *ku + 1 - j, i__5 = *kl + *ku + 1; |
| 15325 |
i__2 = std::min(i__4,i__5); |
| 15326 |
for (i__ = std::max(i__3,1_integer); i__ <= i__2; ++i__) { |
| 15327 |
sum += (d__1 = ab[i__ + j * ab_dim1], abs(d__1)); |
| 15328 |
/* L30: */ |
| 15329 |
} |
| 15330 |
value = std::max(value,sum); |
| 15331 |
/* L40: */ |
| 15332 |
} |
| 15333 |
} else if (lsame_(norm, "I")) { |
| 15334 |
|
| 15335 |
/* Find normI(A). */ |
| 15336 |
|
| 15337 |
i__1 = *n; |
| 15338 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 15339 |
work[i__] = 0.; |
| 15340 |
/* L50: */ |
| 15341 |
} |
| 15342 |
i__1 = *n; |
| 15343 |
for (j = 1; j <= i__1; ++j) { |
| 15344 |
k = *ku + 1 - j; |
| 15345 |
/* Computing MAX */ |
| 15346 |
i__2 = 1, i__3 = j - *ku; |
| 15347 |
/* Computing MIN */ |
| 15348 |
i__5 = *n, i__6 = j + *kl; |
| 15349 |
i__4 = std::min(i__5,i__6); |
| 15350 |
for (i__ = std::max(i__2,i__3); i__ <= i__4; ++i__) { |
| 15351 |
work[i__] += (d__1 = ab[k + i__ + j * ab_dim1], abs(d__1)); |
| 15352 |
/* L60: */ |
| 15353 |
} |
| 15354 |
/* L70: */ |
| 15355 |
} |
| 15356 |
value = 0.; |
| 15357 |
i__1 = *n; |
| 15358 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 15359 |
/* Computing MAX */ |
| 15360 |
d__1 = value, d__2 = work[i__]; |
| 15361 |
value = std::max(d__1,d__2); |
| 15362 |
/* L80: */ |
| 15363 |
} |
| 15364 |
} else if (lsame_(norm, "F") || lsame_(norm, "E")) { |
| 15365 |
|
| 15366 |
/* Find normF(A). */ |
| 15367 |
|
| 15368 |
scale = 0.; |
| 15369 |
sum = 1.; |
| 15370 |
i__1 = *n; |
| 15371 |
for (j = 1; j <= i__1; ++j) { |
| 15372 |
/* Computing MAX */ |
| 15373 |
i__4 = 1, i__2 = j - *ku; |
| 15374 |
l = std::max(i__4,i__2); |
| 15375 |
k = *ku + 1 - j + l; |
| 15376 |
/* Computing MIN */ |
| 15377 |
i__2 = *n, i__3 = j + *kl; |
| 15378 |
i__4 = std::min(i__2,i__3) - l + 1; |
| 15379 |
dlassq_(&i__4, &ab[k + j * ab_dim1], &c__1, &scale, &sum); |
| 15380 |
/* L90: */ |
| 15381 |
} |
| 15382 |
value = scale * sqrt(sum); |
| 15383 |
} |
| 15384 |
|
| 15385 |
ret_val = value; |
| 15386 |
return ret_val; |
| 15387 |
|
| 15388 |
/* End of DLANGB */ |
| 15389 |
|
| 15390 |
} /* dlangb_ */ |
| 15391 |
|
| 15392 |
/* Subroutine */ double dlange_(const char *norm, integer *m, integer *n, double *a, integer |
| 15393 |
*lda, double *work) |
| 15394 |
{ |
| 15395 |
/* Table of constant values */ |
| 15396 |
static integer c__1 = 1; |
| 15397 |
|
| 15398 |
/* System generated locals */ |
| 15399 |
integer a_dim1, a_offset, i__1, i__2; |
| 15400 |
double ret_val, d__1, d__2, d__3; |
| 15401 |
|
| 15402 |
/* Builtin functions |
| 15403 |
double sqrt(double); */ |
| 15404 |
|
| 15405 |
/* Local variables */ |
| 15406 |
integer i__, j; |
| 15407 |
double sum, scale; |
| 15408 |
double value; |
| 15409 |
|
| 15410 |
|
| 15411 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 15412 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 15413 |
/* November 2006 */ |
| 15414 |
|
| 15415 |
/* .. Scalar Arguments .. */ |
| 15416 |
/* .. */ |
| 15417 |
/* .. Array Arguments .. */ |
| 15418 |
/* .. */ |
| 15419 |
|
| 15420 |
/* Purpose */ |
| 15421 |
/* ======= */ |
| 15422 |
|
| 15423 |
/* DLANGE returns the value of the one norm, or the Frobenius norm, or */ |
| 15424 |
/* the infinity norm, or the element of largest absolute value of a */ |
| 15425 |
/* real matrix A. */ |
| 15426 |
|
| 15427 |
/* Description */ |
| 15428 |
/* =========== */ |
| 15429 |
|
| 15430 |
/* DLANGE returns the value */ |
| 15431 |
|
| 15432 |
/* DLANGE = ( max(abs(A(i,j))), NORM = 'M' or 'm' */ |
| 15433 |
/* ( */ |
| 15434 |
/* ( norm1(A), NORM = '1', 'O' or 'o' */ |
| 15435 |
/* ( */ |
| 15436 |
/* ( normI(A), NORM = 'I' or 'i' */ |
| 15437 |
/* ( */ |
| 15438 |
/* ( normF(A), NORM = 'F', 'f', 'E' or 'e' */ |
| 15439 |
|
| 15440 |
/* where norm1 denotes the one norm of a matrix (maximum column sum), */ |
| 15441 |
/* normI denotes the infinity norm of a matrix (maximum row sum) and */ |
| 15442 |
/* normF denotes the Frobenius norm of a matrix (square root of sum of */ |
| 15443 |
/* squares). Note that max(abs(A(i,j))) is not a consistent matrix norm. */ |
| 15444 |
|
| 15445 |
/* Arguments */ |
| 15446 |
/* ========= */ |
| 15447 |
|
| 15448 |
/* NORM (input) CHARACTER*1 */ |
| 15449 |
/* Specifies the value to be returned in DLANGE as described */ |
| 15450 |
/* above. */ |
| 15451 |
|
| 15452 |
/* M (input) INTEGER */ |
| 15453 |
/* The number of rows of the matrix A. M >= 0. When M = 0, */ |
| 15454 |
/* DLANGE is set to zero. */ |
| 15455 |
|
| 15456 |
/* N (input) INTEGER */ |
| 15457 |
/* The number of columns of the matrix A. N >= 0. When N = 0, */ |
| 15458 |
/* DLANGE is set to zero. */ |
| 15459 |
|
| 15460 |
/* A (input) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 15461 |
/* The m by n matrix A. */ |
| 15462 |
|
| 15463 |
/* LDA (input) INTEGER */ |
| 15464 |
/* The leading dimension of the array A. LDA >= max(M,1). */ |
| 15465 |
|
| 15466 |
/* WORK (workspace) DOUBLE PRECISION array, dimension (MAX(1,LWORK)), */ |
| 15467 |
/* where LWORK >= M when NORM = 'I'; otherwise, WORK is not */ |
| 15468 |
/* referenced. */ |
| 15469 |
|
| 15470 |
/* ===================================================================== */ |
| 15471 |
|
| 15472 |
/* .. Parameters .. */ |
| 15473 |
/* .. */ |
| 15474 |
/* .. Local Scalars .. */ |
| 15475 |
/* .. */ |
| 15476 |
/* .. External Subroutines .. */ |
| 15477 |
/* .. */ |
| 15478 |
/* .. External Functions .. */ |
| 15479 |
/* .. */ |
| 15480 |
/* .. Intrinsic Functions .. */ |
| 15481 |
/* .. */ |
| 15482 |
/* .. Executable Statements .. */ |
| 15483 |
|
| 15484 |
/* Parameter adjustments */ |
| 15485 |
a_dim1 = *lda; |
| 15486 |
a_offset = 1 + a_dim1; |
| 15487 |
a -= a_offset; |
| 15488 |
--work; |
| 15489 |
|
| 15490 |
/* Function Body */ |
| 15491 |
if (std::min(*m,*n) == 0) { |
| 15492 |
value = 0.; |
| 15493 |
} else if (lsame_(norm, "M")) { |
| 15494 |
|
| 15495 |
/* Find max(abs(A(i,j))). */ |
| 15496 |
|
| 15497 |
value = 0.; |
| 15498 |
i__1 = *n; |
| 15499 |
for (j = 1; j <= i__1; ++j) { |
| 15500 |
i__2 = *m; |
| 15501 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 15502 |
/* Computing MAX */ |
| 15503 |
d__2 = value, d__3 = (d__1 = a[i__ + j * a_dim1], abs(d__1)); |
| 15504 |
value = std::max(d__2,d__3); |
| 15505 |
/* L10: */ |
| 15506 |
} |
| 15507 |
/* L20: */ |
| 15508 |
} |
| 15509 |
} else if (lsame_(norm, "O") || *(unsigned char *) |
| 15510 |
norm == '1') { |
| 15511 |
|
| 15512 |
/* Find norm1(A). */ |
| 15513 |
|
| 15514 |
value = 0.; |
| 15515 |
i__1 = *n; |
| 15516 |
for (j = 1; j <= i__1; ++j) { |
| 15517 |
sum = 0.; |
| 15518 |
i__2 = *m; |
| 15519 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 15520 |
sum += (d__1 = a[i__ + j * a_dim1], abs(d__1)); |
| 15521 |
/* L30: */ |
| 15522 |
} |
| 15523 |
value = std::max(value,sum); |
| 15524 |
/* L40: */ |
| 15525 |
} |
| 15526 |
} else if (lsame_(norm, "I")) { |
| 15527 |
|
| 15528 |
/* Find normI(A). */ |
| 15529 |
|
| 15530 |
i__1 = *m; |
| 15531 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 15532 |
work[i__] = 0.; |
| 15533 |
/* L50: */ |
| 15534 |
} |
| 15535 |
i__1 = *n; |
| 15536 |
for (j = 1; j <= i__1; ++j) { |
| 15537 |
i__2 = *m; |
| 15538 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 15539 |
work[i__] += (d__1 = a[i__ + j * a_dim1], abs(d__1)); |
| 15540 |
/* L60: */ |
| 15541 |
} |
| 15542 |
/* L70: */ |
| 15543 |
} |
| 15544 |
value = 0.; |
| 15545 |
i__1 = *m; |
| 15546 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 15547 |
/* Computing MAX */ |
| 15548 |
d__1 = value, d__2 = work[i__]; |
| 15549 |
value = std::max(d__1,d__2); |
| 15550 |
/* L80: */ |
| 15551 |
} |
| 15552 |
} else if (lsame_(norm, "F") || lsame_(norm, "E")) { |
| 15553 |
|
| 15554 |
/* Find normF(A). */ |
| 15555 |
|
| 15556 |
scale = 0.; |
| 15557 |
sum = 1.; |
| 15558 |
i__1 = *n; |
| 15559 |
for (j = 1; j <= i__1; ++j) { |
| 15560 |
dlassq_(m, &a[j * a_dim1 + 1], &c__1, &scale, &sum); |
| 15561 |
/* L90: */ |
| 15562 |
} |
| 15563 |
value = scale * sqrt(sum); |
| 15564 |
} |
| 15565 |
|
| 15566 |
ret_val = value; |
| 15567 |
return ret_val; |
| 15568 |
|
| 15569 |
/* End of DLANGE */ |
| 15570 |
|
| 15571 |
} /* dlange_ */ |
| 15572 |
|
| 15573 |
/* Subroutine */ double dlangt_(const char *norm, integer *n, double *dl, double *d__, |
| 15574 |
double *du) |
| 15575 |
{ |
| 15576 |
/* Table of constant values */ |
| 15577 |
static integer c__1 = 1; |
| 15578 |
|
| 15579 |
/* System generated locals */ |
| 15580 |
integer i__1; |
| 15581 |
double ret_val, d__1, d__2, d__3, d__4, d__5; |
| 15582 |
|
| 15583 |
/* Builtin functions |
| 15584 |
double sqrt(double); */ |
| 15585 |
|
| 15586 |
/* Local variables */ |
| 15587 |
integer i__; |
| 15588 |
double sum, scale; |
| 15589 |
double anorm; |
| 15590 |
|
| 15591 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 15592 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 15593 |
/* November 2006 */ |
| 15594 |
|
| 15595 |
/* .. Scalar Arguments .. */ |
| 15596 |
/* .. */ |
| 15597 |
/* .. Array Arguments .. */ |
| 15598 |
/* .. */ |
| 15599 |
|
| 15600 |
/* Purpose */ |
| 15601 |
/* ======= */ |
| 15602 |
|
| 15603 |
/* DLANGT returns the value of the one norm, or the Frobenius norm, or */ |
| 15604 |
/* the infinity norm, or the element of largest absolute value of a */ |
| 15605 |
/* real tridiagonal matrix A. */ |
| 15606 |
|
| 15607 |
/* Description */ |
| 15608 |
/* =========== */ |
| 15609 |
|
| 15610 |
/* DLANGT returns the value */ |
| 15611 |
|
| 15612 |
/* DLANGT = ( max(abs(A(i,j))), NORM = 'M' or 'm' */ |
| 15613 |
/* ( */ |
| 15614 |
/* ( norm1(A), NORM = '1', 'O' or 'o' */ |
| 15615 |
/* ( */ |
| 15616 |
/* ( normI(A), NORM = 'I' or 'i' */ |
| 15617 |
/* ( */ |
| 15618 |
/* ( normF(A), NORM = 'F', 'f', 'E' or 'e' */ |
| 15619 |
|
| 15620 |
/* where norm1 denotes the one norm of a matrix (maximum column sum), */ |
| 15621 |
/* normI denotes the infinity norm of a matrix (maximum row sum) and */ |
| 15622 |
/* normF denotes the Frobenius norm of a matrix (square root of sum of */ |
| 15623 |
/* squares). Note that max(abs(A(i,j))) is not a consistent matrix norm. */ |
| 15624 |
|
| 15625 |
/* Arguments */ |
| 15626 |
/* ========= */ |
| 15627 |
|
| 15628 |
/* NORM (input) CHARACTER*1 */ |
| 15629 |
/* Specifies the value to be returned in DLANGT as described */ |
| 15630 |
/* above. */ |
| 15631 |
|
| 15632 |
/* N (input) INTEGER */ |
| 15633 |
/* The order of the matrix A. N >= 0. When N = 0, DLANGT is */ |
| 15634 |
/* set to zero. */ |
| 15635 |
|
| 15636 |
/* DL (input) DOUBLE PRECISION array, dimension (N-1) */ |
| 15637 |
/* The (n-1) sub-diagonal elements of A. */ |
| 15638 |
|
| 15639 |
/* D (input) DOUBLE PRECISION array, dimension (N) */ |
| 15640 |
/* The diagonal elements of A. */ |
| 15641 |
|
| 15642 |
/* DU (input) DOUBLE PRECISION array, dimension (N-1) */ |
| 15643 |
/* The (n-1) super-diagonal elements of A. */ |
| 15644 |
|
| 15645 |
/* ===================================================================== */ |
| 15646 |
|
| 15647 |
/* .. Parameters .. */ |
| 15648 |
/* .. */ |
| 15649 |
/* .. Local Scalars .. */ |
| 15650 |
/* .. */ |
| 15651 |
/* .. External Functions .. */ |
| 15652 |
/* .. */ |
| 15653 |
/* .. External Subroutines .. */ |
| 15654 |
/* .. */ |
| 15655 |
/* .. Intrinsic Functions .. */ |
| 15656 |
/* .. */ |
| 15657 |
/* .. Executable Statements .. */ |
| 15658 |
|
| 15659 |
/* Parameter adjustments */ |
| 15660 |
--du; |
| 15661 |
--d__; |
| 15662 |
--dl; |
| 15663 |
|
| 15664 |
/* Function Body */ |
| 15665 |
if (*n <= 0) { |
| 15666 |
anorm = 0.; |
| 15667 |
} else if (lsame_(norm, "M")) { |
| 15668 |
|
| 15669 |
/* Find max(abs(A(i,j))). */ |
| 15670 |
|
| 15671 |
anorm = (d__1 = d__[*n], abs(d__1)); |
| 15672 |
i__1 = *n - 1; |
| 15673 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 15674 |
/* Computing MAX */ |
| 15675 |
d__2 = anorm, d__3 = (d__1 = dl[i__], abs(d__1)); |
| 15676 |
anorm = std::max(d__2,d__3); |
| 15677 |
/* Computing MAX */ |
| 15678 |
d__2 = anorm, d__3 = (d__1 = d__[i__], abs(d__1)); |
| 15679 |
anorm = std::max(d__2,d__3); |
| 15680 |
/* Computing MAX */ |
| 15681 |
d__2 = anorm, d__3 = (d__1 = du[i__], abs(d__1)); |
| 15682 |
anorm = std::max(d__2,d__3); |
| 15683 |
/* L10: */ |
| 15684 |
} |
| 15685 |
} else if (lsame_(norm, "O") || *(unsigned char *) |
| 15686 |
norm == '1') { |
| 15687 |
|
| 15688 |
/* Find norm1(A). */ |
| 15689 |
|
| 15690 |
if (*n == 1) { |
| 15691 |
anorm = abs(d__[1]); |
| 15692 |
} else { |
| 15693 |
/* Computing MAX */ |
| 15694 |
d__3 = abs(d__[1]) + abs(dl[1]), d__4 = (d__1 = d__[*n], abs(d__1) |
| 15695 |
) + (d__2 = du[*n - 1], abs(d__2)); |
| 15696 |
anorm = std::max(d__3,d__4); |
| 15697 |
i__1 = *n - 1; |
| 15698 |
for (i__ = 2; i__ <= i__1; ++i__) { |
| 15699 |
/* Computing MAX */ |
| 15700 |
d__4 = anorm, d__5 = (d__1 = d__[i__], abs(d__1)) + (d__2 = |
| 15701 |
dl[i__], abs(d__2)) + (d__3 = du[i__ - 1], abs(d__3)); |
| 15702 |
anorm = std::max(d__4,d__5); |
| 15703 |
/* L20: */ |
| 15704 |
} |
| 15705 |
} |
| 15706 |
} else if (lsame_(norm, "I")) { |
| 15707 |
|
| 15708 |
/* Find normI(A). */ |
| 15709 |
|
| 15710 |
if (*n == 1) { |
| 15711 |
anorm = abs(d__[1]); |
| 15712 |
} else { |
| 15713 |
/* Computing MAX */ |
| 15714 |
d__3 = abs(d__[1]) + abs(du[1]), d__4 = (d__1 = d__[*n], abs(d__1) |
| 15715 |
) + (d__2 = dl[*n - 1], abs(d__2)); |
| 15716 |
anorm = std::max(d__3,d__4); |
| 15717 |
i__1 = *n - 1; |
| 15718 |
for (i__ = 2; i__ <= i__1; ++i__) { |
| 15719 |
/* Computing MAX */ |
| 15720 |
d__4 = anorm, d__5 = (d__1 = d__[i__], abs(d__1)) + (d__2 = |
| 15721 |
du[i__], abs(d__2)) + (d__3 = dl[i__ - 1], abs(d__3)); |
| 15722 |
anorm = std::max(d__4,d__5); |
| 15723 |
/* L30: */ |
| 15724 |
} |
| 15725 |
} |
| 15726 |
} else if (lsame_(norm, "F") || lsame_(norm, "E")) { |
| 15727 |
|
| 15728 |
/* Find normF(A). */ |
| 15729 |
|
| 15730 |
scale = 0.; |
| 15731 |
sum = 1.; |
| 15732 |
dlassq_(n, &d__[1], &c__1, &scale, &sum); |
| 15733 |
if (*n > 1) { |
| 15734 |
i__1 = *n - 1; |
| 15735 |
dlassq_(&i__1, &dl[1], &c__1, &scale, &sum); |
| 15736 |
i__1 = *n - 1; |
| 15737 |
dlassq_(&i__1, &du[1], &c__1, &scale, &sum); |
| 15738 |
} |
| 15739 |
anorm = scale * sqrt(sum); |
| 15740 |
} |
| 15741 |
|
| 15742 |
ret_val = anorm; |
| 15743 |
return ret_val; |
| 15744 |
|
| 15745 |
/* End of DLANGT */ |
| 15746 |
|
| 15747 |
} /* dlangt_ */ |
| 15748 |
|
| 15749 |
/* Subroutine */ double dlanhs_(const char *norm, integer *n, double *a, integer *lda, |
| 15750 |
double *work) |
| 15751 |
{ |
| 15752 |
/* Table of constant values */ |
| 15753 |
static integer c__1 = 1; |
| 15754 |
|
| 15755 |
/* System generated locals */ |
| 15756 |
integer a_dim1, a_offset, i__1, i__2, i__3, i__4; |
| 15757 |
double ret_val, d__1, d__2, d__3; |
| 15758 |
|
| 15759 |
/* Local variables */ |
| 15760 |
integer i__, j; |
| 15761 |
double sum, scale; |
| 15762 |
double value; |
| 15763 |
|
| 15764 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 15765 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 15766 |
/* November 2006 */ |
| 15767 |
|
| 15768 |
/* .. Scalar Arguments .. */ |
| 15769 |
/* .. */ |
| 15770 |
/* .. Array Arguments .. */ |
| 15771 |
/* .. */ |
| 15772 |
|
| 15773 |
/* Purpose */ |
| 15774 |
/* ======= */ |
| 15775 |
|
| 15776 |
/* DLANHS returns the value of the one norm, or the Frobenius norm, or */ |
| 15777 |
/* the infinity norm, or the element of largest absolute value of a */ |
| 15778 |
/* Hessenberg matrix A. */ |
| 15779 |
|
| 15780 |
/* Description */ |
| 15781 |
/* =========== */ |
| 15782 |
|
| 15783 |
/* DLANHS returns the value */ |
| 15784 |
|
| 15785 |
/* DLANHS = ( max(abs(A(i,j))), NORM = 'M' or 'm' */ |
| 15786 |
/* ( */ |
| 15787 |
/* ( norm1(A), NORM = '1', 'O' or 'o' */ |
| 15788 |
/* ( */ |
| 15789 |
/* ( normI(A), NORM = 'I' or 'i' */ |
| 15790 |
/* ( */ |
| 15791 |
/* ( normF(A), NORM = 'F', 'f', 'E' or 'e' */ |
| 15792 |
|
| 15793 |
/* where norm1 denotes the one norm of a matrix (maximum column sum), */ |
| 15794 |
/* normI denotes the infinity norm of a matrix (maximum row sum) and */ |
| 15795 |
/* normF denotes the Frobenius norm of a matrix (square root of sum of */ |
| 15796 |
/* squares). Note that max(abs(A(i,j))) is not a consistent matrix norm. */ |
| 15797 |
|
| 15798 |
/* Arguments */ |
| 15799 |
/* ========= */ |
| 15800 |
|
| 15801 |
/* NORM (input) CHARACTER*1 */ |
| 15802 |
/* Specifies the value to be returned in DLANHS as described */ |
| 15803 |
/* above. */ |
| 15804 |
|
| 15805 |
/* N (input) INTEGER */ |
| 15806 |
/* The order of the matrix A. N >= 0. When N = 0, DLANHS is */ |
| 15807 |
/* set to zero. */ |
| 15808 |
|
| 15809 |
/* A (input) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 15810 |
/* The n by n upper Hessenberg matrix A; the part of A below the */ |
| 15811 |
/* first sub-diagonal is not referenced. */ |
| 15812 |
|
| 15813 |
/* LDA (input) INTEGER */ |
| 15814 |
/* The leading dimension of the array A. LDA >= max(N,1). */ |
| 15815 |
|
| 15816 |
/* WORK (workspace) DOUBLE PRECISION array, dimension (MAX(1,LWORK)), */ |
| 15817 |
/* where LWORK >= N when NORM = 'I'; otherwise, WORK is not */ |
| 15818 |
/* referenced. */ |
| 15819 |
|
| 15820 |
/* ===================================================================== */ |
| 15821 |
|
| 15822 |
/* .. Parameters .. */ |
| 15823 |
/* .. */ |
| 15824 |
/* .. Local Scalars .. */ |
| 15825 |
/* .. */ |
| 15826 |
/* .. External Subroutines .. */ |
| 15827 |
/* .. */ |
| 15828 |
/* .. External Functions .. */ |
| 15829 |
/* .. */ |
| 15830 |
/* .. Intrinsic Functions .. */ |
| 15831 |
/* .. */ |
| 15832 |
/* .. Executable Statements .. */ |
| 15833 |
|
| 15834 |
/* Parameter adjustments */ |
| 15835 |
a_dim1 = *lda; |
| 15836 |
a_offset = 1 + a_dim1; |
| 15837 |
a -= a_offset; |
| 15838 |
--work; |
| 15839 |
|
| 15840 |
/* Function Body */ |
| 15841 |
if (*n == 0) { |
| 15842 |
value = 0.; |
| 15843 |
} else if (lsame_(norm, "M")) { |
| 15844 |
|
| 15845 |
/* Find max(abs(A(i,j))). */ |
| 15846 |
|
| 15847 |
value = 0.; |
| 15848 |
i__1 = *n; |
| 15849 |
for (j = 1; j <= i__1; ++j) { |
| 15850 |
/* Computing MIN */ |
| 15851 |
i__3 = *n, i__4 = j + 1; |
| 15852 |
i__2 = std::min(i__3,i__4); |
| 15853 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 15854 |
/* Computing MAX */ |
| 15855 |
d__2 = value, d__3 = (d__1 = a[i__ + j * a_dim1], abs(d__1)); |
| 15856 |
value = std::max(d__2,d__3); |
| 15857 |
/* L10: */ |
| 15858 |
} |
| 15859 |
/* L20: */ |
| 15860 |
} |
| 15861 |
} else if (lsame_(norm, "O") || *(unsigned char *) |
| 15862 |
norm == '1') { |
| 15863 |
|
| 15864 |
/* Find norm1(A). */ |
| 15865 |
|
| 15866 |
value = 0.; |
| 15867 |
i__1 = *n; |
| 15868 |
for (j = 1; j <= i__1; ++j) { |
| 15869 |
sum = 0.; |
| 15870 |
/* Computing MIN */ |
| 15871 |
i__3 = *n, i__4 = j + 1; |
| 15872 |
i__2 = std::min(i__3,i__4); |
| 15873 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 15874 |
sum += (d__1 = a[i__ + j * a_dim1], abs(d__1)); |
| 15875 |
/* L30: */ |
| 15876 |
} |
| 15877 |
value = std::max(value,sum); |
| 15878 |
/* L40: */ |
| 15879 |
} |
| 15880 |
} else if (lsame_(norm, "I")) { |
| 15881 |
|
| 15882 |
/* Find normI(A). */ |
| 15883 |
|
| 15884 |
i__1 = *n; |
| 15885 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 15886 |
work[i__] = 0.; |
| 15887 |
/* L50: */ |
| 15888 |
} |
| 15889 |
i__1 = *n; |
| 15890 |
for (j = 1; j <= i__1; ++j) { |
| 15891 |
/* Computing MIN */ |
| 15892 |
i__3 = *n, i__4 = j + 1; |
| 15893 |
i__2 = std::min(i__3,i__4); |
| 15894 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 15895 |
work[i__] += (d__1 = a[i__ + j * a_dim1], abs(d__1)); |
| 15896 |
/* L60: */ |
| 15897 |
} |
| 15898 |
/* L70: */ |
| 15899 |
} |
| 15900 |
value = 0.; |
| 15901 |
i__1 = *n; |
| 15902 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 15903 |
/* Computing MAX */ |
| 15904 |
d__1 = value, d__2 = work[i__]; |
| 15905 |
value = std::max(d__1,d__2); |
| 15906 |
/* L80: */ |
| 15907 |
} |
| 15908 |
} else if (lsame_(norm, "F") || lsame_(norm, "E")) { |
| 15909 |
|
| 15910 |
/* Find normF(A). */ |
| 15911 |
|
| 15912 |
scale = 0.; |
| 15913 |
sum = 1.; |
| 15914 |
i__1 = *n; |
| 15915 |
for (j = 1; j <= i__1; ++j) { |
| 15916 |
/* Computing MIN */ |
| 15917 |
i__3 = *n, i__4 = j + 1; |
| 15918 |
i__2 = std::min(i__3,i__4); |
| 15919 |
dlassq_(&i__2, &a[j * a_dim1 + 1], &c__1, &scale, &sum); |
| 15920 |
/* L90: */ |
| 15921 |
} |
| 15922 |
value = scale * sqrt(sum); |
| 15923 |
} |
| 15924 |
|
| 15925 |
ret_val = value; |
| 15926 |
return ret_val; |
| 15927 |
|
| 15928 |
/* End of DLANHS */ |
| 15929 |
|
| 15930 |
} /* dlanhs_ */ |
| 15931 |
|
| 15932 |
/* Subroutine */ double dlansb_(const char *norm, const char *uplo, integer *n, integer *k, double |
| 15933 |
*ab, integer *ldab, double *work) |
| 15934 |
{ |
| 15935 |
/* Table of constant values */ |
| 15936 |
static integer c__1 = 1; |
| 15937 |
|
| 15938 |
/* System generated locals */ |
| 15939 |
integer ab_dim1, ab_offset, i__1, i__2, i__3, i__4; |
| 15940 |
double ret_val, d__1, d__2, d__3; |
| 15941 |
|
| 15942 |
/* Local variables */ |
| 15943 |
integer i__, j, l; |
| 15944 |
double sum, absa, scale; |
| 15945 |
double value; |
| 15946 |
|
| 15947 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 15948 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 15949 |
/* November 2006 */ |
| 15950 |
|
| 15951 |
/* .. Scalar Arguments .. */ |
| 15952 |
/* .. */ |
| 15953 |
/* .. Array Arguments .. */ |
| 15954 |
/* .. */ |
| 15955 |
|
| 15956 |
/* Purpose */ |
| 15957 |
/* ======= */ |
| 15958 |
|
| 15959 |
/* DLANSB returns the value of the one norm, or the Frobenius norm, or */ |
| 15960 |
/* the infinity norm, or the element of largest absolute value of an */ |
| 15961 |
/* n by n symmetric band matrix A, with k super-diagonals. */ |
| 15962 |
|
| 15963 |
/* Description */ |
| 15964 |
/* =========== */ |
| 15965 |
|
| 15966 |
/* DLANSB returns the value */ |
| 15967 |
|
| 15968 |
/* DLANSB = ( max(abs(A(i,j))), NORM = 'M' or 'm' */ |
| 15969 |
/* ( */ |
| 15970 |
/* ( norm1(A), NORM = '1', 'O' or 'o' */ |
| 15971 |
/* ( */ |
| 15972 |
/* ( normI(A), NORM = 'I' or 'i' */ |
| 15973 |
/* ( */ |
| 15974 |
/* ( normF(A), NORM = 'F', 'f', 'E' or 'e' */ |
| 15975 |
|
| 15976 |
/* where norm1 denotes the one norm of a matrix (maximum column sum), */ |
| 15977 |
/* normI denotes the infinity norm of a matrix (maximum row sum) and */ |
| 15978 |
/* normF denotes the Frobenius norm of a matrix (square root of sum of */ |
| 15979 |
/* squares). Note that max(abs(A(i,j))) is not a consistent matrix norm. */ |
| 15980 |
|
| 15981 |
/* Arguments */ |
| 15982 |
/* ========= */ |
| 15983 |
|
| 15984 |
/* NORM (input) CHARACTER*1 */ |
| 15985 |
/* Specifies the value to be returned in DLANSB as described */ |
| 15986 |
/* above. */ |
| 15987 |
|
| 15988 |
/* UPLO (input) CHARACTER*1 */ |
| 15989 |
/* Specifies whether the upper or lower triangular part of the */ |
| 15990 |
/* band matrix A is supplied. */ |
| 15991 |
/* = 'U': Upper triangular part is supplied */ |
| 15992 |
/* = 'L': Lower triangular part is supplied */ |
| 15993 |
|
| 15994 |
/* N (input) INTEGER */ |
| 15995 |
/* The order of the matrix A. N >= 0. When N = 0, DLANSB is */ |
| 15996 |
/* set to zero. */ |
| 15997 |
|
| 15998 |
/* K (input) INTEGER */ |
| 15999 |
/* The number of super-diagonals or sub-diagonals of the */ |
| 16000 |
/* band matrix A. K >= 0. */ |
| 16001 |
|
| 16002 |
/* AB (input) DOUBLE PRECISION array, dimension (LDAB,N) */ |
| 16003 |
/* The upper or lower triangle of the symmetric band matrix A, */ |
| 16004 |
/* stored in the first K+1 rows of AB. The j-th column of A is */ |
| 16005 |
/* stored in the j-th column of the array AB as follows: */ |
| 16006 |
/* if UPLO = 'U', AB(k+1+i-j,j) = A(i,j) for max(1,j-k)<=i<=j; */ |
| 16007 |
/* if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+k). */ |
| 16008 |
|
| 16009 |
/* LDAB (input) INTEGER */ |
| 16010 |
/* The leading dimension of the array AB. LDAB >= K+1. */ |
| 16011 |
|
| 16012 |
/* WORK (workspace) DOUBLE PRECISION array, dimension (MAX(1,LWORK)), */ |
| 16013 |
/* where LWORK >= N when NORM = 'I' or '1' or 'O'; otherwise, */ |
| 16014 |
/* WORK is not referenced. */ |
| 16015 |
|
| 16016 |
/* ===================================================================== */ |
| 16017 |
|
| 16018 |
/* .. Parameters .. */ |
| 16019 |
/* .. */ |
| 16020 |
/* .. Local Scalars .. */ |
| 16021 |
/* .. */ |
| 16022 |
/* .. External Subroutines .. */ |
| 16023 |
/* .. */ |
| 16024 |
/* .. External Functions .. */ |
| 16025 |
/* .. */ |
| 16026 |
/* .. Intrinsic Functions .. */ |
| 16027 |
/* .. */ |
| 16028 |
/* .. Executable Statements .. */ |
| 16029 |
|
| 16030 |
/* Parameter adjustments */ |
| 16031 |
ab_dim1 = *ldab; |
| 16032 |
ab_offset = 1 + ab_dim1; |
| 16033 |
ab -= ab_offset; |
| 16034 |
--work; |
| 16035 |
|
| 16036 |
/* Function Body */ |
| 16037 |
if (*n == 0) { |
| 16038 |
value = 0.; |
| 16039 |
} else if (lsame_(norm, "M")) { |
| 16040 |
|
| 16041 |
/* Find max(abs(A(i,j))). */ |
| 16042 |
|
| 16043 |
value = 0.; |
| 16044 |
if (lsame_(uplo, "U")) { |
| 16045 |
i__1 = *n; |
| 16046 |
for (j = 1; j <= i__1; ++j) { |
| 16047 |
/* Computing MAX */ |
| 16048 |
i__2 = *k + 2 - j; |
| 16049 |
i__3 = *k + 1; |
| 16050 |
for (i__ = std::max(i__2,1_integer); i__ <= i__3; ++i__) { |
| 16051 |
/* Computing MAX */ |
| 16052 |
d__2 = value, d__3 = (d__1 = ab[i__ + j * ab_dim1], abs( |
| 16053 |
d__1)); |
| 16054 |
value = std::max(d__2,d__3); |
| 16055 |
/* L10: */ |
| 16056 |
} |
| 16057 |
/* L20: */ |
| 16058 |
} |
| 16059 |
} else { |
| 16060 |
i__1 = *n; |
| 16061 |
for (j = 1; j <= i__1; ++j) { |
| 16062 |
/* Computing MIN */ |
| 16063 |
i__2 = *n + 1 - j, i__4 = *k + 1; |
| 16064 |
i__3 = std::min(i__2,i__4); |
| 16065 |
for (i__ = 1; i__ <= i__3; ++i__) { |
| 16066 |
/* Computing MAX */ |
| 16067 |
d__2 = value, d__3 = (d__1 = ab[i__ + j * ab_dim1], abs( |
| 16068 |
d__1)); |
| 16069 |
value = std::max(d__2,d__3); |
| 16070 |
/* L30: */ |
| 16071 |
} |
| 16072 |
/* L40: */ |
| 16073 |
} |
| 16074 |
} |
| 16075 |
} else if (lsame_(norm, "I") || lsame_(norm, "O") || *(unsigned char *)norm == '1') { |
| 16076 |
|
| 16077 |
/* Find normI(A) ( = norm1(A), since A is symmetric). */ |
| 16078 |
|
| 16079 |
value = 0.; |
| 16080 |
if (lsame_(uplo, "U")) { |
| 16081 |
i__1 = *n; |
| 16082 |
for (j = 1; j <= i__1; ++j) { |
| 16083 |
sum = 0.; |
| 16084 |
l = *k + 1 - j; |
| 16085 |
/* Computing MAX */ |
| 16086 |
i__3 = 1, i__2 = j - *k; |
| 16087 |
i__4 = j - 1; |
| 16088 |
for (i__ = std::max(i__3,i__2); i__ <= i__4; ++i__) { |
| 16089 |
absa = (d__1 = ab[l + i__ + j * ab_dim1], abs(d__1)); |
| 16090 |
sum += absa; |
| 16091 |
work[i__] += absa; |
| 16092 |
/* L50: */ |
| 16093 |
} |
| 16094 |
work[j] = sum + (d__1 = ab[*k + 1 + j * ab_dim1], abs(d__1)); |
| 16095 |
/* L60: */ |
| 16096 |
} |
| 16097 |
i__1 = *n; |
| 16098 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 16099 |
/* Computing MAX */ |
| 16100 |
d__1 = value, d__2 = work[i__]; |
| 16101 |
value = std::max(d__1,d__2); |
| 16102 |
/* L70: */ |
| 16103 |
} |
| 16104 |
} else { |
| 16105 |
i__1 = *n; |
| 16106 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 16107 |
work[i__] = 0.; |
| 16108 |
/* L80: */ |
| 16109 |
} |
| 16110 |
i__1 = *n; |
| 16111 |
for (j = 1; j <= i__1; ++j) { |
| 16112 |
sum = work[j] + (d__1 = ab[j * ab_dim1 + 1], abs(d__1)); |
| 16113 |
l = 1 - j; |
| 16114 |
/* Computing MIN */ |
| 16115 |
i__3 = *n, i__2 = j + *k; |
| 16116 |
i__4 = std::min(i__3,i__2); |
| 16117 |
for (i__ = j + 1; i__ <= i__4; ++i__) { |
| 16118 |
absa = (d__1 = ab[l + i__ + j * ab_dim1], abs(d__1)); |
| 16119 |
sum += absa; |
| 16120 |
work[i__] += absa; |
| 16121 |
/* L90: */ |
| 16122 |
} |
| 16123 |
value = std::max(value,sum); |
| 16124 |
/* L100: */ |
| 16125 |
} |
| 16126 |
} |
| 16127 |
} else if (lsame_(norm, "F") || lsame_(norm, "E")) { |
| 16128 |
|
| 16129 |
/* Find normF(A). */ |
| 16130 |
|
| 16131 |
scale = 0.; |
| 16132 |
sum = 1.; |
| 16133 |
if (*k > 0) { |
| 16134 |
if (lsame_(uplo, "U")) { |
| 16135 |
i__1 = *n; |
| 16136 |
for (j = 2; j <= i__1; ++j) { |
| 16137 |
/* Computing MIN */ |
| 16138 |
i__3 = j - 1; |
| 16139 |
i__4 = std::min(i__3,*k); |
| 16140 |
/* Computing MAX */ |
| 16141 |
i__2 = *k + 2 - j; |
| 16142 |
dlassq_(&i__4, &ab[std::max(i__2, 1_integer)+ j * ab_dim1], &c__1, & |
| 16143 |
scale, &sum); |
| 16144 |
/* L110: */ |
| 16145 |
} |
| 16146 |
l = *k + 1; |
| 16147 |
} else { |
| 16148 |
i__1 = *n - 1; |
| 16149 |
for (j = 1; j <= i__1; ++j) { |
| 16150 |
/* Computing MIN */ |
| 16151 |
i__3 = *n - j; |
| 16152 |
i__4 = std::min(i__3,*k); |
| 16153 |
dlassq_(&i__4, &ab[j * ab_dim1 + 2], &c__1, &scale, &sum); |
| 16154 |
/* L120: */ |
| 16155 |
} |
| 16156 |
l = 1; |
| 16157 |
} |
| 16158 |
sum *= 2; |
| 16159 |
} else { |
| 16160 |
l = 1; |
| 16161 |
} |
| 16162 |
dlassq_(n, &ab[l + ab_dim1], ldab, &scale, &sum); |
| 16163 |
value = scale * sqrt(sum); |
| 16164 |
} |
| 16165 |
|
| 16166 |
ret_val = value; |
| 16167 |
return ret_val; |
| 16168 |
|
| 16169 |
/* End of DLANSB */ |
| 16170 |
|
| 16171 |
} /* dlansb_ */ |
| 16172 |
|
| 16173 |
double dlansf_(const char *norm, char *transr, char *uplo, integer *n, double *a, double *work) |
| 16174 |
{ |
| 16175 |
/* Table of constant values */ |
| 16176 |
static integer c__1 = 1; |
| 16177 |
|
| 16178 |
/* System generated locals */ |
| 16179 |
integer i__1, i__2; |
| 16180 |
double ret_val, d__1, d__2, d__3; |
| 16181 |
|
| 16182 |
/* Local variables */ |
| 16183 |
integer i__, j, k, l; |
| 16184 |
double s; |
| 16185 |
integer n1; |
| 16186 |
double aa; |
| 16187 |
integer lda, ifm, noe, ilu; |
| 16188 |
double scale; |
| 16189 |
double value; |
| 16190 |
|
| 16191 |
|
| 16192 |
/* -- LAPACK routine (version 3.2) -- */ |
| 16193 |
|
| 16194 |
/* -- Contributed by Fred Gustavson of the IBM Watson Research Center -- */ |
| 16195 |
/* -- November 2008 -- */ |
| 16196 |
|
| 16197 |
/* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ |
| 16198 |
/* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ |
| 16199 |
|
| 16200 |
/* .. Scalar Arguments .. */ |
| 16201 |
/* .. */ |
| 16202 |
/* .. Array Arguments .. */ |
| 16203 |
/* .. */ |
| 16204 |
|
| 16205 |
/* Purpose */ |
| 16206 |
/* ======= */ |
| 16207 |
|
| 16208 |
/* DLANSF returns the value of the one norm, or the Frobenius norm, or */ |
| 16209 |
/* the infinity norm, or the element of largest absolute value of a */ |
| 16210 |
/* real symmetric matrix A in RFP format. */ |
| 16211 |
|
| 16212 |
/* Description */ |
| 16213 |
/* =========== */ |
| 16214 |
|
| 16215 |
/* DLANSF returns the value */ |
| 16216 |
|
| 16217 |
/* DLANSF = ( max(abs(A(i,j))), NORM = 'M' or 'm' */ |
| 16218 |
/* ( */ |
| 16219 |
/* ( norm1(A), NORM = '1', 'O' or 'o' */ |
| 16220 |
/* ( */ |
| 16221 |
/* ( normI(A), NORM = 'I' or 'i' */ |
| 16222 |
/* ( */ |
| 16223 |
/* ( normF(A), NORM = 'F', 'f', 'E' or 'e' */ |
| 16224 |
|
| 16225 |
/* where norm1 denotes the one norm of a matrix (maximum column sum), */ |
| 16226 |
/* normI denotes the infinity norm of a matrix (maximum row sum) and */ |
| 16227 |
/* normF denotes the Frobenius norm of a matrix (square root of sum of */ |
| 16228 |
/* squares). Note that max(abs(A(i,j))) is not a matrix norm. */ |
| 16229 |
|
| 16230 |
/* Arguments */ |
| 16231 |
/* ========= */ |
| 16232 |
|
| 16233 |
/* NORM (input) CHARACTER */ |
| 16234 |
/* Specifies the value to be returned in DLANSF as described */ |
| 16235 |
/* above. */ |
| 16236 |
|
| 16237 |
/* TRANSR (input) CHARACTER */ |
| 16238 |
/* Specifies whether the RFP format of A is normal or */ |
| 16239 |
/* transposed format. */ |
| 16240 |
/* = 'N': RFP format is Normal; */ |
| 16241 |
/* = 'T': RFP format is Transpose. */ |
| 16242 |
|
| 16243 |
/* UPLO (input) CHARACTER */ |
| 16244 |
/* On entry, UPLO specifies whether the RFP matrix A came from */ |
| 16245 |
/* an upper or lower triangular matrix as follows: */ |
| 16246 |
/* = 'U': RFP A came from an upper triangular matrix; */ |
| 16247 |
/* = 'L': RFP A came from a lower triangular matrix. */ |
| 16248 |
|
| 16249 |
/* N (input) INTEGER */ |
| 16250 |
/* The order of the matrix A. N >= 0. When N = 0, DLANSF is */ |
| 16251 |
/* set to zero. */ |
| 16252 |
|
| 16253 |
/* A (input) DOUBLE PRECISION array, dimension ( N*(N+1)/2 ); */ |
| 16254 |
/* On entry, the upper (if UPLO = 'U') or lower (if UPLO = 'L') */ |
| 16255 |
/* part of the symmetric matrix A stored in RFP format. See the */ |
| 16256 |
/* "Notes" below for more details. */ |
| 16257 |
/* Unchanged on exit. */ |
| 16258 |
|
| 16259 |
/* WORK (workspace) DOUBLE PRECISION array, dimension (MAX(1,LWORK)), */ |
| 16260 |
/* where LWORK >= N when NORM = 'I' or '1' or 'O'; otherwise, */ |
| 16261 |
/* WORK is not referenced. */ |
| 16262 |
|
| 16263 |
/* Notes */ |
| 16264 |
/* ===== */ |
| 16265 |
|
| 16266 |
/* We first consider Rectangular Full Packed (RFP) Format when N is */ |
| 16267 |
/* even. We give an example where N = 6. */ |
| 16268 |
|
| 16269 |
/* AP is Upper AP is Lower */ |
| 16270 |
|
| 16271 |
/* 00 01 02 03 04 05 00 */ |
| 16272 |
/* 11 12 13 14 15 10 11 */ |
| 16273 |
/* 22 23 24 25 20 21 22 */ |
| 16274 |
/* 33 34 35 30 31 32 33 */ |
| 16275 |
/* 44 45 40 41 42 43 44 */ |
| 16276 |
/* 55 50 51 52 53 54 55 */ |
| 16277 |
|
| 16278 |
|
| 16279 |
/* Let TRANSR = 'N'. RFP holds AP as follows: */ |
| 16280 |
/* For UPLO = 'U' the upper trapezoid A(0:5,0:2) consists of the last */ |
| 16281 |
/* three columns of AP upper. The lower triangle A(4:6,0:2) consists of */ |
| 16282 |
/* the transpose of the first three columns of AP upper. */ |
| 16283 |
/* For UPLO = 'L' the lower trapezoid A(1:6,0:2) consists of the first */ |
| 16284 |
/* three columns of AP lower. The upper triangle A(0:2,0:2) consists of */ |
| 16285 |
/* the transpose of the last three columns of AP lower. */ |
| 16286 |
/* This covers the case N even and TRANSR = 'N'. */ |
| 16287 |
|
| 16288 |
/* RFP A RFP A */ |
| 16289 |
|
| 16290 |
/* 03 04 05 33 43 53 */ |
| 16291 |
/* 13 14 15 00 44 54 */ |
| 16292 |
/* 23 24 25 10 11 55 */ |
| 16293 |
/* 33 34 35 20 21 22 */ |
| 16294 |
/* 00 44 45 30 31 32 */ |
| 16295 |
/* 01 11 55 40 41 42 */ |
| 16296 |
/* 02 12 22 50 51 52 */ |
| 16297 |
|
| 16298 |
/* Now let TRANSR = 'T'. RFP A in both UPLO cases is just the */ |
| 16299 |
/* transpose of RFP A above. One therefore gets: */ |
| 16300 |
|
| 16301 |
|
| 16302 |
/* RFP A RFP A */ |
| 16303 |
|
| 16304 |
/* 03 13 23 33 00 01 02 33 00 10 20 30 40 50 */ |
| 16305 |
/* 04 14 24 34 44 11 12 43 44 11 21 31 41 51 */ |
| 16306 |
/* 05 15 25 35 45 55 22 53 54 55 22 32 42 52 */ |
| 16307 |
|
| 16308 |
|
| 16309 |
/* We first consider Rectangular Full Packed (RFP) Format when N is */ |
| 16310 |
/* odd. We give an example where N = 5. */ |
| 16311 |
|
| 16312 |
/* AP is Upper AP is Lower */ |
| 16313 |
|
| 16314 |
/* 00 01 02 03 04 00 */ |
| 16315 |
/* 11 12 13 14 10 11 */ |
| 16316 |
/* 22 23 24 20 21 22 */ |
| 16317 |
/* 33 34 30 31 32 33 */ |
| 16318 |
/* 44 40 41 42 43 44 */ |
| 16319 |
|
| 16320 |
|
| 16321 |
/* Let TRANSR = 'N'. RFP holds AP as follows: */ |
| 16322 |
/* For UPLO = 'U' the upper trapezoid A(0:4,0:2) consists of the last */ |
| 16323 |
/* three columns of AP upper. The lower triangle A(3:4,0:1) consists of */ |
| 16324 |
/* the transpose of the first two columns of AP upper. */ |
| 16325 |
/* For UPLO = 'L' the lower trapezoid A(0:4,0:2) consists of the first */ |
| 16326 |
/* three columns of AP lower. The upper triangle A(0:1,1:2) consists of */ |
| 16327 |
/* the transpose of the last two columns of AP lower. */ |
| 16328 |
/* This covers the case N odd and TRANSR = 'N'. */ |
| 16329 |
|
| 16330 |
/* RFP A RFP A */ |
| 16331 |
|
| 16332 |
/* 02 03 04 00 33 43 */ |
| 16333 |
/* 12 13 14 10 11 44 */ |
| 16334 |
/* 22 23 24 20 21 22 */ |
| 16335 |
/* 00 33 34 30 31 32 */ |
| 16336 |
/* 01 11 44 40 41 42 */ |
| 16337 |
|
| 16338 |
/* Now let TRANSR = 'T'. RFP A in both UPLO cases is just the */ |
| 16339 |
/* transpose of RFP A above. One therefore gets: */ |
| 16340 |
|
| 16341 |
/* RFP A RFP A */ |
| 16342 |
|
| 16343 |
/* 02 12 22 00 01 00 10 20 30 40 50 */ |
| 16344 |
/* 03 13 23 33 11 33 11 21 31 41 51 */ |
| 16345 |
/* 04 14 24 34 44 43 44 22 32 42 52 */ |
| 16346 |
|
| 16347 |
/* Reference */ |
| 16348 |
/* ========= */ |
| 16349 |
|
| 16350 |
/* ===================================================================== */ |
| 16351 |
|
| 16352 |
/* .. Parameters .. */ |
| 16353 |
/* .. */ |
| 16354 |
/* .. Local Scalars .. */ |
| 16355 |
/* .. */ |
| 16356 |
/* .. External Functions .. */ |
| 16357 |
/* .. */ |
| 16358 |
/* .. External Subroutines .. */ |
| 16359 |
/* .. */ |
| 16360 |
/* .. Intrinsic Functions .. */ |
| 16361 |
/* .. */ |
| 16362 |
/* .. Executable Statements .. */ |
| 16363 |
|
| 16364 |
if (*n == 0) { |
| 16365 |
ret_val = 0.; |
| 16366 |
return ret_val; |
| 16367 |
} |
| 16368 |
|
| 16369 |
/* set noe = 1 if n is odd. if n is even set noe=0 */ |
| 16370 |
|
| 16371 |
noe = 1; |
| 16372 |
if (*n % 2 == 0) { |
| 16373 |
noe = 0; |
| 16374 |
} |
| 16375 |
|
| 16376 |
/* set ifm = 0 when form='T or 't' and 1 otherwise */ |
| 16377 |
|
| 16378 |
ifm = 1; |
| 16379 |
if (lsame_(transr, "T")) { |
| 16380 |
ifm = 0; |
| 16381 |
} |
| 16382 |
|
| 16383 |
/* set ilu = 0 when uplo='U or 'u' and 1 otherwise */ |
| 16384 |
|
| 16385 |
ilu = 1; |
| 16386 |
if (lsame_(uplo, "U")) { |
| 16387 |
ilu = 0; |
| 16388 |
} |
| 16389 |
|
| 16390 |
/* set lda = (n+1)/2 when ifm = 0 */ |
| 16391 |
/* set lda = n when ifm = 1 and noe = 1 */ |
| 16392 |
/* set lda = n+1 when ifm = 1 and noe = 0 */ |
| 16393 |
|
| 16394 |
if (ifm == 1) { |
| 16395 |
if (noe == 1) { |
| 16396 |
lda = *n; |
| 16397 |
} else { |
| 16398 |
/* noe=0 */ |
| 16399 |
lda = *n + 1; |
| 16400 |
} |
| 16401 |
} else { |
| 16402 |
/* ifm=0 */ |
| 16403 |
lda = (*n + 1) / 2; |
| 16404 |
} |
| 16405 |
|
| 16406 |
if (lsame_(norm, "M")) { |
| 16407 |
|
| 16408 |
/* Find max(abs(A(i,j))). */ |
| 16409 |
|
| 16410 |
k = (*n + 1) / 2; |
| 16411 |
value = 0.; |
| 16412 |
if (noe == 1) { |
| 16413 |
/* n is odd */ |
| 16414 |
if (ifm == 1) { |
| 16415 |
/* A is n by k */ |
| 16416 |
i__1 = k - 1; |
| 16417 |
for (j = 0; j <= i__1; ++j) { |
| 16418 |
i__2 = *n - 1; |
| 16419 |
for (i__ = 0; i__ <= i__2; ++i__) { |
| 16420 |
/* Computing MAX */ |
| 16421 |
d__2 = value, d__3 = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16422 |
value = std::max(d__2,d__3); |
| 16423 |
} |
| 16424 |
} |
| 16425 |
} else { |
| 16426 |
/* xpose case; A is k by n */ |
| 16427 |
i__1 = *n - 1; |
| 16428 |
for (j = 0; j <= i__1; ++j) { |
| 16429 |
i__2 = k - 1; |
| 16430 |
for (i__ = 0; i__ <= i__2; ++i__) { |
| 16431 |
/* Computing MAX */ |
| 16432 |
d__2 = value, d__3 = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16433 |
value = std::max(d__2,d__3); |
| 16434 |
} |
| 16435 |
} |
| 16436 |
} |
| 16437 |
} else { |
| 16438 |
/* n is even */ |
| 16439 |
if (ifm == 1) { |
| 16440 |
/* A is n+1 by k */ |
| 16441 |
i__1 = k - 1; |
| 16442 |
for (j = 0; j <= i__1; ++j) { |
| 16443 |
i__2 = *n; |
| 16444 |
for (i__ = 0; i__ <= i__2; ++i__) { |
| 16445 |
/* Computing MAX */ |
| 16446 |
d__2 = value, d__3 = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16447 |
value = std::max(d__2,d__3); |
| 16448 |
} |
| 16449 |
} |
| 16450 |
} else { |
| 16451 |
/* xpose case; A is k by n+1 */ |
| 16452 |
i__1 = *n; |
| 16453 |
for (j = 0; j <= i__1; ++j) { |
| 16454 |
i__2 = k - 1; |
| 16455 |
for (i__ = 0; i__ <= i__2; ++i__) { |
| 16456 |
/* Computing MAX */ |
| 16457 |
d__2 = value, d__3 = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16458 |
value = std::max(d__2,d__3); |
| 16459 |
} |
| 16460 |
} |
| 16461 |
} |
| 16462 |
} |
| 16463 |
} else if (lsame_(norm, "I") || lsame_(norm, "O") || *(unsigned char *)norm == '1') { |
| 16464 |
|
| 16465 |
/* Find normI(A) ( = norm1(A), since A is symmetric). */ |
| 16466 |
|
| 16467 |
if (ifm == 1) { |
| 16468 |
k = *n / 2; |
| 16469 |
if (noe == 1) { |
| 16470 |
/* n is odd */ |
| 16471 |
if (ilu == 0) { |
| 16472 |
i__1 = k - 1; |
| 16473 |
for (i__ = 0; i__ <= i__1; ++i__) { |
| 16474 |
work[i__] = 0.; |
| 16475 |
} |
| 16476 |
i__1 = k; |
| 16477 |
for (j = 0; j <= i__1; ++j) { |
| 16478 |
s = 0.; |
| 16479 |
i__2 = k + j - 1; |
| 16480 |
for (i__ = 0; i__ <= i__2; ++i__) { |
| 16481 |
aa = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16482 |
/* -> A(i,j+k) */ |
| 16483 |
s += aa; |
| 16484 |
work[i__] += aa; |
| 16485 |
} |
| 16486 |
aa = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16487 |
/* -> A(j+k,j+k) */ |
| 16488 |
work[j + k] = s + aa; |
| 16489 |
if (i__ == k + k) { |
| 16490 |
goto L10; |
| 16491 |
} |
| 16492 |
++i__; |
| 16493 |
aa = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16494 |
/* -> A(j,j) */ |
| 16495 |
work[j] += aa; |
| 16496 |
s = 0.; |
| 16497 |
i__2 = k - 1; |
| 16498 |
for (l = j + 1; l <= i__2; ++l) { |
| 16499 |
++i__; |
| 16500 |
aa = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16501 |
/* -> A(l,j) */ |
| 16502 |
s += aa; |
| 16503 |
work[l] += aa; |
| 16504 |
} |
| 16505 |
work[j] += s; |
| 16506 |
} |
| 16507 |
L10: |
| 16508 |
i__ = idamax_(n, work, &c__1); |
| 16509 |
value = work[i__ - 1]; |
| 16510 |
} else { |
| 16511 |
/* ilu = 1 */ |
| 16512 |
++k; |
| 16513 |
/* k=(n+1)/2 for n odd and ilu=1 */ |
| 16514 |
i__1 = *n - 1; |
| 16515 |
for (i__ = k; i__ <= i__1; ++i__) { |
| 16516 |
work[i__] = 0.; |
| 16517 |
} |
| 16518 |
for (j = k - 1; j >= 0; --j) { |
| 16519 |
s = 0.; |
| 16520 |
i__1 = j - 2; |
| 16521 |
for (i__ = 0; i__ <= i__1; ++i__) { |
| 16522 |
aa = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16523 |
/* -> A(j+k,i+k) */ |
| 16524 |
s += aa; |
| 16525 |
work[i__ + k] += aa; |
| 16526 |
} |
| 16527 |
if (j > 0) { |
| 16528 |
aa = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16529 |
/* -> A(j+k,j+k) */ |
| 16530 |
s += aa; |
| 16531 |
work[i__ + k] += s; |
| 16532 |
/* i=j */ |
| 16533 |
++i__; |
| 16534 |
} |
| 16535 |
aa = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16536 |
/* -> A(j,j) */ |
| 16537 |
work[j] = aa; |
| 16538 |
s = 0.; |
| 16539 |
i__1 = *n - 1; |
| 16540 |
for (l = j + 1; l <= i__1; ++l) { |
| 16541 |
++i__; |
| 16542 |
aa = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16543 |
/* -> A(l,j) */ |
| 16544 |
s += aa; |
| 16545 |
work[l] += aa; |
| 16546 |
} |
| 16547 |
work[j] += s; |
| 16548 |
} |
| 16549 |
i__ = idamax_(n, work, &c__1); |
| 16550 |
value = work[i__ - 1]; |
| 16551 |
} |
| 16552 |
} else { |
| 16553 |
/* n is even */ |
| 16554 |
if (ilu == 0) { |
| 16555 |
i__1 = k - 1; |
| 16556 |
for (i__ = 0; i__ <= i__1; ++i__) { |
| 16557 |
work[i__] = 0.; |
| 16558 |
} |
| 16559 |
i__1 = k - 1; |
| 16560 |
for (j = 0; j <= i__1; ++j) { |
| 16561 |
s = 0.; |
| 16562 |
i__2 = k + j - 1; |
| 16563 |
for (i__ = 0; i__ <= i__2; ++i__) { |
| 16564 |
aa = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16565 |
/* -> A(i,j+k) */ |
| 16566 |
s += aa; |
| 16567 |
work[i__] += aa; |
| 16568 |
} |
| 16569 |
aa = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16570 |
/* -> A(j+k,j+k) */ |
| 16571 |
work[j + k] = s + aa; |
| 16572 |
++i__; |
| 16573 |
aa = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16574 |
/* -> A(j,j) */ |
| 16575 |
work[j] += aa; |
| 16576 |
s = 0.; |
| 16577 |
i__2 = k - 1; |
| 16578 |
for (l = j + 1; l <= i__2; ++l) { |
| 16579 |
++i__; |
| 16580 |
aa = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16581 |
/* -> A(l,j) */ |
| 16582 |
s += aa; |
| 16583 |
work[l] += aa; |
| 16584 |
} |
| 16585 |
work[j] += s; |
| 16586 |
} |
| 16587 |
i__ = idamax_(n, work, &c__1); |
| 16588 |
value = work[i__ - 1]; |
| 16589 |
} else { |
| 16590 |
/* ilu = 1 */ |
| 16591 |
i__1 = *n - 1; |
| 16592 |
for (i__ = k; i__ <= i__1; ++i__) { |
| 16593 |
work[i__] = 0.; |
| 16594 |
} |
| 16595 |
for (j = k - 1; j >= 0; --j) { |
| 16596 |
s = 0.; |
| 16597 |
i__1 = j - 1; |
| 16598 |
for (i__ = 0; i__ <= i__1; ++i__) { |
| 16599 |
aa = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16600 |
/* -> A(j+k,i+k) */ |
| 16601 |
s += aa; |
| 16602 |
work[i__ + k] += aa; |
| 16603 |
} |
| 16604 |
aa = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16605 |
/* -> A(j+k,j+k) */ |
| 16606 |
s += aa; |
| 16607 |
work[i__ + k] += s; |
| 16608 |
/* i=j */ |
| 16609 |
++i__; |
| 16610 |
aa = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16611 |
/* -> A(j,j) */ |
| 16612 |
work[j] = aa; |
| 16613 |
s = 0.; |
| 16614 |
i__1 = *n - 1; |
| 16615 |
for (l = j + 1; l <= i__1; ++l) { |
| 16616 |
++i__; |
| 16617 |
aa = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16618 |
/* -> A(l,j) */ |
| 16619 |
s += aa; |
| 16620 |
work[l] += aa; |
| 16621 |
} |
| 16622 |
work[j] += s; |
| 16623 |
} |
| 16624 |
i__ = idamax_(n, work, &c__1); |
| 16625 |
value = work[i__ - 1]; |
| 16626 |
} |
| 16627 |
} |
| 16628 |
} else { |
| 16629 |
/* ifm=0 */ |
| 16630 |
k = *n / 2; |
| 16631 |
if (noe == 1) { |
| 16632 |
/* n is odd */ |
| 16633 |
if (ilu == 0) { |
| 16634 |
n1 = k; |
| 16635 |
/* n/2 */ |
| 16636 |
++k; |
| 16637 |
/* k is the row size and lda */ |
| 16638 |
i__1 = *n - 1; |
| 16639 |
for (i__ = n1; i__ <= i__1; ++i__) { |
| 16640 |
work[i__] = 0.; |
| 16641 |
} |
| 16642 |
i__1 = n1 - 1; |
| 16643 |
for (j = 0; j <= i__1; ++j) { |
| 16644 |
s = 0.; |
| 16645 |
i__2 = k - 1; |
| 16646 |
for (i__ = 0; i__ <= i__2; ++i__) { |
| 16647 |
aa = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16648 |
/* A(j,n1+i) */ |
| 16649 |
work[i__ + n1] += aa; |
| 16650 |
s += aa; |
| 16651 |
} |
| 16652 |
work[j] = s; |
| 16653 |
} |
| 16654 |
/* j=n1=k-1 is special */ |
| 16655 |
s = (d__1 = a[j * lda], abs(d__1)); |
| 16656 |
/* A(k-1,k-1) */ |
| 16657 |
i__1 = k - 1; |
| 16658 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 16659 |
aa = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16660 |
/* A(k-1,i+n1) */ |
| 16661 |
work[i__ + n1] += aa; |
| 16662 |
s += aa; |
| 16663 |
} |
| 16664 |
work[j] += s; |
| 16665 |
i__1 = *n - 1; |
| 16666 |
for (j = k; j <= i__1; ++j) { |
| 16667 |
s = 0.; |
| 16668 |
i__2 = j - k - 1; |
| 16669 |
for (i__ = 0; i__ <= i__2; ++i__) { |
| 16670 |
aa = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16671 |
/* A(i,j-k) */ |
| 16672 |
work[i__] += aa; |
| 16673 |
s += aa; |
| 16674 |
} |
| 16675 |
/* i=j-k */ |
| 16676 |
aa = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16677 |
/* A(j-k,j-k) */ |
| 16678 |
s += aa; |
| 16679 |
work[j - k] += s; |
| 16680 |
++i__; |
| 16681 |
s = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16682 |
/* A(j,j) */ |
| 16683 |
i__2 = *n - 1; |
| 16684 |
for (l = j + 1; l <= i__2; ++l) { |
| 16685 |
++i__; |
| 16686 |
aa = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16687 |
/* A(j,l) */ |
| 16688 |
work[l] += aa; |
| 16689 |
s += aa; |
| 16690 |
} |
| 16691 |
work[j] += s; |
| 16692 |
} |
| 16693 |
i__ = idamax_(n, work, &c__1); |
| 16694 |
value = work[i__ - 1]; |
| 16695 |
} else { |
| 16696 |
/* ilu=1 */ |
| 16697 |
++k; |
| 16698 |
/* k=(n+1)/2 for n odd and ilu=1 */ |
| 16699 |
i__1 = *n - 1; |
| 16700 |
for (i__ = k; i__ <= i__1; ++i__) { |
| 16701 |
work[i__] = 0.; |
| 16702 |
} |
| 16703 |
i__1 = k - 2; |
| 16704 |
for (j = 0; j <= i__1; ++j) { |
| 16705 |
/* process */ |
| 16706 |
s = 0.; |
| 16707 |
i__2 = j - 1; |
| 16708 |
for (i__ = 0; i__ <= i__2; ++i__) { |
| 16709 |
aa = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16710 |
/* A(j,i) */ |
| 16711 |
work[i__] += aa; |
| 16712 |
s += aa; |
| 16713 |
} |
| 16714 |
aa = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16715 |
/* i=j so process of A(j,j) */ |
| 16716 |
s += aa; |
| 16717 |
work[j] = s; |
| 16718 |
/* is initialised here */ |
| 16719 |
++i__; |
| 16720 |
/* i=j process A(j+k,j+k) */ |
| 16721 |
aa = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16722 |
s = aa; |
| 16723 |
i__2 = *n - 1; |
| 16724 |
for (l = k + j + 1; l <= i__2; ++l) { |
| 16725 |
++i__; |
| 16726 |
aa = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16727 |
/* A(l,k+j) */ |
| 16728 |
s += aa; |
| 16729 |
work[l] += aa; |
| 16730 |
} |
| 16731 |
work[k + j] += s; |
| 16732 |
} |
| 16733 |
/* j=k-1 is special :process col A(k-1,0:k-1) */ |
| 16734 |
s = 0.; |
| 16735 |
i__1 = k - 2; |
| 16736 |
for (i__ = 0; i__ <= i__1; ++i__) { |
| 16737 |
aa = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16738 |
/* A(k,i) */ |
| 16739 |
work[i__] += aa; |
| 16740 |
s += aa; |
| 16741 |
} |
| 16742 |
/* i=k-1 */ |
| 16743 |
aa = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16744 |
/* A(k-1,k-1) */ |
| 16745 |
s += aa; |
| 16746 |
work[i__] = s; |
| 16747 |
/* done with col j=k+1 */ |
| 16748 |
i__1 = *n - 1; |
| 16749 |
for (j = k; j <= i__1; ++j) { |
| 16750 |
/* process col j of A = A(j,0:k-1) */ |
| 16751 |
s = 0.; |
| 16752 |
i__2 = k - 1; |
| 16753 |
for (i__ = 0; i__ <= i__2; ++i__) { |
| 16754 |
aa = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16755 |
/* A(j,i) */ |
| 16756 |
work[i__] += aa; |
| 16757 |
s += aa; |
| 16758 |
} |
| 16759 |
work[j] += s; |
| 16760 |
} |
| 16761 |
i__ = idamax_(n, work, &c__1); |
| 16762 |
value = work[i__ - 1]; |
| 16763 |
} |
| 16764 |
} else { |
| 16765 |
/* n is even */ |
| 16766 |
if (ilu == 0) { |
| 16767 |
i__1 = *n - 1; |
| 16768 |
for (i__ = k; i__ <= i__1; ++i__) { |
| 16769 |
work[i__] = 0.; |
| 16770 |
} |
| 16771 |
i__1 = k - 1; |
| 16772 |
for (j = 0; j <= i__1; ++j) { |
| 16773 |
s = 0.; |
| 16774 |
i__2 = k - 1; |
| 16775 |
for (i__ = 0; i__ <= i__2; ++i__) { |
| 16776 |
aa = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16777 |
/* A(j,i+k) */ |
| 16778 |
work[i__ + k] += aa; |
| 16779 |
s += aa; |
| 16780 |
} |
| 16781 |
work[j] = s; |
| 16782 |
} |
| 16783 |
/* j=k */ |
| 16784 |
aa = (d__1 = a[j * lda], abs(d__1)); |
| 16785 |
/* A(k,k) */ |
| 16786 |
s = aa; |
| 16787 |
i__1 = k - 1; |
| 16788 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 16789 |
aa = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16790 |
/* A(k,k+i) */ |
| 16791 |
work[i__ + k] += aa; |
| 16792 |
s += aa; |
| 16793 |
} |
| 16794 |
work[j] += s; |
| 16795 |
i__1 = *n - 1; |
| 16796 |
for (j = k + 1; j <= i__1; ++j) { |
| 16797 |
s = 0.; |
| 16798 |
i__2 = j - 2 - k; |
| 16799 |
for (i__ = 0; i__ <= i__2; ++i__) { |
| 16800 |
aa = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16801 |
/* A(i,j-k-1) */ |
| 16802 |
work[i__] += aa; |
| 16803 |
s += aa; |
| 16804 |
} |
| 16805 |
/* i=j-1-k */ |
| 16806 |
aa = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16807 |
/* A(j-k-1,j-k-1) */ |
| 16808 |
s += aa; |
| 16809 |
work[j - k - 1] += s; |
| 16810 |
++i__; |
| 16811 |
aa = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16812 |
/* A(j,j) */ |
| 16813 |
s = aa; |
| 16814 |
i__2 = *n - 1; |
| 16815 |
for (l = j + 1; l <= i__2; ++l) { |
| 16816 |
++i__; |
| 16817 |
aa = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16818 |
/* A(j,l) */ |
| 16819 |
work[l] += aa; |
| 16820 |
s += aa; |
| 16821 |
} |
| 16822 |
work[j] += s; |
| 16823 |
} |
| 16824 |
/* j=n */ |
| 16825 |
s = 0.; |
| 16826 |
i__1 = k - 2; |
| 16827 |
for (i__ = 0; i__ <= i__1; ++i__) { |
| 16828 |
aa = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16829 |
/* A(i,k-1) */ |
| 16830 |
work[i__] += aa; |
| 16831 |
s += aa; |
| 16832 |
} |
| 16833 |
/* i=k-1 */ |
| 16834 |
aa = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16835 |
/* A(k-1,k-1) */ |
| 16836 |
s += aa; |
| 16837 |
work[i__] += s; |
| 16838 |
i__ = idamax_(n, work, &c__1); |
| 16839 |
value = work[i__ - 1]; |
| 16840 |
} else { |
| 16841 |
/* ilu=1 */ |
| 16842 |
i__1 = *n - 1; |
| 16843 |
for (i__ = k; i__ <= i__1; ++i__) { |
| 16844 |
work[i__] = 0.; |
| 16845 |
} |
| 16846 |
/* j=0 is special :process col A(k:n-1,k) */ |
| 16847 |
s = abs(a[0]); |
| 16848 |
/* A(k,k) */ |
| 16849 |
i__1 = k - 1; |
| 16850 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 16851 |
aa = (d__1 = a[i__], abs(d__1)); |
| 16852 |
/* A(k+i,k) */ |
| 16853 |
work[i__ + k] += aa; |
| 16854 |
s += aa; |
| 16855 |
} |
| 16856 |
work[k] += s; |
| 16857 |
i__1 = k - 1; |
| 16858 |
for (j = 1; j <= i__1; ++j) { |
| 16859 |
/* process */ |
| 16860 |
s = 0.; |
| 16861 |
i__2 = j - 2; |
| 16862 |
for (i__ = 0; i__ <= i__2; ++i__) { |
| 16863 |
aa = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16864 |
/* A(j-1,i) */ |
| 16865 |
work[i__] += aa; |
| 16866 |
s += aa; |
| 16867 |
} |
| 16868 |
aa = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16869 |
/* i=j-1 so process of A(j-1,j-1) */ |
| 16870 |
s += aa; |
| 16871 |
work[j - 1] = s; |
| 16872 |
/* is initialised here */ |
| 16873 |
++i__; |
| 16874 |
/* i=j process A(j+k,j+k) */ |
| 16875 |
aa = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16876 |
s = aa; |
| 16877 |
i__2 = *n - 1; |
| 16878 |
for (l = k + j + 1; l <= i__2; ++l) { |
| 16879 |
++i__; |
| 16880 |
aa = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16881 |
/* A(l,k+j) */ |
| 16882 |
s += aa; |
| 16883 |
work[l] += aa; |
| 16884 |
} |
| 16885 |
work[k + j] += s; |
| 16886 |
} |
| 16887 |
/* j=k is special :process col A(k,0:k-1) */ |
| 16888 |
s = 0.; |
| 16889 |
i__1 = k - 2; |
| 16890 |
for (i__ = 0; i__ <= i__1; ++i__) { |
| 16891 |
aa = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16892 |
/* A(k,i) */ |
| 16893 |
work[i__] += aa; |
| 16894 |
s += aa; |
| 16895 |
} |
| 16896 |
/* i=k-1 */ |
| 16897 |
aa = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16898 |
/* A(k-1,k-1) */ |
| 16899 |
s += aa; |
| 16900 |
work[i__] = s; |
| 16901 |
/* done with col j=k+1 */ |
| 16902 |
i__1 = *n; |
| 16903 |
for (j = k + 1; j <= i__1; ++j) { |
| 16904 |
/* process col j-1 of A = A(j-1,0:k-1) */ |
| 16905 |
s = 0.; |
| 16906 |
i__2 = k - 1; |
| 16907 |
for (i__ = 0; i__ <= i__2; ++i__) { |
| 16908 |
aa = (d__1 = a[i__ + j * lda], abs(d__1)); |
| 16909 |
/* A(j-1,i) */ |
| 16910 |
work[i__] += aa; |
| 16911 |
s += aa; |
| 16912 |
} |
| 16913 |
work[j - 1] += s; |
| 16914 |
} |
| 16915 |
i__ = idamax_(n, work, &c__1); |
| 16916 |
value = work[i__ - 1]; |
| 16917 |
} |
| 16918 |
} |
| 16919 |
} |
| 16920 |
} else if (lsame_(norm, "F") || lsame_(norm, "E")) { |
| 16921 |
|
| 16922 |
/* Find normF(A). */ |
| 16923 |
|
| 16924 |
k = (*n + 1) / 2; |
| 16925 |
scale = 0.; |
| 16926 |
s = 1.; |
| 16927 |
if (noe == 1) { |
| 16928 |
/* n is odd */ |
| 16929 |
if (ifm == 1) { |
| 16930 |
/* A is normal */ |
| 16931 |
if (ilu == 0) { |
| 16932 |
/* A is upper */ |
| 16933 |
i__1 = k - 3; |
| 16934 |
for (j = 0; j <= i__1; ++j) { |
| 16935 |
i__2 = k - j - 2; |
| 16936 |
dlassq_(&i__2, &a[k + j + 1 + j * lda], &c__1, &scale, |
| 16937 |
&s); |
| 16938 |
/* L at A(k,0) */ |
| 16939 |
} |
| 16940 |
i__1 = k - 1; |
| 16941 |
for (j = 0; j <= i__1; ++j) { |
| 16942 |
i__2 = k + j - 1; |
| 16943 |
dlassq_(&i__2, &a[j * lda], &c__1, &scale, &s); |
| 16944 |
/* trap U at A(0,0) */ |
| 16945 |
} |
| 16946 |
s += s; |
| 16947 |
/* double s for the off diagonal elements */ |
| 16948 |
i__1 = k - 1; |
| 16949 |
i__2 = lda + 1; |
| 16950 |
dlassq_(&i__1, &a[k], &i__2, &scale, &s); |
| 16951 |
/* tri L at A(k,0) */ |
| 16952 |
i__1 = lda + 1; |
| 16953 |
dlassq_(&k, &a[k - 1], &i__1, &scale, &s); |
| 16954 |
/* tri U at A(k-1,0) */ |
| 16955 |
} else { |
| 16956 |
/* ilu=1 & A is lower */ |
| 16957 |
i__1 = k - 1; |
| 16958 |
for (j = 0; j <= i__1; ++j) { |
| 16959 |
i__2 = *n - j - 1; |
| 16960 |
dlassq_(&i__2, &a[j + 1 + j * lda], &c__1, &scale, &s) |
| 16961 |
; |
| 16962 |
/* trap L at A(0,0) */ |
| 16963 |
} |
| 16964 |
i__1 = k - 2; |
| 16965 |
for (j = 0; j <= i__1; ++j) { |
| 16966 |
dlassq_(&j, &a[(j + 1) * lda], &c__1, &scale, &s); |
| 16967 |
/* U at A(0,1) */ |
| 16968 |
} |
| 16969 |
s += s; |
| 16970 |
/* double s for the off diagonal elements */ |
| 16971 |
i__1 = lda + 1; |
| 16972 |
dlassq_(&k, a, &i__1, &scale, &s); |
| 16973 |
/* tri L at A(0,0) */ |
| 16974 |
i__1 = k - 1; |
| 16975 |
i__2 = lda + 1; |
| 16976 |
dlassq_(&i__1, &a[lda], &i__2, &scale, &s); |
| 16977 |
/* tri U at A(0,1) */ |
| 16978 |
} |
| 16979 |
} else { |
| 16980 |
/* A is xpose */ |
| 16981 |
if (ilu == 0) { |
| 16982 |
/* A' is upper */ |
| 16983 |
i__1 = k - 2; |
| 16984 |
for (j = 1; j <= i__1; ++j) { |
| 16985 |
dlassq_(&j, &a[(k + j) * lda], &c__1, &scale, &s); |
| 16986 |
/* U at A(0,k) */ |
| 16987 |
} |
| 16988 |
i__1 = k - 2; |
| 16989 |
for (j = 0; j <= i__1; ++j) { |
| 16990 |
dlassq_(&k, &a[j * lda], &c__1, &scale, &s); |
| 16991 |
/* k by k-1 rect. at A(0,0) */ |
| 16992 |
} |
| 16993 |
i__1 = k - 2; |
| 16994 |
for (j = 0; j <= i__1; ++j) { |
| 16995 |
i__2 = k - j - 1; |
| 16996 |
dlassq_(&i__2, &a[j + 1 + (j + k - 1) * lda], &c__1, & |
| 16997 |
scale, &s); |
| 16998 |
/* L at A(0,k-1) */ |
| 16999 |
} |
| 17000 |
s += s; |
| 17001 |
/* double s for the off diagonal elements */ |
| 17002 |
i__1 = k - 1; |
| 17003 |
i__2 = lda + 1; |
| 17004 |
dlassq_(&i__1, &a[k * lda], &i__2, &scale, &s); |
| 17005 |
/* tri U at A(0,k) */ |
| 17006 |
i__1 = lda + 1; |
| 17007 |
dlassq_(&k, &a[(k - 1) * lda], &i__1, &scale, &s); |
| 17008 |
/* tri L at A(0,k-1) */ |
| 17009 |
} else { |
| 17010 |
/* A' is lower */ |
| 17011 |
i__1 = k - 1; |
| 17012 |
for (j = 1; j <= i__1; ++j) { |
| 17013 |
dlassq_(&j, &a[j * lda], &c__1, &scale, &s); |
| 17014 |
/* U at A(0,0) */ |
| 17015 |
} |
| 17016 |
i__1 = *n - 1; |
| 17017 |
for (j = k; j <= i__1; ++j) { |
| 17018 |
dlassq_(&k, &a[j * lda], &c__1, &scale, &s); |
| 17019 |
/* k by k-1 rect. at A(0,k) */ |
| 17020 |
} |
| 17021 |
i__1 = k - 3; |
| 17022 |
for (j = 0; j <= i__1; ++j) { |
| 17023 |
i__2 = k - j - 2; |
| 17024 |
dlassq_(&i__2, &a[j + 2 + j * lda], &c__1, &scale, &s) |
| 17025 |
; |
| 17026 |
/* L at A(1,0) */ |
| 17027 |
} |
| 17028 |
s += s; |
| 17029 |
/* double s for the off diagonal elements */ |
| 17030 |
i__1 = lda + 1; |
| 17031 |
dlassq_(&k, a, &i__1, &scale, &s); |
| 17032 |
/* tri U at A(0,0) */ |
| 17033 |
i__1 = k - 1; |
| 17034 |
i__2 = lda + 1; |
| 17035 |
dlassq_(&i__1, &a[1], &i__2, &scale, &s); |
| 17036 |
/* tri L at A(1,0) */ |
| 17037 |
} |
| 17038 |
} |
| 17039 |
} else { |
| 17040 |
/* n is even */ |
| 17041 |
if (ifm == 1) { |
| 17042 |
/* A is normal */ |
| 17043 |
if (ilu == 0) { |
| 17044 |
/* A is upper */ |
| 17045 |
i__1 = k - 2; |
| 17046 |
for (j = 0; j <= i__1; ++j) { |
| 17047 |
i__2 = k - j - 1; |
| 17048 |
dlassq_(&i__2, &a[k + j + 2 + j * lda], &c__1, &scale, |
| 17049 |
&s); |
| 17050 |
/* L at A(k+1,0) */ |
| 17051 |
} |
| 17052 |
i__1 = k - 1; |
| 17053 |
for (j = 0; j <= i__1; ++j) { |
| 17054 |
i__2 = k + j; |
| 17055 |
dlassq_(&i__2, &a[j * lda], &c__1, &scale, &s); |
| 17056 |
/* trap U at A(0,0) */ |
| 17057 |
} |
| 17058 |
s += s; |
| 17059 |
/* double s for the off diagonal elements */ |
| 17060 |
i__1 = lda + 1; |
| 17061 |
dlassq_(&k, &a[k + 1], &i__1, &scale, &s); |
| 17062 |
/* tri L at A(k+1,0) */ |
| 17063 |
i__1 = lda + 1; |
| 17064 |
dlassq_(&k, &a[k], &i__1, &scale, &s); |
| 17065 |
/* tri U at A(k,0) */ |
| 17066 |
} else { |
| 17067 |
/* ilu=1 & A is lower */ |
| 17068 |
i__1 = k - 1; |
| 17069 |
for (j = 0; j <= i__1; ++j) { |
| 17070 |
i__2 = *n - j - 1; |
| 17071 |
dlassq_(&i__2, &a[j + 2 + j * lda], &c__1, &scale, &s) |
| 17072 |
; |
| 17073 |
/* trap L at A(1,0) */ |
| 17074 |
} |
| 17075 |
i__1 = k - 1; |
| 17076 |
for (j = 1; j <= i__1; ++j) { |
| 17077 |
dlassq_(&j, &a[j * lda], &c__1, &scale, &s); |
| 17078 |
/* U at A(0,0) */ |
| 17079 |
} |
| 17080 |
s += s; |
| 17081 |
/* double s for the off diagonal elements */ |
| 17082 |
i__1 = lda + 1; |
| 17083 |
dlassq_(&k, &a[1], &i__1, &scale, &s); |
| 17084 |
/* tri L at A(1,0) */ |
| 17085 |
i__1 = lda + 1; |
| 17086 |
dlassq_(&k, a, &i__1, &scale, &s); |
| 17087 |
/* tri U at A(0,0) */ |
| 17088 |
} |
| 17089 |
} else { |
| 17090 |
/* A is xpose */ |
| 17091 |
if (ilu == 0) { |
| 17092 |
/* A' is upper */ |
| 17093 |
i__1 = k - 1; |
| 17094 |
for (j = 1; j <= i__1; ++j) { |
| 17095 |
dlassq_(&j, &a[(k + 1 + j) * lda], &c__1, &scale, &s); |
| 17096 |
/* U at A(0,k+1) */ |
| 17097 |
} |
| 17098 |
i__1 = k - 1; |
| 17099 |
for (j = 0; j <= i__1; ++j) { |
| 17100 |
dlassq_(&k, &a[j * lda], &c__1, &scale, &s); |
| 17101 |
/* k by k rect. at A(0,0) */ |
| 17102 |
} |
| 17103 |
i__1 = k - 2; |
| 17104 |
for (j = 0; j <= i__1; ++j) { |
| 17105 |
i__2 = k - j - 1; |
| 17106 |
dlassq_(&i__2, &a[j + 1 + (j + k) * lda], &c__1, & |
| 17107 |
scale, &s); |
| 17108 |
/* L at A(0,k) */ |
| 17109 |
} |
| 17110 |
s += s; |
| 17111 |
/* double s for the off diagonal elements */ |
| 17112 |
i__1 = lda + 1; |
| 17113 |
dlassq_(&k, &a[(k + 1) * lda], &i__1, &scale, &s); |
| 17114 |
/* tri U at A(0,k+1) */ |
| 17115 |
i__1 = lda + 1; |
| 17116 |
dlassq_(&k, &a[k * lda], &i__1, &scale, &s); |
| 17117 |
/* tri L at A(0,k) */ |
| 17118 |
} else { |
| 17119 |
/* A' is lower */ |
| 17120 |
i__1 = k - 1; |
| 17121 |
for (j = 1; j <= i__1; ++j) { |
| 17122 |
dlassq_(&j, &a[(j + 1) * lda], &c__1, &scale, &s); |
| 17123 |
/* U at A(0,1) */ |
| 17124 |
} |
| 17125 |
i__1 = *n; |
| 17126 |
for (j = k + 1; j <= i__1; ++j) { |
| 17127 |
dlassq_(&k, &a[j * lda], &c__1, &scale, &s); |
| 17128 |
/* k by k rect. at A(0,k+1) */ |
| 17129 |
} |
| 17130 |
i__1 = k - 2; |
| 17131 |
for (j = 0; j <= i__1; ++j) { |
| 17132 |
i__2 = k - j - 1; |
| 17133 |
dlassq_(&i__2, &a[j + 1 + j * lda], &c__1, &scale, &s) |
| 17134 |
; |
| 17135 |
/* L at A(0,0) */ |
| 17136 |
} |
| 17137 |
s += s; |
| 17138 |
/* double s for the off diagonal elements */ |
| 17139 |
i__1 = lda + 1; |
| 17140 |
dlassq_(&k, &a[lda], &i__1, &scale, &s); |
| 17141 |
/* tri L at A(0,1) */ |
| 17142 |
i__1 = lda + 1; |
| 17143 |
dlassq_(&k, a, &i__1, &scale, &s); |
| 17144 |
/* tri U at A(0,0) */ |
| 17145 |
} |
| 17146 |
} |
| 17147 |
} |
| 17148 |
value = scale * sqrt(s); |
| 17149 |
} |
| 17150 |
|
| 17151 |
ret_val = value; |
| 17152 |
return ret_val; |
| 17153 |
|
| 17154 |
/* End of DLANSF */ |
| 17155 |
|
| 17156 |
} /* dlansf_ */ |
| 17157 |
|
| 17158 |
/* Subroutine */ double dlansp_(const char *norm, const char *uplo, integer *n, double *ap, |
| 17159 |
double *work) |
| 17160 |
{ |
| 17161 |
/* Table of constant values */ |
| 17162 |
static integer c__1 = 1; |
| 17163 |
|
| 17164 |
/* System generated locals */ |
| 17165 |
integer i__1, i__2; |
| 17166 |
double ret_val, d__1, d__2, d__3; |
| 17167 |
|
| 17168 |
/* Local variables */ |
| 17169 |
integer i__, j, k; |
| 17170 |
double sum, absa, scale; |
| 17171 |
double value; |
| 17172 |
|
| 17173 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 17174 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 17175 |
/* November 2006 */ |
| 17176 |
|
| 17177 |
/* .. Scalar Arguments .. */ |
| 17178 |
/* .. */ |
| 17179 |
/* .. Array Arguments .. */ |
| 17180 |
/* .. */ |
| 17181 |
|
| 17182 |
/* Purpose */ |
| 17183 |
/* ======= */ |
| 17184 |
|
| 17185 |
/* DLANSP returns the value of the one norm, or the Frobenius norm, or */ |
| 17186 |
/* the infinity norm, or the element of largest absolute value of a */ |
| 17187 |
/* real symmetric matrix A, supplied in packed form. */ |
| 17188 |
|
| 17189 |
/* Description */ |
| 17190 |
/* =========== */ |
| 17191 |
|
| 17192 |
/* DLANSP returns the value */ |
| 17193 |
|
| 17194 |
/* DLANSP = ( max(abs(A(i,j))), NORM = 'M' or 'm' */ |
| 17195 |
/* ( */ |
| 17196 |
/* ( norm1(A), NORM = '1', 'O' or 'o' */ |
| 17197 |
/* ( */ |
| 17198 |
/* ( normI(A), NORM = 'I' or 'i' */ |
| 17199 |
/* ( */ |
| 17200 |
/* ( normF(A), NORM = 'F', 'f', 'E' or 'e' */ |
| 17201 |
|
| 17202 |
/* where norm1 denotes the one norm of a matrix (maximum column sum), */ |
| 17203 |
/* normI denotes the infinity norm of a matrix (maximum row sum) and */ |
| 17204 |
/* normF denotes the Frobenius norm of a matrix (square root of sum of */ |
| 17205 |
/* squares). Note that max(abs(A(i,j))) is not a consistent matrix norm. */ |
| 17206 |
|
| 17207 |
/* Arguments */ |
| 17208 |
/* ========= */ |
| 17209 |
|
| 17210 |
/* NORM (input) CHARACTER*1 */ |
| 17211 |
/* Specifies the value to be returned in DLANSP as described */ |
| 17212 |
/* above. */ |
| 17213 |
|
| 17214 |
/* UPLO (input) CHARACTER*1 */ |
| 17215 |
/* Specifies whether the upper or lower triangular part of the */ |
| 17216 |
/* symmetric matrix A is supplied. */ |
| 17217 |
/* = 'U': Upper triangular part of A is supplied */ |
| 17218 |
/* = 'L': Lower triangular part of A is supplied */ |
| 17219 |
|
| 17220 |
/* N (input) INTEGER */ |
| 17221 |
/* The order of the matrix A. N >= 0. When N = 0, DLANSP is */ |
| 17222 |
/* set to zero. */ |
| 17223 |
|
| 17224 |
/* AP (input) DOUBLE PRECISION array, dimension (N*(N+1)/2) */ |
| 17225 |
/* The upper or lower triangle of the symmetric matrix A, packed */ |
| 17226 |
/* columnwise in a linear array. The j-th column of A is stored */ |
| 17227 |
/* in the array AP as follows: */ |
| 17228 |
/* if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; */ |
| 17229 |
/* if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n. */ |
| 17230 |
|
| 17231 |
/* WORK (workspace) DOUBLE PRECISION array, dimension (MAX(1,LWORK)), */ |
| 17232 |
/* where LWORK >= N when NORM = 'I' or '1' or 'O'; otherwise, */ |
| 17233 |
/* WORK is not referenced. */ |
| 17234 |
|
| 17235 |
/* ===================================================================== */ |
| 17236 |
|
| 17237 |
/* .. Parameters .. */ |
| 17238 |
/* .. */ |
| 17239 |
/* .. Local Scalars .. */ |
| 17240 |
/* .. */ |
| 17241 |
/* .. External Subroutines .. */ |
| 17242 |
/* .. */ |
| 17243 |
/* .. External Functions .. */ |
| 17244 |
/* .. */ |
| 17245 |
/* .. Intrinsic Functions .. */ |
| 17246 |
/* .. */ |
| 17247 |
/* .. Executable Statements .. */ |
| 17248 |
|
| 17249 |
/* Parameter adjustments */ |
| 17250 |
--work; |
| 17251 |
--ap; |
| 17252 |
|
| 17253 |
/* Function Body */ |
| 17254 |
if (*n == 0) { |
| 17255 |
value = 0.; |
| 17256 |
} else if (lsame_(norm, "M")) { |
| 17257 |
|
| 17258 |
/* Find max(abs(A(i,j))). */ |
| 17259 |
|
| 17260 |
value = 0.; |
| 17261 |
if (lsame_(uplo, "U")) { |
| 17262 |
k = 1; |
| 17263 |
i__1 = *n; |
| 17264 |
for (j = 1; j <= i__1; ++j) { |
| 17265 |
i__2 = k + j - 1; |
| 17266 |
for (i__ = k; i__ <= i__2; ++i__) { |
| 17267 |
/* Computing MAX */ |
| 17268 |
d__2 = value, d__3 = (d__1 = ap[i__], abs(d__1)); |
| 17269 |
value = std::max(d__2,d__3); |
| 17270 |
/* L10: */ |
| 17271 |
} |
| 17272 |
k += j; |
| 17273 |
/* L20: */ |
| 17274 |
} |
| 17275 |
} else { |
| 17276 |
k = 1; |
| 17277 |
i__1 = *n; |
| 17278 |
for (j = 1; j <= i__1; ++j) { |
| 17279 |
i__2 = k + *n - j; |
| 17280 |
for (i__ = k; i__ <= i__2; ++i__) { |
| 17281 |
/* Computing MAX */ |
| 17282 |
d__2 = value, d__3 = (d__1 = ap[i__], abs(d__1)); |
| 17283 |
value = std::max(d__2,d__3); |
| 17284 |
/* L30: */ |
| 17285 |
} |
| 17286 |
k = k + *n - j + 1; |
| 17287 |
/* L40: */ |
| 17288 |
} |
| 17289 |
} |
| 17290 |
} else if (lsame_(norm, "I") || lsame_(norm, "O") || *(unsigned char *)norm == '1') { |
| 17291 |
|
| 17292 |
/* Find normI(A) ( = norm1(A), since A is symmetric). */ |
| 17293 |
|
| 17294 |
value = 0.; |
| 17295 |
k = 1; |
| 17296 |
if (lsame_(uplo, "U")) { |
| 17297 |
i__1 = *n; |
| 17298 |
for (j = 1; j <= i__1; ++j) { |
| 17299 |
sum = 0.; |
| 17300 |
i__2 = j - 1; |
| 17301 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 17302 |
absa = (d__1 = ap[k], abs(d__1)); |
| 17303 |
sum += absa; |
| 17304 |
work[i__] += absa; |
| 17305 |
++k; |
| 17306 |
/* L50: */ |
| 17307 |
} |
| 17308 |
work[j] = sum + (d__1 = ap[k], abs(d__1)); |
| 17309 |
++k; |
| 17310 |
/* L60: */ |
| 17311 |
} |
| 17312 |
i__1 = *n; |
| 17313 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 17314 |
/* Computing MAX */ |
| 17315 |
d__1 = value, d__2 = work[i__]; |
| 17316 |
value = std::max(d__1,d__2); |
| 17317 |
/* L70: */ |
| 17318 |
} |
| 17319 |
} else { |
| 17320 |
i__1 = *n; |
| 17321 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 17322 |
work[i__] = 0.; |
| 17323 |
/* L80: */ |
| 17324 |
} |
| 17325 |
i__1 = *n; |
| 17326 |
for (j = 1; j <= i__1; ++j) { |
| 17327 |
sum = work[j] + (d__1 = ap[k], abs(d__1)); |
| 17328 |
++k; |
| 17329 |
i__2 = *n; |
| 17330 |
for (i__ = j + 1; i__ <= i__2; ++i__) { |
| 17331 |
absa = (d__1 = ap[k], abs(d__1)); |
| 17332 |
sum += absa; |
| 17333 |
work[i__] += absa; |
| 17334 |
++k; |
| 17335 |
/* L90: */ |
| 17336 |
} |
| 17337 |
value = std::max(value,sum); |
| 17338 |
/* L100: */ |
| 17339 |
} |
| 17340 |
} |
| 17341 |
} else if (lsame_(norm, "F") || lsame_(norm, "E")) { |
| 17342 |
|
| 17343 |
/* Find normF(A). */ |
| 17344 |
|
| 17345 |
scale = 0.; |
| 17346 |
sum = 1.; |
| 17347 |
k = 2; |
| 17348 |
if (lsame_(uplo, "U")) { |
| 17349 |
i__1 = *n; |
| 17350 |
for (j = 2; j <= i__1; ++j) { |
| 17351 |
i__2 = j - 1; |
| 17352 |
dlassq_(&i__2, &ap[k], &c__1, &scale, &sum); |
| 17353 |
k += j; |
| 17354 |
/* L110: */ |
| 17355 |
} |
| 17356 |
} else { |
| 17357 |
i__1 = *n - 1; |
| 17358 |
for (j = 1; j <= i__1; ++j) { |
| 17359 |
i__2 = *n - j; |
| 17360 |
dlassq_(&i__2, &ap[k], &c__1, &scale, &sum); |
| 17361 |
k = k + *n - j + 1; |
| 17362 |
/* L120: */ |
| 17363 |
} |
| 17364 |
} |
| 17365 |
sum *= 2; |
| 17366 |
k = 1; |
| 17367 |
i__1 = *n; |
| 17368 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 17369 |
if (ap[k] != 0.) { |
| 17370 |
absa = (d__1 = ap[k], abs(d__1)); |
| 17371 |
if (scale < absa) { |
| 17372 |
/* Computing 2nd power */ |
| 17373 |
d__1 = scale / absa; |
| 17374 |
sum = sum * (d__1 * d__1) + 1.; |
| 17375 |
scale = absa; |
| 17376 |
} else { |
| 17377 |
/* Computing 2nd power */ |
| 17378 |
d__1 = absa / scale; |
| 17379 |
sum += d__1 * d__1; |
| 17380 |
} |
| 17381 |
} |
| 17382 |
if (lsame_(uplo, "U")) { |
| 17383 |
k = k + i__ + 1; |
| 17384 |
} else { |
| 17385 |
k = k + *n - i__ + 1; |
| 17386 |
} |
| 17387 |
/* L130: */ |
| 17388 |
} |
| 17389 |
value = scale * sqrt(sum); |
| 17390 |
} |
| 17391 |
|
| 17392 |
ret_val = value; |
| 17393 |
return ret_val; |
| 17394 |
|
| 17395 |
/* End of DLANSP */ |
| 17396 |
|
| 17397 |
} /* dlansp_ */ |
| 17398 |
|
| 17399 |
/* Subroutine */ double dlanst_(const char *norm, integer *n, double *d__, double *e) |
| 17400 |
{ |
| 17401 |
/* Table of constant values */ |
| 17402 |
static integer c__1 = 1; |
| 17403 |
|
| 17404 |
/* System generated locals */ |
| 17405 |
integer i__1; |
| 17406 |
double ret_val, d__1, d__2, d__3, d__4, d__5; |
| 17407 |
|
| 17408 |
/* Builtin functions |
| 17409 |
double sqrt(double); */ |
| 17410 |
|
| 17411 |
/* Local variables */ |
| 17412 |
integer i__; |
| 17413 |
double sum, scale; |
| 17414 |
double anorm; |
| 17415 |
|
| 17416 |
|
| 17417 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 17418 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 17419 |
/* November 2006 */ |
| 17420 |
|
| 17421 |
/* .. Scalar Arguments .. */ |
| 17422 |
/* .. */ |
| 17423 |
/* .. Array Arguments .. */ |
| 17424 |
/* .. */ |
| 17425 |
|
| 17426 |
/* Purpose */ |
| 17427 |
/* ======= */ |
| 17428 |
|
| 17429 |
/* DLANST returns the value of the one norm, or the Frobenius norm, or */ |
| 17430 |
/* the infinity norm, or the element of largest absolute value of a */ |
| 17431 |
/* real symmetric tridiagonal matrix A. */ |
| 17432 |
|
| 17433 |
/* Description */ |
| 17434 |
/* =========== */ |
| 17435 |
|
| 17436 |
/* DLANST returns the value */ |
| 17437 |
|
| 17438 |
/* DLANST = ( max(abs(A(i,j))), NORM = 'M' or 'm' */ |
| 17439 |
/* ( */ |
| 17440 |
/* ( norm1(A), NORM = '1', 'O' or 'o' */ |
| 17441 |
/* ( */ |
| 17442 |
/* ( normI(A), NORM = 'I' or 'i' */ |
| 17443 |
/* ( */ |
| 17444 |
/* ( normF(A), NORM = 'F', 'f', 'E' or 'e' */ |
| 17445 |
|
| 17446 |
/* where norm1 denotes the one norm of a matrix (maximum column sum), */ |
| 17447 |
/* normI denotes the infinity norm of a matrix (maximum row sum) and */ |
| 17448 |
/* normF denotes the Frobenius norm of a matrix (square root of sum of */ |
| 17449 |
/* squares). Note that max(abs(A(i,j))) is not a consistent matrix norm. */ |
| 17450 |
|
| 17451 |
/* Arguments */ |
| 17452 |
/* ========= */ |
| 17453 |
|
| 17454 |
/* NORM (input) CHARACTER*1 */ |
| 17455 |
/* Specifies the value to be returned in DLANST as described */ |
| 17456 |
/* above. */ |
| 17457 |
|
| 17458 |
/* N (input) INTEGER */ |
| 17459 |
/* The order of the matrix A. N >= 0. When N = 0, DLANST is */ |
| 17460 |
/* set to zero. */ |
| 17461 |
|
| 17462 |
/* D (input) DOUBLE PRECISION array, dimension (N) */ |
| 17463 |
/* The diagonal elements of A. */ |
| 17464 |
|
| 17465 |
/* E (input) DOUBLE PRECISION array, dimension (N-1) */ |
| 17466 |
/* The (n-1) sub-diagonal or super-diagonal elements of A. */ |
| 17467 |
|
| 17468 |
/* ===================================================================== */ |
| 17469 |
|
| 17470 |
/* .. Parameters .. */ |
| 17471 |
/* .. */ |
| 17472 |
/* .. Local Scalars .. */ |
| 17473 |
/* .. */ |
| 17474 |
/* .. External Functions .. */ |
| 17475 |
/* .. */ |
| 17476 |
/* .. External Subroutines .. */ |
| 17477 |
/* .. */ |
| 17478 |
/* .. Intrinsic Functions .. */ |
| 17479 |
/* .. */ |
| 17480 |
/* .. Executable Statements .. */ |
| 17481 |
|
| 17482 |
/* Parameter adjustments */ |
| 17483 |
--e; |
| 17484 |
--d__; |
| 17485 |
|
| 17486 |
/* Function Body */ |
| 17487 |
if (*n <= 0) { |
| 17488 |
anorm = 0.; |
| 17489 |
} else if (lsame_(norm, "M")) { |
| 17490 |
|
| 17491 |
/* Find max(abs(A(i,j))). */ |
| 17492 |
|
| 17493 |
anorm = (d__1 = d__[*n], abs(d__1)); |
| 17494 |
i__1 = *n - 1; |
| 17495 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 17496 |
/* Computing MAX */ |
| 17497 |
d__2 = anorm, d__3 = (d__1 = d__[i__], abs(d__1)); |
| 17498 |
anorm = std::max(d__2,d__3); |
| 17499 |
/* Computing MAX */ |
| 17500 |
d__2 = anorm, d__3 = (d__1 = e[i__], abs(d__1)); |
| 17501 |
anorm = std::max(d__2,d__3); |
| 17502 |
/* L10: */ |
| 17503 |
} |
| 17504 |
} else if (lsame_(norm, "O") || *(unsigned char *) |
| 17505 |
norm == '1' || lsame_(norm, "I")) { |
| 17506 |
|
| 17507 |
/* Find norm1(A). */ |
| 17508 |
|
| 17509 |
if (*n == 1) { |
| 17510 |
anorm = abs(d__[1]); |
| 17511 |
} else { |
| 17512 |
/* Computing MAX */ |
| 17513 |
d__3 = abs(d__[1]) + abs(e[1]), d__4 = (d__1 = e[*n - 1], abs( |
| 17514 |
d__1)) + (d__2 = d__[*n], abs(d__2)); |
| 17515 |
anorm = std::max(d__3,d__4); |
| 17516 |
i__1 = *n - 1; |
| 17517 |
for (i__ = 2; i__ <= i__1; ++i__) { |
| 17518 |
/* Computing MAX */ |
| 17519 |
d__4 = anorm, d__5 = (d__1 = d__[i__], abs(d__1)) + (d__2 = e[ |
| 17520 |
i__], abs(d__2)) + (d__3 = e[i__ - 1], abs(d__3)); |
| 17521 |
anorm = std::max(d__4,d__5); |
| 17522 |
/* L20: */ |
| 17523 |
} |
| 17524 |
} |
| 17525 |
} else if (lsame_(norm, "F") || lsame_(norm, "E")) { |
| 17526 |
|
| 17527 |
/* Find normF(A). */ |
| 17528 |
|
| 17529 |
scale = 0.; |
| 17530 |
sum = 1.; |
| 17531 |
if (*n > 1) { |
| 17532 |
i__1 = *n - 1; |
| 17533 |
dlassq_(&i__1, &e[1], &c__1, &scale, &sum); |
| 17534 |
sum *= 2; |
| 17535 |
} |
| 17536 |
dlassq_(n, &d__[1], &c__1, &scale, &sum); |
| 17537 |
anorm = scale * sqrt(sum); |
| 17538 |
} |
| 17539 |
|
| 17540 |
ret_val = anorm; |
| 17541 |
return ret_val; |
| 17542 |
|
| 17543 |
/* End of DLANST */ |
| 17544 |
|
| 17545 |
} /* dlanst_ */ |
| 17546 |
|
| 17547 |
/* Subroutine */ double dlansy_(const char *norm, const char *uplo, integer *n, double *a, integer |
| 17548 |
*lda, double *work) |
| 17549 |
{ |
| 17550 |
/* Table of constant values */ |
| 17551 |
static integer c__1 = 1; |
| 17552 |
|
| 17553 |
/* System generated locals */ |
| 17554 |
integer a_dim1, a_offset, i__1, i__2; |
| 17555 |
double ret_val, d__1, d__2, d__3; |
| 17556 |
|
| 17557 |
/* Builtin functions |
| 17558 |
double sqrt(double); */ |
| 17559 |
|
| 17560 |
/* Local variables */ |
| 17561 |
integer i__, j; |
| 17562 |
double sum, absa, scale; |
| 17563 |
double value; |
| 17564 |
|
| 17565 |
|
| 17566 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 17567 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 17568 |
/* November 2006 */ |
| 17569 |
|
| 17570 |
/* .. Scalar Arguments .. */ |
| 17571 |
/* .. */ |
| 17572 |
/* .. Array Arguments .. */ |
| 17573 |
/* .. */ |
| 17574 |
|
| 17575 |
/* Purpose */ |
| 17576 |
/* ======= */ |
| 17577 |
|
| 17578 |
/* DLANSY returns the value of the one norm, or the Frobenius norm, or */ |
| 17579 |
/* the infinity norm, or the element of largest absolute value of a */ |
| 17580 |
/* real symmetric matrix A. */ |
| 17581 |
|
| 17582 |
/* Description */ |
| 17583 |
/* =========== */ |
| 17584 |
|
| 17585 |
/* DLANSY returns the value */ |
| 17586 |
|
| 17587 |
/* DLANSY = ( max(abs(A(i,j))), NORM = 'M' or 'm' */ |
| 17588 |
/* ( */ |
| 17589 |
/* ( norm1(A), NORM = '1', 'O' or 'o' */ |
| 17590 |
/* ( */ |
| 17591 |
/* ( normI(A), NORM = 'I' or 'i' */ |
| 17592 |
/* ( */ |
| 17593 |
/* ( normF(A), NORM = 'F', 'f', 'E' or 'e' */ |
| 17594 |
|
| 17595 |
/* where norm1 denotes the one norm of a matrix (maximum column sum), */ |
| 17596 |
/* normI denotes the infinity norm of a matrix (maximum row sum) and */ |
| 17597 |
/* normF denotes the Frobenius norm of a matrix (square root of sum of */ |
| 17598 |
/* squares). Note that max(abs(A(i,j))) is not a consistent matrix norm. */ |
| 17599 |
|
| 17600 |
/* Arguments */ |
| 17601 |
/* ========= */ |
| 17602 |
|
| 17603 |
/* NORM (input) CHARACTER*1 */ |
| 17604 |
/* Specifies the value to be returned in DLANSY as described */ |
| 17605 |
/* above. */ |
| 17606 |
|
| 17607 |
/* UPLO (input) CHARACTER*1 */ |
| 17608 |
/* Specifies whether the upper or lower triangular part of the */ |
| 17609 |
/* symmetric matrix A is to be referenced. */ |
| 17610 |
/* = 'U': Upper triangular part of A is referenced */ |
| 17611 |
/* = 'L': Lower triangular part of A is referenced */ |
| 17612 |
|
| 17613 |
/* N (input) INTEGER */ |
| 17614 |
/* The order of the matrix A. N >= 0. When N = 0, DLANSY is */ |
| 17615 |
/* set to zero. */ |
| 17616 |
|
| 17617 |
/* A (input) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 17618 |
/* The symmetric matrix A. If UPLO = 'U', the leading n by n */ |
| 17619 |
/* upper triangular part of A contains the upper triangular part */ |
| 17620 |
/* of the matrix A, and the strictly lower triangular part of A */ |
| 17621 |
/* is not referenced. If UPLO = 'L', the leading n by n lower */ |
| 17622 |
/* triangular part of A contains the lower triangular part of */ |
| 17623 |
/* the matrix A, and the strictly upper triangular part of A is */ |
| 17624 |
/* not referenced. */ |
| 17625 |
|
| 17626 |
/* LDA (input) INTEGER */ |
| 17627 |
/* The leading dimension of the array A. LDA >= max(N,1). */ |
| 17628 |
|
| 17629 |
/* WORK (workspace) DOUBLE PRECISION array, dimension (MAX(1,LWORK)), */ |
| 17630 |
/* where LWORK >= N when NORM = 'I' or '1' or 'O'; otherwise, */ |
| 17631 |
/* WORK is not referenced. */ |
| 17632 |
|
| 17633 |
/* ===================================================================== */ |
| 17634 |
|
| 17635 |
/* .. Parameters .. */ |
| 17636 |
/* .. */ |
| 17637 |
/* .. Local Scalars .. */ |
| 17638 |
/* .. */ |
| 17639 |
/* .. External Subroutines .. */ |
| 17640 |
/* .. */ |
| 17641 |
/* .. External Functions .. */ |
| 17642 |
/* .. */ |
| 17643 |
/* .. Intrinsic Functions .. */ |
| 17644 |
/* .. */ |
| 17645 |
/* .. Executable Statements .. */ |
| 17646 |
|
| 17647 |
/* Parameter adjustments */ |
| 17648 |
a_dim1 = *lda; |
| 17649 |
a_offset = 1 + a_dim1; |
| 17650 |
a -= a_offset; |
| 17651 |
--work; |
| 17652 |
|
| 17653 |
/* Function Body */ |
| 17654 |
if (*n == 0) { |
| 17655 |
value = 0.; |
| 17656 |
} else if (lsame_(norm, "M")) { |
| 17657 |
|
| 17658 |
/* Find max(abs(A(i,j))). */ |
| 17659 |
|
| 17660 |
value = 0.; |
| 17661 |
if (lsame_(uplo, "U")) { |
| 17662 |
i__1 = *n; |
| 17663 |
for (j = 1; j <= i__1; ++j) { |
| 17664 |
i__2 = j; |
| 17665 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 17666 |
/* Computing MAX */ |
| 17667 |
d__2 = value, d__3 = (d__1 = a[i__ + j * a_dim1], abs( |
| 17668 |
d__1)); |
| 17669 |
value = std::max(d__2,d__3); |
| 17670 |
/* L10: */ |
| 17671 |
} |
| 17672 |
/* L20: */ |
| 17673 |
} |
| 17674 |
} else { |
| 17675 |
i__1 = *n; |
| 17676 |
for (j = 1; j <= i__1; ++j) { |
| 17677 |
i__2 = *n; |
| 17678 |
for (i__ = j; i__ <= i__2; ++i__) { |
| 17679 |
/* Computing MAX */ |
| 17680 |
d__2 = value, d__3 = (d__1 = a[i__ + j * a_dim1], abs( |
| 17681 |
d__1)); |
| 17682 |
value = std::max(d__2,d__3); |
| 17683 |
/* L30: */ |
| 17684 |
} |
| 17685 |
/* L40: */ |
| 17686 |
} |
| 17687 |
} |
| 17688 |
} else if (lsame_(norm, "I") || lsame_(norm, "O") || *(unsigned char *)norm == '1') { |
| 17689 |
|
| 17690 |
/* Find normI(A) ( = norm1(A), since A is symmetric). */ |
| 17691 |
|
| 17692 |
value = 0.; |
| 17693 |
if (lsame_(uplo, "U")) { |
| 17694 |
i__1 = *n; |
| 17695 |
for (j = 1; j <= i__1; ++j) { |
| 17696 |
sum = 0.; |
| 17697 |
i__2 = j - 1; |
| 17698 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 17699 |
absa = (d__1 = a[i__ + j * a_dim1], abs(d__1)); |
| 17700 |
sum += absa; |
| 17701 |
work[i__] += absa; |
| 17702 |
/* L50: */ |
| 17703 |
} |
| 17704 |
work[j] = sum + (d__1 = a[j + j * a_dim1], abs(d__1)); |
| 17705 |
/* L60: */ |
| 17706 |
} |
| 17707 |
i__1 = *n; |
| 17708 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 17709 |
/* Computing MAX */ |
| 17710 |
d__1 = value, d__2 = work[i__]; |
| 17711 |
value = std::max(d__1,d__2); |
| 17712 |
/* L70: */ |
| 17713 |
} |
| 17714 |
} else { |
| 17715 |
i__1 = *n; |
| 17716 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 17717 |
work[i__] = 0.; |
| 17718 |
/* L80: */ |
| 17719 |
} |
| 17720 |
i__1 = *n; |
| 17721 |
for (j = 1; j <= i__1; ++j) { |
| 17722 |
sum = work[j] + (d__1 = a[j + j * a_dim1], abs(d__1)); |
| 17723 |
i__2 = *n; |
| 17724 |
for (i__ = j + 1; i__ <= i__2; ++i__) { |
| 17725 |
absa = (d__1 = a[i__ + j * a_dim1], abs(d__1)); |
| 17726 |
sum += absa; |
| 17727 |
work[i__] += absa; |
| 17728 |
/* L90: */ |
| 17729 |
} |
| 17730 |
value = std::max(value,sum); |
| 17731 |
/* L100: */ |
| 17732 |
} |
| 17733 |
} |
| 17734 |
} else if (lsame_(norm, "F") || lsame_(norm, "E")) { |
| 17735 |
|
| 17736 |
/* Find normF(A). */ |
| 17737 |
|
| 17738 |
scale = 0.; |
| 17739 |
sum = 1.; |
| 17740 |
if (lsame_(uplo, "U")) { |
| 17741 |
i__1 = *n; |
| 17742 |
for (j = 2; j <= i__1; ++j) { |
| 17743 |
i__2 = j - 1; |
| 17744 |
dlassq_(&i__2, &a[j * a_dim1 + 1], &c__1, &scale, &sum); |
| 17745 |
/* L110: */ |
| 17746 |
} |
| 17747 |
} else { |
| 17748 |
i__1 = *n - 1; |
| 17749 |
for (j = 1; j <= i__1; ++j) { |
| 17750 |
i__2 = *n - j; |
| 17751 |
dlassq_(&i__2, &a[j + 1 + j * a_dim1], &c__1, &scale, &sum); |
| 17752 |
/* L120: */ |
| 17753 |
} |
| 17754 |
} |
| 17755 |
sum *= 2; |
| 17756 |
i__1 = *lda + 1; |
| 17757 |
dlassq_(n, &a[a_offset], &i__1, &scale, &sum); |
| 17758 |
value = scale * sqrt(sum); |
| 17759 |
} |
| 17760 |
|
| 17761 |
ret_val = value; |
| 17762 |
return ret_val; |
| 17763 |
|
| 17764 |
/* End of DLANSY */ |
| 17765 |
|
| 17766 |
} /* dlansy_ */ |
| 17767 |
|
| 17768 |
/* Subroutine */ double dlantb_(const char *norm, const char *uplo, const char *diag, integer *n, integer *k, |
| 17769 |
double *ab, integer *ldab, double *work) |
| 17770 |
{ |
| 17771 |
/* Table of constant values */ |
| 17772 |
static integer c__1 = 1; |
| 17773 |
|
| 17774 |
/* System generated locals */ |
| 17775 |
integer ab_dim1, ab_offset, i__1, i__2, i__3, i__4, i__5; |
| 17776 |
double ret_val, d__1, d__2, d__3; |
| 17777 |
|
| 17778 |
/* Local variables */ |
| 17779 |
integer i__, j, l; |
| 17780 |
double sum, scale; |
| 17781 |
bool udiag; |
| 17782 |
double value; |
| 17783 |
|
| 17784 |
|
| 17785 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 17786 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 17787 |
/* November 2006 */ |
| 17788 |
|
| 17789 |
/* .. Scalar Arguments .. */ |
| 17790 |
/* .. */ |
| 17791 |
/* .. Array Arguments .. */ |
| 17792 |
/* .. */ |
| 17793 |
|
| 17794 |
/* Purpose */ |
| 17795 |
/* ======= */ |
| 17796 |
|
| 17797 |
/* DLANTB returns the value of the one norm, or the Frobenius norm, or */ |
| 17798 |
/* the infinity norm, or the element of largest absolute value of an */ |
| 17799 |
/* n by n triangular band matrix A, with ( k + 1 ) diagonals. */ |
| 17800 |
|
| 17801 |
/* Description */ |
| 17802 |
/* =========== */ |
| 17803 |
|
| 17804 |
/* DLANTB returns the value */ |
| 17805 |
|
| 17806 |
/* DLANTB = ( max(abs(A(i,j))), NORM = 'M' or 'm' */ |
| 17807 |
/* ( */ |
| 17808 |
/* ( norm1(A), NORM = '1', 'O' or 'o' */ |
| 17809 |
/* ( */ |
| 17810 |
/* ( normI(A), NORM = 'I' or 'i' */ |
| 17811 |
/* ( */ |
| 17812 |
/* ( normF(A), NORM = 'F', 'f', 'E' or 'e' */ |
| 17813 |
|
| 17814 |
/* where norm1 denotes the one norm of a matrix (maximum column sum), */ |
| 17815 |
/* normI denotes the infinity norm of a matrix (maximum row sum) and */ |
| 17816 |
/* normF denotes the Frobenius norm of a matrix (square root of sum of */ |
| 17817 |
/* squares). Note that max(abs(A(i,j))) is not a consistent matrix norm. */ |
| 17818 |
|
| 17819 |
/* Arguments */ |
| 17820 |
/* ========= */ |
| 17821 |
|
| 17822 |
/* NORM (input) CHARACTER*1 */ |
| 17823 |
/* Specifies the value to be returned in DLANTB as described */ |
| 17824 |
/* above. */ |
| 17825 |
|
| 17826 |
/* UPLO (input) CHARACTER*1 */ |
| 17827 |
/* Specifies whether the matrix A is upper or lower triangular. */ |
| 17828 |
/* = 'U': Upper triangular */ |
| 17829 |
/* = 'L': Lower triangular */ |
| 17830 |
|
| 17831 |
/* DIAG (input) CHARACTER*1 */ |
| 17832 |
/* Specifies whether or not the matrix A is unit triangular. */ |
| 17833 |
/* = 'N': Non-unit triangular */ |
| 17834 |
/* = 'U': Unit triangular */ |
| 17835 |
|
| 17836 |
/* N (input) INTEGER */ |
| 17837 |
/* The order of the matrix A. N >= 0. When N = 0, DLANTB is */ |
| 17838 |
/* set to zero. */ |
| 17839 |
|
| 17840 |
/* K (input) INTEGER */ |
| 17841 |
/* The number of super-diagonals of the matrix A if UPLO = 'U', */ |
| 17842 |
/* or the number of sub-diagonals of the matrix A if UPLO = 'L'. */ |
| 17843 |
/* K >= 0. */ |
| 17844 |
|
| 17845 |
/* AB (input) DOUBLE PRECISION array, dimension (LDAB,N) */ |
| 17846 |
/* The upper or lower triangular band matrix A, stored in the */ |
| 17847 |
/* first k+1 rows of AB. The j-th column of A is stored */ |
| 17848 |
/* in the j-th column of the array AB as follows: */ |
| 17849 |
/* if UPLO = 'U', AB(k+1+i-j,j) = A(i,j) for max(1,j-k)<=i<=j; */ |
| 17850 |
/* if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+k). */ |
| 17851 |
/* Note that when DIAG = 'U', the elements of the array AB */ |
| 17852 |
/* corresponding to the diagonal elements of the matrix A are */ |
| 17853 |
/* not referenced, but are assumed to be one. */ |
| 17854 |
|
| 17855 |
/* LDAB (input) INTEGER */ |
| 17856 |
/* The leading dimension of the array AB. LDAB >= K+1. */ |
| 17857 |
|
| 17858 |
/* WORK (workspace) DOUBLE PRECISION array, dimension (MAX(1,LWORK)), */ |
| 17859 |
/* where LWORK >= N when NORM = 'I'; otherwise, WORK is not */ |
| 17860 |
/* referenced. */ |
| 17861 |
|
| 17862 |
/* ===================================================================== */ |
| 17863 |
|
| 17864 |
/* .. Parameters .. */ |
| 17865 |
/* .. */ |
| 17866 |
/* .. Local Scalars .. */ |
| 17867 |
/* .. */ |
| 17868 |
/* .. External Subroutines .. */ |
| 17869 |
/* .. */ |
| 17870 |
/* .. External Functions .. */ |
| 17871 |
/* .. */ |
| 17872 |
/* .. Intrinsic Functions .. */ |
| 17873 |
/* .. */ |
| 17874 |
/* .. Executable Statements .. */ |
| 17875 |
|
| 17876 |
/* Parameter adjustments */ |
| 17877 |
ab_dim1 = *ldab; |
| 17878 |
ab_offset = 1 + ab_dim1; |
| 17879 |
ab -= ab_offset; |
| 17880 |
--work; |
| 17881 |
|
| 17882 |
/* Function Body */ |
| 17883 |
if (*n == 0) { |
| 17884 |
value = 0.; |
| 17885 |
} else if (lsame_(norm, "M")) { |
| 17886 |
|
| 17887 |
/* Find max(abs(A(i,j))). */ |
| 17888 |
|
| 17889 |
if (lsame_(diag, "U")) { |
| 17890 |
value = 1.; |
| 17891 |
if (lsame_(uplo, "U")) { |
| 17892 |
i__1 = *n; |
| 17893 |
for (j = 1; j <= i__1; ++j) { |
| 17894 |
/* Computing MAX */ |
| 17895 |
i__2 = *k + 2 - j; |
| 17896 |
i__3 = *k; |
| 17897 |
for (i__ = std::max(i__2,1_integer); i__ <= i__3; ++i__) { |
| 17898 |
/* Computing MAX */ |
| 17899 |
d__2 = value, d__3 = (d__1 = ab[i__ + j * ab_dim1], |
| 17900 |
abs(d__1)); |
| 17901 |
value = std::max(d__2,d__3); |
| 17902 |
/* L10: */ |
| 17903 |
} |
| 17904 |
/* L20: */ |
| 17905 |
} |
| 17906 |
} else { |
| 17907 |
i__1 = *n; |
| 17908 |
for (j = 1; j <= i__1; ++j) { |
| 17909 |
/* Computing MIN */ |
| 17910 |
i__2 = *n + 1 - j, i__4 = *k + 1; |
| 17911 |
i__3 = std::min(i__2,i__4); |
| 17912 |
for (i__ = 2; i__ <= i__3; ++i__) { |
| 17913 |
/* Computing MAX */ |
| 17914 |
d__2 = value, d__3 = (d__1 = ab[i__ + j * ab_dim1], |
| 17915 |
abs(d__1)); |
| 17916 |
value = std::max(d__2,d__3); |
| 17917 |
/* L30: */ |
| 17918 |
} |
| 17919 |
/* L40: */ |
| 17920 |
} |
| 17921 |
} |
| 17922 |
} else { |
| 17923 |
value = 0.; |
| 17924 |
if (lsame_(uplo, "U")) { |
| 17925 |
i__1 = *n; |
| 17926 |
for (j = 1; j <= i__1; ++j) { |
| 17927 |
/* Computing MAX */ |
| 17928 |
i__3 = *k + 2 - j; |
| 17929 |
i__2 = *k + 1; |
| 17930 |
for (i__ = std::max(i__3,1_integer); i__ <= i__2; ++i__) { |
| 17931 |
/* Computing MAX */ |
| 17932 |
d__2 = value, d__3 = (d__1 = ab[i__ + j * ab_dim1], |
| 17933 |
abs(d__1)); |
| 17934 |
value = std::max(d__2,d__3); |
| 17935 |
/* L50: */ |
| 17936 |
} |
| 17937 |
/* L60: */ |
| 17938 |
} |
| 17939 |
} else { |
| 17940 |
i__1 = *n; |
| 17941 |
for (j = 1; j <= i__1; ++j) { |
| 17942 |
/* Computing MIN */ |
| 17943 |
i__3 = *n + 1 - j, i__4 = *k + 1; |
| 17944 |
i__2 = std::min(i__3,i__4); |
| 17945 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 17946 |
/* Computing MAX */ |
| 17947 |
d__2 = value, d__3 = (d__1 = ab[i__ + j * ab_dim1], |
| 17948 |
abs(d__1)); |
| 17949 |
value = std::max(d__2,d__3); |
| 17950 |
/* L70: */ |
| 17951 |
} |
| 17952 |
/* L80: */ |
| 17953 |
} |
| 17954 |
} |
| 17955 |
} |
| 17956 |
} else if (lsame_(norm, "O") || *(unsigned char *) |
| 17957 |
norm == '1') { |
| 17958 |
|
| 17959 |
/* Find norm1(A). */ |
| 17960 |
|
| 17961 |
value = 0.; |
| 17962 |
udiag = lsame_(diag, "U"); |
| 17963 |
if (lsame_(uplo, "U")) { |
| 17964 |
i__1 = *n; |
| 17965 |
for (j = 1; j <= i__1; ++j) { |
| 17966 |
if (udiag) { |
| 17967 |
sum = 1.; |
| 17968 |
/* Computing MAX */ |
| 17969 |
i__2 = *k + 2 - j; |
| 17970 |
i__3 = *k; |
| 17971 |
for (i__ = std::max(i__2,1_integer); i__ <= i__3; ++i__) { |
| 17972 |
sum += (d__1 = ab[i__ + j * ab_dim1], abs(d__1)); |
| 17973 |
/* L90: */ |
| 17974 |
} |
| 17975 |
} else { |
| 17976 |
sum = 0.; |
| 17977 |
/* Computing MAX */ |
| 17978 |
i__3 = *k + 2 - j; |
| 17979 |
i__2 = *k + 1; |
| 17980 |
for (i__ = std::max(i__3,1_integer); i__ <= i__2; ++i__) { |
| 17981 |
sum += (d__1 = ab[i__ + j * ab_dim1], abs(d__1)); |
| 17982 |
/* L100: */ |
| 17983 |
} |
| 17984 |
} |
| 17985 |
value = std::max(value,sum); |
| 17986 |
/* L110: */ |
| 17987 |
} |
| 17988 |
} else { |
| 17989 |
i__1 = *n; |
| 17990 |
for (j = 1; j <= i__1; ++j) { |
| 17991 |
if (udiag) { |
| 17992 |
sum = 1.; |
| 17993 |
/* Computing MIN */ |
| 17994 |
i__3 = *n + 1 - j, i__4 = *k + 1; |
| 17995 |
i__2 = std::min(i__3,i__4); |
| 17996 |
for (i__ = 2; i__ <= i__2; ++i__) { |
| 17997 |
sum += (d__1 = ab[i__ + j * ab_dim1], abs(d__1)); |
| 17998 |
/* L120: */ |
| 17999 |
} |
| 18000 |
} else { |
| 18001 |
sum = 0.; |
| 18002 |
/* Computing MIN */ |
| 18003 |
i__3 = *n + 1 - j, i__4 = *k + 1; |
| 18004 |
i__2 = std::min(i__3,i__4); |
| 18005 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 18006 |
sum += (d__1 = ab[i__ + j * ab_dim1], abs(d__1)); |
| 18007 |
/* L130: */ |
| 18008 |
} |
| 18009 |
} |
| 18010 |
value = std::max(value,sum); |
| 18011 |
/* L140: */ |
| 18012 |
} |
| 18013 |
} |
| 18014 |
} else if (lsame_(norm, "I")) { |
| 18015 |
|
| 18016 |
/* Find normI(A). */ |
| 18017 |
|
| 18018 |
value = 0.; |
| 18019 |
if (lsame_(uplo, "U")) { |
| 18020 |
if (lsame_(diag, "U")) { |
| 18021 |
i__1 = *n; |
| 18022 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 18023 |
work[i__] = 1.; |
| 18024 |
/* L150: */ |
| 18025 |
} |
| 18026 |
i__1 = *n; |
| 18027 |
for (j = 1; j <= i__1; ++j) { |
| 18028 |
l = *k + 1 - j; |
| 18029 |
/* Computing MAX */ |
| 18030 |
i__2 = 1, i__3 = j - *k; |
| 18031 |
i__4 = j - 1; |
| 18032 |
for (i__ = std::max(i__2,i__3); i__ <= i__4; ++i__) { |
| 18033 |
work[i__] += (d__1 = ab[l + i__ + j * ab_dim1], abs( |
| 18034 |
d__1)); |
| 18035 |
/* L160: */ |
| 18036 |
} |
| 18037 |
/* L170: */ |
| 18038 |
} |
| 18039 |
} else { |
| 18040 |
i__1 = *n; |
| 18041 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 18042 |
work[i__] = 0.; |
| 18043 |
/* L180: */ |
| 18044 |
} |
| 18045 |
i__1 = *n; |
| 18046 |
for (j = 1; j <= i__1; ++j) { |
| 18047 |
l = *k + 1 - j; |
| 18048 |
/* Computing MAX */ |
| 18049 |
i__4 = 1, i__2 = j - *k; |
| 18050 |
i__3 = j; |
| 18051 |
for (i__ = std::max(i__4,i__2); i__ <= i__3; ++i__) { |
| 18052 |
work[i__] += (d__1 = ab[l + i__ + j * ab_dim1], abs( |
| 18053 |
d__1)); |
| 18054 |
/* L190: */ |
| 18055 |
} |
| 18056 |
/* L200: */ |
| 18057 |
} |
| 18058 |
} |
| 18059 |
} else { |
| 18060 |
if (lsame_(diag, "U")) { |
| 18061 |
i__1 = *n; |
| 18062 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 18063 |
work[i__] = 1.; |
| 18064 |
/* L210: */ |
| 18065 |
} |
| 18066 |
i__1 = *n; |
| 18067 |
for (j = 1; j <= i__1; ++j) { |
| 18068 |
l = 1 - j; |
| 18069 |
/* Computing MIN */ |
| 18070 |
i__4 = *n, i__2 = j + *k; |
| 18071 |
i__3 = std::min(i__4,i__2); |
| 18072 |
for (i__ = j + 1; i__ <= i__3; ++i__) { |
| 18073 |
work[i__] += (d__1 = ab[l + i__ + j * ab_dim1], abs( |
| 18074 |
d__1)); |
| 18075 |
/* L220: */ |
| 18076 |
} |
| 18077 |
/* L230: */ |
| 18078 |
} |
| 18079 |
} else { |
| 18080 |
i__1 = *n; |
| 18081 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 18082 |
work[i__] = 0.; |
| 18083 |
/* L240: */ |
| 18084 |
} |
| 18085 |
i__1 = *n; |
| 18086 |
for (j = 1; j <= i__1; ++j) { |
| 18087 |
l = 1 - j; |
| 18088 |
/* Computing MIN */ |
| 18089 |
i__4 = *n, i__2 = j + *k; |
| 18090 |
i__3 = std::min(i__4,i__2); |
| 18091 |
for (i__ = j; i__ <= i__3; ++i__) { |
| 18092 |
work[i__] += (d__1 = ab[l + i__ + j * ab_dim1], abs( |
| 18093 |
d__1)); |
| 18094 |
/* L250: */ |
| 18095 |
} |
| 18096 |
/* L260: */ |
| 18097 |
} |
| 18098 |
} |
| 18099 |
} |
| 18100 |
i__1 = *n; |
| 18101 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 18102 |
/* Computing MAX */ |
| 18103 |
d__1 = value, d__2 = work[i__]; |
| 18104 |
value = std::max(d__1,d__2); |
| 18105 |
/* L270: */ |
| 18106 |
} |
| 18107 |
} else if (lsame_(norm, "F") || lsame_(norm, "E")) { |
| 18108 |
|
| 18109 |
/* Find normF(A). */ |
| 18110 |
|
| 18111 |
if (lsame_(uplo, "U")) { |
| 18112 |
if (lsame_(diag, "U")) { |
| 18113 |
scale = 1.; |
| 18114 |
sum = (double) (*n); |
| 18115 |
if (*k > 0) { |
| 18116 |
i__1 = *n; |
| 18117 |
for (j = 2; j <= i__1; ++j) { |
| 18118 |
/* Computing MIN */ |
| 18119 |
i__4 = j - 1; |
| 18120 |
i__3 = std::min(i__4,*k); |
| 18121 |
/* Computing MAX */ |
| 18122 |
i__2 = *k + 2 - j; |
| 18123 |
dlassq_(&i__3, &ab[std::max(i__2,1_integer)+ j * ab_dim1], &c__1, |
| 18124 |
&scale, &sum); |
| 18125 |
/* L280: */ |
| 18126 |
} |
| 18127 |
} |
| 18128 |
} else { |
| 18129 |
scale = 0.; |
| 18130 |
sum = 1.; |
| 18131 |
i__1 = *n; |
| 18132 |
for (j = 1; j <= i__1; ++j) { |
| 18133 |
/* Computing MIN */ |
| 18134 |
i__4 = j, i__2 = *k + 1; |
| 18135 |
i__3 = std::min(i__4,i__2); |
| 18136 |
/* Computing MAX */ |
| 18137 |
i__5 = *k + 2 - j; |
| 18138 |
dlassq_(&i__3, &ab[std::max(i__5,1_integer)+ j * ab_dim1], &c__1, & |
| 18139 |
scale, &sum); |
| 18140 |
/* L290: */ |
| 18141 |
} |
| 18142 |
} |
| 18143 |
} else { |
| 18144 |
if (lsame_(diag, "U")) { |
| 18145 |
scale = 1.; |
| 18146 |
sum = (double) (*n); |
| 18147 |
if (*k > 0) { |
| 18148 |
i__1 = *n - 1; |
| 18149 |
for (j = 1; j <= i__1; ++j) { |
| 18150 |
/* Computing MIN */ |
| 18151 |
i__4 = *n - j; |
| 18152 |
i__3 = std::min(i__4,*k); |
| 18153 |
dlassq_(&i__3, &ab[j * ab_dim1 + 2], &c__1, &scale, & |
| 18154 |
sum); |
| 18155 |
/* L300: */ |
| 18156 |
} |
| 18157 |
} |
| 18158 |
} else { |
| 18159 |
scale = 0.; |
| 18160 |
sum = 1.; |
| 18161 |
i__1 = *n; |
| 18162 |
for (j = 1; j <= i__1; ++j) { |
| 18163 |
/* Computing MIN */ |
| 18164 |
i__4 = *n - j + 1, i__2 = *k + 1; |
| 18165 |
i__3 = std::min(i__4,i__2); |
| 18166 |
dlassq_(&i__3, &ab[j * ab_dim1 + 1], &c__1, &scale, &sum); |
| 18167 |
/* L310: */ |
| 18168 |
} |
| 18169 |
} |
| 18170 |
} |
| 18171 |
value = scale * sqrt(sum); |
| 18172 |
} |
| 18173 |
|
| 18174 |
ret_val = value; |
| 18175 |
return ret_val; |
| 18176 |
|
| 18177 |
/* End of DLANTB */ |
| 18178 |
|
| 18179 |
} /* dlantb_ */ |
| 18180 |
|
| 18181 |
/* Subroutine */ double dlantp_(const char *norm, const char *uplo, const char *diag, integer *n, double |
| 18182 |
*ap, double *work) |
| 18183 |
{ |
| 18184 |
/* Table of constant values */ |
| 18185 |
static integer c__1 = 1; |
| 18186 |
|
| 18187 |
/* System generated locals */ |
| 18188 |
integer i__1, i__2; |
| 18189 |
double ret_val, d__1, d__2, d__3; |
| 18190 |
|
| 18191 |
/* Local variables */ |
| 18192 |
integer i__, j, k; |
| 18193 |
double sum, scale; |
| 18194 |
bool udiag; |
| 18195 |
double value; |
| 18196 |
|
| 18197 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 18198 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 18199 |
/* November 2006 */ |
| 18200 |
|
| 18201 |
/* .. Scalar Arguments .. */ |
| 18202 |
/* .. */ |
| 18203 |
/* .. Array Arguments .. */ |
| 18204 |
/* .. */ |
| 18205 |
|
| 18206 |
/* Purpose */ |
| 18207 |
/* ======= */ |
| 18208 |
|
| 18209 |
/* DLANTP returns the value of the one norm, or the Frobenius norm, or */ |
| 18210 |
/* the infinity norm, or the element of largest absolute value of a */ |
| 18211 |
/* triangular matrix A, supplied in packed form. */ |
| 18212 |
|
| 18213 |
/* Description */ |
| 18214 |
/* =========== */ |
| 18215 |
|
| 18216 |
/* DLANTP returns the value */ |
| 18217 |
|
| 18218 |
/* DLANTP = ( max(abs(A(i,j))), NORM = 'M' or 'm' */ |
| 18219 |
/* ( */ |
| 18220 |
/* ( norm1(A), NORM = '1', 'O' or 'o' */ |
| 18221 |
/* ( */ |
| 18222 |
/* ( normI(A), NORM = 'I' or 'i' */ |
| 18223 |
/* ( */ |
| 18224 |
/* ( normF(A), NORM = 'F', 'f', 'E' or 'e' */ |
| 18225 |
|
| 18226 |
/* where norm1 denotes the one norm of a matrix (maximum column sum), */ |
| 18227 |
/* normI denotes the infinity norm of a matrix (maximum row sum) and */ |
| 18228 |
/* normF denotes the Frobenius norm of a matrix (square root of sum of */ |
| 18229 |
/* squares). Note that max(abs(A(i,j))) is not a consistent matrix norm. */ |
| 18230 |
|
| 18231 |
/* Arguments */ |
| 18232 |
/* ========= */ |
| 18233 |
|
| 18234 |
/* NORM (input) CHARACTER*1 */ |
| 18235 |
/* Specifies the value to be returned in DLANTP as described */ |
| 18236 |
/* above. */ |
| 18237 |
|
| 18238 |
/* UPLO (input) CHARACTER*1 */ |
| 18239 |
/* Specifies whether the matrix A is upper or lower triangular. */ |
| 18240 |
/* = 'U': Upper triangular */ |
| 18241 |
/* = 'L': Lower triangular */ |
| 18242 |
|
| 18243 |
/* DIAG (input) CHARACTER*1 */ |
| 18244 |
/* Specifies whether or not the matrix A is unit triangular. */ |
| 18245 |
/* = 'N': Non-unit triangular */ |
| 18246 |
/* = 'U': Unit triangular */ |
| 18247 |
|
| 18248 |
/* N (input) INTEGER */ |
| 18249 |
/* The order of the matrix A. N >= 0. When N = 0, DLANTP is */ |
| 18250 |
/* set to zero. */ |
| 18251 |
|
| 18252 |
/* AP (input) DOUBLE PRECISION array, dimension (N*(N+1)/2) */ |
| 18253 |
/* The upper or lower triangular matrix A, packed columnwise in */ |
| 18254 |
/* a linear array. The j-th column of A is stored in the array */ |
| 18255 |
/* AP as follows: */ |
| 18256 |
/* if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; */ |
| 18257 |
/* if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n. */ |
| 18258 |
/* Note that when DIAG = 'U', the elements of the array AP */ |
| 18259 |
/* corresponding to the diagonal elements of the matrix A are */ |
| 18260 |
/* not referenced, but are assumed to be one. */ |
| 18261 |
|
| 18262 |
/* WORK (workspace) DOUBLE PRECISION array, dimension (MAX(1,LWORK)), */ |
| 18263 |
/* where LWORK >= N when NORM = 'I'; otherwise, WORK is not */ |
| 18264 |
/* referenced. */ |
| 18265 |
|
| 18266 |
/* ===================================================================== */ |
| 18267 |
|
| 18268 |
/* .. Parameters .. */ |
| 18269 |
/* .. */ |
| 18270 |
/* .. Local Scalars .. */ |
| 18271 |
/* .. */ |
| 18272 |
/* .. External Subroutines .. */ |
| 18273 |
/* .. */ |
| 18274 |
/* .. External Functions .. */ |
| 18275 |
/* .. */ |
| 18276 |
/* .. Intrinsic Functions .. */ |
| 18277 |
/* .. */ |
| 18278 |
/* .. Executable Statements .. */ |
| 18279 |
|
| 18280 |
/* Parameter adjustments */ |
| 18281 |
--work; |
| 18282 |
--ap; |
| 18283 |
|
| 18284 |
/* Function Body */ |
| 18285 |
if (*n == 0) { |
| 18286 |
value = 0.; |
| 18287 |
} else if (lsame_(norm, "M")) { |
| 18288 |
|
| 18289 |
/* Find max(abs(A(i,j))). */ |
| 18290 |
|
| 18291 |
k = 1; |
| 18292 |
if (lsame_(diag, "U")) { |
| 18293 |
value = 1.; |
| 18294 |
if (lsame_(uplo, "U")) { |
| 18295 |
i__1 = *n; |
| 18296 |
for (j = 1; j <= i__1; ++j) { |
| 18297 |
i__2 = k + j - 2; |
| 18298 |
for (i__ = k; i__ <= i__2; ++i__) { |
| 18299 |
/* Computing MAX */ |
| 18300 |
d__2 = value, d__3 = (d__1 = ap[i__], abs(d__1)); |
| 18301 |
value = std::max(d__2,d__3); |
| 18302 |
/* L10: */ |
| 18303 |
} |
| 18304 |
k += j; |
| 18305 |
/* L20: */ |
| 18306 |
} |
| 18307 |
} else { |
| 18308 |
i__1 = *n; |
| 18309 |
for (j = 1; j <= i__1; ++j) { |
| 18310 |
i__2 = k + *n - j; |
| 18311 |
for (i__ = k + 1; i__ <= i__2; ++i__) { |
| 18312 |
/* Computing MAX */ |
| 18313 |
d__2 = value, d__3 = (d__1 = ap[i__], abs(d__1)); |
| 18314 |
value = std::max(d__2,d__3); |
| 18315 |
/* L30: */ |
| 18316 |
} |
| 18317 |
k = k + *n - j + 1; |
| 18318 |
/* L40: */ |
| 18319 |
} |
| 18320 |
} |
| 18321 |
} else { |
| 18322 |
value = 0.; |
| 18323 |
if (lsame_(uplo, "U")) { |
| 18324 |
i__1 = *n; |
| 18325 |
for (j = 1; j <= i__1; ++j) { |
| 18326 |
i__2 = k + j - 1; |
| 18327 |
for (i__ = k; i__ <= i__2; ++i__) { |
| 18328 |
/* Computing MAX */ |
| 18329 |
d__2 = value, d__3 = (d__1 = ap[i__], abs(d__1)); |
| 18330 |
value = std::max(d__2,d__3); |
| 18331 |
/* L50: */ |
| 18332 |
} |
| 18333 |
k += j; |
| 18334 |
/* L60: */ |
| 18335 |
} |
| 18336 |
} else { |
| 18337 |
i__1 = *n; |
| 18338 |
for (j = 1; j <= i__1; ++j) { |
| 18339 |
i__2 = k + *n - j; |
| 18340 |
for (i__ = k; i__ <= i__2; ++i__) { |
| 18341 |
/* Computing MAX */ |
| 18342 |
d__2 = value, d__3 = (d__1 = ap[i__], abs(d__1)); |
| 18343 |
value = std::max(d__2,d__3); |
| 18344 |
/* L70: */ |
| 18345 |
} |
| 18346 |
k = k + *n - j + 1; |
| 18347 |
/* L80: */ |
| 18348 |
} |
| 18349 |
} |
| 18350 |
} |
| 18351 |
} else if (lsame_(norm, "O") || *(unsigned char *) |
| 18352 |
norm == '1') { |
| 18353 |
|
| 18354 |
/* Find norm1(A). */ |
| 18355 |
|
| 18356 |
value = 0.; |
| 18357 |
k = 1; |
| 18358 |
udiag = lsame_(diag, "U"); |
| 18359 |
if (lsame_(uplo, "U")) { |
| 18360 |
i__1 = *n; |
| 18361 |
for (j = 1; j <= i__1; ++j) { |
| 18362 |
if (udiag) { |
| 18363 |
sum = 1.; |
| 18364 |
i__2 = k + j - 2; |
| 18365 |
for (i__ = k; i__ <= i__2; ++i__) { |
| 18366 |
sum += (d__1 = ap[i__], abs(d__1)); |
| 18367 |
/* L90: */ |
| 18368 |
} |
| 18369 |
} else { |
| 18370 |
sum = 0.; |
| 18371 |
i__2 = k + j - 1; |
| 18372 |
for (i__ = k; i__ <= i__2; ++i__) { |
| 18373 |
sum += (d__1 = ap[i__], abs(d__1)); |
| 18374 |
/* L100: */ |
| 18375 |
} |
| 18376 |
} |
| 18377 |
k += j; |
| 18378 |
value = std::max(value,sum); |
| 18379 |
/* L110: */ |
| 18380 |
} |
| 18381 |
} else { |
| 18382 |
i__1 = *n; |
| 18383 |
for (j = 1; j <= i__1; ++j) { |
| 18384 |
if (udiag) { |
| 18385 |
sum = 1.; |
| 18386 |
i__2 = k + *n - j; |
| 18387 |
for (i__ = k + 1; i__ <= i__2; ++i__) { |
| 18388 |
sum += (d__1 = ap[i__], abs(d__1)); |
| 18389 |
/* L120: */ |
| 18390 |
} |
| 18391 |
} else { |
| 18392 |
sum = 0.; |
| 18393 |
i__2 = k + *n - j; |
| 18394 |
for (i__ = k; i__ <= i__2; ++i__) { |
| 18395 |
sum += (d__1 = ap[i__], abs(d__1)); |
| 18396 |
/* L130: */ |
| 18397 |
} |
| 18398 |
} |
| 18399 |
k = k + *n - j + 1; |
| 18400 |
value = std::max(value,sum); |
| 18401 |
/* L140: */ |
| 18402 |
} |
| 18403 |
} |
| 18404 |
} else if (lsame_(norm, "I")) { |
| 18405 |
|
| 18406 |
/* Find normI(A). */ |
| 18407 |
|
| 18408 |
k = 1; |
| 18409 |
if (lsame_(uplo, "U")) { |
| 18410 |
if (lsame_(diag, "U")) { |
| 18411 |
i__1 = *n; |
| 18412 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 18413 |
work[i__] = 1.; |
| 18414 |
/* L150: */ |
| 18415 |
} |
| 18416 |
i__1 = *n; |
| 18417 |
for (j = 1; j <= i__1; ++j) { |
| 18418 |
i__2 = j - 1; |
| 18419 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 18420 |
work[i__] += (d__1 = ap[k], abs(d__1)); |
| 18421 |
++k; |
| 18422 |
/* L160: */ |
| 18423 |
} |
| 18424 |
++k; |
| 18425 |
/* L170: */ |
| 18426 |
} |
| 18427 |
} else { |
| 18428 |
i__1 = *n; |
| 18429 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 18430 |
work[i__] = 0.; |
| 18431 |
/* L180: */ |
| 18432 |
} |
| 18433 |
i__1 = *n; |
| 18434 |
for (j = 1; j <= i__1; ++j) { |
| 18435 |
i__2 = j; |
| 18436 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 18437 |
work[i__] += (d__1 = ap[k], abs(d__1)); |
| 18438 |
++k; |
| 18439 |
/* L190: */ |
| 18440 |
} |
| 18441 |
/* L200: */ |
| 18442 |
} |
| 18443 |
} |
| 18444 |
} else { |
| 18445 |
if (lsame_(diag, "U")) { |
| 18446 |
i__1 = *n; |
| 18447 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 18448 |
work[i__] = 1.; |
| 18449 |
/* L210: */ |
| 18450 |
} |
| 18451 |
i__1 = *n; |
| 18452 |
for (j = 1; j <= i__1; ++j) { |
| 18453 |
++k; |
| 18454 |
i__2 = *n; |
| 18455 |
for (i__ = j + 1; i__ <= i__2; ++i__) { |
| 18456 |
work[i__] += (d__1 = ap[k], abs(d__1)); |
| 18457 |
++k; |
| 18458 |
/* L220: */ |
| 18459 |
} |
| 18460 |
/* L230: */ |
| 18461 |
} |
| 18462 |
} else { |
| 18463 |
i__1 = *n; |
| 18464 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 18465 |
work[i__] = 0.; |
| 18466 |
/* L240: */ |
| 18467 |
} |
| 18468 |
i__1 = *n; |
| 18469 |
for (j = 1; j <= i__1; ++j) { |
| 18470 |
i__2 = *n; |
| 18471 |
for (i__ = j; i__ <= i__2; ++i__) { |
| 18472 |
work[i__] += (d__1 = ap[k], abs(d__1)); |
| 18473 |
++k; |
| 18474 |
/* L250: */ |
| 18475 |
} |
| 18476 |
/* L260: */ |
| 18477 |
} |
| 18478 |
} |
| 18479 |
} |
| 18480 |
value = 0.; |
| 18481 |
i__1 = *n; |
| 18482 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 18483 |
/* Computing MAX */ |
| 18484 |
d__1 = value, d__2 = work[i__]; |
| 18485 |
value = std::max(d__1,d__2); |
| 18486 |
/* L270: */ |
| 18487 |
} |
| 18488 |
} else if (lsame_(norm, "F") || lsame_(norm, "E")) { |
| 18489 |
|
| 18490 |
/* Find normF(A). */ |
| 18491 |
|
| 18492 |
if (lsame_(uplo, "U")) { |
| 18493 |
if (lsame_(diag, "U")) { |
| 18494 |
scale = 1.; |
| 18495 |
sum = (double) (*n); |
| 18496 |
k = 2; |
| 18497 |
i__1 = *n; |
| 18498 |
for (j = 2; j <= i__1; ++j) { |
| 18499 |
i__2 = j - 1; |
| 18500 |
dlassq_(&i__2, &ap[k], &c__1, &scale, &sum); |
| 18501 |
k += j; |
| 18502 |
/* L280: */ |
| 18503 |
} |
| 18504 |
} else { |
| 18505 |
scale = 0.; |
| 18506 |
sum = 1.; |
| 18507 |
k = 1; |
| 18508 |
i__1 = *n; |
| 18509 |
for (j = 1; j <= i__1; ++j) { |
| 18510 |
dlassq_(&j, &ap[k], &c__1, &scale, &sum); |
| 18511 |
k += j; |
| 18512 |
/* L290: */ |
| 18513 |
} |
| 18514 |
} |
| 18515 |
} else { |
| 18516 |
if (lsame_(diag, "U")) { |
| 18517 |
scale = 1.; |
| 18518 |
sum = (double) (*n); |
| 18519 |
k = 2; |
| 18520 |
i__1 = *n - 1; |
| 18521 |
for (j = 1; j <= i__1; ++j) { |
| 18522 |
i__2 = *n - j; |
| 18523 |
dlassq_(&i__2, &ap[k], &c__1, &scale, &sum); |
| 18524 |
k = k + *n - j + 1; |
| 18525 |
/* L300: */ |
| 18526 |
} |
| 18527 |
} else { |
| 18528 |
scale = 0.; |
| 18529 |
sum = 1.; |
| 18530 |
k = 1; |
| 18531 |
i__1 = *n; |
| 18532 |
for (j = 1; j <= i__1; ++j) { |
| 18533 |
i__2 = *n - j + 1; |
| 18534 |
dlassq_(&i__2, &ap[k], &c__1, &scale, &sum); |
| 18535 |
k = k + *n - j + 1; |
| 18536 |
/* L310: */ |
| 18537 |
} |
| 18538 |
} |
| 18539 |
} |
| 18540 |
value = scale * sqrt(sum); |
| 18541 |
} |
| 18542 |
|
| 18543 |
ret_val = value; |
| 18544 |
return ret_val; |
| 18545 |
|
| 18546 |
/* End of DLANTP */ |
| 18547 |
|
| 18548 |
} /* dlantp_ */ |
| 18549 |
|
| 18550 |
/* Subroutine */ double dlantr_(const char *norm, const char *uplo, const char *diag, integer *m, integer *n, |
| 18551 |
double *a, integer *lda, double *work) |
| 18552 |
{ |
| 18553 |
/* Table of constant values */ |
| 18554 |
static integer c__1 = 1; |
| 18555 |
|
| 18556 |
/* System generated locals */ |
| 18557 |
integer a_dim1, a_offset, i__1, i__2, i__3, i__4; |
| 18558 |
double ret_val, d__1, d__2, d__3; |
| 18559 |
|
| 18560 |
/* Local variables */ |
| 18561 |
integer i__, j; |
| 18562 |
double sum, scale; |
| 18563 |
bool udiag; |
| 18564 |
double value; |
| 18565 |
|
| 18566 |
|
| 18567 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 18568 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 18569 |
/* November 2006 */ |
| 18570 |
|
| 18571 |
/* .. Scalar Arguments .. */ |
| 18572 |
/* .. */ |
| 18573 |
/* .. Array Arguments .. */ |
| 18574 |
/* .. */ |
| 18575 |
|
| 18576 |
/* Purpose */ |
| 18577 |
/* ======= */ |
| 18578 |
|
| 18579 |
/* DLANTR returns the value of the one norm, or the Frobenius norm, or */ |
| 18580 |
/* the infinity norm, or the element of largest absolute value of a */ |
| 18581 |
/* trapezoidal or triangular matrix A. */ |
| 18582 |
|
| 18583 |
/* Description */ |
| 18584 |
/* =========== */ |
| 18585 |
|
| 18586 |
/* DLANTR returns the value */ |
| 18587 |
|
| 18588 |
/* DLANTR = ( max(abs(A(i,j))), NORM = 'M' or 'm' */ |
| 18589 |
/* ( */ |
| 18590 |
/* ( norm1(A), NORM = '1', 'O' or 'o' */ |
| 18591 |
/* ( */ |
| 18592 |
/* ( normI(A), NORM = 'I' or 'i' */ |
| 18593 |
/* ( */ |
| 18594 |
/* ( normF(A), NORM = 'F', 'f', 'E' or 'e' */ |
| 18595 |
|
| 18596 |
/* where norm1 denotes the one norm of a matrix (maximum column sum), */ |
| 18597 |
/* normI denotes the infinity norm of a matrix (maximum row sum) and */ |
| 18598 |
/* normF denotes the Frobenius norm of a matrix (square root of sum of */ |
| 18599 |
/* squares). Note that max(abs(A(i,j))) is not a consistent matrix norm. */ |
| 18600 |
|
| 18601 |
/* Arguments */ |
| 18602 |
/* ========= */ |
| 18603 |
|
| 18604 |
/* NORM (input) CHARACTER*1 */ |
| 18605 |
/* Specifies the value to be returned in DLANTR as described */ |
| 18606 |
/* above. */ |
| 18607 |
|
| 18608 |
/* UPLO (input) CHARACTER*1 */ |
| 18609 |
/* Specifies whether the matrix A is upper or lower trapezoidal. */ |
| 18610 |
/* = 'U': Upper trapezoidal */ |
| 18611 |
/* = 'L': Lower trapezoidal */ |
| 18612 |
/* Note that A is triangular instead of trapezoidal if M = N. */ |
| 18613 |
|
| 18614 |
/* DIAG (input) CHARACTER*1 */ |
| 18615 |
/* Specifies whether or not the matrix A has unit diagonal. */ |
| 18616 |
/* = 'N': Non-unit diagonal */ |
| 18617 |
/* = 'U': Unit diagonal */ |
| 18618 |
|
| 18619 |
/* M (input) INTEGER */ |
| 18620 |
/* The number of rows of the matrix A. M >= 0, and if */ |
| 18621 |
/* UPLO = 'U', M <= N. When M = 0, DLANTR is set to zero. */ |
| 18622 |
|
| 18623 |
/* N (input) INTEGER */ |
| 18624 |
/* The number of columns of the matrix A. N >= 0, and if */ |
| 18625 |
/* UPLO = 'L', N <= M. When N = 0, DLANTR is set to zero. */ |
| 18626 |
|
| 18627 |
/* A (input) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 18628 |
/* The trapezoidal matrix A (A is triangular if M = N). */ |
| 18629 |
/* If UPLO = 'U', the leading m by n upper trapezoidal part of */ |
| 18630 |
/* the array A contains the upper trapezoidal matrix, and the */ |
| 18631 |
/* strictly lower triangular part of A is not referenced. */ |
| 18632 |
/* If UPLO = 'L', the leading m by n lower trapezoidal part of */ |
| 18633 |
/* the array A contains the lower trapezoidal matrix, and the */ |
| 18634 |
/* strictly upper triangular part of A is not referenced. Note */ |
| 18635 |
/* that when DIAG = 'U', the diagonal elements of A are not */ |
| 18636 |
/* referenced and are assumed to be one. */ |
| 18637 |
|
| 18638 |
/* LDA (input) INTEGER */ |
| 18639 |
/* The leading dimension of the array A. LDA >= max(M,1). */ |
| 18640 |
|
| 18641 |
/* WORK (workspace) DOUBLE PRECISION array, dimension (MAX(1,LWORK)), */ |
| 18642 |
/* where LWORK >= M when NORM = 'I'; otherwise, WORK is not */ |
| 18643 |
/* referenced. */ |
| 18644 |
|
| 18645 |
/* ===================================================================== */ |
| 18646 |
|
| 18647 |
/* .. Parameters .. */ |
| 18648 |
/* .. */ |
| 18649 |
/* .. Local Scalars .. */ |
| 18650 |
/* .. */ |
| 18651 |
/* .. External Subroutines .. */ |
| 18652 |
/* .. */ |
| 18653 |
/* .. External Functions .. */ |
| 18654 |
/* .. */ |
| 18655 |
/* .. Intrinsic Functions .. */ |
| 18656 |
/* .. */ |
| 18657 |
/* .. Executable Statements .. */ |
| 18658 |
|
| 18659 |
/* Parameter adjustments */ |
| 18660 |
a_dim1 = *lda; |
| 18661 |
a_offset = 1 + a_dim1; |
| 18662 |
a -= a_offset; |
| 18663 |
--work; |
| 18664 |
|
| 18665 |
/* Function Body */ |
| 18666 |
if (std::min(*m,*n) == 0) { |
| 18667 |
value = 0.; |
| 18668 |
} else if (lsame_(norm, "M")) { |
| 18669 |
|
| 18670 |
/* Find max(abs(A(i,j))). */ |
| 18671 |
|
| 18672 |
if (lsame_(diag, "U")) { |
| 18673 |
value = 1.; |
| 18674 |
if (lsame_(uplo, "U")) { |
| 18675 |
i__1 = *n; |
| 18676 |
for (j = 1; j <= i__1; ++j) { |
| 18677 |
/* Computing MIN */ |
| 18678 |
i__3 = *m, i__4 = j - 1; |
| 18679 |
i__2 = std::min(i__3,i__4); |
| 18680 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 18681 |
/* Computing MAX */ |
| 18682 |
d__2 = value, d__3 = (d__1 = a[i__ + j * a_dim1], abs( |
| 18683 |
d__1)); |
| 18684 |
value = std::max(d__2,d__3); |
| 18685 |
/* L10: */ |
| 18686 |
} |
| 18687 |
/* L20: */ |
| 18688 |
} |
| 18689 |
} else { |
| 18690 |
i__1 = *n; |
| 18691 |
for (j = 1; j <= i__1; ++j) { |
| 18692 |
i__2 = *m; |
| 18693 |
for (i__ = j + 1; i__ <= i__2; ++i__) { |
| 18694 |
/* Computing MAX */ |
| 18695 |
d__2 = value, d__3 = (d__1 = a[i__ + j * a_dim1], abs( |
| 18696 |
d__1)); |
| 18697 |
value = std::max(d__2,d__3); |
| 18698 |
/* L30: */ |
| 18699 |
} |
| 18700 |
/* L40: */ |
| 18701 |
} |
| 18702 |
} |
| 18703 |
} else { |
| 18704 |
value = 0.; |
| 18705 |
if (lsame_(uplo, "U")) { |
| 18706 |
i__1 = *n; |
| 18707 |
for (j = 1; j <= i__1; ++j) { |
| 18708 |
i__2 = std::min(*m,j); |
| 18709 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 18710 |
/* Computing MAX */ |
| 18711 |
d__2 = value, d__3 = (d__1 = a[i__ + j * a_dim1], abs( |
| 18712 |
d__1)); |
| 18713 |
value = std::max(d__2,d__3); |
| 18714 |
/* L50: */ |
| 18715 |
} |
| 18716 |
/* L60: */ |
| 18717 |
} |
| 18718 |
} else { |
| 18719 |
i__1 = *n; |
| 18720 |
for (j = 1; j <= i__1; ++j) { |
| 18721 |
i__2 = *m; |
| 18722 |
for (i__ = j; i__ <= i__2; ++i__) { |
| 18723 |
/* Computing MAX */ |
| 18724 |
d__2 = value, d__3 = (d__1 = a[i__ + j * a_dim1], abs( |
| 18725 |
d__1)); |
| 18726 |
value = std::max(d__2,d__3); |
| 18727 |
/* L70: */ |
| 18728 |
} |
| 18729 |
/* L80: */ |
| 18730 |
} |
| 18731 |
} |
| 18732 |
} |
| 18733 |
} else if (lsame_(norm, "O") || *(unsigned char *) |
| 18734 |
norm == '1') { |
| 18735 |
|
| 18736 |
/* Find norm1(A). */ |
| 18737 |
|
| 18738 |
value = 0.; |
| 18739 |
udiag = lsame_(diag, "U"); |
| 18740 |
if (lsame_(uplo, "U")) { |
| 18741 |
i__1 = *n; |
| 18742 |
for (j = 1; j <= i__1; ++j) { |
| 18743 |
if (udiag && j <= *m) { |
| 18744 |
sum = 1.; |
| 18745 |
i__2 = j - 1; |
| 18746 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 18747 |
sum += (d__1 = a[i__ + j * a_dim1], abs(d__1)); |
| 18748 |
/* L90: */ |
| 18749 |
} |
| 18750 |
} else { |
| 18751 |
sum = 0.; |
| 18752 |
i__2 = std::min(*m,j); |
| 18753 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 18754 |
sum += (d__1 = a[i__ + j * a_dim1], abs(d__1)); |
| 18755 |
/* L100: */ |
| 18756 |
} |
| 18757 |
} |
| 18758 |
value = std::max(value,sum); |
| 18759 |
/* L110: */ |
| 18760 |
} |
| 18761 |
} else { |
| 18762 |
i__1 = *n; |
| 18763 |
for (j = 1; j <= i__1; ++j) { |
| 18764 |
if (udiag) { |
| 18765 |
sum = 1.; |
| 18766 |
i__2 = *m; |
| 18767 |
for (i__ = j + 1; i__ <= i__2; ++i__) { |
| 18768 |
sum += (d__1 = a[i__ + j * a_dim1], abs(d__1)); |
| 18769 |
/* L120: */ |
| 18770 |
} |
| 18771 |
} else { |
| 18772 |
sum = 0.; |
| 18773 |
i__2 = *m; |
| 18774 |
for (i__ = j; i__ <= i__2; ++i__) { |
| 18775 |
sum += (d__1 = a[i__ + j * a_dim1], abs(d__1)); |
| 18776 |
/* L130: */ |
| 18777 |
} |
| 18778 |
} |
| 18779 |
value = std::max(value,sum); |
| 18780 |
/* L140: */ |
| 18781 |
} |
| 18782 |
} |
| 18783 |
} else if (lsame_(norm, "I")) { |
| 18784 |
|
| 18785 |
/* Find normI(A). */ |
| 18786 |
|
| 18787 |
if (lsame_(uplo, "U")) { |
| 18788 |
if (lsame_(diag, "U")) { |
| 18789 |
i__1 = *m; |
| 18790 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 18791 |
work[i__] = 1.; |
| 18792 |
/* L150: */ |
| 18793 |
} |
| 18794 |
i__1 = *n; |
| 18795 |
for (j = 1; j <= i__1; ++j) { |
| 18796 |
/* Computing MIN */ |
| 18797 |
i__3 = *m, i__4 = j - 1; |
| 18798 |
i__2 = std::min(i__3,i__4); |
| 18799 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 18800 |
work[i__] += (d__1 = a[i__ + j * a_dim1], abs(d__1)); |
| 18801 |
/* L160: */ |
| 18802 |
} |
| 18803 |
/* L170: */ |
| 18804 |
} |
| 18805 |
} else { |
| 18806 |
i__1 = *m; |
| 18807 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 18808 |
work[i__] = 0.; |
| 18809 |
/* L180: */ |
| 18810 |
} |
| 18811 |
i__1 = *n; |
| 18812 |
for (j = 1; j <= i__1; ++j) { |
| 18813 |
i__2 = std::min(*m,j); |
| 18814 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 18815 |
work[i__] += (d__1 = a[i__ + j * a_dim1], abs(d__1)); |
| 18816 |
/* L190: */ |
| 18817 |
} |
| 18818 |
/* L200: */ |
| 18819 |
} |
| 18820 |
} |
| 18821 |
} else { |
| 18822 |
if (lsame_(diag, "U")) { |
| 18823 |
i__1 = *n; |
| 18824 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 18825 |
work[i__] = 1.; |
| 18826 |
/* L210: */ |
| 18827 |
} |
| 18828 |
i__1 = *m; |
| 18829 |
for (i__ = *n + 1; i__ <= i__1; ++i__) { |
| 18830 |
work[i__] = 0.; |
| 18831 |
/* L220: */ |
| 18832 |
} |
| 18833 |
i__1 = *n; |
| 18834 |
for (j = 1; j <= i__1; ++j) { |
| 18835 |
i__2 = *m; |
| 18836 |
for (i__ = j + 1; i__ <= i__2; ++i__) { |
| 18837 |
work[i__] += (d__1 = a[i__ + j * a_dim1], abs(d__1)); |
| 18838 |
/* L230: */ |
| 18839 |
} |
| 18840 |
/* L240: */ |
| 18841 |
} |
| 18842 |
} else { |
| 18843 |
i__1 = *m; |
| 18844 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 18845 |
work[i__] = 0.; |
| 18846 |
/* L250: */ |
| 18847 |
} |
| 18848 |
i__1 = *n; |
| 18849 |
for (j = 1; j <= i__1; ++j) { |
| 18850 |
i__2 = *m; |
| 18851 |
for (i__ = j; i__ <= i__2; ++i__) { |
| 18852 |
work[i__] += (d__1 = a[i__ + j * a_dim1], abs(d__1)); |
| 18853 |
/* L260: */ |
| 18854 |
} |
| 18855 |
/* L270: */ |
| 18856 |
} |
| 18857 |
} |
| 18858 |
} |
| 18859 |
value = 0.; |
| 18860 |
i__1 = *m; |
| 18861 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 18862 |
/* Computing MAX */ |
| 18863 |
d__1 = value, d__2 = work[i__]; |
| 18864 |
value = std::max(d__1,d__2); |
| 18865 |
/* L280: */ |
| 18866 |
} |
| 18867 |
} else if (lsame_(norm, "F") || lsame_(norm, "E")) { |
| 18868 |
|
| 18869 |
/* Find normF(A). */ |
| 18870 |
|
| 18871 |
if (lsame_(uplo, "U")) { |
| 18872 |
if (lsame_(diag, "U")) { |
| 18873 |
scale = 1.; |
| 18874 |
sum = (double) std::min(*m,*n); |
| 18875 |
i__1 = *n; |
| 18876 |
for (j = 2; j <= i__1; ++j) { |
| 18877 |
/* Computing MIN */ |
| 18878 |
i__3 = *m, i__4 = j - 1; |
| 18879 |
i__2 = std::min(i__3,i__4); |
| 18880 |
dlassq_(&i__2, &a[j * a_dim1 + 1], &c__1, &scale, &sum); |
| 18881 |
/* L290: */ |
| 18882 |
} |
| 18883 |
} else { |
| 18884 |
scale = 0.; |
| 18885 |
sum = 1.; |
| 18886 |
i__1 = *n; |
| 18887 |
for (j = 1; j <= i__1; ++j) { |
| 18888 |
i__2 = std::min(*m,j); |
| 18889 |
dlassq_(&i__2, &a[j * a_dim1 + 1], &c__1, &scale, &sum); |
| 18890 |
/* L300: */ |
| 18891 |
} |
| 18892 |
} |
| 18893 |
} else { |
| 18894 |
if (lsame_(diag, "U")) { |
| 18895 |
scale = 1.; |
| 18896 |
sum = (double) std::min(*m,*n); |
| 18897 |
i__1 = *n; |
| 18898 |
for (j = 1; j <= i__1; ++j) { |
| 18899 |
i__2 = *m - j; |
| 18900 |
/* Computing MIN */ |
| 18901 |
i__3 = *m, i__4 = j + 1; |
| 18902 |
dlassq_(&i__2, &a[std::min(i__3, i__4)+ j * a_dim1], &c__1, & |
| 18903 |
scale, &sum); |
| 18904 |
/* L310: */ |
| 18905 |
} |
| 18906 |
} else { |
| 18907 |
scale = 0.; |
| 18908 |
sum = 1.; |
| 18909 |
i__1 = *n; |
| 18910 |
for (j = 1; j <= i__1; ++j) { |
| 18911 |
i__2 = *m - j + 1; |
| 18912 |
dlassq_(&i__2, &a[j + j * a_dim1], &c__1, &scale, &sum); |
| 18913 |
/* L320: */ |
| 18914 |
} |
| 18915 |
} |
| 18916 |
} |
| 18917 |
value = scale * sqrt(sum); |
| 18918 |
} |
| 18919 |
|
| 18920 |
ret_val = value; |
| 18921 |
return ret_val; |
| 18922 |
|
| 18923 |
/* End of DLANTR */ |
| 18924 |
|
| 18925 |
} /* dlantr_ */ |
| 18926 |
|
| 18927 |
/* Subroutine */ int dlanv2_(double *a, double *b, double *c__, |
| 18928 |
double *d__, double *rt1r, double *rt1i, double *rt2r, |
| 18929 |
double *rt2i, double *cs, double *sn) |
| 18930 |
{ |
| 18931 |
/* Table of constant values */ |
| 18932 |
static double c_b4 = 1.; |
| 18933 |
|
| 18934 |
/* System generated locals */ |
| 18935 |
double d__1, d__2; |
| 18936 |
|
| 18937 |
/* Builtin functions |
| 18938 |
double d_sign(double *, double *), sqrt(double); */ |
| 18939 |
|
| 18940 |
/* Local variables */ |
| 18941 |
double p, z__, aa, bb, cc, dd, cs1, sn1, sab, sac, eps, tau, temp, |
| 18942 |
scale, bcmax, bcmis, sigma; |
| 18943 |
|
| 18944 |
|
| 18945 |
|
| 18946 |
/* -- LAPACK driver routine (version 3.1) -- */ |
| 18947 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 18948 |
/* November 2006 */ |
| 18949 |
|
| 18950 |
/* .. Scalar Arguments .. */ |
| 18951 |
/* .. */ |
| 18952 |
|
| 18953 |
/* Purpose */ |
| 18954 |
/* ======= */ |
| 18955 |
|
| 18956 |
/* DLANV2 computes the Schur factorization of a real 2-by-2 nonsymmetric */ |
| 18957 |
/* matrix in standard form: */ |
| 18958 |
|
| 18959 |
/* [ A B ] = [ CS -SN ] [ AA BB ] [ CS SN ] */ |
| 18960 |
/* [ C D ] [ SN CS ] [ CC DD ] [-SN CS ] */ |
| 18961 |
|
| 18962 |
/* where either */ |
| 18963 |
/* 1) CC = 0 so that AA and DD are real eigenvalues of the matrix, or */ |
| 18964 |
/* 2) AA = DD and BB*CC < 0, so that AA + or - sqrt(BB*CC) are complex */ |
| 18965 |
/* conjugate eigenvalues. */ |
| 18966 |
|
| 18967 |
/* Arguments */ |
| 18968 |
/* ========= */ |
| 18969 |
|
| 18970 |
/* A (input/output) DOUBLE PRECISION */ |
| 18971 |
/* B (input/output) DOUBLE PRECISION */ |
| 18972 |
/* C (input/output) DOUBLE PRECISION */ |
| 18973 |
/* D (input/output) DOUBLE PRECISION */ |
| 18974 |
/* On entry, the elements of the input matrix. */ |
| 18975 |
/* On exit, they are overwritten by the elements of the */ |
| 18976 |
/* standardised Schur form. */ |
| 18977 |
|
| 18978 |
/* RT1R (output) DOUBLE PRECISION */ |
| 18979 |
/* RT1I (output) DOUBLE PRECISION */ |
| 18980 |
/* RT2R (output) DOUBLE PRECISION */ |
| 18981 |
/* RT2I (output) DOUBLE PRECISION */ |
| 18982 |
/* The real and imaginary parts of the eigenvalues. If the */ |
| 18983 |
/* eigenvalues are a complex conjugate pair, RT1I > 0. */ |
| 18984 |
|
| 18985 |
/* CS (output) DOUBLE PRECISION */ |
| 18986 |
/* SN (output) DOUBLE PRECISION */ |
| 18987 |
/* Parameters of the rotation matrix. */ |
| 18988 |
|
| 18989 |
/* Further Details */ |
| 18990 |
/* =============== */ |
| 18991 |
|
| 18992 |
/* Modified by V. Sima, Research Institute for Informatics, Bucharest, */ |
| 18993 |
/* Romania, to reduce the risk of cancellation errors, */ |
| 18994 |
/* when computing real eigenvalues, and to ensure, if possible, that */ |
| 18995 |
/* abs(RT1R) >= abs(RT2R). */ |
| 18996 |
|
| 18997 |
/* ===================================================================== */ |
| 18998 |
|
| 18999 |
/* .. Parameters .. */ |
| 19000 |
/* .. */ |
| 19001 |
/* .. Local Scalars .. */ |
| 19002 |
/* .. */ |
| 19003 |
/* .. External Functions .. */ |
| 19004 |
/* .. */ |
| 19005 |
/* .. Intrinsic Functions .. */ |
| 19006 |
/* .. */ |
| 19007 |
/* .. Executable Statements .. */ |
| 19008 |
|
| 19009 |
eps = dlamch_("P"); |
| 19010 |
if (*c__ == 0.) { |
| 19011 |
*cs = 1.; |
| 19012 |
*sn = 0.; |
| 19013 |
goto L10; |
| 19014 |
|
| 19015 |
} else if (*b == 0.) { |
| 19016 |
|
| 19017 |
/* Swap rows and columns */ |
| 19018 |
|
| 19019 |
*cs = 0.; |
| 19020 |
*sn = 1.; |
| 19021 |
temp = *d__; |
| 19022 |
*d__ = *a; |
| 19023 |
*a = temp; |
| 19024 |
*b = -(*c__); |
| 19025 |
*c__ = 0.; |
| 19026 |
goto L10; |
| 19027 |
} else if (*a - *d__ == 0. && d_sign(&c_b4, b) != d_sign(&c_b4, c__)) { |
| 19028 |
*cs = 1.; |
| 19029 |
*sn = 0.; |
| 19030 |
goto L10; |
| 19031 |
} else { |
| 19032 |
|
| 19033 |
temp = *a - *d__; |
| 19034 |
p = temp * .5; |
| 19035 |
/* Computing MAX */ |
| 19036 |
d__1 = abs(*b), d__2 = abs(*c__); |
| 19037 |
bcmax = std::max(d__1,d__2); |
| 19038 |
/* Computing MIN */ |
| 19039 |
d__1 = abs(*b), d__2 = abs(*c__); |
| 19040 |
bcmis = std::min(d__1,d__2) * d_sign(&c_b4, b) * d_sign(&c_b4, c__); |
| 19041 |
/* Computing MAX */ |
| 19042 |
d__1 = abs(p); |
| 19043 |
scale = std::max(d__1,bcmax); |
| 19044 |
z__ = p / scale * p + bcmax / scale * bcmis; |
| 19045 |
|
| 19046 |
/* If Z is of the order of the machine accuracy, postpone the */ |
| 19047 |
/* decision on the nature of eigenvalues */ |
| 19048 |
|
| 19049 |
if (z__ >= eps * 4.) { |
| 19050 |
|
| 19051 |
/* Real eigenvalues. Compute A and D. */ |
| 19052 |
|
| 19053 |
d__1 = sqrt(scale) * sqrt(z__); |
| 19054 |
z__ = p + d_sign(&d__1, &p); |
| 19055 |
*a = *d__ + z__; |
| 19056 |
*d__ -= bcmax / z__ * bcmis; |
| 19057 |
|
| 19058 |
/* Compute B and the rotation matrix */ |
| 19059 |
|
| 19060 |
tau = dlapy2_(c__, &z__); |
| 19061 |
*cs = z__ / tau; |
| 19062 |
*sn = *c__ / tau; |
| 19063 |
*b -= *c__; |
| 19064 |
*c__ = 0.; |
| 19065 |
} else { |
| 19066 |
|
| 19067 |
/* Complex eigenvalues, or real (almost) equal eigenvalues. */ |
| 19068 |
/* Make diagonal elements equal. */ |
| 19069 |
|
| 19070 |
sigma = *b + *c__; |
| 19071 |
tau = dlapy2_(&sigma, &temp); |
| 19072 |
*cs = sqrt((abs(sigma) / tau + 1.) * .5); |
| 19073 |
*sn = -(p / (tau * *cs)) * d_sign(&c_b4, &sigma); |
| 19074 |
|
| 19075 |
/* Compute [ AA BB ] = [ A B ] [ CS -SN ] */ |
| 19076 |
/* [ CC DD ] [ C D ] [ SN CS ] */ |
| 19077 |
|
| 19078 |
aa = *a * *cs + *b * *sn; |
| 19079 |
bb = -(*a) * *sn + *b * *cs; |
| 19080 |
cc = *c__ * *cs + *d__ * *sn; |
| 19081 |
dd = -(*c__) * *sn + *d__ * *cs; |
| 19082 |
|
| 19083 |
/* Compute [ A B ] = [ CS SN ] [ AA BB ] */ |
| 19084 |
/* [ C D ] [-SN CS ] [ CC DD ] */ |
| 19085 |
|
| 19086 |
*a = aa * *cs + cc * *sn; |
| 19087 |
*b = bb * *cs + dd * *sn; |
| 19088 |
*c__ = -aa * *sn + cc * *cs; |
| 19089 |
*d__ = -bb * *sn + dd * *cs; |
| 19090 |
|
| 19091 |
temp = (*a + *d__) * .5; |
| 19092 |
*a = temp; |
| 19093 |
*d__ = temp; |
| 19094 |
|
| 19095 |
if (*c__ != 0.) { |
| 19096 |
if (*b != 0.) { |
| 19097 |
if (d_sign(&c_b4, b) == d_sign(&c_b4, c__)) { |
| 19098 |
|
| 19099 |
/* Real eigenvalues: reduce to upper triangular form */ |
| 19100 |
|
| 19101 |
sab = sqrt((abs(*b))); |
| 19102 |
sac = sqrt((abs(*c__))); |
| 19103 |
d__1 = sab * sac; |
| 19104 |
p = d_sign(&d__1, c__); |
| 19105 |
tau = 1. / sqrt((d__1 = *b + *c__, abs(d__1))); |
| 19106 |
*a = temp + p; |
| 19107 |
*d__ = temp - p; |
| 19108 |
*b -= *c__; |
| 19109 |
*c__ = 0.; |
| 19110 |
cs1 = sab * tau; |
| 19111 |
sn1 = sac * tau; |
| 19112 |
temp = *cs * cs1 - *sn * sn1; |
| 19113 |
*sn = *cs * sn1 + *sn * cs1; |
| 19114 |
*cs = temp; |
| 19115 |
} |
| 19116 |
} else { |
| 19117 |
*b = -(*c__); |
| 19118 |
*c__ = 0.; |
| 19119 |
temp = *cs; |
| 19120 |
*cs = -(*sn); |
| 19121 |
*sn = temp; |
| 19122 |
} |
| 19123 |
} |
| 19124 |
} |
| 19125 |
|
| 19126 |
} |
| 19127 |
|
| 19128 |
L10: |
| 19129 |
|
| 19130 |
/* Store eigenvalues in (RT1R,RT1I) and (RT2R,RT2I). */ |
| 19131 |
|
| 19132 |
*rt1r = *a; |
| 19133 |
*rt2r = *d__; |
| 19134 |
if (*c__ == 0.) { |
| 19135 |
*rt1i = 0.; |
| 19136 |
*rt2i = 0.; |
| 19137 |
} else { |
| 19138 |
*rt1i = sqrt((abs(*b))) * sqrt((abs(*c__))); |
| 19139 |
*rt2i = -(*rt1i); |
| 19140 |
} |
| 19141 |
return 0; |
| 19142 |
|
| 19143 |
/* End of DLANV2 */ |
| 19144 |
|
| 19145 |
} /* dlanv2_ */ |
| 19146 |
|
| 19147 |
/* Subroutine */ int dlapll_(integer *n, double *x, integer *incx, |
| 19148 |
double *y, integer *incy, double *ssmin) |
| 19149 |
{ |
| 19150 |
/* System generated locals */ |
| 19151 |
integer i__1; |
| 19152 |
|
| 19153 |
/* Local variables */ |
| 19154 |
double c__, a11, a12, a22, tau; |
| 19155 |
double ssmax; |
| 19156 |
|
| 19157 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 19158 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 19159 |
/* November 2006 */ |
| 19160 |
|
| 19161 |
/* .. Scalar Arguments .. */ |
| 19162 |
/* .. */ |
| 19163 |
/* .. Array Arguments .. */ |
| 19164 |
/* .. */ |
| 19165 |
|
| 19166 |
/* Purpose */ |
| 19167 |
/* ======= */ |
| 19168 |
|
| 19169 |
/* Given two column vectors X and Y, let */ |
| 19170 |
|
| 19171 |
/* A = ( X Y ). */ |
| 19172 |
|
| 19173 |
/* The subroutine first computes the QR factorization of A = Q*R, */ |
| 19174 |
/* and then computes the SVD of the 2-by-2 upper triangular matrix R. */ |
| 19175 |
/* The smaller singular value of R is returned in SSMIN, which is used */ |
| 19176 |
/* as the measurement of the linear dependency of the vectors X and Y. */ |
| 19177 |
|
| 19178 |
/* Arguments */ |
| 19179 |
/* ========= */ |
| 19180 |
|
| 19181 |
/* N (input) INTEGER */ |
| 19182 |
/* The length of the vectors X and Y. */ |
| 19183 |
|
| 19184 |
/* X (input/output) DOUBLE PRECISION array, */ |
| 19185 |
/* dimension (1+(N-1)*INCX) */ |
| 19186 |
/* On entry, X contains the N-vector X. */ |
| 19187 |
/* On exit, X is overwritten. */ |
| 19188 |
|
| 19189 |
/* INCX (input) INTEGER */ |
| 19190 |
/* The increment between successive elements of X. INCX > 0. */ |
| 19191 |
|
| 19192 |
/* Y (input/output) DOUBLE PRECISION array, */ |
| 19193 |
/* dimension (1+(N-1)*INCY) */ |
| 19194 |
/* On entry, Y contains the N-vector Y. */ |
| 19195 |
/* On exit, Y is overwritten. */ |
| 19196 |
|
| 19197 |
/* INCY (input) INTEGER */ |
| 19198 |
/* The increment between successive elements of Y. INCY > 0. */ |
| 19199 |
|
| 19200 |
/* SSMIN (output) DOUBLE PRECISION */ |
| 19201 |
/* The smallest singular value of the N-by-2 matrix A = ( X Y ). */ |
| 19202 |
|
| 19203 |
/* ===================================================================== */ |
| 19204 |
|
| 19205 |
/* .. Parameters .. */ |
| 19206 |
/* .. */ |
| 19207 |
/* .. Local Scalars .. */ |
| 19208 |
/* .. */ |
| 19209 |
/* .. External Functions .. */ |
| 19210 |
/* .. */ |
| 19211 |
/* .. External Subroutines .. */ |
| 19212 |
/* .. */ |
| 19213 |
/* .. Executable Statements .. */ |
| 19214 |
|
| 19215 |
/* Quick return if possible */ |
| 19216 |
|
| 19217 |
/* Parameter adjustments */ |
| 19218 |
--y; |
| 19219 |
--x; |
| 19220 |
|
| 19221 |
/* Function Body */ |
| 19222 |
if (*n <= 1) { |
| 19223 |
*ssmin = 0.; |
| 19224 |
return 0; |
| 19225 |
} |
| 19226 |
|
| 19227 |
/* Compute the QR factorization of the N-by-2 matrix ( X Y ) */ |
| 19228 |
|
| 19229 |
dlarfg_(n, &x[1], &x[*incx + 1], incx, &tau); |
| 19230 |
a11 = x[1]; |
| 19231 |
x[1] = 1.; |
| 19232 |
|
| 19233 |
c__ = -tau * ddot_(n, &x[1], incx, &y[1], incy); |
| 19234 |
daxpy_(n, &c__, &x[1], incx, &y[1], incy); |
| 19235 |
|
| 19236 |
i__1 = *n - 1; |
| 19237 |
dlarfg_(&i__1, &y[*incy + 1], &y[(*incy << 1) + 1], incy, &tau); |
| 19238 |
|
| 19239 |
a12 = y[1]; |
| 19240 |
a22 = y[*incy + 1]; |
| 19241 |
|
| 19242 |
/* Compute the SVD of 2-by-2 Upper triangular matrix. */ |
| 19243 |
|
| 19244 |
dlas2_(&a11, &a12, &a22, ssmin, &ssmax); |
| 19245 |
|
| 19246 |
return 0; |
| 19247 |
|
| 19248 |
/* End of DLAPLL */ |
| 19249 |
|
| 19250 |
} /* dlapll_ */ |
| 19251 |
|
| 19252 |
/* Subroutine */ int dlapmt_(bool *forwrd, integer *m, integer *n, |
| 19253 |
double *x, integer *ldx, integer *k) |
| 19254 |
{ |
| 19255 |
/* System generated locals */ |
| 19256 |
integer x_dim1, x_offset, i__1, i__2; |
| 19257 |
|
| 19258 |
/* Local variables */ |
| 19259 |
integer i__, j, ii, in; |
| 19260 |
double temp; |
| 19261 |
|
| 19262 |
|
| 19263 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 19264 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 19265 |
/* November 2006 */ |
| 19266 |
|
| 19267 |
/* .. Scalar Arguments .. */ |
| 19268 |
/* .. */ |
| 19269 |
/* .. Array Arguments .. */ |
| 19270 |
/* .. */ |
| 19271 |
|
| 19272 |
/* Purpose */ |
| 19273 |
/* ======= */ |
| 19274 |
|
| 19275 |
/* DLAPMT rearranges the columns of the M by N matrix X as specified */ |
| 19276 |
/* by the permutation K(1),K(2),...,K(N) of the integers 1,...,N. */ |
| 19277 |
/* If FORWRD = .TRUE., forward permutation: */ |
| 19278 |
|
| 19279 |
/* X(*,K(J)) is moved X(*,J) for J = 1,2,...,N. */ |
| 19280 |
|
| 19281 |
/* If FORWRD = .FALSE., backward permutation: */ |
| 19282 |
|
| 19283 |
/* X(*,J) is moved to X(*,K(J)) for J = 1,2,...,N. */ |
| 19284 |
|
| 19285 |
/* Arguments */ |
| 19286 |
/* ========= */ |
| 19287 |
|
| 19288 |
/* FORWRD (input) LOGICAL */ |
| 19289 |
/* = .TRUE., forward permutation */ |
| 19290 |
/* = .FALSE., backward permutation */ |
| 19291 |
|
| 19292 |
/* M (input) INTEGER */ |
| 19293 |
/* The number of rows of the matrix X. M >= 0. */ |
| 19294 |
|
| 19295 |
/* N (input) INTEGER */ |
| 19296 |
/* The number of columns of the matrix X. N >= 0. */ |
| 19297 |
|
| 19298 |
/* X (input/output) DOUBLE PRECISION array, dimension (LDX,N) */ |
| 19299 |
/* On entry, the M by N matrix X. */ |
| 19300 |
/* On exit, X contains the permuted matrix X. */ |
| 19301 |
|
| 19302 |
/* LDX (input) INTEGER */ |
| 19303 |
/* The leading dimension of the array X, LDX >= MAX(1,M). */ |
| 19304 |
|
| 19305 |
/* K (input/output) INTEGER array, dimension (N) */ |
| 19306 |
/* On entry, K contains the permutation vector. K is used as */ |
| 19307 |
/* internal workspace, but reset to its original value on */ |
| 19308 |
/* output. */ |
| 19309 |
|
| 19310 |
/* ===================================================================== */ |
| 19311 |
|
| 19312 |
/* .. Local Scalars .. */ |
| 19313 |
/* .. */ |
| 19314 |
/* .. Executable Statements .. */ |
| 19315 |
|
| 19316 |
/* Parameter adjustments */ |
| 19317 |
x_dim1 = *ldx; |
| 19318 |
x_offset = 1 + x_dim1; |
| 19319 |
x -= x_offset; |
| 19320 |
--k; |
| 19321 |
|
| 19322 |
/* Function Body */ |
| 19323 |
if (*n <= 1) { |
| 19324 |
return 0; |
| 19325 |
} |
| 19326 |
|
| 19327 |
i__1 = *n; |
| 19328 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 19329 |
k[i__] = -k[i__]; |
| 19330 |
/* L10: */ |
| 19331 |
} |
| 19332 |
|
| 19333 |
if (*forwrd) { |
| 19334 |
|
| 19335 |
/* Forward permutation */ |
| 19336 |
|
| 19337 |
i__1 = *n; |
| 19338 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 19339 |
|
| 19340 |
if (k[i__] > 0) { |
| 19341 |
goto L40; |
| 19342 |
} |
| 19343 |
|
| 19344 |
j = i__; |
| 19345 |
k[j] = -k[j]; |
| 19346 |
in = k[j]; |
| 19347 |
|
| 19348 |
L20: |
| 19349 |
if (k[in] > 0) { |
| 19350 |
goto L40; |
| 19351 |
} |
| 19352 |
|
| 19353 |
i__2 = *m; |
| 19354 |
for (ii = 1; ii <= i__2; ++ii) { |
| 19355 |
temp = x[ii + j * x_dim1]; |
| 19356 |
x[ii + j * x_dim1] = x[ii + in * x_dim1]; |
| 19357 |
x[ii + in * x_dim1] = temp; |
| 19358 |
/* L30: */ |
| 19359 |
} |
| 19360 |
|
| 19361 |
k[in] = -k[in]; |
| 19362 |
j = in; |
| 19363 |
in = k[in]; |
| 19364 |
goto L20; |
| 19365 |
|
| 19366 |
L40: |
| 19367 |
|
| 19368 |
/* L50: */ |
| 19369 |
; |
| 19370 |
} |
| 19371 |
|
| 19372 |
} else { |
| 19373 |
|
| 19374 |
/* Backward permutation */ |
| 19375 |
|
| 19376 |
i__1 = *n; |
| 19377 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 19378 |
|
| 19379 |
if (k[i__] > 0) { |
| 19380 |
goto L80; |
| 19381 |
} |
| 19382 |
|
| 19383 |
k[i__] = -k[i__]; |
| 19384 |
j = k[i__]; |
| 19385 |
L60: |
| 19386 |
if (j == i__) { |
| 19387 |
goto L80; |
| 19388 |
} |
| 19389 |
|
| 19390 |
i__2 = *m; |
| 19391 |
for (ii = 1; ii <= i__2; ++ii) { |
| 19392 |
temp = x[ii + i__ * x_dim1]; |
| 19393 |
x[ii + i__ * x_dim1] = x[ii + j * x_dim1]; |
| 19394 |
x[ii + j * x_dim1] = temp; |
| 19395 |
/* L70: */ |
| 19396 |
} |
| 19397 |
|
| 19398 |
k[j] = -k[j]; |
| 19399 |
j = k[j]; |
| 19400 |
goto L60; |
| 19401 |
|
| 19402 |
L80: |
| 19403 |
|
| 19404 |
/* L90: */ |
| 19405 |
; |
| 19406 |
} |
| 19407 |
|
| 19408 |
} |
| 19409 |
|
| 19410 |
return 0; |
| 19411 |
|
| 19412 |
/* End of DLAPMT */ |
| 19413 |
|
| 19414 |
} /* dlapmt_ */ |
| 19415 |
|
| 19416 |
/* Subroutine */ double dlapy2_(double *x, double *y) |
| 19417 |
{ |
| 19418 |
/* System generated locals */ |
| 19419 |
double ret_val, d__1; |
| 19420 |
|
| 19421 |
/* Builtin functions |
| 19422 |
double sqrt(double); */ |
| 19423 |
|
| 19424 |
/* Local variables */ |
| 19425 |
double w, z__, xabs, yabs; |
| 19426 |
|
| 19427 |
|
| 19428 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 19429 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 19430 |
/* November 2006 */ |
| 19431 |
|
| 19432 |
/* .. Scalar Arguments .. */ |
| 19433 |
/* .. */ |
| 19434 |
|
| 19435 |
/* Purpose */ |
| 19436 |
/* ======= */ |
| 19437 |
|
| 19438 |
/* DLAPY2 returns sqrt(x**2+y**2), taking care not to cause unnecessary */ |
| 19439 |
/* overflow. */ |
| 19440 |
|
| 19441 |
/* Arguments */ |
| 19442 |
/* ========= */ |
| 19443 |
|
| 19444 |
/* X (input) DOUBLE PRECISION */ |
| 19445 |
/* Y (input) DOUBLE PRECISION */ |
| 19446 |
/* X and Y specify the values x and y. */ |
| 19447 |
|
| 19448 |
/* ===================================================================== */ |
| 19449 |
|
| 19450 |
/* .. Parameters .. */ |
| 19451 |
/* .. */ |
| 19452 |
/* .. Local Scalars .. */ |
| 19453 |
/* .. */ |
| 19454 |
/* .. Intrinsic Functions .. */ |
| 19455 |
/* .. */ |
| 19456 |
/* .. Executable Statements .. */ |
| 19457 |
|
| 19458 |
xabs = abs(*x); |
| 19459 |
yabs = abs(*y); |
| 19460 |
w = std::max(xabs,yabs); |
| 19461 |
z__ = std::min(xabs,yabs); |
| 19462 |
if (z__ == 0.) { |
| 19463 |
ret_val = w; |
| 19464 |
} else { |
| 19465 |
/* Computing 2nd power */ |
| 19466 |
d__1 = z__ / w; |
| 19467 |
ret_val = w * sqrt(d__1 * d__1 + 1.); |
| 19468 |
} |
| 19469 |
return ret_val; |
| 19470 |
|
| 19471 |
/* End of DLAPY2 */ |
| 19472 |
|
| 19473 |
} /* dlapy2_ */ |
| 19474 |
|
| 19475 |
/* Subroutine */ double dlapy3_(double *x, double *y, double *z__) |
| 19476 |
{ |
| 19477 |
/* System generated locals */ |
| 19478 |
double ret_val, d__1, d__2, d__3; |
| 19479 |
|
| 19480 |
/* Builtin functions |
| 19481 |
double sqrt(double); */ |
| 19482 |
|
| 19483 |
/* Local variables */ |
| 19484 |
double w, xabs, yabs, zabs; |
| 19485 |
|
| 19486 |
|
| 19487 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 19488 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 19489 |
/* November 2006 */ |
| 19490 |
|
| 19491 |
/* .. Scalar Arguments .. */ |
| 19492 |
/* .. */ |
| 19493 |
|
| 19494 |
/* Purpose */ |
| 19495 |
/* ======= */ |
| 19496 |
|
| 19497 |
/* DLAPY3 returns sqrt(x**2+y**2+z**2), taking care not to cause */ |
| 19498 |
/* unnecessary overflow. */ |
| 19499 |
|
| 19500 |
/* Arguments */ |
| 19501 |
/* ========= */ |
| 19502 |
|
| 19503 |
/* X (input) DOUBLE PRECISION */ |
| 19504 |
/* Y (input) DOUBLE PRECISION */ |
| 19505 |
/* Z (input) DOUBLE PRECISION */ |
| 19506 |
/* X, Y and Z specify the values x, y and z. */ |
| 19507 |
|
| 19508 |
/* ===================================================================== */ |
| 19509 |
|
| 19510 |
/* .. Parameters .. */ |
| 19511 |
/* .. */ |
| 19512 |
/* .. Local Scalars .. */ |
| 19513 |
/* .. */ |
| 19514 |
/* .. Intrinsic Functions .. */ |
| 19515 |
/* .. */ |
| 19516 |
/* .. Executable Statements .. */ |
| 19517 |
|
| 19518 |
xabs = abs(*x); |
| 19519 |
yabs = abs(*y); |
| 19520 |
zabs = abs(*z__); |
| 19521 |
/* Computing MAX */ |
| 19522 |
d__1 = std::max(xabs,yabs); |
| 19523 |
w = std::max(d__1,zabs); |
| 19524 |
if (w == 0.) { |
| 19525 |
/* W can be zero for max(0_integer,nan,0) */ |
| 19526 |
/* adding all three entries together will make sure */ |
| 19527 |
/* NaN will not disappear. */ |
| 19528 |
ret_val = xabs + yabs + zabs; |
| 19529 |
} else { |
| 19530 |
/* Computing 2nd power */ |
| 19531 |
d__1 = xabs / w; |
| 19532 |
/* Computing 2nd power */ |
| 19533 |
d__2 = yabs / w; |
| 19534 |
/* Computing 2nd power */ |
| 19535 |
d__3 = zabs / w; |
| 19536 |
ret_val = w * sqrt(d__1 * d__1 + d__2 * d__2 + d__3 * d__3); |
| 19537 |
} |
| 19538 |
return ret_val; |
| 19539 |
|
| 19540 |
/* End of DLAPY3 */ |
| 19541 |
|
| 19542 |
} /* dlapy3_ */ |
| 19543 |
|
| 19544 |
/* Subroutine */ int dlaqgb_(integer *m, integer *n, integer *kl, integer *ku, |
| 19545 |
double *ab, integer *ldab, double *r__, double *c__, |
| 19546 |
double *rowcnd, double *colcnd, double *amax, char *equed) |
| 19547 |
{ |
| 19548 |
/* System generated locals */ |
| 19549 |
integer ab_dim1, ab_offset, i__1, i__2, i__3, i__4, i__5, i__6; |
| 19550 |
|
| 19551 |
/* Local variables */ |
| 19552 |
integer i__, j; |
| 19553 |
double cj, large, small; |
| 19554 |
|
| 19555 |
|
| 19556 |
|
| 19557 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 19558 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 19559 |
/* November 2006 */ |
| 19560 |
|
| 19561 |
/* .. Scalar Arguments .. */ |
| 19562 |
/* .. */ |
| 19563 |
/* .. Array Arguments .. */ |
| 19564 |
/* .. */ |
| 19565 |
|
| 19566 |
/* Purpose */ |
| 19567 |
/* ======= */ |
| 19568 |
|
| 19569 |
/* DLAQGB equilibrates a general M by N band matrix A with KL */ |
| 19570 |
/* subdiagonals and KU superdiagonals using the row and scaling factors */ |
| 19571 |
/* in the vectors R and C. */ |
| 19572 |
|
| 19573 |
/* Arguments */ |
| 19574 |
/* ========= */ |
| 19575 |
|
| 19576 |
/* M (input) INTEGER */ |
| 19577 |
/* The number of rows of the matrix A. M >= 0. */ |
| 19578 |
|
| 19579 |
/* N (input) INTEGER */ |
| 19580 |
/* The number of columns of the matrix A. N >= 0. */ |
| 19581 |
|
| 19582 |
/* KL (input) INTEGER */ |
| 19583 |
/* The number of subdiagonals within the band of A. KL >= 0. */ |
| 19584 |
|
| 19585 |
/* KU (input) INTEGER */ |
| 19586 |
/* The number of superdiagonals within the band of A. KU >= 0. */ |
| 19587 |
|
| 19588 |
/* AB (input/output) DOUBLE PRECISION array, dimension (LDAB,N) */ |
| 19589 |
/* On entry, the matrix A in band storage, in rows 1 to KL+KU+1. */ |
| 19590 |
/* The j-th column of A is stored in the j-th column of the */ |
| 19591 |
/* array AB as follows: */ |
| 19592 |
/* AB(ku+1+i-j,j) = A(i,j) for max(1,j-ku)<=i<=min(m,j+kl) */ |
| 19593 |
|
| 19594 |
/* On exit, the equilibrated matrix, in the same storage format */ |
| 19595 |
/* as A. See EQUED for the form of the equilibrated matrix. */ |
| 19596 |
|
| 19597 |
/* LDAB (input) INTEGER */ |
| 19598 |
/* The leading dimension of the array AB. LDA >= KL+KU+1. */ |
| 19599 |
|
| 19600 |
/* R (input) DOUBLE PRECISION array, dimension (M) */ |
| 19601 |
/* The row scale factors for A. */ |
| 19602 |
|
| 19603 |
/* C (input) DOUBLE PRECISION array, dimension (N) */ |
| 19604 |
/* The column scale factors for A. */ |
| 19605 |
|
| 19606 |
/* ROWCND (input) DOUBLE PRECISION */ |
| 19607 |
/* Ratio of the smallest R(i) to the largest R(i). */ |
| 19608 |
|
| 19609 |
/* COLCND (input) DOUBLE PRECISION */ |
| 19610 |
/* Ratio of the smallest C(i) to the largest C(i). */ |
| 19611 |
|
| 19612 |
/* AMAX (input) DOUBLE PRECISION */ |
| 19613 |
/* Absolute value of largest matrix entry. */ |
| 19614 |
|
| 19615 |
/* EQUED (output) CHARACTER*1 */ |
| 19616 |
/* Specifies the form of equilibration that was done. */ |
| 19617 |
/* = 'N': No equilibration */ |
| 19618 |
/* = 'R': Row equilibration, i.e., A has been premultiplied by */ |
| 19619 |
/* diag(R). */ |
| 19620 |
/* = 'C': Column equilibration, i.e., A has been postmultiplied */ |
| 19621 |
/* by diag(C). */ |
| 19622 |
/* = 'B': Both row and column equilibration, i.e., A has been */ |
| 19623 |
/* replaced by diag(R) * A * diag(C). */ |
| 19624 |
|
| 19625 |
/* Internal Parameters */ |
| 19626 |
/* =================== */ |
| 19627 |
|
| 19628 |
/* THRESH is a threshold value used to decide if row or column scaling */ |
| 19629 |
/* should be done based on the ratio of the row or column scaling */ |
| 19630 |
/* factors. If ROWCND < THRESH, row scaling is done, and if */ |
| 19631 |
/* COLCND < THRESH, column scaling is done. */ |
| 19632 |
|
| 19633 |
/* LARGE and SMALL are threshold values used to decide if row scaling */ |
| 19634 |
/* should be done based on the absolute size of the largest matrix */ |
| 19635 |
/* element. If AMAX > LARGE or AMAX < SMALL, row scaling is done. */ |
| 19636 |
|
| 19637 |
/* ===================================================================== */ |
| 19638 |
|
| 19639 |
/* .. Parameters .. */ |
| 19640 |
/* .. */ |
| 19641 |
/* .. Local Scalars .. */ |
| 19642 |
/* .. */ |
| 19643 |
/* .. External Functions .. */ |
| 19644 |
/* .. */ |
| 19645 |
/* .. Intrinsic Functions .. */ |
| 19646 |
/* .. */ |
| 19647 |
/* .. Executable Statements .. */ |
| 19648 |
|
| 19649 |
/* Quick return if possible */ |
| 19650 |
|
| 19651 |
/* Parameter adjustments */ |
| 19652 |
ab_dim1 = *ldab; |
| 19653 |
ab_offset = 1 + ab_dim1; |
| 19654 |
ab -= ab_offset; |
| 19655 |
--r__; |
| 19656 |
--c__; |
| 19657 |
|
| 19658 |
/* Function Body */ |
| 19659 |
if (*m <= 0 || *n <= 0) { |
| 19660 |
*(unsigned char *)equed = 'N'; |
| 19661 |
return 0; |
| 19662 |
} |
| 19663 |
|
| 19664 |
/* Initialize LARGE and SMALL. */ |
| 19665 |
|
| 19666 |
small = dlamch_("Safe minimum") / dlamch_("Precision"); |
| 19667 |
large = 1. / small; |
| 19668 |
|
| 19669 |
if (*rowcnd >= .1 && *amax >= small && *amax <= large) { |
| 19670 |
|
| 19671 |
/* No row scaling */ |
| 19672 |
|
| 19673 |
if (*colcnd >= .1) { |
| 19674 |
|
| 19675 |
/* No column scaling */ |
| 19676 |
|
| 19677 |
*(unsigned char *)equed = 'N'; |
| 19678 |
} else { |
| 19679 |
|
| 19680 |
/* Column scaling */ |
| 19681 |
|
| 19682 |
i__1 = *n; |
| 19683 |
for (j = 1; j <= i__1; ++j) { |
| 19684 |
cj = c__[j]; |
| 19685 |
/* Computing MAX */ |
| 19686 |
i__2 = 1, i__3 = j - *ku; |
| 19687 |
/* Computing MIN */ |
| 19688 |
i__5 = *m, i__6 = j + *kl; |
| 19689 |
i__4 = std::min(i__5,i__6); |
| 19690 |
for (i__ = std::max(i__2,i__3); i__ <= i__4; ++i__) { |
| 19691 |
ab[*ku + 1 + i__ - j + j * ab_dim1] = cj * ab[*ku + 1 + |
| 19692 |
i__ - j + j * ab_dim1]; |
| 19693 |
/* L10: */ |
| 19694 |
} |
| 19695 |
/* L20: */ |
| 19696 |
} |
| 19697 |
*(unsigned char *)equed = 'C'; |
| 19698 |
} |
| 19699 |
} else if (*colcnd >= .1) { |
| 19700 |
|
| 19701 |
/* Row scaling, no column scaling */ |
| 19702 |
|
| 19703 |
i__1 = *n; |
| 19704 |
for (j = 1; j <= i__1; ++j) { |
| 19705 |
/* Computing MAX */ |
| 19706 |
i__4 = 1, i__2 = j - *ku; |
| 19707 |
/* Computing MIN */ |
| 19708 |
i__5 = *m, i__6 = j + *kl; |
| 19709 |
i__3 = std::min(i__5,i__6); |
| 19710 |
for (i__ = std::max(i__4,i__2); i__ <= i__3; ++i__) { |
| 19711 |
ab[*ku + 1 + i__ - j + j * ab_dim1] = r__[i__] * ab[*ku + 1 + |
| 19712 |
i__ - j + j * ab_dim1]; |
| 19713 |
/* L30: */ |
| 19714 |
} |
| 19715 |
/* L40: */ |
| 19716 |
} |
| 19717 |
*(unsigned char *)equed = 'R'; |
| 19718 |
} else { |
| 19719 |
|
| 19720 |
/* Row and column scaling */ |
| 19721 |
|
| 19722 |
i__1 = *n; |
| 19723 |
for (j = 1; j <= i__1; ++j) { |
| 19724 |
cj = c__[j]; |
| 19725 |
/* Computing MAX */ |
| 19726 |
i__3 = 1, i__4 = j - *ku; |
| 19727 |
/* Computing MIN */ |
| 19728 |
i__5 = *m, i__6 = j + *kl; |
| 19729 |
i__2 = std::min(i__5,i__6); |
| 19730 |
for (i__ = std::max(i__3,i__4); i__ <= i__2; ++i__) { |
| 19731 |
ab[*ku + 1 + i__ - j + j * ab_dim1] = cj * r__[i__] * ab[*ku |
| 19732 |
+ 1 + i__ - j + j * ab_dim1]; |
| 19733 |
/* L50: */ |
| 19734 |
} |
| 19735 |
/* L60: */ |
| 19736 |
} |
| 19737 |
*(unsigned char *)equed = 'B'; |
| 19738 |
} |
| 19739 |
|
| 19740 |
return 0; |
| 19741 |
|
| 19742 |
/* End of DLAQGB */ |
| 19743 |
|
| 19744 |
} /* dlaqgb_ */ |
| 19745 |
|
| 19746 |
/* Subroutine */ int dlaqge_(integer *m, integer *n, double *a, integer * |
| 19747 |
lda, double *r__, double *c__, double *rowcnd, double |
| 19748 |
*colcnd, double *amax, char *equed) |
| 19749 |
{ |
| 19750 |
/* System generated locals */ |
| 19751 |
integer a_dim1, a_offset, i__1, i__2; |
| 19752 |
|
| 19753 |
/* Local variables */ |
| 19754 |
integer i__, j; |
| 19755 |
double cj, large, small; |
| 19756 |
|
| 19757 |
|
| 19758 |
|
| 19759 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 19760 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 19761 |
/* November 2006 */ |
| 19762 |
|
| 19763 |
/* .. Scalar Arguments .. */ |
| 19764 |
/* .. */ |
| 19765 |
/* .. Array Arguments .. */ |
| 19766 |
/* .. */ |
| 19767 |
|
| 19768 |
/* Purpose */ |
| 19769 |
/* ======= */ |
| 19770 |
|
| 19771 |
/* DLAQGE equilibrates a general M by N matrix A using the row and */ |
| 19772 |
/* column scaling factors in the vectors R and C. */ |
| 19773 |
|
| 19774 |
/* Arguments */ |
| 19775 |
/* ========= */ |
| 19776 |
|
| 19777 |
/* M (input) INTEGER */ |
| 19778 |
/* The number of rows of the matrix A. M >= 0. */ |
| 19779 |
|
| 19780 |
/* N (input) INTEGER */ |
| 19781 |
/* The number of columns of the matrix A. N >= 0. */ |
| 19782 |
|
| 19783 |
/* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 19784 |
/* On entry, the M by N matrix A. */ |
| 19785 |
/* On exit, the equilibrated matrix. See EQUED for the form of */ |
| 19786 |
/* the equilibrated matrix. */ |
| 19787 |
|
| 19788 |
/* LDA (input) INTEGER */ |
| 19789 |
/* The leading dimension of the array A. LDA >= max(M,1). */ |
| 19790 |
|
| 19791 |
/* R (input) DOUBLE PRECISION array, dimension (M) */ |
| 19792 |
/* The row scale factors for A. */ |
| 19793 |
|
| 19794 |
/* C (input) DOUBLE PRECISION array, dimension (N) */ |
| 19795 |
/* The column scale factors for A. */ |
| 19796 |
|
| 19797 |
/* ROWCND (input) DOUBLE PRECISION */ |
| 19798 |
/* Ratio of the smallest R(i) to the largest R(i). */ |
| 19799 |
|
| 19800 |
/* COLCND (input) DOUBLE PRECISION */ |
| 19801 |
/* Ratio of the smallest C(i) to the largest C(i). */ |
| 19802 |
|
| 19803 |
/* AMAX (input) DOUBLE PRECISION */ |
| 19804 |
/* Absolute value of largest matrix entry. */ |
| 19805 |
|
| 19806 |
/* EQUED (output) CHARACTER*1 */ |
| 19807 |
/* Specifies the form of equilibration that was done. */ |
| 19808 |
/* = 'N': No equilibration */ |
| 19809 |
/* = 'R': Row equilibration, i.e., A has been premultiplied by */ |
| 19810 |
/* diag(R). */ |
| 19811 |
/* = 'C': Column equilibration, i.e., A has been postmultiplied */ |
| 19812 |
/* by diag(C). */ |
| 19813 |
/* = 'B': Both row and column equilibration, i.e., A has been */ |
| 19814 |
/* replaced by diag(R) * A * diag(C). */ |
| 19815 |
|
| 19816 |
/* Internal Parameters */ |
| 19817 |
/* =================== */ |
| 19818 |
|
| 19819 |
/* THRESH is a threshold value used to decide if row or column scaling */ |
| 19820 |
/* should be done based on the ratio of the row or column scaling */ |
| 19821 |
/* factors. If ROWCND < THRESH, row scaling is done, and if */ |
| 19822 |
/* COLCND < THRESH, column scaling is done. */ |
| 19823 |
|
| 19824 |
/* LARGE and SMALL are threshold values used to decide if row scaling */ |
| 19825 |
/* should be done based on the absolute size of the largest matrix */ |
| 19826 |
/* element. If AMAX > LARGE or AMAX < SMALL, row scaling is done. */ |
| 19827 |
|
| 19828 |
/* ===================================================================== */ |
| 19829 |
|
| 19830 |
/* .. Parameters .. */ |
| 19831 |
/* .. */ |
| 19832 |
/* .. Local Scalars .. */ |
| 19833 |
/* .. */ |
| 19834 |
/* .. External Functions .. */ |
| 19835 |
/* .. */ |
| 19836 |
/* .. Executable Statements .. */ |
| 19837 |
|
| 19838 |
/* Quick return if possible */ |
| 19839 |
|
| 19840 |
/* Parameter adjustments */ |
| 19841 |
a_dim1 = *lda; |
| 19842 |
a_offset = 1 + a_dim1; |
| 19843 |
a -= a_offset; |
| 19844 |
--r__; |
| 19845 |
--c__; |
| 19846 |
|
| 19847 |
/* Function Body */ |
| 19848 |
if (*m <= 0 || *n <= 0) { |
| 19849 |
*(unsigned char *)equed = 'N'; |
| 19850 |
return 0; |
| 19851 |
} |
| 19852 |
|
| 19853 |
/* Initialize LARGE and SMALL. */ |
| 19854 |
|
| 19855 |
small = dlamch_("Safe minimum") / dlamch_("Precision"); |
| 19856 |
large = 1. / small; |
| 19857 |
|
| 19858 |
if (*rowcnd >= .1 && *amax >= small && *amax <= large) { |
| 19859 |
|
| 19860 |
/* No row scaling */ |
| 19861 |
|
| 19862 |
if (*colcnd >= .1) { |
| 19863 |
|
| 19864 |
/* No column scaling */ |
| 19865 |
|
| 19866 |
*(unsigned char *)equed = 'N'; |
| 19867 |
} else { |
| 19868 |
|
| 19869 |
/* Column scaling */ |
| 19870 |
|
| 19871 |
i__1 = *n; |
| 19872 |
for (j = 1; j <= i__1; ++j) { |
| 19873 |
cj = c__[j]; |
| 19874 |
i__2 = *m; |
| 19875 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 19876 |
a[i__ + j * a_dim1] = cj * a[i__ + j * a_dim1]; |
| 19877 |
/* L10: */ |
| 19878 |
} |
| 19879 |
/* L20: */ |
| 19880 |
} |
| 19881 |
*(unsigned char *)equed = 'C'; |
| 19882 |
} |
| 19883 |
} else if (*colcnd >= .1) { |
| 19884 |
|
| 19885 |
/* Row scaling, no column scaling */ |
| 19886 |
|
| 19887 |
i__1 = *n; |
| 19888 |
for (j = 1; j <= i__1; ++j) { |
| 19889 |
i__2 = *m; |
| 19890 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 19891 |
a[i__ + j * a_dim1] = r__[i__] * a[i__ + j * a_dim1]; |
| 19892 |
/* L30: */ |
| 19893 |
} |
| 19894 |
/* L40: */ |
| 19895 |
} |
| 19896 |
*(unsigned char *)equed = 'R'; |
| 19897 |
} else { |
| 19898 |
|
| 19899 |
/* Row and column scaling */ |
| 19900 |
|
| 19901 |
i__1 = *n; |
| 19902 |
for (j = 1; j <= i__1; ++j) { |
| 19903 |
cj = c__[j]; |
| 19904 |
i__2 = *m; |
| 19905 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 19906 |
a[i__ + j * a_dim1] = cj * r__[i__] * a[i__ + j * a_dim1]; |
| 19907 |
/* L50: */ |
| 19908 |
} |
| 19909 |
/* L60: */ |
| 19910 |
} |
| 19911 |
*(unsigned char *)equed = 'B'; |
| 19912 |
} |
| 19913 |
|
| 19914 |
return 0; |
| 19915 |
|
| 19916 |
/* End of DLAQGE */ |
| 19917 |
|
| 19918 |
} /* dlaqge_ */ |
| 19919 |
|
| 19920 |
/* Subroutine */ int dlaqp2_(integer *m, integer *n, integer *offset, |
| 19921 |
double *a, integer *lda, integer *jpvt, double *tau, |
| 19922 |
double *vn1, double *vn2, double *work) |
| 19923 |
{ |
| 19924 |
/* Table of constant values */ |
| 19925 |
static integer c__1 = 1; |
| 19926 |
|
| 19927 |
/* System generated locals */ |
| 19928 |
integer a_dim1, a_offset, i__1, i__2, i__3; |
| 19929 |
double d__1, d__2; |
| 19930 |
|
| 19931 |
/* Local variables */ |
| 19932 |
integer i__, j, mn; |
| 19933 |
double aii; |
| 19934 |
integer pvt; |
| 19935 |
double temp; |
| 19936 |
double temp2, tol3z; |
| 19937 |
integer offpi, itemp; |
| 19938 |
|
| 19939 |
|
| 19940 |
/* -- LAPACK auxiliary routine (version 3.2) -- */ |
| 19941 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 19942 |
/* November 2006 */ |
| 19943 |
|
| 19944 |
/* .. Scalar Arguments .. */ |
| 19945 |
/* .. */ |
| 19946 |
/* .. Array Arguments .. */ |
| 19947 |
/* .. */ |
| 19948 |
|
| 19949 |
/* Purpose */ |
| 19950 |
/* ======= */ |
| 19951 |
|
| 19952 |
/* DLAQP2 computes a QR factorization with column pivoting of */ |
| 19953 |
/* the block A(OFFSET+1:M,1:N). */ |
| 19954 |
/* The block A(1:OFFSET,1:N) is accordingly pivoted, but not factorized. */ |
| 19955 |
|
| 19956 |
/* Arguments */ |
| 19957 |
/* ========= */ |
| 19958 |
|
| 19959 |
/* M (input) INTEGER */ |
| 19960 |
/* The number of rows of the matrix A. M >= 0. */ |
| 19961 |
|
| 19962 |
/* N (input) INTEGER */ |
| 19963 |
/* The number of columns of the matrix A. N >= 0. */ |
| 19964 |
|
| 19965 |
/* OFFSET (input) INTEGER */ |
| 19966 |
/* The number of rows of the matrix A that must be pivoted */ |
| 19967 |
/* but no factorized. OFFSET >= 0. */ |
| 19968 |
|
| 19969 |
/* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 19970 |
/* On entry, the M-by-N matrix A. */ |
| 19971 |
/* On exit, the upper triangle of block A(OFFSET+1:M,1:N) is */ |
| 19972 |
/* the triangular factor obtained; the elements in block */ |
| 19973 |
/* A(OFFSET+1:M,1:N) below the diagonal, together with the */ |
| 19974 |
/* array TAU, represent the orthogonal matrix Q as a product of */ |
| 19975 |
/* elementary reflectors. Block A(1:OFFSET,1:N) has been */ |
| 19976 |
/* accordingly pivoted, but no factorized. */ |
| 19977 |
|
| 19978 |
/* LDA (input) INTEGER */ |
| 19979 |
/* The leading dimension of the array A. LDA >= max(1,M). */ |
| 19980 |
|
| 19981 |
/* JPVT (input/output) INTEGER array, dimension (N) */ |
| 19982 |
/* On entry, if JPVT(i) .ne. 0, the i-th column of A is permuted */ |
| 19983 |
/* to the front of A*P (a leading column); if JPVT(i) = 0, */ |
| 19984 |
/* the i-th column of A is a free column. */ |
| 19985 |
/* On exit, if JPVT(i) = k, then the i-th column of A*P */ |
| 19986 |
/* was the k-th column of A. */ |
| 19987 |
|
| 19988 |
/* TAU (output) DOUBLE PRECISION array, dimension (min(M,N)) */ |
| 19989 |
/* The scalar factors of the elementary reflectors. */ |
| 19990 |
|
| 19991 |
/* VN1 (input/output) DOUBLE PRECISION array, dimension (N) */ |
| 19992 |
/* The vector with the partial column norms. */ |
| 19993 |
|
| 19994 |
/* VN2 (input/output) DOUBLE PRECISION array, dimension (N) */ |
| 19995 |
/* The vector with the exact column norms. */ |
| 19996 |
|
| 19997 |
/* WORK (workspace) DOUBLE PRECISION array, dimension (N) */ |
| 19998 |
|
| 19999 |
/* Further Details */ |
| 20000 |
/* =============== */ |
| 20001 |
|
| 20002 |
/* Based on contributions by */ |
| 20003 |
/* G. Quintana-Orti, Depto. de Informatica, Universidad Jaime I, Spain */ |
| 20004 |
/* X. Sun, Computer Science Dept., Duke University, USA */ |
| 20005 |
|
| 20006 |
/* Partial column norm updating strategy modified by */ |
| 20007 |
/* Z. Drmac and Z. Bujanovic, Dept. of Mathematics, */ |
| 20008 |
/* University of Zagreb, Croatia. */ |
| 20009 |
/* June 2006. */ |
| 20010 |
/* For more details see LAPACK Working Note 176. */ |
| 20011 |
/* ===================================================================== */ |
| 20012 |
|
| 20013 |
/* .. Parameters .. */ |
| 20014 |
/* .. */ |
| 20015 |
/* .. Local Scalars .. */ |
| 20016 |
/* .. */ |
| 20017 |
/* .. External Subroutines .. */ |
| 20018 |
/* .. */ |
| 20019 |
/* .. Intrinsic Functions .. */ |
| 20020 |
/* .. */ |
| 20021 |
/* .. External Functions .. */ |
| 20022 |
/* .. */ |
| 20023 |
/* .. Executable Statements .. */ |
| 20024 |
|
| 20025 |
/* Parameter adjustments */ |
| 20026 |
a_dim1 = *lda; |
| 20027 |
a_offset = 1 + a_dim1; |
| 20028 |
a -= a_offset; |
| 20029 |
--jpvt; |
| 20030 |
--tau; |
| 20031 |
--vn1; |
| 20032 |
--vn2; |
| 20033 |
--work; |
| 20034 |
|
| 20035 |
/* Function Body */ |
| 20036 |
/* Computing MIN */ |
| 20037 |
i__1 = *m - *offset; |
| 20038 |
mn = std::min(i__1,*n); |
| 20039 |
tol3z = sqrt(dlamch_("Epsilon")); |
| 20040 |
|
| 20041 |
/* Compute factorization. */ |
| 20042 |
|
| 20043 |
i__1 = mn; |
| 20044 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 20045 |
|
| 20046 |
offpi = *offset + i__; |
| 20047 |
|
| 20048 |
/* Determine ith pivot column and swap if necessary. */ |
| 20049 |
|
| 20050 |
i__2 = *n - i__ + 1; |
| 20051 |
pvt = i__ - 1 + idamax_(&i__2, &vn1[i__], &c__1); |
| 20052 |
|
| 20053 |
if (pvt != i__) { |
| 20054 |
dswap_(m, &a[pvt * a_dim1 + 1], &c__1, &a[i__ * a_dim1 + 1], & |
| 20055 |
c__1); |
| 20056 |
itemp = jpvt[pvt]; |
| 20057 |
jpvt[pvt] = jpvt[i__]; |
| 20058 |
jpvt[i__] = itemp; |
| 20059 |
vn1[pvt] = vn1[i__]; |
| 20060 |
vn2[pvt] = vn2[i__]; |
| 20061 |
} |
| 20062 |
|
| 20063 |
/* Generate elementary reflector H(i). */ |
| 20064 |
|
| 20065 |
if (offpi < *m) { |
| 20066 |
i__2 = *m - offpi + 1; |
| 20067 |
dlarfp_(&i__2, &a[offpi + i__ * a_dim1], &a[offpi + 1 + i__ * |
| 20068 |
a_dim1], &c__1, &tau[i__]); |
| 20069 |
} else { |
| 20070 |
dlarfp_(&c__1, &a[*m + i__ * a_dim1], &a[*m + i__ * a_dim1], & |
| 20071 |
c__1, &tau[i__]); |
| 20072 |
} |
| 20073 |
|
| 20074 |
if (i__ <= *n) { |
| 20075 |
|
| 20076 |
/* Apply H(i)' to A(offset+i:m,i+1:n) from the left. */ |
| 20077 |
|
| 20078 |
aii = a[offpi + i__ * a_dim1]; |
| 20079 |
a[offpi + i__ * a_dim1] = 1.; |
| 20080 |
i__2 = *m - offpi + 1; |
| 20081 |
i__3 = *n - i__; |
| 20082 |
dlarf_("Left", &i__2, &i__3, &a[offpi + i__ * a_dim1], &c__1, & |
| 20083 |
tau[i__], &a[offpi + (i__ + 1) * a_dim1], lda, &work[1]); |
| 20084 |
a[offpi + i__ * a_dim1] = aii; |
| 20085 |
} |
| 20086 |
|
| 20087 |
/* Update partial column norms. */ |
| 20088 |
|
| 20089 |
i__2 = *n; |
| 20090 |
for (j = i__ + 1; j <= i__2; ++j) { |
| 20091 |
if (vn1[j] != 0.) { |
| 20092 |
|
| 20093 |
/* NOTE: The following 4 lines follow from the analysis in */ |
| 20094 |
/* Lapack Working Note 176. */ |
| 20095 |
|
| 20096 |
/* Computing 2nd power */ |
| 20097 |
d__2 = (d__1 = a[offpi + j * a_dim1], abs(d__1)) / vn1[j]; |
| 20098 |
temp = 1. - d__2 * d__2; |
| 20099 |
temp = std::max(temp,0.); |
| 20100 |
/* Computing 2nd power */ |
| 20101 |
d__1 = vn1[j] / vn2[j]; |
| 20102 |
temp2 = temp * (d__1 * d__1); |
| 20103 |
if (temp2 <= tol3z) { |
| 20104 |
if (offpi < *m) { |
| 20105 |
i__3 = *m - offpi; |
| 20106 |
vn1[j] = dnrm2_(&i__3, &a[offpi + 1 + j * a_dim1], & |
| 20107 |
c__1); |
| 20108 |
vn2[j] = vn1[j]; |
| 20109 |
} else { |
| 20110 |
vn1[j] = 0.; |
| 20111 |
vn2[j] = 0.; |
| 20112 |
} |
| 20113 |
} else { |
| 20114 |
vn1[j] *= sqrt(temp); |
| 20115 |
} |
| 20116 |
} |
| 20117 |
/* L10: */ |
| 20118 |
} |
| 20119 |
|
| 20120 |
/* L20: */ |
| 20121 |
} |
| 20122 |
|
| 20123 |
return 0; |
| 20124 |
|
| 20125 |
/* End of DLAQP2 */ |
| 20126 |
|
| 20127 |
} /* dlaqp2_ */ |
| 20128 |
|
| 20129 |
/* Subroutine */ int dlaqps_(integer *m, integer *n, integer *offset, integer |
| 20130 |
*nb, integer *kb, double *a, integer *lda, integer *jpvt, |
| 20131 |
double *tau, double *vn1, double *vn2, double *auxv, |
| 20132 |
double *f, integer *ldf) |
| 20133 |
{ |
| 20134 |
/* Table of constant values */ |
| 20135 |
static integer c__1 = 1; |
| 20136 |
static double c_b8 = -1.; |
| 20137 |
static double c_b9 = 1.; |
| 20138 |
static double c_b16 = 0.; |
| 20139 |
|
| 20140 |
/* System generated locals */ |
| 20141 |
integer a_dim1, a_offset, f_dim1, f_offset, i__1, i__2; |
| 20142 |
double d__1, d__2; |
| 20143 |
|
| 20144 |
/* Local variables */ |
| 20145 |
integer j, k, rk; |
| 20146 |
double akk; |
| 20147 |
integer pvt; |
| 20148 |
double temp; |
| 20149 |
double temp2, tol3z; |
| 20150 |
integer itemp; |
| 20151 |
integer lsticc, lastrk; |
| 20152 |
|
| 20153 |
|
| 20154 |
/* -- LAPACK auxiliary routine (version 3.2) -- */ |
| 20155 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 20156 |
/* November 2006 */ |
| 20157 |
|
| 20158 |
/* .. Scalar Arguments .. */ |
| 20159 |
/* .. */ |
| 20160 |
/* .. Array Arguments .. */ |
| 20161 |
/* .. */ |
| 20162 |
|
| 20163 |
/* Purpose */ |
| 20164 |
/* ======= */ |
| 20165 |
|
| 20166 |
/* DLAQPS computes a step of QR factorization with column pivoting */ |
| 20167 |
/* of a real M-by-N matrix A by using Blas-3. It tries to factorize */ |
| 20168 |
/* NB columns from A starting from the row OFFSET+1, and updates all */ |
| 20169 |
/* of the matrix with Blas-3 xGEMM. */ |
| 20170 |
|
| 20171 |
/* In some cases, due to catastrophic cancellations, it cannot */ |
| 20172 |
/* factorize NB columns. Hence, the actual number of factorized */ |
| 20173 |
/* columns is returned in KB. */ |
| 20174 |
|
| 20175 |
/* Block A(1:OFFSET,1:N) is accordingly pivoted, but not factorized. */ |
| 20176 |
|
| 20177 |
/* Arguments */ |
| 20178 |
/* ========= */ |
| 20179 |
|
| 20180 |
/* M (input) INTEGER */ |
| 20181 |
/* The number of rows of the matrix A. M >= 0. */ |
| 20182 |
|
| 20183 |
/* N (input) INTEGER */ |
| 20184 |
/* The number of columns of the matrix A. N >= 0 */ |
| 20185 |
|
| 20186 |
/* OFFSET (input) INTEGER */ |
| 20187 |
/* The number of rows of A that have been factorized in */ |
| 20188 |
/* previous steps. */ |
| 20189 |
|
| 20190 |
/* NB (input) INTEGER */ |
| 20191 |
/* The number of columns to factorize. */ |
| 20192 |
|
| 20193 |
/* KB (output) INTEGER */ |
| 20194 |
/* The number of columns actually factorized. */ |
| 20195 |
|
| 20196 |
/* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 20197 |
/* On entry, the M-by-N matrix A. */ |
| 20198 |
/* On exit, block A(OFFSET+1:M,1:KB) is the triangular */ |
| 20199 |
/* factor obtained and block A(1:OFFSET,1:N) has been */ |
| 20200 |
/* accordingly pivoted, but no factorized. */ |
| 20201 |
/* The rest of the matrix, block A(OFFSET+1:M,KB+1:N) has */ |
| 20202 |
/* been updated. */ |
| 20203 |
|
| 20204 |
/* LDA (input) INTEGER */ |
| 20205 |
/* The leading dimension of the array A. LDA >= max(1,M). */ |
| 20206 |
|
| 20207 |
/* JPVT (input/output) INTEGER array, dimension (N) */ |
| 20208 |
/* JPVT(I) = K <==> Column K of the full matrix A has been */ |
| 20209 |
/* permuted into position I in AP. */ |
| 20210 |
|
| 20211 |
/* TAU (output) DOUBLE PRECISION array, dimension (KB) */ |
| 20212 |
/* The scalar factors of the elementary reflectors. */ |
| 20213 |
|
| 20214 |
/* VN1 (input/output) DOUBLE PRECISION array, dimension (N) */ |
| 20215 |
/* The vector with the partial column norms. */ |
| 20216 |
|
| 20217 |
/* VN2 (input/output) DOUBLE PRECISION array, dimension (N) */ |
| 20218 |
/* The vector with the exact column norms. */ |
| 20219 |
|
| 20220 |
/* AUXV (input/output) DOUBLE PRECISION array, dimension (NB) */ |
| 20221 |
/* Auxiliar vector. */ |
| 20222 |
|
| 20223 |
/* F (input/output) DOUBLE PRECISION array, dimension (LDF,NB) */ |
| 20224 |
/* Matrix F' = L*Y'*A. */ |
| 20225 |
|
| 20226 |
/* LDF (input) INTEGER */ |
| 20227 |
/* The leading dimension of the array F. LDF >= max(1,N). */ |
| 20228 |
|
| 20229 |
/* Further Details */ |
| 20230 |
/* =============== */ |
| 20231 |
|
| 20232 |
/* Based on contributions by */ |
| 20233 |
/* G. Quintana-Orti, Depto. de Informatica, Universidad Jaime I, Spain */ |
| 20234 |
/* X. Sun, Computer Science Dept., Duke University, USA */ |
| 20235 |
|
| 20236 |
/* Partial column norm updating strategy modified by */ |
| 20237 |
/* Z. Drmac and Z. Bujanovic, Dept. of Mathematics, */ |
| 20238 |
/* University of Zagreb, Croatia. */ |
| 20239 |
/* June 2006. */ |
| 20240 |
/* For more details see LAPACK Working Note 176. */ |
| 20241 |
/* ===================================================================== */ |
| 20242 |
|
| 20243 |
/* .. Parameters .. */ |
| 20244 |
/* .. */ |
| 20245 |
/* .. Local Scalars .. */ |
| 20246 |
/* .. */ |
| 20247 |
/* .. External Subroutines .. */ |
| 20248 |
/* .. */ |
| 20249 |
/* .. Intrinsic Functions .. */ |
| 20250 |
/* .. */ |
| 20251 |
/* .. External Functions .. */ |
| 20252 |
/* .. */ |
| 20253 |
/* .. Executable Statements .. */ |
| 20254 |
|
| 20255 |
/* Parameter adjustments */ |
| 20256 |
a_dim1 = *lda; |
| 20257 |
a_offset = 1 + a_dim1; |
| 20258 |
a -= a_offset; |
| 20259 |
--jpvt; |
| 20260 |
--tau; |
| 20261 |
--vn1; |
| 20262 |
--vn2; |
| 20263 |
--auxv; |
| 20264 |
f_dim1 = *ldf; |
| 20265 |
f_offset = 1 + f_dim1; |
| 20266 |
f -= f_offset; |
| 20267 |
|
| 20268 |
/* Function Body */ |
| 20269 |
/* Computing MIN */ |
| 20270 |
i__1 = *m, i__2 = *n + *offset; |
| 20271 |
lastrk = std::min(i__1,i__2); |
| 20272 |
lsticc = 0; |
| 20273 |
k = 0; |
| 20274 |
tol3z = sqrt(dlamch_("Epsilon")); |
| 20275 |
|
| 20276 |
/* Beginning of while loop. */ |
| 20277 |
|
| 20278 |
L10: |
| 20279 |
if (k < *nb && lsticc == 0) { |
| 20280 |
++k; |
| 20281 |
rk = *offset + k; |
| 20282 |
|
| 20283 |
/* Determine ith pivot column and swap if necessary */ |
| 20284 |
|
| 20285 |
i__1 = *n - k + 1; |
| 20286 |
pvt = k - 1 + idamax_(&i__1, &vn1[k], &c__1); |
| 20287 |
if (pvt != k) { |
| 20288 |
dswap_(m, &a[pvt * a_dim1 + 1], &c__1, &a[k * a_dim1 + 1], &c__1); |
| 20289 |
i__1 = k - 1; |
| 20290 |
dswap_(&i__1, &f[pvt + f_dim1], ldf, &f[k + f_dim1], ldf); |
| 20291 |
itemp = jpvt[pvt]; |
| 20292 |
jpvt[pvt] = jpvt[k]; |
| 20293 |
jpvt[k] = itemp; |
| 20294 |
vn1[pvt] = vn1[k]; |
| 20295 |
vn2[pvt] = vn2[k]; |
| 20296 |
} |
| 20297 |
|
| 20298 |
/* Apply previous Householder reflectors to column K: */ |
| 20299 |
/* A(RK:M,K) := A(RK:M,K) - A(RK:M,1:K-1)*F(K,1:K-1)'. */ |
| 20300 |
|
| 20301 |
if (k > 1) { |
| 20302 |
i__1 = *m - rk + 1; |
| 20303 |
i__2 = k - 1; |
| 20304 |
dgemv_("No transpose", &i__1, &i__2, &c_b8, &a[rk + a_dim1], lda, |
| 20305 |
&f[k + f_dim1], ldf, &c_b9, &a[rk + k * a_dim1], &c__1); |
| 20306 |
} |
| 20307 |
|
| 20308 |
/* Generate elementary reflector H(k). */ |
| 20309 |
|
| 20310 |
if (rk < *m) { |
| 20311 |
i__1 = *m - rk + 1; |
| 20312 |
dlarfp_(&i__1, &a[rk + k * a_dim1], &a[rk + 1 + k * a_dim1], & |
| 20313 |
c__1, &tau[k]); |
| 20314 |
} else { |
| 20315 |
dlarfp_(&c__1, &a[rk + k * a_dim1], &a[rk + k * a_dim1], &c__1, & |
| 20316 |
tau[k]); |
| 20317 |
} |
| 20318 |
|
| 20319 |
akk = a[rk + k * a_dim1]; |
| 20320 |
a[rk + k * a_dim1] = 1.; |
| 20321 |
|
| 20322 |
/* Compute Kth column of F: */ |
| 20323 |
|
| 20324 |
/* Compute F(K+1:N,K) := tau(K)*A(RK:M,K+1:N)'*A(RK:M,K). */ |
| 20325 |
|
| 20326 |
if (k < *n) { |
| 20327 |
i__1 = *m - rk + 1; |
| 20328 |
i__2 = *n - k; |
| 20329 |
dgemv_("Transpose", &i__1, &i__2, &tau[k], &a[rk + (k + 1) * |
| 20330 |
a_dim1], lda, &a[rk + k * a_dim1], &c__1, &c_b16, &f[k + |
| 20331 |
1 + k * f_dim1], &c__1); |
| 20332 |
} |
| 20333 |
|
| 20334 |
/* Padding F(1:K,K) with zeros. */ |
| 20335 |
|
| 20336 |
i__1 = k; |
| 20337 |
for (j = 1; j <= i__1; ++j) { |
| 20338 |
f[j + k * f_dim1] = 0.; |
| 20339 |
/* L20: */ |
| 20340 |
} |
| 20341 |
|
| 20342 |
/* Incremental updating of F: */ |
| 20343 |
/* F(1:N,K) := F(1:N,K) - tau(K)*F(1:N,1:K-1)*A(RK:M,1:K-1)' */ |
| 20344 |
/* *A(RK:M,K). */ |
| 20345 |
|
| 20346 |
if (k > 1) { |
| 20347 |
i__1 = *m - rk + 1; |
| 20348 |
i__2 = k - 1; |
| 20349 |
d__1 = -tau[k]; |
| 20350 |
dgemv_("Transpose", &i__1, &i__2, &d__1, &a[rk + a_dim1], lda, &a[ |
| 20351 |
rk + k * a_dim1], &c__1, &c_b16, &auxv[1], &c__1); |
| 20352 |
|
| 20353 |
i__1 = k - 1; |
| 20354 |
dgemv_("No transpose", n, &i__1, &c_b9, &f[f_dim1 + 1], ldf, & |
| 20355 |
auxv[1], &c__1, &c_b9, &f[k * f_dim1 + 1], &c__1); |
| 20356 |
} |
| 20357 |
|
| 20358 |
/* Update the current row of A: */ |
| 20359 |
/* A(RK,K+1:N) := A(RK,K+1:N) - A(RK,1:K)*F(K+1:N,1:K)'. */ |
| 20360 |
|
| 20361 |
if (k < *n) { |
| 20362 |
i__1 = *n - k; |
| 20363 |
dgemv_("No transpose", &i__1, &k, &c_b8, &f[k + 1 + f_dim1], ldf, |
| 20364 |
&a[rk + a_dim1], lda, &c_b9, &a[rk + (k + 1) * a_dim1], |
| 20365 |
lda); |
| 20366 |
} |
| 20367 |
|
| 20368 |
/* Update partial column norms. */ |
| 20369 |
|
| 20370 |
if (rk < lastrk) { |
| 20371 |
i__1 = *n; |
| 20372 |
for (j = k + 1; j <= i__1; ++j) { |
| 20373 |
if (vn1[j] != 0.) { |
| 20374 |
|
| 20375 |
/* NOTE: The following 4 lines follow from the analysis in */ |
| 20376 |
/* Lapack Working Note 176. */ |
| 20377 |
|
| 20378 |
temp = (d__1 = a[rk + j * a_dim1], abs(d__1)) / vn1[j]; |
| 20379 |
/* Computing MAX */ |
| 20380 |
d__1 = 0., d__2 = (temp + 1.) * (1. - temp); |
| 20381 |
temp = std::max(d__1,d__2); |
| 20382 |
/* Computing 2nd power */ |
| 20383 |
d__1 = vn1[j] / vn2[j]; |
| 20384 |
temp2 = temp * (d__1 * d__1); |
| 20385 |
if (temp2 <= tol3z) { |
| 20386 |
vn2[j] = (double) lsticc; |
| 20387 |
lsticc = j; |
| 20388 |
} else { |
| 20389 |
vn1[j] *= sqrt(temp); |
| 20390 |
} |
| 20391 |
} |
| 20392 |
/* L30: */ |
| 20393 |
} |
| 20394 |
} |
| 20395 |
|
| 20396 |
a[rk + k * a_dim1] = akk; |
| 20397 |
|
| 20398 |
/* End of while loop. */ |
| 20399 |
|
| 20400 |
goto L10; |
| 20401 |
} |
| 20402 |
*kb = k; |
| 20403 |
rk = *offset + *kb; |
| 20404 |
|
| 20405 |
/* Apply the block reflector to the rest of the matrix: */ |
| 20406 |
/* A(OFFSET+KB+1:M,KB+1:N) := A(OFFSET+KB+1:M,KB+1:N) - */ |
| 20407 |
/* A(OFFSET+KB+1:M,1:KB)*F(KB+1:N,1:KB)'. */ |
| 20408 |
|
| 20409 |
/* Computing MIN */ |
| 20410 |
i__1 = *n, i__2 = *m - *offset; |
| 20411 |
if (*kb < std::min(i__1,i__2)) { |
| 20412 |
i__1 = *m - rk; |
| 20413 |
i__2 = *n - *kb; |
| 20414 |
dgemm_("No transpose", "Transpose", &i__1, &i__2, kb, &c_b8, &a[rk + |
| 20415 |
1 + a_dim1], lda, &f[*kb + 1 + f_dim1], ldf, &c_b9, &a[rk + 1 |
| 20416 |
+ (*kb + 1) * a_dim1], lda); |
| 20417 |
} |
| 20418 |
|
| 20419 |
/* Recomputation of difficult columns. */ |
| 20420 |
|
| 20421 |
L40: |
| 20422 |
if (lsticc > 0) { |
| 20423 |
itemp = i_dnnt(&vn2[lsticc]); |
| 20424 |
i__1 = *m - rk; |
| 20425 |
vn1[lsticc] = dnrm2_(&i__1, &a[rk + 1 + lsticc * a_dim1], &c__1); |
| 20426 |
|
| 20427 |
/* NOTE: The computation of VN1( LSTICC ) relies on the fact that */ |
| 20428 |
/* SNRM2 does not fail on vectors with norm below the value of */ |
| 20429 |
/* SQRT(DLAMCH('S')) */ |
| 20430 |
|
| 20431 |
vn2[lsticc] = vn1[lsticc]; |
| 20432 |
lsticc = itemp; |
| 20433 |
goto L40; |
| 20434 |
} |
| 20435 |
|
| 20436 |
return 0; |
| 20437 |
|
| 20438 |
/* End of DLAQPS */ |
| 20439 |
|
| 20440 |
} /* dlaqps_ */ |
| 20441 |
|
| 20442 |
/* Subroutine */ int dlaqr0_(bool *wantt, bool *wantz, integer *n, |
| 20443 |
integer *ilo, integer *ihi, double *h__, integer *ldh, double |
| 20444 |
*wr, double *wi, integer *iloz, integer *ihiz, double *z__, |
| 20445 |
integer *ldz, double *work, integer *lwork, integer *info) |
| 20446 |
{ |
| 20447 |
/* Table of constant values */ |
| 20448 |
static integer c__13 = 13; |
| 20449 |
static integer c__15 = 15; |
| 20450 |
static integer c_n1 = -1; |
| 20451 |
static integer c__12 = 12; |
| 20452 |
static integer c__14 = 14; |
| 20453 |
static integer c__16 = 16; |
| 20454 |
static bool c_false = false; |
| 20455 |
static integer c__1 = 1; |
| 20456 |
static integer c__3 = 3; |
| 20457 |
|
| 20458 |
/* System generated locals */ |
| 20459 |
integer h_dim1, h_offset, z_dim1, z_offset, i__1, i__2, i__3, i__4, i__5; |
| 20460 |
double d__1, d__2, d__3, d__4; |
| 20461 |
|
| 20462 |
/* Local variables */ |
| 20463 |
integer i__, k; |
| 20464 |
double aa, bb, cc, dd; |
| 20465 |
integer ld; |
| 20466 |
double cs; |
| 20467 |
integer nh, it, ks, kt; |
| 20468 |
double sn; |
| 20469 |
integer ku, kv, ls, ns; |
| 20470 |
double ss; |
| 20471 |
integer nw, inf, kdu, nho, nve, kwh, nsr, nwr, kwv, ndec, ndfl, kbot, nmin; |
| 20472 |
double swap; |
| 20473 |
integer ktop; |
| 20474 |
double zdum[1] /* was [1][1] */; |
| 20475 |
integer kacc22, itmax, nsmax, nwmax, kwtop; |
| 20476 |
integer nibble, nwupbd; |
| 20477 |
char jbcmpz[3]; |
| 20478 |
bool sorted; |
| 20479 |
integer lwkopt; |
| 20480 |
|
| 20481 |
|
| 20482 |
/* -- LAPACK auxiliary routine (version 3.2) -- */ |
| 20483 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 20484 |
/* November 2006 */ |
| 20485 |
|
| 20486 |
/* .. Scalar Arguments .. */ |
| 20487 |
/* .. */ |
| 20488 |
/* .. Array Arguments .. */ |
| 20489 |
/* .. */ |
| 20490 |
|
| 20491 |
/* Purpose */ |
| 20492 |
/* ======= */ |
| 20493 |
|
| 20494 |
/* DLAQR0 computes the eigenvalues of a Hessenberg matrix H */ |
| 20495 |
/* and, optionally, the matrices T and Z from the Schur decomposition */ |
| 20496 |
/* H = Z T Z**T, where T is an upper quasi-triangular matrix (the */ |
| 20497 |
/* Schur form), and Z is the orthogonal matrix of Schur vectors. */ |
| 20498 |
|
| 20499 |
/* Optionally Z may be postmultiplied into an input orthogonal */ |
| 20500 |
/* matrix Q so that this routine can give the Schur factorization */ |
| 20501 |
/* of a matrix A which has been reduced to the Hessenberg form H */ |
| 20502 |
/* by the orthogonal matrix Q: A = Q*H*Q**T = (QZ)*T*(QZ)**T. */ |
| 20503 |
|
| 20504 |
/* Arguments */ |
| 20505 |
/* ========= */ |
| 20506 |
|
| 20507 |
/* WANTT (input) LOGICAL */ |
| 20508 |
/* = .TRUE. : the full Schur form T is required; */ |
| 20509 |
/* = .FALSE.: only eigenvalues are required. */ |
| 20510 |
|
| 20511 |
/* WANTZ (input) LOGICAL */ |
| 20512 |
/* = .TRUE. : the matrix of Schur vectors Z is required; */ |
| 20513 |
/* = .FALSE.: Schur vectors are not required. */ |
| 20514 |
|
| 20515 |
/* N (input) INTEGER */ |
| 20516 |
/* The order of the matrix H. N .GE. 0. */ |
| 20517 |
|
| 20518 |
/* ILO (input) INTEGER */ |
| 20519 |
/* IHI (input) INTEGER */ |
| 20520 |
/* It is assumed that H is already upper triangular in rows */ |
| 20521 |
/* and columns 1:ILO-1 and IHI+1:N and, if ILO.GT.1, */ |
| 20522 |
/* H(ILO,ILO-1) is zero. ILO and IHI are normally set by a */ |
| 20523 |
/* previous call to DGEBAL, and then passed to DGEHRD when the */ |
| 20524 |
/* matrix output by DGEBAL is reduced to Hessenberg form. */ |
| 20525 |
/* Otherwise, ILO and IHI should be set to 1 and N, */ |
| 20526 |
/* respectively. If N.GT.0, then 1.LE.ILO.LE.IHI.LE.N. */ |
| 20527 |
/* If N = 0, then ILO = 1 and IHI = 0. */ |
| 20528 |
|
| 20529 |
/* H (input/output) DOUBLE PRECISION array, dimension (LDH,N) */ |
| 20530 |
/* On entry, the upper Hessenberg matrix H. */ |
| 20531 |
/* On exit, if INFO = 0 and WANTT is .TRUE., then H contains */ |
| 20532 |
/* the upper quasi-triangular matrix T from the Schur */ |
| 20533 |
/* decomposition (the Schur form); 2-by-2 diagonal blocks */ |
| 20534 |
/* (corresponding to complex conjugate pairs of eigenvalues) */ |
| 20535 |
/* are returned in standard form, with H(i,i) = H(i+1,i+1) */ |
| 20536 |
/* and H(i+1,i)*H(i,i+1).LT.0. If INFO = 0 and WANTT is */ |
| 20537 |
/* .FALSE., then the contents of H are unspecified on exit. */ |
| 20538 |
/* (The output value of H when INFO.GT.0 is given under the */ |
| 20539 |
/* description of INFO below.) */ |
| 20540 |
|
| 20541 |
/* This subroutine may explicitly set H(i,j) = 0 for i.GT.j and */ |
| 20542 |
/* j = 1, 2, ... ILO-1 or j = IHI+1, IHI+2, ... N. */ |
| 20543 |
|
| 20544 |
/* LDH (input) INTEGER */ |
| 20545 |
/* The leading dimension of the array H. LDH .GE. max(1,N). */ |
| 20546 |
|
| 20547 |
/* WR (output) DOUBLE PRECISION array, dimension (IHI) */ |
| 20548 |
/* WI (output) DOUBLE PRECISION array, dimension (IHI) */ |
| 20549 |
/* The real and imaginary parts, respectively, of the computed */ |
| 20550 |
/* eigenvalues of H(ILO:IHI,ILO:IHI) are stored in WR(ILO:IHI) */ |
| 20551 |
/* and WI(ILO:IHI). If two eigenvalues are computed as a */ |
| 20552 |
/* complex conjugate pair, they are stored in consecutive */ |
| 20553 |
/* elements of WR and WI, say the i-th and (i+1)th, with */ |
| 20554 |
/* WI(i) .GT. 0 and WI(i+1) .LT. 0. If WANTT is .TRUE., then */ |
| 20555 |
/* the eigenvalues are stored in the same order as on the */ |
| 20556 |
/* diagonal of the Schur form returned in H, with */ |
| 20557 |
/* WR(i) = H(i,i) and, if H(i:i+1,i:i+1) is a 2-by-2 diagonal */ |
| 20558 |
/* block, WI(i) = sqrt(-H(i+1,i)*H(i,i+1)) and */ |
| 20559 |
/* WI(i+1) = -WI(i). */ |
| 20560 |
|
| 20561 |
/* ILOZ (input) INTEGER */ |
| 20562 |
/* IHIZ (input) INTEGER */ |
| 20563 |
/* Specify the rows of Z to which transformations must be */ |
| 20564 |
/* applied if WANTZ is .TRUE.. */ |
| 20565 |
/* 1 .LE. ILOZ .LE. ILO; IHI .LE. IHIZ .LE. N. */ |
| 20566 |
|
| 20567 |
/* Z (input/output) DOUBLE PRECISION array, dimension (LDZ,IHI) */ |
| 20568 |
/* If WANTZ is .FALSE., then Z is not referenced. */ |
| 20569 |
/* If WANTZ is .TRUE., then Z(ILO:IHI,ILOZ:IHIZ) is */ |
| 20570 |
/* replaced by Z(ILO:IHI,ILOZ:IHIZ)*U where U is the */ |
| 20571 |
/* orthogonal Schur factor of H(ILO:IHI,ILO:IHI). */ |
| 20572 |
/* (The output value of Z when INFO.GT.0 is given under */ |
| 20573 |
/* the description of INFO below.) */ |
| 20574 |
|
| 20575 |
/* LDZ (input) INTEGER */ |
| 20576 |
/* The leading dimension of the array Z. if WANTZ is .TRUE. */ |
| 20577 |
/* then LDZ.GE.MAX(1,IHIZ). Otherwize, LDZ.GE.1. */ |
| 20578 |
|
| 20579 |
/* WORK (workspace/output) DOUBLE PRECISION array, dimension LWORK */ |
| 20580 |
/* On exit, if LWORK = -1, WORK(1) returns an estimate of */ |
| 20581 |
/* the optimal value for LWORK. */ |
| 20582 |
|
| 20583 |
/* LWORK (input) INTEGER */ |
| 20584 |
/* The dimension of the array WORK. LWORK .GE. max(1,N) */ |
| 20585 |
/* is sufficient, but LWORK typically as large as 6*N may */ |
| 20586 |
/* be required for optimal performance. A workspace query */ |
| 20587 |
/* to determine the optimal workspace size is recommended. */ |
| 20588 |
|
| 20589 |
/* If LWORK = -1, then DLAQR0 does a workspace query. */ |
| 20590 |
/* In this case, DLAQR0 checks the input parameters and */ |
| 20591 |
/* estimates the optimal workspace size for the given */ |
| 20592 |
/* values of N, ILO and IHI. The estimate is returned */ |
| 20593 |
/* in WORK(1). No error message related to LWORK is */ |
| 20594 |
/* issued by XERBLA. Neither H nor Z are accessed. */ |
| 20595 |
|
| 20596 |
|
| 20597 |
/* INFO (output) INTEGER */ |
| 20598 |
/* = 0: successful exit */ |
| 20599 |
/* .GT. 0: if INFO = i, DLAQR0 failed to compute all of */ |
| 20600 |
/* the eigenvalues. Elements 1:ilo-1 and i+1:n of WR */ |
| 20601 |
/* and WI contain those eigenvalues which have been */ |
| 20602 |
/* successfully computed. (Failures are rare.) */ |
| 20603 |
|
| 20604 |
/* If INFO .GT. 0 and WANT is .FALSE., then on exit, */ |
| 20605 |
/* the remaining unconverged eigenvalues are the eigen- */ |
| 20606 |
/* values of the upper Hessenberg matrix rows and */ |
| 20607 |
/* columns ILO through INFO of the final, output */ |
| 20608 |
/* value of H. */ |
| 20609 |
|
| 20610 |
/* If INFO .GT. 0 and WANTT is .TRUE., then on exit */ |
| 20611 |
|
| 20612 |
/* (*) (initial value of H)*U = U*(final value of H) */ |
| 20613 |
|
| 20614 |
/* where U is an orthogonal matrix. The final */ |
| 20615 |
/* value of H is upper Hessenberg and quasi-triangular */ |
| 20616 |
/* in rows and columns INFO+1 through IHI. */ |
| 20617 |
|
| 20618 |
/* If INFO .GT. 0 and WANTZ is .TRUE., then on exit */ |
| 20619 |
|
| 20620 |
/* (final value of Z(ILO:IHI,ILOZ:IHIZ) */ |
| 20621 |
/* = (initial value of Z(ILO:IHI,ILOZ:IHIZ)*U */ |
| 20622 |
|
| 20623 |
/* where U is the orthogonal matrix in (*) (regard- */ |
| 20624 |
/* less of the value of WANTT.) */ |
| 20625 |
|
| 20626 |
/* If INFO .GT. 0 and WANTZ is .FALSE., then Z is not */ |
| 20627 |
/* accessed. */ |
| 20628 |
|
| 20629 |
/* ================================================================ */ |
| 20630 |
/* Based on contributions by */ |
| 20631 |
/* Karen Braman and Ralph Byers, Department of Mathematics, */ |
| 20632 |
/* University of Kansas, USA */ |
| 20633 |
|
| 20634 |
/* ================================================================ */ |
| 20635 |
/* References: */ |
| 20636 |
/* K. Braman, R. Byers and R. Mathias, The Multi-Shift QR */ |
| 20637 |
/* Algorithm Part I: Maintaining Well Focused Shifts, and Level 3 */ |
| 20638 |
/* Performance, SIAM Journal of Matrix Analysis, volume 23, pages */ |
| 20639 |
/* 929--947, 2002. */ |
| 20640 |
|
| 20641 |
/* K. Braman, R. Byers and R. Mathias, The Multi-Shift QR */ |
| 20642 |
/* Algorithm Part II: Aggressive Early Deflation, SIAM Journal */ |
| 20643 |
/* of Matrix Analysis, volume 23, pages 948--973, 2002. */ |
| 20644 |
|
| 20645 |
/* ================================================================ */ |
| 20646 |
/* .. Parameters .. */ |
| 20647 |
|
| 20648 |
/* ==== Matrices of order NTINY or smaller must be processed by */ |
| 20649 |
/* . DLAHQR because of insufficient subdiagonal scratch space. */ |
| 20650 |
/* . (This is a hard limit.) ==== */ |
| 20651 |
|
| 20652 |
/* ==== Exceptional deflation windows: try to cure rare */ |
| 20653 |
/* . slow convergence by varying the size of the */ |
| 20654 |
/* . deflation window after KEXNW iterations. ==== */ |
| 20655 |
|
| 20656 |
/* ==== Exceptional shifts: try to cure rare slow convergence */ |
| 20657 |
/* . with ad-hoc exceptional shifts every KEXSH iterations. */ |
| 20658 |
/* . ==== */ |
| 20659 |
|
| 20660 |
/* ==== The constants WILK1 and WILK2 are used to form the */ |
| 20661 |
/* . exceptional shifts. ==== */ |
| 20662 |
/* .. */ |
| 20663 |
/* .. Local Scalars .. */ |
| 20664 |
/* .. */ |
| 20665 |
/* .. External Functions .. */ |
| 20666 |
/* .. */ |
| 20667 |
/* .. Local Arrays .. */ |
| 20668 |
/* .. */ |
| 20669 |
/* .. External Subroutines .. */ |
| 20670 |
/* .. */ |
| 20671 |
/* .. Intrinsic Functions .. */ |
| 20672 |
/* .. */ |
| 20673 |
/* .. Executable Statements .. */ |
| 20674 |
/* Parameter adjustments */ |
| 20675 |
h_dim1 = *ldh; |
| 20676 |
h_offset = 1 + h_dim1; |
| 20677 |
h__ -= h_offset; |
| 20678 |
--wr; |
| 20679 |
--wi; |
| 20680 |
z_dim1 = *ldz; |
| 20681 |
z_offset = 1 + z_dim1; |
| 20682 |
z__ -= z_offset; |
| 20683 |
--work; |
| 20684 |
|
| 20685 |
/* Function Body */ |
| 20686 |
*info = 0; |
| 20687 |
|
| 20688 |
/* ==== Quick return for N = 0: nothing to do. ==== */ |
| 20689 |
|
| 20690 |
if (*n == 0) { |
| 20691 |
work[1] = 1.; |
| 20692 |
return 0; |
| 20693 |
} |
| 20694 |
|
| 20695 |
if (*n <= 11) { |
| 20696 |
|
| 20697 |
/* ==== Tiny matrices must use DLAHQR. ==== */ |
| 20698 |
|
| 20699 |
lwkopt = 1; |
| 20700 |
if (*lwork != -1) { |
| 20701 |
dlahqr_(wantt, wantz, n, ilo, ihi, &h__[h_offset], ldh, &wr[1], & |
| 20702 |
wi[1], iloz, ihiz, &z__[z_offset], ldz, info); |
| 20703 |
} |
| 20704 |
} else { |
| 20705 |
|
| 20706 |
/* ==== Use small bulge multi-shift QR with aggressive early */ |
| 20707 |
/* . deflation on larger-than-tiny matrices. ==== */ |
| 20708 |
|
| 20709 |
/* ==== Hope for the best. ==== */ |
| 20710 |
|
| 20711 |
*info = 0; |
| 20712 |
|
| 20713 |
/* ==== Set up job flags for ILAENV. ==== */ |
| 20714 |
|
| 20715 |
if (*wantt) { |
| 20716 |
* (unsigned char *) & jbcmpz [0] = 'S'; |
| 20717 |
} else { |
| 20718 |
* (unsigned char *) & jbcmpz [0] = 'E'; |
| 20719 |
} |
| 20720 |
if (*wantz) { |
| 20721 |
* (unsigned char *) & jbcmpz [1] = 'V'; |
| 20722 |
} else { |
| 20723 |
* (unsigned char *) & jbcmpz [1] = 'N'; |
| 20724 |
} |
| 20725 |
jbcmpz [2] = '\0'; |
| 20726 |
/* ==== NWR = recommended deflation window size. At this */ |
| 20727 |
/* . point, N .GT. NTINY = 11, so there is enough */ |
| 20728 |
/* . subdiagonal workspace for NWR.GE.2 as required. */ |
| 20729 |
/* . (In fact, there is enough subdiagonal space for */ |
| 20730 |
/* . NWR.GE.3.) ==== */ |
| 20731 |
|
| 20732 |
nwr = ilaenv_(&c__13, "DLAQR0", jbcmpz, n, ilo, ihi, lwork); |
| 20733 |
nwr = std::max(2_integer,nwr); |
| 20734 |
/* Computing MIN */ |
| 20735 |
i__1 = *ihi - *ilo + 1, i__2 = (*n - 1) / 3, i__1 = std::min(i__1,i__2); |
| 20736 |
nwr = std::min(i__1,nwr); |
| 20737 |
|
| 20738 |
/* ==== NSR = recommended number of simultaneous shifts. */ |
| 20739 |
/* . At this point N .GT. NTINY = 11, so there is at */ |
| 20740 |
/* . enough subdiagonal workspace for NSR to be even */ |
| 20741 |
/* . and greater than or equal to two as required. ==== */ |
| 20742 |
|
| 20743 |
nsr = ilaenv_(&c__15, "DLAQR0", jbcmpz, n, ilo, ihi, lwork); |
| 20744 |
/* Computing MIN */ |
| 20745 |
i__1 = nsr, i__2 = (*n + 6) / 9, i__1 = std::min(i__1,i__2), i__2 = *ihi - *ilo; |
| 20746 |
nsr = std::min(i__1,i__2); |
| 20747 |
/* Computing MAX */ |
| 20748 |
i__1 = 2, i__2 = nsr - nsr % 2; |
| 20749 |
nsr = std::max(i__1,i__2); |
| 20750 |
|
| 20751 |
/* ==== Estimate optimal workspace ==== */ |
| 20752 |
|
| 20753 |
/* ==== Workspace query call to DLAQR3 ==== */ |
| 20754 |
|
| 20755 |
i__1 = nwr + 1; |
| 20756 |
dlaqr3_(wantt, wantz, n, ilo, ihi, &i__1, &h__[h_offset], ldh, iloz, |
| 20757 |
ihiz, &z__[z_offset], ldz, &ls, &ld, &wr[1], &wi[1], &h__[ |
| 20758 |
h_offset], ldh, n, &h__[h_offset], ldh, n, &h__[h_offset], |
| 20759 |
ldh, &work[1], &c_n1); |
| 20760 |
|
| 20761 |
/* ==== Optimal workspace = MAX(DLAQR5, DLAQR3) ==== */ |
| 20762 |
|
| 20763 |
/* Computing MAX */ |
| 20764 |
i__1 = nsr * 3 / 2, i__2 = (integer) work[1]; |
| 20765 |
lwkopt = std::max(i__1,i__2); |
| 20766 |
|
| 20767 |
/* ==== Quick return in case of workspace query. ==== */ |
| 20768 |
|
| 20769 |
if (*lwork == -1) { |
| 20770 |
work[1] = (double) lwkopt; |
| 20771 |
return 0; |
| 20772 |
} |
| 20773 |
|
| 20774 |
/* ==== DLAHQR/DLAQR0 crossover point ==== */ |
| 20775 |
|
| 20776 |
nmin = ilaenv_(&c__12, "DLAQR0", jbcmpz, n, ilo, ihi, lwork); |
| 20777 |
nmin = std::max(11_integer,nmin); |
| 20778 |
|
| 20779 |
/* ==== Nibble crossover point ==== */ |
| 20780 |
|
| 20781 |
nibble = ilaenv_(&c__14, "DLAQR0", jbcmpz, n, ilo, ihi, lwork); |
| 20782 |
nibble = std::max(0_integer,nibble); |
| 20783 |
|
| 20784 |
/* ==== Accumulate reflections during ttswp? Use block */ |
| 20785 |
/* . 2-by-2 structure during matrix-matrix multiply? ==== */ |
| 20786 |
|
| 20787 |
kacc22 = ilaenv_(&c__16, "DLAQR0", jbcmpz, n, ilo, ihi, lwork); |
| 20788 |
kacc22 = std::max(0_integer,kacc22); |
| 20789 |
kacc22 = std::min(2_integer,kacc22); |
| 20790 |
|
| 20791 |
/* ==== NWMAX = the largest possible deflation window for */ |
| 20792 |
/* . which there is sufficient workspace. ==== */ |
| 20793 |
|
| 20794 |
/* Computing MIN */ |
| 20795 |
i__1 = (*n - 1) / 3, i__2 = *lwork / 2; |
| 20796 |
nwmax = std::min(i__1,i__2); |
| 20797 |
nw = nwmax; |
| 20798 |
|
| 20799 |
/* ==== NSMAX = the Largest number of simultaneous shifts */ |
| 20800 |
/* . for which there is sufficient workspace. ==== */ |
| 20801 |
|
| 20802 |
/* Computing MIN */ |
| 20803 |
i__1 = (*n + 6) / 9, i__2 = (*lwork << 1) / 3; |
| 20804 |
nsmax = std::min(i__1,i__2); |
| 20805 |
nsmax -= nsmax % 2; |
| 20806 |
|
| 20807 |
/* ==== NDFL: an iteration count restarted at deflation. ==== */ |
| 20808 |
|
| 20809 |
ndfl = 1; |
| 20810 |
|
| 20811 |
/* ==== ITMAX = iteration limit ==== */ |
| 20812 |
|
| 20813 |
/* Computing MAX */ |
| 20814 |
i__1 = 10, i__2 = *ihi - *ilo + 1; |
| 20815 |
itmax = std::max(i__1,i__2) * 30; |
| 20816 |
|
| 20817 |
/* ==== Last row and column in the active block ==== */ |
| 20818 |
|
| 20819 |
kbot = *ihi; |
| 20820 |
|
| 20821 |
/* ==== Main Loop ==== */ |
| 20822 |
|
| 20823 |
i__1 = itmax; |
| 20824 |
for (it = 1; it <= i__1; ++it) { |
| 20825 |
|
| 20826 |
/* ==== Done when KBOT falls below ILO ==== */ |
| 20827 |
|
| 20828 |
if (kbot < *ilo) { |
| 20829 |
goto L90; |
| 20830 |
} |
| 20831 |
|
| 20832 |
/* ==== Locate active block ==== */ |
| 20833 |
|
| 20834 |
i__2 = *ilo + 1; |
| 20835 |
for (k = kbot; k >= i__2; --k) { |
| 20836 |
if (h__[k + (k - 1) * h_dim1] == 0.) { |
| 20837 |
goto L20; |
| 20838 |
} |
| 20839 |
/* L10: */ |
| 20840 |
} |
| 20841 |
k = *ilo; |
| 20842 |
L20: |
| 20843 |
ktop = k; |
| 20844 |
|
| 20845 |
/* ==== Select deflation window size: */ |
| 20846 |
/* . Typical Case: */ |
| 20847 |
/* . If possible and advisable, nibble the entire */ |
| 20848 |
/* . active block. If not, use size MIN(NWR,NWMAX) */ |
| 20849 |
/* . or MIN(NWR+1,NWMAX) depending upon which has */ |
| 20850 |
/* . the smaller corresponding subdiagonal entry */ |
| 20851 |
/* . (a heuristic). */ |
| 20852 |
/* . */ |
| 20853 |
/* . Exceptional Case: */ |
| 20854 |
/* . If there have been no deflations in KEXNW or */ |
| 20855 |
/* . more iterations, then vary the deflation window */ |
| 20856 |
/* . size. At first, because, larger windows are, */ |
| 20857 |
/* . in general, more powerful than smaller ones, */ |
| 20858 |
/* . rapidly increase the window to the maximum possible. */ |
| 20859 |
/* . Then, gradually reduce the window size. ==== */ |
| 20860 |
|
| 20861 |
nh = kbot - ktop + 1; |
| 20862 |
nwupbd = std::min(nh,nwmax); |
| 20863 |
if (ndfl < 5) { |
| 20864 |
nw = std::min(nwupbd,nwr); |
| 20865 |
} else { |
| 20866 |
/* Computing MIN */ |
| 20867 |
i__2 =nwupbd, i__3 = nw << 1; |
| 20868 |
nw = std::min(i__2,i__3); |
| 20869 |
} |
| 20870 |
if (nw < nwmax) { |
| 20871 |
if (nw >= nh - 1) { |
| 20872 |
nw = nh; |
| 20873 |
} else { |
| 20874 |
kwtop = kbot - nw + 1; |
| 20875 |
if ((d__1 = h__[kwtop + (kwtop - 1) * h_dim1], abs(d__1)) |
| 20876 |
> (d__2 = h__[kwtop - 1 + (kwtop - 2) * h_dim1], |
| 20877 |
abs(d__2))) { |
| 20878 |
++nw; |
| 20879 |
} |
| 20880 |
} |
| 20881 |
} |
| 20882 |
if (ndfl < 5) { |
| 20883 |
ndec = -1; |
| 20884 |
} else if (ndec >= 0 || nw >= nwupbd) { |
| 20885 |
++ndec; |
| 20886 |
if (nw - ndec < 2) { |
| 20887 |
ndec = 0; |
| 20888 |
} |
| 20889 |
nw -= ndec; |
| 20890 |
} |
| 20891 |
|
| 20892 |
/* ==== Aggressive early deflation: */ |
| 20893 |
/* . split workspace under the subdiagonal into */ |
| 20894 |
/* . - an nw-by-nw work array V in the lower */ |
| 20895 |
/* . left-hand-corner, */ |
| 20896 |
/* . - an NW-by-at-least-NW-but-more-is-better */ |
| 20897 |
/* . (NW-by-NHO) horizontal work array along */ |
| 20898 |
/* . the bottom edge, */ |
| 20899 |
/* . - an at-least-NW-but-more-is-better (NHV-by-NW) */ |
| 20900 |
/* . vertical work array along the left-hand-edge. */ |
| 20901 |
/* . ==== */ |
| 20902 |
|
| 20903 |
kv = *n - nw + 1; |
| 20904 |
kt = nw + 1; |
| 20905 |
nho = *n - nw - 1 - kt + 1; |
| 20906 |
kwv = nw + 2; |
| 20907 |
nve = *n - nw - kwv + 1; |
| 20908 |
|
| 20909 |
/* ==== Aggressive early deflation ==== */ |
| 20910 |
|
| 20911 |
dlaqr3_(wantt, wantz, n, &ktop, &kbot, &nw, &h__[h_offset], ldh, |
| 20912 |
iloz, ihiz, &z__[z_offset], ldz, &ls, &ld, &wr[1], &wi[1], |
| 20913 |
&h__[kv + h_dim1], ldh, &nho, &h__[kv + kt * h_dim1], |
| 20914 |
ldh, &nve, &h__[kwv + h_dim1], ldh, &work[1], lwork); |
| 20915 |
|
| 20916 |
/* ==== Adjust KBOT accounting for new deflations. ==== */ |
| 20917 |
|
| 20918 |
kbot -= ld; |
| 20919 |
|
| 20920 |
/* ==== KS points to the shifts. ==== */ |
| 20921 |
|
| 20922 |
ks = kbot - ls + 1; |
| 20923 |
|
| 20924 |
/* ==== Skip an expensive QR sweep if there is a (partly */ |
| 20925 |
/* . heuristic) reason to expect that many eigenvalues */ |
| 20926 |
/* . will deflate without it. Here, the QR sweep is */ |
| 20927 |
/* . skipped if many eigenvalues have just been deflated */ |
| 20928 |
/* . or if the remaining active block is small. */ |
| 20929 |
|
| 20930 |
if (ld == 0 || ld * 100 <= nw * nibble && kbot - ktop + 1 > std::min( |
| 20931 |
nmin,nwmax)) { |
| 20932 |
|
| 20933 |
/* ==== NS = nominal number of simultaneous shifts. */ |
| 20934 |
/* . This may be lowered (slightly) if DLAQR3 */ |
| 20935 |
/* . did not provide that many shifts. ==== */ |
| 20936 |
|
| 20937 |
/* Computing MIN */ |
| 20938 |
/* Computing MAX */ |
| 20939 |
i__4 = 2, i__5 = kbot - ktop; |
| 20940 |
i__2 = std::min(nsmax,nsr), i__3 = std::max(i__4,i__5); |
| 20941 |
ns = std::min(i__2,i__3); |
| 20942 |
ns -= ns % 2; |
| 20943 |
|
| 20944 |
/* ==== If there have been no deflations */ |
| 20945 |
/* . in a multiple of KEXSH iterations, */ |
| 20946 |
/* . then try exceptional shifts. */ |
| 20947 |
/* . Otherwise use shifts provided by */ |
| 20948 |
/* . DLAQR3 above or from the eigenvalues */ |
| 20949 |
/* . of a trailing principal submatrix. ==== */ |
| 20950 |
|
| 20951 |
if (ndfl % 6 == 0) { |
| 20952 |
ks = kbot - ns + 1; |
| 20953 |
/* Computing MAX */ |
| 20954 |
i__3 = ks + 1, i__4 = ktop + 2; |
| 20955 |
i__2 = std::max(i__3,i__4); |
| 20956 |
for (i__ = kbot; i__ >= i__2; i__ += -2) { |
| 20957 |
ss = (d__1 = h__[i__ + (i__ - 1) * h_dim1], abs(d__1)) |
| 20958 |
+ (d__2 = h__[i__ - 1 + (i__ - 2) * h_dim1], |
| 20959 |
abs(d__2)); |
| 20960 |
aa = ss * .75 + h__[i__ + i__ * h_dim1]; |
| 20961 |
bb = ss; |
| 20962 |
cc = ss * -.4375; |
| 20963 |
dd = aa; |
| 20964 |
dlanv2_(&aa, &bb, &cc, &dd, &wr[i__ - 1], &wi[i__ - 1] |
| 20965 |
, &wr[i__], &wi[i__], &cs, &sn); |
| 20966 |
/* L30: */ |
| 20967 |
} |
| 20968 |
if (ks == ktop) { |
| 20969 |
wr[ks + 1] = h__[ks + 1 + (ks + 1) * h_dim1]; |
| 20970 |
wi[ks + 1] = 0.; |
| 20971 |
wr[ks] = wr[ks + 1]; |
| 20972 |
wi[ks] = wi[ks + 1]; |
| 20973 |
} |
| 20974 |
} else { |
| 20975 |
|
| 20976 |
/* ==== Got NS/2 or fewer shifts? Use DLAQR4 or */ |
| 20977 |
/* . DLAHQR on a trailing principal submatrix to */ |
| 20978 |
/* . get more. (Since NS.LE.NSMAX.LE.(N+6)/9, */ |
| 20979 |
/* . there is enough space below the subdiagonal */ |
| 20980 |
/* . to fit an NS-by-NS scratch array.) ==== */ |
| 20981 |
|
| 20982 |
if (kbot - ks + 1 <= ns / 2) { |
| 20983 |
ks = kbot - ns + 1; |
| 20984 |
kt = *n - ns + 1; |
| 20985 |
dlacpy_("A", &ns, &ns, &h__[ks + ks * h_dim1], ldh, & |
| 20986 |
h__[kt + h_dim1], ldh); |
| 20987 |
if (ns > nmin) { |
| 20988 |
dlaqr4_(&c_false, &c_false, &ns, &c__1, &ns, &h__[ |
| 20989 |
kt + h_dim1], ldh, &wr[ks], &wi[ks], & |
| 20990 |
c__1, &c__1, zdum, &c__1, &work[1], lwork, |
| 20991 |
&inf); |
| 20992 |
} else { |
| 20993 |
dlahqr_(&c_false, &c_false, &ns, &c__1, &ns, &h__[ |
| 20994 |
kt + h_dim1], ldh, &wr[ks], &wi[ks], & |
| 20995 |
c__1, &c__1, zdum, &c__1, &inf); |
| 20996 |
} |
| 20997 |
ks += inf; |
| 20998 |
|
| 20999 |
/* ==== In case of a rare QR failure use */ |
| 21000 |
/* . eigenvalues of the trailing 2-by-2 */ |
| 21001 |
/* . principal submatrix. ==== */ |
| 21002 |
|
| 21003 |
if (ks >= kbot) { |
| 21004 |
aa = h__[kbot - 1 + (kbot - 1) * h_dim1]; |
| 21005 |
cc = h__[kbot + (kbot - 1) * h_dim1]; |
| 21006 |
bb = h__[kbot - 1 + kbot * h_dim1]; |
| 21007 |
dd = h__[kbot + kbot * h_dim1]; |
| 21008 |
dlanv2_(&aa, &bb, &cc, &dd, &wr[kbot - 1], &wi[ |
| 21009 |
kbot - 1], &wr[kbot], &wi[kbot], &cs, &sn) |
| 21010 |
; |
| 21011 |
ks = kbot - 1; |
| 21012 |
} |
| 21013 |
} |
| 21014 |
|
| 21015 |
if (kbot - ks + 1 > ns) { |
| 21016 |
|
| 21017 |
/* ==== Sort the shifts (Helps a little) */ |
| 21018 |
/* . Bubble sort keeps complex conjugate */ |
| 21019 |
/* . pairs together. ==== */ |
| 21020 |
|
| 21021 |
sorted = false; |
| 21022 |
i__2 = ks + 1; |
| 21023 |
for (k = kbot; k >= i__2; --k) { |
| 21024 |
if (sorted) { |
| 21025 |
goto L60; |
| 21026 |
} |
| 21027 |
sorted = true; |
| 21028 |
i__3 = k - 1; |
| 21029 |
for (i__ = ks; i__ <= i__3; ++i__) { |
| 21030 |
if ((d__1 = wr[i__], abs(d__1)) + (d__2 = wi[ |
| 21031 |
i__], abs(d__2)) < (d__3 = wr[i__ + 1] |
| 21032 |
, abs(d__3)) + (d__4 = wi[i__ + 1], |
| 21033 |
abs(d__4))) { |
| 21034 |
sorted = false; |
| 21035 |
|
| 21036 |
swap = wr[i__]; |
| 21037 |
wr[i__] = wr[i__ + 1]; |
| 21038 |
wr[i__ + 1] = swap; |
| 21039 |
|
| 21040 |
swap = wi[i__]; |
| 21041 |
wi[i__] = wi[i__ + 1]; |
| 21042 |
wi[i__ + 1] = swap; |
| 21043 |
} |
| 21044 |
/* L40: */ |
| 21045 |
} |
| 21046 |
/* L50: */ |
| 21047 |
} |
| 21048 |
L60: |
| 21049 |
; |
| 21050 |
} |
| 21051 |
|
| 21052 |
/* ==== Shuffle shifts into pairs of real shifts */ |
| 21053 |
/* . and pairs of complex conjugate shifts */ |
| 21054 |
/* . assuming complex conjugate shifts are */ |
| 21055 |
/* . already adjacent to one another. (Yes, */ |
| 21056 |
/* . they are.) ==== */ |
| 21057 |
|
| 21058 |
i__2 = ks + 2; |
| 21059 |
for (i__ = kbot; i__ >= i__2; i__ += -2) { |
| 21060 |
if (wi[i__] != -wi[i__ - 1]) { |
| 21061 |
|
| 21062 |
swap = wr[i__]; |
| 21063 |
wr[i__] = wr[i__ - 1]; |
| 21064 |
wr[i__ - 1] = wr[i__ - 2]; |
| 21065 |
wr[i__ - 2] = swap; |
| 21066 |
|
| 21067 |
swap = wi[i__]; |
| 21068 |
wi[i__] = wi[i__ - 1]; |
| 21069 |
wi[i__ - 1] = wi[i__ - 2]; |
| 21070 |
wi[i__ - 2] = swap; |
| 21071 |
} |
| 21072 |
/* L70: */ |
| 21073 |
} |
| 21074 |
} |
| 21075 |
|
| 21076 |
/* ==== If there are only two shifts and both are */ |
| 21077 |
/* . real, then use only one. ==== */ |
| 21078 |
|
| 21079 |
if (kbot - ks + 1 == 2) { |
| 21080 |
if (wi[kbot] == 0.) { |
| 21081 |
if ((d__1 = wr[kbot] - h__[kbot + kbot * h_dim1], abs( |
| 21082 |
d__1)) < (d__2 = wr[kbot - 1] - h__[kbot + |
| 21083 |
kbot * h_dim1], abs(d__2))) { |
| 21084 |
wr[kbot - 1] = wr[kbot]; |
| 21085 |
} else { |
| 21086 |
wr[kbot] = wr[kbot - 1]; |
| 21087 |
} |
| 21088 |
} |
| 21089 |
} |
| 21090 |
|
| 21091 |
/* ==== Use up to NS of the the smallest magnatiude */ |
| 21092 |
/* . shifts. If there aren't NS shifts available, */ |
| 21093 |
/* . then use them all, possibly dropping one to */ |
| 21094 |
/* . make the number of shifts even. ==== */ |
| 21095 |
|
| 21096 |
/* Computing MIN */ |
| 21097 |
i__2 = ns, i__3 = kbot - ks + 1; |
| 21098 |
ns = std::min(i__2,i__3); |
| 21099 |
ns -= ns % 2; |
| 21100 |
ks = kbot - ns + 1; |
| 21101 |
|
| 21102 |
/* ==== Small-bulge multi-shift QR sweep: */ |
| 21103 |
/* . split workspace under the subdiagonal into */ |
| 21104 |
/* . - a KDU-by-KDU work array U in the lower */ |
| 21105 |
/* . left-hand-corner, */ |
| 21106 |
/* . - a KDU-by-at-least-KDU-but-more-is-better */ |
| 21107 |
/* . (KDU-by-NHo) horizontal work array WH along */ |
| 21108 |
/* . the bottom edge, */ |
| 21109 |
/* . - and an at-least-KDU-but-more-is-better-by-KDU */ |
| 21110 |
/* . (NVE-by-KDU) vertical work WV arrow along */ |
| 21111 |
/* . the left-hand-edge. ==== */ |
| 21112 |
|
| 21113 |
kdu = ns * 3 - 3; |
| 21114 |
ku = *n - kdu + 1; |
| 21115 |
kwh = kdu + 1; |
| 21116 |
nho = *n - kdu - 3 - (kdu + 1) + 1; |
| 21117 |
kwv = kdu + 4; |
| 21118 |
nve = *n - kdu - kwv + 1; |
| 21119 |
|
| 21120 |
/* ==== Small-bulge multi-shift QR sweep ==== */ |
| 21121 |
|
| 21122 |
dlaqr5_(wantt, wantz, &kacc22, n, &ktop, &kbot, &ns, &wr[ks], |
| 21123 |
&wi[ks], &h__[h_offset], ldh, iloz, ihiz, &z__[ |
| 21124 |
z_offset], ldz, &work[1], &c__3, &h__[ku + h_dim1], |
| 21125 |
ldh, &nve, &h__[kwv + h_dim1], ldh, &nho, &h__[ku + |
| 21126 |
kwh * h_dim1], ldh); |
| 21127 |
} |
| 21128 |
|
| 21129 |
/* ==== Note progress (or the lack of it). ==== */ |
| 21130 |
|
| 21131 |
if (ld > 0) { |
| 21132 |
ndfl = 1; |
| 21133 |
} else { |
| 21134 |
++ndfl; |
| 21135 |
} |
| 21136 |
|
| 21137 |
/* ==== End of main loop ==== */ |
| 21138 |
/* L80: */ |
| 21139 |
} |
| 21140 |
|
| 21141 |
/* ==== Iteration limit exceeded. Set INFO to show where */ |
| 21142 |
/* . the problem occurred and exit. ==== */ |
| 21143 |
|
| 21144 |
*info = kbot; |
| 21145 |
L90: |
| 21146 |
; |
| 21147 |
} |
| 21148 |
|
| 21149 |
/* ==== Return the optimal value of LWORK. ==== */ |
| 21150 |
|
| 21151 |
work[1] = (double) lwkopt; |
| 21152 |
|
| 21153 |
/* ==== End of DLAQR0 ==== */ |
| 21154 |
|
| 21155 |
return 0; |
| 21156 |
} /* dlaqr0_ */ |
| 21157 |
|
| 21158 |
/* Subroutine */ int dlaqr1_(integer *n, double *h__, integer *ldh, |
| 21159 |
double *sr1, double *si1, double *sr2, double *si2, |
| 21160 |
double *v) |
| 21161 |
{ |
| 21162 |
/* System generated locals */ |
| 21163 |
integer h_dim1, h_offset; |
| 21164 |
double d__1, d__2, d__3; |
| 21165 |
|
| 21166 |
/* Local variables */ |
| 21167 |
double s, h21s, h31s; |
| 21168 |
|
| 21169 |
|
| 21170 |
/* -- LAPACK auxiliary routine (version 3.2) -- */ |
| 21171 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 21172 |
/* November 2006 */ |
| 21173 |
|
| 21174 |
/* .. Scalar Arguments .. */ |
| 21175 |
/* .. */ |
| 21176 |
/* .. Array Arguments .. */ |
| 21177 |
/* .. */ |
| 21178 |
|
| 21179 |
/* Given a 2-by-2 or 3-by-3 matrix H, DLAQR1 sets v to a */ |
| 21180 |
/* scalar multiple of the first column of the product */ |
| 21181 |
|
| 21182 |
/* (*) K = (H - (sr1 + i*si1)*I)*(H - (sr2 + i*si2)*I) */ |
| 21183 |
|
| 21184 |
/* scaling to avoid overflows and most underflows. It */ |
| 21185 |
/* is assumed that either */ |
| 21186 |
|
| 21187 |
/* 1) sr1 = sr2 and si1 = -si2 */ |
| 21188 |
/* or */ |
| 21189 |
/* 2) si1 = si2 = 0. */ |
| 21190 |
|
| 21191 |
/* This is useful for starting double implicit shift bulges */ |
| 21192 |
/* in the QR algorithm. */ |
| 21193 |
|
| 21194 |
|
| 21195 |
/* N (input) integer */ |
| 21196 |
/* Order of the matrix H. N must be either 2 or 3. */ |
| 21197 |
|
| 21198 |
/* H (input) DOUBLE PRECISION array of dimension (LDH,N) */ |
| 21199 |
/* The 2-by-2 or 3-by-3 matrix H in (*). */ |
| 21200 |
|
| 21201 |
/* LDH (input) integer */ |
| 21202 |
/* The leading dimension of H as declared in */ |
| 21203 |
/* the calling procedure. LDH.GE.N */ |
| 21204 |
|
| 21205 |
/* SR1 (input) DOUBLE PRECISION */ |
| 21206 |
/* SI1 The shifts in (*). */ |
| 21207 |
/* SR2 */ |
| 21208 |
/* SI2 */ |
| 21209 |
|
| 21210 |
/* V (output) DOUBLE PRECISION array of dimension N */ |
| 21211 |
/* A scalar multiple of the first column of the */ |
| 21212 |
/* matrix K in (*). */ |
| 21213 |
|
| 21214 |
/* ================================================================ */ |
| 21215 |
/* Based on contributions by */ |
| 21216 |
/* Karen Braman and Ralph Byers, Department of Mathematics, */ |
| 21217 |
/* University of Kansas, USA */ |
| 21218 |
|
| 21219 |
/* ================================================================ */ |
| 21220 |
|
| 21221 |
/* .. Parameters .. */ |
| 21222 |
/* .. */ |
| 21223 |
/* .. Local Scalars .. */ |
| 21224 |
/* .. */ |
| 21225 |
/* .. Intrinsic Functions .. */ |
| 21226 |
/* .. */ |
| 21227 |
/* .. Executable Statements .. */ |
| 21228 |
/* Parameter adjustments */ |
| 21229 |
h_dim1 = *ldh; |
| 21230 |
h_offset = 1 + h_dim1; |
| 21231 |
h__ -= h_offset; |
| 21232 |
--v; |
| 21233 |
|
| 21234 |
/* Function Body */ |
| 21235 |
if (*n == 2) { |
| 21236 |
s = (d__1 = h__[h_dim1 + 1] - *sr2, abs(d__1)) + abs(*si2) + (d__2 = |
| 21237 |
h__[h_dim1 + 2], abs(d__2)); |
| 21238 |
if (s == 0.) { |
| 21239 |
v[1] = 0.; |
| 21240 |
v[2] = 0.; |
| 21241 |
} else { |
| 21242 |
h21s = h__[h_dim1 + 2] / s; |
| 21243 |
v[1] = h21s * h__[(h_dim1 << 1) + 1] + (h__[h_dim1 + 1] - *sr1) * |
| 21244 |
((h__[h_dim1 + 1] - *sr2) / s) - *si1 * (*si2 / s); |
| 21245 |
v[2] = h21s * (h__[h_dim1 + 1] + h__[(h_dim1 << 1) + 2] - *sr1 - * |
| 21246 |
sr2); |
| 21247 |
} |
| 21248 |
} else { |
| 21249 |
s = (d__1 = h__[h_dim1 + 1] - *sr2, abs(d__1)) + abs(*si2) + (d__2 = |
| 21250 |
h__[h_dim1 + 2], abs(d__2)) + (d__3 = h__[h_dim1 + 3], abs( |
| 21251 |
d__3)); |
| 21252 |
if (s == 0.) { |
| 21253 |
v[1] = 0.; |
| 21254 |
v[2] = 0.; |
| 21255 |
v[3] = 0.; |
| 21256 |
} else { |
| 21257 |
h21s = h__[h_dim1 + 2] / s; |
| 21258 |
h31s = h__[h_dim1 + 3] / s; |
| 21259 |
v[1] = (h__[h_dim1 + 1] - *sr1) * ((h__[h_dim1 + 1] - *sr2) / s) |
| 21260 |
- *si1 * (*si2 / s) + h__[(h_dim1 << 1) + 1] * h21s + h__[ |
| 21261 |
h_dim1 * 3 + 1] * h31s; |
| 21262 |
v[2] = h21s * (h__[h_dim1 + 1] + h__[(h_dim1 << 1) + 2] - *sr1 - * |
| 21263 |
sr2) + h__[h_dim1 * 3 + 2] * h31s; |
| 21264 |
v[3] = h31s * (h__[h_dim1 + 1] + h__[h_dim1 * 3 + 3] - *sr1 - * |
| 21265 |
sr2) + h21s * h__[(h_dim1 << 1) + 3]; |
| 21266 |
} |
| 21267 |
} |
| 21268 |
return 0; |
| 21269 |
} /* dlaqr1_ */ |
| 21270 |
|
| 21271 |
/* Subroutine */ int dlaqr2_(bool *wantt, bool *wantz, integer *n, integer *ktop, integer *kbot, integer *nw, |
| 21272 |
double *h__, integer *ldh, integer *iloz, integer *ihiz, double *z__, integer *ldz, |
| 21273 |
integer *ns, integer *nd, double *sr, double *si, double *v, integer *ldv, integer *nh, |
| 21274 |
double *t, integer *ldt, integer *nv, double *wv, integer *ldwv, double *work, integer *lwork) |
| 21275 |
{ |
| 21276 |
/* Table of constant values */ |
| 21277 |
static integer c__1 = 1; |
| 21278 |
static integer c_n1 = -1; |
| 21279 |
static double c_b12 = 0.; |
| 21280 |
static double c_b13 = 1.; |
| 21281 |
static bool c_true = true; |
| 21282 |
|
| 21283 |
/* System generated locals */ |
| 21284 |
integer h_dim1, h_offset, t_dim1, t_offset, v_dim1, v_offset, wv_dim1, |
| 21285 |
wv_offset, z_dim1, z_offset, i__1, i__2, i__3, i__4; |
| 21286 |
double d__1, d__2, d__3, d__4, d__5, d__6; |
| 21287 |
|
| 21288 |
/* Local variables */ |
| 21289 |
integer i__, j, k; |
| 21290 |
double s, aa, bb, cc, dd, cs, sn; |
| 21291 |
integer jw; |
| 21292 |
double evi, evk, foo; |
| 21293 |
integer kln; |
| 21294 |
double tau, ulp; |
| 21295 |
integer lwk1, lwk2; |
| 21296 |
double beta; |
| 21297 |
integer kend, kcol, info, ifst, ilst, ltop, krow; |
| 21298 |
bool bulge; |
| 21299 |
integer infqr, kwtop; |
| 21300 |
double safmin; |
| 21301 |
double safmax; |
| 21302 |
bool sorted; |
| 21303 |
double smlnum; |
| 21304 |
integer lwkopt; |
| 21305 |
|
| 21306 |
/* -- LAPACK auxiliary routine (version 3.2.1) -- */ |
| 21307 |
/* Univ. of Tennessee, Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd.. */ |
| 21308 |
/* -- April 2009 -- */ |
| 21309 |
|
| 21310 |
/* .. Scalar Arguments .. */ |
| 21311 |
/* .. */ |
| 21312 |
/* .. Array Arguments .. */ |
| 21313 |
/* .. */ |
| 21314 |
|
| 21315 |
/* This subroutine is identical to DLAQR3 except that it avoids */ |
| 21316 |
/* recursion by calling DLAHQR instead of DLAQR4. */ |
| 21317 |
|
| 21318 |
|
| 21319 |
/* ****************************************************************** */ |
| 21320 |
/* Aggressive early deflation: */ |
| 21321 |
|
| 21322 |
/* This subroutine accepts as input an upper Hessenberg matrix */ |
| 21323 |
/* H and performs an orthogonal similarity transformation */ |
| 21324 |
/* designed to detect and deflate fully converged eigenvalues from */ |
| 21325 |
/* a trailing principal submatrix. On output H has been over- */ |
| 21326 |
/* written by a new Hessenberg matrix that is a perturbation of */ |
| 21327 |
/* an orthogonal similarity transformation of H. It is to be */ |
| 21328 |
/* hoped that the final version of H has many zero subdiagonal */ |
| 21329 |
/* entries. */ |
| 21330 |
|
| 21331 |
/* ****************************************************************** */ |
| 21332 |
/* WANTT (input) LOGICAL */ |
| 21333 |
/* If .TRUE., then the Hessenberg matrix H is fully updated */ |
| 21334 |
/* so that the quasi-triangular Schur factor may be */ |
| 21335 |
/* computed (in cooperation with the calling subroutine). */ |
| 21336 |
/* If .FALSE., then only enough of H is updated to preserve */ |
| 21337 |
/* the eigenvalues. */ |
| 21338 |
|
| 21339 |
/* WANTZ (input) LOGICAL */ |
| 21340 |
/* If .TRUE., then the orthogonal matrix Z is updated so */ |
| 21341 |
/* so that the orthogonal Schur factor may be computed */ |
| 21342 |
/* (in cooperation with the calling subroutine). */ |
| 21343 |
/* If .FALSE., then Z is not referenced. */ |
| 21344 |
|
| 21345 |
/* N (input) INTEGER */ |
| 21346 |
/* The order of the matrix H and (if WANTZ is .TRUE.) the */ |
| 21347 |
/* order of the orthogonal matrix Z. */ |
| 21348 |
|
| 21349 |
/* KTOP (input) INTEGER */ |
| 21350 |
/* It is assumed that either KTOP = 1 or H(KTOP,KTOP-1)=0. */ |
| 21351 |
/* KBOT and KTOP together determine an isolated block */ |
| 21352 |
/* along the diagonal of the Hessenberg matrix. */ |
| 21353 |
|
| 21354 |
/* KBOT (input) INTEGER */ |
| 21355 |
/* It is assumed without a check that either */ |
| 21356 |
/* KBOT = N or H(KBOT+1,KBOT)=0. KBOT and KTOP together */ |
| 21357 |
/* determine an isolated block along the diagonal of the */ |
| 21358 |
/* Hessenberg matrix. */ |
| 21359 |
|
| 21360 |
/* NW (input) INTEGER */ |
| 21361 |
/* Deflation window size. 1 .LE. NW .LE. (KBOT-KTOP+1). */ |
| 21362 |
|
| 21363 |
/* H (input/output) DOUBLE PRECISION array, dimension (LDH,N) */ |
| 21364 |
/* On input the initial N-by-N section of H stores the */ |
| 21365 |
/* Hessenberg matrix undergoing aggressive early deflation. */ |
| 21366 |
/* On output H has been transformed by an orthogonal */ |
| 21367 |
/* similarity transformation, perturbed, and the returned */ |
| 21368 |
/* to Hessenberg form that (it is to be hoped) has some */ |
| 21369 |
/* zero subdiagonal entries. */ |
| 21370 |
|
| 21371 |
/* LDH (input) integer */ |
| 21372 |
/* Leading dimension of H just as declared in the calling */ |
| 21373 |
/* subroutine. N .LE. LDH */ |
| 21374 |
|
| 21375 |
/* ILOZ (input) INTEGER */ |
| 21376 |
/* IHIZ (input) INTEGER */ |
| 21377 |
/* Specify the rows of Z to which transformations must be */ |
| 21378 |
/* applied if WANTZ is .TRUE.. 1 .LE. ILOZ .LE. IHIZ .LE. N. */ |
| 21379 |
|
| 21380 |
/* Z (input/output) DOUBLE PRECISION array, dimension (LDZ,N) */ |
| 21381 |
/* IF WANTZ is .TRUE., then on output, the orthogonal */ |
| 21382 |
/* similarity transformation mentioned above has been */ |
| 21383 |
/* accumulated into Z(ILOZ:IHIZ,ILO:IHI) from the right. */ |
| 21384 |
/* If WANTZ is .FALSE., then Z is unreferenced. */ |
| 21385 |
|
| 21386 |
/* LDZ (input) integer */ |
| 21387 |
/* The leading dimension of Z just as declared in the */ |
| 21388 |
/* calling subroutine. 1 .LE. LDZ. */ |
| 21389 |
|
| 21390 |
/* NS (output) integer */ |
| 21391 |
/* The number of unconverged (ie approximate) eigenvalues */ |
| 21392 |
/* returned in SR and SI that may be used as shifts by the */ |
| 21393 |
/* calling subroutine. */ |
| 21394 |
|
| 21395 |
/* ND (output) integer */ |
| 21396 |
/* The number of converged eigenvalues uncovered by this */ |
| 21397 |
/* subroutine. */ |
| 21398 |
|
| 21399 |
/* SR (output) DOUBLE PRECISION array, dimension KBOT */ |
| 21400 |
/* SI (output) DOUBLE PRECISION array, dimension KBOT */ |
| 21401 |
/* On output, the real and imaginary parts of approximate */ |
| 21402 |
/* eigenvalues that may be used for shifts are stored in */ |
| 21403 |
/* SR(KBOT-ND-NS+1) through SR(KBOT-ND) and */ |
| 21404 |
/* SI(KBOT-ND-NS+1) through SI(KBOT-ND), respectively. */ |
| 21405 |
/* The real and imaginary parts of converged eigenvalues */ |
| 21406 |
/* are stored in SR(KBOT-ND+1) through SR(KBOT) and */ |
| 21407 |
/* SI(KBOT-ND+1) through SI(KBOT), respectively. */ |
| 21408 |
|
| 21409 |
/* V (workspace) DOUBLE PRECISION array, dimension (LDV,NW) */ |
| 21410 |
/* An NW-by-NW work array. */ |
| 21411 |
|
| 21412 |
/* LDV (input) integer scalar */ |
| 21413 |
/* The leading dimension of V just as declared in the */ |
| 21414 |
/* calling subroutine. NW .LE. LDV */ |
| 21415 |
|
| 21416 |
/* NH (input) integer scalar */ |
| 21417 |
/* The number of columns of T. NH.GE.NW. */ |
| 21418 |
|
| 21419 |
/* T (workspace) DOUBLE PRECISION array, dimension (LDT,NW) */ |
| 21420 |
|
| 21421 |
/* LDT (input) integer */ |
| 21422 |
/* The leading dimension of T just as declared in the */ |
| 21423 |
/* calling subroutine. NW .LE. LDT */ |
| 21424 |
|
| 21425 |
/* NV (input) integer */ |
| 21426 |
/* The number of rows of work array WV available for */ |
| 21427 |
/* workspace. NV.GE.NW. */ |
| 21428 |
|
| 21429 |
/* WV (workspace) DOUBLE PRECISION array, dimension (LDWV,NW) */ |
| 21430 |
|
| 21431 |
/* LDWV (input) integer */ |
| 21432 |
/* The leading dimension of W just as declared in the */ |
| 21433 |
/* calling subroutine. NW .LE. LDV */ |
| 21434 |
|
| 21435 |
/* WORK (workspace) DOUBLE PRECISION array, dimension LWORK. */ |
| 21436 |
/* On exit, WORK(1) is set to an estimate of the optimal value */ |
| 21437 |
/* of LWORK for the given values of N, NW, KTOP and KBOT. */ |
| 21438 |
|
| 21439 |
/* LWORK (input) integer */ |
| 21440 |
/* The dimension of the work array WORK. LWORK = 2*NW */ |
| 21441 |
/* suffices, but greater efficiency may result from larger */ |
| 21442 |
/* values of LWORK. */ |
| 21443 |
|
| 21444 |
/* If LWORK = -1, then a workspace query is assumed; DLAQR2 */ |
| 21445 |
/* only estimates the optimal workspace size for the given */ |
| 21446 |
/* values of N, NW, KTOP and KBOT. The estimate is returned */ |
| 21447 |
/* in WORK(1). No error message related to LWORK is issued */ |
| 21448 |
/* by XERBLA. Neither H nor Z are accessed. */ |
| 21449 |
|
| 21450 |
/* ================================================================ */ |
| 21451 |
/* Based on contributions by */ |
| 21452 |
/* Karen Braman and Ralph Byers, Department of Mathematics, */ |
| 21453 |
/* University of Kansas, USA */ |
| 21454 |
|
| 21455 |
/* ================================================================ */ |
| 21456 |
/* .. Parameters .. */ |
| 21457 |
/* .. */ |
| 21458 |
/* .. Local Scalars .. */ |
| 21459 |
/* .. */ |
| 21460 |
/* .. External Functions .. */ |
| 21461 |
/* .. */ |
| 21462 |
/* .. External Subroutines .. */ |
| 21463 |
/* .. */ |
| 21464 |
/* .. Intrinsic Functions .. */ |
| 21465 |
/* .. */ |
| 21466 |
/* .. Executable Statements .. */ |
| 21467 |
|
| 21468 |
/* ==== Estimate optimal workspace. ==== */ |
| 21469 |
|
| 21470 |
/* Parameter adjustments */ |
| 21471 |
h_dim1 = *ldh; |
| 21472 |
h_offset = 1 + h_dim1; |
| 21473 |
h__ -= h_offset; |
| 21474 |
z_dim1 = *ldz; |
| 21475 |
z_offset = 1 + z_dim1; |
| 21476 |
z__ -= z_offset; |
| 21477 |
--sr; |
| 21478 |
--si; |
| 21479 |
v_dim1 = *ldv; |
| 21480 |
v_offset = 1 + v_dim1; |
| 21481 |
v -= v_offset; |
| 21482 |
t_dim1 = *ldt; |
| 21483 |
t_offset = 1 + t_dim1; |
| 21484 |
t -= t_offset; |
| 21485 |
wv_dim1 = *ldwv; |
| 21486 |
wv_offset = 1 + wv_dim1; |
| 21487 |
wv -= wv_offset; |
| 21488 |
--work; |
| 21489 |
|
| 21490 |
/* Function Body */ |
| 21491 |
/* Computing MIN */ |
| 21492 |
i__1 = *nw, i__2 = *kbot - *ktop + 1; |
| 21493 |
jw = std::min(i__1,i__2); |
| 21494 |
if (jw <= 2) { |
| 21495 |
lwkopt = 1; |
| 21496 |
} else { |
| 21497 |
|
| 21498 |
/* ==== Workspace query call to DGEHRD ==== */ |
| 21499 |
|
| 21500 |
i__1 = jw - 1; |
| 21501 |
dgehrd_(&jw, &c__1, &i__1, &t[t_offset], ldt, &work[1], &work[1], & |
| 21502 |
c_n1, &info); |
| 21503 |
lwk1 = (integer) work[1]; |
| 21504 |
|
| 21505 |
/* ==== Workspace query call to DORMHR ==== */ |
| 21506 |
|
| 21507 |
i__1 = jw - 1; |
| 21508 |
dormhr_("R", "N", &jw, &jw, &c__1, &i__1, &t[t_offset], ldt, &work[1], |
| 21509 |
&v[v_offset], ldv, &work[1], &c_n1, &info); |
| 21510 |
lwk2 = (integer) work[1]; |
| 21511 |
|
| 21512 |
/* ==== Optimal workspace ==== */ |
| 21513 |
|
| 21514 |
lwkopt = jw + std::max(lwk1,lwk2); |
| 21515 |
} |
| 21516 |
|
| 21517 |
/* ==== Quick return in case of workspace query. ==== */ |
| 21518 |
|
| 21519 |
if (*lwork == -1) { |
| 21520 |
work[1] = (double) lwkopt; |
| 21521 |
return 0; |
| 21522 |
} |
| 21523 |
|
| 21524 |
/* ==== Nothing to do ... */ |
| 21525 |
/* ... for an empty active block ... ==== */ |
| 21526 |
*ns = 0; |
| 21527 |
*nd = 0; |
| 21528 |
work[1] = 1.; |
| 21529 |
if (*ktop > *kbot) { |
| 21530 |
return 0; |
| 21531 |
} |
| 21532 |
/* ... nor for an empty deflation window. ==== */ |
| 21533 |
if (*nw < 1) { |
| 21534 |
return 0; |
| 21535 |
} |
| 21536 |
|
| 21537 |
/* ==== Machine constants ==== */ |
| 21538 |
|
| 21539 |
safmin = dlamch_("SAFE MINIMUM"); |
| 21540 |
safmax = 1. / safmin; |
| 21541 |
dlabad_(&safmin, &safmax); |
| 21542 |
ulp = dlamch_("PRECISION"); |
| 21543 |
smlnum = safmin * ((double) (*n) / ulp); |
| 21544 |
|
| 21545 |
/* ==== Setup deflation window ==== */ |
| 21546 |
|
| 21547 |
/* Computing MIN */ |
| 21548 |
i__1 = *nw, i__2 = *kbot - *ktop + 1; |
| 21549 |
jw = std::min(i__1,i__2); |
| 21550 |
kwtop = *kbot - jw + 1; |
| 21551 |
if (kwtop == *ktop) { |
| 21552 |
s = 0.; |
| 21553 |
} else { |
| 21554 |
s = h__[kwtop + (kwtop - 1) * h_dim1]; |
| 21555 |
} |
| 21556 |
|
| 21557 |
if (*kbot == kwtop) { |
| 21558 |
|
| 21559 |
/* ==== 1-by-1 deflation window: not much to do ==== */ |
| 21560 |
|
| 21561 |
sr[kwtop] = h__[kwtop + kwtop * h_dim1]; |
| 21562 |
si[kwtop] = 0.; |
| 21563 |
*ns = 1; |
| 21564 |
*nd = 0; |
| 21565 |
/* Computing MAX */ |
| 21566 |
d__2 = smlnum, d__3 = ulp * (d__1 = h__[kwtop + kwtop * h_dim1], abs( |
| 21567 |
d__1)); |
| 21568 |
if (abs(s) <= std::max(d__2,d__3)) { |
| 21569 |
*ns = 0; |
| 21570 |
*nd = 1; |
| 21571 |
if (kwtop > *ktop) { |
| 21572 |
h__[kwtop + (kwtop - 1) * h_dim1] = 0.; |
| 21573 |
} |
| 21574 |
} |
| 21575 |
work[1] = 1.; |
| 21576 |
return 0; |
| 21577 |
} |
| 21578 |
|
| 21579 |
/* ==== Convert to spike-triangular form. (In case of a */ |
| 21580 |
/* . rare QR failure, this routine continues to do */ |
| 21581 |
/* . aggressive early deflation using that part of */ |
| 21582 |
/* . the deflation window that converged using INFQR */ |
| 21583 |
/* . here and there to keep track.) ==== */ |
| 21584 |
|
| 21585 |
dlacpy_("U", &jw, &jw, &h__[kwtop + kwtop * h_dim1], ldh, &t[t_offset], |
| 21586 |
ldt); |
| 21587 |
i__1 = jw - 1; |
| 21588 |
i__2 = *ldh + 1; |
| 21589 |
i__3 = *ldt + 1; |
| 21590 |
dcopy_(&i__1, &h__[kwtop + 1 + kwtop * h_dim1], &i__2, &t[t_dim1 + 2], & |
| 21591 |
i__3); |
| 21592 |
|
| 21593 |
dlaset_("A", &jw, &jw, &c_b12, &c_b13, &v[v_offset], ldv); |
| 21594 |
dlahqr_(&c_true, &c_true, &jw, &c__1, &jw, &t[t_offset], ldt, &sr[kwtop], |
| 21595 |
&si[kwtop], &c__1, &jw, &v[v_offset], ldv, &infqr); |
| 21596 |
|
| 21597 |
/* ==== DTREXC needs a clean margin near the diagonal ==== */ |
| 21598 |
|
| 21599 |
i__1 = jw - 3; |
| 21600 |
for (j = 1; j <= i__1; ++j) { |
| 21601 |
t[j + 2 + j * t_dim1] = 0.; |
| 21602 |
t[j + 3 + j * t_dim1] = 0.; |
| 21603 |
/* L10: */ |
| 21604 |
} |
| 21605 |
if (jw > 2) { |
| 21606 |
t[jw + (jw - 2) * t_dim1] = 0.; |
| 21607 |
} |
| 21608 |
|
| 21609 |
/* ==== Deflation detection loop ==== */ |
| 21610 |
|
| 21611 |
*ns = jw; |
| 21612 |
ilst = infqr + 1; |
| 21613 |
L20: |
| 21614 |
if (ilst <= *ns) { |
| 21615 |
if (*ns == 1) { |
| 21616 |
bulge = false; |
| 21617 |
} else { |
| 21618 |
bulge = t[*ns + (*ns - 1) * t_dim1] != 0.; |
| 21619 |
} |
| 21620 |
|
| 21621 |
/* ==== Small spike tip test for deflation ==== */ |
| 21622 |
|
| 21623 |
if (! bulge) { |
| 21624 |
|
| 21625 |
/* ==== Real eigenvalue ==== */ |
| 21626 |
|
| 21627 |
foo = (d__1 = t[*ns + *ns * t_dim1], abs(d__1)); |
| 21628 |
if (foo == 0.) { |
| 21629 |
foo = abs(s); |
| 21630 |
} |
| 21631 |
/* Computing MAX */ |
| 21632 |
d__2 = smlnum, d__3 = ulp * foo; |
| 21633 |
if ((d__1 = s * v[*ns * v_dim1 + 1], abs(d__1)) <= std::max(d__2,d__3)) |
| 21634 |
{ |
| 21635 |
|
| 21636 |
/* ==== Deflatable ==== */ |
| 21637 |
|
| 21638 |
--(*ns); |
| 21639 |
} else { |
| 21640 |
|
| 21641 |
/* ==== Undeflatable. Move it up out of the way. */ |
| 21642 |
/* . (DTREXC can not fail in this case.) ==== */ |
| 21643 |
|
| 21644 |
ifst = *ns; |
| 21645 |
dtrexc_("V", &jw, &t[t_offset], ldt, &v[v_offset], ldv, &ifst, |
| 21646 |
&ilst, &work[1], &info); |
| 21647 |
++ilst; |
| 21648 |
} |
| 21649 |
} else { |
| 21650 |
|
| 21651 |
/* ==== Complex conjugate pair ==== */ |
| 21652 |
|
| 21653 |
foo = (d__3 = t[*ns + *ns * t_dim1], abs(d__3)) + sqrt((d__1 = t[* |
| 21654 |
ns + (*ns - 1) * t_dim1], abs(d__1))) * sqrt((d__2 = t[* |
| 21655 |
ns - 1 + *ns * t_dim1], abs(d__2))); |
| 21656 |
if (foo == 0.) { |
| 21657 |
foo = abs(s); |
| 21658 |
} |
| 21659 |
/* Computing MAX */ |
| 21660 |
d__3 = (d__1 = s * v[*ns * v_dim1 + 1], abs(d__1)), d__4 = (d__2 = |
| 21661 |
s * v[(*ns - 1) * v_dim1 + 1], abs(d__2)); |
| 21662 |
/* Computing MAX */ |
| 21663 |
d__5 = smlnum, d__6 = ulp * foo; |
| 21664 |
if (std::max(d__3,d__4) <= std::max(d__5,d__6)) { |
| 21665 |
|
| 21666 |
/* ==== Deflatable ==== */ |
| 21667 |
|
| 21668 |
*ns += -2; |
| 21669 |
} else { |
| 21670 |
|
| 21671 |
/* ==== Undflatable. Move them up out of the way. */ |
| 21672 |
/* . Fortunately, DTREXC does the right thing with */ |
| 21673 |
/* . ILST in case of a rare exchange failure. ==== */ |
| 21674 |
|
| 21675 |
ifst = *ns; |
| 21676 |
dtrexc_("V", &jw, &t[t_offset], ldt, &v[v_offset], ldv, &ifst, |
| 21677 |
&ilst, &work[1], &info); |
| 21678 |
ilst += 2; |
| 21679 |
} |
| 21680 |
} |
| 21681 |
|
| 21682 |
/* ==== End deflation detection loop ==== */ |
| 21683 |
|
| 21684 |
goto L20; |
| 21685 |
} |
| 21686 |
|
| 21687 |
/* ==== Return to Hessenberg form ==== */ |
| 21688 |
|
| 21689 |
if (*ns == 0) { |
| 21690 |
s = 0.; |
| 21691 |
} |
| 21692 |
|
| 21693 |
if (*ns < jw) { |
| 21694 |
|
| 21695 |
/* ==== sorting diagonal blocks of T improves accuracy for */ |
| 21696 |
/* . graded matrices. Bubble sort deals well with */ |
| 21697 |
/* . exchange failures. ==== */ |
| 21698 |
|
| 21699 |
sorted = false; |
| 21700 |
i__ = *ns + 1; |
| 21701 |
L30: |
| 21702 |
if (sorted) { |
| 21703 |
goto L50; |
| 21704 |
} |
| 21705 |
sorted = true; |
| 21706 |
|
| 21707 |
kend = i__ - 1; |
| 21708 |
i__ = infqr + 1; |
| 21709 |
if (i__ == *ns) { |
| 21710 |
k = i__ + 1; |
| 21711 |
} else if (t[i__ + 1 + i__ * t_dim1] == 0.) { |
| 21712 |
k = i__ + 1; |
| 21713 |
} else { |
| 21714 |
k = i__ + 2; |
| 21715 |
} |
| 21716 |
L40: |
| 21717 |
if (k <= kend) { |
| 21718 |
if (k == i__ + 1) { |
| 21719 |
evi = (d__1 = t[i__ + i__ * t_dim1], abs(d__1)); |
| 21720 |
} else { |
| 21721 |
evi = (d__3 = t[i__ + i__ * t_dim1], abs(d__3)) + sqrt((d__1 = |
| 21722 |
t[i__ + 1 + i__ * t_dim1], abs(d__1))) * sqrt((d__2 = |
| 21723 |
t[i__ + (i__ + 1) * t_dim1], abs(d__2))); |
| 21724 |
} |
| 21725 |
|
| 21726 |
if (k == kend) { |
| 21727 |
evk = (d__1 = t[k + k * t_dim1], abs(d__1)); |
| 21728 |
} else if (t[k + 1 + k * t_dim1] == 0.) { |
| 21729 |
evk = (d__1 = t[k + k * t_dim1], abs(d__1)); |
| 21730 |
} else { |
| 21731 |
evk = (d__3 = t[k + k * t_dim1], abs(d__3)) + sqrt((d__1 = t[ |
| 21732 |
k + 1 + k * t_dim1], abs(d__1))) * sqrt((d__2 = t[k + |
| 21733 |
(k + 1) * t_dim1], abs(d__2))); |
| 21734 |
} |
| 21735 |
|
| 21736 |
if (evi >= evk) { |
| 21737 |
i__ = k; |
| 21738 |
} else { |
| 21739 |
sorted = false; |
| 21740 |
ifst = i__; |
| 21741 |
ilst = k; |
| 21742 |
dtrexc_("V", &jw, &t[t_offset], ldt, &v[v_offset], ldv, &ifst, |
| 21743 |
&ilst, &work[1], &info); |
| 21744 |
if (info == 0) { |
| 21745 |
i__ = ilst; |
| 21746 |
} else { |
| 21747 |
i__ = k; |
| 21748 |
} |
| 21749 |
} |
| 21750 |
if (i__ == kend) { |
| 21751 |
k = i__ + 1; |
| 21752 |
} else if (t[i__ + 1 + i__ * t_dim1] == 0.) { |
| 21753 |
k = i__ + 1; |
| 21754 |
} else { |
| 21755 |
k = i__ + 2; |
| 21756 |
} |
| 21757 |
goto L40; |
| 21758 |
} |
| 21759 |
goto L30; |
| 21760 |
L50: |
| 21761 |
; |
| 21762 |
} |
| 21763 |
|
| 21764 |
/* ==== Restore shift/eigenvalue array from T ==== */ |
| 21765 |
|
| 21766 |
i__ = jw; |
| 21767 |
L60: |
| 21768 |
if (i__ >= infqr + 1) { |
| 21769 |
if (i__ == infqr + 1) { |
| 21770 |
sr[kwtop + i__ - 1] = t[i__ + i__ * t_dim1]; |
| 21771 |
si[kwtop + i__ - 1] = 0.; |
| 21772 |
--i__; |
| 21773 |
} else if (t[i__ + (i__ - 1) * t_dim1] == 0.) { |
| 21774 |
sr[kwtop + i__ - 1] = t[i__ + i__ * t_dim1]; |
| 21775 |
si[kwtop + i__ - 1] = 0.; |
| 21776 |
--i__; |
| 21777 |
} else { |
| 21778 |
aa = t[i__ - 1 + (i__ - 1) * t_dim1]; |
| 21779 |
cc = t[i__ + (i__ - 1) * t_dim1]; |
| 21780 |
bb = t[i__ - 1 + i__ * t_dim1]; |
| 21781 |
dd = t[i__ + i__ * t_dim1]; |
| 21782 |
dlanv2_(&aa, &bb, &cc, &dd, &sr[kwtop + i__ - 2], &si[kwtop + i__ |
| 21783 |
- 2], &sr[kwtop + i__ - 1], &si[kwtop + i__ - 1], &cs, & |
| 21784 |
sn); |
| 21785 |
i__ += -2; |
| 21786 |
} |
| 21787 |
goto L60; |
| 21788 |
} |
| 21789 |
|
| 21790 |
if (*ns < jw || s == 0.) { |
| 21791 |
if (*ns > 1 && s != 0.) { |
| 21792 |
|
| 21793 |
/* ==== Reflect spike back into lower triangle ==== */ |
| 21794 |
|
| 21795 |
dcopy_(ns, &v[v_offset], ldv, &work[1], &c__1); |
| 21796 |
beta = work[1]; |
| 21797 |
dlarfg_(ns, &beta, &work[2], &c__1, &tau); |
| 21798 |
work[1] = 1.; |
| 21799 |
|
| 21800 |
i__1 = jw - 2; |
| 21801 |
i__2 = jw - 2; |
| 21802 |
dlaset_("L", &i__1, &i__2, &c_b12, &c_b12, &t[t_dim1 + 3], ldt); |
| 21803 |
|
| 21804 |
dlarf_("L", ns, &jw, &work[1], &c__1, &tau, &t[t_offset], ldt, & |
| 21805 |
work[jw + 1]); |
| 21806 |
dlarf_("R", ns, ns, &work[1], &c__1, &tau, &t[t_offset], ldt, & |
| 21807 |
work[jw + 1]); |
| 21808 |
dlarf_("R", &jw, ns, &work[1], &c__1, &tau, &v[v_offset], ldv, & |
| 21809 |
work[jw + 1]); |
| 21810 |
|
| 21811 |
i__1 = *lwork - jw; |
| 21812 |
dgehrd_(&jw, &c__1, ns, &t[t_offset], ldt, &work[1], &work[jw + 1] |
| 21813 |
, &i__1, &info); |
| 21814 |
} |
| 21815 |
|
| 21816 |
/* ==== Copy updated reduced window into place ==== */ |
| 21817 |
|
| 21818 |
if (kwtop > 1) { |
| 21819 |
h__[kwtop + (kwtop - 1) * h_dim1] = s * v[v_dim1 + 1]; |
| 21820 |
} |
| 21821 |
dlacpy_("U", &jw, &jw, &t[t_offset], ldt, &h__[kwtop + kwtop * h_dim1] |
| 21822 |
, ldh); |
| 21823 |
i__1 = jw - 1; |
| 21824 |
i__2 = *ldt + 1; |
| 21825 |
i__3 = *ldh + 1; |
| 21826 |
dcopy_(&i__1, &t[t_dim1 + 2], &i__2, &h__[kwtop + 1 + kwtop * h_dim1], |
| 21827 |
&i__3); |
| 21828 |
|
| 21829 |
/* ==== Accumulate orthogonal matrix in order update */ |
| 21830 |
/* . H and Z, if requested. ==== */ |
| 21831 |
|
| 21832 |
if (*ns > 1 && s != 0.) { |
| 21833 |
i__1 = *lwork - jw; |
| 21834 |
dormhr_("R", "N", &jw, ns, &c__1, ns, &t[t_offset], ldt, &work[1], |
| 21835 |
&v[v_offset], ldv, &work[jw + 1], &i__1, &info); |
| 21836 |
} |
| 21837 |
|
| 21838 |
/* ==== Update vertical slab in H ==== */ |
| 21839 |
|
| 21840 |
if (*wantt) { |
| 21841 |
ltop = 1; |
| 21842 |
} else { |
| 21843 |
ltop = *ktop; |
| 21844 |
} |
| 21845 |
i__1 = kwtop - 1; |
| 21846 |
i__2 = *nv; |
| 21847 |
for (krow = ltop; i__2 < 0 ? krow >= i__1 : krow <= i__1; krow += |
| 21848 |
i__2) { |
| 21849 |
/* Computing MIN */ |
| 21850 |
i__3 = *nv, i__4 = kwtop - krow; |
| 21851 |
kln = std::min(i__3,i__4); |
| 21852 |
dgemm_("N", "N", &kln, &jw, &jw, &c_b13, &h__[krow + kwtop * |
| 21853 |
h_dim1], ldh, &v[v_offset], ldv, &c_b12, &wv[wv_offset], |
| 21854 |
ldwv); |
| 21855 |
dlacpy_("A", &kln, &jw, &wv[wv_offset], ldwv, &h__[krow + kwtop * |
| 21856 |
h_dim1], ldh); |
| 21857 |
/* L70: */ |
| 21858 |
} |
| 21859 |
|
| 21860 |
/* ==== Update horizontal slab in H ==== */ |
| 21861 |
|
| 21862 |
if (*wantt) { |
| 21863 |
i__2 = *n; |
| 21864 |
i__1 = *nh; |
| 21865 |
for (kcol = *kbot + 1; i__1 < 0 ? kcol >= i__2 : kcol <= i__2; |
| 21866 |
kcol += i__1) { |
| 21867 |
/* Computing MIN */ |
| 21868 |
i__3 = *nh, i__4 = *n - kcol + 1; |
| 21869 |
kln = std::min(i__3,i__4); |
| 21870 |
dgemm_("C", "N", &jw, &kln, &jw, &c_b13, &v[v_offset], ldv, & |
| 21871 |
h__[kwtop + kcol * h_dim1], ldh, &c_b12, &t[t_offset], |
| 21872 |
ldt); |
| 21873 |
dlacpy_("A", &jw, &kln, &t[t_offset], ldt, &h__[kwtop + kcol * |
| 21874 |
h_dim1], ldh); |
| 21875 |
/* L80: */ |
| 21876 |
} |
| 21877 |
} |
| 21878 |
|
| 21879 |
/* ==== Update vertical slab in Z ==== */ |
| 21880 |
|
| 21881 |
if (*wantz) { |
| 21882 |
i__1 = *ihiz; |
| 21883 |
i__2 = *nv; |
| 21884 |
for (krow = *iloz; i__2 < 0 ? krow >= i__1 : krow <= i__1; krow += |
| 21885 |
i__2) { |
| 21886 |
/* Computing MIN */ |
| 21887 |
i__3 = *nv, i__4 = *ihiz - krow + 1; |
| 21888 |
kln = std::min(i__3,i__4); |
| 21889 |
dgemm_("N", "N", &kln, &jw, &jw, &c_b13, &z__[krow + kwtop * |
| 21890 |
z_dim1], ldz, &v[v_offset], ldv, &c_b12, &wv[ |
| 21891 |
wv_offset], ldwv); |
| 21892 |
dlacpy_("A", &kln, &jw, &wv[wv_offset], ldwv, &z__[krow + |
| 21893 |
kwtop * z_dim1], ldz); |
| 21894 |
/* L90: */ |
| 21895 |
} |
| 21896 |
} |
| 21897 |
} |
| 21898 |
|
| 21899 |
/* ==== Return the number of deflations ... ==== */ |
| 21900 |
|
| 21901 |
*nd = jw - *ns; |
| 21902 |
|
| 21903 |
/* ==== ... and the number of shifts. (Subtracting */ |
| 21904 |
/* . INFQR from the spike length takes care */ |
| 21905 |
/* . of the case of a rare QR failure while */ |
| 21906 |
/* . calculating eigenvalues of the deflation */ |
| 21907 |
/* . window.) ==== */ |
| 21908 |
|
| 21909 |
*ns -= infqr; |
| 21910 |
|
| 21911 |
/* ==== Return optimal workspace. ==== */ |
| 21912 |
|
| 21913 |
work[1] = (double) lwkopt; |
| 21914 |
|
| 21915 |
/* ==== End of DLAQR2 ==== */ |
| 21916 |
|
| 21917 |
return 0; |
| 21918 |
} /* dlaqr2_ */ |
| 21919 |
|
| 21920 |
/* Subroutine */ int dlaqr3_(bool *wantt, bool *wantz, integer *n, integer *ktop, integer *kbot, integer *nw, |
| 21921 |
double *h__, integer *ldh, integer *iloz, integer *ihiz, double *z__, integer *ldz, |
| 21922 |
integer *ns, integer *nd, double *sr, double *si, double *v, integer *ldv, integer *nh, |
| 21923 |
double *t, integer *ldt, integer *nv, double *wv, integer *ldwv, double *work, integer *lwork) |
| 21924 |
{ |
| 21925 |
/* Table of constant values */ |
| 21926 |
static integer c__1 = 1; |
| 21927 |
static integer c_n1 = -1; |
| 21928 |
static bool c_true = true; |
| 21929 |
static double c_b17 = 0.; |
| 21930 |
static double c_b18 = 1.; |
| 21931 |
static integer c__12 = 12; |
| 21932 |
|
| 21933 |
/* System generated locals */ |
| 21934 |
integer h_dim1, h_offset, t_dim1, t_offset, v_dim1, v_offset, wv_dim1, |
| 21935 |
wv_offset, z_dim1, z_offset, i__1, i__2, i__3, i__4; |
| 21936 |
double d__1, d__2, d__3, d__4, d__5, d__6; |
| 21937 |
|
| 21938 |
/* Local variables */ |
| 21939 |
integer i__, j, k; |
| 21940 |
double s, aa, bb, cc, dd, cs, sn; |
| 21941 |
integer jw; |
| 21942 |
double evi, evk, foo; |
| 21943 |
integer kln; |
| 21944 |
double tau, ulp; |
| 21945 |
integer lwk1, lwk2, lwk3; |
| 21946 |
double beta; |
| 21947 |
integer kend, kcol, info, nmin, ifst, ilst, ltop, krow; |
| 21948 |
bool bulge; |
| 21949 |
integer infqr, kwtop; |
| 21950 |
double safmin; |
| 21951 |
double safmax; |
| 21952 |
bool sorted; |
| 21953 |
double smlnum; |
| 21954 |
integer lwkopt; |
| 21955 |
|
| 21956 |
|
| 21957 |
/* -- LAPACK auxiliary routine (version 3.2.1) -- */ |
| 21958 |
/* Univ. of Tennessee, Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd.. */ |
| 21959 |
/* -- April 2009 -- */ |
| 21960 |
|
| 21961 |
/* .. Scalar Arguments .. */ |
| 21962 |
/* .. */ |
| 21963 |
/* .. Array Arguments .. */ |
| 21964 |
/* .. */ |
| 21965 |
|
| 21966 |
/* ****************************************************************** */ |
| 21967 |
/* Aggressive early deflation: */ |
| 21968 |
|
| 21969 |
/* This subroutine accepts as input an upper Hessenberg matrix */ |
| 21970 |
/* H and performs an orthogonal similarity transformation */ |
| 21971 |
/* designed to detect and deflate fully converged eigenvalues from */ |
| 21972 |
/* a trailing principal submatrix. On output H has been over- */ |
| 21973 |
/* written by a new Hessenberg matrix that is a perturbation of */ |
| 21974 |
/* an orthogonal similarity transformation of H. It is to be */ |
| 21975 |
/* hoped that the final version of H has many zero subdiagonal */ |
| 21976 |
/* entries. */ |
| 21977 |
|
| 21978 |
/* ****************************************************************** */ |
| 21979 |
/* WANTT (input) LOGICAL */ |
| 21980 |
/* If .TRUE., then the Hessenberg matrix H is fully updated */ |
| 21981 |
/* so that the quasi-triangular Schur factor may be */ |
| 21982 |
/* computed (in cooperation with the calling subroutine). */ |
| 21983 |
/* If .FALSE., then only enough of H is updated to preserve */ |
| 21984 |
/* the eigenvalues. */ |
| 21985 |
|
| 21986 |
/* WANTZ (input) LOGICAL */ |
| 21987 |
/* If .TRUE., then the orthogonal matrix Z is updated so */ |
| 21988 |
/* so that the orthogonal Schur factor may be computed */ |
| 21989 |
/* (in cooperation with the calling subroutine). */ |
| 21990 |
/* If .FALSE., then Z is not referenced. */ |
| 21991 |
|
| 21992 |
/* N (input) INTEGER */ |
| 21993 |
/* The order of the matrix H and (if WANTZ is .TRUE.) the */ |
| 21994 |
/* order of the orthogonal matrix Z. */ |
| 21995 |
|
| 21996 |
/* KTOP (input) INTEGER */ |
| 21997 |
/* It is assumed that either KTOP = 1 or H(KTOP,KTOP-1)=0. */ |
| 21998 |
/* KBOT and KTOP together determine an isolated block */ |
| 21999 |
/* along the diagonal of the Hessenberg matrix. */ |
| 22000 |
|
| 22001 |
/* KBOT (input) INTEGER */ |
| 22002 |
/* It is assumed without a check that either */ |
| 22003 |
/* KBOT = N or H(KBOT+1,KBOT)=0. KBOT and KTOP together */ |
| 22004 |
/* determine an isolated block along the diagonal of the */ |
| 22005 |
/* Hessenberg matrix. */ |
| 22006 |
|
| 22007 |
/* NW (input) INTEGER */ |
| 22008 |
/* Deflation window size. 1 .LE. NW .LE. (KBOT-KTOP+1). */ |
| 22009 |
|
| 22010 |
/* H (input/output) DOUBLE PRECISION array, dimension (LDH,N) */ |
| 22011 |
/* On input the initial N-by-N section of H stores the */ |
| 22012 |
/* Hessenberg matrix undergoing aggressive early deflation. */ |
| 22013 |
/* On output H has been transformed by an orthogonal */ |
| 22014 |
/* similarity transformation, perturbed, and the returned */ |
| 22015 |
/* to Hessenberg form that (it is to be hoped) has some */ |
| 22016 |
/* zero subdiagonal entries. */ |
| 22017 |
|
| 22018 |
/* LDH (input) integer */ |
| 22019 |
/* Leading dimension of H just as declared in the calling */ |
| 22020 |
/* subroutine. N .LE. LDH */ |
| 22021 |
|
| 22022 |
/* ILOZ (input) INTEGER */ |
| 22023 |
/* IHIZ (input) INTEGER */ |
| 22024 |
/* Specify the rows of Z to which transformations must be */ |
| 22025 |
/* applied if WANTZ is .TRUE.. 1 .LE. ILOZ .LE. IHIZ .LE. N. */ |
| 22026 |
|
| 22027 |
/* Z (input/output) DOUBLE PRECISION array, dimension (LDZ,N) */ |
| 22028 |
/* IF WANTZ is .TRUE., then on output, the orthogonal */ |
| 22029 |
/* similarity transformation mentioned above has been */ |
| 22030 |
/* accumulated into Z(ILOZ:IHIZ,ILO:IHI) from the right. */ |
| 22031 |
/* If WANTZ is .FALSE., then Z is unreferenced. */ |
| 22032 |
|
| 22033 |
/* LDZ (input) integer */ |
| 22034 |
/* The leading dimension of Z just as declared in the */ |
| 22035 |
/* calling subroutine. 1 .LE. LDZ. */ |
| 22036 |
|
| 22037 |
/* NS (output) integer */ |
| 22038 |
/* The number of unconverged (ie approximate) eigenvalues */ |
| 22039 |
/* returned in SR and SI that may be used as shifts by the */ |
| 22040 |
/* calling subroutine. */ |
| 22041 |
|
| 22042 |
/* ND (output) integer */ |
| 22043 |
/* The number of converged eigenvalues uncovered by this */ |
| 22044 |
/* subroutine. */ |
| 22045 |
|
| 22046 |
/* SR (output) DOUBLE PRECISION array, dimension KBOT */ |
| 22047 |
/* SI (output) DOUBLE PRECISION array, dimension KBOT */ |
| 22048 |
/* On output, the real and imaginary parts of approximate */ |
| 22049 |
/* eigenvalues that may be used for shifts are stored in */ |
| 22050 |
/* SR(KBOT-ND-NS+1) through SR(KBOT-ND) and */ |
| 22051 |
/* SI(KBOT-ND-NS+1) through SI(KBOT-ND), respectively. */ |
| 22052 |
/* The real and imaginary parts of converged eigenvalues */ |
| 22053 |
/* are stored in SR(KBOT-ND+1) through SR(KBOT) and */ |
| 22054 |
/* SI(KBOT-ND+1) through SI(KBOT), respectively. */ |
| 22055 |
|
| 22056 |
/* V (workspace) DOUBLE PRECISION array, dimension (LDV,NW) */ |
| 22057 |
/* An NW-by-NW work array. */ |
| 22058 |
|
| 22059 |
/* LDV (input) integer scalar */ |
| 22060 |
/* The leading dimension of V just as declared in the */ |
| 22061 |
/* calling subroutine. NW .LE. LDV */ |
| 22062 |
|
| 22063 |
/* NH (input) integer scalar */ |
| 22064 |
/* The number of columns of T. NH.GE.NW. */ |
| 22065 |
|
| 22066 |
/* T (workspace) DOUBLE PRECISION array, dimension (LDT,NW) */ |
| 22067 |
|
| 22068 |
/* LDT (input) integer */ |
| 22069 |
/* The leading dimension of T just as declared in the */ |
| 22070 |
/* calling subroutine. NW .LE. LDT */ |
| 22071 |
|
| 22072 |
/* NV (input) integer */ |
| 22073 |
/* The number of rows of work array WV available for */ |
| 22074 |
/* workspace. NV.GE.NW. */ |
| 22075 |
|
| 22076 |
/* WV (workspace) DOUBLE PRECISION array, dimension (LDWV,NW) */ |
| 22077 |
|
| 22078 |
/* LDWV (input) integer */ |
| 22079 |
/* The leading dimension of W just as declared in the */ |
| 22080 |
/* calling subroutine. NW .LE. LDV */ |
| 22081 |
|
| 22082 |
/* WORK (workspace) DOUBLE PRECISION array, dimension LWORK. */ |
| 22083 |
/* On exit, WORK(1) is set to an estimate of the optimal value */ |
| 22084 |
/* of LWORK for the given values of N, NW, KTOP and KBOT. */ |
| 22085 |
|
| 22086 |
/* LWORK (input) integer */ |
| 22087 |
/* The dimension of the work array WORK. LWORK = 2*NW */ |
| 22088 |
/* suffices, but greater efficiency may result from larger */ |
| 22089 |
/* values of LWORK. */ |
| 22090 |
|
| 22091 |
/* If LWORK = -1, then a workspace query is assumed; DLAQR3 */ |
| 22092 |
/* only estimates the optimal workspace size for the given */ |
| 22093 |
/* values of N, NW, KTOP and KBOT. The estimate is returned */ |
| 22094 |
/* in WORK(1). No error message related to LWORK is issued */ |
| 22095 |
/* by XERBLA. Neither H nor Z are accessed. */ |
| 22096 |
|
| 22097 |
/* ================================================================ */ |
| 22098 |
/* Based on contributions by */ |
| 22099 |
/* Karen Braman and Ralph Byers, Department of Mathematics, */ |
| 22100 |
/* University of Kansas, USA */ |
| 22101 |
|
| 22102 |
/* ================================================================== */ |
| 22103 |
/* .. Parameters .. */ |
| 22104 |
/* .. */ |
| 22105 |
/* .. Local Scalars .. */ |
| 22106 |
/* .. */ |
| 22107 |
/* .. External Functions .. */ |
| 22108 |
/* .. */ |
| 22109 |
/* .. External Subroutines .. */ |
| 22110 |
/* .. */ |
| 22111 |
/* .. Intrinsic Functions .. */ |
| 22112 |
/* .. */ |
| 22113 |
/* .. Executable Statements .. */ |
| 22114 |
|
| 22115 |
/* ==== Estimate optimal workspace. ==== */ |
| 22116 |
|
| 22117 |
/* Parameter adjustments */ |
| 22118 |
h_dim1 = *ldh; |
| 22119 |
h_offset = 1 + h_dim1; |
| 22120 |
h__ -= h_offset; |
| 22121 |
z_dim1 = *ldz; |
| 22122 |
z_offset = 1 + z_dim1; |
| 22123 |
z__ -= z_offset; |
| 22124 |
--sr; |
| 22125 |
--si; |
| 22126 |
v_dim1 = *ldv; |
| 22127 |
v_offset = 1 + v_dim1; |
| 22128 |
v -= v_offset; |
| 22129 |
t_dim1 = *ldt; |
| 22130 |
t_offset = 1 + t_dim1; |
| 22131 |
t -= t_offset; |
| 22132 |
wv_dim1 = *ldwv; |
| 22133 |
wv_offset = 1 + wv_dim1; |
| 22134 |
wv -= wv_offset; |
| 22135 |
--work; |
| 22136 |
|
| 22137 |
/* Function Body */ |
| 22138 |
/* Computing MIN */ |
| 22139 |
i__1 = *nw, i__2 = *kbot - *ktop + 1; |
| 22140 |
jw = std::min(i__1,i__2); |
| 22141 |
if (jw <= 2) { |
| 22142 |
lwkopt = 1; |
| 22143 |
} else { |
| 22144 |
|
| 22145 |
/* ==== Workspace query call to DGEHRD ==== */ |
| 22146 |
|
| 22147 |
i__1 = jw - 1; |
| 22148 |
dgehrd_(&jw, &c__1, &i__1, &t[t_offset], ldt, &work[1], &work[1], & |
| 22149 |
c_n1, &info); |
| 22150 |
lwk1 = (integer) work[1]; |
| 22151 |
|
| 22152 |
/* ==== Workspace query call to DORMHR ==== */ |
| 22153 |
|
| 22154 |
i__1 = jw - 1; |
| 22155 |
dormhr_("R", "N", &jw, &jw, &c__1, &i__1, &t[t_offset], ldt, &work[1], |
| 22156 |
&v[v_offset], ldv, &work[1], &c_n1, &info); |
| 22157 |
lwk2 = (integer) work[1]; |
| 22158 |
|
| 22159 |
/* ==== Workspace query call to DLAQR4 ==== */ |
| 22160 |
|
| 22161 |
dlaqr4_(&c_true, &c_true, &jw, &c__1, &jw, &t[t_offset], ldt, &sr[1], |
| 22162 |
&si[1], &c__1, &jw, &v[v_offset], ldv, &work[1], &c_n1, & |
| 22163 |
infqr); |
| 22164 |
lwk3 = (integer) work[1]; |
| 22165 |
|
| 22166 |
/* ==== Optimal workspace ==== */ |
| 22167 |
|
| 22168 |
/* Computing MAX */ |
| 22169 |
i__1 = jw + std::max(lwk1,lwk2); |
| 22170 |
lwkopt = std::max(i__1,lwk3); |
| 22171 |
} |
| 22172 |
|
| 22173 |
/* ==== Quick return in case of workspace query. ==== */ |
| 22174 |
|
| 22175 |
if (*lwork == -1) { |
| 22176 |
work[1] = (double) lwkopt; |
| 22177 |
return 0; |
| 22178 |
} |
| 22179 |
|
| 22180 |
/* ==== Nothing to do ... */ |
| 22181 |
/* ... for an empty active block ... ==== */ |
| 22182 |
*ns = 0; |
| 22183 |
*nd = 0; |
| 22184 |
work[1] = 1.; |
| 22185 |
if (*ktop > *kbot) { |
| 22186 |
return 0; |
| 22187 |
} |
| 22188 |
/* ... nor for an empty deflation window. ==== */ |
| 22189 |
if (*nw < 1) { |
| 22190 |
return 0; |
| 22191 |
} |
| 22192 |
|
| 22193 |
/* ==== Machine constants ==== */ |
| 22194 |
|
| 22195 |
safmin = dlamch_("SAFE MINIMUM"); |
| 22196 |
safmax = 1. / safmin; |
| 22197 |
dlabad_(&safmin, &safmax); |
| 22198 |
ulp = dlamch_("PRECISION"); |
| 22199 |
smlnum = safmin * ((double) (*n) / ulp); |
| 22200 |
|
| 22201 |
/* ==== Setup deflation window ==== */ |
| 22202 |
|
| 22203 |
/* Computing MIN */ |
| 22204 |
i__1 = *nw, i__2 = *kbot - *ktop + 1; |
| 22205 |
jw = std::min(i__1,i__2); |
| 22206 |
kwtop = *kbot - jw + 1; |
| 22207 |
if (kwtop == *ktop) { |
| 22208 |
s = 0.; |
| 22209 |
} else { |
| 22210 |
s = h__[kwtop + (kwtop - 1) * h_dim1]; |
| 22211 |
} |
| 22212 |
|
| 22213 |
if (*kbot == kwtop) { |
| 22214 |
|
| 22215 |
/* ==== 1-by-1 deflation window: not much to do ==== */ |
| 22216 |
|
| 22217 |
sr[kwtop] = h__[kwtop + kwtop * h_dim1]; |
| 22218 |
si[kwtop] = 0.; |
| 22219 |
*ns = 1; |
| 22220 |
*nd = 0; |
| 22221 |
/* Computing MAX */ |
| 22222 |
d__2 = smlnum, d__3 = ulp * (d__1 = h__[kwtop + kwtop * h_dim1], abs( |
| 22223 |
d__1)); |
| 22224 |
if (abs(s) <= std::max(d__2,d__3)) { |
| 22225 |
*ns = 0; |
| 22226 |
*nd = 1; |
| 22227 |
if (kwtop > *ktop) { |
| 22228 |
h__[kwtop + (kwtop - 1) * h_dim1] = 0.; |
| 22229 |
} |
| 22230 |
} |
| 22231 |
work[1] = 1.; |
| 22232 |
return 0; |
| 22233 |
} |
| 22234 |
|
| 22235 |
/* ==== Convert to spike-triangular form. (In case of a */ |
| 22236 |
/* . rare QR failure, this routine continues to do */ |
| 22237 |
/* . aggressive early deflation using that part of */ |
| 22238 |
/* . the deflation window that converged using INFQR */ |
| 22239 |
/* . here and there to keep track.) ==== */ |
| 22240 |
|
| 22241 |
dlacpy_("U", &jw, &jw, &h__[kwtop + kwtop * h_dim1], ldh, &t[t_offset], |
| 22242 |
ldt); |
| 22243 |
i__1 = jw - 1; |
| 22244 |
i__2 = *ldh + 1; |
| 22245 |
i__3 = *ldt + 1; |
| 22246 |
dcopy_(&i__1, &h__[kwtop + 1 + kwtop * h_dim1], &i__2, &t[t_dim1 + 2], & |
| 22247 |
i__3); |
| 22248 |
|
| 22249 |
dlaset_("A", &jw, &jw, &c_b17, &c_b18, &v[v_offset], ldv); |
| 22250 |
nmin = ilaenv_(&c__12, "DLAQR3", "SV", &jw, &c__1, &jw, lwork); |
| 22251 |
if (jw > nmin) { |
| 22252 |
dlaqr4_(&c_true, &c_true, &jw, &c__1, &jw, &t[t_offset], ldt, &sr[ |
| 22253 |
kwtop], &si[kwtop], &c__1, &jw, &v[v_offset], ldv, &work[1], |
| 22254 |
lwork, &infqr); |
| 22255 |
} else { |
| 22256 |
dlahqr_(&c_true, &c_true, &jw, &c__1, &jw, &t[t_offset], ldt, &sr[ |
| 22257 |
kwtop], &si[kwtop], &c__1, &jw, &v[v_offset], ldv, &infqr); |
| 22258 |
} |
| 22259 |
|
| 22260 |
/* ==== DTREXC needs a clean margin near the diagonal ==== */ |
| 22261 |
|
| 22262 |
i__1 = jw - 3; |
| 22263 |
for (j = 1; j <= i__1; ++j) { |
| 22264 |
t[j + 2 + j * t_dim1] = 0.; |
| 22265 |
t[j + 3 + j * t_dim1] = 0.; |
| 22266 |
/* L10: */ |
| 22267 |
} |
| 22268 |
if (jw > 2) { |
| 22269 |
t[jw + (jw - 2) * t_dim1] = 0.; |
| 22270 |
} |
| 22271 |
|
| 22272 |
/* ==== Deflation detection loop ==== */ |
| 22273 |
|
| 22274 |
*ns = jw; |
| 22275 |
ilst = infqr + 1; |
| 22276 |
L20: |
| 22277 |
if (ilst <= *ns) { |
| 22278 |
if (*ns == 1) { |
| 22279 |
bulge = false; |
| 22280 |
} else { |
| 22281 |
bulge = t[*ns + (*ns - 1) * t_dim1] != 0.; |
| 22282 |
} |
| 22283 |
|
| 22284 |
/* ==== Small spike tip test for deflation ==== */ |
| 22285 |
|
| 22286 |
if (! bulge) { |
| 22287 |
|
| 22288 |
/* ==== Real eigenvalue ==== */ |
| 22289 |
|
| 22290 |
foo = (d__1 = t[*ns + *ns * t_dim1], abs(d__1)); |
| 22291 |
if (foo == 0.) { |
| 22292 |
foo = abs(s); |
| 22293 |
} |
| 22294 |
/* Computing MAX */ |
| 22295 |
d__2 = smlnum, d__3 = ulp * foo; |
| 22296 |
if ((d__1 = s * v[*ns * v_dim1 + 1], abs(d__1)) <= std::max(d__2,d__3)) |
| 22297 |
{ |
| 22298 |
|
| 22299 |
/* ==== Deflatable ==== */ |
| 22300 |
|
| 22301 |
--(*ns); |
| 22302 |
} else { |
| 22303 |
|
| 22304 |
/* ==== Undeflatable. Move it up out of the way. */ |
| 22305 |
/* . (DTREXC can not fail in this case.) ==== */ |
| 22306 |
|
| 22307 |
ifst = *ns; |
| 22308 |
dtrexc_("V", &jw, &t[t_offset], ldt, &v[v_offset], ldv, &ifst, |
| 22309 |
&ilst, &work[1], &info); |
| 22310 |
++ilst; |
| 22311 |
} |
| 22312 |
} else { |
| 22313 |
|
| 22314 |
/* ==== Complex conjugate pair ==== */ |
| 22315 |
|
| 22316 |
foo = (d__3 = t[*ns + *ns * t_dim1], abs(d__3)) + sqrt((d__1 = t[* |
| 22317 |
ns + (*ns - 1) * t_dim1], abs(d__1))) * sqrt((d__2 = t[* |
| 22318 |
ns - 1 + *ns * t_dim1], abs(d__2))); |
| 22319 |
if (foo == 0.) { |
| 22320 |
foo = abs(s); |
| 22321 |
} |
| 22322 |
/* Computing MAX */ |
| 22323 |
d__3 = (d__1 = s * v[*ns * v_dim1 + 1], abs(d__1)), d__4 = (d__2 = |
| 22324 |
s * v[(*ns - 1) * v_dim1 + 1], abs(d__2)); |
| 22325 |
/* Computing MAX */ |
| 22326 |
d__5 = smlnum, d__6 = ulp * foo; |
| 22327 |
if (std::max(d__3,d__4) <= std::max(d__5,d__6)) { |
| 22328 |
|
| 22329 |
/* ==== Deflatable ==== */ |
| 22330 |
|
| 22331 |
*ns += -2; |
| 22332 |
} else { |
| 22333 |
|
| 22334 |
/* ==== Undeflatable. Move them up out of the way. */ |
| 22335 |
/* . Fortunately, DTREXC does the right thing with */ |
| 22336 |
/* . ILST in case of a rare exchange failure. ==== */ |
| 22337 |
|
| 22338 |
ifst = *ns; |
| 22339 |
dtrexc_("V", &jw, &t[t_offset], ldt, &v[v_offset], ldv, &ifst, |
| 22340 |
&ilst, &work[1], &info); |
| 22341 |
ilst += 2; |
| 22342 |
} |
| 22343 |
} |
| 22344 |
|
| 22345 |
/* ==== End deflation detection loop ==== */ |
| 22346 |
|
| 22347 |
goto L20; |
| 22348 |
} |
| 22349 |
|
| 22350 |
/* ==== Return to Hessenberg form ==== */ |
| 22351 |
|
| 22352 |
if (*ns == 0) { |
| 22353 |
s = 0.; |
| 22354 |
} |
| 22355 |
|
| 22356 |
if (*ns < jw) { |
| 22357 |
|
| 22358 |
/* ==== sorting diagonal blocks of T improves accuracy for */ |
| 22359 |
/* . graded matrices. Bubble sort deals well with */ |
| 22360 |
/* . exchange failures. ==== */ |
| 22361 |
|
| 22362 |
sorted = false; |
| 22363 |
i__ = *ns + 1; |
| 22364 |
L30: |
| 22365 |
if (sorted) { |
| 22366 |
goto L50; |
| 22367 |
} |
| 22368 |
sorted = true; |
| 22369 |
|
| 22370 |
kend = i__ - 1; |
| 22371 |
i__ = infqr + 1; |
| 22372 |
if (i__ == *ns) { |
| 22373 |
k = i__ + 1; |
| 22374 |
} else if (t[i__ + 1 + i__ * t_dim1] == 0.) { |
| 22375 |
k = i__ + 1; |
| 22376 |
} else { |
| 22377 |
k = i__ + 2; |
| 22378 |
} |
| 22379 |
L40: |
| 22380 |
if (k <= kend) { |
| 22381 |
if (k == i__ + 1) { |
| 22382 |
evi = (d__1 = t[i__ + i__ * t_dim1], abs(d__1)); |
| 22383 |
} else { |
| 22384 |
evi = (d__3 = t[i__ + i__ * t_dim1], abs(d__3)) + sqrt((d__1 = |
| 22385 |
t[i__ + 1 + i__ * t_dim1], abs(d__1))) * sqrt((d__2 = |
| 22386 |
t[i__ + (i__ + 1) * t_dim1], abs(d__2))); |
| 22387 |
} |
| 22388 |
|
| 22389 |
if (k == kend) { |
| 22390 |
evk = (d__1 = t[k + k * t_dim1], abs(d__1)); |
| 22391 |
} else if (t[k + 1 + k * t_dim1] == 0.) { |
| 22392 |
evk = (d__1 = t[k + k * t_dim1], abs(d__1)); |
| 22393 |
} else { |
| 22394 |
evk = (d__3 = t[k + k * t_dim1], abs(d__3)) + sqrt((d__1 = t[ |
| 22395 |
k + 1 + k * t_dim1], abs(d__1))) * sqrt((d__2 = t[k + |
| 22396 |
(k + 1) * t_dim1], abs(d__2))); |
| 22397 |
} |
| 22398 |
|
| 22399 |
if (evi >= evk) { |
| 22400 |
i__ = k; |
| 22401 |
} else { |
| 22402 |
sorted = false; |
| 22403 |
ifst = i__; |
| 22404 |
ilst = k; |
| 22405 |
dtrexc_("V", &jw, &t[t_offset], ldt, &v[v_offset], ldv, &ifst, |
| 22406 |
&ilst, &work[1], &info); |
| 22407 |
if (info == 0) { |
| 22408 |
i__ = ilst; |
| 22409 |
} else { |
| 22410 |
i__ = k; |
| 22411 |
} |
| 22412 |
} |
| 22413 |
if (i__ == kend) { |
| 22414 |
k = i__ + 1; |
| 22415 |
} else if (t[i__ + 1 + i__ * t_dim1] == 0.) { |
| 22416 |
k = i__ + 1; |
| 22417 |
} else { |
| 22418 |
k = i__ + 2; |
| 22419 |
} |
| 22420 |
goto L40; |
| 22421 |
} |
| 22422 |
goto L30; |
| 22423 |
L50: |
| 22424 |
; |
| 22425 |
} |
| 22426 |
|
| 22427 |
/* ==== Restore shift/eigenvalue array from T ==== */ |
| 22428 |
|
| 22429 |
i__ = jw; |
| 22430 |
L60: |
| 22431 |
if (i__ >= infqr + 1) { |
| 22432 |
if (i__ == infqr + 1) { |
| 22433 |
sr[kwtop + i__ - 1] = t[i__ + i__ * t_dim1]; |
| 22434 |
si[kwtop + i__ - 1] = 0.; |
| 22435 |
--i__; |
| 22436 |
} else if (t[i__ + (i__ - 1) * t_dim1] == 0.) { |
| 22437 |
sr[kwtop + i__ - 1] = t[i__ + i__ * t_dim1]; |
| 22438 |
si[kwtop + i__ - 1] = 0.; |
| 22439 |
--i__; |
| 22440 |
} else { |
| 22441 |
aa = t[i__ - 1 + (i__ - 1) * t_dim1]; |
| 22442 |
cc = t[i__ + (i__ - 1) * t_dim1]; |
| 22443 |
bb = t[i__ - 1 + i__ * t_dim1]; |
| 22444 |
dd = t[i__ + i__ * t_dim1]; |
| 22445 |
dlanv2_(&aa, &bb, &cc, &dd, &sr[kwtop + i__ - 2], &si[kwtop + i__ |
| 22446 |
- 2], &sr[kwtop + i__ - 1], &si[kwtop + i__ - 1], &cs, & |
| 22447 |
sn); |
| 22448 |
i__ += -2; |
| 22449 |
} |
| 22450 |
goto L60; |
| 22451 |
} |
| 22452 |
|
| 22453 |
if (*ns < jw || s == 0.) { |
| 22454 |
if (*ns > 1 && s != 0.) { |
| 22455 |
|
| 22456 |
/* ==== Reflect spike back into lower triangle ==== */ |
| 22457 |
|
| 22458 |
dcopy_(ns, &v[v_offset], ldv, &work[1], &c__1); |
| 22459 |
beta = work[1]; |
| 22460 |
dlarfg_(ns, &beta, &work[2], &c__1, &tau); |
| 22461 |
work[1] = 1.; |
| 22462 |
|
| 22463 |
i__1 = jw - 2; |
| 22464 |
i__2 = jw - 2; |
| 22465 |
dlaset_("L", &i__1, &i__2, &c_b17, &c_b17, &t[t_dim1 + 3], ldt); |
| 22466 |
|
| 22467 |
dlarf_("L", ns, &jw, &work[1], &c__1, &tau, &t[t_offset], ldt, & |
| 22468 |
work[jw + 1]); |
| 22469 |
dlarf_("R", ns, ns, &work[1], &c__1, &tau, &t[t_offset], ldt, & |
| 22470 |
work[jw + 1]); |
| 22471 |
dlarf_("R", &jw, ns, &work[1], &c__1, &tau, &v[v_offset], ldv, & |
| 22472 |
work[jw + 1]); |
| 22473 |
|
| 22474 |
i__1 = *lwork - jw; |
| 22475 |
dgehrd_(&jw, &c__1, ns, &t[t_offset], ldt, &work[1], &work[jw + 1] |
| 22476 |
, &i__1, &info); |
| 22477 |
} |
| 22478 |
|
| 22479 |
/* ==== Copy updated reduced window into place ==== */ |
| 22480 |
|
| 22481 |
if (kwtop > 1) { |
| 22482 |
h__[kwtop + (kwtop - 1) * h_dim1] = s * v[v_dim1 + 1]; |
| 22483 |
} |
| 22484 |
dlacpy_("U", &jw, &jw, &t[t_offset], ldt, &h__[kwtop + kwtop * h_dim1] |
| 22485 |
, ldh); |
| 22486 |
i__1 = jw - 1; |
| 22487 |
i__2 = *ldt + 1; |
| 22488 |
i__3 = *ldh + 1; |
| 22489 |
dcopy_(&i__1, &t[t_dim1 + 2], &i__2, &h__[kwtop + 1 + kwtop * h_dim1], |
| 22490 |
&i__3); |
| 22491 |
|
| 22492 |
/* ==== Accumulate orthogonal matrix in order update */ |
| 22493 |
/* . H and Z, if requested. ==== */ |
| 22494 |
|
| 22495 |
if (*ns > 1 && s != 0.) { |
| 22496 |
i__1 = *lwork - jw; |
| 22497 |
dormhr_("R", "N", &jw, ns, &c__1, ns, &t[t_offset], ldt, &work[1], |
| 22498 |
&v[v_offset], ldv, &work[jw + 1], &i__1, &info); |
| 22499 |
} |
| 22500 |
|
| 22501 |
/* ==== Update vertical slab in H ==== */ |
| 22502 |
|
| 22503 |
if (*wantt) { |
| 22504 |
ltop = 1; |
| 22505 |
} else { |
| 22506 |
ltop = *ktop; |
| 22507 |
} |
| 22508 |
i__1 = kwtop - 1; |
| 22509 |
i__2 = *nv; |
| 22510 |
for (krow = ltop; i__2 < 0 ? krow >= i__1 : krow <= i__1; krow += |
| 22511 |
i__2) { |
| 22512 |
/* Computing MIN */ |
| 22513 |
i__3 = *nv, i__4 = kwtop - krow; |
| 22514 |
kln = std::min(i__3,i__4); |
| 22515 |
dgemm_("N", "N", &kln, &jw, &jw, &c_b18, &h__[krow + kwtop * |
| 22516 |
h_dim1], ldh, &v[v_offset], ldv, &c_b17, &wv[wv_offset], |
| 22517 |
ldwv); |
| 22518 |
dlacpy_("A", &kln, &jw, &wv[wv_offset], ldwv, &h__[krow + kwtop * |
| 22519 |
h_dim1], ldh); |
| 22520 |
/* L70: */ |
| 22521 |
} |
| 22522 |
|
| 22523 |
/* ==== Update horizontal slab in H ==== */ |
| 22524 |
|
| 22525 |
if (*wantt) { |
| 22526 |
i__2 = *n; |
| 22527 |
i__1 = *nh; |
| 22528 |
for (kcol = *kbot + 1; i__1 < 0 ? kcol >= i__2 : kcol <= i__2; |
| 22529 |
kcol += i__1) { |
| 22530 |
/* Computing MIN */ |
| 22531 |
i__3 = *nh, i__4 = *n - kcol + 1; |
| 22532 |
kln = std::min(i__3,i__4); |
| 22533 |
dgemm_("C", "N", &jw, &kln, &jw, &c_b18, &v[v_offset], ldv, & |
| 22534 |
h__[kwtop + kcol * h_dim1], ldh, &c_b17, &t[t_offset], |
| 22535 |
ldt); |
| 22536 |
dlacpy_("A", &jw, &kln, &t[t_offset], ldt, &h__[kwtop + kcol * |
| 22537 |
h_dim1], ldh); |
| 22538 |
/* L80: */ |
| 22539 |
} |
| 22540 |
} |
| 22541 |
|
| 22542 |
/* ==== Update vertical slab in Z ==== */ |
| 22543 |
|
| 22544 |
if (*wantz) { |
| 22545 |
i__1 = *ihiz; |
| 22546 |
i__2 = *nv; |
| 22547 |
for (krow = *iloz; i__2 < 0 ? krow >= i__1 : krow <= i__1; krow += |
| 22548 |
i__2) { |
| 22549 |
/* Computing MIN */ |
| 22550 |
i__3 = *nv, i__4 = *ihiz - krow + 1; |
| 22551 |
kln = std::min(i__3,i__4); |
| 22552 |
dgemm_("N", "N", &kln, &jw, &jw, &c_b18, &z__[krow + kwtop * |
| 22553 |
z_dim1], ldz, &v[v_offset], ldv, &c_b17, &wv[ |
| 22554 |
wv_offset], ldwv); |
| 22555 |
dlacpy_("A", &kln, &jw, &wv[wv_offset], ldwv, &z__[krow + |
| 22556 |
kwtop * z_dim1], ldz); |
| 22557 |
/* L90: */ |
| 22558 |
} |
| 22559 |
} |
| 22560 |
} |
| 22561 |
|
| 22562 |
/* ==== Return the number of deflations ... ==== */ |
| 22563 |
|
| 22564 |
*nd = jw - *ns; |
| 22565 |
|
| 22566 |
/* ==== ... and the number of shifts. (Subtracting */ |
| 22567 |
/* . INFQR from the spike length takes care */ |
| 22568 |
/* . of the case of a rare QR failure while */ |
| 22569 |
/* . calculating eigenvalues of the deflation */ |
| 22570 |
/* . window.) ==== */ |
| 22571 |
|
| 22572 |
*ns -= infqr; |
| 22573 |
|
| 22574 |
/* ==== Return optimal workspace. ==== */ |
| 22575 |
|
| 22576 |
work[1] = (double) lwkopt; |
| 22577 |
|
| 22578 |
/* ==== End of DLAQR3 ==== */ |
| 22579 |
|
| 22580 |
return 0; |
| 22581 |
} /* dlaqr3_ */ |
| 22582 |
|
| 22583 |
/* Subroutine */ int dlaqr4_(bool *wantt, bool *wantz, integer *n, integer *ilo, integer *ihi, double *h__, |
| 22584 |
integer *ldh, double *wr, double *wi, integer *iloz, integer *ihiz, double *z__, |
| 22585 |
integer *ldz, double *work, integer *lwork, integer *info) |
| 22586 |
{ |
| 22587 |
/* Table of constant values */ |
| 22588 |
static integer c__13 = 13; |
| 22589 |
static integer c__15 = 15; |
| 22590 |
static integer c_n1 = -1; |
| 22591 |
static integer c__12 = 12; |
| 22592 |
static integer c__14 = 14; |
| 22593 |
static integer c__16 = 16; |
| 22594 |
static bool c_false = false; |
| 22595 |
static integer c__1 = 1; |
| 22596 |
static integer c__3 = 3; |
| 22597 |
|
| 22598 |
/* System generated locals */ |
| 22599 |
integer h_dim1, h_offset, z_dim1, z_offset, i__1, i__2, i__3, i__4, i__5; |
| 22600 |
double d__1, d__2, d__3, d__4; |
| 22601 |
|
| 22602 |
/* Local variables */ |
| 22603 |
integer i__, k, ld, nh, it, ks, kt, ku, kv, ls, ns; |
| 22604 |
double aa, bb, cc, dd; |
| 22605 |
double cs, sn, ss, swap; |
| 22606 |
integer nw, inf, kdu, nho, nve, kwh, nsr, nwr, kwv, ndec, ndfl, kbot, nmin; |
| 22607 |
integer ktop, kacc22; |
| 22608 |
double zdum[1] /* was [1][1] */; |
| 22609 |
bool sorted; |
| 22610 |
integer itmax, nsmax, nwmax, kwtop, lwkopt, nibble, nwupbd; |
| 22611 |
char jbcmpz[3]; |
| 22612 |
|
| 22613 |
|
| 22614 |
/* -- LAPACK auxiliary routine (version 3.2) -- */ |
| 22615 |
/* Univ. of Tennessee, Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd.. */ |
| 22616 |
/* November 2006 */ |
| 22617 |
|
| 22618 |
/* .. Scalar Arguments .. */ |
| 22619 |
/* .. */ |
| 22620 |
/* .. Array Arguments .. */ |
| 22621 |
/* .. */ |
| 22622 |
|
| 22623 |
/* This subroutine implements one level of recursion for DLAQR0. */ |
| 22624 |
/* It is a complete implementation of the small bulge multi-shift */ |
| 22625 |
/* QR algorithm. It may be called by DLAQR0 and, for large enough */ |
| 22626 |
/* deflation window size, it may be called by DLAQR3. This */ |
| 22627 |
/* subroutine is identical to DLAQR0 except that it calls DLAQR2 */ |
| 22628 |
/* instead of DLAQR3. */ |
| 22629 |
|
| 22630 |
/* Purpose */ |
| 22631 |
/* ======= */ |
| 22632 |
|
| 22633 |
/* DLAQR4 computes the eigenvalues of a Hessenberg matrix H */ |
| 22634 |
/* and, optionally, the matrices T and Z from the Schur decomposition */ |
| 22635 |
/* H = Z T Z**T, where T is an upper quasi-triangular matrix (the */ |
| 22636 |
/* Schur form), and Z is the orthogonal matrix of Schur vectors. */ |
| 22637 |
|
| 22638 |
/* Optionally Z may be postmultiplied into an input orthogonal */ |
| 22639 |
/* matrix Q so that this routine can give the Schur factorization */ |
| 22640 |
/* of a matrix A which has been reduced to the Hessenberg form H */ |
| 22641 |
/* by the orthogonal matrix Q: A = Q*H*Q**T = (QZ)*T*(QZ)**T. */ |
| 22642 |
|
| 22643 |
/* Arguments */ |
| 22644 |
/* ========= */ |
| 22645 |
|
| 22646 |
/* WANTT (input) LOGICAL */ |
| 22647 |
/* = .TRUE. : the full Schur form T is required; */ |
| 22648 |
/* = .FALSE.: only eigenvalues are required. */ |
| 22649 |
|
| 22650 |
/* WANTZ (input) LOGICAL */ |
| 22651 |
/* = .TRUE. : the matrix of Schur vectors Z is required; */ |
| 22652 |
/* = .FALSE.: Schur vectors are not required. */ |
| 22653 |
|
| 22654 |
/* N (input) INTEGER */ |
| 22655 |
/* The order of the matrix H. N .GE. 0. */ |
| 22656 |
|
| 22657 |
/* ILO (input) INTEGER */ |
| 22658 |
/* IHI (input) INTEGER */ |
| 22659 |
/* It is assumed that H is already upper triangular in rows */ |
| 22660 |
/* and columns 1:ILO-1 and IHI+1:N and, if ILO.GT.1, */ |
| 22661 |
/* H(ILO,ILO-1) is zero. ILO and IHI are normally set by a */ |
| 22662 |
/* previous call to DGEBAL, and then passed to DGEHRD when the */ |
| 22663 |
/* matrix output by DGEBAL is reduced to Hessenberg form. */ |
| 22664 |
/* Otherwise, ILO and IHI should be set to 1 and N, */ |
| 22665 |
/* respectively. If N.GT.0, then 1.LE.ILO.LE.IHI.LE.N. */ |
| 22666 |
/* If N = 0, then ILO = 1 and IHI = 0. */ |
| 22667 |
|
| 22668 |
/* H (input/output) DOUBLE PRECISION array, dimension (LDH,N) */ |
| 22669 |
/* On entry, the upper Hessenberg matrix H. */ |
| 22670 |
/* On exit, if INFO = 0 and WANTT is .TRUE., then H contains */ |
| 22671 |
/* the upper quasi-triangular matrix T from the Schur */ |
| 22672 |
/* decomposition (the Schur form); 2-by-2 diagonal blocks */ |
| 22673 |
/* (corresponding to complex conjugate pairs of eigenvalues) */ |
| 22674 |
/* are returned in standard form, with H(i,i) = H(i+1,i+1) */ |
| 22675 |
/* and H(i+1,i)*H(i,i+1).LT.0. If INFO = 0 and WANTT is */ |
| 22676 |
/* .FALSE., then the contents of H are unspecified on exit. */ |
| 22677 |
/* (The output value of H when INFO.GT.0 is given under the */ |
| 22678 |
/* description of INFO below.) */ |
| 22679 |
|
| 22680 |
/* This subroutine may explicitly set H(i,j) = 0 for i.GT.j and */ |
| 22681 |
/* j = 1, 2, ... ILO-1 or j = IHI+1, IHI+2, ... N. */ |
| 22682 |
|
| 22683 |
/* LDH (input) INTEGER */ |
| 22684 |
/* The leading dimension of the array H. LDH .GE. max(1,N). */ |
| 22685 |
|
| 22686 |
/* WR (output) DOUBLE PRECISION array, dimension (IHI) */ |
| 22687 |
/* WI (output) DOUBLE PRECISION array, dimension (IHI) */ |
| 22688 |
/* The real and imaginary parts, respectively, of the computed */ |
| 22689 |
/* eigenvalues of H(ILO:IHI,ILO:IHI) are stored in WR(ILO:IHI) */ |
| 22690 |
/* and WI(ILO:IHI). If two eigenvalues are computed as a */ |
| 22691 |
/* complex conjugate pair, they are stored in consecutive */ |
| 22692 |
/* elements of WR and WI, say the i-th and (i+1)th, with */ |
| 22693 |
/* WI(i) .GT. 0 and WI(i+1) .LT. 0. If WANTT is .TRUE., then */ |
| 22694 |
/* the eigenvalues are stored in the same order as on the */ |
| 22695 |
/* diagonal of the Schur form returned in H, with */ |
| 22696 |
/* WR(i) = H(i,i) and, if H(i:i+1,i:i+1) is a 2-by-2 diagonal */ |
| 22697 |
/* block, WI(i) = sqrt(-H(i+1,i)*H(i,i+1)) and */ |
| 22698 |
/* WI(i+1) = -WI(i). */ |
| 22699 |
|
| 22700 |
/* ILOZ (input) INTEGER */ |
| 22701 |
/* IHIZ (input) INTEGER */ |
| 22702 |
/* Specify the rows of Z to which transformations must be */ |
| 22703 |
/* applied if WANTZ is .TRUE.. */ |
| 22704 |
/* 1 .LE. ILOZ .LE. ILO; IHI .LE. IHIZ .LE. N. */ |
| 22705 |
|
| 22706 |
/* Z (input/output) DOUBLE PRECISION array, dimension (LDZ,IHI) */ |
| 22707 |
/* If WANTZ is .FALSE., then Z is not referenced. */ |
| 22708 |
/* If WANTZ is .TRUE., then Z(ILO:IHI,ILOZ:IHIZ) is */ |
| 22709 |
/* replaced by Z(ILO:IHI,ILOZ:IHIZ)*U where U is the */ |
| 22710 |
/* orthogonal Schur factor of H(ILO:IHI,ILO:IHI). */ |
| 22711 |
/* (The output value of Z when INFO.GT.0 is given under */ |
| 22712 |
/* the description of INFO below.) */ |
| 22713 |
|
| 22714 |
/* LDZ (input) INTEGER */ |
| 22715 |
/* The leading dimension of the array Z. if WANTZ is .TRUE. */ |
| 22716 |
/* then LDZ.GE.MAX(1,IHIZ). Otherwize, LDZ.GE.1. */ |
| 22717 |
|
| 22718 |
/* WORK (workspace/output) DOUBLE PRECISION array, dimension LWORK */ |
| 22719 |
/* On exit, if LWORK = -1, WORK(1) returns an estimate of */ |
| 22720 |
/* the optimal value for LWORK. */ |
| 22721 |
|
| 22722 |
/* LWORK (input) INTEGER */ |
| 22723 |
/* The dimension of the array WORK. LWORK .GE. max(1,N) */ |
| 22724 |
/* is sufficient, but LWORK typically as large as 6*N may */ |
| 22725 |
/* be required for optimal performance. A workspace query */ |
| 22726 |
/* to determine the optimal workspace size is recommended. */ |
| 22727 |
|
| 22728 |
/* If LWORK = -1, then DLAQR4 does a workspace query. */ |
| 22729 |
/* In this case, DLAQR4 checks the input parameters and */ |
| 22730 |
/* estimates the optimal workspace size for the given */ |
| 22731 |
/* values of N, ILO and IHI. The estimate is returned */ |
| 22732 |
/* in WORK(1). No error message related to LWORK is */ |
| 22733 |
/* issued by XERBLA. Neither H nor Z are accessed. */ |
| 22734 |
|
| 22735 |
|
| 22736 |
/* INFO (output) INTEGER */ |
| 22737 |
/* = 0: successful exit */ |
| 22738 |
/* .GT. 0: if INFO = i, DLAQR4 failed to compute all of */ |
| 22739 |
/* the eigenvalues. Elements 1:ilo-1 and i+1:n of WR */ |
| 22740 |
/* and WI contain those eigenvalues which have been */ |
| 22741 |
/* successfully computed. (Failures are rare.) */ |
| 22742 |
|
| 22743 |
/* If INFO .GT. 0 and WANT is .FALSE., then on exit, */ |
| 22744 |
/* the remaining unconverged eigenvalues are the eigen- */ |
| 22745 |
/* values of the upper Hessenberg matrix rows and */ |
| 22746 |
/* columns ILO through INFO of the final, output */ |
| 22747 |
/* value of H. */ |
| 22748 |
|
| 22749 |
/* If INFO .GT. 0 and WANTT is .TRUE., then on exit */ |
| 22750 |
|
| 22751 |
/* (*) (initial value of H)*U = U*(final value of H) */ |
| 22752 |
|
| 22753 |
/* where U is an orthogonal matrix. The final */ |
| 22754 |
/* value of H is upper Hessenberg and quasi-triangular */ |
| 22755 |
/* in rows and columns INFO+1 through IHI. */ |
| 22756 |
|
| 22757 |
/* If INFO .GT. 0 and WANTZ is .TRUE., then on exit */ |
| 22758 |
|
| 22759 |
/* (final value of Z(ILO:IHI,ILOZ:IHIZ) */ |
| 22760 |
/* = (initial value of Z(ILO:IHI,ILOZ:IHIZ)*U */ |
| 22761 |
|
| 22762 |
/* where U is the orthogonal matrix in (*) (regard- */ |
| 22763 |
/* less of the value of WANTT.) */ |
| 22764 |
|
| 22765 |
/* If INFO .GT. 0 and WANTZ is .FALSE., then Z is not */ |
| 22766 |
/* accessed. */ |
| 22767 |
|
| 22768 |
/* ================================================================ */ |
| 22769 |
/* Based on contributions by */ |
| 22770 |
/* Karen Braman and Ralph Byers, Department of Mathematics, */ |
| 22771 |
/* University of Kansas, USA */ |
| 22772 |
|
| 22773 |
/* ================================================================ */ |
| 22774 |
/* References: */ |
| 22775 |
/* K. Braman, R. Byers and R. Mathias, The Multi-Shift QR */ |
| 22776 |
/* Algorithm Part I: Maintaining Well Focused Shifts, and Level 3 */ |
| 22777 |
/* Performance, SIAM Journal of Matrix Analysis, volume 23, pages */ |
| 22778 |
/* 929--947, 2002. */ |
| 22779 |
|
| 22780 |
/* K. Braman, R. Byers and R. Mathias, The Multi-Shift QR */ |
| 22781 |
/* Algorithm Part II: Aggressive Early Deflation, SIAM Journal */ |
| 22782 |
/* of Matrix Analysis, volume 23, pages 948--973, 2002. */ |
| 22783 |
|
| 22784 |
/* ================================================================ */ |
| 22785 |
/* .. Parameters .. */ |
| 22786 |
|
| 22787 |
/* ==== Matrices of order NTINY or smaller must be processed by */ |
| 22788 |
/* . DLAHQR because of insufficient subdiagonal scratch space. */ |
| 22789 |
/* . (This is a hard limit.) ==== */ |
| 22790 |
|
| 22791 |
/* ==== Exceptional deflation windows: try to cure rare */ |
| 22792 |
/* . slow convergence by varying the size of the */ |
| 22793 |
/* . deflation window after KEXNW iterations. ==== */ |
| 22794 |
|
| 22795 |
/* ==== Exceptional shifts: try to cure rare slow convergence */ |
| 22796 |
/* . with ad-hoc exceptional shifts every KEXSH iterations. */ |
| 22797 |
/* . ==== */ |
| 22798 |
|
| 22799 |
/* ==== The constants WILK1 and WILK2 are used to form the */ |
| 22800 |
/* . exceptional shifts. ==== */ |
| 22801 |
/* .. */ |
| 22802 |
/* .. Local Scalars .. */ |
| 22803 |
/* .. */ |
| 22804 |
/* .. External Functions .. */ |
| 22805 |
/* .. */ |
| 22806 |
/* .. Local Arrays .. */ |
| 22807 |
/* .. */ |
| 22808 |
/* .. External Subroutines .. */ |
| 22809 |
/* .. */ |
| 22810 |
/* .. Intrinsic Functions .. */ |
| 22811 |
/* .. */ |
| 22812 |
/* .. Executable Statements .. */ |
| 22813 |
/* Parameter adjustments */ |
| 22814 |
h_dim1 = *ldh; |
| 22815 |
h_offset = 1 + h_dim1; |
| 22816 |
h__ -= h_offset; |
| 22817 |
--wr; |
| 22818 |
--wi; |
| 22819 |
z_dim1 = *ldz; |
| 22820 |
z_offset = 1 + z_dim1; |
| 22821 |
z__ -= z_offset; |
| 22822 |
--work; |
| 22823 |
|
| 22824 |
/* Function Body */ |
| 22825 |
*info = 0; |
| 22826 |
|
| 22827 |
/* ==== Quick return for N = 0: nothing to do. ==== */ |
| 22828 |
|
| 22829 |
if (*n == 0) { |
| 22830 |
work[1] = 1.; |
| 22831 |
return 0; |
| 22832 |
} |
| 22833 |
|
| 22834 |
if (*n <= 11) { |
| 22835 |
/* ==== Tiny matrices must use DLAHQR. ==== */ |
| 22836 |
|
| 22837 |
lwkopt = 1; |
| 22838 |
if (*lwork != -1) { |
| 22839 |
dlahqr_(wantt, wantz, n, ilo, ihi, &h__[h_offset], ldh, &wr[1], & |
| 22840 |
wi[1], iloz, ihiz, &z__[z_offset], ldz, info); |
| 22841 |
} |
| 22842 |
} else { |
| 22843 |
|
| 22844 |
/* ==== Use small bulge multi-shift QR with aggressive early */ |
| 22845 |
/* . deflation on larger-than-tiny matrices. ==== */ |
| 22846 |
|
| 22847 |
/* ==== Hope for the best. ==== */ |
| 22848 |
|
| 22849 |
*info = 0; |
| 22850 |
|
| 22851 |
/* ==== Set up job flags for ILAENV. ==== */ |
| 22852 |
|
| 22853 |
if (*wantt) { |
| 22854 |
* (unsigned char *) & jbcmpz [0] = 'S'; |
| 22855 |
} else { |
| 22856 |
* (unsigned char *) & jbcmpz [0] = 'E'; |
| 22857 |
} |
| 22858 |
if (*wantz) { |
| 22859 |
* (unsigned char *) & jbcmpz [1] = 'V'; |
| 22860 |
} else { |
| 22861 |
* (unsigned char *) & jbcmpz [1] = 'N'; |
| 22862 |
} |
| 22863 |
jbcmpz [2] = '\0'; |
| 22864 |
/* ==== NWR = recommended deflation window size. At this */ |
| 22865 |
/* . point, N .GT. NTINY = 11, so there is enough */ |
| 22866 |
/* . subdiagonal workspace for NWR.GE.2 as required. */ |
| 22867 |
/* . (In fact, there is enough subdiagonal space for */ |
| 22868 |
/* . NWR.GE.3.) ==== */ |
| 22869 |
|
| 22870 |
nwr = ilaenv_(&c__13, "DLAQR4", jbcmpz, n, ilo, ihi, lwork); |
| 22871 |
nwr = std::max(2_integer,nwr); |
| 22872 |
/* Computing MIN */ |
| 22873 |
i__1 = *ihi - *ilo + 1, i__2 = (*n - 1) / 3, i__1 = std::min(i__1,i__2); |
| 22874 |
nwr = std::min(i__1,nwr); |
| 22875 |
|
| 22876 |
/* ==== NSR = recommended number of simultaneous shifts. */ |
| 22877 |
/* . At this point N .GT. NTINY = 11, so there is at */ |
| 22878 |
/* . enough subdiagonal workspace for NSR to be even */ |
| 22879 |
/* . and greater than or equal to two as required. ==== */ |
| 22880 |
|
| 22881 |
nsr = ilaenv_(&c__15, "DLAQR4", jbcmpz, n, ilo, ihi, lwork); |
| 22882 |
/* Computing MIN */ |
| 22883 |
i__1 = nsr, i__2 = (*n + 6) / 9, i__1 = std::min(i__1,i__2), i__2 = *ihi - |
| 22884 |
*ilo; |
| 22885 |
nsr = std::min(i__1,i__2); |
| 22886 |
/* Computing MAX */ |
| 22887 |
i__1 = 2, i__2 = nsr - nsr % 2; |
| 22888 |
nsr = std::max(i__1,i__2); |
| 22889 |
|
| 22890 |
/* ==== Estimate optimal workspace ==== */ |
| 22891 |
|
| 22892 |
/* ==== Workspace query call to DLAQR2 ==== */ |
| 22893 |
|
| 22894 |
i__1 = nwr + 1; |
| 22895 |
dlaqr2_(wantt, wantz, n, ilo, ihi, &i__1, &h__[h_offset], ldh, iloz, |
| 22896 |
ihiz, &z__[z_offset], ldz, &ls, &ld, &wr[1], &wi[1], &h__[ |
| 22897 |
h_offset], ldh, n, &h__[h_offset], ldh, n, &h__[h_offset], |
| 22898 |
ldh, &work[1], &c_n1); |
| 22899 |
|
| 22900 |
/* ==== Optimal workspace = MAX(DLAQR5, DLAQR2) ==== */ |
| 22901 |
|
| 22902 |
/* Computing MAX */ |
| 22903 |
i__1 = nsr * 3 / 2, i__2 = (integer) work[1]; |
| 22904 |
lwkopt = std::max(i__1,i__2); |
| 22905 |
|
| 22906 |
/* ==== Quick return in case of workspace query. ==== */ |
| 22907 |
|
| 22908 |
if (*lwork == -1) { |
| 22909 |
work[1] = (double) lwkopt; |
| 22910 |
return 0; |
| 22911 |
} |
| 22912 |
|
| 22913 |
/* ==== DLAHQR/DLAQR0 crossover point ==== */ |
| 22914 |
|
| 22915 |
nmin = ilaenv_(&c__12, "DLAQR4", jbcmpz, n, ilo, ihi, lwork); |
| 22916 |
nmin = std::max(11_integer,nmin); |
| 22917 |
|
| 22918 |
/* ==== Nibble crossover point ==== */ |
| 22919 |
|
| 22920 |
nibble = ilaenv_(&c__14, "DLAQR4", jbcmpz, n, ilo, ihi, lwork); |
| 22921 |
nibble = std::max(0_integer,nibble); |
| 22922 |
|
| 22923 |
/* ==== Accumulate reflections during ttswp? Use block */ |
| 22924 |
/* . 2-by-2 structure during matrix-matrix multiply? ==== */ |
| 22925 |
|
| 22926 |
kacc22 = ilaenv_(&c__16, "DLAQR4", jbcmpz, n, ilo, ihi, lwork); |
| 22927 |
kacc22 = std::max(0_integer,kacc22); |
| 22928 |
kacc22 = std::min(2_integer,kacc22); |
| 22929 |
|
| 22930 |
/* ==== NWMAX = the largest possible deflation window for */ |
| 22931 |
/* . which there is sufficient workspace. ==== */ |
| 22932 |
|
| 22933 |
/* Computing MIN */ |
| 22934 |
i__1 = (*n - 1) / 3, i__2 = *lwork / 2; |
| 22935 |
nwmax = std::min(i__1,i__2); |
| 22936 |
nw = nwmax; |
| 22937 |
|
| 22938 |
/* ==== NSMAX = the Largest number of simultaneous shifts */ |
| 22939 |
/* . for which there is sufficient workspace. ==== */ |
| 22940 |
|
| 22941 |
/* Computing MIN */ |
| 22942 |
i__1 = (*n + 6) / 9, i__2 = (*lwork << 1) / 3; |
| 22943 |
nsmax = std::min(i__1,i__2); |
| 22944 |
nsmax -= nsmax % 2; |
| 22945 |
|
| 22946 |
/* ==== NDFL: an iteration count restarted at deflation. ==== */ |
| 22947 |
|
| 22948 |
ndfl = 1; |
| 22949 |
|
| 22950 |
/* ==== ITMAX = iteration limit ==== */ |
| 22951 |
|
| 22952 |
/* Computing MAX */ |
| 22953 |
i__1 = 10, i__2 = *ihi - *ilo + 1; |
| 22954 |
itmax = std::max(i__1,i__2) * 30; |
| 22955 |
|
| 22956 |
/* ==== Last row and column in the active block ==== */ |
| 22957 |
|
| 22958 |
kbot = *ihi; |
| 22959 |
|
| 22960 |
/* ==== Main Loop ==== */ |
| 22961 |
|
| 22962 |
i__1 = itmax; |
| 22963 |
for (it = 1; it <= i__1; ++it) { |
| 22964 |
|
| 22965 |
/* ==== Done when KBOT falls below ILO ==== */ |
| 22966 |
|
| 22967 |
if (kbot < *ilo) { |
| 22968 |
goto L90; |
| 22969 |
} |
| 22970 |
|
| 22971 |
/* ==== Locate active block ==== */ |
| 22972 |
|
| 22973 |
i__2 = *ilo + 1; |
| 22974 |
for (k = kbot; k >= i__2; --k) { |
| 22975 |
if (h__[k + (k - 1) * h_dim1] == 0.) { |
| 22976 |
goto L20; |
| 22977 |
} |
| 22978 |
/* L10: */ |
| 22979 |
} |
| 22980 |
k = *ilo; |
| 22981 |
L20: |
| 22982 |
ktop = k; |
| 22983 |
|
| 22984 |
/* ==== Select deflation window size: */ |
| 22985 |
/* . Typical Case: */ |
| 22986 |
/* . If possible and advisable, nibble the entire */ |
| 22987 |
/* . active block. If not, use size MIN(NWR,NWMAX) */ |
| 22988 |
/* . or MIN(NWR+1,NWMAX) depending upon which has */ |
| 22989 |
/* . the smaller corresponding subdiagonal entry */ |
| 22990 |
/* . (a heuristic). */ |
| 22991 |
/* . */ |
| 22992 |
/* . Exceptional Case: */ |
| 22993 |
/* . If there have been no deflations in KEXNW or */ |
| 22994 |
/* . more iterations, then vary the deflation window */ |
| 22995 |
/* . size. At first, because, larger windows are, */ |
| 22996 |
/* . in general, more powerful than smaller ones, */ |
| 22997 |
/* . rapidly increase the window to the maximum possible. */ |
| 22998 |
/* . Then, gradually reduce the window size. ==== */ |
| 22999 |
|
| 23000 |
nh = kbot - ktop + 1; |
| 23001 |
nwupbd = std::min(nh,nwmax); |
| 23002 |
if (ndfl < 5) { |
| 23003 |
nw = std::min(nwupbd,nwr); |
| 23004 |
} else { |
| 23005 |
/* Computing MIN */ |
| 23006 |
i__2 = nwupbd, i__3 = nw << 1; |
| 23007 |
nw = std::min(i__2,i__3); |
| 23008 |
} |
| 23009 |
if (nw < nwmax) { |
| 23010 |
if (nw >= nh - 1) { |
| 23011 |
nw = nh; |
| 23012 |
} else { |
| 23013 |
kwtop = kbot - nw + 1; |
| 23014 |
if ((d__1 = h__[kwtop + (kwtop - 1) * h_dim1], abs(d__1)) |
| 23015 |
> (d__2 = h__[kwtop - 1 + (kwtop - 2) * h_dim1], |
| 23016 |
abs(d__2))) { |
| 23017 |
++nw; |
| 23018 |
} |
| 23019 |
} |
| 23020 |
} |
| 23021 |
if (ndfl < 5) { |
| 23022 |
ndec = -1; |
| 23023 |
} else if (ndec >= 0 || nw >= nwupbd) { |
| 23024 |
++ndec; |
| 23025 |
if (nw - ndec < 2) { |
| 23026 |
ndec = 0; |
| 23027 |
} |
| 23028 |
nw -= ndec; |
| 23029 |
} |
| 23030 |
|
| 23031 |
/* ==== Aggressive early deflation: */ |
| 23032 |
/* . split workspace under the subdiagonal into */ |
| 23033 |
/* . - an nw-by-nw work array V in the lower */ |
| 23034 |
/* . left-hand-corner, */ |
| 23035 |
/* . - an NW-by-at-least-NW-but-more-is-better */ |
| 23036 |
/* . (NW-by-NHO) horizontal work array along */ |
| 23037 |
/* . the bottom edge, */ |
| 23038 |
/* . - an at-least-NW-but-more-is-better (NHV-by-NW) */ |
| 23039 |
/* . vertical work array along the left-hand-edge. */ |
| 23040 |
/* . ==== */ |
| 23041 |
|
| 23042 |
kv = *n - nw + 1; |
| 23043 |
kt = nw + 1; |
| 23044 |
nho = *n - nw - 1 - kt + 1; |
| 23045 |
kwv = nw + 2; |
| 23046 |
nve = *n - nw - kwv + 1; |
| 23047 |
|
| 23048 |
/* ==== Aggressive early deflation ==== */ |
| 23049 |
|
| 23050 |
dlaqr2_(wantt, wantz, n, &ktop, &kbot, &nw, &h__[h_offset], ldh, |
| 23051 |
iloz, ihiz, &z__[z_offset], ldz, &ls, &ld, &wr[1], &wi[1], |
| 23052 |
&h__[kv + h_dim1], ldh, &nho, &h__[kv + kt * h_dim1], |
| 23053 |
ldh, &nve, &h__[kwv + h_dim1], ldh, &work[1], lwork); |
| 23054 |
|
| 23055 |
/* ==== Adjust KBOT accounting for new deflations. ==== */ |
| 23056 |
|
| 23057 |
kbot -= ld; |
| 23058 |
|
| 23059 |
/* ==== KS points to the shifts. ==== */ |
| 23060 |
|
| 23061 |
ks = kbot - ls + 1; |
| 23062 |
|
| 23063 |
/* ==== Skip an expensive QR sweep if there is a (partly */ |
| 23064 |
/* . heuristic) reason to expect that many eigenvalues */ |
| 23065 |
/* . will deflate without it. Here, the QR sweep is */ |
| 23066 |
/* . skipped if many eigenvalues have just been deflated */ |
| 23067 |
/* . or if the remaining active block is small. */ |
| 23068 |
|
| 23069 |
if (ld == 0 || ld * 100 <= nw * nibble && kbot - ktop + 1 > std::min( |
| 23070 |
nmin,nwmax)) { |
| 23071 |
|
| 23072 |
/* ==== NS = nominal number of simultaneous shifts. */ |
| 23073 |
/* . This may be lowered (slightly) if DLAQR2 */ |
| 23074 |
/* . did not provide that many shifts. ==== */ |
| 23075 |
|
| 23076 |
/* Computing MIN */ |
| 23077 |
/* Computing MAX */ |
| 23078 |
i__4 = 2, i__5 = kbot - ktop; |
| 23079 |
i__2 = std::min(nsmax,nsr), i__3 = std::max(i__4,i__5); |
| 23080 |
ns = std::min(i__2,i__3); |
| 23081 |
ns -= ns % 2; |
| 23082 |
|
| 23083 |
/* ==== If there have been no deflations */ |
| 23084 |
/* . in a multiple of KEXSH iterations, */ |
| 23085 |
/* . then try exceptional shifts. */ |
| 23086 |
/* . Otherwise use shifts provided by */ |
| 23087 |
/* . DLAQR2 above or from the eigenvalues */ |
| 23088 |
/* . of a trailing principal submatrix. ==== */ |
| 23089 |
|
| 23090 |
if (ndfl % 6 == 0) { |
| 23091 |
ks = kbot - ns + 1; |
| 23092 |
/* Computing MAX */ |
| 23093 |
i__3 = ks + 1, i__4 = ktop + 2; |
| 23094 |
i__2 = std::max(i__3,i__4); |
| 23095 |
for (i__ = kbot; i__ >= i__2; i__ += -2) { |
| 23096 |
ss = (d__1 = h__[i__ + (i__ - 1) * h_dim1], abs(d__1)) |
| 23097 |
+ (d__2 = h__[i__ - 1 + (i__ - 2) * h_dim1], |
| 23098 |
abs(d__2)); |
| 23099 |
aa = ss * .75 + h__[i__ + i__ * h_dim1]; |
| 23100 |
bb = ss; |
| 23101 |
cc = ss * -.4375; |
| 23102 |
dd = aa; |
| 23103 |
dlanv2_(&aa, &bb, &cc, &dd, &wr[i__ - 1], &wi[i__ - 1] |
| 23104 |
, &wr[i__], &wi[i__], &cs, &sn); |
| 23105 |
/* L30: */ |
| 23106 |
} |
| 23107 |
if (ks == ktop) { |
| 23108 |
wr[ks + 1] = h__[ks + 1 + (ks + 1) * h_dim1]; |
| 23109 |
wi[ks + 1] = 0.; |
| 23110 |
wr[ks] = wr[ks + 1]; |
| 23111 |
wi[ks] = wi[ks + 1]; |
| 23112 |
} |
| 23113 |
} else { |
| 23114 |
|
| 23115 |
/* ==== Got NS/2 or fewer shifts? Use DLAHQR */ |
| 23116 |
/* . on a trailing principal submatrix to */ |
| 23117 |
/* . get more. (Since NS.LE.NSMAX.LE.(N+6)/9, */ |
| 23118 |
/* . there is enough space below the subdiagonal */ |
| 23119 |
/* . to fit an NS-by-NS scratch array.) ==== */ |
| 23120 |
|
| 23121 |
if (kbot - ks + 1 <= ns / 2) { |
| 23122 |
ks = kbot - ns + 1; |
| 23123 |
kt = *n - ns + 1; |
| 23124 |
dlacpy_("A", &ns, &ns, &h__[ks + ks * h_dim1], ldh, & |
| 23125 |
h__[kt + h_dim1], ldh); |
| 23126 |
dlahqr_(&c_false, &c_false, &ns, &c__1, &ns, &h__[kt |
| 23127 |
+ h_dim1], ldh, &wr[ks], &wi[ks], &c__1, & |
| 23128 |
c__1, zdum, &c__1, &inf); |
| 23129 |
ks += inf; |
| 23130 |
|
| 23131 |
/* ==== In case of a rare QR failure use */ |
| 23132 |
/* . eigenvalues of the trailing 2-by-2 */ |
| 23133 |
/* . principal submatrix. ==== */ |
| 23134 |
|
| 23135 |
if (ks >= kbot) { |
| 23136 |
aa = h__[kbot - 1 + (kbot - 1) * h_dim1]; |
| 23137 |
cc = h__[kbot + (kbot - 1) * h_dim1]; |
| 23138 |
bb = h__[kbot - 1 + kbot * h_dim1]; |
| 23139 |
dd = h__[kbot + kbot * h_dim1]; |
| 23140 |
dlanv2_(&aa, &bb, &cc, &dd, &wr[kbot - 1], &wi[ |
| 23141 |
kbot - 1], &wr[kbot], &wi[kbot], &cs, &sn) |
| 23142 |
; |
| 23143 |
ks = kbot - 1; |
| 23144 |
} |
| 23145 |
} |
| 23146 |
|
| 23147 |
if (kbot - ks + 1 > ns) { |
| 23148 |
|
| 23149 |
/* ==== Sort the shifts (Helps a little) */ |
| 23150 |
/* . Bubble sort keeps complex conjugate */ |
| 23151 |
/* . pairs together. ==== */ |
| 23152 |
|
| 23153 |
sorted = false; |
| 23154 |
i__2 = ks + 1; |
| 23155 |
for (k = kbot; k >= i__2; --k) { |
| 23156 |
if (sorted) { |
| 23157 |
goto L60; |
| 23158 |
} |
| 23159 |
sorted = true; |
| 23160 |
i__3 = k - 1; |
| 23161 |
for (i__ = ks; i__ <= i__3; ++i__) { |
| 23162 |
if ((d__1 = wr[i__], abs(d__1)) + (d__2 = wi[ |
| 23163 |
i__], abs(d__2)) < (d__3 = wr[i__ + 1] |
| 23164 |
, abs(d__3)) + (d__4 = wi[i__ + 1], |
| 23165 |
abs(d__4))) { |
| 23166 |
sorted = false; |
| 23167 |
|
| 23168 |
swap = wr[i__]; |
| 23169 |
wr[i__] = wr[i__ + 1]; |
| 23170 |
wr[i__ + 1] = swap; |
| 23171 |
|
| 23172 |
swap = wi[i__]; |
| 23173 |
wi[i__] = wi[i__ + 1]; |
| 23174 |
wi[i__ + 1] = swap; |
| 23175 |
} |
| 23176 |
/* L40: */ |
| 23177 |
} |
| 23178 |
/* L50: */ |
| 23179 |
} |
| 23180 |
L60: |
| 23181 |
; |
| 23182 |
} |
| 23183 |
|
| 23184 |
/* ==== Shuffle shifts into pairs of real shifts */ |
| 23185 |
/* . and pairs of complex conjugate shifts */ |
| 23186 |
/* . assuming complex conjugate shifts are */ |
| 23187 |
/* . already adjacent to one another. (Yes, */ |
| 23188 |
/* . they are.) ==== */ |
| 23189 |
|
| 23190 |
i__2 = ks + 2; |
| 23191 |
for (i__ = kbot; i__ >= i__2; i__ += -2) { |
| 23192 |
if (wi[i__] != -wi[i__ - 1]) { |
| 23193 |
|
| 23194 |
swap = wr[i__]; |
| 23195 |
wr[i__] = wr[i__ - 1]; |
| 23196 |
wr[i__ - 1] = wr[i__ - 2]; |
| 23197 |
wr[i__ - 2] = swap; |
| 23198 |
|
| 23199 |
swap = wi[i__]; |
| 23200 |
wi[i__] = wi[i__ - 1]; |
| 23201 |
wi[i__ - 1] = wi[i__ - 2]; |
| 23202 |
wi[i__ - 2] = swap; |
| 23203 |
} |
| 23204 |
/* L70: */ |
| 23205 |
} |
| 23206 |
} |
| 23207 |
|
| 23208 |
/* ==== If there are only two shifts and both are */ |
| 23209 |
/* . real, then use only one. ==== */ |
| 23210 |
|
| 23211 |
if (kbot - ks + 1 == 2) { |
| 23212 |
if (wi[kbot] == 0.) { |
| 23213 |
if ((d__1 = wr[kbot] - h__[kbot + kbot * h_dim1], abs( |
| 23214 |
d__1)) < (d__2 = wr[kbot - 1] - h__[kbot + |
| 23215 |
kbot * h_dim1], abs(d__2))) { |
| 23216 |
wr[kbot - 1] = wr[kbot]; |
| 23217 |
} else { |
| 23218 |
wr[kbot] = wr[kbot - 1]; |
| 23219 |
} |
| 23220 |
} |
| 23221 |
} |
| 23222 |
|
| 23223 |
/* ==== Use up to NS of the the smallest magnatiude */ |
| 23224 |
/* . shifts. If there aren't NS shifts available, */ |
| 23225 |
/* . then use them all, possibly dropping one to */ |
| 23226 |
/* . make the number of shifts even. ==== */ |
| 23227 |
|
| 23228 |
/* Computing MIN */ |
| 23229 |
i__2 = ns, i__3 = kbot - ks + 1; |
| 23230 |
ns = std::min(i__2,i__3); |
| 23231 |
ns -= ns % 2; |
| 23232 |
ks = kbot - ns + 1; |
| 23233 |
|
| 23234 |
/* ==== Small-bulge multi-shift QR sweep: */ |
| 23235 |
/* . split workspace under the subdiagonal into */ |
| 23236 |
/* . - a KDU-by-KDU work array U in the lower */ |
| 23237 |
/* . left-hand-corner, */ |
| 23238 |
/* . - a KDU-by-at-least-KDU-but-more-is-better */ |
| 23239 |
/* . (KDU-by-NHo) horizontal work array WH along */ |
| 23240 |
/* . the bottom edge, */ |
| 23241 |
/* . - and an at-least-KDU-but-more-is-better-by-KDU */ |
| 23242 |
/* . (NVE-by-KDU) vertical work WV arrow along */ |
| 23243 |
/* . the left-hand-edge. ==== */ |
| 23244 |
|
| 23245 |
kdu = ns * 3 - 3; |
| 23246 |
ku = *n - kdu + 1; |
| 23247 |
kwh = kdu + 1; |
| 23248 |
nho = *n - kdu - 3 - (kdu + 1) + 1; |
| 23249 |
kwv = kdu + 4; |
| 23250 |
nve = *n - kdu - kwv + 1; |
| 23251 |
|
| 23252 |
/* ==== Small-bulge multi-shift QR sweep ==== */ |
| 23253 |
|
| 23254 |
dlaqr5_(wantt, wantz, &kacc22, n, &ktop, &kbot, &ns, &wr[ks], |
| 23255 |
&wi[ks], &h__[h_offset], ldh, iloz, ihiz, &z__[ |
| 23256 |
z_offset], ldz, &work[1], &c__3, &h__[ku + h_dim1], |
| 23257 |
ldh, &nve, &h__[kwv + h_dim1], ldh, &nho, &h__[ku + |
| 23258 |
kwh * h_dim1], ldh); |
| 23259 |
} |
| 23260 |
|
| 23261 |
/* ==== Note progress (or the lack of it). ==== */ |
| 23262 |
|
| 23263 |
if (ld > 0) { |
| 23264 |
ndfl = 1; |
| 23265 |
} else { |
| 23266 |
++ndfl; |
| 23267 |
} |
| 23268 |
|
| 23269 |
/* ==== End of main loop ==== */ |
| 23270 |
/* L80: */ |
| 23271 |
} |
| 23272 |
|
| 23273 |
/* ==== Iteration limit exceeded. Set INFO to show where */ |
| 23274 |
/* . the problem occurred and exit. ==== */ |
| 23275 |
|
| 23276 |
*info = kbot; |
| 23277 |
L90: |
| 23278 |
; |
| 23279 |
} |
| 23280 |
|
| 23281 |
/* ==== Return the optimal value of LWORK. ==== */ |
| 23282 |
|
| 23283 |
work[1] = (double) lwkopt; |
| 23284 |
|
| 23285 |
/* ==== End of DLAQR4 ==== */ |
| 23286 |
|
| 23287 |
return 0; |
| 23288 |
} /* dlaqr4_ */ |
| 23289 |
|
| 23290 |
/* Subroutine */ int dlaqr5_(bool *wantt, bool *wantz, integer *kacc22, |
| 23291 |
integer *n, integer *ktop, integer *kbot, integer *nshfts, double |
| 23292 |
*sr, double *si, double *h__, integer *ldh, integer *iloz, |
| 23293 |
integer *ihiz, double *z__, integer *ldz, double *v, integer * |
| 23294 |
ldv, double *u, integer *ldu, integer *nv, double *wv, |
| 23295 |
integer *ldwv, integer *nh, double *wh, integer *ldwh) |
| 23296 |
{ |
| 23297 |
/* Table of constant values */ |
| 23298 |
static double c_b7 = 0.; |
| 23299 |
static double c_b8 = 1.; |
| 23300 |
static integer c__3 = 3; |
| 23301 |
static integer c__1 = 1; |
| 23302 |
static integer c__2 = 2; |
| 23303 |
|
| 23304 |
/* System generated locals */ |
| 23305 |
integer h_dim1, h_offset, u_dim1, u_offset, v_dim1, v_offset, wh_dim1, |
| 23306 |
wh_offset, wv_dim1, wv_offset, z_dim1, z_offset, i__1, i__2, i__3, |
| 23307 |
i__4, i__5, i__6, i__7; |
| 23308 |
double d__1, d__2, d__3, d__4, d__5; |
| 23309 |
|
| 23310 |
/* Local variables */ |
| 23311 |
integer i__, j, k, m, i2, j2, i4, j4, k1; |
| 23312 |
double h11, h12, h21, h22; |
| 23313 |
integer m22, ns, nu; |
| 23314 |
double vt[3], scl; |
| 23315 |
integer kdu, kms; |
| 23316 |
double ulp; |
| 23317 |
integer knz, kzs; |
| 23318 |
double tst1, tst2, beta; |
| 23319 |
bool blk22, bmp22, accum; |
| 23320 |
integer mend, jcol, jlen, jbot, mbot, jtop, jrow, mtop; |
| 23321 |
integer ndcol, incol, krcol, nbmps; |
| 23322 |
double swap, alpha, safmin, safmax, refsum, smlnum; |
| 23323 |
integer mstart; |
| 23324 |
|
| 23325 |
|
| 23326 |
/* -- LAPACK auxiliary routine (version 3.2) -- */ |
| 23327 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 23328 |
/* November 2006 */ |
| 23329 |
|
| 23330 |
/* .. Scalar Arguments .. */ |
| 23331 |
/* .. */ |
| 23332 |
/* .. Array Arguments .. */ |
| 23333 |
/* .. */ |
| 23334 |
|
| 23335 |
/* This auxiliary subroutine called by DLAQR0 performs a */ |
| 23336 |
/* single small-bulge multi-shift QR sweep. */ |
| 23337 |
|
| 23338 |
/* WANTT (input) logical scalar */ |
| 23339 |
/* WANTT = .true. if the quasi-triangular Schur factor */ |
| 23340 |
/* is being computed. WANTT is set to .false. otherwise. */ |
| 23341 |
|
| 23342 |
/* WANTZ (input) logical scalar */ |
| 23343 |
/* WANTZ = .true. if the orthogonal Schur factor is being */ |
| 23344 |
/* computed. WANTZ is set to .false. otherwise. */ |
| 23345 |
|
| 23346 |
/* KACC22 (input) integer with value 0, 1, or 2. */ |
| 23347 |
/* Specifies the computation mode of far-from-diagonal */ |
| 23348 |
/* orthogonal updates. */ |
| 23349 |
/* = 0: DLAQR5 does not accumulate reflections and does not */ |
| 23350 |
/* use matrix-matrix multiply to update far-from-diagonal */ |
| 23351 |
/* matrix entries. */ |
| 23352 |
/* = 1: DLAQR5 accumulates reflections and uses matrix-matrix */ |
| 23353 |
/* multiply to update the far-from-diagonal matrix entries. */ |
| 23354 |
/* = 2: DLAQR5 accumulates reflections, uses matrix-matrix */ |
| 23355 |
/* multiply to update the far-from-diagonal matrix entries, */ |
| 23356 |
/* and takes advantage of 2-by-2 block structure during */ |
| 23357 |
/* matrix multiplies. */ |
| 23358 |
|
| 23359 |
/* N (input) integer scalar */ |
| 23360 |
/* N is the order of the Hessenberg matrix H upon which this */ |
| 23361 |
/* subroutine operates. */ |
| 23362 |
|
| 23363 |
/* KTOP (input) integer scalar */ |
| 23364 |
/* KBOT (input) integer scalar */ |
| 23365 |
/* These are the first and last rows and columns of an */ |
| 23366 |
/* isolated diagonal block upon which the QR sweep is to be */ |
| 23367 |
/* applied. It is assumed without a check that */ |
| 23368 |
/* either KTOP = 1 or H(KTOP,KTOP-1) = 0 */ |
| 23369 |
/* and */ |
| 23370 |
/* either KBOT = N or H(KBOT+1,KBOT) = 0. */ |
| 23371 |
|
| 23372 |
/* NSHFTS (input) integer scalar */ |
| 23373 |
/* NSHFTS gives the number of simultaneous shifts. NSHFTS */ |
| 23374 |
/* must be positive and even. */ |
| 23375 |
|
| 23376 |
/* SR (input/output) DOUBLE PRECISION array of size (NSHFTS) */ |
| 23377 |
/* SI (input/output) DOUBLE PRECISION array of size (NSHFTS) */ |
| 23378 |
/* SR contains the real parts and SI contains the imaginary */ |
| 23379 |
/* parts of the NSHFTS shifts of origin that define the */ |
| 23380 |
/* multi-shift QR sweep. On output SR and SI may be */ |
| 23381 |
/* reordered. */ |
| 23382 |
|
| 23383 |
/* H (input/output) DOUBLE PRECISION array of size (LDH,N) */ |
| 23384 |
/* On input H contains a Hessenberg matrix. On output a */ |
| 23385 |
/* multi-shift QR sweep with shifts SR(J)+i*SI(J) is applied */ |
| 23386 |
/* to the isolated diagonal block in rows and columns KTOP */ |
| 23387 |
/* through KBOT. */ |
| 23388 |
|
| 23389 |
/* LDH (input) integer scalar */ |
| 23390 |
/* LDH is the leading dimension of H just as declared in the */ |
| 23391 |
/* calling procedure. LDH.GE.MAX(1,N). */ |
| 23392 |
|
| 23393 |
/* ILOZ (input) INTEGER */ |
| 23394 |
/* IHIZ (input) INTEGER */ |
| 23395 |
/* Specify the rows of Z to which transformations must be */ |
| 23396 |
/* applied if WANTZ is .TRUE.. 1 .LE. ILOZ .LE. IHIZ .LE. N */ |
| 23397 |
|
| 23398 |
/* Z (input/output) DOUBLE PRECISION array of size (LDZ,IHI) */ |
| 23399 |
/* If WANTZ = .TRUE., then the QR Sweep orthogonal */ |
| 23400 |
/* similarity transformation is accumulated into */ |
| 23401 |
/* Z(ILOZ:IHIZ,ILO:IHI) from the right. */ |
| 23402 |
/* If WANTZ = .FALSE., then Z is unreferenced. */ |
| 23403 |
|
| 23404 |
/* LDZ (input) integer scalar */ |
| 23405 |
/* LDA is the leading dimension of Z just as declared in */ |
| 23406 |
/* the calling procedure. LDZ.GE.N. */ |
| 23407 |
|
| 23408 |
/* V (workspace) DOUBLE PRECISION array of size (LDV,NSHFTS/2) */ |
| 23409 |
|
| 23410 |
/* LDV (input) integer scalar */ |
| 23411 |
/* LDV is the leading dimension of V as declared in the */ |
| 23412 |
/* calling procedure. LDV.GE.3. */ |
| 23413 |
|
| 23414 |
/* U (workspace) DOUBLE PRECISION array of size */ |
| 23415 |
/* (LDU,3*NSHFTS-3) */ |
| 23416 |
|
| 23417 |
/* LDU (input) integer scalar */ |
| 23418 |
/* LDU is the leading dimension of U just as declared in the */ |
| 23419 |
/* in the calling subroutine. LDU.GE.3*NSHFTS-3. */ |
| 23420 |
|
| 23421 |
/* NH (input) integer scalar */ |
| 23422 |
/* NH is the number of columns in array WH available for */ |
| 23423 |
/* workspace. NH.GE.1. */ |
| 23424 |
|
| 23425 |
/* WH (workspace) DOUBLE PRECISION array of size (LDWH,NH) */ |
| 23426 |
|
| 23427 |
/* LDWH (input) integer scalar */ |
| 23428 |
/* Leading dimension of WH just as declared in the */ |
| 23429 |
/* calling procedure. LDWH.GE.3*NSHFTS-3. */ |
| 23430 |
|
| 23431 |
/* NV (input) integer scalar */ |
| 23432 |
/* NV is the number of rows in WV agailable for workspace. */ |
| 23433 |
/* NV.GE.1. */ |
| 23434 |
|
| 23435 |
/* WV (workspace) DOUBLE PRECISION array of size */ |
| 23436 |
/* (LDWV,3*NSHFTS-3) */ |
| 23437 |
|
| 23438 |
/* LDWV (input) integer scalar */ |
| 23439 |
/* LDWV is the leading dimension of WV as declared in the */ |
| 23440 |
/* in the calling subroutine. LDWV.GE.NV. */ |
| 23441 |
|
| 23442 |
/* ================================================================ */ |
| 23443 |
/* Based on contributions by */ |
| 23444 |
/* Karen Braman and Ralph Byers, Department of Mathematics, */ |
| 23445 |
/* University of Kansas, USA */ |
| 23446 |
|
| 23447 |
/* ================================================================ */ |
| 23448 |
/* Reference: */ |
| 23449 |
|
| 23450 |
/* K. Braman, R. Byers and R. Mathias, The Multi-Shift QR */ |
| 23451 |
/* Algorithm Part I: Maintaining Well Focused Shifts, and */ |
| 23452 |
/* Level 3 Performance, SIAM Journal of Matrix Analysis, */ |
| 23453 |
/* volume 23, pages 929--947, 2002. */ |
| 23454 |
|
| 23455 |
/* ================================================================ */ |
| 23456 |
/* .. Parameters .. */ |
| 23457 |
/* .. */ |
| 23458 |
/* .. Local Scalars .. */ |
| 23459 |
/* .. */ |
| 23460 |
/* .. External Functions .. */ |
| 23461 |
/* .. */ |
| 23462 |
/* .. Intrinsic Functions .. */ |
| 23463 |
|
| 23464 |
/* .. */ |
| 23465 |
/* .. Local Arrays .. */ |
| 23466 |
/* .. */ |
| 23467 |
/* .. External Subroutines .. */ |
| 23468 |
/* .. */ |
| 23469 |
/* .. Executable Statements .. */ |
| 23470 |
|
| 23471 |
/* ==== If there are no shifts, then there is nothing to do. ==== */ |
| 23472 |
|
| 23473 |
/* Parameter adjustments */ |
| 23474 |
--sr; |
| 23475 |
--si; |
| 23476 |
h_dim1 = *ldh; |
| 23477 |
h_offset = 1 + h_dim1; |
| 23478 |
h__ -= h_offset; |
| 23479 |
z_dim1 = *ldz; |
| 23480 |
z_offset = 1 + z_dim1; |
| 23481 |
z__ -= z_offset; |
| 23482 |
v_dim1 = *ldv; |
| 23483 |
v_offset = 1 + v_dim1; |
| 23484 |
v -= v_offset; |
| 23485 |
u_dim1 = *ldu; |
| 23486 |
u_offset = 1 + u_dim1; |
| 23487 |
u -= u_offset; |
| 23488 |
wv_dim1 = *ldwv; |
| 23489 |
wv_offset = 1 + wv_dim1; |
| 23490 |
wv -= wv_offset; |
| 23491 |
wh_dim1 = *ldwh; |
| 23492 |
wh_offset = 1 + wh_dim1; |
| 23493 |
wh -= wh_offset; |
| 23494 |
|
| 23495 |
/* Function Body */ |
| 23496 |
if (*nshfts < 2) { |
| 23497 |
return 0; |
| 23498 |
} |
| 23499 |
|
| 23500 |
/* ==== If the active block is empty or 1-by-1, then there */ |
| 23501 |
/* . is nothing to do. ==== */ |
| 23502 |
|
| 23503 |
if (*ktop >= *kbot) { |
| 23504 |
return 0; |
| 23505 |
} |
| 23506 |
|
| 23507 |
/* ==== Shuffle shifts into pairs of real shifts and pairs */ |
| 23508 |
/* . of complex conjugate shifts assuming complex */ |
| 23509 |
/* . conjugate shifts are already adjacent to one */ |
| 23510 |
/* . another. ==== */ |
| 23511 |
|
| 23512 |
i__1 = *nshfts - 2; |
| 23513 |
for (i__ = 1; i__ <= i__1; i__ += 2) { |
| 23514 |
if (si[i__] != -si[i__ + 1]) { |
| 23515 |
|
| 23516 |
swap = sr[i__]; |
| 23517 |
sr[i__] = sr[i__ + 1]; |
| 23518 |
sr[i__ + 1] = sr[i__ + 2]; |
| 23519 |
sr[i__ + 2] = swap; |
| 23520 |
|
| 23521 |
swap = si[i__]; |
| 23522 |
si[i__] = si[i__ + 1]; |
| 23523 |
si[i__ + 1] = si[i__ + 2]; |
| 23524 |
si[i__ + 2] = swap; |
| 23525 |
} |
| 23526 |
/* L10: */ |
| 23527 |
} |
| 23528 |
|
| 23529 |
/* ==== NSHFTS is supposed to be even, but if it is odd, */ |
| 23530 |
/* . then simply reduce it by one. The shuffle above */ |
| 23531 |
/* . ensures that the dropped shift is real and that */ |
| 23532 |
/* . the remaining shifts are paired. ==== */ |
| 23533 |
|
| 23534 |
ns = *nshfts - *nshfts % 2; |
| 23535 |
|
| 23536 |
/* ==== Machine constants for deflation ==== */ |
| 23537 |
|
| 23538 |
safmin = dlamch_("SAFE MINIMUM"); |
| 23539 |
safmax = 1. / safmin; |
| 23540 |
dlabad_(&safmin, &safmax); |
| 23541 |
ulp = dlamch_("PRECISION"); |
| 23542 |
smlnum = safmin * ((double) (*n) / ulp); |
| 23543 |
|
| 23544 |
/* ==== Use accumulated reflections to update far-from-diagonal */ |
| 23545 |
/* . entries ? ==== */ |
| 23546 |
|
| 23547 |
accum = *kacc22 == 1 || *kacc22 == 2; |
| 23548 |
|
| 23549 |
/* ==== If so, exploit the 2-by-2 block structure? ==== */ |
| 23550 |
|
| 23551 |
blk22 = ns > 2 && *kacc22 == 2; |
| 23552 |
|
| 23553 |
/* ==== clear trash ==== */ |
| 23554 |
|
| 23555 |
if (*ktop + 2 <= *kbot) { |
| 23556 |
h__[*ktop + 2 + *ktop * h_dim1] = 0.; |
| 23557 |
} |
| 23558 |
|
| 23559 |
/* ==== NBMPS = number of 2-shift bulges in the chain ==== */ |
| 23560 |
|
| 23561 |
nbmps = ns / 2; |
| 23562 |
|
| 23563 |
/* ==== KDU = width of slab ==== */ |
| 23564 |
|
| 23565 |
kdu = nbmps * 6 - 3; |
| 23566 |
|
| 23567 |
/* ==== Create and chase chains of NBMPS bulges ==== */ |
| 23568 |
|
| 23569 |
i__1 = *kbot - 2; |
| 23570 |
i__2 = nbmps * 3 - 2; |
| 23571 |
for (incol = (1 - nbmps) * 3 + *ktop - 1; i__2 < 0 ? incol >= i__1 : |
| 23572 |
incol <= i__1; incol += i__2) { |
| 23573 |
ndcol = incol + kdu; |
| 23574 |
if (accum) { |
| 23575 |
dlaset_("ALL", &kdu, &kdu, &c_b7, &c_b8, &u[u_offset], ldu); |
| 23576 |
} |
| 23577 |
|
| 23578 |
/* ==== Near-the-diagonal bulge chase. The following loop */ |
| 23579 |
/* . performs the near-the-diagonal part of a small bulge */ |
| 23580 |
/* . multi-shift QR sweep. Each 6*NBMPS-2 column diagonal */ |
| 23581 |
/* . chunk extends from column INCOL to column NDCOL */ |
| 23582 |
/* . (including both column INCOL and column NDCOL). The */ |
| 23583 |
/* . following loop chases a 3*NBMPS column long chain of */ |
| 23584 |
/* . NBMPS bulges 3*NBMPS-2 columns to the right. (INCOL */ |
| 23585 |
/* . may be less than KTOP and and NDCOL may be greater than */ |
| 23586 |
/* . KBOT indicating phantom columns from which to chase */ |
| 23587 |
/* . bulges before they are actually introduced or to which */ |
| 23588 |
/* . to chase bulges beyond column KBOT.) ==== */ |
| 23589 |
|
| 23590 |
/* Computing MIN */ |
| 23591 |
i__4 = incol + nbmps * 3 - 3, i__5 = *kbot - 2; |
| 23592 |
i__3 = std::min(i__4,i__5); |
| 23593 |
for (krcol = incol; krcol <= i__3; ++krcol) { |
| 23594 |
|
| 23595 |
/* ==== Bulges number MTOP to MBOT are active double implicit */ |
| 23596 |
/* . shift bulges. There may or may not also be small */ |
| 23597 |
/* . 2-by-2 bulge, if there is room. The inactive bulges */ |
| 23598 |
/* . (if any) must wait until the active bulges have moved */ |
| 23599 |
/* . down the diagonal to make room. The phantom matrix */ |
| 23600 |
/* . paradigm described above helps keep track. ==== */ |
| 23601 |
|
| 23602 |
/* Computing MAX */ |
| 23603 |
i__4 = 1, i__5 = (*ktop - 1 - krcol + 2) / 3 + 1; |
| 23604 |
mtop = std::max(i__4,i__5); |
| 23605 |
/* Computing MIN */ |
| 23606 |
i__4 = nbmps, i__5 = (*kbot - krcol) / 3; |
| 23607 |
mbot = std::min(i__4,i__5); |
| 23608 |
m22 = mbot + 1; |
| 23609 |
bmp22 = mbot < nbmps && krcol + (m22 - 1) * 3 == *kbot - 2; |
| 23610 |
|
| 23611 |
/* ==== Generate reflections to chase the chain right */ |
| 23612 |
/* . one column. (The minimum value of K is KTOP-1.) ==== */ |
| 23613 |
|
| 23614 |
i__4 = mbot; |
| 23615 |
for (m = mtop; m <= i__4; ++m) { |
| 23616 |
k = krcol + (m - 1) * 3; |
| 23617 |
if (k == *ktop - 1) { |
| 23618 |
dlaqr1_(&c__3, &h__[*ktop + *ktop * h_dim1], ldh, &sr[(m |
| 23619 |
<< 1) - 1], &si[(m << 1) - 1], &sr[m * 2], &si[m * |
| 23620 |
2], &v[m * v_dim1 + 1]); |
| 23621 |
alpha = v[m * v_dim1 + 1]; |
| 23622 |
dlarfg_(&c__3, &alpha, &v[m * v_dim1 + 2], &c__1, &v[m * |
| 23623 |
v_dim1 + 1]); |
| 23624 |
} else { |
| 23625 |
beta = h__[k + 1 + k * h_dim1]; |
| 23626 |
v[m * v_dim1 + 2] = h__[k + 2 + k * h_dim1]; |
| 23627 |
v[m * v_dim1 + 3] = h__[k + 3 + k * h_dim1]; |
| 23628 |
dlarfg_(&c__3, &beta, &v[m * v_dim1 + 2], &c__1, &v[m * |
| 23629 |
v_dim1 + 1]); |
| 23630 |
|
| 23631 |
/* ==== A Bulge may collapse because of vigilant */ |
| 23632 |
/* . deflation or destructive underflow. In the */ |
| 23633 |
/* . underflow case, try the two-small-subdiagonals */ |
| 23634 |
/* . trick to try to reinflate the bulge. ==== */ |
| 23635 |
|
| 23636 |
if (h__[k + 3 + k * h_dim1] != 0. || h__[k + 3 + (k + 1) * |
| 23637 |
h_dim1] != 0. || h__[k + 3 + (k + 2) * h_dim1] == |
| 23638 |
0.) { |
| 23639 |
|
| 23640 |
/* ==== Typical case: not collapsed (yet). ==== */ |
| 23641 |
|
| 23642 |
h__[k + 1 + k * h_dim1] = beta; |
| 23643 |
h__[k + 2 + k * h_dim1] = 0.; |
| 23644 |
h__[k + 3 + k * h_dim1] = 0.; |
| 23645 |
} else { |
| 23646 |
|
| 23647 |
/* ==== Atypical case: collapsed. Attempt to */ |
| 23648 |
/* . reintroduce ignoring H(K+1,K) and H(K+2,K). */ |
| 23649 |
/* . If the fill resulting from the new */ |
| 23650 |
/* . reflector is too large, then abandon it. */ |
| 23651 |
/* . Otherwise, use the new one. ==== */ |
| 23652 |
|
| 23653 |
dlaqr1_(&c__3, &h__[k + 1 + (k + 1) * h_dim1], ldh, & |
| 23654 |
sr[(m << 1) - 1], &si[(m << 1) - 1], &sr[m * |
| 23655 |
2], &si[m * 2], vt); |
| 23656 |
alpha = vt[0]; |
| 23657 |
dlarfg_(&c__3, &alpha, &vt[1], &c__1, vt); |
| 23658 |
refsum = vt[0] * (h__[k + 1 + k * h_dim1] + vt[1] * |
| 23659 |
h__[k + 2 + k * h_dim1]); |
| 23660 |
|
| 23661 |
if ((d__1 = h__[k + 2 + k * h_dim1] - refsum * vt[1], |
| 23662 |
abs(d__1)) + (d__2 = refsum * vt[2], abs(d__2) |
| 23663 |
) > ulp * ((d__3 = h__[k + k * h_dim1], abs( |
| 23664 |
d__3)) + (d__4 = h__[k + 1 + (k + 1) * h_dim1] |
| 23665 |
, abs(d__4)) + (d__5 = h__[k + 2 + (k + 2) * |
| 23666 |
h_dim1], abs(d__5)))) { |
| 23667 |
|
| 23668 |
/* ==== Starting a new bulge here would */ |
| 23669 |
/* . create non-negligible fill. Use */ |
| 23670 |
/* . the old one with trepidation. ==== */ |
| 23671 |
|
| 23672 |
h__[k + 1 + k * h_dim1] = beta; |
| 23673 |
h__[k + 2 + k * h_dim1] = 0.; |
| 23674 |
h__[k + 3 + k * h_dim1] = 0.; |
| 23675 |
} else { |
| 23676 |
|
| 23677 |
/* ==== Stating a new bulge here would */ |
| 23678 |
/* . create only negligible fill. */ |
| 23679 |
/* . Replace the old reflector with */ |
| 23680 |
/* . the new one. ==== */ |
| 23681 |
|
| 23682 |
h__[k + 1 + k * h_dim1] -= refsum; |
| 23683 |
h__[k + 2 + k * h_dim1] = 0.; |
| 23684 |
h__[k + 3 + k * h_dim1] = 0.; |
| 23685 |
v[m * v_dim1 + 1] = vt[0]; |
| 23686 |
v[m * v_dim1 + 2] = vt[1]; |
| 23687 |
v[m * v_dim1 + 3] = vt[2]; |
| 23688 |
} |
| 23689 |
} |
| 23690 |
} |
| 23691 |
/* L20: */ |
| 23692 |
} |
| 23693 |
|
| 23694 |
/* ==== Generate a 2-by-2 reflection, if needed. ==== */ |
| 23695 |
|
| 23696 |
k = krcol + (m22 - 1) * 3; |
| 23697 |
if (bmp22) { |
| 23698 |
if (k == *ktop - 1) { |
| 23699 |
dlaqr1_(&c__2, &h__[k + 1 + (k + 1) * h_dim1], ldh, &sr[( |
| 23700 |
m22 << 1) - 1], &si[(m22 << 1) - 1], &sr[m22 * 2], |
| 23701 |
&si[m22 * 2], &v[m22 * v_dim1 + 1]); |
| 23702 |
beta = v[m22 * v_dim1 + 1]; |
| 23703 |
dlarfg_(&c__2, &beta, &v[m22 * v_dim1 + 2], &c__1, &v[m22 |
| 23704 |
* v_dim1 + 1]); |
| 23705 |
} else { |
| 23706 |
beta = h__[k + 1 + k * h_dim1]; |
| 23707 |
v[m22 * v_dim1 + 2] = h__[k + 2 + k * h_dim1]; |
| 23708 |
dlarfg_(&c__2, &beta, &v[m22 * v_dim1 + 2], &c__1, &v[m22 |
| 23709 |
* v_dim1 + 1]); |
| 23710 |
h__[k + 1 + k * h_dim1] = beta; |
| 23711 |
h__[k + 2 + k * h_dim1] = 0.; |
| 23712 |
} |
| 23713 |
} |
| 23714 |
|
| 23715 |
/* ==== Multiply H by reflections from the left ==== */ |
| 23716 |
|
| 23717 |
if (accum) { |
| 23718 |
jbot = std::min(ndcol,*kbot); |
| 23719 |
} else if (*wantt) { |
| 23720 |
jbot = *n; |
| 23721 |
} else { |
| 23722 |
jbot = *kbot; |
| 23723 |
} |
| 23724 |
i__4 = jbot; |
| 23725 |
for (j = std::max(*ktop,krcol); j <= i__4; ++j) { |
| 23726 |
/* Computing MIN */ |
| 23727 |
i__5 = mbot, i__6 = (j - krcol + 2) / 3; |
| 23728 |
mend = std::min(i__5,i__6); |
| 23729 |
i__5 = mend; |
| 23730 |
for (m = mtop; m <= i__5; ++m) { |
| 23731 |
k = krcol + (m - 1) * 3; |
| 23732 |
refsum = v[m * v_dim1 + 1] * (h__[k + 1 + j * h_dim1] + v[ |
| 23733 |
m * v_dim1 + 2] * h__[k + 2 + j * h_dim1] + v[m * |
| 23734 |
v_dim1 + 3] * h__[k + 3 + j * h_dim1]); |
| 23735 |
h__[k + 1 + j * h_dim1] -= refsum; |
| 23736 |
h__[k + 2 + j * h_dim1] -= refsum * v[m * v_dim1 + 2]; |
| 23737 |
h__[k + 3 + j * h_dim1] -= refsum * v[m * v_dim1 + 3]; |
| 23738 |
/* L30: */ |
| 23739 |
} |
| 23740 |
/* L40: */ |
| 23741 |
} |
| 23742 |
if (bmp22) { |
| 23743 |
k = krcol + (m22 - 1) * 3; |
| 23744 |
/* Computing MAX */ |
| 23745 |
i__4 = k + 1; |
| 23746 |
i__5 = jbot; |
| 23747 |
for (j = std::max(i__4,*ktop); j <= i__5; ++j) { |
| 23748 |
refsum = v[m22 * v_dim1 + 1] * (h__[k + 1 + j * h_dim1] + |
| 23749 |
v[m22 * v_dim1 + 2] * h__[k + 2 + j * h_dim1]); |
| 23750 |
h__[k + 1 + j * h_dim1] -= refsum; |
| 23751 |
h__[k + 2 + j * h_dim1] -= refsum * v[m22 * v_dim1 + 2]; |
| 23752 |
/* L50: */ |
| 23753 |
} |
| 23754 |
} |
| 23755 |
|
| 23756 |
/* ==== Multiply H by reflections from the right. */ |
| 23757 |
/* . Delay filling in the last row until the */ |
| 23758 |
/* . vigilant deflation check is complete. ==== */ |
| 23759 |
|
| 23760 |
if (accum) { |
| 23761 |
jtop = std::max(*ktop,incol); |
| 23762 |
} else if (*wantt) { |
| 23763 |
jtop = 1; |
| 23764 |
} else { |
| 23765 |
jtop = *ktop; |
| 23766 |
} |
| 23767 |
i__5 = mbot; |
| 23768 |
for (m = mtop; m <= i__5; ++m) { |
| 23769 |
if (v[m * v_dim1 + 1] != 0.) { |
| 23770 |
k = krcol + (m - 1) * 3; |
| 23771 |
/* Computing MIN */ |
| 23772 |
i__6 = *kbot, i__7 = k + 3; |
| 23773 |
i__4 = std::min(i__6,i__7); |
| 23774 |
for (j = jtop; j <= i__4; ++j) { |
| 23775 |
refsum = v[m * v_dim1 + 1] * (h__[j + (k + 1) * |
| 23776 |
h_dim1] + v[m * v_dim1 + 2] * h__[j + (k + 2) |
| 23777 |
* h_dim1] + v[m * v_dim1 + 3] * h__[j + (k + |
| 23778 |
3) * h_dim1]); |
| 23779 |
h__[j + (k + 1) * h_dim1] -= refsum; |
| 23780 |
h__[j + (k + 2) * h_dim1] -= refsum * v[m * v_dim1 + |
| 23781 |
2]; |
| 23782 |
h__[j + (k + 3) * h_dim1] -= refsum * v[m * v_dim1 + |
| 23783 |
3]; |
| 23784 |
/* L60: */ |
| 23785 |
} |
| 23786 |
|
| 23787 |
if (accum) { |
| 23788 |
|
| 23789 |
/* ==== Accumulate U. (If necessary, update Z later */ |
| 23790 |
/* . with with an efficient matrix-matrix */ |
| 23791 |
/* . multiply.) ==== */ |
| 23792 |
|
| 23793 |
kms = k - incol; |
| 23794 |
/* Computing MAX */ |
| 23795 |
i__4 = 1, i__6 = *ktop - incol; |
| 23796 |
i__7 = kdu; |
| 23797 |
for (j = std::max(i__4,i__6); j <= i__7; ++j) { |
| 23798 |
refsum = v[m * v_dim1 + 1] * (u[j + (kms + 1) * |
| 23799 |
u_dim1] + v[m * v_dim1 + 2] * u[j + (kms |
| 23800 |
+ 2) * u_dim1] + v[m * v_dim1 + 3] * u[j |
| 23801 |
+ (kms + 3) * u_dim1]); |
| 23802 |
u[j + (kms + 1) * u_dim1] -= refsum; |
| 23803 |
u[j + (kms + 2) * u_dim1] -= refsum * v[m * |
| 23804 |
v_dim1 + 2]; |
| 23805 |
u[j + (kms + 3) * u_dim1] -= refsum * v[m * |
| 23806 |
v_dim1 + 3]; |
| 23807 |
/* L70: */ |
| 23808 |
} |
| 23809 |
} else if (*wantz) { |
| 23810 |
|
| 23811 |
/* ==== U is not accumulated, so update Z */ |
| 23812 |
/* . now by multiplying by reflections */ |
| 23813 |
/* . from the right. ==== */ |
| 23814 |
|
| 23815 |
i__7 = *ihiz; |
| 23816 |
for (j = *iloz; j <= i__7; ++j) { |
| 23817 |
refsum = v[m * v_dim1 + 1] * (z__[j + (k + 1) * |
| 23818 |
z_dim1] + v[m * v_dim1 + 2] * z__[j + (k |
| 23819 |
+ 2) * z_dim1] + v[m * v_dim1 + 3] * z__[ |
| 23820 |
j + (k + 3) * z_dim1]); |
| 23821 |
z__[j + (k + 1) * z_dim1] -= refsum; |
| 23822 |
z__[j + (k + 2) * z_dim1] -= refsum * v[m * |
| 23823 |
v_dim1 + 2]; |
| 23824 |
z__[j + (k + 3) * z_dim1] -= refsum * v[m * |
| 23825 |
v_dim1 + 3]; |
| 23826 |
/* L80: */ |
| 23827 |
} |
| 23828 |
} |
| 23829 |
} |
| 23830 |
/* L90: */ |
| 23831 |
} |
| 23832 |
|
| 23833 |
/* ==== Special case: 2-by-2 reflection (if needed) ==== */ |
| 23834 |
|
| 23835 |
k = krcol + (m22 - 1) * 3; |
| 23836 |
if (bmp22 && v[m22 * v_dim1 + 1] != 0.) { |
| 23837 |
/* Computing MIN */ |
| 23838 |
i__7 = *kbot, i__4 = k + 3; |
| 23839 |
i__5 = std::min(i__7,i__4); |
| 23840 |
for (j = jtop; j <= i__5; ++j) { |
| 23841 |
refsum = v[m22 * v_dim1 + 1] * (h__[j + (k + 1) * h_dim1] |
| 23842 |
+ v[m22 * v_dim1 + 2] * h__[j + (k + 2) * h_dim1]) |
| 23843 |
; |
| 23844 |
h__[j + (k + 1) * h_dim1] -= refsum; |
| 23845 |
h__[j + (k + 2) * h_dim1] -= refsum * v[m22 * v_dim1 + 2]; |
| 23846 |
/* L100: */ |
| 23847 |
} |
| 23848 |
|
| 23849 |
if (accum) { |
| 23850 |
kms = k - incol; |
| 23851 |
/* Computing MAX */ |
| 23852 |
i__5 = 1, i__7 = *ktop - incol; |
| 23853 |
i__4 = kdu; |
| 23854 |
for (j = std::max(i__5,i__7); j <= i__4; ++j) { |
| 23855 |
refsum = v[m22 * v_dim1 + 1] * (u[j + (kms + 1) * |
| 23856 |
u_dim1] + v[m22 * v_dim1 + 2] * u[j + (kms + |
| 23857 |
2) * u_dim1]); |
| 23858 |
u[j + (kms + 1) * u_dim1] -= refsum; |
| 23859 |
u[j + (kms + 2) * u_dim1] -= refsum * v[m22 * v_dim1 |
| 23860 |
+ 2]; |
| 23861 |
/* L110: */ |
| 23862 |
} |
| 23863 |
} else if (*wantz) { |
| 23864 |
i__4 = *ihiz; |
| 23865 |
for (j = *iloz; j <= i__4; ++j) { |
| 23866 |
refsum = v[m22 * v_dim1 + 1] * (z__[j + (k + 1) * |
| 23867 |
z_dim1] + v[m22 * v_dim1 + 2] * z__[j + (k + |
| 23868 |
2) * z_dim1]); |
| 23869 |
z__[j + (k + 1) * z_dim1] -= refsum; |
| 23870 |
z__[j + (k + 2) * z_dim1] -= refsum * v[m22 * v_dim1 |
| 23871 |
+ 2]; |
| 23872 |
/* L120: */ |
| 23873 |
} |
| 23874 |
} |
| 23875 |
} |
| 23876 |
|
| 23877 |
/* ==== Vigilant deflation check ==== */ |
| 23878 |
|
| 23879 |
mstart = mtop; |
| 23880 |
if (krcol + (mstart - 1) * 3 < *ktop) { |
| 23881 |
++mstart; |
| 23882 |
} |
| 23883 |
mend = mbot; |
| 23884 |
if (bmp22) { |
| 23885 |
++mend; |
| 23886 |
} |
| 23887 |
if (krcol == *kbot - 2) { |
| 23888 |
++mend; |
| 23889 |
} |
| 23890 |
i__4 = mend; |
| 23891 |
for (m = mstart; m <= i__4; ++m) { |
| 23892 |
/* Computing MIN */ |
| 23893 |
i__5 = *kbot - 1, i__7 = krcol + (m - 1) * 3; |
| 23894 |
k = std::min(i__5,i__7); |
| 23895 |
|
| 23896 |
/* ==== The following convergence test requires that */ |
| 23897 |
/* . the tradition small-compared-to-nearby-diagonals */ |
| 23898 |
/* . criterion and the Ahues & Tisseur (LAWN 122, 1997) */ |
| 23899 |
/* . criteria both be satisfied. The latter improves */ |
| 23900 |
/* . accuracy in some examples. Falling back on an */ |
| 23901 |
/* . alternate convergence criterion when TST1 or TST2 */ |
| 23902 |
/* . is zero (as done here) is traditional but probably */ |
| 23903 |
/* . unnecessary. ==== */ |
| 23904 |
|
| 23905 |
if (h__[k + 1 + k * h_dim1] != 0.) { |
| 23906 |
tst1 = (d__1 = h__[k + k * h_dim1], abs(d__1)) + (d__2 = |
| 23907 |
h__[k + 1 + (k + 1) * h_dim1], abs(d__2)); |
| 23908 |
if (tst1 == 0.) { |
| 23909 |
if (k >= *ktop + 1) { |
| 23910 |
tst1 += (d__1 = h__[k + (k - 1) * h_dim1], abs( |
| 23911 |
d__1)); |
| 23912 |
} |
| 23913 |
if (k >= *ktop + 2) { |
| 23914 |
tst1 += (d__1 = h__[k + (k - 2) * h_dim1], abs( |
| 23915 |
d__1)); |
| 23916 |
} |
| 23917 |
if (k >= *ktop + 3) { |
| 23918 |
tst1 += (d__1 = h__[k + (k - 3) * h_dim1], abs( |
| 23919 |
d__1)); |
| 23920 |
} |
| 23921 |
if (k <= *kbot - 2) { |
| 23922 |
tst1 += (d__1 = h__[k + 2 + (k + 1) * h_dim1], |
| 23923 |
abs(d__1)); |
| 23924 |
} |
| 23925 |
if (k <= *kbot - 3) { |
| 23926 |
tst1 += (d__1 = h__[k + 3 + (k + 1) * h_dim1], |
| 23927 |
abs(d__1)); |
| 23928 |
} |
| 23929 |
if (k <= *kbot - 4) { |
| 23930 |
tst1 += (d__1 = h__[k + 4 + (k + 1) * h_dim1], |
| 23931 |
abs(d__1)); |
| 23932 |
} |
| 23933 |
} |
| 23934 |
/* Computing MAX */ |
| 23935 |
d__2 = smlnum, d__3 = ulp * tst1; |
| 23936 |
if ((d__1 = h__[k + 1 + k * h_dim1], abs(d__1)) <= std::max( |
| 23937 |
d__2,d__3)) { |
| 23938 |
/* Computing MAX */ |
| 23939 |
d__3 = (d__1 = h__[k + 1 + k * h_dim1], abs(d__1)), |
| 23940 |
d__4 = (d__2 = h__[k + (k + 1) * h_dim1], abs( |
| 23941 |
d__2)); |
| 23942 |
h12 = std::max(d__3,d__4); |
| 23943 |
/* Computing MIN */ |
| 23944 |
d__3 = (d__1 = h__[k + 1 + k * h_dim1], abs(d__1)), |
| 23945 |
d__4 = (d__2 = h__[k + (k + 1) * h_dim1], abs( |
| 23946 |
d__2)); |
| 23947 |
h21 = std::min(d__3,d__4); |
| 23948 |
/* Computing MAX */ |
| 23949 |
d__3 = (d__1 = h__[k + 1 + (k + 1) * h_dim1], abs( |
| 23950 |
d__1)), d__4 = (d__2 = h__[k + k * h_dim1] - |
| 23951 |
h__[k + 1 + (k + 1) * h_dim1], abs(d__2)); |
| 23952 |
h11 = std::max(d__3,d__4); |
| 23953 |
/* Computing MIN */ |
| 23954 |
d__3 = (d__1 = h__[k + 1 + (k + 1) * h_dim1], abs( |
| 23955 |
d__1)), d__4 = (d__2 = h__[k + k * h_dim1] - |
| 23956 |
h__[k + 1 + (k + 1) * h_dim1], abs(d__2)); |
| 23957 |
h22 = std::min(d__3,d__4); |
| 23958 |
scl = h11 + h12; |
| 23959 |
tst2 = h22 * (h11 / scl); |
| 23960 |
|
| 23961 |
/* Computing MAX */ |
| 23962 |
d__1 = smlnum, d__2 = ulp * tst2; |
| 23963 |
if (tst2 == 0. || h21 * (h12 / scl) <= std::max(d__1,d__2)) |
| 23964 |
{ |
| 23965 |
h__[k + 1 + k * h_dim1] = 0.; |
| 23966 |
} |
| 23967 |
} |
| 23968 |
} |
| 23969 |
/* L130: */ |
| 23970 |
} |
| 23971 |
|
| 23972 |
/* ==== Fill in the last row of each bulge. ==== */ |
| 23973 |
|
| 23974 |
/* Computing MIN */ |
| 23975 |
i__4 = nbmps, i__5 = (*kbot - krcol - 1) / 3; |
| 23976 |
mend = std::min(i__4,i__5); |
| 23977 |
i__4 = mend; |
| 23978 |
for (m = mtop; m <= i__4; ++m) { |
| 23979 |
k = krcol + (m - 1) * 3; |
| 23980 |
refsum = v[m * v_dim1 + 1] * v[m * v_dim1 + 3] * h__[k + 4 + ( |
| 23981 |
k + 3) * h_dim1]; |
| 23982 |
h__[k + 4 + (k + 1) * h_dim1] = -refsum; |
| 23983 |
h__[k + 4 + (k + 2) * h_dim1] = -refsum * v[m * v_dim1 + 2]; |
| 23984 |
h__[k + 4 + (k + 3) * h_dim1] -= refsum * v[m * v_dim1 + 3]; |
| 23985 |
/* L140: */ |
| 23986 |
} |
| 23987 |
|
| 23988 |
/* ==== End of near-the-diagonal bulge chase. ==== */ |
| 23989 |
|
| 23990 |
/* L150: */ |
| 23991 |
} |
| 23992 |
|
| 23993 |
/* ==== Use U (if accumulated) to update far-from-diagonal */ |
| 23994 |
/* . entries in H. If required, use U to update Z as */ |
| 23995 |
/* . well. ==== */ |
| 23996 |
|
| 23997 |
if (accum) { |
| 23998 |
if (*wantt) { |
| 23999 |
jtop = 1; |
| 24000 |
jbot = *n; |
| 24001 |
} else { |
| 24002 |
jtop = *ktop; |
| 24003 |
jbot = *kbot; |
| 24004 |
} |
| 24005 |
if (! blk22 || incol < *ktop || ndcol > *kbot || ns <= 2) { |
| 24006 |
|
| 24007 |
/* ==== Updates not exploiting the 2-by-2 block */ |
| 24008 |
/* . structure of U. K1 and NU keep track of */ |
| 24009 |
/* . the location and size of U in the special */ |
| 24010 |
/* . cases of introducing bulges and chasing */ |
| 24011 |
/* . bulges off the bottom. In these special */ |
| 24012 |
/* . cases and in case the number of shifts */ |
| 24013 |
/* . is NS = 2, there is no 2-by-2 block */ |
| 24014 |
/* . structure to exploit. ==== */ |
| 24015 |
|
| 24016 |
/* Computing MAX */ |
| 24017 |
i__3 = 1, i__4 = *ktop - incol; |
| 24018 |
k1 = std::max(i__3,i__4); |
| 24019 |
/* Computing MAX */ |
| 24020 |
i__3 = 0, i__4 = ndcol - *kbot; |
| 24021 |
nu = kdu - std::max(i__3,i__4) - k1 + 1; |
| 24022 |
|
| 24023 |
/* ==== Horizontal Multiply ==== */ |
| 24024 |
|
| 24025 |
i__3 = jbot; |
| 24026 |
i__4 = *nh; |
| 24027 |
for (jcol = std::min(ndcol,*kbot) + 1; i__4 < 0 ? jcol >= i__3 : |
| 24028 |
jcol <= i__3; jcol += i__4) { |
| 24029 |
/* Computing MIN */ |
| 24030 |
i__5 = *nh, i__7 = jbot - jcol + 1; |
| 24031 |
jlen = std::min(i__5,i__7); |
| 24032 |
dgemm_("C", "N", &nu, &jlen, &nu, &c_b8, &u[k1 + k1 * |
| 24033 |
u_dim1], ldu, &h__[incol + k1 + jcol * h_dim1], |
| 24034 |
ldh, &c_b7, &wh[wh_offset], ldwh); |
| 24035 |
dlacpy_("ALL", &nu, &jlen, &wh[wh_offset], ldwh, &h__[ |
| 24036 |
incol + k1 + jcol * h_dim1], ldh); |
| 24037 |
/* L160: */ |
| 24038 |
} |
| 24039 |
|
| 24040 |
/* ==== Vertical multiply ==== */ |
| 24041 |
|
| 24042 |
i__4 = std::max(*ktop,incol) - 1; |
| 24043 |
i__3 = *nv; |
| 24044 |
for (jrow = jtop; i__3 < 0 ? jrow >= i__4 : jrow <= i__4; |
| 24045 |
jrow += i__3) { |
| 24046 |
/* Computing MIN */ |
| 24047 |
i__5 = *nv, i__7 = std::max(*ktop,incol) - jrow; |
| 24048 |
jlen = std::min(i__5,i__7); |
| 24049 |
dgemm_("N", "N", &jlen, &nu, &nu, &c_b8, &h__[jrow + ( |
| 24050 |
incol + k1) * h_dim1], ldh, &u[k1 + k1 * u_dim1], |
| 24051 |
ldu, &c_b7, &wv[wv_offset], ldwv); |
| 24052 |
dlacpy_("ALL", &jlen, &nu, &wv[wv_offset], ldwv, &h__[ |
| 24053 |
jrow + (incol + k1) * h_dim1], ldh); |
| 24054 |
/* L170: */ |
| 24055 |
} |
| 24056 |
|
| 24057 |
/* ==== Z multiply (also vertical) ==== */ |
| 24058 |
|
| 24059 |
if (*wantz) { |
| 24060 |
i__3 = *ihiz; |
| 24061 |
i__4 = *nv; |
| 24062 |
for (jrow = *iloz; i__4 < 0 ? jrow >= i__3 : jrow <= i__3; |
| 24063 |
jrow += i__4) { |
| 24064 |
/* Computing MIN */ |
| 24065 |
i__5 = *nv, i__7 = *ihiz - jrow + 1; |
| 24066 |
jlen = std::min(i__5,i__7); |
| 24067 |
dgemm_("N", "N", &jlen, &nu, &nu, &c_b8, &z__[jrow + ( |
| 24068 |
incol + k1) * z_dim1], ldz, &u[k1 + k1 * |
| 24069 |
u_dim1], ldu, &c_b7, &wv[wv_offset], ldwv); |
| 24070 |
dlacpy_("ALL", &jlen, &nu, &wv[wv_offset], ldwv, &z__[ |
| 24071 |
jrow + (incol + k1) * z_dim1], ldz) |
| 24072 |
; |
| 24073 |
/* L180: */ |
| 24074 |
} |
| 24075 |
} |
| 24076 |
} else { |
| 24077 |
|
| 24078 |
/* ==== Updates exploiting U's 2-by-2 block structure. */ |
| 24079 |
/* . (I2, I4, J2, J4 are the last rows and columns */ |
| 24080 |
/* . of the blocks.) ==== */ |
| 24081 |
|
| 24082 |
i2 = (kdu + 1) / 2; |
| 24083 |
i4 = kdu; |
| 24084 |
j2 = i4 - i2; |
| 24085 |
j4 = kdu; |
| 24086 |
|
| 24087 |
/* ==== KZS and KNZ deal with the band of zeros */ |
| 24088 |
/* . along the diagonal of one of the triangular */ |
| 24089 |
/* . blocks. ==== */ |
| 24090 |
|
| 24091 |
kzs = j4 - j2 - (ns + 1); |
| 24092 |
knz = ns + 1; |
| 24093 |
|
| 24094 |
/* ==== Horizontal multiply ==== */ |
| 24095 |
|
| 24096 |
i__4 = jbot; |
| 24097 |
i__3 = *nh; |
| 24098 |
for (jcol = std::min(ndcol,*kbot) + 1; i__3 < 0 ? jcol >= i__4 : |
| 24099 |
jcol <= i__4; jcol += i__3) { |
| 24100 |
/* Computing MIN */ |
| 24101 |
i__5 = *nh, i__7 = jbot - jcol + 1; |
| 24102 |
jlen = std::min(i__5,i__7); |
| 24103 |
|
| 24104 |
/* ==== Copy bottom of H to top+KZS of scratch ==== */ |
| 24105 |
/* (The first KZS rows get multiplied by zero.) ==== */ |
| 24106 |
|
| 24107 |
dlacpy_("ALL", &knz, &jlen, &h__[incol + 1 + j2 + jcol * |
| 24108 |
h_dim1], ldh, &wh[kzs + 1 + wh_dim1], ldwh); |
| 24109 |
|
| 24110 |
/* ==== Multiply by U21' ==== */ |
| 24111 |
|
| 24112 |
dlaset_("ALL", &kzs, &jlen, &c_b7, &c_b7, &wh[wh_offset], |
| 24113 |
ldwh); |
| 24114 |
dtrmm_("L", "U", "C", "N", &knz, &jlen, &c_b8, &u[j2 + 1 |
| 24115 |
+ (kzs + 1) * u_dim1], ldu, &wh[kzs + 1 + wh_dim1] |
| 24116 |
, ldwh); |
| 24117 |
|
| 24118 |
/* ==== Multiply top of H by U11' ==== */ |
| 24119 |
|
| 24120 |
dgemm_("C", "N", &i2, &jlen, &j2, &c_b8, &u[u_offset], |
| 24121 |
ldu, &h__[incol + 1 + jcol * h_dim1], ldh, &c_b8, |
| 24122 |
&wh[wh_offset], ldwh); |
| 24123 |
|
| 24124 |
/* ==== Copy top of H to bottom of WH ==== */ |
| 24125 |
|
| 24126 |
dlacpy_("ALL", &j2, &jlen, &h__[incol + 1 + jcol * h_dim1] |
| 24127 |
, ldh, &wh[i2 + 1 + wh_dim1], ldwh); |
| 24128 |
|
| 24129 |
/* ==== Multiply by U21' ==== */ |
| 24130 |
|
| 24131 |
dtrmm_("L", "L", "C", "N", &j2, &jlen, &c_b8, &u[(i2 + 1) |
| 24132 |
* u_dim1 + 1], ldu, &wh[i2 + 1 + wh_dim1], ldwh); |
| 24133 |
|
| 24134 |
/* ==== Multiply by U22 ==== */ |
| 24135 |
|
| 24136 |
i__5 = i4 - i2; |
| 24137 |
i__7 = j4 - j2; |
| 24138 |
dgemm_("C", "N", &i__5, &jlen, &i__7, &c_b8, &u[j2 + 1 + ( |
| 24139 |
i2 + 1) * u_dim1], ldu, &h__[incol + 1 + j2 + |
| 24140 |
jcol * h_dim1], ldh, &c_b8, &wh[i2 + 1 + wh_dim1], |
| 24141 |
ldwh); |
| 24142 |
|
| 24143 |
/* ==== Copy it back ==== */ |
| 24144 |
|
| 24145 |
dlacpy_("ALL", &kdu, &jlen, &wh[wh_offset], ldwh, &h__[ |
| 24146 |
incol + 1 + jcol * h_dim1], ldh); |
| 24147 |
/* L190: */ |
| 24148 |
} |
| 24149 |
|
| 24150 |
/* ==== Vertical multiply ==== */ |
| 24151 |
|
| 24152 |
i__3 = std::max(incol,*ktop) - 1; |
| 24153 |
i__4 = *nv; |
| 24154 |
for (jrow = jtop; i__4 < 0 ? jrow >= i__3 : jrow <= i__3; |
| 24155 |
jrow += i__4) { |
| 24156 |
/* Computing MIN */ |
| 24157 |
i__5 = *nv, i__7 = std::max(incol,*ktop) - jrow; |
| 24158 |
jlen = std::min(i__5,i__7); |
| 24159 |
|
| 24160 |
/* ==== Copy right of H to scratch (the first KZS */ |
| 24161 |
/* . columns get multiplied by zero) ==== */ |
| 24162 |
|
| 24163 |
dlacpy_("ALL", &jlen, &knz, &h__[jrow + (incol + 1 + j2) * |
| 24164 |
h_dim1], ldh, &wv[(kzs + 1) * wv_dim1 + 1], ldwv); |
| 24165 |
|
| 24166 |
/* ==== Multiply by U21 ==== */ |
| 24167 |
|
| 24168 |
dlaset_("ALL", &jlen, &kzs, &c_b7, &c_b7, &wv[wv_offset], |
| 24169 |
ldwv); |
| 24170 |
dtrmm_("R", "U", "N", "N", &jlen, &knz, &c_b8, &u[j2 + 1 |
| 24171 |
+ (kzs + 1) * u_dim1], ldu, &wv[(kzs + 1) * |
| 24172 |
wv_dim1 + 1], ldwv); |
| 24173 |
|
| 24174 |
/* ==== Multiply by U11 ==== */ |
| 24175 |
|
| 24176 |
dgemm_("N", "N", &jlen, &i2, &j2, &c_b8, &h__[jrow + ( |
| 24177 |
incol + 1) * h_dim1], ldh, &u[u_offset], ldu, & |
| 24178 |
c_b8, &wv[wv_offset], ldwv); |
| 24179 |
|
| 24180 |
/* ==== Copy left of H to right of scratch ==== */ |
| 24181 |
|
| 24182 |
dlacpy_("ALL", &jlen, &j2, &h__[jrow + (incol + 1) * |
| 24183 |
h_dim1], ldh, &wv[(i2 + 1) * wv_dim1 + 1], ldwv); |
| 24184 |
|
| 24185 |
/* ==== Multiply by U21 ==== */ |
| 24186 |
|
| 24187 |
i__5 = i4 - i2; |
| 24188 |
dtrmm_("R", "L", "N", "N", &jlen, &i__5, &c_b8, &u[(i2 + |
| 24189 |
1) * u_dim1 + 1], ldu, &wv[(i2 + 1) * wv_dim1 + 1] |
| 24190 |
, ldwv); |
| 24191 |
|
| 24192 |
/* ==== Multiply by U22 ==== */ |
| 24193 |
|
| 24194 |
i__5 = i4 - i2; |
| 24195 |
i__7 = j4 - j2; |
| 24196 |
dgemm_("N", "N", &jlen, &i__5, &i__7, &c_b8, &h__[jrow + ( |
| 24197 |
incol + 1 + j2) * h_dim1], ldh, &u[j2 + 1 + (i2 + |
| 24198 |
1) * u_dim1], ldu, &c_b8, &wv[(i2 + 1) * wv_dim1 |
| 24199 |
+ 1], ldwv); |
| 24200 |
|
| 24201 |
/* ==== Copy it back ==== */ |
| 24202 |
|
| 24203 |
dlacpy_("ALL", &jlen, &kdu, &wv[wv_offset], ldwv, &h__[ |
| 24204 |
jrow + (incol + 1) * h_dim1], ldh); |
| 24205 |
/* L200: */ |
| 24206 |
} |
| 24207 |
|
| 24208 |
/* ==== Multiply Z (also vertical) ==== */ |
| 24209 |
|
| 24210 |
if (*wantz) { |
| 24211 |
i__4 = *ihiz; |
| 24212 |
i__3 = *nv; |
| 24213 |
for (jrow = *iloz; i__3 < 0 ? jrow >= i__4 : jrow <= i__4; |
| 24214 |
jrow += i__3) { |
| 24215 |
/* Computing MIN */ |
| 24216 |
i__5 = *nv, i__7 = *ihiz - jrow + 1; |
| 24217 |
jlen = std::min(i__5,i__7); |
| 24218 |
|
| 24219 |
/* ==== Copy right of Z to left of scratch (first */ |
| 24220 |
/* . KZS columns get multiplied by zero) ==== */ |
| 24221 |
|
| 24222 |
dlacpy_("ALL", &jlen, &knz, &z__[jrow + (incol + 1 + |
| 24223 |
j2) * z_dim1], ldz, &wv[(kzs + 1) * wv_dim1 + |
| 24224 |
1], ldwv); |
| 24225 |
|
| 24226 |
/* ==== Multiply by U12 ==== */ |
| 24227 |
|
| 24228 |
dlaset_("ALL", &jlen, &kzs, &c_b7, &c_b7, &wv[ |
| 24229 |
wv_offset], ldwv); |
| 24230 |
dtrmm_("R", "U", "N", "N", &jlen, &knz, &c_b8, &u[j2 |
| 24231 |
+ 1 + (kzs + 1) * u_dim1], ldu, &wv[(kzs + 1) |
| 24232 |
* wv_dim1 + 1], ldwv); |
| 24233 |
|
| 24234 |
/* ==== Multiply by U11 ==== */ |
| 24235 |
|
| 24236 |
dgemm_("N", "N", &jlen, &i2, &j2, &c_b8, &z__[jrow + ( |
| 24237 |
incol + 1) * z_dim1], ldz, &u[u_offset], ldu, |
| 24238 |
&c_b8, &wv[wv_offset], ldwv); |
| 24239 |
|
| 24240 |
/* ==== Copy left of Z to right of scratch ==== */ |
| 24241 |
|
| 24242 |
dlacpy_("ALL", &jlen, &j2, &z__[jrow + (incol + 1) * |
| 24243 |
z_dim1], ldz, &wv[(i2 + 1) * wv_dim1 + 1], |
| 24244 |
ldwv); |
| 24245 |
|
| 24246 |
/* ==== Multiply by U21 ==== */ |
| 24247 |
|
| 24248 |
i__5 = i4 - i2; |
| 24249 |
dtrmm_("R", "L", "N", "N", &jlen, &i__5, &c_b8, &u[( |
| 24250 |
i2 + 1) * u_dim1 + 1], ldu, &wv[(i2 + 1) * |
| 24251 |
wv_dim1 + 1], ldwv); |
| 24252 |
|
| 24253 |
/* ==== Multiply by U22 ==== */ |
| 24254 |
|
| 24255 |
i__5 = i4 - i2; |
| 24256 |
i__7 = j4 - j2; |
| 24257 |
dgemm_("N", "N", &jlen, &i__5, &i__7, &c_b8, &z__[ |
| 24258 |
jrow + (incol + 1 + j2) * z_dim1], ldz, &u[j2 |
| 24259 |
+ 1 + (i2 + 1) * u_dim1], ldu, &c_b8, &wv[(i2 |
| 24260 |
+ 1) * wv_dim1 + 1], ldwv); |
| 24261 |
|
| 24262 |
/* ==== Copy the result back to Z ==== */ |
| 24263 |
|
| 24264 |
dlacpy_("ALL", &jlen, &kdu, &wv[wv_offset], ldwv, & |
| 24265 |
z__[jrow + (incol + 1) * z_dim1], ldz); |
| 24266 |
/* L210: */ |
| 24267 |
} |
| 24268 |
} |
| 24269 |
} |
| 24270 |
} |
| 24271 |
/* L220: */ |
| 24272 |
} |
| 24273 |
|
| 24274 |
/* ==== End of DLAQR5 ==== */ |
| 24275 |
|
| 24276 |
return 0; |
| 24277 |
} /* dlaqr5_ */ |
| 24278 |
|
| 24279 |
/* Subroutine */ int dlaqsb_(const char *uplo, integer *n, integer *kd, double * |
| 24280 |
ab, integer *ldab, double *s, double *scond, double *amax, |
| 24281 |
const char *equed) |
| 24282 |
{ |
| 24283 |
/* System generated locals */ |
| 24284 |
integer ab_dim1, ab_offset, i__1, i__2, i__3, i__4; |
| 24285 |
|
| 24286 |
/* Local variables */ |
| 24287 |
integer i__, j; |
| 24288 |
double cj, large; |
| 24289 |
|
| 24290 |
double small; |
| 24291 |
|
| 24292 |
|
| 24293 |
|
| 24294 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 24295 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 24296 |
/* November 2006 */ |
| 24297 |
|
| 24298 |
/* .. Scalar Arguments .. */ |
| 24299 |
/* .. */ |
| 24300 |
/* .. Array Arguments .. */ |
| 24301 |
/* .. */ |
| 24302 |
|
| 24303 |
/* Purpose */ |
| 24304 |
/* ======= */ |
| 24305 |
|
| 24306 |
/* DLAQSB equilibrates a symmetric band matrix A using the scaling */ |
| 24307 |
/* factors in the vector S. */ |
| 24308 |
|
| 24309 |
/* Arguments */ |
| 24310 |
/* ========= */ |
| 24311 |
|
| 24312 |
/* UPLO (input) CHARACTER*1 */ |
| 24313 |
/* Specifies whether the upper or lower triangular part of the */ |
| 24314 |
/* symmetric matrix A is stored. */ |
| 24315 |
/* = 'U': Upper triangular */ |
| 24316 |
/* = 'L': Lower triangular */ |
| 24317 |
|
| 24318 |
/* N (input) INTEGER */ |
| 24319 |
/* The order of the matrix A. N >= 0. */ |
| 24320 |
|
| 24321 |
/* KD (input) INTEGER */ |
| 24322 |
/* The number of super-diagonals of the matrix A if UPLO = 'U', */ |
| 24323 |
/* or the number of sub-diagonals if UPLO = 'L'. KD >= 0. */ |
| 24324 |
|
| 24325 |
/* AB (input/output) DOUBLE PRECISION array, dimension (LDAB,N) */ |
| 24326 |
/* On entry, the upper or lower triangle of the symmetric band */ |
| 24327 |
/* matrix A, stored in the first KD+1 rows of the array. The */ |
| 24328 |
/* j-th column of A is stored in the j-th column of the array AB */ |
| 24329 |
/* as follows: */ |
| 24330 |
/* if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j; */ |
| 24331 |
/* if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd). */ |
| 24332 |
|
| 24333 |
/* On exit, if INFO = 0, the triangular factor U or L from the */ |
| 24334 |
/* Cholesky factorization A = U'*U or A = L*L' of the band */ |
| 24335 |
/* matrix A, in the same storage format as A. */ |
| 24336 |
|
| 24337 |
/* LDAB (input) INTEGER */ |
| 24338 |
/* The leading dimension of the array AB. LDAB >= KD+1. */ |
| 24339 |
|
| 24340 |
/* S (input) DOUBLE PRECISION array, dimension (N) */ |
| 24341 |
/* The scale factors for A. */ |
| 24342 |
|
| 24343 |
/* SCOND (input) DOUBLE PRECISION */ |
| 24344 |
/* Ratio of the smallest S(i) to the largest S(i). */ |
| 24345 |
|
| 24346 |
/* AMAX (input) DOUBLE PRECISION */ |
| 24347 |
/* Absolute value of largest matrix entry. */ |
| 24348 |
|
| 24349 |
/* EQUED (output) CHARACTER*1 */ |
| 24350 |
/* Specifies whether or not equilibration was done. */ |
| 24351 |
/* = 'N': No equilibration. */ |
| 24352 |
/* = 'Y': Equilibration was done, i.e., A has been replaced by */ |
| 24353 |
/* diag(S) * A * diag(S). */ |
| 24354 |
|
| 24355 |
/* Internal Parameters */ |
| 24356 |
/* =================== */ |
| 24357 |
|
| 24358 |
/* THRESH is a threshold value used to decide if scaling should be done */ |
| 24359 |
/* based on the ratio of the scaling factors. If SCOND < THRESH, */ |
| 24360 |
/* scaling is done. */ |
| 24361 |
|
| 24362 |
/* LARGE and SMALL are threshold values used to decide if scaling should */ |
| 24363 |
/* be done based on the absolute size of the largest matrix element. */ |
| 24364 |
/* If AMAX > LARGE or AMAX < SMALL, scaling is done. */ |
| 24365 |
|
| 24366 |
/* ===================================================================== */ |
| 24367 |
|
| 24368 |
/* .. Parameters .. */ |
| 24369 |
/* .. */ |
| 24370 |
/* .. Local Scalars .. */ |
| 24371 |
/* .. */ |
| 24372 |
/* .. External Functions .. */ |
| 24373 |
/* .. */ |
| 24374 |
/* .. Intrinsic Functions .. */ |
| 24375 |
/* .. */ |
| 24376 |
/* .. Executable Statements .. */ |
| 24377 |
|
| 24378 |
/* Quick return if possible */ |
| 24379 |
|
| 24380 |
/* Parameter adjustments */ |
| 24381 |
ab_dim1 = *ldab; |
| 24382 |
ab_offset = 1 + ab_dim1; |
| 24383 |
ab -= ab_offset; |
| 24384 |
--s; |
| 24385 |
|
| 24386 |
/* Function Body */ |
| 24387 |
if (*n <= 0) { |
| 24388 |
*(unsigned char *)equed = 'N'; |
| 24389 |
return 0; |
| 24390 |
} |
| 24391 |
|
| 24392 |
/* Initialize LARGE and SMALL. */ |
| 24393 |
|
| 24394 |
small = dlamch_("Safe minimum") / dlamch_("Precision"); |
| 24395 |
large = 1. / small; |
| 24396 |
|
| 24397 |
if (*scond >= .1 && *amax >= small && *amax <= large) { |
| 24398 |
|
| 24399 |
/* No equilibration */ |
| 24400 |
|
| 24401 |
*(unsigned char *)equed = 'N'; |
| 24402 |
} else { |
| 24403 |
|
| 24404 |
/* Replace A by diag(S) * A * diag(S). */ |
| 24405 |
|
| 24406 |
if (lsame_(uplo, "U")) { |
| 24407 |
|
| 24408 |
/* Upper triangle of A is stored in band format. */ |
| 24409 |
|
| 24410 |
i__1 = *n; |
| 24411 |
for (j = 1; j <= i__1; ++j) { |
| 24412 |
cj = s[j]; |
| 24413 |
/* Computing MAX */ |
| 24414 |
i__2 = 1, i__3 = j - *kd; |
| 24415 |
i__4 = j; |
| 24416 |
for (i__ = std::max(i__2,i__3); i__ <= i__4; ++i__) { |
| 24417 |
ab[*kd + 1 + i__ - j + j * ab_dim1] = cj * s[i__] * ab[* |
| 24418 |
kd + 1 + i__ - j + j * ab_dim1]; |
| 24419 |
/* L10: */ |
| 24420 |
} |
| 24421 |
/* L20: */ |
| 24422 |
} |
| 24423 |
} else { |
| 24424 |
|
| 24425 |
/* Lower triangle of A is stored. */ |
| 24426 |
|
| 24427 |
i__1 = *n; |
| 24428 |
for (j = 1; j <= i__1; ++j) { |
| 24429 |
cj = s[j]; |
| 24430 |
/* Computing MIN */ |
| 24431 |
i__2 = *n, i__3 = j + *kd; |
| 24432 |
i__4 = std::min(i__2,i__3); |
| 24433 |
for (i__ = j; i__ <= i__4; ++i__) { |
| 24434 |
ab[i__ + 1 - j + j * ab_dim1] = cj * s[i__] * ab[i__ + 1 |
| 24435 |
- j + j * ab_dim1]; |
| 24436 |
/* L30: */ |
| 24437 |
} |
| 24438 |
/* L40: */ |
| 24439 |
} |
| 24440 |
} |
| 24441 |
*(unsigned char *)equed = 'Y'; |
| 24442 |
} |
| 24443 |
|
| 24444 |
return 0; |
| 24445 |
|
| 24446 |
/* End of DLAQSB */ |
| 24447 |
|
| 24448 |
} /* dlaqsb_ */ |
| 24449 |
|
| 24450 |
/* Subroutine */ int dlaqsp_(const char *uplo, integer *n, double *ap, |
| 24451 |
double *s, double *scond, double *amax, char *equed) |
| 24452 |
{ |
| 24453 |
/* System generated locals */ |
| 24454 |
integer i__1, i__2; |
| 24455 |
|
| 24456 |
/* Local variables */ |
| 24457 |
integer i__, j, jc; |
| 24458 |
double cj, large; |
| 24459 |
|
| 24460 |
double small; |
| 24461 |
|
| 24462 |
|
| 24463 |
|
| 24464 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 24465 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 24466 |
/* November 2006 */ |
| 24467 |
|
| 24468 |
/* .. Scalar Arguments .. */ |
| 24469 |
/* .. */ |
| 24470 |
/* .. Array Arguments .. */ |
| 24471 |
/* .. */ |
| 24472 |
|
| 24473 |
/* Purpose */ |
| 24474 |
/* ======= */ |
| 24475 |
|
| 24476 |
/* DLAQSP equilibrates a symmetric matrix A using the scaling factors */ |
| 24477 |
/* in the vector S. */ |
| 24478 |
|
| 24479 |
/* Arguments */ |
| 24480 |
/* ========= */ |
| 24481 |
|
| 24482 |
/* UPLO (input) CHARACTER*1 */ |
| 24483 |
/* Specifies whether the upper or lower triangular part of the */ |
| 24484 |
/* symmetric matrix A is stored. */ |
| 24485 |
/* = 'U': Upper triangular */ |
| 24486 |
/* = 'L': Lower triangular */ |
| 24487 |
|
| 24488 |
/* N (input) INTEGER */ |
| 24489 |
/* The order of the matrix A. N >= 0. */ |
| 24490 |
|
| 24491 |
/* AP (input/output) DOUBLE PRECISION array, dimension (N*(N+1)/2) */ |
| 24492 |
/* On entry, the upper or lower triangle of the symmetric matrix */ |
| 24493 |
/* A, packed columnwise in a linear array. The j-th column of A */ |
| 24494 |
/* is stored in the array AP as follows: */ |
| 24495 |
/* if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; */ |
| 24496 |
/* if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n. */ |
| 24497 |
|
| 24498 |
/* On exit, the equilibrated matrix: diag(S) * A * diag(S), in */ |
| 24499 |
/* the same storage format as A. */ |
| 24500 |
|
| 24501 |
/* S (input) DOUBLE PRECISION array, dimension (N) */ |
| 24502 |
/* The scale factors for A. */ |
| 24503 |
|
| 24504 |
/* SCOND (input) DOUBLE PRECISION */ |
| 24505 |
/* Ratio of the smallest S(i) to the largest S(i). */ |
| 24506 |
|
| 24507 |
/* AMAX (input) DOUBLE PRECISION */ |
| 24508 |
/* Absolute value of largest matrix entry. */ |
| 24509 |
|
| 24510 |
/* EQUED (output) CHARACTER*1 */ |
| 24511 |
/* Specifies whether or not equilibration was done. */ |
| 24512 |
/* = 'N': No equilibration. */ |
| 24513 |
/* = 'Y': Equilibration was done, i.e., A has been replaced by */ |
| 24514 |
/* diag(S) * A * diag(S). */ |
| 24515 |
|
| 24516 |
/* Internal Parameters */ |
| 24517 |
/* =================== */ |
| 24518 |
|
| 24519 |
/* THRESH is a threshold value used to decide if scaling should be done */ |
| 24520 |
/* based on the ratio of the scaling factors. If SCOND < THRESH, */ |
| 24521 |
/* scaling is done. */ |
| 24522 |
|
| 24523 |
/* LARGE and SMALL are threshold values used to decide if scaling should */ |
| 24524 |
/* be done based on the absolute size of the largest matrix element. */ |
| 24525 |
/* If AMAX > LARGE or AMAX < SMALL, scaling is done. */ |
| 24526 |
|
| 24527 |
/* ===================================================================== */ |
| 24528 |
|
| 24529 |
/* .. Parameters .. */ |
| 24530 |
/* .. */ |
| 24531 |
/* .. Local Scalars .. */ |
| 24532 |
/* .. */ |
| 24533 |
/* .. External Functions .. */ |
| 24534 |
/* .. */ |
| 24535 |
/* .. Executable Statements .. */ |
| 24536 |
|
| 24537 |
/* Quick return if possible */ |
| 24538 |
|
| 24539 |
/* Parameter adjustments */ |
| 24540 |
--s; |
| 24541 |
--ap; |
| 24542 |
|
| 24543 |
/* Function Body */ |
| 24544 |
if (*n <= 0) { |
| 24545 |
*(unsigned char *)equed = 'N'; |
| 24546 |
return 0; |
| 24547 |
} |
| 24548 |
|
| 24549 |
/* Initialize LARGE and SMALL. */ |
| 24550 |
|
| 24551 |
small = dlamch_("Safe minimum") / dlamch_("Precision"); |
| 24552 |
large = 1. / small; |
| 24553 |
|
| 24554 |
if (*scond >= .1 && *amax >= small && *amax <= large) { |
| 24555 |
|
| 24556 |
/* No equilibration */ |
| 24557 |
|
| 24558 |
*(unsigned char *)equed = 'N'; |
| 24559 |
} else { |
| 24560 |
|
| 24561 |
/* Replace A by diag(S) * A * diag(S). */ |
| 24562 |
|
| 24563 |
if (lsame_(uplo, "U")) { |
| 24564 |
|
| 24565 |
/* Upper triangle of A is stored. */ |
| 24566 |
|
| 24567 |
jc = 1; |
| 24568 |
i__1 = *n; |
| 24569 |
for (j = 1; j <= i__1; ++j) { |
| 24570 |
cj = s[j]; |
| 24571 |
i__2 = j; |
| 24572 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 24573 |
ap[jc + i__ - 1] = cj * s[i__] * ap[jc + i__ - 1]; |
| 24574 |
/* L10: */ |
| 24575 |
} |
| 24576 |
jc += j; |
| 24577 |
/* L20: */ |
| 24578 |
} |
| 24579 |
} else { |
| 24580 |
|
| 24581 |
/* Lower triangle of A is stored. */ |
| 24582 |
|
| 24583 |
jc = 1; |
| 24584 |
i__1 = *n; |
| 24585 |
for (j = 1; j <= i__1; ++j) { |
| 24586 |
cj = s[j]; |
| 24587 |
i__2 = *n; |
| 24588 |
for (i__ = j; i__ <= i__2; ++i__) { |
| 24589 |
ap[jc + i__ - j] = cj * s[i__] * ap[jc + i__ - j]; |
| 24590 |
/* L30: */ |
| 24591 |
} |
| 24592 |
jc = jc + *n - j + 1; |
| 24593 |
/* L40: */ |
| 24594 |
} |
| 24595 |
} |
| 24596 |
*(unsigned char *)equed = 'Y'; |
| 24597 |
} |
| 24598 |
|
| 24599 |
return 0; |
| 24600 |
|
| 24601 |
/* End of DLAQSP */ |
| 24602 |
|
| 24603 |
} /* dlaqsp_ */ |
| 24604 |
|
| 24605 |
/* Subroutine */ int dlaqsy_(const char *uplo, integer *n, double *a, integer * |
| 24606 |
lda, double *s, double *scond, double *amax, char *equed) |
| 24607 |
{ |
| 24608 |
/* System generated locals */ |
| 24609 |
integer a_dim1, a_offset, i__1, i__2; |
| 24610 |
|
| 24611 |
/* Local variables */ |
| 24612 |
integer i__, j; |
| 24613 |
double cj, large; |
| 24614 |
|
| 24615 |
double small; |
| 24616 |
|
| 24617 |
|
| 24618 |
|
| 24619 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 24620 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 24621 |
/* November 2006 */ |
| 24622 |
|
| 24623 |
/* .. Scalar Arguments .. */ |
| 24624 |
/* .. */ |
| 24625 |
/* .. Array Arguments .. */ |
| 24626 |
/* .. */ |
| 24627 |
|
| 24628 |
/* Purpose */ |
| 24629 |
/* ======= */ |
| 24630 |
|
| 24631 |
/* DLAQSY equilibrates a symmetric matrix A using the scaling factors */ |
| 24632 |
/* in the vector S. */ |
| 24633 |
|
| 24634 |
/* Arguments */ |
| 24635 |
/* ========= */ |
| 24636 |
|
| 24637 |
/* UPLO (input) CHARACTER*1 */ |
| 24638 |
/* Specifies whether the upper or lower triangular part of the */ |
| 24639 |
/* symmetric matrix A is stored. */ |
| 24640 |
/* = 'U': Upper triangular */ |
| 24641 |
/* = 'L': Lower triangular */ |
| 24642 |
|
| 24643 |
/* N (input) INTEGER */ |
| 24644 |
/* The order of the matrix A. N >= 0. */ |
| 24645 |
|
| 24646 |
/* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 24647 |
/* On entry, the symmetric matrix A. If UPLO = 'U', the leading */ |
| 24648 |
/* n by n upper triangular part of A contains the upper */ |
| 24649 |
/* triangular part of the matrix A, and the strictly lower */ |
| 24650 |
/* triangular part of A is not referenced. If UPLO = 'L', the */ |
| 24651 |
/* leading n by n lower triangular part of A contains the lower */ |
| 24652 |
/* triangular part of the matrix A, and the strictly upper */ |
| 24653 |
/* triangular part of A is not referenced. */ |
| 24654 |
|
| 24655 |
/* On exit, if EQUED = 'Y', the equilibrated matrix: */ |
| 24656 |
/* diag(S) * A * diag(S). */ |
| 24657 |
|
| 24658 |
/* LDA (input) INTEGER */ |
| 24659 |
/* The leading dimension of the array A. LDA >= max(N,1). */ |
| 24660 |
|
| 24661 |
/* S (input) DOUBLE PRECISION array, dimension (N) */ |
| 24662 |
/* The scale factors for A. */ |
| 24663 |
|
| 24664 |
/* SCOND (input) DOUBLE PRECISION */ |
| 24665 |
/* Ratio of the smallest S(i) to the largest S(i). */ |
| 24666 |
|
| 24667 |
/* AMAX (input) DOUBLE PRECISION */ |
| 24668 |
/* Absolute value of largest matrix entry. */ |
| 24669 |
|
| 24670 |
/* EQUED (output) CHARACTER*1 */ |
| 24671 |
/* Specifies whether or not equilibration was done. */ |
| 24672 |
/* = 'N': No equilibration. */ |
| 24673 |
/* = 'Y': Equilibration was done, i.e., A has been replaced by */ |
| 24674 |
/* diag(S) * A * diag(S). */ |
| 24675 |
|
| 24676 |
/* Internal Parameters */ |
| 24677 |
/* =================== */ |
| 24678 |
|
| 24679 |
/* THRESH is a threshold value used to decide if scaling should be done */ |
| 24680 |
/* based on the ratio of the scaling factors. If SCOND < THRESH, */ |
| 24681 |
/* scaling is done. */ |
| 24682 |
|
| 24683 |
/* LARGE and SMALL are threshold values used to decide if scaling should */ |
| 24684 |
/* be done based on the absolute size of the largest matrix element. */ |
| 24685 |
/* If AMAX > LARGE or AMAX < SMALL, scaling is done. */ |
| 24686 |
|
| 24687 |
/* ===================================================================== */ |
| 24688 |
|
| 24689 |
/* .. Parameters .. */ |
| 24690 |
/* .. */ |
| 24691 |
/* .. Local Scalars .. */ |
| 24692 |
/* .. */ |
| 24693 |
/* .. External Functions .. */ |
| 24694 |
/* .. */ |
| 24695 |
/* .. Executable Statements .. */ |
| 24696 |
|
| 24697 |
/* Quick return if possible */ |
| 24698 |
|
| 24699 |
/* Parameter adjustments */ |
| 24700 |
a_dim1 = *lda; |
| 24701 |
a_offset = 1 + a_dim1; |
| 24702 |
a -= a_offset; |
| 24703 |
--s; |
| 24704 |
|
| 24705 |
/* Function Body */ |
| 24706 |
if (*n <= 0) { |
| 24707 |
*(unsigned char *)equed = 'N'; |
| 24708 |
return 0; |
| 24709 |
} |
| 24710 |
|
| 24711 |
/* Initialize LARGE and SMALL. */ |
| 24712 |
|
| 24713 |
small = dlamch_("Safe minimum") / dlamch_("Precision"); |
| 24714 |
large = 1. / small; |
| 24715 |
|
| 24716 |
if (*scond >= .1 && *amax >= small && *amax <= large) { |
| 24717 |
|
| 24718 |
/* No equilibration */ |
| 24719 |
|
| 24720 |
*(unsigned char *)equed = 'N'; |
| 24721 |
} else { |
| 24722 |
|
| 24723 |
/* Replace A by diag(S) * A * diag(S). */ |
| 24724 |
|
| 24725 |
if (lsame_(uplo, "U")) { |
| 24726 |
|
| 24727 |
/* Upper triangle of A is stored. */ |
| 24728 |
|
| 24729 |
i__1 = *n; |
| 24730 |
for (j = 1; j <= i__1; ++j) { |
| 24731 |
cj = s[j]; |
| 24732 |
i__2 = j; |
| 24733 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 24734 |
a[i__ + j * a_dim1] = cj * s[i__] * a[i__ + j * a_dim1]; |
| 24735 |
/* L10: */ |
| 24736 |
} |
| 24737 |
/* L20: */ |
| 24738 |
} |
| 24739 |
} else { |
| 24740 |
|
| 24741 |
/* Lower triangle of A is stored. */ |
| 24742 |
|
| 24743 |
i__1 = *n; |
| 24744 |
for (j = 1; j <= i__1; ++j) { |
| 24745 |
cj = s[j]; |
| 24746 |
i__2 = *n; |
| 24747 |
for (i__ = j; i__ <= i__2; ++i__) { |
| 24748 |
a[i__ + j * a_dim1] = cj * s[i__] * a[i__ + j * a_dim1]; |
| 24749 |
/* L30: */ |
| 24750 |
} |
| 24751 |
/* L40: */ |
| 24752 |
} |
| 24753 |
} |
| 24754 |
*(unsigned char *)equed = 'Y'; |
| 24755 |
} |
| 24756 |
|
| 24757 |
return 0; |
| 24758 |
|
| 24759 |
/* End of DLAQSY */ |
| 24760 |
|
| 24761 |
} /* dlaqsy_ */ |
| 24762 |
|
| 24763 |
/* Subroutine */ int dlaqtr_(bool *ltran, bool *lreal, integer *n, |
| 24764 |
double *t, integer *ldt, double *b, double *w, double |
| 24765 |
*scale, double *x, double *work, integer *info) |
| 24766 |
{ |
| 24767 |
/* Table of constant values */ |
| 24768 |
static integer c__1 = 1; |
| 24769 |
static bool c_false = false; |
| 24770 |
static integer c__2 = 2; |
| 24771 |
static double c_b21 = 1.; |
| 24772 |
static double c_b25 = 0.; |
| 24773 |
static bool c_true = true; |
| 24774 |
|
| 24775 |
/* System generated locals */ |
| 24776 |
integer t_dim1, t_offset, i__1, i__2; |
| 24777 |
double d__1, d__2, d__3, d__4, d__5, d__6; |
| 24778 |
|
| 24779 |
/* Local variables */ |
| 24780 |
double d__[4] /* was [2][2] */; |
| 24781 |
integer i__, j, k; |
| 24782 |
double v[4] /* was [2][2] */, z__; |
| 24783 |
integer j1, j2, n1, n2; |
| 24784 |
double si, xj, sr, rec, eps, tjj, tmp; |
| 24785 |
integer ierr; |
| 24786 |
double smin, xmax; |
| 24787 |
integer jnext; |
| 24788 |
double sminw, xnorm; |
| 24789 |
double scaloc; |
| 24790 |
double bignum; |
| 24791 |
bool notran; |
| 24792 |
double smlnum; |
| 24793 |
|
| 24794 |
|
| 24795 |
/* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 24796 |
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 24797 |
/* November 2006 */ |
| 24798 |
|
| 24799 |
/* .. Scalar Arguments .. */ |
| 24800 |
/* .. */ |
| 24801 |
/* .. Array Arguments .. */ |
| 24802 |
/* .. */ |
| 24803 |
|
| 24804 |
/* Purpose */ |
| 24805 |
/* ======= */ |
| 24806 |
|
| 24807 |
/* DLAQTR solves the real quasi-triangular system */ |
| 24808 |
|
| 24809 |
/* op(T)*p = scale*c, if LREAL = .TRUE. */ |
| 24810 |
|
| 24811 |
/* or the complex quasi-triangular systems */ |
| 24812 |
|
| 24813 |
/* op(T + iB)*(p+iq) = scale*(c+id), if LREAL = .FALSE. */ |
| 24814 |
|
| 24815 |
/* in real arithmetic, where T is upper quasi-triangular. */ |
| 24816 |
/* If LREAL = .FALSE., then the first diagonal block of T must be */ |
| 24817 |
/* 1 by 1, B is the specially structured matrix */ |
| 24818 |
|
| 24819 |
/* B = [ b(1) b(2) ... b(n) ] */ |
| 24820 |
/* [ w ] */ |
| 24821 |
/* [ w ] */ |
| 24822 |
/* [ . ] */ |
| 24823 |
/* [ w ] */ |
| 24824 |
|
| 24825 |
/* op(A) = A or A', A' denotes the conjugate transpose of */ |
| 24826 |
/* matrix A. */ |
| 24827 |
|
| 24828 |
/* On input, X = [ c ]. On output, X = [ p ]. */ |
| 24829 |
/* [ d ] [ q ] */ |
| 24830 |
|
| 24831 |
/* This subroutine is designed for the condition number estimation */ |
| 24832 |
/* in routine DTRSNA. */ |
| 24833 |
|
| 24834 |
/* Arguments */ |
| 24835 |
/* ========= */ |
| 24836 |
|
| 24837 |
/* LTRAN (input) LOGICAL */ |
| 24838 |
/* On entry, LTRAN specifies the option of conjugate transpose: */ |
| 24839 |
/* = .FALSE., op(T+i*B) = T+i*B, */ |
| 24840 |
/* = .TRUE., op(T+i*B) = (T+i*B)'. */ |
| 24841 |
|
| 24842 |
/* LREAL (input) LOGICAL */ |
| 24843 |
/* On entry, LREAL specifies the input matrix structure: */ |
| 24844 |
/* = .FALSE., the input is complex */ |
| 24845 |
/* = .TRUE., the input is real */ |
| 24846 |
|
| 24847 |
/* N (input) INTEGER */ |
| 24848 |
/* On entry, N specifies the order of T+i*B. N >= 0. */ |
| 24849 |
|
| 24850 |
/* T (input) DOUBLE PRECISION array, dimension (LDT,N) */ |
| 24851 |
/* On entry, T contains a matrix in Schur canonical form. */ |
| 24852 |
/* If LREAL = .FALSE., then the first diagonal block of T mu */ |
| 24853 |
/* be 1 by 1. */ |
| 24854 |
|
| 24855 |
/* LDT (input) INTEGER */ |
| 24856 |
/* The leading dimension of the matrix T. LDT >= max(1,N). */ |
| 24857 |
|
| 24858 |
/* B (input) DOUBLE PRECISION array, dimension (N) */ |
| 24859 |
/* On entry, B contains the elements to form the matrix */ |
| 24860 |
/* B as described above. */ |
| 24861 |
/* If LREAL = .TRUE., B is not referenced. */ |
| 24862 |
|
| 24863 |
/* W (input) DOUBLE PRECISION */ |
| 24864 |
/* On entry, W is the diagonal element of the matrix B. */ |
| 24865 |
/* If LREAL = .TRUE., W is not referenced. */ |
| 24866 |
|
| 24867 |
/* SCALE (output) DOUBLE PRECISION */ |
| 24868 |
/* On exit, SCALE is the scale factor. */ |
| 24869 |
|
| 24870 |
/* X (input/output) DOUBLE PRECISION array, dimension (2*N) */ |
| 24871 |
/* On entry, X contains the right hand side of the system. */ |
| 24872 |
/* On exit, X is overwritten by the solution. */ |
| 24873 |
|
| 24874 |
/* WORK (workspace) DOUBLE PRECISION array, dimension (N) */ |
| 24875 |
|
| 24876 |
/* INFO (output) INTEGER */ |
| 24877 |
/* On exit, INFO is set to */ |
| 24878 |
/* 0: successful exit. */ |
| 24879 |
/* 1: the some diagonal 1 by 1 block has been perturbed by */ |
| 24880 |
/* a small number SMIN to keep nonsingularity. */ |
| 24881 |
/* 2: the some diagonal 2 by 2 block has been perturbed by */ |
| 24882 |
/* a small number in DLALN2 to keep nonsingularity. */ |
| 24883 |
/* NOTE: In the interests of speed, this routine does not */ |
| 24884 |
/* check the inputs for errors. */ |
| 24885 |
|
| 24886 |
/* ===================================================================== */ |
| 24887 |
|
| 24888 |
/* .. Parameters .. */ |
| 24889 |
/* .. */ |
| 24890 |
/* .. Local Scalars .. */ |
| 24891 |
/* .. */ |
| 24892 |
/* .. Local Arrays .. */ |
| 24893 |
/* .. */ |
| 24894 |
/* .. External Functions .. */ |
| 24895 |
/* .. */ |
| 24896 |
/* .. External Subroutines .. */ |
| 24897 |
/* .. */ |
| 24898 |
/* .. Intrinsic Functions .. */ |
| 24899 |
/* .. */ |
| 24900 |
/* .. Executable Statements .. */ |
| 24901 |
|
| 24902 |
/* Do not test the input parameters for errors */ |
| 24903 |
|
| 24904 |
/* Parameter adjustments */ |
| 24905 |
t_dim1 = *ldt; |
| 24906 |
t_offset = 1 + t_dim1; |
| 24907 |
t -= t_offset; |
| 24908 |
--b; |
| 24909 |
--x; |
| 24910 |
--work; |
| 24911 |
|
| 24912 |
/* Function Body */ |
| 24913 |
notran = ! (*ltran); |
| 24914 |
*info = 0; |
| 24915 |
|
| 24916 |
/* Quick return if possible */ |
| 24917 |
|
| 24918 |
if (*n == 0) { |
| 24919 |
return 0; |
| 24920 |
} |
| 24921 |
|
| 24922 |
/* Set constants to control overflow */ |
| 24923 |
|
| 24924 |
eps = dlamch_("P"); |
| 24925 |
smlnum = dlamch_("S") / eps; |
| 24926 |
bignum = 1. / smlnum; |
| 24927 |
|
| 24928 |
xnorm = dlange_("M", n, n, &t[t_offset], ldt, d__); |
| 24929 |
if (! (*lreal)) { |
| 24930 |
/* Computing MAX */ |
| 24931 |
d__1 = xnorm, d__2 = abs(*w), d__1 = std::max(d__1,d__2), d__2 = dlange_( |
| 24932 |
"M", n, &c__1, &b[1], n, d__); |
| 24933 |
xnorm = std::max(d__1,d__2); |
| 24934 |
} |
| 24935 |
/* Computing MAX */ |
| 24936 |
d__1 = smlnum, d__2 = eps * xnorm; |
| 24937 |
smin = std::max(d__1,d__2); |
| 24938 |
|
| 24939 |
/* Compute 1-norm of each column of strictly upper triangular */ |
| 24940 |
/* part of T to control overflow in triangular solver. */ |
| 24941 |
|
| 24942 |
work[1] = 0.; |
| 24943 |
i__1 = *n; |
| 24944 |
for (j = 2; j <= i__1; ++j) { |
| 24945 |
i__2 = j - 1; |
| 24946 |
work[j] = dasum_(&i__2, &t[j * t_dim1 + 1], &c__1); |
| 24947 |
/* L10: */ |
| 24948 |
} |
| 24949 |
|
| 24950 |
if (! (*lreal)) { |
| 24951 |
i__1 = *n; |
| 24952 |
for (i__ = 2; i__ <= i__1; ++i__) { |
| 24953 |
work[i__] += (d__1 = b[i__], abs(d__1)); |
| 24954 |
/* L20: */ |
| 24955 |
} |
| 24956 |
} |
| 24957 |
|
| 24958 |
n2 = *n << 1; |
| 24959 |
n1 = *n; |
| 24960 |
if (! (*lreal)) { |
| 24961 |
n1 = n2; |
| 24962 |
} |
| 24963 |
k = idamax_(&n1, &x[1], &c__1); |
| 24964 |
xmax = (d__1 = x[k], abs(d__1)); |
| 24965 |
*scale = 1.; |
| 24966 |
|
| 24967 |
if (xmax > bignum) { |
| 24968 |
*scale = bignum / xmax; |
| 24969 |
dscal_(&n1, scale, &x[1], &c__1); |
| 24970 |
xmax = bignum; |
| 24971 |
} |
| 24972 |
|
| 24973 |
if (*lreal) { |
| 24974 |
|
| 24975 |
if (notran) { |
| 24976 |
|
| 24977 |
/* Solve T*p = scale*c */ |
| 24978 |
|
| 24979 |
jnext = *n; |
| 24980 |
for (j = *n; j >= 1; --j) { |
| 24981 |
if (j > jnext) { |
| 24982 |
goto L30; |
| 24983 |
} |
| 24984 |
j1 = j; |
| 24985 |
j2 = j; |
| 24986 |
jnext = j - 1; |
| 24987 |
if (j > 1) { |
| 24988 |
if (t[j + (j - 1) * t_dim1] != 0.) { |
| 24989 |
j1 = j - 1; |
| 24990 |
jnext = j - 2; |
| 24991 |
} |
| 24992 |
} |
| 24993 |
|
| 24994 |
if (j1 == j2) { |
| 24995 |
|
| 24996 |
/* Meet 1 by 1 diagonal block */ |
| 24997 |
|
| 24998 |
/* Scale to avoid overflow when computing */ |
| 24999 |
/* x(j) = b(j)/T(j,j) */ |
| 25000 |
|
| 25001 |
xj = (d__1 = x[j1], abs(d__1)); |
| 25002 |
tjj = (d__1 = t[j1 + j1 * t_dim1], abs(d__1)); |
| 25003 |
tmp = t[j1 + j1 * t_dim1]; |
| 25004 |
if (tjj < smin) { |
| 25005 |
tmp = smin; |
| 25006 |
tjj = smin; |
| 25007 |
*info = 1; |
| 25008 |
} |
| 25009 |
|
| 25010 |
if (xj == 0.) { |
| 25011 |
goto L30; |
| 25012 |
} |
| 25013 |
|
| 25014 |
if (tjj < 1.) { |
| 25015 |
if (xj > bignum * tjj) { |
| 25016 |
rec = 1. / xj; |
| 25017 |
dscal_(n, &rec, &x[1], &c__1); |
| 25018 |
*scale *= rec; |
| 25019 |
xmax *= rec; |
| 25020 |
} |
| 25021 |
} |
| 25022 |
x[j1] /= tmp; |
| 25023 |
xj = (d__1 = x[j1], abs(d__1)); |
| 25024 |
|
| 25025 |
/* Scale x if necessary to avoid overflow when adding a */ |
| 25026 |
/* multiple of column j1 of T. */ |
| 25027 |
|
| 25028 |
if (xj > 1.) { |
| 25029 |
rec = 1. / xj; |
| 25030 |
if (work[j1] > (bignum - xmax) * rec) { |
| 25031 |
dscal_(n, &rec, &x[1], &c__1); |
| 25032 |
*scale *= rec; |
| 25033 |
} |
| 25034 |
} |
| 25035 |
if (j1 > 1) { |
| 25036 |
i__1 = j1 - 1; |
| 25037 |
d__1 = -x[j1]; |
| 25038 |
daxpy_(&i__1, &d__1, &t[j1 * t_dim1 + 1], &c__1, &x[1] |
| 25039 |
, &c__1); |
| 25040 |
i__1 = j1 - 1; |
| 25041 |
k = idamax_(&i__1, &x[1], &c__1); |
| 25042 |
xmax = (d__1 = x[k], abs(d__1)); |
| 25043 |
} |
| 25044 |
|
| 25045 |
} else { |
| 25046 |
|
| 25047 |
/* Meet 2 by 2 diagonal block */ |
| 25048 |
|
| 25049 |
/* Call 2 by 2 linear system solve, to take */ |
| 25050 |
/* care of possible overflow by scaling factor. */ |
| 25051 |
|
| 25052 |
d__[0] = x[j1]; |
| 25053 |
d__[1] = x[j2]; |
| 25054 |
dlaln2_(&c_false, &c__2, &c__1, &smin, &c_b21, &t[j1 + j1 |
| 25055 |
* t_dim1], ldt, &c_b21, &c_b21, d__, &c__2, & |
| 25056 |
c_b25, &c_b25, v, &c__2, &scaloc, &xnorm, &ierr); |
| 25057 |
if (ierr != 0) { |
| 25058 |
*info = 2; |
| 25059 |
} |
| 25060 |
|
| 25061 |
if (scaloc != 1.) { |
| 25062 |
dscal_(n, &scaloc, &x[1], &c__1); |
| 25063 |
*scale *= scaloc; |
| 25064 |
} |
| 25065 |
x[j1] = v[0]; |
| 25066 |
x[j2] = v[1]; |
| 25067 |
|
| 25068 |
/* Scale V(1,1) (= X(J1)) and/or V(2,1) (=X(J2)) */ |
| 25069 |
/* to avoid overflow in updating right-hand side. */ |
| 25070 |
|
| 25071 |
/* Computing MAX */ |
| 25072 |
d__1 = abs(v[0]), d__2 = abs(v[1]); |
| 25073 |
xj = std::max(d__1,d__2); |
| 25074 |
if (xj > 1.) { |
| 25075 |
rec = 1. / xj; |
| 25076 |
/* Computing MAX */ |
| 25077 |
d__1 = work[j1], d__2 = work[j2]; |
| 25078 |
if (std::max(d__1,d__2) > (bignum - xmax) * rec) { |
| 25079 |
dscal_(n, &rec, &x[1], &c__1); |
| 25080 |
*scale *= rec; |
| 25081 |
} |
| 25082 |
} |
| 25083 |
|
| 25084 |
/* Update right-hand side */ |
| 25085 |
|
| 25086 |
if (j1 > 1) { |
| 25087 |
i__1 = j1 - 1; |
| 25088 |
d__1 = -x[j1]; |
| 25089 |
daxpy_(&i__1, &d__1, &t[j1 * t_dim1 + 1], &c__1, &x[1] |
| 25090 |
, &c__1); |
| 25091 |
i__1 = j1 - 1; |
| 25092 |
d__1 = -x[j2]; |
| 25093 |
daxpy_(&i__1, &d__1, &t[j2 * t_dim1 + 1], &c__1, &x[1] |
| 25094 |
, &c__1); |
| 25095 |
i__1 = j1 - 1; |
| 25096 |
k = idamax_(&i__1, &x[1], &c__1); |
| 25097 |
xmax = (d__1 = x[k], abs(d__1)); |
| 25098 |
} |
| 25099 |
|
| 25100 |
} |
| 25101 |
|
| 25102 |
L30: |
| 25103 |
; |
| 25104 |
} |
| 25105 |
|
| 25106 |
} else { |
| 25107 |
|
| 25108 |
/* Solve T'*p = scale*c */ |
| 25109 |
|
| 25110 |
jnext = 1; |
| 25111 |
i__1 = *n; |
| 25112 |
for (j = 1; j <= i__1; ++j) { |
| 25113 |
if (j < jnext) { |
| 25114 |
goto L40; |
| 25115 |
} |
| 25116 |
j1 = j; |
| 25117 |
j2 = j; |
| 25118 |
jnext = j + 1; |
| 25119 |
if (j < *n) { |
| 25120 |
if (t[j + 1 + j * t_dim1] != 0.) { |
| 25121 |
j2 = j + 1; |
| 25122 |
jnext = j + 2; |
| 25123 |
} |
| 25124 |
} |
| 25125 |
|
| 25126 |
if (j1 == j2) { |
| 25127 |
|
| 25128 |
/* 1 by 1 diagonal block */ |
| 25129 |
|
| 25130 |
/* Scale if necessary to avoid overflow in forming the */ |
| 25131 |
/* right-hand side element by inner product. */ |
| 25132 |
|
| 25133 |
xj = (d__1 = x[j1], abs(d__1)); |
| 25134 |
if (xmax > 1.) { |
| 25135 |
rec = 1. / xmax; |
| 25136 |
if (work[j1] > (bignum - xj) * rec) { |
| 25137 |
dscal_(n, &rec, &x[1], &c__1); |
| 25138 |
*scale *= rec; |
| 25139 |
xmax *= rec; |
| 25140 |
} |
| 25141 |
} |
| 25142 |
|
| 25143 |
i__2 = j1 - 1; |
| 25144 |
x[j1] -= ddot_(&i__2, &t[j1 * t_dim1 + 1], &c__1, &x[1], & |
| 25145 |
c__1); |
| 25146 |
|
| 25147 |
xj = (d__1 = x[j1], abs(d__1)); |
| 25148 |
tjj = (d__1 = t[j1 + j1 * t_dim1], abs(d__1)); |
| 25149 |
tmp = t[j1 + j1 * t_dim1]; |
| 25150 |
if (tjj < smin) { |
| 25151 |
tmp = smin; |
| 25152 |
tjj = smin; |
| 25153 |
*info = 1; |
| 25154 |
} |
| 25155 |
|
| 25156 |
if (tjj < 1.) { |
| 25157 |
if (xj > bignum * tjj) { |
| 25158 |
rec = 1. / xj; |
| 25159 |
dscal_(n, &rec, &x[1], &c__1); |
| 25160 |
*scale *= rec; |
| 25161 |
xmax *= rec; |
| 25162 |
} |
| 25163 |
} |
| 25164 |
x[j1] /= tmp; |
| 25165 |
/* Computing MAX */ |
| 25166 |
d__2 = xmax, d__3 = (d__1 = x[j1], abs(d__1)); |
| 25167 |
xmax = std::max(d__2,d__3); |
| 25168 |
|
| 25169 |
} else { |
| 25170 |
|
| 25171 |
/* 2 by 2 diagonal block */ |
| 25172 |
|
| 25173 |
/* Scale if necessary to avoid overflow in forming the */ |
| 25174 |
/* right-hand side elements by inner product. */ |
| 25175 |
|
| 25176 |
/* Computing MAX */ |
| 25177 |
d__3 = (d__1 = x[j1], abs(d__1)), d__4 = (d__2 = x[j2], |
| 25178 |
abs(d__2)); |
| 25179 |
xj = std::max(d__3,d__4); |
| 25180 |
if (xmax > 1.) { |
| 25181 |
rec = 1. / xmax; |
| 25182 |
/* Computing MAX */ |
| 25183 |
d__1 = work[j2], d__2 = work[j1]; |
| 25184 |
if (std::max(d__1,d__2) > (bignum - xj) * rec) { |
| 25185 |
dscal_(n, &rec, &x[1], &c__1); |
| 25186 |
*scale *= rec; |
| 25187 |
xmax *= rec; |
| 25188 |
} |
| 25189 |
} |
| 25190 |
|
| 25191 |
i__2 = j1 - 1; |
| 25192 |
d__[0] = x[j1] - ddot_(&i__2, &t[j1 * t_dim1 + 1], &c__1, |
| 25193 |
&x[1], &c__1); |
| 25194 |
i__2 = j1 - 1; |
| 25195 |
d__[1] = x[j2] - ddot_(&i__2, &t[j2 * t_dim1 + 1], &c__1, |
| 25196 |
&x[1], &c__1); |
| 25197 |
|
| 25198 |
dlaln2_(&c_true, &c__2, &c__1, &smin, &c_b21, &t[j1 + j1 * |
| 25199 |
t_dim1], ldt, &c_b21, &c_b21, d__, &c__2, &c_b25, |
| 25200 |
&c_b25, v, &c__2, &scaloc, &xnorm, &ierr); |
| 25201 |
if (ierr != 0) { |
| 25202 |
*info = 2; |
| 25203 |
} |
| 25204 |
|
| 25205 |
if (scaloc != 1.) { |
| 25206 |
dscal_(n, &scaloc, &x[1], &c__1); |
| 25207 |
*scale *= scaloc; |
| 25208 |
} |
| 25209 |
x[j1] = v[0]; |
| 25210 |
x[j2] = v[1]; |
| 25211 |
/* Computing MAX */ |
| 25212 |
d__3 = (d__1 = x[j1], abs(d__1)), d__4 = (d__2 = x[j2], |
| 25213 |
abs(d__2)), d__3 = std::max(d__3,d__4); |
| 25214 |
xmax = std::max(d__3,xmax); |
| 25215 |
|
| 25216 |
} |
| 25217 |
L40: |
| 25218 |
; |
| 25219 |
} |
| 25220 |
} |
| 25221 |
|
| 25222 |
} else { |
| 25223 |
|
| 25224 |
/* Computing MAX */ |
| 25225 |
d__1 = eps * abs(*w); |
| 25226 |
sminw = std::max(d__1,smin); |
| 25227 |
if (notran) { |
| 25228 |
|
| 25229 |
/* Solve (T + iB)*(p+iq) = c+id */ |
| 25230 |
|
| 25231 |
jnext = *n; |
| 25232 |
for (j = *n; j >= 1; --j) { |
| 25233 |
if (j > jnext) { |
| 25234 |
goto L70; |
| 25235 |
} |
| 25236 |
j1 = j; |
| 25237 |
j2 = j; |
| 25238 |
jnext = j - 1; |
| 25239 |
if (j > 1) { |
| 25240 |
if (t[j + (j - 1) * t_dim1] != 0.) { |
| 25241 |
j1 = j - 1; |
| 25242 |
jnext = j - 2; |
| 25243 |
} |
| 25244 |
} |
| 25245 |
|
| 25246 |
if (j1 == j2) { |
| 25247 |
|
| 25248 |
/* 1 by 1 diagonal block */ |
| 25249 |
|
| 25250 |
/* Scale if necessary to avoid overflow in division */ |
| 25251 |
|
| 25252 |
z__ = *w; |
| 25253 |
if (j1 == 1) { |
| 25254 |
z__ = b[1]; |
| 25255 |
} |
| 25256 |
xj = (d__1 = x[j1], abs(d__1)) + (d__2 = x[*n + j1], abs( |
| 25257 |
d__2)); |
| 25258 |
tjj = (d__1 = t[j1 + j1 * t_dim1], abs(d__1)) + abs(z__); |
| 25259 |
tmp = t[j1 + j1 * t_dim1]; |
| 25260 |
if (tjj < sminw) { |
| 25261 |
tmp = sminw; |
| 25262 |
tjj = sminw; |
| 25263 |
*info = 1; |
| 25264 |
} |
| 25265 |
|
| 25266 |
if (xj == 0.) { |
| 25267 |
goto L70; |
| 25268 |
} |
| 25269 |
|
| 25270 |
if (tjj < 1.) { |
| 25271 |
if (xj > bignum * tjj) { |
| 25272 |
rec = 1. / xj; |
| 25273 |
dscal_(&n2, &rec, &x[1], &c__1); |
| 25274 |
*scale *= rec; |
| 25275 |
xmax *= rec; |
| 25276 |
} |
| 25277 |
} |
| 25278 |
dladiv_(&x[j1], &x[*n + j1], &tmp, &z__, &sr, &si); |
| 25279 |
x[j1] = sr; |
| 25280 |
x[*n + j1] = si; |
| 25281 |
xj = (d__1 = x[j1], abs(d__1)) + (d__2 = x[*n + j1], abs( |
| 25282 |
d__2)); |
| 25283 |
|
| 25284 |
/* Scale x if necessary to avoid overflow when adding a */ |
| 25285 |
/* multiple of column j1 of T. */ |
| 25286 |
|
| 25287 |
if (xj > 1.) { |
| 25288 |
rec = 1. / xj; |
| 25289 |
if (work[j1] > (bignum - xmax) * rec) { |
| 25290 |
dscal_(&n2, &rec, &x[1], &c__1); |
| 25291 |
*scale *= rec; |
| 25292 |
} |
| 25293 |
} |
| 25294 |
|
| 25295 |
if (j1 > 1) { |
| 25296 |
i__1 = j1 - 1; |
| 25297 |
d__1 = -x[j1]; |
| 25298 |
daxpy_(&i__1, &d__1, &t[j1 * t_dim1 + 1], &c__1, &x[1] |
| 25299 |
, &c__1); |
| 25300 |
i__1 = j1 - 1; |
| 25301 |
d__1 = -x[*n + j1]; |
| 25302 |
daxpy_(&i__1, &d__1, &t[j1 * t_dim1 + 1], &c__1, &x[* |
| 25303 |
n + 1], &c__1); |
| 25304 |
|
| 25305 |
x[1] += b[j1] * x[*n + j1]; |
| 25306 |
x[*n + 1] -= b[j1] * x[j1]; |
| 25307 |
|
| 25308 |
xmax = 0.; |
| 25309 |
i__1 = j1 - 1; |
| 25310 |
for (k = 1; k <= i__1; ++k) { |
| 25311 |
/* Computing MAX */ |
| 25312 |
d__3 = xmax, d__4 = (d__1 = x[k], abs(d__1)) + ( |
| 25313 |
d__2 = x[k + *n], abs(d__2)); |
| 25314 |
xmax = std::max(d__3,d__4); |
| 25315 |
/* L50: */ |
| 25316 |
} |
| 25317 |
} |
| 25318 |
|
| 25319 |
} else { |
| 25320 |
|
| 25321 |
/* Meet 2 by 2 diagonal block */ |
| 25322 |
|
| 25323 |
d__[0] = x[j1]; |
| 25324 |
d__[1] = x[j2]; |
| 25325 |
d__[2] = x[*n + j1]; |
| 25326 |
d__[3] = x[*n + j2]; |
| 25327 |
d__1 = -(*w); |
| 25328 |
dlaln2_(&c_false, &c__2, &c__2, &sminw, &c_b21, &t[j1 + |
| 25329 |
j1 * t_dim1], ldt, &c_b21, &c_b21, d__, &c__2, & |
| 25330 |
c_b25, &d__1, v, &c__2, &scaloc, &xnorm, &ierr); |
| 25331 |
if (ierr != 0) { |
| 25332 |
*info = 2; |
| 25333 |
} |
| 25334 |
|
| 25335 |
if (scaloc != 1.) { |
| 25336 |
i__1 = *n << 1; |
| 25337 |
dscal_(&i__1, &scaloc, &x[1], &c__1); |
| 25338 |
*scale = scaloc * *scale; |
| 25339 |
} |
| 25340 |
x[j1] = v[0]; |
| 25341 |
x[j2] = v[1]; |
| 25342 |
x[*n + j1] = v[2]; |
| 25343 |
x[*n + j2] = v[3]; |
| 25344 |
|
| 25345 |
/* Scale X(J1), .... to avoid overflow in */ |
| 25346 |
/* updating right hand side. */ |
| 25347 |
|
| 25348 |
/* Computing MAX */ |
| 25349 |
d__1 = abs(v[0]) + abs(v[2]), d__2 = abs(v[1]) + abs(v[3]) |
| 25350 |
; |
| 25351 |
xj = std::max(d__1,d__2); |
| 25352 |
if (xj > 1.) { |
| 25353 |
rec = 1. / xj; |
| 25354 |
/* Computing MAX */ |
| 25355 |
d__1 = work[j1], d__2 = work[j2]; |
| 25356 |
if (std::max(d__1,d__2) > (bignum - xmax) * rec) { |
| 25357 |
dscal_(&n2, &rec, &x[1], &c__1); |
| 25358 |
*scale *= rec; |
| 25359 |
} |
| 25360 |
} |
| 25361 |
|
| 25362 |
/* Update the right-hand side. */ |
| 25363 |
|
| 25364 |
if (j1 > 1) { |
| 25365 |
i__1 = j1 - 1; |
| 25366 |
d__1 = -x[j1]; |
| 25367 |
daxpy_(&i__1, &d__1, &t[j1 * t_dim1 + 1], &c__1, &x[1] |
| 25368 |
, &c__1); |
| 25369 |
i__1 = j1 - 1; |
| 25370 |
d__1 = -x[j2]; |
| 25371 |
daxpy_(&i__1, &d__1, &t[j2 * t_dim1 + 1], &c__1, &x[1] |
| 25372 |
, &c__1); |
| 25373 |
|
| 25374 |
i__1 = j1 - 1; |
| 25375 |
d__1 = -x[*n + j1]; |
| 25376 |
daxpy_(&i__1, &d__1, &t[j1 * t_dim1 + 1], &c__1, &x[* |
| 25377 |
n + 1], &c__1); |
| 25378 |
i__1 = j1 - 1; |
| 25379 |
d__1 = -x[*n + j2]; |
| 25380 |
daxpy_(&i__1, &d__1, &t[j2 * t_dim1 + 1], &c__1, &x[* |
| 25381 |
n + 1], &c__1); |
| 25382 |
|
| 25383 |
x[1] = x[1] + b[j1] * x[*n + j1] + b[j2] * x[*n + j2]; |
| 25384 |
x[*n + 1] = x[*n + 1] - b[j1] * x[j1] - b[j2] * x[j2]; |
| 25385 |
|
| 25386 |
xmax = 0.; |
| 25387 |
i__1 = j1 - 1; |
| 25388 |
for (k = 1; k <= i__1; ++k) { |
| 25389 |
/* Computing MAX */ |
| 25390 |
d__3 = (d__1 = x[k], abs(d__1)) + (d__2 = x[k + * |
| 25391 |
n], abs(d__2)); |
| 25392 |
xmax = std::max(d__3,xmax); |
| 25393 |
/* L60: */ |
| 25394 |
} |
| 25395 |
} |
| 25396 |
|
| 25397 |
} |
| 25398 |
L70: |
| 25399 |
; |
| 25400 |
} |
| 25401 |
|
| 25402 |
} else { |
| 25403 |
|
| 25404 |
/* Solve (T + iB)'*(p+iq) = c+id */ |
| 25405 |
|
| 25406 |
jnext = 1; |
| 25407 |
i__1 = *n; |
| 25408 |
for (j = 1; j <= i__1; ++j) { |
| 25409 |
if (j < jnext) { |
| 25410 |
goto L80; |
| 25411 |
} |
| 25412 |
j1 = j; |
| 25413 |
j2 = j; |
| 25414 |
jnext = j + 1; |
| 25415 |
if (j < *n) { |
| 25416 |
if (t[j + 1 + j * t_dim1] != 0.) { |
| 25417 |
j2 = j + 1; |
| 25418 |
jnext = j + 2; |
| 25419 |
} |
| 25420 |
} |
| 25421 |
|
| 25422 |
if (j1 == j2) { |
| 25423 |
|
| 25424 |
/* 1 by 1 diagonal block */ |
| 25425 |
|
| 25426 |
/* Scale if necessary to avoid overflow in forming the */ |
| 25427 |
/* right-hand side element by inner product. */ |
| 25428 |
|
| 25429 |
xj = (d__1 = x[j1], abs(d__1)) + (d__2 = x[j1 + *n], abs( |
| 25430 |
d__2)); |
| 25431 |
if (xmax > 1.) { |
| 25432 |
rec = 1. / xmax; |
| 25433 |
if (work[j1] > (bignum - xj) * rec) { |
| 25434 |
dscal_(&n2, &rec, &x[1], &c__1); |
| 25435 |
*scale *= rec; |
| 25436 |
xmax *= rec; |
| 25437 |
} |
| 25438 |
} |
| 25439 |
|
| 25440 |
i__2 = j1 - 1; |
| 25441 |
x[j1] -= ddot_(&i__2, &t[j1 * t_dim1 + 1], &c__1, &x[1], & |
| 25442 |
c__1); |
| 25443 |
i__2 = j1 - 1; |
| 25444 |
x[*n + j1] -= ddot_(&i__2, &t[j1 * t_dim1 + 1], &c__1, &x[ |
| 25445 |
*n + 1], &c__1); |
| 25446 |
if (j1 > 1) { |
| 25447 |
x[j1] -= b[j1] * x[*n + 1]; |
| 25448 |
x[*n + j1] += b[j1] * x[1]; |
| 25449 |
} |
| 25450 |
xj = (d__1 = x[j1], abs(d__1)) + (d__2 = x[j1 + *n], abs( |
| 25451 |
d__2)); |
| 25452 |
|
| 25453 |
z__ = *w; |
| 25454 |
if (j1 == 1) { |
| 25455 |
z__ = b[1]; |
| 25456 |
} |
| 25457 |
|
| 25458 |
/* Scale if necessary to avoid overflow in */ |
| 25459 |
/* complex division */ |
| 25460 |
|
| 25461 |
tjj = (d__1 = t[j1 + j1 * t_dim1], abs(d__1)) + abs(z__); |
| 25462 |
tmp = t[j1 + j1 * t_dim1]; |
| 25463 |
if (tjj < sminw) { |
| 25464 |
tmp = sminw; |
| 25465 |
tjj = sminw; |
| 25466 |
*info = 1; |
| 25467 |
} |
| 25468 |
|
| 25469 |
if (tjj < 1.) { |
| 25470 |
if (xj > bignum * tjj) { |
| 25471 |
rec = 1. / xj; |
| 25472 |
dscal_(&n2, &rec, &x[1], &c__1); |
| 25473 |
*scale *= rec; |
| 25474 |
xmax *= rec; |
| 25475 |
} |
| 25476 |
} |
| 25477 |
d__1 = -z__; |
| 25478 |
dladiv_(&x[j1], &x[*n + j1], &tmp, &d__1, &sr, &si); |
| 25479 |
x[j1] = sr; |
| 25480 |
x[j1 + *n] = si; |
| 25481 |
/* Computing MAX */ |
| 25482 |
d__3 = (d__1 = x[j1], abs(d__1)) + (d__2 = x[j1 + *n], |
| 25483 |
abs(d__2)); |
| 25484 |
xmax = std::max(d__3,xmax); |
| 25485 |
|
| 25486 |
} else { |
| 25487 |
|
| 25488 |
/* 2 by 2 diagonal block */ |
| 25489 |
|
| 25490 |
/* Scale if necessary to avoid overflow in forming the */ |
| 25491 |
/* right-hand side element by inner product. */ |
| 25492 |
|
| 25493 |
/* Computing MAX */ |
| 25494 |
d__5 = (d__1 = x[j1], abs(d__1)) + (d__2 = x[*n + j1], |
| 25495 |
abs(d__2)), d__6 = (d__3 = x[j2], abs(d__3)) + ( |
| 25496 |
d__4 = x[*n + j2], abs(d__4)); |
| 25497 |
xj = std::max(d__5,d__6); |
| 25498 |
if (xmax > 1.) { |
| 25499 |
rec = 1. / xmax; |
| 25500 |
/* Computing MAX */ |
| 25501 |
d__1 = work[j1], d__2 = work[j2]; |
| 25502 |
if (std::max(d__1,d__2) > (bignum - xj) / xmax) { |
| 25503 |
dscal_(&n2, &rec, &x[1], &c__1); |
| 25504 |
*scale *= rec; |
| 25505 |
xmax *= rec; |
| 25506 |
} |
| 25507 |
} |
| 25508 |
|
| 25509 |
i__2 = j1 - 1; |
| 25510 |
d__[0] = x[j1] - ddot_(&i__2, &t[j1 * t_dim1 + 1], &c__1, |
| 25511 |
&x[1], &c__1); |
| 25512 |
i__2 = j1 - 1; |
| 25513 |
d__[1] = x[j2] - ddot_(&i__2, &t[j2 * t_dim1 + 1], &c__1, |
| 25514 |
&x[1], &c__1); |
| 25515 |
i__2 = j1 - 1; |
| 25516 |
d__[2] = x[*n + j1] - ddot_(&i__2, &t[j1 * t_dim1 + 1], & |
| 25517 |
c__1, &x[*n + 1], &c__1); |
| 25518 |
i__2 = j1 - 1; |
| 25519 |
d__[3] = x[*n + j2] - ddot_(&i__2, &t[j2 * t_dim1 + 1], & |
| 25520 |
c__1, &x[*n + 1], &c__1); |
| 25521 |
d__[0] -= b[j1] * x[*n + 1]; |
| 25522 |
d__[1] -= b[j2] * x[*n + 1]; |
| 25523 |
d__[2] += b[j1] * x[1]; |
| 25524 |
d__[3] += b[j2] * x[1]; |
| 25525 |
|
| 25526 |
dlaln2_(&c_true, &c__2, &c__2, &sminw, &c_b21, &t[j1 + j1 |
| 25527 |
* t_dim1], ldt, &c_b21, &c_b21, d__, &c__2, & |
| 25528 |
c_b25, w, v, &c__2, &scaloc, &xnorm, &ierr); |
| 25529 |
if (ierr != 0) { |
| 25530 |
*info = 2; |
| 25531 |
} |
| 25532 |
|
| 25533 |
if (scaloc != 1.) { |
| 25534 |
dscal_(&n2, &scaloc, &x[1], &c__1); |
| 25535 |
*scale = scaloc * *scale; |
| 25536 |
} |
| 25537 |
x[j1] = v[0]; |
| 25538 |
x[j2] = v[1]; |
| 25539 |
x[*n + j1] = v[2]; |
| 25540 |
x[*n + j2] = v[3]; |
| 25541 |
/* Computing MAX */ |
| 25542 |
d__5 = (d__1 = x[j1], abs(d__1)) + (d__2 = x[*n + j1], |
| 25543 |
abs(d__2)), d__6 = (d__3 = x[j2], abs(d__3)) + ( |
| 25544 |
d__4 = x[*n + j2], abs(d__4)), d__5 = std::max(d__5, |
| 25545 |
d__6); |
| 25546 |
xmax = std::max(d__5,xmax); |
| 25547 |
|
| 25548 |
} |
| 25549 |
|
| 25550 |
L80: |
| 25551 |
; |
| 25552 |
} |
| 25553 |
|
| 25554 |
} |
| 25555 |
|
| 25556 |
} |
| 25557 |
|
| 25558 |
return 0; |
| 25559 |
|
| 25560 |
/* End of DLAQTR */ |
| 25561 |
|
| 25562 |
} /* dlaqtr_ */ |