| 1 | #cxx . . $ `<file>/external/clapack/lapack_dg.cpp`/include "clapack.h"cxx . . $ `<file>/external/clapack/clapack.h`/ |
| 2 | #include "f2cP.h"cxx . . $ `<file>/external/clapack/f2cP.h`/ |
| 3 | |
| 4 | /* Subroutine */ int dgbbrd_cxx . . $ dgbbrd_(b2632182fbc33135).(const char *vect, integercxx . . $ integer# *m, integercxx . . $ integer# *n, integercxx . . $ integer# *ncc, |
| 5 | integercxx . . $ integer# *kl, integercxx . . $ integer# *ku, double *ab, integercxx . . $ integer# *ldab, double * |
| 6 | d__, double *e, double *q, integercxx . . $ integer# *ldq, double *pt, |
| 7 | integercxx . . $ integer# *ldpt, double *c__, integercxx . . $ integer# *ldc, double *work, |
| 8 | integercxx . . $ integer# *info) |
| 9 | { |
| 10 | /* Table of constant values */ |
| 11 | static double c_b8 = 0.; |
| 12 | static double c_b9 = 1.; |
| 13 | static integercxx . . $ integer# c__1 = 1; |
| 14 | |
| 15 | /* System generated locals */ |
| 16 | integercxx . . $ integer# ab_dim1, ab_offset, c_dim1, c_offset, pt_dim1, pt_offset, q_dim1, |
| 17 | q_offset, i__1, i__2, i__3, i__4, i__5, i__6, i__7; |
| 18 | |
| 19 | /* Local variables */ |
| 20 | integercxx . . $ integer# i__, j, l, j1, j2, kb; |
| 21 | double ra, rb, rc; |
| 22 | integercxx . . $ integer# kk, ml, mn, nr, mu; |
| 23 | double rs; |
| 24 | integercxx . . $ integer# kb1, ml0, mu0, klm, kun, nrt, klu1, inca; |
| 25 | bool wantb, wantc; |
| 26 | integercxx . . $ integer# minmn; |
| 27 | bool wantq; |
| 28 | bool wantpt; |
| 29 | |
| 30 | |
| 31 | /* -- LAPACK routine (version 3.1) -- */ |
| 32 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 33 | /* November 2006 */ |
| 34 | |
| 35 | /* .. Scalar Arguments .. */ |
| 36 | /* .. */ |
| 37 | /* .. Array Arguments .. */ |
| 38 | /* .. */ |
| 39 | |
| 40 | /* Purpose */ |
| 41 | /* ======= */ |
| 42 | |
| 43 | /* DGBBRD reduces a real general m-by-n band matrix A to upper */ |
| 44 | /* bidiagonal form B by an orthogonal transformation: Q' * A * P = B. */ |
| 45 | |
| 46 | /* The routine computes B, and optionally forms Q or P', or computes */ |
| 47 | /* Q'*C for a given matrix C. */ |
| 48 | |
| 49 | /* Arguments */ |
| 50 | /* ========= */ |
| 51 | |
| 52 | /* VECT (input) CHARACTER*1 */ |
| 53 | /* Specifies whether or not the matrices Q and P' are to be */ |
| 54 | /* formed. */ |
| 55 | /* = 'N': do not form Q or P'; */ |
| 56 | /* = 'Q': form Q only; */ |
| 57 | /* = 'P': form P' only; */ |
| 58 | /* = 'B': form both. */ |
| 59 | |
| 60 | /* M (input) INTEGER */ |
| 61 | /* The number of rows of the matrix A. M >= 0. */ |
| 62 | |
| 63 | /* N (input) INTEGER */ |
| 64 | /* The number of columns of the matrix A. N >= 0. */ |
| 65 | |
| 66 | /* NCC (input) INTEGER */ |
| 67 | /* The number of columns of the matrix C. NCC >= 0. */ |
| 68 | |
| 69 | /* KL (input) INTEGER */ |
| 70 | /* The number of subdiagonals of the matrix A. KL >= 0. */ |
| 71 | |
| 72 | /* KU (input) INTEGER */ |
| 73 | /* The number of superdiagonals of the matrix A. KU >= 0. */ |
| 74 | |
| 75 | /* AB (input/output) DOUBLE PRECISION array, dimension (LDAB,N) */ |
| 76 | /* On entry, the m-by-n band matrix A, stored in rows 1 to */ |
| 77 | /* KL+KU+1. The j-th column of A is stored in the j-th column of */ |
| 78 | /* the array AB as follows: */ |
| 79 | /* AB(ku+1+i-j,j) = A(i,j) for max(1,j-ku)<=i<=min(m,j+kl). */ |
| 80 | /* On exit, A is overwritten by values generated during the */ |
| 81 | /* reduction. */ |
| 82 | |
| 83 | /* LDAB (input) INTEGER */ |
| 84 | /* The leading dimension of the array A. LDAB >= KL+KU+1. */ |
| 85 | |
| 86 | /* D (output) DOUBLE PRECISION array, dimension (min(M,N)) */ |
| 87 | /* The diagonal elements of the bidiagonal matrix B. */ |
| 88 | |
| 89 | /* E (output) DOUBLE PRECISION array, dimension (min(M,N)-1) */ |
| 90 | /* The superdiagonal elements of the bidiagonal matrix B. */ |
| 91 | |
| 92 | /* Q (output) DOUBLE PRECISION array, dimension (LDQ,M) */ |
| 93 | /* If VECT = 'Q' or 'B', the m-by-m orthogonal matrix Q. */ |
| 94 | /* If VECT = 'N' or 'P', the array Q is not referenced. */ |
| 95 | |
| 96 | /* LDQ (input) INTEGER */ |
| 97 | /* The leading dimension of the array Q. */ |
| 98 | /* LDQ >= max(1,M) if VECT = 'Q' or 'B'; LDQ >= 1 otherwise. */ |
| 99 | |
| 100 | /* PT (output) DOUBLE PRECISION array, dimension (LDPT,N) */ |
| 101 | /* If VECT = 'P' or 'B', the n-by-n orthogonal matrix P'. */ |
| 102 | /* If VECT = 'N' or 'Q', the array PT is not referenced. */ |
| 103 | |
| 104 | /* LDPT (input) INTEGER */ |
| 105 | /* The leading dimension of the array PT. */ |
| 106 | /* LDPT >= max(1,N) if VECT = 'P' or 'B'; LDPT >= 1 otherwise. */ |
| 107 | |
| 108 | /* C (input/output) DOUBLE PRECISION array, dimension (LDC,NCC) */ |
| 109 | /* On entry, an m-by-ncc matrix C. */ |
| 110 | /* On exit, C is overwritten by Q'*C. */ |
| 111 | /* C is not referenced if NCC = 0. */ |
| 112 | |
| 113 | /* LDC (input) INTEGER */ |
| 114 | /* The leading dimension of the array C. */ |
| 115 | /* LDC >= max(1,M) if NCC > 0; LDC >= 1 if NCC = 0. */ |
| 116 | |
| 117 | /* WORK (workspace) DOUBLE PRECISION array, dimension (2*max(M,N)) */ |
| 118 | |
| 119 | /* INFO (output) INTEGER */ |
| 120 | /* = 0: successful exit. */ |
| 121 | /* < 0: if INFO = -i, the i-th argument had an illegal value. */ |
| 122 | |
| 123 | /* ===================================================================== */ |
| 124 | |
| 125 | /* .. Parameters .. */ |
| 126 | /* .. */ |
| 127 | /* .. Local Scalars .. */ |
| 128 | /* .. */ |
| 129 | /* .. External Subroutines .. */ |
| 130 | /* .. */ |
| 131 | /* .. Intrinsic Functions .. */ |
| 132 | /* .. */ |
| 133 | /* .. External Functions .. */ |
| 134 | /* .. */ |
| 135 | /* .. Executable Statements .. */ |
| 136 | |
| 137 | /* Test the input parameters */ |
| 138 | |
| 139 | /* Parameter adjustments */ |
| 140 | ab_dim1 = *ldab; |
| 141 | ab_offset = 1 + ab_dim1; |
| 142 | ab -= ab_offset; |
| 143 | --d__; |
| 144 | --e; |
| 145 | q_dim1 = *ldq; |
| 146 | q_offset = 1 + q_dim1; |
| 147 | q -= q_offset; |
| 148 | pt_dim1 = *ldpt; |
| 149 | pt_offset = 1 + pt_dim1; |
| 150 | pt -= pt_offset; |
| 151 | c_dim1 = *ldc; |
| 152 | c_offset = 1 + c_dim1; |
| 153 | c__ -= c_offset; |
| 154 | --work; |
| 155 | |
| 156 | /* Function Body */ |
| 157 | wantb = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(vect, "B"); |
| 158 | wantq = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(vect, "Q") || wantb; |
| 159 | wantpt = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(vect, "P") || wantb; |
| 160 | wantc = *ncc > 0; |
| 161 | klu1 = *kl + *ku + 1; |
| 162 | *info = 0; |
| 163 | if (! wantq && ! wantpt && ! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(vect, "N")) { |
| 164 | *info = -1; |
| 165 | } else if (*m < 0) { |
| 166 | *info = -2; |
| 167 | } else if (*n < 0) { |
| 168 | *info = -3; |
| 169 | } else if (*ncc < 0) { |
| 170 | *info = -4; |
| 171 | } else if (*kl < 0) { |
| 172 | *info = -5; |
| 173 | } else if (*ku < 0) { |
| 174 | *info = -6; |
| 175 | } else if (*ldab < klu1) { |
| 176 | *info = -8; |
| 177 | } else if (*ldq < 1 || wantq && *ldq < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*m)) { |
| 178 | *info = -12; |
| 179 | } else if (*ldpt < 1 || wantpt && *ldpt < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 180 | *info = -14; |
| 181 | } else if (*ldc < 1 || wantc && *ldc < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*m)) { |
| 182 | *info = -16; |
| 183 | } |
| 184 | if (*info != 0) { |
| 185 | i__1 = -(*info); |
| 186 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGBBRD", &i__1); |
| 187 | return 0; |
| 188 | } |
| 189 | |
| 190 | /* Initialize Q and P' to the unit matrix, if needed */ |
| 191 | |
| 192 | if (wantq) { |
| 193 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("Full", m, m, &c_b8, &c_b9, &q[q_offset], ldq); |
| 194 | } |
| 195 | if (wantpt) { |
| 196 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("Full", n, n, &c_b8, &c_b9, &pt[pt_offset], ldpt); |
| 197 | } |
| 198 | |
| 199 | /* Quick return if possible. */ |
| 200 | |
| 201 | if (*m == 0 || *n == 0) { |
| 202 | return 0; |
| 203 | } |
| 204 | |
| 205 | minmn = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(*m,*n); |
| 206 | |
| 207 | if (*kl + *ku > 1) { |
| 208 | |
| 209 | /* Reduce to upper bidiagonal form if KU > 0; if KU = 0, reduce */ |
| 210 | /* first to lower bidiagonal form and then transform to upper */ |
| 211 | /* bidiagonal */ |
| 212 | |
| 213 | if (*ku > 0) { |
| 214 | ml0 = 1; |
| 215 | mu0 = 2; |
| 216 | } else { |
| 217 | ml0 = 2; |
| 218 | mu0 = 1; |
| 219 | } |
| 220 | |
| 221 | /* Wherever possible, plane rotations are generated and applied in */ |
| 222 | /* vector operations of length NR over the index set J1:J2:KLU1. */ |
| 223 | |
| 224 | /* The sines of the plane rotations are stored in WORK(1:max(m,n)) */ |
| 225 | /* and the cosines in WORK(max(m,n)+1:2*max(m,n)). */ |
| 226 | |
| 227 | mn = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(*m,*n); |
| 228 | /* Computing MIN */ |
| 229 | i__1 = *m - 1; |
| 230 | klm = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__1,*kl); |
| 231 | /* Computing MIN */ |
| 232 | i__1 = *n - 1; |
| 233 | kun = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__1,*ku); |
| 234 | kb = klm + kun; |
| 235 | kb1 = kb + 1; |
| 236 | inca = kb1 * *ldab; |
| 237 | nr = 0; |
| 238 | j1 = klm + 2; |
| 239 | j2 = 1 - kun; |
| 240 | |
| 241 | i__1 = minmn; |
| 242 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 243 | |
| 244 | /* Reduce i-th column and i-th row of matrix to bidiagonal form */ |
| 245 | |
| 246 | ml = klm + 1; |
| 247 | mu = kun + 1; |
| 248 | i__2 = kb; |
| 249 | for (kk = 1; kk <= i__2; ++kk) { |
| 250 | j1 += kb; |
| 251 | j2 += kb; |
| 252 | |
| 253 | /* generate plane rotations to annihilate nonzero elements */ |
| 254 | /* which have been created below the band */ |
| 255 | |
| 256 | if (nr > 0) { |
| 257 | dlargv_cxx . . $ dlargv_(2f32124b3213cda3).(&nr, &ab[klu1 + (j1 - klm - 1) * ab_dim1], &inca, |
| 258 | &work[j1], &kb1, &work[mn + j1], &kb1); |
| 259 | } |
| 260 | |
| 261 | /* apply plane rotations from the left */ |
| 262 | |
| 263 | i__3 = kb; |
| 264 | for (l = 1; l <= i__3; ++l) { |
| 265 | if (j2 - klm + l - 1 > *n) { |
| 266 | nrt = nr - 1; |
| 267 | } else { |
| 268 | nrt = nr; |
| 269 | } |
| 270 | if (nrt > 0) { |
| 271 | dlartv_cxx . . $ dlartv_(6543a7aae74f16df).(&nrt, &ab[klu1 - l + (j1 - klm + l - 1) * |
| 272 | ab_dim1], &inca, &ab[klu1 - l + 1 + (j1 - klm |
| 273 | + l - 1) * ab_dim1], &inca, &work[mn + j1], & |
| 274 | work[j1], &kb1); |
| 275 | } |
| 276 | /* L10: */ |
| 277 | } |
| 278 | |
| 279 | if (ml > ml0) { |
| 280 | if (ml <= *m - i__ + 1) { |
| 281 | |
| 282 | /* generate plane rotation to annihilate a(i+ml-1,i) */ |
| 283 | /* within the band, and apply rotation from the left */ |
| 284 | |
| 285 | dlartg_cxx . . $ dlartg_(f2b979bf0498d687).(&ab[*ku + ml - 1 + i__ * ab_dim1], &ab[*ku + |
| 286 | ml + i__ * ab_dim1], &work[mn + i__ + ml - 1], |
| 287 | &work[i__ + ml - 1], &ra); |
| 288 | ab[*ku + ml - 1 + i__ * ab_dim1] = ra; |
| 289 | if (i__ < *n) { |
| 290 | /* Computing MIN */ |
| 291 | i__4 = *ku + ml - 2, i__5 = *n - i__; |
| 292 | i__3 = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__4,i__5); |
| 293 | i__6 = *ldab - 1; |
| 294 | i__7 = *ldab - 1; |
| 295 | drot_cxx . . $ drot_(31e32f39c16a90e0).(&i__3, &ab[*ku + ml - 2 + (i__ + 1) * |
| 296 | ab_dim1], &i__6, &ab[*ku + ml - 1 + (i__ |
| 297 | + 1) * ab_dim1], &i__7, &work[mn + i__ + |
| 298 | ml - 1], &work[i__ + ml - 1]); |
| 299 | } |
| 300 | } |
| 301 | ++nr; |
| 302 | j1 -= kb1; |
| 303 | } |
| 304 | |
| 305 | if (wantq) { |
| 306 | |
| 307 | /* accumulate product of plane rotations in Q */ |
| 308 | |
| 309 | i__3 = j2; |
| 310 | i__4 = kb1; |
| 311 | for (j = j1; i__4 < 0 ? j >= i__3 : j <= i__3; j += i__4) |
| 312 | { |
| 313 | drot_cxx . . $ drot_(31e32f39c16a90e0).(m, &q[(j - 1) * q_dim1 + 1], &c__1, &q[j * |
| 314 | q_dim1 + 1], &c__1, &work[mn + j], &work[j]); |
| 315 | /* L20: */ |
| 316 | } |
| 317 | } |
| 318 | |
| 319 | if (wantc) { |
| 320 | |
| 321 | /* apply plane rotations to C */ |
| 322 | |
| 323 | i__4 = j2; |
| 324 | i__3 = kb1; |
| 325 | for (j = j1; i__3 < 0 ? j >= i__4 : j <= i__4; j += i__3) |
| 326 | { |
| 327 | drot_cxx . . $ drot_(31e32f39c16a90e0).(ncc, &c__[j - 1 + c_dim1], ldc, &c__[j + c_dim1] |
| 328 | , ldc, &work[mn + j], &work[j]); |
| 329 | /* L30: */ |
| 330 | } |
| 331 | } |
| 332 | |
| 333 | if (j2 + kun > *n) { |
| 334 | |
| 335 | /* adjust J2 to keep within the bounds of the matrix */ |
| 336 | |
| 337 | --nr; |
| 338 | j2 -= kb1; |
| 339 | } |
| 340 | |
| 341 | i__3 = j2; |
| 342 | i__4 = kb1; |
| 343 | for (j = j1; i__4 < 0 ? j >= i__3 : j <= i__3; j += i__4) { |
| 344 | |
| 345 | /* create nonzero element a(j-1,j+ku) above the band */ |
| 346 | /* and store it in WORK(n+1:2*n) */ |
| 347 | |
| 348 | work[j + kun] = work[j] * ab[(j + kun) * ab_dim1 + 1]; |
| 349 | ab[(j + kun) * ab_dim1 + 1] = work[mn + j] * ab[(j + kun) |
| 350 | * ab_dim1 + 1]; |
| 351 | /* L40: */ |
| 352 | } |
| 353 | |
| 354 | /* generate plane rotations to annihilate nonzero elements */ |
| 355 | /* which have been generated above the band */ |
| 356 | |
| 357 | if (nr > 0) { |
| 358 | dlargv_cxx . . $ dlargv_(2f32124b3213cda3).(&nr, &ab[(j1 + kun - 1) * ab_dim1 + 1], &inca, & |
| 359 | work[j1 + kun], &kb1, &work[mn + j1 + kun], &kb1); |
| 360 | } |
| 361 | |
| 362 | /* apply plane rotations from the right */ |
| 363 | |
| 364 | i__4 = kb; |
| 365 | for (l = 1; l <= i__4; ++l) { |
| 366 | if (j2 + l - 1 > *m) { |
| 367 | nrt = nr - 1; |
| 368 | } else { |
| 369 | nrt = nr; |
| 370 | } |
| 371 | if (nrt > 0) { |
| 372 | dlartv_cxx . . $ dlartv_(6543a7aae74f16df).(&nrt, &ab[l + 1 + (j1 + kun - 1) * ab_dim1], & |
| 373 | inca, &ab[l + (j1 + kun) * ab_dim1], &inca, & |
| 374 | work[mn + j1 + kun], &work[j1 + kun], &kb1); |
| 375 | } |
| 376 | /* L50: */ |
| 377 | } |
| 378 | |
| 379 | if (ml == ml0 && mu > mu0) { |
| 380 | if (mu <= *n - i__ + 1) { |
| 381 | |
| 382 | /* generate plane rotation to annihilate a(i,i+mu-1) */ |
| 383 | /* within the band, and apply rotation from the right */ |
| 384 | |
| 385 | dlartg_cxx . . $ dlartg_(f2b979bf0498d687).(&ab[*ku - mu + 3 + (i__ + mu - 2) * ab_dim1], |
| 386 | &ab[*ku - mu + 2 + (i__ + mu - 1) * ab_dim1], |
| 387 | &work[mn + i__ + mu - 1], &work[i__ + mu - 1], |
| 388 | &ra); |
| 389 | ab[*ku - mu + 3 + (i__ + mu - 2) * ab_dim1] = ra; |
| 390 | /* Computing MIN */ |
| 391 | i__3 = *kl + mu - 2, i__5 = *m - i__; |
| 392 | i__4 = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__3,i__5); |
| 393 | drot_cxx . . $ drot_(31e32f39c16a90e0).(&i__4, &ab[*ku - mu + 4 + (i__ + mu - 2) * |
| 394 | ab_dim1], &c__1, &ab[*ku - mu + 3 + (i__ + mu |
| 395 | - 1) * ab_dim1], &c__1, &work[mn + i__ + mu - |
| 396 | 1], &work[i__ + mu - 1]); |
| 397 | } |
| 398 | ++nr; |
| 399 | j1 -= kb1; |
| 400 | } |
| 401 | |
| 402 | if (wantpt) { |
| 403 | |
| 404 | /* accumulate product of plane rotations in P' */ |
| 405 | |
| 406 | i__4 = j2; |
| 407 | i__3 = kb1; |
| 408 | for (j = j1; i__3 < 0 ? j >= i__4 : j <= i__4; j += i__3) |
| 409 | { |
| 410 | drot_cxx . . $ drot_(31e32f39c16a90e0).(n, &pt[j + kun - 1 + pt_dim1], ldpt, &pt[j + |
| 411 | kun + pt_dim1], ldpt, &work[mn + j + kun], & |
| 412 | work[j + kun]); |
| 413 | /* L60: */ |
| 414 | } |
| 415 | } |
| 416 | |
| 417 | if (j2 + kb > *m) { |
| 418 | |
| 419 | /* adjust J2 to keep within the bounds of the matrix */ |
| 420 | |
| 421 | --nr; |
| 422 | j2 -= kb1; |
| 423 | } |
| 424 | |
| 425 | i__3 = j2; |
| 426 | i__4 = kb1; |
| 427 | for (j = j1; i__4 < 0 ? j >= i__3 : j <= i__3; j += i__4) { |
| 428 | |
| 429 | /* create nonzero element a(j+kl+ku,j+ku-1) below the */ |
| 430 | /* band and store it in WORK(1:n) */ |
| 431 | |
| 432 | work[j + kb] = work[j + kun] * ab[klu1 + (j + kun) * |
| 433 | ab_dim1]; |
| 434 | ab[klu1 + (j + kun) * ab_dim1] = work[mn + j + kun] * ab[ |
| 435 | klu1 + (j + kun) * ab_dim1]; |
| 436 | /* L70: */ |
| 437 | } |
| 438 | |
| 439 | if (ml > ml0) { |
| 440 | --ml; |
| 441 | } else { |
| 442 | --mu; |
| 443 | } |
| 444 | /* L80: */ |
| 445 | } |
| 446 | /* L90: */ |
| 447 | } |
| 448 | } |
| 449 | |
| 450 | if (*ku == 0 && *kl > 0) { |
| 451 | |
| 452 | /* A has been reduced to lower bidiagonal form */ |
| 453 | |
| 454 | /* Transform lower bidiagonal form to upper bidiagonal by applying */ |
| 455 | /* plane rotations from the left, storing diagonal elements in D */ |
| 456 | /* and off-diagonal elements in E */ |
| 457 | |
| 458 | /* Computing MIN */ |
| 459 | i__2 = *m - 1; |
| 460 | i__1 = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__2,*n); |
| 461 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 462 | dlartg_cxx . . $ dlartg_(f2b979bf0498d687).(&ab[i__ * ab_dim1 + 1], &ab[i__ * ab_dim1 + 2], &rc, &rs, |
| 463 | &ra); |
| 464 | d__[i__] = ra; |
| 465 | if (i__ < *n) { |
| 466 | e[i__] = rs * ab[(i__ + 1) * ab_dim1 + 1]; |
| 467 | ab[(i__ + 1) * ab_dim1 + 1] = rc * ab[(i__ + 1) * ab_dim1 + 1] |
| 468 | ; |
| 469 | } |
| 470 | if (wantq) { |
| 471 | drot_cxx . . $ drot_(31e32f39c16a90e0).(m, &q[i__ * q_dim1 + 1], &c__1, &q[(i__ + 1) * q_dim1 + |
| 472 | 1], &c__1, &rc, &rs); |
| 473 | } |
| 474 | if (wantc) { |
| 475 | drot_cxx . . $ drot_(31e32f39c16a90e0).(ncc, &c__[i__ + c_dim1], ldc, &c__[i__ + 1 + c_dim1], |
| 476 | ldc, &rc, &rs); |
| 477 | } |
| 478 | /* L100: */ |
| 479 | } |
| 480 | if (*m <= *n) { |
| 481 | d__[*m] = ab[*m * ab_dim1 + 1]; |
| 482 | } |
| 483 | } else if (*ku > 0) { |
| 484 | |
| 485 | /* A has been reduced to upper bidiagonal form */ |
| 486 | |
| 487 | if (*m < *n) { |
| 488 | |
| 489 | /* Annihilate a(m,m+1) by applying plane rotations from the */ |
| 490 | /* right, storing diagonal elements in D and off-diagonal */ |
| 491 | /* elements in E */ |
| 492 | |
| 493 | rb = ab[*ku + (*m + 1) * ab_dim1]; |
| 494 | for (i__ = *m; i__ >= 1; --i__) { |
| 495 | dlartg_cxx . . $ dlartg_(f2b979bf0498d687).(&ab[*ku + 1 + i__ * ab_dim1], &rb, &rc, &rs, &ra); |
| 496 | d__[i__] = ra; |
| 497 | if (i__ > 1) { |
| 498 | rb = -rs * ab[*ku + i__ * ab_dim1]; |
| 499 | e[i__ - 1] = rc * ab[*ku + i__ * ab_dim1]; |
| 500 | } |
| 501 | if (wantpt) { |
| 502 | drot_cxx . . $ drot_(31e32f39c16a90e0).(n, &pt[i__ + pt_dim1], ldpt, &pt[*m + 1 + pt_dim1], |
| 503 | ldpt, &rc, &rs); |
| 504 | } |
| 505 | /* L110: */ |
| 506 | } |
| 507 | } else { |
| 508 | |
| 509 | /* Copy off-diagonal elements to E and diagonal elements to D */ |
| 510 | |
| 511 | i__1 = minmn - 1; |
| 512 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 513 | e[i__] = ab[*ku + (i__ + 1) * ab_dim1]; |
| 514 | /* L120: */ |
| 515 | } |
| 516 | i__1 = minmn; |
| 517 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 518 | d__[i__] = ab[*ku + 1 + i__ * ab_dim1]; |
| 519 | /* L130: */ |
| 520 | } |
| 521 | } |
| 522 | } else { |
| 523 | |
| 524 | /* A is diagonal. Set elements of E to zero and copy diagonal */ |
| 525 | /* elements to D. */ |
| 526 | |
| 527 | i__1 = minmn - 1; |
| 528 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 529 | e[i__] = 0.; |
| 530 | /* L140: */ |
| 531 | } |
| 532 | i__1 = minmn; |
| 533 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 534 | d__[i__] = ab[i__ * ab_dim1 + 1]; |
| 535 | /* L150: */ |
| 536 | } |
| 537 | } |
| 538 | return 0; |
| 539 | |
| 540 | /* End of DGBBRD */ |
| 541 | |
| 542 | } /* dgbbrd_ */ |
| 543 | |
| 544 | /* Subroutine */ int dgbcon_cxx . . $ dgbcon_(95628f5c4a095809).(const char *norm, integercxx . . $ integer# *n, integercxx . . $ integer# *kl, integercxx . . $ integer# *ku, |
| 545 | double *ab, integercxx . . $ integer# *ldab, integercxx . . $ integer# *ipiv, double *anorm, |
| 546 | double *rcond, double *work, integercxx . . $ integer# *iwork, integercxx . . $ integer# *info) |
| 547 | { |
| 548 | /* Table of constant values */ |
| 549 | static integercxx . . $ integer# c__1 = 1; |
| 550 | |
| 551 | /* System generated locals */ |
| 552 | integercxx . . $ integer# ab_dim1, ab_offset, i__1, i__2, i__3; |
| 553 | double d__1; |
| 554 | |
| 555 | /* Local variables */ |
| 556 | integercxx . . $ integer# j; |
| 557 | double t; |
| 558 | integercxx . . $ integer# kd, lm, jp, ix, kase; |
| 559 | integercxx . . $ integer# kase1; |
| 560 | double scale; |
| 561 | integercxx . . $ integer# isave[3]; |
| 562 | bool lnoti; |
| 563 | double ainvnm; |
| 564 | bool onenrm; |
| 565 | char normin[1]; |
| 566 | double smlnum; |
| 567 | |
| 568 | /* -- LAPACK routine (version 3.1) -- */ |
| 569 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 570 | /* November 2006 */ |
| 571 | |
| 572 | /* Modified to call DLACN2 in place of DLACON, 5 Feb 03, SJH. */ |
| 573 | |
| 574 | /* .. Scalar Arguments .. */ |
| 575 | /* .. */ |
| 576 | /* .. Array Arguments .. */ |
| 577 | /* .. */ |
| 578 | |
| 579 | /* Purpose */ |
| 580 | /* ======= */ |
| 581 | |
| 582 | /* DGBCON estimates the reciprocal of the condition number of a real */ |
| 583 | /* general band matrix A, in either the 1-norm or the infinity-norm, */ |
| 584 | /* using the LU factorization computed by DGBTRF. */ |
| 585 | |
| 586 | /* An estimate is obtained for norm(inv(A)), and the reciprocal of the */ |
| 587 | /* condition number is computed as */ |
| 588 | /* RCOND = 1 / ( norm(A) * norm(inv(A)) ). */ |
| 589 | |
| 590 | /* Arguments */ |
| 591 | /* ========= */ |
| 592 | |
| 593 | /* NORM (input) CHARACTER*1 */ |
| 594 | /* Specifies whether the 1-norm condition number or the */ |
| 595 | /* infinity-norm condition number is required: */ |
| 596 | /* = '1' or 'O': 1-norm; */ |
| 597 | /* = 'I': Infinity-norm. */ |
| 598 | |
| 599 | /* N (input) INTEGER */ |
| 600 | /* The order of the matrix A. N >= 0. */ |
| 601 | |
| 602 | /* KL (input) INTEGER */ |
| 603 | /* The number of subdiagonals within the band of A. KL >= 0. */ |
| 604 | |
| 605 | /* KU (input) INTEGER */ |
| 606 | /* The number of superdiagonals within the band of A. KU >= 0. */ |
| 607 | |
| 608 | /* AB (input) DOUBLE PRECISION array, dimension (LDAB,N) */ |
| 609 | /* Details of the LU factorization of the band matrix A, as */ |
| 610 | /* computed by DGBTRF. U is stored as an upper triangular band */ |
| 611 | /* matrix with KL+KU superdiagonals in rows 1 to KL+KU+1, and */ |
| 612 | /* the multipliers used during the factorization are stored in */ |
| 613 | /* rows KL+KU+2 to 2*KL+KU+1. */ |
| 614 | /* LDAB (input) INTEGER */ |
| 615 | /* The leading dimension of the array AB. LDAB >= 2*KL+KU+1. */ |
| 616 | |
| 617 | /* IPIV (input) INTEGER array, dimension (N) */ |
| 618 | /* The pivot indices; for 1 <= i <= N, row i of the matrix was */ |
| 619 | /* interchanged with row IPIV(i). */ |
| 620 | |
| 621 | /* ANORM (input) DOUBLE PRECISION */ |
| 622 | /* If NORM = '1' or 'O', the 1-norm of the original matrix A. */ |
| 623 | /* If NORM = 'I', the infinity-norm of the original matrix A. */ |
| 624 | |
| 625 | /* RCOND (output) DOUBLE PRECISION */ |
| 626 | /* The reciprocal of the condition number of the matrix A, */ |
| 627 | /* computed as RCOND = 1/(norm(A) * norm(inv(A))). */ |
| 628 | |
| 629 | /* WORK (workspace) DOUBLE PRECISION array, dimension (3*N) */ |
| 630 | |
| 631 | /* IWORK (workspace) INTEGER array, dimension (N) */ |
| 632 | |
| 633 | /* INFO (output) INTEGER */ |
| 634 | /* = 0: successful exit */ |
| 635 | /* < 0: if INFO = -i, the i-th argument had an illegal value */ |
| 636 | |
| 637 | /* ===================================================================== */ |
| 638 | |
| 639 | /* .. Parameters .. */ |
| 640 | /* .. */ |
| 641 | /* .. Local Scalars .. */ |
| 642 | /* .. */ |
| 643 | /* .. Local Arrays .. */ |
| 644 | /* .. */ |
| 645 | /* .. External Functions .. */ |
| 646 | /* .. */ |
| 647 | /* .. External Subroutines .. */ |
| 648 | /* .. */ |
| 649 | /* .. Intrinsic Functions .. */ |
| 650 | /* .. */ |
| 651 | /* .. Executable Statements .. */ |
| 652 | |
| 653 | /* Test the input parameters. */ |
| 654 | |
| 655 | /* Parameter adjustments */ |
| 656 | ab_dim1 = *ldab; |
| 657 | ab_offset = 1 + ab_dim1; |
| 658 | ab -= ab_offset; |
| 659 | --ipiv; |
| 660 | --work; |
| 661 | --iwork; |
| 662 | |
| 663 | /* Function Body */ |
| 664 | *info = 0; |
| 665 | onenrm = *(unsigned char *)norm == '1' || lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(norm, "O"); |
| 666 | if (! onenrm && ! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(norm, "I")) { |
| 667 | *info = -1; |
| 668 | } else if (*n < 0) { |
| 669 | *info = -2; |
| 670 | } else if (*kl < 0) { |
| 671 | *info = -3; |
| 672 | } else if (*ku < 0) { |
| 673 | *info = -4; |
| 674 | } else if (*ldab < (*kl << 1) + *ku + 1) { |
| 675 | *info = -6; |
| 676 | } else if (*anorm < 0.) { |
| 677 | *info = -8; |
| 678 | } |
| 679 | if (*info != 0) { |
| 680 | i__1 = -(*info); |
| 681 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGBCON", &i__1); |
| 682 | return 0; |
| 683 | } |
| 684 | |
| 685 | /* Quick return if possible */ |
| 686 | |
| 687 | *rcond = 0.; |
| 688 | if (*n == 0) { |
| 689 | *rcond = 1.; |
| 690 | return 0; |
| 691 | } else if (*anorm == 0.) { |
| 692 | return 0; |
| 693 | } |
| 694 | |
| 695 | smlnum = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("Safe minimum"); |
| 696 | |
| 697 | /* Estimate the norm of inv(A). */ |
| 698 | |
| 699 | ainvnm = 0.; |
| 700 | *(unsigned char *)normin = 'N'; |
| 701 | if (onenrm) { |
| 702 | kase1 = 1; |
| 703 | } else { |
| 704 | kase1 = 2; |
| 705 | } |
| 706 | kd = *kl + *ku + 1; |
| 707 | lnoti = *kl > 0; |
| 708 | kase = 0; |
| 709 | L10: |
| 710 | dlacn2_cxx . . $ dlacn2_(2d9e0fe6bd3e0917).(n, &work[*n + 1], &work[1], &iwork[1], &ainvnm, &kase, isave); |
| 711 | if (kase != 0) { |
| 712 | if (kase == kase1) { |
| 713 | |
| 714 | /* Multiply by inv(L). */ |
| 715 | |
| 716 | if (lnoti) { |
| 717 | i__1 = *n - 1; |
| 718 | for (j = 1; j <= i__1; ++j) { |
| 719 | /* Computing MIN */ |
| 720 | i__2 = *kl, i__3 = *n - j; |
| 721 | lm = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__2,i__3); |
| 722 | jp = ipiv[j]; |
| 723 | t = work[jp]; |
| 724 | if (jp != j) { |
| 725 | work[jp] = work[j]; |
| 726 | work[j] = t; |
| 727 | } |
| 728 | d__1 = -t; |
| 729 | daxpy_cxx . . $ daxpy_(4b39f621356f7e14).(&lm, &d__1, &ab[kd + 1 + j * ab_dim1], &c__1, & |
| 730 | work[j + 1], &c__1); |
| 731 | /* L20: */ |
| 732 | } |
| 733 | } |
| 734 | |
| 735 | /* Multiply by inv(U). */ |
| 736 | |
| 737 | i__1 = *kl + *ku; |
| 738 | dlatbs_cxx . . $ dlatbs_(a8a853ca788eb975).("Upper", "No transpose", "Non-unit", normin, n, &i__1, & |
| 739 | ab[ab_offset], ldab, &work[1], &scale, &work[(*n << 1) + |
| 740 | 1], info); |
| 741 | } else { |
| 742 | |
| 743 | /* Multiply by inv(U'). */ |
| 744 | |
| 745 | i__1 = *kl + *ku; |
| 746 | dlatbs_cxx . . $ dlatbs_(a8a853ca788eb975).("Upper", "Transpose", "Non-unit", normin, n, &i__1, &ab[ |
| 747 | ab_offset], ldab, &work[1], &scale, &work[(*n << 1) + 1], |
| 748 | info); |
| 749 | |
| 750 | /* Multiply by inv(L'). */ |
| 751 | |
| 752 | if (lnoti) { |
| 753 | for (j = *n - 1; j >= 1; --j) { |
| 754 | /* Computing MIN */ |
| 755 | i__1 = *kl, i__2 = *n - j; |
| 756 | lm = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__1,i__2); |
| 757 | work[j] -= ddot_cxx . . $ ddot_(2885988431543d16).(&lm, &ab[kd + 1 + j * ab_dim1], &c__1, & |
| 758 | work[j + 1], &c__1); |
| 759 | jp = ipiv[j]; |
| 760 | if (jp != j) { |
| 761 | t = work[jp]; |
| 762 | work[jp] = work[j]; |
| 763 | work[j] = t; |
| 764 | } |
| 765 | /* L30: */ |
| 766 | } |
| 767 | } |
| 768 | } |
| 769 | |
| 770 | /* Divide X by 1/SCALE if doing so will not cause overflow. */ |
| 771 | |
| 772 | *(unsigned char *)normin = 'Y'; |
| 773 | if (scale != 1.) { |
| 774 | ix = idamax_cxx . . $ idamax_(a5c31fbfbc00ee45).(n, &work[1], &c__1); |
| 775 | if (scale < (d__1 = work[ix], abscxx . . $ abs(447c67c6676f75c3).(d__1)) * smlnum || scale == 0.) |
| 776 | { |
| 777 | goto L40; |
| 778 | } |
| 779 | drscl_cxx . . $ drscl_(f22c1db71784c345).(n, &scale, &work[1], &c__1); |
| 780 | } |
| 781 | goto L10; |
| 782 | } |
| 783 | |
| 784 | /* Compute the estimate of the reciprocal condition number. */ |
| 785 | |
| 786 | if (ainvnm != 0.) { |
| 787 | *rcond = 1. / ainvnm / *anorm; |
| 788 | } |
| 789 | |
| 790 | L40: |
| 791 | return 0; |
| 792 | |
| 793 | /* End of DGBCON */ |
| 794 | |
| 795 | } /* dgbcon_ */ |
| 796 | |
| 797 | /* Subroutine */ int dgbequ_cxx . . $ dgbequ_(232ca6a811deebd2).(integercxx . . $ integer# *m, integercxx . . $ integer# *n, integercxx . . $ integer# *kl, integercxx . . $ integer# *ku, |
| 798 | double *ab, integercxx . . $ integer# *ldab, double *r__, double *c__, |
| 799 | double *rowcnd, double *colcnd, double *amax, integercxx . . $ integer# * |
| 800 | info) |
| 801 | { |
| 802 | /* System generated locals */ |
| 803 | integercxx . . $ integer# ab_dim1, ab_offset, i__1, i__2, i__3, i__4; |
| 804 | double d__1, d__2, d__3; |
| 805 | |
| 806 | /* Local variables */ |
| 807 | integercxx . . $ integer# i__, j, kd; |
| 808 | double rcmin, rcmax; |
| 809 | double bignum, smlnum; |
| 810 | |
| 811 | |
| 812 | /* -- LAPACK routine (version 3.1) -- */ |
| 813 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 814 | /* November 2006 */ |
| 815 | |
| 816 | /* .. Scalar Arguments .. */ |
| 817 | /* .. */ |
| 818 | /* .. Array Arguments .. */ |
| 819 | /* .. */ |
| 820 | |
| 821 | /* Purpose */ |
| 822 | /* ======= */ |
| 823 | |
| 824 | /* DGBEQU computes row and column scalings intended to equilibrate an */ |
| 825 | /* M-by-N band matrix A and reduce its condition number. R returns the */ |
| 826 | /* row scale factors and C the column scale factors, chosen to try to */ |
| 827 | /* make the largest element in each row and column of the matrix B with */ |
| 828 | /* elements B(i,j)=R(i)*A(i,j)*C(j) have absolute value 1. */ |
| 829 | |
| 830 | /* R(i) and C(j) are restricted to be between SMLNUM = smallest safe */ |
| 831 | /* number and BIGNUM = largest safe number. Use of these scaling */ |
| 832 | /* factors is not guaranteed to reduce the condition number of A but */ |
| 833 | /* works well in practice. */ |
| 834 | |
| 835 | /* Arguments */ |
| 836 | /* ========= */ |
| 837 | |
| 838 | /* M (input) INTEGER */ |
| 839 | /* The number of rows of the matrix A. M >= 0. */ |
| 840 | |
| 841 | /* N (input) INTEGER */ |
| 842 | /* The number of columns of the matrix A. N >= 0. */ |
| 843 | |
| 844 | /* KL (input) INTEGER */ |
| 845 | /* The number of subdiagonals within the band of A. KL >= 0. */ |
| 846 | |
| 847 | /* KU (input) INTEGER */ |
| 848 | /* The number of superdiagonals within the band of A. KU >= 0. */ |
| 849 | |
| 850 | /* AB (input) DOUBLE PRECISION array, dimension (LDAB,N) */ |
| 851 | /* The band matrix A, stored in rows 1 to KL+KU+1. The j-th */ |
| 852 | /* column of A is stored in the j-th column of the array AB as */ |
| 853 | /* follows: */ |
| 854 | /* AB(ku+1+i-j,j) = A(i,j) for max(1,j-ku)<=i<=min(m,j+kl). */ |
| 855 | |
| 856 | /* LDAB (input) INTEGER */ |
| 857 | /* The leading dimension of the array AB. LDAB >= KL+KU+1. */ |
| 858 | |
| 859 | /* R (output) DOUBLE PRECISION array, dimension (M) */ |
| 860 | /* If INFO = 0, or INFO > M, R contains the row scale factors */ |
| 861 | /* for A. */ |
| 862 | |
| 863 | /* C (output) DOUBLE PRECISION array, dimension (N) */ |
| 864 | /* If INFO = 0, C contains the column scale factors for A. */ |
| 865 | |
| 866 | /* ROWCND (output) DOUBLE PRECISION */ |
| 867 | /* If INFO = 0 or INFO > M, ROWCND contains the ratio of the */ |
| 868 | /* smallest R(i) to the largest R(i). If ROWCND >= 0.1 and */ |
| 869 | /* AMAX is neither too large nor too small, it is not worth */ |
| 870 | /* scaling by R. */ |
| 871 | |
| 872 | /* COLCND (output) DOUBLE PRECISION */ |
| 873 | /* If INFO = 0, COLCND contains the ratio of the smallest */ |
| 874 | /* C(i) to the largest C(i). If COLCND >= 0.1, it is not */ |
| 875 | /* worth scaling by C. */ |
| 876 | |
| 877 | /* AMAX (output) DOUBLE PRECISION */ |
| 878 | /* Absolute value of largest matrix element. If AMAX is very */ |
| 879 | /* close to overflow or very close to underflow, the matrix */ |
| 880 | /* should be scaled. */ |
| 881 | |
| 882 | /* INFO (output) INTEGER */ |
| 883 | /* = 0: successful exit */ |
| 884 | /* < 0: if INFO = -i, the i-th argument had an illegal value */ |
| 885 | /* > 0: if INFO = i, and i is */ |
| 886 | /* <= M: the i-th row of A is exactly zero */ |
| 887 | /* > M: the (i-M)-th column of A is exactly zero */ |
| 888 | |
| 889 | /* ===================================================================== */ |
| 890 | |
| 891 | /* .. Parameters .. */ |
| 892 | /* .. */ |
| 893 | /* .. Local Scalars .. */ |
| 894 | /* .. */ |
| 895 | /* .. External Functions .. */ |
| 896 | /* .. */ |
| 897 | /* .. External Subroutines .. */ |
| 898 | /* .. */ |
| 899 | /* .. Intrinsic Functions .. */ |
| 900 | /* .. */ |
| 901 | /* .. Executable Statements .. */ |
| 902 | |
| 903 | /* Test the input parameters */ |
| 904 | |
| 905 | /* Parameter adjustments */ |
| 906 | ab_dim1 = *ldab; |
| 907 | ab_offset = 1 + ab_dim1; |
| 908 | ab -= ab_offset; |
| 909 | --r__; |
| 910 | --c__; |
| 911 | |
| 912 | /* Function Body */ |
| 913 | *info = 0; |
| 914 | if (*m < 0) { |
| 915 | *info = -1; |
| 916 | } else if (*n < 0) { |
| 917 | *info = -2; |
| 918 | } else if (*kl < 0) { |
| 919 | *info = -3; |
| 920 | } else if (*ku < 0) { |
| 921 | *info = -4; |
| 922 | } else if (*ldab < *kl + *ku + 1) { |
| 923 | *info = -6; |
| 924 | } |
| 925 | if (*info != 0) { |
| 926 | i__1 = -(*info); |
| 927 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGBEQU", &i__1); |
| 928 | return 0; |
| 929 | } |
| 930 | |
| 931 | /* Quick return if possible */ |
| 932 | |
| 933 | if (*m == 0 || *n == 0) { |
| 934 | *rowcnd = 1.; |
| 935 | *colcnd = 1.; |
| 936 | *amax = 0.; |
| 937 | return 0; |
| 938 | } |
| 939 | |
| 940 | /* Get machine constants. */ |
| 941 | |
| 942 | smlnum = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("S"); |
| 943 | bignum = 1. / smlnum; |
| 944 | |
| 945 | /* Compute row scale factors. */ |
| 946 | |
| 947 | i__1 = *m; |
| 948 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 949 | r__[i__] = 0.; |
| 950 | /* L10: */ |
| 951 | } |
| 952 | |
| 953 | /* Find the maximum element in each row. */ |
| 954 | |
| 955 | kd = *ku + 1; |
| 956 | i__1 = *n; |
| 957 | for (j = 1; j <= i__1; ++j) { |
| 958 | /* Computing MAX */ |
| 959 | i__2 = j - *ku; |
| 960 | /* Computing MIN */ |
| 961 | i__4 = j + *kl; |
| 962 | i__3 = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__4,*m); |
| 963 | for (i__ = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,1_integercxx . . $ `operator""_integer`(85240eb457c3721a).); i__ <= i__3; ++i__) { |
| 964 | /* Computing MAX */ |
| 965 | d__2 = r__[i__], d__3 = (d__1 = ab[kd + i__ - j + j * ab_dim1], |
| 966 | abscxx . . $ abs(447c67c6676f75c3).(d__1)); |
| 967 | r__[i__] = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__2,d__3); |
| 968 | /* L20: */ |
| 969 | } |
| 970 | /* L30: */ |
| 971 | } |
| 972 | |
| 973 | /* Find the maximum and minimum scale factors. */ |
| 974 | |
| 975 | rcmin = bignum; |
| 976 | rcmax = 0.; |
| 977 | i__1 = *m; |
| 978 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 979 | /* Computing MAX */ |
| 980 | d__1 = rcmax, d__2 = r__[i__]; |
| 981 | rcmax = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__1,d__2); |
| 982 | /* Computing MIN */ |
| 983 | d__1 = rcmin, d__2 = r__[i__]; |
| 984 | rcmin = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(d__1,d__2); |
| 985 | /* L40: */ |
| 986 | } |
| 987 | *amax = rcmax; |
| 988 | |
| 989 | if (rcmin == 0.) { |
| 990 | |
| 991 | /* Find the first zero scale factor and return an error code. */ |
| 992 | |
| 993 | i__1 = *m; |
| 994 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 995 | if (r__[i__] == 0.) { |
| 996 | *info = i__; |
| 997 | return 0; |
| 998 | } |
| 999 | /* L50: */ |
| 1000 | } |
| 1001 | } else { |
| 1002 | |
| 1003 | /* Invert the scale factors. */ |
| 1004 | |
| 1005 | i__1 = *m; |
| 1006 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 1007 | /* Computing MIN */ |
| 1008 | /* Computing MAX */ |
| 1009 | d__2 = r__[i__]; |
| 1010 | d__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__2,smlnum); |
| 1011 | r__[i__] = 1. / stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(d__1,bignum); |
| 1012 | /* L60: */ |
| 1013 | } |
| 1014 | |
| 1015 | /* Compute ROWCND = min(R(I)) / max(R(I)) */ |
| 1016 | |
| 1017 | *rowcnd = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(rcmin,smlnum) / stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(rcmax,bignum); |
| 1018 | } |
| 1019 | |
| 1020 | /* Compute column scale factors */ |
| 1021 | |
| 1022 | i__1 = *n; |
| 1023 | for (j = 1; j <= i__1; ++j) { |
| 1024 | c__[j] = 0.; |
| 1025 | /* L70: */ |
| 1026 | } |
| 1027 | |
| 1028 | /* Find the maximum element in each column, */ |
| 1029 | /* assuming the row scaling computed above. */ |
| 1030 | |
| 1031 | kd = *ku + 1; |
| 1032 | i__1 = *n; |
| 1033 | for (j = 1; j <= i__1; ++j) { |
| 1034 | /* Computing MAX */ |
| 1035 | i__3 = j - *ku; |
| 1036 | /* Computing MIN */ |
| 1037 | i__4 = j + *kl; |
| 1038 | i__2 = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__4,*m); |
| 1039 | for (i__ = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__3,1_integercxx . . $ `operator""_integer`(85240eb457c3721a).); i__ <= i__2; ++i__) { |
| 1040 | /* Computing MAX */ |
| 1041 | d__2 = c__[j], d__3 = (d__1 = ab[kd + i__ - j + j * ab_dim1], abscxx . . $ abs(447c67c6676f75c3).( |
| 1042 | d__1)) * r__[i__]; |
| 1043 | c__[j] = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__2,d__3); |
| 1044 | /* L80: */ |
| 1045 | } |
| 1046 | /* L90: */ |
| 1047 | } |
| 1048 | |
| 1049 | /* Find the maximum and minimum scale factors. */ |
| 1050 | |
| 1051 | rcmin = bignum; |
| 1052 | rcmax = 0.; |
| 1053 | i__1 = *n; |
| 1054 | for (j = 1; j <= i__1; ++j) { |
| 1055 | /* Computing MIN */ |
| 1056 | d__1 = rcmin, d__2 = c__[j]; |
| 1057 | rcmin = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(d__1,d__2); |
| 1058 | /* Computing MAX */ |
| 1059 | d__1 = rcmax, d__2 = c__[j]; |
| 1060 | rcmax = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__1,d__2); |
| 1061 | /* L100: */ |
| 1062 | } |
| 1063 | |
| 1064 | if (rcmin == 0.) { |
| 1065 | |
| 1066 | /* Find the first zero scale factor and return an error code. */ |
| 1067 | |
| 1068 | i__1 = *n; |
| 1069 | for (j = 1; j <= i__1; ++j) { |
| 1070 | if (c__[j] == 0.) { |
| 1071 | *info = *m + j; |
| 1072 | return 0; |
| 1073 | } |
| 1074 | /* L110: */ |
| 1075 | } |
| 1076 | } else { |
| 1077 | |
| 1078 | /* Invert the scale factors. */ |
| 1079 | |
| 1080 | i__1 = *n; |
| 1081 | for (j = 1; j <= i__1; ++j) { |
| 1082 | /* Computing MIN */ |
| 1083 | /* Computing MAX */ |
| 1084 | d__2 = c__[j]; |
| 1085 | d__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__2,smlnum); |
| 1086 | c__[j] = 1. / stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(d__1,bignum); |
| 1087 | /* L120: */ |
| 1088 | } |
| 1089 | |
| 1090 | /* Compute COLCND = min(C(J)) / max(C(J)) */ |
| 1091 | |
| 1092 | *colcnd = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(rcmin,smlnum) / stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(rcmax,bignum); |
| 1093 | } |
| 1094 | |
| 1095 | return 0; |
| 1096 | |
| 1097 | /* End of DGBEQU */ |
| 1098 | |
| 1099 | } /* dgbequ_ */ |
| 1100 | |
| 1101 | /* Subroutine */ int dgbequb_cxx . . $ dgbequb_(232ca6a811deebd2).(integercxx . . $ integer# *m, integercxx . . $ integer# *n, integercxx . . $ integer# *kl, integercxx . . $ integer# * |
| 1102 | ku, double *ab, integercxx . . $ integer# *ldab, double *r__, double *c__, |
| 1103 | double *rowcnd, double *colcnd, double *amax, integercxx . . $ integer# * |
| 1104 | info) |
| 1105 | { |
| 1106 | /* System generated locals */ |
| 1107 | integercxx . . $ integer# ab_dim1, ab_offset, i__1, i__2, i__3, i__4; |
| 1108 | double d__1, d__2, d__3; |
| 1109 | |
| 1110 | /* Local variables */ |
| 1111 | integercxx . . $ integer# i__, j, kd; |
| 1112 | double radix, rcmin, rcmax; |
| 1113 | double bignum, logrdx, smlnum; |
| 1114 | |
| 1115 | |
| 1116 | /* -- LAPACK routine (version 3.2) -- */ |
| 1117 | /* -- Contributed by James Demmel, Deaglan Halligan, Yozo Hida and -- */ |
| 1118 | /* -- Jason Riedy of Univ. of California Berkeley. -- */ |
| 1119 | /* -- November 2008 -- */ |
| 1120 | |
| 1121 | /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ |
| 1122 | /* -- Univ. of California Berkeley and NAG Ltd. -- */ |
| 1123 | |
| 1124 | /* .. */ |
| 1125 | /* .. Scalar Arguments .. */ |
| 1126 | /* .. */ |
| 1127 | /* .. Array Arguments .. */ |
| 1128 | /* .. */ |
| 1129 | |
| 1130 | /* Purpose */ |
| 1131 | /* ======= */ |
| 1132 | |
| 1133 | /* DGBEQUB computes row and column scalings intended to equilibrate an */ |
| 1134 | /* M-by-N matrix A and reduce its condition number. R returns the row */ |
| 1135 | /* scale factors and C the column scale factors, chosen to try to make */ |
| 1136 | /* the largest element in each row and column of the matrix B with */ |
| 1137 | /* elements B(i,j)=R(i)*A(i,j)*C(j) have an absolute value of at most */ |
| 1138 | /* the radix. */ |
| 1139 | |
| 1140 | /* R(i) and C(j) are restricted to be a power of the radix between */ |
| 1141 | /* SMLNUM = smallest safe number and BIGNUM = largest safe number. Use */ |
| 1142 | /* of these scaling factors is not guaranteed to reduce the condition */ |
| 1143 | /* number of A but works well in practice. */ |
| 1144 | |
| 1145 | /* This routine differs from DGEEQU by restricting the scaling factors */ |
| 1146 | /* to a power of the radix. Baring over- and underflow, scaling by */ |
| 1147 | /* these factors introduces no additional rounding errors. However, the */ |
| 1148 | /* scaled entries' magnitured are no longer approximately 1 but lie */ |
| 1149 | /* between sqrt(radix) and 1/sqrt(radix). */ |
| 1150 | |
| 1151 | /* Arguments */ |
| 1152 | /* ========= */ |
| 1153 | |
| 1154 | /* M (input) INTEGER */ |
| 1155 | /* The number of rows of the matrix A. M >= 0. */ |
| 1156 | |
| 1157 | /* N (input) INTEGER */ |
| 1158 | /* The number of columns of the matrix A. N >= 0. */ |
| 1159 | |
| 1160 | /* KL (input) INTEGER */ |
| 1161 | /* The number of subdiagonals within the band of A. KL >= 0. */ |
| 1162 | |
| 1163 | /* KU (input) INTEGER */ |
| 1164 | /* The number of superdiagonals within the band of A. KU >= 0. */ |
| 1165 | |
| 1166 | /* AB (input) DOUBLE PRECISION array, dimension (LDAB,N) */ |
| 1167 | /* On entry, the matrix A in band storage, in rows 1 to KL+KU+1. */ |
| 1168 | /* The j-th column of A is stored in the j-th column of the */ |
| 1169 | /* array AB as follows: */ |
| 1170 | /* AB(KU+1+i-j,j) = A(i,j) for max(1,j-KU)<=i<=min(N,j+kl) */ |
| 1171 | |
| 1172 | /* LDAB (input) INTEGER */ |
| 1173 | /* The leading dimension of the array A. LDAB >= max(1,M). */ |
| 1174 | |
| 1175 | /* R (output) DOUBLE PRECISION array, dimension (M) */ |
| 1176 | /* If INFO = 0 or INFO > M, R contains the row scale factors */ |
| 1177 | /* for A. */ |
| 1178 | |
| 1179 | /* C (output) DOUBLE PRECISION array, dimension (N) */ |
| 1180 | /* If INFO = 0, C contains the column scale factors for A. */ |
| 1181 | |
| 1182 | /* ROWCND (output) DOUBLE PRECISION */ |
| 1183 | /* If INFO = 0 or INFO > M, ROWCND contains the ratio of the */ |
| 1184 | /* smallest R(i) to the largest R(i). If ROWCND >= 0.1 and */ |
| 1185 | /* AMAX is neither too large nor too small, it is not worth */ |
| 1186 | /* scaling by R. */ |
| 1187 | |
| 1188 | /* COLCND (output) DOUBLE PRECISION */ |
| 1189 | /* If INFO = 0, COLCND contains the ratio of the smallest */ |
| 1190 | /* C(i) to the largest C(i). If COLCND >= 0.1, it is not */ |
| 1191 | /* worth scaling by C. */ |
| 1192 | |
| 1193 | /* AMAX (output) DOUBLE PRECISION */ |
| 1194 | /* Absolute value of largest matrix element. If AMAX is very */ |
| 1195 | /* close to overflow or very close to underflow, the matrix */ |
| 1196 | /* should be scaled. */ |
| 1197 | |
| 1198 | /* INFO (output) INTEGER */ |
| 1199 | /* = 0: successful exit */ |
| 1200 | /* < 0: if INFO = -i, the i-th argument had an illegal value */ |
| 1201 | /* > 0: if INFO = i, and i is */ |
| 1202 | /* <= M: the i-th row of A is exactly zero */ |
| 1203 | /* > M: the (i-M)-th column of A is exactly zero */ |
| 1204 | |
| 1205 | /* ===================================================================== */ |
| 1206 | |
| 1207 | /* .. Parameters .. */ |
| 1208 | /* .. */ |
| 1209 | /* .. Local Scalars .. */ |
| 1210 | /* .. */ |
| 1211 | /* .. External Functions .. */ |
| 1212 | /* .. */ |
| 1213 | /* .. External Subroutines .. */ |
| 1214 | /* .. */ |
| 1215 | /* .. Intrinsic Functions .. */ |
| 1216 | /* .. */ |
| 1217 | /* .. Executable Statements .. */ |
| 1218 | |
| 1219 | /* Test the input parameters. */ |
| 1220 | |
| 1221 | /* Parameter adjustments */ |
| 1222 | ab_dim1 = *ldab; |
| 1223 | ab_offset = 1 + ab_dim1; |
| 1224 | ab -= ab_offset; |
| 1225 | --r__; |
| 1226 | --c__; |
| 1227 | |
| 1228 | /* Function Body */ |
| 1229 | *info = 0; |
| 1230 | if (*m < 0) { |
| 1231 | *info = -1; |
| 1232 | } else if (*n < 0) { |
| 1233 | *info = -2; |
| 1234 | } else if (*kl < 0) { |
| 1235 | *info = -3; |
| 1236 | } else if (*ku < 0) { |
| 1237 | *info = -4; |
| 1238 | } else if (*ldab < *kl + *ku + 1) { |
| 1239 | *info = -6; |
| 1240 | } |
| 1241 | if (*info != 0) { |
| 1242 | i__1 = -(*info); |
| 1243 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGBEQUB", &i__1); |
| 1244 | return 0; |
| 1245 | } |
| 1246 | |
| 1247 | /* Quick return if possible. */ |
| 1248 | |
| 1249 | if (*m == 0 || *n == 0) { |
| 1250 | *rowcnd = 1.; |
| 1251 | *colcnd = 1.; |
| 1252 | *amax = 0.; |
| 1253 | return 0; |
| 1254 | } |
| 1255 | |
| 1256 | /* Get machine constants. Assume SMLNUM is a power of the radix. */ |
| 1257 | |
| 1258 | smlnum = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("S"); |
| 1259 | bignum = 1. / smlnum; |
| 1260 | radix = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("B"); |
| 1261 | logrdx = logcxx . . $ log(fee4f1d22bc8e617).(radix); |
| 1262 | |
| 1263 | /* Compute row scale factors. */ |
| 1264 | |
| 1265 | i__1 = *m; |
| 1266 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 1267 | r__[i__] = 0.; |
| 1268 | /* L10: */ |
| 1269 | } |
| 1270 | |
| 1271 | /* Find the maximum element in each row. */ |
| 1272 | |
| 1273 | kd = *ku + 1; |
| 1274 | i__1 = *n; |
| 1275 | for (j = 1; j <= i__1; ++j) { |
| 1276 | /* Computing MAX */ |
| 1277 | i__2 = j - *ku; |
| 1278 | /* Computing MIN */ |
| 1279 | i__4 = j + *kl; |
| 1280 | i__3 = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__4,*m); |
| 1281 | for (i__ = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,1_integercxx . . $ `operator""_integer`(85240eb457c3721a).); i__ <= i__3; ++i__) { |
| 1282 | /* Computing MAX */ |
| 1283 | d__2 = r__[i__], d__3 = (d__1 = ab[kd + i__ - j + j * ab_dim1], |
| 1284 | abscxx . . $ abs(447c67c6676f75c3).(d__1)); |
| 1285 | r__[i__] = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__2,d__3); |
| 1286 | /* L20: */ |
| 1287 | } |
| 1288 | /* L30: */ |
| 1289 | } |
| 1290 | i__1 = *m; |
| 1291 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 1292 | if (r__[i__] > 0.) { |
| 1293 | i__3 = (integercxx . . $ integer#) (logcxx . . $ log(fee4f1d22bc8e617).(r__[i__]) / logrdx); |
| 1294 | r__[i__] = pow_dicxx . . $ pow_di(d073b4717a6ff874).(&radix, &i__3); |
| 1295 | } |
| 1296 | } |
| 1297 | |
| 1298 | /* Find the maximum and minimum scale factors. */ |
| 1299 | |
| 1300 | rcmin = bignum; |
| 1301 | rcmax = 0.; |
| 1302 | i__1 = *m; |
| 1303 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 1304 | /* Computing MAX */ |
| 1305 | d__1 = rcmax, d__2 = r__[i__]; |
| 1306 | rcmax = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__1,d__2); |
| 1307 | /* Computing MIN */ |
| 1308 | d__1 = rcmin, d__2 = r__[i__]; |
| 1309 | rcmin = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(d__1,d__2); |
| 1310 | /* L40: */ |
| 1311 | } |
| 1312 | *amax = rcmax; |
| 1313 | |
| 1314 | if (rcmin == 0.) { |
| 1315 | |
| 1316 | /* Find the first zero scale factor and return an error code. */ |
| 1317 | |
| 1318 | i__1 = *m; |
| 1319 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 1320 | if (r__[i__] == 0.) { |
| 1321 | *info = i__; |
| 1322 | return 0; |
| 1323 | } |
| 1324 | /* L50: */ |
| 1325 | } |
| 1326 | } else { |
| 1327 | |
| 1328 | /* Invert the scale factors. */ |
| 1329 | |
| 1330 | i__1 = *m; |
| 1331 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 1332 | /* Computing MIN */ |
| 1333 | /* Computing MAX */ |
| 1334 | d__2 = r__[i__]; |
| 1335 | d__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__2,smlnum); |
| 1336 | r__[i__] = 1. / stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(d__1,bignum); |
| 1337 | /* L60: */ |
| 1338 | } |
| 1339 | |
| 1340 | /* Compute ROWCND = min(R(I)) / max(R(I)). */ |
| 1341 | |
| 1342 | *rowcnd = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(rcmin,smlnum) / stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(rcmax,bignum); |
| 1343 | } |
| 1344 | |
| 1345 | /* Compute column scale factors. */ |
| 1346 | |
| 1347 | i__1 = *n; |
| 1348 | for (j = 1; j <= i__1; ++j) { |
| 1349 | c__[j] = 0.; |
| 1350 | /* L70: */ |
| 1351 | } |
| 1352 | |
| 1353 | /* Find the maximum element in each column, */ |
| 1354 | /* assuming the row scaling computed above. */ |
| 1355 | |
| 1356 | i__1 = *n; |
| 1357 | for (j = 1; j <= i__1; ++j) { |
| 1358 | /* Computing MAX */ |
| 1359 | i__3 = j - *ku; |
| 1360 | /* Computing MIN */ |
| 1361 | i__4 = j + *kl; |
| 1362 | i__2 = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__4,*m); |
| 1363 | for (i__ = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__3,1_integercxx . . $ `operator""_integer`(85240eb457c3721a).); i__ <= i__2; ++i__) { |
| 1364 | /* Computing MAX */ |
| 1365 | d__2 = c__[j], d__3 = (d__1 = ab[kd + i__ - j + j * ab_dim1], abscxx . . $ abs(447c67c6676f75c3).( |
| 1366 | d__1)) * r__[i__]; |
| 1367 | c__[j] = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__2,d__3); |
| 1368 | /* L80: */ |
| 1369 | } |
| 1370 | if (c__[j] > 0.) { |
| 1371 | i__2 = (integercxx . . $ integer#) (logcxx . . $ log(fee4f1d22bc8e617).(c__[j]) / logrdx); |
| 1372 | c__[j] = pow_dicxx . . $ pow_di(d073b4717a6ff874).(&radix, &i__2); |
| 1373 | } |
| 1374 | /* L90: */ |
| 1375 | } |
| 1376 | |
| 1377 | /* Find the maximum and minimum scale factors. */ |
| 1378 | |
| 1379 | rcmin = bignum; |
| 1380 | rcmax = 0.; |
| 1381 | i__1 = *n; |
| 1382 | for (j = 1; j <= i__1; ++j) { |
| 1383 | /* Computing MIN */ |
| 1384 | d__1 = rcmin, d__2 = c__[j]; |
| 1385 | rcmin = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(d__1,d__2); |
| 1386 | /* Computing MAX */ |
| 1387 | d__1 = rcmax, d__2 = c__[j]; |
| 1388 | rcmax = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__1,d__2); |
| 1389 | /* L100: */ |
| 1390 | } |
| 1391 | |
| 1392 | if (rcmin == 0.) { |
| 1393 | |
| 1394 | /* Find the first zero scale factor and return an error code. */ |
| 1395 | |
| 1396 | i__1 = *n; |
| 1397 | for (j = 1; j <= i__1; ++j) { |
| 1398 | if (c__[j] == 0.) { |
| 1399 | *info = *m + j; |
| 1400 | return 0; |
| 1401 | } |
| 1402 | /* L110: */ |
| 1403 | } |
| 1404 | } else { |
| 1405 | |
| 1406 | /* Invert the scale factors. */ |
| 1407 | |
| 1408 | i__1 = *n; |
| 1409 | for (j = 1; j <= i__1; ++j) { |
| 1410 | /* Computing MIN */ |
| 1411 | /* Computing MAX */ |
| 1412 | d__2 = c__[j]; |
| 1413 | d__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__2,smlnum); |
| 1414 | c__[j] = 1. / stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(d__1,bignum); |
| 1415 | /* L120: */ |
| 1416 | } |
| 1417 | |
| 1418 | /* Compute COLCND = min(C(J)) / max(C(J)). */ |
| 1419 | |
| 1420 | *colcnd = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(rcmin,smlnum) / stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(rcmax,bignum); |
| 1421 | } |
| 1422 | |
| 1423 | return 0; |
| 1424 | |
| 1425 | /* End of DGBEQUB */ |
| 1426 | |
| 1427 | } /* dgbequb_ */ |
| 1428 | |
| 1429 | /* Subroutine */ int dgbrfs_cxx . . $ dgbrfs_(503411a4dcd7fef6).(const char *trans, integercxx . . $ integer# *n, integercxx . . $ integer# *kl, integercxx . . $ integer# * |
| 1430 | ku, integercxx . . $ integer# *nrhs, double *ab, integercxx . . $ integer# *ldab, double *afb, |
| 1431 | integercxx . . $ integer# *ldafb, integercxx . . $ integer# *ipiv, double *b, integercxx . . $ integer# *ldb, |
| 1432 | double *x, integercxx . . $ integer# *ldx, double *ferr, double *berr, |
| 1433 | double *work, integercxx . . $ integer# *iwork, integercxx . . $ integer# *info) |
| 1434 | { |
| 1435 | /* Table of constant values */ |
| 1436 | static integercxx . . $ integer# c__1 = 1; |
| 1437 | static double c_b15 = -1.; |
| 1438 | static double c_b17 = 1.; |
| 1439 | |
| 1440 | /* System generated locals */ |
| 1441 | integercxx . . $ integer# ab_dim1, ab_offset, afb_dim1, afb_offset, b_dim1, b_offset, |
| 1442 | x_dim1, x_offset, i__1, i__2, i__3, i__4, i__5, i__6, i__7; |
| 1443 | double d__1, d__2, d__3; |
| 1444 | |
| 1445 | /* Local variables */ |
| 1446 | integercxx . . $ integer# i__, j, k; |
| 1447 | double s; |
| 1448 | integercxx . . $ integer# kk; |
| 1449 | double xk; |
| 1450 | integercxx . . $ integer# nz; |
| 1451 | double eps; |
| 1452 | integercxx . . $ integer# kase; |
| 1453 | double safe1, safe2; |
| 1454 | integercxx . . $ integer# isave[3]; |
| 1455 | integercxx . . $ integer# count; |
| 1456 | double safmin; |
| 1457 | bool notran; |
| 1458 | char transt[1]; |
| 1459 | double lstres; |
| 1460 | |
| 1461 | |
| 1462 | /* -- LAPACK routine (version 3.1) -- */ |
| 1463 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 1464 | /* November 2006 */ |
| 1465 | |
| 1466 | /* Modified to call DLACN2 in place of DLACON, 5 Feb 03, SJH. */ |
| 1467 | |
| 1468 | /* .. Scalar Arguments .. */ |
| 1469 | /* .. */ |
| 1470 | /* .. Array Arguments .. */ |
| 1471 | /* .. */ |
| 1472 | |
| 1473 | /* Purpose */ |
| 1474 | /* ======= */ |
| 1475 | |
| 1476 | /* DGBRFS improves the computed solution to a system of linear */ |
| 1477 | /* equations when the coefficient matrix is banded, and provides */ |
| 1478 | /* error bounds and backward error estimates for the solution. */ |
| 1479 | |
| 1480 | /* Arguments */ |
| 1481 | /* ========= */ |
| 1482 | |
| 1483 | /* TRANS (input) CHARACTER*1 */ |
| 1484 | /* Specifies the form of the system of equations: */ |
| 1485 | /* = 'N': A * X = B (No transpose) */ |
| 1486 | /* = 'T': A**T * X = B (Transpose) */ |
| 1487 | /* = 'C': A**H * X = B (Conjugate transpose = Transpose) */ |
| 1488 | |
| 1489 | /* N (input) INTEGER */ |
| 1490 | /* The order of the matrix A. N >= 0. */ |
| 1491 | |
| 1492 | /* KL (input) INTEGER */ |
| 1493 | /* The number of subdiagonals within the band of A. KL >= 0. */ |
| 1494 | |
| 1495 | /* KU (input) INTEGER */ |
| 1496 | /* The number of superdiagonals within the band of A. KU >= 0. */ |
| 1497 | |
| 1498 | /* NRHS (input) INTEGER */ |
| 1499 | /* The number of right hand sides, i.e., the number of columns */ |
| 1500 | /* of the matrices B and X. NRHS >= 0. */ |
| 1501 | |
| 1502 | /* AB (input) DOUBLE PRECISION array, dimension (LDAB,N) */ |
| 1503 | /* The original band matrix A, stored in rows 1 to KL+KU+1. */ |
| 1504 | /* The j-th column of A is stored in the j-th column of the */ |
| 1505 | /* array AB as follows: */ |
| 1506 | /* AB(ku+1+i-j,j) = A(i,j) for max(1,j-ku)<=i<=min(n,j+kl). */ |
| 1507 | |
| 1508 | /* LDAB (input) INTEGER */ |
| 1509 | /* The leading dimension of the array AB. LDAB >= KL+KU+1. */ |
| 1510 | |
| 1511 | /* AFB (input) DOUBLE PRECISION array, dimension (LDAFB,N) */ |
| 1512 | /* Details of the LU factorization of the band matrix A, as */ |
| 1513 | /* computed by DGBTRF. U is stored as an upper triangular band */ |
| 1514 | /* matrix with KL+KU superdiagonals in rows 1 to KL+KU+1, and */ |
| 1515 | /* the multipliers used during the factorization are stored in */ |
| 1516 | /* rows KL+KU+2 to 2*KL+KU+1. */ |
| 1517 | |
| 1518 | /* LDAFB (input) INTEGER */ |
| 1519 | /* The leading dimension of the array AFB. LDAFB >= 2*KL*KU+1. */ |
| 1520 | |
| 1521 | /* IPIV (input) INTEGER array, dimension (N) */ |
| 1522 | /* The pivot indices from DGBTRF; for 1<=i<=N, row i of the */ |
| 1523 | /* matrix was interchanged with row IPIV(i). */ |
| 1524 | |
| 1525 | /* B (input) DOUBLE PRECISION array, dimension (LDB,NRHS) */ |
| 1526 | /* The right hand side matrix B. */ |
| 1527 | |
| 1528 | /* LDB (input) INTEGER */ |
| 1529 | /* The leading dimension of the array B. LDB >= max(1,N). */ |
| 1530 | |
| 1531 | /* X (input/output) DOUBLE PRECISION array, dimension (LDX,NRHS) */ |
| 1532 | /* On entry, the solution matrix X, as computed by DGBTRS. */ |
| 1533 | /* On exit, the improved solution matrix X. */ |
| 1534 | |
| 1535 | /* LDX (input) INTEGER */ |
| 1536 | /* The leading dimension of the array X. LDX >= max(1,N). */ |
| 1537 | |
| 1538 | /* FERR (output) DOUBLE PRECISION array, dimension (NRHS) */ |
| 1539 | /* The estimated forward error bound for each solution vector */ |
| 1540 | /* X(j) (the j-th column of the solution matrix X). */ |
| 1541 | /* If XTRUE is the true solution corresponding to X(j), FERR(j) */ |
| 1542 | /* is an estimated upper bound for the magnitude of the largest */ |
| 1543 | /* element in (X(j) - XTRUE) divided by the magnitude of the */ |
| 1544 | /* largest element in X(j). The estimate is as reliable as */ |
| 1545 | /* the estimate for RCOND, and is almost always a slight */ |
| 1546 | /* overestimate of the true error. */ |
| 1547 | |
| 1548 | /* BERR (output) DOUBLE PRECISION array, dimension (NRHS) */ |
| 1549 | /* The componentwise relative backward error of each solution */ |
| 1550 | /* vector X(j) (i.e., the smallest relative change in */ |
| 1551 | /* any element of A or B that makes X(j) an exact solution). */ |
| 1552 | |
| 1553 | /* WORK (workspace) DOUBLE PRECISION array, dimension (3*N) */ |
| 1554 | |
| 1555 | /* IWORK (workspace) INTEGER array, dimension (N) */ |
| 1556 | |
| 1557 | /* INFO (output) INTEGER */ |
| 1558 | /* = 0: successful exit */ |
| 1559 | /* < 0: if INFO = -i, the i-th argument had an illegal value */ |
| 1560 | |
| 1561 | /* Internal Parameters */ |
| 1562 | /* =================== */ |
| 1563 | |
| 1564 | /* ITMAX is the maximum number of steps of iterative refinement. */ |
| 1565 | |
| 1566 | /* ===================================================================== */ |
| 1567 | |
| 1568 | /* .. Parameters .. */ |
| 1569 | /* .. */ |
| 1570 | /* .. Local Scalars .. */ |
| 1571 | /* .. */ |
| 1572 | /* .. Local Arrays .. */ |
| 1573 | /* .. */ |
| 1574 | /* .. External Subroutines .. */ |
| 1575 | /* .. */ |
| 1576 | /* .. Intrinsic Functions .. */ |
| 1577 | /* .. */ |
| 1578 | /* .. External Functions .. */ |
| 1579 | /* .. */ |
| 1580 | /* .. Executable Statements .. */ |
| 1581 | |
| 1582 | /* Test the input parameters. */ |
| 1583 | |
| 1584 | /* Parameter adjustments */ |
| 1585 | ab_dim1 = *ldab; |
| 1586 | ab_offset = 1 + ab_dim1; |
| 1587 | ab -= ab_offset; |
| 1588 | afb_dim1 = *ldafb; |
| 1589 | afb_offset = 1 + afb_dim1; |
| 1590 | afb -= afb_offset; |
| 1591 | --ipiv; |
| 1592 | b_dim1 = *ldb; |
| 1593 | b_offset = 1 + b_dim1; |
| 1594 | b -= b_offset; |
| 1595 | x_dim1 = *ldx; |
| 1596 | x_offset = 1 + x_dim1; |
| 1597 | x -= x_offset; |
| 1598 | --ferr; |
| 1599 | --berr; |
| 1600 | --work; |
| 1601 | --iwork; |
| 1602 | |
| 1603 | /* Function Body */ |
| 1604 | *info = 0; |
| 1605 | notran = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(trans, "N"); |
| 1606 | if (! notran && ! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(trans, "T") && ! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).( |
| 1607 | trans, "C")) { |
| 1608 | *info = -1; |
| 1609 | } else if (*n < 0) { |
| 1610 | *info = -2; |
| 1611 | } else if (*kl < 0) { |
| 1612 | *info = -3; |
| 1613 | } else if (*ku < 0) { |
| 1614 | *info = -4; |
| 1615 | } else if (*nrhs < 0) { |
| 1616 | *info = -5; |
| 1617 | } else if (*ldab < *kl + *ku + 1) { |
| 1618 | *info = -7; |
| 1619 | } else if (*ldafb < (*kl << 1) + *ku + 1) { |
| 1620 | *info = -9; |
| 1621 | } else if (*ldb < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 1622 | *info = -12; |
| 1623 | } else if (*ldx < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 1624 | *info = -14; |
| 1625 | } |
| 1626 | if (*info != 0) { |
| 1627 | i__1 = -(*info); |
| 1628 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGBRFS", &i__1); |
| 1629 | return 0; |
| 1630 | } |
| 1631 | |
| 1632 | /* Quick return if possible */ |
| 1633 | |
| 1634 | if (*n == 0 || *nrhs == 0) { |
| 1635 | i__1 = *nrhs; |
| 1636 | for (j = 1; j <= i__1; ++j) { |
| 1637 | ferr[j] = 0.; |
| 1638 | berr[j] = 0.; |
| 1639 | /* L10: */ |
| 1640 | } |
| 1641 | return 0; |
| 1642 | } |
| 1643 | |
| 1644 | if (notran) { |
| 1645 | *(unsigned char *)transt = 'T'; |
| 1646 | } else { |
| 1647 | *(unsigned char *)transt = 'N'; |
| 1648 | } |
| 1649 | |
| 1650 | /* NZ = maximum number of nonzero elements in each row of A, plus 1 */ |
| 1651 | |
| 1652 | /* Computing MIN */ |
| 1653 | i__1 = *kl + *ku + 2, i__2 = *n + 1; |
| 1654 | nz = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__1,i__2); |
| 1655 | eps = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("Epsilon"); |
| 1656 | safmin = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("Safe minimum"); |
| 1657 | safe1 = nz * safmin; |
| 1658 | safe2 = safe1 / eps; |
| 1659 | |
| 1660 | /* Do for each right hand side */ |
| 1661 | |
| 1662 | i__1 = *nrhs; |
| 1663 | for (j = 1; j <= i__1; ++j) { |
| 1664 | |
| 1665 | count = 1; |
| 1666 | lstres = 3.; |
| 1667 | L20: |
| 1668 | |
| 1669 | /* Loop until stopping criterion is satisfied. */ |
| 1670 | |
| 1671 | /* Compute residual R = B - op(A) * X, */ |
| 1672 | /* where op(A) = A, A**T, or A**H, depending on TRANS. */ |
| 1673 | |
| 1674 | dcopy_cxx . . $ dcopy_(ec261fd7ec3b6bf6).(n, &b[j * b_dim1 + 1], &c__1, &work[*n + 1], &c__1); |
| 1675 | dgbmv_cxx . . $ dgbmv_(a3250cf8523ef76).(trans, n, n, kl, ku, &c_b15, &ab[ab_offset], ldab, &x[j * |
| 1676 | x_dim1 + 1], &c__1, &c_b17, &work[*n + 1], &c__1); |
| 1677 | |
| 1678 | /* Compute componentwise relative backward error from formula */ |
| 1679 | |
| 1680 | /* max(i) ( abs(R(i)) / ( abs(op(A))*abs(X) + abs(B) )(i) ) */ |
| 1681 | |
| 1682 | /* where abs(Z) is the componentwise absolute value of the matrix */ |
| 1683 | /* or vector Z. If the i-th component of the denominator is less */ |
| 1684 | /* than SAFE2, then SAFE1 is added to the i-th components of the */ |
| 1685 | /* numerator and denominator before dividing. */ |
| 1686 | |
| 1687 | i__2 = *n; |
| 1688 | for (i__ = 1; i__ <= i__2; ++i__) { |
| 1689 | work[i__] = (d__1 = b[i__ + j * b_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__1)); |
| 1690 | /* L30: */ |
| 1691 | } |
| 1692 | |
| 1693 | /* Compute abs(op(A))*abs(X) + abs(B). */ |
| 1694 | |
| 1695 | if (notran) { |
| 1696 | i__2 = *n; |
| 1697 | for (k = 1; k <= i__2; ++k) { |
| 1698 | kk = *ku + 1 - k; |
| 1699 | xk = (d__1 = x[k + j * x_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__1)); |
| 1700 | /* Computing MAX */ |
| 1701 | i__3 = 1, i__4 = k - *ku; |
| 1702 | /* Computing MIN */ |
| 1703 | i__6 = *n, i__7 = k + *kl; |
| 1704 | i__5 = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__6,i__7); |
| 1705 | for (i__ = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__3,i__4); i__ <= i__5; ++i__) { |
| 1706 | work[i__] += (d__1 = ab[kk + i__ + k * ab_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__1) |
| 1707 | ) * xk; |
| 1708 | /* L40: */ |
| 1709 | } |
| 1710 | /* L50: */ |
| 1711 | } |
| 1712 | } else { |
| 1713 | i__2 = *n; |
| 1714 | for (k = 1; k <= i__2; ++k) { |
| 1715 | s = 0.; |
| 1716 | kk = *ku + 1 - k; |
| 1717 | /* Computing MAX */ |
| 1718 | i__5 = 1, i__3 = k - *ku; |
| 1719 | /* Computing MIN */ |
| 1720 | i__6 = *n, i__7 = k + *kl; |
| 1721 | i__4 = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__6,i__7); |
| 1722 | for (i__ = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__5,i__3); i__ <= i__4; ++i__) { |
| 1723 | s += (d__1 = ab[kk + i__ + k * ab_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__1)) * ( |
| 1724 | d__2 = x[i__ + j * x_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__2)); |
| 1725 | /* L60: */ |
| 1726 | } |
| 1727 | work[k] += s; |
| 1728 | /* L70: */ |
| 1729 | } |
| 1730 | } |
| 1731 | s = 0.; |
| 1732 | i__2 = *n; |
| 1733 | for (i__ = 1; i__ <= i__2; ++i__) { |
| 1734 | if (work[i__] > safe2) { |
| 1735 | /* Computing MAX */ |
| 1736 | d__2 = s, d__3 = (d__1 = work[*n + i__], abscxx . . $ abs(447c67c6676f75c3).(d__1)) / work[ |
| 1737 | i__]; |
| 1738 | s = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__2,d__3); |
| 1739 | } else { |
| 1740 | /* Computing MAX */ |
| 1741 | d__2 = s, d__3 = ((d__1 = work[*n + i__], abscxx . . $ abs(447c67c6676f75c3).(d__1)) + safe1) |
| 1742 | / (work[i__] + safe1); |
| 1743 | s = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__2,d__3); |
| 1744 | } |
| 1745 | /* L80: */ |
| 1746 | } |
| 1747 | berr[j] = s; |
| 1748 | |
| 1749 | /* Test stopping criterion. Continue iterating if */ |
| 1750 | /* 1) The residual BERR(J) is larger than machine epsilon, and */ |
| 1751 | /* 2) BERR(J) decreased by at least a factor of 2 during the */ |
| 1752 | /* last iteration, and */ |
| 1753 | /* 3) At most ITMAX iterations tried. */ |
| 1754 | |
| 1755 | if (berr[j] > eps && berr[j] * 2. <= lstres && count <= 5) { |
| 1756 | |
| 1757 | /* Update solution and try again. */ |
| 1758 | |
| 1759 | dgbtrs_cxx . . $ dgbtrs_(50a94af1eb812d7f).(trans, n, kl, ku, &c__1, &afb[afb_offset], ldafb, &ipiv[1] |
| 1760 | , &work[*n + 1], n, info); |
| 1761 | daxpy_cxx . . $ daxpy_(4b39f621356f7e14).(n, &c_b17, &work[*n + 1], &c__1, &x[j * x_dim1 + 1], &c__1) |
| 1762 | ; |
| 1763 | lstres = berr[j]; |
| 1764 | ++count; |
| 1765 | goto L20; |
| 1766 | } |
| 1767 | |
| 1768 | /* Bound error from formula */ |
| 1769 | |
| 1770 | /* norm(X - XTRUE) / norm(X) .le. FERR = */ |
| 1771 | /* norm( abs(inv(op(A)))* */ |
| 1772 | /* ( abs(R) + NZ*EPS*( abs(op(A))*abs(X)+abs(B) ))) / norm(X) */ |
| 1773 | |
| 1774 | /* where */ |
| 1775 | /* norm(Z) is the magnitude of the largest component of Z */ |
| 1776 | /* inv(op(A)) is the inverse of op(A) */ |
| 1777 | /* abs(Z) is the componentwise absolute value of the matrix or */ |
| 1778 | /* vector Z */ |
| 1779 | /* NZ is the maximum number of nonzeros in any row of A, plus 1 */ |
| 1780 | /* EPS is machine epsilon */ |
| 1781 | |
| 1782 | /* The i-th component of abs(R)+NZ*EPS*(abs(op(A))*abs(X)+abs(B)) */ |
| 1783 | /* is incremented by SAFE1 if the i-th component of */ |
| 1784 | /* abs(op(A))*abs(X) + abs(B) is less than SAFE2. */ |
| 1785 | |
| 1786 | /* Use DLACN2 to estimate the infinity-norm of the matrix */ |
| 1787 | /* inv(op(A)) * diag(W), */ |
| 1788 | /* where W = abs(R) + NZ*EPS*( abs(op(A))*abs(X)+abs(B) ))) */ |
| 1789 | |
| 1790 | i__2 = *n; |
| 1791 | for (i__ = 1; i__ <= i__2; ++i__) { |
| 1792 | if (work[i__] > safe2) { |
| 1793 | work[i__] = (d__1 = work[*n + i__], abscxx . . $ abs(447c67c6676f75c3).(d__1)) + nz * eps * |
| 1794 | work[i__]; |
| 1795 | } else { |
| 1796 | work[i__] = (d__1 = work[*n + i__], abscxx . . $ abs(447c67c6676f75c3).(d__1)) + nz * eps * |
| 1797 | work[i__] + safe1; |
| 1798 | } |
| 1799 | /* L90: */ |
| 1800 | } |
| 1801 | |
| 1802 | kase = 0; |
| 1803 | L100: |
| 1804 | dlacn2_cxx . . $ dlacn2_(2d9e0fe6bd3e0917).(n, &work[(*n << 1) + 1], &work[*n + 1], &iwork[1], &ferr[j], & |
| 1805 | kase, isave); |
| 1806 | if (kase != 0) { |
| 1807 | if (kase == 1) { |
| 1808 | |
| 1809 | /* Multiply by diag(W)*inv(op(A)**T). */ |
| 1810 | |
| 1811 | dgbtrs_cxx . . $ dgbtrs_(50a94af1eb812d7f).(transt, n, kl, ku, &c__1, &afb[afb_offset], ldafb, & |
| 1812 | ipiv[1], &work[*n + 1], n, info); |
| 1813 | i__2 = *n; |
| 1814 | for (i__ = 1; i__ <= i__2; ++i__) { |
| 1815 | work[*n + i__] *= work[i__]; |
| 1816 | /* L110: */ |
| 1817 | } |
| 1818 | } else { |
| 1819 | |
| 1820 | /* Multiply by inv(op(A))*diag(W). */ |
| 1821 | |
| 1822 | i__2 = *n; |
| 1823 | for (i__ = 1; i__ <= i__2; ++i__) { |
| 1824 | work[*n + i__] *= work[i__]; |
| 1825 | /* L120: */ |
| 1826 | } |
| 1827 | dgbtrs_cxx . . $ dgbtrs_(50a94af1eb812d7f).(trans, n, kl, ku, &c__1, &afb[afb_offset], ldafb, & |
| 1828 | ipiv[1], &work[*n + 1], n, info); |
| 1829 | } |
| 1830 | goto L100; |
| 1831 | } |
| 1832 | |
| 1833 | /* Normalize error. */ |
| 1834 | |
| 1835 | lstres = 0.; |
| 1836 | i__2 = *n; |
| 1837 | for (i__ = 1; i__ <= i__2; ++i__) { |
| 1838 | /* Computing MAX */ |
| 1839 | d__2 = lstres, d__3 = (d__1 = x[i__ + j * x_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__1)); |
| 1840 | lstres = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__2,d__3); |
| 1841 | /* L130: */ |
| 1842 | } |
| 1843 | if (lstres != 0.) { |
| 1844 | ferr[j] /= lstres; |
| 1845 | } |
| 1846 | |
| 1847 | /* L140: */ |
| 1848 | } |
| 1849 | |
| 1850 | return 0; |
| 1851 | |
| 1852 | /* End of DGBRFS */ |
| 1853 | |
| 1854 | } /* dgbrfs_ */ |
| 1855 | |
| 1856 | #if 0 |
| 1857 | /* Subroutine */ int dgbrfsx_(const char *trans, const char *equed, integer *n, integer * |
| 1858 | kl, integer *ku, integer *nrhs, double *ab, integer *ldab, |
| 1859 | double *afb, integer *ldafb, integer *ipiv, double *r__, |
| 1860 | double *c__, double *b, integer *ldb, double *x, integer * |
| 1861 | ldx, double *rcond, double *berr, integer *n_err_bnds__, |
| 1862 | double *err_bnds_norm__, double *err_bnds_comp__, integer * |
| 1863 | nparams, double *params, double *work, integer *iwork, integer *info) |
| 1864 | { |
| 1865 | /* Table of constant values */ |
| 1866 | static integer c_n1 = -1; |
| 1867 | static integer c__0 = 0; |
| 1868 | static integer c__1 = 1; |
| 1869 | |
| 1870 | /* System generated locals */ |
| 1871 | integer ab_dim1, ab_offset, afb_dim1, afb_offset, b_dim1, b_offset, |
| 1872 | x_dim1, x_offset, err_bnds_norm_dim1, err_bnds_norm_offset, |
| 1873 | err_bnds_comp_dim1, err_bnds_comp_offset, i__1; |
| 1874 | double d__1, d__2; |
| 1875 | |
| 1876 | /* Local variables */ |
| 1877 | double illrcond_thresh__, unstable_thresh__, err_lbnd__; |
| 1878 | integer ref_type__; |
| 1879 | integer j; |
| 1880 | double rcond_tmp__; |
| 1881 | integer prec_type__, trans_type__; |
| 1882 | double cwise_wrong__; |
| 1883 | char norm[1]; |
| 1884 | bool ignore_cwise__; |
| 1885 | double anorm; |
| 1886 | bool colequ, notran, rowequ; |
| 1887 | integer ithresh, n_norms__; |
| 1888 | double rthresh; |
| 1889 | |
| 1890 | |
| 1891 | /* -- LAPACK routine (version 3.2.1) -- */ |
| 1892 | /* -- Contributed by James Demmel, Deaglan Halligan, Yozo Hida and -- */ |
| 1893 | /* -- Jason Riedy of Univ. of California Berkeley. -- */ |
| 1894 | /* -- April 2009 -- */ |
| 1895 | |
| 1896 | /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ |
| 1897 | /* -- Univ. of California Berkeley and NAG Ltd. -- */ |
| 1898 | |
| 1899 | /* .. */ |
| 1900 | /* .. Scalar Arguments .. */ |
| 1901 | /* .. */ |
| 1902 | /* .. Array Arguments .. */ |
| 1903 | /* .. */ |
| 1904 | |
| 1905 | /* Purpose */ |
| 1906 | /* ======= */ |
| 1907 | |
| 1908 | /* DGBRFSX improves the computed solution to a system of linear */ |
| 1909 | /* equations and provides error bounds and backward error estimates */ |
| 1910 | /* for the solution. In addition to normwise error bound, the code */ |
| 1911 | /* provides maximum componentwise error bound if possible. See */ |
| 1912 | /* comments for ERR_BNDS_NORM and ERR_BNDS_COMP for details of the */ |
| 1913 | /* error bounds. */ |
| 1914 | |
| 1915 | /* The original system of linear equations may have been equilibrated */ |
| 1916 | /* before calling this routine, as described by arguments EQUED, R */ |
| 1917 | /* and C below. In this case, the solution and error bounds returned */ |
| 1918 | /* are for the original unequilibrated system. */ |
| 1919 | |
| 1920 | /* Arguments */ |
| 1921 | /* ========= */ |
| 1922 | |
| 1923 | /* Some optional parameters are bundled in the PARAMS array. These */ |
| 1924 | /* settings determine how refinement is performed, but often the */ |
| 1925 | /* defaults are acceptable. If the defaults are acceptable, users */ |
| 1926 | /* can pass NPARAMS = 0 which prevents the source code from accessing */ |
| 1927 | /* the PARAMS argument. */ |
| 1928 | |
| 1929 | /* TRANS (input) CHARACTER*1 */ |
| 1930 | /* Specifies the form of the system of equations: */ |
| 1931 | /* = 'N': A * X = B (No transpose) */ |
| 1932 | /* = 'T': A**T * X = B (Transpose) */ |
| 1933 | /* = 'C': A**H * X = B (Conjugate transpose = Transpose) */ |
| 1934 | |
| 1935 | /* EQUED (input) CHARACTER*1 */ |
| 1936 | /* Specifies the form of equilibration that was done to A */ |
| 1937 | /* before calling this routine. This is needed to compute */ |
| 1938 | /* the solution and error bounds correctly. */ |
| 1939 | /* = 'N': No equilibration */ |
| 1940 | /* = 'R': Row equilibration, i.e., A has been premultiplied by */ |
| 1941 | /* diag(R). */ |
| 1942 | /* = 'C': Column equilibration, i.e., A has been postmultiplied */ |
| 1943 | /* by diag(C). */ |
| 1944 | /* = 'B': Both row and column equilibration, i.e., A has been */ |
| 1945 | /* replaced by diag(R) * A * diag(C). */ |
| 1946 | /* The right hand side B has been changed accordingly. */ |
| 1947 | |
| 1948 | /* N (input) INTEGER */ |
| 1949 | /* The order of the matrix A. N >= 0. */ |
| 1950 | |
| 1951 | /* KL (input) INTEGER */ |
| 1952 | /* The number of subdiagonals within the band of A. KL >= 0. */ |
| 1953 | |
| 1954 | /* KU (input) INTEGER */ |
| 1955 | /* The number of superdiagonals within the band of A. KU >= 0. */ |
| 1956 | |
| 1957 | /* NRHS (input) INTEGER */ |
| 1958 | /* The number of right hand sides, i.e., the number of columns */ |
| 1959 | /* of the matrices B and X. NRHS >= 0. */ |
| 1960 | |
| 1961 | /* AB (input) DOUBLE PRECISION array, dimension (LDAB,N) */ |
| 1962 | /* The original band matrix A, stored in rows 1 to KL+KU+1. */ |
| 1963 | /* The j-th column of A is stored in the j-th column of the */ |
| 1964 | /* array AB as follows: */ |
| 1965 | /* AB(ku+1+i-j,j) = A(i,j) for max(1,j-ku)<=i<=min(n,j+kl). */ |
| 1966 | |
| 1967 | /* LDAB (input) INTEGER */ |
| 1968 | /* The leading dimension of the array AB. LDAB >= KL+KU+1. */ |
| 1969 | |
| 1970 | /* AFB (input) DOUBLE PRECISION array, dimension (LDAFB,N) */ |
| 1971 | /* Details of the LU factorization of the band matrix A, as */ |
| 1972 | /* computed by DGBTRF. U is stored as an upper triangular band */ |
| 1973 | /* matrix with KL+KU superdiagonals in rows 1 to KL+KU+1, and */ |
| 1974 | /* the multipliers used during the factorization are stored in */ |
| 1975 | /* rows KL+KU+2 to 2*KL+KU+1. */ |
| 1976 | |
| 1977 | /* LDAFB (input) INTEGER */ |
| 1978 | /* The leading dimension of the array AFB. LDAFB >= 2*KL*KU+1. */ |
| 1979 | |
| 1980 | /* IPIV (input) INTEGER array, dimension (N) */ |
| 1981 | /* The pivot indices from DGETRF; for 1<=i<=N, row i of the */ |
| 1982 | /* matrix was interchanged with row IPIV(i). */ |
| 1983 | |
| 1984 | /* R (input or output) DOUBLE PRECISION array, dimension (N) */ |
| 1985 | /* The row scale factors for A. If EQUED = 'R' or 'B', A is */ |
| 1986 | /* multiplied on the left by diag(R); if EQUED = 'N' or 'C', R */ |
| 1987 | /* is not accessed. R is an input argument if FACT = 'F'; */ |
| 1988 | /* otherwise, R is an output argument. If FACT = 'F' and */ |
| 1989 | /* EQUED = 'R' or 'B', each element of R must be positive. */ |
| 1990 | /* If R is output, each element of R is a power of the radix. */ |
| 1991 | /* If R is input, each element of R should be a power of the radix */ |
| 1992 | /* to ensure a reliable solution and error estimates. Scaling by */ |
| 1993 | /* powers of the radix does not cause rounding errors unless the */ |
| 1994 | /* result underflows or overflows. Rounding errors during scaling */ |
| 1995 | /* lead to refining with a matrix that is not equivalent to the */ |
| 1996 | /* input matrix, producing error estimates that may not be */ |
| 1997 | /* reliable. */ |
| 1998 | |
| 1999 | /* C (input or output) DOUBLE PRECISION array, dimension (N) */ |
| 2000 | /* The column scale factors for A. If EQUED = 'C' or 'B', A is */ |
| 2001 | /* multiplied on the right by diag(C); if EQUED = 'N' or 'R', C */ |
| 2002 | /* is not accessed. C is an input argument if FACT = 'F'; */ |
| 2003 | /* otherwise, C is an output argument. If FACT = 'F' and */ |
| 2004 | /* EQUED = 'C' or 'B', each element of C must be positive. */ |
| 2005 | /* If C is output, each element of C is a power of the radix. */ |
| 2006 | /* If C is input, each element of C should be a power of the radix */ |
| 2007 | /* to ensure a reliable solution and error estimates. Scaling by */ |
| 2008 | /* powers of the radix does not cause rounding errors unless the */ |
| 2009 | /* result underflows or overflows. Rounding errors during scaling */ |
| 2010 | /* lead to refining with a matrix that is not equivalent to the */ |
| 2011 | /* input matrix, producing error estimates that may not be */ |
| 2012 | /* reliable. */ |
| 2013 | |
| 2014 | /* B (input) DOUBLE PRECISION array, dimension (LDB,NRHS) */ |
| 2015 | /* The right hand side matrix B. */ |
| 2016 | |
| 2017 | /* LDB (input) INTEGER */ |
| 2018 | /* The leading dimension of the array B. LDB >= max(1,N). */ |
| 2019 | |
| 2020 | /* X (input/output) DOUBLE PRECISION array, dimension (LDX,NRHS) */ |
| 2021 | /* On entry, the solution matrix X, as computed by DGETRS. */ |
| 2022 | /* On exit, the improved solution matrix X. */ |
| 2023 | |
| 2024 | /* LDX (input) INTEGER */ |
| 2025 | /* The leading dimension of the array X. LDX >= max(1,N). */ |
| 2026 | |
| 2027 | /* RCOND (output) DOUBLE PRECISION */ |
| 2028 | /* Reciprocal scaled condition number. This is an estimate of the */ |
| 2029 | /* reciprocal Skeel condition number of the matrix A after */ |
| 2030 | /* equilibration (if done). If this is less than the machine */ |
| 2031 | /* precision (in particular, if it is zero), the matrix is singular */ |
| 2032 | /* to working precision. Note that the error may still be small even */ |
| 2033 | /* if this number is very small and the matrix appears ill- */ |
| 2034 | /* conditioned. */ |
| 2035 | |
| 2036 | /* BERR (output) DOUBLE PRECISION array, dimension (NRHS) */ |
| 2037 | /* Componentwise relative backward error. This is the */ |
| 2038 | /* componentwise relative backward error of each solution vector X(j) */ |
| 2039 | /* (i.e., the smallest relative change in any element of A or B that */ |
| 2040 | /* makes X(j) an exact solution). */ |
| 2041 | |
| 2042 | /* N_ERR_BNDS (input) INTEGER */ |
| 2043 | /* Number of error bounds to return for each right hand side */ |
| 2044 | /* and each type (normwise or componentwise). See ERR_BNDS_NORM and */ |
| 2045 | /* ERR_BNDS_COMP below. */ |
| 2046 | |
| 2047 | /* ERR_BNDS_NORM (output) DOUBLE PRECISION array, dimension (NRHS, N_ERR_BNDS) */ |
| 2048 | /* For each right-hand side, this array contains information about */ |
| 2049 | /* various error bounds and condition numbers corresponding to the */ |
| 2050 | /* normwise relative error, which is defined as follows: */ |
| 2051 | |
| 2052 | /* Normwise relative error in the ith solution vector: */ |
| 2053 | /* max_j (abs(XTRUE(j,i) - X(j,i))) */ |
| 2054 | /* ------------------------------ */ |
| 2055 | /* max_j abs(X(j,i)) */ |
| 2056 | |
| 2057 | /* The array is indexed by the type of error information as described */ |
| 2058 | /* below. There currently are up to three pieces of information */ |
| 2059 | /* returned. */ |
| 2060 | |
| 2061 | /* The first index in ERR_BNDS_NORM(i,:) corresponds to the ith */ |
| 2062 | /* right-hand side. */ |
| 2063 | |
| 2064 | /* The second index in ERR_BNDS_NORM(:,err) contains the following */ |
| 2065 | /* three fields: */ |
| 2066 | /* err = 1 "Trust/don't trust" boolean. Trust the answer if the */ |
| 2067 | /* reciprocal condition number is less than the threshold */ |
| 2068 | /* sqrt(n) * dlamch('Epsilon'). */ |
| 2069 | |
| 2070 | /* err = 2 "Guaranteed" error bound: The estimated forward error, */ |
| 2071 | /* almost certainly within a factor of 10 of the true error */ |
| 2072 | /* so long as the next entry is greater than the threshold */ |
| 2073 | /* sqrt(n) * dlamch('Epsilon'). This error bound should only */ |
| 2074 | /* be trusted if the previous boolean is true. */ |
| 2075 | |
| 2076 | /* err = 3 Reciprocal condition number: Estimated normwise */ |
| 2077 | /* reciprocal condition number. Compared with the threshold */ |
| 2078 | /* sqrt(n) * dlamch('Epsilon') to determine if the error */ |
| 2079 | /* estimate is "guaranteed". These reciprocal condition */ |
| 2080 | /* numbers are 1 / (norm(Z^{-1},inf) * norm(Z,inf)) for some */ |
| 2081 | /* appropriately scaled matrix Z. */ |
| 2082 | /* Let Z = S*A, where S scales each row by a power of the */ |
| 2083 | /* radix so all absolute row sums of Z are approximately 1. */ |
| 2084 | |
| 2085 | /* See Lapack Working Note 165 for further details and extra */ |
| 2086 | /* cautions. */ |
| 2087 | |
| 2088 | /* ERR_BNDS_COMP (output) DOUBLE PRECISION array, dimension (NRHS, N_ERR_BNDS) */ |
| 2089 | /* For each right-hand side, this array contains information about */ |
| 2090 | /* various error bounds and condition numbers corresponding to the */ |
| 2091 | /* componentwise relative error, which is defined as follows: */ |
| 2092 | |
| 2093 | /* Componentwise relative error in the ith solution vector: */ |
| 2094 | /* abs(XTRUE(j,i) - X(j,i)) */ |
| 2095 | /* max_j ---------------------- */ |
| 2096 | /* abs(X(j,i)) */ |
| 2097 | |
| 2098 | /* The array is indexed by the right-hand side i (on which the */ |
| 2099 | /* componentwise relative error depends), and the type of error */ |
| 2100 | /* information as described below. There currently are up to three */ |
| 2101 | /* pieces of information returned for each right-hand side. If */ |
| 2102 | /* componentwise accuracy is not requested (PARAMS(3) = 0.0), then */ |
| 2103 | /* ERR_BNDS_COMP is not accessed. If N_ERR_BNDS .LT. 3, then at most */ |
| 2104 | /* the first (:,N_ERR_BNDS) entries are returned. */ |
| 2105 | |
| 2106 | /* The first index in ERR_BNDS_COMP(i,:) corresponds to the ith */ |
| 2107 | /* right-hand side. */ |
| 2108 | |
| 2109 | /* The second index in ERR_BNDS_COMP(:,err) contains the following */ |
| 2110 | /* three fields: */ |
| 2111 | /* err = 1 "Trust/don't trust" boolean. Trust the answer if the */ |
| 2112 | /* reciprocal condition number is less than the threshold */ |
| 2113 | /* sqrt(n) * dlamch('Epsilon'). */ |
| 2114 | |
| 2115 | /* err = 2 "Guaranteed" error bound: The estimated forward error, */ |
| 2116 | /* almost certainly within a factor of 10 of the true error */ |
| 2117 | /* so long as the next entry is greater than the threshold */ |
| 2118 | /* sqrt(n) * dlamch('Epsilon'). This error bound should only */ |
| 2119 | /* be trusted if the previous boolean is true. */ |
| 2120 | |
| 2121 | /* err = 3 Reciprocal condition number: Estimated componentwise */ |
| 2122 | /* reciprocal condition number. Compared with the threshold */ |
| 2123 | /* sqrt(n) * dlamch('Epsilon') to determine if the error */ |
| 2124 | /* estimate is "guaranteed". These reciprocal condition */ |
| 2125 | /* numbers are 1 / (norm(Z^{-1},inf) * norm(Z,inf)) for some */ |
| 2126 | /* appropriately scaled matrix Z. */ |
| 2127 | /* Let Z = S*(A*diag(x)), where x is the solution for the */ |
| 2128 | /* current right-hand side and S scales each row of */ |
| 2129 | /* A*diag(x) by a power of the radix so all absolute row */ |
| 2130 | /* sums of Z are approximately 1. */ |
| 2131 | |
| 2132 | /* See Lapack Working Note 165 for further details and extra */ |
| 2133 | /* cautions. */ |
| 2134 | |
| 2135 | /* NPARAMS (input) INTEGER */ |
| 2136 | /* Specifies the number of parameters set in PARAMS. If .LE. 0, the */ |
| 2137 | /* PARAMS array is never referenced and default values are used. */ |
| 2138 | |
| 2139 | /* PARAMS (input / output) DOUBLE PRECISION array, dimension NPARAMS */ |
| 2140 | /* Specifies algorithm parameters. If an entry is .LT. 0.0, then */ |
| 2141 | /* that entry will be filled with default value used for that */ |
| 2142 | /* parameter. Only positions up to NPARAMS are accessed; defaults */ |
| 2143 | /* are used for higher-numbered parameters. */ |
| 2144 | |
| 2145 | /* PARAMS(LA_LINRX_ITREF_I = 1) : Whether to perform iterative */ |
| 2146 | /* refinement or not. */ |
| 2147 | /* Default: 1.0D+0 */ |
| 2148 | /* = 0.0 : No refinement is performed, and no error bounds are */ |
| 2149 | /* computed. */ |
| 2150 | /* = 1.0 : Use the double-precision refinement algorithm, */ |
| 2151 | /* possibly with doubled-single computations if the */ |
| 2152 | /* compilation environment does not support DOUBLE */ |
| 2153 | /* PRECISION. */ |
| 2154 | /* (other values are reserved for future use) */ |
| 2155 | |
| 2156 | /* PARAMS(LA_LINRX_ITHRESH_I = 2) : Maximum number of residual */ |
| 2157 | /* computations allowed for refinement. */ |
| 2158 | /* Default: 10 */ |
| 2159 | /* Aggressive: Set to 100 to permit convergence using approximate */ |
| 2160 | /* factorizations or factorizations other than LU. If */ |
| 2161 | /* the factorization uses a technique other than */ |
| 2162 | /* Gaussian elimination, the guarantees in */ |
| 2163 | /* err_bnds_norm and err_bnds_comp may no longer be */ |
| 2164 | /* trustworthy. */ |
| 2165 | |
| 2166 | /* PARAMS(LA_LINRX_CWISE_I = 3) : Flag determining if the code */ |
| 2167 | /* will attempt to find a solution with small componentwise */ |
| 2168 | /* relative error in the double-precision algorithm. Positive */ |
| 2169 | /* is true, 0.0 is false. */ |
| 2170 | /* Default: 1.0 (attempt componentwise convergence) */ |
| 2171 | |
| 2172 | /* WORK (workspace) DOUBLE PRECISION array, dimension (4*N) */ |
| 2173 | |
| 2174 | /* IWORK (workspace) INTEGER array, dimension (N) */ |
| 2175 | |
| 2176 | /* INFO (output) INTEGER */ |
| 2177 | /* = 0: Successful exit. The solution to every right-hand side is */ |
| 2178 | /* guaranteed. */ |
| 2179 | /* < 0: If INFO = -i, the i-th argument had an illegal value */ |
| 2180 | /* > 0 and <= N: U(INFO,INFO) is exactly zero. The factorization */ |
| 2181 | /* has been completed, but the factor U is exactly singular, so */ |
| 2182 | /* the solution and error bounds could not be computed. RCOND = 0 */ |
| 2183 | /* is returned. */ |
| 2184 | /* = N+J: The solution corresponding to the Jth right-hand side is */ |
| 2185 | /* not guaranteed. The solutions corresponding to other right- */ |
| 2186 | /* hand sides K with K > J may not be guaranteed as well, but */ |
| 2187 | /* only the first such right-hand side is reported. If a small */ |
| 2188 | /* componentwise error is not requested (PARAMS(3) = 0.0) then */ |
| 2189 | /* the Jth right-hand side is the first with a normwise error */ |
| 2190 | /* bound that is not guaranteed (the smallest J such */ |
| 2191 | /* that ERR_BNDS_NORM(J,1) = 0.0). By default (PARAMS(3) = 1.0) */ |
| 2192 | /* the Jth right-hand side is the first with either a normwise or */ |
| 2193 | /* componentwise error bound that is not guaranteed (the smallest */ |
| 2194 | /* J such that either ERR_BNDS_NORM(J,1) = 0.0 or */ |
| 2195 | /* ERR_BNDS_COMP(J,1) = 0.0). See the definition of */ |
| 2196 | /* ERR_BNDS_NORM(:,1) and ERR_BNDS_COMP(:,1). To get information */ |
| 2197 | /* about all of the right-hand sides check ERR_BNDS_NORM or */ |
| 2198 | /* ERR_BNDS_COMP. */ |
| 2199 | |
| 2200 | /* ================================================================== */ |
| 2201 | |
| 2202 | /* .. Parameters .. */ |
| 2203 | /* .. */ |
| 2204 | /* .. Local Scalars .. */ |
| 2205 | /* .. */ |
| 2206 | /* .. External Subroutines .. */ |
| 2207 | /* .. */ |
| 2208 | /* .. Intrinsic Functions .. */ |
| 2209 | /* .. */ |
| 2210 | /* .. External Functions .. */ |
| 2211 | /* .. */ |
| 2212 | /* .. Executable Statements .. */ |
| 2213 | |
| 2214 | /* Check the input parameters. */ |
| 2215 | |
| 2216 | /* Parameter adjustments */ |
| 2217 | err_bnds_comp_dim1 = *nrhs; |
| 2218 | err_bnds_comp_offset = 1 + err_bnds_comp_dim1; |
| 2219 | err_bnds_comp__ -= err_bnds_comp_offset; |
| 2220 | err_bnds_norm_dim1 = *nrhs; |
| 2221 | err_bnds_norm_offset = 1 + err_bnds_norm_dim1; |
| 2222 | err_bnds_norm__ -= err_bnds_norm_offset; |
| 2223 | ab_dim1 = *ldab; |
| 2224 | ab_offset = 1 + ab_dim1; |
| 2225 | ab -= ab_offset; |
| 2226 | afb_dim1 = *ldafb; |
| 2227 | afb_offset = 1 + afb_dim1; |
| 2228 | afb -= afb_offset; |
| 2229 | --ipiv; |
| 2230 | --r__; |
| 2231 | --c__; |
| 2232 | b_dim1 = *ldb; |
| 2233 | b_offset = 1 + b_dim1; |
| 2234 | b -= b_offset; |
| 2235 | x_dim1 = *ldx; |
| 2236 | x_offset = 1 + x_dim1; |
| 2237 | x -= x_offset; |
| 2238 | --berr; |
| 2239 | --params; |
| 2240 | --work; |
| 2241 | --iwork; |
| 2242 | |
| 2243 | /* Function Body */ |
| 2244 | *info = 0; |
| 2245 | trans_type__ = ilatrans_(trans); |
| 2246 | ref_type__ = 1; |
| 2247 | if (*nparams >= 1) { |
| 2248 | if (params[1] < 0.) { |
| 2249 | params[1] = 1.; |
| 2250 | } else { |
| 2251 | ref_type__ = (integer) params[1]; |
| 2252 | } |
| 2253 | } |
| 2254 | |
| 2255 | /* Set default parameters. */ |
| 2256 | |
| 2257 | illrcond_thresh__ = (double) (*n) * dlamch_("Epsilon"); |
| 2258 | ithresh = 10; |
| 2259 | rthresh = .5; |
| 2260 | unstable_thresh__ = .25; |
| 2261 | ignore_cwise__ = false; |
| 2262 | |
| 2263 | if (*nparams >= 2) { |
| 2264 | if (params[2] < 0.) { |
| 2265 | params[2] = (double) ithresh; |
| 2266 | } else { |
| 2267 | ithresh = (integer) params[2]; |
| 2268 | } |
| 2269 | } |
| 2270 | if (*nparams >= 3) { |
| 2271 | if (params[3] < 0.) { |
| 2272 | if (ignore_cwise__) { |
| 2273 | params[3] = 0.; |
| 2274 | } else { |
| 2275 | params[3] = 1.; |
| 2276 | } |
| 2277 | } else { |
| 2278 | ignore_cwise__ = params[3] == 0.; |
| 2279 | } |
| 2280 | } |
| 2281 | if (ref_type__ == 0 || *n_err_bnds__ == 0) { |
| 2282 | n_norms__ = 0; |
| 2283 | } else if (ignore_cwise__) { |
| 2284 | n_norms__ = 1; |
| 2285 | } else { |
| 2286 | n_norms__ = 2; |
| 2287 | } |
| 2288 | |
| 2289 | notran = lsame_(trans, "N"); |
| 2290 | rowequ = lsame_(equed, "R") || lsame_(equed, "B"); |
| 2291 | colequ = lsame_(equed, "C") || lsame_(equed, "B"); |
| 2292 | |
| 2293 | /* Test input parameters. */ |
| 2294 | |
| 2295 | if (trans_type__ == -1) { |
| 2296 | *info = -1; |
| 2297 | } else if (! rowequ && ! colequ && ! lsame_(equed, "N")) { |
| 2298 | *info = -2; |
| 2299 | } else if (*n < 0) { |
| 2300 | *info = -3; |
| 2301 | } else if (*kl < 0) { |
| 2302 | *info = -4; |
| 2303 | } else if (*ku < 0) { |
| 2304 | *info = -5; |
| 2305 | } else if (*nrhs < 0) { |
| 2306 | *info = -6; |
| 2307 | } else if (*ldab < *kl + *ku + 1) { |
| 2308 | *info = -8; |
| 2309 | } else if (*ldafb < (*kl << 1) + *ku + 1) { |
| 2310 | *info = -10; |
| 2311 | } else if (*ldb < std::max(1_integer,*n)) { |
| 2312 | *info = -13; |
| 2313 | } else if (*ldx < std::max(1_integer,*n)) { |
| 2314 | *info = -15; |
| 2315 | } |
| 2316 | if (*info != 0) { |
| 2317 | i__1 = -(*info); |
| 2318 | xerbla_("DGBRFSX", &i__1); |
| 2319 | return 0; |
| 2320 | } |
| 2321 | |
| 2322 | /* Quick return if possible. */ |
| 2323 | |
| 2324 | if (*n == 0 || *nrhs == 0) { |
| 2325 | *rcond = 1.; |
| 2326 | i__1 = *nrhs; |
| 2327 | for (j = 1; j <= i__1; ++j) { |
| 2328 | berr[j] = 0.; |
| 2329 | if (*n_err_bnds__ >= 1) { |
| 2330 | err_bnds_norm__[j + err_bnds_norm_dim1] = 1.; |
| 2331 | err_bnds_comp__[j + err_bnds_comp_dim1] = 1.; |
| 2332 | } else if (*n_err_bnds__ >= 2) { |
| 2333 | err_bnds_norm__[j + (err_bnds_norm_dim1 << 1)] = 0.; |
| 2334 | err_bnds_comp__[j + (err_bnds_comp_dim1 << 1)] = 0.; |
| 2335 | } else if (*n_err_bnds__ >= 3) { |
| 2336 | err_bnds_norm__[j + err_bnds_norm_dim1 * 3] = 1.; |
| 2337 | err_bnds_comp__[j + err_bnds_comp_dim1 * 3] = 1.; |
| 2338 | } |
| 2339 | } |
| 2340 | return 0; |
| 2341 | } |
| 2342 | |
| 2343 | /* Default to failure. */ |
| 2344 | |
| 2345 | *rcond = 0.; |
| 2346 | i__1 = *nrhs; |
| 2347 | for (j = 1; j <= i__1; ++j) { |
| 2348 | berr[j] = 1.; |
| 2349 | if (*n_err_bnds__ >= 1) { |
| 2350 | err_bnds_norm__[j + err_bnds_norm_dim1] = 1.; |
| 2351 | err_bnds_comp__[j + err_bnds_comp_dim1] = 1.; |
| 2352 | } else if (*n_err_bnds__ >= 2) { |
| 2353 | err_bnds_norm__[j + (err_bnds_norm_dim1 << 1)] = 1.; |
| 2354 | err_bnds_comp__[j + (err_bnds_comp_dim1 << 1)] = 1.; |
| 2355 | } else if (*n_err_bnds__ >= 3) { |
| 2356 | err_bnds_norm__[j + err_bnds_norm_dim1 * 3] = 0.; |
| 2357 | err_bnds_comp__[j + err_bnds_comp_dim1 * 3] = 0.; |
| 2358 | } |
| 2359 | } |
| 2360 | |
| 2361 | /* Compute the norm of A and the reciprocal of the condition */ |
| 2362 | /* number of A. */ |
| 2363 | |
| 2364 | if (notran) { |
| 2365 | *(unsigned char *)norm = 'I'; |
| 2366 | } else { |
| 2367 | *(unsigned char *)norm = '1'; |
| 2368 | } |
| 2369 | anorm = dlangb_(norm, n, kl, ku, &ab[ab_offset], ldab, &work[1]); |
| 2370 | dgbcon_(norm, n, kl, ku, &afb[afb_offset], ldafb, &ipiv[1], &anorm, rcond, |
| 2371 | &work[1], &iwork[1], info); |
| 2372 | |
| 2373 | /* Perform refinement on each right-hand side */ |
| 2374 | |
| 2375 | if (ref_type__ != 0) { |
| 2376 | prec_type__ = ilaprec_("E"); |
| 2377 | if (notran) { |
| 2378 | dla_gbrfsx_extended__(&prec_type__, &trans_type__, n, kl, ku, |
| 2379 | nrhs, &ab[ab_offset], ldab, &afb[afb_offset], ldafb, & |
| 2380 | ipiv[1], &colequ, &c__[1], &b[b_offset], ldb, &x[x_offset] |
| 2381 | , ldx, &berr[1], &n_norms__, &err_bnds_norm__[ |
| 2382 | err_bnds_norm_offset], &err_bnds_comp__[ |
| 2383 | err_bnds_comp_offset], &work[*n + 1], &work[1], &work[(*n |
| 2384 | << 1) + 1], &work[1], rcond, &ithresh, &rthresh, & |
| 2385 | unstable_thresh__, &ignore_cwise__, info); |
| 2386 | } else { |
| 2387 | dla_gbrfsx_extended__(&prec_type__, &trans_type__, n, kl, ku, |
| 2388 | nrhs, &ab[ab_offset], ldab, &afb[afb_offset], ldafb, & |
| 2389 | ipiv[1], &rowequ, &r__[1], &b[b_offset], ldb, &x[x_offset] |
| 2390 | , ldx, &berr[1], &n_norms__, &err_bnds_norm__[ |
| 2391 | err_bnds_norm_offset], &err_bnds_comp__[ |
| 2392 | err_bnds_comp_offset], &work[*n + 1], &work[1], &work[(*n |
| 2393 | << 1) + 1], &work[1], rcond, &ithresh, &rthresh, & |
| 2394 | unstable_thresh__, &ignore_cwise__, info); |
| 2395 | } |
| 2396 | } |
| 2397 | /* Computing MAX */ |
| 2398 | d__1 = 10., d__2 = sqrt((double) (*n)); |
| 2399 | err_lbnd__ = std::max(d__1,d__2) * dlamch_("Epsilon"); |
| 2400 | if (*n_err_bnds__ >= 1 && n_norms__ >= 1) { |
| 2401 | |
| 2402 | /* Compute scaled normwise condition number cond(A*C). */ |
| 2403 | |
| 2404 | if (colequ && notran) { |
| 2405 | rcond_tmp__ = dla_gbrcond__(trans, n, kl, ku, &ab[ab_offset], |
| 2406 | ldab, &afb[afb_offset], ldafb, &ipiv[1], &c_n1, &c__[1], |
| 2407 | info, &work[1], &iwork[1], 1_integer); |
| 2408 | } else if (rowequ && ! notran) { |
| 2409 | rcond_tmp__ = dla_gbrcond__(trans, n, kl, ku, &ab[ab_offset], |
| 2410 | ldab, &afb[afb_offset], ldafb, &ipiv[1], &c_n1, &r__[1], |
| 2411 | info, &work[1], &iwork[1], 1_integer); |
| 2412 | } else { |
| 2413 | rcond_tmp__ = dla_gbrcond__(trans, n, kl, ku, &ab[ab_offset], |
| 2414 | ldab, &afb[afb_offset], ldafb, &ipiv[1], &c__0, &r__[1], |
| 2415 | info, &work[1], &iwork[1], 1_integer); |
| 2416 | } |
| 2417 | i__1 = *nrhs; |
| 2418 | for (j = 1; j <= i__1; ++j) { |
| 2419 | |
| 2420 | /* Cap the error at 1.0. */ |
| 2421 | |
| 2422 | if (*n_err_bnds__ >= 2 && err_bnds_norm__[j + (err_bnds_norm_dim1 |
| 2423 | << 1)] > 1.) { |
| 2424 | err_bnds_norm__[j + (err_bnds_norm_dim1 << 1)] = 1.; |
| 2425 | } |
| 2426 | |
| 2427 | /* Threshold the error (see LAWN). */ |
| 2428 | |
| 2429 | if (rcond_tmp__ < illrcond_thresh__) { |
| 2430 | err_bnds_norm__[j + (err_bnds_norm_dim1 << 1)] = 1.; |
| 2431 | err_bnds_norm__[j + err_bnds_norm_dim1] = 0.; |
| 2432 | if (*info <= *n) { |
| 2433 | *info = *n + j; |
| 2434 | } |
| 2435 | } else if (err_bnds_norm__[j + (err_bnds_norm_dim1 << 1)] < |
| 2436 | err_lbnd__) { |
| 2437 | err_bnds_norm__[j + (err_bnds_norm_dim1 << 1)] = err_lbnd__; |
| 2438 | err_bnds_norm__[j + err_bnds_norm_dim1] = 1.; |
| 2439 | } |
| 2440 | |
| 2441 | /* Save the condition number. */ |
| 2442 | |
| 2443 | if (*n_err_bnds__ >= 3) { |
| 2444 | err_bnds_norm__[j + err_bnds_norm_dim1 * 3] = rcond_tmp__; |
| 2445 | } |
| 2446 | } |
| 2447 | } |
| 2448 | if (*n_err_bnds__ >= 1 && n_norms__ >= 2) { |
| 2449 | |
| 2450 | /* Compute componentwise condition number cond(A*diag(Y(:,J))) for */ |
| 2451 | /* each right-hand side using the current solution as an estimate of */ |
| 2452 | /* the true solution. If the componentwise error estimate is too */ |
| 2453 | /* large, then the solution is a lousy estimate of truth and the */ |
| 2454 | /* estimated RCOND may be too optimistic. To avoid misleading users, */ |
| 2455 | /* the inverse condition number is set to 0.0 when the estimated */ |
| 2456 | /* cwise error is at least CWISE_WRONG. */ |
| 2457 | |
| 2458 | cwise_wrong__ = sqrt(dlamch_("Epsilon")); |
| 2459 | i__1 = *nrhs; |
| 2460 | for (j = 1; j <= i__1; ++j) { |
| 2461 | if (err_bnds_comp__[j + (err_bnds_comp_dim1 << 1)] < |
| 2462 | cwise_wrong__) { |
| 2463 | rcond_tmp__ = dla_gbrcond__(trans, n, kl, ku, &ab[ab_offset], |
| 2464 | ldab, &afb[afb_offset], ldafb, &ipiv[1], &c__1, &x[j * |
| 2465 | x_dim1 + 1], info, &work[1], &iwork[1], 1_integer); |
| 2466 | } else { |
| 2467 | rcond_tmp__ = 0.; |
| 2468 | } |
| 2469 | |
| 2470 | /* Cap the error at 1.0. */ |
| 2471 | |
| 2472 | if (*n_err_bnds__ >= 2 && err_bnds_comp__[j + (err_bnds_comp_dim1 |
| 2473 | << 1)] > 1.) { |
| 2474 | err_bnds_comp__[j + (err_bnds_comp_dim1 << 1)] = 1.; |
| 2475 | } |
| 2476 | |
| 2477 | /* Threshold the error (see LAWN). */ |
| 2478 | |
| 2479 | if (rcond_tmp__ < illrcond_thresh__) { |
| 2480 | err_bnds_comp__[j + (err_bnds_comp_dim1 << 1)] = 1.; |
| 2481 | err_bnds_comp__[j + err_bnds_comp_dim1] = 0.; |
| 2482 | if (params[3] == 1. && *info < *n + j) { |
| 2483 | *info = *n + j; |
| 2484 | } |
| 2485 | } else if (err_bnds_comp__[j + (err_bnds_comp_dim1 << 1)] < |
| 2486 | err_lbnd__) { |
| 2487 | err_bnds_comp__[j + (err_bnds_comp_dim1 << 1)] = err_lbnd__; |
| 2488 | err_bnds_comp__[j + err_bnds_comp_dim1] = 1.; |
| 2489 | } |
| 2490 | |
| 2491 | /* Save the condition number. */ |
| 2492 | |
| 2493 | if (*n_err_bnds__ >= 3) { |
| 2494 | err_bnds_comp__[j + err_bnds_comp_dim1 * 3] = rcond_tmp__; |
| 2495 | } |
| 2496 | } |
| 2497 | } |
| 2498 | |
| 2499 | return 0; |
| 2500 | |
| 2501 | /* End of DGBRFSX */ |
| 2502 | |
| 2503 | } /* dgbrfsx_ */ |
| 2504 | #endif |
| 2505 | |
| 2506 | /* Subroutine */ int dgbsv_cxx . . $ dgbsv_(ca3a299d13467b39).(integercxx . . $ integer# *n, integercxx . . $ integer# *kl, integercxx . . $ integer# *ku, integercxx . . $ integer# * |
| 2507 | nrhs, double *ab, integercxx . . $ integer# *ldab, integercxx . . $ integer# *ipiv, double *b, |
| 2508 | integercxx . . $ integer# *ldb, integercxx . . $ integer# *info) |
| 2509 | { |
| 2510 | /* System generated locals */ |
| 2511 | integercxx . . $ integer# ab_dim1, ab_offset, b_dim1, b_offset, i__1; |
| 2512 | |
| 2513 | /* -- LAPACK driver routine (version 3.1) -- */ |
| 2514 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 2515 | /* November 2006 */ |
| 2516 | |
| 2517 | /* .. Scalar Arguments .. */ |
| 2518 | /* .. */ |
| 2519 | /* .. Array Arguments .. */ |
| 2520 | /* .. */ |
| 2521 | |
| 2522 | /* Purpose */ |
| 2523 | /* ======= */ |
| 2524 | |
| 2525 | /* DGBSV computes the solution to a real system of linear equations */ |
| 2526 | /* A * X = B, where A is a band matrix of order N with KL subdiagonals */ |
| 2527 | /* and KU superdiagonals, and X and B are N-by-NRHS matrices. */ |
| 2528 | |
| 2529 | /* The LU decomposition with partial pivoting and row interchanges is */ |
| 2530 | /* used to factor A as A = L * U, where L is a product of permutation */ |
| 2531 | /* and unit lower triangular matrices with KL subdiagonals, and U is */ |
| 2532 | /* upper triangular with KL+KU superdiagonals. The factored form of A */ |
| 2533 | /* is then used to solve the system of equations A * X = B. */ |
| 2534 | |
| 2535 | /* Arguments */ |
| 2536 | /* ========= */ |
| 2537 | |
| 2538 | /* N (input) INTEGER */ |
| 2539 | /* The number of linear equations, i.e., the order of the */ |
| 2540 | /* matrix A. N >= 0. */ |
| 2541 | |
| 2542 | /* KL (input) INTEGER */ |
| 2543 | /* The number of subdiagonals within the band of A. KL >= 0. */ |
| 2544 | |
| 2545 | /* KU (input) INTEGER */ |
| 2546 | /* The number of superdiagonals within the band of A. KU >= 0. */ |
| 2547 | |
| 2548 | /* NRHS (input) INTEGER */ |
| 2549 | /* The number of right hand sides, i.e., the number of columns */ |
| 2550 | /* of the matrix B. NRHS >= 0. */ |
| 2551 | |
| 2552 | /* AB (input/output) DOUBLE PRECISION array, dimension (LDAB,N) */ |
| 2553 | /* On entry, the matrix A in band storage, in rows KL+1 to */ |
| 2554 | /* 2*KL+KU+1; rows 1 to KL of the array need not be set. */ |
| 2555 | /* The j-th column of A is stored in the j-th column of the */ |
| 2556 | /* array AB as follows: */ |
| 2557 | /* AB(KL+KU+1+i-j,j) = A(i,j) for max(1,j-KU)<=i<=min(N,j+KL) */ |
| 2558 | /* On exit, details of the factorization: U is stored as an */ |
| 2559 | /* upper triangular band matrix with KL+KU superdiagonals in */ |
| 2560 | /* rows 1 to KL+KU+1, and the multipliers used during the */ |
| 2561 | /* factorization are stored in rows KL+KU+2 to 2*KL+KU+1. */ |
| 2562 | /* See below for further details. */ |
| 2563 | |
| 2564 | /* LDAB (input) INTEGER */ |
| 2565 | /* The leading dimension of the array AB. LDAB >= 2*KL+KU+1. */ |
| 2566 | |
| 2567 | /* IPIV (output) INTEGER array, dimension (N) */ |
| 2568 | /* The pivot indices that define the permutation matrix P; */ |
| 2569 | /* row i of the matrix was interchanged with row IPIV(i). */ |
| 2570 | |
| 2571 | /* B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */ |
| 2572 | /* On entry, the N-by-NRHS right hand side matrix B. */ |
| 2573 | /* On exit, if INFO = 0, the N-by-NRHS solution matrix X. */ |
| 2574 | |
| 2575 | /* LDB (input) INTEGER */ |
| 2576 | /* The leading dimension of the array B. LDB >= max(1,N). */ |
| 2577 | |
| 2578 | /* INFO (output) INTEGER */ |
| 2579 | /* = 0: successful exit */ |
| 2580 | /* < 0: if INFO = -i, the i-th argument had an illegal value */ |
| 2581 | /* > 0: if INFO = i, U(i,i) is exactly zero. The factorization */ |
| 2582 | /* has been completed, but the factor U is exactly */ |
| 2583 | /* singular, and the solution has not been computed. */ |
| 2584 | |
| 2585 | /* Further Details */ |
| 2586 | /* =============== */ |
| 2587 | |
| 2588 | /* The band storage scheme is illustrated by the following example, when */ |
| 2589 | /* M = N = 6, KL = 2, KU = 1: */ |
| 2590 | |
| 2591 | /* On entry: On exit: */ |
| 2592 | |
| 2593 | /* * * * + + + * * * u14 u25 u36 */ |
| 2594 | /* * * + + + + * * u13 u24 u35 u46 */ |
| 2595 | /* * a12 a23 a34 a45 a56 * u12 u23 u34 u45 u56 */ |
| 2596 | /* a11 a22 a33 a44 a55 a66 u11 u22 u33 u44 u55 u66 */ |
| 2597 | /* a21 a32 a43 a54 a65 * m21 m32 m43 m54 m65 * */ |
| 2598 | /* a31 a42 a53 a64 * * m31 m42 m53 m64 * * */ |
| 2599 | |
| 2600 | /* Array elements marked * are not used by the routine; elements marked */ |
| 2601 | /* + need not be set on entry, but are required by the routine to store */ |
| 2602 | /* elements of U because of fill-in resulting from the row interchanges. */ |
| 2603 | |
| 2604 | /* ===================================================================== */ |
| 2605 | |
| 2606 | /* .. External Subroutines .. */ |
| 2607 | /* .. */ |
| 2608 | /* .. Intrinsic Functions .. */ |
| 2609 | /* .. */ |
| 2610 | /* .. Executable Statements .. */ |
| 2611 | |
| 2612 | /* Test the input parameters. */ |
| 2613 | |
| 2614 | /* Parameter adjustments */ |
| 2615 | ab_dim1 = *ldab; |
| 2616 | ab_offset = 1 + ab_dim1; |
| 2617 | ab -= ab_offset; |
| 2618 | --ipiv; |
| 2619 | b_dim1 = *ldb; |
| 2620 | b_offset = 1 + b_dim1; |
| 2621 | b -= b_offset; |
| 2622 | |
| 2623 | /* Function Body */ |
| 2624 | *info = 0; |
| 2625 | if (*n < 0) { |
| 2626 | *info = -1; |
| 2627 | } else if (*kl < 0) { |
| 2628 | *info = -2; |
| 2629 | } else if (*ku < 0) { |
| 2630 | *info = -3; |
| 2631 | } else if (*nrhs < 0) { |
| 2632 | *info = -4; |
| 2633 | } else if (*ldab < (*kl << 1) + *ku + 1) { |
| 2634 | *info = -6; |
| 2635 | } else if (*ldb < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(*n,1_integercxx . . $ `operator""_integer`(85240eb457c3721a).)) { |
| 2636 | *info = -9; |
| 2637 | } |
| 2638 | if (*info != 0) { |
| 2639 | i__1 = -(*info); |
| 2640 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGBSV ", &i__1); |
| 2641 | return 0; |
| 2642 | } |
| 2643 | |
| 2644 | /* Compute the LU factorization of the band matrix A. */ |
| 2645 | |
| 2646 | dgbtrf_cxx . . $ dgbtrf_(6c38e8b1f1607139).(n, n, kl, ku, &ab[ab_offset], ldab, &ipiv[1], info); |
| 2647 | if (*info == 0) { |
| 2648 | |
| 2649 | /* Solve the system A*X = B, overwriting B with X. */ |
| 2650 | |
| 2651 | dgbtrs_cxx . . $ dgbtrs_(50a94af1eb812d7f).("No transpose", n, kl, ku, nrhs, &ab[ab_offset], ldab, &ipiv[ |
| 2652 | 1], &b[b_offset], ldb, info); |
| 2653 | } |
| 2654 | return 0; |
| 2655 | |
| 2656 | /* End of DGBSV */ |
| 2657 | |
| 2658 | } /* dgbsv_ */ |
| 2659 | |
| 2660 | /* Subroutine */ int dgbsvx_cxx . . $ dgbsvx_(9721ef93ea5caa7e).(const char *fact, const char *trans, integercxx . . $ integer# *n, integercxx . . $ integer# *kl, |
| 2661 | integercxx . . $ integer# *ku, integercxx . . $ integer# *nrhs, double *ab, integercxx . . $ integer# *ldab, |
| 2662 | double *afb, integercxx . . $ integer# *ldafb, integercxx . . $ integer# *ipiv, char *equed, |
| 2663 | double *r__, double *c__, double *b, integercxx . . $ integer# *ldb, |
| 2664 | double *x, integercxx . . $ integer# *ldx, double *rcond, double *ferr, |
| 2665 | double *berr, double *work, integercxx . . $ integer# *iwork, integercxx . . $ integer# *info) |
| 2666 | { |
| 2667 | /* Table of constant values */ |
| 2668 | static integercxx . . $ integer# c__1 = 1; |
| 2669 | |
| 2670 | /* System generated locals */ |
| 2671 | integercxx . . $ integer# ab_dim1, ab_offset, afb_dim1, afb_offset, b_dim1, b_offset, |
| 2672 | x_dim1, x_offset, i__1, i__2, i__3, i__4, i__5; |
| 2673 | double d__1, d__2, d__3; |
| 2674 | |
| 2675 | /* Local variables */ |
| 2676 | integercxx . . $ integer# i__, j, j1, j2; |
| 2677 | double amax; |
| 2678 | char norm[1]; |
| 2679 | double rcmin, rcmax, anorm; |
| 2680 | bool equil; |
| 2681 | double colcnd; |
| 2682 | bool nofact; |
| 2683 | double bignum; |
| 2684 | integercxx . . $ integer# infequ; |
| 2685 | bool colequ; |
| 2686 | double rowcnd; |
| 2687 | bool notran; |
| 2688 | double smlnum; |
| 2689 | bool rowequ; |
| 2690 | double rpvgrw; |
| 2691 | |
| 2692 | |
| 2693 | /* -- LAPACK driver routine (version 3.1) -- */ |
| 2694 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 2695 | /* November 2006 */ |
| 2696 | |
| 2697 | /* .. Scalar Arguments .. */ |
| 2698 | /* .. */ |
| 2699 | /* .. Array Arguments .. */ |
| 2700 | /* .. */ |
| 2701 | |
| 2702 | /* Purpose */ |
| 2703 | /* ======= */ |
| 2704 | |
| 2705 | /* DGBSVX uses the LU factorization to compute the solution to a real */ |
| 2706 | /* system of linear equations A * X = B, A**T * X = B, or A**H * X = B, */ |
| 2707 | /* where A is a band matrix of order N with KL subdiagonals and KU */ |
| 2708 | /* superdiagonals, and X and B are N-by-NRHS matrices. */ |
| 2709 | |
| 2710 | /* Error bounds on the solution and a condition estimate are also */ |
| 2711 | /* provided. */ |
| 2712 | |
| 2713 | /* Description */ |
| 2714 | /* =========== */ |
| 2715 | |
| 2716 | /* The following steps are performed by this subroutine: */ |
| 2717 | |
| 2718 | /* 1. If FACT = 'E', real scaling factors are computed to equilibrate */ |
| 2719 | /* the system: */ |
| 2720 | /* TRANS = 'N': diag(R)*A*diag(C) *inv(diag(C))*X = diag(R)*B */ |
| 2721 | /* TRANS = 'T': (diag(R)*A*diag(C))**T *inv(diag(R))*X = diag(C)*B */ |
| 2722 | /* TRANS = 'C': (diag(R)*A*diag(C))**H *inv(diag(R))*X = diag(C)*B */ |
| 2723 | /* Whether or not the system will be equilibrated depends on the */ |
| 2724 | /* scaling of the matrix A, but if equilibration is used, A is */ |
| 2725 | /* overwritten by diag(R)*A*diag(C) and B by diag(R)*B (if TRANS='N') */ |
| 2726 | /* or diag(C)*B (if TRANS = 'T' or 'C'). */ |
| 2727 | |
| 2728 | /* 2. If FACT = 'N' or 'E', the LU decomposition is used to factor the */ |
| 2729 | /* matrix A (after equilibration if FACT = 'E') as */ |
| 2730 | /* A = L * U, */ |
| 2731 | /* where L is a product of permutation and unit lower triangular */ |
| 2732 | /* matrices with KL subdiagonals, and U is upper triangular with */ |
| 2733 | /* KL+KU superdiagonals. */ |
| 2734 | |
| 2735 | /* 3. If some U(i,i)=0, so that U is exactly singular, then the routine */ |
| 2736 | /* returns with INFO = i. Otherwise, the factored form of A is used */ |
| 2737 | /* to estimate the condition number of the matrix A. If the */ |
| 2738 | /* reciprocal of the condition number is less than machine precision, */ |
| 2739 | /* INFO = N+1 is returned as a warning, but the routine still goes on */ |
| 2740 | /* to solve for X and compute error bounds as described below. */ |
| 2741 | |
| 2742 | /* 4. The system of equations is solved for X using the factored form */ |
| 2743 | /* of A. */ |
| 2744 | |
| 2745 | /* 5. Iterative refinement is applied to improve the computed solution */ |
| 2746 | /* matrix and calculate error bounds and backward error estimates */ |
| 2747 | /* for it. */ |
| 2748 | |
| 2749 | /* 6. If equilibration was used, the matrix X is premultiplied by */ |
| 2750 | /* diag(C) (if TRANS = 'N') or diag(R) (if TRANS = 'T' or 'C') so */ |
| 2751 | /* that it solves the original system before equilibration. */ |
| 2752 | |
| 2753 | /* Arguments */ |
| 2754 | /* ========= */ |
| 2755 | |
| 2756 | /* FACT (input) CHARACTER*1 */ |
| 2757 | /* Specifies whether or not the factored form of the matrix A is */ |
| 2758 | /* supplied on entry, and if not, whether the matrix A should be */ |
| 2759 | /* equilibrated before it is factored. */ |
| 2760 | /* = 'F': On entry, AFB and IPIV contain the factored form of */ |
| 2761 | /* A. If EQUED is not 'N', the matrix A has been */ |
| 2762 | /* equilibrated with scaling factors given by R and C. */ |
| 2763 | /* AB, AFB, and IPIV are not modified. */ |
| 2764 | /* = 'N': The matrix A will be copied to AFB and factored. */ |
| 2765 | /* = 'E': The matrix A will be equilibrated if necessary, then */ |
| 2766 | /* copied to AFB and factored. */ |
| 2767 | |
| 2768 | /* TRANS (input) CHARACTER*1 */ |
| 2769 | /* Specifies the form of the system of equations. */ |
| 2770 | /* = 'N': A * X = B (No transpose) */ |
| 2771 | /* = 'T': A**T * X = B (Transpose) */ |
| 2772 | /* = 'C': A**H * X = B (Transpose) */ |
| 2773 | |
| 2774 | /* N (input) INTEGER */ |
| 2775 | /* The number of linear equations, i.e., the order of the */ |
| 2776 | /* matrix A. N >= 0. */ |
| 2777 | |
| 2778 | /* KL (input) INTEGER */ |
| 2779 | /* The number of subdiagonals within the band of A. KL >= 0. */ |
| 2780 | |
| 2781 | /* KU (input) INTEGER */ |
| 2782 | /* The number of superdiagonals within the band of A. KU >= 0. */ |
| 2783 | |
| 2784 | /* NRHS (input) INTEGER */ |
| 2785 | /* The number of right hand sides, i.e., the number of columns */ |
| 2786 | /* of the matrices B and X. NRHS >= 0. */ |
| 2787 | |
| 2788 | /* AB (input/output) DOUBLE PRECISION array, dimension (LDAB,N) */ |
| 2789 | /* On entry, the matrix A in band storage, in rows 1 to KL+KU+1. */ |
| 2790 | /* The j-th column of A is stored in the j-th column of the */ |
| 2791 | /* array AB as follows: */ |
| 2792 | /* AB(KU+1+i-j,j) = A(i,j) for max(1,j-KU)<=i<=min(N,j+kl) */ |
| 2793 | |
| 2794 | /* If FACT = 'F' and EQUED is not 'N', then A must have been */ |
| 2795 | /* equilibrated by the scaling factors in R and/or C. AB is not */ |
| 2796 | /* modified if FACT = 'F' or 'N', or if FACT = 'E' and */ |
| 2797 | /* EQUED = 'N' on exit. */ |
| 2798 | |
| 2799 | /* On exit, if EQUED .ne. 'N', A is scaled as follows: */ |
| 2800 | /* EQUED = 'R': A := diag(R) * A */ |
| 2801 | /* EQUED = 'C': A := A * diag(C) */ |
| 2802 | /* EQUED = 'B': A := diag(R) * A * diag(C). */ |
| 2803 | |
| 2804 | /* LDAB (input) INTEGER */ |
| 2805 | /* The leading dimension of the array AB. LDAB >= KL+KU+1. */ |
| 2806 | |
| 2807 | /* AFB (input or output) DOUBLE PRECISION array, dimension (LDAFB,N) */ |
| 2808 | /* If FACT = 'F', then AFB is an input argument and on entry */ |
| 2809 | /* contains details of the LU factorization of the band matrix */ |
| 2810 | /* A, as computed by DGBTRF. U is stored as an upper triangular */ |
| 2811 | /* band matrix with KL+KU superdiagonals in rows 1 to KL+KU+1, */ |
| 2812 | /* and the multipliers used during the factorization are stored */ |
| 2813 | /* in rows KL+KU+2 to 2*KL+KU+1. If EQUED .ne. 'N', then AFB is */ |
| 2814 | /* the factored form of the equilibrated matrix A. */ |
| 2815 | |
| 2816 | /* If FACT = 'N', then AFB is an output argument and on exit */ |
| 2817 | /* returns details of the LU factorization of A. */ |
| 2818 | |
| 2819 | /* If FACT = 'E', then AFB is an output argument and on exit */ |
| 2820 | /* returns details of the LU factorization of the equilibrated */ |
| 2821 | /* matrix A (see the description of AB for the form of the */ |
| 2822 | /* equilibrated matrix). */ |
| 2823 | |
| 2824 | /* LDAFB (input) INTEGER */ |
| 2825 | /* The leading dimension of the array AFB. LDAFB >= 2*KL+KU+1. */ |
| 2826 | |
| 2827 | /* IPIV (input or output) INTEGER array, dimension (N) */ |
| 2828 | /* If FACT = 'F', then IPIV is an input argument and on entry */ |
| 2829 | /* contains the pivot indices from the factorization A = L*U */ |
| 2830 | /* as computed by DGBTRF; row i of the matrix was interchanged */ |
| 2831 | /* with row IPIV(i). */ |
| 2832 | |
| 2833 | /* If FACT = 'N', then IPIV is an output argument and on exit */ |
| 2834 | /* contains the pivot indices from the factorization A = L*U */ |
| 2835 | /* of the original matrix A. */ |
| 2836 | |
| 2837 | /* If FACT = 'E', then IPIV is an output argument and on exit */ |
| 2838 | /* contains the pivot indices from the factorization A = L*U */ |
| 2839 | /* of the equilibrated matrix A. */ |
| 2840 | |
| 2841 | /* EQUED (input or output) CHARACTER*1 */ |
| 2842 | /* Specifies the form of equilibration that was done. */ |
| 2843 | /* = 'N': No equilibration (always true if FACT = 'N'). */ |
| 2844 | /* = 'R': Row equilibration, i.e., A has been premultiplied by */ |
| 2845 | /* diag(R). */ |
| 2846 | /* = 'C': Column equilibration, i.e., A has been postmultiplied */ |
| 2847 | /* by diag(C). */ |
| 2848 | /* = 'B': Both row and column equilibration, i.e., A has been */ |
| 2849 | /* replaced by diag(R) * A * diag(C). */ |
| 2850 | /* EQUED is an input argument if FACT = 'F'; otherwise, it is an */ |
| 2851 | /* output argument. */ |
| 2852 | |
| 2853 | /* R (input or output) DOUBLE PRECISION array, dimension (N) */ |
| 2854 | /* The row scale factors for A. If EQUED = 'R' or 'B', A is */ |
| 2855 | /* multiplied on the left by diag(R); if EQUED = 'N' or 'C', R */ |
| 2856 | /* is not accessed. R is an input argument if FACT = 'F'; */ |
| 2857 | /* otherwise, R is an output argument. If FACT = 'F' and */ |
| 2858 | /* EQUED = 'R' or 'B', each element of R must be positive. */ |
| 2859 | |
| 2860 | /* C (input or output) DOUBLE PRECISION array, dimension (N) */ |
| 2861 | /* The column scale factors for A. If EQUED = 'C' or 'B', A is */ |
| 2862 | /* multiplied on the right by diag(C); if EQUED = 'N' or 'R', C */ |
| 2863 | /* is not accessed. C is an input argument if FACT = 'F'; */ |
| 2864 | /* otherwise, C is an output argument. If FACT = 'F' and */ |
| 2865 | /* EQUED = 'C' or 'B', each element of C must be positive. */ |
| 2866 | |
| 2867 | /* B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */ |
| 2868 | /* On entry, the right hand side matrix B. */ |
| 2869 | /* On exit, */ |
| 2870 | /* if EQUED = 'N', B is not modified; */ |
| 2871 | /* if TRANS = 'N' and EQUED = 'R' or 'B', B is overwritten by */ |
| 2872 | /* diag(R)*B; */ |
| 2873 | /* if TRANS = 'T' or 'C' and EQUED = 'C' or 'B', B is */ |
| 2874 | /* overwritten by diag(C)*B. */ |
| 2875 | |
| 2876 | /* LDB (input) INTEGER */ |
| 2877 | /* The leading dimension of the array B. LDB >= max(1,N). */ |
| 2878 | |
| 2879 | /* X (output) DOUBLE PRECISION array, dimension (LDX,NRHS) */ |
| 2880 | /* If INFO = 0 or INFO = N+1, the N-by-NRHS solution matrix X */ |
| 2881 | /* to the original system of equations. Note that A and B are */ |
| 2882 | /* modified on exit if EQUED .ne. 'N', and the solution to the */ |
| 2883 | /* equilibrated system is inv(diag(C))*X if TRANS = 'N' and */ |
| 2884 | /* EQUED = 'C' or 'B', or inv(diag(R))*X if TRANS = 'T' or 'C' */ |
| 2885 | /* and EQUED = 'R' or 'B'. */ |
| 2886 | |
| 2887 | /* LDX (input) INTEGER */ |
| 2888 | /* The leading dimension of the array X. LDX >= max(1,N). */ |
| 2889 | |
| 2890 | /* RCOND (output) DOUBLE PRECISION */ |
| 2891 | /* The estimate of the reciprocal condition number of the matrix */ |
| 2892 | /* A after equilibration (if done). If RCOND is less than the */ |
| 2893 | /* machine precision (in particular, if RCOND = 0), the matrix */ |
| 2894 | /* is singular to working precision. This condition is */ |
| 2895 | /* indicated by a return code of INFO > 0. */ |
| 2896 | |
| 2897 | /* FERR (output) DOUBLE PRECISION array, dimension (NRHS) */ |
| 2898 | /* The estimated forward error bound for each solution vector */ |
| 2899 | /* X(j) (the j-th column of the solution matrix X). */ |
| 2900 | /* If XTRUE is the true solution corresponding to X(j), FERR(j) */ |
| 2901 | /* is an estimated upper bound for the magnitude of the largest */ |
| 2902 | /* element in (X(j) - XTRUE) divided by the magnitude of the */ |
| 2903 | /* largest element in X(j). The estimate is as reliable as */ |
| 2904 | /* the estimate for RCOND, and is almost always a slight */ |
| 2905 | /* overestimate of the true error. */ |
| 2906 | |
| 2907 | /* BERR (output) DOUBLE PRECISION array, dimension (NRHS) */ |
| 2908 | /* The componentwise relative backward error of each solution */ |
| 2909 | /* vector X(j) (i.e., the smallest relative change in */ |
| 2910 | /* any element of A or B that makes X(j) an exact solution). */ |
| 2911 | |
| 2912 | /* WORK (workspace/output) DOUBLE PRECISION array, dimension (3*N) */ |
| 2913 | /* On exit, WORK(1) contains the reciprocal pivot growth */ |
| 2914 | /* factor norm(A)/norm(U). The "max absolute element" norm is */ |
| 2915 | /* used. If WORK(1) is much less than 1, then the stability */ |
| 2916 | /* of the LU factorization of the (equilibrated) matrix A */ |
| 2917 | /* could be poor. This also means that the solution X, condition */ |
| 2918 | /* estimator RCOND, and forward error bound FERR could be */ |
| 2919 | /* unreliable. If factorization fails with 0<INFO<=N, then */ |
| 2920 | /* WORK(1) contains the reciprocal pivot growth factor for the */ |
| 2921 | /* leading INFO columns of A. */ |
| 2922 | |
| 2923 | /* IWORK (workspace) INTEGER array, dimension (N) */ |
| 2924 | |
| 2925 | /* INFO (output) INTEGER */ |
| 2926 | /* = 0: successful exit */ |
| 2927 | /* < 0: if INFO = -i, the i-th argument had an illegal value */ |
| 2928 | /* > 0: if INFO = i, and i is */ |
| 2929 | /* <= N: U(i,i) is exactly zero. The factorization */ |
| 2930 | /* has been completed, but the factor U is exactly */ |
| 2931 | /* singular, so the solution and error bounds */ |
| 2932 | /* could not be computed. RCOND = 0 is returned. */ |
| 2933 | /* = N+1: U is nonsingular, but RCOND is less than machine */ |
| 2934 | /* precision, meaning that the matrix is singular */ |
| 2935 | /* to working precision. Nevertheless, the */ |
| 2936 | /* solution and error bounds are computed because */ |
| 2937 | /* there are a number of situations where the */ |
| 2938 | /* computed solution can be more accurate than the */ |
| 2939 | /* value of RCOND would suggest. */ |
| 2940 | |
| 2941 | /* ===================================================================== */ |
| 2942 | |
| 2943 | /* .. Parameters .. */ |
| 2944 | /* .. */ |
| 2945 | /* .. Local Scalars .. */ |
| 2946 | /* .. */ |
| 2947 | /* .. External Functions .. */ |
| 2948 | /* .. */ |
| 2949 | /* .. External Subroutines .. */ |
| 2950 | /* .. */ |
| 2951 | /* .. Intrinsic Functions .. */ |
| 2952 | /* .. */ |
| 2953 | /* .. Executable Statements .. */ |
| 2954 | |
| 2955 | /* Parameter adjustments */ |
| 2956 | ab_dim1 = *ldab; |
| 2957 | ab_offset = 1 + ab_dim1; |
| 2958 | ab -= ab_offset; |
| 2959 | afb_dim1 = *ldafb; |
| 2960 | afb_offset = 1 + afb_dim1; |
| 2961 | afb -= afb_offset; |
| 2962 | --ipiv; |
| 2963 | --r__; |
| 2964 | --c__; |
| 2965 | b_dim1 = *ldb; |
| 2966 | b_offset = 1 + b_dim1; |
| 2967 | b -= b_offset; |
| 2968 | x_dim1 = *ldx; |
| 2969 | x_offset = 1 + x_dim1; |
| 2970 | x -= x_offset; |
| 2971 | --ferr; |
| 2972 | --berr; |
| 2973 | --work; |
| 2974 | --iwork; |
| 2975 | |
| 2976 | /* Function Body */ |
| 2977 | *info = 0; |
| 2978 | nofact = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(fact, "N"); |
| 2979 | equil = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(fact, "E"); |
| 2980 | notran = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(trans, "N"); |
| 2981 | if (nofact || equil) { |
| 2982 | *(unsigned char *)equed = 'N'; |
| 2983 | rowequ = false; |
| 2984 | colequ = false; |
| 2985 | } else { |
| 2986 | rowequ = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(equed, "R") || lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(equed, |
| 2987 | "B"); |
| 2988 | colequ = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(equed, "C") || lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(equed, |
| 2989 | "B"); |
| 2990 | smlnum = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("Safe minimum"); |
| 2991 | bignum = 1. / smlnum; |
| 2992 | } |
| 2993 | |
| 2994 | /* Test the input parameters. */ |
| 2995 | |
| 2996 | if (! nofact && ! equil && ! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(fact, "F")) { |
| 2997 | *info = -1; |
| 2998 | } else if (! notran && ! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(trans, "T") && ! |
| 2999 | lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(trans, "C")) { |
| 3000 | *info = -2; |
| 3001 | } else if (*n < 0) { |
| 3002 | *info = -3; |
| 3003 | } else if (*kl < 0) { |
| 3004 | *info = -4; |
| 3005 | } else if (*ku < 0) { |
| 3006 | *info = -5; |
| 3007 | } else if (*nrhs < 0) { |
| 3008 | *info = -6; |
| 3009 | } else if (*ldab < *kl + *ku + 1) { |
| 3010 | *info = -8; |
| 3011 | } else if (*ldafb < (*kl << 1) + *ku + 1) { |
| 3012 | *info = -10; |
| 3013 | } else if (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(fact, "F") && ! (rowequ || colequ |
| 3014 | || lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(equed, "N"))) { |
| 3015 | *info = -12; |
| 3016 | } else { |
| 3017 | if (rowequ) { |
| 3018 | rcmin = bignum; |
| 3019 | rcmax = 0.; |
| 3020 | i__1 = *n; |
| 3021 | for (j = 1; j <= i__1; ++j) { |
| 3022 | /* Computing MIN */ |
| 3023 | d__1 = rcmin, d__2 = r__[j]; |
| 3024 | rcmin = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(d__1,d__2); |
| 3025 | /* Computing MAX */ |
| 3026 | d__1 = rcmax, d__2 = r__[j]; |
| 3027 | rcmax = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__1,d__2); |
| 3028 | /* L10: */ |
| 3029 | } |
| 3030 | if (rcmin <= 0.) { |
| 3031 | *info = -13; |
| 3032 | } else if (*n > 0) { |
| 3033 | rowcnd = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(rcmin,smlnum) / stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(rcmax,bignum); |
| 3034 | } else { |
| 3035 | rowcnd = 1.; |
| 3036 | } |
| 3037 | } |
| 3038 | if (colequ && *info == 0) { |
| 3039 | rcmin = bignum; |
| 3040 | rcmax = 0.; |
| 3041 | i__1 = *n; |
| 3042 | for (j = 1; j <= i__1; ++j) { |
| 3043 | /* Computing MIN */ |
| 3044 | d__1 = rcmin, d__2 = c__[j]; |
| 3045 | rcmin = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(d__1,d__2); |
| 3046 | /* Computing MAX */ |
| 3047 | d__1 = rcmax, d__2 = c__[j]; |
| 3048 | rcmax = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__1,d__2); |
| 3049 | /* L20: */ |
| 3050 | } |
| 3051 | if (rcmin <= 0.) { |
| 3052 | *info = -14; |
| 3053 | } else if (*n > 0) { |
| 3054 | colcnd = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(rcmin,smlnum) / stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(rcmax,bignum); |
| 3055 | } else { |
| 3056 | colcnd = 1.; |
| 3057 | } |
| 3058 | } |
| 3059 | if (*info == 0) { |
| 3060 | if (*ldb < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 3061 | *info = -16; |
| 3062 | } else if (*ldx < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 3063 | *info = -18; |
| 3064 | } |
| 3065 | } |
| 3066 | } |
| 3067 | |
| 3068 | if (*info != 0) { |
| 3069 | i__1 = -(*info); |
| 3070 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGBSVX", &i__1); |
| 3071 | return 0; |
| 3072 | } |
| 3073 | |
| 3074 | if (equil) { |
| 3075 | |
| 3076 | /* Compute row and column scalings to equilibrate the matrix A. */ |
| 3077 | |
| 3078 | dgbequ_cxx . . $ dgbequ_(232ca6a811deebd2).(n, n, kl, ku, &ab[ab_offset], ldab, &r__[1], &c__[1], &rowcnd, |
| 3079 | &colcnd, &amax, &infequ); |
| 3080 | if (infequ == 0) { |
| 3081 | |
| 3082 | /* Equilibrate the matrix. */ |
| 3083 | |
| 3084 | dlaqgb_cxx . . $ dlaqgb_(2a4e5b51de034086).(n, n, kl, ku, &ab[ab_offset], ldab, &r__[1], &c__[1], & |
| 3085 | rowcnd, &colcnd, &amax, equed); |
| 3086 | rowequ = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(equed, "R") || lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(equed, |
| 3087 | "B"); |
| 3088 | colequ = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(equed, "C") || lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(equed, |
| 3089 | "B"); |
| 3090 | } |
| 3091 | } |
| 3092 | |
| 3093 | /* Scale the right hand side. */ |
| 3094 | |
| 3095 | if (notran) { |
| 3096 | if (rowequ) { |
| 3097 | i__1 = *nrhs; |
| 3098 | for (j = 1; j <= i__1; ++j) { |
| 3099 | i__2 = *n; |
| 3100 | for (i__ = 1; i__ <= i__2; ++i__) { |
| 3101 | b[i__ + j * b_dim1] = r__[i__] * b[i__ + j * b_dim1]; |
| 3102 | /* L30: */ |
| 3103 | } |
| 3104 | /* L40: */ |
| 3105 | } |
| 3106 | } |
| 3107 | } else if (colequ) { |
| 3108 | i__1 = *nrhs; |
| 3109 | for (j = 1; j <= i__1; ++j) { |
| 3110 | i__2 = *n; |
| 3111 | for (i__ = 1; i__ <= i__2; ++i__) { |
| 3112 | b[i__ + j * b_dim1] = c__[i__] * b[i__ + j * b_dim1]; |
| 3113 | /* L50: */ |
| 3114 | } |
| 3115 | /* L60: */ |
| 3116 | } |
| 3117 | } |
| 3118 | |
| 3119 | if (nofact || equil) { |
| 3120 | |
| 3121 | /* Compute the LU factorization of the band matrix A. */ |
| 3122 | |
| 3123 | i__1 = *n; |
| 3124 | for (j = 1; j <= i__1; ++j) { |
| 3125 | /* Computing MAX */ |
| 3126 | i__2 = j - *ku; |
| 3127 | j1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,1_integercxx . . $ `operator""_integer`(85240eb457c3721a).); |
| 3128 | /* Computing MIN */ |
| 3129 | i__2 = j + *kl; |
| 3130 | j2 = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__2,*n); |
| 3131 | i__2 = j2 - j1 + 1; |
| 3132 | dcopy_cxx . . $ dcopy_(ec261fd7ec3b6bf6).(&i__2, &ab[*ku + 1 - j + j1 + j * ab_dim1], &c__1, &afb[* |
| 3133 | kl + *ku + 1 - j + j1 + j * afb_dim1], &c__1); |
| 3134 | /* L70: */ |
| 3135 | } |
| 3136 | |
| 3137 | dgbtrf_cxx . . $ dgbtrf_(6c38e8b1f1607139).(n, n, kl, ku, &afb[afb_offset], ldafb, &ipiv[1], info); |
| 3138 | |
| 3139 | /* Return if INFO is non-zero. */ |
| 3140 | |
| 3141 | if (*info > 0) { |
| 3142 | |
| 3143 | /* Compute the reciprocal pivot growth factor of the */ |
| 3144 | /* leading rank-deficient INFO columns of A. */ |
| 3145 | |
| 3146 | anorm = 0.; |
| 3147 | i__1 = *info; |
| 3148 | for (j = 1; j <= i__1; ++j) { |
| 3149 | /* Computing MAX */ |
| 3150 | i__2 = *ku + 2 - j; |
| 3151 | /* Computing MIN */ |
| 3152 | i__4 = *n + *ku + 1 - j, i__5 = *kl + *ku + 1; |
| 3153 | i__3 = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__4,i__5); |
| 3154 | for (i__ = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,1_integercxx . . $ `operator""_integer`(85240eb457c3721a).); i__ <= i__3; ++i__) { |
| 3155 | /* Computing MAX */ |
| 3156 | d__2 = anorm, d__3 = (d__1 = ab[i__ + j * ab_dim1], abscxx . . $ abs(447c67c6676f75c3).( |
| 3157 | d__1)); |
| 3158 | anorm = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__2,d__3); |
| 3159 | /* L80: */ |
| 3160 | } |
| 3161 | /* L90: */ |
| 3162 | } |
| 3163 | /* Computing MIN */ |
| 3164 | i__3 = *info - 1, i__2 = *kl + *ku; |
| 3165 | i__1 = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__3,i__2); |
| 3166 | /* Computing MAX */ |
| 3167 | i__4 = 1, i__5 = *kl + *ku + 2 - *info; |
| 3168 | rpvgrw = dlantb_cxx . . $ dlantb_(7eea4a72e21f75ae).("M", "U", "N", info, &i__1, &afb[stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__4, i__5) |
| 3169 | + afb_dim1], ldafb, &work[1]); |
| 3170 | if (rpvgrw == 0.) { |
| 3171 | rpvgrw = 1.; |
| 3172 | } else { |
| 3173 | rpvgrw = anorm / rpvgrw; |
| 3174 | } |
| 3175 | work[1] = rpvgrw; |
| 3176 | *rcond = 0.; |
| 3177 | return 0; |
| 3178 | } |
| 3179 | } |
| 3180 | |
| 3181 | /* Compute the norm of the matrix A and the */ |
| 3182 | /* reciprocal pivot growth factor RPVGRW. */ |
| 3183 | |
| 3184 | if (notran) { |
| 3185 | *(unsigned char *)norm = '1'; |
| 3186 | } else { |
| 3187 | *(unsigned char *)norm = 'I'; |
| 3188 | } |
| 3189 | anorm = dlangb_cxx . . $ dlangb_(c1b38e6f6f58920b).(norm, n, kl, ku, &ab[ab_offset], ldab, &work[1]); |
| 3190 | i__1 = *kl + *ku; |
| 3191 | rpvgrw = dlantb_cxx . . $ dlantb_(7eea4a72e21f75ae).("M", "U", "N", n, &i__1, &afb[afb_offset], ldafb, &work[ |
| 3192 | 1]); |
| 3193 | if (rpvgrw == 0.) { |
| 3194 | rpvgrw = 1.; |
| 3195 | } else { |
| 3196 | rpvgrw = dlangb_cxx . . $ dlangb_(c1b38e6f6f58920b).("M", n, kl, ku, &ab[ab_offset], ldab, &work[1]) / rpvgrw; |
| 3197 | } |
| 3198 | |
| 3199 | /* Compute the reciprocal of the condition number of A. */ |
| 3200 | |
| 3201 | dgbcon_cxx . . $ dgbcon_(95628f5c4a095809).(norm, n, kl, ku, &afb[afb_offset], ldafb, &ipiv[1], &anorm, rcond, |
| 3202 | &work[1], &iwork[1], info); |
| 3203 | |
| 3204 | /* Compute the solution matrix X. */ |
| 3205 | |
| 3206 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("Full", n, nrhs, &b[b_offset], ldb, &x[x_offset], ldx); |
| 3207 | dgbtrs_cxx . . $ dgbtrs_(50a94af1eb812d7f).(trans, n, kl, ku, nrhs, &afb[afb_offset], ldafb, &ipiv[1], &x[ |
| 3208 | x_offset], ldx, info); |
| 3209 | |
| 3210 | /* Use iterative refinement to improve the computed solution and */ |
| 3211 | /* compute error bounds and backward error estimates for it. */ |
| 3212 | |
| 3213 | dgbrfs_cxx . . $ dgbrfs_(503411a4dcd7fef6).(trans, n, kl, ku, nrhs, &ab[ab_offset], ldab, &afb[afb_offset], |
| 3214 | ldafb, &ipiv[1], &b[b_offset], ldb, &x[x_offset], ldx, &ferr[1], & |
| 3215 | berr[1], &work[1], &iwork[1], info); |
| 3216 | |
| 3217 | /* Transform the solution matrix X to a solution of the original */ |
| 3218 | /* system. */ |
| 3219 | |
| 3220 | if (notran) { |
| 3221 | if (colequ) { |
| 3222 | i__1 = *nrhs; |
| 3223 | for (j = 1; j <= i__1; ++j) { |
| 3224 | i__3 = *n; |
| 3225 | for (i__ = 1; i__ <= i__3; ++i__) { |
| 3226 | x[i__ + j * x_dim1] = c__[i__] * x[i__ + j * x_dim1]; |
| 3227 | /* L100: */ |
| 3228 | } |
| 3229 | /* L110: */ |
| 3230 | } |
| 3231 | i__1 = *nrhs; |
| 3232 | for (j = 1; j <= i__1; ++j) { |
| 3233 | ferr[j] /= colcnd; |
| 3234 | /* L120: */ |
| 3235 | } |
| 3236 | } |
| 3237 | } else if (rowequ) { |
| 3238 | i__1 = *nrhs; |
| 3239 | for (j = 1; j <= i__1; ++j) { |
| 3240 | i__3 = *n; |
| 3241 | for (i__ = 1; i__ <= i__3; ++i__) { |
| 3242 | x[i__ + j * x_dim1] = r__[i__] * x[i__ + j * x_dim1]; |
| 3243 | /* L130: */ |
| 3244 | } |
| 3245 | /* L140: */ |
| 3246 | } |
| 3247 | i__1 = *nrhs; |
| 3248 | for (j = 1; j <= i__1; ++j) { |
| 3249 | ferr[j] /= rowcnd; |
| 3250 | /* L150: */ |
| 3251 | } |
| 3252 | } |
| 3253 | |
| 3254 | /* Set INFO = N+1 if the matrix is singular to working precision. */ |
| 3255 | |
| 3256 | if (*rcond < dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("Epsilon")) { |
| 3257 | *info = *n + 1; |
| 3258 | } |
| 3259 | |
| 3260 | work[1] = rpvgrw; |
| 3261 | return 0; |
| 3262 | |
| 3263 | /* End of DGBSVX */ |
| 3264 | |
| 3265 | } /* dgbsvx_ */ |
| 3266 | |
| 3267 | #if 0 |
| 3268 | /* Subroutine */ int dgbsvxx_(const char *fact, const char *trans, integer *n, integer * |
| 3269 | kl, integer *ku, integer *nrhs, double *ab, integer *ldab, |
| 3270 | double *afb, integer *ldafb, integer *ipiv, char *equed, |
| 3271 | double *r__, double *c__, double *b, integer *ldb, |
| 3272 | double *x, integer *ldx, double *rcond, double *rpvgrw, |
| 3273 | double *berr, integer *n_err_bnds__, double *err_bnds_norm__, |
| 3274 | double *err_bnds_comp__, integer *nparams, double *params, |
| 3275 | double *work, integer *iwork, integer *info) |
| 3276 | { |
| 3277 | /* System generated locals */ |
| 3278 | integer ab_dim1, ab_offset, afb_dim1, afb_offset, b_dim1, b_offset, |
| 3279 | x_dim1, x_offset, err_bnds_norm_dim1, err_bnds_norm_offset, |
| 3280 | err_bnds_comp_dim1, err_bnds_comp_offset, i__1, i__2; |
| 3281 | double d__1, d__2; |
| 3282 | |
| 3283 | /* Local variables */ |
| 3284 | integer i__, j; |
| 3285 | double amax; |
| 3286 | double rcmin, rcmax; |
| 3287 | bool equil; |
| 3288 | double colcnd; |
| 3289 | bool nofact; |
| 3290 | double bignum; |
| 3291 | integer infequ; |
| 3292 | bool colequ; |
| 3293 | double rowcnd; |
| 3294 | bool notran; |
| 3295 | double smlnum; |
| 3296 | bool rowequ; |
| 3297 | |
| 3298 | /* -- LAPACK driver routine (version 3.2) -- */ |
| 3299 | /* -- Contributed by James Demmel, Deaglan Halligan, Yozo Hida and -- */ |
| 3300 | /* -- Jason Riedy of Univ. of California Berkeley. -- */ |
| 3301 | /* -- November 2008 -- */ |
| 3302 | |
| 3303 | /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ |
| 3304 | /* -- Univ. of California Berkeley and NAG Ltd. -- */ |
| 3305 | |
| 3306 | /* .. */ |
| 3307 | /* .. Scalar Arguments .. */ |
| 3308 | /* .. */ |
| 3309 | /* .. Array Arguments .. */ |
| 3310 | /* .. */ |
| 3311 | |
| 3312 | /* Purpose */ |
| 3313 | /* ======= */ |
| 3314 | |
| 3315 | /* DGBSVXX uses the LU factorization to compute the solution to a */ |
| 3316 | /* double precision system of linear equations A * X = B, where A is an */ |
| 3317 | /* N-by-N matrix and X and B are N-by-NRHS matrices. */ |
| 3318 | |
| 3319 | /* If requested, both normwise and maximum componentwise error bounds */ |
| 3320 | /* are returned. DGBSVXX will return a solution with a tiny */ |
| 3321 | /* guaranteed error (O(eps) where eps is the working machine */ |
| 3322 | /* precision) unless the matrix is very ill-conditioned, in which */ |
| 3323 | /* case a warning is returned. Relevant condition numbers also are */ |
| 3324 | /* calculated and returned. */ |
| 3325 | |
| 3326 | /* DGBSVXX accepts user-provided factorizations and equilibration */ |
| 3327 | /* factors; see the definitions of the FACT and EQUED options. */ |
| 3328 | /* Solving with refinement and using a factorization from a previous */ |
| 3329 | /* DGBSVXX call will also produce a solution with either O(eps) */ |
| 3330 | /* errors or warnings, but we cannot make that claim for general */ |
| 3331 | /* user-provided factorizations and equilibration factors if they */ |
| 3332 | /* differ from what DGBSVXX would itself produce. */ |
| 3333 | |
| 3334 | /* Description */ |
| 3335 | /* =========== */ |
| 3336 | |
| 3337 | /* The following steps are performed: */ |
| 3338 | |
| 3339 | /* 1. If FACT = 'E', double precision scaling factors are computed to equilibrate */ |
| 3340 | /* the system: */ |
| 3341 | |
| 3342 | /* TRANS = 'N': diag(R)*A*diag(C) *inv(diag(C))*X = diag(R)*B */ |
| 3343 | /* TRANS = 'T': (diag(R)*A*diag(C))**T *inv(diag(R))*X = diag(C)*B */ |
| 3344 | /* TRANS = 'C': (diag(R)*A*diag(C))**H *inv(diag(R))*X = diag(C)*B */ |
| 3345 | |
| 3346 | /* Whether or not the system will be equilibrated depends on the */ |
| 3347 | /* scaling of the matrix A, but if equilibration is used, A is */ |
| 3348 | /* overwritten by diag(R)*A*diag(C) and B by diag(R)*B (if TRANS='N') */ |
| 3349 | /* or diag(C)*B (if TRANS = 'T' or 'C'). */ |
| 3350 | |
| 3351 | /* 2. If FACT = 'N' or 'E', the LU decomposition is used to factor */ |
| 3352 | /* the matrix A (after equilibration if FACT = 'E') as */ |
| 3353 | |
| 3354 | /* A = P * L * U, */ |
| 3355 | |
| 3356 | /* where P is a permutation matrix, L is a unit lower triangular */ |
| 3357 | /* matrix, and U is upper triangular. */ |
| 3358 | |
| 3359 | /* 3. If some U(i,i)=0, so that U is exactly singular, then the */ |
| 3360 | /* routine returns with INFO = i. Otherwise, the factored form of A */ |
| 3361 | /* is used to estimate the condition number of the matrix A (see */ |
| 3362 | /* argument RCOND). If the reciprocal of the condition number is less */ |
| 3363 | /* than machine precision, the routine still goes on to solve for X */ |
| 3364 | /* and compute error bounds as described below. */ |
| 3365 | |
| 3366 | /* 4. The system of equations is solved for X using the factored form */ |
| 3367 | /* of A. */ |
| 3368 | |
| 3369 | /* 5. By default (unless PARAMS(LA_LINRX_ITREF_I) is set to zero), */ |
| 3370 | /* the routine will use iterative refinement to try to get a small */ |
| 3371 | /* error and error bounds. Refinement calculates the residual to at */ |
| 3372 | /* least twice the working precision. */ |
| 3373 | |
| 3374 | /* 6. If equilibration was used, the matrix X is premultiplied by */ |
| 3375 | /* diag(C) (if TRANS = 'N') or diag(R) (if TRANS = 'T' or 'C') so */ |
| 3376 | /* that it solves the original system before equilibration. */ |
| 3377 | |
| 3378 | /* Arguments */ |
| 3379 | /* ========= */ |
| 3380 | |
| 3381 | /* Some optional parameters are bundled in the PARAMS array. These */ |
| 3382 | /* settings determine how refinement is performed, but often the */ |
| 3383 | /* defaults are acceptable. If the defaults are acceptable, users */ |
| 3384 | /* can pass NPARAMS = 0 which prevents the source code from accessing */ |
| 3385 | /* the PARAMS argument. */ |
| 3386 | |
| 3387 | /* FACT (input) CHARACTER*1 */ |
| 3388 | /* Specifies whether or not the factored form of the matrix A is */ |
| 3389 | /* supplied on entry, and if not, whether the matrix A should be */ |
| 3390 | /* equilibrated before it is factored. */ |
| 3391 | /* = 'F': On entry, AF and IPIV contain the factored form of A. */ |
| 3392 | /* If EQUED is not 'N', the matrix A has been */ |
| 3393 | /* equilibrated with scaling factors given by R and C. */ |
| 3394 | /* A, AF, and IPIV are not modified. */ |
| 3395 | /* = 'N': The matrix A will be copied to AF and factored. */ |
| 3396 | /* = 'E': The matrix A will be equilibrated if necessary, then */ |
| 3397 | /* copied to AF and factored. */ |
| 3398 | |
| 3399 | /* TRANS (input) CHARACTER*1 */ |
| 3400 | /* Specifies the form of the system of equations: */ |
| 3401 | /* = 'N': A * X = B (No transpose) */ |
| 3402 | /* = 'T': A**T * X = B (Transpose) */ |
| 3403 | /* = 'C': A**H * X = B (Conjugate Transpose = Transpose) */ |
| 3404 | |
| 3405 | /* N (input) INTEGER */ |
| 3406 | /* The number of linear equations, i.e., the order of the */ |
| 3407 | /* matrix A. N >= 0. */ |
| 3408 | |
| 3409 | /* KL (input) INTEGER */ |
| 3410 | /* The number of subdiagonals within the band of A. KL >= 0. */ |
| 3411 | |
| 3412 | /* KU (input) INTEGER */ |
| 3413 | /* The number of superdiagonals within the band of A. KU >= 0. */ |
| 3414 | |
| 3415 | /* NRHS (input) INTEGER */ |
| 3416 | /* The number of right hand sides, i.e., the number of columns */ |
| 3417 | /* of the matrices B and X. NRHS >= 0. */ |
| 3418 | |
| 3419 | /* AB (input/output) DOUBLE PRECISION array, dimension (LDAB,N) */ |
| 3420 | /* On entry, the matrix A in band storage, in rows 1 to KL+KU+1. */ |
| 3421 | /* The j-th column of A is stored in the j-th column of the */ |
| 3422 | /* array AB as follows: */ |
| 3423 | /* AB(KU+1+i-j,j) = A(i,j) for max(1,j-KU)<=i<=min(N,j+kl) */ |
| 3424 | |
| 3425 | /* If FACT = 'F' and EQUED is not 'N', then AB must have been */ |
| 3426 | /* equilibrated by the scaling factors in R and/or C. AB is not */ |
| 3427 | /* modified if FACT = 'F' or 'N', or if FACT = 'E' and */ |
| 3428 | /* EQUED = 'N' on exit. */ |
| 3429 | |
| 3430 | /* On exit, if EQUED .ne. 'N', A is scaled as follows: */ |
| 3431 | /* EQUED = 'R': A := diag(R) * A */ |
| 3432 | /* EQUED = 'C': A := A * diag(C) */ |
| 3433 | /* EQUED = 'B': A := diag(R) * A * diag(C). */ |
| 3434 | |
| 3435 | /* LDAB (input) INTEGER */ |
| 3436 | /* The leading dimension of the array AB. LDAB >= KL+KU+1. */ |
| 3437 | |
| 3438 | /* AFB (input or output) DOUBLE PRECISION array, dimension (LDAFB,N) */ |
| 3439 | /* If FACT = 'F', then AFB is an input argument and on entry */ |
| 3440 | /* contains details of the LU factorization of the band matrix */ |
| 3441 | /* A, as computed by DGBTRF. U is stored as an upper triangular */ |
| 3442 | /* band matrix with KL+KU superdiagonals in rows 1 to KL+KU+1, */ |
| 3443 | /* and the multipliers used during the factorization are stored */ |
| 3444 | /* in rows KL+KU+2 to 2*KL+KU+1. If EQUED .ne. 'N', then AFB is */ |
| 3445 | /* the factored form of the equilibrated matrix A. */ |
| 3446 | |
| 3447 | /* If FACT = 'N', then AF is an output argument and on exit */ |
| 3448 | /* returns the factors L and U from the factorization A = P*L*U */ |
| 3449 | /* of the original matrix A. */ |
| 3450 | |
| 3451 | /* If FACT = 'E', then AF is an output argument and on exit */ |
| 3452 | /* returns the factors L and U from the factorization A = P*L*U */ |
| 3453 | /* of the equilibrated matrix A (see the description of A for */ |
| 3454 | /* the form of the equilibrated matrix). */ |
| 3455 | |
| 3456 | /* LDAFB (input) INTEGER */ |
| 3457 | /* The leading dimension of the array AFB. LDAFB >= 2*KL+KU+1. */ |
| 3458 | |
| 3459 | /* IPIV (input or output) INTEGER array, dimension (N) */ |
| 3460 | /* If FACT = 'F', then IPIV is an input argument and on entry */ |
| 3461 | /* contains the pivot indices from the factorization A = P*L*U */ |
| 3462 | /* as computed by DGETRF; row i of the matrix was interchanged */ |
| 3463 | /* with row IPIV(i). */ |
| 3464 | |
| 3465 | /* If FACT = 'N', then IPIV is an output argument and on exit */ |
| 3466 | /* contains the pivot indices from the factorization A = P*L*U */ |
| 3467 | /* of the original matrix A. */ |
| 3468 | |
| 3469 | /* If FACT = 'E', then IPIV is an output argument and on exit */ |
| 3470 | /* contains the pivot indices from the factorization A = P*L*U */ |
| 3471 | /* of the equilibrated matrix A. */ |
| 3472 | |
| 3473 | /* EQUED (input or output) CHARACTER*1 */ |
| 3474 | /* Specifies the form of equilibration that was done. */ |
| 3475 | /* = 'N': No equilibration (always true if FACT = 'N'). */ |
| 3476 | /* = 'R': Row equilibration, i.e., A has been premultiplied by */ |
| 3477 | /* diag(R). */ |
| 3478 | /* = 'C': Column equilibration, i.e., A has been postmultiplied */ |
| 3479 | /* by diag(C). */ |
| 3480 | /* = 'B': Both row and column equilibration, i.e., A has been */ |
| 3481 | /* replaced by diag(R) * A * diag(C). */ |
| 3482 | /* EQUED is an input argument if FACT = 'F'; otherwise, it is an */ |
| 3483 | /* output argument. */ |
| 3484 | |
| 3485 | /* R (input or output) DOUBLE PRECISION array, dimension (N) */ |
| 3486 | /* The row scale factors for A. If EQUED = 'R' or 'B', A is */ |
| 3487 | /* multiplied on the left by diag(R); if EQUED = 'N' or 'C', R */ |
| 3488 | /* is not accessed. R is an input argument if FACT = 'F'; */ |
| 3489 | /* otherwise, R is an output argument. If FACT = 'F' and */ |
| 3490 | /* EQUED = 'R' or 'B', each element of R must be positive. */ |
| 3491 | /* If R is output, each element of R is a power of the radix. */ |
| 3492 | /* If R is input, each element of R should be a power of the radix */ |
| 3493 | /* to ensure a reliable solution and error estimates. Scaling by */ |
| 3494 | /* powers of the radix does not cause rounding errors unless the */ |
| 3495 | /* result underflows or overflows. Rounding errors during scaling */ |
| 3496 | /* lead to refining with a matrix that is not equivalent to the */ |
| 3497 | /* input matrix, producing error estimates that may not be */ |
| 3498 | /* reliable. */ |
| 3499 | |
| 3500 | /* C (input or output) DOUBLE PRECISION array, dimension (N) */ |
| 3501 | /* The column scale factors for A. If EQUED = 'C' or 'B', A is */ |
| 3502 | /* multiplied on the right by diag(C); if EQUED = 'N' or 'R', C */ |
| 3503 | /* is not accessed. C is an input argument if FACT = 'F'; */ |
| 3504 | /* otherwise, C is an output argument. If FACT = 'F' and */ |
| 3505 | /* EQUED = 'C' or 'B', each element of C must be positive. */ |
| 3506 | /* If C is output, each element of C is a power of the radix. */ |
| 3507 | /* If C is input, each element of C should be a power of the radix */ |
| 3508 | /* to ensure a reliable solution and error estimates. Scaling by */ |
| 3509 | /* powers of the radix does not cause rounding errors unless the */ |
| 3510 | /* result underflows or overflows. Rounding errors during scaling */ |
| 3511 | /* lead to refining with a matrix that is not equivalent to the */ |
| 3512 | /* input matrix, producing error estimates that may not be */ |
| 3513 | /* reliable. */ |
| 3514 | |
| 3515 | /* B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */ |
| 3516 | /* On entry, the N-by-NRHS right hand side matrix B. */ |
| 3517 | /* On exit, */ |
| 3518 | /* if EQUED = 'N', B is not modified; */ |
| 3519 | /* if TRANS = 'N' and EQUED = 'R' or 'B', B is overwritten by */ |
| 3520 | /* diag(R)*B; */ |
| 3521 | /* if TRANS = 'T' or 'C' and EQUED = 'C' or 'B', B is */ |
| 3522 | /* overwritten by diag(C)*B. */ |
| 3523 | |
| 3524 | /* LDB (input) INTEGER */ |
| 3525 | /* The leading dimension of the array B. LDB >= max(1,N). */ |
| 3526 | |
| 3527 | /* X (output) DOUBLE PRECISION array, dimension (LDX,NRHS) */ |
| 3528 | /* If INFO = 0, the N-by-NRHS solution matrix X to the original */ |
| 3529 | /* system of equations. Note that A and B are modified on exit */ |
| 3530 | /* if EQUED .ne. 'N', and the solution to the equilibrated system is */ |
| 3531 | /* inv(diag(C))*X if TRANS = 'N' and EQUED = 'C' or 'B', or */ |
| 3532 | /* inv(diag(R))*X if TRANS = 'T' or 'C' and EQUED = 'R' or 'B'. */ |
| 3533 | |
| 3534 | /* LDX (input) INTEGER */ |
| 3535 | /* The leading dimension of the array X. LDX >= max(1,N). */ |
| 3536 | |
| 3537 | /* RCOND (output) DOUBLE PRECISION */ |
| 3538 | /* Reciprocal scaled condition number. This is an estimate of the */ |
| 3539 | /* reciprocal Skeel condition number of the matrix A after */ |
| 3540 | /* equilibration (if done). If this is less than the machine */ |
| 3541 | /* precision (in particular, if it is zero), the matrix is singular */ |
| 3542 | /* to working precision. Note that the error may still be small even */ |
| 3543 | /* if this number is very small and the matrix appears ill- */ |
| 3544 | /* conditioned. */ |
| 3545 | |
| 3546 | /* RPVGRW (output) DOUBLE PRECISION */ |
| 3547 | /* Reciprocal pivot growth. On exit, this contains the reciprocal */ |
| 3548 | /* pivot growth factor norm(A)/norm(U). The "max absolute element" */ |
| 3549 | /* norm is used. If this is much less than 1, then the stability of */ |
| 3550 | /* the LU factorization of the (equilibrated) matrix A could be poor. */ |
| 3551 | /* This also means that the solution X, estimated condition numbers, */ |
| 3552 | /* and error bounds could be unreliable. If factorization fails with */ |
| 3553 | /* 0<INFO<=N, then this contains the reciprocal pivot growth factor */ |
| 3554 | /* for the leading INFO columns of A. In DGESVX, this quantity is */ |
| 3555 | /* returned in WORK(1). */ |
| 3556 | |
| 3557 | /* BERR (output) DOUBLE PRECISION array, dimension (NRHS) */ |
| 3558 | /* Componentwise relative backward error. This is the */ |
| 3559 | /* componentwise relative backward error of each solution vector X(j) */ |
| 3560 | /* (i.e., the smallest relative change in any element of A or B that */ |
| 3561 | /* makes X(j) an exact solution). */ |
| 3562 | |
| 3563 | /* N_ERR_BNDS (input) INTEGER */ |
| 3564 | /* Number of error bounds to return for each right hand side */ |
| 3565 | /* and each type (normwise or componentwise). See ERR_BNDS_NORM and */ |
| 3566 | /* ERR_BNDS_COMP below. */ |
| 3567 | |
| 3568 | /* ERR_BNDS_NORM (output) DOUBLE PRECISION array, dimension (NRHS, N_ERR_BNDS) */ |
| 3569 | /* For each right-hand side, this array contains information about */ |
| 3570 | /* various error bounds and condition numbers corresponding to the */ |
| 3571 | /* normwise relative error, which is defined as follows: */ |
| 3572 | |
| 3573 | /* Normwise relative error in the ith solution vector: */ |
| 3574 | /* max_j (abs(XTRUE(j,i) - X(j,i))) */ |
| 3575 | /* ------------------------------ */ |
| 3576 | /* max_j abs(X(j,i)) */ |
| 3577 | |
| 3578 | /* The array is indexed by the type of error information as described */ |
| 3579 | /* below. There currently are up to three pieces of information */ |
| 3580 | /* returned. */ |
| 3581 | |
| 3582 | /* The first index in ERR_BNDS_NORM(i,:) corresponds to the ith */ |
| 3583 | /* right-hand side. */ |
| 3584 | |
| 3585 | /* The second index in ERR_BNDS_NORM(:,err) contains the following */ |
| 3586 | /* three fields: */ |
| 3587 | /* err = 1 "Trust/don't trust" boolean. Trust the answer if the */ |
| 3588 | /* reciprocal condition number is less than the threshold */ |
| 3589 | /* sqrt(n) * dlamch('Epsilon'). */ |
| 3590 | |
| 3591 | /* err = 2 "Guaranteed" error bound: The estimated forward error, */ |
| 3592 | /* almost certainly within a factor of 10 of the true error */ |
| 3593 | /* so long as the next entry is greater than the threshold */ |
| 3594 | /* sqrt(n) * dlamch('Epsilon'). This error bound should only */ |
| 3595 | /* be trusted if the previous boolean is true. */ |
| 3596 | |
| 3597 | /* err = 3 Reciprocal condition number: Estimated normwise */ |
| 3598 | /* reciprocal condition number. Compared with the threshold */ |
| 3599 | /* sqrt(n) * dlamch('Epsilon') to determine if the error */ |
| 3600 | /* estimate is "guaranteed". These reciprocal condition */ |
| 3601 | /* numbers are 1 / (norm(Z^{-1},inf) * norm(Z,inf)) for some */ |
| 3602 | /* appropriately scaled matrix Z. */ |
| 3603 | /* Let Z = S*A, where S scales each row by a power of the */ |
| 3604 | /* radix so all absolute row sums of Z are approximately 1. */ |
| 3605 | |
| 3606 | /* See Lapack Working Note 165 for further details and extra */ |
| 3607 | /* cautions. */ |
| 3608 | |
| 3609 | /* ERR_BNDS_COMP (output) DOUBLE PRECISION array, dimension (NRHS, N_ERR_BNDS) */ |
| 3610 | /* For each right-hand side, this array contains information about */ |
| 3611 | /* various error bounds and condition numbers corresponding to the */ |
| 3612 | /* componentwise relative error, which is defined as follows: */ |
| 3613 | |
| 3614 | /* Componentwise relative error in the ith solution vector: */ |
| 3615 | /* abs(XTRUE(j,i) - X(j,i)) */ |
| 3616 | /* max_j ---------------------- */ |
| 3617 | /* abs(X(j,i)) */ |
| 3618 | |
| 3619 | /* The array is indexed by the right-hand side i (on which the */ |
| 3620 | /* componentwise relative error depends), and the type of error */ |
| 3621 | /* information as described below. There currently are up to three */ |
| 3622 | /* pieces of information returned for each right-hand side. If */ |
| 3623 | /* componentwise accuracy is not requested (PARAMS(3) = 0.0), then */ |
| 3624 | /* ERR_BNDS_COMP is not accessed. If N_ERR_BNDS .LT. 3, then at most */ |
| 3625 | /* the first (:,N_ERR_BNDS) entries are returned. */ |
| 3626 | |
| 3627 | /* The first index in ERR_BNDS_COMP(i,:) corresponds to the ith */ |
| 3628 | /* right-hand side. */ |
| 3629 | |
| 3630 | /* The second index in ERR_BNDS_COMP(:,err) contains the following */ |
| 3631 | /* three fields: */ |
| 3632 | /* err = 1 "Trust/don't trust" boolean. Trust the answer if the */ |
| 3633 | /* reciprocal condition number is less than the threshold */ |
| 3634 | /* sqrt(n) * dlamch('Epsilon'). */ |
| 3635 | |
| 3636 | /* err = 2 "Guaranteed" error bound: The estimated forward error, */ |
| 3637 | /* almost certainly within a factor of 10 of the true error */ |
| 3638 | /* so long as the next entry is greater than the threshold */ |
| 3639 | /* sqrt(n) * dlamch('Epsilon'). This error bound should only */ |
| 3640 | /* be trusted if the previous boolean is true. */ |
| 3641 | |
| 3642 | /* err = 3 Reciprocal condition number: Estimated componentwise */ |
| 3643 | /* reciprocal condition number. Compared with the threshold */ |
| 3644 | /* sqrt(n) * dlamch('Epsilon') to determine if the error */ |
| 3645 | /* estimate is "guaranteed". These reciprocal condition */ |
| 3646 | /* numbers are 1 / (norm(Z^{-1},inf) * norm(Z,inf)) for some */ |
| 3647 | /* appropriately scaled matrix Z. */ |
| 3648 | /* Let Z = S*(A*diag(x)), where x is the solution for the */ |
| 3649 | /* current right-hand side and S scales each row of */ |
| 3650 | /* A*diag(x) by a power of the radix so all absolute row */ |
| 3651 | /* sums of Z are approximately 1. */ |
| 3652 | |
| 3653 | /* See Lapack Working Note 165 for further details and extra */ |
| 3654 | /* cautions. */ |
| 3655 | |
| 3656 | /* NPARAMS (input) INTEGER */ |
| 3657 | /* Specifies the number of parameters set in PARAMS. If .LE. 0, the */ |
| 3658 | /* PARAMS array is never referenced and default values are used. */ |
| 3659 | |
| 3660 | /* PARAMS (input / output) DOUBLE PRECISION array, dimension NPARAMS */ |
| 3661 | /* Specifies algorithm parameters. If an entry is .LT. 0.0, then */ |
| 3662 | /* that entry will be filled with default value used for that */ |
| 3663 | /* parameter. Only positions up to NPARAMS are accessed; defaults */ |
| 3664 | /* are used for higher-numbered parameters. */ |
| 3665 | |
| 3666 | /* PARAMS(LA_LINRX_ITREF_I = 1) : Whether to perform iterative */ |
| 3667 | /* refinement or not. */ |
| 3668 | /* Default: 1.0D+0 */ |
| 3669 | /* = 0.0 : No refinement is performed, and no error bounds are */ |
| 3670 | /* computed. */ |
| 3671 | /* = 1.0 : Use the extra-precise refinement algorithm. */ |
| 3672 | /* (other values are reserved for future use) */ |
| 3673 | |
| 3674 | /* PARAMS(LA_LINRX_ITHRESH_I = 2) : Maximum number of residual */ |
| 3675 | /* computations allowed for refinement. */ |
| 3676 | /* Default: 10 */ |
| 3677 | /* Aggressive: Set to 100 to permit convergence using approximate */ |
| 3678 | /* factorizations or factorizations other than LU. If */ |
| 3679 | /* the factorization uses a technique other than */ |
| 3680 | /* Gaussian elimination, the guarantees in */ |
| 3681 | /* err_bnds_norm and err_bnds_comp may no longer be */ |
| 3682 | /* trustworthy. */ |
| 3683 | |
| 3684 | /* PARAMS(LA_LINRX_CWISE_I = 3) : Flag determining if the code */ |
| 3685 | /* will attempt to find a solution with small componentwise */ |
| 3686 | /* relative error in the double-precision algorithm. Positive */ |
| 3687 | /* is true, 0.0 is false. */ |
| 3688 | /* Default: 1.0 (attempt componentwise convergence) */ |
| 3689 | |
| 3690 | /* WORK (workspace) DOUBLE PRECISION array, dimension (4*N) */ |
| 3691 | |
| 3692 | /* IWORK (workspace) INTEGER array, dimension (N) */ |
| 3693 | |
| 3694 | /* INFO (output) INTEGER */ |
| 3695 | /* = 0: Successful exit. The solution to every right-hand side is */ |
| 3696 | /* guaranteed. */ |
| 3697 | /* < 0: If INFO = -i, the i-th argument had an illegal value */ |
| 3698 | /* > 0 and <= N: U(INFO,INFO) is exactly zero. The factorization */ |
| 3699 | /* has been completed, but the factor U is exactly singular, so */ |
| 3700 | /* the solution and error bounds could not be computed. RCOND = 0 */ |
| 3701 | /* is returned. */ |
| 3702 | /* = N+J: The solution corresponding to the Jth right-hand side is */ |
| 3703 | /* not guaranteed. The solutions corresponding to other right- */ |
| 3704 | /* hand sides K with K > J may not be guaranteed as well, but */ |
| 3705 | /* only the first such right-hand side is reported. If a small */ |
| 3706 | /* componentwise error is not requested (PARAMS(3) = 0.0) then */ |
| 3707 | /* the Jth right-hand side is the first with a normwise error */ |
| 3708 | /* bound that is not guaranteed (the smallest J such */ |
| 3709 | /* that ERR_BNDS_NORM(J,1) = 0.0). By default (PARAMS(3) = 1.0) */ |
| 3710 | /* the Jth right-hand side is the first with either a normwise or */ |
| 3711 | /* componentwise error bound that is not guaranteed (the smallest */ |
| 3712 | /* J such that either ERR_BNDS_NORM(J,1) = 0.0 or */ |
| 3713 | /* ERR_BNDS_COMP(J,1) = 0.0). See the definition of */ |
| 3714 | /* ERR_BNDS_NORM(:,1) and ERR_BNDS_COMP(:,1). To get information */ |
| 3715 | /* about all of the right-hand sides check ERR_BNDS_NORM or */ |
| 3716 | /* ERR_BNDS_COMP. */ |
| 3717 | |
| 3718 | /* ================================================================== */ |
| 3719 | |
| 3720 | /* .. Parameters .. */ |
| 3721 | /* .. */ |
| 3722 | /* .. Local Scalars .. */ |
| 3723 | /* .. */ |
| 3724 | /* .. External Functions .. */ |
| 3725 | /* .. */ |
| 3726 | /* .. External Subroutines .. */ |
| 3727 | /* .. */ |
| 3728 | /* .. Intrinsic Functions .. */ |
| 3729 | /* .. */ |
| 3730 | /* .. Executable Statements .. */ |
| 3731 | |
| 3732 | /* Parameter adjustments */ |
| 3733 | err_bnds_comp_dim1 = *nrhs; |
| 3734 | err_bnds_comp_offset = 1 + err_bnds_comp_dim1; |
| 3735 | err_bnds_comp__ -= err_bnds_comp_offset; |
| 3736 | err_bnds_norm_dim1 = *nrhs; |
| 3737 | err_bnds_norm_offset = 1 + err_bnds_norm_dim1; |
| 3738 | err_bnds_norm__ -= err_bnds_norm_offset; |
| 3739 | ab_dim1 = *ldab; |
| 3740 | ab_offset = 1 + ab_dim1; |
| 3741 | ab -= ab_offset; |
| 3742 | afb_dim1 = *ldafb; |
| 3743 | afb_offset = 1 + afb_dim1; |
| 3744 | afb -= afb_offset; |
| 3745 | --ipiv; |
| 3746 | --r__; |
| 3747 | --c__; |
| 3748 | b_dim1 = *ldb; |
| 3749 | b_offset = 1 + b_dim1; |
| 3750 | b -= b_offset; |
| 3751 | x_dim1 = *ldx; |
| 3752 | x_offset = 1 + x_dim1; |
| 3753 | x -= x_offset; |
| 3754 | --berr; |
| 3755 | --params; |
| 3756 | --work; |
| 3757 | --iwork; |
| 3758 | |
| 3759 | /* Function Body */ |
| 3760 | *info = 0; |
| 3761 | nofact = lsame_(fact, "N"); |
| 3762 | equil = lsame_(fact, "E"); |
| 3763 | notran = lsame_(trans, "N"); |
| 3764 | smlnum = dlamch_("Safe minimum"); |
| 3765 | bignum = 1. / smlnum; |
| 3766 | if (nofact || equil) { |
| 3767 | *(unsigned char *)equed = 'N'; |
| 3768 | rowequ = false; |
| 3769 | colequ = false; |
| 3770 | } else { |
| 3771 | rowequ = lsame_(equed, "R") || lsame_(equed, "B"); |
| 3772 | colequ = lsame_(equed, "C") || lsame_(equed, "B"); |
| 3773 | } |
| 3774 | |
| 3775 | /* Default is failure. If an input parameter is wrong or */ |
| 3776 | /* factorization fails, make everything look horrible. Only the */ |
| 3777 | /* pivot growth is set here, the rest is initialized in DGBRFSX. */ |
| 3778 | |
| 3779 | *rpvgrw = 0.; |
| 3780 | |
| 3781 | /* Test the input parameters. PARAMS is not tested until DGBRFSX. */ |
| 3782 | |
| 3783 | if (! nofact && ! equil && ! lsame_(fact, "F")) { |
| 3784 | *info = -1; |
| 3785 | } else if (! notran && ! lsame_(trans, "T") && ! |
| 3786 | lsame_(trans, "C")) { |
| 3787 | *info = -2; |
| 3788 | } else if (*n < 0) { |
| 3789 | *info = -3; |
| 3790 | } else if (*kl < 0) { |
| 3791 | *info = -4; |
| 3792 | } else if (*ku < 0) { |
| 3793 | *info = -5; |
| 3794 | } else if (*nrhs < 0) { |
| 3795 | *info = -6; |
| 3796 | } else if (*ldab < *kl + *ku + 1) { |
| 3797 | *info = -8; |
| 3798 | } else if (*ldafb < (*kl << 1) + *ku + 1) { |
| 3799 | *info = -10; |
| 3800 | } else if (lsame_(fact, "F") && ! (rowequ || colequ |
| 3801 | || lsame_(equed, "N"))) { |
| 3802 | *info = -12; |
| 3803 | } else { |
| 3804 | if (rowequ) { |
| 3805 | rcmin = bignum; |
| 3806 | rcmax = 0.; |
| 3807 | i__1 = *n; |
| 3808 | for (j = 1; j <= i__1; ++j) { |
| 3809 | /* Computing MIN */ |
| 3810 | d__1 = rcmin, d__2 = r__[j]; |
| 3811 | rcmin = std::min(d__1,d__2); |
| 3812 | /* Computing MAX */ |
| 3813 | d__1 = rcmax, d__2 = r__[j]; |
| 3814 | rcmax = std::max(d__1,d__2); |
| 3815 | /* L10: */ |
| 3816 | } |
| 3817 | if (rcmin <= 0.) { |
| 3818 | *info = -13; |
| 3819 | } else if (*n > 0) { |
| 3820 | rowcnd = std::max(rcmin,smlnum) / std::min(rcmax,bignum); |
| 3821 | } else { |
| 3822 | rowcnd = 1.; |
| 3823 | } |
| 3824 | } |
| 3825 | if (colequ && *info == 0) { |
| 3826 | rcmin = bignum; |
| 3827 | rcmax = 0.; |
| 3828 | i__1 = *n; |
| 3829 | for (j = 1; j <= i__1; ++j) { |
| 3830 | /* Computing MIN */ |
| 3831 | d__1 = rcmin, d__2 = c__[j]; |
| 3832 | rcmin = std::min(d__1,d__2); |
| 3833 | /* Computing MAX */ |
| 3834 | d__1 = rcmax, d__2 = c__[j]; |
| 3835 | rcmax = std::max(d__1,d__2); |
| 3836 | /* L20: */ |
| 3837 | } |
| 3838 | if (rcmin <= 0.) { |
| 3839 | *info = -14; |
| 3840 | } else if (*n > 0) { |
| 3841 | colcnd = std::max(rcmin,smlnum) / std::min(rcmax,bignum); |
| 3842 | } else { |
| 3843 | colcnd = 1.; |
| 3844 | } |
| 3845 | } |
| 3846 | if (*info == 0) { |
| 3847 | if (*ldb < std::max(1_integer,*n)) { |
| 3848 | *info = -15; |
| 3849 | } else if (*ldx < std::max(1_integer,*n)) { |
| 3850 | *info = -16; |
| 3851 | } |
| 3852 | } |
| 3853 | } |
| 3854 | |
| 3855 | if (*info != 0) { |
| 3856 | i__1 = -(*info); |
| 3857 | xerbla_("DGBSVXX", &i__1); |
| 3858 | return 0; |
| 3859 | } |
| 3860 | |
| 3861 | if (equil) { |
| 3862 | |
| 3863 | /* Compute row and column scalings to equilibrate the matrix A. */ |
| 3864 | |
| 3865 | dgbequb_(n, n, kl, ku, &ab[ab_offset], ldab, &r__[1], &c__[1], & |
| 3866 | rowcnd, &colcnd, &amax, &infequ); |
| 3867 | if (infequ == 0) { |
| 3868 | |
| 3869 | /* Equilibrate the matrix. */ |
| 3870 | |
| 3871 | dlaqgb_(n, n, kl, ku, &ab[ab_offset], ldab, &r__[1], &c__[1], & |
| 3872 | rowcnd, &colcnd, &amax, equed); |
| 3873 | rowequ = lsame_(equed, "R") || lsame_(equed, |
| 3874 | "B"); |
| 3875 | colequ = lsame_(equed, "C") || lsame_(equed, |
| 3876 | "B"); |
| 3877 | } |
| 3878 | |
| 3879 | /* If the scaling factors are not applied, set them to 1.0. */ |
| 3880 | |
| 3881 | if (! rowequ) { |
| 3882 | i__1 = *n; |
| 3883 | for (j = 1; j <= i__1; ++j) { |
| 3884 | r__[j] = 1.; |
| 3885 | } |
| 3886 | } |
| 3887 | if (! colequ) { |
| 3888 | i__1 = *n; |
| 3889 | for (j = 1; j <= i__1; ++j) { |
| 3890 | c__[j] = 1.; |
| 3891 | } |
| 3892 | } |
| 3893 | } |
| 3894 | |
| 3895 | /* Scale the right hand side. */ |
| 3896 | |
| 3897 | if (notran) { |
| 3898 | if (rowequ) { |
| 3899 | dlascl2_(n, nrhs, &r__[1], &b[b_offset], ldb); |
| 3900 | } |
| 3901 | } else { |
| 3902 | if (colequ) { |
| 3903 | dlascl2_(n, nrhs, &c__[1], &b[b_offset], ldb); |
| 3904 | } |
| 3905 | } |
| 3906 | |
| 3907 | if (nofact || equil) { |
| 3908 | |
| 3909 | /* Compute the LU factorization of A. */ |
| 3910 | |
| 3911 | i__1 = *n; |
| 3912 | for (j = 1; j <= i__1; ++j) { |
| 3913 | i__2 = (*kl << 1) + *ku + 1; |
| 3914 | for (i__ = *kl + 1; i__ <= i__2; ++i__) { |
| 3915 | afb[i__ + j * afb_dim1] = ab[i__ - *kl + j * ab_dim1]; |
| 3916 | /* L30: */ |
| 3917 | } |
| 3918 | /* L40: */ |
| 3919 | } |
| 3920 | dgbtrf_(n, n, kl, ku, &afb[afb_offset], ldafb, &ipiv[1], info); |
| 3921 | |
| 3922 | /* Return if INFO is non-zero. */ |
| 3923 | |
| 3924 | if (*info > 0) { |
| 3925 | |
| 3926 | /* Pivot in column INFO is exactly 0 */ |
| 3927 | /* Compute the reciprocal pivot growth factor of the */ |
| 3928 | /* leading rank-deficient INFO columns of A. */ |
| 3929 | |
| 3930 | *rpvgrw = dla_gbrpvgrw__(n, kl, ku, info, &ab[ab_offset], ldab, & |
| 3931 | afb[afb_offset], ldafb); |
| 3932 | return 0; |
| 3933 | } |
| 3934 | } |
| 3935 | |
| 3936 | /* Compute the reciprocal pivot growth factor RPVGRW. */ |
| 3937 | |
| 3938 | *rpvgrw = dla_gbrpvgrw__(n, kl, ku, n, &ab[ab_offset], ldab, &afb[ |
| 3939 | afb_offset], ldafb); |
| 3940 | |
| 3941 | /* Compute the solution matrix X. */ |
| 3942 | |
| 3943 | dlacpy_("Full", n, nrhs, &b[b_offset], ldb, &x[x_offset], ldx); |
| 3944 | dgbtrs_(trans, n, kl, ku, nrhs, &afb[afb_offset], ldafb, &ipiv[1], &x[ |
| 3945 | x_offset], ldx, info); |
| 3946 | |
| 3947 | /* Use iterative refinement to improve the computed solution and */ |
| 3948 | /* compute error bounds and backward error estimates for it. */ |
| 3949 | |
| 3950 | dgbrfsx_(trans, equed, n, kl, ku, nrhs, &ab[ab_offset], ldab, &afb[ |
| 3951 | afb_offset], ldafb, &ipiv[1], &r__[1], &c__[1], &b[b_offset], ldb, |
| 3952 | &x[x_offset], ldx, rcond, &berr[1], n_err_bnds__, & |
| 3953 | err_bnds_norm__[err_bnds_norm_offset], &err_bnds_comp__[ |
| 3954 | err_bnds_comp_offset], nparams, ¶ms[1], &work[1], &iwork[1], |
| 3955 | info); |
| 3956 | |
| 3957 | /* Scale solutions. */ |
| 3958 | |
| 3959 | if (colequ && notran) { |
| 3960 | dlascl2_(n, nrhs, &c__[1], &x[x_offset], ldx); |
| 3961 | } else if (rowequ && ! notran) { |
| 3962 | dlascl2_(n, nrhs, &r__[1], &x[x_offset], ldx); |
| 3963 | } |
| 3964 | |
| 3965 | return 0; |
| 3966 | |
| 3967 | /* End of DGBSVXX */ |
| 3968 | |
| 3969 | } /* dgbsvxx_ */ |
| 3970 | #endif |
| 3971 | |
| 3972 | /* Subroutine */ int dgbtf2_cxx . . $ dgbtf2_(6c38e8b1f1607139).(integercxx . . $ integer# *m, integercxx . . $ integer# *n, integercxx . . $ integer# *kl, integercxx . . $ integer# *ku, |
| 3973 | double *ab, integercxx . . $ integer# *ldab, integercxx . . $ integer# *ipiv, integercxx . . $ integer# *info) |
| 3974 | { |
| 3975 | /* Table of constant values */ |
| 3976 | static integercxx . . $ integer# c__1 = 1; |
| 3977 | static double c_b9 = -1.; |
| 3978 | |
| 3979 | /* System generated locals */ |
| 3980 | integercxx . . $ integer# ab_dim1, ab_offset, i__1, i__2, i__3, i__4; |
| 3981 | double d__1; |
| 3982 | |
| 3983 | /* Local variables */ |
| 3984 | integercxx . . $ integer# i__, j, km, jp, ju, kv; |
| 3985 | |
| 3986 | |
| 3987 | /* -- LAPACK routine (version 3.1) -- */ |
| 3988 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 3989 | /* November 2006 */ |
| 3990 | |
| 3991 | /* .. Scalar Arguments .. */ |
| 3992 | /* .. */ |
| 3993 | /* .. Array Arguments .. */ |
| 3994 | /* .. */ |
| 3995 | |
| 3996 | /* Purpose */ |
| 3997 | /* ======= */ |
| 3998 | |
| 3999 | /* DGBTF2 computes an LU factorization of a real m-by-n band matrix A */ |
| 4000 | /* using partial pivoting with row interchanges. */ |
| 4001 | |
| 4002 | /* This is the unblocked version of the algorithm, calling Level 2 BLAS. */ |
| 4003 | |
| 4004 | /* Arguments */ |
| 4005 | /* ========= */ |
| 4006 | |
| 4007 | /* M (input) INTEGER */ |
| 4008 | /* The number of rows of the matrix A. M >= 0. */ |
| 4009 | |
| 4010 | /* N (input) INTEGER */ |
| 4011 | /* The number of columns of the matrix A. N >= 0. */ |
| 4012 | |
| 4013 | /* KL (input) INTEGER */ |
| 4014 | /* The number of subdiagonals within the band of A. KL >= 0. */ |
| 4015 | |
| 4016 | /* KU (input) INTEGER */ |
| 4017 | /* The number of superdiagonals within the band of A. KU >= 0. */ |
| 4018 | |
| 4019 | /* AB (input/output) DOUBLE PRECISION array, dimension (LDAB,N) */ |
| 4020 | /* On entry, the matrix A in band storage, in rows KL+1 to */ |
| 4021 | /* 2*KL+KU+1; rows 1 to KL of the array need not be set. */ |
| 4022 | /* The j-th column of A is stored in the j-th column of the */ |
| 4023 | /* array AB as follows: */ |
| 4024 | /* AB(kl+ku+1+i-j,j) = A(i,j) for max(1,j-ku)<=i<=min(m,j+kl) */ |
| 4025 | |
| 4026 | /* On exit, details of the factorization: U is stored as an */ |
| 4027 | /* upper triangular band matrix with KL+KU superdiagonals in */ |
| 4028 | /* rows 1 to KL+KU+1, and the multipliers used during the */ |
| 4029 | /* factorization are stored in rows KL+KU+2 to 2*KL+KU+1. */ |
| 4030 | /* See below for further details. */ |
| 4031 | |
| 4032 | /* LDAB (input) INTEGER */ |
| 4033 | /* The leading dimension of the array AB. LDAB >= 2*KL+KU+1. */ |
| 4034 | |
| 4035 | /* IPIV (output) INTEGER array, dimension (min(M,N)) */ |
| 4036 | /* The pivot indices; for 1 <= i <= min(M,N), row i of the */ |
| 4037 | /* matrix was interchanged with row IPIV(i). */ |
| 4038 | |
| 4039 | /* INFO (output) INTEGER */ |
| 4040 | /* = 0: successful exit */ |
| 4041 | /* < 0: if INFO = -i, the i-th argument had an illegal value */ |
| 4042 | /* > 0: if INFO = +i, U(i,i) is exactly zero. The factorization */ |
| 4043 | /* has been completed, but the factor U is exactly */ |
| 4044 | /* singular, and division by zero will occur if it is used */ |
| 4045 | /* to solve a system of equations. */ |
| 4046 | |
| 4047 | /* Further Details */ |
| 4048 | /* =============== */ |
| 4049 | |
| 4050 | /* The band storage scheme is illustrated by the following example, when */ |
| 4051 | /* M = N = 6, KL = 2, KU = 1: */ |
| 4052 | |
| 4053 | /* On entry: On exit: */ |
| 4054 | |
| 4055 | /* * * * + + + * * * u14 u25 u36 */ |
| 4056 | /* * * + + + + * * u13 u24 u35 u46 */ |
| 4057 | /* * a12 a23 a34 a45 a56 * u12 u23 u34 u45 u56 */ |
| 4058 | /* a11 a22 a33 a44 a55 a66 u11 u22 u33 u44 u55 u66 */ |
| 4059 | /* a21 a32 a43 a54 a65 * m21 m32 m43 m54 m65 * */ |
| 4060 | /* a31 a42 a53 a64 * * m31 m42 m53 m64 * * */ |
| 4061 | |
| 4062 | /* Array elements marked * are not used by the routine; elements marked */ |
| 4063 | /* + need not be set on entry, but are required by the routine to store */ |
| 4064 | /* elements of U, because of fill-in resulting from the row */ |
| 4065 | /* interchanges. */ |
| 4066 | |
| 4067 | /* ===================================================================== */ |
| 4068 | |
| 4069 | /* .. Parameters .. */ |
| 4070 | /* .. */ |
| 4071 | /* .. Local Scalars .. */ |
| 4072 | /* .. */ |
| 4073 | /* .. External Functions .. */ |
| 4074 | /* .. */ |
| 4075 | /* .. External Subroutines .. */ |
| 4076 | /* .. */ |
| 4077 | /* .. Intrinsic Functions .. */ |
| 4078 | /* .. */ |
| 4079 | /* .. Executable Statements .. */ |
| 4080 | |
| 4081 | /* KV is the number of superdiagonals in the factor U, allowing for */ |
| 4082 | /* fill-in. */ |
| 4083 | |
| 4084 | /* Parameter adjustments */ |
| 4085 | ab_dim1 = *ldab; |
| 4086 | ab_offset = 1 + ab_dim1; |
| 4087 | ab -= ab_offset; |
| 4088 | --ipiv; |
| 4089 | |
| 4090 | /* Function Body */ |
| 4091 | kv = *ku + *kl; |
| 4092 | |
| 4093 | /* Test the input parameters. */ |
| 4094 | |
| 4095 | *info = 0; |
| 4096 | if (*m < 0) { |
| 4097 | *info = -1; |
| 4098 | } else if (*n < 0) { |
| 4099 | *info = -2; |
| 4100 | } else if (*kl < 0) { |
| 4101 | *info = -3; |
| 4102 | } else if (*ku < 0) { |
| 4103 | *info = -4; |
| 4104 | } else if (*ldab < *kl + kv + 1) { |
| 4105 | *info = -6; |
| 4106 | } |
| 4107 | if (*info != 0) { |
| 4108 | i__1 = -(*info); |
| 4109 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGBTF2", &i__1); |
| 4110 | return 0; |
| 4111 | } |
| 4112 | |
| 4113 | /* Quick return if possible */ |
| 4114 | |
| 4115 | if (*m == 0 || *n == 0) { |
| 4116 | return 0; |
| 4117 | } |
| 4118 | |
| 4119 | /* Gaussian elimination with partial pivoting */ |
| 4120 | |
| 4121 | /* Set fill-in elements in columns KU+2 to KV to zero. */ |
| 4122 | |
| 4123 | i__1 = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(kv,*n); |
| 4124 | for (j = *ku + 2; j <= i__1; ++j) { |
| 4125 | i__2 = *kl; |
| 4126 | for (i__ = kv - j + 2; i__ <= i__2; ++i__) { |
| 4127 | ab[i__ + j * ab_dim1] = 0.; |
| 4128 | /* L10: */ |
| 4129 | } |
| 4130 | /* L20: */ |
| 4131 | } |
| 4132 | |
| 4133 | /* JU is the index of the last column affected by the current stage */ |
| 4134 | /* of the factorization. */ |
| 4135 | |
| 4136 | ju = 1; |
| 4137 | |
| 4138 | i__1 = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(*m,*n); |
| 4139 | for (j = 1; j <= i__1; ++j) { |
| 4140 | |
| 4141 | /* Set fill-in elements in column J+KV to zero. */ |
| 4142 | |
| 4143 | if (j + kv <= *n) { |
| 4144 | i__2 = *kl; |
| 4145 | for (i__ = 1; i__ <= i__2; ++i__) { |
| 4146 | ab[i__ + (j + kv) * ab_dim1] = 0.; |
| 4147 | /* L30: */ |
| 4148 | } |
| 4149 | } |
| 4150 | |
| 4151 | /* Find pivot and test for singularity. KM is the number of */ |
| 4152 | /* subdiagonal elements in the current column. */ |
| 4153 | |
| 4154 | /* Computing MIN */ |
| 4155 | i__2 = *kl, i__3 = *m - j; |
| 4156 | km = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__2,i__3); |
| 4157 | i__2 = km + 1; |
| 4158 | jp = idamax_cxx . . $ idamax_(a5c31fbfbc00ee45).(&i__2, &ab[kv + 1 + j * ab_dim1], &c__1); |
| 4159 | ipiv[j] = jp + j - 1; |
| 4160 | if (ab[kv + jp + j * ab_dim1] != 0.) { |
| 4161 | /* Computing MAX */ |
| 4162 | /* Computing MIN */ |
| 4163 | i__4 = j + *ku + jp - 1; |
| 4164 | i__2 = ju, i__3 = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__4,*n); |
| 4165 | ju = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 4166 | |
| 4167 | /* Apply interchange to columns J to JU. */ |
| 4168 | |
| 4169 | if (jp != 1) { |
| 4170 | i__2 = ju - j + 1; |
| 4171 | i__3 = *ldab - 1; |
| 4172 | i__4 = *ldab - 1; |
| 4173 | dswap_cxx . . $ dswap_(ec261fd7ec3b6bf6).(&i__2, &ab[kv + jp + j * ab_dim1], &i__3, &ab[kv + 1 + |
| 4174 | j * ab_dim1], &i__4); |
| 4175 | } |
| 4176 | |
| 4177 | if (km > 0) { |
| 4178 | |
| 4179 | /* Compute multipliers. */ |
| 4180 | |
| 4181 | d__1 = 1. / ab[kv + 1 + j * ab_dim1]; |
| 4182 | dscal_cxx . . $ dscal_(f22c1db71784c345).(&km, &d__1, &ab[kv + 2 + j * ab_dim1], &c__1); |
| 4183 | |
| 4184 | /* Update trailing submatrix within the band. */ |
| 4185 | |
| 4186 | if (ju > j) { |
| 4187 | i__2 = ju - j; |
| 4188 | i__3 = *ldab - 1; |
| 4189 | i__4 = *ldab - 1; |
| 4190 | dger_cxx . . $ dger_(655ac4c2f34f763a).(&km, &i__2, &c_b9, &ab[kv + 2 + j * ab_dim1], &c__1, |
| 4191 | &ab[kv + (j + 1) * ab_dim1], &i__3, &ab[kv + 1 + |
| 4192 | (j + 1) * ab_dim1], &i__4); |
| 4193 | } |
| 4194 | } |
| 4195 | } else { |
| 4196 | |
| 4197 | /* If pivot is zero, set INFO to the index of the pivot */ |
| 4198 | /* unless a zero pivot has already been found. */ |
| 4199 | |
| 4200 | if (*info == 0) { |
| 4201 | *info = j; |
| 4202 | } |
| 4203 | } |
| 4204 | /* L40: */ |
| 4205 | } |
| 4206 | return 0; |
| 4207 | |
| 4208 | /* End of DGBTF2 */ |
| 4209 | |
| 4210 | } /* dgbtf2_ */ |
| 4211 | |
| 4212 | /* Subroutine */ int dgbtrf_cxx . . $ dgbtrf_(6c38e8b1f1607139).(integercxx . . $ integer# *m, integercxx . . $ integer# *n, integercxx . . $ integer# *kl, integercxx . . $ integer# *ku, |
| 4213 | double *ab, integercxx . . $ integer# *ldab, integercxx . . $ integer# *ipiv, integercxx . . $ integer# *info) |
| 4214 | { |
| 4215 | /* Table of constant values */ |
| 4216 | static integercxx . . $ integer# c__1 = 1; |
| 4217 | static integercxx . . $ integer# c__65 = 65; |
| 4218 | static double c_b18 = -1.; |
| 4219 | static double c_b31 = 1.; |
| 4220 | |
| 4221 | /* System generated locals */ |
| 4222 | integercxx . . $ integer# ab_dim1, ab_offset, i__1, i__2, i__3, i__4, i__5, i__6; |
| 4223 | double d__1; |
| 4224 | |
| 4225 | /* Local variables */ |
| 4226 | integercxx . . $ integer# i__, j, i2, i3, j2, j3, k2, jb, nb, ii, jj, jm, ip, jp, km, ju, |
| 4227 | kv, nw; |
| 4228 | double temp; |
| 4229 | double work13[4160] /* was [65][64] */, work31[4160] /* |
| 4230 | was [65][64] */; |
| 4231 | |
| 4232 | /* -- LAPACK routine (version 3.1) -- */ |
| 4233 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 4234 | /* November 2006 */ |
| 4235 | |
| 4236 | /* .. Scalar Arguments .. */ |
| 4237 | /* .. */ |
| 4238 | /* .. Array Arguments .. */ |
| 4239 | /* .. */ |
| 4240 | |
| 4241 | /* Purpose */ |
| 4242 | /* ======= */ |
| 4243 | |
| 4244 | /* DGBTRF computes an LU factorization of a real m-by-n band matrix A */ |
| 4245 | /* using partial pivoting with row interchanges. */ |
| 4246 | |
| 4247 | /* This is the blocked version of the algorithm, calling Level 3 BLAS. */ |
| 4248 | |
| 4249 | /* Arguments */ |
| 4250 | /* ========= */ |
| 4251 | |
| 4252 | /* M (input) INTEGER */ |
| 4253 | /* The number of rows of the matrix A. M >= 0. */ |
| 4254 | |
| 4255 | /* N (input) INTEGER */ |
| 4256 | /* The number of columns of the matrix A. N >= 0. */ |
| 4257 | |
| 4258 | /* KL (input) INTEGER */ |
| 4259 | /* The number of subdiagonals within the band of A. KL >= 0. */ |
| 4260 | |
| 4261 | /* KU (input) INTEGER */ |
| 4262 | /* The number of superdiagonals within the band of A. KU >= 0. */ |
| 4263 | |
| 4264 | /* AB (input/output) DOUBLE PRECISION array, dimension (LDAB,N) */ |
| 4265 | /* On entry, the matrix A in band storage, in rows KL+1 to */ |
| 4266 | /* 2*KL+KU+1; rows 1 to KL of the array need not be set. */ |
| 4267 | /* The j-th column of A is stored in the j-th column of the */ |
| 4268 | /* array AB as follows: */ |
| 4269 | /* AB(kl+ku+1+i-j,j) = A(i,j) for max(1,j-ku)<=i<=min(m,j+kl) */ |
| 4270 | |
| 4271 | /* On exit, details of the factorization: U is stored as an */ |
| 4272 | /* upper triangular band matrix with KL+KU superdiagonals in */ |
| 4273 | /* rows 1 to KL+KU+1, and the multipliers used during the */ |
| 4274 | /* factorization are stored in rows KL+KU+2 to 2*KL+KU+1. */ |
| 4275 | /* See below for further details. */ |
| 4276 | |
| 4277 | /* LDAB (input) INTEGER */ |
| 4278 | /* The leading dimension of the array AB. LDAB >= 2*KL+KU+1. */ |
| 4279 | |
| 4280 | /* IPIV (output) INTEGER array, dimension (min(M,N)) */ |
| 4281 | /* The pivot indices; for 1 <= i <= min(M,N), row i of the */ |
| 4282 | /* matrix was interchanged with row IPIV(i). */ |
| 4283 | |
| 4284 | /* INFO (output) INTEGER */ |
| 4285 | /* = 0: successful exit */ |
| 4286 | /* < 0: if INFO = -i, the i-th argument had an illegal value */ |
| 4287 | /* > 0: if INFO = +i, U(i,i) is exactly zero. The factorization */ |
| 4288 | /* has been completed, but the factor U is exactly */ |
| 4289 | /* singular, and division by zero will occur if it is used */ |
| 4290 | /* to solve a system of equations. */ |
| 4291 | |
| 4292 | /* Further Details */ |
| 4293 | /* =============== */ |
| 4294 | |
| 4295 | /* The band storage scheme is illustrated by the following example, when */ |
| 4296 | /* M = N = 6, KL = 2, KU = 1: */ |
| 4297 | |
| 4298 | /* On entry: On exit: */ |
| 4299 | |
| 4300 | /* * * * + + + * * * u14 u25 u36 */ |
| 4301 | /* * * + + + + * * u13 u24 u35 u46 */ |
| 4302 | /* * a12 a23 a34 a45 a56 * u12 u23 u34 u45 u56 */ |
| 4303 | /* a11 a22 a33 a44 a55 a66 u11 u22 u33 u44 u55 u66 */ |
| 4304 | /* a21 a32 a43 a54 a65 * m21 m32 m43 m54 m65 * */ |
| 4305 | /* a31 a42 a53 a64 * * m31 m42 m53 m64 * * */ |
| 4306 | |
| 4307 | /* Array elements marked * are not used by the routine; elements marked */ |
| 4308 | /* + need not be set on entry, but are required by the routine to store */ |
| 4309 | /* elements of U because of fill-in resulting from the row interchanges. */ |
| 4310 | |
| 4311 | /* ===================================================================== */ |
| 4312 | |
| 4313 | /* .. Parameters .. */ |
| 4314 | /* .. */ |
| 4315 | /* .. Local Scalars .. */ |
| 4316 | /* .. */ |
| 4317 | /* .. Local Arrays .. */ |
| 4318 | /* .. */ |
| 4319 | /* .. External Functions .. */ |
| 4320 | /* .. */ |
| 4321 | /* .. External Subroutines .. */ |
| 4322 | /* .. */ |
| 4323 | /* .. Intrinsic Functions .. */ |
| 4324 | /* .. */ |
| 4325 | /* .. Executable Statements .. */ |
| 4326 | |
| 4327 | /* KV is the number of superdiagonals in the factor U, allowing for */ |
| 4328 | /* fill-in */ |
| 4329 | |
| 4330 | /* Parameter adjustments */ |
| 4331 | ab_dim1 = *ldab; |
| 4332 | ab_offset = 1 + ab_dim1; |
| 4333 | ab -= ab_offset; |
| 4334 | --ipiv; |
| 4335 | |
| 4336 | /* Function Body */ |
| 4337 | kv = *ku + *kl; |
| 4338 | |
| 4339 | /* Test the input parameters. */ |
| 4340 | |
| 4341 | *info = 0; |
| 4342 | if (*m < 0) { |
| 4343 | *info = -1; |
| 4344 | } else if (*n < 0) { |
| 4345 | *info = -2; |
| 4346 | } else if (*kl < 0) { |
| 4347 | *info = -3; |
| 4348 | } else if (*ku < 0) { |
| 4349 | *info = -4; |
| 4350 | } else if (*ldab < *kl + kv + 1) { |
| 4351 | *info = -6; |
| 4352 | } |
| 4353 | if (*info != 0) { |
| 4354 | i__1 = -(*info); |
| 4355 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGBTRF", &i__1); |
| 4356 | return 0; |
| 4357 | } |
| 4358 | |
| 4359 | /* Quick return if possible */ |
| 4360 | |
| 4361 | if (*m == 0 || *n == 0) { |
| 4362 | return 0; |
| 4363 | } |
| 4364 | |
| 4365 | /* Determine the block size for this environment */ |
| 4366 | |
| 4367 | nb = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGBTRF", " ", m, n, kl, ku); |
| 4368 | |
| 4369 | /* The block size must not exceed the limit set by the size of the */ |
| 4370 | /* local arrays WORK13 and WORK31. */ |
| 4371 | |
| 4372 | nb = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(nb,64_integercxx . . $ `operator""_integer`(85240eb457c3721a).); |
| 4373 | |
| 4374 | if (nb <= 1 || nb > *kl) { |
| 4375 | |
| 4376 | /* Use unblocked code */ |
| 4377 | |
| 4378 | dgbtf2_cxx . . $ dgbtf2_(6c38e8b1f1607139).(m, n, kl, ku, &ab[ab_offset], ldab, &ipiv[1], info); |
| 4379 | } else { |
| 4380 | |
| 4381 | /* Use blocked code */ |
| 4382 | |
| 4383 | /* Zero the superdiagonal elements of the work array WORK13 */ |
| 4384 | |
| 4385 | i__1 = nb; |
| 4386 | for (j = 1; j <= i__1; ++j) { |
| 4387 | i__2 = j - 1; |
| 4388 | for (i__ = 1; i__ <= i__2; ++i__) { |
| 4389 | work13[i__ + j * 65 - 66] = 0.; |
| 4390 | /* L10: */ |
| 4391 | } |
| 4392 | /* L20: */ |
| 4393 | } |
| 4394 | |
| 4395 | /* Zero the subdiagonal elements of the work array WORK31 */ |
| 4396 | |
| 4397 | i__1 = nb; |
| 4398 | for (j = 1; j <= i__1; ++j) { |
| 4399 | i__2 = nb; |
| 4400 | for (i__ = j + 1; i__ <= i__2; ++i__) { |
| 4401 | work31[i__ + j * 65 - 66] = 0.; |
| 4402 | /* L30: */ |
| 4403 | } |
| 4404 | /* L40: */ |
| 4405 | } |
| 4406 | |
| 4407 | /* Gaussian elimination with partial pivoting */ |
| 4408 | |
| 4409 | /* Set fill-in elements in columns KU+2 to KV to zero */ |
| 4410 | |
| 4411 | i__1 = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(kv,*n); |
| 4412 | for (j = *ku + 2; j <= i__1; ++j) { |
| 4413 | i__2 = *kl; |
| 4414 | for (i__ = kv - j + 2; i__ <= i__2; ++i__) { |
| 4415 | ab[i__ + j * ab_dim1] = 0.; |
| 4416 | /* L50: */ |
| 4417 | } |
| 4418 | /* L60: */ |
| 4419 | } |
| 4420 | |
| 4421 | /* JU is the index of the last column affected by the current */ |
| 4422 | /* stage of the factorization */ |
| 4423 | |
| 4424 | ju = 1; |
| 4425 | |
| 4426 | i__1 = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(*m,*n); |
| 4427 | i__2 = nb; |
| 4428 | for (j = 1; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) { |
| 4429 | /* Computing MIN */ |
| 4430 | i__3 = nb, i__4 = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(*m,*n) - j + 1; |
| 4431 | jb = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__3,i__4); |
| 4432 | |
| 4433 | /* The active part of the matrix is partitioned */ |
| 4434 | |
| 4435 | /* A11 A12 A13 */ |
| 4436 | /* A21 A22 A23 */ |
| 4437 | /* A31 A32 A33 */ |
| 4438 | |
| 4439 | /* Here A11, A21 and A31 denote the current block of JB columns */ |
| 4440 | /* which is about to be factorized. The number of rows in the */ |
| 4441 | /* partitioning are JB, I2, I3 respectively, and the numbers */ |
| 4442 | /* of columns are JB, J2, J3. The superdiagonal elements of A13 */ |
| 4443 | /* and the subdiagonal elements of A31 lie outside the band. */ |
| 4444 | |
| 4445 | /* Computing MIN */ |
| 4446 | i__3 = *kl - jb, i__4 = *m - j - jb + 1; |
| 4447 | i2 = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__3,i__4); |
| 4448 | /* Computing MIN */ |
| 4449 | i__3 = jb, i__4 = *m - j - *kl + 1; |
| 4450 | i3 = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__3,i__4); |
| 4451 | |
| 4452 | /* J2 and J3 are computed after JU has been updated. */ |
| 4453 | |
| 4454 | /* Factorize the current block of JB columns */ |
| 4455 | |
| 4456 | i__3 = j + jb - 1; |
| 4457 | for (jj = j; jj <= i__3; ++jj) { |
| 4458 | |
| 4459 | /* Set fill-in elements in column JJ+KV to zero */ |
| 4460 | |
| 4461 | if (jj + kv <= *n) { |
| 4462 | i__4 = *kl; |
| 4463 | for (i__ = 1; i__ <= i__4; ++i__) { |
| 4464 | ab[i__ + (jj + kv) * ab_dim1] = 0.; |
| 4465 | /* L70: */ |
| 4466 | } |
| 4467 | } |
| 4468 | |
| 4469 | /* Find pivot and test for singularity. KM is the number of */ |
| 4470 | /* subdiagonal elements in the current column. */ |
| 4471 | |
| 4472 | /* Computing MIN */ |
| 4473 | i__4 = *kl, i__5 = *m - jj; |
| 4474 | km = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__4,i__5); |
| 4475 | i__4 = km + 1; |
| 4476 | jp = idamax_cxx . . $ idamax_(a5c31fbfbc00ee45).(&i__4, &ab[kv + 1 + jj * ab_dim1], &c__1); |
| 4477 | ipiv[jj] = jp + jj - j; |
| 4478 | if (ab[kv + jp + jj * ab_dim1] != 0.) { |
| 4479 | /* Computing MAX */ |
| 4480 | /* Computing MIN */ |
| 4481 | i__6 = jj + *ku + jp - 1; |
| 4482 | i__4 = ju, i__5 = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__6,*n); |
| 4483 | ju = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__4,i__5); |
| 4484 | if (jp != 1) { |
| 4485 | |
| 4486 | /* Apply interchange to columns J to J+JB-1 */ |
| 4487 | |
| 4488 | if (jp + jj - 1 < j + *kl) { |
| 4489 | |
| 4490 | i__4 = *ldab - 1; |
| 4491 | i__5 = *ldab - 1; |
| 4492 | dswap_cxx . . $ dswap_(ec261fd7ec3b6bf6).(&jb, &ab[kv + 1 + jj - j + j * ab_dim1], & |
| 4493 | i__4, &ab[kv + jp + jj - j + j * ab_dim1], |
| 4494 | &i__5); |
| 4495 | } else { |
| 4496 | |
| 4497 | /* The interchange affects columns J to JJ-1 of A31 */ |
| 4498 | /* which are stored in the work array WORK31 */ |
| 4499 | |
| 4500 | i__4 = jj - j; |
| 4501 | i__5 = *ldab - 1; |
| 4502 | dswap_cxx . . $ dswap_(ec261fd7ec3b6bf6).(&i__4, &ab[kv + 1 + jj - j + j * ab_dim1], |
| 4503 | &i__5, &work31[jp + jj - j - *kl - 1], & |
| 4504 | c__65); |
| 4505 | i__4 = j + jb - jj; |
| 4506 | i__5 = *ldab - 1; |
| 4507 | i__6 = *ldab - 1; |
| 4508 | dswap_cxx . . $ dswap_(ec261fd7ec3b6bf6).(&i__4, &ab[kv + 1 + jj * ab_dim1], &i__5, & |
| 4509 | ab[kv + jp + jj * ab_dim1], &i__6); |
| 4510 | } |
| 4511 | } |
| 4512 | |
| 4513 | /* Compute multipliers */ |
| 4514 | |
| 4515 | d__1 = 1. / ab[kv + 1 + jj * ab_dim1]; |
| 4516 | dscal_cxx . . $ dscal_(f22c1db71784c345).(&km, &d__1, &ab[kv + 2 + jj * ab_dim1], &c__1); |
| 4517 | |
| 4518 | /* Update trailing submatrix within the band and within */ |
| 4519 | /* the current block. JM is the index of the last column */ |
| 4520 | /* which needs to be updated. */ |
| 4521 | |
| 4522 | /* Computing MIN */ |
| 4523 | i__4 = ju, i__5 = j + jb - 1; |
| 4524 | jm = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__4,i__5); |
| 4525 | if (jm > jj) { |
| 4526 | i__4 = jm - jj; |
| 4527 | i__5 = *ldab - 1; |
| 4528 | i__6 = *ldab - 1; |
| 4529 | dger_cxx . . $ dger_(655ac4c2f34f763a).(&km, &i__4, &c_b18, &ab[kv + 2 + jj * ab_dim1], |
| 4530 | &c__1, &ab[kv + (jj + 1) * ab_dim1], &i__5, & |
| 4531 | ab[kv + 1 + (jj + 1) * ab_dim1], &i__6); |
| 4532 | } |
| 4533 | } else { |
| 4534 | |
| 4535 | /* If pivot is zero, set INFO to the index of the pivot */ |
| 4536 | /* unless a zero pivot has already been found. */ |
| 4537 | |
| 4538 | if (*info == 0) { |
| 4539 | *info = jj; |
| 4540 | } |
| 4541 | } |
| 4542 | |
| 4543 | /* Copy current column of A31 into the work array WORK31 */ |
| 4544 | |
| 4545 | /* Computing MIN */ |
| 4546 | i__4 = jj - j + 1; |
| 4547 | nw = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__4,i3); |
| 4548 | if (nw > 0) { |
| 4549 | dcopy_cxx . . $ dcopy_(ec261fd7ec3b6bf6).(&nw, &ab[kv + *kl + 1 - jj + j + jj * ab_dim1], & |
| 4550 | c__1, &work31[(jj - j + 1) * 65 - 65], &c__1); |
| 4551 | } |
| 4552 | /* L80: */ |
| 4553 | } |
| 4554 | if (j + jb <= *n) { |
| 4555 | |
| 4556 | /* Apply the row interchanges to the other blocks. */ |
| 4557 | |
| 4558 | /* Computing MIN */ |
| 4559 | i__3 = ju - j + 1; |
| 4560 | j2 = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__3,kv) - jb; |
| 4561 | /* Computing MAX */ |
| 4562 | i__3 = 0, i__4 = ju - j - kv + 1; |
| 4563 | j3 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__3,i__4); |
| 4564 | |
| 4565 | /* Use DLASWP to apply the row interchanges to A12, A22, and */ |
| 4566 | /* A32. */ |
| 4567 | |
| 4568 | i__3 = *ldab - 1; |
| 4569 | dlaswp_cxx . . $ dlaswp_(fd840d72c89a956b).(&j2, &ab[kv + 1 - jb + (j + jb) * ab_dim1], &i__3, & |
| 4570 | c__1, &jb, &ipiv[j], &c__1); |
| 4571 | |
| 4572 | /* Adjust the pivot indices. */ |
| 4573 | |
| 4574 | i__3 = j + jb - 1; |
| 4575 | for (i__ = j; i__ <= i__3; ++i__) { |
| 4576 | ipiv[i__] = ipiv[i__] + j - 1; |
| 4577 | /* L90: */ |
| 4578 | } |
| 4579 | |
| 4580 | /* Apply the row interchanges to A13, A23, and A33 */ |
| 4581 | /* columnwise. */ |
| 4582 | |
| 4583 | k2 = j - 1 + jb + j2; |
| 4584 | i__3 = j3; |
| 4585 | for (i__ = 1; i__ <= i__3; ++i__) { |
| 4586 | jj = k2 + i__; |
| 4587 | i__4 = j + jb - 1; |
| 4588 | for (ii = j + i__ - 1; ii <= i__4; ++ii) { |
| 4589 | ip = ipiv[ii]; |
| 4590 | if (ip != ii) { |
| 4591 | temp = ab[kv + 1 + ii - jj + jj * ab_dim1]; |
| 4592 | ab[kv + 1 + ii - jj + jj * ab_dim1] = ab[kv + 1 + |
| 4593 | ip - jj + jj * ab_dim1]; |
| 4594 | ab[kv + 1 + ip - jj + jj * ab_dim1] = temp; |
| 4595 | } |
| 4596 | /* L100: */ |
| 4597 | } |
| 4598 | /* L110: */ |
| 4599 | } |
| 4600 | |
| 4601 | /* Update the relevant part of the trailing submatrix */ |
| 4602 | |
| 4603 | if (j2 > 0) { |
| 4604 | |
| 4605 | /* Update A12 */ |
| 4606 | |
| 4607 | i__3 = *ldab - 1; |
| 4608 | i__4 = *ldab - 1; |
| 4609 | dtrsm_cxx . . $ dtrsm_(47bcf6c639067e06).("Left", "Lower", "No transpose", "Unit", &jb, &j2, |
| 4610 | &c_b31, &ab[kv + 1 + j * ab_dim1], &i__3, &ab[kv |
| 4611 | + 1 - jb + (j + jb) * ab_dim1], &i__4); |
| 4612 | |
| 4613 | if (i2 > 0) { |
| 4614 | |
| 4615 | /* Update A22 */ |
| 4616 | |
| 4617 | i__3 = *ldab - 1; |
| 4618 | i__4 = *ldab - 1; |
| 4619 | i__5 = *ldab - 1; |
| 4620 | dgemm_cxx . . $ dgemm_(7f9a15c7502022ea).("No transpose", "No transpose", &i2, &j2, &jb, |
| 4621 | &c_b18, &ab[kv + 1 + jb + j * ab_dim1], &i__3, |
| 4622 | &ab[kv + 1 - jb + (j + jb) * ab_dim1], &i__4, |
| 4623 | &c_b31, &ab[kv + 1 + (j + jb) * ab_dim1], & |
| 4624 | i__5); |
| 4625 | } |
| 4626 | |
| 4627 | if (i3 > 0) { |
| 4628 | |
| 4629 | /* Update A32 */ |
| 4630 | |
| 4631 | i__3 = *ldab - 1; |
| 4632 | i__4 = *ldab - 1; |
| 4633 | dgemm_cxx . . $ dgemm_(7f9a15c7502022ea).("No transpose", "No transpose", &i3, &j2, &jb, |
| 4634 | &c_b18, work31, &c__65, &ab[kv + 1 - jb + (j |
| 4635 | + jb) * ab_dim1], &i__3, &c_b31, &ab[kv + *kl |
| 4636 | + 1 - jb + (j + jb) * ab_dim1], &i__4); |
| 4637 | } |
| 4638 | } |
| 4639 | |
| 4640 | if (j3 > 0) { |
| 4641 | |
| 4642 | /* Copy the lower triangle of A13 into the work array */ |
| 4643 | /* WORK13 */ |
| 4644 | |
| 4645 | i__3 = j3; |
| 4646 | for (jj = 1; jj <= i__3; ++jj) { |
| 4647 | i__4 = jb; |
| 4648 | for (ii = jj; ii <= i__4; ++ii) { |
| 4649 | work13[ii + jj * 65 - 66] = ab[ii - jj + 1 + (jj |
| 4650 | + j + kv - 1) * ab_dim1]; |
| 4651 | /* L120: */ |
| 4652 | } |
| 4653 | /* L130: */ |
| 4654 | } |
| 4655 | |
| 4656 | /* Update A13 in the work array */ |
| 4657 | |
| 4658 | i__3 = *ldab - 1; |
| 4659 | dtrsm_cxx . . $ dtrsm_(47bcf6c639067e06).("Left", "Lower", "No transpose", "Unit", &jb, &j3, |
| 4660 | &c_b31, &ab[kv + 1 + j * ab_dim1], &i__3, work13, |
| 4661 | &c__65); |
| 4662 | |
| 4663 | if (i2 > 0) { |
| 4664 | |
| 4665 | /* Update A23 */ |
| 4666 | |
| 4667 | i__3 = *ldab - 1; |
| 4668 | i__4 = *ldab - 1; |
| 4669 | dgemm_cxx . . $ dgemm_(7f9a15c7502022ea).("No transpose", "No transpose", &i2, &j3, &jb, |
| 4670 | &c_b18, &ab[kv + 1 + jb + j * ab_dim1], &i__3, |
| 4671 | work13, &c__65, &c_b31, &ab[jb + 1 + (j + kv) |
| 4672 | * ab_dim1], &i__4); |
| 4673 | } |
| 4674 | |
| 4675 | if (i3 > 0) { |
| 4676 | |
| 4677 | /* Update A33 */ |
| 4678 | |
| 4679 | i__3 = *ldab - 1; |
| 4680 | dgemm_cxx . . $ dgemm_(7f9a15c7502022ea).("No transpose", "No transpose", &i3, &j3, &jb, |
| 4681 | &c_b18, work31, &c__65, work13, &c__65, & |
| 4682 | c_b31, &ab[*kl + 1 + (j + kv) * ab_dim1], & |
| 4683 | i__3); |
| 4684 | } |
| 4685 | |
| 4686 | /* Copy the lower triangle of A13 back into place */ |
| 4687 | |
| 4688 | i__3 = j3; |
| 4689 | for (jj = 1; jj <= i__3; ++jj) { |
| 4690 | i__4 = jb; |
| 4691 | for (ii = jj; ii <= i__4; ++ii) { |
| 4692 | ab[ii - jj + 1 + (jj + j + kv - 1) * ab_dim1] = |
| 4693 | work13[ii + jj * 65 - 66]; |
| 4694 | /* L140: */ |
| 4695 | } |
| 4696 | /* L150: */ |
| 4697 | } |
| 4698 | } |
| 4699 | } else { |
| 4700 | |
| 4701 | /* Adjust the pivot indices. */ |
| 4702 | |
| 4703 | i__3 = j + jb - 1; |
| 4704 | for (i__ = j; i__ <= i__3; ++i__) { |
| 4705 | ipiv[i__] = ipiv[i__] + j - 1; |
| 4706 | /* L160: */ |
| 4707 | } |
| 4708 | } |
| 4709 | |
| 4710 | /* Partially undo the interchanges in the current block to */ |
| 4711 | /* restore the upper triangular form of A31 and copy the upper */ |
| 4712 | /* triangle of A31 back into place */ |
| 4713 | |
| 4714 | i__3 = j; |
| 4715 | for (jj = j + jb - 1; jj >= i__3; --jj) { |
| 4716 | jp = ipiv[jj] - jj + 1; |
| 4717 | if (jp != 1) { |
| 4718 | |
| 4719 | /* Apply interchange to columns J to JJ-1 */ |
| 4720 | |
| 4721 | if (jp + jj - 1 < j + *kl) { |
| 4722 | |
| 4723 | /* The interchange does not affect A31 */ |
| 4724 | |
| 4725 | i__4 = jj - j; |
| 4726 | i__5 = *ldab - 1; |
| 4727 | i__6 = *ldab - 1; |
| 4728 | dswap_cxx . . $ dswap_(ec261fd7ec3b6bf6).(&i__4, &ab[kv + 1 + jj - j + j * ab_dim1], & |
| 4729 | i__5, &ab[kv + jp + jj - j + j * ab_dim1], & |
| 4730 | i__6); |
| 4731 | } else { |
| 4732 | |
| 4733 | /* The interchange does affect A31 */ |
| 4734 | |
| 4735 | i__4 = jj - j; |
| 4736 | i__5 = *ldab - 1; |
| 4737 | dswap_cxx . . $ dswap_(ec261fd7ec3b6bf6).(&i__4, &ab[kv + 1 + jj - j + j * ab_dim1], & |
| 4738 | i__5, &work31[jp + jj - j - *kl - 1], &c__65); |
| 4739 | } |
| 4740 | } |
| 4741 | |
| 4742 | /* Copy the current column of A31 back into place */ |
| 4743 | |
| 4744 | /* Computing MIN */ |
| 4745 | i__4 = i3, i__5 = jj - j + 1; |
| 4746 | nw = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__4,i__5); |
| 4747 | if (nw > 0) { |
| 4748 | dcopy_cxx . . $ dcopy_(ec261fd7ec3b6bf6).(&nw, &work31[(jj - j + 1) * 65 - 65], &c__1, &ab[ |
| 4749 | kv + *kl + 1 - jj + j + jj * ab_dim1], &c__1); |
| 4750 | } |
| 4751 | /* L170: */ |
| 4752 | } |
| 4753 | /* L180: */ |
| 4754 | } |
| 4755 | } |
| 4756 | |
| 4757 | return 0; |
| 4758 | |
| 4759 | /* End of DGBTRF */ |
| 4760 | |
| 4761 | } /* dgbtrf_ */ |
| 4762 | |
| 4763 | /* Subroutine */ int dgbtrs_cxx . . $ dgbtrs_(50a94af1eb812d7f).(const char *trans, integercxx . . $ integer# *n, integercxx . . $ integer# *kl, integercxx . . $ integer# * |
| 4764 | ku, integercxx . . $ integer# *nrhs, double *ab, integercxx . . $ integer# *ldab, integercxx . . $ integer# *ipiv, |
| 4765 | double *b, integercxx . . $ integer# *ldb, integercxx . . $ integer# *info) |
| 4766 | { |
| 4767 | /* Table of constant values */ |
| 4768 | static double c_b7 = -1.; |
| 4769 | static integercxx . . $ integer# c__1 = 1; |
| 4770 | static double c_b23 = 1.; |
| 4771 | |
| 4772 | /* System generated locals */ |
| 4773 | integercxx . . $ integer# ab_dim1, ab_offset, b_dim1, b_offset, i__1, i__2, i__3; |
| 4774 | |
| 4775 | /* Local variables */ |
| 4776 | integercxx . . $ integer# i__, j, l, kd, lm; |
| 4777 | bool lnoti; |
| 4778 | bool notran; |
| 4779 | |
| 4780 | |
| 4781 | /* -- LAPACK routine (version 3.1) -- */ |
| 4782 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 4783 | /* November 2006 */ |
| 4784 | |
| 4785 | /* .. Scalar Arguments .. */ |
| 4786 | /* .. */ |
| 4787 | /* .. Array Arguments .. */ |
| 4788 | /* .. */ |
| 4789 | |
| 4790 | /* Purpose */ |
| 4791 | /* ======= */ |
| 4792 | |
| 4793 | /* DGBTRS solves a system of linear equations */ |
| 4794 | /* A * X = B or A' * X = B */ |
| 4795 | /* with a general band matrix A using the LU factorization computed */ |
| 4796 | /* by DGBTRF. */ |
| 4797 | |
| 4798 | /* Arguments */ |
| 4799 | /* ========= */ |
| 4800 | |
| 4801 | /* TRANS (input) CHARACTER*1 */ |
| 4802 | /* Specifies the form of the system of equations. */ |
| 4803 | /* = 'N': A * X = B (No transpose) */ |
| 4804 | /* = 'T': A'* X = B (Transpose) */ |
| 4805 | /* = 'C': A'* X = B (Conjugate transpose = Transpose) */ |
| 4806 | |
| 4807 | /* N (input) INTEGER */ |
| 4808 | /* The order of the matrix A. N >= 0. */ |
| 4809 | |
| 4810 | /* KL (input) INTEGER */ |
| 4811 | /* The number of subdiagonals within the band of A. KL >= 0. */ |
| 4812 | |
| 4813 | /* KU (input) INTEGER */ |
| 4814 | /* The number of superdiagonals within the band of A. KU >= 0. */ |
| 4815 | |
| 4816 | /* NRHS (input) INTEGER */ |
| 4817 | /* The number of right hand sides, i.e., the number of columns */ |
| 4818 | /* of the matrix B. NRHS >= 0. */ |
| 4819 | |
| 4820 | /* AB (input) DOUBLE PRECISION array, dimension (LDAB,N) */ |
| 4821 | /* Details of the LU factorization of the band matrix A, as */ |
| 4822 | /* computed by DGBTRF. U is stored as an upper triangular band */ |
| 4823 | /* matrix with KL+KU superdiagonals in rows 1 to KL+KU+1, and */ |
| 4824 | /* the multipliers used during the factorization are stored in */ |
| 4825 | /* rows KL+KU+2 to 2*KL+KU+1. */ |
| 4826 | |
| 4827 | /* LDAB (input) INTEGER */ |
| 4828 | /* The leading dimension of the array AB. LDAB >= 2*KL+KU+1. */ |
| 4829 | |
| 4830 | /* IPIV (input) INTEGER array, dimension (N) */ |
| 4831 | /* The pivot indices; for 1 <= i <= N, row i of the matrix was */ |
| 4832 | /* interchanged with row IPIV(i). */ |
| 4833 | |
| 4834 | /* B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */ |
| 4835 | /* On entry, the right hand side matrix B. */ |
| 4836 | /* On exit, the solution matrix X. */ |
| 4837 | |
| 4838 | /* LDB (input) INTEGER */ |
| 4839 | /* The leading dimension of the array B. LDB >= max(1,N). */ |
| 4840 | |
| 4841 | /* INFO (output) INTEGER */ |
| 4842 | /* = 0: successful exit */ |
| 4843 | /* < 0: if INFO = -i, the i-th argument had an illegal value */ |
| 4844 | |
| 4845 | /* ===================================================================== */ |
| 4846 | |
| 4847 | /* .. Parameters .. */ |
| 4848 | /* .. */ |
| 4849 | /* .. Local Scalars .. */ |
| 4850 | /* .. */ |
| 4851 | /* .. External Functions .. */ |
| 4852 | /* .. */ |
| 4853 | /* .. External Subroutines .. */ |
| 4854 | /* .. */ |
| 4855 | /* .. Intrinsic Functions .. */ |
| 4856 | /* .. */ |
| 4857 | /* .. Executable Statements .. */ |
| 4858 | |
| 4859 | /* Test the input parameters. */ |
| 4860 | |
| 4861 | /* Parameter adjustments */ |
| 4862 | ab_dim1 = *ldab; |
| 4863 | ab_offset = 1 + ab_dim1; |
| 4864 | ab -= ab_offset; |
| 4865 | --ipiv; |
| 4866 | b_dim1 = *ldb; |
| 4867 | b_offset = 1 + b_dim1; |
| 4868 | b -= b_offset; |
| 4869 | |
| 4870 | /* Function Body */ |
| 4871 | *info = 0; |
| 4872 | notran = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(trans, "N"); |
| 4873 | if (! notran && ! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(trans, "T") && ! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).( |
| 4874 | trans, "C")) { |
| 4875 | *info = -1; |
| 4876 | } else if (*n < 0) { |
| 4877 | *info = -2; |
| 4878 | } else if (*kl < 0) { |
| 4879 | *info = -3; |
| 4880 | } else if (*ku < 0) { |
| 4881 | *info = -4; |
| 4882 | } else if (*nrhs < 0) { |
| 4883 | *info = -5; |
| 4884 | } else if (*ldab < (*kl << 1) + *ku + 1) { |
| 4885 | *info = -7; |
| 4886 | } else if (*ldb < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 4887 | *info = -10; |
| 4888 | } |
| 4889 | if (*info != 0) { |
| 4890 | i__1 = -(*info); |
| 4891 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGBTRS", &i__1); |
| 4892 | return 0; |
| 4893 | } |
| 4894 | |
| 4895 | /* Quick return if possible */ |
| 4896 | |
| 4897 | if (*n == 0 || *nrhs == 0) { |
| 4898 | return 0; |
| 4899 | } |
| 4900 | |
| 4901 | kd = *ku + *kl + 1; |
| 4902 | lnoti = *kl > 0; |
| 4903 | |
| 4904 | if (notran) { |
| 4905 | |
| 4906 | /* Solve A*X = B. */ |
| 4907 | |
| 4908 | /* Solve L*X = B, overwriting B with X. */ |
| 4909 | |
| 4910 | /* L is represented as a product of permutations and unit lower */ |
| 4911 | /* triangular matrices L = P(1) * L(1) * ... * P(n-1) * L(n-1), */ |
| 4912 | /* where each transformation L(i) is a rank-one modification of */ |
| 4913 | /* the identity matrix. */ |
| 4914 | |
| 4915 | if (lnoti) { |
| 4916 | i__1 = *n - 1; |
| 4917 | for (j = 1; j <= i__1; ++j) { |
| 4918 | /* Computing MIN */ |
| 4919 | i__2 = *kl, i__3 = *n - j; |
| 4920 | lm = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__2,i__3); |
| 4921 | l = ipiv[j]; |
| 4922 | if (l != j) { |
| 4923 | dswap_cxx . . $ dswap_(ec261fd7ec3b6bf6).(nrhs, &b[l + b_dim1], ldb, &b[j + b_dim1], ldb); |
| 4924 | } |
| 4925 | dger_cxx . . $ dger_(655ac4c2f34f763a).(&lm, nrhs, &c_b7, &ab[kd + 1 + j * ab_dim1], &c__1, &b[ |
| 4926 | j + b_dim1], ldb, &b[j + 1 + b_dim1], ldb); |
| 4927 | /* L10: */ |
| 4928 | } |
| 4929 | } |
| 4930 | |
| 4931 | i__1 = *nrhs; |
| 4932 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 4933 | |
| 4934 | /* Solve U*X = B, overwriting B with X. */ |
| 4935 | |
| 4936 | i__2 = *kl + *ku; |
| 4937 | dtbsv_cxx . . $ dtbsv_(b263eabb7251b8d1).("Upper", "No transpose", "Non-unit", n, &i__2, &ab[ |
| 4938 | ab_offset], ldab, &b[i__ * b_dim1 + 1], &c__1); |
| 4939 | /* L20: */ |
| 4940 | } |
| 4941 | |
| 4942 | } else { |
| 4943 | |
| 4944 | /* Solve A'*X = B. */ |
| 4945 | |
| 4946 | i__1 = *nrhs; |
| 4947 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 4948 | |
| 4949 | /* Solve U'*X = B, overwriting B with X. */ |
| 4950 | |
| 4951 | i__2 = *kl + *ku; |
| 4952 | dtbsv_cxx . . $ dtbsv_(b263eabb7251b8d1).("Upper", "Transpose", "Non-unit", n, &i__2, &ab[ab_offset], |
| 4953 | ldab, &b[i__ * b_dim1 + 1], &c__1); |
| 4954 | /* L30: */ |
| 4955 | } |
| 4956 | |
| 4957 | /* Solve L'*X = B, overwriting B with X. */ |
| 4958 | |
| 4959 | if (lnoti) { |
| 4960 | for (j = *n - 1; j >= 1; --j) { |
| 4961 | /* Computing MIN */ |
| 4962 | i__1 = *kl, i__2 = *n - j; |
| 4963 | lm = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__1,i__2); |
| 4964 | dgemv_cxx . . $ dgemv_(828a5131add94649).("Transpose", &lm, nrhs, &c_b7, &b[j + 1 + b_dim1], ldb, |
| 4965 | &ab[kd + 1 + j * ab_dim1], &c__1, &c_b23, &b[j + |
| 4966 | b_dim1], ldb); |
| 4967 | l = ipiv[j]; |
| 4968 | if (l != j) { |
| 4969 | dswap_cxx . . $ dswap_(ec261fd7ec3b6bf6).(nrhs, &b[l + b_dim1], ldb, &b[j + b_dim1], ldb); |
| 4970 | } |
| 4971 | /* L40: */ |
| 4972 | } |
| 4973 | } |
| 4974 | } |
| 4975 | return 0; |
| 4976 | |
| 4977 | /* End of DGBTRS */ |
| 4978 | |
| 4979 | } /* dgbtrs_ */ |
| 4980 | |
| 4981 | /* Subroutine */ int dgebak_cxx . . $ dgebak_(51612d8f5027ec5a).(const char *job, const char *side, integercxx . . $ integer# *n, integercxx . . $ integer# *ilo, |
| 4982 | integercxx . . $ integer# *ihi, double *scale, integercxx . . $ integer# *m, double *v, integercxx . . $ integer# * |
| 4983 | ldv, integercxx . . $ integer# *info) |
| 4984 | { |
| 4985 | /* System generated locals */ |
| 4986 | integercxx . . $ integer# v_dim1, v_offset, i__1; |
| 4987 | |
| 4988 | /* Local variables */ |
| 4989 | integercxx . . $ integer# i__, k; |
| 4990 | double s; |
| 4991 | integercxx . . $ integer# ii; |
| 4992 | bool leftv; |
| 4993 | bool rightv; |
| 4994 | |
| 4995 | |
| 4996 | /* -- LAPACK routine (version 3.1) -- */ |
| 4997 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 4998 | /* November 2006 */ |
| 4999 | |
| 5000 | /* .. Scalar Arguments .. */ |
| 5001 | /* .. */ |
| 5002 | /* .. Array Arguments .. */ |
| 5003 | /* .. */ |
| 5004 | |
| 5005 | /* Purpose */ |
| 5006 | /* ======= */ |
| 5007 | |
| 5008 | /* DGEBAK forms the right or left eigenvectors of a real general matrix */ |
| 5009 | /* by backward transformation on the computed eigenvectors of the */ |
| 5010 | /* balanced matrix output by DGEBAL. */ |
| 5011 | |
| 5012 | /* Arguments */ |
| 5013 | /* ========= */ |
| 5014 | |
| 5015 | /* JOB (input) CHARACTER*1 */ |
| 5016 | /* Specifies the type of backward transformation required: */ |
| 5017 | /* = 'N', do nothing, return immediately; */ |
| 5018 | /* = 'P', do backward transformation for permutation only; */ |
| 5019 | /* = 'S', do backward transformation for scaling only; */ |
| 5020 | /* = 'B', do backward transformations for both permutation and */ |
| 5021 | /* scaling. */ |
| 5022 | /* JOB must be the same as the argument JOB supplied to DGEBAL. */ |
| 5023 | |
| 5024 | /* SIDE (input) CHARACTER*1 */ |
| 5025 | /* = 'R': V contains right eigenvectors; */ |
| 5026 | /* = 'L': V contains left eigenvectors. */ |
| 5027 | |
| 5028 | /* N (input) INTEGER */ |
| 5029 | /* The number of rows of the matrix V. N >= 0. */ |
| 5030 | |
| 5031 | /* ILO (input) INTEGER */ |
| 5032 | /* IHI (input) INTEGER */ |
| 5033 | /* The integers ILO and IHI determined by DGEBAL. */ |
| 5034 | /* 1 <= ILO <= IHI <= N, if N > 0; ILO=1 and IHI=0, if N=0. */ |
| 5035 | |
| 5036 | /* SCALE (input) DOUBLE PRECISION array, dimension (N) */ |
| 5037 | /* Details of the permutation and scaling factors, as returned */ |
| 5038 | /* by DGEBAL. */ |
| 5039 | |
| 5040 | /* M (input) INTEGER */ |
| 5041 | /* The number of columns of the matrix V. M >= 0. */ |
| 5042 | |
| 5043 | /* V (input/output) DOUBLE PRECISION array, dimension (LDV,M) */ |
| 5044 | /* On entry, the matrix of right or left eigenvectors to be */ |
| 5045 | /* transformed, as returned by DHSEIN or DTREVC. */ |
| 5046 | /* On exit, V is overwritten by the transformed eigenvectors. */ |
| 5047 | |
| 5048 | /* LDV (input) INTEGER */ |
| 5049 | /* The leading dimension of the array V. LDV >= max(1,N). */ |
| 5050 | |
| 5051 | /* INFO (output) INTEGER */ |
| 5052 | /* = 0: successful exit */ |
| 5053 | /* < 0: if INFO = -i, the i-th argument had an illegal value. */ |
| 5054 | |
| 5055 | /* ===================================================================== */ |
| 5056 | |
| 5057 | /* .. Parameters .. */ |
| 5058 | /* .. */ |
| 5059 | /* .. Local Scalars .. */ |
| 5060 | /* .. */ |
| 5061 | /* .. External Functions .. */ |
| 5062 | /* .. */ |
| 5063 | /* .. External Subroutines .. */ |
| 5064 | /* .. */ |
| 5065 | /* .. Intrinsic Functions .. */ |
| 5066 | /* .. */ |
| 5067 | /* .. Executable Statements .. */ |
| 5068 | |
| 5069 | /* Decode and Test the input parameters */ |
| 5070 | |
| 5071 | /* Parameter adjustments */ |
| 5072 | --scale; |
| 5073 | v_dim1 = *ldv; |
| 5074 | v_offset = 1 + v_dim1; |
| 5075 | v -= v_offset; |
| 5076 | |
| 5077 | /* Function Body */ |
| 5078 | rightv = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(side, "R"); |
| 5079 | leftv = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(side, "L"); |
| 5080 | |
| 5081 | *info = 0; |
| 5082 | if (! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(job, "N") && ! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(job, "P") && ! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(job, "S") |
| 5083 | && ! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(job, "B")) { |
| 5084 | *info = -1; |
| 5085 | } else if (! rightv && ! leftv) { |
| 5086 | *info = -2; |
| 5087 | } else if (*n < 0) { |
| 5088 | *info = -3; |
| 5089 | } else if (*ilo < 1 || *ilo > stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 5090 | *info = -4; |
| 5091 | } else if (*ihi < stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(*ilo,*n) || *ihi > *n) { |
| 5092 | *info = -5; |
| 5093 | } else if (*m < 0) { |
| 5094 | *info = -7; |
| 5095 | } else if (*ldv < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 5096 | *info = -9; |
| 5097 | } |
| 5098 | if (*info != 0) { |
| 5099 | i__1 = -(*info); |
| 5100 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGEBAK", &i__1); |
| 5101 | return 0; |
| 5102 | } |
| 5103 | |
| 5104 | /* Quick return if possible */ |
| 5105 | |
| 5106 | if (*n == 0) { |
| 5107 | return 0; |
| 5108 | } |
| 5109 | if (*m == 0) { |
| 5110 | return 0; |
| 5111 | } |
| 5112 | if (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(job, "N")) { |
| 5113 | return 0; |
| 5114 | } |
| 5115 | |
| 5116 | if (*ilo == *ihi) { |
| 5117 | goto L30; |
| 5118 | } |
| 5119 | |
| 5120 | /* Backward balance */ |
| 5121 | |
| 5122 | if (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(job, "S") || lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(job, "B")) { |
| 5123 | |
| 5124 | if (rightv) { |
| 5125 | i__1 = *ihi; |
| 5126 | for (i__ = *ilo; i__ <= i__1; ++i__) { |
| 5127 | s = scale[i__]; |
| 5128 | dscal_cxx . . $ dscal_(f22c1db71784c345).(m, &s, &v[i__ + v_dim1], ldv); |
| 5129 | /* L10: */ |
| 5130 | } |
| 5131 | } |
| 5132 | |
| 5133 | if (leftv) { |
| 5134 | i__1 = *ihi; |
| 5135 | for (i__ = *ilo; i__ <= i__1; ++i__) { |
| 5136 | s = 1. / scale[i__]; |
| 5137 | dscal_cxx . . $ dscal_(f22c1db71784c345).(m, &s, &v[i__ + v_dim1], ldv); |
| 5138 | /* L20: */ |
| 5139 | } |
| 5140 | } |
| 5141 | |
| 5142 | } |
| 5143 | |
| 5144 | /* Backward permutation */ |
| 5145 | |
| 5146 | /* For I = ILO-1 step -1 until 1, */ |
| 5147 | /* IHI+1 step 1 until N do -- */ |
| 5148 | |
| 5149 | L30: |
| 5150 | if (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(job, "P") || lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(job, "B")) { |
| 5151 | if (rightv) { |
| 5152 | i__1 = *n; |
| 5153 | for (ii = 1; ii <= i__1; ++ii) { |
| 5154 | i__ = ii; |
| 5155 | if (i__ >= *ilo && i__ <= *ihi) { |
| 5156 | goto L40; |
| 5157 | } |
| 5158 | if (i__ < *ilo) { |
| 5159 | i__ = *ilo - ii; |
| 5160 | } |
| 5161 | k = (integercxx . . $ integer#) scale[i__]; |
| 5162 | if (k == i__) { |
| 5163 | goto L40; |
| 5164 | } |
| 5165 | dswap_cxx . . $ dswap_(ec261fd7ec3b6bf6).(m, &v[i__ + v_dim1], ldv, &v[k + v_dim1], ldv); |
| 5166 | L40: |
| 5167 | ; |
| 5168 | } |
| 5169 | } |
| 5170 | |
| 5171 | if (leftv) { |
| 5172 | i__1 = *n; |
| 5173 | for (ii = 1; ii <= i__1; ++ii) { |
| 5174 | i__ = ii; |
| 5175 | if (i__ >= *ilo && i__ <= *ihi) { |
| 5176 | goto L50; |
| 5177 | } |
| 5178 | if (i__ < *ilo) { |
| 5179 | i__ = *ilo - ii; |
| 5180 | } |
| 5181 | k = (integercxx . . $ integer#) scale[i__]; |
| 5182 | if (k == i__) { |
| 5183 | goto L50; |
| 5184 | } |
| 5185 | dswap_cxx . . $ dswap_(ec261fd7ec3b6bf6).(m, &v[i__ + v_dim1], ldv, &v[k + v_dim1], ldv); |
| 5186 | L50: |
| 5187 | ; |
| 5188 | } |
| 5189 | } |
| 5190 | } |
| 5191 | |
| 5192 | return 0; |
| 5193 | |
| 5194 | /* End of DGEBAK */ |
| 5195 | |
| 5196 | } /* dgebak_ */ |
| 5197 | |
| 5198 | /* Subroutine */ int dgebal_cxx . . $ dgebal_(4da4b22b53009041).(const char *job, integercxx . . $ integer# *n, double *a, integercxx . . $ integer# * |
| 5199 | lda, integercxx . . $ integer# *ilo, integercxx . . $ integer# *ihi, double *scale, integercxx . . $ integer# *info) |
| 5200 | { |
| 5201 | /* Table of constant values */ |
| 5202 | static integercxx . . $ integer# c__1 = 1; |
| 5203 | |
| 5204 | /* System generated locals */ |
| 5205 | integercxx . . $ integer# a_dim1, a_offset, i__1, i__2; |
| 5206 | double d__1, d__2; |
| 5207 | |
| 5208 | /* Local variables */ |
| 5209 | double c__, f, g; |
| 5210 | integercxx . . $ integer# i__, j, k, l, m; |
| 5211 | double r__, s, ca, ra; |
| 5212 | integercxx . . $ integer# ica, ira, iexc; |
| 5213 | double sfmin1, sfmin2, sfmax1, sfmax2; |
| 5214 | bool noconv; |
| 5215 | |
| 5216 | |
| 5217 | /* -- LAPACK routine (version 3.1) -- */ |
| 5218 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 5219 | /* November 2006 */ |
| 5220 | |
| 5221 | /* .. Scalar Arguments .. */ |
| 5222 | /* .. */ |
| 5223 | /* .. Array Arguments .. */ |
| 5224 | /* .. */ |
| 5225 | |
| 5226 | /* Purpose */ |
| 5227 | /* ======= */ |
| 5228 | |
| 5229 | /* DGEBAL balances a general real matrix A. This involves, first, */ |
| 5230 | /* permuting A by a similarity transformation to isolate eigenvalues */ |
| 5231 | /* in the first 1 to ILO-1 and last IHI+1 to N elements on the */ |
| 5232 | /* diagonal; and second, applying a diagonal similarity transformation */ |
| 5233 | /* to rows and columns ILO to IHI to make the rows and columns as */ |
| 5234 | /* close in norm as possible. Both steps are optional. */ |
| 5235 | |
| 5236 | /* Balancing may reduce the 1-norm of the matrix, and improve the */ |
| 5237 | /* accuracy of the computed eigenvalues and/or eigenvectors. */ |
| 5238 | |
| 5239 | /* Arguments */ |
| 5240 | /* ========= */ |
| 5241 | |
| 5242 | /* JOB (input) CHARACTER*1 */ |
| 5243 | /* Specifies the operations to be performed on A: */ |
| 5244 | /* = 'N': none: simply set ILO = 1, IHI = N, SCALE(I) = 1.0 */ |
| 5245 | /* for i = 1,...,N; */ |
| 5246 | /* = 'P': permute only; */ |
| 5247 | /* = 'S': scale only; */ |
| 5248 | /* = 'B': both permute and scale. */ |
| 5249 | |
| 5250 | /* N (input) INTEGER */ |
| 5251 | /* The order of the matrix A. N >= 0. */ |
| 5252 | |
| 5253 | /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 5254 | /* On entry, the input matrix A. */ |
| 5255 | /* On exit, A is overwritten by the balanced matrix. */ |
| 5256 | /* If JOB = 'N', A is not referenced. */ |
| 5257 | /* See Further Details. */ |
| 5258 | |
| 5259 | /* LDA (input) INTEGER */ |
| 5260 | /* The leading dimension of the array A. LDA >= max(1,N). */ |
| 5261 | |
| 5262 | /* ILO (output) INTEGER */ |
| 5263 | /* IHI (output) INTEGER */ |
| 5264 | /* ILO and IHI are set to integers such that on exit */ |
| 5265 | /* A(i,j) = 0 if i > j and j = 1,...,ILO-1 or I = IHI+1,...,N. */ |
| 5266 | /* If JOB = 'N' or 'S', ILO = 1 and IHI = N. */ |
| 5267 | |
| 5268 | /* SCALE (output) DOUBLE PRECISION array, dimension (N) */ |
| 5269 | /* Details of the permutations and scaling factors applied to */ |
| 5270 | /* A. If P(j) is the index of the row and column interchanged */ |
| 5271 | /* with row and column j and D(j) is the scaling factor */ |
| 5272 | /* applied to row and column j, then */ |
| 5273 | /* SCALE(j) = P(j) for j = 1,...,ILO-1 */ |
| 5274 | /* = D(j) for j = ILO,...,IHI */ |
| 5275 | /* = P(j) for j = IHI+1,...,N. */ |
| 5276 | /* The order in which the interchanges are made is N to IHI+1, */ |
| 5277 | /* then 1 to ILO-1. */ |
| 5278 | |
| 5279 | /* INFO (output) INTEGER */ |
| 5280 | /* = 0: successful exit. */ |
| 5281 | /* < 0: if INFO = -i, the i-th argument had an illegal value. */ |
| 5282 | |
| 5283 | /* Further Details */ |
| 5284 | /* =============== */ |
| 5285 | |
| 5286 | /* The permutations consist of row and column interchanges which put */ |
| 5287 | /* the matrix in the form */ |
| 5288 | |
| 5289 | /* ( T1 X Y ) */ |
| 5290 | /* P A P = ( 0 B Z ) */ |
| 5291 | /* ( 0 0 T2 ) */ |
| 5292 | |
| 5293 | /* where T1 and T2 are upper triangular matrices whose eigenvalues lie */ |
| 5294 | /* along the diagonal. The column indices ILO and IHI mark the starting */ |
| 5295 | /* and ending columns of the submatrix B. Balancing consists of applying */ |
| 5296 | /* a diagonal similarity transformation inv(D) * B * D to make the */ |
| 5297 | /* 1-norms of each row of B and its corresponding column nearly equal. */ |
| 5298 | /* The output matrix is */ |
| 5299 | |
| 5300 | /* ( T1 X*D Y ) */ |
| 5301 | /* ( 0 inv(D)*B*D inv(D)*Z ). */ |
| 5302 | /* ( 0 0 T2 ) */ |
| 5303 | |
| 5304 | /* Information about the permutations P and the diagonal matrix D is */ |
| 5305 | /* returned in the vector SCALE. */ |
| 5306 | |
| 5307 | /* This subroutine is based on the EISPACK routine BALANC. */ |
| 5308 | |
| 5309 | /* Modified by Tzu-Yi Chen, Computer Science Division, University of */ |
| 5310 | /* California at Berkeley, USA */ |
| 5311 | |
| 5312 | /* ===================================================================== */ |
| 5313 | |
| 5314 | /* .. Parameters .. */ |
| 5315 | /* .. */ |
| 5316 | /* .. Local Scalars .. */ |
| 5317 | /* .. */ |
| 5318 | /* .. External Functions .. */ |
| 5319 | /* .. */ |
| 5320 | /* .. External Subroutines .. */ |
| 5321 | /* .. */ |
| 5322 | /* .. Intrinsic Functions .. */ |
| 5323 | /* .. */ |
| 5324 | /* .. Executable Statements .. */ |
| 5325 | |
| 5326 | /* Test the input parameters */ |
| 5327 | |
| 5328 | /* Parameter adjustments */ |
| 5329 | a_dim1 = *lda; |
| 5330 | a_offset = 1 + a_dim1; |
| 5331 | a -= a_offset; |
| 5332 | --scale; |
| 5333 | |
| 5334 | /* Function Body */ |
| 5335 | *info = 0; |
| 5336 | if (! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(job, "N") && ! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(job, "P") && ! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(job, "S") |
| 5337 | && ! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(job, "B")) { |
| 5338 | *info = -1; |
| 5339 | } else if (*n < 0) { |
| 5340 | *info = -2; |
| 5341 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 5342 | *info = -4; |
| 5343 | } |
| 5344 | if (*info != 0) { |
| 5345 | i__1 = -(*info); |
| 5346 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGEBAL", &i__1); |
| 5347 | return 0; |
| 5348 | } |
| 5349 | |
| 5350 | k = 1; |
| 5351 | l = *n; |
| 5352 | |
| 5353 | if (*n == 0) { |
| 5354 | goto L210; |
| 5355 | } |
| 5356 | |
| 5357 | if (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(job, "N")) { |
| 5358 | i__1 = *n; |
| 5359 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 5360 | scale[i__] = 1.; |
| 5361 | /* L10: */ |
| 5362 | } |
| 5363 | goto L210; |
| 5364 | } |
| 5365 | |
| 5366 | if (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(job, "S")) { |
| 5367 | goto L120; |
| 5368 | } |
| 5369 | |
| 5370 | /* Permutation to isolate eigenvalues if possible */ |
| 5371 | |
| 5372 | goto L50; |
| 5373 | |
| 5374 | /* Row and column exchange. */ |
| 5375 | |
| 5376 | L20: |
| 5377 | scale[m] = (double) j; |
| 5378 | if (j == m) { |
| 5379 | goto L30; |
| 5380 | } |
| 5381 | |
| 5382 | dswap_cxx . . $ dswap_(ec261fd7ec3b6bf6).(&l, &a[j * a_dim1 + 1], &c__1, &a[m * a_dim1 + 1], &c__1); |
| 5383 | i__1 = *n - k + 1; |
| 5384 | dswap_cxx . . $ dswap_(ec261fd7ec3b6bf6).(&i__1, &a[j + k * a_dim1], lda, &a[m + k * a_dim1], lda); |
| 5385 | |
| 5386 | L30: |
| 5387 | switch (iexc) { |
| 5388 | case 1: goto L40; |
| 5389 | case 2: goto L80; |
| 5390 | } |
| 5391 | |
| 5392 | /* Search for rows isolating an eigenvalue and push them down. */ |
| 5393 | |
| 5394 | L40: |
| 5395 | if (l == 1) { |
| 5396 | goto L210; |
| 5397 | } |
| 5398 | --l; |
| 5399 | |
| 5400 | L50: |
| 5401 | for (j = l; j >= 1; --j) { |
| 5402 | |
| 5403 | i__1 = l; |
| 5404 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 5405 | if (i__ == j) { |
| 5406 | goto L60; |
| 5407 | } |
| 5408 | if (a[j + i__ * a_dim1] != 0.) { |
| 5409 | goto L70; |
| 5410 | } |
| 5411 | L60: |
| 5412 | ; |
| 5413 | } |
| 5414 | |
| 5415 | m = l; |
| 5416 | iexc = 1; |
| 5417 | goto L20; |
| 5418 | L70: |
| 5419 | ; |
| 5420 | } |
| 5421 | |
| 5422 | goto L90; |
| 5423 | |
| 5424 | /* Search for columns isolating an eigenvalue and push them left. */ |
| 5425 | |
| 5426 | L80: |
| 5427 | ++k; |
| 5428 | |
| 5429 | L90: |
| 5430 | i__1 = l; |
| 5431 | for (j = k; j <= i__1; ++j) { |
| 5432 | |
| 5433 | i__2 = l; |
| 5434 | for (i__ = k; i__ <= i__2; ++i__) { |
| 5435 | if (i__ == j) { |
| 5436 | goto L100; |
| 5437 | } |
| 5438 | if (a[i__ + j * a_dim1] != 0.) { |
| 5439 | goto L110; |
| 5440 | } |
| 5441 | L100: |
| 5442 | ; |
| 5443 | } |
| 5444 | |
| 5445 | m = k; |
| 5446 | iexc = 2; |
| 5447 | goto L20; |
| 5448 | L110: |
| 5449 | ; |
| 5450 | } |
| 5451 | |
| 5452 | L120: |
| 5453 | i__1 = l; |
| 5454 | for (i__ = k; i__ <= i__1; ++i__) { |
| 5455 | scale[i__] = 1.; |
| 5456 | /* L130: */ |
| 5457 | } |
| 5458 | |
| 5459 | if (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(job, "P")) { |
| 5460 | goto L210; |
| 5461 | } |
| 5462 | |
| 5463 | /* Balance the submatrix in rows K to L. */ |
| 5464 | |
| 5465 | /* Iterative loop for norm reduction */ |
| 5466 | |
| 5467 | sfmin1 = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("S") / dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("P"); |
| 5468 | sfmax1 = 1. / sfmin1; |
| 5469 | sfmin2 = sfmin1 * 2.; |
| 5470 | sfmax2 = 1. / sfmin2; |
| 5471 | L140: |
| 5472 | noconv = false; |
| 5473 | |
| 5474 | i__1 = l; |
| 5475 | for (i__ = k; i__ <= i__1; ++i__) { |
| 5476 | c__ = 0.; |
| 5477 | r__ = 0.; |
| 5478 | |
| 5479 | i__2 = l; |
| 5480 | for (j = k; j <= i__2; ++j) { |
| 5481 | if (j == i__) { |
| 5482 | goto L150; |
| 5483 | } |
| 5484 | c__ += (d__1 = a[j + i__ * a_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__1)); |
| 5485 | r__ += (d__1 = a[i__ + j * a_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__1)); |
| 5486 | L150: |
| 5487 | ; |
| 5488 | } |
| 5489 | ica = idamax_cxx . . $ idamax_(a5c31fbfbc00ee45).(&l, &a[i__ * a_dim1 + 1], &c__1); |
| 5490 | ca = (d__1 = a[ica + i__ * a_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__1)); |
| 5491 | i__2 = *n - k + 1; |
| 5492 | ira = idamax_cxx . . $ idamax_(a5c31fbfbc00ee45).(&i__2, &a[i__ + k * a_dim1], lda); |
| 5493 | ra = (d__1 = a[i__ + (ira + k - 1) * a_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__1)); |
| 5494 | |
| 5495 | /* Guard against zero C or R due to underflow. */ |
| 5496 | |
| 5497 | if (c__ == 0. || r__ == 0.) { |
| 5498 | goto L200; |
| 5499 | } |
| 5500 | g = r__ / 2.; |
| 5501 | f = 1.; |
| 5502 | s = c__ + r__; |
| 5503 | L160: |
| 5504 | /* Computing MAX */ |
| 5505 | d__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(f,c__); |
| 5506 | /* Computing MIN */ |
| 5507 | d__2 = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(r__,g); |
| 5508 | if (c__ >= g || stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__1,ca) >= sfmax2 || stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(d__2,ra) <= sfmin2) { |
| 5509 | goto L170; |
| 5510 | } |
| 5511 | f *= 2.; |
| 5512 | c__ *= 2.; |
| 5513 | ca *= 2.; |
| 5514 | r__ /= 2.; |
| 5515 | g /= 2.; |
| 5516 | ra /= 2.; |
| 5517 | goto L160; |
| 5518 | |
| 5519 | L170: |
| 5520 | g = c__ / 2.; |
| 5521 | L180: |
| 5522 | /* Computing MIN */ |
| 5523 | d__1 = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(f,c__), d__1 = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(d__1,g); |
| 5524 | if (g < r__ || stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(r__,ra) >= sfmax2 || stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(d__1,ca) <= sfmin2) { |
| 5525 | goto L190; |
| 5526 | } |
| 5527 | f /= 2.; |
| 5528 | c__ /= 2.; |
| 5529 | g /= 2.; |
| 5530 | ca /= 2.; |
| 5531 | r__ *= 2.; |
| 5532 | ra *= 2.; |
| 5533 | goto L180; |
| 5534 | |
| 5535 | /* Now balance. */ |
| 5536 | |
| 5537 | L190: |
| 5538 | if (c__ + r__ >= s * .95) { |
| 5539 | goto L200; |
| 5540 | } |
| 5541 | if (f < 1. && scale[i__] < 1.) { |
| 5542 | if (f * scale[i__] <= sfmin1) { |
| 5543 | goto L200; |
| 5544 | } |
| 5545 | } |
| 5546 | if (f > 1. && scale[i__] > 1.) { |
| 5547 | if (scale[i__] >= sfmax1 / f) { |
| 5548 | goto L200; |
| 5549 | } |
| 5550 | } |
| 5551 | g = 1. / f; |
| 5552 | scale[i__] *= f; |
| 5553 | noconv = true; |
| 5554 | |
| 5555 | i__2 = *n - k + 1; |
| 5556 | dscal_cxx . . $ dscal_(f22c1db71784c345).(&i__2, &g, &a[i__ + k * a_dim1], lda); |
| 5557 | dscal_cxx . . $ dscal_(f22c1db71784c345).(&l, &f, &a[i__ * a_dim1 + 1], &c__1); |
| 5558 | |
| 5559 | L200: |
| 5560 | ; |
| 5561 | } |
| 5562 | |
| 5563 | if (noconv) { |
| 5564 | goto L140; |
| 5565 | } |
| 5566 | |
| 5567 | L210: |
| 5568 | *ilo = k; |
| 5569 | *ihi = l; |
| 5570 | |
| 5571 | return 0; |
| 5572 | |
| 5573 | /* End of DGEBAL */ |
| 5574 | |
| 5575 | } /* dgebal_ */ |
| 5576 | |
| 5577 | /* Subroutine */ int dgebd2_cxx . . $ dgebd2_(799434dec6c8879c).(integercxx . . $ integer# *m, integercxx . . $ integer# *n, double *a, integercxx . . $ integer# * |
| 5578 | lda, double *d__, double *e, double *tauq, double * |
| 5579 | taup, double *work, integercxx . . $ integer# *info) |
| 5580 | { |
| 5581 | /* Table of constant values */ |
| 5582 | static integercxx . . $ integer# c__1 = 1; |
| 5583 | |
| 5584 | /* System generated locals */ |
| 5585 | integercxx . . $ integer# a_dim1, a_offset, i__1, i__2, i__3; |
| 5586 | |
| 5587 | /* Local variables */ |
| 5588 | integercxx . . $ integer# i__; |
| 5589 | |
| 5590 | /* -- LAPACK routine (version 3.1) -- */ |
| 5591 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 5592 | /* November 2006 */ |
| 5593 | |
| 5594 | /* .. Scalar Arguments .. */ |
| 5595 | /* .. */ |
| 5596 | /* .. Array Arguments .. */ |
| 5597 | /* .. */ |
| 5598 | |
| 5599 | /* Purpose */ |
| 5600 | /* ======= */ |
| 5601 | |
| 5602 | /* DGEBD2 reduces a real general m by n matrix A to upper or lower */ |
| 5603 | /* bidiagonal form B by an orthogonal transformation: Q' * A * P = B. */ |
| 5604 | |
| 5605 | /* If m >= n, B is upper bidiagonal; if m < n, B is lower bidiagonal. */ |
| 5606 | |
| 5607 | /* Arguments */ |
| 5608 | /* ========= */ |
| 5609 | |
| 5610 | /* M (input) INTEGER */ |
| 5611 | /* The number of rows in the matrix A. M >= 0. */ |
| 5612 | |
| 5613 | /* N (input) INTEGER */ |
| 5614 | /* The number of columns in the matrix A. N >= 0. */ |
| 5615 | |
| 5616 | /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 5617 | /* On entry, the m by n general matrix to be reduced. */ |
| 5618 | /* On exit, */ |
| 5619 | /* if m >= n, the diagonal and the first superdiagonal are */ |
| 5620 | /* overwritten with the upper bidiagonal matrix B; the */ |
| 5621 | /* elements below the diagonal, with the array TAUQ, represent */ |
| 5622 | /* the orthogonal matrix Q as a product of elementary */ |
| 5623 | /* reflectors, and the elements above the first superdiagonal, */ |
| 5624 | /* with the array TAUP, represent the orthogonal matrix P as */ |
| 5625 | /* a product of elementary reflectors; */ |
| 5626 | /* if m < n, the diagonal and the first subdiagonal are */ |
| 5627 | /* overwritten with the lower bidiagonal matrix B; the */ |
| 5628 | /* elements below the first subdiagonal, with the array TAUQ, */ |
| 5629 | /* represent the orthogonal matrix Q as a product of */ |
| 5630 | /* elementary reflectors, and the elements above the diagonal, */ |
| 5631 | /* with the array TAUP, represent the orthogonal matrix P as */ |
| 5632 | /* a product of elementary reflectors. */ |
| 5633 | /* See Further Details. */ |
| 5634 | |
| 5635 | /* LDA (input) INTEGER */ |
| 5636 | /* The leading dimension of the array A. LDA >= max(1,M). */ |
| 5637 | |
| 5638 | /* D (output) DOUBLE PRECISION array, dimension (min(M,N)) */ |
| 5639 | /* The diagonal elements of the bidiagonal matrix B: */ |
| 5640 | /* D(i) = A(i,i). */ |
| 5641 | |
| 5642 | /* E (output) DOUBLE PRECISION array, dimension (min(M,N)-1) */ |
| 5643 | /* The off-diagonal elements of the bidiagonal matrix B: */ |
| 5644 | /* if m >= n, E(i) = A(i,i+1) for i = 1,2,...,n-1; */ |
| 5645 | /* if m < n, E(i) = A(i+1,i) for i = 1,2,...,m-1. */ |
| 5646 | |
| 5647 | /* TAUQ (output) DOUBLE PRECISION array dimension (min(M,N)) */ |
| 5648 | /* The scalar factors of the elementary reflectors which */ |
| 5649 | /* represent the orthogonal matrix Q. See Further Details. */ |
| 5650 | |
| 5651 | /* TAUP (output) DOUBLE PRECISION array, dimension (min(M,N)) */ |
| 5652 | /* The scalar factors of the elementary reflectors which */ |
| 5653 | /* represent the orthogonal matrix P. See Further Details. */ |
| 5654 | |
| 5655 | /* WORK (workspace) DOUBLE PRECISION array, dimension (max(M,N)) */ |
| 5656 | |
| 5657 | /* INFO (output) INTEGER */ |
| 5658 | /* = 0: successful exit. */ |
| 5659 | /* < 0: if INFO = -i, the i-th argument had an illegal value. */ |
| 5660 | |
| 5661 | /* Further Details */ |
| 5662 | /* =============== */ |
| 5663 | |
| 5664 | /* The matrices Q and P are represented as products of elementary */ |
| 5665 | /* reflectors: */ |
| 5666 | |
| 5667 | /* If m >= n, */ |
| 5668 | |
| 5669 | /* Q = H(1) H(2) . . . H(n) and P = G(1) G(2) . . . G(n-1) */ |
| 5670 | |
| 5671 | /* Each H(i) and G(i) has the form: */ |
| 5672 | |
| 5673 | /* H(i) = I - tauq * v * v' and G(i) = I - taup * u * u' */ |
| 5674 | |
| 5675 | /* where tauq and taup are real scalars, and v and u are real vectors; */ |
| 5676 | /* v(1:i-1) = 0, v(i) = 1, and v(i+1:m) is stored on exit in A(i+1:m,i); */ |
| 5677 | /* u(1:i) = 0, u(i+1) = 1, and u(i+2:n) is stored on exit in A(i,i+2:n); */ |
| 5678 | /* tauq is stored in TAUQ(i) and taup in TAUP(i). */ |
| 5679 | |
| 5680 | /* If m < n, */ |
| 5681 | |
| 5682 | /* Q = H(1) H(2) . . . H(m-1) and P = G(1) G(2) . . . G(m) */ |
| 5683 | |
| 5684 | /* Each H(i) and G(i) has the form: */ |
| 5685 | |
| 5686 | /* H(i) = I - tauq * v * v' and G(i) = I - taup * u * u' */ |
| 5687 | |
| 5688 | /* where tauq and taup are real scalars, and v and u are real vectors; */ |
| 5689 | /* v(1:i) = 0, v(i+1) = 1, and v(i+2:m) is stored on exit in A(i+2:m,i); */ |
| 5690 | /* u(1:i-1) = 0, u(i) = 1, and u(i+1:n) is stored on exit in A(i,i+1:n); */ |
| 5691 | /* tauq is stored in TAUQ(i) and taup in TAUP(i). */ |
| 5692 | |
| 5693 | /* The contents of A on exit are illustrated by the following examples: */ |
| 5694 | |
| 5695 | /* m = 6 and n = 5 (m > n): m = 5 and n = 6 (m < n): */ |
| 5696 | |
| 5697 | /* ( d e u1 u1 u1 ) ( d u1 u1 u1 u1 u1 ) */ |
| 5698 | /* ( v1 d e u2 u2 ) ( e d u2 u2 u2 u2 ) */ |
| 5699 | /* ( v1 v2 d e u3 ) ( v1 e d u3 u3 u3 ) */ |
| 5700 | /* ( v1 v2 v3 d e ) ( v1 v2 e d u4 u4 ) */ |
| 5701 | /* ( v1 v2 v3 v4 d ) ( v1 v2 v3 e d u5 ) */ |
| 5702 | /* ( v1 v2 v3 v4 v5 ) */ |
| 5703 | |
| 5704 | /* where d and e denote diagonal and off-diagonal elements of B, vi */ |
| 5705 | /* denotes an element of the vector defining H(i), and ui an element of */ |
| 5706 | /* the vector defining G(i). */ |
| 5707 | |
| 5708 | /* ===================================================================== */ |
| 5709 | |
| 5710 | /* .. Parameters .. */ |
| 5711 | /* .. */ |
| 5712 | /* .. Local Scalars .. */ |
| 5713 | /* .. */ |
| 5714 | /* .. External Subroutines .. */ |
| 5715 | /* .. */ |
| 5716 | /* .. Intrinsic Functions .. */ |
| 5717 | /* .. */ |
| 5718 | /* .. Executable Statements .. */ |
| 5719 | |
| 5720 | /* Test the input parameters */ |
| 5721 | |
| 5722 | /* Parameter adjustments */ |
| 5723 | a_dim1 = *lda; |
| 5724 | a_offset = 1 + a_dim1; |
| 5725 | a -= a_offset; |
| 5726 | --d__; |
| 5727 | --e; |
| 5728 | --tauq; |
| 5729 | --taup; |
| 5730 | --work; |
| 5731 | |
| 5732 | /* Function Body */ |
| 5733 | *info = 0; |
| 5734 | if (*m < 0) { |
| 5735 | *info = -1; |
| 5736 | } else if (*n < 0) { |
| 5737 | *info = -2; |
| 5738 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*m)) { |
| 5739 | *info = -4; |
| 5740 | } |
| 5741 | if (*info < 0) { |
| 5742 | i__1 = -(*info); |
| 5743 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGEBD2", &i__1); |
| 5744 | return 0; |
| 5745 | } |
| 5746 | |
| 5747 | if (*m >= *n) { |
| 5748 | |
| 5749 | /* Reduce to upper bidiagonal form */ |
| 5750 | |
| 5751 | i__1 = *n; |
| 5752 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 5753 | |
| 5754 | /* Generate elementary reflector H(i) to annihilate A(i+1:m,i) */ |
| 5755 | |
| 5756 | i__2 = *m - i__ + 1; |
| 5757 | /* Computing MIN */ |
| 5758 | i__3 = i__ + 1; |
| 5759 | dlarfg_cxx . . $ dlarfg_(ae28ee921df873ff).(&i__2, &a[i__ + i__ * a_dim1], &a[stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__3, *m)+ i__ * |
| 5760 | a_dim1], &c__1, &tauq[i__]); |
| 5761 | d__[i__] = a[i__ + i__ * a_dim1]; |
| 5762 | a[i__ + i__ * a_dim1] = 1.; |
| 5763 | |
| 5764 | /* Apply H(i) to A(i:m,i+1:n) from the left */ |
| 5765 | |
| 5766 | if (i__ < *n) { |
| 5767 | i__2 = *m - i__ + 1; |
| 5768 | i__3 = *n - i__; |
| 5769 | dlarf_cxx . . $ dlarf_(f67bbcf4c4b4eb96).("Left", &i__2, &i__3, &a[i__ + i__ * a_dim1], &c__1, & |
| 5770 | tauq[i__], &a[i__ + (i__ + 1) * a_dim1], lda, &work[1] |
| 5771 | ); |
| 5772 | } |
| 5773 | a[i__ + i__ * a_dim1] = d__[i__]; |
| 5774 | |
| 5775 | if (i__ < *n) { |
| 5776 | |
| 5777 | /* Generate elementary reflector G(i) to annihilate */ |
| 5778 | /* A(i,i+2:n) */ |
| 5779 | |
| 5780 | i__2 = *n - i__; |
| 5781 | /* Computing MIN */ |
| 5782 | i__3 = i__ + 2; |
| 5783 | dlarfg_cxx . . $ dlarfg_(ae28ee921df873ff).(&i__2, &a[i__ + (i__ + 1) * a_dim1], &a[i__ + stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).( |
| 5784 | i__3, *n)* a_dim1], lda, &taup[i__]); |
| 5785 | e[i__] = a[i__ + (i__ + 1) * a_dim1]; |
| 5786 | a[i__ + (i__ + 1) * a_dim1] = 1.; |
| 5787 | |
| 5788 | /* Apply G(i) to A(i+1:m,i+1:n) from the right */ |
| 5789 | |
| 5790 | i__2 = *m - i__; |
| 5791 | i__3 = *n - i__; |
| 5792 | dlarf_cxx . . $ dlarf_(f67bbcf4c4b4eb96).("Right", &i__2, &i__3, &a[i__ + (i__ + 1) * a_dim1], |
| 5793 | lda, &taup[i__], &a[i__ + 1 + (i__ + 1) * a_dim1], |
| 5794 | lda, &work[1]); |
| 5795 | a[i__ + (i__ + 1) * a_dim1] = e[i__]; |
| 5796 | } else { |
| 5797 | taup[i__] = 0.; |
| 5798 | } |
| 5799 | /* L10: */ |
| 5800 | } |
| 5801 | } else { |
| 5802 | |
| 5803 | /* Reduce to lower bidiagonal form */ |
| 5804 | |
| 5805 | i__1 = *m; |
| 5806 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 5807 | |
| 5808 | /* Generate elementary reflector G(i) to annihilate A(i,i+1:n) */ |
| 5809 | |
| 5810 | i__2 = *n - i__ + 1; |
| 5811 | /* Computing MIN */ |
| 5812 | i__3 = i__ + 1; |
| 5813 | dlarfg_cxx . . $ dlarfg_(ae28ee921df873ff).(&i__2, &a[i__ + i__ * a_dim1], &a[i__ + stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__3, *n)* |
| 5814 | a_dim1], lda, &taup[i__]); |
| 5815 | d__[i__] = a[i__ + i__ * a_dim1]; |
| 5816 | a[i__ + i__ * a_dim1] = 1.; |
| 5817 | |
| 5818 | /* Apply G(i) to A(i+1:m,i:n) from the right */ |
| 5819 | |
| 5820 | if (i__ < *m) { |
| 5821 | i__2 = *m - i__; |
| 5822 | i__3 = *n - i__ + 1; |
| 5823 | dlarf_cxx . . $ dlarf_(f67bbcf4c4b4eb96).("Right", &i__2, &i__3, &a[i__ + i__ * a_dim1], lda, & |
| 5824 | taup[i__], &a[i__ + 1 + i__ * a_dim1], lda, &work[1]); |
| 5825 | } |
| 5826 | a[i__ + i__ * a_dim1] = d__[i__]; |
| 5827 | |
| 5828 | if (i__ < *m) { |
| 5829 | |
| 5830 | /* Generate elementary reflector H(i) to annihilate */ |
| 5831 | /* A(i+2:m,i) */ |
| 5832 | |
| 5833 | i__2 = *m - i__; |
| 5834 | /* Computing MIN */ |
| 5835 | i__3 = i__ + 2; |
| 5836 | dlarfg_cxx . . $ dlarfg_(ae28ee921df873ff).(&i__2, &a[i__ + 1 + i__ * a_dim1], &a[stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__3, *m)+ |
| 5837 | i__ * a_dim1], &c__1, &tauq[i__]); |
| 5838 | e[i__] = a[i__ + 1 + i__ * a_dim1]; |
| 5839 | a[i__ + 1 + i__ * a_dim1] = 1.; |
| 5840 | |
| 5841 | /* Apply H(i) to A(i+1:m,i+1:n) from the left */ |
| 5842 | |
| 5843 | i__2 = *m - i__; |
| 5844 | i__3 = *n - i__; |
| 5845 | dlarf_cxx . . $ dlarf_(f67bbcf4c4b4eb96).("Left", &i__2, &i__3, &a[i__ + 1 + i__ * a_dim1], & |
| 5846 | c__1, &tauq[i__], &a[i__ + 1 + (i__ + 1) * a_dim1], |
| 5847 | lda, &work[1]); |
| 5848 | a[i__ + 1 + i__ * a_dim1] = e[i__]; |
| 5849 | } else { |
| 5850 | tauq[i__] = 0.; |
| 5851 | } |
| 5852 | /* L20: */ |
| 5853 | } |
| 5854 | } |
| 5855 | return 0; |
| 5856 | |
| 5857 | /* End of DGEBD2 */ |
| 5858 | |
| 5859 | } /* dgebd2_ */ |
| 5860 | |
| 5861 | /* Subroutine */ int dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(integercxx . . $ integer# *m, integercxx . . $ integer# *n, double *a, integercxx . . $ integer# * |
| 5862 | lda, double *d__, double *e, double *tauq, double * |
| 5863 | taup, double *work, integercxx . . $ integer# *lwork, integercxx . . $ integer# *info) |
| 5864 | { |
| 5865 | /* Table of constant values */ |
| 5866 | static integercxx . . $ integer# c__1 = 1; |
| 5867 | static integercxx . . $ integer# c_n1 = -1; |
| 5868 | static integercxx . . $ integer# c__3 = 3; |
| 5869 | static integercxx . . $ integer# c__2 = 2; |
| 5870 | static double c_b21 = -1.; |
| 5871 | static double c_b22 = 1.; |
| 5872 | |
| 5873 | /* System generated locals */ |
| 5874 | integercxx . . $ integer# a_dim1, a_offset, i__1, i__2, i__3, i__4; |
| 5875 | |
| 5876 | /* Local variables */ |
| 5877 | integercxx . . $ integer# i__, j, nb, nx; |
| 5878 | double ws; |
| 5879 | integercxx . . $ integer# nbmin, iinfo, minmn; |
| 5880 | integercxx . . $ integer# ldwrkx, ldwrky, lwkopt; |
| 5881 | bool lquery; |
| 5882 | |
| 5883 | |
| 5884 | /* -- LAPACK routine (version 3.1) -- */ |
| 5885 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 5886 | /* November 2006 */ |
| 5887 | |
| 5888 | /* .. Scalar Arguments .. */ |
| 5889 | /* .. */ |
| 5890 | /* .. Array Arguments .. */ |
| 5891 | /* .. */ |
| 5892 | |
| 5893 | /* Purpose */ |
| 5894 | /* ======= */ |
| 5895 | |
| 5896 | /* DGEBRD reduces a general real M-by-N matrix A to upper or lower */ |
| 5897 | /* bidiagonal form B by an orthogonal transformation: Q**T * A * P = B. */ |
| 5898 | |
| 5899 | /* If m >= n, B is upper bidiagonal; if m < n, B is lower bidiagonal. */ |
| 5900 | |
| 5901 | /* Arguments */ |
| 5902 | /* ========= */ |
| 5903 | |
| 5904 | /* M (input) INTEGER */ |
| 5905 | /* The number of rows in the matrix A. M >= 0. */ |
| 5906 | |
| 5907 | /* N (input) INTEGER */ |
| 5908 | /* The number of columns in the matrix A. N >= 0. */ |
| 5909 | |
| 5910 | /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 5911 | /* On entry, the M-by-N general matrix to be reduced. */ |
| 5912 | /* On exit, */ |
| 5913 | /* if m >= n, the diagonal and the first superdiagonal are */ |
| 5914 | /* overwritten with the upper bidiagonal matrix B; the */ |
| 5915 | /* elements below the diagonal, with the array TAUQ, represent */ |
| 5916 | /* the orthogonal matrix Q as a product of elementary */ |
| 5917 | /* reflectors, and the elements above the first superdiagonal, */ |
| 5918 | /* with the array TAUP, represent the orthogonal matrix P as */ |
| 5919 | /* a product of elementary reflectors; */ |
| 5920 | /* if m < n, the diagonal and the first subdiagonal are */ |
| 5921 | /* overwritten with the lower bidiagonal matrix B; the */ |
| 5922 | /* elements below the first subdiagonal, with the array TAUQ, */ |
| 5923 | /* represent the orthogonal matrix Q as a product of */ |
| 5924 | /* elementary reflectors, and the elements above the diagonal, */ |
| 5925 | /* with the array TAUP, represent the orthogonal matrix P as */ |
| 5926 | /* a product of elementary reflectors. */ |
| 5927 | /* See Further Details. */ |
| 5928 | |
| 5929 | /* LDA (input) INTEGER */ |
| 5930 | /* The leading dimension of the array A. LDA >= max(1,M). */ |
| 5931 | |
| 5932 | /* D (output) DOUBLE PRECISION array, dimension (min(M,N)) */ |
| 5933 | /* The diagonal elements of the bidiagonal matrix B: */ |
| 5934 | /* D(i) = A(i,i). */ |
| 5935 | |
| 5936 | /* E (output) DOUBLE PRECISION array, dimension (min(M,N)-1) */ |
| 5937 | /* The off-diagonal elements of the bidiagonal matrix B: */ |
| 5938 | /* if m >= n, E(i) = A(i,i+1) for i = 1,2,...,n-1; */ |
| 5939 | /* if m < n, E(i) = A(i+1,i) for i = 1,2,...,m-1. */ |
| 5940 | |
| 5941 | /* TAUQ (output) DOUBLE PRECISION array dimension (min(M,N)) */ |
| 5942 | /* The scalar factors of the elementary reflectors which */ |
| 5943 | /* represent the orthogonal matrix Q. See Further Details. */ |
| 5944 | |
| 5945 | /* TAUP (output) DOUBLE PRECISION array, dimension (min(M,N)) */ |
| 5946 | /* The scalar factors of the elementary reflectors which */ |
| 5947 | /* represent the orthogonal matrix P. See Further Details. */ |
| 5948 | |
| 5949 | /* WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) */ |
| 5950 | /* On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ |
| 5951 | |
| 5952 | /* LWORK (input) INTEGER */ |
| 5953 | /* The length of the array WORK. LWORK >= max(1,M,N). */ |
| 5954 | /* For optimum performance LWORK >= (M+N)*NB, where NB */ |
| 5955 | /* is the optimal blocksize. */ |
| 5956 | |
| 5957 | /* If LWORK = -1, then a workspace query is assumed; the routine */ |
| 5958 | /* only calculates the optimal size of the WORK array, returns */ |
| 5959 | /* this value as the first entry of the WORK array, and no error */ |
| 5960 | /* message related to LWORK is issued by XERBLA. */ |
| 5961 | |
| 5962 | /* INFO (output) INTEGER */ |
| 5963 | /* = 0: successful exit */ |
| 5964 | /* < 0: if INFO = -i, the i-th argument had an illegal value. */ |
| 5965 | |
| 5966 | /* Further Details */ |
| 5967 | /* =============== */ |
| 5968 | |
| 5969 | /* The matrices Q and P are represented as products of elementary */ |
| 5970 | /* reflectors: */ |
| 5971 | |
| 5972 | /* If m >= n, */ |
| 5973 | |
| 5974 | /* Q = H(1) H(2) . . . H(n) and P = G(1) G(2) . . . G(n-1) */ |
| 5975 | |
| 5976 | /* Each H(i) and G(i) has the form: */ |
| 5977 | |
| 5978 | /* H(i) = I - tauq * v * v' and G(i) = I - taup * u * u' */ |
| 5979 | |
| 5980 | /* where tauq and taup are real scalars, and v and u are real vectors; */ |
| 5981 | /* v(1:i-1) = 0, v(i) = 1, and v(i+1:m) is stored on exit in A(i+1:m,i); */ |
| 5982 | /* u(1:i) = 0, u(i+1) = 1, and u(i+2:n) is stored on exit in A(i,i+2:n); */ |
| 5983 | /* tauq is stored in TAUQ(i) and taup in TAUP(i). */ |
| 5984 | |
| 5985 | /* If m < n, */ |
| 5986 | |
| 5987 | /* Q = H(1) H(2) . . . H(m-1) and P = G(1) G(2) . . . G(m) */ |
| 5988 | |
| 5989 | /* Each H(i) and G(i) has the form: */ |
| 5990 | |
| 5991 | /* H(i) = I - tauq * v * v' and G(i) = I - taup * u * u' */ |
| 5992 | |
| 5993 | /* where tauq and taup are real scalars, and v and u are real vectors; */ |
| 5994 | /* v(1:i) = 0, v(i+1) = 1, and v(i+2:m) is stored on exit in A(i+2:m,i); */ |
| 5995 | /* u(1:i-1) = 0, u(i) = 1, and u(i+1:n) is stored on exit in A(i,i+1:n); */ |
| 5996 | /* tauq is stored in TAUQ(i) and taup in TAUP(i). */ |
| 5997 | |
| 5998 | /* The contents of A on exit are illustrated by the following examples: */ |
| 5999 | |
| 6000 | /* m = 6 and n = 5 (m > n): m = 5 and n = 6 (m < n): */ |
| 6001 | |
| 6002 | /* ( d e u1 u1 u1 ) ( d u1 u1 u1 u1 u1 ) */ |
| 6003 | /* ( v1 d e u2 u2 ) ( e d u2 u2 u2 u2 ) */ |
| 6004 | /* ( v1 v2 d e u3 ) ( v1 e d u3 u3 u3 ) */ |
| 6005 | /* ( v1 v2 v3 d e ) ( v1 v2 e d u4 u4 ) */ |
| 6006 | /* ( v1 v2 v3 v4 d ) ( v1 v2 v3 e d u5 ) */ |
| 6007 | /* ( v1 v2 v3 v4 v5 ) */ |
| 6008 | |
| 6009 | /* where d and e denote diagonal and off-diagonal elements of B, vi */ |
| 6010 | /* denotes an element of the vector defining H(i), and ui an element of */ |
| 6011 | /* the vector defining G(i). */ |
| 6012 | |
| 6013 | /* ===================================================================== */ |
| 6014 | |
| 6015 | /* .. Parameters .. */ |
| 6016 | /* .. */ |
| 6017 | /* .. Local Scalars .. */ |
| 6018 | /* .. */ |
| 6019 | /* .. External Subroutines .. */ |
| 6020 | /* .. */ |
| 6021 | /* .. Intrinsic Functions .. */ |
| 6022 | /* .. */ |
| 6023 | /* .. External Functions .. */ |
| 6024 | /* .. */ |
| 6025 | /* .. Executable Statements .. */ |
| 6026 | |
| 6027 | /* Test the input parameters */ |
| 6028 | |
| 6029 | /* Parameter adjustments */ |
| 6030 | a_dim1 = *lda; |
| 6031 | a_offset = 1 + a_dim1; |
| 6032 | a -= a_offset; |
| 6033 | --d__; |
| 6034 | --e; |
| 6035 | --tauq; |
| 6036 | --taup; |
| 6037 | --work; |
| 6038 | |
| 6039 | /* Function Body */ |
| 6040 | *info = 0; |
| 6041 | /* Computing MAX */ |
| 6042 | i__1 = 1, i__2 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEBRD", " ", m, n, &c_n1, &c_n1); |
| 6043 | nb = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 6044 | lwkopt = (*m + *n) * nb; |
| 6045 | work[1] = (double) lwkopt; |
| 6046 | lquery = *lwork == -1; |
| 6047 | if (*m < 0) { |
| 6048 | *info = -1; |
| 6049 | } else if (*n < 0) { |
| 6050 | *info = -2; |
| 6051 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*m)) { |
| 6052 | *info = -4; |
| 6053 | } else /* if(complicated condition) */ { |
| 6054 | /* Computing MAX */ |
| 6055 | i__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*m); |
| 6056 | if (*lwork < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,*n) && ! lquery) { |
| 6057 | *info = -10; |
| 6058 | } |
| 6059 | } |
| 6060 | if (*info < 0) { |
| 6061 | i__1 = -(*info); |
| 6062 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGEBRD", &i__1); |
| 6063 | return 0; |
| 6064 | } else if (lquery) { |
| 6065 | return 0; |
| 6066 | } |
| 6067 | |
| 6068 | /* Quick return if possible */ |
| 6069 | |
| 6070 | minmn = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(*m,*n); |
| 6071 | if (minmn == 0) { |
| 6072 | work[1] = 1.; |
| 6073 | return 0; |
| 6074 | } |
| 6075 | |
| 6076 | ws = (double) stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(*m,*n); |
| 6077 | ldwrkx = *m; |
| 6078 | ldwrky = *n; |
| 6079 | |
| 6080 | if (nb > 1 && nb < minmn) { |
| 6081 | |
| 6082 | /* Set the crossover point NX. */ |
| 6083 | |
| 6084 | /* Computing MAX */ |
| 6085 | i__1 = nb, i__2 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__3, "DGEBRD", " ", m, n, &c_n1, &c_n1); |
| 6086 | nx = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 6087 | |
| 6088 | /* Determine when to switch from blocked to unblocked code. */ |
| 6089 | |
| 6090 | if (nx < minmn) { |
| 6091 | ws = (double) ((*m + *n) * nb); |
| 6092 | if ((double) (*lwork) < ws) { |
| 6093 | |
| 6094 | /* Not enough work space for the optimal NB, consider using */ |
| 6095 | /* a smaller block size. */ |
| 6096 | |
| 6097 | nbmin = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__2, "DGEBRD", " ", m, n, &c_n1, &c_n1); |
| 6098 | if (*lwork >= (*m + *n) * nbmin) { |
| 6099 | nb = *lwork / (*m + *n); |
| 6100 | } else { |
| 6101 | nb = 1; |
| 6102 | nx = minmn; |
| 6103 | } |
| 6104 | } |
| 6105 | } |
| 6106 | } else { |
| 6107 | nx = minmn; |
| 6108 | } |
| 6109 | |
| 6110 | i__1 = minmn - nx; |
| 6111 | i__2 = nb; |
| 6112 | for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) { |
| 6113 | |
| 6114 | /* Reduce rows and columns i:i+nb-1 to bidiagonal form and return */ |
| 6115 | /* the matrices X and Y which are needed to update the unreduced */ |
| 6116 | /* part of the matrix */ |
| 6117 | |
| 6118 | i__3 = *m - i__ + 1; |
| 6119 | i__4 = *n - i__ + 1; |
| 6120 | dlabrd_cxx . . $ dlabrd_(f0fbf790c39930a7).(&i__3, &i__4, &nb, &a[i__ + i__ * a_dim1], lda, &d__[i__], &e[ |
| 6121 | i__], &tauq[i__], &taup[i__], &work[1], &ldwrkx, &work[ldwrkx |
| 6122 | * nb + 1], &ldwrky); |
| 6123 | |
| 6124 | /* Update the trailing submatrix A(i+nb:m,i+nb:n), using an update */ |
| 6125 | /* of the form A := A - V*Y' - X*U' */ |
| 6126 | |
| 6127 | i__3 = *m - i__ - nb + 1; |
| 6128 | i__4 = *n - i__ - nb + 1; |
| 6129 | dgemm_cxx . . $ dgemm_(7f9a15c7502022ea).("No transpose", "Transpose", &i__3, &i__4, &nb, &c_b21, &a[i__ |
| 6130 | + nb + i__ * a_dim1], lda, &work[ldwrkx * nb + nb + 1], & |
| 6131 | ldwrky, &c_b22, &a[i__ + nb + (i__ + nb) * a_dim1], lda); |
| 6132 | i__3 = *m - i__ - nb + 1; |
| 6133 | i__4 = *n - i__ - nb + 1; |
| 6134 | dgemm_cxx . . $ dgemm_(7f9a15c7502022ea).("No transpose", "No transpose", &i__3, &i__4, &nb, &c_b21, & |
| 6135 | work[nb + 1], &ldwrkx, &a[i__ + (i__ + nb) * a_dim1], lda, & |
| 6136 | c_b22, &a[i__ + nb + (i__ + nb) * a_dim1], lda); |
| 6137 | |
| 6138 | /* Copy diagonal and off-diagonal elements of B back into A */ |
| 6139 | |
| 6140 | if (*m >= *n) { |
| 6141 | i__3 = i__ + nb - 1; |
| 6142 | for (j = i__; j <= i__3; ++j) { |
| 6143 | a[j + j * a_dim1] = d__[j]; |
| 6144 | a[j + (j + 1) * a_dim1] = e[j]; |
| 6145 | /* L10: */ |
| 6146 | } |
| 6147 | } else { |
| 6148 | i__3 = i__ + nb - 1; |
| 6149 | for (j = i__; j <= i__3; ++j) { |
| 6150 | a[j + j * a_dim1] = d__[j]; |
| 6151 | a[j + 1 + j * a_dim1] = e[j]; |
| 6152 | /* L20: */ |
| 6153 | } |
| 6154 | } |
| 6155 | /* L30: */ |
| 6156 | } |
| 6157 | |
| 6158 | /* Use unblocked code to reduce the remainder of the matrix */ |
| 6159 | |
| 6160 | i__2 = *m - i__ + 1; |
| 6161 | i__1 = *n - i__ + 1; |
| 6162 | dgebd2_cxx . . $ dgebd2_(799434dec6c8879c).(&i__2, &i__1, &a[i__ + i__ * a_dim1], lda, &d__[i__], &e[i__], & |
| 6163 | tauq[i__], &taup[i__], &work[1], &iinfo); |
| 6164 | work[1] = ws; |
| 6165 | return 0; |
| 6166 | |
| 6167 | /* End of DGEBRD */ |
| 6168 | |
| 6169 | } /* dgebrd_ */ |
| 6170 | |
| 6171 | /* Subroutine */ int dgecon_cxx . . $ dgecon_(c4c31d5cb8de3c00).(const char *norm, integercxx . . $ integer# *n, double *a, integercxx . . $ integer# * |
| 6172 | lda, double *anorm, double *rcond, double *work, integercxx . . $ integer# * |
| 6173 | iwork, integercxx . . $ integer# *info) |
| 6174 | { |
| 6175 | /* Table of constant values */ |
| 6176 | static integercxx . . $ integer# c__1 = 1; |
| 6177 | |
| 6178 | /* System generated locals */ |
| 6179 | integercxx . . $ integer# a_dim1, a_offset, i__1; |
| 6180 | double d__1; |
| 6181 | |
| 6182 | /* Local variables */ |
| 6183 | double sl; |
| 6184 | integercxx . . $ integer# ix; |
| 6185 | double su; |
| 6186 | integercxx . . $ integer# kase, kase1; |
| 6187 | double scale; |
| 6188 | integercxx . . $ integer# isave[3]; |
| 6189 | double ainvnm; |
| 6190 | bool onenrm; |
| 6191 | char normin[1]; |
| 6192 | double smlnum; |
| 6193 | |
| 6194 | |
| 6195 | /* -- LAPACK routine (version 3.1) -- */ |
| 6196 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 6197 | /* November 2006 */ |
| 6198 | |
| 6199 | /* Modified to call DLACN2 in place of DLACON, 5 Feb 03, SJH. */ |
| 6200 | |
| 6201 | /* .. Scalar Arguments .. */ |
| 6202 | /* .. */ |
| 6203 | /* .. Array Arguments .. */ |
| 6204 | /* .. */ |
| 6205 | |
| 6206 | /* Purpose */ |
| 6207 | /* ======= */ |
| 6208 | |
| 6209 | /* DGECON estimates the reciprocal of the condition number of a general */ |
| 6210 | /* real matrix A, in either the 1-norm or the infinity-norm, using */ |
| 6211 | /* the LU factorization computed by DGETRF. */ |
| 6212 | |
| 6213 | /* An estimate is obtained for norm(inv(A)), and the reciprocal of the */ |
| 6214 | /* condition number is computed as */ |
| 6215 | /* RCOND = 1 / ( norm(A) * norm(inv(A)) ). */ |
| 6216 | |
| 6217 | /* Arguments */ |
| 6218 | /* ========= */ |
| 6219 | |
| 6220 | /* NORM (input) CHARACTER*1 */ |
| 6221 | /* Specifies whether the 1-norm condition number or the */ |
| 6222 | /* infinity-norm condition number is required: */ |
| 6223 | /* = '1' or 'O': 1-norm; */ |
| 6224 | /* = 'I': Infinity-norm. */ |
| 6225 | |
| 6226 | /* N (input) INTEGER */ |
| 6227 | /* The order of the matrix A. N >= 0. */ |
| 6228 | |
| 6229 | /* A (input) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 6230 | /* The factors L and U from the factorization A = P*L*U */ |
| 6231 | /* as computed by DGETRF. */ |
| 6232 | |
| 6233 | /* LDA (input) INTEGER */ |
| 6234 | /* The leading dimension of the array A. LDA >= max(1,N). */ |
| 6235 | |
| 6236 | /* ANORM (input) DOUBLE PRECISION */ |
| 6237 | /* If NORM = '1' or 'O', the 1-norm of the original matrix A. */ |
| 6238 | /* If NORM = 'I', the infinity-norm of the original matrix A. */ |
| 6239 | |
| 6240 | /* RCOND (output) DOUBLE PRECISION */ |
| 6241 | /* The reciprocal of the condition number of the matrix A, */ |
| 6242 | /* computed as RCOND = 1/(norm(A) * norm(inv(A))). */ |
| 6243 | |
| 6244 | /* WORK (workspace) DOUBLE PRECISION array, dimension (4*N) */ |
| 6245 | |
| 6246 | /* IWORK (workspace) INTEGER array, dimension (N) */ |
| 6247 | |
| 6248 | /* INFO (output) INTEGER */ |
| 6249 | /* = 0: successful exit */ |
| 6250 | /* < 0: if INFO = -i, the i-th argument had an illegal value */ |
| 6251 | |
| 6252 | /* ===================================================================== */ |
| 6253 | |
| 6254 | /* .. Parameters .. */ |
| 6255 | /* .. */ |
| 6256 | /* .. Local Scalars .. */ |
| 6257 | /* .. */ |
| 6258 | /* .. Local Arrays .. */ |
| 6259 | /* .. */ |
| 6260 | /* .. External Functions .. */ |
| 6261 | /* .. */ |
| 6262 | /* .. External Subroutines .. */ |
| 6263 | /* .. */ |
| 6264 | /* .. Intrinsic Functions .. */ |
| 6265 | /* .. */ |
| 6266 | /* .. Executable Statements .. */ |
| 6267 | |
| 6268 | /* Test the input parameters. */ |
| 6269 | |
| 6270 | /* Parameter adjustments */ |
| 6271 | a_dim1 = *lda; |
| 6272 | a_offset = 1 + a_dim1; |
| 6273 | a -= a_offset; |
| 6274 | --work; |
| 6275 | --iwork; |
| 6276 | |
| 6277 | /* Function Body */ |
| 6278 | *info = 0; |
| 6279 | onenrm = *(unsigned char *)norm == '1' || lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(norm, "O"); |
| 6280 | if (! onenrm && ! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(norm, "I")) { |
| 6281 | *info = -1; |
| 6282 | } else if (*n < 0) { |
| 6283 | *info = -2; |
| 6284 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 6285 | *info = -4; |
| 6286 | } else if (*anorm < 0.) { |
| 6287 | *info = -5; |
| 6288 | } |
| 6289 | if (*info != 0) { |
| 6290 | i__1 = -(*info); |
| 6291 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGECON", &i__1); |
| 6292 | return 0; |
| 6293 | } |
| 6294 | |
| 6295 | /* Quick return if possible */ |
| 6296 | |
| 6297 | *rcond = 0.; |
| 6298 | if (*n == 0) { |
| 6299 | *rcond = 1.; |
| 6300 | return 0; |
| 6301 | } else if (*anorm == 0.) { |
| 6302 | return 0; |
| 6303 | } |
| 6304 | |
| 6305 | smlnum = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("Safe minimum"); |
| 6306 | |
| 6307 | /* Estimate the norm of inv(A). */ |
| 6308 | |
| 6309 | ainvnm = 0.; |
| 6310 | *(unsigned char *)normin = 'N'; |
| 6311 | if (onenrm) { |
| 6312 | kase1 = 1; |
| 6313 | } else { |
| 6314 | kase1 = 2; |
| 6315 | } |
| 6316 | kase = 0; |
| 6317 | L10: |
| 6318 | dlacn2_cxx . . $ dlacn2_(2d9e0fe6bd3e0917).(n, &work[*n + 1], &work[1], &iwork[1], &ainvnm, &kase, isave); |
| 6319 | if (kase != 0) { |
| 6320 | if (kase == kase1) { |
| 6321 | |
| 6322 | /* Multiply by inv(L). */ |
| 6323 | |
| 6324 | dlatrs_cxx . . $ dlatrs_(975eda200f349d36).("Lower", "No transpose", "Unit", normin, n, &a[a_offset], |
| 6325 | lda, &work[1], &sl, &work[(*n << 1) + 1], info); |
| 6326 | |
| 6327 | /* Multiply by inv(U). */ |
| 6328 | |
| 6329 | dlatrs_cxx . . $ dlatrs_(975eda200f349d36).("Upper", "No transpose", "Non-unit", normin, n, &a[ |
| 6330 | a_offset], lda, &work[1], &su, &work[*n * 3 + 1], info); |
| 6331 | } else { |
| 6332 | |
| 6333 | /* Multiply by inv(U'). */ |
| 6334 | |
| 6335 | dlatrs_cxx . . $ dlatrs_(975eda200f349d36).("Upper", "Transpose", "Non-unit", normin, n, &a[a_offset], |
| 6336 | lda, &work[1], &su, &work[*n * 3 + 1], info); |
| 6337 | |
| 6338 | /* Multiply by inv(L'). */ |
| 6339 | |
| 6340 | dlatrs_cxx . . $ dlatrs_(975eda200f349d36).("Lower", "Transpose", "Unit", normin, n, &a[a_offset], |
| 6341 | lda, &work[1], &sl, &work[(*n << 1) + 1], info); |
| 6342 | } |
| 6343 | |
| 6344 | /* Divide X by 1/(SL*SU) if doing so will not cause overflow. */ |
| 6345 | |
| 6346 | scale = sl * su; |
| 6347 | *(unsigned char *)normin = 'Y'; |
| 6348 | if (scale != 1.) { |
| 6349 | ix = idamax_cxx . . $ idamax_(a5c31fbfbc00ee45).(n, &work[1], &c__1); |
| 6350 | if (scale < (d__1 = work[ix], abscxx . . $ abs(447c67c6676f75c3).(d__1)) * smlnum || scale == 0.) |
| 6351 | { |
| 6352 | goto L20; |
| 6353 | } |
| 6354 | drscl_cxx . . $ drscl_(f22c1db71784c345).(n, &scale, &work[1], &c__1); |
| 6355 | } |
| 6356 | goto L10; |
| 6357 | } |
| 6358 | |
| 6359 | /* Compute the estimate of the reciprocal condition number. */ |
| 6360 | |
| 6361 | if (ainvnm != 0.) { |
| 6362 | *rcond = 1. / ainvnm / *anorm; |
| 6363 | } |
| 6364 | |
| 6365 | L20: |
| 6366 | return 0; |
| 6367 | |
| 6368 | /* End of DGECON */ |
| 6369 | |
| 6370 | } /* dgecon_ */ |
| 6371 | |
| 6372 | /* Subroutine */ int dgeequ_cxx . . $ dgeequ_(799434dec6c8879c).(integercxx . . $ integer# *m, integercxx . . $ integer# *n, double *a, integercxx . . $ integer# * |
| 6373 | lda, double *r__, double *c__, double *rowcnd, double |
| 6374 | *colcnd, double *amax, integercxx . . $ integer# *info) |
| 6375 | { |
| 6376 | /* System generated locals */ |
| 6377 | integercxx . . $ integer# a_dim1, a_offset, i__1, i__2; |
| 6378 | double d__1, d__2, d__3; |
| 6379 | |
| 6380 | /* Local variables */ |
| 6381 | integercxx . . $ integer# i__, j; |
| 6382 | double rcmin, rcmax; |
| 6383 | double bignum, smlnum; |
| 6384 | |
| 6385 | |
| 6386 | /* -- LAPACK routine (version 3.1) -- */ |
| 6387 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 6388 | /* November 2006 */ |
| 6389 | |
| 6390 | /* .. Scalar Arguments .. */ |
| 6391 | /* .. */ |
| 6392 | /* .. Array Arguments .. */ |
| 6393 | /* .. */ |
| 6394 | |
| 6395 | /* Purpose */ |
| 6396 | /* ======= */ |
| 6397 | |
| 6398 | /* DGEEQU computes row and column scalings intended to equilibrate an */ |
| 6399 | /* M-by-N matrix A and reduce its condition number. R returns the row */ |
| 6400 | /* scale factors and C the column scale factors, chosen to try to make */ |
| 6401 | /* the largest element in each row and column of the matrix B with */ |
| 6402 | /* elements B(i,j)=R(i)*A(i,j)*C(j) have absolute value 1. */ |
| 6403 | |
| 6404 | /* R(i) and C(j) are restricted to be between SMLNUM = smallest safe */ |
| 6405 | /* number and BIGNUM = largest safe number. Use of these scaling */ |
| 6406 | /* factors is not guaranteed to reduce the condition number of A but */ |
| 6407 | /* works well in practice. */ |
| 6408 | |
| 6409 | /* Arguments */ |
| 6410 | /* ========= */ |
| 6411 | |
| 6412 | /* M (input) INTEGER */ |
| 6413 | /* The number of rows of the matrix A. M >= 0. */ |
| 6414 | |
| 6415 | /* N (input) INTEGER */ |
| 6416 | /* The number of columns of the matrix A. N >= 0. */ |
| 6417 | |
| 6418 | /* A (input) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 6419 | /* The M-by-N matrix whose equilibration factors are */ |
| 6420 | /* to be computed. */ |
| 6421 | |
| 6422 | /* LDA (input) INTEGER */ |
| 6423 | /* The leading dimension of the array A. LDA >= max(1,M). */ |
| 6424 | |
| 6425 | /* R (output) DOUBLE PRECISION array, dimension (M) */ |
| 6426 | /* If INFO = 0 or INFO > M, R contains the row scale factors */ |
| 6427 | /* for A. */ |
| 6428 | |
| 6429 | /* C (output) DOUBLE PRECISION array, dimension (N) */ |
| 6430 | /* If INFO = 0, C contains the column scale factors for A. */ |
| 6431 | |
| 6432 | /* ROWCND (output) DOUBLE PRECISION */ |
| 6433 | /* If INFO = 0 or INFO > M, ROWCND contains the ratio of the */ |
| 6434 | /* smallest R(i) to the largest R(i). If ROWCND >= 0.1 and */ |
| 6435 | /* AMAX is neither too large nor too small, it is not worth */ |
| 6436 | /* scaling by R. */ |
| 6437 | |
| 6438 | /* COLCND (output) DOUBLE PRECISION */ |
| 6439 | /* If INFO = 0, COLCND contains the ratio of the smallest */ |
| 6440 | /* C(i) to the largest C(i). If COLCND >= 0.1, it is not */ |
| 6441 | /* worth scaling by C. */ |
| 6442 | |
| 6443 | /* AMAX (output) DOUBLE PRECISION */ |
| 6444 | /* Absolute value of largest matrix element. If AMAX is very */ |
| 6445 | /* close to overflow or very close to underflow, the matrix */ |
| 6446 | /* should be scaled. */ |
| 6447 | |
| 6448 | /* INFO (output) INTEGER */ |
| 6449 | /* = 0: successful exit */ |
| 6450 | /* < 0: if INFO = -i, the i-th argument had an illegal value */ |
| 6451 | /* > 0: if INFO = i, and i is */ |
| 6452 | /* <= M: the i-th row of A is exactly zero */ |
| 6453 | /* > M: the (i-M)-th column of A is exactly zero */ |
| 6454 | |
| 6455 | /* ===================================================================== */ |
| 6456 | |
| 6457 | /* .. Parameters .. */ |
| 6458 | /* .. */ |
| 6459 | /* .. Local Scalars .. */ |
| 6460 | /* .. */ |
| 6461 | /* .. External Functions .. */ |
| 6462 | /* .. */ |
| 6463 | /* .. External Subroutines .. */ |
| 6464 | /* .. */ |
| 6465 | /* .. Intrinsic Functions .. */ |
| 6466 | /* .. */ |
| 6467 | /* .. Executable Statements .. */ |
| 6468 | |
| 6469 | /* Test the input parameters. */ |
| 6470 | |
| 6471 | /* Parameter adjustments */ |
| 6472 | a_dim1 = *lda; |
| 6473 | a_offset = 1 + a_dim1; |
| 6474 | a -= a_offset; |
| 6475 | --r__; |
| 6476 | --c__; |
| 6477 | |
| 6478 | /* Function Body */ |
| 6479 | *info = 0; |
| 6480 | if (*m < 0) { |
| 6481 | *info = -1; |
| 6482 | } else if (*n < 0) { |
| 6483 | *info = -2; |
| 6484 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*m)) { |
| 6485 | *info = -4; |
| 6486 | } |
| 6487 | if (*info != 0) { |
| 6488 | i__1 = -(*info); |
| 6489 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGEEQU", &i__1); |
| 6490 | return 0; |
| 6491 | } |
| 6492 | |
| 6493 | /* Quick return if possible */ |
| 6494 | |
| 6495 | if (*m == 0 || *n == 0) { |
| 6496 | *rowcnd = 1.; |
| 6497 | *colcnd = 1.; |
| 6498 | *amax = 0.; |
| 6499 | return 0; |
| 6500 | } |
| 6501 | |
| 6502 | /* Get machine constants. */ |
| 6503 | |
| 6504 | smlnum = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("S"); |
| 6505 | bignum = 1. / smlnum; |
| 6506 | |
| 6507 | /* Compute row scale factors. */ |
| 6508 | |
| 6509 | i__1 = *m; |
| 6510 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 6511 | r__[i__] = 0.; |
| 6512 | /* L10: */ |
| 6513 | } |
| 6514 | |
| 6515 | /* Find the maximum element in each row. */ |
| 6516 | |
| 6517 | i__1 = *n; |
| 6518 | for (j = 1; j <= i__1; ++j) { |
| 6519 | i__2 = *m; |
| 6520 | for (i__ = 1; i__ <= i__2; ++i__) { |
| 6521 | /* Computing MAX */ |
| 6522 | d__2 = r__[i__], d__3 = (d__1 = a[i__ + j * a_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__1)); |
| 6523 | r__[i__] = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__2,d__3); |
| 6524 | /* L20: */ |
| 6525 | } |
| 6526 | /* L30: */ |
| 6527 | } |
| 6528 | |
| 6529 | /* Find the maximum and minimum scale factors. */ |
| 6530 | |
| 6531 | rcmin = bignum; |
| 6532 | rcmax = 0.; |
| 6533 | i__1 = *m; |
| 6534 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 6535 | /* Computing MAX */ |
| 6536 | d__1 = rcmax, d__2 = r__[i__]; |
| 6537 | rcmax = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__1,d__2); |
| 6538 | /* Computing MIN */ |
| 6539 | d__1 = rcmin, d__2 = r__[i__]; |
| 6540 | rcmin = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(d__1,d__2); |
| 6541 | /* L40: */ |
| 6542 | } |
| 6543 | *amax = rcmax; |
| 6544 | |
| 6545 | if (rcmin == 0.) { |
| 6546 | |
| 6547 | /* Find the first zero scale factor and return an error code. */ |
| 6548 | |
| 6549 | i__1 = *m; |
| 6550 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 6551 | if (r__[i__] == 0.) { |
| 6552 | *info = i__; |
| 6553 | return 0; |
| 6554 | } |
| 6555 | /* L50: */ |
| 6556 | } |
| 6557 | } else { |
| 6558 | |
| 6559 | /* Invert the scale factors. */ |
| 6560 | |
| 6561 | i__1 = *m; |
| 6562 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 6563 | /* Computing MIN */ |
| 6564 | /* Computing MAX */ |
| 6565 | d__2 = r__[i__]; |
| 6566 | d__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__2,smlnum); |
| 6567 | r__[i__] = 1. / stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(d__1,bignum); |
| 6568 | /* L60: */ |
| 6569 | } |
| 6570 | |
| 6571 | /* Compute ROWCND = min(R(I)) / max(R(I)) */ |
| 6572 | |
| 6573 | *rowcnd = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(rcmin,smlnum) / stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(rcmax,bignum); |
| 6574 | } |
| 6575 | |
| 6576 | /* Compute column scale factors */ |
| 6577 | |
| 6578 | i__1 = *n; |
| 6579 | for (j = 1; j <= i__1; ++j) { |
| 6580 | c__[j] = 0.; |
| 6581 | /* L70: */ |
| 6582 | } |
| 6583 | |
| 6584 | /* Find the maximum element in each column, */ |
| 6585 | /* assuming the row scaling computed above. */ |
| 6586 | |
| 6587 | i__1 = *n; |
| 6588 | for (j = 1; j <= i__1; ++j) { |
| 6589 | i__2 = *m; |
| 6590 | for (i__ = 1; i__ <= i__2; ++i__) { |
| 6591 | /* Computing MAX */ |
| 6592 | d__2 = c__[j], d__3 = (d__1 = a[i__ + j * a_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__1)) * |
| 6593 | r__[i__]; |
| 6594 | c__[j] = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__2,d__3); |
| 6595 | /* L80: */ |
| 6596 | } |
| 6597 | /* L90: */ |
| 6598 | } |
| 6599 | |
| 6600 | /* Find the maximum and minimum scale factors. */ |
| 6601 | |
| 6602 | rcmin = bignum; |
| 6603 | rcmax = 0.; |
| 6604 | i__1 = *n; |
| 6605 | for (j = 1; j <= i__1; ++j) { |
| 6606 | /* Computing MIN */ |
| 6607 | d__1 = rcmin, d__2 = c__[j]; |
| 6608 | rcmin = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(d__1,d__2); |
| 6609 | /* Computing MAX */ |
| 6610 | d__1 = rcmax, d__2 = c__[j]; |
| 6611 | rcmax = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__1,d__2); |
| 6612 | /* L100: */ |
| 6613 | } |
| 6614 | |
| 6615 | if (rcmin == 0.) { |
| 6616 | |
| 6617 | /* Find the first zero scale factor and return an error code. */ |
| 6618 | |
| 6619 | i__1 = *n; |
| 6620 | for (j = 1; j <= i__1; ++j) { |
| 6621 | if (c__[j] == 0.) { |
| 6622 | *info = *m + j; |
| 6623 | return 0; |
| 6624 | } |
| 6625 | /* L110: */ |
| 6626 | } |
| 6627 | } else { |
| 6628 | |
| 6629 | /* Invert the scale factors. */ |
| 6630 | |
| 6631 | i__1 = *n; |
| 6632 | for (j = 1; j <= i__1; ++j) { |
| 6633 | /* Computing MIN */ |
| 6634 | /* Computing MAX */ |
| 6635 | d__2 = c__[j]; |
| 6636 | d__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__2,smlnum); |
| 6637 | c__[j] = 1. / stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(d__1,bignum); |
| 6638 | /* L120: */ |
| 6639 | } |
| 6640 | |
| 6641 | /* Compute COLCND = min(C(J)) / max(C(J)) */ |
| 6642 | |
| 6643 | *colcnd = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(rcmin,smlnum) / stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(rcmax,bignum); |
| 6644 | } |
| 6645 | |
| 6646 | return 0; |
| 6647 | |
| 6648 | /* End of DGEEQU */ |
| 6649 | |
| 6650 | } /* dgeequ_ */ |
| 6651 | |
| 6652 | /* Subroutine */ int dgeequb_cxx . . $ dgeequb_(799434dec6c8879c).(integercxx . . $ integer# *m, integercxx . . $ integer# *n, double *a, integercxx . . $ integer# * |
| 6653 | lda, double *r__, double *c__, double *rowcnd, double |
| 6654 | *colcnd, double *amax, integercxx . . $ integer# *info) |
| 6655 | { |
| 6656 | /* System generated locals */ |
| 6657 | integercxx . . $ integer# a_dim1, a_offset, i__1, i__2; |
| 6658 | double d__1, d__2, d__3; |
| 6659 | |
| 6660 | /* Local variables */ |
| 6661 | integercxx . . $ integer# i__, j; |
| 6662 | double radix, rcmin, rcmax; |
| 6663 | double bignum, logrdx, smlnum; |
| 6664 | |
| 6665 | |
| 6666 | /* -- LAPACK routine (version 3.2) -- */ |
| 6667 | /* -- Contributed by James Demmel, Deaglan Halligan, Yozo Hida and -- */ |
| 6668 | /* -- Jason Riedy of Univ. of California Berkeley. -- */ |
| 6669 | /* -- November 2008 -- */ |
| 6670 | |
| 6671 | /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ |
| 6672 | /* -- Univ. of California Berkeley and NAG Ltd. -- */ |
| 6673 | |
| 6674 | /* .. */ |
| 6675 | /* .. Scalar Arguments .. */ |
| 6676 | /* .. */ |
| 6677 | /* .. Array Arguments .. */ |
| 6678 | /* .. */ |
| 6679 | |
| 6680 | /* Purpose */ |
| 6681 | /* ======= */ |
| 6682 | |
| 6683 | /* DGEEQUB computes row and column scalings intended to equilibrate an */ |
| 6684 | /* M-by-N matrix A and reduce its condition number. R returns the row */ |
| 6685 | /* scale factors and C the column scale factors, chosen to try to make */ |
| 6686 | /* the largest element in each row and column of the matrix B with */ |
| 6687 | /* elements B(i,j)=R(i)*A(i,j)*C(j) have an absolute value of at most */ |
| 6688 | /* the radix. */ |
| 6689 | |
| 6690 | /* R(i) and C(j) are restricted to be a power of the radix between */ |
| 6691 | /* SMLNUM = smallest safe number and BIGNUM = largest safe number. Use */ |
| 6692 | /* of these scaling factors is not guaranteed to reduce the condition */ |
| 6693 | /* number of A but works well in practice. */ |
| 6694 | |
| 6695 | /* This routine differs from DGEEQU by restricting the scaling factors */ |
| 6696 | /* to a power of the radix. Baring over- and underflow, scaling by */ |
| 6697 | /* these factors introduces no additional rounding errors. However, the */ |
| 6698 | /* scaled entries' magnitured are no longer approximately 1 but lie */ |
| 6699 | /* between sqrt(radix) and 1/sqrt(radix). */ |
| 6700 | |
| 6701 | /* Arguments */ |
| 6702 | /* ========= */ |
| 6703 | |
| 6704 | /* M (input) INTEGER */ |
| 6705 | /* The number of rows of the matrix A. M >= 0. */ |
| 6706 | |
| 6707 | /* N (input) INTEGER */ |
| 6708 | /* The number of columns of the matrix A. N >= 0. */ |
| 6709 | |
| 6710 | /* A (input) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 6711 | /* The M-by-N matrix whose equilibration factors are */ |
| 6712 | /* to be computed. */ |
| 6713 | |
| 6714 | /* LDA (input) INTEGER */ |
| 6715 | /* The leading dimension of the array A. LDA >= max(1,M). */ |
| 6716 | |
| 6717 | /* R (output) DOUBLE PRECISION array, dimension (M) */ |
| 6718 | /* If INFO = 0 or INFO > M, R contains the row scale factors */ |
| 6719 | /* for A. */ |
| 6720 | |
| 6721 | /* C (output) DOUBLE PRECISION array, dimension (N) */ |
| 6722 | /* If INFO = 0, C contains the column scale factors for A. */ |
| 6723 | |
| 6724 | /* ROWCND (output) DOUBLE PRECISION */ |
| 6725 | /* If INFO = 0 or INFO > M, ROWCND contains the ratio of the */ |
| 6726 | /* smallest R(i) to the largest R(i). If ROWCND >= 0.1 and */ |
| 6727 | /* AMAX is neither too large nor too small, it is not worth */ |
| 6728 | /* scaling by R. */ |
| 6729 | |
| 6730 | /* COLCND (output) DOUBLE PRECISION */ |
| 6731 | /* If INFO = 0, COLCND contains the ratio of the smallest */ |
| 6732 | /* C(i) to the largest C(i). If COLCND >= 0.1, it is not */ |
| 6733 | /* worth scaling by C. */ |
| 6734 | |
| 6735 | /* AMAX (output) DOUBLE PRECISION */ |
| 6736 | /* Absolute value of largest matrix element. If AMAX is very */ |
| 6737 | /* close to overflow or very close to underflow, the matrix */ |
| 6738 | /* should be scaled. */ |
| 6739 | |
| 6740 | /* INFO (output) INTEGER */ |
| 6741 | /* = 0: successful exit */ |
| 6742 | /* < 0: if INFO = -i, the i-th argument had an illegal value */ |
| 6743 | /* > 0: if INFO = i, and i is */ |
| 6744 | /* <= M: the i-th row of A is exactly zero */ |
| 6745 | /* > M: the (i-M)-th column of A is exactly zero */ |
| 6746 | |
| 6747 | /* ===================================================================== */ |
| 6748 | |
| 6749 | /* .. Parameters .. */ |
| 6750 | /* .. */ |
| 6751 | /* .. Local Scalars .. */ |
| 6752 | /* .. */ |
| 6753 | /* .. External Functions .. */ |
| 6754 | /* .. */ |
| 6755 | /* .. External Subroutines .. */ |
| 6756 | /* .. */ |
| 6757 | /* .. Intrinsic Functions .. */ |
| 6758 | /* .. */ |
| 6759 | /* .. Executable Statements .. */ |
| 6760 | |
| 6761 | /* Test the input parameters. */ |
| 6762 | |
| 6763 | /* Parameter adjustments */ |
| 6764 | a_dim1 = *lda; |
| 6765 | a_offset = 1 + a_dim1; |
| 6766 | a -= a_offset; |
| 6767 | --r__; |
| 6768 | --c__; |
| 6769 | |
| 6770 | /* Function Body */ |
| 6771 | *info = 0; |
| 6772 | if (*m < 0) { |
| 6773 | *info = -1; |
| 6774 | } else if (*n < 0) { |
| 6775 | *info = -2; |
| 6776 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*m)) { |
| 6777 | *info = -4; |
| 6778 | } |
| 6779 | if (*info != 0) { |
| 6780 | i__1 = -(*info); |
| 6781 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGEEQUB", &i__1); |
| 6782 | return 0; |
| 6783 | } |
| 6784 | |
| 6785 | /* Quick return if possible. */ |
| 6786 | |
| 6787 | if (*m == 0 || *n == 0) { |
| 6788 | *rowcnd = 1.; |
| 6789 | *colcnd = 1.; |
| 6790 | *amax = 0.; |
| 6791 | return 0; |
| 6792 | } |
| 6793 | |
| 6794 | /* Get machine constants. Assume SMLNUM is a power of the radix. */ |
| 6795 | |
| 6796 | smlnum = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("S"); |
| 6797 | bignum = 1. / smlnum; |
| 6798 | radix = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("B"); |
| 6799 | logrdx = logcxx . . $ log(fee4f1d22bc8e617).(radix); |
| 6800 | |
| 6801 | /* Compute row scale factors. */ |
| 6802 | |
| 6803 | i__1 = *m; |
| 6804 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 6805 | r__[i__] = 0.; |
| 6806 | /* L10: */ |
| 6807 | } |
| 6808 | |
| 6809 | /* Find the maximum element in each row. */ |
| 6810 | |
| 6811 | i__1 = *n; |
| 6812 | for (j = 1; j <= i__1; ++j) { |
| 6813 | i__2 = *m; |
| 6814 | for (i__ = 1; i__ <= i__2; ++i__) { |
| 6815 | /* Computing MAX */ |
| 6816 | d__2 = r__[i__], d__3 = (d__1 = a[i__ + j * a_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__1)); |
| 6817 | r__[i__] = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__2,d__3); |
| 6818 | /* L20: */ |
| 6819 | } |
| 6820 | /* L30: */ |
| 6821 | } |
| 6822 | i__1 = *m; |
| 6823 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 6824 | if (r__[i__] > 0.) { |
| 6825 | i__2 = (integercxx . . $ integer#) (logcxx . . $ log(fee4f1d22bc8e617).(r__[i__]) / logrdx); |
| 6826 | r__[i__] = pow_dicxx . . $ pow_di(d073b4717a6ff874).(&radix, &i__2); |
| 6827 | } |
| 6828 | } |
| 6829 | |
| 6830 | /* Find the maximum and minimum scale factors. */ |
| 6831 | |
| 6832 | rcmin = bignum; |
| 6833 | rcmax = 0.; |
| 6834 | i__1 = *m; |
| 6835 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 6836 | /* Computing MAX */ |
| 6837 | d__1 = rcmax, d__2 = r__[i__]; |
| 6838 | rcmax = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__1,d__2); |
| 6839 | /* Computing MIN */ |
| 6840 | d__1 = rcmin, d__2 = r__[i__]; |
| 6841 | rcmin = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(d__1,d__2); |
| 6842 | /* L40: */ |
| 6843 | } |
| 6844 | *amax = rcmax; |
| 6845 | |
| 6846 | if (rcmin == 0.) { |
| 6847 | |
| 6848 | /* Find the first zero scale factor and return an error code. */ |
| 6849 | |
| 6850 | i__1 = *m; |
| 6851 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 6852 | if (r__[i__] == 0.) { |
| 6853 | *info = i__; |
| 6854 | return 0; |
| 6855 | } |
| 6856 | /* L50: */ |
| 6857 | } |
| 6858 | } else { |
| 6859 | |
| 6860 | /* Invert the scale factors. */ |
| 6861 | |
| 6862 | i__1 = *m; |
| 6863 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 6864 | /* Computing MIN */ |
| 6865 | /* Computing MAX */ |
| 6866 | d__2 = r__[i__]; |
| 6867 | d__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__2,smlnum); |
| 6868 | r__[i__] = 1. / stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(d__1,bignum); |
| 6869 | /* L60: */ |
| 6870 | } |
| 6871 | |
| 6872 | /* Compute ROWCND = min(R(I)) / max(R(I)). */ |
| 6873 | |
| 6874 | *rowcnd = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(rcmin,smlnum) / stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(rcmax,bignum); |
| 6875 | } |
| 6876 | |
| 6877 | /* Compute column scale factors */ |
| 6878 | |
| 6879 | i__1 = *n; |
| 6880 | for (j = 1; j <= i__1; ++j) { |
| 6881 | c__[j] = 0.; |
| 6882 | /* L70: */ |
| 6883 | } |
| 6884 | |
| 6885 | /* Find the maximum element in each column, */ |
| 6886 | /* assuming the row scaling computed above. */ |
| 6887 | |
| 6888 | i__1 = *n; |
| 6889 | for (j = 1; j <= i__1; ++j) { |
| 6890 | i__2 = *m; |
| 6891 | for (i__ = 1; i__ <= i__2; ++i__) { |
| 6892 | /* Computing MAX */ |
| 6893 | d__2 = c__[j], d__3 = (d__1 = a[i__ + j * a_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__1)) * |
| 6894 | r__[i__]; |
| 6895 | c__[j] = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__2,d__3); |
| 6896 | /* L80: */ |
| 6897 | } |
| 6898 | if (c__[j] > 0.) { |
| 6899 | i__2 = (integercxx . . $ integer#) (logcxx . . $ log(fee4f1d22bc8e617).(c__[j]) / logrdx); |
| 6900 | c__[j] = pow_dicxx . . $ pow_di(d073b4717a6ff874).(&radix, &i__2); |
| 6901 | } |
| 6902 | /* L90: */ |
| 6903 | } |
| 6904 | |
| 6905 | /* Find the maximum and minimum scale factors. */ |
| 6906 | |
| 6907 | rcmin = bignum; |
| 6908 | rcmax = 0.; |
| 6909 | i__1 = *n; |
| 6910 | for (j = 1; j <= i__1; ++j) { |
| 6911 | /* Computing MIN */ |
| 6912 | d__1 = rcmin, d__2 = c__[j]; |
| 6913 | rcmin = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(d__1,d__2); |
| 6914 | /* Computing MAX */ |
| 6915 | d__1 = rcmax, d__2 = c__[j]; |
| 6916 | rcmax = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__1,d__2); |
| 6917 | /* L100: */ |
| 6918 | } |
| 6919 | |
| 6920 | if (rcmin == 0.) { |
| 6921 | |
| 6922 | /* Find the first zero scale factor and return an error code. */ |
| 6923 | |
| 6924 | i__1 = *n; |
| 6925 | for (j = 1; j <= i__1; ++j) { |
| 6926 | if (c__[j] == 0.) { |
| 6927 | *info = *m + j; |
| 6928 | return 0; |
| 6929 | } |
| 6930 | /* L110: */ |
| 6931 | } |
| 6932 | } else { |
| 6933 | |
| 6934 | /* Invert the scale factors. */ |
| 6935 | |
| 6936 | i__1 = *n; |
| 6937 | for (j = 1; j <= i__1; ++j) { |
| 6938 | /* Computing MIN */ |
| 6939 | /* Computing MAX */ |
| 6940 | d__2 = c__[j]; |
| 6941 | d__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__2,smlnum); |
| 6942 | c__[j] = 1. / stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(d__1,bignum); |
| 6943 | /* L120: */ |
| 6944 | } |
| 6945 | |
| 6946 | /* Compute COLCND = min(C(J)) / max(C(J)). */ |
| 6947 | |
| 6948 | *colcnd = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(rcmin,smlnum) / stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(rcmax,bignum); |
| 6949 | } |
| 6950 | |
| 6951 | return 0; |
| 6952 | |
| 6953 | /* End of DGEEQUB */ |
| 6954 | |
| 6955 | } /* dgeequb_ */ |
| 6956 | |
| 6957 | /* Subroutine */ int dgees_cxx . . $ dgees_(b6bcc6525acbe5db).(const char *jobvs, const char *sort, bool (*select)(const double *, const double *), |
| 6958 | integercxx . . $ integer# *n, double *a, integercxx . . $ integer# *lda, integercxx . . $ integer# *sdim, double *wr, |
| 6959 | double *wi, double *vs, integercxx . . $ integer# *ldvs, double *work, |
| 6960 | integercxx . . $ integer# *lwork, bool *bwork, integercxx . . $ integer# *info) |
| 6961 | { |
| 6962 | /* Table of constant values */ |
| 6963 | static integercxx . . $ integer# c__1 = 1; |
| 6964 | static integercxx . . $ integer# c__0 = 0; |
| 6965 | static integercxx . . $ integer# c_n1 = -1; |
| 6966 | |
| 6967 | /* System generated locals */ |
| 6968 | integercxx . . $ integer# a_dim1, a_offset, vs_dim1, vs_offset, i__1, i__2, i__3; |
| 6969 | |
| 6970 | /* Builtin functions |
| 6971 | double sqrt(double);*/ |
| 6972 | |
| 6973 | /* Local variables */ |
| 6974 | integercxx . . $ integer# i__; |
| 6975 | double s; |
| 6976 | integercxx . . $ integer# i1, i2, ip, ihi, ilo; |
| 6977 | double dum[1], eps, sep; |
| 6978 | integercxx . . $ integer# ibal; |
| 6979 | double anrm; |
| 6980 | integercxx . . $ integer# idum[1], ierr, itau, iwrk, inxt, icond, ieval; |
| 6981 | bool cursl; |
| 6982 | bool lst2sl, scalea; |
| 6983 | double cscale; |
| 6984 | double bignum; |
| 6985 | bool lastsl; |
| 6986 | integercxx . . $ integer# minwrk, maxwrk; |
| 6987 | double smlnum; |
| 6988 | integercxx . . $ integer# hswork; |
| 6989 | bool wantst, lquery, wantvs; |
| 6990 | |
| 6991 | |
| 6992 | /* -- LAPACK driver routine (version 3.1) -- */ |
| 6993 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 6994 | /* November 2006 */ |
| 6995 | |
| 6996 | /* .. Scalar Arguments .. */ |
| 6997 | /* .. */ |
| 6998 | /* .. Array Arguments .. */ |
| 6999 | /* .. */ |
| 7000 | /* .. Function Arguments .. */ |
| 7001 | /* .. */ |
| 7002 | |
| 7003 | /* Purpose */ |
| 7004 | /* ======= */ |
| 7005 | |
| 7006 | /* DGEES computes for an N-by-N real nonsymmetric matrix A, the */ |
| 7007 | /* eigenvalues, the real Schur form T, and, optionally, the matrix of */ |
| 7008 | /* Schur vectors Z. This gives the Schur factorization A = Z*T*(Z**T). */ |
| 7009 | |
| 7010 | /* Optionally, it also orders the eigenvalues on the diagonal of the */ |
| 7011 | /* real Schur form so that selected eigenvalues are at the top left. */ |
| 7012 | /* The leading columns of Z then form an orthonormal basis for the */ |
| 7013 | /* invariant subspace corresponding to the selected eigenvalues. */ |
| 7014 | |
| 7015 | /* A matrix is in real Schur form if it is upper quasi-triangular with */ |
| 7016 | /* 1-by-1 and 2-by-2 blocks. 2-by-2 blocks will be standardized in the */ |
| 7017 | /* form */ |
| 7018 | /* [ a b ] */ |
| 7019 | /* [ c a ] */ |
| 7020 | |
| 7021 | /* where b*c < 0. The eigenvalues of such a block are a +- sqrt(bc). */ |
| 7022 | |
| 7023 | /* Arguments */ |
| 7024 | /* ========= */ |
| 7025 | |
| 7026 | /* JOBVS (input) CHARACTER*1 */ |
| 7027 | /* = 'N': Schur vectors are not computed; */ |
| 7028 | /* = 'V': Schur vectors are computed. */ |
| 7029 | |
| 7030 | /* SORT (input) CHARACTER*1 */ |
| 7031 | /* Specifies whether or not to order the eigenvalues on the */ |
| 7032 | /* diagonal of the Schur form. */ |
| 7033 | /* = 'N': Eigenvalues are not ordered; */ |
| 7034 | /* = 'S': Eigenvalues are ordered (see SELECT). */ |
| 7035 | |
| 7036 | /* SELECT (external procedure) LOGICAL FUNCTION of two DOUBLE PRECISION arguments */ |
| 7037 | /* SELECT must be declared EXTERNAL in the calling subroutine. */ |
| 7038 | /* If SORT = 'S', SELECT is used to select eigenvalues to sort */ |
| 7039 | /* to the top left of the Schur form. */ |
| 7040 | /* If SORT = 'N', SELECT is not referenced. */ |
| 7041 | /* An eigenvalue WR(j)+sqrt(-1)*WI(j) is selected if */ |
| 7042 | /* SELECT(WR(j),WI(j)) is true; i.e., if either one of a complex */ |
| 7043 | /* conjugate pair of eigenvalues is selected, then both complex */ |
| 7044 | /* eigenvalues are selected. */ |
| 7045 | /* Note that a selected complex eigenvalue may no longer */ |
| 7046 | /* satisfy SELECT(WR(j),WI(j)) = .TRUE. after ordering, since */ |
| 7047 | /* ordering may change the value of complex eigenvalues */ |
| 7048 | /* (especially if the eigenvalue is ill-conditioned); in this */ |
| 7049 | /* case INFO is set to N+2 (see INFO below). */ |
| 7050 | |
| 7051 | /* N (input) INTEGER */ |
| 7052 | /* The order of the matrix A. N >= 0. */ |
| 7053 | |
| 7054 | /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 7055 | /* On entry, the N-by-N matrix A. */ |
| 7056 | /* On exit, A has been overwritten by its real Schur form T. */ |
| 7057 | |
| 7058 | /* LDA (input) INTEGER */ |
| 7059 | /* The leading dimension of the array A. LDA >= max(1,N). */ |
| 7060 | |
| 7061 | /* SDIM (output) INTEGER */ |
| 7062 | /* If SORT = 'N', SDIM = 0. */ |
| 7063 | /* If SORT = 'S', SDIM = number of eigenvalues (after sorting) */ |
| 7064 | /* for which SELECT is true. (Complex conjugate */ |
| 7065 | /* pairs for which SELECT is true for either */ |
| 7066 | /* eigenvalue count as 2.) */ |
| 7067 | |
| 7068 | /* WR (output) DOUBLE PRECISION array, dimension (N) */ |
| 7069 | /* WI (output) DOUBLE PRECISION array, dimension (N) */ |
| 7070 | /* WR and WI contain the real and imaginary parts, */ |
| 7071 | /* respectively, of the computed eigenvalues in the same order */ |
| 7072 | /* that they appear on the diagonal of the output Schur form T. */ |
| 7073 | /* Complex conjugate pairs of eigenvalues will appear */ |
| 7074 | /* consecutively with the eigenvalue having the positive */ |
| 7075 | /* imaginary part first. */ |
| 7076 | |
| 7077 | /* VS (output) DOUBLE PRECISION array, dimension (LDVS,N) */ |
| 7078 | /* If JOBVS = 'V', VS contains the orthogonal matrix Z of Schur */ |
| 7079 | /* vectors. */ |
| 7080 | /* If JOBVS = 'N', VS is not referenced. */ |
| 7081 | |
| 7082 | /* LDVS (input) INTEGER */ |
| 7083 | /* The leading dimension of the array VS. LDVS >= 1; if */ |
| 7084 | /* JOBVS = 'V', LDVS >= N. */ |
| 7085 | |
| 7086 | /* WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) */ |
| 7087 | /* On exit, if INFO = 0, WORK(1) contains the optimal LWORK. */ |
| 7088 | |
| 7089 | /* LWORK (input) INTEGER */ |
| 7090 | /* The dimension of the array WORK. LWORK >= max(1,3*N). */ |
| 7091 | /* For good performance, LWORK must generally be larger. */ |
| 7092 | |
| 7093 | /* If LWORK = -1, then a workspace query is assumed; the routine */ |
| 7094 | /* only calculates the optimal size of the WORK array, returns */ |
| 7095 | /* this value as the first entry of the WORK array, and no error */ |
| 7096 | /* message related to LWORK is issued by XERBLA. */ |
| 7097 | |
| 7098 | /* BWORK (workspace) LOGICAL array, dimension (N) */ |
| 7099 | /* Not referenced if SORT = 'N'. */ |
| 7100 | |
| 7101 | /* INFO (output) INTEGER */ |
| 7102 | /* = 0: successful exit */ |
| 7103 | /* < 0: if INFO = -i, the i-th argument had an illegal value. */ |
| 7104 | /* > 0: if INFO = i, and i is */ |
| 7105 | /* <= N: the QR algorithm failed to compute all the */ |
| 7106 | /* eigenvalues; elements 1:ILO-1 and i+1:N of WR and WI */ |
| 7107 | /* contain those eigenvalues which have converged; if */ |
| 7108 | /* JOBVS = 'V', VS contains the matrix which reduces A */ |
| 7109 | /* to its partially converged Schur form. */ |
| 7110 | /* = N+1: the eigenvalues could not be reordered because some */ |
| 7111 | /* eigenvalues were too close to separate (the problem */ |
| 7112 | /* is very ill-conditioned); */ |
| 7113 | /* = N+2: after reordering, roundoff changed values of some */ |
| 7114 | /* complex eigenvalues so that leading eigenvalues in */ |
| 7115 | /* the Schur form no longer satisfy SELECT=.TRUE. This */ |
| 7116 | /* could also be caused by underflow due to scaling. */ |
| 7117 | |
| 7118 | /* ===================================================================== */ |
| 7119 | |
| 7120 | /* .. Parameters .. */ |
| 7121 | /* .. */ |
| 7122 | /* .. Local Scalars .. */ |
| 7123 | /* .. */ |
| 7124 | /* .. Local Arrays .. */ |
| 7125 | /* .. */ |
| 7126 | /* .. External Subroutines .. */ |
| 7127 | /* .. */ |
| 7128 | /* .. External Functions .. */ |
| 7129 | /* .. */ |
| 7130 | /* .. Intrinsic Functions .. */ |
| 7131 | /* .. */ |
| 7132 | /* .. Executable Statements .. */ |
| 7133 | |
| 7134 | /* Test the input arguments */ |
| 7135 | |
| 7136 | /* Parameter adjustments */ |
| 7137 | a_dim1 = *lda; |
| 7138 | a_offset = 1 + a_dim1; |
| 7139 | a -= a_offset; |
| 7140 | --wr; |
| 7141 | --wi; |
| 7142 | vs_dim1 = *ldvs; |
| 7143 | vs_offset = 1 + vs_dim1; |
| 7144 | vs -= vs_offset; |
| 7145 | --work; |
| 7146 | --bwork; |
| 7147 | |
| 7148 | /* Function Body */ |
| 7149 | *info = 0; |
| 7150 | lquery = *lwork == -1; |
| 7151 | wantvs = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobvs, "V"); |
| 7152 | wantst = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(sort, "S"); |
| 7153 | if (! wantvs && ! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobvs, "N")) { |
| 7154 | *info = -1; |
| 7155 | } else if (! wantst && ! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(sort, "N")) { |
| 7156 | *info = -2; |
| 7157 | } else if (*n < 0) { |
| 7158 | *info = -4; |
| 7159 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 7160 | *info = -6; |
| 7161 | } else if (*ldvs < 1 || wantvs && *ldvs < *n) { |
| 7162 | *info = -11; |
| 7163 | } |
| 7164 | |
| 7165 | /* Compute workspace */ |
| 7166 | /* (Note: Comments in the code beginning "Workspace:" describe the */ |
| 7167 | /* minimal amount of workspace needed at that point in the code, */ |
| 7168 | /* as well as the preferred amount for good performance. */ |
| 7169 | /* NB refers to the optimal block size for the immediately */ |
| 7170 | /* following subroutine, as returned by ILAENV. */ |
| 7171 | /* HSWORK refers to the workspace preferred by DHSEQR, as */ |
| 7172 | /* calculated below. HSWORK is computed assuming ILO=1 and IHI=N, */ |
| 7173 | /* the worst case.) */ |
| 7174 | |
| 7175 | if (*info == 0) { |
| 7176 | if (*n == 0) { |
| 7177 | minwrk = 1; |
| 7178 | maxwrk = 1; |
| 7179 | } else { |
| 7180 | maxwrk = (*n << 1) + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEHRD", " ", n, &c__1, |
| 7181 | n, &c__0); |
| 7182 | minwrk = *n * 3; |
| 7183 | |
| 7184 | dhseqr_cxx . . $ dhseqr_(658beefb48cc805a).("S", jobvs, n, &c__1, n, &a[a_offset], lda, &wr[1], &wi[1] |
| 7185 | , &vs[vs_offset], ldvs, &work[1], &c_n1, &ieval); |
| 7186 | hswork = (integercxx . . $ integer#) work[1]; |
| 7187 | |
| 7188 | if (! wantvs) { |
| 7189 | /* Computing MAX */ |
| 7190 | i__1 = maxwrk, i__2 = *n + hswork; |
| 7191 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 7192 | } else { |
| 7193 | /* Computing MAX */ |
| 7194 | i__1 = maxwrk, i__2 = (*n << 1) + (*n - 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 7195 | "DORGHR", " ", n, &c__1, n, &c_n1); |
| 7196 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 7197 | /* Computing MAX */ |
| 7198 | i__1 = maxwrk, i__2 = *n + hswork; |
| 7199 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 7200 | } |
| 7201 | } |
| 7202 | work[1] = (double) maxwrk; |
| 7203 | |
| 7204 | if (*lwork < minwrk && ! lquery) { |
| 7205 | *info = -13; |
| 7206 | } |
| 7207 | } |
| 7208 | |
| 7209 | if (*info != 0) { |
| 7210 | i__1 = -(*info); |
| 7211 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGEES ", &i__1); |
| 7212 | return 0; |
| 7213 | } else if (lquery) { |
| 7214 | return 0; |
| 7215 | } |
| 7216 | |
| 7217 | /* Quick return if possible */ |
| 7218 | |
| 7219 | if (*n == 0) { |
| 7220 | *sdim = 0; |
| 7221 | return 0; |
| 7222 | } |
| 7223 | |
| 7224 | /* Get machine constants */ |
| 7225 | |
| 7226 | eps = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("P"); |
| 7227 | smlnum = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("S"); |
| 7228 | bignum = 1. / smlnum; |
| 7229 | dlabad_cxx . . $ dlabad_(4730c933dae9b326).(&smlnum, &bignum); |
| 7230 | smlnum = sqrtcxx . . $ sqrt(fee4f1d22bc8e617).(smlnum) / eps; |
| 7231 | bignum = 1. / smlnum; |
| 7232 | |
| 7233 | /* Scale A if max element outside range [SMLNUM,BIGNUM] */ |
| 7234 | |
| 7235 | anrm = dlange_cxx . . $ dlange_(98d44e6417336f20).("M", n, n, &a[a_offset], lda, dum); |
| 7236 | scalea = false; |
| 7237 | if (anrm > 0. && anrm < smlnum) { |
| 7238 | scalea = true; |
| 7239 | cscale = smlnum; |
| 7240 | } else if (anrm > bignum) { |
| 7241 | scalea = true; |
| 7242 | cscale = bignum; |
| 7243 | } |
| 7244 | if (scalea) { |
| 7245 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &anrm, &cscale, n, n, &a[a_offset], lda, & |
| 7246 | ierr); |
| 7247 | } |
| 7248 | |
| 7249 | /* Permute the matrix to make it more nearly triangular */ |
| 7250 | /* (Workspace: need N) */ |
| 7251 | |
| 7252 | ibal = 1; |
| 7253 | dgebal_cxx . . $ dgebal_(4da4b22b53009041).("P", n, &a[a_offset], lda, &ilo, &ihi, &work[ibal], &ierr); |
| 7254 | |
| 7255 | /* Reduce to upper Hessenberg form */ |
| 7256 | /* (Workspace: need 3*N, prefer 2*N+N*NB) */ |
| 7257 | |
| 7258 | itau = *n + ibal; |
| 7259 | iwrk = *n + itau; |
| 7260 | i__1 = *lwork - iwrk + 1; |
| 7261 | dgehrd_cxx . . $ dgehrd_(424524679a238630).(n, &ilo, &ihi, &a[a_offset], lda, &work[itau], &work[iwrk], &i__1, |
| 7262 | &ierr); |
| 7263 | |
| 7264 | if (wantvs) { |
| 7265 | |
| 7266 | /* Copy Householder vectors to VS */ |
| 7267 | |
| 7268 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("L", n, n, &a[a_offset], lda, &vs[vs_offset], ldvs) |
| 7269 | ; |
| 7270 | |
| 7271 | /* Generate orthogonal matrix in VS */ |
| 7272 | /* (Workspace: need 3*N-1, prefer 2*N+(N-1)*NB) */ |
| 7273 | |
| 7274 | i__1 = *lwork - iwrk + 1; |
| 7275 | dorghr_cxx . . $ dorghr_(424524679a238630).(n, &ilo, &ihi, &vs[vs_offset], ldvs, &work[itau], &work[iwrk], |
| 7276 | &i__1, &ierr); |
| 7277 | } |
| 7278 | |
| 7279 | *sdim = 0; |
| 7280 | |
| 7281 | /* Perform QR iteration, accumulating Schur vectors in VS if desired */ |
| 7282 | /* (Workspace: need N+1, prefer N+HSWORK (see comments) ) */ |
| 7283 | |
| 7284 | iwrk = itau; |
| 7285 | i__1 = *lwork - iwrk + 1; |
| 7286 | dhseqr_cxx . . $ dhseqr_(658beefb48cc805a).("S", jobvs, n, &ilo, &ihi, &a[a_offset], lda, &wr[1], &wi[1], &vs[ |
| 7287 | vs_offset], ldvs, &work[iwrk], &i__1, &ieval); |
| 7288 | if (ieval > 0) { |
| 7289 | *info = ieval; |
| 7290 | } |
| 7291 | |
| 7292 | /* Sort eigenvalues if desired */ |
| 7293 | |
| 7294 | if (wantst && *info == 0) { |
| 7295 | if (scalea) { |
| 7296 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &cscale, &anrm, n, &c__1, &wr[1], n, & |
| 7297 | ierr); |
| 7298 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &cscale, &anrm, n, &c__1, &wi[1], n, & |
| 7299 | ierr); |
| 7300 | } |
| 7301 | i__1 = *n; |
| 7302 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 7303 | bwork[i__] = (*select)(&wr[i__], &wi[i__]); |
| 7304 | /* L10: */ |
| 7305 | } |
| 7306 | |
| 7307 | /* Reorder eigenvalues and transform Schur vectors */ |
| 7308 | /* (Workspace: none needed) */ |
| 7309 | |
| 7310 | i__1 = *lwork - iwrk + 1; |
| 7311 | dtrsen_cxx . . $ dtrsen_(189d40317d8d1f2c).("N", jobvs, &bwork[1], n, &a[a_offset], lda, &vs[vs_offset], |
| 7312 | ldvs, &wr[1], &wi[1], sdim, &s, &sep, &work[iwrk], &i__1, |
| 7313 | idum, &c__1, &icond); |
| 7314 | if (icond > 0) { |
| 7315 | *info = *n + icond; |
| 7316 | } |
| 7317 | } |
| 7318 | |
| 7319 | if (wantvs) { |
| 7320 | |
| 7321 | /* Undo balancing */ |
| 7322 | /* (Workspace: need N) */ |
| 7323 | |
| 7324 | dgebak_cxx . . $ dgebak_(51612d8f5027ec5a).("P", "R", n, &ilo, &ihi, &work[ibal], n, &vs[vs_offset], ldvs, |
| 7325 | &ierr); |
| 7326 | } |
| 7327 | |
| 7328 | if (scalea) { |
| 7329 | |
| 7330 | /* Undo scaling for the Schur form of A */ |
| 7331 | |
| 7332 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("H", &c__0, &c__0, &cscale, &anrm, n, n, &a[a_offset], lda, & |
| 7333 | ierr); |
| 7334 | i__1 = *lda + 1; |
| 7335 | dcopy_cxx . . $ dcopy_(ec261fd7ec3b6bf6).(n, &a[a_offset], &i__1, &wr[1], &c__1); |
| 7336 | if (cscale == smlnum) { |
| 7337 | |
| 7338 | /* If scaling back towards underflow, adjust WI if an */ |
| 7339 | /* offdiagonal element of a 2-by-2 block in the Schur form */ |
| 7340 | /* underflows. */ |
| 7341 | |
| 7342 | if (ieval > 0) { |
| 7343 | i1 = ieval + 1; |
| 7344 | i2 = ihi - 1; |
| 7345 | i__1 = ilo - 1; |
| 7346 | /* Computing MAX */ |
| 7347 | i__3 = ilo - 1; |
| 7348 | i__2 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__3,1_integercxx . . $ `operator""_integer`(85240eb457c3721a).); |
| 7349 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &cscale, &anrm, &i__1, &c__1, &wi[ |
| 7350 | 1], &i__2, &ierr); |
| 7351 | } else if (wantst) { |
| 7352 | i1 = 1; |
| 7353 | i2 = *n - 1; |
| 7354 | } else { |
| 7355 | i1 = ilo; |
| 7356 | i2 = ihi - 1; |
| 7357 | } |
| 7358 | inxt = i1 - 1; |
| 7359 | i__1 = i2; |
| 7360 | for (i__ = i1; i__ <= i__1; ++i__) { |
| 7361 | if (i__ < inxt) { |
| 7362 | goto L20; |
| 7363 | } |
| 7364 | if (wi[i__] == 0.) { |
| 7365 | inxt = i__ + 1; |
| 7366 | } else { |
| 7367 | if (a[i__ + 1 + i__ * a_dim1] == 0.) { |
| 7368 | wi[i__] = 0.; |
| 7369 | wi[i__ + 1] = 0.; |
| 7370 | } else if (a[i__ + 1 + i__ * a_dim1] != 0. && a[i__ + ( |
| 7371 | i__ + 1) * a_dim1] == 0.) { |
| 7372 | wi[i__] = 0.; |
| 7373 | wi[i__ + 1] = 0.; |
| 7374 | if (i__ > 1) { |
| 7375 | i__2 = i__ - 1; |
| 7376 | dswap_cxx . . $ dswap_(ec261fd7ec3b6bf6).(&i__2, &a[i__ * a_dim1 + 1], &c__1, &a[( |
| 7377 | i__ + 1) * a_dim1 + 1], &c__1); |
| 7378 | } |
| 7379 | if (*n > i__ + 1) { |
| 7380 | i__2 = *n - i__ - 1; |
| 7381 | dswap_cxx . . $ dswap_(ec261fd7ec3b6bf6).(&i__2, &a[i__ + (i__ + 2) * a_dim1], lda, & |
| 7382 | a[i__ + 1 + (i__ + 2) * a_dim1], lda); |
| 7383 | } |
| 7384 | if (wantvs) { |
| 7385 | dswap_cxx . . $ dswap_(ec261fd7ec3b6bf6).(n, &vs[i__ * vs_dim1 + 1], &c__1, &vs[(i__ |
| 7386 | + 1) * vs_dim1 + 1], &c__1); |
| 7387 | } |
| 7388 | a[i__ + (i__ + 1) * a_dim1] = a[i__ + 1 + i__ * |
| 7389 | a_dim1]; |
| 7390 | a[i__ + 1 + i__ * a_dim1] = 0.; |
| 7391 | } |
| 7392 | inxt = i__ + 2; |
| 7393 | } |
| 7394 | L20: |
| 7395 | ; |
| 7396 | } |
| 7397 | } |
| 7398 | |
| 7399 | /* Undo scaling for the imaginary part of the eigenvalues */ |
| 7400 | |
| 7401 | i__1 = *n - ieval; |
| 7402 | /* Computing MAX */ |
| 7403 | i__3 = *n - ieval; |
| 7404 | i__2 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__3,1_integercxx . . $ `operator""_integer`(85240eb457c3721a).); |
| 7405 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &cscale, &anrm, &i__1, &c__1, &wi[ieval + |
| 7406 | 1], &i__2, &ierr); |
| 7407 | } |
| 7408 | |
| 7409 | if (wantst && *info == 0) { |
| 7410 | |
| 7411 | /* Check if reordering successful */ |
| 7412 | |
| 7413 | lastsl = true; |
| 7414 | lst2sl = true; |
| 7415 | *sdim = 0; |
| 7416 | ip = 0; |
| 7417 | i__1 = *n; |
| 7418 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 7419 | cursl = (*select)(&wr[i__], &wi[i__]); |
| 7420 | if (wi[i__] == 0.) { |
| 7421 | if (cursl) { |
| 7422 | ++(*sdim); |
| 7423 | } |
| 7424 | ip = 0; |
| 7425 | if (cursl && ! lastsl) { |
| 7426 | *info = *n + 2; |
| 7427 | } |
| 7428 | } else { |
| 7429 | if (ip == 1) { |
| 7430 | |
| 7431 | /* Last eigenvalue of conjugate pair */ |
| 7432 | |
| 7433 | cursl = cursl || lastsl; |
| 7434 | lastsl = cursl; |
| 7435 | if (cursl) { |
| 7436 | *sdim += 2; |
| 7437 | } |
| 7438 | ip = -1; |
| 7439 | if (cursl && ! lst2sl) { |
| 7440 | *info = *n + 2; |
| 7441 | } |
| 7442 | } else { |
| 7443 | |
| 7444 | /* First eigenvalue of conjugate pair */ |
| 7445 | |
| 7446 | ip = 1; |
| 7447 | } |
| 7448 | } |
| 7449 | lst2sl = lastsl; |
| 7450 | lastsl = cursl; |
| 7451 | /* L30: */ |
| 7452 | } |
| 7453 | } |
| 7454 | |
| 7455 | work[1] = (double) maxwrk; |
| 7456 | return 0; |
| 7457 | |
| 7458 | /* End of DGEES */ |
| 7459 | |
| 7460 | } /* dgees_ */ |
| 7461 | |
| 7462 | /* Subroutine */ int dgeesx_cxx . . $ dgeesx_(634229584e0250c9).(const char *jobvs, const char *sort, bool (*select)(const double *, const double *), |
| 7463 | const char *sense, integercxx . . $ integer# *n, double *a, integercxx . . $ integer# *lda, integercxx . . $ integer# *sdim, |
| 7464 | double *wr, double *wi, double *vs, integercxx . . $ integer# *ldvs, |
| 7465 | double *rconde, double *rcondv, double *work, integercxx . . $ integer# * |
| 7466 | lwork, integercxx . . $ integer# *iwork, integercxx . . $ integer# *liwork, bool *bwork, integercxx . . $ integer# *info) |
| 7467 | { |
| 7468 | /* Table of constant values */ |
| 7469 | static integercxx . . $ integer# c__1 = 1; |
| 7470 | static integercxx . . $ integer# c__0 = 0; |
| 7471 | static integercxx . . $ integer# c_n1 = -1; |
| 7472 | |
| 7473 | /* System generated locals */ |
| 7474 | integercxx . . $ integer# a_dim1, a_offset, vs_dim1, vs_offset, i__1, i__2, i__3; |
| 7475 | |
| 7476 | /* Local variables */ |
| 7477 | integercxx . . $ integer# i__, i1, i2, ip, ihi, ilo; |
| 7478 | double dum[1], eps; |
| 7479 | integercxx . . $ integer# ibal; |
| 7480 | double anrm; |
| 7481 | integercxx . . $ integer# ierr, itau, iwrk, lwrk, inxt, icond, ieval; |
| 7482 | bool cursl; |
| 7483 | integercxx . . $ integer# liwrk; |
| 7484 | bool lst2sl, scalea; |
| 7485 | double cscale; |
| 7486 | double bignum; |
| 7487 | bool wantsb; |
| 7488 | bool wantse, lastsl; |
| 7489 | integercxx . . $ integer# minwrk, maxwrk; |
| 7490 | bool wantsn; |
| 7491 | double smlnum; |
| 7492 | integercxx . . $ integer# hswork; |
| 7493 | bool wantst, lquery, wantsv, wantvs; |
| 7494 | |
| 7495 | |
| 7496 | /* -- LAPACK driver routine (version 3.1) -- */ |
| 7497 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 7498 | /* November 2006 */ |
| 7499 | |
| 7500 | /* .. Scalar Arguments .. */ |
| 7501 | /* .. */ |
| 7502 | /* .. Array Arguments .. */ |
| 7503 | /* .. */ |
| 7504 | /* .. Function Arguments .. */ |
| 7505 | /* .. */ |
| 7506 | |
| 7507 | /* Purpose */ |
| 7508 | /* ======= */ |
| 7509 | |
| 7510 | /* DGEESX computes for an N-by-N real nonsymmetric matrix A, the */ |
| 7511 | /* eigenvalues, the real Schur form T, and, optionally, the matrix of */ |
| 7512 | /* Schur vectors Z. This gives the Schur factorization A = Z*T*(Z**T). */ |
| 7513 | |
| 7514 | /* Optionally, it also orders the eigenvalues on the diagonal of the */ |
| 7515 | /* real Schur form so that selected eigenvalues are at the top left; */ |
| 7516 | /* computes a reciprocal condition number for the average of the */ |
| 7517 | /* selected eigenvalues (RCONDE); and computes a reciprocal condition */ |
| 7518 | /* number for the right invariant subspace corresponding to the */ |
| 7519 | /* selected eigenvalues (RCONDV). The leading columns of Z form an */ |
| 7520 | /* orthonormal basis for this invariant subspace. */ |
| 7521 | |
| 7522 | /* For further explanation of the reciprocal condition numbers RCONDE */ |
| 7523 | /* and RCONDV, see Section 4.10 of the LAPACK Users' Guide (where */ |
| 7524 | /* these quantities are called s and sep respectively). */ |
| 7525 | |
| 7526 | /* A real matrix is in real Schur form if it is upper quasi-triangular */ |
| 7527 | /* with 1-by-1 and 2-by-2 blocks. 2-by-2 blocks will be standardized in */ |
| 7528 | /* the form */ |
| 7529 | /* [ a b ] */ |
| 7530 | /* [ c a ] */ |
| 7531 | |
| 7532 | /* where b*c < 0. The eigenvalues of such a block are a +- sqrt(bc). */ |
| 7533 | |
| 7534 | /* Arguments */ |
| 7535 | /* ========= */ |
| 7536 | |
| 7537 | /* JOBVS (input) CHARACTER*1 */ |
| 7538 | /* = 'N': Schur vectors are not computed; */ |
| 7539 | /* = 'V': Schur vectors are computed. */ |
| 7540 | |
| 7541 | /* SORT (input) CHARACTER*1 */ |
| 7542 | /* Specifies whether or not to order the eigenvalues on the */ |
| 7543 | /* diagonal of the Schur form. */ |
| 7544 | /* = 'N': Eigenvalues are not ordered; */ |
| 7545 | /* = 'S': Eigenvalues are ordered (see SELECT). */ |
| 7546 | |
| 7547 | /* SELECT (external procedure) LOGICAL FUNCTION of two DOUBLE PRECISION arguments */ |
| 7548 | /* SELECT must be declared EXTERNAL in the calling subroutine. */ |
| 7549 | /* If SORT = 'S', SELECT is used to select eigenvalues to sort */ |
| 7550 | /* to the top left of the Schur form. */ |
| 7551 | /* If SORT = 'N', SELECT is not referenced. */ |
| 7552 | /* An eigenvalue WR(j)+sqrt(-1)*WI(j) is selected if */ |
| 7553 | /* SELECT(WR(j),WI(j)) is true; i.e., if either one of a */ |
| 7554 | /* complex conjugate pair of eigenvalues is selected, then both */ |
| 7555 | /* are. Note that a selected complex eigenvalue may no longer */ |
| 7556 | /* satisfy SELECT(WR(j),WI(j)) = .TRUE. after ordering, since */ |
| 7557 | /* ordering may change the value of complex eigenvalues */ |
| 7558 | /* (especially if the eigenvalue is ill-conditioned); in this */ |
| 7559 | /* case INFO may be set to N+3 (see INFO below). */ |
| 7560 | |
| 7561 | /* SENSE (input) CHARACTER*1 */ |
| 7562 | /* Determines which reciprocal condition numbers are computed. */ |
| 7563 | /* = 'N': None are computed; */ |
| 7564 | /* = 'E': Computed for average of selected eigenvalues only; */ |
| 7565 | /* = 'V': Computed for selected right invariant subspace only; */ |
| 7566 | /* = 'B': Computed for both. */ |
| 7567 | /* If SENSE = 'E', 'V' or 'B', SORT must equal 'S'. */ |
| 7568 | |
| 7569 | /* N (input) INTEGER */ |
| 7570 | /* The order of the matrix A. N >= 0. */ |
| 7571 | |
| 7572 | /* A (input/output) DOUBLE PRECISION array, dimension (LDA, N) */ |
| 7573 | /* On entry, the N-by-N matrix A. */ |
| 7574 | /* On exit, A is overwritten by its real Schur form T. */ |
| 7575 | |
| 7576 | /* LDA (input) INTEGER */ |
| 7577 | /* The leading dimension of the array A. LDA >= max(1,N). */ |
| 7578 | |
| 7579 | /* SDIM (output) INTEGER */ |
| 7580 | /* If SORT = 'N', SDIM = 0. */ |
| 7581 | /* If SORT = 'S', SDIM = number of eigenvalues (after sorting) */ |
| 7582 | /* for which SELECT is true. (Complex conjugate */ |
| 7583 | /* pairs for which SELECT is true for either */ |
| 7584 | /* eigenvalue count as 2.) */ |
| 7585 | |
| 7586 | /* WR (output) DOUBLE PRECISION array, dimension (N) */ |
| 7587 | /* WI (output) DOUBLE PRECISION array, dimension (N) */ |
| 7588 | /* WR and WI contain the real and imaginary parts, respectively, */ |
| 7589 | /* of the computed eigenvalues, in the same order that they */ |
| 7590 | /* appear on the diagonal of the output Schur form T. Complex */ |
| 7591 | /* conjugate pairs of eigenvalues appear consecutively with the */ |
| 7592 | /* eigenvalue having the positive imaginary part first. */ |
| 7593 | |
| 7594 | /* VS (output) DOUBLE PRECISION array, dimension (LDVS,N) */ |
| 7595 | /* If JOBVS = 'V', VS contains the orthogonal matrix Z of Schur */ |
| 7596 | /* vectors. */ |
| 7597 | /* If JOBVS = 'N', VS is not referenced. */ |
| 7598 | |
| 7599 | /* LDVS (input) INTEGER */ |
| 7600 | /* The leading dimension of the array VS. LDVS >= 1, and if */ |
| 7601 | /* JOBVS = 'V', LDVS >= N. */ |
| 7602 | |
| 7603 | /* RCONDE (output) DOUBLE PRECISION */ |
| 7604 | /* If SENSE = 'E' or 'B', RCONDE contains the reciprocal */ |
| 7605 | /* condition number for the average of the selected eigenvalues. */ |
| 7606 | /* Not referenced if SENSE = 'N' or 'V'. */ |
| 7607 | |
| 7608 | /* RCONDV (output) DOUBLE PRECISION */ |
| 7609 | /* If SENSE = 'V' or 'B', RCONDV contains the reciprocal */ |
| 7610 | /* condition number for the selected right invariant subspace. */ |
| 7611 | /* Not referenced if SENSE = 'N' or 'E'. */ |
| 7612 | |
| 7613 | /* WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) */ |
| 7614 | /* On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ |
| 7615 | |
| 7616 | /* LWORK (input) INTEGER */ |
| 7617 | /* The dimension of the array WORK. LWORK >= max(1,3*N). */ |
| 7618 | /* Also, if SENSE = 'E' or 'V' or 'B', */ |
| 7619 | /* LWORK >= N+2*SDIM*(N-SDIM), where SDIM is the number of */ |
| 7620 | /* selected eigenvalues computed by this routine. Note that */ |
| 7621 | /* N+2*SDIM*(N-SDIM) <= N+N*N/2. Note also that an error is only */ |
| 7622 | /* returned if LWORK < max(1,3*N), but if SENSE = 'E' or 'V' or */ |
| 7623 | /* 'B' this may not be large enough. */ |
| 7624 | /* For good performance, LWORK must generally be larger. */ |
| 7625 | |
| 7626 | /* If LWORK = -1, then a workspace query is assumed; the routine */ |
| 7627 | /* only calculates upper bounds on the optimal sizes of the */ |
| 7628 | /* arrays WORK and IWORK, returns these values as the first */ |
| 7629 | /* entries of the WORK and IWORK arrays, and no error messages */ |
| 7630 | /* related to LWORK or LIWORK are issued by XERBLA. */ |
| 7631 | |
| 7632 | /* IWORK (workspace/output) INTEGER array, dimension (MAX(1,LIWORK)) */ |
| 7633 | /* On exit, if INFO = 0, IWORK(1) returns the optimal LIWORK. */ |
| 7634 | |
| 7635 | /* LIWORK (input) INTEGER */ |
| 7636 | /* The dimension of the array IWORK. */ |
| 7637 | /* LIWORK >= 1; if SENSE = 'V' or 'B', LIWORK >= SDIM*(N-SDIM). */ |
| 7638 | /* Note that SDIM*(N-SDIM) <= N*N/4. Note also that an error is */ |
| 7639 | /* only returned if LIWORK < 1, but if SENSE = 'V' or 'B' this */ |
| 7640 | /* may not be large enough. */ |
| 7641 | |
| 7642 | /* If LIWORK = -1, then a workspace query is assumed; the */ |
| 7643 | /* routine only calculates upper bounds on the optimal sizes of */ |
| 7644 | /* the arrays WORK and IWORK, returns these values as the first */ |
| 7645 | /* entries of the WORK and IWORK arrays, and no error messages */ |
| 7646 | /* related to LWORK or LIWORK are issued by XERBLA. */ |
| 7647 | |
| 7648 | /* BWORK (workspace) LOGICAL array, dimension (N) */ |
| 7649 | /* Not referenced if SORT = 'N'. */ |
| 7650 | |
| 7651 | /* INFO (output) INTEGER */ |
| 7652 | /* = 0: successful exit */ |
| 7653 | /* < 0: if INFO = -i, the i-th argument had an illegal value. */ |
| 7654 | /* > 0: if INFO = i, and i is */ |
| 7655 | /* <= N: the QR algorithm failed to compute all the */ |
| 7656 | /* eigenvalues; elements 1:ILO-1 and i+1:N of WR and WI */ |
| 7657 | /* contain those eigenvalues which have converged; if */ |
| 7658 | /* JOBVS = 'V', VS contains the transformation which */ |
| 7659 | /* reduces A to its partially converged Schur form. */ |
| 7660 | /* = N+1: the eigenvalues could not be reordered because some */ |
| 7661 | /* eigenvalues were too close to separate (the problem */ |
| 7662 | /* is very ill-conditioned); */ |
| 7663 | /* = N+2: after reordering, roundoff changed values of some */ |
| 7664 | /* complex eigenvalues so that leading eigenvalues in */ |
| 7665 | /* the Schur form no longer satisfy SELECT=.TRUE. This */ |
| 7666 | /* could also be caused by underflow due to scaling. */ |
| 7667 | |
| 7668 | /* ===================================================================== */ |
| 7669 | |
| 7670 | /* .. Parameters .. */ |
| 7671 | /* .. */ |
| 7672 | /* .. Local Scalars .. */ |
| 7673 | /* .. */ |
| 7674 | /* .. Local Arrays .. */ |
| 7675 | /* .. */ |
| 7676 | /* .. External Subroutines .. */ |
| 7677 | /* .. */ |
| 7678 | /* .. External Functions .. */ |
| 7679 | /* .. */ |
| 7680 | /* .. Intrinsic Functions .. */ |
| 7681 | /* .. */ |
| 7682 | /* .. Executable Statements .. */ |
| 7683 | |
| 7684 | /* Test the input arguments */ |
| 7685 | |
| 7686 | /* Parameter adjustments */ |
| 7687 | a_dim1 = *lda; |
| 7688 | a_offset = 1 + a_dim1; |
| 7689 | a -= a_offset; |
| 7690 | --wr; |
| 7691 | --wi; |
| 7692 | vs_dim1 = *ldvs; |
| 7693 | vs_offset = 1 + vs_dim1; |
| 7694 | vs -= vs_offset; |
| 7695 | --work; |
| 7696 | --iwork; |
| 7697 | --bwork; |
| 7698 | |
| 7699 | /* Function Body */ |
| 7700 | *info = 0; |
| 7701 | wantvs = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobvs, "V"); |
| 7702 | wantst = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(sort, "S"); |
| 7703 | wantsn = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(sense, "N"); |
| 7704 | wantse = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(sense, "E"); |
| 7705 | wantsv = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(sense, "V"); |
| 7706 | wantsb = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(sense, "B"); |
| 7707 | lquery = *lwork == -1 || *liwork == -1; |
| 7708 | if (! wantvs && ! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobvs, "N")) { |
| 7709 | *info = -1; |
| 7710 | } else if (! wantst && ! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(sort, "N")) { |
| 7711 | *info = -2; |
| 7712 | } else if (! (wantsn || wantse || wantsv || wantsb) || ! wantst && ! |
| 7713 | wantsn) { |
| 7714 | *info = -4; |
| 7715 | } else if (*n < 0) { |
| 7716 | *info = -5; |
| 7717 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 7718 | *info = -7; |
| 7719 | } else if (*ldvs < 1 || wantvs && *ldvs < *n) { |
| 7720 | *info = -12; |
| 7721 | } |
| 7722 | |
| 7723 | /* Compute workspace */ |
| 7724 | /* (Note: Comments in the code beginning "RWorkspace:" describe the */ |
| 7725 | /* minimal amount of real workspace needed at that point in the */ |
| 7726 | /* code, as well as the preferred amount for good performance. */ |
| 7727 | /* IWorkspace refers to integer workspace. */ |
| 7728 | /* NB refers to the optimal block size for the immediately */ |
| 7729 | /* following subroutine, as returned by ILAENV. */ |
| 7730 | /* HSWORK refers to the workspace preferred by DHSEQR, as */ |
| 7731 | /* calculated below. HSWORK is computed assuming ILO=1 and IHI=N, */ |
| 7732 | /* the worst case. */ |
| 7733 | /* If SENSE = 'E', 'V' or 'B', then the amount of workspace needed */ |
| 7734 | /* depends on SDIM, which is computed by the routine DTRSEN later */ |
| 7735 | /* in the code.) */ |
| 7736 | |
| 7737 | if (*info == 0) { |
| 7738 | liwrk = 1; |
| 7739 | if (*n == 0) { |
| 7740 | minwrk = 1; |
| 7741 | lwrk = 1; |
| 7742 | } else { |
| 7743 | maxwrk = (*n << 1) + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEHRD", " ", n, &c__1, |
| 7744 | n, &c__0); |
| 7745 | minwrk = *n * 3; |
| 7746 | |
| 7747 | dhseqr_cxx . . $ dhseqr_(658beefb48cc805a).("S", jobvs, n, &c__1, n, &a[a_offset], lda, &wr[1], &wi[1] |
| 7748 | , &vs[vs_offset], ldvs, &work[1], &c_n1, &ieval); |
| 7749 | hswork = (integercxx . . $ integer#) work[1]; |
| 7750 | |
| 7751 | if (! wantvs) { |
| 7752 | /* Computing MAX */ |
| 7753 | i__1 = maxwrk, i__2 = *n + hswork; |
| 7754 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 7755 | } else { |
| 7756 | /* Computing MAX */ |
| 7757 | i__1 = maxwrk, i__2 = (*n << 1) + (*n - 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 7758 | "DORGHR", " ", n, &c__1, n, &c_n1); |
| 7759 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 7760 | /* Computing MAX */ |
| 7761 | i__1 = maxwrk, i__2 = *n + hswork; |
| 7762 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 7763 | } |
| 7764 | lwrk = maxwrk; |
| 7765 | if (! wantsn) { |
| 7766 | /* Computing MAX */ |
| 7767 | i__1 = lwrk, i__2 = *n + *n * *n / 2; |
| 7768 | lwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 7769 | } |
| 7770 | if (wantsv || wantsb) { |
| 7771 | liwrk = *n * *n / 4; |
| 7772 | } |
| 7773 | } |
| 7774 | iwork[1] = liwrk; |
| 7775 | work[1] = (double) lwrk; |
| 7776 | |
| 7777 | if (*lwork < minwrk && ! lquery) { |
| 7778 | *info = -16; |
| 7779 | } else if (*liwork < 1 && ! lquery) { |
| 7780 | *info = -18; |
| 7781 | } |
| 7782 | } |
| 7783 | |
| 7784 | if (*info != 0) { |
| 7785 | i__1 = -(*info); |
| 7786 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGEESX", &i__1); |
| 7787 | return 0; |
| 7788 | } |
| 7789 | |
| 7790 | /* Quick return if possible */ |
| 7791 | |
| 7792 | if (*n == 0) { |
| 7793 | *sdim = 0; |
| 7794 | return 0; |
| 7795 | } |
| 7796 | |
| 7797 | /* Get machine constants */ |
| 7798 | |
| 7799 | eps = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("P"); |
| 7800 | smlnum = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("S"); |
| 7801 | bignum = 1. / smlnum; |
| 7802 | dlabad_cxx . . $ dlabad_(4730c933dae9b326).(&smlnum, &bignum); |
| 7803 | smlnum = sqrtcxx . . $ sqrt(fee4f1d22bc8e617).(smlnum) / eps; |
| 7804 | bignum = 1. / smlnum; |
| 7805 | |
| 7806 | /* Scale A if max element outside range [SMLNUM,BIGNUM] */ |
| 7807 | |
| 7808 | anrm = dlange_cxx . . $ dlange_(98d44e6417336f20).("M", n, n, &a[a_offset], lda, dum); |
| 7809 | scalea = false; |
| 7810 | if (anrm > 0. && anrm < smlnum) { |
| 7811 | scalea = true; |
| 7812 | cscale = smlnum; |
| 7813 | } else if (anrm > bignum) { |
| 7814 | scalea = true; |
| 7815 | cscale = bignum; |
| 7816 | } |
| 7817 | if (scalea) { |
| 7818 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &anrm, &cscale, n, n, &a[a_offset], lda, & |
| 7819 | ierr); |
| 7820 | } |
| 7821 | |
| 7822 | /* Permute the matrix to make it more nearly triangular */ |
| 7823 | /* (RWorkspace: need N) */ |
| 7824 | |
| 7825 | ibal = 1; |
| 7826 | dgebal_cxx . . $ dgebal_(4da4b22b53009041).("P", n, &a[a_offset], lda, &ilo, &ihi, &work[ibal], &ierr); |
| 7827 | |
| 7828 | /* Reduce to upper Hessenberg form */ |
| 7829 | /* (RWorkspace: need 3*N, prefer 2*N+N*NB) */ |
| 7830 | |
| 7831 | itau = *n + ibal; |
| 7832 | iwrk = *n + itau; |
| 7833 | i__1 = *lwork - iwrk + 1; |
| 7834 | dgehrd_cxx . . $ dgehrd_(424524679a238630).(n, &ilo, &ihi, &a[a_offset], lda, &work[itau], &work[iwrk], &i__1, |
| 7835 | &ierr); |
| 7836 | |
| 7837 | if (wantvs) { |
| 7838 | |
| 7839 | /* Copy Householder vectors to VS */ |
| 7840 | |
| 7841 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("L", n, n, &a[a_offset], lda, &vs[vs_offset], ldvs) |
| 7842 | ; |
| 7843 | |
| 7844 | /* Generate orthogonal matrix in VS */ |
| 7845 | /* (RWorkspace: need 3*N-1, prefer 2*N+(N-1)*NB) */ |
| 7846 | |
| 7847 | i__1 = *lwork - iwrk + 1; |
| 7848 | dorghr_cxx . . $ dorghr_(424524679a238630).(n, &ilo, &ihi, &vs[vs_offset], ldvs, &work[itau], &work[iwrk], |
| 7849 | &i__1, &ierr); |
| 7850 | } |
| 7851 | |
| 7852 | *sdim = 0; |
| 7853 | |
| 7854 | /* Perform QR iteration, accumulating Schur vectors in VS if desired */ |
| 7855 | /* (RWorkspace: need N+1, prefer N+HSWORK (see comments) ) */ |
| 7856 | |
| 7857 | iwrk = itau; |
| 7858 | i__1 = *lwork - iwrk + 1; |
| 7859 | dhseqr_cxx . . $ dhseqr_(658beefb48cc805a).("S", jobvs, n, &ilo, &ihi, &a[a_offset], lda, &wr[1], &wi[1], &vs[ |
| 7860 | vs_offset], ldvs, &work[iwrk], &i__1, &ieval); |
| 7861 | if (ieval > 0) { |
| 7862 | *info = ieval; |
| 7863 | } |
| 7864 | |
| 7865 | /* Sort eigenvalues if desired */ |
| 7866 | |
| 7867 | if (wantst && *info == 0) { |
| 7868 | if (scalea) { |
| 7869 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &cscale, &anrm, n, &c__1, &wr[1], n, & |
| 7870 | ierr); |
| 7871 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &cscale, &anrm, n, &c__1, &wi[1], n, & |
| 7872 | ierr); |
| 7873 | } |
| 7874 | i__1 = *n; |
| 7875 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 7876 | bwork[i__] = (*select)(&wr[i__], &wi[i__]); |
| 7877 | /* L10: */ |
| 7878 | } |
| 7879 | |
| 7880 | /* Reorder eigenvalues, transform Schur vectors, and compute */ |
| 7881 | /* reciprocal condition numbers */ |
| 7882 | /* (RWorkspace: if SENSE is not 'N', need N+2*SDIM*(N-SDIM) */ |
| 7883 | /* otherwise, need N ) */ |
| 7884 | /* (IWorkspace: if SENSE is 'V' or 'B', need SDIM*(N-SDIM) */ |
| 7885 | /* otherwise, need 0 ) */ |
| 7886 | |
| 7887 | i__1 = *lwork - iwrk + 1; |
| 7888 | dtrsen_cxx . . $ dtrsen_(189d40317d8d1f2c).(sense, jobvs, &bwork[1], n, &a[a_offset], lda, &vs[vs_offset], |
| 7889 | ldvs, &wr[1], &wi[1], sdim, rconde, rcondv, &work[iwrk], & |
| 7890 | i__1, &iwork[1], liwork, &icond); |
| 7891 | if (! wantsn) { |
| 7892 | /* Computing MAX */ |
| 7893 | i__1 = maxwrk, i__2 = *n + (*sdim << 1) * (*n - *sdim); |
| 7894 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 7895 | } |
| 7896 | if (icond == -15) { |
| 7897 | |
| 7898 | /* Not enough real workspace */ |
| 7899 | |
| 7900 | *info = -16; |
| 7901 | } else if (icond == -17) { |
| 7902 | |
| 7903 | /* Not enough integer workspace */ |
| 7904 | |
| 7905 | *info = -18; |
| 7906 | } else if (icond > 0) { |
| 7907 | |
| 7908 | /* DTRSEN failed to reorder or to restore standard Schur form */ |
| 7909 | |
| 7910 | *info = icond + *n; |
| 7911 | } |
| 7912 | } |
| 7913 | |
| 7914 | if (wantvs) { |
| 7915 | |
| 7916 | /* Undo balancing */ |
| 7917 | /* (RWorkspace: need N) */ |
| 7918 | |
| 7919 | dgebak_cxx . . $ dgebak_(51612d8f5027ec5a).("P", "R", n, &ilo, &ihi, &work[ibal], n, &vs[vs_offset], ldvs, |
| 7920 | &ierr); |
| 7921 | } |
| 7922 | |
| 7923 | if (scalea) { |
| 7924 | |
| 7925 | /* Undo scaling for the Schur form of A */ |
| 7926 | |
| 7927 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("H", &c__0, &c__0, &cscale, &anrm, n, n, &a[a_offset], lda, & |
| 7928 | ierr); |
| 7929 | i__1 = *lda + 1; |
| 7930 | dcopy_cxx . . $ dcopy_(ec261fd7ec3b6bf6).(n, &a[a_offset], &i__1, &wr[1], &c__1); |
| 7931 | if ((wantsv || wantsb) && *info == 0) { |
| 7932 | dum[0] = *rcondv; |
| 7933 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &cscale, &anrm, &c__1, &c__1, dum, & |
| 7934 | c__1, &ierr); |
| 7935 | *rcondv = dum[0]; |
| 7936 | } |
| 7937 | if (cscale == smlnum) { |
| 7938 | |
| 7939 | /* If scaling back towards underflow, adjust WI if an */ |
| 7940 | /* offdiagonal element of a 2-by-2 block in the Schur form */ |
| 7941 | /* underflows. */ |
| 7942 | |
| 7943 | if (ieval > 0) { |
| 7944 | i1 = ieval + 1; |
| 7945 | i2 = ihi - 1; |
| 7946 | i__1 = ilo - 1; |
| 7947 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &cscale, &anrm, &i__1, &c__1, &wi[ |
| 7948 | 1], n, &ierr); |
| 7949 | } else if (wantst) { |
| 7950 | i1 = 1; |
| 7951 | i2 = *n - 1; |
| 7952 | } else { |
| 7953 | i1 = ilo; |
| 7954 | i2 = ihi - 1; |
| 7955 | } |
| 7956 | inxt = i1 - 1; |
| 7957 | i__1 = i2; |
| 7958 | for (i__ = i1; i__ <= i__1; ++i__) { |
| 7959 | if (i__ < inxt) { |
| 7960 | goto L20; |
| 7961 | } |
| 7962 | if (wi[i__] == 0.) { |
| 7963 | inxt = i__ + 1; |
| 7964 | } else { |
| 7965 | if (a[i__ + 1 + i__ * a_dim1] == 0.) { |
| 7966 | wi[i__] = 0.; |
| 7967 | wi[i__ + 1] = 0.; |
| 7968 | } else if (a[i__ + 1 + i__ * a_dim1] != 0. && a[i__ + ( |
| 7969 | i__ + 1) * a_dim1] == 0.) { |
| 7970 | wi[i__] = 0.; |
| 7971 | wi[i__ + 1] = 0.; |
| 7972 | if (i__ > 1) { |
| 7973 | i__2 = i__ - 1; |
| 7974 | dswap_cxx . . $ dswap_(ec261fd7ec3b6bf6).(&i__2, &a[i__ * a_dim1 + 1], &c__1, &a[( |
| 7975 | i__ + 1) * a_dim1 + 1], &c__1); |
| 7976 | } |
| 7977 | if (*n > i__ + 1) { |
| 7978 | i__2 = *n - i__ - 1; |
| 7979 | dswap_cxx . . $ dswap_(ec261fd7ec3b6bf6).(&i__2, &a[i__ + (i__ + 2) * a_dim1], lda, & |
| 7980 | a[i__ + 1 + (i__ + 2) * a_dim1], lda); |
| 7981 | } |
| 7982 | dswap_cxx . . $ dswap_(ec261fd7ec3b6bf6).(n, &vs[i__ * vs_dim1 + 1], &c__1, &vs[(i__ + 1) |
| 7983 | * vs_dim1 + 1], &c__1); |
| 7984 | a[i__ + (i__ + 1) * a_dim1] = a[i__ + 1 + i__ * |
| 7985 | a_dim1]; |
| 7986 | a[i__ + 1 + i__ * a_dim1] = 0.; |
| 7987 | } |
| 7988 | inxt = i__ + 2; |
| 7989 | } |
| 7990 | L20: |
| 7991 | ; |
| 7992 | } |
| 7993 | } |
| 7994 | i__1 = *n - ieval; |
| 7995 | /* Computing MAX */ |
| 7996 | i__3 = *n - ieval; |
| 7997 | i__2 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__3,1_integercxx . . $ `operator""_integer`(85240eb457c3721a).); |
| 7998 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &cscale, &anrm, &i__1, &c__1, &wi[ieval + |
| 7999 | 1], &i__2, &ierr); |
| 8000 | } |
| 8001 | |
| 8002 | if (wantst && *info == 0) { |
| 8003 | |
| 8004 | /* Check if reordering successful */ |
| 8005 | |
| 8006 | lastsl = true; |
| 8007 | lst2sl = true; |
| 8008 | *sdim = 0; |
| 8009 | ip = 0; |
| 8010 | i__1 = *n; |
| 8011 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 8012 | cursl = (*select)(&wr[i__], &wi[i__]); |
| 8013 | if (wi[i__] == 0.) { |
| 8014 | if (cursl) { |
| 8015 | ++(*sdim); |
| 8016 | } |
| 8017 | ip = 0; |
| 8018 | if (cursl && ! lastsl) { |
| 8019 | *info = *n + 2; |
| 8020 | } |
| 8021 | } else { |
| 8022 | if (ip == 1) { |
| 8023 | |
| 8024 | /* Last eigenvalue of conjugate pair */ |
| 8025 | |
| 8026 | cursl = cursl || lastsl; |
| 8027 | lastsl = cursl; |
| 8028 | if (cursl) { |
| 8029 | *sdim += 2; |
| 8030 | } |
| 8031 | ip = -1; |
| 8032 | if (cursl && ! lst2sl) { |
| 8033 | *info = *n + 2; |
| 8034 | } |
| 8035 | } else { |
| 8036 | |
| 8037 | /* First eigenvalue of conjugate pair */ |
| 8038 | |
| 8039 | ip = 1; |
| 8040 | } |
| 8041 | } |
| 8042 | lst2sl = lastsl; |
| 8043 | lastsl = cursl; |
| 8044 | /* L30: */ |
| 8045 | } |
| 8046 | } |
| 8047 | |
| 8048 | work[1] = (double) maxwrk; |
| 8049 | if (wantsv || wantsb) { |
| 8050 | /* Computing MAX */ |
| 8051 | i__1 = 1, i__2 = *sdim * (*n - *sdim); |
| 8052 | iwork[1] = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 8053 | } else { |
| 8054 | iwork[1] = 1; |
| 8055 | } |
| 8056 | |
| 8057 | return 0; |
| 8058 | |
| 8059 | /* End of DGEESX */ |
| 8060 | |
| 8061 | } /* dgeesx_ */ |
| 8062 | |
| 8063 | /* Subroutine */ int dgeev_cxx . . $ dgeev_(cad49b079db8ab27).(const char *jobvl, const char *jobvr, integercxx . . $ integer# *n, double *a, integercxx . . $ integer# *lda, double *wr, double *wi, |
| 8064 | double *vl, integercxx . . $ integer# *ldvl, double *vr, integercxx . . $ integer# *ldvr, double *work, integercxx . . $ integer# *lwork, integercxx . . $ integer# *info) |
| 8065 | { |
| 8066 | /* Table of constant values */ |
| 8067 | static integercxx . . $ integer# c__1 = 1; |
| 8068 | static integercxx . . $ integer# c__0 = 0; |
| 8069 | static integercxx . . $ integer# c_n1 = -1; |
| 8070 | |
| 8071 | /* System generated locals */ |
| 8072 | integercxx . . $ integer# a_dim1, a_offset, vl_dim1, vl_offset, vr_dim1, vr_offset, i__1, |
| 8073 | i__2, i__3; |
| 8074 | double d__1, d__2; |
| 8075 | |
| 8076 | /* Local variables */ |
| 8077 | integercxx . . $ integer# i__, k; |
| 8078 | double r__, cs, sn; |
| 8079 | integercxx . . $ integer# ihi; |
| 8080 | double scl; |
| 8081 | integercxx . . $ integer# ilo; |
| 8082 | double dum[1], eps; |
| 8083 | integercxx . . $ integer# ibal; |
| 8084 | char side[1]; |
| 8085 | double anrm; |
| 8086 | integercxx . . $ integer# ierr, itau; |
| 8087 | integercxx . . $ integer# iwrk, nout; |
| 8088 | bool scalea; |
| 8089 | double cscale; |
| 8090 | bool select[1]; |
| 8091 | double bignum; |
| 8092 | integercxx . . $ integer# minwrk, maxwrk; |
| 8093 | bool wantvl; |
| 8094 | double smlnum; |
| 8095 | integercxx . . $ integer# hswork; |
| 8096 | bool lquery, wantvr; |
| 8097 | |
| 8098 | |
| 8099 | /* -- LAPACK driver routine (version 3.1) -- */ |
| 8100 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 8101 | /* November 2006 */ |
| 8102 | |
| 8103 | /* .. Scalar Arguments .. */ |
| 8104 | /* .. */ |
| 8105 | /* .. Array Arguments .. */ |
| 8106 | /* .. */ |
| 8107 | |
| 8108 | /* Purpose */ |
| 8109 | /* ======= */ |
| 8110 | |
| 8111 | /* DGEEV computes for an N-by-N real nonsymmetric matrix A, the */ |
| 8112 | /* eigenvalues and, optionally, the left and/or right eigenvectors. */ |
| 8113 | |
| 8114 | /* The right eigenvector v(j) of A satisfies */ |
| 8115 | /* A * v(j) = lambda(j) * v(j) */ |
| 8116 | /* where lambda(j) is its eigenvalue. */ |
| 8117 | /* The left eigenvector u(j) of A satisfies */ |
| 8118 | /* u(j)**H * A = lambda(j) * u(j)**H */ |
| 8119 | /* where u(j)**H denotes the conjugate transpose of u(j). */ |
| 8120 | |
| 8121 | /* The computed eigenvectors are normalized to have Euclidean norm */ |
| 8122 | /* equal to 1 and largest component real. */ |
| 8123 | |
| 8124 | /* Arguments */ |
| 8125 | /* ========= */ |
| 8126 | |
| 8127 | /* JOBVL (input) CHARACTER*1 */ |
| 8128 | /* = 'N': left eigenvectors of A are not computed; */ |
| 8129 | /* = 'V': left eigenvectors of A are computed. */ |
| 8130 | |
| 8131 | /* JOBVR (input) CHARACTER*1 */ |
| 8132 | /* = 'N': right eigenvectors of A are not computed; */ |
| 8133 | /* = 'V': right eigenvectors of A are computed. */ |
| 8134 | |
| 8135 | /* N (input) INTEGER */ |
| 8136 | /* The order of the matrix A. N >= 0. */ |
| 8137 | |
| 8138 | /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 8139 | /* On entry, the N-by-N matrix A. */ |
| 8140 | /* On exit, A has been overwritten. */ |
| 8141 | |
| 8142 | /* LDA (input) INTEGER */ |
| 8143 | /* The leading dimension of the array A. LDA >= max(1,N). */ |
| 8144 | |
| 8145 | /* WR (output) DOUBLE PRECISION array, dimension (N) */ |
| 8146 | /* WI (output) DOUBLE PRECISION array, dimension (N) */ |
| 8147 | /* WR and WI contain the real and imaginary parts, */ |
| 8148 | /* respectively, of the computed eigenvalues. Complex */ |
| 8149 | /* conjugate pairs of eigenvalues appear consecutively */ |
| 8150 | /* with the eigenvalue having the positive imaginary part */ |
| 8151 | /* first. */ |
| 8152 | |
| 8153 | /* VL (output) DOUBLE PRECISION array, dimension (LDVL,N) */ |
| 8154 | /* If JOBVL = 'V', the left eigenvectors u(j) are stored one */ |
| 8155 | /* after another in the columns of VL, in the same order */ |
| 8156 | /* as their eigenvalues. */ |
| 8157 | /* If JOBVL = 'N', VL is not referenced. */ |
| 8158 | /* If the j-th eigenvalue is real, then u(j) = VL(:,j), */ |
| 8159 | /* the j-th column of VL. */ |
| 8160 | /* If the j-th and (j+1)-st eigenvalues form a complex */ |
| 8161 | /* conjugate pair, then u(j) = VL(:,j) + i*VL(:,j+1) and */ |
| 8162 | /* u(j+1) = VL(:,j) - i*VL(:,j+1). */ |
| 8163 | |
| 8164 | /* LDVL (input) INTEGER */ |
| 8165 | /* The leading dimension of the array VL. LDVL >= 1; if */ |
| 8166 | /* JOBVL = 'V', LDVL >= N. */ |
| 8167 | |
| 8168 | /* VR (output) DOUBLE PRECISION array, dimension (LDVR,N) */ |
| 8169 | /* If JOBVR = 'V', the right eigenvectors v(j) are stored one */ |
| 8170 | /* after another in the columns of VR, in the same order */ |
| 8171 | /* as their eigenvalues. */ |
| 8172 | /* If JOBVR = 'N', VR is not referenced. */ |
| 8173 | /* If the j-th eigenvalue is real, then v(j) = VR(:,j), */ |
| 8174 | /* the j-th column of VR. */ |
| 8175 | /* If the j-th and (j+1)-st eigenvalues form a complex */ |
| 8176 | /* conjugate pair, then v(j) = VR(:,j) + i*VR(:,j+1) and */ |
| 8177 | /* v(j+1) = VR(:,j) - i*VR(:,j+1). */ |
| 8178 | |
| 8179 | /* LDVR (input) INTEGER */ |
| 8180 | /* The leading dimension of the array VR. LDVR >= 1; if */ |
| 8181 | /* JOBVR = 'V', LDVR >= N. */ |
| 8182 | |
| 8183 | /* WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) */ |
| 8184 | /* On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ |
| 8185 | |
| 8186 | /* LWORK (input) INTEGER */ |
| 8187 | /* The dimension of the array WORK. LWORK >= max(1,3*N), and */ |
| 8188 | /* if JOBVL = 'V' or JOBVR = 'V', LWORK >= 4*N. For good */ |
| 8189 | /* performance, LWORK must generally be larger. */ |
| 8190 | |
| 8191 | /* If LWORK = -1, then a workspace query is assumed; the routine */ |
| 8192 | /* only calculates the optimal size of the WORK array, returns */ |
| 8193 | /* this value as the first entry of the WORK array, and no error */ |
| 8194 | /* message related to LWORK is issued by XERBLA. */ |
| 8195 | |
| 8196 | /* INFO (output) INTEGER */ |
| 8197 | /* = 0: successful exit */ |
| 8198 | /* < 0: if INFO = -i, the i-th argument had an illegal value. */ |
| 8199 | /* > 0: if INFO = i, the QR algorithm failed to compute all the */ |
| 8200 | /* eigenvalues, and no eigenvectors have been computed; */ |
| 8201 | /* elements i+1:N of WR and WI contain eigenvalues which */ |
| 8202 | /* have converged. */ |
| 8203 | |
| 8204 | /* ===================================================================== */ |
| 8205 | |
| 8206 | /* .. Parameters .. */ |
| 8207 | /* .. */ |
| 8208 | /* .. Local Scalars .. */ |
| 8209 | /* .. */ |
| 8210 | /* .. Local Arrays .. */ |
| 8211 | /* .. */ |
| 8212 | /* .. External Subroutines .. */ |
| 8213 | /* .. */ |
| 8214 | /* .. External Functions .. */ |
| 8215 | /* .. */ |
| 8216 | /* .. Intrinsic Functions .. */ |
| 8217 | /* .. */ |
| 8218 | /* .. Executable Statements .. */ |
| 8219 | |
| 8220 | /* Test the input arguments */ |
| 8221 | |
| 8222 | /* Parameter adjustments */ |
| 8223 | a_dim1 = *lda; |
| 8224 | a_offset = 1 + a_dim1; |
| 8225 | a -= a_offset; |
| 8226 | --wr; |
| 8227 | --wi; |
| 8228 | vl_dim1 = *ldvl; |
| 8229 | vl_offset = 1 + vl_dim1; |
| 8230 | vl -= vl_offset; |
| 8231 | vr_dim1 = *ldvr; |
| 8232 | vr_offset = 1 + vr_dim1; |
| 8233 | vr -= vr_offset; |
| 8234 | --work; |
| 8235 | |
| 8236 | /* Function Body */ |
| 8237 | *info = 0; |
| 8238 | lquery = *lwork == -1; |
| 8239 | wantvl = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobvl, "V"); |
| 8240 | wantvr = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobvr, "V"); |
| 8241 | if (! wantvl && ! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobvl, "N")) { |
| 8242 | *info = -1; |
| 8243 | } else if (! wantvr && ! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobvr, "N")) { |
| 8244 | *info = -2; |
| 8245 | } else if (*n < 0) { |
| 8246 | *info = -3; |
| 8247 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 8248 | *info = -5; |
| 8249 | } else if (*ldvl < 1 || wantvl && *ldvl < *n) { |
| 8250 | *info = -9; |
| 8251 | } else if (*ldvr < 1 || wantvr && *ldvr < *n) { |
| 8252 | *info = -11; |
| 8253 | } |
| 8254 | |
| 8255 | /* Compute workspace */ |
| 8256 | /* (Note: Comments in the code beginning "Workspace:" describe the */ |
| 8257 | /* minimal amount of workspace needed at that point in the code, */ |
| 8258 | /* as well as the preferred amount for good performance. */ |
| 8259 | /* NB refers to the optimal block size for the immediately */ |
| 8260 | /* following subroutine, as returned by ILAENV. */ |
| 8261 | /* HSWORK refers to the workspace preferred by DHSEQR, as */ |
| 8262 | /* calculated below. HSWORK is computed assuming ILO=1 and IHI=N, */ |
| 8263 | /* the worst case.) */ |
| 8264 | |
| 8265 | if (*info == 0) { |
| 8266 | if (*n == 0) { |
| 8267 | minwrk = 1; |
| 8268 | maxwrk = 1; |
| 8269 | } else { |
| 8270 | maxwrk = (*n << 1) + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEHRD", " ", n, &c__1, |
| 8271 | n, &c__0); |
| 8272 | if (wantvl) { |
| 8273 | minwrk = *n << 2; |
| 8274 | /* Computing MAX */ |
| 8275 | i__1 = maxwrk, i__2 = (*n << 1) + (*n - 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 8276 | "DORGHR", " ", n, &c__1, n, &c_n1); |
| 8277 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 8278 | dhseqr_cxx . . $ dhseqr_(658beefb48cc805a).("S", "V", n, &c__1, n, &a[a_offset], lda, &wr[1], &wi[ |
| 8279 | 1], &vl[vl_offset], ldvl, &work[1], &c_n1, info); |
| 8280 | hswork = (integercxx . . $ integer#) work[1]; |
| 8281 | /* Computing MAX */ |
| 8282 | i__1 = maxwrk, i__2 = *n + 1, i__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2), i__2 = * |
| 8283 | n + hswork; |
| 8284 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 8285 | /* Computing MAX */ |
| 8286 | i__1 = maxwrk, i__2 = *n << 2; |
| 8287 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 8288 | } else if (wantvr) { |
| 8289 | minwrk = *n << 2; |
| 8290 | /* Computing MAX */ |
| 8291 | i__1 = maxwrk, i__2 = (*n << 1) + (*n - 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 8292 | "DORGHR", " ", n, &c__1, n, &c_n1); |
| 8293 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 8294 | dhseqr_cxx . . $ dhseqr_(658beefb48cc805a).("S", "V", n, &c__1, n, &a[a_offset], lda, &wr[1], &wi[ |
| 8295 | 1], &vr[vr_offset], ldvr, &work[1], &c_n1, info); |
| 8296 | hswork = (integercxx . . $ integer#) work[1]; |
| 8297 | /* Computing MAX */ |
| 8298 | i__1 = maxwrk, i__2 = *n + 1, i__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2), i__2 = * |
| 8299 | n + hswork; |
| 8300 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 8301 | /* Computing MAX */ |
| 8302 | i__1 = maxwrk, i__2 = *n << 2; |
| 8303 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 8304 | } else { |
| 8305 | minwrk = *n * 3; |
| 8306 | dhseqr_cxx . . $ dhseqr_(658beefb48cc805a).("E", "N", n, &c__1, n, &a[a_offset], lda, &wr[1], &wi[ |
| 8307 | 1], &vr[vr_offset], ldvr, &work[1], &c_n1, info); |
| 8308 | hswork = (integercxx . . $ integer#) work[1]; |
| 8309 | /* Computing MAX */ |
| 8310 | i__1 = maxwrk, i__2 = *n + 1, i__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2), i__2 = * |
| 8311 | n + hswork; |
| 8312 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 8313 | } |
| 8314 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(maxwrk,minwrk); |
| 8315 | } |
| 8316 | work[1] = (double) maxwrk; |
| 8317 | |
| 8318 | if (*lwork < minwrk && ! lquery) { |
| 8319 | *info = -13; |
| 8320 | } |
| 8321 | } |
| 8322 | |
| 8323 | if (*info != 0) { |
| 8324 | i__1 = -(*info); |
| 8325 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGEEV ", &i__1); |
| 8326 | return 0; |
| 8327 | } else if (lquery) { |
| 8328 | return 0; |
| 8329 | } |
| 8330 | |
| 8331 | /* Quick return if possible */ |
| 8332 | |
| 8333 | if (*n == 0) { |
| 8334 | return 0; |
| 8335 | } |
| 8336 | |
| 8337 | /* Get machine constants */ |
| 8338 | |
| 8339 | eps = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("P"); |
| 8340 | smlnum = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("S"); |
| 8341 | bignum = 1. / smlnum; |
| 8342 | dlabad_cxx . . $ dlabad_(4730c933dae9b326).(&smlnum, &bignum); |
| 8343 | smlnum = sqrtcxx . . $ sqrt(fee4f1d22bc8e617).(smlnum) / eps; |
| 8344 | bignum = 1. / smlnum; |
| 8345 | |
| 8346 | /* Scale A if max element outside range [SMLNUM,BIGNUM] */ |
| 8347 | |
| 8348 | anrm = dlange_cxx . . $ dlange_(98d44e6417336f20).("M", n, n, &a[a_offset], lda, dum); |
| 8349 | scalea = false; |
| 8350 | if (anrm > 0. && anrm < smlnum) { |
| 8351 | scalea = true; |
| 8352 | cscale = smlnum; |
| 8353 | } else if (anrm > bignum) { |
| 8354 | scalea = true; |
| 8355 | cscale = bignum; |
| 8356 | } |
| 8357 | if (scalea) { |
| 8358 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &anrm, &cscale, n, n, &a[a_offset], lda, & |
| 8359 | ierr); |
| 8360 | } |
| 8361 | |
| 8362 | /* Balance the matrix */ |
| 8363 | /* (Workspace: need N) */ |
| 8364 | |
| 8365 | ibal = 1; |
| 8366 | dgebal_cxx . . $ dgebal_(4da4b22b53009041).("B", n, &a[a_offset], lda, &ilo, &ihi, &work[ibal], &ierr); |
| 8367 | |
| 8368 | /* Reduce to upper Hessenberg form */ |
| 8369 | /* (Workspace: need 3*N, prefer 2*N+N*NB) */ |
| 8370 | |
| 8371 | itau = ibal + *n; |
| 8372 | iwrk = itau + *n; |
| 8373 | i__1 = *lwork - iwrk + 1; |
| 8374 | dgehrd_cxx . . $ dgehrd_(424524679a238630).(n, &ilo, &ihi, &a[a_offset], lda, &work[itau], &work[iwrk], &i__1, |
| 8375 | &ierr); |
| 8376 | |
| 8377 | if (wantvl) { |
| 8378 | |
| 8379 | /* Want left eigenvectors */ |
| 8380 | /* Copy Householder vectors to VL */ |
| 8381 | |
| 8382 | *(unsigned char *)side = 'L'; |
| 8383 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("L", n, n, &a[a_offset], lda, &vl[vl_offset], ldvl) |
| 8384 | ; |
| 8385 | |
| 8386 | /* Generate orthogonal matrix in VL */ |
| 8387 | /* (Workspace: need 3*N-1, prefer 2*N+(N-1)*NB) */ |
| 8388 | |
| 8389 | i__1 = *lwork - iwrk + 1; |
| 8390 | dorghr_cxx . . $ dorghr_(424524679a238630).(n, &ilo, &ihi, &vl[vl_offset], ldvl, &work[itau], &work[iwrk], |
| 8391 | &i__1, &ierr); |
| 8392 | |
| 8393 | /* Perform QR iteration, accumulating Schur vectors in VL */ |
| 8394 | /* (Workspace: need N+1, prefer N+HSWORK (see comments) ) */ |
| 8395 | |
| 8396 | iwrk = itau; |
| 8397 | i__1 = *lwork - iwrk + 1; |
| 8398 | dhseqr_cxx . . $ dhseqr_(658beefb48cc805a).("S", "V", n, &ilo, &ihi, &a[a_offset], lda, &wr[1], &wi[1], & |
| 8399 | vl[vl_offset], ldvl, &work[iwrk], &i__1, info); |
| 8400 | |
| 8401 | if (wantvr) { |
| 8402 | |
| 8403 | /* Want left and right eigenvectors */ |
| 8404 | /* Copy Schur vectors to VR */ |
| 8405 | |
| 8406 | *(unsigned char *)side = 'B'; |
| 8407 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("F", n, n, &vl[vl_offset], ldvl, &vr[vr_offset], ldvr); |
| 8408 | } |
| 8409 | |
| 8410 | } else if (wantvr) { |
| 8411 | |
| 8412 | /* Want right eigenvectors */ |
| 8413 | /* Copy Householder vectors to VR */ |
| 8414 | |
| 8415 | *(unsigned char *)side = 'R'; |
| 8416 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("L", n, n, &a[a_offset], lda, &vr[vr_offset], ldvr) |
| 8417 | ; |
| 8418 | |
| 8419 | /* Generate orthogonal matrix in VR */ |
| 8420 | /* (Workspace: need 3*N-1, prefer 2*N+(N-1)*NB) */ |
| 8421 | |
| 8422 | i__1 = *lwork - iwrk + 1; |
| 8423 | dorghr_cxx . . $ dorghr_(424524679a238630).(n, &ilo, &ihi, &vr[vr_offset], ldvr, &work[itau], &work[iwrk], |
| 8424 | &i__1, &ierr); |
| 8425 | |
| 8426 | /* Perform QR iteration, accumulating Schur vectors in VR */ |
| 8427 | /* (Workspace: need N+1, prefer N+HSWORK (see comments) ) */ |
| 8428 | |
| 8429 | iwrk = itau; |
| 8430 | i__1 = *lwork - iwrk + 1; |
| 8431 | dhseqr_cxx . . $ dhseqr_(658beefb48cc805a).("S", "V", n, &ilo, &ihi, &a[a_offset], lda, &wr[1], &wi[1], & |
| 8432 | vr[vr_offset], ldvr, &work[iwrk], &i__1, info); |
| 8433 | |
| 8434 | } else { |
| 8435 | |
| 8436 | /* Compute eigenvalues only */ |
| 8437 | /* (Workspace: need N+1, prefer N+HSWORK (see comments) ) */ |
| 8438 | |
| 8439 | iwrk = itau; |
| 8440 | i__1 = *lwork - iwrk + 1; |
| 8441 | dhseqr_cxx . . $ dhseqr_(658beefb48cc805a).("E", "N", n, &ilo, &ihi, &a[a_offset], lda, &wr[1], &wi[1], & |
| 8442 | vr[vr_offset], ldvr, &work[iwrk], &i__1, info); |
| 8443 | } |
| 8444 | |
| 8445 | /* If INFO > 0 from DHSEQR, then quit */ |
| 8446 | |
| 8447 | if (*info > 0) { |
| 8448 | goto L50; |
| 8449 | } |
| 8450 | |
| 8451 | if (wantvl || wantvr) { |
| 8452 | |
| 8453 | /* Compute left and/or right eigenvectors */ |
| 8454 | /* (Workspace: need 4*N) */ |
| 8455 | |
| 8456 | dtrevc_cxx . . $ dtrevc_(7b3a76416ced2fcb).(side, "B", select, n, &a[a_offset], lda, &vl[vl_offset], ldvl, |
| 8457 | &vr[vr_offset], ldvr, n, &nout, &work[iwrk], &ierr); |
| 8458 | } |
| 8459 | |
| 8460 | if (wantvl) { |
| 8461 | |
| 8462 | /* Undo balancing of left eigenvectors */ |
| 8463 | /* (Workspace: need N) */ |
| 8464 | |
| 8465 | dgebak_cxx . . $ dgebak_(51612d8f5027ec5a).("B", "L", n, &ilo, &ihi, &work[ibal], n, &vl[vl_offset], ldvl, |
| 8466 | &ierr); |
| 8467 | |
| 8468 | /* Normalize left eigenvectors and make largest component real */ |
| 8469 | |
| 8470 | i__1 = *n; |
| 8471 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 8472 | if (wi[i__] == 0.) { |
| 8473 | scl = 1. / dnrm2_cxx . . $ dnrm2_(c4756756b043e0f).(n, &vl[i__ * vl_dim1 + 1], &c__1); |
| 8474 | dscal_cxx . . $ dscal_(f22c1db71784c345).(n, &scl, &vl[i__ * vl_dim1 + 1], &c__1); |
| 8475 | } else if (wi[i__] > 0.) { |
| 8476 | d__1 = dnrm2_cxx . . $ dnrm2_(c4756756b043e0f).(n, &vl[i__ * vl_dim1 + 1], &c__1); |
| 8477 | d__2 = dnrm2_cxx . . $ dnrm2_(c4756756b043e0f).(n, &vl[(i__ + 1) * vl_dim1 + 1], &c__1); |
| 8478 | scl = 1. / dlapy2_cxx . . $ dlapy2_(8fcf9002b7f393aa).(&d__1, &d__2); |
| 8479 | dscal_cxx . . $ dscal_(f22c1db71784c345).(n, &scl, &vl[i__ * vl_dim1 + 1], &c__1); |
| 8480 | dscal_cxx . . $ dscal_(f22c1db71784c345).(n, &scl, &vl[(i__ + 1) * vl_dim1 + 1], &c__1); |
| 8481 | i__2 = *n; |
| 8482 | for (k = 1; k <= i__2; ++k) { |
| 8483 | /* Computing 2nd power */ |
| 8484 | d__1 = vl[k + i__ * vl_dim1]; |
| 8485 | /* Computing 2nd power */ |
| 8486 | d__2 = vl[k + (i__ + 1) * vl_dim1]; |
| 8487 | work[iwrk + k - 1] = d__1 * d__1 + d__2 * d__2; |
| 8488 | /* L10: */ |
| 8489 | } |
| 8490 | k = idamax_cxx . . $ idamax_(a5c31fbfbc00ee45).(n, &work[iwrk], &c__1); |
| 8491 | dlartg_cxx . . $ dlartg_(f2b979bf0498d687).(&vl[k + i__ * vl_dim1], &vl[k + (i__ + 1) * vl_dim1], |
| 8492 | &cs, &sn, &r__); |
| 8493 | drot_cxx . . $ drot_(31e32f39c16a90e0).(n, &vl[i__ * vl_dim1 + 1], &c__1, &vl[(i__ + 1) * |
| 8494 | vl_dim1 + 1], &c__1, &cs, &sn); |
| 8495 | vl[k + (i__ + 1) * vl_dim1] = 0.; |
| 8496 | } |
| 8497 | /* L20: */ |
| 8498 | } |
| 8499 | } |
| 8500 | |
| 8501 | if (wantvr) { |
| 8502 | |
| 8503 | /* Undo balancing of right eigenvectors */ |
| 8504 | /* (Workspace: need N) */ |
| 8505 | |
| 8506 | dgebak_cxx . . $ dgebak_(51612d8f5027ec5a).("B", "R", n, &ilo, &ihi, &work[ibal], n, &vr[vr_offset], ldvr, |
| 8507 | &ierr); |
| 8508 | |
| 8509 | /* Normalize right eigenvectors and make largest component real */ |
| 8510 | |
| 8511 | i__1 = *n; |
| 8512 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 8513 | if (wi[i__] == 0.) { |
| 8514 | scl = 1. / dnrm2_cxx . . $ dnrm2_(c4756756b043e0f).(n, &vr[i__ * vr_dim1 + 1], &c__1); |
| 8515 | dscal_cxx . . $ dscal_(f22c1db71784c345).(n, &scl, &vr[i__ * vr_dim1 + 1], &c__1); |
| 8516 | } else if (wi[i__] > 0.) { |
| 8517 | d__1 = dnrm2_cxx . . $ dnrm2_(c4756756b043e0f).(n, &vr[i__ * vr_dim1 + 1], &c__1); |
| 8518 | d__2 = dnrm2_cxx . . $ dnrm2_(c4756756b043e0f).(n, &vr[(i__ + 1) * vr_dim1 + 1], &c__1); |
| 8519 | scl = 1. / dlapy2_cxx . . $ dlapy2_(8fcf9002b7f393aa).(&d__1, &d__2); |
| 8520 | dscal_cxx . . $ dscal_(f22c1db71784c345).(n, &scl, &vr[i__ * vr_dim1 + 1], &c__1); |
| 8521 | dscal_cxx . . $ dscal_(f22c1db71784c345).(n, &scl, &vr[(i__ + 1) * vr_dim1 + 1], &c__1); |
| 8522 | i__2 = *n; |
| 8523 | for (k = 1; k <= i__2; ++k) { |
| 8524 | /* Computing 2nd power */ |
| 8525 | d__1 = vr[k + i__ * vr_dim1]; |
| 8526 | /* Computing 2nd power */ |
| 8527 | d__2 = vr[k + (i__ + 1) * vr_dim1]; |
| 8528 | work[iwrk + k - 1] = d__1 * d__1 + d__2 * d__2; |
| 8529 | /* L30: */ |
| 8530 | } |
| 8531 | k = idamax_cxx . . $ idamax_(a5c31fbfbc00ee45).(n, &work[iwrk], &c__1); |
| 8532 | dlartg_cxx . . $ dlartg_(f2b979bf0498d687).(&vr[k + i__ * vr_dim1], &vr[k + (i__ + 1) * vr_dim1], |
| 8533 | &cs, &sn, &r__); |
| 8534 | drot_cxx . . $ drot_(31e32f39c16a90e0).(n, &vr[i__ * vr_dim1 + 1], &c__1, &vr[(i__ + 1) * |
| 8535 | vr_dim1 + 1], &c__1, &cs, &sn); |
| 8536 | vr[k + (i__ + 1) * vr_dim1] = 0.; |
| 8537 | } |
| 8538 | /* L40: */ |
| 8539 | } |
| 8540 | } |
| 8541 | |
| 8542 | /* Undo scaling if necessary */ |
| 8543 | |
| 8544 | L50: |
| 8545 | if (scalea) { |
| 8546 | i__1 = *n - *info; |
| 8547 | /* Computing MAX */ |
| 8548 | i__3 = *n - *info; |
| 8549 | i__2 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__3,1_integercxx . . $ `operator""_integer`(85240eb457c3721a).); |
| 8550 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &cscale, &anrm, &i__1, &c__1, &wr[*info + |
| 8551 | 1], &i__2, &ierr); |
| 8552 | i__1 = *n - *info; |
| 8553 | /* Computing MAX */ |
| 8554 | i__3 = *n - *info; |
| 8555 | i__2 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__3,1_integercxx . . $ `operator""_integer`(85240eb457c3721a).); |
| 8556 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &cscale, &anrm, &i__1, &c__1, &wi[*info + |
| 8557 | 1], &i__2, &ierr); |
| 8558 | if (*info > 0) { |
| 8559 | i__1 = ilo - 1; |
| 8560 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &cscale, &anrm, &i__1, &c__1, &wr[1], |
| 8561 | n, &ierr); |
| 8562 | i__1 = ilo - 1; |
| 8563 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &cscale, &anrm, &i__1, &c__1, &wi[1], |
| 8564 | n, &ierr); |
| 8565 | } |
| 8566 | } |
| 8567 | |
| 8568 | work[1] = (double) maxwrk; |
| 8569 | return 0; |
| 8570 | |
| 8571 | /* End of DGEEV */ |
| 8572 | |
| 8573 | } /* dgeev_ */ |
| 8574 | |
| 8575 | /* Subroutine */ int dgeevx_cxx . . $ dgeevx_(b9f2362e24e66fa6).(const char *balanc, const char *jobvl, const char *jobvr, const char * |
| 8576 | sense, integercxx . . $ integer# *n, double *a, integercxx . . $ integer# *lda, double *wr, |
| 8577 | double *wi, double *vl, integercxx . . $ integer# *ldvl, double *vr, |
| 8578 | integercxx . . $ integer# *ldvr, integercxx . . $ integer# *ilo, integercxx . . $ integer# *ihi, double *scale, |
| 8579 | double *abnrm, double *rconde, double *rcondv, double |
| 8580 | *work, integercxx . . $ integer# *lwork, integercxx . . $ integer# *iwork, integercxx . . $ integer# *info) |
| 8581 | { |
| 8582 | /* Table of constant values */ |
| 8583 | static integercxx . . $ integer# c__1 = 1; |
| 8584 | static integercxx . . $ integer# c__0 = 0; |
| 8585 | static integercxx . . $ integer# c_n1 = -1; |
| 8586 | |
| 8587 | /* System generated locals */ |
| 8588 | integercxx . . $ integer# a_dim1, a_offset, vl_dim1, vl_offset, vr_dim1, vr_offset, i__1, |
| 8589 | i__2, i__3; |
| 8590 | double d__1, d__2; |
| 8591 | |
| 8592 | /* Builtin functions |
| 8593 | double sqrt(double); */ |
| 8594 | |
| 8595 | /* Local variables */ |
| 8596 | integercxx . . $ integer# i__, k; |
| 8597 | double r__, cs, sn; |
| 8598 | char job[1]; |
| 8599 | double scl, dum[1], eps; |
| 8600 | char side[1]; |
| 8601 | double anrm; |
| 8602 | integercxx . . $ integer# ierr, itau; |
| 8603 | integercxx . . $ integer# iwrk, nout; |
| 8604 | integercxx . . $ integer# icond; |
| 8605 | bool scalea; |
| 8606 | double cscale; |
| 8607 | bool select[1]; |
| 8608 | double bignum; |
| 8609 | integercxx . . $ integer# minwrk, maxwrk; |
| 8610 | bool wantvl, wntsnb; |
| 8611 | integercxx . . $ integer# hswork; |
| 8612 | bool wntsne; |
| 8613 | double smlnum; |
| 8614 | bool lquery, wantvr, wntsnn, wntsnv; |
| 8615 | |
| 8616 | |
| 8617 | /* -- LAPACK driver routine (version 3.1) -- */ |
| 8618 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 8619 | /* November 2006 */ |
| 8620 | |
| 8621 | /* .. Scalar Arguments .. */ |
| 8622 | /* .. */ |
| 8623 | /* .. Array Arguments .. */ |
| 8624 | /* .. */ |
| 8625 | |
| 8626 | /* Purpose */ |
| 8627 | /* ======= */ |
| 8628 | |
| 8629 | /* DGEEVX computes for an N-by-N real nonsymmetric matrix A, the */ |
| 8630 | /* eigenvalues and, optionally, the left and/or right eigenvectors. */ |
| 8631 | |
| 8632 | /* Optionally also, it computes a balancing transformation to improve */ |
| 8633 | /* the conditioning of the eigenvalues and eigenvectors (ILO, IHI, */ |
| 8634 | /* SCALE, and ABNRM), reciprocal condition numbers for the eigenvalues */ |
| 8635 | /* (RCONDE), and reciprocal condition numbers for the right */ |
| 8636 | /* eigenvectors (RCONDV). */ |
| 8637 | |
| 8638 | /* The right eigenvector v(j) of A satisfies */ |
| 8639 | /* A * v(j) = lambda(j) * v(j) */ |
| 8640 | /* where lambda(j) is its eigenvalue. */ |
| 8641 | /* The left eigenvector u(j) of A satisfies */ |
| 8642 | /* u(j)**H * A = lambda(j) * u(j)**H */ |
| 8643 | /* where u(j)**H denotes the conjugate transpose of u(j). */ |
| 8644 | |
| 8645 | /* The computed eigenvectors are normalized to have Euclidean norm */ |
| 8646 | /* equal to 1 and largest component real. */ |
| 8647 | |
| 8648 | /* Balancing a matrix means permuting the rows and columns to make it */ |
| 8649 | /* more nearly upper triangular, and applying a diagonal similarity */ |
| 8650 | /* transformation D * A * D**(-1), where D is a diagonal matrix, to */ |
| 8651 | /* make its rows and columns closer in norm and the condition numbers */ |
| 8652 | /* of its eigenvalues and eigenvectors smaller. The computed */ |
| 8653 | /* reciprocal condition numbers correspond to the balanced matrix. */ |
| 8654 | /* Permuting rows and columns will not change the condition numbers */ |
| 8655 | /* (in exact arithmetic) but diagonal scaling will. For further */ |
| 8656 | /* explanation of balancing, see section 4.10.2 of the LAPACK */ |
| 8657 | /* Users' Guide. */ |
| 8658 | |
| 8659 | /* Arguments */ |
| 8660 | /* ========= */ |
| 8661 | |
| 8662 | /* BALANC (input) CHARACTER*1 */ |
| 8663 | /* Indicates how the input matrix should be diagonally scaled */ |
| 8664 | /* and/or permuted to improve the conditioning of its */ |
| 8665 | /* eigenvalues. */ |
| 8666 | /* = 'N': Do not diagonally scale or permute; */ |
| 8667 | /* = 'P': Perform permutations to make the matrix more nearly */ |
| 8668 | /* upper triangular. Do not diagonally scale; */ |
| 8669 | /* = 'S': Diagonally scale the matrix, i.e. replace A by */ |
| 8670 | /* D*A*D**(-1), where D is a diagonal matrix chosen */ |
| 8671 | /* to make the rows and columns of A more equal in */ |
| 8672 | /* norm. Do not permute; */ |
| 8673 | /* = 'B': Both diagonally scale and permute A. */ |
| 8674 | |
| 8675 | /* Computed reciprocal condition numbers will be for the matrix */ |
| 8676 | /* after balancing and/or permuting. Permuting does not change */ |
| 8677 | /* condition numbers (in exact arithmetic), but balancing does. */ |
| 8678 | |
| 8679 | /* JOBVL (input) CHARACTER*1 */ |
| 8680 | /* = 'N': left eigenvectors of A are not computed; */ |
| 8681 | /* = 'V': left eigenvectors of A are computed. */ |
| 8682 | /* If SENSE = 'E' or 'B', JOBVL must = 'V'. */ |
| 8683 | |
| 8684 | /* JOBVR (input) CHARACTER*1 */ |
| 8685 | /* = 'N': right eigenvectors of A are not computed; */ |
| 8686 | /* = 'V': right eigenvectors of A are computed. */ |
| 8687 | /* If SENSE = 'E' or 'B', JOBVR must = 'V'. */ |
| 8688 | |
| 8689 | /* SENSE (input) CHARACTER*1 */ |
| 8690 | /* Determines which reciprocal condition numbers are computed. */ |
| 8691 | /* = 'N': None are computed; */ |
| 8692 | /* = 'E': Computed for eigenvalues only; */ |
| 8693 | /* = 'V': Computed for right eigenvectors only; */ |
| 8694 | /* = 'B': Computed for eigenvalues and right eigenvectors. */ |
| 8695 | |
| 8696 | /* If SENSE = 'E' or 'B', both left and right eigenvectors */ |
| 8697 | /* must also be computed (JOBVL = 'V' and JOBVR = 'V'). */ |
| 8698 | |
| 8699 | /* N (input) INTEGER */ |
| 8700 | /* The order of the matrix A. N >= 0. */ |
| 8701 | |
| 8702 | /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 8703 | /* On entry, the N-by-N matrix A. */ |
| 8704 | /* On exit, A has been overwritten. If JOBVL = 'V' or */ |
| 8705 | /* JOBVR = 'V', A contains the real Schur form of the balanced */ |
| 8706 | /* version of the input matrix A. */ |
| 8707 | |
| 8708 | /* LDA (input) INTEGER */ |
| 8709 | /* The leading dimension of the array A. LDA >= max(1,N). */ |
| 8710 | |
| 8711 | /* WR (output) DOUBLE PRECISION array, dimension (N) */ |
| 8712 | /* WI (output) DOUBLE PRECISION array, dimension (N) */ |
| 8713 | /* WR and WI contain the real and imaginary parts, */ |
| 8714 | /* respectively, of the computed eigenvalues. Complex */ |
| 8715 | /* conjugate pairs of eigenvalues will appear consecutively */ |
| 8716 | /* with the eigenvalue having the positive imaginary part */ |
| 8717 | /* first. */ |
| 8718 | |
| 8719 | /* VL (output) DOUBLE PRECISION array, dimension (LDVL,N) */ |
| 8720 | /* If JOBVL = 'V', the left eigenvectors u(j) are stored one */ |
| 8721 | /* after another in the columns of VL, in the same order */ |
| 8722 | /* as their eigenvalues. */ |
| 8723 | /* If JOBVL = 'N', VL is not referenced. */ |
| 8724 | /* If the j-th eigenvalue is real, then u(j) = VL(:,j), */ |
| 8725 | /* the j-th column of VL. */ |
| 8726 | /* If the j-th and (j+1)-st eigenvalues form a complex */ |
| 8727 | /* conjugate pair, then u(j) = VL(:,j) + i*VL(:,j+1) and */ |
| 8728 | /* u(j+1) = VL(:,j) - i*VL(:,j+1). */ |
| 8729 | |
| 8730 | /* LDVL (input) INTEGER */ |
| 8731 | /* The leading dimension of the array VL. LDVL >= 1; if */ |
| 8732 | /* JOBVL = 'V', LDVL >= N. */ |
| 8733 | |
| 8734 | /* VR (output) DOUBLE PRECISION array, dimension (LDVR,N) */ |
| 8735 | /* If JOBVR = 'V', the right eigenvectors v(j) are stored one */ |
| 8736 | /* after another in the columns of VR, in the same order */ |
| 8737 | /* as their eigenvalues. */ |
| 8738 | /* If JOBVR = 'N', VR is not referenced. */ |
| 8739 | /* If the j-th eigenvalue is real, then v(j) = VR(:,j), */ |
| 8740 | /* the j-th column of VR. */ |
| 8741 | /* If the j-th and (j+1)-st eigenvalues form a complex */ |
| 8742 | /* conjugate pair, then v(j) = VR(:,j) + i*VR(:,j+1) and */ |
| 8743 | /* v(j+1) = VR(:,j) - i*VR(:,j+1). */ |
| 8744 | |
| 8745 | /* LDVR (input) INTEGER */ |
| 8746 | /* The leading dimension of the array VR. LDVR >= 1, and if */ |
| 8747 | /* JOBVR = 'V', LDVR >= N. */ |
| 8748 | |
| 8749 | /* ILO (output) INTEGER */ |
| 8750 | /* IHI (output) INTEGER */ |
| 8751 | /* ILO and IHI are integer values determined when A was */ |
| 8752 | /* balanced. The balanced A(i,j) = 0 if I > J and */ |
| 8753 | /* J = 1,...,ILO-1 or I = IHI+1,...,N. */ |
| 8754 | |
| 8755 | /* SCALE (output) DOUBLE PRECISION array, dimension (N) */ |
| 8756 | /* Details of the permutations and scaling factors applied */ |
| 8757 | /* when balancing A. If P(j) is the index of the row and column */ |
| 8758 | /* interchanged with row and column j, and D(j) is the scaling */ |
| 8759 | /* factor applied to row and column j, then */ |
| 8760 | /* SCALE(J) = P(J), for J = 1,...,ILO-1 */ |
| 8761 | /* = D(J), for J = ILO,...,IHI */ |
| 8762 | /* = P(J) for J = IHI+1,...,N. */ |
| 8763 | /* The order in which the interchanges are made is N to IHI+1, */ |
| 8764 | /* then 1 to ILO-1. */ |
| 8765 | |
| 8766 | /* ABNRM (output) DOUBLE PRECISION */ |
| 8767 | /* The one-norm of the balanced matrix (the maximum */ |
| 8768 | /* of the sum of absolute values of elements of any column). */ |
| 8769 | |
| 8770 | /* RCONDE (output) DOUBLE PRECISION array, dimension (N) */ |
| 8771 | /* RCONDE(j) is the reciprocal condition number of the j-th */ |
| 8772 | /* eigenvalue. */ |
| 8773 | |
| 8774 | /* RCONDV (output) DOUBLE PRECISION array, dimension (N) */ |
| 8775 | /* RCONDV(j) is the reciprocal condition number of the j-th */ |
| 8776 | /* right eigenvector. */ |
| 8777 | |
| 8778 | /* WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) */ |
| 8779 | /* On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ |
| 8780 | |
| 8781 | /* LWORK (input) INTEGER */ |
| 8782 | /* The dimension of the array WORK. If SENSE = 'N' or 'E', */ |
| 8783 | /* LWORK >= max(1,2*N), and if JOBVL = 'V' or JOBVR = 'V', */ |
| 8784 | /* LWORK >= 3*N. If SENSE = 'V' or 'B', LWORK >= N*(N+6). */ |
| 8785 | /* For good performance, LWORK must generally be larger. */ |
| 8786 | |
| 8787 | /* If LWORK = -1, then a workspace query is assumed; the routine */ |
| 8788 | /* only calculates the optimal size of the WORK array, returns */ |
| 8789 | /* this value as the first entry of the WORK array, and no error */ |
| 8790 | /* message related to LWORK is issued by XERBLA. */ |
| 8791 | |
| 8792 | /* IWORK (workspace) INTEGER array, dimension (2*N-2) */ |
| 8793 | /* If SENSE = 'N' or 'E', not referenced. */ |
| 8794 | |
| 8795 | /* INFO (output) INTEGER */ |
| 8796 | /* = 0: successful exit */ |
| 8797 | /* < 0: if INFO = -i, the i-th argument had an illegal value. */ |
| 8798 | /* > 0: if INFO = i, the QR algorithm failed to compute all the */ |
| 8799 | /* eigenvalues, and no eigenvectors or condition numbers */ |
| 8800 | /* have been computed; elements 1:ILO-1 and i+1:N of WR */ |
| 8801 | /* and WI contain eigenvalues which have converged. */ |
| 8802 | |
| 8803 | /* ===================================================================== */ |
| 8804 | |
| 8805 | /* .. Parameters .. */ |
| 8806 | /* .. */ |
| 8807 | /* .. Local Scalars .. */ |
| 8808 | /* .. */ |
| 8809 | /* .. Local Arrays .. */ |
| 8810 | /* .. */ |
| 8811 | /* .. External Subroutines .. */ |
| 8812 | /* .. */ |
| 8813 | /* .. External Functions .. */ |
| 8814 | /* .. */ |
| 8815 | /* .. Intrinsic Functions .. */ |
| 8816 | /* .. */ |
| 8817 | /* .. Executable Statements .. */ |
| 8818 | |
| 8819 | /* Test the input arguments */ |
| 8820 | |
| 8821 | /* Parameter adjustments */ |
| 8822 | a_dim1 = *lda; |
| 8823 | a_offset = 1 + a_dim1; |
| 8824 | a -= a_offset; |
| 8825 | --wr; |
| 8826 | --wi; |
| 8827 | vl_dim1 = *ldvl; |
| 8828 | vl_offset = 1 + vl_dim1; |
| 8829 | vl -= vl_offset; |
| 8830 | vr_dim1 = *ldvr; |
| 8831 | vr_offset = 1 + vr_dim1; |
| 8832 | vr -= vr_offset; |
| 8833 | --scale; |
| 8834 | --rconde; |
| 8835 | --rcondv; |
| 8836 | --work; |
| 8837 | --iwork; |
| 8838 | |
| 8839 | /* Function Body */ |
| 8840 | *info = 0; |
| 8841 | lquery = *lwork == -1; |
| 8842 | wantvl = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobvl, "V"); |
| 8843 | wantvr = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobvr, "V"); |
| 8844 | wntsnn = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(sense, "N"); |
| 8845 | wntsne = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(sense, "E"); |
| 8846 | wntsnv = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(sense, "V"); |
| 8847 | wntsnb = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(sense, "B"); |
| 8848 | if (! (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(balanc, "N") || lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(balanc, "S") || lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(balanc, "P") |
| 8849 | || lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(balanc, "B"))) { |
| 8850 | *info = -1; |
| 8851 | } else if (! wantvl && ! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobvl, "N")) { |
| 8852 | *info = -2; |
| 8853 | } else if (! wantvr && ! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobvr, "N")) { |
| 8854 | *info = -3; |
| 8855 | } else if (! (wntsnn || wntsne || wntsnb || wntsnv) || (wntsne || wntsnb) |
| 8856 | && ! (wantvl && wantvr)) { |
| 8857 | *info = -4; |
| 8858 | } else if (*n < 0) { |
| 8859 | *info = -5; |
| 8860 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 8861 | *info = -7; |
| 8862 | } else if (*ldvl < 1 || wantvl && *ldvl < *n) { |
| 8863 | *info = -11; |
| 8864 | } else if (*ldvr < 1 || wantvr && *ldvr < *n) { |
| 8865 | *info = -13; |
| 8866 | } |
| 8867 | |
| 8868 | /* Compute workspace */ |
| 8869 | /* (Note: Comments in the code beginning "Workspace:" describe the */ |
| 8870 | /* minimal amount of workspace needed at that point in the code, */ |
| 8871 | /* as well as the preferred amount for good performance. */ |
| 8872 | /* NB refers to the optimal block size for the immediately */ |
| 8873 | /* following subroutine, as returned by ILAENV. */ |
| 8874 | /* HSWORK refers to the workspace preferred by DHSEQR, as */ |
| 8875 | /* calculated below. HSWORK is computed assuming ILO=1 and IHI=N, */ |
| 8876 | /* the worst case.) */ |
| 8877 | |
| 8878 | if (*info == 0) { |
| 8879 | if (*n == 0) { |
| 8880 | minwrk = 1; |
| 8881 | maxwrk = 1; |
| 8882 | } else { |
| 8883 | maxwrk = *n + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEHRD", " ", n, &c__1, n, & |
| 8884 | c__0); |
| 8885 | |
| 8886 | if (wantvl) { |
| 8887 | dhseqr_cxx . . $ dhseqr_(658beefb48cc805a).("S", "V", n, &c__1, n, &a[a_offset], lda, &wr[1], &wi[ |
| 8888 | 1], &vl[vl_offset], ldvl, &work[1], &c_n1, info); |
| 8889 | } else if (wantvr) { |
| 8890 | dhseqr_cxx . . $ dhseqr_(658beefb48cc805a).("S", "V", n, &c__1, n, &a[a_offset], lda, &wr[1], &wi[ |
| 8891 | 1], &vr[vr_offset], ldvr, &work[1], &c_n1, info); |
| 8892 | } else { |
| 8893 | if (wntsnn) { |
| 8894 | dhseqr_cxx . . $ dhseqr_(658beefb48cc805a).("E", "N", n, &c__1, n, &a[a_offset], lda, &wr[1], |
| 8895 | &wi[1], &vr[vr_offset], ldvr, &work[1], &c_n1, |
| 8896 | info); |
| 8897 | } else { |
| 8898 | dhseqr_cxx . . $ dhseqr_(658beefb48cc805a).("S", "N", n, &c__1, n, &a[a_offset], lda, &wr[1], |
| 8899 | &wi[1], &vr[vr_offset], ldvr, &work[1], &c_n1, |
| 8900 | info); |
| 8901 | } |
| 8902 | } |
| 8903 | hswork = (integercxx . . $ integer#) work[1]; |
| 8904 | |
| 8905 | if (! wantvl && ! wantvr) { |
| 8906 | minwrk = *n << 1; |
| 8907 | if (! wntsnn) { |
| 8908 | /* Computing MAX */ |
| 8909 | i__1 = minwrk, i__2 = *n * *n + *n * 6; |
| 8910 | minwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 8911 | } |
| 8912 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(maxwrk,hswork); |
| 8913 | if (! wntsnn) { |
| 8914 | /* Computing MAX */ |
| 8915 | i__1 = maxwrk, i__2 = *n * *n + *n * 6; |
| 8916 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 8917 | } |
| 8918 | } else { |
| 8919 | minwrk = *n * 3; |
| 8920 | if (! wntsnn && ! wntsne) { |
| 8921 | /* Computing MAX */ |
| 8922 | i__1 = minwrk, i__2 = *n * *n + *n * 6; |
| 8923 | minwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 8924 | } |
| 8925 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(maxwrk,hswork); |
| 8926 | /* Computing MAX */ |
| 8927 | i__1 = maxwrk, i__2 = *n + (*n - 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORGHR", |
| 8928 | " ", n, &c__1, n, &c_n1); |
| 8929 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 8930 | if (! wntsnn && ! wntsne) { |
| 8931 | /* Computing MAX */ |
| 8932 | i__1 = maxwrk, i__2 = *n * *n + *n * 6; |
| 8933 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 8934 | } |
| 8935 | /* Computing MAX */ |
| 8936 | i__1 = maxwrk, i__2 = *n * 3; |
| 8937 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 8938 | } |
| 8939 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(maxwrk,minwrk); |
| 8940 | } |
| 8941 | work[1] = (double) maxwrk; |
| 8942 | |
| 8943 | if (*lwork < minwrk && ! lquery) { |
| 8944 | *info = -21; |
| 8945 | } |
| 8946 | } |
| 8947 | |
| 8948 | if (*info != 0) { |
| 8949 | i__1 = -(*info); |
| 8950 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGEEVX", &i__1); |
| 8951 | return 0; |
| 8952 | } else if (lquery) { |
| 8953 | return 0; |
| 8954 | } |
| 8955 | |
| 8956 | /* Quick return if possible */ |
| 8957 | |
| 8958 | if (*n == 0) { |
| 8959 | return 0; |
| 8960 | } |
| 8961 | |
| 8962 | /* Get machine constants */ |
| 8963 | |
| 8964 | eps = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("P"); |
| 8965 | smlnum = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("S"); |
| 8966 | bignum = 1. / smlnum; |
| 8967 | dlabad_cxx . . $ dlabad_(4730c933dae9b326).(&smlnum, &bignum); |
| 8968 | smlnum = sqrtcxx . . $ sqrt(fee4f1d22bc8e617).(smlnum) / eps; |
| 8969 | bignum = 1. / smlnum; |
| 8970 | |
| 8971 | /* Scale A if max element outside range [SMLNUM,BIGNUM] */ |
| 8972 | |
| 8973 | icond = 0; |
| 8974 | anrm = dlange_cxx . . $ dlange_(98d44e6417336f20).("M", n, n, &a[a_offset], lda, dum); |
| 8975 | scalea = false; |
| 8976 | if (anrm > 0. && anrm < smlnum) { |
| 8977 | scalea = true; |
| 8978 | cscale = smlnum; |
| 8979 | } else if (anrm > bignum) { |
| 8980 | scalea = true; |
| 8981 | cscale = bignum; |
| 8982 | } |
| 8983 | if (scalea) { |
| 8984 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &anrm, &cscale, n, n, &a[a_offset], lda, & |
| 8985 | ierr); |
| 8986 | } |
| 8987 | |
| 8988 | /* Balance the matrix and compute ABNRM */ |
| 8989 | |
| 8990 | dgebal_cxx . . $ dgebal_(4da4b22b53009041).(balanc, n, &a[a_offset], lda, ilo, ihi, &scale[1], &ierr); |
| 8991 | *abnrm = dlange_cxx . . $ dlange_(98d44e6417336f20).("1", n, n, &a[a_offset], lda, dum); |
| 8992 | if (scalea) { |
| 8993 | dum[0] = *abnrm; |
| 8994 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &cscale, &anrm, &c__1, &c__1, dum, &c__1, & |
| 8995 | ierr); |
| 8996 | *abnrm = dum[0]; |
| 8997 | } |
| 8998 | |
| 8999 | /* Reduce to upper Hessenberg form */ |
| 9000 | /* (Workspace: need 2*N, prefer N+N*NB) */ |
| 9001 | |
| 9002 | itau = 1; |
| 9003 | iwrk = itau + *n; |
| 9004 | i__1 = *lwork - iwrk + 1; |
| 9005 | dgehrd_cxx . . $ dgehrd_(424524679a238630).(n, ilo, ihi, &a[a_offset], lda, &work[itau], &work[iwrk], &i__1, & |
| 9006 | ierr); |
| 9007 | |
| 9008 | if (wantvl) { |
| 9009 | |
| 9010 | /* Want left eigenvectors */ |
| 9011 | /* Copy Householder vectors to VL */ |
| 9012 | |
| 9013 | *(unsigned char *)side = 'L'; |
| 9014 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("L", n, n, &a[a_offset], lda, &vl[vl_offset], ldvl) |
| 9015 | ; |
| 9016 | |
| 9017 | /* Generate orthogonal matrix in VL */ |
| 9018 | /* (Workspace: need 2*N-1, prefer N+(N-1)*NB) */ |
| 9019 | |
| 9020 | i__1 = *lwork - iwrk + 1; |
| 9021 | dorghr_cxx . . $ dorghr_(424524679a238630).(n, ilo, ihi, &vl[vl_offset], ldvl, &work[itau], &work[iwrk], & |
| 9022 | i__1, &ierr); |
| 9023 | |
| 9024 | /* Perform QR iteration, accumulating Schur vectors in VL */ |
| 9025 | /* (Workspace: need 1, prefer HSWORK (see comments) ) */ |
| 9026 | |
| 9027 | iwrk = itau; |
| 9028 | i__1 = *lwork - iwrk + 1; |
| 9029 | dhseqr_cxx . . $ dhseqr_(658beefb48cc805a).("S", "V", n, ilo, ihi, &a[a_offset], lda, &wr[1], &wi[1], &vl[ |
| 9030 | vl_offset], ldvl, &work[iwrk], &i__1, info); |
| 9031 | |
| 9032 | if (wantvr) { |
| 9033 | |
| 9034 | /* Want left and right eigenvectors */ |
| 9035 | /* Copy Schur vectors to VR */ |
| 9036 | |
| 9037 | *(unsigned char *)side = 'B'; |
| 9038 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("F", n, n, &vl[vl_offset], ldvl, &vr[vr_offset], ldvr); |
| 9039 | } |
| 9040 | |
| 9041 | } else if (wantvr) { |
| 9042 | |
| 9043 | /* Want right eigenvectors */ |
| 9044 | /* Copy Householder vectors to VR */ |
| 9045 | |
| 9046 | *(unsigned char *)side = 'R'; |
| 9047 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("L", n, n, &a[a_offset], lda, &vr[vr_offset], ldvr) |
| 9048 | ; |
| 9049 | |
| 9050 | /* Generate orthogonal matrix in VR */ |
| 9051 | /* (Workspace: need 2*N-1, prefer N+(N-1)*NB) */ |
| 9052 | |
| 9053 | i__1 = *lwork - iwrk + 1; |
| 9054 | dorghr_cxx . . $ dorghr_(424524679a238630).(n, ilo, ihi, &vr[vr_offset], ldvr, &work[itau], &work[iwrk], & |
| 9055 | i__1, &ierr); |
| 9056 | |
| 9057 | /* Perform QR iteration, accumulating Schur vectors in VR */ |
| 9058 | /* (Workspace: need 1, prefer HSWORK (see comments) ) */ |
| 9059 | |
| 9060 | iwrk = itau; |
| 9061 | i__1 = *lwork - iwrk + 1; |
| 9062 | dhseqr_cxx . . $ dhseqr_(658beefb48cc805a).("S", "V", n, ilo, ihi, &a[a_offset], lda, &wr[1], &wi[1], &vr[ |
| 9063 | vr_offset], ldvr, &work[iwrk], &i__1, info); |
| 9064 | |
| 9065 | } else { |
| 9066 | |
| 9067 | /* Compute eigenvalues only */ |
| 9068 | /* If condition numbers desired, compute Schur form */ |
| 9069 | |
| 9070 | if (wntsnn) { |
| 9071 | *(unsigned char *)job = 'E'; |
| 9072 | } else { |
| 9073 | *(unsigned char *)job = 'S'; |
| 9074 | } |
| 9075 | |
| 9076 | /* (Workspace: need 1, prefer HSWORK (see comments) ) */ |
| 9077 | |
| 9078 | iwrk = itau; |
| 9079 | i__1 = *lwork - iwrk + 1; |
| 9080 | dhseqr_cxx . . $ dhseqr_(658beefb48cc805a).(job, "N", n, ilo, ihi, &a[a_offset], lda, &wr[1], &wi[1], &vr[ |
| 9081 | vr_offset], ldvr, &work[iwrk], &i__1, info); |
| 9082 | } |
| 9083 | |
| 9084 | /* If INFO > 0 from DHSEQR, then quit */ |
| 9085 | |
| 9086 | if (*info > 0) { |
| 9087 | goto L50; |
| 9088 | } |
| 9089 | |
| 9090 | if (wantvl || wantvr) { |
| 9091 | |
| 9092 | /* Compute left and/or right eigenvectors */ |
| 9093 | /* (Workspace: need 3*N) */ |
| 9094 | |
| 9095 | dtrevc_cxx . . $ dtrevc_(7b3a76416ced2fcb).(side, "B", select, n, &a[a_offset], lda, &vl[vl_offset], ldvl, |
| 9096 | &vr[vr_offset], ldvr, n, &nout, &work[iwrk], &ierr); |
| 9097 | } |
| 9098 | |
| 9099 | /* Compute condition numbers if desired */ |
| 9100 | /* (Workspace: need N*N+6*N unless SENSE = 'E') */ |
| 9101 | |
| 9102 | if (! wntsnn) { |
| 9103 | dtrsna_cxx . . $ dtrsna_(a952c7ab3277d856).(sense, "A", select, n, &a[a_offset], lda, &vl[vl_offset], |
| 9104 | ldvl, &vr[vr_offset], ldvr, &rconde[1], &rcondv[1], n, &nout, |
| 9105 | &work[iwrk], n, &iwork[1], &icond); |
| 9106 | } |
| 9107 | |
| 9108 | if (wantvl) { |
| 9109 | |
| 9110 | /* Undo balancing of left eigenvectors */ |
| 9111 | |
| 9112 | dgebak_cxx . . $ dgebak_(51612d8f5027ec5a).(balanc, "L", n, ilo, ihi, &scale[1], n, &vl[vl_offset], ldvl, |
| 9113 | &ierr); |
| 9114 | |
| 9115 | /* Normalize left eigenvectors and make largest component real */ |
| 9116 | |
| 9117 | i__1 = *n; |
| 9118 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 9119 | if (wi[i__] == 0.) { |
| 9120 | scl = 1. / dnrm2_cxx . . $ dnrm2_(c4756756b043e0f).(n, &vl[i__ * vl_dim1 + 1], &c__1); |
| 9121 | dscal_cxx . . $ dscal_(f22c1db71784c345).(n, &scl, &vl[i__ * vl_dim1 + 1], &c__1); |
| 9122 | } else if (wi[i__] > 0.) { |
| 9123 | d__1 = dnrm2_cxx . . $ dnrm2_(c4756756b043e0f).(n, &vl[i__ * vl_dim1 + 1], &c__1); |
| 9124 | d__2 = dnrm2_cxx . . $ dnrm2_(c4756756b043e0f).(n, &vl[(i__ + 1) * vl_dim1 + 1], &c__1); |
| 9125 | scl = 1. / dlapy2_cxx . . $ dlapy2_(8fcf9002b7f393aa).(&d__1, &d__2); |
| 9126 | dscal_cxx . . $ dscal_(f22c1db71784c345).(n, &scl, &vl[i__ * vl_dim1 + 1], &c__1); |
| 9127 | dscal_cxx . . $ dscal_(f22c1db71784c345).(n, &scl, &vl[(i__ + 1) * vl_dim1 + 1], &c__1); |
| 9128 | i__2 = *n; |
| 9129 | for (k = 1; k <= i__2; ++k) { |
| 9130 | /* Computing 2nd power */ |
| 9131 | d__1 = vl[k + i__ * vl_dim1]; |
| 9132 | /* Computing 2nd power */ |
| 9133 | d__2 = vl[k + (i__ + 1) * vl_dim1]; |
| 9134 | work[k] = d__1 * d__1 + d__2 * d__2; |
| 9135 | /* L10: */ |
| 9136 | } |
| 9137 | k = idamax_cxx . . $ idamax_(a5c31fbfbc00ee45).(n, &work[1], &c__1); |
| 9138 | dlartg_cxx . . $ dlartg_(f2b979bf0498d687).(&vl[k + i__ * vl_dim1], &vl[k + (i__ + 1) * vl_dim1], |
| 9139 | &cs, &sn, &r__); |
| 9140 | drot_cxx . . $ drot_(31e32f39c16a90e0).(n, &vl[i__ * vl_dim1 + 1], &c__1, &vl[(i__ + 1) * |
| 9141 | vl_dim1 + 1], &c__1, &cs, &sn); |
| 9142 | vl[k + (i__ + 1) * vl_dim1] = 0.; |
| 9143 | } |
| 9144 | /* L20: */ |
| 9145 | } |
| 9146 | } |
| 9147 | |
| 9148 | if (wantvr) { |
| 9149 | |
| 9150 | /* Undo balancing of right eigenvectors */ |
| 9151 | |
| 9152 | dgebak_cxx . . $ dgebak_(51612d8f5027ec5a).(balanc, "R", n, ilo, ihi, &scale[1], n, &vr[vr_offset], ldvr, |
| 9153 | &ierr); |
| 9154 | |
| 9155 | /* Normalize right eigenvectors and make largest component real */ |
| 9156 | |
| 9157 | i__1 = *n; |
| 9158 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 9159 | if (wi[i__] == 0.) { |
| 9160 | scl = 1. / dnrm2_cxx . . $ dnrm2_(c4756756b043e0f).(n, &vr[i__ * vr_dim1 + 1], &c__1); |
| 9161 | dscal_cxx . . $ dscal_(f22c1db71784c345).(n, &scl, &vr[i__ * vr_dim1 + 1], &c__1); |
| 9162 | } else if (wi[i__] > 0.) { |
| 9163 | d__1 = dnrm2_cxx . . $ dnrm2_(c4756756b043e0f).(n, &vr[i__ * vr_dim1 + 1], &c__1); |
| 9164 | d__2 = dnrm2_cxx . . $ dnrm2_(c4756756b043e0f).(n, &vr[(i__ + 1) * vr_dim1 + 1], &c__1); |
| 9165 | scl = 1. / dlapy2_cxx . . $ dlapy2_(8fcf9002b7f393aa).(&d__1, &d__2); |
| 9166 | dscal_cxx . . $ dscal_(f22c1db71784c345).(n, &scl, &vr[i__ * vr_dim1 + 1], &c__1); |
| 9167 | dscal_cxx . . $ dscal_(f22c1db71784c345).(n, &scl, &vr[(i__ + 1) * vr_dim1 + 1], &c__1); |
| 9168 | i__2 = *n; |
| 9169 | for (k = 1; k <= i__2; ++k) { |
| 9170 | /* Computing 2nd power */ |
| 9171 | d__1 = vr[k + i__ * vr_dim1]; |
| 9172 | /* Computing 2nd power */ |
| 9173 | d__2 = vr[k + (i__ + 1) * vr_dim1]; |
| 9174 | work[k] = d__1 * d__1 + d__2 * d__2; |
| 9175 | /* L30: */ |
| 9176 | } |
| 9177 | k = idamax_cxx . . $ idamax_(a5c31fbfbc00ee45).(n, &work[1], &c__1); |
| 9178 | dlartg_cxx . . $ dlartg_(f2b979bf0498d687).(&vr[k + i__ * vr_dim1], &vr[k + (i__ + 1) * vr_dim1], |
| 9179 | &cs, &sn, &r__); |
| 9180 | drot_cxx . . $ drot_(31e32f39c16a90e0).(n, &vr[i__ * vr_dim1 + 1], &c__1, &vr[(i__ + 1) * |
| 9181 | vr_dim1 + 1], &c__1, &cs, &sn); |
| 9182 | vr[k + (i__ + 1) * vr_dim1] = 0.; |
| 9183 | } |
| 9184 | /* L40: */ |
| 9185 | } |
| 9186 | } |
| 9187 | |
| 9188 | /* Undo scaling if necessary */ |
| 9189 | |
| 9190 | L50: |
| 9191 | if (scalea) { |
| 9192 | i__1 = *n - *info; |
| 9193 | /* Computing MAX */ |
| 9194 | i__3 = *n - *info; |
| 9195 | i__2 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__3,1_integercxx . . $ `operator""_integer`(85240eb457c3721a).); |
| 9196 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &cscale, &anrm, &i__1, &c__1, &wr[*info + |
| 9197 | 1], &i__2, &ierr); |
| 9198 | i__1 = *n - *info; |
| 9199 | /* Computing MAX */ |
| 9200 | i__3 = *n - *info; |
| 9201 | i__2 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__3,1_integercxx . . $ `operator""_integer`(85240eb457c3721a).); |
| 9202 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &cscale, &anrm, &i__1, &c__1, &wi[*info + |
| 9203 | 1], &i__2, &ierr); |
| 9204 | if (*info == 0) { |
| 9205 | if ((wntsnv || wntsnb) && icond == 0) { |
| 9206 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &cscale, &anrm, n, &c__1, &rcondv[ |
| 9207 | 1], n, &ierr); |
| 9208 | } |
| 9209 | } else { |
| 9210 | i__1 = *ilo - 1; |
| 9211 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &cscale, &anrm, &i__1, &c__1, &wr[1], |
| 9212 | n, &ierr); |
| 9213 | i__1 = *ilo - 1; |
| 9214 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &cscale, &anrm, &i__1, &c__1, &wi[1], |
| 9215 | n, &ierr); |
| 9216 | } |
| 9217 | } |
| 9218 | |
| 9219 | work[1] = (double) maxwrk; |
| 9220 | return 0; |
| 9221 | |
| 9222 | /* End of DGEEVX */ |
| 9223 | |
| 9224 | } /* dgeevx_ */ |
| 9225 | |
| 9226 | /* Subroutine */ int dgegs_cxx . . $ dgegs_(6679849dbeb3d4b5).(const char *jobvsl, const char *jobvsr, integercxx . . $ integer# *n, |
| 9227 | double *a, integercxx . . $ integer# *lda, double *b, integercxx . . $ integer# *ldb, double * |
| 9228 | alphar, double *alphai, double *beta, double *vsl, |
| 9229 | integercxx . . $ integer# *ldvsl, double *vsr, integercxx . . $ integer# *ldvsr, double *work, |
| 9230 | integercxx . . $ integer# *lwork, integercxx . . $ integer# *info) |
| 9231 | { |
| 9232 | /* Table of constant values */ |
| 9233 | static integercxx . . $ integer# c__1 = 1; |
| 9234 | static integercxx . . $ integer# c_n1 = -1; |
| 9235 | static double c_b36 = 0.; |
| 9236 | static double c_b37 = 1.; |
| 9237 | |
| 9238 | /* System generated locals */ |
| 9239 | integercxx . . $ integer# a_dim1, a_offset, b_dim1, b_offset, vsl_dim1, vsl_offset, |
| 9240 | vsr_dim1, vsr_offset, i__1, i__2; |
| 9241 | |
| 9242 | /* Local variables */ |
| 9243 | integercxx . . $ integer# nb, nb1, nb2, nb3, ihi, ilo; |
| 9244 | double eps, anrm, bnrm; |
| 9245 | integercxx . . $ integer# itau, lopt; |
| 9246 | integercxx . . $ integer# ileft, iinfo, icols; |
| 9247 | bool ilvsl; |
| 9248 | integercxx . . $ integer# iwork; |
| 9249 | bool ilvsr; |
| 9250 | integercxx . . $ integer# irows; |
| 9251 | bool ilascl, ilbscl; |
| 9252 | double safmin; |
| 9253 | double bignum; |
| 9254 | integercxx . . $ integer# ijobvl, iright, ijobvr; |
| 9255 | double anrmto; |
| 9256 | integercxx . . $ integer# lwkmin; |
| 9257 | double bnrmto; |
| 9258 | double smlnum; |
| 9259 | integercxx . . $ integer# lwkopt; |
| 9260 | bool lquery; |
| 9261 | |
| 9262 | |
| 9263 | /* -- LAPACK driver routine (version 3.1) -- */ |
| 9264 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 9265 | /* November 2006 */ |
| 9266 | |
| 9267 | /* .. Scalar Arguments .. */ |
| 9268 | /* .. */ |
| 9269 | /* .. Array Arguments .. */ |
| 9270 | /* .. */ |
| 9271 | |
| 9272 | /* Purpose */ |
| 9273 | /* ======= */ |
| 9274 | |
| 9275 | /* This routine is deprecated and has been replaced by routine DGGES. */ |
| 9276 | |
| 9277 | /* DGEGS computes the eigenvalues, real Schur form, and, optionally, */ |
| 9278 | /* left and or/right Schur vectors of a real matrix pair (A,B). */ |
| 9279 | /* Given two square matrices A and B, the generalized real Schur */ |
| 9280 | /* factorization has the form */ |
| 9281 | |
| 9282 | /* A = Q*S*Z**T, B = Q*T*Z**T */ |
| 9283 | |
| 9284 | /* where Q and Z are orthogonal matrices, T is upper triangular, and S */ |
| 9285 | /* is an upper quasi-triangular matrix with 1-by-1 and 2-by-2 diagonal */ |
| 9286 | /* blocks, the 2-by-2 blocks corresponding to complex conjugate pairs */ |
| 9287 | /* of eigenvalues of (A,B). The columns of Q are the left Schur vectors */ |
| 9288 | /* and the columns of Z are the right Schur vectors. */ |
| 9289 | |
| 9290 | /* If only the eigenvalues of (A,B) are needed, the driver routine */ |
| 9291 | /* DGEGV should be used instead. See DGEGV for a description of the */ |
| 9292 | /* eigenvalues of the generalized nonsymmetric eigenvalue problem */ |
| 9293 | /* (GNEP). */ |
| 9294 | |
| 9295 | /* Arguments */ |
| 9296 | /* ========= */ |
| 9297 | |
| 9298 | /* JOBVSL (input) CHARACTER*1 */ |
| 9299 | /* = 'N': do not compute the left Schur vectors; */ |
| 9300 | /* = 'V': compute the left Schur vectors (returned in VSL). */ |
| 9301 | |
| 9302 | /* JOBVSR (input) CHARACTER*1 */ |
| 9303 | /* = 'N': do not compute the right Schur vectors; */ |
| 9304 | /* = 'V': compute the right Schur vectors (returned in VSR). */ |
| 9305 | |
| 9306 | /* N (input) INTEGER */ |
| 9307 | /* The order of the matrices A, B, VSL, and VSR. N >= 0. */ |
| 9308 | |
| 9309 | /* A (input/output) DOUBLE PRECISION array, dimension (LDA, N) */ |
| 9310 | /* On entry, the matrix A. */ |
| 9311 | /* On exit, the upper quasi-triangular matrix S from the */ |
| 9312 | /* generalized real Schur factorization. */ |
| 9313 | |
| 9314 | /* LDA (input) INTEGER */ |
| 9315 | /* The leading dimension of A. LDA >= max(1,N). */ |
| 9316 | |
| 9317 | /* B (input/output) DOUBLE PRECISION array, dimension (LDB, N) */ |
| 9318 | /* On entry, the matrix B. */ |
| 9319 | /* On exit, the upper triangular matrix T from the generalized */ |
| 9320 | /* real Schur factorization. */ |
| 9321 | |
| 9322 | /* LDB (input) INTEGER */ |
| 9323 | /* The leading dimension of B. LDB >= max(1,N). */ |
| 9324 | |
| 9325 | /* ALPHAR (output) DOUBLE PRECISION array, dimension (N) */ |
| 9326 | /* The real parts of each scalar alpha defining an eigenvalue */ |
| 9327 | /* of GNEP. */ |
| 9328 | |
| 9329 | /* ALPHAI (output) DOUBLE PRECISION array, dimension (N) */ |
| 9330 | /* The imaginary parts of each scalar alpha defining an */ |
| 9331 | /* eigenvalue of GNEP. If ALPHAI(j) is zero, then the j-th */ |
| 9332 | /* eigenvalue is real; if positive, then the j-th and (j+1)-st */ |
| 9333 | /* eigenvalues are a complex conjugate pair, with */ |
| 9334 | /* ALPHAI(j+1) = -ALPHAI(j). */ |
| 9335 | |
| 9336 | /* BETA (output) DOUBLE PRECISION array, dimension (N) */ |
| 9337 | /* The scalars beta that define the eigenvalues of GNEP. */ |
| 9338 | /* Together, the quantities alpha = (ALPHAR(j),ALPHAI(j)) and */ |
| 9339 | /* beta = BETA(j) represent the j-th eigenvalue of the matrix */ |
| 9340 | /* pair (A,B), in one of the forms lambda = alpha/beta or */ |
| 9341 | /* mu = beta/alpha. Since either lambda or mu may overflow, */ |
| 9342 | /* they should not, in general, be computed. */ |
| 9343 | |
| 9344 | /* VSL (output) DOUBLE PRECISION array, dimension (LDVSL,N) */ |
| 9345 | /* If JOBVSL = 'V', the matrix of left Schur vectors Q. */ |
| 9346 | /* Not referenced if JOBVSL = 'N'. */ |
| 9347 | |
| 9348 | /* LDVSL (input) INTEGER */ |
| 9349 | /* The leading dimension of the matrix VSL. LDVSL >=1, and */ |
| 9350 | /* if JOBVSL = 'V', LDVSL >= N. */ |
| 9351 | |
| 9352 | /* VSR (output) DOUBLE PRECISION array, dimension (LDVSR,N) */ |
| 9353 | /* If JOBVSR = 'V', the matrix of right Schur vectors Z. */ |
| 9354 | /* Not referenced if JOBVSR = 'N'. */ |
| 9355 | |
| 9356 | /* LDVSR (input) INTEGER */ |
| 9357 | /* The leading dimension of the matrix VSR. LDVSR >= 1, and */ |
| 9358 | /* if JOBVSR = 'V', LDVSR >= N. */ |
| 9359 | |
| 9360 | /* WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) */ |
| 9361 | /* On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ |
| 9362 | |
| 9363 | /* LWORK (input) INTEGER */ |
| 9364 | /* The dimension of the array WORK. LWORK >= max(1,4*N). */ |
| 9365 | /* For good performance, LWORK must generally be larger. */ |
| 9366 | /* To compute the optimal value of LWORK, call ILAENV to get */ |
| 9367 | /* blocksizes (for DGEQRF, DORMQR, and DORGQR.) Then compute: */ |
| 9368 | /* NB -- MAX of the blocksizes for DGEQRF, DORMQR, and DORGQR */ |
| 9369 | /* The optimal LWORK is 2*N + N*(NB+1). */ |
| 9370 | |
| 9371 | /* If LWORK = -1, then a workspace query is assumed; the routine */ |
| 9372 | /* only calculates the optimal size of the WORK array, returns */ |
| 9373 | /* this value as the first entry of the WORK array, and no error */ |
| 9374 | /* message related to LWORK is issued by XERBLA. */ |
| 9375 | |
| 9376 | /* INFO (output) INTEGER */ |
| 9377 | /* = 0: successful exit */ |
| 9378 | /* < 0: if INFO = -i, the i-th argument had an illegal value. */ |
| 9379 | /* = 1,...,N: */ |
| 9380 | /* The QZ iteration failed. (A,B) are not in Schur */ |
| 9381 | /* form, but ALPHAR(j), ALPHAI(j), and BETA(j) should */ |
| 9382 | /* be correct for j=INFO+1,...,N. */ |
| 9383 | /* > N: errors that usually indicate LAPACK problems: */ |
| 9384 | /* =N+1: error return from DGGBAL */ |
| 9385 | /* =N+2: error return from DGEQRF */ |
| 9386 | /* =N+3: error return from DORMQR */ |
| 9387 | /* =N+4: error return from DORGQR */ |
| 9388 | /* =N+5: error return from DGGHRD */ |
| 9389 | /* =N+6: error return from DHGEQZ (other than failed */ |
| 9390 | /* iteration) */ |
| 9391 | /* =N+7: error return from DGGBAK (computing VSL) */ |
| 9392 | /* =N+8: error return from DGGBAK (computing VSR) */ |
| 9393 | /* =N+9: error return from DLASCL (various places) */ |
| 9394 | |
| 9395 | /* ===================================================================== */ |
| 9396 | |
| 9397 | /* .. Parameters .. */ |
| 9398 | /* .. */ |
| 9399 | /* .. Local Scalars .. */ |
| 9400 | /* .. */ |
| 9401 | /* .. External Subroutines .. */ |
| 9402 | /* .. */ |
| 9403 | /* .. External Functions .. */ |
| 9404 | /* .. */ |
| 9405 | /* .. Intrinsic Functions .. */ |
| 9406 | /* .. */ |
| 9407 | /* .. Executable Statements .. */ |
| 9408 | |
| 9409 | /* Decode the input arguments */ |
| 9410 | |
| 9411 | /* Parameter adjustments */ |
| 9412 | a_dim1 = *lda; |
| 9413 | a_offset = 1 + a_dim1; |
| 9414 | a -= a_offset; |
| 9415 | b_dim1 = *ldb; |
| 9416 | b_offset = 1 + b_dim1; |
| 9417 | b -= b_offset; |
| 9418 | --alphar; |
| 9419 | --alphai; |
| 9420 | --beta; |
| 9421 | vsl_dim1 = *ldvsl; |
| 9422 | vsl_offset = 1 + vsl_dim1; |
| 9423 | vsl -= vsl_offset; |
| 9424 | vsr_dim1 = *ldvsr; |
| 9425 | vsr_offset = 1 + vsr_dim1; |
| 9426 | vsr -= vsr_offset; |
| 9427 | --work; |
| 9428 | |
| 9429 | /* Function Body */ |
| 9430 | if (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobvsl, "N")) { |
| 9431 | ijobvl = 1; |
| 9432 | ilvsl = false; |
| 9433 | } else if (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobvsl, "V")) { |
| 9434 | ijobvl = 2; |
| 9435 | ilvsl = true; |
| 9436 | } else { |
| 9437 | ijobvl = -1; |
| 9438 | ilvsl = false; |
| 9439 | } |
| 9440 | |
| 9441 | if (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobvsr, "N")) { |
| 9442 | ijobvr = 1; |
| 9443 | ilvsr = false; |
| 9444 | } else if (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobvsr, "V")) { |
| 9445 | ijobvr = 2; |
| 9446 | ilvsr = true; |
| 9447 | } else { |
| 9448 | ijobvr = -1; |
| 9449 | ilvsr = false; |
| 9450 | } |
| 9451 | |
| 9452 | /* Test the input arguments */ |
| 9453 | |
| 9454 | /* Computing MAX */ |
| 9455 | i__1 = *n << 2; |
| 9456 | lwkmin = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,1_integercxx . . $ `operator""_integer`(85240eb457c3721a).); |
| 9457 | lwkopt = lwkmin; |
| 9458 | work[1] = (double) lwkopt; |
| 9459 | lquery = *lwork == -1; |
| 9460 | *info = 0; |
| 9461 | if (ijobvl <= 0) { |
| 9462 | *info = -1; |
| 9463 | } else if (ijobvr <= 0) { |
| 9464 | *info = -2; |
| 9465 | } else if (*n < 0) { |
| 9466 | *info = -3; |
| 9467 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 9468 | *info = -5; |
| 9469 | } else if (*ldb < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 9470 | *info = -7; |
| 9471 | } else if (*ldvsl < 1 || ilvsl && *ldvsl < *n) { |
| 9472 | *info = -12; |
| 9473 | } else if (*ldvsr < 1 || ilvsr && *ldvsr < *n) { |
| 9474 | *info = -14; |
| 9475 | } else if (*lwork < lwkmin && ! lquery) { |
| 9476 | *info = -16; |
| 9477 | } |
| 9478 | |
| 9479 | if (*info == 0) { |
| 9480 | nb1 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEQRF", " ", n, n, &c_n1, &c_n1); |
| 9481 | nb2 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMQR", " ", n, n, n, &c_n1); |
| 9482 | nb3 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORGQR", " ", n, n, n, &c_n1); |
| 9483 | /* Computing MAX */ |
| 9484 | i__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(nb1,nb2); |
| 9485 | nb = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,nb3); |
| 9486 | lopt = (*n << 1) + *n * (nb + 1); |
| 9487 | work[1] = (double) lopt; |
| 9488 | } |
| 9489 | |
| 9490 | if (*info != 0) { |
| 9491 | i__1 = -(*info); |
| 9492 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGEGS ", &i__1); |
| 9493 | return 0; |
| 9494 | } else if (lquery) { |
| 9495 | return 0; |
| 9496 | } |
| 9497 | |
| 9498 | /* Quick return if possible */ |
| 9499 | |
| 9500 | if (*n == 0) { |
| 9501 | return 0; |
| 9502 | } |
| 9503 | |
| 9504 | /* Get machine constants */ |
| 9505 | |
| 9506 | eps = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("E") * dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("B"); |
| 9507 | safmin = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("S"); |
| 9508 | smlnum = *n * safmin / eps; |
| 9509 | bignum = 1. / smlnum; |
| 9510 | |
| 9511 | /* Scale A if max element outside range [SMLNUM,BIGNUM] */ |
| 9512 | |
| 9513 | anrm = dlange_cxx . . $ dlange_(98d44e6417336f20).("M", n, n, &a[a_offset], lda, &work[1]); |
| 9514 | ilascl = false; |
| 9515 | if (anrm > 0. && anrm < smlnum) { |
| 9516 | anrmto = smlnum; |
| 9517 | ilascl = true; |
| 9518 | } else if (anrm > bignum) { |
| 9519 | anrmto = bignum; |
| 9520 | ilascl = true; |
| 9521 | } |
| 9522 | |
| 9523 | if (ilascl) { |
| 9524 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c_n1, &c_n1, &anrm, &anrmto, n, n, &a[a_offset], lda, & |
| 9525 | iinfo); |
| 9526 | if (iinfo != 0) { |
| 9527 | *info = *n + 9; |
| 9528 | return 0; |
| 9529 | } |
| 9530 | } |
| 9531 | |
| 9532 | /* Scale B if max element outside range [SMLNUM,BIGNUM] */ |
| 9533 | |
| 9534 | bnrm = dlange_cxx . . $ dlange_(98d44e6417336f20).("M", n, n, &b[b_offset], ldb, &work[1]); |
| 9535 | ilbscl = false; |
| 9536 | if (bnrm > 0. && bnrm < smlnum) { |
| 9537 | bnrmto = smlnum; |
| 9538 | ilbscl = true; |
| 9539 | } else if (bnrm > bignum) { |
| 9540 | bnrmto = bignum; |
| 9541 | ilbscl = true; |
| 9542 | } |
| 9543 | |
| 9544 | if (ilbscl) { |
| 9545 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c_n1, &c_n1, &bnrm, &bnrmto, n, n, &b[b_offset], ldb, & |
| 9546 | iinfo); |
| 9547 | if (iinfo != 0) { |
| 9548 | *info = *n + 9; |
| 9549 | return 0; |
| 9550 | } |
| 9551 | } |
| 9552 | |
| 9553 | /* Permute the matrix to make it more nearly triangular */ |
| 9554 | /* Workspace layout: (2*N words -- "work..." not actually used) */ |
| 9555 | /* left_permutation, right_permutation, work... */ |
| 9556 | |
| 9557 | ileft = 1; |
| 9558 | iright = *n + 1; |
| 9559 | iwork = iright + *n; |
| 9560 | dggbal_cxx . . $ dggbal_(69bfde64ff0f2aeb).("P", n, &a[a_offset], lda, &b[b_offset], ldb, &ilo, &ihi, &work[ |
| 9561 | ileft], &work[iright], &work[iwork], &iinfo); |
| 9562 | if (iinfo != 0) { |
| 9563 | *info = *n + 1; |
| 9564 | goto L10; |
| 9565 | } |
| 9566 | |
| 9567 | /* Reduce B to triangular form, and initialize VSL and/or VSR */ |
| 9568 | /* Workspace layout: ("work..." must have at least N words) */ |
| 9569 | /* left_permutation, right_permutation, tau, work... */ |
| 9570 | |
| 9571 | irows = ihi + 1 - ilo; |
| 9572 | icols = *n + 1 - ilo; |
| 9573 | itau = iwork; |
| 9574 | iwork = itau + irows; |
| 9575 | i__1 = *lwork + 1 - iwork; |
| 9576 | dgeqrf_cxx . . $ dgeqrf_(b2aaa174babf002e).(&irows, &icols, &b[ilo + ilo * b_dim1], ldb, &work[itau], &work[ |
| 9577 | iwork], &i__1, &iinfo); |
| 9578 | if (iinfo >= 0) { |
| 9579 | /* Computing MAX */ |
| 9580 | i__1 = lwkopt, i__2 = (integercxx . . $ integer#) work[iwork] + iwork - 1; |
| 9581 | lwkopt = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 9582 | } |
| 9583 | if (iinfo != 0) { |
| 9584 | *info = *n + 2; |
| 9585 | goto L10; |
| 9586 | } |
| 9587 | |
| 9588 | i__1 = *lwork + 1 - iwork; |
| 9589 | dormqr_cxx . . $ dormqr_(c6b7238dd97e9cf9).("L", "T", &irows, &icols, &irows, &b[ilo + ilo * b_dim1], ldb, & |
| 9590 | work[itau], &a[ilo + ilo * a_dim1], lda, &work[iwork], &i__1, & |
| 9591 | iinfo); |
| 9592 | if (iinfo >= 0) { |
| 9593 | /* Computing MAX */ |
| 9594 | i__1 = lwkopt, i__2 = (integercxx . . $ integer#) work[iwork] + iwork - 1; |
| 9595 | lwkopt = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 9596 | } |
| 9597 | if (iinfo != 0) { |
| 9598 | *info = *n + 3; |
| 9599 | goto L10; |
| 9600 | } |
| 9601 | |
| 9602 | if (ilvsl) { |
| 9603 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("Full", n, n, &c_b36, &c_b37, &vsl[vsl_offset], ldvsl); |
| 9604 | i__1 = irows - 1; |
| 9605 | i__2 = irows - 1; |
| 9606 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("L", &i__1, &i__2, &b[ilo + 1 + ilo * b_dim1], ldb, &vsl[ilo |
| 9607 | + 1 + ilo * vsl_dim1], ldvsl); |
| 9608 | i__1 = *lwork + 1 - iwork; |
| 9609 | dorgqr_cxx . . $ dorgqr_(424524679a238630).(&irows, &irows, &irows, &vsl[ilo + ilo * vsl_dim1], ldvsl, & |
| 9610 | work[itau], &work[iwork], &i__1, &iinfo); |
| 9611 | if (iinfo >= 0) { |
| 9612 | /* Computing MAX */ |
| 9613 | i__1 = lwkopt, i__2 = (integercxx . . $ integer#) work[iwork] + iwork - 1; |
| 9614 | lwkopt = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 9615 | } |
| 9616 | if (iinfo != 0) { |
| 9617 | *info = *n + 4; |
| 9618 | goto L10; |
| 9619 | } |
| 9620 | } |
| 9621 | |
| 9622 | if (ilvsr) { |
| 9623 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("Full", n, n, &c_b36, &c_b37, &vsr[vsr_offset], ldvsr); |
| 9624 | } |
| 9625 | |
| 9626 | /* Reduce to generalized Hessenberg form */ |
| 9627 | |
| 9628 | dgghrd_cxx . . $ dgghrd_(a37938716ecaec33).(jobvsl, jobvsr, n, &ilo, &ihi, &a[a_offset], lda, &b[b_offset], |
| 9629 | ldb, &vsl[vsl_offset], ldvsl, &vsr[vsr_offset], ldvsr, &iinfo); |
| 9630 | if (iinfo != 0) { |
| 9631 | *info = *n + 5; |
| 9632 | goto L10; |
| 9633 | } |
| 9634 | |
| 9635 | /* Perform QZ algorithm, computing Schur vectors if desired */ |
| 9636 | /* Workspace layout: ("work..." must have at least 1 word) */ |
| 9637 | /* left_permutation, right_permutation, work... */ |
| 9638 | |
| 9639 | iwork = itau; |
| 9640 | i__1 = *lwork + 1 - iwork; |
| 9641 | dhgeqz_cxx . . $ dhgeqz_(1c7cf0ed1736d01d).("S", jobvsl, jobvsr, n, &ilo, &ihi, &a[a_offset], lda, &b[ |
| 9642 | b_offset], ldb, &alphar[1], &alphai[1], &beta[1], &vsl[vsl_offset] |
| 9643 | , ldvsl, &vsr[vsr_offset], ldvsr, &work[iwork], &i__1, &iinfo); |
| 9644 | if (iinfo >= 0) { |
| 9645 | /* Computing MAX */ |
| 9646 | i__1 = lwkopt, i__2 = (integercxx . . $ integer#) work[iwork] + iwork - 1; |
| 9647 | lwkopt = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 9648 | } |
| 9649 | if (iinfo != 0) { |
| 9650 | if (iinfo > 0 && iinfo <= *n) { |
| 9651 | *info = iinfo; |
| 9652 | } else if (iinfo > *n && iinfo <= *n << 1) { |
| 9653 | *info = iinfo - *n; |
| 9654 | } else { |
| 9655 | *info = *n + 6; |
| 9656 | } |
| 9657 | goto L10; |
| 9658 | } |
| 9659 | |
| 9660 | /* Apply permutation to VSL and VSR */ |
| 9661 | |
| 9662 | if (ilvsl) { |
| 9663 | dggbak_cxx . . $ dggbak_(3fb2e360e620705c).("P", "L", n, &ilo, &ihi, &work[ileft], &work[iright], n, &vsl[ |
| 9664 | vsl_offset], ldvsl, &iinfo); |
| 9665 | if (iinfo != 0) { |
| 9666 | *info = *n + 7; |
| 9667 | goto L10; |
| 9668 | } |
| 9669 | } |
| 9670 | if (ilvsr) { |
| 9671 | dggbak_cxx . . $ dggbak_(3fb2e360e620705c).("P", "R", n, &ilo, &ihi, &work[ileft], &work[iright], n, &vsr[ |
| 9672 | vsr_offset], ldvsr, &iinfo); |
| 9673 | if (iinfo != 0) { |
| 9674 | *info = *n + 8; |
| 9675 | goto L10; |
| 9676 | } |
| 9677 | } |
| 9678 | |
| 9679 | /* Undo scaling */ |
| 9680 | |
| 9681 | if (ilascl) { |
| 9682 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("H", &c_n1, &c_n1, &anrmto, &anrm, n, n, &a[a_offset], lda, & |
| 9683 | iinfo); |
| 9684 | if (iinfo != 0) { |
| 9685 | *info = *n + 9; |
| 9686 | return 0; |
| 9687 | } |
| 9688 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c_n1, &c_n1, &anrmto, &anrm, n, &c__1, &alphar[1], n, & |
| 9689 | iinfo); |
| 9690 | if (iinfo != 0) { |
| 9691 | *info = *n + 9; |
| 9692 | return 0; |
| 9693 | } |
| 9694 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c_n1, &c_n1, &anrmto, &anrm, n, &c__1, &alphai[1], n, & |
| 9695 | iinfo); |
| 9696 | if (iinfo != 0) { |
| 9697 | *info = *n + 9; |
| 9698 | return 0; |
| 9699 | } |
| 9700 | } |
| 9701 | |
| 9702 | if (ilbscl) { |
| 9703 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("U", &c_n1, &c_n1, &bnrmto, &bnrm, n, n, &b[b_offset], ldb, & |
| 9704 | iinfo); |
| 9705 | if (iinfo != 0) { |
| 9706 | *info = *n + 9; |
| 9707 | return 0; |
| 9708 | } |
| 9709 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c_n1, &c_n1, &bnrmto, &bnrm, n, &c__1, &beta[1], n, & |
| 9710 | iinfo); |
| 9711 | if (iinfo != 0) { |
| 9712 | *info = *n + 9; |
| 9713 | return 0; |
| 9714 | } |
| 9715 | } |
| 9716 | |
| 9717 | L10: |
| 9718 | work[1] = (double) lwkopt; |
| 9719 | |
| 9720 | return 0; |
| 9721 | |
| 9722 | /* End of DGEGS */ |
| 9723 | |
| 9724 | } /* dgegs_ */ |
| 9725 | |
| 9726 | /* Subroutine */ int dgegv_cxx . . $ dgegv_(6679849dbeb3d4b5).(const char *jobvl, const char *jobvr, integercxx . . $ integer# *n, double * |
| 9727 | a, integercxx . . $ integer# *lda, double *b, integercxx . . $ integer# *ldb, double *alphar, |
| 9728 | double *alphai, double *beta, double *vl, integercxx . . $ integer# *ldvl, |
| 9729 | double *vr, integercxx . . $ integer# *ldvr, double *work, integercxx . . $ integer# *lwork, |
| 9730 | integercxx . . $ integer# *info) |
| 9731 | { |
| 9732 | /* Table of constant values */ |
| 9733 | static integercxx . . $ integer# c__1 = 1; |
| 9734 | static integercxx . . $ integer# c_n1 = -1; |
| 9735 | static double c_b27 = 1.; |
| 9736 | static double c_b38 = 0.; |
| 9737 | |
| 9738 | /* System generated locals */ |
| 9739 | integercxx . . $ integer# a_dim1, a_offset, b_dim1, b_offset, vl_dim1, vl_offset, vr_dim1, |
| 9740 | vr_offset, i__1, i__2; |
| 9741 | double d__1, d__2, d__3, d__4; |
| 9742 | |
| 9743 | /* Local variables */ |
| 9744 | integercxx . . $ integer# jc, nb, in, jr, nb1, nb2, nb3, ihi, ilo; |
| 9745 | double eps; |
| 9746 | bool ilv; |
| 9747 | double absb, anrm, bnrm; |
| 9748 | integercxx . . $ integer# itau; |
| 9749 | double temp; |
| 9750 | bool ilvl, ilvr; |
| 9751 | integercxx . . $ integer# lopt; |
| 9752 | double anrm1, anrm2, bnrm1, bnrm2, absai, scale, absar, sbeta; |
| 9753 | integercxx . . $ integer# ileft, iinfo, icols, iwork, irows; |
| 9754 | double salfai; |
| 9755 | double salfar; |
| 9756 | double safmin; |
| 9757 | double safmax; |
| 9758 | char chtemp[1]; |
| 9759 | bool ldumma[1]; |
| 9760 | integercxx . . $ integer# ijobvl, iright; |
| 9761 | bool ilimit; |
| 9762 | integercxx . . $ integer# ijobvr; |
| 9763 | double onepls; |
| 9764 | integercxx . . $ integer# lwkmin; |
| 9765 | integercxx . . $ integer# lwkopt; |
| 9766 | bool lquery; |
| 9767 | |
| 9768 | |
| 9769 | /* -- LAPACK driver routine (version 3.1) -- */ |
| 9770 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 9771 | /* November 2006 */ |
| 9772 | |
| 9773 | /* .. Scalar Arguments .. */ |
| 9774 | /* .. */ |
| 9775 | /* .. Array Arguments .. */ |
| 9776 | /* .. */ |
| 9777 | |
| 9778 | /* Purpose */ |
| 9779 | /* ======= */ |
| 9780 | |
| 9781 | /* This routine is deprecated and has been replaced by routine DGGEV. */ |
| 9782 | |
| 9783 | /* DGEGV computes the eigenvalues and, optionally, the left and/or right */ |
| 9784 | /* eigenvectors of a real matrix pair (A,B). */ |
| 9785 | /* Given two square matrices A and B, */ |
| 9786 | /* the generalized nonsymmetric eigenvalue problem (GNEP) is to find the */ |
| 9787 | /* eigenvalues lambda and corresponding (non-zero) eigenvectors x such */ |
| 9788 | /* that */ |
| 9789 | |
| 9790 | /* A*x = lambda*B*x. */ |
| 9791 | |
| 9792 | /* An alternate form is to find the eigenvalues mu and corresponding */ |
| 9793 | /* eigenvectors y such that */ |
| 9794 | |
| 9795 | /* mu*A*y = B*y. */ |
| 9796 | |
| 9797 | /* These two forms are equivalent with mu = 1/lambda and x = y if */ |
| 9798 | /* neither lambda nor mu is zero. In order to deal with the case that */ |
| 9799 | /* lambda or mu is zero or small, two values alpha and beta are returned */ |
| 9800 | /* for each eigenvalue, such that lambda = alpha/beta and */ |
| 9801 | /* mu = beta/alpha. */ |
| 9802 | |
| 9803 | /* The vectors x and y in the above equations are right eigenvectors of */ |
| 9804 | /* the matrix pair (A,B). Vectors u and v satisfying */ |
| 9805 | |
| 9806 | /* u**H*A = lambda*u**H*B or mu*v**H*A = v**H*B */ |
| 9807 | |
| 9808 | /* are left eigenvectors of (A,B). */ |
| 9809 | |
| 9810 | /* Note: this routine performs "full balancing" on A and B -- see */ |
| 9811 | /* "Further Details", below. */ |
| 9812 | |
| 9813 | /* Arguments */ |
| 9814 | /* ========= */ |
| 9815 | |
| 9816 | /* JOBVL (input) CHARACTER*1 */ |
| 9817 | /* = 'N': do not compute the left generalized eigenvectors; */ |
| 9818 | /* = 'V': compute the left generalized eigenvectors (returned */ |
| 9819 | /* in VL). */ |
| 9820 | |
| 9821 | /* JOBVR (input) CHARACTER*1 */ |
| 9822 | /* = 'N': do not compute the right generalized eigenvectors; */ |
| 9823 | /* = 'V': compute the right generalized eigenvectors (returned */ |
| 9824 | /* in VR). */ |
| 9825 | |
| 9826 | /* N (input) INTEGER */ |
| 9827 | /* The order of the matrices A, B, VL, and VR. N >= 0. */ |
| 9828 | |
| 9829 | /* A (input/output) DOUBLE PRECISION array, dimension (LDA, N) */ |
| 9830 | /* On entry, the matrix A. */ |
| 9831 | /* If JOBVL = 'V' or JOBVR = 'V', then on exit A */ |
| 9832 | /* contains the real Schur form of A from the generalized Schur */ |
| 9833 | /* factorization of the pair (A,B) after balancing. */ |
| 9834 | /* If no eigenvectors were computed, then only the diagonal */ |
| 9835 | /* blocks from the Schur form will be correct. See DGGHRD and */ |
| 9836 | /* DHGEQZ for details. */ |
| 9837 | |
| 9838 | /* LDA (input) INTEGER */ |
| 9839 | /* The leading dimension of A. LDA >= max(1,N). */ |
| 9840 | |
| 9841 | /* B (input/output) DOUBLE PRECISION array, dimension (LDB, N) */ |
| 9842 | /* On entry, the matrix B. */ |
| 9843 | /* If JOBVL = 'V' or JOBVR = 'V', then on exit B contains the */ |
| 9844 | /* upper triangular matrix obtained from B in the generalized */ |
| 9845 | /* Schur factorization of the pair (A,B) after balancing. */ |
| 9846 | /* If no eigenvectors were computed, then only those elements of */ |
| 9847 | /* B corresponding to the diagonal blocks from the Schur form of */ |
| 9848 | /* A will be correct. See DGGHRD and DHGEQZ for details. */ |
| 9849 | |
| 9850 | /* LDB (input) INTEGER */ |
| 9851 | /* The leading dimension of B. LDB >= max(1,N). */ |
| 9852 | |
| 9853 | /* ALPHAR (output) DOUBLE PRECISION array, dimension (N) */ |
| 9854 | /* The real parts of each scalar alpha defining an eigenvalue of */ |
| 9855 | /* GNEP. */ |
| 9856 | |
| 9857 | /* ALPHAI (output) DOUBLE PRECISION array, dimension (N) */ |
| 9858 | /* The imaginary parts of each scalar alpha defining an */ |
| 9859 | /* eigenvalue of GNEP. If ALPHAI(j) is zero, then the j-th */ |
| 9860 | /* eigenvalue is real; if positive, then the j-th and */ |
| 9861 | /* (j+1)-st eigenvalues are a complex conjugate pair, with */ |
| 9862 | /* ALPHAI(j+1) = -ALPHAI(j). */ |
| 9863 | |
| 9864 | /* BETA (output) DOUBLE PRECISION array, dimension (N) */ |
| 9865 | /* The scalars beta that define the eigenvalues of GNEP. */ |
| 9866 | |
| 9867 | /* Together, the quantities alpha = (ALPHAR(j),ALPHAI(j)) and */ |
| 9868 | /* beta = BETA(j) represent the j-th eigenvalue of the matrix */ |
| 9869 | /* pair (A,B), in one of the forms lambda = alpha/beta or */ |
| 9870 | /* mu = beta/alpha. Since either lambda or mu may overflow, */ |
| 9871 | /* they should not, in general, be computed. */ |
| 9872 | |
| 9873 | /* VL (output) DOUBLE PRECISION array, dimension (LDVL,N) */ |
| 9874 | /* If JOBVL = 'V', the left eigenvectors u(j) are stored */ |
| 9875 | /* in the columns of VL, in the same order as their eigenvalues. */ |
| 9876 | /* If the j-th eigenvalue is real, then u(j) = VL(:,j). */ |
| 9877 | /* If the j-th and (j+1)-st eigenvalues form a complex conjugate */ |
| 9878 | /* pair, then */ |
| 9879 | /* u(j) = VL(:,j) + i*VL(:,j+1) */ |
| 9880 | /* and */ |
| 9881 | /* u(j+1) = VL(:,j) - i*VL(:,j+1). */ |
| 9882 | |
| 9883 | /* Each eigenvector is scaled so that its largest component has */ |
| 9884 | /* abs(real part) + abs(imag. part) = 1, except for eigenvectors */ |
| 9885 | /* corresponding to an eigenvalue with alpha = beta = 0, which */ |
| 9886 | /* are set to zero. */ |
| 9887 | /* Not referenced if JOBVL = 'N'. */ |
| 9888 | |
| 9889 | /* LDVL (input) INTEGER */ |
| 9890 | /* The leading dimension of the matrix VL. LDVL >= 1, and */ |
| 9891 | /* if JOBVL = 'V', LDVL >= N. */ |
| 9892 | |
| 9893 | /* VR (output) DOUBLE PRECISION array, dimension (LDVR,N) */ |
| 9894 | /* If JOBVR = 'V', the right eigenvectors x(j) are stored */ |
| 9895 | /* in the columns of VR, in the same order as their eigenvalues. */ |
| 9896 | /* If the j-th eigenvalue is real, then x(j) = VR(:,j). */ |
| 9897 | /* If the j-th and (j+1)-st eigenvalues form a complex conjugate */ |
| 9898 | /* pair, then */ |
| 9899 | /* x(j) = VR(:,j) + i*VR(:,j+1) */ |
| 9900 | /* and */ |
| 9901 | /* x(j+1) = VR(:,j) - i*VR(:,j+1). */ |
| 9902 | |
| 9903 | /* Each eigenvector is scaled so that its largest component has */ |
| 9904 | /* abs(real part) + abs(imag. part) = 1, except for eigenvalues */ |
| 9905 | /* corresponding to an eigenvalue with alpha = beta = 0, which */ |
| 9906 | /* are set to zero. */ |
| 9907 | /* Not referenced if JOBVR = 'N'. */ |
| 9908 | |
| 9909 | /* LDVR (input) INTEGER */ |
| 9910 | /* The leading dimension of the matrix VR. LDVR >= 1, and */ |
| 9911 | /* if JOBVR = 'V', LDVR >= N. */ |
| 9912 | |
| 9913 | /* WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) */ |
| 9914 | /* On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ |
| 9915 | |
| 9916 | /* LWORK (input) INTEGER */ |
| 9917 | /* The dimension of the array WORK. LWORK >= max(1,8*N). */ |
| 9918 | /* For good performance, LWORK must generally be larger. */ |
| 9919 | /* To compute the optimal value of LWORK, call ILAENV to get */ |
| 9920 | /* blocksizes (for DGEQRF, DORMQR, and DORGQR.) Then compute: */ |
| 9921 | /* NB -- MAX of the blocksizes for DGEQRF, DORMQR, and DORGQR; */ |
| 9922 | /* The optimal LWORK is: */ |
| 9923 | /* 2*N + MAX( 6*N, N*(NB+1) ). */ |
| 9924 | |
| 9925 | /* If LWORK = -1, then a workspace query is assumed; the routine */ |
| 9926 | /* only calculates the optimal size of the WORK array, returns */ |
| 9927 | /* this value as the first entry of the WORK array, and no error */ |
| 9928 | /* message related to LWORK is issued by XERBLA. */ |
| 9929 | |
| 9930 | /* INFO (output) INTEGER */ |
| 9931 | /* = 0: successful exit */ |
| 9932 | /* < 0: if INFO = -i, the i-th argument had an illegal value. */ |
| 9933 | /* = 1,...,N: */ |
| 9934 | /* The QZ iteration failed. No eigenvectors have been */ |
| 9935 | /* calculated, but ALPHAR(j), ALPHAI(j), and BETA(j) */ |
| 9936 | /* should be correct for j=INFO+1,...,N. */ |
| 9937 | /* > N: errors that usually indicate LAPACK problems: */ |
| 9938 | /* =N+1: error return from DGGBAL */ |
| 9939 | /* =N+2: error return from DGEQRF */ |
| 9940 | /* =N+3: error return from DORMQR */ |
| 9941 | /* =N+4: error return from DORGQR */ |
| 9942 | /* =N+5: error return from DGGHRD */ |
| 9943 | /* =N+6: error return from DHGEQZ (other than failed */ |
| 9944 | /* iteration) */ |
| 9945 | /* =N+7: error return from DTGEVC */ |
| 9946 | /* =N+8: error return from DGGBAK (computing VL) */ |
| 9947 | /* =N+9: error return from DGGBAK (computing VR) */ |
| 9948 | /* =N+10: error return from DLASCL (various calls) */ |
| 9949 | |
| 9950 | /* Further Details */ |
| 9951 | /* =============== */ |
| 9952 | |
| 9953 | /* Balancing */ |
| 9954 | /* --------- */ |
| 9955 | |
| 9956 | /* This driver calls DGGBAL to both permute and scale rows and columns */ |
| 9957 | /* of A and B. The permutations PL and PR are chosen so that PL*A*PR */ |
| 9958 | /* and PL*B*R will be upper triangular except for the diagonal blocks */ |
| 9959 | /* A(i:j,i:j) and B(i:j,i:j), with i and j as close together as */ |
| 9960 | /* possible. The diagonal scaling matrices DL and DR are chosen so */ |
| 9961 | /* that the pair DL*PL*A*PR*DR, DL*PL*B*PR*DR have elements close to */ |
| 9962 | /* one (except for the elements that start out zero.) */ |
| 9963 | |
| 9964 | /* After the eigenvalues and eigenvectors of the balanced matrices */ |
| 9965 | /* have been computed, DGGBAK transforms the eigenvectors back to what */ |
| 9966 | /* they would have been (in perfect arithmetic) if they had not been */ |
| 9967 | /* balanced. */ |
| 9968 | |
| 9969 | /* Contents of A and B on Exit */ |
| 9970 | /* -------- -- - --- - -- ---- */ |
| 9971 | |
| 9972 | /* If any eigenvectors are computed (either JOBVL='V' or JOBVR='V' or */ |
| 9973 | /* both), then on exit the arrays A and B will contain the real Schur */ |
| 9974 | /* form[*] of the "balanced" versions of A and B. If no eigenvectors */ |
| 9975 | /* are computed, then only the diagonal blocks will be correct. */ |
| 9976 | |
| 9977 | /* [*] See DHGEQZ, DGEGS, or read the book "Matrix Computations", */ |
| 9978 | /* by Golub & van Loan, pub. by Johns Hopkins U. Press. */ |
| 9979 | |
| 9980 | /* ===================================================================== */ |
| 9981 | |
| 9982 | /* .. Parameters .. */ |
| 9983 | /* .. */ |
| 9984 | /* .. Local Scalars .. */ |
| 9985 | /* .. */ |
| 9986 | /* .. Local Arrays .. */ |
| 9987 | /* .. */ |
| 9988 | /* .. External Subroutines .. */ |
| 9989 | /* .. */ |
| 9990 | /* .. External Functions .. */ |
| 9991 | /* .. */ |
| 9992 | /* .. Intrinsic Functions .. */ |
| 9993 | /* .. */ |
| 9994 | /* .. Executable Statements .. */ |
| 9995 | |
| 9996 | /* Decode the input arguments */ |
| 9997 | |
| 9998 | /* Parameter adjustments */ |
| 9999 | a_dim1 = *lda; |
| 10000 | a_offset = 1 + a_dim1; |
| 10001 | a -= a_offset; |
| 10002 | b_dim1 = *ldb; |
| 10003 | b_offset = 1 + b_dim1; |
| 10004 | b -= b_offset; |
| 10005 | --alphar; |
| 10006 | --alphai; |
| 10007 | --beta; |
| 10008 | vl_dim1 = *ldvl; |
| 10009 | vl_offset = 1 + vl_dim1; |
| 10010 | vl -= vl_offset; |
| 10011 | vr_dim1 = *ldvr; |
| 10012 | vr_offset = 1 + vr_dim1; |
| 10013 | vr -= vr_offset; |
| 10014 | --work; |
| 10015 | |
| 10016 | /* Function Body */ |
| 10017 | if (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobvl, "N")) { |
| 10018 | ijobvl = 1; |
| 10019 | ilvl = false; |
| 10020 | } else if (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobvl, "V")) { |
| 10021 | ijobvl = 2; |
| 10022 | ilvl = true; |
| 10023 | } else { |
| 10024 | ijobvl = -1; |
| 10025 | ilvl = false; |
| 10026 | } |
| 10027 | |
| 10028 | if (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobvr, "N")) { |
| 10029 | ijobvr = 1; |
| 10030 | ilvr = false; |
| 10031 | } else if (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobvr, "V")) { |
| 10032 | ijobvr = 2; |
| 10033 | ilvr = true; |
| 10034 | } else { |
| 10035 | ijobvr = -1; |
| 10036 | ilvr = false; |
| 10037 | } |
| 10038 | ilv = ilvl || ilvr; |
| 10039 | |
| 10040 | /* Test the input arguments */ |
| 10041 | |
| 10042 | /* Computing MAX */ |
| 10043 | i__1 = *n << 3; |
| 10044 | lwkmin = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,1_integercxx . . $ `operator""_integer`(85240eb457c3721a).); |
| 10045 | lwkopt = lwkmin; |
| 10046 | work[1] = (double) lwkopt; |
| 10047 | lquery = *lwork == -1; |
| 10048 | *info = 0; |
| 10049 | if (ijobvl <= 0) { |
| 10050 | *info = -1; |
| 10051 | } else if (ijobvr <= 0) { |
| 10052 | *info = -2; |
| 10053 | } else if (*n < 0) { |
| 10054 | *info = -3; |
| 10055 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 10056 | *info = -5; |
| 10057 | } else if (*ldb < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 10058 | *info = -7; |
| 10059 | } else if (*ldvl < 1 || ilvl && *ldvl < *n) { |
| 10060 | *info = -12; |
| 10061 | } else if (*ldvr < 1 || ilvr && *ldvr < *n) { |
| 10062 | *info = -14; |
| 10063 | } else if (*lwork < lwkmin && ! lquery) { |
| 10064 | *info = -16; |
| 10065 | } |
| 10066 | |
| 10067 | if (*info == 0) { |
| 10068 | nb1 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEQRF", " ", n, n, &c_n1, &c_n1); |
| 10069 | nb2 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMQR", " ", n, n, n, &c_n1); |
| 10070 | nb3 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORGQR", " ", n, n, n, &c_n1); |
| 10071 | /* Computing MAX */ |
| 10072 | i__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(nb1,nb2); |
| 10073 | nb = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,nb3); |
| 10074 | /* Computing MAX */ |
| 10075 | i__1 = *n * 6, i__2 = *n * (nb + 1); |
| 10076 | lopt = (*n << 1) + stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 10077 | work[1] = (double) lopt; |
| 10078 | } |
| 10079 | |
| 10080 | if (*info != 0) { |
| 10081 | i__1 = -(*info); |
| 10082 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGEGV ", &i__1); |
| 10083 | return 0; |
| 10084 | } else if (lquery) { |
| 10085 | return 0; |
| 10086 | } |
| 10087 | |
| 10088 | /* Quick return if possible */ |
| 10089 | |
| 10090 | if (*n == 0) { |
| 10091 | return 0; |
| 10092 | } |
| 10093 | |
| 10094 | /* Get machine constants */ |
| 10095 | |
| 10096 | eps = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("E") * dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("B"); |
| 10097 | safmin = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("S"); |
| 10098 | safmin += safmin; |
| 10099 | safmax = 1. / safmin; |
| 10100 | onepls = eps * 4 + 1.; |
| 10101 | |
| 10102 | /* Scale A */ |
| 10103 | |
| 10104 | anrm = dlange_cxx . . $ dlange_(98d44e6417336f20).("M", n, n, &a[a_offset], lda, &work[1]); |
| 10105 | anrm1 = anrm; |
| 10106 | anrm2 = 1.; |
| 10107 | if (anrm < 1.) { |
| 10108 | if (safmax * anrm < 1.) { |
| 10109 | anrm1 = safmin; |
| 10110 | anrm2 = safmax * anrm; |
| 10111 | } |
| 10112 | } |
| 10113 | |
| 10114 | if (anrm > 0.) { |
| 10115 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c_n1, &c_n1, &anrm, &c_b27, n, n, &a[a_offset], lda, & |
| 10116 | iinfo); |
| 10117 | if (iinfo != 0) { |
| 10118 | *info = *n + 10; |
| 10119 | return 0; |
| 10120 | } |
| 10121 | } |
| 10122 | |
| 10123 | /* Scale B */ |
| 10124 | |
| 10125 | bnrm = dlange_cxx . . $ dlange_(98d44e6417336f20).("M", n, n, &b[b_offset], ldb, &work[1]); |
| 10126 | bnrm1 = bnrm; |
| 10127 | bnrm2 = 1.; |
| 10128 | if (bnrm < 1.) { |
| 10129 | if (safmax * bnrm < 1.) { |
| 10130 | bnrm1 = safmin; |
| 10131 | bnrm2 = safmax * bnrm; |
| 10132 | } |
| 10133 | } |
| 10134 | |
| 10135 | if (bnrm > 0.) { |
| 10136 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c_n1, &c_n1, &bnrm, &c_b27, n, n, &b[b_offset], ldb, & |
| 10137 | iinfo); |
| 10138 | if (iinfo != 0) { |
| 10139 | *info = *n + 10; |
| 10140 | return 0; |
| 10141 | } |
| 10142 | } |
| 10143 | |
| 10144 | /* Permute the matrix to make it more nearly triangular */ |
| 10145 | /* Workspace layout: (8*N words -- "work" requires 6*N words) */ |
| 10146 | /* left_permutation, right_permutation, work... */ |
| 10147 | |
| 10148 | ileft = 1; |
| 10149 | iright = *n + 1; |
| 10150 | iwork = iright + *n; |
| 10151 | dggbal_cxx . . $ dggbal_(69bfde64ff0f2aeb).("P", n, &a[a_offset], lda, &b[b_offset], ldb, &ilo, &ihi, &work[ |
| 10152 | ileft], &work[iright], &work[iwork], &iinfo); |
| 10153 | if (iinfo != 0) { |
| 10154 | *info = *n + 1; |
| 10155 | goto L120; |
| 10156 | } |
| 10157 | |
| 10158 | /* Reduce B to triangular form, and initialize VL and/or VR */ |
| 10159 | /* Workspace layout: ("work..." must have at least N words) */ |
| 10160 | /* left_permutation, right_permutation, tau, work... */ |
| 10161 | |
| 10162 | irows = ihi + 1 - ilo; |
| 10163 | if (ilv) { |
| 10164 | icols = *n + 1 - ilo; |
| 10165 | } else { |
| 10166 | icols = irows; |
| 10167 | } |
| 10168 | itau = iwork; |
| 10169 | iwork = itau + irows; |
| 10170 | i__1 = *lwork + 1 - iwork; |
| 10171 | dgeqrf_cxx . . $ dgeqrf_(b2aaa174babf002e).(&irows, &icols, &b[ilo + ilo * b_dim1], ldb, &work[itau], &work[ |
| 10172 | iwork], &i__1, &iinfo); |
| 10173 | if (iinfo >= 0) { |
| 10174 | /* Computing MAX */ |
| 10175 | i__1 = lwkopt, i__2 = (integercxx . . $ integer#) work[iwork] + iwork - 1; |
| 10176 | lwkopt = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 10177 | } |
| 10178 | if (iinfo != 0) { |
| 10179 | *info = *n + 2; |
| 10180 | goto L120; |
| 10181 | } |
| 10182 | |
| 10183 | i__1 = *lwork + 1 - iwork; |
| 10184 | dormqr_cxx . . $ dormqr_(c6b7238dd97e9cf9).("L", "T", &irows, &icols, &irows, &b[ilo + ilo * b_dim1], ldb, & |
| 10185 | work[itau], &a[ilo + ilo * a_dim1], lda, &work[iwork], &i__1, & |
| 10186 | iinfo); |
| 10187 | if (iinfo >= 0) { |
| 10188 | /* Computing MAX */ |
| 10189 | i__1 = lwkopt, i__2 = (integercxx . . $ integer#) work[iwork] + iwork - 1; |
| 10190 | lwkopt = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 10191 | } |
| 10192 | if (iinfo != 0) { |
| 10193 | *info = *n + 3; |
| 10194 | goto L120; |
| 10195 | } |
| 10196 | |
| 10197 | if (ilvl) { |
| 10198 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("Full", n, n, &c_b38, &c_b27, &vl[vl_offset], ldvl) |
| 10199 | ; |
| 10200 | i__1 = irows - 1; |
| 10201 | i__2 = irows - 1; |
| 10202 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("L", &i__1, &i__2, &b[ilo + 1 + ilo * b_dim1], ldb, &vl[ilo + |
| 10203 | 1 + ilo * vl_dim1], ldvl); |
| 10204 | i__1 = *lwork + 1 - iwork; |
| 10205 | dorgqr_cxx . . $ dorgqr_(424524679a238630).(&irows, &irows, &irows, &vl[ilo + ilo * vl_dim1], ldvl, &work[ |
| 10206 | itau], &work[iwork], &i__1, &iinfo); |
| 10207 | if (iinfo >= 0) { |
| 10208 | /* Computing MAX */ |
| 10209 | i__1 = lwkopt, i__2 = (integercxx . . $ integer#) work[iwork] + iwork - 1; |
| 10210 | lwkopt = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 10211 | } |
| 10212 | if (iinfo != 0) { |
| 10213 | *info = *n + 4; |
| 10214 | goto L120; |
| 10215 | } |
| 10216 | } |
| 10217 | |
| 10218 | if (ilvr) { |
| 10219 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("Full", n, n, &c_b38, &c_b27, &vr[vr_offset], ldvr) |
| 10220 | ; |
| 10221 | } |
| 10222 | |
| 10223 | /* Reduce to generalized Hessenberg form */ |
| 10224 | |
| 10225 | if (ilv) { |
| 10226 | |
| 10227 | /* Eigenvectors requested -- work on whole matrix. */ |
| 10228 | |
| 10229 | dgghrd_cxx . . $ dgghrd_(a37938716ecaec33).(jobvl, jobvr, n, &ilo, &ihi, &a[a_offset], lda, &b[b_offset], |
| 10230 | ldb, &vl[vl_offset], ldvl, &vr[vr_offset], ldvr, &iinfo); |
| 10231 | } else { |
| 10232 | dgghrd_cxx . . $ dgghrd_(a37938716ecaec33).("N", "N", &irows, &c__1, &irows, &a[ilo + ilo * a_dim1], lda, |
| 10233 | &b[ilo + ilo * b_dim1], ldb, &vl[vl_offset], ldvl, &vr[ |
| 10234 | vr_offset], ldvr, &iinfo); |
| 10235 | } |
| 10236 | if (iinfo != 0) { |
| 10237 | *info = *n + 5; |
| 10238 | goto L120; |
| 10239 | } |
| 10240 | |
| 10241 | /* Perform QZ algorithm */ |
| 10242 | /* Workspace layout: ("work..." must have at least 1 word) */ |
| 10243 | /* left_permutation, right_permutation, work... */ |
| 10244 | |
| 10245 | iwork = itau; |
| 10246 | if (ilv) { |
| 10247 | *(unsigned char *)chtemp = 'S'; |
| 10248 | } else { |
| 10249 | *(unsigned char *)chtemp = 'E'; |
| 10250 | } |
| 10251 | i__1 = *lwork + 1 - iwork; |
| 10252 | dhgeqz_cxx . . $ dhgeqz_(1c7cf0ed1736d01d).(chtemp, jobvl, jobvr, n, &ilo, &ihi, &a[a_offset], lda, &b[ |
| 10253 | b_offset], ldb, &alphar[1], &alphai[1], &beta[1], &vl[vl_offset], |
| 10254 | ldvl, &vr[vr_offset], ldvr, &work[iwork], &i__1, &iinfo); |
| 10255 | if (iinfo >= 0) { |
| 10256 | /* Computing MAX */ |
| 10257 | i__1 = lwkopt, i__2 = (integercxx . . $ integer#) work[iwork] + iwork - 1; |
| 10258 | lwkopt = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 10259 | } |
| 10260 | if (iinfo != 0) { |
| 10261 | if (iinfo > 0 && iinfo <= *n) { |
| 10262 | *info = iinfo; |
| 10263 | } else if (iinfo > *n && iinfo <= *n << 1) { |
| 10264 | *info = iinfo - *n; |
| 10265 | } else { |
| 10266 | *info = *n + 6; |
| 10267 | } |
| 10268 | goto L120; |
| 10269 | } |
| 10270 | |
| 10271 | if (ilv) { |
| 10272 | |
| 10273 | /* Compute Eigenvectors (DTGEVC requires 6*N words of workspace) */ |
| 10274 | |
| 10275 | if (ilvl) { |
| 10276 | if (ilvr) { |
| 10277 | *(unsigned char *)chtemp = 'B'; |
| 10278 | } else { |
| 10279 | *(unsigned char *)chtemp = 'L'; |
| 10280 | } |
| 10281 | } else { |
| 10282 | *(unsigned char *)chtemp = 'R'; |
| 10283 | } |
| 10284 | |
| 10285 | dtgevc_cxx . . $ dtgevc_(66a19661ce790798).(chtemp, "B", ldumma, n, &a[a_offset], lda, &b[b_offset], ldb, |
| 10286 | &vl[vl_offset], ldvl, &vr[vr_offset], ldvr, n, &in, &work[ |
| 10287 | iwork], &iinfo); |
| 10288 | if (iinfo != 0) { |
| 10289 | *info = *n + 7; |
| 10290 | goto L120; |
| 10291 | } |
| 10292 | |
| 10293 | /* Undo balancing on VL and VR, rescale */ |
| 10294 | |
| 10295 | if (ilvl) { |
| 10296 | dggbak_cxx . . $ dggbak_(3fb2e360e620705c).("P", "L", n, &ilo, &ihi, &work[ileft], &work[iright], n, & |
| 10297 | vl[vl_offset], ldvl, &iinfo); |
| 10298 | if (iinfo != 0) { |
| 10299 | *info = *n + 8; |
| 10300 | goto L120; |
| 10301 | } |
| 10302 | i__1 = *n; |
| 10303 | for (jc = 1; jc <= i__1; ++jc) { |
| 10304 | if (alphai[jc] < 0.) { |
| 10305 | goto L50; |
| 10306 | } |
| 10307 | temp = 0.; |
| 10308 | if (alphai[jc] == 0.) { |
| 10309 | i__2 = *n; |
| 10310 | for (jr = 1; jr <= i__2; ++jr) { |
| 10311 | /* Computing MAX */ |
| 10312 | d__2 = temp, d__3 = (d__1 = vl[jr + jc * vl_dim1], |
| 10313 | abscxx . . $ abs(447c67c6676f75c3).(d__1)); |
| 10314 | temp = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__2,d__3); |
| 10315 | /* L10: */ |
| 10316 | } |
| 10317 | } else { |
| 10318 | i__2 = *n; |
| 10319 | for (jr = 1; jr <= i__2; ++jr) { |
| 10320 | /* Computing MAX */ |
| 10321 | d__3 = temp, d__4 = (d__1 = vl[jr + jc * vl_dim1], |
| 10322 | abscxx . . $ abs(447c67c6676f75c3).(d__1)) + (d__2 = vl[jr + (jc + 1) * |
| 10323 | vl_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__2)); |
| 10324 | temp = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__3,d__4); |
| 10325 | /* L20: */ |
| 10326 | } |
| 10327 | } |
| 10328 | if (temp < safmin) { |
| 10329 | goto L50; |
| 10330 | } |
| 10331 | temp = 1. / temp; |
| 10332 | if (alphai[jc] == 0.) { |
| 10333 | i__2 = *n; |
| 10334 | for (jr = 1; jr <= i__2; ++jr) { |
| 10335 | vl[jr + jc * vl_dim1] *= temp; |
| 10336 | /* L30: */ |
| 10337 | } |
| 10338 | } else { |
| 10339 | i__2 = *n; |
| 10340 | for (jr = 1; jr <= i__2; ++jr) { |
| 10341 | vl[jr + jc * vl_dim1] *= temp; |
| 10342 | vl[jr + (jc + 1) * vl_dim1] *= temp; |
| 10343 | /* L40: */ |
| 10344 | } |
| 10345 | } |
| 10346 | L50: |
| 10347 | ; |
| 10348 | } |
| 10349 | } |
| 10350 | if (ilvr) { |
| 10351 | dggbak_cxx . . $ dggbak_(3fb2e360e620705c).("P", "R", n, &ilo, &ihi, &work[ileft], &work[iright], n, & |
| 10352 | vr[vr_offset], ldvr, &iinfo); |
| 10353 | if (iinfo != 0) { |
| 10354 | *info = *n + 9; |
| 10355 | goto L120; |
| 10356 | } |
| 10357 | i__1 = *n; |
| 10358 | for (jc = 1; jc <= i__1; ++jc) { |
| 10359 | if (alphai[jc] < 0.) { |
| 10360 | goto L100; |
| 10361 | } |
| 10362 | temp = 0.; |
| 10363 | if (alphai[jc] == 0.) { |
| 10364 | i__2 = *n; |
| 10365 | for (jr = 1; jr <= i__2; ++jr) { |
| 10366 | /* Computing MAX */ |
| 10367 | d__2 = temp, d__3 = (d__1 = vr[jr + jc * vr_dim1], |
| 10368 | abscxx . . $ abs(447c67c6676f75c3).(d__1)); |
| 10369 | temp = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__2,d__3); |
| 10370 | /* L60: */ |
| 10371 | } |
| 10372 | } else { |
| 10373 | i__2 = *n; |
| 10374 | for (jr = 1; jr <= i__2; ++jr) { |
| 10375 | /* Computing MAX */ |
| 10376 | d__3 = temp, d__4 = (d__1 = vr[jr + jc * vr_dim1], |
| 10377 | abscxx . . $ abs(447c67c6676f75c3).(d__1)) + (d__2 = vr[jr + (jc + 1) * |
| 10378 | vr_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__2)); |
| 10379 | temp = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__3,d__4); |
| 10380 | /* L70: */ |
| 10381 | } |
| 10382 | } |
| 10383 | if (temp < safmin) { |
| 10384 | goto L100; |
| 10385 | } |
| 10386 | temp = 1. / temp; |
| 10387 | if (alphai[jc] == 0.) { |
| 10388 | i__2 = *n; |
| 10389 | for (jr = 1; jr <= i__2; ++jr) { |
| 10390 | vr[jr + jc * vr_dim1] *= temp; |
| 10391 | /* L80: */ |
| 10392 | } |
| 10393 | } else { |
| 10394 | i__2 = *n; |
| 10395 | for (jr = 1; jr <= i__2; ++jr) { |
| 10396 | vr[jr + jc * vr_dim1] *= temp; |
| 10397 | vr[jr + (jc + 1) * vr_dim1] *= temp; |
| 10398 | /* L90: */ |
| 10399 | } |
| 10400 | } |
| 10401 | L100: |
| 10402 | ; |
| 10403 | } |
| 10404 | } |
| 10405 | |
| 10406 | /* End of eigenvector calculation */ |
| 10407 | |
| 10408 | } |
| 10409 | |
| 10410 | /* Undo scaling in alpha, beta */ |
| 10411 | |
| 10412 | /* Note: this does not give the alpha and beta for the unscaled */ |
| 10413 | /* problem. */ |
| 10414 | |
| 10415 | /* Un-scaling is limited to avoid underflow in alpha and beta */ |
| 10416 | /* if they are significant. */ |
| 10417 | |
| 10418 | i__1 = *n; |
| 10419 | for (jc = 1; jc <= i__1; ++jc) { |
| 10420 | absar = (d__1 = alphar[jc], abscxx . . $ abs(447c67c6676f75c3).(d__1)); |
| 10421 | absai = (d__1 = alphai[jc], abscxx . . $ abs(447c67c6676f75c3).(d__1)); |
| 10422 | absb = (d__1 = beta[jc], abscxx . . $ abs(447c67c6676f75c3).(d__1)); |
| 10423 | salfar = anrm * alphar[jc]; |
| 10424 | salfai = anrm * alphai[jc]; |
| 10425 | sbeta = bnrm * beta[jc]; |
| 10426 | ilimit = false; |
| 10427 | scale = 1.; |
| 10428 | |
| 10429 | /* Check for significant underflow in ALPHAI */ |
| 10430 | |
| 10431 | /* Computing MAX */ |
| 10432 | d__1 = safmin, d__2 = eps * absar, d__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__1,d__2), d__2 = eps * |
| 10433 | absb; |
| 10434 | if (abscxx . . $ abs(447c67c6676f75c3).(salfai) < safmin && absai >= stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__1,d__2)) { |
| 10435 | ilimit = true; |
| 10436 | /* Computing MAX */ |
| 10437 | d__1 = onepls * safmin, d__2 = anrm2 * absai; |
| 10438 | scale = onepls * safmin / anrm1 / stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__1,d__2); |
| 10439 | |
| 10440 | } else if (salfai == 0.) { |
| 10441 | |
| 10442 | /* If insignificant underflow in ALPHAI, then make the */ |
| 10443 | /* conjugate eigenvalue real. */ |
| 10444 | |
| 10445 | if (alphai[jc] < 0. && jc > 1) { |
| 10446 | alphai[jc - 1] = 0.; |
| 10447 | } else if (alphai[jc] > 0. && jc < *n) { |
| 10448 | alphai[jc + 1] = 0.; |
| 10449 | } |
| 10450 | } |
| 10451 | |
| 10452 | /* Check for significant underflow in ALPHAR */ |
| 10453 | |
| 10454 | /* Computing MAX */ |
| 10455 | d__1 = safmin, d__2 = eps * absai, d__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__1,d__2), d__2 = eps * |
| 10456 | absb; |
| 10457 | if (abscxx . . $ abs(447c67c6676f75c3).(salfar) < safmin && absar >= stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__1,d__2)) { |
| 10458 | ilimit = true; |
| 10459 | /* Computing MAX */ |
| 10460 | /* Computing MAX */ |
| 10461 | d__3 = onepls * safmin, d__4 = anrm2 * absar; |
| 10462 | d__1 = scale, d__2 = onepls * safmin / anrm1 / stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__3,d__4); |
| 10463 | scale = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__1,d__2); |
| 10464 | } |
| 10465 | |
| 10466 | /* Check for significant underflow in BETA */ |
| 10467 | |
| 10468 | /* Computing MAX */ |
| 10469 | d__1 = safmin, d__2 = eps * absar, d__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__1,d__2), d__2 = eps * |
| 10470 | absai; |
| 10471 | if (abscxx . . $ abs(447c67c6676f75c3).(sbeta) < safmin && absb >= stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__1,d__2)) { |
| 10472 | ilimit = true; |
| 10473 | /* Computing MAX */ |
| 10474 | /* Computing MAX */ |
| 10475 | d__3 = onepls * safmin, d__4 = bnrm2 * absb; |
| 10476 | d__1 = scale, d__2 = onepls * safmin / bnrm1 / stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__3,d__4); |
| 10477 | scale = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__1,d__2); |
| 10478 | } |
| 10479 | |
| 10480 | /* Check for possible overflow when limiting scaling */ |
| 10481 | |
| 10482 | if (ilimit) { |
| 10483 | /* Computing MAX */ |
| 10484 | d__1 = abscxx . . $ abs(447c67c6676f75c3).(salfar), d__2 = abscxx . . $ abs(447c67c6676f75c3).(salfai), d__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__1,d__2), |
| 10485 | d__2 = abscxx . . $ abs(447c67c6676f75c3).(sbeta); |
| 10486 | temp = scale * safmin * stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__1,d__2); |
| 10487 | if (temp > 1.) { |
| 10488 | scale /= temp; |
| 10489 | } |
| 10490 | if (scale < 1.) { |
| 10491 | ilimit = false; |
| 10492 | } |
| 10493 | } |
| 10494 | |
| 10495 | /* Recompute un-scaled ALPHAR, ALPHAI, BETA if necessary. */ |
| 10496 | |
| 10497 | if (ilimit) { |
| 10498 | salfar = scale * alphar[jc] * anrm; |
| 10499 | salfai = scale * alphai[jc] * anrm; |
| 10500 | sbeta = scale * beta[jc] * bnrm; |
| 10501 | } |
| 10502 | alphar[jc] = salfar; |
| 10503 | alphai[jc] = salfai; |
| 10504 | beta[jc] = sbeta; |
| 10505 | /* L110: */ |
| 10506 | } |
| 10507 | |
| 10508 | L120: |
| 10509 | work[1] = (double) lwkopt; |
| 10510 | |
| 10511 | return 0; |
| 10512 | |
| 10513 | /* End of DGEGV */ |
| 10514 | |
| 10515 | } /* dgegv_ */ |
| 10516 | |
| 10517 | /* Subroutine */ int dgehd2_cxx . . $ dgehd2_(75bc6169f7761452).(integercxx . . $ integer# *n, integercxx . . $ integer# *ilo, integercxx . . $ integer# *ihi, |
| 10518 | double *a, integercxx . . $ integer# *lda, double *tau, double *work, |
| 10519 | integercxx . . $ integer# *info) |
| 10520 | { |
| 10521 | /* Table of constant values */ |
| 10522 | static integercxx . . $ integer# c__1 = 1; |
| 10523 | |
| 10524 | /* System generated locals */ |
| 10525 | integercxx . . $ integer# a_dim1, a_offset, i__1, i__2, i__3; |
| 10526 | |
| 10527 | /* Local variables */ |
| 10528 | integercxx . . $ integer# i__; |
| 10529 | double aii; |
| 10530 | |
| 10531 | |
| 10532 | /* -- LAPACK routine (version 3.1) -- */ |
| 10533 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 10534 | /* November 2006 */ |
| 10535 | |
| 10536 | /* .. Scalar Arguments .. */ |
| 10537 | /* .. */ |
| 10538 | /* .. Array Arguments .. */ |
| 10539 | /* .. */ |
| 10540 | |
| 10541 | /* Purpose */ |
| 10542 | /* ======= */ |
| 10543 | |
| 10544 | /* DGEHD2 reduces a real general matrix A to upper Hessenberg form H by */ |
| 10545 | /* an orthogonal similarity transformation: Q' * A * Q = H . */ |
| 10546 | |
| 10547 | /* Arguments */ |
| 10548 | /* ========= */ |
| 10549 | |
| 10550 | /* N (input) INTEGER */ |
| 10551 | /* The order of the matrix A. N >= 0. */ |
| 10552 | |
| 10553 | /* ILO (input) INTEGER */ |
| 10554 | /* IHI (input) INTEGER */ |
| 10555 | /* It is assumed that A is already upper triangular in rows */ |
| 10556 | /* and columns 1:ILO-1 and IHI+1:N. ILO and IHI are normally */ |
| 10557 | /* set by a previous call to DGEBAL; otherwise they should be */ |
| 10558 | /* set to 1 and N respectively. See Further Details. */ |
| 10559 | /* 1 <= ILO <= IHI <= max(1,N). */ |
| 10560 | |
| 10561 | /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 10562 | /* On entry, the n by n general matrix to be reduced. */ |
| 10563 | /* On exit, the upper triangle and the first subdiagonal of A */ |
| 10564 | /* are overwritten with the upper Hessenberg matrix H, and the */ |
| 10565 | /* elements below the first subdiagonal, with the array TAU, */ |
| 10566 | /* represent the orthogonal matrix Q as a product of elementary */ |
| 10567 | /* reflectors. See Further Details. */ |
| 10568 | |
| 10569 | /* LDA (input) INTEGER */ |
| 10570 | /* The leading dimension of the array A. LDA >= max(1,N). */ |
| 10571 | |
| 10572 | /* TAU (output) DOUBLE PRECISION array, dimension (N-1) */ |
| 10573 | /* The scalar factors of the elementary reflectors (see Further */ |
| 10574 | /* Details). */ |
| 10575 | |
| 10576 | /* WORK (workspace) DOUBLE PRECISION array, dimension (N) */ |
| 10577 | |
| 10578 | /* INFO (output) INTEGER */ |
| 10579 | /* = 0: successful exit. */ |
| 10580 | /* < 0: if INFO = -i, the i-th argument had an illegal value. */ |
| 10581 | |
| 10582 | /* Further Details */ |
| 10583 | /* =============== */ |
| 10584 | |
| 10585 | /* The matrix Q is represented as a product of (ihi-ilo) elementary */ |
| 10586 | /* reflectors */ |
| 10587 | |
| 10588 | /* Q = H(ilo) H(ilo+1) . . . H(ihi-1). */ |
| 10589 | |
| 10590 | /* Each H(i) has the form */ |
| 10591 | |
| 10592 | /* H(i) = I - tau * v * v' */ |
| 10593 | |
| 10594 | /* where tau is a real scalar, and v is a real vector with */ |
| 10595 | /* v(1:i) = 0, v(i+1) = 1 and v(ihi+1:n) = 0; v(i+2:ihi) is stored on */ |
| 10596 | /* exit in A(i+2:ihi,i), and tau in TAU(i). */ |
| 10597 | |
| 10598 | /* The contents of A are illustrated by the following example, with */ |
| 10599 | /* n = 7, ilo = 2 and ihi = 6: */ |
| 10600 | |
| 10601 | /* on entry, on exit, */ |
| 10602 | |
| 10603 | /* ( a a a a a a a ) ( a a h h h h a ) */ |
| 10604 | /* ( a a a a a a ) ( a h h h h a ) */ |
| 10605 | /* ( a a a a a a ) ( h h h h h h ) */ |
| 10606 | /* ( a a a a a a ) ( v2 h h h h h ) */ |
| 10607 | /* ( a a a a a a ) ( v2 v3 h h h h ) */ |
| 10608 | /* ( a a a a a a ) ( v2 v3 v4 h h h ) */ |
| 10609 | /* ( a ) ( a ) */ |
| 10610 | |
| 10611 | /* where a denotes an element of the original matrix A, h denotes a */ |
| 10612 | /* modified element of the upper Hessenberg matrix H, and vi denotes an */ |
| 10613 | /* element of the vector defining H(i). */ |
| 10614 | |
| 10615 | /* ===================================================================== */ |
| 10616 | |
| 10617 | /* .. Parameters .. */ |
| 10618 | /* .. */ |
| 10619 | /* .. Local Scalars .. */ |
| 10620 | /* .. */ |
| 10621 | /* .. External Subroutines .. */ |
| 10622 | /* .. */ |
| 10623 | /* .. Intrinsic Functions .. */ |
| 10624 | /* .. */ |
| 10625 | /* .. Executable Statements .. */ |
| 10626 | |
| 10627 | /* Test the input parameters */ |
| 10628 | |
| 10629 | /* Parameter adjustments */ |
| 10630 | a_dim1 = *lda; |
| 10631 | a_offset = 1 + a_dim1; |
| 10632 | a -= a_offset; |
| 10633 | --tau; |
| 10634 | --work; |
| 10635 | |
| 10636 | /* Function Body */ |
| 10637 | *info = 0; |
| 10638 | if (*n < 0) { |
| 10639 | *info = -1; |
| 10640 | } else if (*ilo < 1 || *ilo > stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 10641 | *info = -2; |
| 10642 | } else if (*ihi < stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(*ilo,*n) || *ihi > *n) { |
| 10643 | *info = -3; |
| 10644 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 10645 | *info = -5; |
| 10646 | } |
| 10647 | if (*info != 0) { |
| 10648 | i__1 = -(*info); |
| 10649 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGEHD2", &i__1); |
| 10650 | return 0; |
| 10651 | } |
| 10652 | |
| 10653 | i__1 = *ihi - 1; |
| 10654 | for (i__ = *ilo; i__ <= i__1; ++i__) { |
| 10655 | |
| 10656 | /* Compute elementary reflector H(i) to annihilate A(i+2:ihi,i) */ |
| 10657 | |
| 10658 | i__2 = *ihi - i__; |
| 10659 | /* Computing MIN */ |
| 10660 | i__3 = i__ + 2; |
| 10661 | dlarfg_cxx . . $ dlarfg_(ae28ee921df873ff).(&i__2, &a[i__ + 1 + i__ * a_dim1], &a[stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__3, *n)+ i__ * |
| 10662 | a_dim1], &c__1, &tau[i__]); |
| 10663 | aii = a[i__ + 1 + i__ * a_dim1]; |
| 10664 | a[i__ + 1 + i__ * a_dim1] = 1.; |
| 10665 | |
| 10666 | /* Apply H(i) to A(1:ihi,i+1:ihi) from the right */ |
| 10667 | |
| 10668 | i__2 = *ihi - i__; |
| 10669 | dlarf_cxx . . $ dlarf_(f67bbcf4c4b4eb96).("Right", ihi, &i__2, &a[i__ + 1 + i__ * a_dim1], &c__1, &tau[ |
| 10670 | i__], &a[(i__ + 1) * a_dim1 + 1], lda, &work[1]); |
| 10671 | |
| 10672 | /* Apply H(i) to A(i+1:ihi,i+1:n) from the left */ |
| 10673 | |
| 10674 | i__2 = *ihi - i__; |
| 10675 | i__3 = *n - i__; |
| 10676 | dlarf_cxx . . $ dlarf_(f67bbcf4c4b4eb96).("Left", &i__2, &i__3, &a[i__ + 1 + i__ * a_dim1], &c__1, &tau[ |
| 10677 | i__], &a[i__ + 1 + (i__ + 1) * a_dim1], lda, &work[1]); |
| 10678 | |
| 10679 | a[i__ + 1 + i__ * a_dim1] = aii; |
| 10680 | /* L10: */ |
| 10681 | } |
| 10682 | |
| 10683 | return 0; |
| 10684 | |
| 10685 | /* End of DGEHD2 */ |
| 10686 | |
| 10687 | } /* dgehd2_ */ |
| 10688 | |
| 10689 | /* Subroutine */ int dgehrd_cxx . . $ dgehrd_(424524679a238630).(integercxx . . $ integer# *n, integercxx . . $ integer# *ilo, integercxx . . $ integer# *ihi, |
| 10690 | double *a, integercxx . . $ integer# *lda, double *tau, double *work, |
| 10691 | integercxx . . $ integer# *lwork, integercxx . . $ integer# *info) |
| 10692 | { |
| 10693 | /* Table of constant values */ |
| 10694 | static integercxx . . $ integer# c__1 = 1; |
| 10695 | static integercxx . . $ integer# c_n1 = -1; |
| 10696 | static integercxx . . $ integer# c__3 = 3; |
| 10697 | static integercxx . . $ integer# c__2 = 2; |
| 10698 | static integercxx . . $ integer# c__65 = 65; |
| 10699 | static double c_b25 = -1.; |
| 10700 | static double c_b26 = 1.; |
| 10701 | |
| 10702 | /* System generated locals */ |
| 10703 | integercxx . . $ integer# a_dim1, a_offset, i__1, i__2, i__3, i__4; |
| 10704 | |
| 10705 | /* Local variables */ |
| 10706 | integercxx . . $ integer# i__, j; |
| 10707 | double t[4160] /* was [65][64] */; |
| 10708 | integercxx . . $ integer# ib; |
| 10709 | double ei; |
| 10710 | integercxx . . $ integer# nb, nh, nx, iws; |
| 10711 | integercxx . . $ integer# nbmin, iinfo; |
| 10712 | integercxx . . $ integer# ldwork, lwkopt; |
| 10713 | bool lquery; |
| 10714 | |
| 10715 | |
| 10716 | /* -- LAPACK routine (version 3.1) -- */ |
| 10717 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 10718 | /* November 2006 */ |
| 10719 | |
| 10720 | /* .. Scalar Arguments .. */ |
| 10721 | /* .. */ |
| 10722 | /* .. Array Arguments .. */ |
| 10723 | /* .. */ |
| 10724 | |
| 10725 | /* Purpose */ |
| 10726 | /* ======= */ |
| 10727 | |
| 10728 | /* DGEHRD reduces a real general matrix A to upper Hessenberg form H by */ |
| 10729 | /* an orthogonal similarity transformation: Q' * A * Q = H . */ |
| 10730 | |
| 10731 | /* Arguments */ |
| 10732 | /* ========= */ |
| 10733 | |
| 10734 | /* N (input) INTEGER */ |
| 10735 | /* The order of the matrix A. N >= 0. */ |
| 10736 | |
| 10737 | /* ILO (input) INTEGER */ |
| 10738 | /* IHI (input) INTEGER */ |
| 10739 | /* It is assumed that A is already upper triangular in rows */ |
| 10740 | /* and columns 1:ILO-1 and IHI+1:N. ILO and IHI are normally */ |
| 10741 | /* set by a previous call to DGEBAL; otherwise they should be */ |
| 10742 | /* set to 1 and N respectively. See Further Details. */ |
| 10743 | /* 1 <= ILO <= IHI <= N, if N > 0; ILO=1 and IHI=0, if N=0. */ |
| 10744 | |
| 10745 | /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 10746 | /* On entry, the N-by-N general matrix to be reduced. */ |
| 10747 | /* On exit, the upper triangle and the first subdiagonal of A */ |
| 10748 | /* are overwritten with the upper Hessenberg matrix H, and the */ |
| 10749 | /* elements below the first subdiagonal, with the array TAU, */ |
| 10750 | /* represent the orthogonal matrix Q as a product of elementary */ |
| 10751 | /* reflectors. See Further Details. */ |
| 10752 | |
| 10753 | /* LDA (input) INTEGER */ |
| 10754 | /* The leading dimension of the array A. LDA >= max(1,N). */ |
| 10755 | |
| 10756 | /* TAU (output) DOUBLE PRECISION array, dimension (N-1) */ |
| 10757 | /* The scalar factors of the elementary reflectors (see Further */ |
| 10758 | /* Details). Elements 1:ILO-1 and IHI:N-1 of TAU are set to */ |
| 10759 | /* zero. */ |
| 10760 | |
| 10761 | /* WORK (workspace/output) DOUBLE PRECISION array, dimension (LWORK) */ |
| 10762 | /* On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ |
| 10763 | |
| 10764 | /* LWORK (input) INTEGER */ |
| 10765 | /* The length of the array WORK. LWORK >= max(1,N). */ |
| 10766 | /* For optimum performance LWORK >= N*NB, where NB is the */ |
| 10767 | /* optimal blocksize. */ |
| 10768 | |
| 10769 | /* If LWORK = -1, then a workspace query is assumed; the routine */ |
| 10770 | /* only calculates the optimal size of the WORK array, returns */ |
| 10771 | /* this value as the first entry of the WORK array, and no error */ |
| 10772 | /* message related to LWORK is issued by XERBLA. */ |
| 10773 | |
| 10774 | /* INFO (output) INTEGER */ |
| 10775 | /* = 0: successful exit */ |
| 10776 | /* < 0: if INFO = -i, the i-th argument had an illegal value. */ |
| 10777 | |
| 10778 | /* Further Details */ |
| 10779 | /* =============== */ |
| 10780 | |
| 10781 | /* The matrix Q is represented as a product of (ihi-ilo) elementary */ |
| 10782 | /* reflectors */ |
| 10783 | |
| 10784 | /* Q = H(ilo) H(ilo+1) . . . H(ihi-1). */ |
| 10785 | |
| 10786 | /* Each H(i) has the form */ |
| 10787 | |
| 10788 | /* H(i) = I - tau * v * v' */ |
| 10789 | |
| 10790 | /* where tau is a real scalar, and v is a real vector with */ |
| 10791 | /* v(1:i) = 0, v(i+1) = 1 and v(ihi+1:n) = 0; v(i+2:ihi) is stored on */ |
| 10792 | /* exit in A(i+2:ihi,i), and tau in TAU(i). */ |
| 10793 | |
| 10794 | /* The contents of A are illustrated by the following example, with */ |
| 10795 | /* n = 7, ilo = 2 and ihi = 6: */ |
| 10796 | |
| 10797 | /* on entry, on exit, */ |
| 10798 | |
| 10799 | /* ( a a a a a a a ) ( a a h h h h a ) */ |
| 10800 | /* ( a a a a a a ) ( a h h h h a ) */ |
| 10801 | /* ( a a a a a a ) ( h h h h h h ) */ |
| 10802 | /* ( a a a a a a ) ( v2 h h h h h ) */ |
| 10803 | /* ( a a a a a a ) ( v2 v3 h h h h ) */ |
| 10804 | /* ( a a a a a a ) ( v2 v3 v4 h h h ) */ |
| 10805 | /* ( a ) ( a ) */ |
| 10806 | |
| 10807 | /* where a denotes an element of the original matrix A, h denotes a */ |
| 10808 | /* modified element of the upper Hessenberg matrix H, and vi denotes an */ |
| 10809 | /* element of the vector defining H(i). */ |
| 10810 | |
| 10811 | /* This file is a slight modification of LAPACK-3.0's DGEHRD */ |
| 10812 | /* subroutine incorporating improvements proposed by Quintana-Orti and */ |
| 10813 | /* Van de Geijn (2005). */ |
| 10814 | |
| 10815 | /* ===================================================================== */ |
| 10816 | |
| 10817 | /* .. Parameters .. */ |
| 10818 | /* .. */ |
| 10819 | /* .. Local Scalars .. */ |
| 10820 | /* .. */ |
| 10821 | /* .. Local Arrays .. */ |
| 10822 | /* .. */ |
| 10823 | /* .. External Subroutines .. */ |
| 10824 | /* .. */ |
| 10825 | /* .. Intrinsic Functions .. */ |
| 10826 | /* .. */ |
| 10827 | /* .. External Functions .. */ |
| 10828 | /* .. */ |
| 10829 | /* .. Executable Statements .. */ |
| 10830 | |
| 10831 | /* Test the input parameters */ |
| 10832 | |
| 10833 | /* Parameter adjustments */ |
| 10834 | a_dim1 = *lda; |
| 10835 | a_offset = 1 + a_dim1; |
| 10836 | a -= a_offset; |
| 10837 | --tau; |
| 10838 | --work; |
| 10839 | |
| 10840 | /* Function Body */ |
| 10841 | *info = 0; |
| 10842 | /* Computing MIN */ |
| 10843 | i__1 = 64, i__2 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEHRD", " ", n, ilo, ihi, &c_n1); |
| 10844 | nb = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__1,i__2); |
| 10845 | lwkopt = *n * nb; |
| 10846 | work[1] = (double) lwkopt; |
| 10847 | lquery = *lwork == -1; |
| 10848 | if (*n < 0) { |
| 10849 | *info = -1; |
| 10850 | } else if (*ilo < 1 || *ilo > stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 10851 | *info = -2; |
| 10852 | } else if (*ihi < stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(*ilo,*n) || *ihi > *n) { |
| 10853 | *info = -3; |
| 10854 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 10855 | *info = -5; |
| 10856 | } else if (*lwork < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n) && ! lquery) { |
| 10857 | *info = -8; |
| 10858 | } |
| 10859 | if (*info != 0) { |
| 10860 | i__1 = -(*info); |
| 10861 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGEHRD", &i__1); |
| 10862 | return 0; |
| 10863 | } else if (lquery) { |
| 10864 | return 0; |
| 10865 | } |
| 10866 | |
| 10867 | /* Set elements 1:ILO-1 and IHI:N-1 of TAU to zero */ |
| 10868 | |
| 10869 | i__1 = *ilo - 1; |
| 10870 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 10871 | tau[i__] = 0.; |
| 10872 | /* L10: */ |
| 10873 | } |
| 10874 | i__1 = *n - 1; |
| 10875 | for (i__ = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*ihi); i__ <= i__1; ++i__) { |
| 10876 | tau[i__] = 0.; |
| 10877 | /* L20: */ |
| 10878 | } |
| 10879 | |
| 10880 | /* Quick return if possible */ |
| 10881 | |
| 10882 | nh = *ihi - *ilo + 1; |
| 10883 | if (nh <= 1) { |
| 10884 | work[1] = 1.; |
| 10885 | return 0; |
| 10886 | } |
| 10887 | |
| 10888 | /* Determine the block size */ |
| 10889 | |
| 10890 | /* Computing MIN */ |
| 10891 | i__1 = 64, i__2 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEHRD", " ", n, ilo, ihi, &c_n1); |
| 10892 | nb = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__1,i__2); |
| 10893 | nbmin = 2; |
| 10894 | iws = 1; |
| 10895 | if (nb > 1 && nb < nh) { |
| 10896 | |
| 10897 | /* Determine when to cross over from blocked to unblocked code */ |
| 10898 | /* (last block is always handled by unblocked code) */ |
| 10899 | |
| 10900 | /* Computing MAX */ |
| 10901 | i__1 = nb, i__2 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__3, "DGEHRD", " ", n, ilo, ihi, &c_n1); |
| 10902 | nx = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 10903 | if (nx < nh) { |
| 10904 | |
| 10905 | /* Determine if workspace is large enough for blocked code */ |
| 10906 | |
| 10907 | iws = *n * nb; |
| 10908 | if (*lwork < iws) { |
| 10909 | |
| 10910 | /* Not enough workspace to use optimal NB: determine the */ |
| 10911 | /* minimum value of NB, and reduce NB or force use of */ |
| 10912 | /* unblocked code */ |
| 10913 | |
| 10914 | /* Computing MAX */ |
| 10915 | i__1 = 2, i__2 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__2, "DGEHRD", " ", n, ilo, ihi, & |
| 10916 | c_n1); |
| 10917 | nbmin = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 10918 | if (*lwork >= *n * nbmin) { |
| 10919 | nb = *lwork / *n; |
| 10920 | } else { |
| 10921 | nb = 1; |
| 10922 | } |
| 10923 | } |
| 10924 | } |
| 10925 | } |
| 10926 | ldwork = *n; |
| 10927 | |
| 10928 | if (nb < nbmin || nb >= nh) { |
| 10929 | |
| 10930 | /* Use unblocked code below */ |
| 10931 | |
| 10932 | i__ = *ilo; |
| 10933 | |
| 10934 | } else { |
| 10935 | |
| 10936 | /* Use blocked code */ |
| 10937 | |
| 10938 | i__1 = *ihi - 1 - nx; |
| 10939 | i__2 = nb; |
| 10940 | for (i__ = *ilo; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) { |
| 10941 | /* Computing MIN */ |
| 10942 | i__3 = nb, i__4 = *ihi - i__; |
| 10943 | ib = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__3,i__4); |
| 10944 | |
| 10945 | /* Reduce columns i:i+ib-1 to Hessenberg form, returning the */ |
| 10946 | /* matrices V and T of the block reflector H = I - V*T*V' */ |
| 10947 | /* which performs the reduction, and also the matrix Y = A*V*T */ |
| 10948 | |
| 10949 | dlahr2_cxx . . $ dlahr2_(5dd98e08f9c86c8e).(ihi, &i__, &ib, &a[i__ * a_dim1 + 1], lda, &tau[i__], t, & |
| 10950 | c__65, &work[1], &ldwork); |
| 10951 | |
| 10952 | /* Apply the block reflector H to A(1:ihi,i+ib:ihi) from the */ |
| 10953 | /* right, computing A := A - Y * V'. V(i+ib,ib-1) must be set */ |
| 10954 | /* to 1 */ |
| 10955 | |
| 10956 | ei = a[i__ + ib + (i__ + ib - 1) * a_dim1]; |
| 10957 | a[i__ + ib + (i__ + ib - 1) * a_dim1] = 1.; |
| 10958 | i__3 = *ihi - i__ - ib + 1; |
| 10959 | dgemm_cxx . . $ dgemm_(7f9a15c7502022ea).("No transpose", "Transpose", ihi, &i__3, &ib, &c_b25, & |
| 10960 | work[1], &ldwork, &a[i__ + ib + i__ * a_dim1], lda, & |
| 10961 | c_b26, &a[(i__ + ib) * a_dim1 + 1], lda); |
| 10962 | a[i__ + ib + (i__ + ib - 1) * a_dim1] = ei; |
| 10963 | |
| 10964 | /* Apply the block reflector H to A(1:i,i+1:i+ib-1) from the */ |
| 10965 | /* right */ |
| 10966 | |
| 10967 | i__3 = ib - 1; |
| 10968 | dtrmm_cxx . . $ dtrmm_(47bcf6c639067e06).("Right", "Lower", "Transpose", "Unit", &i__, &i__3, &c_b26, |
| 10969 | &a[i__ + 1 + i__ * a_dim1], lda, &work[1], &ldwork); |
| 10970 | i__3 = ib - 2; |
| 10971 | for (j = 0; j <= i__3; ++j) { |
| 10972 | daxpy_cxx . . $ daxpy_(4b39f621356f7e14).(&i__, &c_b25, &work[ldwork * j + 1], &c__1, &a[(i__ + |
| 10973 | j + 1) * a_dim1 + 1], &c__1); |
| 10974 | /* L30: */ |
| 10975 | } |
| 10976 | |
| 10977 | /* Apply the block reflector H to A(i+1:ihi,i+ib:n) from the */ |
| 10978 | /* left */ |
| 10979 | |
| 10980 | i__3 = *ihi - i__; |
| 10981 | i__4 = *n - i__ - ib + 1; |
| 10982 | dlarfb_cxx . . $ dlarfb_(b0af75de90da309c).("Left", "Transpose", "Forward", "Columnwise", &i__3, & |
| 10983 | i__4, &ib, &a[i__ + 1 + i__ * a_dim1], lda, t, &c__65, &a[ |
| 10984 | i__ + 1 + (i__ + ib) * a_dim1], lda, &work[1], &ldwork); |
| 10985 | /* L40: */ |
| 10986 | } |
| 10987 | } |
| 10988 | |
| 10989 | /* Use unblocked code to reduce the rest of the matrix */ |
| 10990 | |
| 10991 | dgehd2_cxx . . $ dgehd2_(75bc6169f7761452).(n, &i__, ihi, &a[a_offset], lda, &tau[1], &work[1], &iinfo); |
| 10992 | work[1] = (double) iws; |
| 10993 | |
| 10994 | return 0; |
| 10995 | |
| 10996 | /* End of DGEHRD */ |
| 10997 | |
| 10998 | } /* dgehrd_ */ |
| 10999 | |
| 11000 | /* Subroutine */ int dgelq2_cxx . . $ dgelq2_(19b4abe06ca5e75b).(integercxx . . $ integer# *m, integercxx . . $ integer# *n, double *a, integercxx . . $ integer# * |
| 11001 | lda, double *tau, double *work, integercxx . . $ integer# *info) |
| 11002 | { |
| 11003 | /* System generated locals */ |
| 11004 | integercxx . . $ integer# a_dim1, a_offset, i__1, i__2, i__3; |
| 11005 | |
| 11006 | /* Local variables */ |
| 11007 | integercxx . . $ integer# i__, k; |
| 11008 | double aii; |
| 11009 | |
| 11010 | /* -- LAPACK routine (version 3.2) -- */ |
| 11011 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 11012 | /* November 2006 */ |
| 11013 | |
| 11014 | /* .. Scalar Arguments .. */ |
| 11015 | /* .. */ |
| 11016 | /* .. Array Arguments .. */ |
| 11017 | /* .. */ |
| 11018 | |
| 11019 | /* Purpose */ |
| 11020 | /* ======= */ |
| 11021 | |
| 11022 | /* DGELQ2 computes an LQ factorization of a real m by n matrix A: */ |
| 11023 | /* A = L * Q. */ |
| 11024 | |
| 11025 | /* Arguments */ |
| 11026 | /* ========= */ |
| 11027 | |
| 11028 | /* M (input) INTEGER */ |
| 11029 | /* The number of rows of the matrix A. M >= 0. */ |
| 11030 | |
| 11031 | /* N (input) INTEGER */ |
| 11032 | /* The number of columns of the matrix A. N >= 0. */ |
| 11033 | |
| 11034 | /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 11035 | /* On entry, the m by n matrix A. */ |
| 11036 | /* On exit, the elements on and below the diagonal of the array */ |
| 11037 | /* contain the m by min(m,n) lower trapezoidal matrix L (L is */ |
| 11038 | /* lower triangular if m <= n); the elements above the diagonal, */ |
| 11039 | /* with the array TAU, represent the orthogonal matrix Q as a */ |
| 11040 | /* product of elementary reflectors (see Further Details). */ |
| 11041 | |
| 11042 | /* LDA (input) INTEGER */ |
| 11043 | /* The leading dimension of the array A. LDA >= max(1,M). */ |
| 11044 | |
| 11045 | /* TAU (output) DOUBLE PRECISION array, dimension (min(M,N)) */ |
| 11046 | /* The scalar factors of the elementary reflectors (see Further */ |
| 11047 | /* Details). */ |
| 11048 | |
| 11049 | /* WORK (workspace) DOUBLE PRECISION array, dimension (M) */ |
| 11050 | |
| 11051 | /* INFO (output) INTEGER */ |
| 11052 | /* = 0: successful exit */ |
| 11053 | /* < 0: if INFO = -i, the i-th argument had an illegal value */ |
| 11054 | |
| 11055 | /* Further Details */ |
| 11056 | /* =============== */ |
| 11057 | |
| 11058 | /* The matrix Q is represented as a product of elementary reflectors */ |
| 11059 | |
| 11060 | /* Q = H(k) . . . H(2) H(1), where k = min(m,n). */ |
| 11061 | |
| 11062 | /* Each H(i) has the form */ |
| 11063 | |
| 11064 | /* H(i) = I - tau * v * v' */ |
| 11065 | |
| 11066 | /* where tau is a real scalar, and v is a real vector with */ |
| 11067 | /* v(1:i-1) = 0 and v(i) = 1; v(i+1:n) is stored on exit in A(i,i+1:n), */ |
| 11068 | /* and tau in TAU(i). */ |
| 11069 | |
| 11070 | /* ===================================================================== */ |
| 11071 | |
| 11072 | /* .. Parameters .. */ |
| 11073 | /* .. */ |
| 11074 | /* .. Local Scalars .. */ |
| 11075 | /* .. */ |
| 11076 | /* .. External Subroutines .. */ |
| 11077 | /* .. */ |
| 11078 | /* .. Intrinsic Functions .. */ |
| 11079 | /* .. */ |
| 11080 | /* .. Executable Statements .. */ |
| 11081 | |
| 11082 | /* Test the input arguments */ |
| 11083 | |
| 11084 | /* Parameter adjustments */ |
| 11085 | a_dim1 = *lda; |
| 11086 | a_offset = 1 + a_dim1; |
| 11087 | a -= a_offset; |
| 11088 | --tau; |
| 11089 | --work; |
| 11090 | |
| 11091 | /* Function Body */ |
| 11092 | *info = 0; |
| 11093 | if (*m < 0) { |
| 11094 | *info = -1; |
| 11095 | } else if (*n < 0) { |
| 11096 | *info = -2; |
| 11097 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*m)) { |
| 11098 | *info = -4; |
| 11099 | } |
| 11100 | if (*info != 0) { |
| 11101 | i__1 = -(*info); |
| 11102 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGELQ2", &i__1); |
| 11103 | return 0; |
| 11104 | } |
| 11105 | |
| 11106 | k = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(*m,*n); |
| 11107 | |
| 11108 | i__1 = k; |
| 11109 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 11110 | |
| 11111 | /* Generate elementary reflector H(i) to annihilate A(i,i+1:n) */ |
| 11112 | |
| 11113 | i__2 = *n - i__ + 1; |
| 11114 | /* Computing MIN */ |
| 11115 | i__3 = i__ + 1; |
| 11116 | dlarfp_cxx . . $ dlarfp_(ae28ee921df873ff).(&i__2, &a[i__ + i__ * a_dim1], &a[i__ + stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__3, *n)* a_dim1] |
| 11117 | , lda, &tau[i__]); |
| 11118 | if (i__ < *m) { |
| 11119 | |
| 11120 | /* Apply H(i) to A(i+1:m,i:n) from the right */ |
| 11121 | |
| 11122 | aii = a[i__ + i__ * a_dim1]; |
| 11123 | a[i__ + i__ * a_dim1] = 1.; |
| 11124 | i__2 = *m - i__; |
| 11125 | i__3 = *n - i__ + 1; |
| 11126 | dlarf_cxx . . $ dlarf_(f67bbcf4c4b4eb96).("Right", &i__2, &i__3, &a[i__ + i__ * a_dim1], lda, &tau[ |
| 11127 | i__], &a[i__ + 1 + i__ * a_dim1], lda, &work[1]); |
| 11128 | a[i__ + i__ * a_dim1] = aii; |
| 11129 | } |
| 11130 | /* L10: */ |
| 11131 | } |
| 11132 | return 0; |
| 11133 | |
| 11134 | /* End of DGELQ2 */ |
| 11135 | |
| 11136 | } /* dgelq2_ */ |
| 11137 | |
| 11138 | /* Subroutine */ int dgelqf_cxx . . $ dgelqf_(b2aaa174babf002e).(integercxx . . $ integer# *m, integercxx . . $ integer# *n, double *a, integercxx . . $ integer# * |
| 11139 | lda, double *tau, double *work, integercxx . . $ integer# *lwork, integercxx . . $ integer# *info) |
| 11140 | { |
| 11141 | /* Table of constant values */ |
| 11142 | static integercxx . . $ integer# c__1 = 1; |
| 11143 | static integercxx . . $ integer# c_n1 = -1; |
| 11144 | static integercxx . . $ integer# c__3 = 3; |
| 11145 | static integercxx . . $ integer# c__2 = 2; |
| 11146 | |
| 11147 | /* System generated locals */ |
| 11148 | integercxx . . $ integer# a_dim1, a_offset, i__1, i__2, i__3, i__4; |
| 11149 | |
| 11150 | /* Local variables */ |
| 11151 | integercxx . . $ integer# i__, k, ib, nb, nx, iws, nbmin, iinfo; |
| 11152 | integercxx . . $ integer# ldwork, lwkopt; |
| 11153 | bool lquery; |
| 11154 | |
| 11155 | |
| 11156 | /* -- LAPACK routine (version 3.1) -- */ |
| 11157 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 11158 | /* November 2006 */ |
| 11159 | |
| 11160 | /* .. Scalar Arguments .. */ |
| 11161 | /* .. */ |
| 11162 | /* .. Array Arguments .. */ |
| 11163 | /* .. */ |
| 11164 | |
| 11165 | /* Purpose */ |
| 11166 | /* ======= */ |
| 11167 | |
| 11168 | /* DGELQF computes an LQ factorization of a real M-by-N matrix A: */ |
| 11169 | /* A = L * Q. */ |
| 11170 | |
| 11171 | /* Arguments */ |
| 11172 | /* ========= */ |
| 11173 | |
| 11174 | /* M (input) INTEGER */ |
| 11175 | /* The number of rows of the matrix A. M >= 0. */ |
| 11176 | |
| 11177 | /* N (input) INTEGER */ |
| 11178 | /* The number of columns of the matrix A. N >= 0. */ |
| 11179 | |
| 11180 | /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 11181 | /* On entry, the M-by-N matrix A. */ |
| 11182 | /* On exit, the elements on and below the diagonal of the array */ |
| 11183 | /* contain the m-by-min(m,n) lower trapezoidal matrix L (L is */ |
| 11184 | /* lower triangular if m <= n); the elements above the diagonal, */ |
| 11185 | /* with the array TAU, represent the orthogonal matrix Q as a */ |
| 11186 | /* product of elementary reflectors (see Further Details). */ |
| 11187 | |
| 11188 | /* LDA (input) INTEGER */ |
| 11189 | /* The leading dimension of the array A. LDA >= max(1,M). */ |
| 11190 | |
| 11191 | /* TAU (output) DOUBLE PRECISION array, dimension (min(M,N)) */ |
| 11192 | /* The scalar factors of the elementary reflectors (see Further */ |
| 11193 | /* Details). */ |
| 11194 | |
| 11195 | /* WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) */ |
| 11196 | /* On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ |
| 11197 | |
| 11198 | /* LWORK (input) INTEGER */ |
| 11199 | /* The dimension of the array WORK. LWORK >= max(1,M). */ |
| 11200 | /* For optimum performance LWORK >= M*NB, where NB is the */ |
| 11201 | /* optimal blocksize. */ |
| 11202 | |
| 11203 | /* If LWORK = -1, then a workspace query is assumed; the routine */ |
| 11204 | /* only calculates the optimal size of the WORK array, returns */ |
| 11205 | /* this value as the first entry of the WORK array, and no error */ |
| 11206 | /* message related to LWORK is issued by XERBLA. */ |
| 11207 | |
| 11208 | /* INFO (output) INTEGER */ |
| 11209 | /* = 0: successful exit */ |
| 11210 | /* < 0: if INFO = -i, the i-th argument had an illegal value */ |
| 11211 | |
| 11212 | /* Further Details */ |
| 11213 | /* =============== */ |
| 11214 | |
| 11215 | /* The matrix Q is represented as a product of elementary reflectors */ |
| 11216 | |
| 11217 | /* Q = H(k) . . . H(2) H(1), where k = min(m,n). */ |
| 11218 | |
| 11219 | /* Each H(i) has the form */ |
| 11220 | |
| 11221 | /* H(i) = I - tau * v * v' */ |
| 11222 | |
| 11223 | /* where tau is a real scalar, and v is a real vector with */ |
| 11224 | /* v(1:i-1) = 0 and v(i) = 1; v(i+1:n) is stored on exit in A(i,i+1:n), */ |
| 11225 | /* and tau in TAU(i). */ |
| 11226 | |
| 11227 | /* ===================================================================== */ |
| 11228 | |
| 11229 | /* .. Local Scalars .. */ |
| 11230 | /* .. */ |
| 11231 | /* .. External Subroutines .. */ |
| 11232 | /* .. */ |
| 11233 | /* .. Intrinsic Functions .. */ |
| 11234 | /* .. */ |
| 11235 | /* .. External Functions .. */ |
| 11236 | /* .. */ |
| 11237 | /* .. Executable Statements .. */ |
| 11238 | |
| 11239 | /* Test the input arguments */ |
| 11240 | |
| 11241 | /* Parameter adjustments */ |
| 11242 | a_dim1 = *lda; |
| 11243 | a_offset = 1 + a_dim1; |
| 11244 | a -= a_offset; |
| 11245 | --tau; |
| 11246 | --work; |
| 11247 | |
| 11248 | /* Function Body */ |
| 11249 | *info = 0; |
| 11250 | nb = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGELQF", " ", m, n, &c_n1, &c_n1); |
| 11251 | lwkopt = *m * nb; |
| 11252 | work[1] = (double) lwkopt; |
| 11253 | lquery = *lwork == -1; |
| 11254 | if (*m < 0) { |
| 11255 | *info = -1; |
| 11256 | } else if (*n < 0) { |
| 11257 | *info = -2; |
| 11258 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*m)) { |
| 11259 | *info = -4; |
| 11260 | } else if (*lwork < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*m) && ! lquery) { |
| 11261 | *info = -7; |
| 11262 | } |
| 11263 | if (*info != 0) { |
| 11264 | i__1 = -(*info); |
| 11265 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGELQF", &i__1); |
| 11266 | return 0; |
| 11267 | } else if (lquery) { |
| 11268 | return 0; |
| 11269 | } |
| 11270 | |
| 11271 | /* Quick return if possible */ |
| 11272 | |
| 11273 | k = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(*m,*n); |
| 11274 | if (k == 0) { |
| 11275 | work[1] = 1.; |
| 11276 | return 0; |
| 11277 | } |
| 11278 | |
| 11279 | nbmin = 2; |
| 11280 | nx = 0; |
| 11281 | iws = *m; |
| 11282 | if (nb > 1 && nb < k) { |
| 11283 | |
| 11284 | /* Determine when to cross over from blocked to unblocked code. */ |
| 11285 | |
| 11286 | /* Computing MAX */ |
| 11287 | i__1 = 0, i__2 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__3, "DGELQF", " ", m, n, &c_n1, &c_n1); |
| 11288 | nx = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 11289 | if (nx < k) { |
| 11290 | |
| 11291 | /* Determine if workspace is large enough for blocked code. */ |
| 11292 | |
| 11293 | ldwork = *m; |
| 11294 | iws = ldwork * nb; |
| 11295 | if (*lwork < iws) { |
| 11296 | |
| 11297 | /* Not enough workspace to use optimal NB: reduce NB and */ |
| 11298 | /* determine the minimum value of NB. */ |
| 11299 | |
| 11300 | nb = *lwork / ldwork; |
| 11301 | /* Computing MAX */ |
| 11302 | i__1 = 2, i__2 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__2, "DGELQF", " ", m, n, &c_n1, & |
| 11303 | c_n1); |
| 11304 | nbmin = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 11305 | } |
| 11306 | } |
| 11307 | } |
| 11308 | |
| 11309 | if (nb >= nbmin && nb < k && nx < k) { |
| 11310 | |
| 11311 | /* Use blocked code initially */ |
| 11312 | |
| 11313 | i__1 = k - nx; |
| 11314 | i__2 = nb; |
| 11315 | for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) { |
| 11316 | /* Computing MIN */ |
| 11317 | i__3 = k - i__ + 1; |
| 11318 | ib = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__3,nb); |
| 11319 | |
| 11320 | /* Compute the LQ factorization of the current block */ |
| 11321 | /* A(i:i+ib-1,i:n) */ |
| 11322 | |
| 11323 | i__3 = *n - i__ + 1; |
| 11324 | dgelq2_cxx . . $ dgelq2_(19b4abe06ca5e75b).(&ib, &i__3, &a[i__ + i__ * a_dim1], lda, &tau[i__], &work[ |
| 11325 | 1], &iinfo); |
| 11326 | if (i__ + ib <= *m) { |
| 11327 | |
| 11328 | /* Form the triangular factor of the block reflector */ |
| 11329 | /* H = H(i) H(i+1) . . . H(i+ib-1) */ |
| 11330 | |
| 11331 | i__3 = *n - i__ + 1; |
| 11332 | dlarft_cxx . . $ dlarft_(9d83c62c83e92799).("Forward", "Rowwise", &i__3, &ib, &a[i__ + i__ * |
| 11333 | a_dim1], lda, &tau[i__], &work[1], &ldwork); |
| 11334 | |
| 11335 | /* Apply H to A(i+ib:m,i:n) from the right */ |
| 11336 | |
| 11337 | i__3 = *m - i__ - ib + 1; |
| 11338 | i__4 = *n - i__ + 1; |
| 11339 | dlarfb_cxx . . $ dlarfb_(b0af75de90da309c).("Right", "No transpose", "Forward", "Rowwise", &i__3, |
| 11340 | &i__4, &ib, &a[i__ + i__ * a_dim1], lda, &work[1], & |
| 11341 | ldwork, &a[i__ + ib + i__ * a_dim1], lda, &work[ib + |
| 11342 | 1], &ldwork); |
| 11343 | } |
| 11344 | /* L10: */ |
| 11345 | } |
| 11346 | } else { |
| 11347 | i__ = 1; |
| 11348 | } |
| 11349 | |
| 11350 | /* Use unblocked code to factor the last or only block. */ |
| 11351 | |
| 11352 | if (i__ <= k) { |
| 11353 | i__2 = *m - i__ + 1; |
| 11354 | i__1 = *n - i__ + 1; |
| 11355 | dgelq2_cxx . . $ dgelq2_(19b4abe06ca5e75b).(&i__2, &i__1, &a[i__ + i__ * a_dim1], lda, &tau[i__], &work[1] |
| 11356 | , &iinfo); |
| 11357 | } |
| 11358 | |
| 11359 | work[1] = (double) iws; |
| 11360 | return 0; |
| 11361 | |
| 11362 | /* End of DGELQF */ |
| 11363 | |
| 11364 | } /* dgelqf_ */ |
| 11365 | |
| 11366 | /* Subroutine */ int dgels_cxx . . $ dgels_(ebc76036aff7813d).(const char *trans, integercxx . . $ integer# *m, integercxx . . $ integer# *n, integercxx . . $ integer# * |
| 11367 | nrhs, double *a, integercxx . . $ integer# *lda, double *b, integercxx . . $ integer# *ldb, |
| 11368 | double *work, integercxx . . $ integer# *lwork, integercxx . . $ integer# *info) |
| 11369 | { |
| 11370 | /* Table of constant values */ |
| 11371 | static integercxx . . $ integer# c__1 = 1; |
| 11372 | static integercxx . . $ integer# c_n1 = -1; |
| 11373 | static double c_b33 = 0.; |
| 11374 | static integercxx . . $ integer# c__0 = 0; |
| 11375 | |
| 11376 | /* System generated locals */ |
| 11377 | integercxx . . $ integer# a_dim1, a_offset, b_dim1, b_offset, i__1, i__2; |
| 11378 | |
| 11379 | /* Local variables */ |
| 11380 | integercxx . . $ integer# i__, j, nb, mn; |
| 11381 | double anrm, bnrm; |
| 11382 | integercxx . . $ integer# brow; |
| 11383 | bool tpsd; |
| 11384 | integercxx . . $ integer# iascl, ibscl; |
| 11385 | integercxx . . $ integer# wsize; |
| 11386 | double rwork[1]; |
| 11387 | integercxx . . $ integer# scllen; |
| 11388 | double bignum; |
| 11389 | double smlnum; |
| 11390 | bool lquery; |
| 11391 | |
| 11392 | |
| 11393 | /* -- LAPACK driver routine (version 3.1) -- */ |
| 11394 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 11395 | /* November 2006 */ |
| 11396 | |
| 11397 | /* .. Scalar Arguments .. */ |
| 11398 | /* .. */ |
| 11399 | /* .. Array Arguments .. */ |
| 11400 | /* .. */ |
| 11401 | |
| 11402 | /* Purpose */ |
| 11403 | /* ======= */ |
| 11404 | |
| 11405 | /* DGELS solves overdetermined or underdetermined real linear systems */ |
| 11406 | /* involving an M-by-N matrix A, or its transpose, using a QR or LQ */ |
| 11407 | /* factorization of A. It is assumed that A has full rank. */ |
| 11408 | |
| 11409 | /* The following options are provided: */ |
| 11410 | |
| 11411 | /* 1. If TRANS = 'N' and m >= n: find the least squares solution of */ |
| 11412 | /* an overdetermined system, i.e., solve the least squares problem */ |
| 11413 | /* minimize || B - A*X ||. */ |
| 11414 | |
| 11415 | /* 2. If TRANS = 'N' and m < n: find the minimum norm solution of */ |
| 11416 | /* an underdetermined system A * X = B. */ |
| 11417 | |
| 11418 | /* 3. If TRANS = 'T' and m >= n: find the minimum norm solution of */ |
| 11419 | /* an undetermined system A**T * X = B. */ |
| 11420 | |
| 11421 | /* 4. If TRANS = 'T' and m < n: find the least squares solution of */ |
| 11422 | /* an overdetermined system, i.e., solve the least squares problem */ |
| 11423 | /* minimize || B - A**T * X ||. */ |
| 11424 | |
| 11425 | /* Several right hand side vectors b and solution vectors x can be */ |
| 11426 | /* handled in a single call; they are stored as the columns of the */ |
| 11427 | /* M-by-NRHS right hand side matrix B and the N-by-NRHS solution */ |
| 11428 | /* matrix X. */ |
| 11429 | |
| 11430 | /* Arguments */ |
| 11431 | /* ========= */ |
| 11432 | |
| 11433 | /* TRANS (input) CHARACTER*1 */ |
| 11434 | /* = 'N': the linear system involves A; */ |
| 11435 | /* = 'T': the linear system involves A**T. */ |
| 11436 | |
| 11437 | /* M (input) INTEGER */ |
| 11438 | /* The number of rows of the matrix A. M >= 0. */ |
| 11439 | |
| 11440 | /* N (input) INTEGER */ |
| 11441 | /* The number of columns of the matrix A. N >= 0. */ |
| 11442 | |
| 11443 | /* NRHS (input) INTEGER */ |
| 11444 | /* The number of right hand sides, i.e., the number of */ |
| 11445 | /* columns of the matrices B and X. NRHS >=0. */ |
| 11446 | |
| 11447 | /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 11448 | /* On entry, the M-by-N matrix A. */ |
| 11449 | /* On exit, */ |
| 11450 | /* if M >= N, A is overwritten by details of its QR */ |
| 11451 | /* factorization as returned by DGEQRF; */ |
| 11452 | /* if M < N, A is overwritten by details of its LQ */ |
| 11453 | /* factorization as returned by DGELQF. */ |
| 11454 | |
| 11455 | /* LDA (input) INTEGER */ |
| 11456 | /* The leading dimension of the array A. LDA >= max(1,M). */ |
| 11457 | |
| 11458 | /* B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */ |
| 11459 | /* On entry, the matrix B of right hand side vectors, stored */ |
| 11460 | /* columnwise; B is M-by-NRHS if TRANS = 'N', or N-by-NRHS */ |
| 11461 | /* if TRANS = 'T'. */ |
| 11462 | /* On exit, if INFO = 0, B is overwritten by the solution */ |
| 11463 | /* vectors, stored columnwise: */ |
| 11464 | /* if TRANS = 'N' and m >= n, rows 1 to n of B contain the least */ |
| 11465 | /* squares solution vectors; the residual sum of squares for the */ |
| 11466 | /* solution in each column is given by the sum of squares of */ |
| 11467 | /* elements N+1 to M in that column; */ |
| 11468 | /* if TRANS = 'N' and m < n, rows 1 to N of B contain the */ |
| 11469 | /* minimum norm solution vectors; */ |
| 11470 | /* if TRANS = 'T' and m >= n, rows 1 to M of B contain the */ |
| 11471 | /* minimum norm solution vectors; */ |
| 11472 | /* if TRANS = 'T' and m < n, rows 1 to M of B contain the */ |
| 11473 | /* least squares solution vectors; the residual sum of squares */ |
| 11474 | /* for the solution in each column is given by the sum of */ |
| 11475 | /* squares of elements M+1 to N in that column. */ |
| 11476 | |
| 11477 | /* LDB (input) INTEGER */ |
| 11478 | /* The leading dimension of the array B. LDB >= MAX(1,M,N). */ |
| 11479 | |
| 11480 | /* WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) */ |
| 11481 | /* On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ |
| 11482 | |
| 11483 | /* LWORK (input) INTEGER */ |
| 11484 | /* The dimension of the array WORK. */ |
| 11485 | /* LWORK >= max( 1, MN + max( MN, NRHS ) ). */ |
| 11486 | /* For optimal performance, */ |
| 11487 | /* LWORK >= max( 1, MN + max( MN, NRHS )*NB ). */ |
| 11488 | /* where MN = min(M,N) and NB is the optimum block size. */ |
| 11489 | |
| 11490 | /* If LWORK = -1, then a workspace query is assumed; the routine */ |
| 11491 | /* only calculates the optimal size of the WORK array, returns */ |
| 11492 | /* this value as the first entry of the WORK array, and no error */ |
| 11493 | /* message related to LWORK is issued by XERBLA. */ |
| 11494 | |
| 11495 | /* INFO (output) INTEGER */ |
| 11496 | /* = 0: successful exit */ |
| 11497 | /* < 0: if INFO = -i, the i-th argument had an illegal value */ |
| 11498 | /* > 0: if INFO = i, the i-th diagonal element of the */ |
| 11499 | /* triangular factor of A is zero, so that A does not have */ |
| 11500 | /* full rank; the least squares solution could not be */ |
| 11501 | /* computed. */ |
| 11502 | |
| 11503 | /* ===================================================================== */ |
| 11504 | |
| 11505 | /* .. Parameters .. */ |
| 11506 | /* .. */ |
| 11507 | /* .. Local Scalars .. */ |
| 11508 | /* .. */ |
| 11509 | /* .. Local Arrays .. */ |
| 11510 | /* .. */ |
| 11511 | /* .. External Functions .. */ |
| 11512 | /* .. */ |
| 11513 | /* .. External Subroutines .. */ |
| 11514 | /* .. */ |
| 11515 | /* .. Intrinsic Functions .. */ |
| 11516 | /* .. */ |
| 11517 | /* .. Executable Statements .. */ |
| 11518 | |
| 11519 | /* Test the input arguments. */ |
| 11520 | |
| 11521 | /* Parameter adjustments */ |
| 11522 | a_dim1 = *lda; |
| 11523 | a_offset = 1 + a_dim1; |
| 11524 | a -= a_offset; |
| 11525 | b_dim1 = *ldb; |
| 11526 | b_offset = 1 + b_dim1; |
| 11527 | b -= b_offset; |
| 11528 | --work; |
| 11529 | |
| 11530 | /* Function Body */ |
| 11531 | *info = 0; |
| 11532 | mn = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(*m,*n); |
| 11533 | lquery = *lwork == -1; |
| 11534 | if (! (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(trans, "N") || lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(trans, "T"))) { |
| 11535 | *info = -1; |
| 11536 | } else if (*m < 0) { |
| 11537 | *info = -2; |
| 11538 | } else if (*n < 0) { |
| 11539 | *info = -3; |
| 11540 | } else if (*nrhs < 0) { |
| 11541 | *info = -4; |
| 11542 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*m)) { |
| 11543 | *info = -6; |
| 11544 | } else /* if(complicated condition) */ { |
| 11545 | /* Computing MAX */ |
| 11546 | i__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*m); |
| 11547 | if (*ldb < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,*n)) { |
| 11548 | *info = -8; |
| 11549 | } else /* if(complicated condition) */ { |
| 11550 | /* Computing MAX */ |
| 11551 | i__1 = 1, i__2 = mn + stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(mn,*nrhs); |
| 11552 | if (*lwork < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2) && ! lquery) { |
| 11553 | *info = -10; |
| 11554 | } |
| 11555 | } |
| 11556 | } |
| 11557 | |
| 11558 | /* Figure out optimal block size */ |
| 11559 | |
| 11560 | if (*info == 0 || *info == -10) { |
| 11561 | |
| 11562 | tpsd = true; |
| 11563 | if (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(trans, "N")) { |
| 11564 | tpsd = false; |
| 11565 | } |
| 11566 | |
| 11567 | if (*m >= *n) { |
| 11568 | nb = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEQRF", " ", m, n, &c_n1, &c_n1); |
| 11569 | if (tpsd) { |
| 11570 | /* Computing MAX */ |
| 11571 | i__1 = nb, i__2 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMQR", "LN", m, nrhs, n, & |
| 11572 | c_n1); |
| 11573 | nb = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 11574 | } else { |
| 11575 | /* Computing MAX */ |
| 11576 | i__1 = nb, i__2 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMQR", "LT", m, nrhs, n, & |
| 11577 | c_n1); |
| 11578 | nb = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 11579 | } |
| 11580 | } else { |
| 11581 | nb = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGELQF", " ", m, n, &c_n1, &c_n1); |
| 11582 | if (tpsd) { |
| 11583 | /* Computing MAX */ |
| 11584 | i__1 = nb, i__2 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMLQ", "LT", n, nrhs, m, & |
| 11585 | c_n1); |
| 11586 | nb = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 11587 | } else { |
| 11588 | /* Computing MAX */ |
| 11589 | i__1 = nb, i__2 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMLQ", "LN", n, nrhs, m, & |
| 11590 | c_n1); |
| 11591 | nb = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 11592 | } |
| 11593 | } |
| 11594 | |
| 11595 | /* Computing MAX */ |
| 11596 | i__1 = 1, i__2 = mn + stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(mn,*nrhs) * nb; |
| 11597 | wsize = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 11598 | work[1] = (double) wsize; |
| 11599 | |
| 11600 | } |
| 11601 | |
| 11602 | if (*info != 0) { |
| 11603 | i__1 = -(*info); |
| 11604 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGELS ", &i__1); |
| 11605 | return 0; |
| 11606 | } else if (lquery) { |
| 11607 | return 0; |
| 11608 | } |
| 11609 | |
| 11610 | /* Quick return if possible */ |
| 11611 | |
| 11612 | /* Computing MIN */ |
| 11613 | i__1 = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(*m,*n); |
| 11614 | if (stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__1,*nrhs) == 0) { |
| 11615 | i__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(*m,*n); |
| 11616 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("Full", &i__1, nrhs, &c_b33, &c_b33, &b[b_offset], ldb); |
| 11617 | return 0; |
| 11618 | } |
| 11619 | |
| 11620 | /* Get machine parameters */ |
| 11621 | |
| 11622 | smlnum = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("S") / dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("P"); |
| 11623 | bignum = 1. / smlnum; |
| 11624 | dlabad_cxx . . $ dlabad_(4730c933dae9b326).(&smlnum, &bignum); |
| 11625 | |
| 11626 | /* Scale A, B if max element outside range [SMLNUM,BIGNUM] */ |
| 11627 | |
| 11628 | anrm = dlange_cxx . . $ dlange_(98d44e6417336f20).("M", m, n, &a[a_offset], lda, rwork); |
| 11629 | iascl = 0; |
| 11630 | if (anrm > 0. && anrm < smlnum) { |
| 11631 | |
| 11632 | /* Scale matrix norm up to SMLNUM */ |
| 11633 | |
| 11634 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &anrm, &smlnum, m, n, &a[a_offset], lda, |
| 11635 | info); |
| 11636 | iascl = 1; |
| 11637 | } else if (anrm > bignum) { |
| 11638 | |
| 11639 | /* Scale matrix norm down to BIGNUM */ |
| 11640 | |
| 11641 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &anrm, &bignum, m, n, &a[a_offset], lda, |
| 11642 | info); |
| 11643 | iascl = 2; |
| 11644 | } else if (anrm == 0.) { |
| 11645 | |
| 11646 | /* Matrix all zero. Return zero solution. */ |
| 11647 | |
| 11648 | i__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(*m,*n); |
| 11649 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("F", &i__1, nrhs, &c_b33, &c_b33, &b[b_offset], ldb); |
| 11650 | goto L50; |
| 11651 | } |
| 11652 | |
| 11653 | brow = *m; |
| 11654 | if (tpsd) { |
| 11655 | brow = *n; |
| 11656 | } |
| 11657 | bnrm = dlange_cxx . . $ dlange_(98d44e6417336f20).("M", &brow, nrhs, &b[b_offset], ldb, rwork); |
| 11658 | ibscl = 0; |
| 11659 | if (bnrm > 0. && bnrm < smlnum) { |
| 11660 | |
| 11661 | /* Scale matrix norm up to SMLNUM */ |
| 11662 | |
| 11663 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &bnrm, &smlnum, &brow, nrhs, &b[b_offset], |
| 11664 | ldb, info); |
| 11665 | ibscl = 1; |
| 11666 | } else if (bnrm > bignum) { |
| 11667 | |
| 11668 | /* Scale matrix norm down to BIGNUM */ |
| 11669 | |
| 11670 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &bnrm, &bignum, &brow, nrhs, &b[b_offset], |
| 11671 | ldb, info); |
| 11672 | ibscl = 2; |
| 11673 | } |
| 11674 | |
| 11675 | if (*m >= *n) { |
| 11676 | |
| 11677 | /* compute QR factorization of A */ |
| 11678 | |
| 11679 | i__1 = *lwork - mn; |
| 11680 | dgeqrf_cxx . . $ dgeqrf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[1], &work[mn + 1], &i__1, info) |
| 11681 | ; |
| 11682 | |
| 11683 | /* workspace at least N, optimally N*NB */ |
| 11684 | |
| 11685 | if (! tpsd) { |
| 11686 | |
| 11687 | /* Least-Squares Problem min || A * X - B || */ |
| 11688 | |
| 11689 | /* B(1:M,1:NRHS) := Q' * B(1:M,1:NRHS) */ |
| 11690 | |
| 11691 | i__1 = *lwork - mn; |
| 11692 | dormqr_cxx . . $ dormqr_(c6b7238dd97e9cf9).("Left", "Transpose", m, nrhs, n, &a[a_offset], lda, &work[ |
| 11693 | 1], &b[b_offset], ldb, &work[mn + 1], &i__1, info); |
| 11694 | |
| 11695 | /* workspace at least NRHS, optimally NRHS*NB */ |
| 11696 | |
| 11697 | /* B(1:N,1:NRHS) := inv(R) * B(1:N,1:NRHS) */ |
| 11698 | |
| 11699 | dtrtrs_cxx . . $ dtrtrs_(dee8bd198981a606).("Upper", "No transpose", "Non-unit", n, nrhs, &a[a_offset] |
| 11700 | , lda, &b[b_offset], ldb, info); |
| 11701 | |
| 11702 | if (*info > 0) { |
| 11703 | return 0; |
| 11704 | } |
| 11705 | |
| 11706 | scllen = *n; |
| 11707 | |
| 11708 | } else { |
| 11709 | |
| 11710 | /* Overdetermined system of equations A' * X = B */ |
| 11711 | |
| 11712 | /* B(1:N,1:NRHS) := inv(R') * B(1:N,1:NRHS) */ |
| 11713 | |
| 11714 | dtrtrs_cxx . . $ dtrtrs_(dee8bd198981a606).("Upper", "Transpose", "Non-unit", n, nrhs, &a[a_offset], |
| 11715 | lda, &b[b_offset], ldb, info); |
| 11716 | |
| 11717 | if (*info > 0) { |
| 11718 | return 0; |
| 11719 | } |
| 11720 | |
| 11721 | /* B(N+1:M,1:NRHS) = ZERO */ |
| 11722 | |
| 11723 | i__1 = *nrhs; |
| 11724 | for (j = 1; j <= i__1; ++j) { |
| 11725 | i__2 = *m; |
| 11726 | for (i__ = *n + 1; i__ <= i__2; ++i__) { |
| 11727 | b[i__ + j * b_dim1] = 0.; |
| 11728 | /* L10: */ |
| 11729 | } |
| 11730 | /* L20: */ |
| 11731 | } |
| 11732 | |
| 11733 | /* B(1:M,1:NRHS) := Q(1:N,:) * B(1:N,1:NRHS) */ |
| 11734 | |
| 11735 | i__1 = *lwork - mn; |
| 11736 | dormqr_cxx . . $ dormqr_(c6b7238dd97e9cf9).("Left", "No transpose", m, nrhs, n, &a[a_offset], lda, & |
| 11737 | work[1], &b[b_offset], ldb, &work[mn + 1], &i__1, info); |
| 11738 | |
| 11739 | /* workspace at least NRHS, optimally NRHS*NB */ |
| 11740 | |
| 11741 | scllen = *m; |
| 11742 | |
| 11743 | } |
| 11744 | |
| 11745 | } else { |
| 11746 | |
| 11747 | /* Compute LQ factorization of A */ |
| 11748 | |
| 11749 | i__1 = *lwork - mn; |
| 11750 | dgelqf_cxx . . $ dgelqf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[1], &work[mn + 1], &i__1, info) |
| 11751 | ; |
| 11752 | |
| 11753 | /* workspace at least M, optimally M*NB. */ |
| 11754 | |
| 11755 | if (! tpsd) { |
| 11756 | |
| 11757 | /* underdetermined system of equations A * X = B */ |
| 11758 | |
| 11759 | /* B(1:M,1:NRHS) := inv(L) * B(1:M,1:NRHS) */ |
| 11760 | |
| 11761 | dtrtrs_cxx . . $ dtrtrs_(dee8bd198981a606).("Lower", "No transpose", "Non-unit", m, nrhs, &a[a_offset] |
| 11762 | , lda, &b[b_offset], ldb, info); |
| 11763 | |
| 11764 | if (*info > 0) { |
| 11765 | return 0; |
| 11766 | } |
| 11767 | |
| 11768 | /* B(M+1:N,1:NRHS) = 0 */ |
| 11769 | |
| 11770 | i__1 = *nrhs; |
| 11771 | for (j = 1; j <= i__1; ++j) { |
| 11772 | i__2 = *n; |
| 11773 | for (i__ = *m + 1; i__ <= i__2; ++i__) { |
| 11774 | b[i__ + j * b_dim1] = 0.; |
| 11775 | /* L30: */ |
| 11776 | } |
| 11777 | /* L40: */ |
| 11778 | } |
| 11779 | |
| 11780 | /* B(1:N,1:NRHS) := Q(1:N,:)' * B(1:M,1:NRHS) */ |
| 11781 | |
| 11782 | i__1 = *lwork - mn; |
| 11783 | dormlq_cxx . . $ dormlq_(c6b7238dd97e9cf9).("Left", "Transpose", n, nrhs, m, &a[a_offset], lda, &work[ |
| 11784 | 1], &b[b_offset], ldb, &work[mn + 1], &i__1, info); |
| 11785 | |
| 11786 | /* workspace at least NRHS, optimally NRHS*NB */ |
| 11787 | |
| 11788 | scllen = *n; |
| 11789 | |
| 11790 | } else { |
| 11791 | |
| 11792 | /* overdetermined system min || A' * X - B || */ |
| 11793 | |
| 11794 | /* B(1:N,1:NRHS) := Q * B(1:N,1:NRHS) */ |
| 11795 | |
| 11796 | i__1 = *lwork - mn; |
| 11797 | dormlq_cxx . . $ dormlq_(c6b7238dd97e9cf9).("Left", "No transpose", n, nrhs, m, &a[a_offset], lda, & |
| 11798 | work[1], &b[b_offset], ldb, &work[mn + 1], &i__1, info); |
| 11799 | |
| 11800 | /* workspace at least NRHS, optimally NRHS*NB */ |
| 11801 | |
| 11802 | /* B(1:M,1:NRHS) := inv(L') * B(1:M,1:NRHS) */ |
| 11803 | |
| 11804 | dtrtrs_cxx . . $ dtrtrs_(dee8bd198981a606).("Lower", "Transpose", "Non-unit", m, nrhs, &a[a_offset], |
| 11805 | lda, &b[b_offset], ldb, info); |
| 11806 | |
| 11807 | if (*info > 0) { |
| 11808 | return 0; |
| 11809 | } |
| 11810 | |
| 11811 | scllen = *m; |
| 11812 | |
| 11813 | } |
| 11814 | |
| 11815 | } |
| 11816 | |
| 11817 | /* Undo scaling */ |
| 11818 | |
| 11819 | if (iascl == 1) { |
| 11820 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &anrm, &smlnum, &scllen, nrhs, &b[b_offset] |
| 11821 | , ldb, info); |
| 11822 | } else if (iascl == 2) { |
| 11823 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &anrm, &bignum, &scllen, nrhs, &b[b_offset] |
| 11824 | , ldb, info); |
| 11825 | } |
| 11826 | if (ibscl == 1) { |
| 11827 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &smlnum, &bnrm, &scllen, nrhs, &b[b_offset] |
| 11828 | , ldb, info); |
| 11829 | } else if (ibscl == 2) { |
| 11830 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &bignum, &bnrm, &scllen, nrhs, &b[b_offset] |
| 11831 | , ldb, info); |
| 11832 | } |
| 11833 | |
| 11834 | L50: |
| 11835 | work[1] = (double) wsize; |
| 11836 | |
| 11837 | return 0; |
| 11838 | |
| 11839 | /* End of DGELS */ |
| 11840 | |
| 11841 | } /* dgels_ */ |
| 11842 | |
| 11843 | /* Subroutine */ int dgelsd_cxx . . $ dgelsd_(cec05d45a9d3d8c8).(integercxx . . $ integer# *m, integercxx . . $ integer# *n, integercxx . . $ integer# *nrhs, |
| 11844 | double *a, integercxx . . $ integer# *lda, double *b, integercxx . . $ integer# *ldb, double * |
| 11845 | s, double *rcond, integercxx . . $ integer# *rank, double *work, integercxx . . $ integer# *lwork, |
| 11846 | integercxx . . $ integer# *iwork, integercxx . . $ integer# *info) |
| 11847 | { |
| 11848 | /* Table of constant values */ |
| 11849 | static integercxx . . $ integer# c__6 = 6; |
| 11850 | static integercxx . . $ integer# c_n1 = -1; |
| 11851 | static integercxx . . $ integer# c__9 = 9; |
| 11852 | static integercxx . . $ integer# c__0 = 0; |
| 11853 | static integercxx . . $ integer# c__1 = 1; |
| 11854 | static double c_b82 = 0.; |
| 11855 | |
| 11856 | /* System generated locals */ |
| 11857 | integercxx . . $ integer# a_dim1, a_offset, b_dim1, b_offset, i__1, i__2, i__3, i__4; |
| 11858 | |
| 11859 | /* Builtin functions |
| 11860 | double log(double); */ |
| 11861 | |
| 11862 | /* Local variables */ |
| 11863 | integercxx . . $ integer# ie, il, mm; |
| 11864 | double eps, anrm, bnrm; |
| 11865 | integercxx . . $ integer# itau, nlvl, iascl, ibscl; |
| 11866 | double sfmin; |
| 11867 | integercxx . . $ integer# minmn, maxmn, itaup, itauq, mnthr, nwork; |
| 11868 | double bignum; |
| 11869 | integercxx . . $ integer# wlalsd; |
| 11870 | integercxx . . $ integer# ldwork; |
| 11871 | integercxx . . $ integer# minwrk, maxwrk; |
| 11872 | double smlnum; |
| 11873 | bool lquery; |
| 11874 | integercxx . . $ integer# smlsiz; |
| 11875 | |
| 11876 | |
| 11877 | /* -- LAPACK driver routine (version 3.2) -- */ |
| 11878 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 11879 | /* November 2006 */ |
| 11880 | |
| 11881 | /* .. Scalar Arguments .. */ |
| 11882 | /* .. */ |
| 11883 | /* .. Array Arguments .. */ |
| 11884 | /* .. */ |
| 11885 | |
| 11886 | /* Purpose */ |
| 11887 | /* ======= */ |
| 11888 | |
| 11889 | /* DGELSD computes the minimum-norm solution to a real linear least */ |
| 11890 | /* squares problem: */ |
| 11891 | /* minimize 2-norm(| b - A*x |) */ |
| 11892 | /* using the singular value decomposition (SVD) of A. A is an M-by-N */ |
| 11893 | /* matrix which may be rank-deficient. */ |
| 11894 | |
| 11895 | /* Several right hand side vectors b and solution vectors x can be */ |
| 11896 | /* handled in a single call; they are stored as the columns of the */ |
| 11897 | /* M-by-NRHS right hand side matrix B and the N-by-NRHS solution */ |
| 11898 | /* matrix X. */ |
| 11899 | |
| 11900 | /* The problem is solved in three steps: */ |
| 11901 | /* (1) Reduce the coefficient matrix A to bidiagonal form with */ |
| 11902 | /* Householder transformations, reducing the original problem */ |
| 11903 | /* into a "bidiagonal least squares problem" (BLS) */ |
| 11904 | /* (2) Solve the BLS using a divide and conquer approach. */ |
| 11905 | /* (3) Apply back all the Householder tranformations to solve */ |
| 11906 | /* the original least squares problem. */ |
| 11907 | |
| 11908 | /* The effective rank of A is determined by treating as zero those */ |
| 11909 | /* singular values which are less than RCOND times the largest singular */ |
| 11910 | /* value. */ |
| 11911 | |
| 11912 | /* The divide and conquer algorithm makes very mild assumptions about */ |
| 11913 | /* floating point arithmetic. It will work on machines with a guard */ |
| 11914 | /* digit in add/subtract, or on those binary machines without guard */ |
| 11915 | /* digits which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or */ |
| 11916 | /* Cray-2. It could conceivably fail on hexadecimal or decimal machines */ |
| 11917 | /* without guard digits, but we know of none. */ |
| 11918 | |
| 11919 | /* Arguments */ |
| 11920 | /* ========= */ |
| 11921 | |
| 11922 | /* M (input) INTEGER */ |
| 11923 | /* The number of rows of A. M >= 0. */ |
| 11924 | |
| 11925 | /* N (input) INTEGER */ |
| 11926 | /* The number of columns of A. N >= 0. */ |
| 11927 | |
| 11928 | /* NRHS (input) INTEGER */ |
| 11929 | /* The number of right hand sides, i.e., the number of columns */ |
| 11930 | /* of the matrices B and X. NRHS >= 0. */ |
| 11931 | |
| 11932 | /* A (input) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 11933 | /* On entry, the M-by-N matrix A. */ |
| 11934 | /* On exit, A has been destroyed. */ |
| 11935 | |
| 11936 | /* LDA (input) INTEGER */ |
| 11937 | /* The leading dimension of the array A. LDA >= max(1,M). */ |
| 11938 | |
| 11939 | /* B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */ |
| 11940 | /* On entry, the M-by-NRHS right hand side matrix B. */ |
| 11941 | /* On exit, B is overwritten by the N-by-NRHS solution */ |
| 11942 | /* matrix X. If m >= n and RANK = n, the residual */ |
| 11943 | /* sum-of-squares for the solution in the i-th column is given */ |
| 11944 | /* by the sum of squares of elements n+1:m in that column. */ |
| 11945 | |
| 11946 | /* LDB (input) INTEGER */ |
| 11947 | /* The leading dimension of the array B. LDB >= max(1,max(M,N)). */ |
| 11948 | |
| 11949 | /* S (output) DOUBLE PRECISION array, dimension (min(M,N)) */ |
| 11950 | /* The singular values of A in decreasing order. */ |
| 11951 | /* The condition number of A in the 2-norm = S(1)/S(min(m,n)). */ |
| 11952 | |
| 11953 | /* RCOND (input) DOUBLE PRECISION */ |
| 11954 | /* RCOND is used to determine the effective rank of A. */ |
| 11955 | /* Singular values S(i) <= RCOND*S(1) are treated as zero. */ |
| 11956 | /* If RCOND < 0, machine precision is used instead. */ |
| 11957 | |
| 11958 | /* RANK (output) INTEGER */ |
| 11959 | /* The effective rank of A, i.e., the number of singular values */ |
| 11960 | /* which are greater than RCOND*S(1). */ |
| 11961 | |
| 11962 | /* WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) */ |
| 11963 | /* On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ |
| 11964 | |
| 11965 | /* LWORK (input) INTEGER */ |
| 11966 | /* The dimension of the array WORK. LWORK must be at least 1. */ |
| 11967 | /* The exact minimum amount of workspace needed depends on M, */ |
| 11968 | /* N and NRHS. As long as LWORK is at least */ |
| 11969 | /* 12*N + 2*N*SMLSIZ + 8*N*NLVL + N*NRHS + (SMLSIZ+1)**2, */ |
| 11970 | /* if M is greater than or equal to N or */ |
| 11971 | /* 12*M + 2*M*SMLSIZ + 8*M*NLVL + M*NRHS + (SMLSIZ+1)**2, */ |
| 11972 | /* if M is less than N, the code will execute correctly. */ |
| 11973 | /* SMLSIZ is returned by ILAENV and is equal to the maximum */ |
| 11974 | /* size of the subproblems at the bottom of the computation */ |
| 11975 | /* tree (usually about 25), and */ |
| 11976 | /* NLVL = MAX( 0, INT( LOG_2( MIN( M,N )/(SMLSIZ+1) ) ) + 1 ) */ |
| 11977 | /* For good performance, LWORK should generally be larger. */ |
| 11978 | |
| 11979 | /* If LWORK = -1, then a workspace query is assumed; the routine */ |
| 11980 | /* only calculates the optimal size of the WORK array, returns */ |
| 11981 | /* this value as the first entry of the WORK array, and no error */ |
| 11982 | /* message related to LWORK is issued by XERBLA. */ |
| 11983 | |
| 11984 | /* IWORK (workspace) INTEGER array, dimension (MAX(1,LIWORK)) */ |
| 11985 | /* LIWORK >= 3 * MINMN * NLVL + 11 * MINMN, */ |
| 11986 | /* where MINMN = MIN( M,N ). */ |
| 11987 | |
| 11988 | /* INFO (output) INTEGER */ |
| 11989 | /* = 0: successful exit */ |
| 11990 | /* < 0: if INFO = -i, the i-th argument had an illegal value. */ |
| 11991 | /* > 0: the algorithm for computing the SVD failed to converge; */ |
| 11992 | /* if INFO = i, i off-diagonal elements of an intermediate */ |
| 11993 | /* bidiagonal form did not converge to zero. */ |
| 11994 | |
| 11995 | /* Further Details */ |
| 11996 | /* =============== */ |
| 11997 | |
| 11998 | /* Based on contributions by */ |
| 11999 | /* Ming Gu and Ren-Cang Li, Computer Science Division, University of */ |
| 12000 | /* California at Berkeley, USA */ |
| 12001 | /* Osni Marques, LBNL/NERSC, USA */ |
| 12002 | |
| 12003 | /* ===================================================================== */ |
| 12004 | |
| 12005 | /* .. Parameters .. */ |
| 12006 | /* .. */ |
| 12007 | /* .. Local Scalars .. */ |
| 12008 | /* .. */ |
| 12009 | /* .. External Subroutines .. */ |
| 12010 | /* .. */ |
| 12011 | /* .. External Functions .. */ |
| 12012 | /* .. */ |
| 12013 | /* .. Intrinsic Functions .. */ |
| 12014 | /* .. */ |
| 12015 | /* .. Executable Statements .. */ |
| 12016 | |
| 12017 | /* Test the input arguments. */ |
| 12018 | |
| 12019 | /* Parameter adjustments */ |
| 12020 | a_dim1 = *lda; |
| 12021 | a_offset = 1 + a_dim1; |
| 12022 | a -= a_offset; |
| 12023 | b_dim1 = *ldb; |
| 12024 | b_offset = 1 + b_dim1; |
| 12025 | b -= b_offset; |
| 12026 | --s; |
| 12027 | --work; |
| 12028 | --iwork; |
| 12029 | |
| 12030 | /* Function Body */ |
| 12031 | *info = 0; |
| 12032 | minmn = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(*m,*n); |
| 12033 | maxmn = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(*m,*n); |
| 12034 | mnthr = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__6, "DGELSD", " ", m, n, nrhs, &c_n1); |
| 12035 | lquery = *lwork == -1; |
| 12036 | if (*m < 0) { |
| 12037 | *info = -1; |
| 12038 | } else if (*n < 0) { |
| 12039 | *info = -2; |
| 12040 | } else if (*nrhs < 0) { |
| 12041 | *info = -3; |
| 12042 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*m)) { |
| 12043 | *info = -5; |
| 12044 | } else if (*ldb < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,maxmn)) { |
| 12045 | *info = -7; |
| 12046 | } |
| 12047 | |
| 12048 | smlsiz = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__9, "DGELSD", " ", &c__0, &c__0, &c__0, &c__0); |
| 12049 | |
| 12050 | /* Compute workspace. */ |
| 12051 | /* (Note: Comments in the code beginning "Workspace:" describe the */ |
| 12052 | /* minimal amount of workspace needed at that point in the code, */ |
| 12053 | /* as well as the preferred amount for good performance. */ |
| 12054 | /* NB refers to the optimal block size for the immediately */ |
| 12055 | /* following subroutine, as returned by ILAENV.) */ |
| 12056 | |
| 12057 | minwrk = 1; |
| 12058 | minmn = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,minmn); |
| 12059 | /* Computing MAX */ |
| 12060 | i__1 = (integercxx . . $ integer#) (logcxx . . $ log(fee4f1d22bc8e617).((double) minmn / (double) (smlsiz + 1)) / |
| 12061 | logcxx . . $ log(fee4f1d22bc8e617).(2.)) + 1; |
| 12062 | nlvl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,0_integercxx . . $ `operator""_integer`(85240eb457c3721a).); |
| 12063 | |
| 12064 | if (*info == 0) { |
| 12065 | maxwrk = 0; |
| 12066 | mm = *m; |
| 12067 | if (*m >= *n && *m >= mnthr) { |
| 12068 | |
| 12069 | /* Path 1a - overdetermined, with many more rows than columns. */ |
| 12070 | |
| 12071 | mm = *n; |
| 12072 | /* Computing MAX */ |
| 12073 | i__1 = maxwrk, i__2 = *n + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEQRF", " ", m, |
| 12074 | n, &c_n1, &c_n1); |
| 12075 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 12076 | /* Computing MAX */ |
| 12077 | i__1 = maxwrk, i__2 = *n + *nrhs * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMQR", "LT", |
| 12078 | m, nrhs, n, &c_n1); |
| 12079 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 12080 | } |
| 12081 | if (*m >= *n) { |
| 12082 | |
| 12083 | /* Path 1 - overdetermined or exactly determined. */ |
| 12084 | |
| 12085 | /* Computing MAX */ |
| 12086 | i__1 = maxwrk, i__2 = *n * 3 + (mm + *n) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEBRD" |
| 12087 | , " ", &mm, n, &c_n1, &c_n1); |
| 12088 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 12089 | /* Computing MAX */ |
| 12090 | i__1 = maxwrk, i__2 = *n * 3 + *nrhs * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMBR", |
| 12091 | "QLT", &mm, nrhs, n, &c_n1); |
| 12092 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 12093 | /* Computing MAX */ |
| 12094 | i__1 = maxwrk, i__2 = *n * 3 + (*n - 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMBR", |
| 12095 | "PLN", n, nrhs, n, &c_n1); |
| 12096 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 12097 | /* Computing 2nd power */ |
| 12098 | i__1 = smlsiz + 1; |
| 12099 | wlalsd = *n * 9 + (*n << 1) * smlsiz + (*n << 3) * nlvl + *n * * |
| 12100 | nrhs + i__1 * i__1; |
| 12101 | /* Computing MAX */ |
| 12102 | i__1 = maxwrk, i__2 = *n * 3 + wlalsd; |
| 12103 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 12104 | /* Computing MAX */ |
| 12105 | i__1 = *n * 3 + mm, i__2 = *n * 3 + *nrhs, i__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2), |
| 12106 | i__2 = *n * 3 + wlalsd; |
| 12107 | minwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 12108 | } |
| 12109 | if (*n > *m) { |
| 12110 | /* Computing 2nd power */ |
| 12111 | i__1 = smlsiz + 1; |
| 12112 | wlalsd = *m * 9 + (*m << 1) * smlsiz + (*m << 3) * nlvl + *m * * |
| 12113 | nrhs + i__1 * i__1; |
| 12114 | if (*n >= mnthr) { |
| 12115 | |
| 12116 | /* Path 2a - underdetermined, with many more columns */ |
| 12117 | /* than rows. */ |
| 12118 | |
| 12119 | maxwrk = *m + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGELQF", " ", m, n, &c_n1, |
| 12120 | &c_n1); |
| 12121 | /* Computing MAX */ |
| 12122 | i__1 = maxwrk, i__2 = *m * *m + (*m << 2) + (*m << 1) * |
| 12123 | ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEBRD", " ", m, m, &c_n1, &c_n1); |
| 12124 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 12125 | /* Computing MAX */ |
| 12126 | i__1 = maxwrk, i__2 = *m * *m + (*m << 2) + *nrhs * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(& |
| 12127 | c__1, "DORMBR", "QLT", m, nrhs, m, &c_n1); |
| 12128 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 12129 | /* Computing MAX */ |
| 12130 | i__1 = maxwrk, i__2 = *m * *m + (*m << 2) + (*m - 1) * |
| 12131 | ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMBR", "PLN", m, nrhs, m, &c_n1); |
| 12132 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 12133 | if (*nrhs > 1) { |
| 12134 | /* Computing MAX */ |
| 12135 | i__1 = maxwrk, i__2 = *m * *m + *m + *m * *nrhs; |
| 12136 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 12137 | } else { |
| 12138 | /* Computing MAX */ |
| 12139 | i__1 = maxwrk, i__2 = *m * *m + (*m << 1); |
| 12140 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 12141 | } |
| 12142 | /* Computing MAX */ |
| 12143 | i__1 = maxwrk, i__2 = *m + *nrhs * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMLQ", |
| 12144 | "LT", n, nrhs, m, &c_n1); |
| 12145 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 12146 | /* Computing MAX */ |
| 12147 | i__1 = maxwrk, i__2 = *m * *m + (*m << 2) + wlalsd; |
| 12148 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 12149 | /* XXX: Ensure the Path 2a case below is triggered. The workspace */ |
| 12150 | /* calculation should use queries for all routines eventually. */ |
| 12151 | /* Computing MAX */ |
| 12152 | /* Computing MAX */ |
| 12153 | i__3 = *m, i__4 = (*m << 1) - 4, i__3 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__3,i__4), i__3 = |
| 12154 | stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__3,*nrhs), i__4 = *n - *m * 3; |
| 12155 | i__1 = maxwrk, i__2 = (*m << 2) + *m * *m + stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__3,i__4); |
| 12156 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 12157 | } else { |
| 12158 | |
| 12159 | /* Path 2 - remaining underdetermined cases. */ |
| 12160 | |
| 12161 | maxwrk = *m * 3 + (*n + *m) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEBRD", " ", m, |
| 12162 | n, &c_n1, &c_n1); |
| 12163 | /* Computing MAX */ |
| 12164 | i__1 = maxwrk, i__2 = *m * 3 + *nrhs * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMBR" |
| 12165 | , "QLT", m, nrhs, n, &c_n1); |
| 12166 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 12167 | /* Computing MAX */ |
| 12168 | i__1 = maxwrk, i__2 = *m * 3 + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMBR", |
| 12169 | "PLN", n, nrhs, m, &c_n1); |
| 12170 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 12171 | /* Computing MAX */ |
| 12172 | i__1 = maxwrk, i__2 = *m * 3 + wlalsd; |
| 12173 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 12174 | } |
| 12175 | /* Computing MAX */ |
| 12176 | i__1 = *m * 3 + *nrhs, i__2 = *m * 3 + *m, i__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2), |
| 12177 | i__2 = *m * 3 + wlalsd; |
| 12178 | minwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 12179 | } |
| 12180 | minwrk = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(minwrk,maxwrk); |
| 12181 | work[1] = (double) maxwrk; |
| 12182 | if (*lwork < minwrk && ! lquery) { |
| 12183 | *info = -12; |
| 12184 | } |
| 12185 | } |
| 12186 | |
| 12187 | if (*info != 0) { |
| 12188 | i__1 = -(*info); |
| 12189 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGELSD", &i__1); |
| 12190 | return 0; |
| 12191 | } else if (lquery) { |
| 12192 | goto L10; |
| 12193 | } |
| 12194 | |
| 12195 | /* Quick return if possible. */ |
| 12196 | |
| 12197 | if (*m == 0 || *n == 0) { |
| 12198 | *rank = 0; |
| 12199 | return 0; |
| 12200 | } |
| 12201 | |
| 12202 | /* Get machine parameters. */ |
| 12203 | |
| 12204 | eps = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("P"); |
| 12205 | sfmin = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("S"); |
| 12206 | smlnum = sfmin / eps; |
| 12207 | bignum = 1. / smlnum; |
| 12208 | dlabad_cxx . . $ dlabad_(4730c933dae9b326).(&smlnum, &bignum); |
| 12209 | |
| 12210 | /* Scale A if max entry outside range [SMLNUM,BIGNUM]. */ |
| 12211 | |
| 12212 | anrm = dlange_cxx . . $ dlange_(98d44e6417336f20).("M", m, n, &a[a_offset], lda, &work[1]); |
| 12213 | iascl = 0; |
| 12214 | if (anrm > 0. && anrm < smlnum) { |
| 12215 | |
| 12216 | /* Scale matrix norm up to SMLNUM. */ |
| 12217 | |
| 12218 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &anrm, &smlnum, m, n, &a[a_offset], lda, |
| 12219 | info); |
| 12220 | iascl = 1; |
| 12221 | } else if (anrm > bignum) { |
| 12222 | |
| 12223 | /* Scale matrix norm down to BIGNUM. */ |
| 12224 | |
| 12225 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &anrm, &bignum, m, n, &a[a_offset], lda, |
| 12226 | info); |
| 12227 | iascl = 2; |
| 12228 | } else if (anrm == 0.) { |
| 12229 | |
| 12230 | /* Matrix all zero. Return zero solution. */ |
| 12231 | |
| 12232 | i__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(*m,*n); |
| 12233 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("F", &i__1, nrhs, &c_b82, &c_b82, &b[b_offset], ldb); |
| 12234 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("F", &minmn, &c__1, &c_b82, &c_b82, &s[1], &c__1); |
| 12235 | *rank = 0; |
| 12236 | goto L10; |
| 12237 | } |
| 12238 | |
| 12239 | /* Scale B if max entry outside range [SMLNUM,BIGNUM]. */ |
| 12240 | |
| 12241 | bnrm = dlange_cxx . . $ dlange_(98d44e6417336f20).("M", m, nrhs, &b[b_offset], ldb, &work[1]); |
| 12242 | ibscl = 0; |
| 12243 | if (bnrm > 0. && bnrm < smlnum) { |
| 12244 | |
| 12245 | /* Scale matrix norm up to SMLNUM. */ |
| 12246 | |
| 12247 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &bnrm, &smlnum, m, nrhs, &b[b_offset], ldb, |
| 12248 | info); |
| 12249 | ibscl = 1; |
| 12250 | } else if (bnrm > bignum) { |
| 12251 | |
| 12252 | /* Scale matrix norm down to BIGNUM. */ |
| 12253 | |
| 12254 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &bnrm, &bignum, m, nrhs, &b[b_offset], ldb, |
| 12255 | info); |
| 12256 | ibscl = 2; |
| 12257 | } |
| 12258 | |
| 12259 | /* If M < N make sure certain entries of B are zero. */ |
| 12260 | |
| 12261 | if (*m < *n) { |
| 12262 | i__1 = *n - *m; |
| 12263 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("F", &i__1, nrhs, &c_b82, &c_b82, &b[*m + 1 + b_dim1], ldb); |
| 12264 | } |
| 12265 | |
| 12266 | /* Overdetermined case. */ |
| 12267 | |
| 12268 | if (*m >= *n) { |
| 12269 | |
| 12270 | /* Path 1 - overdetermined or exactly determined. */ |
| 12271 | |
| 12272 | mm = *m; |
| 12273 | if (*m >= mnthr) { |
| 12274 | |
| 12275 | /* Path 1a - overdetermined, with many more rows than columns. */ |
| 12276 | |
| 12277 | mm = *n; |
| 12278 | itau = 1; |
| 12279 | nwork = itau + *n; |
| 12280 | |
| 12281 | /* Compute A=Q*R. */ |
| 12282 | /* (Workspace: need 2*N, prefer N+N*NB) */ |
| 12283 | |
| 12284 | i__1 = *lwork - nwork + 1; |
| 12285 | dgeqrf_cxx . . $ dgeqrf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[itau], &work[nwork], &i__1, |
| 12286 | info); |
| 12287 | |
| 12288 | /* Multiply B by transpose(Q). */ |
| 12289 | /* (Workspace: need N+NRHS, prefer N+NRHS*NB) */ |
| 12290 | |
| 12291 | i__1 = *lwork - nwork + 1; |
| 12292 | dormqr_cxx . . $ dormqr_(c6b7238dd97e9cf9).("L", "T", m, nrhs, n, &a[a_offset], lda, &work[itau], &b[ |
| 12293 | b_offset], ldb, &work[nwork], &i__1, info); |
| 12294 | |
| 12295 | /* Zero out below R. */ |
| 12296 | |
| 12297 | if (*n > 1) { |
| 12298 | i__1 = *n - 1; |
| 12299 | i__2 = *n - 1; |
| 12300 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("L", &i__1, &i__2, &c_b82, &c_b82, &a[a_dim1 + 2], |
| 12301 | lda); |
| 12302 | } |
| 12303 | } |
| 12304 | |
| 12305 | ie = 1; |
| 12306 | itauq = ie + *n; |
| 12307 | itaup = itauq + *n; |
| 12308 | nwork = itaup + *n; |
| 12309 | |
| 12310 | /* Bidiagonalize R in A. */ |
| 12311 | /* (Workspace: need 3*N+MM, prefer 3*N+(MM+N)*NB) */ |
| 12312 | |
| 12313 | i__1 = *lwork - nwork + 1; |
| 12314 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(&mm, n, &a[a_offset], lda, &s[1], &work[ie], &work[itauq], & |
| 12315 | work[itaup], &work[nwork], &i__1, info); |
| 12316 | |
| 12317 | /* Multiply B by transpose of left bidiagonalizing vectors of R. */ |
| 12318 | /* (Workspace: need 3*N+NRHS, prefer 3*N+NRHS*NB) */ |
| 12319 | |
| 12320 | i__1 = *lwork - nwork + 1; |
| 12321 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("Q", "L", "T", &mm, nrhs, n, &a[a_offset], lda, &work[itauq], |
| 12322 | &b[b_offset], ldb, &work[nwork], &i__1, info); |
| 12323 | |
| 12324 | /* Solve the bidiagonal least squares problem. */ |
| 12325 | |
| 12326 | dlalsd_cxx . . $ dlalsd_(7271a4ac620fcaca).("U", &smlsiz, n, nrhs, &s[1], &work[ie], &b[b_offset], ldb, |
| 12327 | rcond, rank, &work[nwork], &iwork[1], info); |
| 12328 | if (*info != 0) { |
| 12329 | goto L10; |
| 12330 | } |
| 12331 | |
| 12332 | /* Multiply B by right bidiagonalizing vectors of R. */ |
| 12333 | |
| 12334 | i__1 = *lwork - nwork + 1; |
| 12335 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("P", "L", "N", n, nrhs, n, &a[a_offset], lda, &work[itaup], & |
| 12336 | b[b_offset], ldb, &work[nwork], &i__1, info); |
| 12337 | |
| 12338 | } else /* if(complicated condition) */ { |
| 12339 | /* Computing MAX */ |
| 12340 | i__1 = *m, i__2 = (*m << 1) - 4, i__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2), i__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).( |
| 12341 | i__1,*nrhs), i__2 = *n - *m * 3, i__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 12342 | if (*n >= mnthr && *lwork >= (*m << 2) + *m * *m + stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,wlalsd)) { |
| 12343 | |
| 12344 | /* Path 2a - underdetermined, with many more columns than rows */ |
| 12345 | /* and sufficient workspace for an efficient algorithm. */ |
| 12346 | |
| 12347 | ldwork = *m; |
| 12348 | /* Computing MAX */ |
| 12349 | /* Computing MAX */ |
| 12350 | i__3 = *m, i__4 = (*m << 1) - 4, i__3 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__3,i__4), i__3 = |
| 12351 | stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__3,*nrhs), i__4 = *n - *m * 3; |
| 12352 | i__1 = (*m << 2) + *m * *lda + stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__3,i__4), i__2 = *m * *lda + |
| 12353 | *m + *m * *nrhs, i__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2), i__2 = (*m << 2) |
| 12354 | + *m * *lda + wlalsd; |
| 12355 | if (*lwork >= stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2)) { |
| 12356 | ldwork = *lda; |
| 12357 | } |
| 12358 | itau = 1; |
| 12359 | nwork = *m + 1; |
| 12360 | |
| 12361 | /* Compute A=L*Q. */ |
| 12362 | /* (Workspace: need 2*M, prefer M+M*NB) */ |
| 12363 | |
| 12364 | i__1 = *lwork - nwork + 1; |
| 12365 | dgelqf_cxx . . $ dgelqf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[itau], &work[nwork], &i__1, |
| 12366 | info); |
| 12367 | il = nwork; |
| 12368 | |
| 12369 | /* Copy L to WORK(IL), zeroing out above its diagonal. */ |
| 12370 | |
| 12371 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("L", m, m, &a[a_offset], lda, &work[il], &ldwork); |
| 12372 | i__1 = *m - 1; |
| 12373 | i__2 = *m - 1; |
| 12374 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("U", &i__1, &i__2, &c_b82, &c_b82, &work[il + ldwork], & |
| 12375 | ldwork); |
| 12376 | ie = il + ldwork * *m; |
| 12377 | itauq = ie + *m; |
| 12378 | itaup = itauq + *m; |
| 12379 | nwork = itaup + *m; |
| 12380 | |
| 12381 | /* Bidiagonalize L in WORK(IL). */ |
| 12382 | /* (Workspace: need M*M+5*M, prefer M*M+4*M+2*M*NB) */ |
| 12383 | |
| 12384 | i__1 = *lwork - nwork + 1; |
| 12385 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(m, m, &work[il], &ldwork, &s[1], &work[ie], &work[itauq], |
| 12386 | &work[itaup], &work[nwork], &i__1, info); |
| 12387 | |
| 12388 | /* Multiply B by transpose of left bidiagonalizing vectors of L. */ |
| 12389 | /* (Workspace: need M*M+4*M+NRHS, prefer M*M+4*M+NRHS*NB) */ |
| 12390 | |
| 12391 | i__1 = *lwork - nwork + 1; |
| 12392 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("Q", "L", "T", m, nrhs, m, &work[il], &ldwork, &work[ |
| 12393 | itauq], &b[b_offset], ldb, &work[nwork], &i__1, info); |
| 12394 | |
| 12395 | /* Solve the bidiagonal least squares problem. */ |
| 12396 | |
| 12397 | dlalsd_cxx . . $ dlalsd_(7271a4ac620fcaca).("U", &smlsiz, m, nrhs, &s[1], &work[ie], &b[b_offset], |
| 12398 | ldb, rcond, rank, &work[nwork], &iwork[1], info); |
| 12399 | if (*info != 0) { |
| 12400 | goto L10; |
| 12401 | } |
| 12402 | |
| 12403 | /* Multiply B by right bidiagonalizing vectors of L. */ |
| 12404 | |
| 12405 | i__1 = *lwork - nwork + 1; |
| 12406 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("P", "L", "N", m, nrhs, m, &work[il], &ldwork, &work[ |
| 12407 | itaup], &b[b_offset], ldb, &work[nwork], &i__1, info); |
| 12408 | |
| 12409 | /* Zero out below first M rows of B. */ |
| 12410 | |
| 12411 | i__1 = *n - *m; |
| 12412 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("F", &i__1, nrhs, &c_b82, &c_b82, &b[*m + 1 + b_dim1], |
| 12413 | ldb); |
| 12414 | nwork = itau + *m; |
| 12415 | |
| 12416 | /* Multiply transpose(Q) by B. */ |
| 12417 | /* (Workspace: need M+NRHS, prefer M+NRHS*NB) */ |
| 12418 | |
| 12419 | i__1 = *lwork - nwork + 1; |
| 12420 | dormlq_cxx . . $ dormlq_(c6b7238dd97e9cf9).("L", "T", n, nrhs, m, &a[a_offset], lda, &work[itau], &b[ |
| 12421 | b_offset], ldb, &work[nwork], &i__1, info); |
| 12422 | |
| 12423 | } else { |
| 12424 | |
| 12425 | /* Path 2 - remaining underdetermined cases. */ |
| 12426 | |
| 12427 | ie = 1; |
| 12428 | itauq = ie + *m; |
| 12429 | itaup = itauq + *m; |
| 12430 | nwork = itaup + *m; |
| 12431 | |
| 12432 | /* Bidiagonalize A. */ |
| 12433 | /* (Workspace: need 3*M+N, prefer 3*M+(M+N)*NB) */ |
| 12434 | |
| 12435 | i__1 = *lwork - nwork + 1; |
| 12436 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(m, n, &a[a_offset], lda, &s[1], &work[ie], &work[itauq], & |
| 12437 | work[itaup], &work[nwork], &i__1, info); |
| 12438 | |
| 12439 | /* Multiply B by transpose of left bidiagonalizing vectors. */ |
| 12440 | /* (Workspace: need 3*M+NRHS, prefer 3*M+NRHS*NB) */ |
| 12441 | |
| 12442 | i__1 = *lwork - nwork + 1; |
| 12443 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("Q", "L", "T", m, nrhs, n, &a[a_offset], lda, &work[itauq] |
| 12444 | , &b[b_offset], ldb, &work[nwork], &i__1, info); |
| 12445 | |
| 12446 | /* Solve the bidiagonal least squares problem. */ |
| 12447 | |
| 12448 | dlalsd_cxx . . $ dlalsd_(7271a4ac620fcaca).("L", &smlsiz, m, nrhs, &s[1], &work[ie], &b[b_offset], |
| 12449 | ldb, rcond, rank, &work[nwork], &iwork[1], info); |
| 12450 | if (*info != 0) { |
| 12451 | goto L10; |
| 12452 | } |
| 12453 | |
| 12454 | /* Multiply B by right bidiagonalizing vectors of A. */ |
| 12455 | |
| 12456 | i__1 = *lwork - nwork + 1; |
| 12457 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("P", "L", "N", n, nrhs, m, &a[a_offset], lda, &work[itaup] |
| 12458 | , &b[b_offset], ldb, &work[nwork], &i__1, info); |
| 12459 | |
| 12460 | } |
| 12461 | } |
| 12462 | |
| 12463 | /* Undo scaling. */ |
| 12464 | |
| 12465 | if (iascl == 1) { |
| 12466 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &anrm, &smlnum, n, nrhs, &b[b_offset], ldb, |
| 12467 | info); |
| 12468 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &smlnum, &anrm, &minmn, &c__1, &s[1], & |
| 12469 | minmn, info); |
| 12470 | } else if (iascl == 2) { |
| 12471 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &anrm, &bignum, n, nrhs, &b[b_offset], ldb, |
| 12472 | info); |
| 12473 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &bignum, &anrm, &minmn, &c__1, &s[1], & |
| 12474 | minmn, info); |
| 12475 | } |
| 12476 | if (ibscl == 1) { |
| 12477 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &smlnum, &bnrm, n, nrhs, &b[b_offset], ldb, |
| 12478 | info); |
| 12479 | } else if (ibscl == 2) { |
| 12480 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &bignum, &bnrm, n, nrhs, &b[b_offset], ldb, |
| 12481 | info); |
| 12482 | } |
| 12483 | |
| 12484 | L10: |
| 12485 | work[1] = (double) maxwrk; |
| 12486 | return 0; |
| 12487 | |
| 12488 | /* End of DGELSD */ |
| 12489 | |
| 12490 | } /* dgelsd_ */ |
| 12491 | |
| 12492 | /* Subroutine */ int dgelss_cxx . . $ dgelss_(6fae9e25bc0ca40d).(integercxx . . $ integer# *m, integercxx . . $ integer# *n, integercxx . . $ integer# *nrhs, |
| 12493 | double *a, integercxx . . $ integer# *lda, double *b, integercxx . . $ integer# *ldb, double * |
| 12494 | s, double *rcond, integercxx . . $ integer# *rank, double *work, integercxx . . $ integer# *lwork, |
| 12495 | integercxx . . $ integer# *info) |
| 12496 | { |
| 12497 | /* Table of constant values */ |
| 12498 | static integercxx . . $ integer# c__6 = 6; |
| 12499 | static integercxx . . $ integer# c_n1 = -1; |
| 12500 | static integercxx . . $ integer# c__1 = 1; |
| 12501 | static integercxx . . $ integer# c__0 = 0; |
| 12502 | static double c_b74 = 0.; |
| 12503 | static double c_b108 = 1.; |
| 12504 | |
| 12505 | /* System generated locals */ |
| 12506 | integercxx . . $ integer# a_dim1, a_offset, b_dim1, b_offset, i__1, i__2, i__3, i__4; |
| 12507 | double d__1; |
| 12508 | |
| 12509 | /* Local variables */ |
| 12510 | integercxx . . $ integer# i__, bl, ie, il, mm; |
| 12511 | double eps, thr, anrm, bnrm; |
| 12512 | integercxx . . $ integer# itau; |
| 12513 | double vdum[1]; |
| 12514 | integercxx . . $ integer# iascl, ibscl; |
| 12515 | integercxx . . $ integer# chunk; |
| 12516 | double sfmin; |
| 12517 | integercxx . . $ integer# minmn; |
| 12518 | integercxx . . $ integer# maxmn, itaup, itauq, mnthr, iwork; |
| 12519 | integercxx . . $ integer# bdspac; |
| 12520 | double bignum; |
| 12521 | integercxx . . $ integer# ldwork; |
| 12522 | integercxx . . $ integer# minwrk, maxwrk; |
| 12523 | double smlnum; |
| 12524 | bool lquery; |
| 12525 | |
| 12526 | |
| 12527 | /* -- LAPACK driver routine (version 3.1) -- */ |
| 12528 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 12529 | /* November 2006 */ |
| 12530 | |
| 12531 | /* .. Scalar Arguments .. */ |
| 12532 | /* .. */ |
| 12533 | /* .. Array Arguments .. */ |
| 12534 | /* .. */ |
| 12535 | |
| 12536 | /* Purpose */ |
| 12537 | /* ======= */ |
| 12538 | |
| 12539 | /* DGELSS computes the minimum norm solution to a real linear least */ |
| 12540 | /* squares problem: */ |
| 12541 | |
| 12542 | /* Minimize 2-norm(| b - A*x |). */ |
| 12543 | |
| 12544 | /* using the singular value decomposition (SVD) of A. A is an M-by-N */ |
| 12545 | /* matrix which may be rank-deficient. */ |
| 12546 | |
| 12547 | /* Several right hand side vectors b and solution vectors x can be */ |
| 12548 | /* handled in a single call; they are stored as the columns of the */ |
| 12549 | /* M-by-NRHS right hand side matrix B and the N-by-NRHS solution matrix */ |
| 12550 | /* X. */ |
| 12551 | |
| 12552 | /* The effective rank of A is determined by treating as zero those */ |
| 12553 | /* singular values which are less than RCOND times the largest singular */ |
| 12554 | /* value. */ |
| 12555 | |
| 12556 | /* Arguments */ |
| 12557 | /* ========= */ |
| 12558 | |
| 12559 | /* M (input) INTEGER */ |
| 12560 | /* The number of rows of the matrix A. M >= 0. */ |
| 12561 | |
| 12562 | /* N (input) INTEGER */ |
| 12563 | /* The number of columns of the matrix A. N >= 0. */ |
| 12564 | |
| 12565 | /* NRHS (input) INTEGER */ |
| 12566 | /* The number of right hand sides, i.e., the number of columns */ |
| 12567 | /* of the matrices B and X. NRHS >= 0. */ |
| 12568 | |
| 12569 | /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 12570 | /* On entry, the M-by-N matrix A. */ |
| 12571 | /* On exit, the first min(m,n) rows of A are overwritten with */ |
| 12572 | /* its right singular vectors, stored rowwise. */ |
| 12573 | |
| 12574 | /* LDA (input) INTEGER */ |
| 12575 | /* The leading dimension of the array A. LDA >= max(1,M). */ |
| 12576 | |
| 12577 | /* B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */ |
| 12578 | /* On entry, the M-by-NRHS right hand side matrix B. */ |
| 12579 | /* On exit, B is overwritten by the N-by-NRHS solution */ |
| 12580 | /* matrix X. If m >= n and RANK = n, the residual */ |
| 12581 | /* sum-of-squares for the solution in the i-th column is given */ |
| 12582 | /* by the sum of squares of elements n+1:m in that column. */ |
| 12583 | |
| 12584 | /* LDB (input) INTEGER */ |
| 12585 | /* The leading dimension of the array B. LDB >= max(1,max(M,N)). */ |
| 12586 | |
| 12587 | /* S (output) DOUBLE PRECISION array, dimension (min(M,N)) */ |
| 12588 | /* The singular values of A in decreasing order. */ |
| 12589 | /* The condition number of A in the 2-norm = S(1)/S(min(m,n)). */ |
| 12590 | |
| 12591 | /* RCOND (input) DOUBLE PRECISION */ |
| 12592 | /* RCOND is used to determine the effective rank of A. */ |
| 12593 | /* Singular values S(i) <= RCOND*S(1) are treated as zero. */ |
| 12594 | /* If RCOND < 0, machine precision is used instead. */ |
| 12595 | |
| 12596 | /* RANK (output) INTEGER */ |
| 12597 | /* The effective rank of A, i.e., the number of singular values */ |
| 12598 | /* which are greater than RCOND*S(1). */ |
| 12599 | |
| 12600 | /* WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) */ |
| 12601 | /* On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ |
| 12602 | |
| 12603 | /* LWORK (input) INTEGER */ |
| 12604 | /* The dimension of the array WORK. LWORK >= 1, and also: */ |
| 12605 | /* LWORK >= 3*min(M,N) + max( 2*min(M,N), max(M,N), NRHS ) */ |
| 12606 | /* For good performance, LWORK should generally be larger. */ |
| 12607 | |
| 12608 | /* If LWORK = -1, then a workspace query is assumed; the routine */ |
| 12609 | /* only calculates the optimal size of the WORK array, returns */ |
| 12610 | /* this value as the first entry of the WORK array, and no error */ |
| 12611 | /* message related to LWORK is issued by XERBLA. */ |
| 12612 | |
| 12613 | /* INFO (output) INTEGER */ |
| 12614 | /* = 0: successful exit */ |
| 12615 | /* < 0: if INFO = -i, the i-th argument had an illegal value. */ |
| 12616 | /* > 0: the algorithm for computing the SVD failed to converge; */ |
| 12617 | /* if INFO = i, i off-diagonal elements of an intermediate */ |
| 12618 | /* bidiagonal form did not converge to zero. */ |
| 12619 | |
| 12620 | /* ===================================================================== */ |
| 12621 | |
| 12622 | /* .. Parameters .. */ |
| 12623 | /* .. */ |
| 12624 | /* .. Local Scalars .. */ |
| 12625 | /* .. */ |
| 12626 | /* .. Local Arrays .. */ |
| 12627 | /* .. */ |
| 12628 | /* .. External Subroutines .. */ |
| 12629 | /* .. */ |
| 12630 | /* .. External Functions .. */ |
| 12631 | /* .. */ |
| 12632 | /* .. Intrinsic Functions .. */ |
| 12633 | /* .. */ |
| 12634 | /* .. Executable Statements .. */ |
| 12635 | |
| 12636 | /* Test the input arguments */ |
| 12637 | |
| 12638 | /* Parameter adjustments */ |
| 12639 | a_dim1 = *lda; |
| 12640 | a_offset = 1 + a_dim1; |
| 12641 | a -= a_offset; |
| 12642 | b_dim1 = *ldb; |
| 12643 | b_offset = 1 + b_dim1; |
| 12644 | b -= b_offset; |
| 12645 | --s; |
| 12646 | --work; |
| 12647 | |
| 12648 | /* Function Body */ |
| 12649 | *info = 0; |
| 12650 | minmn = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(*m,*n); |
| 12651 | maxmn = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(*m,*n); |
| 12652 | lquery = *lwork == -1; |
| 12653 | if (*m < 0) { |
| 12654 | *info = -1; |
| 12655 | } else if (*n < 0) { |
| 12656 | *info = -2; |
| 12657 | } else if (*nrhs < 0) { |
| 12658 | *info = -3; |
| 12659 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*m)) { |
| 12660 | *info = -5; |
| 12661 | } else if (*ldb < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,maxmn)) { |
| 12662 | *info = -7; |
| 12663 | } |
| 12664 | |
| 12665 | /* Compute workspace */ |
| 12666 | /* (Note: Comments in the code beginning "Workspace:" describe the */ |
| 12667 | /* minimal amount of workspace needed at that point in the code, */ |
| 12668 | /* as well as the preferred amount for good performance. */ |
| 12669 | /* NB refers to the optimal block size for the immediately */ |
| 12670 | /* following subroutine, as returned by ILAENV.) */ |
| 12671 | |
| 12672 | if (*info == 0) { |
| 12673 | minwrk = 1; |
| 12674 | maxwrk = 1; |
| 12675 | if (minmn > 0) { |
| 12676 | mm = *m; |
| 12677 | mnthr = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__6, "DGELSS", " ", m, n, nrhs, &c_n1); |
| 12678 | if (*m >= *n && *m >= mnthr) { |
| 12679 | |
| 12680 | /* Path 1a - overdetermined, with many more rows than */ |
| 12681 | /* columns */ |
| 12682 | |
| 12683 | mm = *n; |
| 12684 | /* Computing MAX */ |
| 12685 | i__1 = maxwrk, i__2 = *n + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEQRF", |
| 12686 | " ", m, n, &c_n1, &c_n1); |
| 12687 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 12688 | /* Computing MAX */ |
| 12689 | i__1 = maxwrk, i__2 = *n + *nrhs * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMQR", |
| 12690 | "LT", m, nrhs, n, &c_n1); |
| 12691 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 12692 | } |
| 12693 | if (*m >= *n) { |
| 12694 | |
| 12695 | /* Path 1 - overdetermined or exactly determined */ |
| 12696 | |
| 12697 | /* Compute workspace needed for DBDSQR */ |
| 12698 | |
| 12699 | /* Computing MAX */ |
| 12700 | i__1 = 1, i__2 = *n * 5; |
| 12701 | bdspac = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 12702 | /* Computing MAX */ |
| 12703 | i__1 = maxwrk, i__2 = *n * 3 + (mm + *n) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 12704 | "DGEBRD", " ", &mm, n, &c_n1, &c_n1); |
| 12705 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 12706 | /* Computing MAX */ |
| 12707 | i__1 = maxwrk, i__2 = *n * 3 + *nrhs * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMBR" |
| 12708 | , "QLT", &mm, nrhs, n, &c_n1); |
| 12709 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 12710 | /* Computing MAX */ |
| 12711 | i__1 = maxwrk, i__2 = *n * 3 + (*n - 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 12712 | "DORGBR", "P", n, n, n, &c_n1); |
| 12713 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 12714 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(maxwrk,bdspac); |
| 12715 | /* Computing MAX */ |
| 12716 | i__1 = maxwrk, i__2 = *n * *nrhs; |
| 12717 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 12718 | /* Computing MAX */ |
| 12719 | i__1 = *n * 3 + mm, i__2 = *n * 3 + *nrhs, i__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1, |
| 12720 | i__2); |
| 12721 | minwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,bdspac); |
| 12722 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(minwrk,maxwrk); |
| 12723 | } |
| 12724 | if (*n > *m) { |
| 12725 | |
| 12726 | /* Compute workspace needed for DBDSQR */ |
| 12727 | |
| 12728 | /* Computing MAX */ |
| 12729 | i__1 = 1, i__2 = *m * 5; |
| 12730 | bdspac = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 12731 | /* Computing MAX */ |
| 12732 | i__1 = *m * 3 + *nrhs, i__2 = *m * 3 + *n, i__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1, |
| 12733 | i__2); |
| 12734 | minwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,bdspac); |
| 12735 | if (*n >= mnthr) { |
| 12736 | |
| 12737 | /* Path 2a - underdetermined, with many more columns */ |
| 12738 | /* than rows */ |
| 12739 | |
| 12740 | maxwrk = *m + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGELQF", " ", m, n, & |
| 12741 | c_n1, &c_n1); |
| 12742 | /* Computing MAX */ |
| 12743 | i__1 = maxwrk, i__2 = *m * *m + (*m << 2) + (*m << 1) * |
| 12744 | ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEBRD", " ", m, m, &c_n1, &c_n1); |
| 12745 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 12746 | /* Computing MAX */ |
| 12747 | i__1 = maxwrk, i__2 = *m * *m + (*m << 2) + *nrhs * |
| 12748 | ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMBR", "QLT", m, nrhs, m, &c_n1); |
| 12749 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 12750 | /* Computing MAX */ |
| 12751 | i__1 = maxwrk, i__2 = *m * *m + (*m << 2) + (*m - 1) * |
| 12752 | ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORGBR", "P", m, m, m, &c_n1); |
| 12753 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 12754 | /* Computing MAX */ |
| 12755 | i__1 = maxwrk, i__2 = *m * *m + *m + bdspac; |
| 12756 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 12757 | if (*nrhs > 1) { |
| 12758 | /* Computing MAX */ |
| 12759 | i__1 = maxwrk, i__2 = *m * *m + *m + *m * *nrhs; |
| 12760 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 12761 | } else { |
| 12762 | /* Computing MAX */ |
| 12763 | i__1 = maxwrk, i__2 = *m * *m + (*m << 1); |
| 12764 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 12765 | } |
| 12766 | /* Computing MAX */ |
| 12767 | i__1 = maxwrk, i__2 = *m + *nrhs * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMLQ" |
| 12768 | , "LT", n, nrhs, m, &c_n1); |
| 12769 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 12770 | } else { |
| 12771 | |
| 12772 | /* Path 2 - underdetermined */ |
| 12773 | |
| 12774 | maxwrk = *m * 3 + (*n + *m) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEBRD", |
| 12775 | " ", m, n, &c_n1, &c_n1); |
| 12776 | /* Computing MAX */ |
| 12777 | i__1 = maxwrk, i__2 = *m * 3 + *nrhs * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 12778 | "DORMBR", "QLT", m, nrhs, m, &c_n1); |
| 12779 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 12780 | /* Computing MAX */ |
| 12781 | i__1 = maxwrk, i__2 = *m * 3 + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORG" |
| 12782 | "BR", "P", m, n, m, &c_n1); |
| 12783 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 12784 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(maxwrk,bdspac); |
| 12785 | /* Computing MAX */ |
| 12786 | i__1 = maxwrk, i__2 = *n * *nrhs; |
| 12787 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 12788 | } |
| 12789 | } |
| 12790 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(minwrk,maxwrk); |
| 12791 | } |
| 12792 | work[1] = (double) maxwrk; |
| 12793 | |
| 12794 | if (*lwork < minwrk && ! lquery) { |
| 12795 | *info = -12; |
| 12796 | } |
| 12797 | } |
| 12798 | |
| 12799 | if (*info != 0) { |
| 12800 | i__1 = -(*info); |
| 12801 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGELSS", &i__1); |
| 12802 | return 0; |
| 12803 | } else if (lquery) { |
| 12804 | return 0; |
| 12805 | } |
| 12806 | |
| 12807 | /* Quick return if possible */ |
| 12808 | |
| 12809 | if (*m == 0 || *n == 0) { |
| 12810 | *rank = 0; |
| 12811 | return 0; |
| 12812 | } |
| 12813 | |
| 12814 | /* Get machine parameters */ |
| 12815 | |
| 12816 | eps = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("P"); |
| 12817 | sfmin = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("S"); |
| 12818 | smlnum = sfmin / eps; |
| 12819 | bignum = 1. / smlnum; |
| 12820 | dlabad_cxx . . $ dlabad_(4730c933dae9b326).(&smlnum, &bignum); |
| 12821 | |
| 12822 | /* Scale A if max element outside range [SMLNUM,BIGNUM] */ |
| 12823 | |
| 12824 | anrm = dlange_cxx . . $ dlange_(98d44e6417336f20).("M", m, n, &a[a_offset], lda, &work[1]); |
| 12825 | iascl = 0; |
| 12826 | if (anrm > 0. && anrm < smlnum) { |
| 12827 | |
| 12828 | /* Scale matrix norm up to SMLNUM */ |
| 12829 | |
| 12830 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &anrm, &smlnum, m, n, &a[a_offset], lda, |
| 12831 | info); |
| 12832 | iascl = 1; |
| 12833 | } else if (anrm > bignum) { |
| 12834 | |
| 12835 | /* Scale matrix norm down to BIGNUM */ |
| 12836 | |
| 12837 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &anrm, &bignum, m, n, &a[a_offset], lda, |
| 12838 | info); |
| 12839 | iascl = 2; |
| 12840 | } else if (anrm == 0.) { |
| 12841 | |
| 12842 | /* Matrix all zero. Return zero solution. */ |
| 12843 | |
| 12844 | i__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(*m,*n); |
| 12845 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("F", &i__1, nrhs, &c_b74, &c_b74, &b[b_offset], ldb); |
| 12846 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("F", &minmn, &c__1, &c_b74, &c_b74, &s[1], &c__1); |
| 12847 | *rank = 0; |
| 12848 | goto L70; |
| 12849 | } |
| 12850 | |
| 12851 | /* Scale B if max element outside range [SMLNUM,BIGNUM] */ |
| 12852 | |
| 12853 | bnrm = dlange_cxx . . $ dlange_(98d44e6417336f20).("M", m, nrhs, &b[b_offset], ldb, &work[1]); |
| 12854 | ibscl = 0; |
| 12855 | if (bnrm > 0. && bnrm < smlnum) { |
| 12856 | |
| 12857 | /* Scale matrix norm up to SMLNUM */ |
| 12858 | |
| 12859 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &bnrm, &smlnum, m, nrhs, &b[b_offset], ldb, |
| 12860 | info); |
| 12861 | ibscl = 1; |
| 12862 | } else if (bnrm > bignum) { |
| 12863 | |
| 12864 | /* Scale matrix norm down to BIGNUM */ |
| 12865 | |
| 12866 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &bnrm, &bignum, m, nrhs, &b[b_offset], ldb, |
| 12867 | info); |
| 12868 | ibscl = 2; |
| 12869 | } |
| 12870 | |
| 12871 | /* Overdetermined case */ |
| 12872 | |
| 12873 | if (*m >= *n) { |
| 12874 | |
| 12875 | /* Path 1 - overdetermined or exactly determined */ |
| 12876 | |
| 12877 | mm = *m; |
| 12878 | if (*m >= mnthr) { |
| 12879 | |
| 12880 | /* Path 1a - overdetermined, with many more rows than columns */ |
| 12881 | |
| 12882 | mm = *n; |
| 12883 | itau = 1; |
| 12884 | iwork = itau + *n; |
| 12885 | |
| 12886 | /* Compute A=Q*R */ |
| 12887 | /* (Workspace: need 2*N, prefer N+N*NB) */ |
| 12888 | |
| 12889 | i__1 = *lwork - iwork + 1; |
| 12890 | dgeqrf_cxx . . $ dgeqrf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[itau], &work[iwork], &i__1, |
| 12891 | info); |
| 12892 | |
| 12893 | /* Multiply B by transpose(Q) */ |
| 12894 | /* (Workspace: need N+NRHS, prefer N+NRHS*NB) */ |
| 12895 | |
| 12896 | i__1 = *lwork - iwork + 1; |
| 12897 | dormqr_cxx . . $ dormqr_(c6b7238dd97e9cf9).("L", "T", m, nrhs, n, &a[a_offset], lda, &work[itau], &b[ |
| 12898 | b_offset], ldb, &work[iwork], &i__1, info); |
| 12899 | |
| 12900 | /* Zero out below R */ |
| 12901 | |
| 12902 | if (*n > 1) { |
| 12903 | i__1 = *n - 1; |
| 12904 | i__2 = *n - 1; |
| 12905 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("L", &i__1, &i__2, &c_b74, &c_b74, &a[a_dim1 + 2], |
| 12906 | lda); |
| 12907 | } |
| 12908 | } |
| 12909 | |
| 12910 | ie = 1; |
| 12911 | itauq = ie + *n; |
| 12912 | itaup = itauq + *n; |
| 12913 | iwork = itaup + *n; |
| 12914 | |
| 12915 | /* Bidiagonalize R in A */ |
| 12916 | /* (Workspace: need 3*N+MM, prefer 3*N+(MM+N)*NB) */ |
| 12917 | |
| 12918 | i__1 = *lwork - iwork + 1; |
| 12919 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(&mm, n, &a[a_offset], lda, &s[1], &work[ie], &work[itauq], & |
| 12920 | work[itaup], &work[iwork], &i__1, info); |
| 12921 | |
| 12922 | /* Multiply B by transpose of left bidiagonalizing vectors of R */ |
| 12923 | /* (Workspace: need 3*N+NRHS, prefer 3*N+NRHS*NB) */ |
| 12924 | |
| 12925 | i__1 = *lwork - iwork + 1; |
| 12926 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("Q", "L", "T", &mm, nrhs, n, &a[a_offset], lda, &work[itauq], |
| 12927 | &b[b_offset], ldb, &work[iwork], &i__1, info); |
| 12928 | |
| 12929 | /* Generate right bidiagonalizing vectors of R in A */ |
| 12930 | /* (Workspace: need 4*N-1, prefer 3*N+(N-1)*NB) */ |
| 12931 | |
| 12932 | i__1 = *lwork - iwork + 1; |
| 12933 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("P", n, n, n, &a[a_offset], lda, &work[itaup], &work[iwork], & |
| 12934 | i__1, info); |
| 12935 | iwork = ie + *n; |
| 12936 | |
| 12937 | /* Perform bidiagonal QR iteration */ |
| 12938 | /* multiply B by transpose of left singular vectors */ |
| 12939 | /* compute right singular vectors in A */ |
| 12940 | /* (Workspace: need BDSPAC) */ |
| 12941 | |
| 12942 | dbdsqr_cxx . . $ dbdsqr_(d6d10c27a7b3c412).("U", n, n, &c__0, nrhs, &s[1], &work[ie], &a[a_offset], lda, |
| 12943 | vdum, &c__1, &b[b_offset], ldb, &work[iwork], info) |
| 12944 | ; |
| 12945 | if (*info != 0) { |
| 12946 | goto L70; |
| 12947 | } |
| 12948 | |
| 12949 | /* Multiply B by reciprocals of singular values */ |
| 12950 | |
| 12951 | /* Computing MAX */ |
| 12952 | d__1 = *rcond * s[1]; |
| 12953 | thr = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__1,sfmin); |
| 12954 | if (*rcond < 0.) { |
| 12955 | /* Computing MAX */ |
| 12956 | d__1 = eps * s[1]; |
| 12957 | thr = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__1,sfmin); |
| 12958 | } |
| 12959 | *rank = 0; |
| 12960 | i__1 = *n; |
| 12961 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 12962 | if (s[i__] > thr) { |
| 12963 | drscl_cxx . . $ drscl_(f22c1db71784c345).(nrhs, &s[i__], &b[i__ + b_dim1], ldb); |
| 12964 | ++(*rank); |
| 12965 | } else { |
| 12966 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("F", &c__1, nrhs, &c_b74, &c_b74, &b[i__ + b_dim1], |
| 12967 | ldb); |
| 12968 | } |
| 12969 | /* L10: */ |
| 12970 | } |
| 12971 | |
| 12972 | /* Multiply B by right singular vectors */ |
| 12973 | /* (Workspace: need N, prefer N*NRHS) */ |
| 12974 | |
| 12975 | if (*lwork >= *ldb * *nrhs && *nrhs > 1) { |
| 12976 | dgemm_cxx . . $ dgemm_(7f9a15c7502022ea).("T", "N", n, nrhs, n, &c_b108, &a[a_offset], lda, &b[ |
| 12977 | b_offset], ldb, &c_b74, &work[1], ldb); |
| 12978 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("G", n, nrhs, &work[1], ldb, &b[b_offset], ldb) |
| 12979 | ; |
| 12980 | } else if (*nrhs > 1) { |
| 12981 | chunk = *lwork / *n; |
| 12982 | i__1 = *nrhs; |
| 12983 | i__2 = chunk; |
| 12984 | for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) { |
| 12985 | /* Computing MIN */ |
| 12986 | i__3 = *nrhs - i__ + 1; |
| 12987 | bl = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__3,chunk); |
| 12988 | dgemm_cxx . . $ dgemm_(7f9a15c7502022ea).("T", "N", n, &bl, n, &c_b108, &a[a_offset], lda, &b[ |
| 12989 | i__ * b_dim1 + 1], ldb, &c_b74, &work[1], n); |
| 12990 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("G", n, &bl, &work[1], n, &b[i__ * b_dim1 + 1], ldb); |
| 12991 | /* L20: */ |
| 12992 | } |
| 12993 | } else { |
| 12994 | dgemv_cxx . . $ dgemv_(828a5131add94649).("T", n, n, &c_b108, &a[a_offset], lda, &b[b_offset], &c__1, |
| 12995 | &c_b74, &work[1], &c__1); |
| 12996 | dcopy_cxx . . $ dcopy_(ec261fd7ec3b6bf6).(n, &work[1], &c__1, &b[b_offset], &c__1); |
| 12997 | } |
| 12998 | |
| 12999 | } else /* if(complicated condition) */ { |
| 13000 | /* Computing MAX */ |
| 13001 | i__2 = *m, i__1 = (*m << 1) - 4, i__2 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__1), i__2 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).( |
| 13002 | i__2,*nrhs), i__1 = *n - *m * 3; |
| 13003 | if (*n >= mnthr && *lwork >= (*m << 2) + *m * *m + stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__1)) { |
| 13004 | |
| 13005 | /* Path 2a - underdetermined, with many more columns than rows */ |
| 13006 | /* and sufficient workspace for an efficient algorithm */ |
| 13007 | |
| 13008 | ldwork = *m; |
| 13009 | /* Computing MAX */ |
| 13010 | /* Computing MAX */ |
| 13011 | i__3 = *m, i__4 = (*m << 1) - 4, i__3 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__3,i__4), i__3 = |
| 13012 | stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__3,*nrhs), i__4 = *n - *m * 3; |
| 13013 | i__2 = (*m << 2) + *m * *lda + stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__3,i__4), i__1 = *m * *lda + |
| 13014 | *m + *m * *nrhs; |
| 13015 | if (*lwork >= stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__1)) { |
| 13016 | ldwork = *lda; |
| 13017 | } |
| 13018 | itau = 1; |
| 13019 | iwork = *m + 1; |
| 13020 | |
| 13021 | /* Compute A=L*Q */ |
| 13022 | /* (Workspace: need 2*M, prefer M+M*NB) */ |
| 13023 | |
| 13024 | i__2 = *lwork - iwork + 1; |
| 13025 | dgelqf_cxx . . $ dgelqf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[itau], &work[iwork], &i__2, |
| 13026 | info); |
| 13027 | il = iwork; |
| 13028 | |
| 13029 | /* Copy L to WORK(IL), zeroing out above it */ |
| 13030 | |
| 13031 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("L", m, m, &a[a_offset], lda, &work[il], &ldwork); |
| 13032 | i__2 = *m - 1; |
| 13033 | i__1 = *m - 1; |
| 13034 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("U", &i__2, &i__1, &c_b74, &c_b74, &work[il + ldwork], & |
| 13035 | ldwork); |
| 13036 | ie = il + ldwork * *m; |
| 13037 | itauq = ie + *m; |
| 13038 | itaup = itauq + *m; |
| 13039 | iwork = itaup + *m; |
| 13040 | |
| 13041 | /* Bidiagonalize L in WORK(IL) */ |
| 13042 | /* (Workspace: need M*M+5*M, prefer M*M+4*M+2*M*NB) */ |
| 13043 | |
| 13044 | i__2 = *lwork - iwork + 1; |
| 13045 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(m, m, &work[il], &ldwork, &s[1], &work[ie], &work[itauq], |
| 13046 | &work[itaup], &work[iwork], &i__2, info); |
| 13047 | |
| 13048 | /* Multiply B by transpose of left bidiagonalizing vectors of L */ |
| 13049 | /* (Workspace: need M*M+4*M+NRHS, prefer M*M+4*M+NRHS*NB) */ |
| 13050 | |
| 13051 | i__2 = *lwork - iwork + 1; |
| 13052 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("Q", "L", "T", m, nrhs, m, &work[il], &ldwork, &work[ |
| 13053 | itauq], &b[b_offset], ldb, &work[iwork], &i__2, info); |
| 13054 | |
| 13055 | /* Generate right bidiagonalizing vectors of R in WORK(IL) */ |
| 13056 | /* (Workspace: need M*M+5*M-1, prefer M*M+4*M+(M-1)*NB) */ |
| 13057 | |
| 13058 | i__2 = *lwork - iwork + 1; |
| 13059 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("P", m, m, m, &work[il], &ldwork, &work[itaup], &work[ |
| 13060 | iwork], &i__2, info); |
| 13061 | iwork = ie + *m; |
| 13062 | |
| 13063 | /* Perform bidiagonal QR iteration, */ |
| 13064 | /* computing right singular vectors of L in WORK(IL) and */ |
| 13065 | /* multiplying B by transpose of left singular vectors */ |
| 13066 | /* (Workspace: need M*M+M+BDSPAC) */ |
| 13067 | |
| 13068 | dbdsqr_cxx . . $ dbdsqr_(d6d10c27a7b3c412).("U", m, m, &c__0, nrhs, &s[1], &work[ie], &work[il], & |
| 13069 | ldwork, &a[a_offset], lda, &b[b_offset], ldb, &work[iwork] |
| 13070 | , info); |
| 13071 | if (*info != 0) { |
| 13072 | goto L70; |
| 13073 | } |
| 13074 | |
| 13075 | /* Multiply B by reciprocals of singular values */ |
| 13076 | |
| 13077 | /* Computing MAX */ |
| 13078 | d__1 = *rcond * s[1]; |
| 13079 | thr = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__1,sfmin); |
| 13080 | if (*rcond < 0.) { |
| 13081 | /* Computing MAX */ |
| 13082 | d__1 = eps * s[1]; |
| 13083 | thr = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__1,sfmin); |
| 13084 | } |
| 13085 | *rank = 0; |
| 13086 | i__2 = *m; |
| 13087 | for (i__ = 1; i__ <= i__2; ++i__) { |
| 13088 | if (s[i__] > thr) { |
| 13089 | drscl_cxx . . $ drscl_(f22c1db71784c345).(nrhs, &s[i__], &b[i__ + b_dim1], ldb); |
| 13090 | ++(*rank); |
| 13091 | } else { |
| 13092 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("F", &c__1, nrhs, &c_b74, &c_b74, &b[i__ + b_dim1] |
| 13093 | , ldb); |
| 13094 | } |
| 13095 | /* L30: */ |
| 13096 | } |
| 13097 | iwork = ie; |
| 13098 | |
| 13099 | /* Multiply B by right singular vectors of L in WORK(IL) */ |
| 13100 | /* (Workspace: need M*M+2*M, prefer M*M+M+M*NRHS) */ |
| 13101 | |
| 13102 | if (*lwork >= *ldb * *nrhs + iwork - 1 && *nrhs > 1) { |
| 13103 | dgemm_cxx . . $ dgemm_(7f9a15c7502022ea).("T", "N", m, nrhs, m, &c_b108, &work[il], &ldwork, &b[ |
| 13104 | b_offset], ldb, &c_b74, &work[iwork], ldb); |
| 13105 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("G", m, nrhs, &work[iwork], ldb, &b[b_offset], ldb); |
| 13106 | } else if (*nrhs > 1) { |
| 13107 | chunk = (*lwork - iwork + 1) / *m; |
| 13108 | i__2 = *nrhs; |
| 13109 | i__1 = chunk; |
| 13110 | for (i__ = 1; i__1 < 0 ? i__ >= i__2 : i__ <= i__2; i__ += |
| 13111 | i__1) { |
| 13112 | /* Computing MIN */ |
| 13113 | i__3 = *nrhs - i__ + 1; |
| 13114 | bl = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__3,chunk); |
| 13115 | dgemm_cxx . . $ dgemm_(7f9a15c7502022ea).("T", "N", m, &bl, m, &c_b108, &work[il], &ldwork, & |
| 13116 | b[i__ * b_dim1 + 1], ldb, &c_b74, &work[iwork], m); |
| 13117 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("G", m, &bl, &work[iwork], m, &b[i__ * b_dim1 + 1] |
| 13118 | , ldb); |
| 13119 | /* L40: */ |
| 13120 | } |
| 13121 | } else { |
| 13122 | dgemv_cxx . . $ dgemv_(828a5131add94649).("T", m, m, &c_b108, &work[il], &ldwork, &b[b_dim1 + 1], |
| 13123 | &c__1, &c_b74, &work[iwork], &c__1); |
| 13124 | dcopy_cxx . . $ dcopy_(ec261fd7ec3b6bf6).(m, &work[iwork], &c__1, &b[b_dim1 + 1], &c__1); |
| 13125 | } |
| 13126 | |
| 13127 | /* Zero out below first M rows of B */ |
| 13128 | |
| 13129 | i__1 = *n - *m; |
| 13130 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("F", &i__1, nrhs, &c_b74, &c_b74, &b[*m + 1 + b_dim1], |
| 13131 | ldb); |
| 13132 | iwork = itau + *m; |
| 13133 | |
| 13134 | /* Multiply transpose(Q) by B */ |
| 13135 | /* (Workspace: need M+NRHS, prefer M+NRHS*NB) */ |
| 13136 | |
| 13137 | i__1 = *lwork - iwork + 1; |
| 13138 | dormlq_cxx . . $ dormlq_(c6b7238dd97e9cf9).("L", "T", n, nrhs, m, &a[a_offset], lda, &work[itau], &b[ |
| 13139 | b_offset], ldb, &work[iwork], &i__1, info); |
| 13140 | |
| 13141 | } else { |
| 13142 | |
| 13143 | /* Path 2 - remaining underdetermined cases */ |
| 13144 | |
| 13145 | ie = 1; |
| 13146 | itauq = ie + *m; |
| 13147 | itaup = itauq + *m; |
| 13148 | iwork = itaup + *m; |
| 13149 | |
| 13150 | /* Bidiagonalize A */ |
| 13151 | /* (Workspace: need 3*M+N, prefer 3*M+(M+N)*NB) */ |
| 13152 | |
| 13153 | i__1 = *lwork - iwork + 1; |
| 13154 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(m, n, &a[a_offset], lda, &s[1], &work[ie], &work[itauq], & |
| 13155 | work[itaup], &work[iwork], &i__1, info); |
| 13156 | |
| 13157 | /* Multiply B by transpose of left bidiagonalizing vectors */ |
| 13158 | /* (Workspace: need 3*M+NRHS, prefer 3*M+NRHS*NB) */ |
| 13159 | |
| 13160 | i__1 = *lwork - iwork + 1; |
| 13161 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("Q", "L", "T", m, nrhs, n, &a[a_offset], lda, &work[itauq] |
| 13162 | , &b[b_offset], ldb, &work[iwork], &i__1, info); |
| 13163 | |
| 13164 | /* Generate right bidiagonalizing vectors in A */ |
| 13165 | /* (Workspace: need 4*M, prefer 3*M+M*NB) */ |
| 13166 | |
| 13167 | i__1 = *lwork - iwork + 1; |
| 13168 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("P", m, n, m, &a[a_offset], lda, &work[itaup], &work[ |
| 13169 | iwork], &i__1, info); |
| 13170 | iwork = ie + *m; |
| 13171 | |
| 13172 | /* Perform bidiagonal QR iteration, */ |
| 13173 | /* computing right singular vectors of A in A and */ |
| 13174 | /* multiplying B by transpose of left singular vectors */ |
| 13175 | /* (Workspace: need BDSPAC) */ |
| 13176 | |
| 13177 | dbdsqr_cxx . . $ dbdsqr_(d6d10c27a7b3c412).("L", m, n, &c__0, nrhs, &s[1], &work[ie], &a[a_offset], |
| 13178 | lda, vdum, &c__1, &b[b_offset], ldb, &work[iwork], info); |
| 13179 | if (*info != 0) { |
| 13180 | goto L70; |
| 13181 | } |
| 13182 | |
| 13183 | /* Multiply B by reciprocals of singular values */ |
| 13184 | |
| 13185 | /* Computing MAX */ |
| 13186 | d__1 = *rcond * s[1]; |
| 13187 | thr = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__1,sfmin); |
| 13188 | if (*rcond < 0.) { |
| 13189 | /* Computing MAX */ |
| 13190 | d__1 = eps * s[1]; |
| 13191 | thr = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__1,sfmin); |
| 13192 | } |
| 13193 | *rank = 0; |
| 13194 | i__1 = *m; |
| 13195 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 13196 | if (s[i__] > thr) { |
| 13197 | drscl_cxx . . $ drscl_(f22c1db71784c345).(nrhs, &s[i__], &b[i__ + b_dim1], ldb); |
| 13198 | ++(*rank); |
| 13199 | } else { |
| 13200 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("F", &c__1, nrhs, &c_b74, &c_b74, &b[i__ + b_dim1] |
| 13201 | , ldb); |
| 13202 | } |
| 13203 | /* L50: */ |
| 13204 | } |
| 13205 | |
| 13206 | /* Multiply B by right singular vectors of A */ |
| 13207 | /* (Workspace: need N, prefer N*NRHS) */ |
| 13208 | |
| 13209 | if (*lwork >= *ldb * *nrhs && *nrhs > 1) { |
| 13210 | dgemm_cxx . . $ dgemm_(7f9a15c7502022ea).("T", "N", n, nrhs, m, &c_b108, &a[a_offset], lda, &b[ |
| 13211 | b_offset], ldb, &c_b74, &work[1], ldb); |
| 13212 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("F", n, nrhs, &work[1], ldb, &b[b_offset], ldb); |
| 13213 | } else if (*nrhs > 1) { |
| 13214 | chunk = *lwork / *n; |
| 13215 | i__1 = *nrhs; |
| 13216 | i__2 = chunk; |
| 13217 | for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += |
| 13218 | i__2) { |
| 13219 | /* Computing MIN */ |
| 13220 | i__3 = *nrhs - i__ + 1; |
| 13221 | bl = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__3,chunk); |
| 13222 | dgemm_cxx . . $ dgemm_(7f9a15c7502022ea).("T", "N", n, &bl, m, &c_b108, &a[a_offset], lda, & |
| 13223 | b[i__ * b_dim1 + 1], ldb, &c_b74, &work[1], n); |
| 13224 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("F", n, &bl, &work[1], n, &b[i__ * b_dim1 + 1], |
| 13225 | ldb); |
| 13226 | /* L60: */ |
| 13227 | } |
| 13228 | } else { |
| 13229 | dgemv_cxx . . $ dgemv_(828a5131add94649).("T", m, n, &c_b108, &a[a_offset], lda, &b[b_offset], & |
| 13230 | c__1, &c_b74, &work[1], &c__1); |
| 13231 | dcopy_cxx . . $ dcopy_(ec261fd7ec3b6bf6).(n, &work[1], &c__1, &b[b_offset], &c__1); |
| 13232 | } |
| 13233 | } |
| 13234 | } |
| 13235 | |
| 13236 | /* Undo scaling */ |
| 13237 | |
| 13238 | if (iascl == 1) { |
| 13239 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &anrm, &smlnum, n, nrhs, &b[b_offset], ldb, |
| 13240 | info); |
| 13241 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &smlnum, &anrm, &minmn, &c__1, &s[1], & |
| 13242 | minmn, info); |
| 13243 | } else if (iascl == 2) { |
| 13244 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &anrm, &bignum, n, nrhs, &b[b_offset], ldb, |
| 13245 | info); |
| 13246 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &bignum, &anrm, &minmn, &c__1, &s[1], & |
| 13247 | minmn, info); |
| 13248 | } |
| 13249 | if (ibscl == 1) { |
| 13250 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &smlnum, &bnrm, n, nrhs, &b[b_offset], ldb, |
| 13251 | info); |
| 13252 | } else if (ibscl == 2) { |
| 13253 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &bignum, &bnrm, n, nrhs, &b[b_offset], ldb, |
| 13254 | info); |
| 13255 | } |
| 13256 | |
| 13257 | L70: |
| 13258 | work[1] = (double) maxwrk; |
| 13259 | return 0; |
| 13260 | |
| 13261 | /* End of DGELSS */ |
| 13262 | |
| 13263 | } /* dgelss_ */ |
| 13264 | |
| 13265 | /* Subroutine */ int dgelsx_cxx . . $ dgelsx_(5de4042eec0b1d60).(integercxx . . $ integer# *m, integercxx . . $ integer# *n, integercxx . . $ integer# *nrhs, |
| 13266 | double *a, integercxx . . $ integer# *lda, double *b, integercxx . . $ integer# *ldb, integercxx . . $ integer# * |
| 13267 | jpvt, double *rcond, integercxx . . $ integer# *rank, double *work, integercxx . . $ integer# * |
| 13268 | info) |
| 13269 | { |
| 13270 | /* Table of constant values */ |
| 13271 | static integercxx . . $ integer# c__0 = 0; |
| 13272 | static double c_b13 = 0.; |
| 13273 | static integercxx . . $ integer# c__2 = 2; |
| 13274 | static integercxx . . $ integer# c__1 = 1; |
| 13275 | static double c_b36 = 1.; |
| 13276 | |
| 13277 | /* System generated locals */ |
| 13278 | integercxx . . $ integer# a_dim1, a_offset, b_dim1, b_offset, i__1, i__2; |
| 13279 | double d__1; |
| 13280 | |
| 13281 | /* Local variables */ |
| 13282 | integercxx . . $ integer# i__, j, k; |
| 13283 | double c1, c2, s1, s2, t1, t2; |
| 13284 | integercxx . . $ integer# mn; |
| 13285 | double anrm, bnrm, smin, smax; |
| 13286 | integercxx . . $ integer# iascl, ibscl, ismin, ismax; |
| 13287 | double bignum; |
| 13288 | double sminpr, smaxpr, smlnum; |
| 13289 | |
| 13290 | |
| 13291 | /* -- LAPACK driver routine (version 3.1) -- */ |
| 13292 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 13293 | /* November 2006 */ |
| 13294 | |
| 13295 | /* .. Scalar Arguments .. */ |
| 13296 | /* .. */ |
| 13297 | /* .. Array Arguments .. */ |
| 13298 | /* .. */ |
| 13299 | |
| 13300 | /* Purpose */ |
| 13301 | /* ======= */ |
| 13302 | |
| 13303 | /* This routine is deprecated and has been replaced by routine DGELSY. */ |
| 13304 | |
| 13305 | /* DGELSX computes the minimum-norm solution to a real linear least */ |
| 13306 | /* squares problem: */ |
| 13307 | /* minimize || A * X - B || */ |
| 13308 | /* using a complete orthogonal factorization of A. A is an M-by-N */ |
| 13309 | /* matrix which may be rank-deficient. */ |
| 13310 | |
| 13311 | /* Several right hand side vectors b and solution vectors x can be */ |
| 13312 | /* handled in a single call; they are stored as the columns of the */ |
| 13313 | /* M-by-NRHS right hand side matrix B and the N-by-NRHS solution */ |
| 13314 | /* matrix X. */ |
| 13315 | |
| 13316 | /* The routine first computes a QR factorization with column pivoting: */ |
| 13317 | /* A * P = Q * [ R11 R12 ] */ |
| 13318 | /* [ 0 R22 ] */ |
| 13319 | /* with R11 defined as the largest leading submatrix whose estimated */ |
| 13320 | /* condition number is less than 1/RCOND. The order of R11, RANK, */ |
| 13321 | /* is the effective rank of A. */ |
| 13322 | |
| 13323 | /* Then, R22 is considered to be negligible, and R12 is annihilated */ |
| 13324 | /* by orthogonal transformations from the right, arriving at the */ |
| 13325 | /* complete orthogonal factorization: */ |
| 13326 | /* A * P = Q * [ T11 0 ] * Z */ |
| 13327 | /* [ 0 0 ] */ |
| 13328 | /* The minimum-norm solution is then */ |
| 13329 | /* X = P * Z' [ inv(T11)*Q1'*B ] */ |
| 13330 | /* [ 0 ] */ |
| 13331 | /* where Q1 consists of the first RANK columns of Q. */ |
| 13332 | |
| 13333 | /* Arguments */ |
| 13334 | /* ========= */ |
| 13335 | |
| 13336 | /* M (input) INTEGER */ |
| 13337 | /* The number of rows of the matrix A. M >= 0. */ |
| 13338 | |
| 13339 | /* N (input) INTEGER */ |
| 13340 | /* The number of columns of the matrix A. N >= 0. */ |
| 13341 | |
| 13342 | /* NRHS (input) INTEGER */ |
| 13343 | /* The number of right hand sides, i.e., the number of */ |
| 13344 | /* columns of matrices B and X. NRHS >= 0. */ |
| 13345 | |
| 13346 | /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 13347 | /* On entry, the M-by-N matrix A. */ |
| 13348 | /* On exit, A has been overwritten by details of its */ |
| 13349 | /* complete orthogonal factorization. */ |
| 13350 | |
| 13351 | /* LDA (input) INTEGER */ |
| 13352 | /* The leading dimension of the array A. LDA >= max(1,M). */ |
| 13353 | |
| 13354 | /* B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */ |
| 13355 | /* On entry, the M-by-NRHS right hand side matrix B. */ |
| 13356 | /* On exit, the N-by-NRHS solution matrix X. */ |
| 13357 | /* If m >= n and RANK = n, the residual sum-of-squares for */ |
| 13358 | /* the solution in the i-th column is given by the sum of */ |
| 13359 | /* squares of elements N+1:M in that column. */ |
| 13360 | |
| 13361 | /* LDB (input) INTEGER */ |
| 13362 | /* The leading dimension of the array B. LDB >= max(1,M,N). */ |
| 13363 | |
| 13364 | /* JPVT (input/output) INTEGER array, dimension (N) */ |
| 13365 | /* On entry, if JPVT(i) .ne. 0, the i-th column of A is an */ |
| 13366 | /* initial column, otherwise it is a free column. Before */ |
| 13367 | /* the QR factorization of A, all initial columns are */ |
| 13368 | /* permuted to the leading positions; only the remaining */ |
| 13369 | /* free columns are moved as a result of column pivoting */ |
| 13370 | /* during the factorization. */ |
| 13371 | /* On exit, if JPVT(i) = k, then the i-th column of A*P */ |
| 13372 | /* was the k-th column of A. */ |
| 13373 | |
| 13374 | /* RCOND (input) DOUBLE PRECISION */ |
| 13375 | /* RCOND is used to determine the effective rank of A, which */ |
| 13376 | /* is defined as the order of the largest leading triangular */ |
| 13377 | /* submatrix R11 in the QR factorization with pivoting of A, */ |
| 13378 | /* whose estimated condition number < 1/RCOND. */ |
| 13379 | |
| 13380 | /* RANK (output) INTEGER */ |
| 13381 | /* The effective rank of A, i.e., the order of the submatrix */ |
| 13382 | /* R11. This is the same as the order of the submatrix T11 */ |
| 13383 | /* in the complete orthogonal factorization of A. */ |
| 13384 | |
| 13385 | /* WORK (workspace) DOUBLE PRECISION array, dimension */ |
| 13386 | /* (max( min(M,N)+3*N, 2*min(M,N)+NRHS )), */ |
| 13387 | |
| 13388 | /* INFO (output) INTEGER */ |
| 13389 | /* = 0: successful exit */ |
| 13390 | /* < 0: if INFO = -i, the i-th argument had an illegal value */ |
| 13391 | |
| 13392 | /* ===================================================================== */ |
| 13393 | |
| 13394 | /* .. Parameters .. */ |
| 13395 | /* .. */ |
| 13396 | /* .. Local Scalars .. */ |
| 13397 | /* .. */ |
| 13398 | /* .. External Functions .. */ |
| 13399 | /* .. */ |
| 13400 | /* .. External Subroutines .. */ |
| 13401 | /* .. */ |
| 13402 | /* .. Intrinsic Functions .. */ |
| 13403 | /* .. */ |
| 13404 | /* .. Executable Statements .. */ |
| 13405 | |
| 13406 | /* Parameter adjustments */ |
| 13407 | a_dim1 = *lda; |
| 13408 | a_offset = 1 + a_dim1; |
| 13409 | a -= a_offset; |
| 13410 | b_dim1 = *ldb; |
| 13411 | b_offset = 1 + b_dim1; |
| 13412 | b -= b_offset; |
| 13413 | --jpvt; |
| 13414 | --work; |
| 13415 | |
| 13416 | /* Function Body */ |
| 13417 | mn = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(*m,*n); |
| 13418 | ismin = mn + 1; |
| 13419 | ismax = (mn << 1) + 1; |
| 13420 | |
| 13421 | /* Test the input arguments. */ |
| 13422 | |
| 13423 | *info = 0; |
| 13424 | if (*m < 0) { |
| 13425 | *info = -1; |
| 13426 | } else if (*n < 0) { |
| 13427 | *info = -2; |
| 13428 | } else if (*nrhs < 0) { |
| 13429 | *info = -3; |
| 13430 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*m)) { |
| 13431 | *info = -5; |
| 13432 | } else /* if(complicated condition) */ { |
| 13433 | /* Computing MAX */ |
| 13434 | i__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*m); |
| 13435 | if (*ldb < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,*n)) { |
| 13436 | *info = -7; |
| 13437 | } |
| 13438 | } |
| 13439 | |
| 13440 | if (*info != 0) { |
| 13441 | i__1 = -(*info); |
| 13442 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGELSX", &i__1); |
| 13443 | return 0; |
| 13444 | } |
| 13445 | |
| 13446 | /* Quick return if possible */ |
| 13447 | |
| 13448 | /* Computing MIN */ |
| 13449 | i__1 = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(*m,*n); |
| 13450 | if (stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__1,*nrhs) == 0) { |
| 13451 | *rank = 0; |
| 13452 | return 0; |
| 13453 | } |
| 13454 | |
| 13455 | /* Get machine parameters */ |
| 13456 | |
| 13457 | smlnum = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("S") / dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("P"); |
| 13458 | bignum = 1. / smlnum; |
| 13459 | dlabad_cxx . . $ dlabad_(4730c933dae9b326).(&smlnum, &bignum); |
| 13460 | |
| 13461 | /* Scale A, B if max elements outside range [SMLNUM,BIGNUM] */ |
| 13462 | |
| 13463 | anrm = dlange_cxx . . $ dlange_(98d44e6417336f20).("M", m, n, &a[a_offset], lda, &work[1]); |
| 13464 | iascl = 0; |
| 13465 | if (anrm > 0. && anrm < smlnum) { |
| 13466 | |
| 13467 | /* Scale matrix norm up to SMLNUM */ |
| 13468 | |
| 13469 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &anrm, &smlnum, m, n, &a[a_offset], lda, |
| 13470 | info); |
| 13471 | iascl = 1; |
| 13472 | } else if (anrm > bignum) { |
| 13473 | |
| 13474 | /* Scale matrix norm down to BIGNUM */ |
| 13475 | |
| 13476 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &anrm, &bignum, m, n, &a[a_offset], lda, |
| 13477 | info); |
| 13478 | iascl = 2; |
| 13479 | } else if (anrm == 0.) { |
| 13480 | |
| 13481 | /* Matrix all zero. Return zero solution. */ |
| 13482 | |
| 13483 | i__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(*m,*n); |
| 13484 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("F", &i__1, nrhs, &c_b13, &c_b13, &b[b_offset], ldb); |
| 13485 | *rank = 0; |
| 13486 | goto L100; |
| 13487 | } |
| 13488 | |
| 13489 | bnrm = dlange_cxx . . $ dlange_(98d44e6417336f20).("M", m, nrhs, &b[b_offset], ldb, &work[1]); |
| 13490 | ibscl = 0; |
| 13491 | if (bnrm > 0. && bnrm < smlnum) { |
| 13492 | |
| 13493 | /* Scale matrix norm up to SMLNUM */ |
| 13494 | |
| 13495 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &bnrm, &smlnum, m, nrhs, &b[b_offset], ldb, |
| 13496 | info); |
| 13497 | ibscl = 1; |
| 13498 | } else if (bnrm > bignum) { |
| 13499 | |
| 13500 | /* Scale matrix norm down to BIGNUM */ |
| 13501 | |
| 13502 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &bnrm, &bignum, m, nrhs, &b[b_offset], ldb, |
| 13503 | info); |
| 13504 | ibscl = 2; |
| 13505 | } |
| 13506 | |
| 13507 | /* Compute QR factorization with column pivoting of A: */ |
| 13508 | /* A * P = Q * R */ |
| 13509 | |
| 13510 | dgeqpf_cxx . . $ dgeqpf_(89014a123b88d601).(m, n, &a[a_offset], lda, &jpvt[1], &work[1], &work[mn + 1], info); |
| 13511 | |
| 13512 | /* workspace 3*N. Details of Householder rotations stored */ |
| 13513 | /* in WORK(1:MN). */ |
| 13514 | |
| 13515 | /* Determine RANK using incremental condition estimation */ |
| 13516 | |
| 13517 | work[ismin] = 1.; |
| 13518 | work[ismax] = 1.; |
| 13519 | smax = (d__1 = a[a_dim1 + 1], abscxx . . $ abs(447c67c6676f75c3).(d__1)); |
| 13520 | smin = smax; |
| 13521 | if ((d__1 = a[a_dim1 + 1], abscxx . . $ abs(447c67c6676f75c3).(d__1)) == 0.) { |
| 13522 | *rank = 0; |
| 13523 | i__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(*m,*n); |
| 13524 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("F", &i__1, nrhs, &c_b13, &c_b13, &b[b_offset], ldb); |
| 13525 | goto L100; |
| 13526 | } else { |
| 13527 | *rank = 1; |
| 13528 | } |
| 13529 | |
| 13530 | L10: |
| 13531 | if (*rank < mn) { |
| 13532 | i__ = *rank + 1; |
| 13533 | dlaic1_cxx . . $ dlaic1_(9dc8b7e228c84f01).(&c__2, rank, &work[ismin], &smin, &a[i__ * a_dim1 + 1], &a[ |
| 13534 | i__ + i__ * a_dim1], &sminpr, &s1, &c1); |
| 13535 | dlaic1_cxx . . $ dlaic1_(9dc8b7e228c84f01).(&c__1, rank, &work[ismax], &smax, &a[i__ * a_dim1 + 1], &a[ |
| 13536 | i__ + i__ * a_dim1], &smaxpr, &s2, &c2); |
| 13537 | |
| 13538 | if (smaxpr * *rcond <= sminpr) { |
| 13539 | i__1 = *rank; |
| 13540 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 13541 | work[ismin + i__ - 1] = s1 * work[ismin + i__ - 1]; |
| 13542 | work[ismax + i__ - 1] = s2 * work[ismax + i__ - 1]; |
| 13543 | /* L20: */ |
| 13544 | } |
| 13545 | work[ismin + *rank] = c1; |
| 13546 | work[ismax + *rank] = c2; |
| 13547 | smin = sminpr; |
| 13548 | smax = smaxpr; |
| 13549 | ++(*rank); |
| 13550 | goto L10; |
| 13551 | } |
| 13552 | } |
| 13553 | |
| 13554 | /* Logically partition R = [ R11 R12 ] */ |
| 13555 | /* [ 0 R22 ] */ |
| 13556 | /* where R11 = R(1:RANK,1:RANK) */ |
| 13557 | |
| 13558 | /* [R11,R12] = [ T11, 0 ] * Y */ |
| 13559 | |
| 13560 | if (*rank < *n) { |
| 13561 | dtzrqf_cxx . . $ dtzrqf_(2d30152eb3da9907).(rank, n, &a[a_offset], lda, &work[mn + 1], info); |
| 13562 | } |
| 13563 | |
| 13564 | /* Details of Householder rotations stored in WORK(MN+1:2*MN) */ |
| 13565 | |
| 13566 | /* B(1:M,1:NRHS) := Q' * B(1:M,1:NRHS) */ |
| 13567 | |
| 13568 | dorm2r_cxx . . $ dorm2r_(2f7504592752aead).("Left", "Transpose", m, nrhs, &mn, &a[a_offset], lda, &work[1], & |
| 13569 | b[b_offset], ldb, &work[(mn << 1) + 1], info); |
| 13570 | |
| 13571 | /* workspace NRHS */ |
| 13572 | |
| 13573 | /* B(1:RANK,1:NRHS) := inv(T11) * B(1:RANK,1:NRHS) */ |
| 13574 | |
| 13575 | dtrsm_cxx . . $ dtrsm_(47bcf6c639067e06).("Left", "Upper", "No transpose", "Non-unit", rank, nrhs, &c_b36, & |
| 13576 | a[a_offset], lda, &b[b_offset], ldb); |
| 13577 | |
| 13578 | i__1 = *n; |
| 13579 | for (i__ = *rank + 1; i__ <= i__1; ++i__) { |
| 13580 | i__2 = *nrhs; |
| 13581 | for (j = 1; j <= i__2; ++j) { |
| 13582 | b[i__ + j * b_dim1] = 0.; |
| 13583 | /* L30: */ |
| 13584 | } |
| 13585 | /* L40: */ |
| 13586 | } |
| 13587 | |
| 13588 | /* B(1:N,1:NRHS) := Y' * B(1:N,1:NRHS) */ |
| 13589 | |
| 13590 | if (*rank < *n) { |
| 13591 | i__1 = *rank; |
| 13592 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 13593 | i__2 = *n - *rank + 1; |
| 13594 | dlatzm_cxx . . $ dlatzm_(4f2f0f1fa7d469eb).("Left", &i__2, nrhs, &a[i__ + (*rank + 1) * a_dim1], lda, |
| 13595 | &work[mn + i__], &b[i__ + b_dim1], &b[*rank + 1 + b_dim1], |
| 13596 | ldb, &work[(mn << 1) + 1]); |
| 13597 | /* L50: */ |
| 13598 | } |
| 13599 | } |
| 13600 | |
| 13601 | /* workspace NRHS */ |
| 13602 | |
| 13603 | /* B(1:N,1:NRHS) := P * B(1:N,1:NRHS) */ |
| 13604 | |
| 13605 | i__1 = *nrhs; |
| 13606 | for (j = 1; j <= i__1; ++j) { |
| 13607 | i__2 = *n; |
| 13608 | for (i__ = 1; i__ <= i__2; ++i__) { |
| 13609 | work[(mn << 1) + i__] = 1.; |
| 13610 | /* L60: */ |
| 13611 | } |
| 13612 | i__2 = *n; |
| 13613 | for (i__ = 1; i__ <= i__2; ++i__) { |
| 13614 | if (work[(mn << 1) + i__] == 1.) { |
| 13615 | if (jpvt[i__] != i__) { |
| 13616 | k = i__; |
| 13617 | t1 = b[k + j * b_dim1]; |
| 13618 | t2 = b[jpvt[k] + j * b_dim1]; |
| 13619 | L70: |
| 13620 | b[jpvt[k] + j * b_dim1] = t1; |
| 13621 | work[(mn << 1) + k] = 0.; |
| 13622 | t1 = t2; |
| 13623 | k = jpvt[k]; |
| 13624 | t2 = b[jpvt[k] + j * b_dim1]; |
| 13625 | if (jpvt[k] != i__) { |
| 13626 | goto L70; |
| 13627 | } |
| 13628 | b[i__ + j * b_dim1] = t1; |
| 13629 | work[(mn << 1) + k] = 0.; |
| 13630 | } |
| 13631 | } |
| 13632 | /* L80: */ |
| 13633 | } |
| 13634 | /* L90: */ |
| 13635 | } |
| 13636 | |
| 13637 | /* Undo scaling */ |
| 13638 | |
| 13639 | if (iascl == 1) { |
| 13640 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &anrm, &smlnum, n, nrhs, &b[b_offset], ldb, |
| 13641 | info); |
| 13642 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("U", &c__0, &c__0, &smlnum, &anrm, rank, rank, &a[a_offset], |
| 13643 | lda, info); |
| 13644 | } else if (iascl == 2) { |
| 13645 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &anrm, &bignum, n, nrhs, &b[b_offset], ldb, |
| 13646 | info); |
| 13647 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("U", &c__0, &c__0, &bignum, &anrm, rank, rank, &a[a_offset], |
| 13648 | lda, info); |
| 13649 | } |
| 13650 | if (ibscl == 1) { |
| 13651 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &smlnum, &bnrm, n, nrhs, &b[b_offset], ldb, |
| 13652 | info); |
| 13653 | } else if (ibscl == 2) { |
| 13654 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &bignum, &bnrm, n, nrhs, &b[b_offset], ldb, |
| 13655 | info); |
| 13656 | } |
| 13657 | |
| 13658 | L100: |
| 13659 | |
| 13660 | return 0; |
| 13661 | |
| 13662 | /* End of DGELSX */ |
| 13663 | |
| 13664 | } /* dgelsx_ */ |
| 13665 | |
| 13666 | /* Subroutine */ int dgelsy_cxx . . $ dgelsy_(7581721809264bce).(integercxx . . $ integer# *m, integercxx . . $ integer# *n, integercxx . . $ integer# *nrhs, |
| 13667 | double *a, integercxx . . $ integer# *lda, double *b, integercxx . . $ integer# *ldb, integercxx . . $ integer# * |
| 13668 | jpvt, double *rcond, integercxx . . $ integer# *rank, double *work, integercxx . . $ integer# * |
| 13669 | lwork, integercxx . . $ integer# *info) |
| 13670 | { |
| 13671 | /* Table of constant values */ |
| 13672 | static integercxx . . $ integer# c__1 = 1; |
| 13673 | static integercxx . . $ integer# c_n1 = -1; |
| 13674 | static integercxx . . $ integer# c__0 = 0; |
| 13675 | static double c_b31 = 0.; |
| 13676 | static integercxx . . $ integer# c__2 = 2; |
| 13677 | static double c_b54 = 1.; |
| 13678 | |
| 13679 | /* System generated locals */ |
| 13680 | integercxx . . $ integer# a_dim1, a_offset, b_dim1, b_offset, i__1, i__2; |
| 13681 | double d__1, d__2; |
| 13682 | |
| 13683 | /* Local variables */ |
| 13684 | integercxx . . $ integer# i__, j; |
| 13685 | double c1, c2, s1, s2; |
| 13686 | integercxx . . $ integer# nb, mn, nb1, nb2, nb3, nb4; |
| 13687 | double anrm, bnrm, smin, smax; |
| 13688 | integercxx . . $ integer# iascl, ibscl; |
| 13689 | integercxx . . $ integer# ismin, ismax; |
| 13690 | double wsize; |
| 13691 | double bignum; |
| 13692 | integercxx . . $ integer# lwkmin; |
| 13693 | double sminpr, smaxpr, smlnum; |
| 13694 | integercxx . . $ integer# lwkopt; |
| 13695 | bool lquery; |
| 13696 | |
| 13697 | |
| 13698 | /* -- LAPACK driver routine (version 3.1) -- */ |
| 13699 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 13700 | /* November 2006 */ |
| 13701 | |
| 13702 | /* .. Scalar Arguments .. */ |
| 13703 | /* .. */ |
| 13704 | /* .. Array Arguments .. */ |
| 13705 | /* .. */ |
| 13706 | |
| 13707 | /* Purpose */ |
| 13708 | /* ======= */ |
| 13709 | |
| 13710 | /* DGELSY computes the minimum-norm solution to a real linear least */ |
| 13711 | /* squares problem: */ |
| 13712 | /* minimize || A * X - B || */ |
| 13713 | /* using a complete orthogonal factorization of A. A is an M-by-N */ |
| 13714 | /* matrix which may be rank-deficient. */ |
| 13715 | |
| 13716 | /* Several right hand side vectors b and solution vectors x can be */ |
| 13717 | /* handled in a single call; they are stored as the columns of the */ |
| 13718 | /* M-by-NRHS right hand side matrix B and the N-by-NRHS solution */ |
| 13719 | /* matrix X. */ |
| 13720 | |
| 13721 | /* The routine first computes a QR factorization with column pivoting: */ |
| 13722 | /* A * P = Q * [ R11 R12 ] */ |
| 13723 | /* [ 0 R22 ] */ |
| 13724 | /* with R11 defined as the largest leading submatrix whose estimated */ |
| 13725 | /* condition number is less than 1/RCOND. The order of R11, RANK, */ |
| 13726 | /* is the effective rank of A. */ |
| 13727 | |
| 13728 | /* Then, R22 is considered to be negligible, and R12 is annihilated */ |
| 13729 | /* by orthogonal transformations from the right, arriving at the */ |
| 13730 | /* complete orthogonal factorization: */ |
| 13731 | /* A * P = Q * [ T11 0 ] * Z */ |
| 13732 | /* [ 0 0 ] */ |
| 13733 | /* The minimum-norm solution is then */ |
| 13734 | /* X = P * Z' [ inv(T11)*Q1'*B ] */ |
| 13735 | /* [ 0 ] */ |
| 13736 | /* where Q1 consists of the first RANK columns of Q. */ |
| 13737 | |
| 13738 | /* This routine is basically identical to the original xGELSX except */ |
| 13739 | /* three differences: */ |
| 13740 | /* o The call to the subroutine xGEQPF has been substituted by the */ |
| 13741 | /* the call to the subroutine xGEQP3. This subroutine is a Blas-3 */ |
| 13742 | /* version of the QR factorization with column pivoting. */ |
| 13743 | /* o Matrix B (the right hand side) is updated with Blas-3. */ |
| 13744 | /* o The permutation of matrix B (the right hand side) is faster and */ |
| 13745 | /* more simple. */ |
| 13746 | |
| 13747 | /* Arguments */ |
| 13748 | /* ========= */ |
| 13749 | |
| 13750 | /* M (input) INTEGER */ |
| 13751 | /* The number of rows of the matrix A. M >= 0. */ |
| 13752 | |
| 13753 | /* N (input) INTEGER */ |
| 13754 | /* The number of columns of the matrix A. N >= 0. */ |
| 13755 | |
| 13756 | /* NRHS (input) INTEGER */ |
| 13757 | /* The number of right hand sides, i.e., the number of */ |
| 13758 | /* columns of matrices B and X. NRHS >= 0. */ |
| 13759 | |
| 13760 | /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 13761 | /* On entry, the M-by-N matrix A. */ |
| 13762 | /* On exit, A has been overwritten by details of its */ |
| 13763 | /* complete orthogonal factorization. */ |
| 13764 | |
| 13765 | /* LDA (input) INTEGER */ |
| 13766 | /* The leading dimension of the array A. LDA >= max(1,M). */ |
| 13767 | |
| 13768 | /* B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */ |
| 13769 | /* On entry, the M-by-NRHS right hand side matrix B. */ |
| 13770 | /* On exit, the N-by-NRHS solution matrix X. */ |
| 13771 | |
| 13772 | /* LDB (input) INTEGER */ |
| 13773 | /* The leading dimension of the array B. LDB >= max(1,M,N). */ |
| 13774 | |
| 13775 | /* JPVT (input/output) INTEGER array, dimension (N) */ |
| 13776 | /* On entry, if JPVT(i) .ne. 0, the i-th column of A is permuted */ |
| 13777 | /* to the front of AP, otherwise column i is a free column. */ |
| 13778 | /* On exit, if JPVT(i) = k, then the i-th column of AP */ |
| 13779 | /* was the k-th column of A. */ |
| 13780 | |
| 13781 | /* RCOND (input) DOUBLE PRECISION */ |
| 13782 | /* RCOND is used to determine the effective rank of A, which */ |
| 13783 | /* is defined as the order of the largest leading triangular */ |
| 13784 | /* submatrix R11 in the QR factorization with pivoting of A, */ |
| 13785 | /* whose estimated condition number < 1/RCOND. */ |
| 13786 | |
| 13787 | /* RANK (output) INTEGER */ |
| 13788 | /* The effective rank of A, i.e., the order of the submatrix */ |
| 13789 | /* R11. This is the same as the order of the submatrix T11 */ |
| 13790 | /* in the complete orthogonal factorization of A. */ |
| 13791 | |
| 13792 | /* WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) */ |
| 13793 | /* On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ |
| 13794 | |
| 13795 | /* LWORK (input) INTEGER */ |
| 13796 | /* The dimension of the array WORK. */ |
| 13797 | /* The unblocked strategy requires that: */ |
| 13798 | /* LWORK >= MAX( MN+3*N+1, 2*MN+NRHS ), */ |
| 13799 | /* where MN = min( M, N ). */ |
| 13800 | /* The block algorithm requires that: */ |
| 13801 | /* LWORK >= MAX( MN+2*N+NB*(N+1), 2*MN+NB*NRHS ), */ |
| 13802 | /* where NB is an upper bound on the blocksize returned */ |
| 13803 | /* by ILAENV for the routines DGEQP3, DTZRZF, STZRQF, DORMQR, */ |
| 13804 | /* and DORMRZ. */ |
| 13805 | |
| 13806 | /* If LWORK = -1, then a workspace query is assumed; the routine */ |
| 13807 | /* only calculates the optimal size of the WORK array, returns */ |
| 13808 | /* this value as the first entry of the WORK array, and no error */ |
| 13809 | /* message related to LWORK is issued by XERBLA. */ |
| 13810 | |
| 13811 | /* INFO (output) INTEGER */ |
| 13812 | /* = 0: successful exit */ |
| 13813 | /* < 0: If INFO = -i, the i-th argument had an illegal value. */ |
| 13814 | |
| 13815 | /* Further Details */ |
| 13816 | /* =============== */ |
| 13817 | |
| 13818 | /* Based on contributions by */ |
| 13819 | /* A. Petitet, Computer Science Dept., Univ. of Tenn., Knoxville, USA */ |
| 13820 | /* E. Quintana-Orti, Depto. de Informatica, Universidad Jaime I, Spain */ |
| 13821 | /* G. Quintana-Orti, Depto. de Informatica, Universidad Jaime I, Spain */ |
| 13822 | |
| 13823 | /* ===================================================================== */ |
| 13824 | |
| 13825 | /* .. Parameters .. */ |
| 13826 | /* .. */ |
| 13827 | /* .. Local Scalars .. */ |
| 13828 | /* .. */ |
| 13829 | /* .. External Functions .. */ |
| 13830 | /* .. */ |
| 13831 | /* .. External Subroutines .. */ |
| 13832 | /* .. */ |
| 13833 | /* .. Intrinsic Functions .. */ |
| 13834 | /* .. */ |
| 13835 | /* .. Executable Statements .. */ |
| 13836 | |
| 13837 | /* Parameter adjustments */ |
| 13838 | a_dim1 = *lda; |
| 13839 | a_offset = 1 + a_dim1; |
| 13840 | a -= a_offset; |
| 13841 | b_dim1 = *ldb; |
| 13842 | b_offset = 1 + b_dim1; |
| 13843 | b -= b_offset; |
| 13844 | --jpvt; |
| 13845 | --work; |
| 13846 | |
| 13847 | /* Function Body */ |
| 13848 | mn = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(*m,*n); |
| 13849 | ismin = mn + 1; |
| 13850 | ismax = (mn << 1) + 1; |
| 13851 | |
| 13852 | /* Test the input arguments. */ |
| 13853 | |
| 13854 | *info = 0; |
| 13855 | lquery = *lwork == -1; |
| 13856 | if (*m < 0) { |
| 13857 | *info = -1; |
| 13858 | } else if (*n < 0) { |
| 13859 | *info = -2; |
| 13860 | } else if (*nrhs < 0) { |
| 13861 | *info = -3; |
| 13862 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*m)) { |
| 13863 | *info = -5; |
| 13864 | } else /* if(complicated condition) */ { |
| 13865 | /* Computing MAX */ |
| 13866 | i__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*m); |
| 13867 | if (*ldb < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,*n)) { |
| 13868 | *info = -7; |
| 13869 | } |
| 13870 | } |
| 13871 | |
| 13872 | /* Figure out optimal block size */ |
| 13873 | |
| 13874 | if (*info == 0) { |
| 13875 | if (mn == 0 || *nrhs == 0) { |
| 13876 | lwkmin = 1; |
| 13877 | lwkopt = 1; |
| 13878 | } else { |
| 13879 | nb1 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEQRF", " ", m, n, &c_n1, &c_n1); |
| 13880 | nb2 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGERQF", " ", m, n, &c_n1, &c_n1); |
| 13881 | nb3 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMQR", " ", m, n, nrhs, &c_n1); |
| 13882 | nb4 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMRQ", " ", m, n, nrhs, &c_n1); |
| 13883 | /* Computing MAX */ |
| 13884 | i__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(nb1,nb2), i__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,nb3); |
| 13885 | nb = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,nb4); |
| 13886 | /* Computing MAX */ |
| 13887 | i__1 = mn << 1, i__2 = *n + 1, i__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2), i__2 = mn + |
| 13888 | *nrhs; |
| 13889 | lwkmin = mn + stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 13890 | /* Computing MAX */ |
| 13891 | i__1 = lwkmin, i__2 = mn + (*n << 1) + nb * (*n + 1), i__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).( |
| 13892 | i__1,i__2), i__2 = (mn << 1) + nb * *nrhs; |
| 13893 | lwkopt = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 13894 | } |
| 13895 | work[1] = (double) lwkopt; |
| 13896 | |
| 13897 | if (*lwork < lwkmin && ! lquery) { |
| 13898 | *info = -12; |
| 13899 | } |
| 13900 | } |
| 13901 | |
| 13902 | if (*info != 0) { |
| 13903 | i__1 = -(*info); |
| 13904 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGELSY", &i__1); |
| 13905 | return 0; |
| 13906 | } else if (lquery) { |
| 13907 | return 0; |
| 13908 | } |
| 13909 | |
| 13910 | /* Quick return if possible */ |
| 13911 | |
| 13912 | if (mn == 0 || *nrhs == 0) { |
| 13913 | *rank = 0; |
| 13914 | return 0; |
| 13915 | } |
| 13916 | |
| 13917 | /* Get machine parameters */ |
| 13918 | |
| 13919 | smlnum = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("S") / dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("P"); |
| 13920 | bignum = 1. / smlnum; |
| 13921 | dlabad_cxx . . $ dlabad_(4730c933dae9b326).(&smlnum, &bignum); |
| 13922 | |
| 13923 | /* Scale A, B if max entries outside range [SMLNUM,BIGNUM] */ |
| 13924 | |
| 13925 | anrm = dlange_cxx . . $ dlange_(98d44e6417336f20).("M", m, n, &a[a_offset], lda, &work[1]); |
| 13926 | iascl = 0; |
| 13927 | if (anrm > 0. && anrm < smlnum) { |
| 13928 | |
| 13929 | /* Scale matrix norm up to SMLNUM */ |
| 13930 | |
| 13931 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &anrm, &smlnum, m, n, &a[a_offset], lda, |
| 13932 | info); |
| 13933 | iascl = 1; |
| 13934 | } else if (anrm > bignum) { |
| 13935 | |
| 13936 | /* Scale matrix norm down to BIGNUM */ |
| 13937 | |
| 13938 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &anrm, &bignum, m, n, &a[a_offset], lda, |
| 13939 | info); |
| 13940 | iascl = 2; |
| 13941 | } else if (anrm == 0.) { |
| 13942 | |
| 13943 | /* Matrix all zero. Return zero solution. */ |
| 13944 | |
| 13945 | i__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(*m,*n); |
| 13946 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("F", &i__1, nrhs, &c_b31, &c_b31, &b[b_offset], ldb); |
| 13947 | *rank = 0; |
| 13948 | goto L70; |
| 13949 | } |
| 13950 | |
| 13951 | bnrm = dlange_cxx . . $ dlange_(98d44e6417336f20).("M", m, nrhs, &b[b_offset], ldb, &work[1]); |
| 13952 | ibscl = 0; |
| 13953 | if (bnrm > 0. && bnrm < smlnum) { |
| 13954 | |
| 13955 | /* Scale matrix norm up to SMLNUM */ |
| 13956 | |
| 13957 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &bnrm, &smlnum, m, nrhs, &b[b_offset], ldb, |
| 13958 | info); |
| 13959 | ibscl = 1; |
| 13960 | } else if (bnrm > bignum) { |
| 13961 | |
| 13962 | /* Scale matrix norm down to BIGNUM */ |
| 13963 | |
| 13964 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &bnrm, &bignum, m, nrhs, &b[b_offset], ldb, |
| 13965 | info); |
| 13966 | ibscl = 2; |
| 13967 | } |
| 13968 | |
| 13969 | /* Compute QR factorization with column pivoting of A: */ |
| 13970 | /* A * P = Q * R */ |
| 13971 | |
| 13972 | i__1 = *lwork - mn; |
| 13973 | dgeqp3_cxx . . $ dgeqp3_(ec2cac48ae8a8a7).(m, n, &a[a_offset], lda, &jpvt[1], &work[1], &work[mn + 1], &i__1, |
| 13974 | info); |
| 13975 | wsize = mn + work[mn + 1]; |
| 13976 | |
| 13977 | /* workspace: MN+2*N+NB*(N+1). */ |
| 13978 | /* Details of Householder rotations stored in WORK(1:MN). */ |
| 13979 | |
| 13980 | /* Determine RANK using incremental condition estimation */ |
| 13981 | |
| 13982 | work[ismin] = 1.; |
| 13983 | work[ismax] = 1.; |
| 13984 | smax = (d__1 = a[a_dim1 + 1], abscxx . . $ abs(447c67c6676f75c3).(d__1)); |
| 13985 | smin = smax; |
| 13986 | if ((d__1 = a[a_dim1 + 1], abscxx . . $ abs(447c67c6676f75c3).(d__1)) == 0.) { |
| 13987 | *rank = 0; |
| 13988 | i__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(*m,*n); |
| 13989 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("F", &i__1, nrhs, &c_b31, &c_b31, &b[b_offset], ldb); |
| 13990 | goto L70; |
| 13991 | } else { |
| 13992 | *rank = 1; |
| 13993 | } |
| 13994 | |
| 13995 | L10: |
| 13996 | if (*rank < mn) { |
| 13997 | i__ = *rank + 1; |
| 13998 | dlaic1_cxx . . $ dlaic1_(9dc8b7e228c84f01).(&c__2, rank, &work[ismin], &smin, &a[i__ * a_dim1 + 1], &a[ |
| 13999 | i__ + i__ * a_dim1], &sminpr, &s1, &c1); |
| 14000 | dlaic1_cxx . . $ dlaic1_(9dc8b7e228c84f01).(&c__1, rank, &work[ismax], &smax, &a[i__ * a_dim1 + 1], &a[ |
| 14001 | i__ + i__ * a_dim1], &smaxpr, &s2, &c2); |
| 14002 | |
| 14003 | if (smaxpr * *rcond <= sminpr) { |
| 14004 | i__1 = *rank; |
| 14005 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 14006 | work[ismin + i__ - 1] = s1 * work[ismin + i__ - 1]; |
| 14007 | work[ismax + i__ - 1] = s2 * work[ismax + i__ - 1]; |
| 14008 | /* L20: */ |
| 14009 | } |
| 14010 | work[ismin + *rank] = c1; |
| 14011 | work[ismax + *rank] = c2; |
| 14012 | smin = sminpr; |
| 14013 | smax = smaxpr; |
| 14014 | ++(*rank); |
| 14015 | goto L10; |
| 14016 | } |
| 14017 | } |
| 14018 | |
| 14019 | /* workspace: 3*MN. */ |
| 14020 | |
| 14021 | /* Logically partition R = [ R11 R12 ] */ |
| 14022 | /* [ 0 R22 ] */ |
| 14023 | /* where R11 = R(1:RANK,1:RANK) */ |
| 14024 | |
| 14025 | /* [R11,R12] = [ T11, 0 ] * Y */ |
| 14026 | |
| 14027 | if (*rank < *n) { |
| 14028 | i__1 = *lwork - (mn << 1); |
| 14029 | dtzrzf_cxx . . $ dtzrzf_(b2aaa174babf002e).(rank, n, &a[a_offset], lda, &work[mn + 1], &work[(mn << 1) + |
| 14030 | 1], &i__1, info); |
| 14031 | } |
| 14032 | |
| 14033 | /* workspace: 2*MN. */ |
| 14034 | /* Details of Householder rotations stored in WORK(MN+1:2*MN) */ |
| 14035 | |
| 14036 | /* B(1:M,1:NRHS) := Q' * B(1:M,1:NRHS) */ |
| 14037 | |
| 14038 | i__1 = *lwork - (mn << 1); |
| 14039 | dormqr_cxx . . $ dormqr_(c6b7238dd97e9cf9).("Left", "Transpose", m, nrhs, &mn, &a[a_offset], lda, &work[1], & |
| 14040 | b[b_offset], ldb, &work[(mn << 1) + 1], &i__1, info); |
| 14041 | /* Computing MAX */ |
| 14042 | d__1 = wsize, d__2 = (mn << 1) + work[(mn << 1) + 1]; |
| 14043 | wsize = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__1,d__2); |
| 14044 | |
| 14045 | /* workspace: 2*MN+NB*NRHS. */ |
| 14046 | |
| 14047 | /* B(1:RANK,1:NRHS) := inv(T11) * B(1:RANK,1:NRHS) */ |
| 14048 | |
| 14049 | dtrsm_cxx . . $ dtrsm_(47bcf6c639067e06).("Left", "Upper", "No transpose", "Non-unit", rank, nrhs, &c_b54, & |
| 14050 | a[a_offset], lda, &b[b_offset], ldb); |
| 14051 | |
| 14052 | i__1 = *nrhs; |
| 14053 | for (j = 1; j <= i__1; ++j) { |
| 14054 | i__2 = *n; |
| 14055 | for (i__ = *rank + 1; i__ <= i__2; ++i__) { |
| 14056 | b[i__ + j * b_dim1] = 0.; |
| 14057 | /* L30: */ |
| 14058 | } |
| 14059 | /* L40: */ |
| 14060 | } |
| 14061 | |
| 14062 | /* B(1:N,1:NRHS) := Y' * B(1:N,1:NRHS) */ |
| 14063 | |
| 14064 | if (*rank < *n) { |
| 14065 | i__1 = *n - *rank; |
| 14066 | i__2 = *lwork - (mn << 1); |
| 14067 | dormrz_cxx . . $ dormrz_(a018fdab7fb71d65).("Left", "Transpose", n, nrhs, rank, &i__1, &a[a_offset], lda, |
| 14068 | &work[mn + 1], &b[b_offset], ldb, &work[(mn << 1) + 1], &i__2, |
| 14069 | info); |
| 14070 | } |
| 14071 | |
| 14072 | /* workspace: 2*MN+NRHS. */ |
| 14073 | |
| 14074 | /* B(1:N,1:NRHS) := P * B(1:N,1:NRHS) */ |
| 14075 | |
| 14076 | i__1 = *nrhs; |
| 14077 | for (j = 1; j <= i__1; ++j) { |
| 14078 | i__2 = *n; |
| 14079 | for (i__ = 1; i__ <= i__2; ++i__) { |
| 14080 | work[jpvt[i__]] = b[i__ + j * b_dim1]; |
| 14081 | /* L50: */ |
| 14082 | } |
| 14083 | dcopy_cxx . . $ dcopy_(ec261fd7ec3b6bf6).(n, &work[1], &c__1, &b[j * b_dim1 + 1], &c__1); |
| 14084 | /* L60: */ |
| 14085 | } |
| 14086 | |
| 14087 | /* workspace: N. */ |
| 14088 | |
| 14089 | /* Undo scaling */ |
| 14090 | |
| 14091 | if (iascl == 1) { |
| 14092 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &anrm, &smlnum, n, nrhs, &b[b_offset], ldb, |
| 14093 | info); |
| 14094 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("U", &c__0, &c__0, &smlnum, &anrm, rank, rank, &a[a_offset], |
| 14095 | lda, info); |
| 14096 | } else if (iascl == 2) { |
| 14097 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &anrm, &bignum, n, nrhs, &b[b_offset], ldb, |
| 14098 | info); |
| 14099 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("U", &c__0, &c__0, &bignum, &anrm, rank, rank, &a[a_offset], |
| 14100 | lda, info); |
| 14101 | } |
| 14102 | if (ibscl == 1) { |
| 14103 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &smlnum, &bnrm, n, nrhs, &b[b_offset], ldb, |
| 14104 | info); |
| 14105 | } else if (ibscl == 2) { |
| 14106 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &bignum, &bnrm, n, nrhs, &b[b_offset], ldb, |
| 14107 | info); |
| 14108 | } |
| 14109 | |
| 14110 | L70: |
| 14111 | work[1] = (double) lwkopt; |
| 14112 | |
| 14113 | return 0; |
| 14114 | |
| 14115 | /* End of DGELSY */ |
| 14116 | |
| 14117 | } /* dgelsy_ */ |
| 14118 | |
| 14119 | /* Subroutine */ int dgeql2_cxx . . $ dgeql2_(19b4abe06ca5e75b).(integercxx . . $ integer# *m, integercxx . . $ integer# *n, double *a, integercxx . . $ integer# * |
| 14120 | lda, double *tau, double *work, integercxx . . $ integer# *info) |
| 14121 | { |
| 14122 | /* Table of constant values */ |
| 14123 | static integercxx . . $ integer# c__1 = 1; |
| 14124 | |
| 14125 | /* System generated locals */ |
| 14126 | integercxx . . $ integer# a_dim1, a_offset, i__1, i__2; |
| 14127 | |
| 14128 | /* Local variables */ |
| 14129 | integercxx . . $ integer# i__, k; |
| 14130 | double aii; |
| 14131 | |
| 14132 | /* -- LAPACK routine (version 3.2) -- */ |
| 14133 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 14134 | /* November 2006 */ |
| 14135 | |
| 14136 | /* .. Scalar Arguments .. */ |
| 14137 | /* .. */ |
| 14138 | /* .. Array Arguments .. */ |
| 14139 | /* .. */ |
| 14140 | |
| 14141 | /* Purpose */ |
| 14142 | /* ======= */ |
| 14143 | |
| 14144 | /* DGEQL2 computes a QL factorization of a real m by n matrix A: */ |
| 14145 | /* A = Q * L. */ |
| 14146 | |
| 14147 | /* Arguments */ |
| 14148 | /* ========= */ |
| 14149 | |
| 14150 | /* M (input) INTEGER */ |
| 14151 | /* The number of rows of the matrix A. M >= 0. */ |
| 14152 | |
| 14153 | /* N (input) INTEGER */ |
| 14154 | /* The number of columns of the matrix A. N >= 0. */ |
| 14155 | |
| 14156 | /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 14157 | /* On entry, the m by n matrix A. */ |
| 14158 | /* On exit, if m >= n, the lower triangle of the subarray */ |
| 14159 | /* A(m-n+1:m,1:n) contains the n by n lower triangular matrix L; */ |
| 14160 | /* if m <= n, the elements on and below the (n-m)-th */ |
| 14161 | /* superdiagonal contain the m by n lower trapezoidal matrix L; */ |
| 14162 | /* the remaining elements, with the array TAU, represent the */ |
| 14163 | /* orthogonal matrix Q as a product of elementary reflectors */ |
| 14164 | /* (see Further Details). */ |
| 14165 | |
| 14166 | /* LDA (input) INTEGER */ |
| 14167 | /* The leading dimension of the array A. LDA >= max(1,M). */ |
| 14168 | |
| 14169 | /* TAU (output) DOUBLE PRECISION array, dimension (min(M,N)) */ |
| 14170 | /* The scalar factors of the elementary reflectors (see Further */ |
| 14171 | /* Details). */ |
| 14172 | |
| 14173 | /* WORK (workspace) DOUBLE PRECISION array, dimension (N) */ |
| 14174 | |
| 14175 | /* INFO (output) INTEGER */ |
| 14176 | /* = 0: successful exit */ |
| 14177 | /* < 0: if INFO = -i, the i-th argument had an illegal value */ |
| 14178 | |
| 14179 | /* Further Details */ |
| 14180 | /* =============== */ |
| 14181 | |
| 14182 | /* The matrix Q is represented as a product of elementary reflectors */ |
| 14183 | |
| 14184 | /* Q = H(k) . . . H(2) H(1), where k = min(m,n). */ |
| 14185 | |
| 14186 | /* Each H(i) has the form */ |
| 14187 | |
| 14188 | /* H(i) = I - tau * v * v' */ |
| 14189 | |
| 14190 | /* where tau is a real scalar, and v is a real vector with */ |
| 14191 | /* v(m-k+i+1:m) = 0 and v(m-k+i) = 1; v(1:m-k+i-1) is stored on exit in */ |
| 14192 | /* A(1:m-k+i-1,n-k+i), and tau in TAU(i). */ |
| 14193 | |
| 14194 | /* ===================================================================== */ |
| 14195 | |
| 14196 | /* .. Parameters .. */ |
| 14197 | /* .. */ |
| 14198 | /* .. Local Scalars .. */ |
| 14199 | /* .. */ |
| 14200 | /* .. External Subroutines .. */ |
| 14201 | /* .. */ |
| 14202 | /* .. Intrinsic Functions .. */ |
| 14203 | /* .. */ |
| 14204 | /* .. Executable Statements .. */ |
| 14205 | |
| 14206 | /* Test the input arguments */ |
| 14207 | |
| 14208 | /* Parameter adjustments */ |
| 14209 | a_dim1 = *lda; |
| 14210 | a_offset = 1 + a_dim1; |
| 14211 | a -= a_offset; |
| 14212 | --tau; |
| 14213 | --work; |
| 14214 | |
| 14215 | /* Function Body */ |
| 14216 | *info = 0; |
| 14217 | if (*m < 0) { |
| 14218 | *info = -1; |
| 14219 | } else if (*n < 0) { |
| 14220 | *info = -2; |
| 14221 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*m)) { |
| 14222 | *info = -4; |
| 14223 | } |
| 14224 | if (*info != 0) { |
| 14225 | i__1 = -(*info); |
| 14226 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGEQL2", &i__1); |
| 14227 | return 0; |
| 14228 | } |
| 14229 | |
| 14230 | k = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(*m,*n); |
| 14231 | |
| 14232 | for (i__ = k; i__ >= 1; --i__) { |
| 14233 | |
| 14234 | /* Generate elementary reflector H(i) to annihilate */ |
| 14235 | /* A(1:m-k+i-1,n-k+i) */ |
| 14236 | |
| 14237 | i__1 = *m - k + i__; |
| 14238 | dlarfp_cxx . . $ dlarfp_(ae28ee921df873ff).(&i__1, &a[*m - k + i__ + (*n - k + i__) * a_dim1], &a[(*n - k |
| 14239 | + i__) * a_dim1 + 1], &c__1, &tau[i__]); |
| 14240 | |
| 14241 | /* Apply H(i) to A(1:m-k+i,1:n-k+i-1) from the left */ |
| 14242 | |
| 14243 | aii = a[*m - k + i__ + (*n - k + i__) * a_dim1]; |
| 14244 | a[*m - k + i__ + (*n - k + i__) * a_dim1] = 1.; |
| 14245 | i__1 = *m - k + i__; |
| 14246 | i__2 = *n - k + i__ - 1; |
| 14247 | dlarf_cxx . . $ dlarf_(f67bbcf4c4b4eb96).("Left", &i__1, &i__2, &a[(*n - k + i__) * a_dim1 + 1], &c__1, & |
| 14248 | tau[i__], &a[a_offset], lda, &work[1]); |
| 14249 | a[*m - k + i__ + (*n - k + i__) * a_dim1] = aii; |
| 14250 | /* L10: */ |
| 14251 | } |
| 14252 | return 0; |
| 14253 | |
| 14254 | /* End of DGEQL2 */ |
| 14255 | |
| 14256 | } /* dgeql2_ */ |
| 14257 | |
| 14258 | |
| 14259 | /* Subroutine */ int dgeqlf_cxx . . $ dgeqlf_(b2aaa174babf002e).(integercxx . . $ integer# *m, integercxx . . $ integer# *n, double *a, integercxx . . $ integer# * |
| 14260 | lda, double *tau, double *work, integercxx . . $ integer# *lwork, integercxx . . $ integer# *info) |
| 14261 | { |
| 14262 | /* Table of constant values */ |
| 14263 | static integercxx . . $ integer# c__1 = 1; |
| 14264 | static integercxx . . $ integer# c_n1 = -1; |
| 14265 | static integercxx . . $ integer# c__3 = 3; |
| 14266 | static integercxx . . $ integer# c__2 = 2; |
| 14267 | |
| 14268 | /* System generated locals */ |
| 14269 | integercxx . . $ integer# a_dim1, a_offset, i__1, i__2, i__3, i__4; |
| 14270 | |
| 14271 | /* Local variables */ |
| 14272 | integercxx . . $ integer# i__, k, ib, nb, ki, kk, mu, nu, nx, iws, nbmin, iinfo; |
| 14273 | integercxx . . $ integer# ldwork, lwkopt; |
| 14274 | bool lquery; |
| 14275 | |
| 14276 | |
| 14277 | /* -- LAPACK routine (version 3.1) -- */ |
| 14278 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 14279 | /* November 2006 */ |
| 14280 | |
| 14281 | /* .. Scalar Arguments .. */ |
| 14282 | /* .. */ |
| 14283 | /* .. Array Arguments .. */ |
| 14284 | /* .. */ |
| 14285 | |
| 14286 | /* Purpose */ |
| 14287 | /* ======= */ |
| 14288 | |
| 14289 | /* DGEQLF computes a QL factorization of a real M-by-N matrix A: */ |
| 14290 | /* A = Q * L. */ |
| 14291 | |
| 14292 | /* Arguments */ |
| 14293 | /* ========= */ |
| 14294 | |
| 14295 | /* M (input) INTEGER */ |
| 14296 | /* The number of rows of the matrix A. M >= 0. */ |
| 14297 | |
| 14298 | /* N (input) INTEGER */ |
| 14299 | /* The number of columns of the matrix A. N >= 0. */ |
| 14300 | |
| 14301 | /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 14302 | /* On entry, the M-by-N matrix A. */ |
| 14303 | /* On exit, */ |
| 14304 | /* if m >= n, the lower triangle of the subarray */ |
| 14305 | /* A(m-n+1:m,1:n) contains the N-by-N lower triangular matrix L; */ |
| 14306 | /* if m <= n, the elements on and below the (n-m)-th */ |
| 14307 | /* superdiagonal contain the M-by-N lower trapezoidal matrix L; */ |
| 14308 | /* the remaining elements, with the array TAU, represent the */ |
| 14309 | /* orthogonal matrix Q as a product of elementary reflectors */ |
| 14310 | /* (see Further Details). */ |
| 14311 | |
| 14312 | /* LDA (input) INTEGER */ |
| 14313 | /* The leading dimension of the array A. LDA >= max(1,M). */ |
| 14314 | |
| 14315 | /* TAU (output) DOUBLE PRECISION array, dimension (min(M,N)) */ |
| 14316 | /* The scalar factors of the elementary reflectors (see Further */ |
| 14317 | /* Details). */ |
| 14318 | |
| 14319 | /* WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) */ |
| 14320 | /* On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ |
| 14321 | |
| 14322 | /* LWORK (input) INTEGER */ |
| 14323 | /* The dimension of the array WORK. LWORK >= max(1,N). */ |
| 14324 | /* For optimum performance LWORK >= N*NB, where NB is the */ |
| 14325 | /* optimal blocksize. */ |
| 14326 | |
| 14327 | /* If LWORK = -1, then a workspace query is assumed; the routine */ |
| 14328 | /* only calculates the optimal size of the WORK array, returns */ |
| 14329 | /* this value as the first entry of the WORK array, and no error */ |
| 14330 | /* message related to LWORK is issued by XERBLA. */ |
| 14331 | |
| 14332 | /* INFO (output) INTEGER */ |
| 14333 | /* = 0: successful exit */ |
| 14334 | /* < 0: if INFO = -i, the i-th argument had an illegal value */ |
| 14335 | |
| 14336 | /* Further Details */ |
| 14337 | /* =============== */ |
| 14338 | |
| 14339 | /* The matrix Q is represented as a product of elementary reflectors */ |
| 14340 | |
| 14341 | /* Q = H(k) . . . H(2) H(1), where k = min(m,n). */ |
| 14342 | |
| 14343 | /* Each H(i) has the form */ |
| 14344 | |
| 14345 | /* H(i) = I - tau * v * v' */ |
| 14346 | |
| 14347 | /* where tau is a real scalar, and v is a real vector with */ |
| 14348 | /* v(m-k+i+1:m) = 0 and v(m-k+i) = 1; v(1:m-k+i-1) is stored on exit in */ |
| 14349 | /* A(1:m-k+i-1,n-k+i), and tau in TAU(i). */ |
| 14350 | |
| 14351 | /* ===================================================================== */ |
| 14352 | |
| 14353 | /* .. Local Scalars .. */ |
| 14354 | /* .. */ |
| 14355 | /* .. External Subroutines .. */ |
| 14356 | /* .. */ |
| 14357 | /* .. Intrinsic Functions .. */ |
| 14358 | /* .. */ |
| 14359 | /* .. External Functions .. */ |
| 14360 | /* .. */ |
| 14361 | /* .. Executable Statements .. */ |
| 14362 | |
| 14363 | /* Test the input arguments */ |
| 14364 | |
| 14365 | /* Parameter adjustments */ |
| 14366 | a_dim1 = *lda; |
| 14367 | a_offset = 1 + a_dim1; |
| 14368 | a -= a_offset; |
| 14369 | --tau; |
| 14370 | --work; |
| 14371 | |
| 14372 | /* Function Body */ |
| 14373 | *info = 0; |
| 14374 | lquery = *lwork == -1; |
| 14375 | if (*m < 0) { |
| 14376 | *info = -1; |
| 14377 | } else if (*n < 0) { |
| 14378 | *info = -2; |
| 14379 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*m)) { |
| 14380 | *info = -4; |
| 14381 | } |
| 14382 | |
| 14383 | if (*info == 0) { |
| 14384 | k = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(*m,*n); |
| 14385 | if (k == 0) { |
| 14386 | lwkopt = 1; |
| 14387 | } else { |
| 14388 | nb = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEQLF", " ", m, n, &c_n1, &c_n1); |
| 14389 | lwkopt = *n * nb; |
| 14390 | } |
| 14391 | work[1] = (double) lwkopt; |
| 14392 | |
| 14393 | if (*lwork < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n) && ! lquery) { |
| 14394 | *info = -7; |
| 14395 | } |
| 14396 | } |
| 14397 | |
| 14398 | if (*info != 0) { |
| 14399 | i__1 = -(*info); |
| 14400 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGEQLF", &i__1); |
| 14401 | return 0; |
| 14402 | } else if (lquery) { |
| 14403 | return 0; |
| 14404 | } |
| 14405 | |
| 14406 | /* Quick return if possible */ |
| 14407 | |
| 14408 | if (k == 0) { |
| 14409 | return 0; |
| 14410 | } |
| 14411 | |
| 14412 | nbmin = 2; |
| 14413 | nx = 1; |
| 14414 | iws = *n; |
| 14415 | if (nb > 1 && nb < k) { |
| 14416 | |
| 14417 | /* Determine when to cross over from blocked to unblocked code. */ |
| 14418 | |
| 14419 | /* Computing MAX */ |
| 14420 | i__1 = 0, i__2 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__3, "DGEQLF", " ", m, n, &c_n1, &c_n1); |
| 14421 | nx = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 14422 | if (nx < k) { |
| 14423 | |
| 14424 | /* Determine if workspace is large enough for blocked code. */ |
| 14425 | |
| 14426 | ldwork = *n; |
| 14427 | iws = ldwork * nb; |
| 14428 | if (*lwork < iws) { |
| 14429 | |
| 14430 | /* Not enough workspace to use optimal NB: reduce NB and */ |
| 14431 | /* determine the minimum value of NB. */ |
| 14432 | |
| 14433 | nb = *lwork / ldwork; |
| 14434 | /* Computing MAX */ |
| 14435 | i__1 = 2, i__2 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__2, "DGEQLF", " ", m, n, &c_n1, & |
| 14436 | c_n1); |
| 14437 | nbmin = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 14438 | } |
| 14439 | } |
| 14440 | } |
| 14441 | |
| 14442 | if (nb >= nbmin && nb < k && nx < k) { |
| 14443 | |
| 14444 | /* Use blocked code initially. */ |
| 14445 | /* The last kk columns are handled by the block method. */ |
| 14446 | |
| 14447 | ki = (k - nx - 1) / nb * nb; |
| 14448 | /* Computing MIN */ |
| 14449 | i__1 = k, i__2 = ki + nb; |
| 14450 | kk = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__1,i__2); |
| 14451 | |
| 14452 | i__1 = k - kk + 1; |
| 14453 | i__2 = -nb; |
| 14454 | for (i__ = k - kk + ki + 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ |
| 14455 | += i__2) { |
| 14456 | /* Computing MIN */ |
| 14457 | i__3 = k - i__ + 1; |
| 14458 | ib = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__3,nb); |
| 14459 | |
| 14460 | /* Compute the QL factorization of the current block */ |
| 14461 | /* A(1:m-k+i+ib-1,n-k+i:n-k+i+ib-1) */ |
| 14462 | |
| 14463 | i__3 = *m - k + i__ + ib - 1; |
| 14464 | dgeql2_cxx . . $ dgeql2_(19b4abe06ca5e75b).(&i__3, &ib, &a[(*n - k + i__) * a_dim1 + 1], lda, &tau[ |
| 14465 | i__], &work[1], &iinfo); |
| 14466 | if (*n - k + i__ > 1) { |
| 14467 | |
| 14468 | /* Form the triangular factor of the block reflector */ |
| 14469 | /* H = H(i+ib-1) . . . H(i+1) H(i) */ |
| 14470 | |
| 14471 | i__3 = *m - k + i__ + ib - 1; |
| 14472 | dlarft_cxx . . $ dlarft_(9d83c62c83e92799).("Backward", "Columnwise", &i__3, &ib, &a[(*n - k + |
| 14473 | i__) * a_dim1 + 1], lda, &tau[i__], &work[1], &ldwork); |
| 14474 | |
| 14475 | /* Apply H' to A(1:m-k+i+ib-1,1:n-k+i-1) from the left */ |
| 14476 | |
| 14477 | i__3 = *m - k + i__ + ib - 1; |
| 14478 | i__4 = *n - k + i__ - 1; |
| 14479 | dlarfb_cxx . . $ dlarfb_(b0af75de90da309c).("Left", "Transpose", "Backward", "Columnwise", &i__3, |
| 14480 | &i__4, &ib, &a[(*n - k + i__) * a_dim1 + 1], lda, & |
| 14481 | work[1], &ldwork, &a[a_offset], lda, &work[ib + 1], & |
| 14482 | ldwork); |
| 14483 | } |
| 14484 | /* L10: */ |
| 14485 | } |
| 14486 | mu = *m - k + i__ + nb - 1; |
| 14487 | nu = *n - k + i__ + nb - 1; |
| 14488 | } else { |
| 14489 | mu = *m; |
| 14490 | nu = *n; |
| 14491 | } |
| 14492 | |
| 14493 | /* Use unblocked code to factor the last or only block */ |
| 14494 | |
| 14495 | if (mu > 0 && nu > 0) { |
| 14496 | dgeql2_cxx . . $ dgeql2_(19b4abe06ca5e75b).(&mu, &nu, &a[a_offset], lda, &tau[1], &work[1], &iinfo); |
| 14497 | } |
| 14498 | |
| 14499 | work[1] = (double) iws; |
| 14500 | return 0; |
| 14501 | |
| 14502 | /* End of DGEQLF */ |
| 14503 | |
| 14504 | } /* dgeqlf_ */ |
| 14505 | |
| 14506 | /* Subroutine */ int dgeqp3_cxx . . $ dgeqp3_(ec2cac48ae8a8a7).(integercxx . . $ integer# *m, integercxx . . $ integer# *n, double *a, integercxx . . $ integer# * |
| 14507 | lda, integercxx . . $ integer# *jpvt, double *tau, double *work, integercxx . . $ integer# *lwork, |
| 14508 | integercxx . . $ integer# *info) |
| 14509 | { |
| 14510 | /* Table of constant values */ |
| 14511 | static integercxx . . $ integer# c__1 = 1; |
| 14512 | static integercxx . . $ integer# c_n1 = -1; |
| 14513 | static integercxx . . $ integer# c__3 = 3; |
| 14514 | static integercxx . . $ integer# c__2 = 2; |
| 14515 | |
| 14516 | /* System generated locals */ |
| 14517 | integercxx . . $ integer# a_dim1, a_offset, i__1, i__2, i__3; |
| 14518 | |
| 14519 | /* Local variables */ |
| 14520 | integercxx . . $ integer# j, jb, na, nb, sm, sn, nx, fjb, iws, nfxd; |
| 14521 | integercxx . . $ integer# nbmin, minmn; |
| 14522 | integercxx . . $ integer# minws; |
| 14523 | integercxx . . $ integer# topbmn, sminmn; |
| 14524 | integercxx . . $ integer# lwkopt; |
| 14525 | bool lquery; |
| 14526 | |
| 14527 | |
| 14528 | /* -- LAPACK routine (version 3.1) -- */ |
| 14529 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 14530 | /* November 2006 */ |
| 14531 | |
| 14532 | /* .. Scalar Arguments .. */ |
| 14533 | /* .. */ |
| 14534 | /* .. Array Arguments .. */ |
| 14535 | /* .. */ |
| 14536 | |
| 14537 | /* Purpose */ |
| 14538 | /* ======= */ |
| 14539 | |
| 14540 | /* DGEQP3 computes a QR factorization with column pivoting of a */ |
| 14541 | /* matrix A: A*P = Q*R using Level 3 BLAS. */ |
| 14542 | |
| 14543 | /* Arguments */ |
| 14544 | /* ========= */ |
| 14545 | |
| 14546 | /* M (input) INTEGER */ |
| 14547 | /* The number of rows of the matrix A. M >= 0. */ |
| 14548 | |
| 14549 | /* N (input) INTEGER */ |
| 14550 | /* The number of columns of the matrix A. N >= 0. */ |
| 14551 | |
| 14552 | /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 14553 | /* On entry, the M-by-N matrix A. */ |
| 14554 | /* On exit, the upper triangle of the array contains the */ |
| 14555 | /* min(M,N)-by-N upper trapezoidal matrix R; the elements below */ |
| 14556 | /* the diagonal, together with the array TAU, represent the */ |
| 14557 | /* orthogonal matrix Q as a product of min(M,N) elementary */ |
| 14558 | /* reflectors. */ |
| 14559 | |
| 14560 | /* LDA (input) INTEGER */ |
| 14561 | /* The leading dimension of the array A. LDA >= max(1,M). */ |
| 14562 | |
| 14563 | /* JPVT (input/output) INTEGER array, dimension (N) */ |
| 14564 | /* On entry, if JPVT(J).ne.0, the J-th column of A is permuted */ |
| 14565 | /* to the front of A*P (a leading column); if JPVT(J)=0, */ |
| 14566 | /* the J-th column of A is a free column. */ |
| 14567 | /* On exit, if JPVT(J)=K, then the J-th column of A*P was the */ |
| 14568 | /* the K-th column of A. */ |
| 14569 | |
| 14570 | /* TAU (output) DOUBLE PRECISION array, dimension (min(M,N)) */ |
| 14571 | /* The scalar factors of the elementary reflectors. */ |
| 14572 | |
| 14573 | /* WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) */ |
| 14574 | /* On exit, if INFO=0, WORK(1) returns the optimal LWORK. */ |
| 14575 | |
| 14576 | /* LWORK (input) INTEGER */ |
| 14577 | /* The dimension of the array WORK. LWORK >= 3*N+1. */ |
| 14578 | /* For optimal performance LWORK >= 2*N+( N+1 )*NB, where NB */ |
| 14579 | /* is the optimal blocksize. */ |
| 14580 | |
| 14581 | /* If LWORK = -1, then a workspace query is assumed; the routine */ |
| 14582 | /* only calculates the optimal size of the WORK array, returns */ |
| 14583 | /* this value as the first entry of the WORK array, and no error */ |
| 14584 | /* message related to LWORK is issued by XERBLA. */ |
| 14585 | |
| 14586 | /* INFO (output) INTEGER */ |
| 14587 | /* = 0: successful exit. */ |
| 14588 | /* < 0: if INFO = -i, the i-th argument had an illegal value. */ |
| 14589 | |
| 14590 | /* Further Details */ |
| 14591 | /* =============== */ |
| 14592 | |
| 14593 | /* The matrix Q is represented as a product of elementary reflectors */ |
| 14594 | |
| 14595 | /* Q = H(1) H(2) . . . H(k), where k = min(m,n). */ |
| 14596 | |
| 14597 | /* Each H(i) has the form */ |
| 14598 | |
| 14599 | /* H(i) = I - tau * v * v' */ |
| 14600 | |
| 14601 | /* where tau is a real/complex scalar, and v is a real/complex vector */ |
| 14602 | /* with v(1:i-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in */ |
| 14603 | /* A(i+1:m,i), and tau in TAU(i). */ |
| 14604 | |
| 14605 | /* Based on contributions by */ |
| 14606 | /* G. Quintana-Orti, Depto. de Informatica, Universidad Jaime I, Spain */ |
| 14607 | /* X. Sun, Computer Science Dept., Duke University, USA */ |
| 14608 | |
| 14609 | /* ===================================================================== */ |
| 14610 | |
| 14611 | /* .. Parameters .. */ |
| 14612 | /* .. */ |
| 14613 | /* .. Local Scalars .. */ |
| 14614 | /* .. */ |
| 14615 | /* .. External Subroutines .. */ |
| 14616 | /* .. */ |
| 14617 | /* .. External Functions .. */ |
| 14618 | /* .. */ |
| 14619 | /* .. Intrinsic Functions .. */ |
| 14620 | /* .. */ |
| 14621 | /* .. Executable Statements .. */ |
| 14622 | |
| 14623 | /* Test input arguments */ |
| 14624 | /* ==================== */ |
| 14625 | |
| 14626 | /* Parameter adjustments */ |
| 14627 | a_dim1 = *lda; |
| 14628 | a_offset = 1 + a_dim1; |
| 14629 | a -= a_offset; |
| 14630 | --jpvt; |
| 14631 | --tau; |
| 14632 | --work; |
| 14633 | |
| 14634 | /* Function Body */ |
| 14635 | *info = 0; |
| 14636 | lquery = *lwork == -1; |
| 14637 | if (*m < 0) { |
| 14638 | *info = -1; |
| 14639 | } else if (*n < 0) { |
| 14640 | *info = -2; |
| 14641 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*m)) { |
| 14642 | *info = -4; |
| 14643 | } |
| 14644 | |
| 14645 | if (*info == 0) { |
| 14646 | minmn = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(*m,*n); |
| 14647 | if (minmn == 0) { |
| 14648 | iws = 1; |
| 14649 | lwkopt = 1; |
| 14650 | } else { |
| 14651 | iws = *n * 3 + 1; |
| 14652 | nb = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEQRF", " ", m, n, &c_n1, &c_n1); |
| 14653 | lwkopt = (*n << 1) + (*n + 1) * nb; |
| 14654 | } |
| 14655 | work[1] = (double) lwkopt; |
| 14656 | |
| 14657 | if (*lwork < iws && ! lquery) { |
| 14658 | *info = -8; |
| 14659 | } |
| 14660 | } |
| 14661 | |
| 14662 | if (*info != 0) { |
| 14663 | i__1 = -(*info); |
| 14664 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGEQP3", &i__1); |
| 14665 | return 0; |
| 14666 | } else if (lquery) { |
| 14667 | return 0; |
| 14668 | } |
| 14669 | |
| 14670 | /* Quick return if possible. */ |
| 14671 | |
| 14672 | if (minmn == 0) { |
| 14673 | return 0; |
| 14674 | } |
| 14675 | |
| 14676 | /* Move initial columns up front. */ |
| 14677 | |
| 14678 | nfxd = 1; |
| 14679 | i__1 = *n; |
| 14680 | for (j = 1; j <= i__1; ++j) { |
| 14681 | if (jpvt[j] != 0) { |
| 14682 | if (j != nfxd) { |
| 14683 | dswap_cxx . . $ dswap_(ec261fd7ec3b6bf6).(m, &a[j * a_dim1 + 1], &c__1, &a[nfxd * a_dim1 + 1], & |
| 14684 | c__1); |
| 14685 | jpvt[j] = jpvt[nfxd]; |
| 14686 | jpvt[nfxd] = j; |
| 14687 | } else { |
| 14688 | jpvt[j] = j; |
| 14689 | } |
| 14690 | ++nfxd; |
| 14691 | } else { |
| 14692 | jpvt[j] = j; |
| 14693 | } |
| 14694 | /* L10: */ |
| 14695 | } |
| 14696 | --nfxd; |
| 14697 | |
| 14698 | /* Factorize fixed columns */ |
| 14699 | /* ======================= */ |
| 14700 | |
| 14701 | /* Compute the QR factorization of fixed columns and update */ |
| 14702 | /* remaining columns. */ |
| 14703 | |
| 14704 | if (nfxd > 0) { |
| 14705 | na = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(*m,nfxd); |
| 14706 | /* CC CALL DGEQR2( M, NA, A, LDA, TAU, WORK, INFO ) */ |
| 14707 | dgeqrf_cxx . . $ dgeqrf_(b2aaa174babf002e).(m, &na, &a[a_offset], lda, &tau[1], &work[1], lwork, info); |
| 14708 | /* Computing MAX */ |
| 14709 | i__1 = iws, i__2 = (integercxx . . $ integer#) work[1]; |
| 14710 | iws = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 14711 | if (na < *n) { |
| 14712 | /* CC CALL DORM2R( 'Left', 'Transpose', M, N-NA, NA, A, LDA, */ |
| 14713 | /* CC $ TAU, A( 1, NA+1 ), LDA, WORK, INFO ) */ |
| 14714 | i__1 = *n - na; |
| 14715 | dormqr_cxx . . $ dormqr_(c6b7238dd97e9cf9).("Left", "Transpose", m, &i__1, &na, &a[a_offset], lda, & |
| 14716 | tau[1], &a[(na + 1) * a_dim1 + 1], lda, &work[1], lwork, |
| 14717 | info); |
| 14718 | /* Computing MAX */ |
| 14719 | i__1 = iws, i__2 = (integercxx . . $ integer#) work[1]; |
| 14720 | iws = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 14721 | } |
| 14722 | } |
| 14723 | |
| 14724 | /* Factorize free columns */ |
| 14725 | /* ====================== */ |
| 14726 | |
| 14727 | if (nfxd < minmn) { |
| 14728 | |
| 14729 | sm = *m - nfxd; |
| 14730 | sn = *n - nfxd; |
| 14731 | sminmn = minmn - nfxd; |
| 14732 | |
| 14733 | /* Determine the block size. */ |
| 14734 | |
| 14735 | nb = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEQRF", " ", &sm, &sn, &c_n1, &c_n1); |
| 14736 | nbmin = 2; |
| 14737 | nx = 0; |
| 14738 | |
| 14739 | if (nb > 1 && nb < sminmn) { |
| 14740 | |
| 14741 | /* Determine when to cross over from blocked to unblocked code. */ |
| 14742 | |
| 14743 | /* Computing MAX */ |
| 14744 | i__1 = 0, i__2 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__3, "DGEQRF", " ", &sm, &sn, &c_n1, & |
| 14745 | c_n1); |
| 14746 | nx = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 14747 | |
| 14748 | |
| 14749 | if (nx < sminmn) { |
| 14750 | |
| 14751 | /* Determine if workspace is large enough for blocked code. */ |
| 14752 | |
| 14753 | minws = (sn << 1) + (sn + 1) * nb; |
| 14754 | iws = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(iws,minws); |
| 14755 | if (*lwork < minws) { |
| 14756 | |
| 14757 | /* Not enough workspace to use optimal NB: Reduce NB and */ |
| 14758 | /* determine the minimum value of NB. */ |
| 14759 | |
| 14760 | nb = (*lwork - (sn << 1)) / (sn + 1); |
| 14761 | /* Computing MAX */ |
| 14762 | i__1 = 2, i__2 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__2, "DGEQRF", " ", &sm, &sn, & |
| 14763 | c_n1, &c_n1); |
| 14764 | nbmin = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 14765 | |
| 14766 | |
| 14767 | } |
| 14768 | } |
| 14769 | } |
| 14770 | |
| 14771 | /* Initialize partial column norms. The first N elements of work */ |
| 14772 | /* store the exact column norms. */ |
| 14773 | |
| 14774 | i__1 = *n; |
| 14775 | for (j = nfxd + 1; j <= i__1; ++j) { |
| 14776 | work[j] = dnrm2_cxx . . $ dnrm2_(c4756756b043e0f).(&sm, &a[nfxd + 1 + j * a_dim1], &c__1); |
| 14777 | work[*n + j] = work[j]; |
| 14778 | /* L20: */ |
| 14779 | } |
| 14780 | |
| 14781 | if (nb >= nbmin && nb < sminmn && nx < sminmn) { |
| 14782 | |
| 14783 | /* Use blocked code initially. */ |
| 14784 | |
| 14785 | j = nfxd + 1; |
| 14786 | |
| 14787 | /* Compute factorization: while loop. */ |
| 14788 | |
| 14789 | |
| 14790 | topbmn = minmn - nx; |
| 14791 | L30: |
| 14792 | if (j <= topbmn) { |
| 14793 | /* Computing MIN */ |
| 14794 | i__1 = nb, i__2 = topbmn - j + 1; |
| 14795 | jb = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__1,i__2); |
| 14796 | |
| 14797 | /* Factorize JB columns among columns J:N. */ |
| 14798 | |
| 14799 | i__1 = *n - j + 1; |
| 14800 | i__2 = j - 1; |
| 14801 | i__3 = *n - j + 1; |
| 14802 | dlaqps_cxx . . $ dlaqps_(edf37998d04439c3).(m, &i__1, &i__2, &jb, &fjb, &a[j * a_dim1 + 1], lda, & |
| 14803 | jpvt[j], &tau[j], &work[j], &work[*n + j], &work[(*n |
| 14804 | << 1) + 1], &work[(*n << 1) + jb + 1], &i__3); |
| 14805 | |
| 14806 | j += fjb; |
| 14807 | goto L30; |
| 14808 | } |
| 14809 | } else { |
| 14810 | j = nfxd + 1; |
| 14811 | } |
| 14812 | |
| 14813 | /* Use unblocked code to factor the last or only block. */ |
| 14814 | |
| 14815 | |
| 14816 | if (j <= minmn) { |
| 14817 | i__1 = *n - j + 1; |
| 14818 | i__2 = j - 1; |
| 14819 | dlaqp2_cxx . . $ dlaqp2_(771d6dc5f8bf21eb).(m, &i__1, &i__2, &a[j * a_dim1 + 1], lda, &jpvt[j], &tau[ |
| 14820 | j], &work[j], &work[*n + j], &work[(*n << 1) + 1]); |
| 14821 | } |
| 14822 | |
| 14823 | } |
| 14824 | |
| 14825 | work[1] = (double) iws; |
| 14826 | return 0; |
| 14827 | |
| 14828 | /* End of DGEQP3 */ |
| 14829 | |
| 14830 | } /* dgeqp3_ */ |
| 14831 | |
| 14832 | /* Subroutine */ int dgeqpf_cxx . . $ dgeqpf_(89014a123b88d601).(integercxx . . $ integer# *m, integercxx . . $ integer# *n, double *a, integercxx . . $ integer# * |
| 14833 | lda, integercxx . . $ integer# *jpvt, double *tau, double *work, integercxx . . $ integer# *info) |
| 14834 | { |
| 14835 | /* Table of constant values */ |
| 14836 | static integercxx . . $ integer# c__1 = 1; |
| 14837 | |
| 14838 | /* System generated locals */ |
| 14839 | integercxx . . $ integer# a_dim1, a_offset, i__1, i__2, i__3; |
| 14840 | double d__1, d__2; |
| 14841 | |
| 14842 | /* Local variables */ |
| 14843 | integercxx . . $ integer# i__, j, ma, mn; |
| 14844 | double aii; |
| 14845 | integercxx . . $ integer# pvt; |
| 14846 | double temp; |
| 14847 | double temp2, tol3z; |
| 14848 | integercxx . . $ integer# itemp; |
| 14849 | |
| 14850 | /* -- LAPACK deprecated driver routine (version 3.2) -- */ |
| 14851 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 14852 | /* November 2006 */ |
| 14853 | |
| 14854 | /* .. Scalar Arguments .. */ |
| 14855 | /* .. */ |
| 14856 | /* .. Array Arguments .. */ |
| 14857 | /* .. */ |
| 14858 | |
| 14859 | /* Purpose */ |
| 14860 | /* ======= */ |
| 14861 | |
| 14862 | /* This routine is deprecated and has been replaced by routine DGEQP3. */ |
| 14863 | |
| 14864 | /* DGEQPF computes a QR factorization with column pivoting of a */ |
| 14865 | /* real M-by-N matrix A: A*P = Q*R. */ |
| 14866 | |
| 14867 | /* Arguments */ |
| 14868 | /* ========= */ |
| 14869 | |
| 14870 | /* M (input) INTEGER */ |
| 14871 | /* The number of rows of the matrix A. M >= 0. */ |
| 14872 | |
| 14873 | /* N (input) INTEGER */ |
| 14874 | /* The number of columns of the matrix A. N >= 0 */ |
| 14875 | |
| 14876 | /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 14877 | /* On entry, the M-by-N matrix A. */ |
| 14878 | /* On exit, the upper triangle of the array contains the */ |
| 14879 | /* min(M,N)-by-N upper triangular matrix R; the elements */ |
| 14880 | /* below the diagonal, together with the array TAU, */ |
| 14881 | /* represent the orthogonal matrix Q as a product of */ |
| 14882 | /* min(m,n) elementary reflectors. */ |
| 14883 | |
| 14884 | /* LDA (input) INTEGER */ |
| 14885 | /* The leading dimension of the array A. LDA >= max(1,M). */ |
| 14886 | |
| 14887 | /* JPVT (input/output) INTEGER array, dimension (N) */ |
| 14888 | /* On entry, if JPVT(i) .ne. 0, the i-th column of A is permuted */ |
| 14889 | /* to the front of A*P (a leading column); if JPVT(i) = 0, */ |
| 14890 | /* the i-th column of A is a free column. */ |
| 14891 | /* On exit, if JPVT(i) = k, then the i-th column of A*P */ |
| 14892 | /* was the k-th column of A. */ |
| 14893 | |
| 14894 | /* TAU (output) DOUBLE PRECISION array, dimension (min(M,N)) */ |
| 14895 | /* The scalar factors of the elementary reflectors. */ |
| 14896 | |
| 14897 | /* WORK (workspace) DOUBLE PRECISION array, dimension (3*N) */ |
| 14898 | |
| 14899 | /* INFO (output) INTEGER */ |
| 14900 | /* = 0: successful exit */ |
| 14901 | /* < 0: if INFO = -i, the i-th argument had an illegal value */ |
| 14902 | |
| 14903 | /* Further Details */ |
| 14904 | /* =============== */ |
| 14905 | |
| 14906 | /* The matrix Q is represented as a product of elementary reflectors */ |
| 14907 | |
| 14908 | /* Q = H(1) H(2) . . . H(n) */ |
| 14909 | |
| 14910 | /* Each H(i) has the form */ |
| 14911 | |
| 14912 | /* H = I - tau * v * v' */ |
| 14913 | |
| 14914 | /* where tau is a real scalar, and v is a real vector with */ |
| 14915 | /* v(1:i-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in A(i+1:m,i). */ |
| 14916 | |
| 14917 | /* The matrix P is represented in jpvt as follows: If */ |
| 14918 | /* jpvt(j) = i */ |
| 14919 | /* then the jth column of P is the ith canonical unit vector. */ |
| 14920 | |
| 14921 | /* Partial column norm updating strategy modified by */ |
| 14922 | /* Z. Drmac and Z. Bujanovic, Dept. of Mathematics, */ |
| 14923 | /* University of Zagreb, Croatia. */ |
| 14924 | /* June 2006. */ |
| 14925 | /* For more details see LAPACK Working Note 176. */ |
| 14926 | |
| 14927 | /* ===================================================================== */ |
| 14928 | |
| 14929 | /* .. Parameters .. */ |
| 14930 | /* .. */ |
| 14931 | /* .. Local Scalars .. */ |
| 14932 | /* .. */ |
| 14933 | /* .. External Subroutines .. */ |
| 14934 | /* .. */ |
| 14935 | /* .. Intrinsic Functions .. */ |
| 14936 | /* .. */ |
| 14937 | /* .. External Functions .. */ |
| 14938 | /* .. */ |
| 14939 | /* .. Executable Statements .. */ |
| 14940 | |
| 14941 | /* Test the input arguments */ |
| 14942 | |
| 14943 | /* Parameter adjustments */ |
| 14944 | a_dim1 = *lda; |
| 14945 | a_offset = 1 + a_dim1; |
| 14946 | a -= a_offset; |
| 14947 | --jpvt; |
| 14948 | --tau; |
| 14949 | --work; |
| 14950 | |
| 14951 | /* Function Body */ |
| 14952 | *info = 0; |
| 14953 | if (*m < 0) { |
| 14954 | *info = -1; |
| 14955 | } else if (*n < 0) { |
| 14956 | *info = -2; |
| 14957 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*m)) { |
| 14958 | *info = -4; |
| 14959 | } |
| 14960 | if (*info != 0) { |
| 14961 | i__1 = -(*info); |
| 14962 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGEQPF", &i__1); |
| 14963 | return 0; |
| 14964 | } |
| 14965 | |
| 14966 | mn = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(*m,*n); |
| 14967 | tol3z = sqrtcxx . . $ sqrt(fee4f1d22bc8e617).(dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("Epsilon")); |
| 14968 | |
| 14969 | /* Move initial columns up front */ |
| 14970 | |
| 14971 | itemp = 1; |
| 14972 | i__1 = *n; |
| 14973 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 14974 | if (jpvt[i__] != 0) { |
| 14975 | if (i__ != itemp) { |
| 14976 | dswap_cxx . . $ dswap_(ec261fd7ec3b6bf6).(m, &a[i__ * a_dim1 + 1], &c__1, &a[itemp * a_dim1 + 1], |
| 14977 | &c__1); |
| 14978 | jpvt[i__] = jpvt[itemp]; |
| 14979 | jpvt[itemp] = i__; |
| 14980 | } else { |
| 14981 | jpvt[i__] = i__; |
| 14982 | } |
| 14983 | ++itemp; |
| 14984 | } else { |
| 14985 | jpvt[i__] = i__; |
| 14986 | } |
| 14987 | /* L10: */ |
| 14988 | } |
| 14989 | --itemp; |
| 14990 | |
| 14991 | /* Compute the QR factorization and update remaining columns */ |
| 14992 | |
| 14993 | if (itemp > 0) { |
| 14994 | ma = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(itemp,*m); |
| 14995 | dgeqr2_cxx . . $ dgeqr2_(19b4abe06ca5e75b).(m, &ma, &a[a_offset], lda, &tau[1], &work[1], info); |
| 14996 | if (ma < *n) { |
| 14997 | i__1 = *n - ma; |
| 14998 | dorm2r_cxx . . $ dorm2r_(2f7504592752aead).("Left", "Transpose", m, &i__1, &ma, &a[a_offset], lda, & |
| 14999 | tau[1], &a[(ma + 1) * a_dim1 + 1], lda, &work[1], info); |
| 15000 | } |
| 15001 | } |
| 15002 | |
| 15003 | if (itemp < mn) { |
| 15004 | |
| 15005 | /* Initialize partial column norms. The first n elements of */ |
| 15006 | /* work store the exact column norms. */ |
| 15007 | |
| 15008 | i__1 = *n; |
| 15009 | for (i__ = itemp + 1; i__ <= i__1; ++i__) { |
| 15010 | i__2 = *m - itemp; |
| 15011 | work[i__] = dnrm2_cxx . . $ dnrm2_(c4756756b043e0f).(&i__2, &a[itemp + 1 + i__ * a_dim1], &c__1); |
| 15012 | work[*n + i__] = work[i__]; |
| 15013 | /* L20: */ |
| 15014 | } |
| 15015 | |
| 15016 | /* Compute factorization */ |
| 15017 | |
| 15018 | i__1 = mn; |
| 15019 | for (i__ = itemp + 1; i__ <= i__1; ++i__) { |
| 15020 | |
| 15021 | /* Determine ith pivot column and swap if necessary */ |
| 15022 | |
| 15023 | i__2 = *n - i__ + 1; |
| 15024 | pvt = i__ - 1 + idamax_cxx . . $ idamax_(a5c31fbfbc00ee45).(&i__2, &work[i__], &c__1); |
| 15025 | |
| 15026 | if (pvt != i__) { |
| 15027 | dswap_cxx . . $ dswap_(ec261fd7ec3b6bf6).(m, &a[pvt * a_dim1 + 1], &c__1, &a[i__ * a_dim1 + 1], & |
| 15028 | c__1); |
| 15029 | itemp = jpvt[pvt]; |
| 15030 | jpvt[pvt] = jpvt[i__]; |
| 15031 | jpvt[i__] = itemp; |
| 15032 | work[pvt] = work[i__]; |
| 15033 | work[*n + pvt] = work[*n + i__]; |
| 15034 | } |
| 15035 | |
| 15036 | /* Generate elementary reflector H(i) */ |
| 15037 | |
| 15038 | if (i__ < *m) { |
| 15039 | i__2 = *m - i__ + 1; |
| 15040 | dlarfp_cxx . . $ dlarfp_(ae28ee921df873ff).(&i__2, &a[i__ + i__ * a_dim1], &a[i__ + 1 + i__ * |
| 15041 | a_dim1], &c__1, &tau[i__]); |
| 15042 | } else { |
| 15043 | dlarfp_cxx . . $ dlarfp_(ae28ee921df873ff).(&c__1, &a[*m + *m * a_dim1], &a[*m + *m * a_dim1], & |
| 15044 | c__1, &tau[*m]); |
| 15045 | } |
| 15046 | |
| 15047 | if (i__ < *n) { |
| 15048 | |
| 15049 | /* Apply H(i) to A(i:m,i+1:n) from the left */ |
| 15050 | |
| 15051 | aii = a[i__ + i__ * a_dim1]; |
| 15052 | a[i__ + i__ * a_dim1] = 1.; |
| 15053 | i__2 = *m - i__ + 1; |
| 15054 | i__3 = *n - i__; |
| 15055 | dlarf_cxx . . $ dlarf_(f67bbcf4c4b4eb96).("LEFT", &i__2, &i__3, &a[i__ + i__ * a_dim1], &c__1, & |
| 15056 | tau[i__], &a[i__ + (i__ + 1) * a_dim1], lda, &work[(* |
| 15057 | n << 1) + 1]); |
| 15058 | a[i__ + i__ * a_dim1] = aii; |
| 15059 | } |
| 15060 | |
| 15061 | /* Update partial column norms */ |
| 15062 | |
| 15063 | i__2 = *n; |
| 15064 | for (j = i__ + 1; j <= i__2; ++j) { |
| 15065 | if (work[j] != 0.) { |
| 15066 | |
| 15067 | /* NOTE: The following 4 lines follow from the analysis in */ |
| 15068 | /* Lapack Working Note 176. */ |
| 15069 | |
| 15070 | temp = (d__1 = a[i__ + j * a_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__1)) / work[j]; |
| 15071 | /* Computing MAX */ |
| 15072 | d__1 = 0., d__2 = (temp + 1.) * (1. - temp); |
| 15073 | temp = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__1,d__2); |
| 15074 | /* Computing 2nd power */ |
| 15075 | d__1 = work[j] / work[*n + j]; |
| 15076 | temp2 = temp * (d__1 * d__1); |
| 15077 | if (temp2 <= tol3z) { |
| 15078 | if (*m - i__ > 0) { |
| 15079 | i__3 = *m - i__; |
| 15080 | work[j] = dnrm2_cxx . . $ dnrm2_(c4756756b043e0f).(&i__3, &a[i__ + 1 + j * a_dim1], |
| 15081 | &c__1); |
| 15082 | work[*n + j] = work[j]; |
| 15083 | } else { |
| 15084 | work[j] = 0.; |
| 15085 | work[*n + j] = 0.; |
| 15086 | } |
| 15087 | } else { |
| 15088 | work[j] *= sqrtcxx . . $ sqrt(fee4f1d22bc8e617).(temp); |
| 15089 | } |
| 15090 | } |
| 15091 | /* L30: */ |
| 15092 | } |
| 15093 | |
| 15094 | /* L40: */ |
| 15095 | } |
| 15096 | } |
| 15097 | return 0; |
| 15098 | |
| 15099 | /* End of DGEQPF */ |
| 15100 | |
| 15101 | } /* dgeqpf_ */ |
| 15102 | |
| 15103 | /* Subroutine */ int dgeqr2_cxx . . $ dgeqr2_(19b4abe06ca5e75b).(integercxx . . $ integer# *m, integercxx . . $ integer# *n, double *a, integercxx . . $ integer# * |
| 15104 | lda, double *tau, double *work, integercxx . . $ integer# *info) |
| 15105 | { |
| 15106 | /* Table of constant values */ |
| 15107 | static integercxx . . $ integer# c__1 = 1; |
| 15108 | |
| 15109 | /* System generated locals */ |
| 15110 | integercxx . . $ integer# a_dim1, a_offset, i__1, i__2, i__3; |
| 15111 | |
| 15112 | /* Local variables */ |
| 15113 | integercxx . . $ integer# i__, k; |
| 15114 | double aii; |
| 15115 | |
| 15116 | /* -- LAPACK routine (version 3.1) -- */ |
| 15117 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 15118 | /* November 2006 */ |
| 15119 | |
| 15120 | /* .. Scalar Arguments .. */ |
| 15121 | /* .. */ |
| 15122 | /* .. Array Arguments .. */ |
| 15123 | /* .. */ |
| 15124 | |
| 15125 | /* Purpose */ |
| 15126 | /* ======= */ |
| 15127 | |
| 15128 | /* DGEQR2 computes a QR factorization of a real m by n matrix A: */ |
| 15129 | /* A = Q * R. */ |
| 15130 | |
| 15131 | /* Arguments */ |
| 15132 | /* ========= */ |
| 15133 | |
| 15134 | /* M (input) INTEGER */ |
| 15135 | /* The number of rows of the matrix A. M >= 0. */ |
| 15136 | |
| 15137 | /* N (input) INTEGER */ |
| 15138 | /* The number of columns of the matrix A. N >= 0. */ |
| 15139 | |
| 15140 | /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 15141 | /* On entry, the m by n matrix A. */ |
| 15142 | /* On exit, the elements on and above the diagonal of the array */ |
| 15143 | /* contain the min(m,n) by n upper trapezoidal matrix R (R is */ |
| 15144 | /* upper triangular if m >= n); the elements below the diagonal, */ |
| 15145 | /* with the array TAU, represent the orthogonal matrix Q as a */ |
| 15146 | /* product of elementary reflectors (see Further Details). */ |
| 15147 | |
| 15148 | /* LDA (input) INTEGER */ |
| 15149 | /* The leading dimension of the array A. LDA >= max(1,M). */ |
| 15150 | |
| 15151 | /* TAU (output) DOUBLE PRECISION array, dimension (min(M,N)) */ |
| 15152 | /* The scalar factors of the elementary reflectors (see Further */ |
| 15153 | /* Details). */ |
| 15154 | |
| 15155 | /* WORK (workspace) DOUBLE PRECISION array, dimension (N) */ |
| 15156 | |
| 15157 | /* INFO (output) INTEGER */ |
| 15158 | /* = 0: successful exit */ |
| 15159 | /* < 0: if INFO = -i, the i-th argument had an illegal value */ |
| 15160 | |
| 15161 | /* Further Details */ |
| 15162 | /* =============== */ |
| 15163 | |
| 15164 | /* The matrix Q is represented as a product of elementary reflectors */ |
| 15165 | |
| 15166 | /* Q = H(1) H(2) . . . H(k), where k = min(m,n). */ |
| 15167 | |
| 15168 | /* Each H(i) has the form */ |
| 15169 | |
| 15170 | /* H(i) = I - tau * v * v' */ |
| 15171 | |
| 15172 | /* where tau is a real scalar, and v is a real vector with */ |
| 15173 | /* v(1:i-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in A(i+1:m,i), */ |
| 15174 | /* and tau in TAU(i). */ |
| 15175 | |
| 15176 | /* ===================================================================== */ |
| 15177 | |
| 15178 | /* .. Parameters .. */ |
| 15179 | /* .. */ |
| 15180 | /* .. Local Scalars .. */ |
| 15181 | /* .. */ |
| 15182 | /* .. External Subroutines .. */ |
| 15183 | /* .. */ |
| 15184 | /* .. Intrinsic Functions .. */ |
| 15185 | /* .. */ |
| 15186 | /* .. Executable Statements .. */ |
| 15187 | |
| 15188 | /* Test the input arguments */ |
| 15189 | |
| 15190 | /* Parameter adjustments */ |
| 15191 | a_dim1 = *lda; |
| 15192 | a_offset = 1 + a_dim1; |
| 15193 | a -= a_offset; |
| 15194 | --tau; |
| 15195 | --work; |
| 15196 | |
| 15197 | /* Function Body */ |
| 15198 | *info = 0; |
| 15199 | if (*m < 0) { |
| 15200 | *info = -1; |
| 15201 | } else if (*n < 0) { |
| 15202 | *info = -2; |
| 15203 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*m)) { |
| 15204 | *info = -4; |
| 15205 | } |
| 15206 | if (*info != 0) { |
| 15207 | i__1 = -(*info); |
| 15208 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGEQR2", &i__1); |
| 15209 | return 0; |
| 15210 | } |
| 15211 | |
| 15212 | k = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(*m,*n); |
| 15213 | |
| 15214 | i__1 = k; |
| 15215 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 15216 | |
| 15217 | /* Generate elementary reflector H(i) to annihilate A(i+1:m,i) */ |
| 15218 | |
| 15219 | i__2 = *m - i__ + 1; |
| 15220 | /* Computing MIN */ |
| 15221 | i__3 = i__ + 1; |
| 15222 | dlarfp_cxx . . $ dlarfp_(ae28ee921df873ff).(&i__2, &a[i__ + i__ * a_dim1], &a[stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__3, *m)+ i__ * a_dim1] |
| 15223 | , &c__1, &tau[i__]); |
| 15224 | if (i__ < *n) { |
| 15225 | |
| 15226 | /* Apply H(i) to A(i:m,i+1:n) from the left */ |
| 15227 | |
| 15228 | aii = a[i__ + i__ * a_dim1]; |
| 15229 | a[i__ + i__ * a_dim1] = 1.; |
| 15230 | i__2 = *m - i__ + 1; |
| 15231 | i__3 = *n - i__; |
| 15232 | dlarf_cxx . . $ dlarf_(f67bbcf4c4b4eb96).("Left", &i__2, &i__3, &a[i__ + i__ * a_dim1], &c__1, &tau[ |
| 15233 | i__], &a[i__ + (i__ + 1) * a_dim1], lda, &work[1]); |
| 15234 | a[i__ + i__ * a_dim1] = aii; |
| 15235 | } |
| 15236 | /* L10: */ |
| 15237 | } |
| 15238 | return 0; |
| 15239 | |
| 15240 | /* End of DGEQR2 */ |
| 15241 | |
| 15242 | } /* dgeqr2_ */ |
| 15243 | |
| 15244 | |
| 15245 | /* Subroutine */ int dgeqrf_cxx . . $ dgeqrf_(b2aaa174babf002e).(integercxx . . $ integer# *m, integercxx . . $ integer# *n, double *a, integercxx . . $ integer# * |
| 15246 | lda, double *tau, double *work, integercxx . . $ integer# *lwork, integercxx . . $ integer# *info) |
| 15247 | { |
| 15248 | /* Table of constant values */ |
| 15249 | static integercxx . . $ integer# c__1 = 1; |
| 15250 | static integercxx . . $ integer# c_n1 = -1; |
| 15251 | static integercxx . . $ integer# c__3 = 3; |
| 15252 | static integercxx . . $ integer# c__2 = 2; |
| 15253 | |
| 15254 | /* System generated locals */ |
| 15255 | integercxx . . $ integer# a_dim1, a_offset, i__1, i__2, i__3, i__4; |
| 15256 | |
| 15257 | /* Local variables */ |
| 15258 | integercxx . . $ integer# i__, k, ib, nb, nx, iws, nbmin, iinfo; |
| 15259 | integercxx . . $ integer# ldwork, lwkopt; |
| 15260 | bool lquery; |
| 15261 | |
| 15262 | |
| 15263 | /* -- LAPACK routine (version 3.1) -- */ |
| 15264 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 15265 | /* November 2006 */ |
| 15266 | |
| 15267 | /* .. Scalar Arguments .. */ |
| 15268 | /* .. */ |
| 15269 | /* .. Array Arguments .. */ |
| 15270 | /* .. */ |
| 15271 | |
| 15272 | /* Purpose */ |
| 15273 | /* ======= */ |
| 15274 | |
| 15275 | /* DGEQRF computes a QR factorization of a real M-by-N matrix A: */ |
| 15276 | /* A = Q * R. */ |
| 15277 | |
| 15278 | /* Arguments */ |
| 15279 | /* ========= */ |
| 15280 | |
| 15281 | /* M (input) INTEGER */ |
| 15282 | /* The number of rows of the matrix A. M >= 0. */ |
| 15283 | |
| 15284 | /* N (input) INTEGER */ |
| 15285 | /* The number of columns of the matrix A. N >= 0. */ |
| 15286 | |
| 15287 | /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 15288 | /* On entry, the M-by-N matrix A. */ |
| 15289 | /* On exit, the elements on and above the diagonal of the array */ |
| 15290 | /* contain the min(M,N)-by-N upper trapezoidal matrix R (R is */ |
| 15291 | /* upper triangular if m >= n); the elements below the diagonal, */ |
| 15292 | /* with the array TAU, represent the orthogonal matrix Q as a */ |
| 15293 | /* product of min(m,n) elementary reflectors (see Further */ |
| 15294 | /* Details). */ |
| 15295 | |
| 15296 | /* LDA (input) INTEGER */ |
| 15297 | /* The leading dimension of the array A. LDA >= max(1,M). */ |
| 15298 | |
| 15299 | /* TAU (output) DOUBLE PRECISION array, dimension (min(M,N)) */ |
| 15300 | /* The scalar factors of the elementary reflectors (see Further */ |
| 15301 | /* Details). */ |
| 15302 | |
| 15303 | /* WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) */ |
| 15304 | /* On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ |
| 15305 | |
| 15306 | /* LWORK (input) INTEGER */ |
| 15307 | /* The dimension of the array WORK. LWORK >= max(1,N). */ |
| 15308 | /* For optimum performance LWORK >= N*NB, where NB is */ |
| 15309 | /* the optimal blocksize. */ |
| 15310 | |
| 15311 | /* If LWORK = -1, then a workspace query is assumed; the routine */ |
| 15312 | /* only calculates the optimal size of the WORK array, returns */ |
| 15313 | /* this value as the first entry of the WORK array, and no error */ |
| 15314 | /* message related to LWORK is issued by XERBLA. */ |
| 15315 | |
| 15316 | /* INFO (output) INTEGER */ |
| 15317 | /* = 0: successful exit */ |
| 15318 | /* < 0: if INFO = -i, the i-th argument had an illegal value */ |
| 15319 | |
| 15320 | /* Further Details */ |
| 15321 | /* =============== */ |
| 15322 | |
| 15323 | /* The matrix Q is represented as a product of elementary reflectors */ |
| 15324 | |
| 15325 | /* Q = H(1) H(2) . . . H(k), where k = min(m,n). */ |
| 15326 | |
| 15327 | /* Each H(i) has the form */ |
| 15328 | |
| 15329 | /* H(i) = I - tau * v * v' */ |
| 15330 | |
| 15331 | /* where tau is a real scalar, and v is a real vector with */ |
| 15332 | /* v(1:i-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in A(i+1:m,i), */ |
| 15333 | /* and tau in TAU(i). */ |
| 15334 | |
| 15335 | /* ===================================================================== */ |
| 15336 | |
| 15337 | /* .. Local Scalars .. */ |
| 15338 | /* .. */ |
| 15339 | /* .. External Subroutines .. */ |
| 15340 | /* .. */ |
| 15341 | /* .. Intrinsic Functions .. */ |
| 15342 | /* .. */ |
| 15343 | /* .. External Functions .. */ |
| 15344 | /* .. */ |
| 15345 | /* .. Executable Statements .. */ |
| 15346 | |
| 15347 | /* Test the input arguments */ |
| 15348 | |
| 15349 | /* Parameter adjustments */ |
| 15350 | a_dim1 = *lda; |
| 15351 | a_offset = 1 + a_dim1; |
| 15352 | a -= a_offset; |
| 15353 | --tau; |
| 15354 | --work; |
| 15355 | |
| 15356 | /* Function Body */ |
| 15357 | *info = 0; |
| 15358 | nb = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEQRF", " ", m, n, &c_n1, &c_n1); |
| 15359 | lwkopt = *n * nb; |
| 15360 | work[1] = (double) lwkopt; |
| 15361 | lquery = *lwork == -1; |
| 15362 | if (*m < 0) { |
| 15363 | *info = -1; |
| 15364 | } else if (*n < 0) { |
| 15365 | *info = -2; |
| 15366 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*m)) { |
| 15367 | *info = -4; |
| 15368 | } else if (*lwork < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n) && ! lquery) { |
| 15369 | *info = -7; |
| 15370 | } |
| 15371 | if (*info != 0) { |
| 15372 | i__1 = -(*info); |
| 15373 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGEQRF", &i__1); |
| 15374 | return 0; |
| 15375 | } else if (lquery) { |
| 15376 | return 0; |
| 15377 | } |
| 15378 | |
| 15379 | /* Quick return if possible */ |
| 15380 | |
| 15381 | k = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(*m,*n); |
| 15382 | if (k == 0) { |
| 15383 | work[1] = 1.; |
| 15384 | return 0; |
| 15385 | } |
| 15386 | |
| 15387 | nbmin = 2; |
| 15388 | nx = 0; |
| 15389 | iws = *n; |
| 15390 | if (nb > 1 && nb < k) { |
| 15391 | |
| 15392 | /* Determine when to cross over from blocked to unblocked code. */ |
| 15393 | |
| 15394 | /* Computing MAX */ |
| 15395 | i__1 = 0, i__2 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__3, "DGEQRF", " ", m, n, &c_n1, &c_n1); |
| 15396 | nx = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 15397 | if (nx < k) { |
| 15398 | |
| 15399 | /* Determine if workspace is large enough for blocked code. */ |
| 15400 | |
| 15401 | ldwork = *n; |
| 15402 | iws = ldwork * nb; |
| 15403 | if (*lwork < iws) { |
| 15404 | |
| 15405 | /* Not enough workspace to use optimal NB: reduce NB and */ |
| 15406 | /* determine the minimum value of NB. */ |
| 15407 | |
| 15408 | nb = *lwork / ldwork; |
| 15409 | /* Computing MAX */ |
| 15410 | i__1 = 2, i__2 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__2, "DGEQRF", " ", m, n, &c_n1, & |
| 15411 | c_n1); |
| 15412 | nbmin = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 15413 | } |
| 15414 | } |
| 15415 | } |
| 15416 | |
| 15417 | if (nb >= nbmin && nb < k && nx < k) { |
| 15418 | |
| 15419 | /* Use blocked code initially */ |
| 15420 | |
| 15421 | i__1 = k - nx; |
| 15422 | i__2 = nb; |
| 15423 | for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) { |
| 15424 | /* Computing MIN */ |
| 15425 | i__3 = k - i__ + 1; |
| 15426 | ib = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__3,nb); |
| 15427 | |
| 15428 | /* Compute the QR factorization of the current block */ |
| 15429 | /* A(i:m,i:i+ib-1) */ |
| 15430 | |
| 15431 | i__3 = *m - i__ + 1; |
| 15432 | dgeqr2_cxx . . $ dgeqr2_(19b4abe06ca5e75b).(&i__3, &ib, &a[i__ + i__ * a_dim1], lda, &tau[i__], &work[ |
| 15433 | 1], &iinfo); |
| 15434 | if (i__ + ib <= *n) { |
| 15435 | |
| 15436 | /* Form the triangular factor of the block reflector */ |
| 15437 | /* H = H(i) H(i+1) . . . H(i+ib-1) */ |
| 15438 | |
| 15439 | i__3 = *m - i__ + 1; |
| 15440 | dlarft_cxx . . $ dlarft_(9d83c62c83e92799).("Forward", "Columnwise", &i__3, &ib, &a[i__ + i__ * |
| 15441 | a_dim1], lda, &tau[i__], &work[1], &ldwork); |
| 15442 | |
| 15443 | /* Apply H' to A(i:m,i+ib:n) from the left */ |
| 15444 | |
| 15445 | i__3 = *m - i__ + 1; |
| 15446 | i__4 = *n - i__ - ib + 1; |
| 15447 | dlarfb_cxx . . $ dlarfb_(b0af75de90da309c).("Left", "Transpose", "Forward", "Columnwise", &i__3, & |
| 15448 | i__4, &ib, &a[i__ + i__ * a_dim1], lda, &work[1], & |
| 15449 | ldwork, &a[i__ + (i__ + ib) * a_dim1], lda, &work[ib |
| 15450 | + 1], &ldwork); |
| 15451 | } |
| 15452 | /* L10: */ |
| 15453 | } |
| 15454 | } else { |
| 15455 | i__ = 1; |
| 15456 | } |
| 15457 | |
| 15458 | /* Use unblocked code to factor the last or only block. */ |
| 15459 | |
| 15460 | if (i__ <= k) { |
| 15461 | i__2 = *m - i__ + 1; |
| 15462 | i__1 = *n - i__ + 1; |
| 15463 | dgeqr2_cxx . . $ dgeqr2_(19b4abe06ca5e75b).(&i__2, &i__1, &a[i__ + i__ * a_dim1], lda, &tau[i__], &work[1] |
| 15464 | , &iinfo); |
| 15465 | } |
| 15466 | |
| 15467 | work[1] = (double) iws; |
| 15468 | return 0; |
| 15469 | |
| 15470 | /* End of DGEQRF */ |
| 15471 | |
| 15472 | } /* dgeqrf_ */ |
| 15473 | |
| 15474 | /* Subroutine */ int dgerfs_cxx . . $ dgerfs_(1ca1405a8fa14711).(const char *trans, integercxx . . $ integer# *n, integercxx . . $ integer# *nrhs, |
| 15475 | double *a, integercxx . . $ integer# *lda, double *af, integercxx . . $ integer# *ldaf, integercxx . . $ integer# * |
| 15476 | ipiv, double *b, integercxx . . $ integer# *ldb, double *x, integercxx . . $ integer# *ldx, |
| 15477 | double *ferr, double *berr, double *work, integercxx . . $ integer# *iwork, |
| 15478 | integercxx . . $ integer# *info) |
| 15479 | { |
| 15480 | /* Table of constant values */ |
| 15481 | static integercxx . . $ integer# c__1 = 1; |
| 15482 | static double c_b15 = -1.; |
| 15483 | static double c_b17 = 1.; |
| 15484 | |
| 15485 | /* System generated locals */ |
| 15486 | integercxx . . $ integer# a_dim1, a_offset, af_dim1, af_offset, b_dim1, b_offset, x_dim1, |
| 15487 | x_offset, i__1, i__2, i__3; |
| 15488 | double d__1, d__2, d__3; |
| 15489 | |
| 15490 | /* Local variables */ |
| 15491 | integercxx . . $ integer# i__, j, k; |
| 15492 | double s, xk; |
| 15493 | integercxx . . $ integer# nz; |
| 15494 | double eps; |
| 15495 | integercxx . . $ integer# kase; |
| 15496 | double safe1, safe2; |
| 15497 | integercxx . . $ integer# isave[3]; |
| 15498 | integercxx . . $ integer# count; |
| 15499 | double safmin; |
| 15500 | bool notran; |
| 15501 | char transt[1]; |
| 15502 | double lstres; |
| 15503 | |
| 15504 | |
| 15505 | /* -- LAPACK routine (version 3.1) -- */ |
| 15506 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 15507 | /* November 2006 */ |
| 15508 | |
| 15509 | /* Modified to call DLACN2 in place of DLACON, 5 Feb 03, SJH. */ |
| 15510 | |
| 15511 | /* .. Scalar Arguments .. */ |
| 15512 | /* .. */ |
| 15513 | /* .. Array Arguments .. */ |
| 15514 | /* .. */ |
| 15515 | |
| 15516 | /* Purpose */ |
| 15517 | /* ======= */ |
| 15518 | |
| 15519 | /* DGERFS improves the computed solution to a system of linear */ |
| 15520 | /* equations and provides error bounds and backward error estimates for */ |
| 15521 | /* the solution. */ |
| 15522 | |
| 15523 | /* Arguments */ |
| 15524 | /* ========= */ |
| 15525 | |
| 15526 | /* TRANS (input) CHARACTER*1 */ |
| 15527 | /* Specifies the form of the system of equations: */ |
| 15528 | /* = 'N': A * X = B (No transpose) */ |
| 15529 | /* = 'T': A**T * X = B (Transpose) */ |
| 15530 | /* = 'C': A**H * X = B (Conjugate transpose = Transpose) */ |
| 15531 | |
| 15532 | /* N (input) INTEGER */ |
| 15533 | /* The order of the matrix A. N >= 0. */ |
| 15534 | |
| 15535 | /* NRHS (input) INTEGER */ |
| 15536 | /* The number of right hand sides, i.e., the number of columns */ |
| 15537 | /* of the matrices B and X. NRHS >= 0. */ |
| 15538 | |
| 15539 | /* A (input) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 15540 | /* The original N-by-N matrix A. */ |
| 15541 | |
| 15542 | /* LDA (input) INTEGER */ |
| 15543 | /* The leading dimension of the array A. LDA >= max(1,N). */ |
| 15544 | |
| 15545 | /* AF (input) DOUBLE PRECISION array, dimension (LDAF,N) */ |
| 15546 | /* The factors L and U from the factorization A = P*L*U */ |
| 15547 | /* as computed by DGETRF. */ |
| 15548 | |
| 15549 | /* LDAF (input) INTEGER */ |
| 15550 | /* The leading dimension of the array AF. LDAF >= max(1,N). */ |
| 15551 | |
| 15552 | /* IPIV (input) INTEGER array, dimension (N) */ |
| 15553 | /* The pivot indices from DGETRF; for 1<=i<=N, row i of the */ |
| 15554 | /* matrix was interchanged with row IPIV(i). */ |
| 15555 | |
| 15556 | /* B (input) DOUBLE PRECISION array, dimension (LDB,NRHS) */ |
| 15557 | /* The right hand side matrix B. */ |
| 15558 | |
| 15559 | /* LDB (input) INTEGER */ |
| 15560 | /* The leading dimension of the array B. LDB >= max(1,N). */ |
| 15561 | |
| 15562 | /* X (input/output) DOUBLE PRECISION array, dimension (LDX,NRHS) */ |
| 15563 | /* On entry, the solution matrix X, as computed by DGETRS. */ |
| 15564 | /* On exit, the improved solution matrix X. */ |
| 15565 | |
| 15566 | /* LDX (input) INTEGER */ |
| 15567 | /* The leading dimension of the array X. LDX >= max(1,N). */ |
| 15568 | |
| 15569 | /* FERR (output) DOUBLE PRECISION array, dimension (NRHS) */ |
| 15570 | /* The estimated forward error bound for each solution vector */ |
| 15571 | /* X(j) (the j-th column of the solution matrix X). */ |
| 15572 | /* If XTRUE is the true solution corresponding to X(j), FERR(j) */ |
| 15573 | /* is an estimated upper bound for the magnitude of the largest */ |
| 15574 | /* element in (X(j) - XTRUE) divided by the magnitude of the */ |
| 15575 | /* largest element in X(j). The estimate is as reliable as */ |
| 15576 | /* the estimate for RCOND, and is almost always a slight */ |
| 15577 | /* overestimate of the true error. */ |
| 15578 | |
| 15579 | /* BERR (output) DOUBLE PRECISION array, dimension (NRHS) */ |
| 15580 | /* The componentwise relative backward error of each solution */ |
| 15581 | /* vector X(j) (i.e., the smallest relative change in */ |
| 15582 | /* any element of A or B that makes X(j) an exact solution). */ |
| 15583 | |
| 15584 | /* WORK (workspace) DOUBLE PRECISION array, dimension (3*N) */ |
| 15585 | |
| 15586 | /* IWORK (workspace) INTEGER array, dimension (N) */ |
| 15587 | |
| 15588 | /* INFO (output) INTEGER */ |
| 15589 | /* = 0: successful exit */ |
| 15590 | /* < 0: if INFO = -i, the i-th argument had an illegal value */ |
| 15591 | |
| 15592 | /* Internal Parameters */ |
| 15593 | /* =================== */ |
| 15594 | |
| 15595 | /* ITMAX is the maximum number of steps of iterative refinement. */ |
| 15596 | |
| 15597 | /* ===================================================================== */ |
| 15598 | |
| 15599 | /* .. Parameters .. */ |
| 15600 | /* .. */ |
| 15601 | /* .. Local Scalars .. */ |
| 15602 | /* .. */ |
| 15603 | /* .. Local Arrays .. */ |
| 15604 | /* .. */ |
| 15605 | /* .. External Subroutines .. */ |
| 15606 | /* .. */ |
| 15607 | /* .. Intrinsic Functions .. */ |
| 15608 | /* .. */ |
| 15609 | /* .. External Functions .. */ |
| 15610 | /* .. */ |
| 15611 | /* .. Executable Statements .. */ |
| 15612 | |
| 15613 | /* Test the input parameters. */ |
| 15614 | |
| 15615 | /* Parameter adjustments */ |
| 15616 | a_dim1 = *lda; |
| 15617 | a_offset = 1 + a_dim1; |
| 15618 | a -= a_offset; |
| 15619 | af_dim1 = *ldaf; |
| 15620 | af_offset = 1 + af_dim1; |
| 15621 | af -= af_offset; |
| 15622 | --ipiv; |
| 15623 | b_dim1 = *ldb; |
| 15624 | b_offset = 1 + b_dim1; |
| 15625 | b -= b_offset; |
| 15626 | x_dim1 = *ldx; |
| 15627 | x_offset = 1 + x_dim1; |
| 15628 | x -= x_offset; |
| 15629 | --ferr; |
| 15630 | --berr; |
| 15631 | --work; |
| 15632 | --iwork; |
| 15633 | |
| 15634 | /* Function Body */ |
| 15635 | *info = 0; |
| 15636 | notran = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(trans, "N"); |
| 15637 | if (! notran && ! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(trans, "T") && ! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).( |
| 15638 | trans, "C")) { |
| 15639 | *info = -1; |
| 15640 | } else if (*n < 0) { |
| 15641 | *info = -2; |
| 15642 | } else if (*nrhs < 0) { |
| 15643 | *info = -3; |
| 15644 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 15645 | *info = -5; |
| 15646 | } else if (*ldaf < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 15647 | *info = -7; |
| 15648 | } else if (*ldb < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 15649 | *info = -10; |
| 15650 | } else if (*ldx < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 15651 | *info = -12; |
| 15652 | } |
| 15653 | if (*info != 0) { |
| 15654 | i__1 = -(*info); |
| 15655 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGERFS", &i__1); |
| 15656 | return 0; |
| 15657 | } |
| 15658 | |
| 15659 | /* Quick return if possible */ |
| 15660 | |
| 15661 | if (*n == 0 || *nrhs == 0) { |
| 15662 | i__1 = *nrhs; |
| 15663 | for (j = 1; j <= i__1; ++j) { |
| 15664 | ferr[j] = 0.; |
| 15665 | berr[j] = 0.; |
| 15666 | /* L10: */ |
| 15667 | } |
| 15668 | return 0; |
| 15669 | } |
| 15670 | |
| 15671 | if (notran) { |
| 15672 | *(unsigned char *)transt = 'T'; |
| 15673 | } else { |
| 15674 | *(unsigned char *)transt = 'N'; |
| 15675 | } |
| 15676 | |
| 15677 | /* NZ = maximum number of nonzero elements in each row of A, plus 1 */ |
| 15678 | |
| 15679 | nz = *n + 1; |
| 15680 | eps = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("Epsilon"); |
| 15681 | safmin = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("Safe minimum"); |
| 15682 | safe1 = nz * safmin; |
| 15683 | safe2 = safe1 / eps; |
| 15684 | |
| 15685 | /* Do for each right hand side */ |
| 15686 | |
| 15687 | i__1 = *nrhs; |
| 15688 | for (j = 1; j <= i__1; ++j) { |
| 15689 | |
| 15690 | count = 1; |
| 15691 | lstres = 3.; |
| 15692 | L20: |
| 15693 | |
| 15694 | /* Loop until stopping criterion is satisfied. */ |
| 15695 | |
| 15696 | /* Compute residual R = B - op(A) * X, */ |
| 15697 | /* where op(A) = A, A**T, or A**H, depending on TRANS. */ |
| 15698 | |
| 15699 | dcopy_cxx . . $ dcopy_(ec261fd7ec3b6bf6).(n, &b[j * b_dim1 + 1], &c__1, &work[*n + 1], &c__1); |
| 15700 | dgemv_cxx . . $ dgemv_(828a5131add94649).(trans, n, n, &c_b15, &a[a_offset], lda, &x[j * x_dim1 + 1], & |
| 15701 | c__1, &c_b17, &work[*n + 1], &c__1); |
| 15702 | |
| 15703 | /* Compute componentwise relative backward error from formula */ |
| 15704 | |
| 15705 | /* max(i) ( abs(R(i)) / ( abs(op(A))*abs(X) + abs(B) )(i) ) */ |
| 15706 | |
| 15707 | /* where abs(Z) is the componentwise absolute value of the matrix */ |
| 15708 | /* or vector Z. If the i-th component of the denominator is less */ |
| 15709 | /* than SAFE2, then SAFE1 is added to the i-th components of the */ |
| 15710 | /* numerator and denominator before dividing. */ |
| 15711 | |
| 15712 | i__2 = *n; |
| 15713 | for (i__ = 1; i__ <= i__2; ++i__) { |
| 15714 | work[i__] = (d__1 = b[i__ + j * b_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__1)); |
| 15715 | /* L30: */ |
| 15716 | } |
| 15717 | |
| 15718 | /* Compute abs(op(A))*abs(X) + abs(B). */ |
| 15719 | |
| 15720 | if (notran) { |
| 15721 | i__2 = *n; |
| 15722 | for (k = 1; k <= i__2; ++k) { |
| 15723 | xk = (d__1 = x[k + j * x_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__1)); |
| 15724 | i__3 = *n; |
| 15725 | for (i__ = 1; i__ <= i__3; ++i__) { |
| 15726 | work[i__] += (d__1 = a[i__ + k * a_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__1)) * xk; |
| 15727 | /* L40: */ |
| 15728 | } |
| 15729 | /* L50: */ |
| 15730 | } |
| 15731 | } else { |
| 15732 | i__2 = *n; |
| 15733 | for (k = 1; k <= i__2; ++k) { |
| 15734 | s = 0.; |
| 15735 | i__3 = *n; |
| 15736 | for (i__ = 1; i__ <= i__3; ++i__) { |
| 15737 | s += (d__1 = a[i__ + k * a_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__1)) * (d__2 = x[ |
| 15738 | i__ + j * x_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__2)); |
| 15739 | /* L60: */ |
| 15740 | } |
| 15741 | work[k] += s; |
| 15742 | /* L70: */ |
| 15743 | } |
| 15744 | } |
| 15745 | s = 0.; |
| 15746 | i__2 = *n; |
| 15747 | for (i__ = 1; i__ <= i__2; ++i__) { |
| 15748 | if (work[i__] > safe2) { |
| 15749 | /* Computing MAX */ |
| 15750 | d__2 = s, d__3 = (d__1 = work[*n + i__], abscxx . . $ abs(447c67c6676f75c3).(d__1)) / work[ |
| 15751 | i__]; |
| 15752 | s = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__2,d__3); |
| 15753 | } else { |
| 15754 | /* Computing MAX */ |
| 15755 | d__2 = s, d__3 = ((d__1 = work[*n + i__], abscxx . . $ abs(447c67c6676f75c3).(d__1)) + safe1) |
| 15756 | / (work[i__] + safe1); |
| 15757 | s = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__2,d__3); |
| 15758 | } |
| 15759 | /* L80: */ |
| 15760 | } |
| 15761 | berr[j] = s; |
| 15762 | |
| 15763 | /* Test stopping criterion. Continue iterating if */ |
| 15764 | /* 1) The residual BERR(J) is larger than machine epsilon, and */ |
| 15765 | /* 2) BERR(J) decreased by at least a factor of 2 during the */ |
| 15766 | /* last iteration, and */ |
| 15767 | /* 3) At most ITMAX iterations tried. */ |
| 15768 | |
| 15769 | if (berr[j] > eps && berr[j] * 2. <= lstres && count <= 5) { |
| 15770 | |
| 15771 | /* Update solution and try again. */ |
| 15772 | |
| 15773 | dgetrs_cxx . . $ dgetrs_(695824aa3fbf5aa2).(trans, n, &c__1, &af[af_offset], ldaf, &ipiv[1], &work[*n |
| 15774 | + 1], n, info); |
| 15775 | daxpy_cxx . . $ daxpy_(4b39f621356f7e14).(n, &c_b17, &work[*n + 1], &c__1, &x[j * x_dim1 + 1], &c__1) |
| 15776 | ; |
| 15777 | lstres = berr[j]; |
| 15778 | ++count; |
| 15779 | goto L20; |
| 15780 | } |
| 15781 | |
| 15782 | /* Bound error from formula */ |
| 15783 | |
| 15784 | /* norm(X - XTRUE) / norm(X) .le. FERR = */ |
| 15785 | /* norm( abs(inv(op(A)))* */ |
| 15786 | /* ( abs(R) + NZ*EPS*( abs(op(A))*abs(X)+abs(B) ))) / norm(X) */ |
| 15787 | |
| 15788 | /* where */ |
| 15789 | /* norm(Z) is the magnitude of the largest component of Z */ |
| 15790 | /* inv(op(A)) is the inverse of op(A) */ |
| 15791 | /* abs(Z) is the componentwise absolute value of the matrix or */ |
| 15792 | /* vector Z */ |
| 15793 | /* NZ is the maximum number of nonzeros in any row of A, plus 1 */ |
| 15794 | /* EPS is machine epsilon */ |
| 15795 | |
| 15796 | /* The i-th component of abs(R)+NZ*EPS*(abs(op(A))*abs(X)+abs(B)) */ |
| 15797 | /* is incremented by SAFE1 if the i-th component of */ |
| 15798 | /* abs(op(A))*abs(X) + abs(B) is less than SAFE2. */ |
| 15799 | |
| 15800 | /* Use DLACN2 to estimate the infinity-norm of the matrix */ |
| 15801 | /* inv(op(A)) * diag(W), */ |
| 15802 | /* where W = abs(R) + NZ*EPS*( abs(op(A))*abs(X)+abs(B) ))) */ |
| 15803 | |
| 15804 | i__2 = *n; |
| 15805 | for (i__ = 1; i__ <= i__2; ++i__) { |
| 15806 | if (work[i__] > safe2) { |
| 15807 | work[i__] = (d__1 = work[*n + i__], abscxx . . $ abs(447c67c6676f75c3).(d__1)) + nz * eps * |
| 15808 | work[i__]; |
| 15809 | } else { |
| 15810 | work[i__] = (d__1 = work[*n + i__], abscxx . . $ abs(447c67c6676f75c3).(d__1)) + nz * eps * |
| 15811 | work[i__] + safe1; |
| 15812 | } |
| 15813 | /* L90: */ |
| 15814 | } |
| 15815 | |
| 15816 | kase = 0; |
| 15817 | L100: |
| 15818 | dlacn2_cxx . . $ dlacn2_(2d9e0fe6bd3e0917).(n, &work[(*n << 1) + 1], &work[*n + 1], &iwork[1], &ferr[j], & |
| 15819 | kase, isave); |
| 15820 | if (kase != 0) { |
| 15821 | if (kase == 1) { |
| 15822 | |
| 15823 | /* Multiply by diag(W)*inv(op(A)**T). */ |
| 15824 | |
| 15825 | dgetrs_cxx . . $ dgetrs_(695824aa3fbf5aa2).(transt, n, &c__1, &af[af_offset], ldaf, &ipiv[1], & |
| 15826 | work[*n + 1], n, info); |
| 15827 | i__2 = *n; |
| 15828 | for (i__ = 1; i__ <= i__2; ++i__) { |
| 15829 | work[*n + i__] = work[i__] * work[*n + i__]; |
| 15830 | /* L110: */ |
| 15831 | } |
| 15832 | } else { |
| 15833 | |
| 15834 | /* Multiply by inv(op(A))*diag(W). */ |
| 15835 | |
| 15836 | i__2 = *n; |
| 15837 | for (i__ = 1; i__ <= i__2; ++i__) { |
| 15838 | work[*n + i__] = work[i__] * work[*n + i__]; |
| 15839 | /* L120: */ |
| 15840 | } |
| 15841 | dgetrs_cxx . . $ dgetrs_(695824aa3fbf5aa2).(trans, n, &c__1, &af[af_offset], ldaf, &ipiv[1], & |
| 15842 | work[*n + 1], n, info); |
| 15843 | } |
| 15844 | goto L100; |
| 15845 | } |
| 15846 | |
| 15847 | /* Normalize error. */ |
| 15848 | |
| 15849 | lstres = 0.; |
| 15850 | i__2 = *n; |
| 15851 | for (i__ = 1; i__ <= i__2; ++i__) { |
| 15852 | /* Computing MAX */ |
| 15853 | d__2 = lstres, d__3 = (d__1 = x[i__ + j * x_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__1)); |
| 15854 | lstres = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__2,d__3); |
| 15855 | /* L130: */ |
| 15856 | } |
| 15857 | if (lstres != 0.) { |
| 15858 | ferr[j] /= lstres; |
| 15859 | } |
| 15860 | |
| 15861 | /* L140: */ |
| 15862 | } |
| 15863 | |
| 15864 | return 0; |
| 15865 | |
| 15866 | /* End of DGERFS */ |
| 15867 | |
| 15868 | } /* dgerfs_ */ |
| 15869 | |
| 15870 | /* Subroutine */ int dgerq2_cxx . . $ dgerq2_(19b4abe06ca5e75b).(integercxx . . $ integer# *m, integercxx . . $ integer# *n, double *a, integercxx . . $ integer# *lda, double *tau, double *work, integercxx . . $ integer# *info) |
| 15871 | { |
| 15872 | /* System generated locals */ |
| 15873 | integercxx . . $ integer# a_dim1, a_offset, i__1, i__2; |
| 15874 | |
| 15875 | /* Local variables */ |
| 15876 | integercxx . . $ integer# i__, k; |
| 15877 | double aii; |
| 15878 | |
| 15879 | /* -- LAPACK routine (version 3.2) -- */ |
| 15880 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 15881 | /* November 2006 */ |
| 15882 | |
| 15883 | /* .. Scalar Arguments .. */ |
| 15884 | /* .. */ |
| 15885 | /* .. Array Arguments .. */ |
| 15886 | /* .. */ |
| 15887 | |
| 15888 | /* Purpose */ |
| 15889 | /* ======= */ |
| 15890 | |
| 15891 | /* DGERQ2 computes an RQ factorization of a real m by n matrix A: */ |
| 15892 | /* A = R * Q. */ |
| 15893 | |
| 15894 | /* Arguments */ |
| 15895 | /* ========= */ |
| 15896 | |
| 15897 | /* M (input) INTEGER */ |
| 15898 | /* The number of rows of the matrix A. M >= 0. */ |
| 15899 | |
| 15900 | /* N (input) INTEGER */ |
| 15901 | /* The number of columns of the matrix A. N >= 0. */ |
| 15902 | |
| 15903 | /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 15904 | /* On entry, the m by n matrix A. */ |
| 15905 | /* On exit, if m <= n, the upper triangle of the subarray */ |
| 15906 | /* A(1:m,n-m+1:n) contains the m by m upper triangular matrix R; */ |
| 15907 | /* if m >= n, the elements on and above the (m-n)-th subdiagonal */ |
| 15908 | /* contain the m by n upper trapezoidal matrix R; the remaining */ |
| 15909 | /* elements, with the array TAU, represent the orthogonal matrix */ |
| 15910 | /* Q as a product of elementary reflectors (see Further */ |
| 15911 | /* Details). */ |
| 15912 | |
| 15913 | /* LDA (input) INTEGER */ |
| 15914 | /* The leading dimension of the array A. LDA >= max(1,M). */ |
| 15915 | |
| 15916 | /* TAU (output) DOUBLE PRECISION array, dimension (min(M,N)) */ |
| 15917 | /* The scalar factors of the elementary reflectors (see Further */ |
| 15918 | /* Details). */ |
| 15919 | |
| 15920 | /* WORK (workspace) DOUBLE PRECISION array, dimension (M) */ |
| 15921 | |
| 15922 | /* INFO (output) INTEGER */ |
| 15923 | /* = 0: successful exit */ |
| 15924 | /* < 0: if INFO = -i, the i-th argument had an illegal value */ |
| 15925 | |
| 15926 | /* Further Details */ |
| 15927 | /* =============== */ |
| 15928 | |
| 15929 | /* The matrix Q is represented as a product of elementary reflectors */ |
| 15930 | |
| 15931 | /* Q = H(1) H(2) . . . H(k), where k = min(m,n). */ |
| 15932 | |
| 15933 | /* Each H(i) has the form */ |
| 15934 | |
| 15935 | /* H(i) = I - tau * v * v' */ |
| 15936 | |
| 15937 | /* where tau is a real scalar, and v is a real vector with */ |
| 15938 | /* v(n-k+i+1:n) = 0 and v(n-k+i) = 1; v(1:n-k+i-1) is stored on exit in */ |
| 15939 | /* A(m-k+i,1:n-k+i-1), and tau in TAU(i). */ |
| 15940 | |
| 15941 | /* ===================================================================== */ |
| 15942 | |
| 15943 | /* .. Parameters .. */ |
| 15944 | /* .. */ |
| 15945 | /* .. Local Scalars .. */ |
| 15946 | /* .. */ |
| 15947 | /* .. External Subroutines .. */ |
| 15948 | /* .. */ |
| 15949 | /* .. Intrinsic Functions .. */ |
| 15950 | /* .. */ |
| 15951 | /* .. Executable Statements .. */ |
| 15952 | |
| 15953 | /* Test the input arguments */ |
| 15954 | |
| 15955 | /* Parameter adjustments */ |
| 15956 | a_dim1 = *lda; |
| 15957 | a_offset = 1 + a_dim1; |
| 15958 | a -= a_offset; |
| 15959 | --tau; |
| 15960 | --work; |
| 15961 | |
| 15962 | /* Function Body */ |
| 15963 | *info = 0; |
| 15964 | if (*m < 0) { |
| 15965 | *info = -1; |
| 15966 | } else if (*n < 0) { |
| 15967 | *info = -2; |
| 15968 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*m)) { |
| 15969 | *info = -4; |
| 15970 | } |
| 15971 | if (*info != 0) { |
| 15972 | i__1 = -(*info); |
| 15973 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGERQ2", &i__1); |
| 15974 | return 0; |
| 15975 | } |
| 15976 | |
| 15977 | k = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(*m,*n); |
| 15978 | |
| 15979 | for (i__ = k; i__ >= 1; --i__) { |
| 15980 | |
| 15981 | /* Generate elementary reflector H(i) to annihilate */ |
| 15982 | /* A(m-k+i,1:n-k+i-1) */ |
| 15983 | |
| 15984 | i__1 = *n - k + i__; |
| 15985 | dlarfp_cxx . . $ dlarfp_(ae28ee921df873ff).(&i__1, &a[*m - k + i__ + (*n - k + i__) * a_dim1], &a[*m - k |
| 15986 | + i__ + a_dim1], lda, &tau[i__]); |
| 15987 | |
| 15988 | /* Apply H(i) to A(1:m-k+i-1,1:n-k+i) from the right */ |
| 15989 | |
| 15990 | aii = a[*m - k + i__ + (*n - k + i__) * a_dim1]; |
| 15991 | a[*m - k + i__ + (*n - k + i__) * a_dim1] = 1.; |
| 15992 | i__1 = *m - k + i__ - 1; |
| 15993 | i__2 = *n - k + i__; |
| 15994 | dlarf_cxx . . $ dlarf_(f67bbcf4c4b4eb96).("Right", &i__1, &i__2, &a[*m - k + i__ + a_dim1], lda, &tau[ |
| 15995 | i__], &a[a_offset], lda, &work[1]); |
| 15996 | a[*m - k + i__ + (*n - k + i__) * a_dim1] = aii; |
| 15997 | /* L10: */ |
| 15998 | } |
| 15999 | return 0; |
| 16000 | |
| 16001 | /* End of DGERQ2 */ |
| 16002 | |
| 16003 | } /* dgerq2_ */ |
| 16004 | |
| 16005 | /* Subroutine */ int dgerqf_cxx . . $ dgerqf_(b2aaa174babf002e).(integercxx . . $ integer# *m, integercxx . . $ integer# *n, double *a, integercxx . . $ integer# * |
| 16006 | lda, double *tau, double *work, integercxx . . $ integer# *lwork, integercxx . . $ integer# *info) |
| 16007 | { |
| 16008 | /* Table of constant values */ |
| 16009 | static integercxx . . $ integer# c__1 = 1; |
| 16010 | static integercxx . . $ integer# c_n1 = -1; |
| 16011 | static integercxx . . $ integer# c__3 = 3; |
| 16012 | static integercxx . . $ integer# c__2 = 2; |
| 16013 | |
| 16014 | /* System generated locals */ |
| 16015 | integercxx . . $ integer# a_dim1, a_offset, i__1, i__2, i__3, i__4; |
| 16016 | |
| 16017 | /* Local variables */ |
| 16018 | integercxx . . $ integer# i__, k, ib, nb, ki, kk, mu, nu, nx, iws, nbmin, iinfo; |
| 16019 | integercxx . . $ integer# ldwork, lwkopt; |
| 16020 | bool lquery; |
| 16021 | |
| 16022 | |
| 16023 | /* -- LAPACK routine (version 3.1) -- */ |
| 16024 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 16025 | /* November 2006 */ |
| 16026 | |
| 16027 | /* .. Scalar Arguments .. */ |
| 16028 | /* .. */ |
| 16029 | /* .. Array Arguments .. */ |
| 16030 | /* .. */ |
| 16031 | |
| 16032 | /* Purpose */ |
| 16033 | /* ======= */ |
| 16034 | |
| 16035 | /* DGERQF computes an RQ factorization of a real M-by-N matrix A: */ |
| 16036 | /* A = R * Q. */ |
| 16037 | |
| 16038 | /* Arguments */ |
| 16039 | /* ========= */ |
| 16040 | |
| 16041 | /* M (input) INTEGER */ |
| 16042 | /* The number of rows of the matrix A. M >= 0. */ |
| 16043 | |
| 16044 | /* N (input) INTEGER */ |
| 16045 | /* The number of columns of the matrix A. N >= 0. */ |
| 16046 | |
| 16047 | /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 16048 | /* On entry, the M-by-N matrix A. */ |
| 16049 | /* On exit, */ |
| 16050 | /* if m <= n, the upper triangle of the subarray */ |
| 16051 | /* A(1:m,n-m+1:n) contains the M-by-M upper triangular matrix R; */ |
| 16052 | /* if m >= n, the elements on and above the (m-n)-th subdiagonal */ |
| 16053 | /* contain the M-by-N upper trapezoidal matrix R; */ |
| 16054 | /* the remaining elements, with the array TAU, represent the */ |
| 16055 | /* orthogonal matrix Q as a product of min(m,n) elementary */ |
| 16056 | /* reflectors (see Further Details). */ |
| 16057 | |
| 16058 | /* LDA (input) INTEGER */ |
| 16059 | /* The leading dimension of the array A. LDA >= max(1,M). */ |
| 16060 | |
| 16061 | /* TAU (output) DOUBLE PRECISION array, dimension (min(M,N)) */ |
| 16062 | /* The scalar factors of the elementary reflectors (see Further */ |
| 16063 | /* Details). */ |
| 16064 | |
| 16065 | /* WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) */ |
| 16066 | /* On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ |
| 16067 | |
| 16068 | /* LWORK (input) INTEGER */ |
| 16069 | /* The dimension of the array WORK. LWORK >= max(1,M). */ |
| 16070 | /* For optimum performance LWORK >= M*NB, where NB is */ |
| 16071 | /* the optimal blocksize. */ |
| 16072 | |
| 16073 | /* If LWORK = -1, then a workspace query is assumed; the routine */ |
| 16074 | /* only calculates the optimal size of the WORK array, returns */ |
| 16075 | /* this value as the first entry of the WORK array, and no error */ |
| 16076 | /* message related to LWORK is issued by XERBLA. */ |
| 16077 | |
| 16078 | /* INFO (output) INTEGER */ |
| 16079 | /* = 0: successful exit */ |
| 16080 | /* < 0: if INFO = -i, the i-th argument had an illegal value */ |
| 16081 | |
| 16082 | /* Further Details */ |
| 16083 | /* =============== */ |
| 16084 | |
| 16085 | /* The matrix Q is represented as a product of elementary reflectors */ |
| 16086 | |
| 16087 | /* Q = H(1) H(2) . . . H(k), where k = min(m,n). */ |
| 16088 | |
| 16089 | /* Each H(i) has the form */ |
| 16090 | |
| 16091 | /* H(i) = I - tau * v * v' */ |
| 16092 | |
| 16093 | /* where tau is a real scalar, and v is a real vector with */ |
| 16094 | /* v(n-k+i+1:n) = 0 and v(n-k+i) = 1; v(1:n-k+i-1) is stored on exit in */ |
| 16095 | /* A(m-k+i,1:n-k+i-1), and tau in TAU(i). */ |
| 16096 | |
| 16097 | /* ===================================================================== */ |
| 16098 | |
| 16099 | /* .. Local Scalars .. */ |
| 16100 | /* .. */ |
| 16101 | /* .. External Subroutines .. */ |
| 16102 | /* .. */ |
| 16103 | /* .. Intrinsic Functions .. */ |
| 16104 | /* .. */ |
| 16105 | /* .. External Functions .. */ |
| 16106 | /* .. */ |
| 16107 | /* .. Executable Statements .. */ |
| 16108 | |
| 16109 | /* Test the input arguments */ |
| 16110 | |
| 16111 | /* Parameter adjustments */ |
| 16112 | a_dim1 = *lda; |
| 16113 | a_offset = 1 + a_dim1; |
| 16114 | a -= a_offset; |
| 16115 | --tau; |
| 16116 | --work; |
| 16117 | |
| 16118 | /* Function Body */ |
| 16119 | *info = 0; |
| 16120 | lquery = *lwork == -1; |
| 16121 | if (*m < 0) { |
| 16122 | *info = -1; |
| 16123 | } else if (*n < 0) { |
| 16124 | *info = -2; |
| 16125 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*m)) { |
| 16126 | *info = -4; |
| 16127 | } |
| 16128 | |
| 16129 | if (*info == 0) { |
| 16130 | k = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(*m,*n); |
| 16131 | if (k == 0) { |
| 16132 | lwkopt = 1; |
| 16133 | } else { |
| 16134 | nb = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGERQF", " ", m, n, &c_n1, &c_n1); |
| 16135 | lwkopt = *m * nb; |
| 16136 | } |
| 16137 | work[1] = (double) lwkopt; |
| 16138 | |
| 16139 | if (*lwork < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*m) && ! lquery) { |
| 16140 | *info = -7; |
| 16141 | } |
| 16142 | } |
| 16143 | |
| 16144 | if (*info != 0) { |
| 16145 | i__1 = -(*info); |
| 16146 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGERQF", &i__1); |
| 16147 | return 0; |
| 16148 | } else if (lquery) { |
| 16149 | return 0; |
| 16150 | } |
| 16151 | |
| 16152 | /* Quick return if possible */ |
| 16153 | |
| 16154 | if (k == 0) { |
| 16155 | return 0; |
| 16156 | } |
| 16157 | |
| 16158 | nbmin = 2; |
| 16159 | nx = 1; |
| 16160 | iws = *m; |
| 16161 | if (nb > 1 && nb < k) { |
| 16162 | |
| 16163 | /* Determine when to cross over from blocked to unblocked code. */ |
| 16164 | |
| 16165 | /* Computing MAX */ |
| 16166 | i__1 = 0, i__2 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__3, "DGERQF", " ", m, n, &c_n1, &c_n1); |
| 16167 | nx = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16168 | if (nx < k) { |
| 16169 | |
| 16170 | /* Determine if workspace is large enough for blocked code. */ |
| 16171 | |
| 16172 | ldwork = *m; |
| 16173 | iws = ldwork * nb; |
| 16174 | if (*lwork < iws) { |
| 16175 | |
| 16176 | /* Not enough workspace to use optimal NB: reduce NB and */ |
| 16177 | /* determine the minimum value of NB. */ |
| 16178 | |
| 16179 | nb = *lwork / ldwork; |
| 16180 | /* Computing MAX */ |
| 16181 | i__1 = 2, i__2 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__2, "DGERQF", " ", m, n, &c_n1, & |
| 16182 | c_n1); |
| 16183 | nbmin = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16184 | } |
| 16185 | } |
| 16186 | } |
| 16187 | |
| 16188 | if (nb >= nbmin && nb < k && nx < k) { |
| 16189 | |
| 16190 | /* Use blocked code initially. */ |
| 16191 | /* The last kk rows are handled by the block method. */ |
| 16192 | |
| 16193 | ki = (k - nx - 1) / nb * nb; |
| 16194 | /* Computing MIN */ |
| 16195 | i__1 = k, i__2 = ki + nb; |
| 16196 | kk = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__1,i__2); |
| 16197 | |
| 16198 | i__1 = k - kk + 1; |
| 16199 | i__2 = -nb; |
| 16200 | for (i__ = k - kk + ki + 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ |
| 16201 | += i__2) { |
| 16202 | /* Computing MIN */ |
| 16203 | i__3 = k - i__ + 1; |
| 16204 | ib = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__3,nb); |
| 16205 | |
| 16206 | /* Compute the RQ factorization of the current block */ |
| 16207 | /* A(m-k+i:m-k+i+ib-1,1:n-k+i+ib-1) */ |
| 16208 | |
| 16209 | i__3 = *n - k + i__ + ib - 1; |
| 16210 | dgerq2_cxx . . $ dgerq2_(19b4abe06ca5e75b).(&ib, &i__3, &a[*m - k + i__ + a_dim1], lda, &tau[i__], & |
| 16211 | work[1], &iinfo); |
| 16212 | if (*m - k + i__ > 1) { |
| 16213 | |
| 16214 | /* Form the triangular factor of the block reflector */ |
| 16215 | /* H = H(i+ib-1) . . . H(i+1) H(i) */ |
| 16216 | |
| 16217 | i__3 = *n - k + i__ + ib - 1; |
| 16218 | dlarft_cxx . . $ dlarft_(9d83c62c83e92799).("Backward", "Rowwise", &i__3, &ib, &a[*m - k + i__ + |
| 16219 | a_dim1], lda, &tau[i__], &work[1], &ldwork); |
| 16220 | |
| 16221 | /* Apply H to A(1:m-k+i-1,1:n-k+i+ib-1) from the right */ |
| 16222 | |
| 16223 | i__3 = *m - k + i__ - 1; |
| 16224 | i__4 = *n - k + i__ + ib - 1; |
| 16225 | dlarfb_cxx . . $ dlarfb_(b0af75de90da309c).("Right", "No transpose", "Backward", "Rowwise", &i__3, |
| 16226 | &i__4, &ib, &a[*m - k + i__ + a_dim1], lda, &work[1], |
| 16227 | &ldwork, &a[a_offset], lda, &work[ib + 1], &ldwork); |
| 16228 | } |
| 16229 | /* L10: */ |
| 16230 | } |
| 16231 | mu = *m - k + i__ + nb - 1; |
| 16232 | nu = *n - k + i__ + nb - 1; |
| 16233 | } else { |
| 16234 | mu = *m; |
| 16235 | nu = *n; |
| 16236 | } |
| 16237 | |
| 16238 | /* Use unblocked code to factor the last or only block */ |
| 16239 | |
| 16240 | if (mu > 0 && nu > 0) { |
| 16241 | dgerq2_cxx . . $ dgerq2_(19b4abe06ca5e75b).(&mu, &nu, &a[a_offset], lda, &tau[1], &work[1], &iinfo); |
| 16242 | } |
| 16243 | |
| 16244 | work[1] = (double) iws; |
| 16245 | return 0; |
| 16246 | |
| 16247 | /* End of DGERQF */ |
| 16248 | |
| 16249 | } /* dgerqf_ */ |
| 16250 | |
| 16251 | /* Subroutine */ int dgesc2_cxx . . $ dgesc2_(2c3221ed4c569f8a).(integercxx . . $ integer# *n, double *a, integercxx . . $ integer# *lda, |
| 16252 | double *rhs, integercxx . . $ integer# *ipiv, integercxx . . $ integer# *jpiv, double *scale) |
| 16253 | { |
| 16254 | /* Table of constant values */ |
| 16255 | static integercxx . . $ integer# c__1 = 1; |
| 16256 | static integercxx . . $ integer# c_n1 = -1; |
| 16257 | |
| 16258 | /* System generated locals */ |
| 16259 | integercxx . . $ integer# a_dim1, a_offset, i__1, i__2; |
| 16260 | double d__1, d__2; |
| 16261 | |
| 16262 | /* Local variables */ |
| 16263 | integercxx . . $ integer# i__, j; |
| 16264 | double eps, temp; |
| 16265 | double bignum; |
| 16266 | double smlnum; |
| 16267 | |
| 16268 | |
| 16269 | /* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 16270 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 16271 | /* November 2006 */ |
| 16272 | |
| 16273 | /* .. Scalar Arguments .. */ |
| 16274 | /* .. */ |
| 16275 | /* .. Array Arguments .. */ |
| 16276 | /* .. */ |
| 16277 | |
| 16278 | /* Purpose */ |
| 16279 | /* ======= */ |
| 16280 | |
| 16281 | /* DGESC2 solves a system of linear equations */ |
| 16282 | |
| 16283 | /* A * X = scale* RHS */ |
| 16284 | |
| 16285 | /* with a general N-by-N matrix A using the LU factorization with */ |
| 16286 | /* complete pivoting computed by DGETC2. */ |
| 16287 | |
| 16288 | /* Arguments */ |
| 16289 | /* ========= */ |
| 16290 | |
| 16291 | /* N (input) INTEGER */ |
| 16292 | /* The order of the matrix A. */ |
| 16293 | |
| 16294 | /* A (input) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 16295 | /* On entry, the LU part of the factorization of the n-by-n */ |
| 16296 | /* matrix A computed by DGETC2: A = P * L * U * Q */ |
| 16297 | |
| 16298 | /* LDA (input) INTEGER */ |
| 16299 | /* The leading dimension of the array A. LDA >= max(1, N). */ |
| 16300 | |
| 16301 | /* RHS (input/output) DOUBLE PRECISION array, dimension (N). */ |
| 16302 | /* On entry, the right hand side vector b. */ |
| 16303 | /* On exit, the solution vector X. */ |
| 16304 | |
| 16305 | /* IPIV (input) INTEGER array, dimension (N). */ |
| 16306 | /* The pivot indices; for 1 <= i <= N, row i of the */ |
| 16307 | /* matrix has been interchanged with row IPIV(i). */ |
| 16308 | |
| 16309 | /* JPIV (input) INTEGER array, dimension (N). */ |
| 16310 | /* The pivot indices; for 1 <= j <= N, column j of the */ |
| 16311 | /* matrix has been interchanged with column JPIV(j). */ |
| 16312 | |
| 16313 | /* SCALE (output) DOUBLE PRECISION */ |
| 16314 | /* On exit, SCALE contains the scale factor. SCALE is chosen */ |
| 16315 | /* 0 <= SCALE <= 1 to prevent owerflow in the solution. */ |
| 16316 | |
| 16317 | /* Further Details */ |
| 16318 | /* =============== */ |
| 16319 | |
| 16320 | /* Based on contributions by */ |
| 16321 | /* Bo Kagstrom and Peter Poromaa, Department of Computing Science, */ |
| 16322 | /* Umea University, S-901 87 Umea, Sweden. */ |
| 16323 | |
| 16324 | /* ===================================================================== */ |
| 16325 | |
| 16326 | /* .. Parameters .. */ |
| 16327 | /* .. */ |
| 16328 | /* .. Local Scalars .. */ |
| 16329 | /* .. */ |
| 16330 | /* .. External Subroutines .. */ |
| 16331 | /* .. */ |
| 16332 | /* .. External Functions .. */ |
| 16333 | /* .. */ |
| 16334 | /* .. Intrinsic Functions .. */ |
| 16335 | /* .. */ |
| 16336 | /* .. Executable Statements .. */ |
| 16337 | |
| 16338 | /* Set constant to control owerflow */ |
| 16339 | |
| 16340 | /* Parameter adjustments */ |
| 16341 | a_dim1 = *lda; |
| 16342 | a_offset = 1 + a_dim1; |
| 16343 | a -= a_offset; |
| 16344 | --rhs; |
| 16345 | --ipiv; |
| 16346 | --jpiv; |
| 16347 | |
| 16348 | /* Function Body */ |
| 16349 | eps = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("P"); |
| 16350 | smlnum = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("S") / eps; |
| 16351 | bignum = 1. / smlnum; |
| 16352 | dlabad_cxx . . $ dlabad_(4730c933dae9b326).(&smlnum, &bignum); |
| 16353 | |
| 16354 | /* Apply permutations IPIV to RHS */ |
| 16355 | |
| 16356 | i__1 = *n - 1; |
| 16357 | dlaswp_cxx . . $ dlaswp_(fd840d72c89a956b).(&c__1, &rhs[1], lda, &c__1, &i__1, &ipiv[1], &c__1); |
| 16358 | |
| 16359 | /* Solve for L part */ |
| 16360 | |
| 16361 | i__1 = *n - 1; |
| 16362 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 16363 | i__2 = *n; |
| 16364 | for (j = i__ + 1; j <= i__2; ++j) { |
| 16365 | rhs[j] -= a[j + i__ * a_dim1] * rhs[i__]; |
| 16366 | /* L10: */ |
| 16367 | } |
| 16368 | /* L20: */ |
| 16369 | } |
| 16370 | |
| 16371 | /* Solve for U part */ |
| 16372 | |
| 16373 | *scale = 1.; |
| 16374 | |
| 16375 | /* Check for scaling */ |
| 16376 | |
| 16377 | i__ = idamax_cxx . . $ idamax_(a5c31fbfbc00ee45).(n, &rhs[1], &c__1); |
| 16378 | if (smlnum * 2. * (d__1 = rhs[i__], abscxx . . $ abs(447c67c6676f75c3).(d__1)) > (d__2 = a[*n + *n * |
| 16379 | a_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__2))) { |
| 16380 | temp = .5 / (d__1 = rhs[i__], abscxx . . $ abs(447c67c6676f75c3).(d__1)); |
| 16381 | dscal_cxx . . $ dscal_(f22c1db71784c345).(n, &temp, &rhs[1], &c__1); |
| 16382 | *scale *= temp; |
| 16383 | } |
| 16384 | |
| 16385 | for (i__ = *n; i__ >= 1; --i__) { |
| 16386 | temp = 1. / a[i__ + i__ * a_dim1]; |
| 16387 | rhs[i__] *= temp; |
| 16388 | i__1 = *n; |
| 16389 | for (j = i__ + 1; j <= i__1; ++j) { |
| 16390 | rhs[i__] -= rhs[j] * (a[i__ + j * a_dim1] * temp); |
| 16391 | /* L30: */ |
| 16392 | } |
| 16393 | /* L40: */ |
| 16394 | } |
| 16395 | |
| 16396 | /* Apply permutations JPIV to the solution (RHS) */ |
| 16397 | |
| 16398 | i__1 = *n - 1; |
| 16399 | dlaswp_cxx . . $ dlaswp_(fd840d72c89a956b).(&c__1, &rhs[1], lda, &c__1, &i__1, &jpiv[1], &c_n1); |
| 16400 | return 0; |
| 16401 | |
| 16402 | /* End of DGESC2 */ |
| 16403 | |
| 16404 | } /* dgesc2_ */ |
| 16405 | |
| 16406 | /* Subroutine */ int dgesdd_cxx . . $ dgesdd_(8df9fbf5d654f25).(const char *jobz, integercxx . . $ integer# *m, integercxx . . $ integer# *n, double * |
| 16407 | a, integercxx . . $ integer# *lda, double *s, double *u, integercxx . . $ integer# *ldu, |
| 16408 | double *vt, integercxx . . $ integer# *ldvt, double *work, integercxx . . $ integer# *lwork, |
| 16409 | integercxx . . $ integer# *iwork, integercxx . . $ integer# *info) |
| 16410 | { |
| 16411 | /* Table of constant values */ |
| 16412 | static integercxx . . $ integer# c__1 = 1; |
| 16413 | static integercxx . . $ integer# c_n1 = -1; |
| 16414 | static integercxx . . $ integer# c__0 = 0; |
| 16415 | static double c_b227 = 0.; |
| 16416 | static double c_b248 = 1.; |
| 16417 | |
| 16418 | /* System generated locals */ |
| 16419 | integercxx . . $ integer# a_dim1, a_offset, u_dim1, u_offset, vt_dim1, vt_offset, i__1, |
| 16420 | i__2, i__3; |
| 16421 | |
| 16422 | /* Local variables */ |
| 16423 | integercxx . . $ integer# i__, ie, il, ir, iu, blk; |
| 16424 | double dum[1], eps; |
| 16425 | integercxx . . $ integer# ivt, iscl; |
| 16426 | double anrm; |
| 16427 | integercxx . . $ integer# idum[1], ierr, itau; |
| 16428 | integercxx . . $ integer# chunk, minmn, wrkbl, itaup, itauq, mnthr; |
| 16429 | bool wntqa; |
| 16430 | integercxx . . $ integer# nwork; |
| 16431 | bool wntqn, wntqo, wntqs; |
| 16432 | integercxx . . $ integer# bdspac; |
| 16433 | double bignum; |
| 16434 | integercxx . . $ integer# ldwrkl, ldwrkr, minwrk, ldwrku, maxwrk, ldwkvt; |
| 16435 | double smlnum; |
| 16436 | bool wntqas, lquery; |
| 16437 | |
| 16438 | |
| 16439 | /* -- LAPACK driver routine (version 3.1) -- */ |
| 16440 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 16441 | /* November 2006 */ |
| 16442 | |
| 16443 | /* .. Scalar Arguments .. */ |
| 16444 | /* .. */ |
| 16445 | /* .. Array Arguments .. */ |
| 16446 | /* .. */ |
| 16447 | |
| 16448 | /* Purpose */ |
| 16449 | /* ======= */ |
| 16450 | |
| 16451 | /* DGESDD computes the singular value decomposition (SVD) of a real */ |
| 16452 | /* M-by-N matrix A, optionally computing the left and right singular */ |
| 16453 | /* vectors. If singular vectors are desired, it uses a */ |
| 16454 | /* divide-and-conquer algorithm. */ |
| 16455 | |
| 16456 | /* The SVD is written */ |
| 16457 | |
| 16458 | /* A = U * SIGMA * transpose(V) */ |
| 16459 | |
| 16460 | /* where SIGMA is an M-by-N matrix which is zero except for its */ |
| 16461 | /* min(m,n) diagonal elements, U is an M-by-M orthogonal matrix, and */ |
| 16462 | /* V is an N-by-N orthogonal matrix. The diagonal elements of SIGMA */ |
| 16463 | /* are the singular values of A; they are real and non-negative, and */ |
| 16464 | /* are returned in descending order. The first min(m,n) columns of */ |
| 16465 | /* U and V are the left and right singular vectors of A. */ |
| 16466 | |
| 16467 | /* Note that the routine returns VT = V**T, not V. */ |
| 16468 | |
| 16469 | /* The divide and conquer algorithm makes very mild assumptions about */ |
| 16470 | /* floating point arithmetic. It will work on machines with a guard */ |
| 16471 | /* digit in add/subtract, or on those binary machines without guard */ |
| 16472 | /* digits which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or */ |
| 16473 | /* Cray-2. It could conceivably fail on hexadecimal or decimal machines */ |
| 16474 | /* without guard digits, but we know of none. */ |
| 16475 | |
| 16476 | /* Arguments */ |
| 16477 | /* ========= */ |
| 16478 | |
| 16479 | /* JOBZ (input) CHARACTER*1 */ |
| 16480 | /* Specifies options for computing all or part of the matrix U: */ |
| 16481 | /* = 'A': all M columns of U and all N rows of V**T are */ |
| 16482 | /* returned in the arrays U and VT; */ |
| 16483 | /* = 'S': the first min(M,N) columns of U and the first */ |
| 16484 | /* min(M,N) rows of V**T are returned in the arrays U */ |
| 16485 | /* and VT; */ |
| 16486 | /* = 'O': If M >= N, the first N columns of U are overwritten */ |
| 16487 | /* on the array A and all rows of V**T are returned in */ |
| 16488 | /* the array VT; */ |
| 16489 | /* otherwise, all columns of U are returned in the */ |
| 16490 | /* array U and the first M rows of V**T are overwritten */ |
| 16491 | /* in the array A; */ |
| 16492 | /* = 'N': no columns of U or rows of V**T are computed. */ |
| 16493 | |
| 16494 | /* M (input) INTEGER */ |
| 16495 | /* The number of rows of the input matrix A. M >= 0. */ |
| 16496 | |
| 16497 | /* N (input) INTEGER */ |
| 16498 | /* The number of columns of the input matrix A. N >= 0. */ |
| 16499 | |
| 16500 | /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 16501 | /* On entry, the M-by-N matrix A. */ |
| 16502 | /* On exit, */ |
| 16503 | /* if JOBZ = 'O', A is overwritten with the first N columns */ |
| 16504 | /* of U (the left singular vectors, stored */ |
| 16505 | /* columnwise) if M >= N; */ |
| 16506 | /* A is overwritten with the first M rows */ |
| 16507 | /* of V**T (the right singular vectors, stored */ |
| 16508 | /* rowwise) otherwise. */ |
| 16509 | /* if JOBZ .ne. 'O', the contents of A are destroyed. */ |
| 16510 | |
| 16511 | /* LDA (input) INTEGER */ |
| 16512 | /* The leading dimension of the array A. LDA >= max(1,M). */ |
| 16513 | |
| 16514 | /* S (output) DOUBLE PRECISION array, dimension (min(M,N)) */ |
| 16515 | /* The singular values of A, sorted so that S(i) >= S(i+1). */ |
| 16516 | |
| 16517 | /* U (output) DOUBLE PRECISION array, dimension (LDU,UCOL) */ |
| 16518 | /* UCOL = M if JOBZ = 'A' or JOBZ = 'O' and M < N; */ |
| 16519 | /* UCOL = min(M,N) if JOBZ = 'S'. */ |
| 16520 | /* If JOBZ = 'A' or JOBZ = 'O' and M < N, U contains the M-by-M */ |
| 16521 | /* orthogonal matrix U; */ |
| 16522 | /* if JOBZ = 'S', U contains the first min(M,N) columns of U */ |
| 16523 | /* (the left singular vectors, stored columnwise); */ |
| 16524 | /* if JOBZ = 'O' and M >= N, or JOBZ = 'N', U is not referenced. */ |
| 16525 | |
| 16526 | /* LDU (input) INTEGER */ |
| 16527 | /* The leading dimension of the array U. LDU >= 1; if */ |
| 16528 | /* JOBZ = 'S' or 'A' or JOBZ = 'O' and M < N, LDU >= M. */ |
| 16529 | |
| 16530 | /* VT (output) DOUBLE PRECISION array, dimension (LDVT,N) */ |
| 16531 | /* If JOBZ = 'A' or JOBZ = 'O' and M >= N, VT contains the */ |
| 16532 | /* N-by-N orthogonal matrix V**T; */ |
| 16533 | /* if JOBZ = 'S', VT contains the first min(M,N) rows of */ |
| 16534 | /* V**T (the right singular vectors, stored rowwise); */ |
| 16535 | /* if JOBZ = 'O' and M < N, or JOBZ = 'N', VT is not referenced. */ |
| 16536 | |
| 16537 | /* LDVT (input) INTEGER */ |
| 16538 | /* The leading dimension of the array VT. LDVT >= 1; if */ |
| 16539 | /* JOBZ = 'A' or JOBZ = 'O' and M >= N, LDVT >= N; */ |
| 16540 | /* if JOBZ = 'S', LDVT >= min(M,N). */ |
| 16541 | |
| 16542 | /* WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) */ |
| 16543 | /* On exit, if INFO = 0, WORK(1) returns the optimal LWORK; */ |
| 16544 | |
| 16545 | /* LWORK (input) INTEGER */ |
| 16546 | /* The dimension of the array WORK. LWORK >= 1. */ |
| 16547 | /* If JOBZ = 'N', */ |
| 16548 | /* LWORK >= 3*min(M,N) + max(max(M,N),7*min(M,N)). */ |
| 16549 | /* If JOBZ = 'O', */ |
| 16550 | /* LWORK >= 3*min(M,N)*min(M,N) + */ |
| 16551 | /* max(max(M,N),5*min(M,N)*min(M,N)+4*min(M,N)). */ |
| 16552 | /* If JOBZ = 'S' or 'A' */ |
| 16553 | /* LWORK >= 3*min(M,N)*min(M,N) + */ |
| 16554 | /* max(max(M,N),4*min(M,N)*min(M,N)+4*min(M,N)). */ |
| 16555 | /* For good performance, LWORK should generally be larger. */ |
| 16556 | /* If LWORK = -1 but other input arguments are legal, WORK(1) */ |
| 16557 | /* returns the optimal LWORK. */ |
| 16558 | |
| 16559 | /* IWORK (workspace) INTEGER array, dimension (8*min(M,N)) */ |
| 16560 | |
| 16561 | /* INFO (output) INTEGER */ |
| 16562 | /* = 0: successful exit. */ |
| 16563 | /* < 0: if INFO = -i, the i-th argument had an illegal value. */ |
| 16564 | /* > 0: DBDSDC did not converge, updating process failed. */ |
| 16565 | |
| 16566 | /* Further Details */ |
| 16567 | /* =============== */ |
| 16568 | |
| 16569 | /* Based on contributions by */ |
| 16570 | /* Ming Gu and Huan Ren, Computer Science Division, University of */ |
| 16571 | /* California at Berkeley, USA */ |
| 16572 | |
| 16573 | /* ===================================================================== */ |
| 16574 | |
| 16575 | /* .. Parameters .. */ |
| 16576 | /* .. */ |
| 16577 | /* .. Local Scalars .. */ |
| 16578 | /* .. */ |
| 16579 | /* .. Local Arrays .. */ |
| 16580 | /* .. */ |
| 16581 | /* .. External Subroutines .. */ |
| 16582 | /* .. */ |
| 16583 | /* .. External Functions .. */ |
| 16584 | /* .. */ |
| 16585 | /* .. Intrinsic Functions .. */ |
| 16586 | /* .. */ |
| 16587 | /* .. Executable Statements .. */ |
| 16588 | |
| 16589 | /* Test the input arguments */ |
| 16590 | |
| 16591 | /* Parameter adjustments */ |
| 16592 | a_dim1 = *lda; |
| 16593 | a_offset = 1 + a_dim1; |
| 16594 | a -= a_offset; |
| 16595 | --s; |
| 16596 | u_dim1 = *ldu; |
| 16597 | u_offset = 1 + u_dim1; |
| 16598 | u -= u_offset; |
| 16599 | vt_dim1 = *ldvt; |
| 16600 | vt_offset = 1 + vt_dim1; |
| 16601 | vt -= vt_offset; |
| 16602 | --work; |
| 16603 | --iwork; |
| 16604 | |
| 16605 | /* Function Body */ |
| 16606 | *info = 0; |
| 16607 | minmn = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(*m,*n); |
| 16608 | wntqa = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobz, "A"); |
| 16609 | wntqs = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobz, "S"); |
| 16610 | wntqas = wntqa || wntqs; |
| 16611 | wntqo = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobz, "O"); |
| 16612 | wntqn = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobz, "N"); |
| 16613 | lquery = *lwork == -1; |
| 16614 | |
| 16615 | if (! (wntqa || wntqs || wntqo || wntqn)) { |
| 16616 | *info = -1; |
| 16617 | } else if (*m < 0) { |
| 16618 | *info = -2; |
| 16619 | } else if (*n < 0) { |
| 16620 | *info = -3; |
| 16621 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*m)) { |
| 16622 | *info = -5; |
| 16623 | } else if (*ldu < 1 || wntqas && *ldu < *m || wntqo && *m < *n && *ldu < * |
| 16624 | m) { |
| 16625 | *info = -8; |
| 16626 | } else if (*ldvt < 1 || wntqa && *ldvt < *n || wntqs && *ldvt < minmn || |
| 16627 | wntqo && *m >= *n && *ldvt < *n) { |
| 16628 | *info = -10; |
| 16629 | } |
| 16630 | |
| 16631 | /* Compute workspace */ |
| 16632 | /* (Note: Comments in the code beginning "Workspace:" describe the */ |
| 16633 | /* minimal amount of workspace needed at that point in the code, */ |
| 16634 | /* as well as the preferred amount for good performance. */ |
| 16635 | /* NB refers to the optimal block size for the immediately */ |
| 16636 | /* following subroutine, as returned by ILAENV.) */ |
| 16637 | |
| 16638 | if (*info == 0) { |
| 16639 | minwrk = 1; |
| 16640 | maxwrk = 1; |
| 16641 | if (*m >= *n && minmn > 0) { |
| 16642 | |
| 16643 | /* Compute space needed for DBDSDC */ |
| 16644 | |
| 16645 | mnthr = (integercxx . . $ integer#) (minmn * 11. / 6.); |
| 16646 | if (wntqn) { |
| 16647 | bdspac = *n * 7; |
| 16648 | } else { |
| 16649 | bdspac = *n * 3 * *n + (*n << 2); |
| 16650 | } |
| 16651 | if (*m >= mnthr) { |
| 16652 | if (wntqn) { |
| 16653 | |
| 16654 | /* Path 1 (M much larger than N, JOBZ='N') */ |
| 16655 | |
| 16656 | wrkbl = *n + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEQRF", " ", m, n, & |
| 16657 | c_n1, &c_n1); |
| 16658 | /* Computing MAX */ |
| 16659 | i__1 = wrkbl, i__2 = *n * 3 + (*n << 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 16660 | "DGEBRD", " ", n, n, &c_n1, &c_n1); |
| 16661 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16662 | /* Computing MAX */ |
| 16663 | i__1 = wrkbl, i__2 = bdspac + *n; |
| 16664 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16665 | minwrk = bdspac + *n; |
| 16666 | } else if (wntqo) { |
| 16667 | |
| 16668 | /* Path 2 (M much larger than N, JOBZ='O') */ |
| 16669 | |
| 16670 | wrkbl = *n + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEQRF", " ", m, n, & |
| 16671 | c_n1, &c_n1); |
| 16672 | /* Computing MAX */ |
| 16673 | i__1 = wrkbl, i__2 = *n + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORGQR", |
| 16674 | " ", m, n, n, &c_n1); |
| 16675 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16676 | /* Computing MAX */ |
| 16677 | i__1 = wrkbl, i__2 = *n * 3 + (*n << 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 16678 | "DGEBRD", " ", n, n, &c_n1, &c_n1); |
| 16679 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16680 | /* Computing MAX */ |
| 16681 | i__1 = wrkbl, i__2 = *n * 3 + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMBR" |
| 16682 | , "QLN", n, n, n, &c_n1); |
| 16683 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16684 | /* Computing MAX */ |
| 16685 | i__1 = wrkbl, i__2 = *n * 3 + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMBR" |
| 16686 | , "PRT", n, n, n, &c_n1); |
| 16687 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16688 | /* Computing MAX */ |
| 16689 | i__1 = wrkbl, i__2 = bdspac + *n * 3; |
| 16690 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16691 | maxwrk = wrkbl + (*n << 1) * *n; |
| 16692 | minwrk = bdspac + (*n << 1) * *n + *n * 3; |
| 16693 | } else if (wntqs) { |
| 16694 | |
| 16695 | /* Path 3 (M much larger than N, JOBZ='S') */ |
| 16696 | |
| 16697 | wrkbl = *n + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEQRF", " ", m, n, & |
| 16698 | c_n1, &c_n1); |
| 16699 | /* Computing MAX */ |
| 16700 | i__1 = wrkbl, i__2 = *n + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORGQR", |
| 16701 | " ", m, n, n, &c_n1); |
| 16702 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16703 | /* Computing MAX */ |
| 16704 | i__1 = wrkbl, i__2 = *n * 3 + (*n << 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 16705 | "DGEBRD", " ", n, n, &c_n1, &c_n1); |
| 16706 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16707 | /* Computing MAX */ |
| 16708 | i__1 = wrkbl, i__2 = *n * 3 + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMBR" |
| 16709 | , "QLN", n, n, n, &c_n1); |
| 16710 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16711 | /* Computing MAX */ |
| 16712 | i__1 = wrkbl, i__2 = *n * 3 + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMBR" |
| 16713 | , "PRT", n, n, n, &c_n1); |
| 16714 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16715 | /* Computing MAX */ |
| 16716 | i__1 = wrkbl, i__2 = bdspac + *n * 3; |
| 16717 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16718 | maxwrk = wrkbl + *n * *n; |
| 16719 | minwrk = bdspac + *n * *n + *n * 3; |
| 16720 | } else if (wntqa) { |
| 16721 | |
| 16722 | /* Path 4 (M much larger than N, JOBZ='A') */ |
| 16723 | |
| 16724 | wrkbl = *n + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEQRF", " ", m, n, & |
| 16725 | c_n1, &c_n1); |
| 16726 | /* Computing MAX */ |
| 16727 | i__1 = wrkbl, i__2 = *n + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORGQR", |
| 16728 | " ", m, m, n, &c_n1); |
| 16729 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16730 | /* Computing MAX */ |
| 16731 | i__1 = wrkbl, i__2 = *n * 3 + (*n << 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 16732 | "DGEBRD", " ", n, n, &c_n1, &c_n1); |
| 16733 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16734 | /* Computing MAX */ |
| 16735 | i__1 = wrkbl, i__2 = *n * 3 + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMBR" |
| 16736 | , "QLN", n, n, n, &c_n1); |
| 16737 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16738 | /* Computing MAX */ |
| 16739 | i__1 = wrkbl, i__2 = *n * 3 + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMBR" |
| 16740 | , "PRT", n, n, n, &c_n1); |
| 16741 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16742 | /* Computing MAX */ |
| 16743 | i__1 = wrkbl, i__2 = bdspac + *n * 3; |
| 16744 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16745 | maxwrk = wrkbl + *n * *n; |
| 16746 | minwrk = bdspac + *n * *n + *n * 3; |
| 16747 | } |
| 16748 | } else { |
| 16749 | |
| 16750 | /* Path 5 (M at least N, but not much larger) */ |
| 16751 | |
| 16752 | wrkbl = *n * 3 + (*m + *n) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEBRD", " ", m, |
| 16753 | n, &c_n1, &c_n1); |
| 16754 | if (wntqn) { |
| 16755 | /* Computing MAX */ |
| 16756 | i__1 = wrkbl, i__2 = bdspac + *n * 3; |
| 16757 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16758 | minwrk = *n * 3 + stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(*m,bdspac); |
| 16759 | } else if (wntqo) { |
| 16760 | /* Computing MAX */ |
| 16761 | i__1 = wrkbl, i__2 = *n * 3 + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMBR" |
| 16762 | , "QLN", m, n, n, &c_n1); |
| 16763 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16764 | /* Computing MAX */ |
| 16765 | i__1 = wrkbl, i__2 = *n * 3 + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMBR" |
| 16766 | , "PRT", n, n, n, &c_n1); |
| 16767 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16768 | /* Computing MAX */ |
| 16769 | i__1 = wrkbl, i__2 = bdspac + *n * 3; |
| 16770 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16771 | maxwrk = wrkbl + *m * *n; |
| 16772 | /* Computing MAX */ |
| 16773 | i__1 = *m, i__2 = *n * *n + bdspac; |
| 16774 | minwrk = *n * 3 + stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16775 | } else if (wntqs) { |
| 16776 | /* Computing MAX */ |
| 16777 | i__1 = wrkbl, i__2 = *n * 3 + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMBR" |
| 16778 | , "QLN", m, n, n, &c_n1); |
| 16779 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16780 | /* Computing MAX */ |
| 16781 | i__1 = wrkbl, i__2 = *n * 3 + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMBR" |
| 16782 | , "PRT", n, n, n, &c_n1); |
| 16783 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16784 | /* Computing MAX */ |
| 16785 | i__1 = wrkbl, i__2 = bdspac + *n * 3; |
| 16786 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16787 | minwrk = *n * 3 + stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(*m,bdspac); |
| 16788 | } else if (wntqa) { |
| 16789 | /* Computing MAX */ |
| 16790 | i__1 = wrkbl, i__2 = *n * 3 + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMBR" |
| 16791 | , "QLN", m, m, n, &c_n1); |
| 16792 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16793 | /* Computing MAX */ |
| 16794 | i__1 = wrkbl, i__2 = *n * 3 + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMBR" |
| 16795 | , "PRT", n, n, n, &c_n1); |
| 16796 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16797 | /* Computing MAX */ |
| 16798 | i__1 = maxwrk, i__2 = bdspac + *n * 3; |
| 16799 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16800 | minwrk = *n * 3 + stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(*m,bdspac); |
| 16801 | } |
| 16802 | } |
| 16803 | } else if (minmn > 0) { |
| 16804 | |
| 16805 | /* Compute space needed for DBDSDC */ |
| 16806 | |
| 16807 | mnthr = (integercxx . . $ integer#) (minmn * 11. / 6.); |
| 16808 | if (wntqn) { |
| 16809 | bdspac = *m * 7; |
| 16810 | } else { |
| 16811 | bdspac = *m * 3 * *m + (*m << 2); |
| 16812 | } |
| 16813 | if (*n >= mnthr) { |
| 16814 | if (wntqn) { |
| 16815 | |
| 16816 | /* Path 1t (N much larger than M, JOBZ='N') */ |
| 16817 | |
| 16818 | wrkbl = *m + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGELQF", " ", m, n, & |
| 16819 | c_n1, &c_n1); |
| 16820 | /* Computing MAX */ |
| 16821 | i__1 = wrkbl, i__2 = *m * 3 + (*m << 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 16822 | "DGEBRD", " ", m, m, &c_n1, &c_n1); |
| 16823 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16824 | /* Computing MAX */ |
| 16825 | i__1 = wrkbl, i__2 = bdspac + *m; |
| 16826 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16827 | minwrk = bdspac + *m; |
| 16828 | } else if (wntqo) { |
| 16829 | |
| 16830 | /* Path 2t (N much larger than M, JOBZ='O') */ |
| 16831 | |
| 16832 | wrkbl = *m + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGELQF", " ", m, n, & |
| 16833 | c_n1, &c_n1); |
| 16834 | /* Computing MAX */ |
| 16835 | i__1 = wrkbl, i__2 = *m + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORGLQ", |
| 16836 | " ", m, n, m, &c_n1); |
| 16837 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16838 | /* Computing MAX */ |
| 16839 | i__1 = wrkbl, i__2 = *m * 3 + (*m << 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 16840 | "DGEBRD", " ", m, m, &c_n1, &c_n1); |
| 16841 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16842 | /* Computing MAX */ |
| 16843 | i__1 = wrkbl, i__2 = *m * 3 + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMBR" |
| 16844 | , "QLN", m, m, m, &c_n1); |
| 16845 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16846 | /* Computing MAX */ |
| 16847 | i__1 = wrkbl, i__2 = *m * 3 + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMBR" |
| 16848 | , "PRT", m, m, m, &c_n1); |
| 16849 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16850 | /* Computing MAX */ |
| 16851 | i__1 = wrkbl, i__2 = bdspac + *m * 3; |
| 16852 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16853 | maxwrk = wrkbl + (*m << 1) * *m; |
| 16854 | minwrk = bdspac + (*m << 1) * *m + *m * 3; |
| 16855 | } else if (wntqs) { |
| 16856 | |
| 16857 | /* Path 3t (N much larger than M, JOBZ='S') */ |
| 16858 | |
| 16859 | wrkbl = *m + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGELQF", " ", m, n, & |
| 16860 | c_n1, &c_n1); |
| 16861 | /* Computing MAX */ |
| 16862 | i__1 = wrkbl, i__2 = *m + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORGLQ", |
| 16863 | " ", m, n, m, &c_n1); |
| 16864 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16865 | /* Computing MAX */ |
| 16866 | i__1 = wrkbl, i__2 = *m * 3 + (*m << 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 16867 | "DGEBRD", " ", m, m, &c_n1, &c_n1); |
| 16868 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16869 | /* Computing MAX */ |
| 16870 | i__1 = wrkbl, i__2 = *m * 3 + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMBR" |
| 16871 | , "QLN", m, m, m, &c_n1); |
| 16872 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16873 | /* Computing MAX */ |
| 16874 | i__1 = wrkbl, i__2 = *m * 3 + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMBR" |
| 16875 | , "PRT", m, m, m, &c_n1); |
| 16876 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16877 | /* Computing MAX */ |
| 16878 | i__1 = wrkbl, i__2 = bdspac + *m * 3; |
| 16879 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16880 | maxwrk = wrkbl + *m * *m; |
| 16881 | minwrk = bdspac + *m * *m + *m * 3; |
| 16882 | } else if (wntqa) { |
| 16883 | |
| 16884 | /* Path 4t (N much larger than M, JOBZ='A') */ |
| 16885 | |
| 16886 | wrkbl = *m + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGELQF", " ", m, n, & |
| 16887 | c_n1, &c_n1); |
| 16888 | /* Computing MAX */ |
| 16889 | i__1 = wrkbl, i__2 = *m + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORGLQ", |
| 16890 | " ", n, n, m, &c_n1); |
| 16891 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16892 | /* Computing MAX */ |
| 16893 | i__1 = wrkbl, i__2 = *m * 3 + (*m << 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 16894 | "DGEBRD", " ", m, m, &c_n1, &c_n1); |
| 16895 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16896 | /* Computing MAX */ |
| 16897 | i__1 = wrkbl, i__2 = *m * 3 + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMBR" |
| 16898 | , "QLN", m, m, m, &c_n1); |
| 16899 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16900 | /* Computing MAX */ |
| 16901 | i__1 = wrkbl, i__2 = *m * 3 + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMBR" |
| 16902 | , "PRT", m, m, m, &c_n1); |
| 16903 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16904 | /* Computing MAX */ |
| 16905 | i__1 = wrkbl, i__2 = bdspac + *m * 3; |
| 16906 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16907 | maxwrk = wrkbl + *m * *m; |
| 16908 | minwrk = bdspac + *m * *m + *m * 3; |
| 16909 | } |
| 16910 | } else { |
| 16911 | |
| 16912 | /* Path 5t (N greater than M, but not much larger) */ |
| 16913 | |
| 16914 | wrkbl = *m * 3 + (*m + *n) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEBRD", " ", m, |
| 16915 | n, &c_n1, &c_n1); |
| 16916 | if (wntqn) { |
| 16917 | /* Computing MAX */ |
| 16918 | i__1 = wrkbl, i__2 = bdspac + *m * 3; |
| 16919 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16920 | minwrk = *m * 3 + stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(*n,bdspac); |
| 16921 | } else if (wntqo) { |
| 16922 | /* Computing MAX */ |
| 16923 | i__1 = wrkbl, i__2 = *m * 3 + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMBR" |
| 16924 | , "QLN", m, m, n, &c_n1); |
| 16925 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16926 | /* Computing MAX */ |
| 16927 | i__1 = wrkbl, i__2 = *m * 3 + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMBR" |
| 16928 | , "PRT", m, n, m, &c_n1); |
| 16929 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16930 | /* Computing MAX */ |
| 16931 | i__1 = wrkbl, i__2 = bdspac + *m * 3; |
| 16932 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16933 | maxwrk = wrkbl + *m * *n; |
| 16934 | /* Computing MAX */ |
| 16935 | i__1 = *n, i__2 = *m * *m + bdspac; |
| 16936 | minwrk = *m * 3 + stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16937 | } else if (wntqs) { |
| 16938 | /* Computing MAX */ |
| 16939 | i__1 = wrkbl, i__2 = *m * 3 + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMBR" |
| 16940 | , "QLN", m, m, n, &c_n1); |
| 16941 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16942 | /* Computing MAX */ |
| 16943 | i__1 = wrkbl, i__2 = *m * 3 + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMBR" |
| 16944 | , "PRT", m, n, m, &c_n1); |
| 16945 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16946 | /* Computing MAX */ |
| 16947 | i__1 = wrkbl, i__2 = bdspac + *m * 3; |
| 16948 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16949 | minwrk = *m * 3 + stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(*n,bdspac); |
| 16950 | } else if (wntqa) { |
| 16951 | /* Computing MAX */ |
| 16952 | i__1 = wrkbl, i__2 = *m * 3 + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMBR" |
| 16953 | , "QLN", m, m, n, &c_n1); |
| 16954 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16955 | /* Computing MAX */ |
| 16956 | i__1 = wrkbl, i__2 = *m * 3 + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMBR" |
| 16957 | , "PRT", n, n, m, &c_n1); |
| 16958 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16959 | /* Computing MAX */ |
| 16960 | i__1 = wrkbl, i__2 = bdspac + *m * 3; |
| 16961 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 16962 | minwrk = *m * 3 + stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(*n,bdspac); |
| 16963 | } |
| 16964 | } |
| 16965 | } |
| 16966 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(maxwrk,minwrk); |
| 16967 | work[1] = (double) maxwrk; |
| 16968 | |
| 16969 | if (*lwork < minwrk && ! lquery) { |
| 16970 | *info = -12; |
| 16971 | } |
| 16972 | } |
| 16973 | |
| 16974 | if (*info != 0) { |
| 16975 | i__1 = -(*info); |
| 16976 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGESDD", &i__1); |
| 16977 | return 0; |
| 16978 | } else if (lquery) { |
| 16979 | return 0; |
| 16980 | } |
| 16981 | |
| 16982 | /* Quick return if possible */ |
| 16983 | |
| 16984 | if (*m == 0 || *n == 0) { |
| 16985 | return 0; |
| 16986 | } |
| 16987 | |
| 16988 | /* Get machine constants */ |
| 16989 | |
| 16990 | eps = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("P"); |
| 16991 | smlnum = sqrtcxx . . $ sqrt(fee4f1d22bc8e617).(dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("S")) / eps; |
| 16992 | bignum = 1. / smlnum; |
| 16993 | |
| 16994 | /* Scale A if max element outside range [SMLNUM,BIGNUM] */ |
| 16995 | |
| 16996 | anrm = dlange_cxx . . $ dlange_(98d44e6417336f20).("M", m, n, &a[a_offset], lda, dum); |
| 16997 | iscl = 0; |
| 16998 | if (anrm > 0. && anrm < smlnum) { |
| 16999 | iscl = 1; |
| 17000 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &anrm, &smlnum, m, n, &a[a_offset], lda, & |
| 17001 | ierr); |
| 17002 | } else if (anrm > bignum) { |
| 17003 | iscl = 1; |
| 17004 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &anrm, &bignum, m, n, &a[a_offset], lda, & |
| 17005 | ierr); |
| 17006 | } |
| 17007 | |
| 17008 | if (*m >= *n) { |
| 17009 | |
| 17010 | /* A has at least as many rows as columns. If A has sufficiently */ |
| 17011 | /* more rows than columns, first reduce using the QR */ |
| 17012 | /* decomposition (if sufficient workspace available) */ |
| 17013 | |
| 17014 | if (*m >= mnthr) { |
| 17015 | |
| 17016 | if (wntqn) { |
| 17017 | |
| 17018 | /* Path 1 (M much larger than N, JOBZ='N') */ |
| 17019 | /* No singular vectors to be computed */ |
| 17020 | |
| 17021 | itau = 1; |
| 17022 | nwork = itau + *n; |
| 17023 | |
| 17024 | /* Compute A=Q*R */ |
| 17025 | /* (Workspace: need 2*N, prefer N+N*NB) */ |
| 17026 | |
| 17027 | i__1 = *lwork - nwork + 1; |
| 17028 | dgeqrf_cxx . . $ dgeqrf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[itau], &work[nwork], & |
| 17029 | i__1, &ierr); |
| 17030 | |
| 17031 | /* Zero out below R */ |
| 17032 | |
| 17033 | i__1 = *n - 1; |
| 17034 | i__2 = *n - 1; |
| 17035 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("L", &i__1, &i__2, &c_b227, &c_b227, &a[a_dim1 + 2], |
| 17036 | lda); |
| 17037 | ie = 1; |
| 17038 | itauq = ie + *n; |
| 17039 | itaup = itauq + *n; |
| 17040 | nwork = itaup + *n; |
| 17041 | |
| 17042 | /* Bidiagonalize R in A */ |
| 17043 | /* (Workspace: need 4*N, prefer 3*N+2*N*NB) */ |
| 17044 | |
| 17045 | i__1 = *lwork - nwork + 1; |
| 17046 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(n, n, &a[a_offset], lda, &s[1], &work[ie], &work[ |
| 17047 | itauq], &work[itaup], &work[nwork], &i__1, &ierr); |
| 17048 | nwork = ie + *n; |
| 17049 | |
| 17050 | /* Perform bidiagonal SVD, computing singular values only */ |
| 17051 | /* (Workspace: need N+BDSPAC) */ |
| 17052 | |
| 17053 | dbdsdc_cxx . . $ dbdsdc_(dd785f63b10dfcb3).("U", "N", n, &s[1], &work[ie], dum, &c__1, dum, &c__1, |
| 17054 | dum, idum, &work[nwork], &iwork[1], info); |
| 17055 | |
| 17056 | } else if (wntqo) { |
| 17057 | |
| 17058 | /* Path 2 (M much larger than N, JOBZ = 'O') */ |
| 17059 | /* N left singular vectors to be overwritten on A and */ |
| 17060 | /* N right singular vectors to be computed in VT */ |
| 17061 | |
| 17062 | ir = 1; |
| 17063 | |
| 17064 | /* WORK(IR) is LDWRKR by N */ |
| 17065 | |
| 17066 | if (*lwork >= *lda * *n + *n * *n + *n * 3 + bdspac) { |
| 17067 | ldwrkr = *lda; |
| 17068 | } else { |
| 17069 | ldwrkr = (*lwork - *n * *n - *n * 3 - bdspac) / *n; |
| 17070 | } |
| 17071 | itau = ir + ldwrkr * *n; |
| 17072 | nwork = itau + *n; |
| 17073 | |
| 17074 | /* Compute A=Q*R */ |
| 17075 | /* (Workspace: need N*N+2*N, prefer N*N+N+N*NB) */ |
| 17076 | |
| 17077 | i__1 = *lwork - nwork + 1; |
| 17078 | dgeqrf_cxx . . $ dgeqrf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[itau], &work[nwork], & |
| 17079 | i__1, &ierr); |
| 17080 | |
| 17081 | /* Copy R to WORK(IR), zeroing out below it */ |
| 17082 | |
| 17083 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("U", n, n, &a[a_offset], lda, &work[ir], &ldwrkr); |
| 17084 | i__1 = *n - 1; |
| 17085 | i__2 = *n - 1; |
| 17086 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("L", &i__1, &i__2, &c_b227, &c_b227, &work[ir + 1], & |
| 17087 | ldwrkr); |
| 17088 | |
| 17089 | /* Generate Q in A */ |
| 17090 | /* (Workspace: need N*N+2*N, prefer N*N+N+N*NB) */ |
| 17091 | |
| 17092 | i__1 = *lwork - nwork + 1; |
| 17093 | dorgqr_cxx . . $ dorgqr_(424524679a238630).(m, n, n, &a[a_offset], lda, &work[itau], &work[nwork], |
| 17094 | &i__1, &ierr); |
| 17095 | ie = itau; |
| 17096 | itauq = ie + *n; |
| 17097 | itaup = itauq + *n; |
| 17098 | nwork = itaup + *n; |
| 17099 | |
| 17100 | /* Bidiagonalize R in VT, copying result to WORK(IR) */ |
| 17101 | /* (Workspace: need N*N+4*N, prefer N*N+3*N+2*N*NB) */ |
| 17102 | |
| 17103 | i__1 = *lwork - nwork + 1; |
| 17104 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(n, n, &work[ir], &ldwrkr, &s[1], &work[ie], &work[ |
| 17105 | itauq], &work[itaup], &work[nwork], &i__1, &ierr); |
| 17106 | |
| 17107 | /* WORK(IU) is N by N */ |
| 17108 | |
| 17109 | iu = nwork; |
| 17110 | nwork = iu + *n * *n; |
| 17111 | |
| 17112 | /* Perform bidiagonal SVD, computing left singular vectors */ |
| 17113 | /* of bidiagonal matrix in WORK(IU) and computing right */ |
| 17114 | /* singular vectors of bidiagonal matrix in VT */ |
| 17115 | /* (Workspace: need N+N*N+BDSPAC) */ |
| 17116 | |
| 17117 | dbdsdc_cxx . . $ dbdsdc_(dd785f63b10dfcb3).("U", "I", n, &s[1], &work[ie], &work[iu], n, &vt[ |
| 17118 | vt_offset], ldvt, dum, idum, &work[nwork], &iwork[1], |
| 17119 | info); |
| 17120 | |
| 17121 | /* Overwrite WORK(IU) by left singular vectors of R */ |
| 17122 | /* and VT by right singular vectors of R */ |
| 17123 | /* (Workspace: need 2*N*N+3*N, prefer 2*N*N+2*N+N*NB) */ |
| 17124 | |
| 17125 | i__1 = *lwork - nwork + 1; |
| 17126 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("Q", "L", "N", n, n, n, &work[ir], &ldwrkr, &work[ |
| 17127 | itauq], &work[iu], n, &work[nwork], &i__1, &ierr); |
| 17128 | i__1 = *lwork - nwork + 1; |
| 17129 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("P", "R", "T", n, n, n, &work[ir], &ldwrkr, &work[ |
| 17130 | itaup], &vt[vt_offset], ldvt, &work[nwork], &i__1, & |
| 17131 | ierr); |
| 17132 | |
| 17133 | /* Multiply Q in A by left singular vectors of R in */ |
| 17134 | /* WORK(IU), storing result in WORK(IR) and copying to A */ |
| 17135 | /* (Workspace: need 2*N*N, prefer N*N+M*N) */ |
| 17136 | |
| 17137 | i__1 = *m; |
| 17138 | i__2 = ldwrkr; |
| 17139 | for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += |
| 17140 | i__2) { |
| 17141 | /* Computing MIN */ |
| 17142 | i__3 = *m - i__ + 1; |
| 17143 | chunk = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__3,ldwrkr); |
| 17144 | dgemm_cxx . . $ dgemm_(7f9a15c7502022ea).("N", "N", &chunk, n, n, &c_b248, &a[i__ + a_dim1], |
| 17145 | lda, &work[iu], n, &c_b227, &work[ir], &ldwrkr); |
| 17146 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("F", &chunk, n, &work[ir], &ldwrkr, &a[i__ + |
| 17147 | a_dim1], lda); |
| 17148 | /* L10: */ |
| 17149 | } |
| 17150 | |
| 17151 | } else if (wntqs) { |
| 17152 | |
| 17153 | /* Path 3 (M much larger than N, JOBZ='S') */ |
| 17154 | /* N left singular vectors to be computed in U and */ |
| 17155 | /* N right singular vectors to be computed in VT */ |
| 17156 | |
| 17157 | ir = 1; |
| 17158 | |
| 17159 | /* WORK(IR) is N by N */ |
| 17160 | |
| 17161 | ldwrkr = *n; |
| 17162 | itau = ir + ldwrkr * *n; |
| 17163 | nwork = itau + *n; |
| 17164 | |
| 17165 | /* Compute A=Q*R */ |
| 17166 | /* (Workspace: need N*N+2*N, prefer N*N+N+N*NB) */ |
| 17167 | |
| 17168 | i__2 = *lwork - nwork + 1; |
| 17169 | dgeqrf_cxx . . $ dgeqrf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[itau], &work[nwork], & |
| 17170 | i__2, &ierr); |
| 17171 | |
| 17172 | /* Copy R to WORK(IR), zeroing out below it */ |
| 17173 | |
| 17174 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("U", n, n, &a[a_offset], lda, &work[ir], &ldwrkr); |
| 17175 | i__2 = *n - 1; |
| 17176 | i__1 = *n - 1; |
| 17177 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("L", &i__2, &i__1, &c_b227, &c_b227, &work[ir + 1], & |
| 17178 | ldwrkr); |
| 17179 | |
| 17180 | /* Generate Q in A */ |
| 17181 | /* (Workspace: need N*N+2*N, prefer N*N+N+N*NB) */ |
| 17182 | |
| 17183 | i__2 = *lwork - nwork + 1; |
| 17184 | dorgqr_cxx . . $ dorgqr_(424524679a238630).(m, n, n, &a[a_offset], lda, &work[itau], &work[nwork], |
| 17185 | &i__2, &ierr); |
| 17186 | ie = itau; |
| 17187 | itauq = ie + *n; |
| 17188 | itaup = itauq + *n; |
| 17189 | nwork = itaup + *n; |
| 17190 | |
| 17191 | /* Bidiagonalize R in WORK(IR) */ |
| 17192 | /* (Workspace: need N*N+4*N, prefer N*N+3*N+2*N*NB) */ |
| 17193 | |
| 17194 | i__2 = *lwork - nwork + 1; |
| 17195 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(n, n, &work[ir], &ldwrkr, &s[1], &work[ie], &work[ |
| 17196 | itauq], &work[itaup], &work[nwork], &i__2, &ierr); |
| 17197 | |
| 17198 | /* Perform bidiagonal SVD, computing left singular vectors */ |
| 17199 | /* of bidiagoal matrix in U and computing right singular */ |
| 17200 | /* vectors of bidiagonal matrix in VT */ |
| 17201 | /* (Workspace: need N+BDSPAC) */ |
| 17202 | |
| 17203 | dbdsdc_cxx . . $ dbdsdc_(dd785f63b10dfcb3).("U", "I", n, &s[1], &work[ie], &u[u_offset], ldu, &vt[ |
| 17204 | vt_offset], ldvt, dum, idum, &work[nwork], &iwork[1], |
| 17205 | info); |
| 17206 | |
| 17207 | /* Overwrite U by left singular vectors of R and VT */ |
| 17208 | /* by right singular vectors of R */ |
| 17209 | /* (Workspace: need N*N+3*N, prefer N*N+2*N+N*NB) */ |
| 17210 | |
| 17211 | i__2 = *lwork - nwork + 1; |
| 17212 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("Q", "L", "N", n, n, n, &work[ir], &ldwrkr, &work[ |
| 17213 | itauq], &u[u_offset], ldu, &work[nwork], &i__2, &ierr); |
| 17214 | |
| 17215 | i__2 = *lwork - nwork + 1; |
| 17216 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("P", "R", "T", n, n, n, &work[ir], &ldwrkr, &work[ |
| 17217 | itaup], &vt[vt_offset], ldvt, &work[nwork], &i__2, & |
| 17218 | ierr); |
| 17219 | |
| 17220 | /* Multiply Q in A by left singular vectors of R in */ |
| 17221 | /* WORK(IR), storing result in U */ |
| 17222 | /* (Workspace: need N*N) */ |
| 17223 | |
| 17224 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("F", n, n, &u[u_offset], ldu, &work[ir], &ldwrkr); |
| 17225 | dgemm_cxx . . $ dgemm_(7f9a15c7502022ea).("N", "N", m, n, n, &c_b248, &a[a_offset], lda, &work[ |
| 17226 | ir], &ldwrkr, &c_b227, &u[u_offset], ldu); |
| 17227 | |
| 17228 | } else if (wntqa) { |
| 17229 | |
| 17230 | /* Path 4 (M much larger than N, JOBZ='A') */ |
| 17231 | /* M left singular vectors to be computed in U and */ |
| 17232 | /* N right singular vectors to be computed in VT */ |
| 17233 | |
| 17234 | iu = 1; |
| 17235 | |
| 17236 | /* WORK(IU) is N by N */ |
| 17237 | |
| 17238 | ldwrku = *n; |
| 17239 | itau = iu + ldwrku * *n; |
| 17240 | nwork = itau + *n; |
| 17241 | |
| 17242 | /* Compute A=Q*R, copying result to U */ |
| 17243 | /* (Workspace: need N*N+2*N, prefer N*N+N+N*NB) */ |
| 17244 | |
| 17245 | i__2 = *lwork - nwork + 1; |
| 17246 | dgeqrf_cxx . . $ dgeqrf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[itau], &work[nwork], & |
| 17247 | i__2, &ierr); |
| 17248 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("L", m, n, &a[a_offset], lda, &u[u_offset], ldu); |
| 17249 | |
| 17250 | /* Generate Q in U */ |
| 17251 | /* (Workspace: need N*N+2*N, prefer N*N+N+N*NB) */ |
| 17252 | i__2 = *lwork - nwork + 1; |
| 17253 | dorgqr_cxx . . $ dorgqr_(424524679a238630).(m, m, n, &u[u_offset], ldu, &work[itau], &work[nwork], |
| 17254 | &i__2, &ierr); |
| 17255 | |
| 17256 | /* Produce R in A, zeroing out other entries */ |
| 17257 | |
| 17258 | i__2 = *n - 1; |
| 17259 | i__1 = *n - 1; |
| 17260 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("L", &i__2, &i__1, &c_b227, &c_b227, &a[a_dim1 + 2], |
| 17261 | lda); |
| 17262 | ie = itau; |
| 17263 | itauq = ie + *n; |
| 17264 | itaup = itauq + *n; |
| 17265 | nwork = itaup + *n; |
| 17266 | |
| 17267 | /* Bidiagonalize R in A */ |
| 17268 | /* (Workspace: need N*N+4*N, prefer N*N+3*N+2*N*NB) */ |
| 17269 | |
| 17270 | i__2 = *lwork - nwork + 1; |
| 17271 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(n, n, &a[a_offset], lda, &s[1], &work[ie], &work[ |
| 17272 | itauq], &work[itaup], &work[nwork], &i__2, &ierr); |
| 17273 | |
| 17274 | /* Perform bidiagonal SVD, computing left singular vectors */ |
| 17275 | /* of bidiagonal matrix in WORK(IU) and computing right */ |
| 17276 | /* singular vectors of bidiagonal matrix in VT */ |
| 17277 | /* (Workspace: need N+N*N+BDSPAC) */ |
| 17278 | |
| 17279 | dbdsdc_cxx . . $ dbdsdc_(dd785f63b10dfcb3).("U", "I", n, &s[1], &work[ie], &work[iu], n, &vt[ |
| 17280 | vt_offset], ldvt, dum, idum, &work[nwork], &iwork[1], |
| 17281 | info); |
| 17282 | |
| 17283 | /* Overwrite WORK(IU) by left singular vectors of R and VT */ |
| 17284 | /* by right singular vectors of R */ |
| 17285 | /* (Workspace: need N*N+3*N, prefer N*N+2*N+N*NB) */ |
| 17286 | |
| 17287 | i__2 = *lwork - nwork + 1; |
| 17288 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("Q", "L", "N", n, n, n, &a[a_offset], lda, &work[ |
| 17289 | itauq], &work[iu], &ldwrku, &work[nwork], &i__2, & |
| 17290 | ierr); |
| 17291 | i__2 = *lwork - nwork + 1; |
| 17292 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("P", "R", "T", n, n, n, &a[a_offset], lda, &work[ |
| 17293 | itaup], &vt[vt_offset], ldvt, &work[nwork], &i__2, & |
| 17294 | ierr); |
| 17295 | |
| 17296 | /* Multiply Q in U by left singular vectors of R in */ |
| 17297 | /* WORK(IU), storing result in A */ |
| 17298 | /* (Workspace: need N*N) */ |
| 17299 | |
| 17300 | dgemm_cxx . . $ dgemm_(7f9a15c7502022ea).("N", "N", m, n, n, &c_b248, &u[u_offset], ldu, &work[ |
| 17301 | iu], &ldwrku, &c_b227, &a[a_offset], lda); |
| 17302 | |
| 17303 | /* Copy left singular vectors of A from A to U */ |
| 17304 | |
| 17305 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("F", m, n, &a[a_offset], lda, &u[u_offset], ldu); |
| 17306 | |
| 17307 | } |
| 17308 | |
| 17309 | } else { |
| 17310 | |
| 17311 | /* M .LT. MNTHR */ |
| 17312 | |
| 17313 | /* Path 5 (M at least N, but not much larger) */ |
| 17314 | /* Reduce to bidiagonal form without QR decomposition */ |
| 17315 | |
| 17316 | ie = 1; |
| 17317 | itauq = ie + *n; |
| 17318 | itaup = itauq + *n; |
| 17319 | nwork = itaup + *n; |
| 17320 | |
| 17321 | /* Bidiagonalize A */ |
| 17322 | /* (Workspace: need 3*N+M, prefer 3*N+(M+N)*NB) */ |
| 17323 | |
| 17324 | i__2 = *lwork - nwork + 1; |
| 17325 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(m, n, &a[a_offset], lda, &s[1], &work[ie], &work[itauq], & |
| 17326 | work[itaup], &work[nwork], &i__2, &ierr); |
| 17327 | if (wntqn) { |
| 17328 | |
| 17329 | /* Perform bidiagonal SVD, only computing singular values */ |
| 17330 | /* (Workspace: need N+BDSPAC) */ |
| 17331 | |
| 17332 | dbdsdc_cxx . . $ dbdsdc_(dd785f63b10dfcb3).("U", "N", n, &s[1], &work[ie], dum, &c__1, dum, &c__1, |
| 17333 | dum, idum, &work[nwork], &iwork[1], info); |
| 17334 | } else if (wntqo) { |
| 17335 | iu = nwork; |
| 17336 | if (*lwork >= *m * *n + *n * 3 + bdspac) { |
| 17337 | |
| 17338 | /* WORK( IU ) is M by N */ |
| 17339 | |
| 17340 | ldwrku = *m; |
| 17341 | nwork = iu + ldwrku * *n; |
| 17342 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("F", m, n, &c_b227, &c_b227, &work[iu], &ldwrku); |
| 17343 | } else { |
| 17344 | |
| 17345 | /* WORK( IU ) is N by N */ |
| 17346 | |
| 17347 | ldwrku = *n; |
| 17348 | nwork = iu + ldwrku * *n; |
| 17349 | |
| 17350 | /* WORK(IR) is LDWRKR by N */ |
| 17351 | |
| 17352 | ir = nwork; |
| 17353 | ldwrkr = (*lwork - *n * *n - *n * 3) / *n; |
| 17354 | } |
| 17355 | nwork = iu + ldwrku * *n; |
| 17356 | |
| 17357 | /* Perform bidiagonal SVD, computing left singular vectors */ |
| 17358 | /* of bidiagonal matrix in WORK(IU) and computing right */ |
| 17359 | /* singular vectors of bidiagonal matrix in VT */ |
| 17360 | /* (Workspace: need N+N*N+BDSPAC) */ |
| 17361 | |
| 17362 | dbdsdc_cxx . . $ dbdsdc_(dd785f63b10dfcb3).("U", "I", n, &s[1], &work[ie], &work[iu], &ldwrku, & |
| 17363 | vt[vt_offset], ldvt, dum, idum, &work[nwork], &iwork[ |
| 17364 | 1], info); |
| 17365 | |
| 17366 | /* Overwrite VT by right singular vectors of A */ |
| 17367 | /* (Workspace: need N*N+2*N, prefer N*N+N+N*NB) */ |
| 17368 | |
| 17369 | i__2 = *lwork - nwork + 1; |
| 17370 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("P", "R", "T", n, n, n, &a[a_offset], lda, &work[ |
| 17371 | itaup], &vt[vt_offset], ldvt, &work[nwork], &i__2, & |
| 17372 | ierr); |
| 17373 | |
| 17374 | if (*lwork >= *m * *n + *n * 3 + bdspac) { |
| 17375 | |
| 17376 | /* Overwrite WORK(IU) by left singular vectors of A */ |
| 17377 | /* (Workspace: need N*N+2*N, prefer N*N+N+N*NB) */ |
| 17378 | |
| 17379 | i__2 = *lwork - nwork + 1; |
| 17380 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("Q", "L", "N", m, n, n, &a[a_offset], lda, &work[ |
| 17381 | itauq], &work[iu], &ldwrku, &work[nwork], &i__2, & |
| 17382 | ierr); |
| 17383 | |
| 17384 | /* Copy left singular vectors of A from WORK(IU) to A */ |
| 17385 | |
| 17386 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("F", m, n, &work[iu], &ldwrku, &a[a_offset], lda); |
| 17387 | } else { |
| 17388 | |
| 17389 | /* Generate Q in A */ |
| 17390 | /* (Workspace: need N*N+2*N, prefer N*N+N+N*NB) */ |
| 17391 | |
| 17392 | i__2 = *lwork - nwork + 1; |
| 17393 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("Q", m, n, n, &a[a_offset], lda, &work[itauq], & |
| 17394 | work[nwork], &i__2, &ierr); |
| 17395 | |
| 17396 | /* Multiply Q in A by left singular vectors of */ |
| 17397 | /* bidiagonal matrix in WORK(IU), storing result in */ |
| 17398 | /* WORK(IR) and copying to A */ |
| 17399 | /* (Workspace: need 2*N*N, prefer N*N+M*N) */ |
| 17400 | |
| 17401 | i__2 = *m; |
| 17402 | i__1 = ldwrkr; |
| 17403 | for (i__ = 1; i__1 < 0 ? i__ >= i__2 : i__ <= i__2; i__ += |
| 17404 | i__1) { |
| 17405 | /* Computing MIN */ |
| 17406 | i__3 = *m - i__ + 1; |
| 17407 | chunk = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__3,ldwrkr); |
| 17408 | dgemm_cxx . . $ dgemm_(7f9a15c7502022ea).("N", "N", &chunk, n, n, &c_b248, &a[i__ + |
| 17409 | a_dim1], lda, &work[iu], &ldwrku, &c_b227, & |
| 17410 | work[ir], &ldwrkr); |
| 17411 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("F", &chunk, n, &work[ir], &ldwrkr, &a[i__ + |
| 17412 | a_dim1], lda); |
| 17413 | /* L20: */ |
| 17414 | } |
| 17415 | } |
| 17416 | |
| 17417 | } else if (wntqs) { |
| 17418 | |
| 17419 | /* Perform bidiagonal SVD, computing left singular vectors */ |
| 17420 | /* of bidiagonal matrix in U and computing right singular */ |
| 17421 | /* vectors of bidiagonal matrix in VT */ |
| 17422 | /* (Workspace: need N+BDSPAC) */ |
| 17423 | |
| 17424 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("F", m, n, &c_b227, &c_b227, &u[u_offset], ldu); |
| 17425 | dbdsdc_cxx . . $ dbdsdc_(dd785f63b10dfcb3).("U", "I", n, &s[1], &work[ie], &u[u_offset], ldu, &vt[ |
| 17426 | vt_offset], ldvt, dum, idum, &work[nwork], &iwork[1], |
| 17427 | info); |
| 17428 | |
| 17429 | /* Overwrite U by left singular vectors of A and VT */ |
| 17430 | /* by right singular vectors of A */ |
| 17431 | /* (Workspace: need 3*N, prefer 2*N+N*NB) */ |
| 17432 | |
| 17433 | i__1 = *lwork - nwork + 1; |
| 17434 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("Q", "L", "N", m, n, n, &a[a_offset], lda, &work[ |
| 17435 | itauq], &u[u_offset], ldu, &work[nwork], &i__1, &ierr); |
| 17436 | i__1 = *lwork - nwork + 1; |
| 17437 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("P", "R", "T", n, n, n, &a[a_offset], lda, &work[ |
| 17438 | itaup], &vt[vt_offset], ldvt, &work[nwork], &i__1, & |
| 17439 | ierr); |
| 17440 | } else if (wntqa) { |
| 17441 | |
| 17442 | /* Perform bidiagonal SVD, computing left singular vectors */ |
| 17443 | /* of bidiagonal matrix in U and computing right singular */ |
| 17444 | /* vectors of bidiagonal matrix in VT */ |
| 17445 | /* (Workspace: need N+BDSPAC) */ |
| 17446 | |
| 17447 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("F", m, m, &c_b227, &c_b227, &u[u_offset], ldu); |
| 17448 | dbdsdc_cxx . . $ dbdsdc_(dd785f63b10dfcb3).("U", "I", n, &s[1], &work[ie], &u[u_offset], ldu, &vt[ |
| 17449 | vt_offset], ldvt, dum, idum, &work[nwork], &iwork[1], |
| 17450 | info); |
| 17451 | |
| 17452 | /* Set the right corner of U to identity matrix */ |
| 17453 | |
| 17454 | if (*m > *n) { |
| 17455 | i__1 = *m - *n; |
| 17456 | i__2 = *m - *n; |
| 17457 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("F", &i__1, &i__2, &c_b227, &c_b248, &u[*n + 1 + ( |
| 17458 | *n + 1) * u_dim1], ldu); |
| 17459 | } |
| 17460 | |
| 17461 | /* Overwrite U by left singular vectors of A and VT */ |
| 17462 | /* by right singular vectors of A */ |
| 17463 | /* (Workspace: need N*N+2*N+M, prefer N*N+2*N+M*NB) */ |
| 17464 | |
| 17465 | i__1 = *lwork - nwork + 1; |
| 17466 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("Q", "L", "N", m, m, n, &a[a_offset], lda, &work[ |
| 17467 | itauq], &u[u_offset], ldu, &work[nwork], &i__1, &ierr); |
| 17468 | i__1 = *lwork - nwork + 1; |
| 17469 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("P", "R", "T", n, n, m, &a[a_offset], lda, &work[ |
| 17470 | itaup], &vt[vt_offset], ldvt, &work[nwork], &i__1, & |
| 17471 | ierr); |
| 17472 | } |
| 17473 | |
| 17474 | } |
| 17475 | |
| 17476 | } else { |
| 17477 | |
| 17478 | /* A has more columns than rows. If A has sufficiently more */ |
| 17479 | /* columns than rows, first reduce using the LQ decomposition (if */ |
| 17480 | /* sufficient workspace available) */ |
| 17481 | |
| 17482 | if (*n >= mnthr) { |
| 17483 | |
| 17484 | if (wntqn) { |
| 17485 | |
| 17486 | /* Path 1t (N much larger than M, JOBZ='N') */ |
| 17487 | /* No singular vectors to be computed */ |
| 17488 | |
| 17489 | itau = 1; |
| 17490 | nwork = itau + *m; |
| 17491 | |
| 17492 | /* Compute A=L*Q */ |
| 17493 | /* (Workspace: need 2*M, prefer M+M*NB) */ |
| 17494 | |
| 17495 | i__1 = *lwork - nwork + 1; |
| 17496 | dgelqf_cxx . . $ dgelqf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[itau], &work[nwork], & |
| 17497 | i__1, &ierr); |
| 17498 | |
| 17499 | /* Zero out above L */ |
| 17500 | |
| 17501 | i__1 = *m - 1; |
| 17502 | i__2 = *m - 1; |
| 17503 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("U", &i__1, &i__2, &c_b227, &c_b227, &a[(a_dim1 << 1) |
| 17504 | + 1], lda); |
| 17505 | ie = 1; |
| 17506 | itauq = ie + *m; |
| 17507 | itaup = itauq + *m; |
| 17508 | nwork = itaup + *m; |
| 17509 | |
| 17510 | /* Bidiagonalize L in A */ |
| 17511 | /* (Workspace: need 4*M, prefer 3*M+2*M*NB) */ |
| 17512 | |
| 17513 | i__1 = *lwork - nwork + 1; |
| 17514 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(m, m, &a[a_offset], lda, &s[1], &work[ie], &work[ |
| 17515 | itauq], &work[itaup], &work[nwork], &i__1, &ierr); |
| 17516 | nwork = ie + *m; |
| 17517 | |
| 17518 | /* Perform bidiagonal SVD, computing singular values only */ |
| 17519 | /* (Workspace: need M+BDSPAC) */ |
| 17520 | |
| 17521 | dbdsdc_cxx . . $ dbdsdc_(dd785f63b10dfcb3).("U", "N", m, &s[1], &work[ie], dum, &c__1, dum, &c__1, |
| 17522 | dum, idum, &work[nwork], &iwork[1], info); |
| 17523 | |
| 17524 | } else if (wntqo) { |
| 17525 | |
| 17526 | /* Path 2t (N much larger than M, JOBZ='O') */ |
| 17527 | /* M right singular vectors to be overwritten on A and */ |
| 17528 | /* M left singular vectors to be computed in U */ |
| 17529 | |
| 17530 | ivt = 1; |
| 17531 | |
| 17532 | /* IVT is M by M */ |
| 17533 | |
| 17534 | il = ivt + *m * *m; |
| 17535 | if (*lwork >= *m * *n + *m * *m + *m * 3 + bdspac) { |
| 17536 | |
| 17537 | /* WORK(IL) is M by N */ |
| 17538 | |
| 17539 | ldwrkl = *m; |
| 17540 | chunk = *n; |
| 17541 | } else { |
| 17542 | ldwrkl = *m; |
| 17543 | chunk = (*lwork - *m * *m) / *m; |
| 17544 | } |
| 17545 | itau = il + ldwrkl * *m; |
| 17546 | nwork = itau + *m; |
| 17547 | |
| 17548 | /* Compute A=L*Q */ |
| 17549 | /* (Workspace: need M*M+2*M, prefer M*M+M+M*NB) */ |
| 17550 | |
| 17551 | i__1 = *lwork - nwork + 1; |
| 17552 | dgelqf_cxx . . $ dgelqf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[itau], &work[nwork], & |
| 17553 | i__1, &ierr); |
| 17554 | |
| 17555 | /* Copy L to WORK(IL), zeroing about above it */ |
| 17556 | |
| 17557 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("L", m, m, &a[a_offset], lda, &work[il], &ldwrkl); |
| 17558 | i__1 = *m - 1; |
| 17559 | i__2 = *m - 1; |
| 17560 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("U", &i__1, &i__2, &c_b227, &c_b227, &work[il + |
| 17561 | ldwrkl], &ldwrkl); |
| 17562 | |
| 17563 | /* Generate Q in A */ |
| 17564 | /* (Workspace: need M*M+2*M, prefer M*M+M+M*NB) */ |
| 17565 | |
| 17566 | i__1 = *lwork - nwork + 1; |
| 17567 | dorglq_cxx . . $ dorglq_(424524679a238630).(m, n, m, &a[a_offset], lda, &work[itau], &work[nwork], |
| 17568 | &i__1, &ierr); |
| 17569 | ie = itau; |
| 17570 | itauq = ie + *m; |
| 17571 | itaup = itauq + *m; |
| 17572 | nwork = itaup + *m; |
| 17573 | |
| 17574 | /* Bidiagonalize L in WORK(IL) */ |
| 17575 | /* (Workspace: need M*M+4*M, prefer M*M+3*M+2*M*NB) */ |
| 17576 | |
| 17577 | i__1 = *lwork - nwork + 1; |
| 17578 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(m, m, &work[il], &ldwrkl, &s[1], &work[ie], &work[ |
| 17579 | itauq], &work[itaup], &work[nwork], &i__1, &ierr); |
| 17580 | |
| 17581 | /* Perform bidiagonal SVD, computing left singular vectors */ |
| 17582 | /* of bidiagonal matrix in U, and computing right singular */ |
| 17583 | /* vectors of bidiagonal matrix in WORK(IVT) */ |
| 17584 | /* (Workspace: need M+M*M+BDSPAC) */ |
| 17585 | |
| 17586 | dbdsdc_cxx . . $ dbdsdc_(dd785f63b10dfcb3).("U", "I", m, &s[1], &work[ie], &u[u_offset], ldu, & |
| 17587 | work[ivt], m, dum, idum, &work[nwork], &iwork[1], |
| 17588 | info); |
| 17589 | |
| 17590 | /* Overwrite U by left singular vectors of L and WORK(IVT) */ |
| 17591 | /* by right singular vectors of L */ |
| 17592 | /* (Workspace: need 2*M*M+3*M, prefer 2*M*M+2*M+M*NB) */ |
| 17593 | |
| 17594 | i__1 = *lwork - nwork + 1; |
| 17595 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("Q", "L", "N", m, m, m, &work[il], &ldwrkl, &work[ |
| 17596 | itauq], &u[u_offset], ldu, &work[nwork], &i__1, &ierr); |
| 17597 | i__1 = *lwork - nwork + 1; |
| 17598 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("P", "R", "T", m, m, m, &work[il], &ldwrkl, &work[ |
| 17599 | itaup], &work[ivt], m, &work[nwork], &i__1, &ierr); |
| 17600 | |
| 17601 | /* Multiply right singular vectors of L in WORK(IVT) by Q */ |
| 17602 | /* in A, storing result in WORK(IL) and copying to A */ |
| 17603 | /* (Workspace: need 2*M*M, prefer M*M+M*N) */ |
| 17604 | |
| 17605 | i__1 = *n; |
| 17606 | i__2 = chunk; |
| 17607 | for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += |
| 17608 | i__2) { |
| 17609 | /* Computing MIN */ |
| 17610 | i__3 = *n - i__ + 1; |
| 17611 | blk = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__3,chunk); |
| 17612 | dgemm_cxx . . $ dgemm_(7f9a15c7502022ea).("N", "N", m, &blk, m, &c_b248, &work[ivt], m, &a[ |
| 17613 | i__ * a_dim1 + 1], lda, &c_b227, &work[il], & |
| 17614 | ldwrkl); |
| 17615 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("F", m, &blk, &work[il], &ldwrkl, &a[i__ * a_dim1 |
| 17616 | + 1], lda); |
| 17617 | /* L30: */ |
| 17618 | } |
| 17619 | |
| 17620 | } else if (wntqs) { |
| 17621 | |
| 17622 | /* Path 3t (N much larger than M, JOBZ='S') */ |
| 17623 | /* M right singular vectors to be computed in VT and */ |
| 17624 | /* M left singular vectors to be computed in U */ |
| 17625 | |
| 17626 | il = 1; |
| 17627 | |
| 17628 | /* WORK(IL) is M by M */ |
| 17629 | |
| 17630 | ldwrkl = *m; |
| 17631 | itau = il + ldwrkl * *m; |
| 17632 | nwork = itau + *m; |
| 17633 | |
| 17634 | /* Compute A=L*Q */ |
| 17635 | /* (Workspace: need M*M+2*M, prefer M*M+M+M*NB) */ |
| 17636 | |
| 17637 | i__2 = *lwork - nwork + 1; |
| 17638 | dgelqf_cxx . . $ dgelqf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[itau], &work[nwork], & |
| 17639 | i__2, &ierr); |
| 17640 | |
| 17641 | /* Copy L to WORK(IL), zeroing out above it */ |
| 17642 | |
| 17643 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("L", m, m, &a[a_offset], lda, &work[il], &ldwrkl); |
| 17644 | i__2 = *m - 1; |
| 17645 | i__1 = *m - 1; |
| 17646 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("U", &i__2, &i__1, &c_b227, &c_b227, &work[il + |
| 17647 | ldwrkl], &ldwrkl); |
| 17648 | |
| 17649 | /* Generate Q in A */ |
| 17650 | /* (Workspace: need M*M+2*M, prefer M*M+M+M*NB) */ |
| 17651 | |
| 17652 | i__2 = *lwork - nwork + 1; |
| 17653 | dorglq_cxx . . $ dorglq_(424524679a238630).(m, n, m, &a[a_offset], lda, &work[itau], &work[nwork], |
| 17654 | &i__2, &ierr); |
| 17655 | ie = itau; |
| 17656 | itauq = ie + *m; |
| 17657 | itaup = itauq + *m; |
| 17658 | nwork = itaup + *m; |
| 17659 | |
| 17660 | /* Bidiagonalize L in WORK(IU), copying result to U */ |
| 17661 | /* (Workspace: need M*M+4*M, prefer M*M+3*M+2*M*NB) */ |
| 17662 | |
| 17663 | i__2 = *lwork - nwork + 1; |
| 17664 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(m, m, &work[il], &ldwrkl, &s[1], &work[ie], &work[ |
| 17665 | itauq], &work[itaup], &work[nwork], &i__2, &ierr); |
| 17666 | |
| 17667 | /* Perform bidiagonal SVD, computing left singular vectors */ |
| 17668 | /* of bidiagonal matrix in U and computing right singular */ |
| 17669 | /* vectors of bidiagonal matrix in VT */ |
| 17670 | /* (Workspace: need M+BDSPAC) */ |
| 17671 | |
| 17672 | dbdsdc_cxx . . $ dbdsdc_(dd785f63b10dfcb3).("U", "I", m, &s[1], &work[ie], &u[u_offset], ldu, &vt[ |
| 17673 | vt_offset], ldvt, dum, idum, &work[nwork], &iwork[1], |
| 17674 | info); |
| 17675 | |
| 17676 | /* Overwrite U by left singular vectors of L and VT */ |
| 17677 | /* by right singular vectors of L */ |
| 17678 | /* (Workspace: need M*M+3*M, prefer M*M+2*M+M*NB) */ |
| 17679 | |
| 17680 | i__2 = *lwork - nwork + 1; |
| 17681 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("Q", "L", "N", m, m, m, &work[il], &ldwrkl, &work[ |
| 17682 | itauq], &u[u_offset], ldu, &work[nwork], &i__2, &ierr); |
| 17683 | i__2 = *lwork - nwork + 1; |
| 17684 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("P", "R", "T", m, m, m, &work[il], &ldwrkl, &work[ |
| 17685 | itaup], &vt[vt_offset], ldvt, &work[nwork], &i__2, & |
| 17686 | ierr); |
| 17687 | |
| 17688 | /* Multiply right singular vectors of L in WORK(IL) by */ |
| 17689 | /* Q in A, storing result in VT */ |
| 17690 | /* (Workspace: need M*M) */ |
| 17691 | |
| 17692 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("F", m, m, &vt[vt_offset], ldvt, &work[il], &ldwrkl); |
| 17693 | dgemm_cxx . . $ dgemm_(7f9a15c7502022ea).("N", "N", m, n, m, &c_b248, &work[il], &ldwrkl, &a[ |
| 17694 | a_offset], lda, &c_b227, &vt[vt_offset], ldvt); |
| 17695 | |
| 17696 | } else if (wntqa) { |
| 17697 | |
| 17698 | /* Path 4t (N much larger than M, JOBZ='A') */ |
| 17699 | /* N right singular vectors to be computed in VT and */ |
| 17700 | /* M left singular vectors to be computed in U */ |
| 17701 | |
| 17702 | ivt = 1; |
| 17703 | |
| 17704 | /* WORK(IVT) is M by M */ |
| 17705 | |
| 17706 | ldwkvt = *m; |
| 17707 | itau = ivt + ldwkvt * *m; |
| 17708 | nwork = itau + *m; |
| 17709 | |
| 17710 | /* Compute A=L*Q, copying result to VT */ |
| 17711 | /* (Workspace: need M*M+2*M, prefer M*M+M+M*NB) */ |
| 17712 | |
| 17713 | i__2 = *lwork - nwork + 1; |
| 17714 | dgelqf_cxx . . $ dgelqf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[itau], &work[nwork], & |
| 17715 | i__2, &ierr); |
| 17716 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("U", m, n, &a[a_offset], lda, &vt[vt_offset], ldvt); |
| 17717 | |
| 17718 | /* Generate Q in VT */ |
| 17719 | /* (Workspace: need M*M+2*M, prefer M*M+M+M*NB) */ |
| 17720 | |
| 17721 | i__2 = *lwork - nwork + 1; |
| 17722 | dorglq_cxx . . $ dorglq_(424524679a238630).(n, n, m, &vt[vt_offset], ldvt, &work[itau], &work[ |
| 17723 | nwork], &i__2, &ierr); |
| 17724 | |
| 17725 | /* Produce L in A, zeroing out other entries */ |
| 17726 | |
| 17727 | i__2 = *m - 1; |
| 17728 | i__1 = *m - 1; |
| 17729 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("U", &i__2, &i__1, &c_b227, &c_b227, &a[(a_dim1 << 1) |
| 17730 | + 1], lda); |
| 17731 | ie = itau; |
| 17732 | itauq = ie + *m; |
| 17733 | itaup = itauq + *m; |
| 17734 | nwork = itaup + *m; |
| 17735 | |
| 17736 | /* Bidiagonalize L in A */ |
| 17737 | /* (Workspace: need M*M+4*M, prefer M*M+3*M+2*M*NB) */ |
| 17738 | |
| 17739 | i__2 = *lwork - nwork + 1; |
| 17740 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(m, m, &a[a_offset], lda, &s[1], &work[ie], &work[ |
| 17741 | itauq], &work[itaup], &work[nwork], &i__2, &ierr); |
| 17742 | |
| 17743 | /* Perform bidiagonal SVD, computing left singular vectors */ |
| 17744 | /* of bidiagonal matrix in U and computing right singular */ |
| 17745 | /* vectors of bidiagonal matrix in WORK(IVT) */ |
| 17746 | /* (Workspace: need M+M*M+BDSPAC) */ |
| 17747 | |
| 17748 | dbdsdc_cxx . . $ dbdsdc_(dd785f63b10dfcb3).("U", "I", m, &s[1], &work[ie], &u[u_offset], ldu, & |
| 17749 | work[ivt], &ldwkvt, dum, idum, &work[nwork], &iwork[1] |
| 17750 | , info); |
| 17751 | |
| 17752 | /* Overwrite U by left singular vectors of L and WORK(IVT) */ |
| 17753 | /* by right singular vectors of L */ |
| 17754 | /* (Workspace: need M*M+3*M, prefer M*M+2*M+M*NB) */ |
| 17755 | |
| 17756 | i__2 = *lwork - nwork + 1; |
| 17757 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("Q", "L", "N", m, m, m, &a[a_offset], lda, &work[ |
| 17758 | itauq], &u[u_offset], ldu, &work[nwork], &i__2, &ierr); |
| 17759 | i__2 = *lwork - nwork + 1; |
| 17760 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("P", "R", "T", m, m, m, &a[a_offset], lda, &work[ |
| 17761 | itaup], &work[ivt], &ldwkvt, &work[nwork], &i__2, & |
| 17762 | ierr); |
| 17763 | |
| 17764 | /* Multiply right singular vectors of L in WORK(IVT) by */ |
| 17765 | /* Q in VT, storing result in A */ |
| 17766 | /* (Workspace: need M*M) */ |
| 17767 | |
| 17768 | dgemm_cxx . . $ dgemm_(7f9a15c7502022ea).("N", "N", m, n, m, &c_b248, &work[ivt], &ldwkvt, &vt[ |
| 17769 | vt_offset], ldvt, &c_b227, &a[a_offset], lda); |
| 17770 | |
| 17771 | /* Copy right singular vectors of A from A to VT */ |
| 17772 | |
| 17773 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("F", m, n, &a[a_offset], lda, &vt[vt_offset], ldvt); |
| 17774 | |
| 17775 | } |
| 17776 | |
| 17777 | } else { |
| 17778 | |
| 17779 | /* N .LT. MNTHR */ |
| 17780 | |
| 17781 | /* Path 5t (N greater than M, but not much larger) */ |
| 17782 | /* Reduce to bidiagonal form without LQ decomposition */ |
| 17783 | |
| 17784 | ie = 1; |
| 17785 | itauq = ie + *m; |
| 17786 | itaup = itauq + *m; |
| 17787 | nwork = itaup + *m; |
| 17788 | |
| 17789 | /* Bidiagonalize A */ |
| 17790 | /* (Workspace: need 3*M+N, prefer 3*M+(M+N)*NB) */ |
| 17791 | |
| 17792 | i__2 = *lwork - nwork + 1; |
| 17793 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(m, n, &a[a_offset], lda, &s[1], &work[ie], &work[itauq], & |
| 17794 | work[itaup], &work[nwork], &i__2, &ierr); |
| 17795 | if (wntqn) { |
| 17796 | |
| 17797 | /* Perform bidiagonal SVD, only computing singular values */ |
| 17798 | /* (Workspace: need M+BDSPAC) */ |
| 17799 | |
| 17800 | dbdsdc_cxx . . $ dbdsdc_(dd785f63b10dfcb3).("L", "N", m, &s[1], &work[ie], dum, &c__1, dum, &c__1, |
| 17801 | dum, idum, &work[nwork], &iwork[1], info); |
| 17802 | } else if (wntqo) { |
| 17803 | ldwkvt = *m; |
| 17804 | ivt = nwork; |
| 17805 | if (*lwork >= *m * *n + *m * 3 + bdspac) { |
| 17806 | |
| 17807 | /* WORK( IVT ) is M by N */ |
| 17808 | |
| 17809 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("F", m, n, &c_b227, &c_b227, &work[ivt], &ldwkvt); |
| 17810 | nwork = ivt + ldwkvt * *n; |
| 17811 | } else { |
| 17812 | |
| 17813 | /* WORK( IVT ) is M by M */ |
| 17814 | |
| 17815 | nwork = ivt + ldwkvt * *m; |
| 17816 | il = nwork; |
| 17817 | |
| 17818 | /* WORK(IL) is M by CHUNK */ |
| 17819 | |
| 17820 | chunk = (*lwork - *m * *m - *m * 3) / *m; |
| 17821 | } |
| 17822 | |
| 17823 | /* Perform bidiagonal SVD, computing left singular vectors */ |
| 17824 | /* of bidiagonal matrix in U and computing right singular */ |
| 17825 | /* vectors of bidiagonal matrix in WORK(IVT) */ |
| 17826 | /* (Workspace: need M*M+BDSPAC) */ |
| 17827 | |
| 17828 | dbdsdc_cxx . . $ dbdsdc_(dd785f63b10dfcb3).("L", "I", m, &s[1], &work[ie], &u[u_offset], ldu, & |
| 17829 | work[ivt], &ldwkvt, dum, idum, &work[nwork], &iwork[1] |
| 17830 | , info); |
| 17831 | |
| 17832 | /* Overwrite U by left singular vectors of A */ |
| 17833 | /* (Workspace: need M*M+2*M, prefer M*M+M+M*NB) */ |
| 17834 | |
| 17835 | i__2 = *lwork - nwork + 1; |
| 17836 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("Q", "L", "N", m, m, n, &a[a_offset], lda, &work[ |
| 17837 | itauq], &u[u_offset], ldu, &work[nwork], &i__2, &ierr); |
| 17838 | |
| 17839 | if (*lwork >= *m * *n + *m * 3 + bdspac) { |
| 17840 | |
| 17841 | /* Overwrite WORK(IVT) by left singular vectors of A */ |
| 17842 | /* (Workspace: need M*M+2*M, prefer M*M+M+M*NB) */ |
| 17843 | |
| 17844 | i__2 = *lwork - nwork + 1; |
| 17845 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("P", "R", "T", m, n, m, &a[a_offset], lda, &work[ |
| 17846 | itaup], &work[ivt], &ldwkvt, &work[nwork], &i__2, |
| 17847 | &ierr); |
| 17848 | |
| 17849 | /* Copy right singular vectors of A from WORK(IVT) to A */ |
| 17850 | |
| 17851 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("F", m, n, &work[ivt], &ldwkvt, &a[a_offset], lda); |
| 17852 | } else { |
| 17853 | |
| 17854 | /* Generate P**T in A */ |
| 17855 | /* (Workspace: need M*M+2*M, prefer M*M+M+M*NB) */ |
| 17856 | |
| 17857 | i__2 = *lwork - nwork + 1; |
| 17858 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("P", m, n, m, &a[a_offset], lda, &work[itaup], & |
| 17859 | work[nwork], &i__2, &ierr); |
| 17860 | |
| 17861 | /* Multiply Q in A by right singular vectors of */ |
| 17862 | /* bidiagonal matrix in WORK(IVT), storing result in */ |
| 17863 | /* WORK(IL) and copying to A */ |
| 17864 | /* (Workspace: need 2*M*M, prefer M*M+M*N) */ |
| 17865 | |
| 17866 | i__2 = *n; |
| 17867 | i__1 = chunk; |
| 17868 | for (i__ = 1; i__1 < 0 ? i__ >= i__2 : i__ <= i__2; i__ += |
| 17869 | i__1) { |
| 17870 | /* Computing MIN */ |
| 17871 | i__3 = *n - i__ + 1; |
| 17872 | blk = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__3,chunk); |
| 17873 | dgemm_cxx . . $ dgemm_(7f9a15c7502022ea).("N", "N", m, &blk, m, &c_b248, &work[ivt], & |
| 17874 | ldwkvt, &a[i__ * a_dim1 + 1], lda, &c_b227, & |
| 17875 | work[il], m); |
| 17876 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("F", m, &blk, &work[il], m, &a[i__ * a_dim1 + |
| 17877 | 1], lda); |
| 17878 | /* L40: */ |
| 17879 | } |
| 17880 | } |
| 17881 | } else if (wntqs) { |
| 17882 | |
| 17883 | /* Perform bidiagonal SVD, computing left singular vectors */ |
| 17884 | /* of bidiagonal matrix in U and computing right singular */ |
| 17885 | /* vectors of bidiagonal matrix in VT */ |
| 17886 | /* (Workspace: need M+BDSPAC) */ |
| 17887 | |
| 17888 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("F", m, n, &c_b227, &c_b227, &vt[vt_offset], ldvt); |
| 17889 | dbdsdc_cxx . . $ dbdsdc_(dd785f63b10dfcb3).("L", "I", m, &s[1], &work[ie], &u[u_offset], ldu, &vt[ |
| 17890 | vt_offset], ldvt, dum, idum, &work[nwork], &iwork[1], |
| 17891 | info); |
| 17892 | |
| 17893 | /* Overwrite U by left singular vectors of A and VT */ |
| 17894 | /* by right singular vectors of A */ |
| 17895 | /* (Workspace: need 3*M, prefer 2*M+M*NB) */ |
| 17896 | |
| 17897 | i__1 = *lwork - nwork + 1; |
| 17898 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("Q", "L", "N", m, m, n, &a[a_offset], lda, &work[ |
| 17899 | itauq], &u[u_offset], ldu, &work[nwork], &i__1, &ierr); |
| 17900 | i__1 = *lwork - nwork + 1; |
| 17901 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("P", "R", "T", m, n, m, &a[a_offset], lda, &work[ |
| 17902 | itaup], &vt[vt_offset], ldvt, &work[nwork], &i__1, & |
| 17903 | ierr); |
| 17904 | } else if (wntqa) { |
| 17905 | |
| 17906 | /* Perform bidiagonal SVD, computing left singular vectors */ |
| 17907 | /* of bidiagonal matrix in U and computing right singular */ |
| 17908 | /* vectors of bidiagonal matrix in VT */ |
| 17909 | /* (Workspace: need M+BDSPAC) */ |
| 17910 | |
| 17911 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("F", n, n, &c_b227, &c_b227, &vt[vt_offset], ldvt); |
| 17912 | dbdsdc_cxx . . $ dbdsdc_(dd785f63b10dfcb3).("L", "I", m, &s[1], &work[ie], &u[u_offset], ldu, &vt[ |
| 17913 | vt_offset], ldvt, dum, idum, &work[nwork], &iwork[1], |
| 17914 | info); |
| 17915 | |
| 17916 | /* Set the right corner of VT to identity matrix */ |
| 17917 | |
| 17918 | if (*n > *m) { |
| 17919 | i__1 = *n - *m; |
| 17920 | i__2 = *n - *m; |
| 17921 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("F", &i__1, &i__2, &c_b227, &c_b248, &vt[*m + 1 + |
| 17922 | (*m + 1) * vt_dim1], ldvt); |
| 17923 | } |
| 17924 | |
| 17925 | /* Overwrite U by left singular vectors of A and VT */ |
| 17926 | /* by right singular vectors of A */ |
| 17927 | /* (Workspace: need 2*M+N, prefer 2*M+N*NB) */ |
| 17928 | |
| 17929 | i__1 = *lwork - nwork + 1; |
| 17930 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("Q", "L", "N", m, m, n, &a[a_offset], lda, &work[ |
| 17931 | itauq], &u[u_offset], ldu, &work[nwork], &i__1, &ierr); |
| 17932 | i__1 = *lwork - nwork + 1; |
| 17933 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("P", "R", "T", n, n, m, &a[a_offset], lda, &work[ |
| 17934 | itaup], &vt[vt_offset], ldvt, &work[nwork], &i__1, & |
| 17935 | ierr); |
| 17936 | } |
| 17937 | |
| 17938 | } |
| 17939 | |
| 17940 | } |
| 17941 | |
| 17942 | /* Undo scaling if necessary */ |
| 17943 | |
| 17944 | if (iscl == 1) { |
| 17945 | if (anrm > bignum) { |
| 17946 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &bignum, &anrm, &minmn, &c__1, &s[1], & |
| 17947 | minmn, &ierr); |
| 17948 | } |
| 17949 | if (anrm < smlnum) { |
| 17950 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &smlnum, &anrm, &minmn, &c__1, &s[1], & |
| 17951 | minmn, &ierr); |
| 17952 | } |
| 17953 | } |
| 17954 | |
| 17955 | /* Return optimal workspace in WORK(1) */ |
| 17956 | |
| 17957 | work[1] = (double) maxwrk; |
| 17958 | |
| 17959 | return 0; |
| 17960 | |
| 17961 | /* End of DGESDD */ |
| 17962 | |
| 17963 | } /* dgesdd_ */ |
| 17964 | |
| 17965 | /* Subroutine */ int dgesv_cxx . . $ dgesv_(b3b13f05b7ed42c5).(integercxx . . $ integer# *n, integercxx . . $ integer# *nrhs, double *a, integercxx . . $ integer# |
| 17966 | *lda, integercxx . . $ integer# *ipiv, double *b, integercxx . . $ integer# *ldb, integercxx . . $ integer# *info) |
| 17967 | { |
| 17968 | /* System generated locals */ |
| 17969 | integercxx . . $ integer# a_dim1, a_offset, b_dim1, b_offset, i__1; |
| 17970 | |
| 17971 | /* -- LAPACK driver routine (version 3.1) -- */ |
| 17972 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 17973 | /* November 2006 */ |
| 17974 | |
| 17975 | /* .. Scalar Arguments .. */ |
| 17976 | /* .. */ |
| 17977 | /* .. Array Arguments .. */ |
| 17978 | /* .. */ |
| 17979 | |
| 17980 | /* Purpose */ |
| 17981 | /* ======= */ |
| 17982 | |
| 17983 | /* DGESV computes the solution to a real system of linear equations */ |
| 17984 | /* A * X = B, */ |
| 17985 | /* where A is an N-by-N matrix and X and B are N-by-NRHS matrices. */ |
| 17986 | |
| 17987 | /* The LU decomposition with partial pivoting and row interchanges is */ |
| 17988 | /* used to factor A as */ |
| 17989 | /* A = P * L * U, */ |
| 17990 | /* where P is a permutation matrix, L is unit lower triangular, and U is */ |
| 17991 | /* upper triangular. The factored form of A is then used to solve the */ |
| 17992 | /* system of equations A * X = B. */ |
| 17993 | |
| 17994 | /* Arguments */ |
| 17995 | /* ========= */ |
| 17996 | |
| 17997 | /* N (input) INTEGER */ |
| 17998 | /* The number of linear equations, i.e., the order of the */ |
| 17999 | /* matrix A. N >= 0. */ |
| 18000 | |
| 18001 | /* NRHS (input) INTEGER */ |
| 18002 | /* The number of right hand sides, i.e., the number of columns */ |
| 18003 | /* of the matrix B. NRHS >= 0. */ |
| 18004 | |
| 18005 | /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 18006 | /* On entry, the N-by-N coefficient matrix A. */ |
| 18007 | /* On exit, the factors L and U from the factorization */ |
| 18008 | /* A = P*L*U; the unit diagonal elements of L are not stored. */ |
| 18009 | |
| 18010 | /* LDA (input) INTEGER */ |
| 18011 | /* The leading dimension of the array A. LDA >= max(1,N). */ |
| 18012 | |
| 18013 | /* IPIV (output) INTEGER array, dimension (N) */ |
| 18014 | /* The pivot indices that define the permutation matrix P; */ |
| 18015 | /* row i of the matrix was interchanged with row IPIV(i). */ |
| 18016 | |
| 18017 | /* B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */ |
| 18018 | /* On entry, the N-by-NRHS matrix of right hand side matrix B. */ |
| 18019 | /* On exit, if INFO = 0, the N-by-NRHS solution matrix X. */ |
| 18020 | |
| 18021 | /* LDB (input) INTEGER */ |
| 18022 | /* The leading dimension of the array B. LDB >= max(1,N). */ |
| 18023 | |
| 18024 | /* INFO (output) INTEGER */ |
| 18025 | /* = 0: successful exit */ |
| 18026 | /* < 0: if INFO = -i, the i-th argument had an illegal value */ |
| 18027 | /* > 0: if INFO = i, U(i,i) is exactly zero. The factorization */ |
| 18028 | /* has been completed, but the factor U is exactly */ |
| 18029 | /* singular, so the solution could not be computed. */ |
| 18030 | |
| 18031 | /* ===================================================================== */ |
| 18032 | |
| 18033 | /* .. External Subroutines .. */ |
| 18034 | /* .. */ |
| 18035 | /* .. Intrinsic Functions .. */ |
| 18036 | /* .. */ |
| 18037 | /* .. Executable Statements .. */ |
| 18038 | |
| 18039 | /* Test the input parameters. */ |
| 18040 | |
| 18041 | /* Parameter adjustments */ |
| 18042 | a_dim1 = *lda; |
| 18043 | a_offset = 1 + a_dim1; |
| 18044 | a -= a_offset; |
| 18045 | --ipiv; |
| 18046 | b_dim1 = *ldb; |
| 18047 | b_offset = 1 + b_dim1; |
| 18048 | b -= b_offset; |
| 18049 | |
| 18050 | /* Function Body */ |
| 18051 | *info = 0; |
| 18052 | if (*n < 0) { |
| 18053 | *info = -1; |
| 18054 | } else if (*nrhs < 0) { |
| 18055 | *info = -2; |
| 18056 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 18057 | *info = -4; |
| 18058 | } else if (*ldb < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 18059 | *info = -7; |
| 18060 | } |
| 18061 | if (*info != 0) { |
| 18062 | i__1 = -(*info); |
| 18063 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGESV ", &i__1); |
| 18064 | return 0; |
| 18065 | } |
| 18066 | |
| 18067 | /* Compute the LU factorization of A. */ |
| 18068 | |
| 18069 | dgetrf_cxx . . $ dgetrf_(7c7a27c235ac304).(n, n, &a[a_offset], lda, &ipiv[1], info); |
| 18070 | if (*info == 0) { |
| 18071 | |
| 18072 | /* Solve the system A*X = B, overwriting B with X. */ |
| 18073 | |
| 18074 | dgetrs_cxx . . $ dgetrs_(695824aa3fbf5aa2).("No transpose", n, nrhs, &a[a_offset], lda, &ipiv[1], &b[ |
| 18075 | b_offset], ldb, info); |
| 18076 | } |
| 18077 | return 0; |
| 18078 | |
| 18079 | /* End of DGESV */ |
| 18080 | |
| 18081 | } /* dgesv_ */ |
| 18082 | |
| 18083 | /* Subroutine */ int dgesvd_cxx . . $ dgesvd_(2bee6ce4c9f2edac).(const char *jobu, const char *jobvt, integercxx . . $ integer# *m, integercxx . . $ integer# *n, |
| 18084 | double *a, integercxx . . $ integer# *lda, double *s, double *u, integercxx . . $ integer# * |
| 18085 | ldu, double *vt, integercxx . . $ integer# *ldvt, double *work, integercxx . . $ integer# *lwork, |
| 18086 | integercxx . . $ integer# *info) |
| 18087 | { |
| 18088 | /* Table of constant values */ |
| 18089 | static integercxx . . $ integer# c__6 = 6; |
| 18090 | static integercxx . . $ integer# c__0 = 0; |
| 18091 | static integercxx . . $ integer# c__2 = 2; |
| 18092 | static integercxx . . $ integer# c__1 = 1; |
| 18093 | static integercxx . . $ integer# c_n1 = -1; |
| 18094 | static double c_b421 = 0.; |
| 18095 | static double c_b443 = 1.; |
| 18096 | |
| 18097 | /* System generated locals */ |
| 18098 | char * a__1[2]; |
| 18099 | integercxx . . $ integer# a_dim1, a_offset, u_dim1, u_offset, vt_dim1, vt_offset, i__1[2], |
| 18100 | i__2, i__3, i__4; |
| 18101 | char ch__1[3]; |
| 18102 | |
| 18103 | /* Local variables */ |
| 18104 | integercxx . . $ integer# i__, ie, ir, iu, blk, ncu; |
| 18105 | double dum[1], eps; |
| 18106 | integercxx . . $ integer# nru, iscl; |
| 18107 | double anrm; |
| 18108 | integercxx . . $ integer# ierr, itau, ncvt, nrvt; |
| 18109 | integercxx . . $ integer# chunk, minmn, wrkbl, itaup, itauq, mnthr, iwork; |
| 18110 | bool wntua, wntva, wntun, wntuo, wntvn, wntvo, wntus, wntvs; |
| 18111 | integercxx . . $ integer# bdspac; |
| 18112 | double bignum; |
| 18113 | integercxx . . $ integer# ldwrkr, minwrk, ldwrku, maxwrk; |
| 18114 | double smlnum; |
| 18115 | bool lquery, wntuas, wntvas; |
| 18116 | |
| 18117 | /* -- LAPACK driver routine (version 3.1) -- */ |
| 18118 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 18119 | /* November 2006 */ |
| 18120 | |
| 18121 | /* .. Scalar Arguments .. */ |
| 18122 | /* .. */ |
| 18123 | /* .. Array Arguments .. */ |
| 18124 | /* .. */ |
| 18125 | |
| 18126 | /* Purpose */ |
| 18127 | /* ======= */ |
| 18128 | |
| 18129 | /* DGESVD computes the singular value decomposition (SVD) of a real */ |
| 18130 | /* M-by-N matrix A, optionally computing the left and/or right singular */ |
| 18131 | /* vectors. The SVD is written */ |
| 18132 | |
| 18133 | /* A = U * SIGMA * transpose(V) */ |
| 18134 | |
| 18135 | /* where SIGMA is an M-by-N matrix which is zero except for its */ |
| 18136 | /* min(m,n) diagonal elements, U is an M-by-M orthogonal matrix, and */ |
| 18137 | /* V is an N-by-N orthogonal matrix. The diagonal elements of SIGMA */ |
| 18138 | /* are the singular values of A; they are real and non-negative, and */ |
| 18139 | /* are returned in descending order. The first min(m,n) columns of */ |
| 18140 | /* U and V are the left and right singular vectors of A. */ |
| 18141 | |
| 18142 | /* Note that the routine returns V**T, not V. */ |
| 18143 | |
| 18144 | /* Arguments */ |
| 18145 | /* ========= */ |
| 18146 | |
| 18147 | /* JOBU (input) CHARACTER*1 */ |
| 18148 | /* Specifies options for computing all or part of the matrix U: */ |
| 18149 | /* = 'A': all M columns of U are returned in array U: */ |
| 18150 | /* = 'S': the first min(m,n) columns of U (the left singular */ |
| 18151 | /* vectors) are returned in the array U; */ |
| 18152 | /* = 'O': the first min(m,n) columns of U (the left singular */ |
| 18153 | /* vectors) are overwritten on the array A; */ |
| 18154 | /* = 'N': no columns of U (no left singular vectors) are */ |
| 18155 | /* computed. */ |
| 18156 | |
| 18157 | /* JOBVT (input) CHARACTER*1 */ |
| 18158 | /* Specifies options for computing all or part of the matrix */ |
| 18159 | /* V**T: */ |
| 18160 | /* = 'A': all N rows of V**T are returned in the array VT; */ |
| 18161 | /* = 'S': the first min(m,n) rows of V**T (the right singular */ |
| 18162 | /* vectors) are returned in the array VT; */ |
| 18163 | /* = 'O': the first min(m,n) rows of V**T (the right singular */ |
| 18164 | /* vectors) are overwritten on the array A; */ |
| 18165 | /* = 'N': no rows of V**T (no right singular vectors) are */ |
| 18166 | /* computed. */ |
| 18167 | |
| 18168 | /* JOBVT and JOBU cannot both be 'O'. */ |
| 18169 | |
| 18170 | /* M (input) INTEGER */ |
| 18171 | /* The number of rows of the input matrix A. M >= 0. */ |
| 18172 | |
| 18173 | /* N (input) INTEGER */ |
| 18174 | /* The number of columns of the input matrix A. N >= 0. */ |
| 18175 | |
| 18176 | /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 18177 | /* On entry, the M-by-N matrix A. */ |
| 18178 | /* On exit, */ |
| 18179 | /* if JOBU = 'O', A is overwritten with the first min(m,n) */ |
| 18180 | /* columns of U (the left singular vectors, */ |
| 18181 | /* stored columnwise); */ |
| 18182 | /* if JOBVT = 'O', A is overwritten with the first min(m,n) */ |
| 18183 | /* rows of V**T (the right singular vectors, */ |
| 18184 | /* stored rowwise); */ |
| 18185 | /* if JOBU .ne. 'O' and JOBVT .ne. 'O', the contents of A */ |
| 18186 | /* are destroyed. */ |
| 18187 | |
| 18188 | /* LDA (input) INTEGER */ |
| 18189 | /* The leading dimension of the array A. LDA >= max(1,M). */ |
| 18190 | |
| 18191 | /* S (output) DOUBLE PRECISION array, dimension (min(M,N)) */ |
| 18192 | /* The singular values of A, sorted so that S(i) >= S(i+1). */ |
| 18193 | |
| 18194 | /* U (output) DOUBLE PRECISION array, dimension (LDU,UCOL) */ |
| 18195 | /* (LDU,M) if JOBU = 'A' or (LDU,min(M,N)) if JOBU = 'S'. */ |
| 18196 | /* If JOBU = 'A', U contains the M-by-M orthogonal matrix U; */ |
| 18197 | /* if JOBU = 'S', U contains the first min(m,n) columns of U */ |
| 18198 | /* (the left singular vectors, stored columnwise); */ |
| 18199 | /* if JOBU = 'N' or 'O', U is not referenced. */ |
| 18200 | |
| 18201 | /* LDU (input) INTEGER */ |
| 18202 | /* The leading dimension of the array U. LDU >= 1; if */ |
| 18203 | /* JOBU = 'S' or 'A', LDU >= M. */ |
| 18204 | |
| 18205 | /* VT (output) DOUBLE PRECISION array, dimension (LDVT,N) */ |
| 18206 | /* If JOBVT = 'A', VT contains the N-by-N orthogonal matrix */ |
| 18207 | /* V**T; */ |
| 18208 | /* if JOBVT = 'S', VT contains the first min(m,n) rows of */ |
| 18209 | /* V**T (the right singular vectors, stored rowwise); */ |
| 18210 | /* if JOBVT = 'N' or 'O', VT is not referenced. */ |
| 18211 | |
| 18212 | /* LDVT (input) INTEGER */ |
| 18213 | /* The leading dimension of the array VT. LDVT >= 1; if */ |
| 18214 | /* JOBVT = 'A', LDVT >= N; if JOBVT = 'S', LDVT >= min(M,N). */ |
| 18215 | |
| 18216 | /* WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) */ |
| 18217 | /* On exit, if INFO = 0, WORK(1) returns the optimal LWORK; */ |
| 18218 | /* if INFO > 0, WORK(2:MIN(M,N)) contains the unconverged */ |
| 18219 | /* superdiagonal elements of an upper bidiagonal matrix B */ |
| 18220 | /* whose diagonal is in S (not necessarily sorted). B */ |
| 18221 | /* satisfies A = U * B * VT, so it has the same singular values */ |
| 18222 | /* as A, and singular vectors related by U and VT. */ |
| 18223 | |
| 18224 | /* LWORK (input) INTEGER */ |
| 18225 | /* The dimension of the array WORK. */ |
| 18226 | /* LWORK >= MAX(1,3*MIN(M,N)+MAX(M,N),5*MIN(M,N)). */ |
| 18227 | /* For good performance, LWORK should generally be larger. */ |
| 18228 | |
| 18229 | /* If LWORK = -1, then a workspace query is assumed; the routine */ |
| 18230 | /* only calculates the optimal size of the WORK array, returns */ |
| 18231 | /* this value as the first entry of the WORK array, and no error */ |
| 18232 | /* message related to LWORK is issued by XERBLA. */ |
| 18233 | |
| 18234 | /* INFO (output) INTEGER */ |
| 18235 | /* = 0: successful exit. */ |
| 18236 | /* < 0: if INFO = -i, the i-th argument had an illegal value. */ |
| 18237 | /* > 0: if DBDSQR did not converge, INFO specifies how many */ |
| 18238 | /* superdiagonals of an intermediate bidiagonal form B */ |
| 18239 | /* did not converge to zero. See the description of WORK */ |
| 18240 | /* above for details. */ |
| 18241 | |
| 18242 | /* ===================================================================== */ |
| 18243 | |
| 18244 | /* .. Parameters .. */ |
| 18245 | /* .. */ |
| 18246 | /* .. Local Scalars .. */ |
| 18247 | /* .. */ |
| 18248 | /* .. Local Arrays .. */ |
| 18249 | /* .. */ |
| 18250 | /* .. External Subroutines .. */ |
| 18251 | /* .. */ |
| 18252 | /* .. External Functions .. */ |
| 18253 | /* .. */ |
| 18254 | /* .. Intrinsic Functions .. */ |
| 18255 | /* .. */ |
| 18256 | /* .. Executable Statements .. */ |
| 18257 | |
| 18258 | /* Test the input arguments */ |
| 18259 | |
| 18260 | /* Parameter adjustments */ |
| 18261 | a_dim1 = *lda; |
| 18262 | a_offset = 1 + a_dim1; |
| 18263 | a -= a_offset; |
| 18264 | --s; |
| 18265 | u_dim1 = *ldu; |
| 18266 | u_offset = 1 + u_dim1; |
| 18267 | u -= u_offset; |
| 18268 | vt_dim1 = *ldvt; |
| 18269 | vt_offset = 1 + vt_dim1; |
| 18270 | vt -= vt_offset; |
| 18271 | --work; |
| 18272 | |
| 18273 | /* Function Body */ |
| 18274 | *info = 0; |
| 18275 | minmn = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(*m,*n); |
| 18276 | wntua = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobu, "A"); |
| 18277 | wntus = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobu, "S"); |
| 18278 | wntuas = wntua || wntus; |
| 18279 | wntuo = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobu, "O"); |
| 18280 | wntun = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobu, "N"); |
| 18281 | wntva = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobvt, "A"); |
| 18282 | wntvs = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobvt, "S"); |
| 18283 | wntvas = wntva || wntvs; |
| 18284 | wntvo = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobvt, "O"); |
| 18285 | wntvn = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobvt, "N"); |
| 18286 | lquery = *lwork == -1; |
| 18287 | |
| 18288 | if (! (wntua || wntus || wntuo || wntun)) { |
| 18289 | *info = -1; |
| 18290 | } else if (! (wntva || wntvs || wntvo || wntvn) || wntvo && wntuo) { |
| 18291 | *info = -2; |
| 18292 | } else if (*m < 0) { |
| 18293 | *info = -3; |
| 18294 | } else if (*n < 0) { |
| 18295 | *info = -4; |
| 18296 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*m)) { |
| 18297 | *info = -6; |
| 18298 | } else if (*ldu < 1 || wntuas && *ldu < *m) { |
| 18299 | *info = -9; |
| 18300 | } else if (*ldvt < 1 || wntva && *ldvt < *n || wntvs && *ldvt < minmn) { |
| 18301 | *info = -11; |
| 18302 | } |
| 18303 | |
| 18304 | /* Compute workspace */ |
| 18305 | /* (Note: Comments in the code beginning "Workspace:" describe the */ |
| 18306 | /* minimal amount of workspace needed at that point in the code, */ |
| 18307 | /* as well as the preferred amount for good performance. */ |
| 18308 | /* NB refers to the optimal block size for the immediately */ |
| 18309 | /* following subroutine, as returned by ILAENV.) */ |
| 18310 | |
| 18311 | if (*info == 0) { |
| 18312 | minwrk = 1; |
| 18313 | maxwrk = 1; |
| 18314 | if (*m >= *n && minmn > 0) { |
| 18315 | |
| 18316 | /* Compute space needed for DBDSQR */ |
| 18317 | |
| 18318 | /* Writing concatenation */ |
| 18319 | i__1[0] = 1, a__1[0] = const_cast<char *>(jobu); |
| 18320 | i__1[1] = 1, a__1[1] = const_cast<char *>(jobvt); |
| 18321 | s_catcxx . . $ s_cat(b5bdb090c7d6401c).(ch__1, a__1, i__1, &c__2, 2_integercxx . . $ `operator""_integer`(85240eb457c3721a).); |
| 18322 | ch__1 [2] = '\0'; |
| 18323 | mnthr = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__6, "DGESVD", ch__1, m, n, &c__0, &c__0); |
| 18324 | bdspac = *n * 5; |
| 18325 | if (*m >= mnthr) { |
| 18326 | if (wntun) { |
| 18327 | |
| 18328 | /* Path 1 (M much larger than N, JOBU='N') */ |
| 18329 | |
| 18330 | maxwrk = *n + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEQRF", " ", m, n, & |
| 18331 | c_n1, &c_n1); |
| 18332 | /* Computing MAX */ |
| 18333 | i__2 = maxwrk, i__3 = *n * 3 + (*n << 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 18334 | "DGEBRD", " ", n, n, &c_n1, &c_n1); |
| 18335 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18336 | if (wntvo || wntvas) { |
| 18337 | /* Computing MAX */ |
| 18338 | i__2 = maxwrk, i__3 = *n * 3 + (*n - 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(& |
| 18339 | c__1, "DORGBR", "P", n, n, n, &c_n1); |
| 18340 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18341 | } |
| 18342 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(maxwrk,bdspac); |
| 18343 | /* Computing MAX */ |
| 18344 | i__2 = *n << 2; |
| 18345 | minwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,bdspac); |
| 18346 | } else if (wntuo && wntvn) { |
| 18347 | |
| 18348 | /* Path 2 (M much larger than N, JOBU='O', JOBVT='N') */ |
| 18349 | |
| 18350 | wrkbl = *n + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEQRF", " ", m, n, & |
| 18351 | c_n1, &c_n1); |
| 18352 | /* Computing MAX */ |
| 18353 | i__2 = wrkbl, i__3 = *n + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORGQR", |
| 18354 | " ", m, n, n, &c_n1); |
| 18355 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18356 | /* Computing MAX */ |
| 18357 | i__2 = wrkbl, i__3 = *n * 3 + (*n << 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 18358 | "DGEBRD", " ", n, n, &c_n1, &c_n1); |
| 18359 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18360 | /* Computing MAX */ |
| 18361 | i__2 = wrkbl, i__3 = *n * 3 + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORGBR" |
| 18362 | , "Q", n, n, n, &c_n1); |
| 18363 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18364 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(wrkbl,bdspac); |
| 18365 | /* Computing MAX */ |
| 18366 | i__2 = *n * *n + wrkbl, i__3 = *n * *n + *m * *n + *n; |
| 18367 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18368 | /* Computing MAX */ |
| 18369 | i__2 = *n * 3 + *m; |
| 18370 | minwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,bdspac); |
| 18371 | } else if (wntuo && wntvas) { |
| 18372 | |
| 18373 | /* Path 3 (M much larger than N, JOBU='O', JOBVT='S' or */ |
| 18374 | /* 'A') */ |
| 18375 | |
| 18376 | wrkbl = *n + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEQRF", " ", m, n, & |
| 18377 | c_n1, &c_n1); |
| 18378 | /* Computing MAX */ |
| 18379 | i__2 = wrkbl, i__3 = *n + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORGQR", |
| 18380 | " ", m, n, n, &c_n1); |
| 18381 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18382 | /* Computing MAX */ |
| 18383 | i__2 = wrkbl, i__3 = *n * 3 + (*n << 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 18384 | "DGEBRD", " ", n, n, &c_n1, &c_n1); |
| 18385 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18386 | /* Computing MAX */ |
| 18387 | i__2 = wrkbl, i__3 = *n * 3 + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORGBR" |
| 18388 | , "Q", n, n, n, &c_n1); |
| 18389 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18390 | /* Computing MAX */ |
| 18391 | i__2 = wrkbl, i__3 = *n * 3 + (*n - 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 18392 | "DORGBR", "P", n, n, n, &c_n1); |
| 18393 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18394 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(wrkbl,bdspac); |
| 18395 | /* Computing MAX */ |
| 18396 | i__2 = *n * *n + wrkbl, i__3 = *n * *n + *m * *n + *n; |
| 18397 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18398 | /* Computing MAX */ |
| 18399 | i__2 = *n * 3 + *m; |
| 18400 | minwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,bdspac); |
| 18401 | } else if (wntus && wntvn) { |
| 18402 | |
| 18403 | /* Path 4 (M much larger than N, JOBU='S', JOBVT='N') */ |
| 18404 | |
| 18405 | wrkbl = *n + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEQRF", " ", m, n, & |
| 18406 | c_n1, &c_n1); |
| 18407 | /* Computing MAX */ |
| 18408 | i__2 = wrkbl, i__3 = *n + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORGQR", |
| 18409 | " ", m, n, n, &c_n1); |
| 18410 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18411 | /* Computing MAX */ |
| 18412 | i__2 = wrkbl, i__3 = *n * 3 + (*n << 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 18413 | "DGEBRD", " ", n, n, &c_n1, &c_n1); |
| 18414 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18415 | /* Computing MAX */ |
| 18416 | i__2 = wrkbl, i__3 = *n * 3 + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORGBR" |
| 18417 | , "Q", n, n, n, &c_n1); |
| 18418 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18419 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(wrkbl,bdspac); |
| 18420 | maxwrk = *n * *n + wrkbl; |
| 18421 | /* Computing MAX */ |
| 18422 | i__2 = *n * 3 + *m; |
| 18423 | minwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,bdspac); |
| 18424 | } else if (wntus && wntvo) { |
| 18425 | |
| 18426 | /* Path 5 (M much larger than N, JOBU='S', JOBVT='O') */ |
| 18427 | |
| 18428 | wrkbl = *n + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEQRF", " ", m, n, & |
| 18429 | c_n1, &c_n1); |
| 18430 | /* Computing MAX */ |
| 18431 | i__2 = wrkbl, i__3 = *n + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORGQR", |
| 18432 | " ", m, n, n, &c_n1); |
| 18433 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18434 | /* Computing MAX */ |
| 18435 | i__2 = wrkbl, i__3 = *n * 3 + (*n << 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 18436 | "DGEBRD", " ", n, n, &c_n1, &c_n1); |
| 18437 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18438 | /* Computing MAX */ |
| 18439 | i__2 = wrkbl, i__3 = *n * 3 + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORGBR" |
| 18440 | , "Q", n, n, n, &c_n1); |
| 18441 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18442 | /* Computing MAX */ |
| 18443 | i__2 = wrkbl, i__3 = *n * 3 + (*n - 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 18444 | "DORGBR", "P", n, n, n, &c_n1); |
| 18445 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18446 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(wrkbl,bdspac); |
| 18447 | maxwrk = (*n << 1) * *n + wrkbl; |
| 18448 | /* Computing MAX */ |
| 18449 | i__2 = *n * 3 + *m; |
| 18450 | minwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,bdspac); |
| 18451 | } else if (wntus && wntvas) { |
| 18452 | |
| 18453 | /* Path 6 (M much larger than N, JOBU='S', JOBVT='S' or */ |
| 18454 | /* 'A') */ |
| 18455 | |
| 18456 | wrkbl = *n + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEQRF", " ", m, n, & |
| 18457 | c_n1, &c_n1); |
| 18458 | /* Computing MAX */ |
| 18459 | i__2 = wrkbl, i__3 = *n + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORGQR", |
| 18460 | " ", m, n, n, &c_n1); |
| 18461 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18462 | /* Computing MAX */ |
| 18463 | i__2 = wrkbl, i__3 = *n * 3 + (*n << 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 18464 | "DGEBRD", " ", n, n, &c_n1, &c_n1); |
| 18465 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18466 | /* Computing MAX */ |
| 18467 | i__2 = wrkbl, i__3 = *n * 3 + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORGBR" |
| 18468 | , "Q", n, n, n, &c_n1); |
| 18469 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18470 | /* Computing MAX */ |
| 18471 | i__2 = wrkbl, i__3 = *n * 3 + (*n - 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 18472 | "DORGBR", "P", n, n, n, &c_n1); |
| 18473 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18474 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(wrkbl,bdspac); |
| 18475 | maxwrk = *n * *n + wrkbl; |
| 18476 | /* Computing MAX */ |
| 18477 | i__2 = *n * 3 + *m; |
| 18478 | minwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,bdspac); |
| 18479 | } else if (wntua && wntvn) { |
| 18480 | |
| 18481 | /* Path 7 (M much larger than N, JOBU='A', JOBVT='N') */ |
| 18482 | |
| 18483 | wrkbl = *n + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEQRF", " ", m, n, & |
| 18484 | c_n1, &c_n1); |
| 18485 | /* Computing MAX */ |
| 18486 | i__2 = wrkbl, i__3 = *n + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORGQR", |
| 18487 | " ", m, m, n, &c_n1); |
| 18488 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18489 | /* Computing MAX */ |
| 18490 | i__2 = wrkbl, i__3 = *n * 3 + (*n << 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 18491 | "DGEBRD", " ", n, n, &c_n1, &c_n1); |
| 18492 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18493 | /* Computing MAX */ |
| 18494 | i__2 = wrkbl, i__3 = *n * 3 + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORGBR" |
| 18495 | , "Q", n, n, n, &c_n1); |
| 18496 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18497 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(wrkbl,bdspac); |
| 18498 | maxwrk = *n * *n + wrkbl; |
| 18499 | /* Computing MAX */ |
| 18500 | i__2 = *n * 3 + *m; |
| 18501 | minwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,bdspac); |
| 18502 | } else if (wntua && wntvo) { |
| 18503 | |
| 18504 | /* Path 8 (M much larger than N, JOBU='A', JOBVT='O') */ |
| 18505 | |
| 18506 | wrkbl = *n + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEQRF", " ", m, n, & |
| 18507 | c_n1, &c_n1); |
| 18508 | /* Computing MAX */ |
| 18509 | i__2 = wrkbl, i__3 = *n + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORGQR", |
| 18510 | " ", m, m, n, &c_n1); |
| 18511 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18512 | /* Computing MAX */ |
| 18513 | i__2 = wrkbl, i__3 = *n * 3 + (*n << 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 18514 | "DGEBRD", " ", n, n, &c_n1, &c_n1); |
| 18515 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18516 | /* Computing MAX */ |
| 18517 | i__2 = wrkbl, i__3 = *n * 3 + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORGBR" |
| 18518 | , "Q", n, n, n, &c_n1); |
| 18519 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18520 | /* Computing MAX */ |
| 18521 | i__2 = wrkbl, i__3 = *n * 3 + (*n - 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 18522 | "DORGBR", "P", n, n, n, &c_n1); |
| 18523 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18524 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(wrkbl,bdspac); |
| 18525 | maxwrk = (*n << 1) * *n + wrkbl; |
| 18526 | /* Computing MAX */ |
| 18527 | i__2 = *n * 3 + *m; |
| 18528 | minwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,bdspac); |
| 18529 | } else if (wntua && wntvas) { |
| 18530 | |
| 18531 | /* Path 9 (M much larger than N, JOBU='A', JOBVT='S' or */ |
| 18532 | /* 'A') */ |
| 18533 | |
| 18534 | wrkbl = *n + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEQRF", " ", m, n, & |
| 18535 | c_n1, &c_n1); |
| 18536 | /* Computing MAX */ |
| 18537 | i__2 = wrkbl, i__3 = *n + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORGQR", |
| 18538 | " ", m, m, n, &c_n1); |
| 18539 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18540 | /* Computing MAX */ |
| 18541 | i__2 = wrkbl, i__3 = *n * 3 + (*n << 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 18542 | "DGEBRD", " ", n, n, &c_n1, &c_n1); |
| 18543 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18544 | /* Computing MAX */ |
| 18545 | i__2 = wrkbl, i__3 = *n * 3 + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORGBR" |
| 18546 | , "Q", n, n, n, &c_n1); |
| 18547 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18548 | /* Computing MAX */ |
| 18549 | i__2 = wrkbl, i__3 = *n * 3 + (*n - 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 18550 | "DORGBR", "P", n, n, n, &c_n1); |
| 18551 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18552 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(wrkbl,bdspac); |
| 18553 | maxwrk = *n * *n + wrkbl; |
| 18554 | /* Computing MAX */ |
| 18555 | i__2 = *n * 3 + *m; |
| 18556 | minwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,bdspac); |
| 18557 | } |
| 18558 | } else { |
| 18559 | |
| 18560 | /* Path 10 (M at least N, but not much larger) */ |
| 18561 | |
| 18562 | maxwrk = *n * 3 + (*m + *n) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEBRD", " ", m, |
| 18563 | n, &c_n1, &c_n1); |
| 18564 | if (wntus || wntuo) { |
| 18565 | /* Computing MAX */ |
| 18566 | i__2 = maxwrk, i__3 = *n * 3 + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORG" |
| 18567 | "BR", "Q", m, n, n, &c_n1); |
| 18568 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18569 | } |
| 18570 | if (wntua) { |
| 18571 | /* Computing MAX */ |
| 18572 | i__2 = maxwrk, i__3 = *n * 3 + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORG" |
| 18573 | "BR", "Q", m, m, n, &c_n1); |
| 18574 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18575 | } |
| 18576 | if (! wntvn) { |
| 18577 | /* Computing MAX */ |
| 18578 | i__2 = maxwrk, i__3 = *n * 3 + (*n - 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 18579 | "DORGBR", "P", n, n, n, &c_n1); |
| 18580 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18581 | } |
| 18582 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(maxwrk,bdspac); |
| 18583 | /* Computing MAX */ |
| 18584 | i__2 = *n * 3 + *m; |
| 18585 | minwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,bdspac); |
| 18586 | } |
| 18587 | } else if (minmn > 0) { |
| 18588 | |
| 18589 | /* Compute space needed for DBDSQR */ |
| 18590 | |
| 18591 | /* Writing concatenation */ |
| 18592 | i__1[0] = 1, a__1[0] = const_cast<char *>(jobu); |
| 18593 | i__1[1] = 1, a__1[1] = const_cast<char *>(jobvt); |
| 18594 | s_catcxx . . $ s_cat(b5bdb090c7d6401c).(ch__1, a__1, i__1, &c__2, 2_integercxx . . $ `operator""_integer`(85240eb457c3721a).); |
| 18595 | ch__1 [2] = '\0'; |
| 18596 | mnthr = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__6, "DGESVD", ch__1, m, n, &c__0, &c__0); |
| 18597 | bdspac = *m * 5; |
| 18598 | if (*n >= mnthr) { |
| 18599 | if (wntvn) { |
| 18600 | |
| 18601 | /* Path 1t(N much larger than M, JOBVT='N') */ |
| 18602 | |
| 18603 | maxwrk = *m + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGELQF", " ", m, n, & |
| 18604 | c_n1, &c_n1); |
| 18605 | /* Computing MAX */ |
| 18606 | i__2 = maxwrk, i__3 = *m * 3 + (*m << 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 18607 | "DGEBRD", " ", m, m, &c_n1, &c_n1); |
| 18608 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18609 | if (wntuo || wntuas) { |
| 18610 | /* Computing MAX */ |
| 18611 | i__2 = maxwrk, i__3 = *m * 3 + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 18612 | "DORGBR", "Q", m, m, m, &c_n1); |
| 18613 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18614 | } |
| 18615 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(maxwrk,bdspac); |
| 18616 | /* Computing MAX */ |
| 18617 | i__2 = *m << 2; |
| 18618 | minwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,bdspac); |
| 18619 | } else if (wntvo && wntun) { |
| 18620 | |
| 18621 | /* Path 2t(N much larger than M, JOBU='N', JOBVT='O') */ |
| 18622 | |
| 18623 | wrkbl = *m + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGELQF", " ", m, n, & |
| 18624 | c_n1, &c_n1); |
| 18625 | /* Computing MAX */ |
| 18626 | i__2 = wrkbl, i__3 = *m + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORGLQ", |
| 18627 | " ", m, n, m, &c_n1); |
| 18628 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18629 | /* Computing MAX */ |
| 18630 | i__2 = wrkbl, i__3 = *m * 3 + (*m << 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 18631 | "DGEBRD", " ", m, m, &c_n1, &c_n1); |
| 18632 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18633 | /* Computing MAX */ |
| 18634 | i__2 = wrkbl, i__3 = *m * 3 + (*m - 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 18635 | "DORGBR", "P", m, m, m, &c_n1); |
| 18636 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18637 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(wrkbl,bdspac); |
| 18638 | /* Computing MAX */ |
| 18639 | i__2 = *m * *m + wrkbl, i__3 = *m * *m + *m * *n + *m; |
| 18640 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18641 | /* Computing MAX */ |
| 18642 | i__2 = *m * 3 + *n; |
| 18643 | minwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,bdspac); |
| 18644 | } else if (wntvo && wntuas) { |
| 18645 | |
| 18646 | /* Path 3t(N much larger than M, JOBU='S' or 'A', */ |
| 18647 | /* JOBVT='O') */ |
| 18648 | |
| 18649 | wrkbl = *m + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGELQF", " ", m, n, & |
| 18650 | c_n1, &c_n1); |
| 18651 | /* Computing MAX */ |
| 18652 | i__2 = wrkbl, i__3 = *m + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORGLQ", |
| 18653 | " ", m, n, m, &c_n1); |
| 18654 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18655 | /* Computing MAX */ |
| 18656 | i__2 = wrkbl, i__3 = *m * 3 + (*m << 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 18657 | "DGEBRD", " ", m, m, &c_n1, &c_n1); |
| 18658 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18659 | /* Computing MAX */ |
| 18660 | i__2 = wrkbl, i__3 = *m * 3 + (*m - 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 18661 | "DORGBR", "P", m, m, m, &c_n1); |
| 18662 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18663 | /* Computing MAX */ |
| 18664 | i__2 = wrkbl, i__3 = *m * 3 + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORGBR" |
| 18665 | , "Q", m, m, m, &c_n1); |
| 18666 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18667 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(wrkbl,bdspac); |
| 18668 | /* Computing MAX */ |
| 18669 | i__2 = *m * *m + wrkbl, i__3 = *m * *m + *m * *n + *m; |
| 18670 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18671 | /* Computing MAX */ |
| 18672 | i__2 = *m * 3 + *n; |
| 18673 | minwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,bdspac); |
| 18674 | } else if (wntvs && wntun) { |
| 18675 | |
| 18676 | /* Path 4t(N much larger than M, JOBU='N', JOBVT='S') */ |
| 18677 | |
| 18678 | wrkbl = *m + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGELQF", " ", m, n, & |
| 18679 | c_n1, &c_n1); |
| 18680 | /* Computing MAX */ |
| 18681 | i__2 = wrkbl, i__3 = *m + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORGLQ", |
| 18682 | " ", m, n, m, &c_n1); |
| 18683 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18684 | /* Computing MAX */ |
| 18685 | i__2 = wrkbl, i__3 = *m * 3 + (*m << 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 18686 | "DGEBRD", " ", m, m, &c_n1, &c_n1); |
| 18687 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18688 | /* Computing MAX */ |
| 18689 | i__2 = wrkbl, i__3 = *m * 3 + (*m - 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 18690 | "DORGBR", "P", m, m, m, &c_n1); |
| 18691 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18692 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(wrkbl,bdspac); |
| 18693 | maxwrk = *m * *m + wrkbl; |
| 18694 | /* Computing MAX */ |
| 18695 | i__2 = *m * 3 + *n; |
| 18696 | minwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,bdspac); |
| 18697 | } else if (wntvs && wntuo) { |
| 18698 | |
| 18699 | /* Path 5t(N much larger than M, JOBU='O', JOBVT='S') */ |
| 18700 | |
| 18701 | wrkbl = *m + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGELQF", " ", m, n, & |
| 18702 | c_n1, &c_n1); |
| 18703 | /* Computing MAX */ |
| 18704 | i__2 = wrkbl, i__3 = *m + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORGLQ", |
| 18705 | " ", m, n, m, &c_n1); |
| 18706 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18707 | /* Computing MAX */ |
| 18708 | i__2 = wrkbl, i__3 = *m * 3 + (*m << 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 18709 | "DGEBRD", " ", m, m, &c_n1, &c_n1); |
| 18710 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18711 | /* Computing MAX */ |
| 18712 | i__2 = wrkbl, i__3 = *m * 3 + (*m - 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 18713 | "DORGBR", "P", m, m, m, &c_n1); |
| 18714 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18715 | /* Computing MAX */ |
| 18716 | i__2 = wrkbl, i__3 = *m * 3 + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORGBR" |
| 18717 | , "Q", m, m, m, &c_n1); |
| 18718 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18719 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(wrkbl,bdspac); |
| 18720 | maxwrk = (*m << 1) * *m + wrkbl; |
| 18721 | /* Computing MAX */ |
| 18722 | i__2 = *m * 3 + *n; |
| 18723 | minwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,bdspac); |
| 18724 | } else if (wntvs && wntuas) { |
| 18725 | |
| 18726 | /* Path 6t(N much larger than M, JOBU='S' or 'A', */ |
| 18727 | /* JOBVT='S') */ |
| 18728 | |
| 18729 | wrkbl = *m + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGELQF", " ", m, n, & |
| 18730 | c_n1, &c_n1); |
| 18731 | /* Computing MAX */ |
| 18732 | i__2 = wrkbl, i__3 = *m + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORGLQ", |
| 18733 | " ", m, n, m, &c_n1); |
| 18734 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18735 | /* Computing MAX */ |
| 18736 | i__2 = wrkbl, i__3 = *m * 3 + (*m << 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 18737 | "DGEBRD", " ", m, m, &c_n1, &c_n1); |
| 18738 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18739 | /* Computing MAX */ |
| 18740 | i__2 = wrkbl, i__3 = *m * 3 + (*m - 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 18741 | "DORGBR", "P", m, m, m, &c_n1); |
| 18742 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18743 | /* Computing MAX */ |
| 18744 | i__2 = wrkbl, i__3 = *m * 3 + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORGBR" |
| 18745 | , "Q", m, m, m, &c_n1); |
| 18746 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18747 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(wrkbl,bdspac); |
| 18748 | maxwrk = *m * *m + wrkbl; |
| 18749 | /* Computing MAX */ |
| 18750 | i__2 = *m * 3 + *n; |
| 18751 | minwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,bdspac); |
| 18752 | } else if (wntva && wntun) { |
| 18753 | |
| 18754 | /* Path 7t(N much larger than M, JOBU='N', JOBVT='A') */ |
| 18755 | |
| 18756 | wrkbl = *m + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGELQF", " ", m, n, & |
| 18757 | c_n1, &c_n1); |
| 18758 | /* Computing MAX */ |
| 18759 | i__2 = wrkbl, i__3 = *m + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORGLQ", |
| 18760 | " ", n, n, m, &c_n1); |
| 18761 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18762 | /* Computing MAX */ |
| 18763 | i__2 = wrkbl, i__3 = *m * 3 + (*m << 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 18764 | "DGEBRD", " ", m, m, &c_n1, &c_n1); |
| 18765 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18766 | /* Computing MAX */ |
| 18767 | i__2 = wrkbl, i__3 = *m * 3 + (*m - 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 18768 | "DORGBR", "P", m, m, m, &c_n1); |
| 18769 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18770 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(wrkbl,bdspac); |
| 18771 | maxwrk = *m * *m + wrkbl; |
| 18772 | /* Computing MAX */ |
| 18773 | i__2 = *m * 3 + *n; |
| 18774 | minwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,bdspac); |
| 18775 | } else if (wntva && wntuo) { |
| 18776 | |
| 18777 | /* Path 8t(N much larger than M, JOBU='O', JOBVT='A') */ |
| 18778 | |
| 18779 | wrkbl = *m + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGELQF", " ", m, n, & |
| 18780 | c_n1, &c_n1); |
| 18781 | /* Computing MAX */ |
| 18782 | i__2 = wrkbl, i__3 = *m + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORGLQ", |
| 18783 | " ", n, n, m, &c_n1); |
| 18784 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18785 | /* Computing MAX */ |
| 18786 | i__2 = wrkbl, i__3 = *m * 3 + (*m << 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 18787 | "DGEBRD", " ", m, m, &c_n1, &c_n1); |
| 18788 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18789 | /* Computing MAX */ |
| 18790 | i__2 = wrkbl, i__3 = *m * 3 + (*m - 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 18791 | "DORGBR", "P", m, m, m, &c_n1); |
| 18792 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18793 | /* Computing MAX */ |
| 18794 | i__2 = wrkbl, i__3 = *m * 3 + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORGBR" |
| 18795 | , "Q", m, m, m, &c_n1); |
| 18796 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18797 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(wrkbl,bdspac); |
| 18798 | maxwrk = (*m << 1) * *m + wrkbl; |
| 18799 | /* Computing MAX */ |
| 18800 | i__2 = *m * 3 + *n; |
| 18801 | minwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,bdspac); |
| 18802 | } else if (wntva && wntuas) { |
| 18803 | |
| 18804 | /* Path 9t(N much larger than M, JOBU='S' or 'A', */ |
| 18805 | /* JOBVT='A') */ |
| 18806 | |
| 18807 | wrkbl = *m + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGELQF", " ", m, n, & |
| 18808 | c_n1, &c_n1); |
| 18809 | /* Computing MAX */ |
| 18810 | i__2 = wrkbl, i__3 = *m + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORGLQ", |
| 18811 | " ", n, n, m, &c_n1); |
| 18812 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18813 | /* Computing MAX */ |
| 18814 | i__2 = wrkbl, i__3 = *m * 3 + (*m << 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 18815 | "DGEBRD", " ", m, m, &c_n1, &c_n1); |
| 18816 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18817 | /* Computing MAX */ |
| 18818 | i__2 = wrkbl, i__3 = *m * 3 + (*m - 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 18819 | "DORGBR", "P", m, m, m, &c_n1); |
| 18820 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18821 | /* Computing MAX */ |
| 18822 | i__2 = wrkbl, i__3 = *m * 3 + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORGBR" |
| 18823 | , "Q", m, m, m, &c_n1); |
| 18824 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18825 | wrkbl = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(wrkbl,bdspac); |
| 18826 | maxwrk = *m * *m + wrkbl; |
| 18827 | /* Computing MAX */ |
| 18828 | i__2 = *m * 3 + *n; |
| 18829 | minwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,bdspac); |
| 18830 | } |
| 18831 | } else { |
| 18832 | |
| 18833 | /* Path 10t(N greater than M, but not much larger) */ |
| 18834 | |
| 18835 | maxwrk = *m * 3 + (*m + *n) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEBRD", " ", m, |
| 18836 | n, &c_n1, &c_n1); |
| 18837 | if (wntvs || wntvo) { |
| 18838 | /* Computing MAX */ |
| 18839 | i__2 = maxwrk, i__3 = *m * 3 + *m * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORG" |
| 18840 | "BR", "P", m, n, m, &c_n1); |
| 18841 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18842 | } |
| 18843 | if (wntva) { |
| 18844 | /* Computing MAX */ |
| 18845 | i__2 = maxwrk, i__3 = *m * 3 + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORG" |
| 18846 | "BR", "P", n, n, m, &c_n1); |
| 18847 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18848 | } |
| 18849 | if (! wntun) { |
| 18850 | /* Computing MAX */ |
| 18851 | i__2 = maxwrk, i__3 = *m * 3 + (*m - 1) * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, |
| 18852 | "DORGBR", "Q", m, m, m, &c_n1); |
| 18853 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 18854 | } |
| 18855 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(maxwrk,bdspac); |
| 18856 | /* Computing MAX */ |
| 18857 | i__2 = *m * 3 + *n; |
| 18858 | minwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,bdspac); |
| 18859 | } |
| 18860 | } |
| 18861 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(maxwrk,minwrk); |
| 18862 | work[1] = (double) maxwrk; |
| 18863 | |
| 18864 | if (*lwork < minwrk && ! lquery) { |
| 18865 | *info = -13; |
| 18866 | } |
| 18867 | } |
| 18868 | |
| 18869 | if (*info != 0) { |
| 18870 | i__2 = -(*info); |
| 18871 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGESVD", &i__2); |
| 18872 | return 0; |
| 18873 | } else if (lquery) { |
| 18874 | return 0; |
| 18875 | } |
| 18876 | |
| 18877 | /* Quick return if possible */ |
| 18878 | |
| 18879 | if (*m == 0 || *n == 0) { |
| 18880 | return 0; |
| 18881 | } |
| 18882 | |
| 18883 | /* Get machine constants */ |
| 18884 | |
| 18885 | eps = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("P"); |
| 18886 | smlnum = sqrtcxx . . $ sqrt(fee4f1d22bc8e617).(dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("S")) / eps; |
| 18887 | bignum = 1. / smlnum; |
| 18888 | |
| 18889 | /* Scale A if max element outside range [SMLNUM,BIGNUM] */ |
| 18890 | |
| 18891 | anrm = dlange_cxx . . $ dlange_(98d44e6417336f20).("M", m, n, &a[a_offset], lda, dum); |
| 18892 | iscl = 0; |
| 18893 | if (anrm > 0. && anrm < smlnum) { |
| 18894 | iscl = 1; |
| 18895 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &anrm, &smlnum, m, n, &a[a_offset], lda, & |
| 18896 | ierr); |
| 18897 | } else if (anrm > bignum) { |
| 18898 | iscl = 1; |
| 18899 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &anrm, &bignum, m, n, &a[a_offset], lda, & |
| 18900 | ierr); |
| 18901 | } |
| 18902 | |
| 18903 | if (*m >= *n) { |
| 18904 | |
| 18905 | /* A has at least as many rows as columns. If A has sufficiently */ |
| 18906 | /* more rows than columns, first reduce using the QR */ |
| 18907 | /* decomposition (if sufficient workspace available) */ |
| 18908 | |
| 18909 | if (*m >= mnthr) { |
| 18910 | |
| 18911 | if (wntun) { |
| 18912 | |
| 18913 | /* Path 1 (M much larger than N, JOBU='N') */ |
| 18914 | /* No left singular vectors to be computed */ |
| 18915 | |
| 18916 | itau = 1; |
| 18917 | iwork = itau + *n; |
| 18918 | |
| 18919 | /* Compute A=Q*R */ |
| 18920 | /* (Workspace: need 2*N, prefer N+N*NB) */ |
| 18921 | |
| 18922 | i__2 = *lwork - iwork + 1; |
| 18923 | dgeqrf_cxx . . $ dgeqrf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[itau], &work[iwork], & |
| 18924 | i__2, &ierr); |
| 18925 | |
| 18926 | /* Zero out below R */ |
| 18927 | |
| 18928 | i__2 = *n - 1; |
| 18929 | i__3 = *n - 1; |
| 18930 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("L", &i__2, &i__3, &c_b421, &c_b421, &a[a_dim1 + 2], |
| 18931 | lda); |
| 18932 | ie = 1; |
| 18933 | itauq = ie + *n; |
| 18934 | itaup = itauq + *n; |
| 18935 | iwork = itaup + *n; |
| 18936 | |
| 18937 | /* Bidiagonalize R in A */ |
| 18938 | /* (Workspace: need 4*N, prefer 3*N+2*N*NB) */ |
| 18939 | |
| 18940 | i__2 = *lwork - iwork + 1; |
| 18941 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(n, n, &a[a_offset], lda, &s[1], &work[ie], &work[ |
| 18942 | itauq], &work[itaup], &work[iwork], &i__2, &ierr); |
| 18943 | ncvt = 0; |
| 18944 | if (wntvo || wntvas) { |
| 18945 | |
| 18946 | /* If right singular vectors desired, generate P'. */ |
| 18947 | /* (Workspace: need 4*N-1, prefer 3*N+(N-1)*NB) */ |
| 18948 | |
| 18949 | i__2 = *lwork - iwork + 1; |
| 18950 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("P", n, n, n, &a[a_offset], lda, &work[itaup], & |
| 18951 | work[iwork], &i__2, &ierr); |
| 18952 | ncvt = *n; |
| 18953 | } |
| 18954 | iwork = ie + *n; |
| 18955 | |
| 18956 | /* Perform bidiagonal QR iteration, computing right */ |
| 18957 | /* singular vectors of A in A if desired */ |
| 18958 | /* (Workspace: need BDSPAC) */ |
| 18959 | |
| 18960 | dbdsqr_cxx . . $ dbdsqr_(d6d10c27a7b3c412).("U", n, &ncvt, &c__0, &c__0, &s[1], &work[ie], &a[ |
| 18961 | a_offset], lda, dum, &c__1, dum, &c__1, &work[iwork], |
| 18962 | info); |
| 18963 | |
| 18964 | /* If right singular vectors desired in VT, copy them there */ |
| 18965 | |
| 18966 | if (wntvas) { |
| 18967 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("F", n, n, &a[a_offset], lda, &vt[vt_offset], |
| 18968 | ldvt); |
| 18969 | } |
| 18970 | |
| 18971 | } else if (wntuo && wntvn) { |
| 18972 | |
| 18973 | /* Path 2 (M much larger than N, JOBU='O', JOBVT='N') */ |
| 18974 | /* N left singular vectors to be overwritten on A and */ |
| 18975 | /* no right singular vectors to be computed */ |
| 18976 | |
| 18977 | /* Computing MAX */ |
| 18978 | i__2 = *n << 2; |
| 18979 | if (*lwork >= *n * *n + stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,bdspac)) { |
| 18980 | |
| 18981 | /* Sufficient workspace for a fast algorithm */ |
| 18982 | |
| 18983 | ir = 1; |
| 18984 | /* Computing MAX */ |
| 18985 | i__2 = wrkbl, i__3 = *lda * *n + *n; |
| 18986 | if (*lwork >= stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3) + *lda * *n) { |
| 18987 | |
| 18988 | /* WORK(IU) is LDA by N, WORK(IR) is LDA by N */ |
| 18989 | |
| 18990 | ldwrku = *lda; |
| 18991 | ldwrkr = *lda; |
| 18992 | } else /* if(complicated condition) */ { |
| 18993 | /* Computing MAX */ |
| 18994 | i__2 = wrkbl, i__3 = *lda * *n + *n; |
| 18995 | if (*lwork >= stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3) + *n * *n) { |
| 18996 | |
| 18997 | /* WORK(IU) is LDA by N, WORK(IR) is N by N */ |
| 18998 | |
| 18999 | ldwrku = *lda; |
| 19000 | ldwrkr = *n; |
| 19001 | } else { |
| 19002 | |
| 19003 | /* WORK(IU) is LDWRKU by N, WORK(IR) is N by N */ |
| 19004 | |
| 19005 | ldwrku = (*lwork - *n * *n - *n) / *n; |
| 19006 | ldwrkr = *n; |
| 19007 | } |
| 19008 | } |
| 19009 | itau = ir + ldwrkr * *n; |
| 19010 | iwork = itau + *n; |
| 19011 | |
| 19012 | /* Compute A=Q*R */ |
| 19013 | /* (Workspace: need N*N+2*N, prefer N*N+N+N*NB) */ |
| 19014 | |
| 19015 | i__2 = *lwork - iwork + 1; |
| 19016 | dgeqrf_cxx . . $ dgeqrf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[itau], &work[iwork] |
| 19017 | , &i__2, &ierr); |
| 19018 | |
| 19019 | /* Copy R to WORK(IR) and zero out below it */ |
| 19020 | |
| 19021 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("U", n, n, &a[a_offset], lda, &work[ir], &ldwrkr); |
| 19022 | i__2 = *n - 1; |
| 19023 | i__3 = *n - 1; |
| 19024 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("L", &i__2, &i__3, &c_b421, &c_b421, &work[ir + 1] |
| 19025 | , &ldwrkr); |
| 19026 | |
| 19027 | /* Generate Q in A */ |
| 19028 | /* (Workspace: need N*N+2*N, prefer N*N+N+N*NB) */ |
| 19029 | |
| 19030 | i__2 = *lwork - iwork + 1; |
| 19031 | dorgqr_cxx . . $ dorgqr_(424524679a238630).(m, n, n, &a[a_offset], lda, &work[itau], &work[ |
| 19032 | iwork], &i__2, &ierr); |
| 19033 | ie = itau; |
| 19034 | itauq = ie + *n; |
| 19035 | itaup = itauq + *n; |
| 19036 | iwork = itaup + *n; |
| 19037 | |
| 19038 | /* Bidiagonalize R in WORK(IR) */ |
| 19039 | /* (Workspace: need N*N+4*N, prefer N*N+3*N+2*N*NB) */ |
| 19040 | |
| 19041 | i__2 = *lwork - iwork + 1; |
| 19042 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(n, n, &work[ir], &ldwrkr, &s[1], &work[ie], &work[ |
| 19043 | itauq], &work[itaup], &work[iwork], &i__2, &ierr); |
| 19044 | |
| 19045 | /* Generate left vectors bidiagonalizing R */ |
| 19046 | /* (Workspace: need N*N+4*N, prefer N*N+3*N+N*NB) */ |
| 19047 | |
| 19048 | i__2 = *lwork - iwork + 1; |
| 19049 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("Q", n, n, n, &work[ir], &ldwrkr, &work[itauq], & |
| 19050 | work[iwork], &i__2, &ierr); |
| 19051 | iwork = ie + *n; |
| 19052 | |
| 19053 | /* Perform bidiagonal QR iteration, computing left */ |
| 19054 | /* singular vectors of R in WORK(IR) */ |
| 19055 | /* (Workspace: need N*N+BDSPAC) */ |
| 19056 | |
| 19057 | dbdsqr_cxx . . $ dbdsqr_(d6d10c27a7b3c412).("U", n, &c__0, n, &c__0, &s[1], &work[ie], dum, & |
| 19058 | c__1, &work[ir], &ldwrkr, dum, &c__1, &work[iwork] |
| 19059 | , info); |
| 19060 | iu = ie + *n; |
| 19061 | |
| 19062 | /* Multiply Q in A by left singular vectors of R in */ |
| 19063 | /* WORK(IR), storing result in WORK(IU) and copying to A */ |
| 19064 | /* (Workspace: need N*N+2*N, prefer N*N+M*N+N) */ |
| 19065 | |
| 19066 | i__2 = *m; |
| 19067 | i__3 = ldwrku; |
| 19068 | for (i__ = 1; i__3 < 0 ? i__ >= i__2 : i__ <= i__2; i__ += |
| 19069 | i__3) { |
| 19070 | /* Computing MIN */ |
| 19071 | i__4 = *m - i__ + 1; |
| 19072 | chunk = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__4,ldwrku); |
| 19073 | dgemm_cxx . . $ dgemm_(7f9a15c7502022ea).("N", "N", &chunk, n, n, &c_b443, &a[i__ + |
| 19074 | a_dim1], lda, &work[ir], &ldwrkr, &c_b421, & |
| 19075 | work[iu], &ldwrku); |
| 19076 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("F", &chunk, n, &work[iu], &ldwrku, &a[i__ + |
| 19077 | a_dim1], lda); |
| 19078 | /* L10: */ |
| 19079 | } |
| 19080 | |
| 19081 | } else { |
| 19082 | |
| 19083 | /* Insufficient workspace for a fast algorithm */ |
| 19084 | |
| 19085 | ie = 1; |
| 19086 | itauq = ie + *n; |
| 19087 | itaup = itauq + *n; |
| 19088 | iwork = itaup + *n; |
| 19089 | |
| 19090 | /* Bidiagonalize A */ |
| 19091 | /* (Workspace: need 3*N+M, prefer 3*N+(M+N)*NB) */ |
| 19092 | |
| 19093 | i__3 = *lwork - iwork + 1; |
| 19094 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(m, n, &a[a_offset], lda, &s[1], &work[ie], &work[ |
| 19095 | itauq], &work[itaup], &work[iwork], &i__3, &ierr); |
| 19096 | |
| 19097 | /* Generate left vectors bidiagonalizing A */ |
| 19098 | /* (Workspace: need 4*N, prefer 3*N+N*NB) */ |
| 19099 | |
| 19100 | i__3 = *lwork - iwork + 1; |
| 19101 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("Q", m, n, n, &a[a_offset], lda, &work[itauq], & |
| 19102 | work[iwork], &i__3, &ierr); |
| 19103 | iwork = ie + *n; |
| 19104 | |
| 19105 | /* Perform bidiagonal QR iteration, computing left */ |
| 19106 | /* singular vectors of A in A */ |
| 19107 | /* (Workspace: need BDSPAC) */ |
| 19108 | |
| 19109 | dbdsqr_cxx . . $ dbdsqr_(d6d10c27a7b3c412).("U", n, &c__0, m, &c__0, &s[1], &work[ie], dum, & |
| 19110 | c__1, &a[a_offset], lda, dum, &c__1, &work[iwork], |
| 19111 | info); |
| 19112 | |
| 19113 | } |
| 19114 | |
| 19115 | } else if (wntuo && wntvas) { |
| 19116 | |
| 19117 | /* Path 3 (M much larger than N, JOBU='O', JOBVT='S' or 'A') */ |
| 19118 | /* N left singular vectors to be overwritten on A and */ |
| 19119 | /* N right singular vectors to be computed in VT */ |
| 19120 | |
| 19121 | /* Computing MAX */ |
| 19122 | i__3 = *n << 2; |
| 19123 | if (*lwork >= *n * *n + stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__3,bdspac)) { |
| 19124 | |
| 19125 | /* Sufficient workspace for a fast algorithm */ |
| 19126 | |
| 19127 | ir = 1; |
| 19128 | /* Computing MAX */ |
| 19129 | i__3 = wrkbl, i__2 = *lda * *n + *n; |
| 19130 | if (*lwork >= stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__3,i__2) + *lda * *n) { |
| 19131 | |
| 19132 | /* WORK(IU) is LDA by N and WORK(IR) is LDA by N */ |
| 19133 | |
| 19134 | ldwrku = *lda; |
| 19135 | ldwrkr = *lda; |
| 19136 | } else /* if(complicated condition) */ { |
| 19137 | /* Computing MAX */ |
| 19138 | i__3 = wrkbl, i__2 = *lda * *n + *n; |
| 19139 | if (*lwork >= stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__3,i__2) + *n * *n) { |
| 19140 | |
| 19141 | /* WORK(IU) is LDA by N and WORK(IR) is N by N */ |
| 19142 | |
| 19143 | ldwrku = *lda; |
| 19144 | ldwrkr = *n; |
| 19145 | } else { |
| 19146 | |
| 19147 | /* WORK(IU) is LDWRKU by N and WORK(IR) is N by N */ |
| 19148 | |
| 19149 | ldwrku = (*lwork - *n * *n - *n) / *n; |
| 19150 | ldwrkr = *n; |
| 19151 | } |
| 19152 | } |
| 19153 | itau = ir + ldwrkr * *n; |
| 19154 | iwork = itau + *n; |
| 19155 | |
| 19156 | /* Compute A=Q*R */ |
| 19157 | /* (Workspace: need N*N+2*N, prefer N*N+N+N*NB) */ |
| 19158 | |
| 19159 | i__3 = *lwork - iwork + 1; |
| 19160 | dgeqrf_cxx . . $ dgeqrf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[itau], &work[iwork] |
| 19161 | , &i__3, &ierr); |
| 19162 | |
| 19163 | /* Copy R to VT, zeroing out below it */ |
| 19164 | |
| 19165 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("U", n, n, &a[a_offset], lda, &vt[vt_offset], |
| 19166 | ldvt); |
| 19167 | if (*n > 1) { |
| 19168 | i__3 = *n - 1; |
| 19169 | i__2 = *n - 1; |
| 19170 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("L", &i__3, &i__2, &c_b421, &c_b421, &vt[ |
| 19171 | vt_dim1 + 2], ldvt); |
| 19172 | } |
| 19173 | |
| 19174 | /* Generate Q in A */ |
| 19175 | /* (Workspace: need N*N+2*N, prefer N*N+N+N*NB) */ |
| 19176 | |
| 19177 | i__3 = *lwork - iwork + 1; |
| 19178 | dorgqr_cxx . . $ dorgqr_(424524679a238630).(m, n, n, &a[a_offset], lda, &work[itau], &work[ |
| 19179 | iwork], &i__3, &ierr); |
| 19180 | ie = itau; |
| 19181 | itauq = ie + *n; |
| 19182 | itaup = itauq + *n; |
| 19183 | iwork = itaup + *n; |
| 19184 | |
| 19185 | /* Bidiagonalize R in VT, copying result to WORK(IR) */ |
| 19186 | /* (Workspace: need N*N+4*N, prefer N*N+3*N+2*N*NB) */ |
| 19187 | |
| 19188 | i__3 = *lwork - iwork + 1; |
| 19189 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(n, n, &vt[vt_offset], ldvt, &s[1], &work[ie], & |
| 19190 | work[itauq], &work[itaup], &work[iwork], &i__3, & |
| 19191 | ierr); |
| 19192 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("L", n, n, &vt[vt_offset], ldvt, &work[ir], & |
| 19193 | ldwrkr); |
| 19194 | |
| 19195 | /* Generate left vectors bidiagonalizing R in WORK(IR) */ |
| 19196 | /* (Workspace: need N*N+4*N, prefer N*N+3*N+N*NB) */ |
| 19197 | |
| 19198 | i__3 = *lwork - iwork + 1; |
| 19199 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("Q", n, n, n, &work[ir], &ldwrkr, &work[itauq], & |
| 19200 | work[iwork], &i__3, &ierr); |
| 19201 | |
| 19202 | /* Generate right vectors bidiagonalizing R in VT */ |
| 19203 | /* (Workspace: need N*N+4*N-1, prefer N*N+3*N+(N-1)*NB) */ |
| 19204 | |
| 19205 | i__3 = *lwork - iwork + 1; |
| 19206 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("P", n, n, n, &vt[vt_offset], ldvt, &work[itaup], |
| 19207 | &work[iwork], &i__3, &ierr); |
| 19208 | iwork = ie + *n; |
| 19209 | |
| 19210 | /* Perform bidiagonal QR iteration, computing left */ |
| 19211 | /* singular vectors of R in WORK(IR) and computing right */ |
| 19212 | /* singular vectors of R in VT */ |
| 19213 | /* (Workspace: need N*N+BDSPAC) */ |
| 19214 | |
| 19215 | dbdsqr_cxx . . $ dbdsqr_(d6d10c27a7b3c412).("U", n, n, n, &c__0, &s[1], &work[ie], &vt[ |
| 19216 | vt_offset], ldvt, &work[ir], &ldwrkr, dum, &c__1, |
| 19217 | &work[iwork], info); |
| 19218 | iu = ie + *n; |
| 19219 | |
| 19220 | /* Multiply Q in A by left singular vectors of R in */ |
| 19221 | /* WORK(IR), storing result in WORK(IU) and copying to A */ |
| 19222 | /* (Workspace: need N*N+2*N, prefer N*N+M*N+N) */ |
| 19223 | |
| 19224 | i__3 = *m; |
| 19225 | i__2 = ldwrku; |
| 19226 | for (i__ = 1; i__2 < 0 ? i__ >= i__3 : i__ <= i__3; i__ += |
| 19227 | i__2) { |
| 19228 | /* Computing MIN */ |
| 19229 | i__4 = *m - i__ + 1; |
| 19230 | chunk = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__4,ldwrku); |
| 19231 | dgemm_cxx . . $ dgemm_(7f9a15c7502022ea).("N", "N", &chunk, n, n, &c_b443, &a[i__ + |
| 19232 | a_dim1], lda, &work[ir], &ldwrkr, &c_b421, & |
| 19233 | work[iu], &ldwrku); |
| 19234 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("F", &chunk, n, &work[iu], &ldwrku, &a[i__ + |
| 19235 | a_dim1], lda); |
| 19236 | /* L20: */ |
| 19237 | } |
| 19238 | |
| 19239 | } else { |
| 19240 | |
| 19241 | /* Insufficient workspace for a fast algorithm */ |
| 19242 | |
| 19243 | itau = 1; |
| 19244 | iwork = itau + *n; |
| 19245 | |
| 19246 | /* Compute A=Q*R */ |
| 19247 | /* (Workspace: need 2*N, prefer N+N*NB) */ |
| 19248 | |
| 19249 | i__2 = *lwork - iwork + 1; |
| 19250 | dgeqrf_cxx . . $ dgeqrf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[itau], &work[iwork] |
| 19251 | , &i__2, &ierr); |
| 19252 | |
| 19253 | /* Copy R to VT, zeroing out below it */ |
| 19254 | |
| 19255 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("U", n, n, &a[a_offset], lda, &vt[vt_offset], |
| 19256 | ldvt); |
| 19257 | if (*n > 1) { |
| 19258 | i__2 = *n - 1; |
| 19259 | i__3 = *n - 1; |
| 19260 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("L", &i__2, &i__3, &c_b421, &c_b421, &vt[ |
| 19261 | vt_dim1 + 2], ldvt); |
| 19262 | } |
| 19263 | |
| 19264 | /* Generate Q in A */ |
| 19265 | /* (Workspace: need 2*N, prefer N+N*NB) */ |
| 19266 | |
| 19267 | i__2 = *lwork - iwork + 1; |
| 19268 | dorgqr_cxx . . $ dorgqr_(424524679a238630).(m, n, n, &a[a_offset], lda, &work[itau], &work[ |
| 19269 | iwork], &i__2, &ierr); |
| 19270 | ie = itau; |
| 19271 | itauq = ie + *n; |
| 19272 | itaup = itauq + *n; |
| 19273 | iwork = itaup + *n; |
| 19274 | |
| 19275 | /* Bidiagonalize R in VT */ |
| 19276 | /* (Workspace: need 4*N, prefer 3*N+2*N*NB) */ |
| 19277 | |
| 19278 | i__2 = *lwork - iwork + 1; |
| 19279 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(n, n, &vt[vt_offset], ldvt, &s[1], &work[ie], & |
| 19280 | work[itauq], &work[itaup], &work[iwork], &i__2, & |
| 19281 | ierr); |
| 19282 | |
| 19283 | /* Multiply Q in A by left vectors bidiagonalizing R */ |
| 19284 | /* (Workspace: need 3*N+M, prefer 3*N+M*NB) */ |
| 19285 | |
| 19286 | i__2 = *lwork - iwork + 1; |
| 19287 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("Q", "R", "N", m, n, n, &vt[vt_offset], ldvt, & |
| 19288 | work[itauq], &a[a_offset], lda, &work[iwork], & |
| 19289 | i__2, &ierr); |
| 19290 | |
| 19291 | /* Generate right vectors bidiagonalizing R in VT */ |
| 19292 | /* (Workspace: need 4*N-1, prefer 3*N+(N-1)*NB) */ |
| 19293 | |
| 19294 | i__2 = *lwork - iwork + 1; |
| 19295 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("P", n, n, n, &vt[vt_offset], ldvt, &work[itaup], |
| 19296 | &work[iwork], &i__2, &ierr); |
| 19297 | iwork = ie + *n; |
| 19298 | |
| 19299 | /* Perform bidiagonal QR iteration, computing left */ |
| 19300 | /* singular vectors of A in A and computing right */ |
| 19301 | /* singular vectors of A in VT */ |
| 19302 | /* (Workspace: need BDSPAC) */ |
| 19303 | |
| 19304 | dbdsqr_cxx . . $ dbdsqr_(d6d10c27a7b3c412).("U", n, n, m, &c__0, &s[1], &work[ie], &vt[ |
| 19305 | vt_offset], ldvt, &a[a_offset], lda, dum, &c__1, & |
| 19306 | work[iwork], info); |
| 19307 | |
| 19308 | } |
| 19309 | |
| 19310 | } else if (wntus) { |
| 19311 | |
| 19312 | if (wntvn) { |
| 19313 | |
| 19314 | /* Path 4 (M much larger than N, JOBU='S', JOBVT='N') */ |
| 19315 | /* N left singular vectors to be computed in U and */ |
| 19316 | /* no right singular vectors to be computed */ |
| 19317 | |
| 19318 | /* Computing MAX */ |
| 19319 | i__2 = *n << 2; |
| 19320 | if (*lwork >= *n * *n + stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,bdspac)) { |
| 19321 | |
| 19322 | /* Sufficient workspace for a fast algorithm */ |
| 19323 | |
| 19324 | ir = 1; |
| 19325 | if (*lwork >= wrkbl + *lda * *n) { |
| 19326 | |
| 19327 | /* WORK(IR) is LDA by N */ |
| 19328 | |
| 19329 | ldwrkr = *lda; |
| 19330 | } else { |
| 19331 | |
| 19332 | /* WORK(IR) is N by N */ |
| 19333 | |
| 19334 | ldwrkr = *n; |
| 19335 | } |
| 19336 | itau = ir + ldwrkr * *n; |
| 19337 | iwork = itau + *n; |
| 19338 | |
| 19339 | /* Compute A=Q*R */ |
| 19340 | /* (Workspace: need N*N+2*N, prefer N*N+N+N*NB) */ |
| 19341 | |
| 19342 | i__2 = *lwork - iwork + 1; |
| 19343 | dgeqrf_cxx . . $ dgeqrf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[itau], &work[ |
| 19344 | iwork], &i__2, &ierr); |
| 19345 | |
| 19346 | /* Copy R to WORK(IR), zeroing out below it */ |
| 19347 | |
| 19348 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("U", n, n, &a[a_offset], lda, &work[ir], & |
| 19349 | ldwrkr); |
| 19350 | i__2 = *n - 1; |
| 19351 | i__3 = *n - 1; |
| 19352 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("L", &i__2, &i__3, &c_b421, &c_b421, &work[ir |
| 19353 | + 1], &ldwrkr); |
| 19354 | |
| 19355 | /* Generate Q in A */ |
| 19356 | /* (Workspace: need N*N+2*N, prefer N*N+N+N*NB) */ |
| 19357 | |
| 19358 | i__2 = *lwork - iwork + 1; |
| 19359 | dorgqr_cxx . . $ dorgqr_(424524679a238630).(m, n, n, &a[a_offset], lda, &work[itau], & |
| 19360 | work[iwork], &i__2, &ierr); |
| 19361 | ie = itau; |
| 19362 | itauq = ie + *n; |
| 19363 | itaup = itauq + *n; |
| 19364 | iwork = itaup + *n; |
| 19365 | |
| 19366 | /* Bidiagonalize R in WORK(IR) */ |
| 19367 | /* (Workspace: need N*N+4*N, prefer N*N+3*N+2*N*NB) */ |
| 19368 | |
| 19369 | i__2 = *lwork - iwork + 1; |
| 19370 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(n, n, &work[ir], &ldwrkr, &s[1], &work[ie], & |
| 19371 | work[itauq], &work[itaup], &work[iwork], & |
| 19372 | i__2, &ierr); |
| 19373 | |
| 19374 | /* Generate left vectors bidiagonalizing R in WORK(IR) */ |
| 19375 | /* (Workspace: need N*N+4*N, prefer N*N+3*N+N*NB) */ |
| 19376 | |
| 19377 | i__2 = *lwork - iwork + 1; |
| 19378 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("Q", n, n, n, &work[ir], &ldwrkr, &work[itauq] |
| 19379 | , &work[iwork], &i__2, &ierr); |
| 19380 | iwork = ie + *n; |
| 19381 | |
| 19382 | /* Perform bidiagonal QR iteration, computing left */ |
| 19383 | /* singular vectors of R in WORK(IR) */ |
| 19384 | /* (Workspace: need N*N+BDSPAC) */ |
| 19385 | |
| 19386 | dbdsqr_cxx . . $ dbdsqr_(d6d10c27a7b3c412).("U", n, &c__0, n, &c__0, &s[1], &work[ie], |
| 19387 | dum, &c__1, &work[ir], &ldwrkr, dum, &c__1, & |
| 19388 | work[iwork], info); |
| 19389 | |
| 19390 | /* Multiply Q in A by left singular vectors of R in */ |
| 19391 | /* WORK(IR), storing result in U */ |
| 19392 | /* (Workspace: need N*N) */ |
| 19393 | |
| 19394 | dgemm_cxx . . $ dgemm_(7f9a15c7502022ea).("N", "N", m, n, n, &c_b443, &a[a_offset], lda, |
| 19395 | &work[ir], &ldwrkr, &c_b421, &u[u_offset], |
| 19396 | ldu); |
| 19397 | |
| 19398 | } else { |
| 19399 | |
| 19400 | /* Insufficient workspace for a fast algorithm */ |
| 19401 | |
| 19402 | itau = 1; |
| 19403 | iwork = itau + *n; |
| 19404 | |
| 19405 | /* Compute A=Q*R, copying result to U */ |
| 19406 | /* (Workspace: need 2*N, prefer N+N*NB) */ |
| 19407 | |
| 19408 | i__2 = *lwork - iwork + 1; |
| 19409 | dgeqrf_cxx . . $ dgeqrf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[itau], &work[ |
| 19410 | iwork], &i__2, &ierr); |
| 19411 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("L", m, n, &a[a_offset], lda, &u[u_offset], |
| 19412 | ldu); |
| 19413 | |
| 19414 | /* Generate Q in U */ |
| 19415 | /* (Workspace: need 2*N, prefer N+N*NB) */ |
| 19416 | |
| 19417 | i__2 = *lwork - iwork + 1; |
| 19418 | dorgqr_cxx . . $ dorgqr_(424524679a238630).(m, n, n, &u[u_offset], ldu, &work[itau], & |
| 19419 | work[iwork], &i__2, &ierr); |
| 19420 | ie = itau; |
| 19421 | itauq = ie + *n; |
| 19422 | itaup = itauq + *n; |
| 19423 | iwork = itaup + *n; |
| 19424 | |
| 19425 | /* Zero out below R in A */ |
| 19426 | |
| 19427 | i__2 = *n - 1; |
| 19428 | i__3 = *n - 1; |
| 19429 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("L", &i__2, &i__3, &c_b421, &c_b421, &a[ |
| 19430 | a_dim1 + 2], lda); |
| 19431 | |
| 19432 | /* Bidiagonalize R in A */ |
| 19433 | /* (Workspace: need 4*N, prefer 3*N+2*N*NB) */ |
| 19434 | |
| 19435 | i__2 = *lwork - iwork + 1; |
| 19436 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(n, n, &a[a_offset], lda, &s[1], &work[ie], & |
| 19437 | work[itauq], &work[itaup], &work[iwork], & |
| 19438 | i__2, &ierr); |
| 19439 | |
| 19440 | /* Multiply Q in U by left vectors bidiagonalizing R */ |
| 19441 | /* (Workspace: need 3*N+M, prefer 3*N+M*NB) */ |
| 19442 | |
| 19443 | i__2 = *lwork - iwork + 1; |
| 19444 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("Q", "R", "N", m, n, n, &a[a_offset], lda, & |
| 19445 | work[itauq], &u[u_offset], ldu, &work[iwork], |
| 19446 | &i__2, &ierr) |
| 19447 | ; |
| 19448 | iwork = ie + *n; |
| 19449 | |
| 19450 | /* Perform bidiagonal QR iteration, computing left */ |
| 19451 | /* singular vectors of A in U */ |
| 19452 | /* (Workspace: need BDSPAC) */ |
| 19453 | |
| 19454 | dbdsqr_cxx . . $ dbdsqr_(d6d10c27a7b3c412).("U", n, &c__0, m, &c__0, &s[1], &work[ie], |
| 19455 | dum, &c__1, &u[u_offset], ldu, dum, &c__1, & |
| 19456 | work[iwork], info); |
| 19457 | |
| 19458 | } |
| 19459 | |
| 19460 | } else if (wntvo) { |
| 19461 | |
| 19462 | /* Path 5 (M much larger than N, JOBU='S', JOBVT='O') */ |
| 19463 | /* N left singular vectors to be computed in U and */ |
| 19464 | /* N right singular vectors to be overwritten on A */ |
| 19465 | |
| 19466 | /* Computing MAX */ |
| 19467 | i__2 = *n << 2; |
| 19468 | if (*lwork >= (*n << 1) * *n + stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,bdspac)) { |
| 19469 | |
| 19470 | /* Sufficient workspace for a fast algorithm */ |
| 19471 | |
| 19472 | iu = 1; |
| 19473 | if (*lwork >= wrkbl + (*lda << 1) * *n) { |
| 19474 | |
| 19475 | /* WORK(IU) is LDA by N and WORK(IR) is LDA by N */ |
| 19476 | |
| 19477 | ldwrku = *lda; |
| 19478 | ir = iu + ldwrku * *n; |
| 19479 | ldwrkr = *lda; |
| 19480 | } else if (*lwork >= wrkbl + (*lda + *n) * *n) { |
| 19481 | |
| 19482 | /* WORK(IU) is LDA by N and WORK(IR) is N by N */ |
| 19483 | |
| 19484 | ldwrku = *lda; |
| 19485 | ir = iu + ldwrku * *n; |
| 19486 | ldwrkr = *n; |
| 19487 | } else { |
| 19488 | |
| 19489 | /* WORK(IU) is N by N and WORK(IR) is N by N */ |
| 19490 | |
| 19491 | ldwrku = *n; |
| 19492 | ir = iu + ldwrku * *n; |
| 19493 | ldwrkr = *n; |
| 19494 | } |
| 19495 | itau = ir + ldwrkr * *n; |
| 19496 | iwork = itau + *n; |
| 19497 | |
| 19498 | /* Compute A=Q*R */ |
| 19499 | /* (Workspace: need 2*N*N+2*N, prefer 2*N*N+N+N*NB) */ |
| 19500 | |
| 19501 | i__2 = *lwork - iwork + 1; |
| 19502 | dgeqrf_cxx . . $ dgeqrf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[itau], &work[ |
| 19503 | iwork], &i__2, &ierr); |
| 19504 | |
| 19505 | /* Copy R to WORK(IU), zeroing out below it */ |
| 19506 | |
| 19507 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("U", n, n, &a[a_offset], lda, &work[iu], & |
| 19508 | ldwrku); |
| 19509 | i__2 = *n - 1; |
| 19510 | i__3 = *n - 1; |
| 19511 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("L", &i__2, &i__3, &c_b421, &c_b421, &work[iu |
| 19512 | + 1], &ldwrku); |
| 19513 | |
| 19514 | /* Generate Q in A */ |
| 19515 | /* (Workspace: need 2*N*N+2*N, prefer 2*N*N+N+N*NB) */ |
| 19516 | |
| 19517 | i__2 = *lwork - iwork + 1; |
| 19518 | dorgqr_cxx . . $ dorgqr_(424524679a238630).(m, n, n, &a[a_offset], lda, &work[itau], & |
| 19519 | work[iwork], &i__2, &ierr); |
| 19520 | ie = itau; |
| 19521 | itauq = ie + *n; |
| 19522 | itaup = itauq + *n; |
| 19523 | iwork = itaup + *n; |
| 19524 | |
| 19525 | /* Bidiagonalize R in WORK(IU), copying result to */ |
| 19526 | /* WORK(IR) */ |
| 19527 | /* (Workspace: need 2*N*N+4*N, */ |
| 19528 | /* prefer 2*N*N+3*N+2*N*NB) */ |
| 19529 | |
| 19530 | i__2 = *lwork - iwork + 1; |
| 19531 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(n, n, &work[iu], &ldwrku, &s[1], &work[ie], & |
| 19532 | work[itauq], &work[itaup], &work[iwork], & |
| 19533 | i__2, &ierr); |
| 19534 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("U", n, n, &work[iu], &ldwrku, &work[ir], & |
| 19535 | ldwrkr); |
| 19536 | |
| 19537 | /* Generate left bidiagonalizing vectors in WORK(IU) */ |
| 19538 | /* (Workspace: need 2*N*N+4*N, prefer 2*N*N+3*N+N*NB) */ |
| 19539 | |
| 19540 | i__2 = *lwork - iwork + 1; |
| 19541 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("Q", n, n, n, &work[iu], &ldwrku, &work[itauq] |
| 19542 | , &work[iwork], &i__2, &ierr); |
| 19543 | |
| 19544 | /* Generate right bidiagonalizing vectors in WORK(IR) */ |
| 19545 | /* (Workspace: need 2*N*N+4*N-1, */ |
| 19546 | /* prefer 2*N*N+3*N+(N-1)*NB) */ |
| 19547 | |
| 19548 | i__2 = *lwork - iwork + 1; |
| 19549 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("P", n, n, n, &work[ir], &ldwrkr, &work[itaup] |
| 19550 | , &work[iwork], &i__2, &ierr); |
| 19551 | iwork = ie + *n; |
| 19552 | |
| 19553 | /* Perform bidiagonal QR iteration, computing left */ |
| 19554 | /* singular vectors of R in WORK(IU) and computing */ |
| 19555 | /* right singular vectors of R in WORK(IR) */ |
| 19556 | /* (Workspace: need 2*N*N+BDSPAC) */ |
| 19557 | |
| 19558 | dbdsqr_cxx . . $ dbdsqr_(d6d10c27a7b3c412).("U", n, n, n, &c__0, &s[1], &work[ie], &work[ |
| 19559 | ir], &ldwrkr, &work[iu], &ldwrku, dum, &c__1, |
| 19560 | &work[iwork], info); |
| 19561 | |
| 19562 | /* Multiply Q in A by left singular vectors of R in */ |
| 19563 | /* WORK(IU), storing result in U */ |
| 19564 | /* (Workspace: need N*N) */ |
| 19565 | |
| 19566 | dgemm_cxx . . $ dgemm_(7f9a15c7502022ea).("N", "N", m, n, n, &c_b443, &a[a_offset], lda, |
| 19567 | &work[iu], &ldwrku, &c_b421, &u[u_offset], |
| 19568 | ldu); |
| 19569 | |
| 19570 | /* Copy right singular vectors of R to A */ |
| 19571 | /* (Workspace: need N*N) */ |
| 19572 | |
| 19573 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("F", n, n, &work[ir], &ldwrkr, &a[a_offset], |
| 19574 | lda); |
| 19575 | |
| 19576 | } else { |
| 19577 | |
| 19578 | /* Insufficient workspace for a fast algorithm */ |
| 19579 | |
| 19580 | itau = 1; |
| 19581 | iwork = itau + *n; |
| 19582 | |
| 19583 | /* Compute A=Q*R, copying result to U */ |
| 19584 | /* (Workspace: need 2*N, prefer N+N*NB) */ |
| 19585 | |
| 19586 | i__2 = *lwork - iwork + 1; |
| 19587 | dgeqrf_cxx . . $ dgeqrf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[itau], &work[ |
| 19588 | iwork], &i__2, &ierr); |
| 19589 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("L", m, n, &a[a_offset], lda, &u[u_offset], |
| 19590 | ldu); |
| 19591 | |
| 19592 | /* Generate Q in U */ |
| 19593 | /* (Workspace: need 2*N, prefer N+N*NB) */ |
| 19594 | |
| 19595 | i__2 = *lwork - iwork + 1; |
| 19596 | dorgqr_cxx . . $ dorgqr_(424524679a238630).(m, n, n, &u[u_offset], ldu, &work[itau], & |
| 19597 | work[iwork], &i__2, &ierr); |
| 19598 | ie = itau; |
| 19599 | itauq = ie + *n; |
| 19600 | itaup = itauq + *n; |
| 19601 | iwork = itaup + *n; |
| 19602 | |
| 19603 | /* Zero out below R in A */ |
| 19604 | |
| 19605 | i__2 = *n - 1; |
| 19606 | i__3 = *n - 1; |
| 19607 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("L", &i__2, &i__3, &c_b421, &c_b421, &a[ |
| 19608 | a_dim1 + 2], lda); |
| 19609 | |
| 19610 | /* Bidiagonalize R in A */ |
| 19611 | /* (Workspace: need 4*N, prefer 3*N+2*N*NB) */ |
| 19612 | |
| 19613 | i__2 = *lwork - iwork + 1; |
| 19614 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(n, n, &a[a_offset], lda, &s[1], &work[ie], & |
| 19615 | work[itauq], &work[itaup], &work[iwork], & |
| 19616 | i__2, &ierr); |
| 19617 | |
| 19618 | /* Multiply Q in U by left vectors bidiagonalizing R */ |
| 19619 | /* (Workspace: need 3*N+M, prefer 3*N+M*NB) */ |
| 19620 | |
| 19621 | i__2 = *lwork - iwork + 1; |
| 19622 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("Q", "R", "N", m, n, n, &a[a_offset], lda, & |
| 19623 | work[itauq], &u[u_offset], ldu, &work[iwork], |
| 19624 | &i__2, &ierr) |
| 19625 | ; |
| 19626 | |
| 19627 | /* Generate right vectors bidiagonalizing R in A */ |
| 19628 | /* (Workspace: need 4*N-1, prefer 3*N+(N-1)*NB) */ |
| 19629 | |
| 19630 | i__2 = *lwork - iwork + 1; |
| 19631 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("P", n, n, n, &a[a_offset], lda, &work[itaup], |
| 19632 | &work[iwork], &i__2, &ierr); |
| 19633 | iwork = ie + *n; |
| 19634 | |
| 19635 | /* Perform bidiagonal QR iteration, computing left */ |
| 19636 | /* singular vectors of A in U and computing right */ |
| 19637 | /* singular vectors of A in A */ |
| 19638 | /* (Workspace: need BDSPAC) */ |
| 19639 | |
| 19640 | dbdsqr_cxx . . $ dbdsqr_(d6d10c27a7b3c412).("U", n, n, m, &c__0, &s[1], &work[ie], &a[ |
| 19641 | a_offset], lda, &u[u_offset], ldu, dum, &c__1, |
| 19642 | &work[iwork], info); |
| 19643 | |
| 19644 | } |
| 19645 | |
| 19646 | } else if (wntvas) { |
| 19647 | |
| 19648 | /* Path 6 (M much larger than N, JOBU='S', JOBVT='S' */ |
| 19649 | /* or 'A') */ |
| 19650 | /* N left singular vectors to be computed in U and */ |
| 19651 | /* N right singular vectors to be computed in VT */ |
| 19652 | |
| 19653 | /* Computing MAX */ |
| 19654 | i__2 = *n << 2; |
| 19655 | if (*lwork >= *n * *n + stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,bdspac)) { |
| 19656 | |
| 19657 | /* Sufficient workspace for a fast algorithm */ |
| 19658 | |
| 19659 | iu = 1; |
| 19660 | if (*lwork >= wrkbl + *lda * *n) { |
| 19661 | |
| 19662 | /* WORK(IU) is LDA by N */ |
| 19663 | |
| 19664 | ldwrku = *lda; |
| 19665 | } else { |
| 19666 | |
| 19667 | /* WORK(IU) is N by N */ |
| 19668 | |
| 19669 | ldwrku = *n; |
| 19670 | } |
| 19671 | itau = iu + ldwrku * *n; |
| 19672 | iwork = itau + *n; |
| 19673 | |
| 19674 | /* Compute A=Q*R */ |
| 19675 | /* (Workspace: need N*N+2*N, prefer N*N+N+N*NB) */ |
| 19676 | |
| 19677 | i__2 = *lwork - iwork + 1; |
| 19678 | dgeqrf_cxx . . $ dgeqrf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[itau], &work[ |
| 19679 | iwork], &i__2, &ierr); |
| 19680 | |
| 19681 | /* Copy R to WORK(IU), zeroing out below it */ |
| 19682 | |
| 19683 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("U", n, n, &a[a_offset], lda, &work[iu], & |
| 19684 | ldwrku); |
| 19685 | i__2 = *n - 1; |
| 19686 | i__3 = *n - 1; |
| 19687 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("L", &i__2, &i__3, &c_b421, &c_b421, &work[iu |
| 19688 | + 1], &ldwrku); |
| 19689 | |
| 19690 | /* Generate Q in A */ |
| 19691 | /* (Workspace: need N*N+2*N, prefer N*N+N+N*NB) */ |
| 19692 | |
| 19693 | i__2 = *lwork - iwork + 1; |
| 19694 | dorgqr_cxx . . $ dorgqr_(424524679a238630).(m, n, n, &a[a_offset], lda, &work[itau], & |
| 19695 | work[iwork], &i__2, &ierr); |
| 19696 | ie = itau; |
| 19697 | itauq = ie + *n; |
| 19698 | itaup = itauq + *n; |
| 19699 | iwork = itaup + *n; |
| 19700 | |
| 19701 | /* Bidiagonalize R in WORK(IU), copying result to VT */ |
| 19702 | /* (Workspace: need N*N+4*N, prefer N*N+3*N+2*N*NB) */ |
| 19703 | |
| 19704 | i__2 = *lwork - iwork + 1; |
| 19705 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(n, n, &work[iu], &ldwrku, &s[1], &work[ie], & |
| 19706 | work[itauq], &work[itaup], &work[iwork], & |
| 19707 | i__2, &ierr); |
| 19708 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("U", n, n, &work[iu], &ldwrku, &vt[vt_offset], |
| 19709 | ldvt); |
| 19710 | |
| 19711 | /* Generate left bidiagonalizing vectors in WORK(IU) */ |
| 19712 | /* (Workspace: need N*N+4*N, prefer N*N+3*N+N*NB) */ |
| 19713 | |
| 19714 | i__2 = *lwork - iwork + 1; |
| 19715 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("Q", n, n, n, &work[iu], &ldwrku, &work[itauq] |
| 19716 | , &work[iwork], &i__2, &ierr); |
| 19717 | |
| 19718 | /* Generate right bidiagonalizing vectors in VT */ |
| 19719 | /* (Workspace: need N*N+4*N-1, */ |
| 19720 | /* prefer N*N+3*N+(N-1)*NB) */ |
| 19721 | |
| 19722 | i__2 = *lwork - iwork + 1; |
| 19723 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("P", n, n, n, &vt[vt_offset], ldvt, &work[ |
| 19724 | itaup], &work[iwork], &i__2, &ierr) |
| 19725 | ; |
| 19726 | iwork = ie + *n; |
| 19727 | |
| 19728 | /* Perform bidiagonal QR iteration, computing left */ |
| 19729 | /* singular vectors of R in WORK(IU) and computing */ |
| 19730 | /* right singular vectors of R in VT */ |
| 19731 | /* (Workspace: need N*N+BDSPAC) */ |
| 19732 | |
| 19733 | dbdsqr_cxx . . $ dbdsqr_(d6d10c27a7b3c412).("U", n, n, n, &c__0, &s[1], &work[ie], &vt[ |
| 19734 | vt_offset], ldvt, &work[iu], &ldwrku, dum, & |
| 19735 | c__1, &work[iwork], info); |
| 19736 | |
| 19737 | /* Multiply Q in A by left singular vectors of R in */ |
| 19738 | /* WORK(IU), storing result in U */ |
| 19739 | /* (Workspace: need N*N) */ |
| 19740 | |
| 19741 | dgemm_cxx . . $ dgemm_(7f9a15c7502022ea).("N", "N", m, n, n, &c_b443, &a[a_offset], lda, |
| 19742 | &work[iu], &ldwrku, &c_b421, &u[u_offset], |
| 19743 | ldu); |
| 19744 | |
| 19745 | } else { |
| 19746 | |
| 19747 | /* Insufficient workspace for a fast algorithm */ |
| 19748 | |
| 19749 | itau = 1; |
| 19750 | iwork = itau + *n; |
| 19751 | |
| 19752 | /* Compute A=Q*R, copying result to U */ |
| 19753 | /* (Workspace: need 2*N, prefer N+N*NB) */ |
| 19754 | |
| 19755 | i__2 = *lwork - iwork + 1; |
| 19756 | dgeqrf_cxx . . $ dgeqrf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[itau], &work[ |
| 19757 | iwork], &i__2, &ierr); |
| 19758 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("L", m, n, &a[a_offset], lda, &u[u_offset], |
| 19759 | ldu); |
| 19760 | |
| 19761 | /* Generate Q in U */ |
| 19762 | /* (Workspace: need 2*N, prefer N+N*NB) */ |
| 19763 | |
| 19764 | i__2 = *lwork - iwork + 1; |
| 19765 | dorgqr_cxx . . $ dorgqr_(424524679a238630).(m, n, n, &u[u_offset], ldu, &work[itau], & |
| 19766 | work[iwork], &i__2, &ierr); |
| 19767 | |
| 19768 | /* Copy R to VT, zeroing out below it */ |
| 19769 | |
| 19770 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("U", n, n, &a[a_offset], lda, &vt[vt_offset], |
| 19771 | ldvt); |
| 19772 | if (*n > 1) { |
| 19773 | i__2 = *n - 1; |
| 19774 | i__3 = *n - 1; |
| 19775 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("L", &i__2, &i__3, &c_b421, &c_b421, &vt[ |
| 19776 | vt_dim1 + 2], ldvt); |
| 19777 | } |
| 19778 | ie = itau; |
| 19779 | itauq = ie + *n; |
| 19780 | itaup = itauq + *n; |
| 19781 | iwork = itaup + *n; |
| 19782 | |
| 19783 | /* Bidiagonalize R in VT */ |
| 19784 | /* (Workspace: need 4*N, prefer 3*N+2*N*NB) */ |
| 19785 | |
| 19786 | i__2 = *lwork - iwork + 1; |
| 19787 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(n, n, &vt[vt_offset], ldvt, &s[1], &work[ie], |
| 19788 | &work[itauq], &work[itaup], &work[iwork], & |
| 19789 | i__2, &ierr); |
| 19790 | |
| 19791 | /* Multiply Q in U by left bidiagonalizing vectors */ |
| 19792 | /* in VT */ |
| 19793 | /* (Workspace: need 3*N+M, prefer 3*N+M*NB) */ |
| 19794 | |
| 19795 | i__2 = *lwork - iwork + 1; |
| 19796 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("Q", "R", "N", m, n, n, &vt[vt_offset], ldvt, |
| 19797 | &work[itauq], &u[u_offset], ldu, &work[iwork], |
| 19798 | &i__2, &ierr); |
| 19799 | |
| 19800 | /* Generate right bidiagonalizing vectors in VT */ |
| 19801 | /* (Workspace: need 4*N-1, prefer 3*N+(N-1)*NB) */ |
| 19802 | |
| 19803 | i__2 = *lwork - iwork + 1; |
| 19804 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("P", n, n, n, &vt[vt_offset], ldvt, &work[ |
| 19805 | itaup], &work[iwork], &i__2, &ierr) |
| 19806 | ; |
| 19807 | iwork = ie + *n; |
| 19808 | |
| 19809 | /* Perform bidiagonal QR iteration, computing left */ |
| 19810 | /* singular vectors of A in U and computing right */ |
| 19811 | /* singular vectors of A in VT */ |
| 19812 | /* (Workspace: need BDSPAC) */ |
| 19813 | |
| 19814 | dbdsqr_cxx . . $ dbdsqr_(d6d10c27a7b3c412).("U", n, n, m, &c__0, &s[1], &work[ie], &vt[ |
| 19815 | vt_offset], ldvt, &u[u_offset], ldu, dum, & |
| 19816 | c__1, &work[iwork], info); |
| 19817 | |
| 19818 | } |
| 19819 | |
| 19820 | } |
| 19821 | |
| 19822 | } else if (wntua) { |
| 19823 | |
| 19824 | if (wntvn) { |
| 19825 | |
| 19826 | /* Path 7 (M much larger than N, JOBU='A', JOBVT='N') */ |
| 19827 | /* M left singular vectors to be computed in U and */ |
| 19828 | /* no right singular vectors to be computed */ |
| 19829 | |
| 19830 | /* Computing MAX */ |
| 19831 | i__2 = *n + *m, i__3 = *n << 2, i__2 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 19832 | if (*lwork >= *n * *n + stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,bdspac)) { |
| 19833 | |
| 19834 | /* Sufficient workspace for a fast algorithm */ |
| 19835 | |
| 19836 | ir = 1; |
| 19837 | if (*lwork >= wrkbl + *lda * *n) { |
| 19838 | |
| 19839 | /* WORK(IR) is LDA by N */ |
| 19840 | |
| 19841 | ldwrkr = *lda; |
| 19842 | } else { |
| 19843 | |
| 19844 | /* WORK(IR) is N by N */ |
| 19845 | |
| 19846 | ldwrkr = *n; |
| 19847 | } |
| 19848 | itau = ir + ldwrkr * *n; |
| 19849 | iwork = itau + *n; |
| 19850 | |
| 19851 | /* Compute A=Q*R, copying result to U */ |
| 19852 | /* (Workspace: need N*N+2*N, prefer N*N+N+N*NB) */ |
| 19853 | |
| 19854 | i__2 = *lwork - iwork + 1; |
| 19855 | dgeqrf_cxx . . $ dgeqrf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[itau], &work[ |
| 19856 | iwork], &i__2, &ierr); |
| 19857 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("L", m, n, &a[a_offset], lda, &u[u_offset], |
| 19858 | ldu); |
| 19859 | |
| 19860 | /* Copy R to WORK(IR), zeroing out below it */ |
| 19861 | |
| 19862 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("U", n, n, &a[a_offset], lda, &work[ir], & |
| 19863 | ldwrkr); |
| 19864 | i__2 = *n - 1; |
| 19865 | i__3 = *n - 1; |
| 19866 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("L", &i__2, &i__3, &c_b421, &c_b421, &work[ir |
| 19867 | + 1], &ldwrkr); |
| 19868 | |
| 19869 | /* Generate Q in U */ |
| 19870 | /* (Workspace: need N*N+N+M, prefer N*N+N+M*NB) */ |
| 19871 | |
| 19872 | i__2 = *lwork - iwork + 1; |
| 19873 | dorgqr_cxx . . $ dorgqr_(424524679a238630).(m, m, n, &u[u_offset], ldu, &work[itau], & |
| 19874 | work[iwork], &i__2, &ierr); |
| 19875 | ie = itau; |
| 19876 | itauq = ie + *n; |
| 19877 | itaup = itauq + *n; |
| 19878 | iwork = itaup + *n; |
| 19879 | |
| 19880 | /* Bidiagonalize R in WORK(IR) */ |
| 19881 | /* (Workspace: need N*N+4*N, prefer N*N+3*N+2*N*NB) */ |
| 19882 | |
| 19883 | i__2 = *lwork - iwork + 1; |
| 19884 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(n, n, &work[ir], &ldwrkr, &s[1], &work[ie], & |
| 19885 | work[itauq], &work[itaup], &work[iwork], & |
| 19886 | i__2, &ierr); |
| 19887 | |
| 19888 | /* Generate left bidiagonalizing vectors in WORK(IR) */ |
| 19889 | /* (Workspace: need N*N+4*N, prefer N*N+3*N+N*NB) */ |
| 19890 | |
| 19891 | i__2 = *lwork - iwork + 1; |
| 19892 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("Q", n, n, n, &work[ir], &ldwrkr, &work[itauq] |
| 19893 | , &work[iwork], &i__2, &ierr); |
| 19894 | iwork = ie + *n; |
| 19895 | |
| 19896 | /* Perform bidiagonal QR iteration, computing left */ |
| 19897 | /* singular vectors of R in WORK(IR) */ |
| 19898 | /* (Workspace: need N*N+BDSPAC) */ |
| 19899 | |
| 19900 | dbdsqr_cxx . . $ dbdsqr_(d6d10c27a7b3c412).("U", n, &c__0, n, &c__0, &s[1], &work[ie], |
| 19901 | dum, &c__1, &work[ir], &ldwrkr, dum, &c__1, & |
| 19902 | work[iwork], info); |
| 19903 | |
| 19904 | /* Multiply Q in U by left singular vectors of R in */ |
| 19905 | /* WORK(IR), storing result in A */ |
| 19906 | /* (Workspace: need N*N) */ |
| 19907 | |
| 19908 | dgemm_cxx . . $ dgemm_(7f9a15c7502022ea).("N", "N", m, n, n, &c_b443, &u[u_offset], ldu, |
| 19909 | &work[ir], &ldwrkr, &c_b421, &a[a_offset], |
| 19910 | lda); |
| 19911 | |
| 19912 | /* Copy left singular vectors of A from A to U */ |
| 19913 | |
| 19914 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("F", m, n, &a[a_offset], lda, &u[u_offset], |
| 19915 | ldu); |
| 19916 | |
| 19917 | } else { |
| 19918 | |
| 19919 | /* Insufficient workspace for a fast algorithm */ |
| 19920 | |
| 19921 | itau = 1; |
| 19922 | iwork = itau + *n; |
| 19923 | |
| 19924 | /* Compute A=Q*R, copying result to U */ |
| 19925 | /* (Workspace: need 2*N, prefer N+N*NB) */ |
| 19926 | |
| 19927 | i__2 = *lwork - iwork + 1; |
| 19928 | dgeqrf_cxx . . $ dgeqrf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[itau], &work[ |
| 19929 | iwork], &i__2, &ierr); |
| 19930 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("L", m, n, &a[a_offset], lda, &u[u_offset], |
| 19931 | ldu); |
| 19932 | |
| 19933 | /* Generate Q in U */ |
| 19934 | /* (Workspace: need N+M, prefer N+M*NB) */ |
| 19935 | |
| 19936 | i__2 = *lwork - iwork + 1; |
| 19937 | dorgqr_cxx . . $ dorgqr_(424524679a238630).(m, m, n, &u[u_offset], ldu, &work[itau], & |
| 19938 | work[iwork], &i__2, &ierr); |
| 19939 | ie = itau; |
| 19940 | itauq = ie + *n; |
| 19941 | itaup = itauq + *n; |
| 19942 | iwork = itaup + *n; |
| 19943 | |
| 19944 | /* Zero out below R in A */ |
| 19945 | |
| 19946 | i__2 = *n - 1; |
| 19947 | i__3 = *n - 1; |
| 19948 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("L", &i__2, &i__3, &c_b421, &c_b421, &a[ |
| 19949 | a_dim1 + 2], lda); |
| 19950 | |
| 19951 | /* Bidiagonalize R in A */ |
| 19952 | /* (Workspace: need 4*N, prefer 3*N+2*N*NB) */ |
| 19953 | |
| 19954 | i__2 = *lwork - iwork + 1; |
| 19955 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(n, n, &a[a_offset], lda, &s[1], &work[ie], & |
| 19956 | work[itauq], &work[itaup], &work[iwork], & |
| 19957 | i__2, &ierr); |
| 19958 | |
| 19959 | /* Multiply Q in U by left bidiagonalizing vectors */ |
| 19960 | /* in A */ |
| 19961 | /* (Workspace: need 3*N+M, prefer 3*N+M*NB) */ |
| 19962 | |
| 19963 | i__2 = *lwork - iwork + 1; |
| 19964 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("Q", "R", "N", m, n, n, &a[a_offset], lda, & |
| 19965 | work[itauq], &u[u_offset], ldu, &work[iwork], |
| 19966 | &i__2, &ierr) |
| 19967 | ; |
| 19968 | iwork = ie + *n; |
| 19969 | |
| 19970 | /* Perform bidiagonal QR iteration, computing left */ |
| 19971 | /* singular vectors of A in U */ |
| 19972 | /* (Workspace: need BDSPAC) */ |
| 19973 | |
| 19974 | dbdsqr_cxx . . $ dbdsqr_(d6d10c27a7b3c412).("U", n, &c__0, m, &c__0, &s[1], &work[ie], |
| 19975 | dum, &c__1, &u[u_offset], ldu, dum, &c__1, & |
| 19976 | work[iwork], info); |
| 19977 | |
| 19978 | } |
| 19979 | |
| 19980 | } else if (wntvo) { |
| 19981 | |
| 19982 | /* Path 8 (M much larger than N, JOBU='A', JOBVT='O') */ |
| 19983 | /* M left singular vectors to be computed in U and */ |
| 19984 | /* N right singular vectors to be overwritten on A */ |
| 19985 | |
| 19986 | /* Computing MAX */ |
| 19987 | i__2 = *n + *m, i__3 = *n << 2, i__2 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 19988 | if (*lwork >= (*n << 1) * *n + stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,bdspac)) { |
| 19989 | |
| 19990 | /* Sufficient workspace for a fast algorithm */ |
| 19991 | |
| 19992 | iu = 1; |
| 19993 | if (*lwork >= wrkbl + (*lda << 1) * *n) { |
| 19994 | |
| 19995 | /* WORK(IU) is LDA by N and WORK(IR) is LDA by N */ |
| 19996 | |
| 19997 | ldwrku = *lda; |
| 19998 | ir = iu + ldwrku * *n; |
| 19999 | ldwrkr = *lda; |
| 20000 | } else if (*lwork >= wrkbl + (*lda + *n) * *n) { |
| 20001 | |
| 20002 | /* WORK(IU) is LDA by N and WORK(IR) is N by N */ |
| 20003 | |
| 20004 | ldwrku = *lda; |
| 20005 | ir = iu + ldwrku * *n; |
| 20006 | ldwrkr = *n; |
| 20007 | } else { |
| 20008 | |
| 20009 | /* WORK(IU) is N by N and WORK(IR) is N by N */ |
| 20010 | |
| 20011 | ldwrku = *n; |
| 20012 | ir = iu + ldwrku * *n; |
| 20013 | ldwrkr = *n; |
| 20014 | } |
| 20015 | itau = ir + ldwrkr * *n; |
| 20016 | iwork = itau + *n; |
| 20017 | |
| 20018 | /* Compute A=Q*R, copying result to U */ |
| 20019 | /* (Workspace: need 2*N*N+2*N, prefer 2*N*N+N+N*NB) */ |
| 20020 | |
| 20021 | i__2 = *lwork - iwork + 1; |
| 20022 | dgeqrf_cxx . . $ dgeqrf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[itau], &work[ |
| 20023 | iwork], &i__2, &ierr); |
| 20024 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("L", m, n, &a[a_offset], lda, &u[u_offset], |
| 20025 | ldu); |
| 20026 | |
| 20027 | /* Generate Q in U */ |
| 20028 | /* (Workspace: need 2*N*N+N+M, prefer 2*N*N+N+M*NB) */ |
| 20029 | |
| 20030 | i__2 = *lwork - iwork + 1; |
| 20031 | dorgqr_cxx . . $ dorgqr_(424524679a238630).(m, m, n, &u[u_offset], ldu, &work[itau], & |
| 20032 | work[iwork], &i__2, &ierr); |
| 20033 | |
| 20034 | /* Copy R to WORK(IU), zeroing out below it */ |
| 20035 | |
| 20036 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("U", n, n, &a[a_offset], lda, &work[iu], & |
| 20037 | ldwrku); |
| 20038 | i__2 = *n - 1; |
| 20039 | i__3 = *n - 1; |
| 20040 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("L", &i__2, &i__3, &c_b421, &c_b421, &work[iu |
| 20041 | + 1], &ldwrku); |
| 20042 | ie = itau; |
| 20043 | itauq = ie + *n; |
| 20044 | itaup = itauq + *n; |
| 20045 | iwork = itaup + *n; |
| 20046 | |
| 20047 | /* Bidiagonalize R in WORK(IU), copying result to */ |
| 20048 | /* WORK(IR) */ |
| 20049 | /* (Workspace: need 2*N*N+4*N, */ |
| 20050 | /* prefer 2*N*N+3*N+2*N*NB) */ |
| 20051 | |
| 20052 | i__2 = *lwork - iwork + 1; |
| 20053 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(n, n, &work[iu], &ldwrku, &s[1], &work[ie], & |
| 20054 | work[itauq], &work[itaup], &work[iwork], & |
| 20055 | i__2, &ierr); |
| 20056 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("U", n, n, &work[iu], &ldwrku, &work[ir], & |
| 20057 | ldwrkr); |
| 20058 | |
| 20059 | /* Generate left bidiagonalizing vectors in WORK(IU) */ |
| 20060 | /* (Workspace: need 2*N*N+4*N, prefer 2*N*N+3*N+N*NB) */ |
| 20061 | |
| 20062 | i__2 = *lwork - iwork + 1; |
| 20063 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("Q", n, n, n, &work[iu], &ldwrku, &work[itauq] |
| 20064 | , &work[iwork], &i__2, &ierr); |
| 20065 | |
| 20066 | /* Generate right bidiagonalizing vectors in WORK(IR) */ |
| 20067 | /* (Workspace: need 2*N*N+4*N-1, */ |
| 20068 | /* prefer 2*N*N+3*N+(N-1)*NB) */ |
| 20069 | |
| 20070 | i__2 = *lwork - iwork + 1; |
| 20071 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("P", n, n, n, &work[ir], &ldwrkr, &work[itaup] |
| 20072 | , &work[iwork], &i__2, &ierr); |
| 20073 | iwork = ie + *n; |
| 20074 | |
| 20075 | /* Perform bidiagonal QR iteration, computing left */ |
| 20076 | /* singular vectors of R in WORK(IU) and computing */ |
| 20077 | /* right singular vectors of R in WORK(IR) */ |
| 20078 | /* (Workspace: need 2*N*N+BDSPAC) */ |
| 20079 | |
| 20080 | dbdsqr_cxx . . $ dbdsqr_(d6d10c27a7b3c412).("U", n, n, n, &c__0, &s[1], &work[ie], &work[ |
| 20081 | ir], &ldwrkr, &work[iu], &ldwrku, dum, &c__1, |
| 20082 | &work[iwork], info); |
| 20083 | |
| 20084 | /* Multiply Q in U by left singular vectors of R in */ |
| 20085 | /* WORK(IU), storing result in A */ |
| 20086 | /* (Workspace: need N*N) */ |
| 20087 | |
| 20088 | dgemm_cxx . . $ dgemm_(7f9a15c7502022ea).("N", "N", m, n, n, &c_b443, &u[u_offset], ldu, |
| 20089 | &work[iu], &ldwrku, &c_b421, &a[a_offset], |
| 20090 | lda); |
| 20091 | |
| 20092 | /* Copy left singular vectors of A from A to U */ |
| 20093 | |
| 20094 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("F", m, n, &a[a_offset], lda, &u[u_offset], |
| 20095 | ldu); |
| 20096 | |
| 20097 | /* Copy right singular vectors of R from WORK(IR) to A */ |
| 20098 | |
| 20099 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("F", n, n, &work[ir], &ldwrkr, &a[a_offset], |
| 20100 | lda); |
| 20101 | |
| 20102 | } else { |
| 20103 | |
| 20104 | /* Insufficient workspace for a fast algorithm */ |
| 20105 | |
| 20106 | itau = 1; |
| 20107 | iwork = itau + *n; |
| 20108 | |
| 20109 | /* Compute A=Q*R, copying result to U */ |
| 20110 | /* (Workspace: need 2*N, prefer N+N*NB) */ |
| 20111 | |
| 20112 | i__2 = *lwork - iwork + 1; |
| 20113 | dgeqrf_cxx . . $ dgeqrf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[itau], &work[ |
| 20114 | iwork], &i__2, &ierr); |
| 20115 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("L", m, n, &a[a_offset], lda, &u[u_offset], |
| 20116 | ldu); |
| 20117 | |
| 20118 | /* Generate Q in U */ |
| 20119 | /* (Workspace: need N+M, prefer N+M*NB) */ |
| 20120 | |
| 20121 | i__2 = *lwork - iwork + 1; |
| 20122 | dorgqr_cxx . . $ dorgqr_(424524679a238630).(m, m, n, &u[u_offset], ldu, &work[itau], & |
| 20123 | work[iwork], &i__2, &ierr); |
| 20124 | ie = itau; |
| 20125 | itauq = ie + *n; |
| 20126 | itaup = itauq + *n; |
| 20127 | iwork = itaup + *n; |
| 20128 | |
| 20129 | /* Zero out below R in A */ |
| 20130 | |
| 20131 | i__2 = *n - 1; |
| 20132 | i__3 = *n - 1; |
| 20133 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("L", &i__2, &i__3, &c_b421, &c_b421, &a[ |
| 20134 | a_dim1 + 2], lda); |
| 20135 | |
| 20136 | /* Bidiagonalize R in A */ |
| 20137 | /* (Workspace: need 4*N, prefer 3*N+2*N*NB) */ |
| 20138 | |
| 20139 | i__2 = *lwork - iwork + 1; |
| 20140 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(n, n, &a[a_offset], lda, &s[1], &work[ie], & |
| 20141 | work[itauq], &work[itaup], &work[iwork], & |
| 20142 | i__2, &ierr); |
| 20143 | |
| 20144 | /* Multiply Q in U by left bidiagonalizing vectors */ |
| 20145 | /* in A */ |
| 20146 | /* (Workspace: need 3*N+M, prefer 3*N+M*NB) */ |
| 20147 | |
| 20148 | i__2 = *lwork - iwork + 1; |
| 20149 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("Q", "R", "N", m, n, n, &a[a_offset], lda, & |
| 20150 | work[itauq], &u[u_offset], ldu, &work[iwork], |
| 20151 | &i__2, &ierr) |
| 20152 | ; |
| 20153 | |
| 20154 | /* Generate right bidiagonalizing vectors in A */ |
| 20155 | /* (Workspace: need 4*N-1, prefer 3*N+(N-1)*NB) */ |
| 20156 | |
| 20157 | i__2 = *lwork - iwork + 1; |
| 20158 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("P", n, n, n, &a[a_offset], lda, &work[itaup], |
| 20159 | &work[iwork], &i__2, &ierr); |
| 20160 | iwork = ie + *n; |
| 20161 | |
| 20162 | /* Perform bidiagonal QR iteration, computing left */ |
| 20163 | /* singular vectors of A in U and computing right */ |
| 20164 | /* singular vectors of A in A */ |
| 20165 | /* (Workspace: need BDSPAC) */ |
| 20166 | |
| 20167 | dbdsqr_cxx . . $ dbdsqr_(d6d10c27a7b3c412).("U", n, n, m, &c__0, &s[1], &work[ie], &a[ |
| 20168 | a_offset], lda, &u[u_offset], ldu, dum, &c__1, |
| 20169 | &work[iwork], info); |
| 20170 | |
| 20171 | } |
| 20172 | |
| 20173 | } else if (wntvas) { |
| 20174 | |
| 20175 | /* Path 9 (M much larger than N, JOBU='A', JOBVT='S' */ |
| 20176 | /* or 'A') */ |
| 20177 | /* M left singular vectors to be computed in U and */ |
| 20178 | /* N right singular vectors to be computed in VT */ |
| 20179 | |
| 20180 | /* Computing MAX */ |
| 20181 | i__2 = *n + *m, i__3 = *n << 2, i__2 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 20182 | if (*lwork >= *n * *n + stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,bdspac)) { |
| 20183 | |
| 20184 | /* Sufficient workspace for a fast algorithm */ |
| 20185 | |
| 20186 | iu = 1; |
| 20187 | if (*lwork >= wrkbl + *lda * *n) { |
| 20188 | |
| 20189 | /* WORK(IU) is LDA by N */ |
| 20190 | |
| 20191 | ldwrku = *lda; |
| 20192 | } else { |
| 20193 | |
| 20194 | /* WORK(IU) is N by N */ |
| 20195 | |
| 20196 | ldwrku = *n; |
| 20197 | } |
| 20198 | itau = iu + ldwrku * *n; |
| 20199 | iwork = itau + *n; |
| 20200 | |
| 20201 | /* Compute A=Q*R, copying result to U */ |
| 20202 | /* (Workspace: need N*N+2*N, prefer N*N+N+N*NB) */ |
| 20203 | |
| 20204 | i__2 = *lwork - iwork + 1; |
| 20205 | dgeqrf_cxx . . $ dgeqrf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[itau], &work[ |
| 20206 | iwork], &i__2, &ierr); |
| 20207 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("L", m, n, &a[a_offset], lda, &u[u_offset], |
| 20208 | ldu); |
| 20209 | |
| 20210 | /* Generate Q in U */ |
| 20211 | /* (Workspace: need N*N+N+M, prefer N*N+N+M*NB) */ |
| 20212 | |
| 20213 | i__2 = *lwork - iwork + 1; |
| 20214 | dorgqr_cxx . . $ dorgqr_(424524679a238630).(m, m, n, &u[u_offset], ldu, &work[itau], & |
| 20215 | work[iwork], &i__2, &ierr); |
| 20216 | |
| 20217 | /* Copy R to WORK(IU), zeroing out below it */ |
| 20218 | |
| 20219 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("U", n, n, &a[a_offset], lda, &work[iu], & |
| 20220 | ldwrku); |
| 20221 | i__2 = *n - 1; |
| 20222 | i__3 = *n - 1; |
| 20223 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("L", &i__2, &i__3, &c_b421, &c_b421, &work[iu |
| 20224 | + 1], &ldwrku); |
| 20225 | ie = itau; |
| 20226 | itauq = ie + *n; |
| 20227 | itaup = itauq + *n; |
| 20228 | iwork = itaup + *n; |
| 20229 | |
| 20230 | /* Bidiagonalize R in WORK(IU), copying result to VT */ |
| 20231 | /* (Workspace: need N*N+4*N, prefer N*N+3*N+2*N*NB) */ |
| 20232 | |
| 20233 | i__2 = *lwork - iwork + 1; |
| 20234 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(n, n, &work[iu], &ldwrku, &s[1], &work[ie], & |
| 20235 | work[itauq], &work[itaup], &work[iwork], & |
| 20236 | i__2, &ierr); |
| 20237 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("U", n, n, &work[iu], &ldwrku, &vt[vt_offset], |
| 20238 | ldvt); |
| 20239 | |
| 20240 | /* Generate left bidiagonalizing vectors in WORK(IU) */ |
| 20241 | /* (Workspace: need N*N+4*N, prefer N*N+3*N+N*NB) */ |
| 20242 | |
| 20243 | i__2 = *lwork - iwork + 1; |
| 20244 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("Q", n, n, n, &work[iu], &ldwrku, &work[itauq] |
| 20245 | , &work[iwork], &i__2, &ierr); |
| 20246 | |
| 20247 | /* Generate right bidiagonalizing vectors in VT */ |
| 20248 | /* (Workspace: need N*N+4*N-1, */ |
| 20249 | /* prefer N*N+3*N+(N-1)*NB) */ |
| 20250 | |
| 20251 | i__2 = *lwork - iwork + 1; |
| 20252 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("P", n, n, n, &vt[vt_offset], ldvt, &work[ |
| 20253 | itaup], &work[iwork], &i__2, &ierr) |
| 20254 | ; |
| 20255 | iwork = ie + *n; |
| 20256 | |
| 20257 | /* Perform bidiagonal QR iteration, computing left */ |
| 20258 | /* singular vectors of R in WORK(IU) and computing */ |
| 20259 | /* right singular vectors of R in VT */ |
| 20260 | /* (Workspace: need N*N+BDSPAC) */ |
| 20261 | |
| 20262 | dbdsqr_cxx . . $ dbdsqr_(d6d10c27a7b3c412).("U", n, n, n, &c__0, &s[1], &work[ie], &vt[ |
| 20263 | vt_offset], ldvt, &work[iu], &ldwrku, dum, & |
| 20264 | c__1, &work[iwork], info); |
| 20265 | |
| 20266 | /* Multiply Q in U by left singular vectors of R in */ |
| 20267 | /* WORK(IU), storing result in A */ |
| 20268 | /* (Workspace: need N*N) */ |
| 20269 | |
| 20270 | dgemm_cxx . . $ dgemm_(7f9a15c7502022ea).("N", "N", m, n, n, &c_b443, &u[u_offset], ldu, |
| 20271 | &work[iu], &ldwrku, &c_b421, &a[a_offset], |
| 20272 | lda); |
| 20273 | |
| 20274 | /* Copy left singular vectors of A from A to U */ |
| 20275 | |
| 20276 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("F", m, n, &a[a_offset], lda, &u[u_offset], |
| 20277 | ldu); |
| 20278 | |
| 20279 | } else { |
| 20280 | |
| 20281 | /* Insufficient workspace for a fast algorithm */ |
| 20282 | |
| 20283 | itau = 1; |
| 20284 | iwork = itau + *n; |
| 20285 | |
| 20286 | /* Compute A=Q*R, copying result to U */ |
| 20287 | /* (Workspace: need 2*N, prefer N+N*NB) */ |
| 20288 | |
| 20289 | i__2 = *lwork - iwork + 1; |
| 20290 | dgeqrf_cxx . . $ dgeqrf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[itau], &work[ |
| 20291 | iwork], &i__2, &ierr); |
| 20292 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("L", m, n, &a[a_offset], lda, &u[u_offset], |
| 20293 | ldu); |
| 20294 | |
| 20295 | /* Generate Q in U */ |
| 20296 | /* (Workspace: need N+M, prefer N+M*NB) */ |
| 20297 | |
| 20298 | i__2 = *lwork - iwork + 1; |
| 20299 | dorgqr_cxx . . $ dorgqr_(424524679a238630).(m, m, n, &u[u_offset], ldu, &work[itau], & |
| 20300 | work[iwork], &i__2, &ierr); |
| 20301 | |
| 20302 | /* Copy R from A to VT, zeroing out below it */ |
| 20303 | |
| 20304 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("U", n, n, &a[a_offset], lda, &vt[vt_offset], |
| 20305 | ldvt); |
| 20306 | if (*n > 1) { |
| 20307 | i__2 = *n - 1; |
| 20308 | i__3 = *n - 1; |
| 20309 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("L", &i__2, &i__3, &c_b421, &c_b421, &vt[ |
| 20310 | vt_dim1 + 2], ldvt); |
| 20311 | } |
| 20312 | ie = itau; |
| 20313 | itauq = ie + *n; |
| 20314 | itaup = itauq + *n; |
| 20315 | iwork = itaup + *n; |
| 20316 | |
| 20317 | /* Bidiagonalize R in VT */ |
| 20318 | /* (Workspace: need 4*N, prefer 3*N+2*N*NB) */ |
| 20319 | |
| 20320 | i__2 = *lwork - iwork + 1; |
| 20321 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(n, n, &vt[vt_offset], ldvt, &s[1], &work[ie], |
| 20322 | &work[itauq], &work[itaup], &work[iwork], & |
| 20323 | i__2, &ierr); |
| 20324 | |
| 20325 | /* Multiply Q in U by left bidiagonalizing vectors */ |
| 20326 | /* in VT */ |
| 20327 | /* (Workspace: need 3*N+M, prefer 3*N+M*NB) */ |
| 20328 | |
| 20329 | i__2 = *lwork - iwork + 1; |
| 20330 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("Q", "R", "N", m, n, n, &vt[vt_offset], ldvt, |
| 20331 | &work[itauq], &u[u_offset], ldu, &work[iwork], |
| 20332 | &i__2, &ierr); |
| 20333 | |
| 20334 | /* Generate right bidiagonalizing vectors in VT */ |
| 20335 | /* (Workspace: need 4*N-1, prefer 3*N+(N-1)*NB) */ |
| 20336 | |
| 20337 | i__2 = *lwork - iwork + 1; |
| 20338 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("P", n, n, n, &vt[vt_offset], ldvt, &work[ |
| 20339 | itaup], &work[iwork], &i__2, &ierr) |
| 20340 | ; |
| 20341 | iwork = ie + *n; |
| 20342 | |
| 20343 | /* Perform bidiagonal QR iteration, computing left */ |
| 20344 | /* singular vectors of A in U and computing right */ |
| 20345 | /* singular vectors of A in VT */ |
| 20346 | /* (Workspace: need BDSPAC) */ |
| 20347 | |
| 20348 | dbdsqr_cxx . . $ dbdsqr_(d6d10c27a7b3c412).("U", n, n, m, &c__0, &s[1], &work[ie], &vt[ |
| 20349 | vt_offset], ldvt, &u[u_offset], ldu, dum, & |
| 20350 | c__1, &work[iwork], info); |
| 20351 | |
| 20352 | } |
| 20353 | |
| 20354 | } |
| 20355 | |
| 20356 | } |
| 20357 | |
| 20358 | } else { |
| 20359 | |
| 20360 | /* M .LT. MNTHR */ |
| 20361 | |
| 20362 | /* Path 10 (M at least N, but not much larger) */ |
| 20363 | /* Reduce to bidiagonal form without QR decomposition */ |
| 20364 | |
| 20365 | ie = 1; |
| 20366 | itauq = ie + *n; |
| 20367 | itaup = itauq + *n; |
| 20368 | iwork = itaup + *n; |
| 20369 | |
| 20370 | /* Bidiagonalize A */ |
| 20371 | /* (Workspace: need 3*N+M, prefer 3*N+(M+N)*NB) */ |
| 20372 | |
| 20373 | i__2 = *lwork - iwork + 1; |
| 20374 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(m, n, &a[a_offset], lda, &s[1], &work[ie], &work[itauq], & |
| 20375 | work[itaup], &work[iwork], &i__2, &ierr); |
| 20376 | if (wntuas) { |
| 20377 | |
| 20378 | /* If left singular vectors desired in U, copy result to U */ |
| 20379 | /* and generate left bidiagonalizing vectors in U */ |
| 20380 | /* (Workspace: need 3*N+NCU, prefer 3*N+NCU*NB) */ |
| 20381 | |
| 20382 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("L", m, n, &a[a_offset], lda, &u[u_offset], ldu); |
| 20383 | if (wntus) { |
| 20384 | ncu = *n; |
| 20385 | } |
| 20386 | if (wntua) { |
| 20387 | ncu = *m; |
| 20388 | } |
| 20389 | i__2 = *lwork - iwork + 1; |
| 20390 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("Q", m, &ncu, n, &u[u_offset], ldu, &work[itauq], & |
| 20391 | work[iwork], &i__2, &ierr); |
| 20392 | } |
| 20393 | if (wntvas) { |
| 20394 | |
| 20395 | /* If right singular vectors desired in VT, copy result to */ |
| 20396 | /* VT and generate right bidiagonalizing vectors in VT */ |
| 20397 | /* (Workspace: need 4*N-1, prefer 3*N+(N-1)*NB) */ |
| 20398 | |
| 20399 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("U", n, n, &a[a_offset], lda, &vt[vt_offset], ldvt); |
| 20400 | i__2 = *lwork - iwork + 1; |
| 20401 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("P", n, n, n, &vt[vt_offset], ldvt, &work[itaup], & |
| 20402 | work[iwork], &i__2, &ierr); |
| 20403 | } |
| 20404 | if (wntuo) { |
| 20405 | |
| 20406 | /* If left singular vectors desired in A, generate left */ |
| 20407 | /* bidiagonalizing vectors in A */ |
| 20408 | /* (Workspace: need 4*N, prefer 3*N+N*NB) */ |
| 20409 | |
| 20410 | i__2 = *lwork - iwork + 1; |
| 20411 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("Q", m, n, n, &a[a_offset], lda, &work[itauq], &work[ |
| 20412 | iwork], &i__2, &ierr); |
| 20413 | } |
| 20414 | if (wntvo) { |
| 20415 | |
| 20416 | /* If right singular vectors desired in A, generate right */ |
| 20417 | /* bidiagonalizing vectors in A */ |
| 20418 | /* (Workspace: need 4*N-1, prefer 3*N+(N-1)*NB) */ |
| 20419 | |
| 20420 | i__2 = *lwork - iwork + 1; |
| 20421 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("P", n, n, n, &a[a_offset], lda, &work[itaup], &work[ |
| 20422 | iwork], &i__2, &ierr); |
| 20423 | } |
| 20424 | iwork = ie + *n; |
| 20425 | if (wntuas || wntuo) { |
| 20426 | nru = *m; |
| 20427 | } |
| 20428 | if (wntun) { |
| 20429 | nru = 0; |
| 20430 | } |
| 20431 | if (wntvas || wntvo) { |
| 20432 | ncvt = *n; |
| 20433 | } |
| 20434 | if (wntvn) { |
| 20435 | ncvt = 0; |
| 20436 | } |
| 20437 | if (! wntuo && ! wntvo) { |
| 20438 | |
| 20439 | /* Perform bidiagonal QR iteration, if desired, computing */ |
| 20440 | /* left singular vectors in U and computing right singular */ |
| 20441 | /* vectors in VT */ |
| 20442 | /* (Workspace: need BDSPAC) */ |
| 20443 | |
| 20444 | dbdsqr_cxx . . $ dbdsqr_(d6d10c27a7b3c412).("U", n, &ncvt, &nru, &c__0, &s[1], &work[ie], &vt[ |
| 20445 | vt_offset], ldvt, &u[u_offset], ldu, dum, &c__1, & |
| 20446 | work[iwork], info); |
| 20447 | } else if (! wntuo && wntvo) { |
| 20448 | |
| 20449 | /* Perform bidiagonal QR iteration, if desired, computing */ |
| 20450 | /* left singular vectors in U and computing right singular */ |
| 20451 | /* vectors in A */ |
| 20452 | /* (Workspace: need BDSPAC) */ |
| 20453 | |
| 20454 | dbdsqr_cxx . . $ dbdsqr_(d6d10c27a7b3c412).("U", n, &ncvt, &nru, &c__0, &s[1], &work[ie], &a[ |
| 20455 | a_offset], lda, &u[u_offset], ldu, dum, &c__1, &work[ |
| 20456 | iwork], info); |
| 20457 | } else { |
| 20458 | |
| 20459 | /* Perform bidiagonal QR iteration, if desired, computing */ |
| 20460 | /* left singular vectors in A and computing right singular */ |
| 20461 | /* vectors in VT */ |
| 20462 | /* (Workspace: need BDSPAC) */ |
| 20463 | |
| 20464 | dbdsqr_cxx . . $ dbdsqr_(d6d10c27a7b3c412).("U", n, &ncvt, &nru, &c__0, &s[1], &work[ie], &vt[ |
| 20465 | vt_offset], ldvt, &a[a_offset], lda, dum, &c__1, & |
| 20466 | work[iwork], info); |
| 20467 | } |
| 20468 | |
| 20469 | } |
| 20470 | |
| 20471 | } else { |
| 20472 | |
| 20473 | /* A has more columns than rows. If A has sufficiently more */ |
| 20474 | /* columns than rows, first reduce using the LQ decomposition (if */ |
| 20475 | /* sufficient workspace available) */ |
| 20476 | |
| 20477 | if (*n >= mnthr) { |
| 20478 | |
| 20479 | if (wntvn) { |
| 20480 | |
| 20481 | /* Path 1t(N much larger than M, JOBVT='N') */ |
| 20482 | /* No right singular vectors to be computed */ |
| 20483 | |
| 20484 | itau = 1; |
| 20485 | iwork = itau + *m; |
| 20486 | |
| 20487 | /* Compute A=L*Q */ |
| 20488 | /* (Workspace: need 2*M, prefer M+M*NB) */ |
| 20489 | |
| 20490 | i__2 = *lwork - iwork + 1; |
| 20491 | dgelqf_cxx . . $ dgelqf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[itau], &work[iwork], & |
| 20492 | i__2, &ierr); |
| 20493 | |
| 20494 | /* Zero out above L */ |
| 20495 | |
| 20496 | i__2 = *m - 1; |
| 20497 | i__3 = *m - 1; |
| 20498 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("U", &i__2, &i__3, &c_b421, &c_b421, &a[(a_dim1 << 1) |
| 20499 | + 1], lda); |
| 20500 | ie = 1; |
| 20501 | itauq = ie + *m; |
| 20502 | itaup = itauq + *m; |
| 20503 | iwork = itaup + *m; |
| 20504 | |
| 20505 | /* Bidiagonalize L in A */ |
| 20506 | /* (Workspace: need 4*M, prefer 3*M+2*M*NB) */ |
| 20507 | |
| 20508 | i__2 = *lwork - iwork + 1; |
| 20509 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(m, m, &a[a_offset], lda, &s[1], &work[ie], &work[ |
| 20510 | itauq], &work[itaup], &work[iwork], &i__2, &ierr); |
| 20511 | if (wntuo || wntuas) { |
| 20512 | |
| 20513 | /* If left singular vectors desired, generate Q */ |
| 20514 | /* (Workspace: need 4*M, prefer 3*M+M*NB) */ |
| 20515 | |
| 20516 | i__2 = *lwork - iwork + 1; |
| 20517 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("Q", m, m, m, &a[a_offset], lda, &work[itauq], & |
| 20518 | work[iwork], &i__2, &ierr); |
| 20519 | } |
| 20520 | iwork = ie + *m; |
| 20521 | nru = 0; |
| 20522 | if (wntuo || wntuas) { |
| 20523 | nru = *m; |
| 20524 | } |
| 20525 | |
| 20526 | /* Perform bidiagonal QR iteration, computing left singular */ |
| 20527 | /* vectors of A in A if desired */ |
| 20528 | /* (Workspace: need BDSPAC) */ |
| 20529 | |
| 20530 | dbdsqr_cxx . . $ dbdsqr_(d6d10c27a7b3c412).("U", m, &c__0, &nru, &c__0, &s[1], &work[ie], dum, & |
| 20531 | c__1, &a[a_offset], lda, dum, &c__1, &work[iwork], |
| 20532 | info); |
| 20533 | |
| 20534 | /* If left singular vectors desired in U, copy them there */ |
| 20535 | |
| 20536 | if (wntuas) { |
| 20537 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("F", m, m, &a[a_offset], lda, &u[u_offset], ldu); |
| 20538 | } |
| 20539 | |
| 20540 | } else if (wntvo && wntun) { |
| 20541 | |
| 20542 | /* Path 2t(N much larger than M, JOBU='N', JOBVT='O') */ |
| 20543 | /* M right singular vectors to be overwritten on A and */ |
| 20544 | /* no left singular vectors to be computed */ |
| 20545 | |
| 20546 | /* Computing MAX */ |
| 20547 | i__2 = *m << 2; |
| 20548 | if (*lwork >= *m * *m + stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,bdspac)) { |
| 20549 | |
| 20550 | /* Sufficient workspace for a fast algorithm */ |
| 20551 | |
| 20552 | ir = 1; |
| 20553 | /* Computing MAX */ |
| 20554 | i__2 = wrkbl, i__3 = *lda * *n + *m; |
| 20555 | if (*lwork >= stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3) + *lda * *m) { |
| 20556 | |
| 20557 | /* WORK(IU) is LDA by N and WORK(IR) is LDA by M */ |
| 20558 | |
| 20559 | ldwrku = *lda; |
| 20560 | chunk = *n; |
| 20561 | ldwrkr = *lda; |
| 20562 | } else /* if(complicated condition) */ { |
| 20563 | /* Computing MAX */ |
| 20564 | i__2 = wrkbl, i__3 = *lda * *n + *m; |
| 20565 | if (*lwork >= stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3) + *m * *m) { |
| 20566 | |
| 20567 | /* WORK(IU) is LDA by N and WORK(IR) is M by M */ |
| 20568 | |
| 20569 | ldwrku = *lda; |
| 20570 | chunk = *n; |
| 20571 | ldwrkr = *m; |
| 20572 | } else { |
| 20573 | |
| 20574 | /* WORK(IU) is M by CHUNK and WORK(IR) is M by M */ |
| 20575 | |
| 20576 | ldwrku = *m; |
| 20577 | chunk = (*lwork - *m * *m - *m) / *m; |
| 20578 | ldwrkr = *m; |
| 20579 | } |
| 20580 | } |
| 20581 | itau = ir + ldwrkr * *m; |
| 20582 | iwork = itau + *m; |
| 20583 | |
| 20584 | /* Compute A=L*Q */ |
| 20585 | /* (Workspace: need M*M+2*M, prefer M*M+M+M*NB) */ |
| 20586 | |
| 20587 | i__2 = *lwork - iwork + 1; |
| 20588 | dgelqf_cxx . . $ dgelqf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[itau], &work[iwork] |
| 20589 | , &i__2, &ierr); |
| 20590 | |
| 20591 | /* Copy L to WORK(IR) and zero out above it */ |
| 20592 | |
| 20593 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("L", m, m, &a[a_offset], lda, &work[ir], &ldwrkr); |
| 20594 | i__2 = *m - 1; |
| 20595 | i__3 = *m - 1; |
| 20596 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("U", &i__2, &i__3, &c_b421, &c_b421, &work[ir + |
| 20597 | ldwrkr], &ldwrkr); |
| 20598 | |
| 20599 | /* Generate Q in A */ |
| 20600 | /* (Workspace: need M*M+2*M, prefer M*M+M+M*NB) */ |
| 20601 | |
| 20602 | i__2 = *lwork - iwork + 1; |
| 20603 | dorglq_cxx . . $ dorglq_(424524679a238630).(m, n, m, &a[a_offset], lda, &work[itau], &work[ |
| 20604 | iwork], &i__2, &ierr); |
| 20605 | ie = itau; |
| 20606 | itauq = ie + *m; |
| 20607 | itaup = itauq + *m; |
| 20608 | iwork = itaup + *m; |
| 20609 | |
| 20610 | /* Bidiagonalize L in WORK(IR) */ |
| 20611 | /* (Workspace: need M*M+4*M, prefer M*M+3*M+2*M*NB) */ |
| 20612 | |
| 20613 | i__2 = *lwork - iwork + 1; |
| 20614 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(m, m, &work[ir], &ldwrkr, &s[1], &work[ie], &work[ |
| 20615 | itauq], &work[itaup], &work[iwork], &i__2, &ierr); |
| 20616 | |
| 20617 | /* Generate right vectors bidiagonalizing L */ |
| 20618 | /* (Workspace: need M*M+4*M-1, prefer M*M+3*M+(M-1)*NB) */ |
| 20619 | |
| 20620 | i__2 = *lwork - iwork + 1; |
| 20621 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("P", m, m, m, &work[ir], &ldwrkr, &work[itaup], & |
| 20622 | work[iwork], &i__2, &ierr); |
| 20623 | iwork = ie + *m; |
| 20624 | |
| 20625 | /* Perform bidiagonal QR iteration, computing right */ |
| 20626 | /* singular vectors of L in WORK(IR) */ |
| 20627 | /* (Workspace: need M*M+BDSPAC) */ |
| 20628 | |
| 20629 | dbdsqr_cxx . . $ dbdsqr_(d6d10c27a7b3c412).("U", m, m, &c__0, &c__0, &s[1], &work[ie], &work[ |
| 20630 | ir], &ldwrkr, dum, &c__1, dum, &c__1, &work[iwork] |
| 20631 | , info); |
| 20632 | iu = ie + *m; |
| 20633 | |
| 20634 | /* Multiply right singular vectors of L in WORK(IR) by Q */ |
| 20635 | /* in A, storing result in WORK(IU) and copying to A */ |
| 20636 | /* (Workspace: need M*M+2*M, prefer M*M+M*N+M) */ |
| 20637 | |
| 20638 | i__2 = *n; |
| 20639 | i__3 = chunk; |
| 20640 | for (i__ = 1; i__3 < 0 ? i__ >= i__2 : i__ <= i__2; i__ += |
| 20641 | i__3) { |
| 20642 | /* Computing MIN */ |
| 20643 | i__4 = *n - i__ + 1; |
| 20644 | blk = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__4,chunk); |
| 20645 | dgemm_cxx . . $ dgemm_(7f9a15c7502022ea).("N", "N", m, &blk, m, &c_b443, &work[ir], & |
| 20646 | ldwrkr, &a[i__ * a_dim1 + 1], lda, &c_b421, & |
| 20647 | work[iu], &ldwrku); |
| 20648 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("F", m, &blk, &work[iu], &ldwrku, &a[i__ * |
| 20649 | a_dim1 + 1], lda); |
| 20650 | /* L30: */ |
| 20651 | } |
| 20652 | |
| 20653 | } else { |
| 20654 | |
| 20655 | /* Insufficient workspace for a fast algorithm */ |
| 20656 | |
| 20657 | ie = 1; |
| 20658 | itauq = ie + *m; |
| 20659 | itaup = itauq + *m; |
| 20660 | iwork = itaup + *m; |
| 20661 | |
| 20662 | /* Bidiagonalize A */ |
| 20663 | /* (Workspace: need 3*M+N, prefer 3*M+(M+N)*NB) */ |
| 20664 | |
| 20665 | i__3 = *lwork - iwork + 1; |
| 20666 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(m, n, &a[a_offset], lda, &s[1], &work[ie], &work[ |
| 20667 | itauq], &work[itaup], &work[iwork], &i__3, &ierr); |
| 20668 | |
| 20669 | /* Generate right vectors bidiagonalizing A */ |
| 20670 | /* (Workspace: need 4*M, prefer 3*M+M*NB) */ |
| 20671 | |
| 20672 | i__3 = *lwork - iwork + 1; |
| 20673 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("P", m, n, m, &a[a_offset], lda, &work[itaup], & |
| 20674 | work[iwork], &i__3, &ierr); |
| 20675 | iwork = ie + *m; |
| 20676 | |
| 20677 | /* Perform bidiagonal QR iteration, computing right */ |
| 20678 | /* singular vectors of A in A */ |
| 20679 | /* (Workspace: need BDSPAC) */ |
| 20680 | |
| 20681 | dbdsqr_cxx . . $ dbdsqr_(d6d10c27a7b3c412).("L", m, n, &c__0, &c__0, &s[1], &work[ie], &a[ |
| 20682 | a_offset], lda, dum, &c__1, dum, &c__1, &work[ |
| 20683 | iwork], info); |
| 20684 | |
| 20685 | } |
| 20686 | |
| 20687 | } else if (wntvo && wntuas) { |
| 20688 | |
| 20689 | /* Path 3t(N much larger than M, JOBU='S' or 'A', JOBVT='O') */ |
| 20690 | /* M right singular vectors to be overwritten on A and */ |
| 20691 | /* M left singular vectors to be computed in U */ |
| 20692 | |
| 20693 | /* Computing MAX */ |
| 20694 | i__3 = *m << 2; |
| 20695 | if (*lwork >= *m * *m + stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__3,bdspac)) { |
| 20696 | |
| 20697 | /* Sufficient workspace for a fast algorithm */ |
| 20698 | |
| 20699 | ir = 1; |
| 20700 | /* Computing MAX */ |
| 20701 | i__3 = wrkbl, i__2 = *lda * *n + *m; |
| 20702 | if (*lwork >= stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__3,i__2) + *lda * *m) { |
| 20703 | |
| 20704 | /* WORK(IU) is LDA by N and WORK(IR) is LDA by M */ |
| 20705 | |
| 20706 | ldwrku = *lda; |
| 20707 | chunk = *n; |
| 20708 | ldwrkr = *lda; |
| 20709 | } else /* if(complicated condition) */ { |
| 20710 | /* Computing MAX */ |
| 20711 | i__3 = wrkbl, i__2 = *lda * *n + *m; |
| 20712 | if (*lwork >= stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__3,i__2) + *m * *m) { |
| 20713 | |
| 20714 | /* WORK(IU) is LDA by N and WORK(IR) is M by M */ |
| 20715 | |
| 20716 | ldwrku = *lda; |
| 20717 | chunk = *n; |
| 20718 | ldwrkr = *m; |
| 20719 | } else { |
| 20720 | |
| 20721 | /* WORK(IU) is M by CHUNK and WORK(IR) is M by M */ |
| 20722 | |
| 20723 | ldwrku = *m; |
| 20724 | chunk = (*lwork - *m * *m - *m) / *m; |
| 20725 | ldwrkr = *m; |
| 20726 | } |
| 20727 | } |
| 20728 | itau = ir + ldwrkr * *m; |
| 20729 | iwork = itau + *m; |
| 20730 | |
| 20731 | /* Compute A=L*Q */ |
| 20732 | /* (Workspace: need M*M+2*M, prefer M*M+M+M*NB) */ |
| 20733 | |
| 20734 | i__3 = *lwork - iwork + 1; |
| 20735 | dgelqf_cxx . . $ dgelqf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[itau], &work[iwork] |
| 20736 | , &i__3, &ierr); |
| 20737 | |
| 20738 | /* Copy L to U, zeroing about above it */ |
| 20739 | |
| 20740 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("L", m, m, &a[a_offset], lda, &u[u_offset], ldu); |
| 20741 | i__3 = *m - 1; |
| 20742 | i__2 = *m - 1; |
| 20743 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("U", &i__3, &i__2, &c_b421, &c_b421, &u[(u_dim1 << |
| 20744 | 1) + 1], ldu); |
| 20745 | |
| 20746 | /* Generate Q in A */ |
| 20747 | /* (Workspace: need M*M+2*M, prefer M*M+M+M*NB) */ |
| 20748 | |
| 20749 | i__3 = *lwork - iwork + 1; |
| 20750 | dorglq_cxx . . $ dorglq_(424524679a238630).(m, n, m, &a[a_offset], lda, &work[itau], &work[ |
| 20751 | iwork], &i__3, &ierr); |
| 20752 | ie = itau; |
| 20753 | itauq = ie + *m; |
| 20754 | itaup = itauq + *m; |
| 20755 | iwork = itaup + *m; |
| 20756 | |
| 20757 | /* Bidiagonalize L in U, copying result to WORK(IR) */ |
| 20758 | /* (Workspace: need M*M+4*M, prefer M*M+3*M+2*M*NB) */ |
| 20759 | |
| 20760 | i__3 = *lwork - iwork + 1; |
| 20761 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(m, m, &u[u_offset], ldu, &s[1], &work[ie], &work[ |
| 20762 | itauq], &work[itaup], &work[iwork], &i__3, &ierr); |
| 20763 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("U", m, m, &u[u_offset], ldu, &work[ir], &ldwrkr); |
| 20764 | |
| 20765 | /* Generate right vectors bidiagonalizing L in WORK(IR) */ |
| 20766 | /* (Workspace: need M*M+4*M-1, prefer M*M+3*M+(M-1)*NB) */ |
| 20767 | |
| 20768 | i__3 = *lwork - iwork + 1; |
| 20769 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("P", m, m, m, &work[ir], &ldwrkr, &work[itaup], & |
| 20770 | work[iwork], &i__3, &ierr); |
| 20771 | |
| 20772 | /* Generate left vectors bidiagonalizing L in U */ |
| 20773 | /* (Workspace: need M*M+4*M, prefer M*M+3*M+M*NB) */ |
| 20774 | |
| 20775 | i__3 = *lwork - iwork + 1; |
| 20776 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("Q", m, m, m, &u[u_offset], ldu, &work[itauq], & |
| 20777 | work[iwork], &i__3, &ierr); |
| 20778 | iwork = ie + *m; |
| 20779 | |
| 20780 | /* Perform bidiagonal QR iteration, computing left */ |
| 20781 | /* singular vectors of L in U, and computing right */ |
| 20782 | /* singular vectors of L in WORK(IR) */ |
| 20783 | /* (Workspace: need M*M+BDSPAC) */ |
| 20784 | |
| 20785 | dbdsqr_cxx . . $ dbdsqr_(d6d10c27a7b3c412).("U", m, m, m, &c__0, &s[1], &work[ie], &work[ir], |
| 20786 | &ldwrkr, &u[u_offset], ldu, dum, &c__1, &work[ |
| 20787 | iwork], info); |
| 20788 | iu = ie + *m; |
| 20789 | |
| 20790 | /* Multiply right singular vectors of L in WORK(IR) by Q */ |
| 20791 | /* in A, storing result in WORK(IU) and copying to A */ |
| 20792 | /* (Workspace: need M*M+2*M, prefer M*M+M*N+M)) */ |
| 20793 | |
| 20794 | i__3 = *n; |
| 20795 | i__2 = chunk; |
| 20796 | for (i__ = 1; i__2 < 0 ? i__ >= i__3 : i__ <= i__3; i__ += |
| 20797 | i__2) { |
| 20798 | /* Computing MIN */ |
| 20799 | i__4 = *n - i__ + 1; |
| 20800 | blk = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__4,chunk); |
| 20801 | dgemm_cxx . . $ dgemm_(7f9a15c7502022ea).("N", "N", m, &blk, m, &c_b443, &work[ir], & |
| 20802 | ldwrkr, &a[i__ * a_dim1 + 1], lda, &c_b421, & |
| 20803 | work[iu], &ldwrku); |
| 20804 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("F", m, &blk, &work[iu], &ldwrku, &a[i__ * |
| 20805 | a_dim1 + 1], lda); |
| 20806 | /* L40: */ |
| 20807 | } |
| 20808 | |
| 20809 | } else { |
| 20810 | |
| 20811 | /* Insufficient workspace for a fast algorithm */ |
| 20812 | |
| 20813 | itau = 1; |
| 20814 | iwork = itau + *m; |
| 20815 | |
| 20816 | /* Compute A=L*Q */ |
| 20817 | /* (Workspace: need 2*M, prefer M+M*NB) */ |
| 20818 | |
| 20819 | i__2 = *lwork - iwork + 1; |
| 20820 | dgelqf_cxx . . $ dgelqf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[itau], &work[iwork] |
| 20821 | , &i__2, &ierr); |
| 20822 | |
| 20823 | /* Copy L to U, zeroing out above it */ |
| 20824 | |
| 20825 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("L", m, m, &a[a_offset], lda, &u[u_offset], ldu); |
| 20826 | i__2 = *m - 1; |
| 20827 | i__3 = *m - 1; |
| 20828 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("U", &i__2, &i__3, &c_b421, &c_b421, &u[(u_dim1 << |
| 20829 | 1) + 1], ldu); |
| 20830 | |
| 20831 | /* Generate Q in A */ |
| 20832 | /* (Workspace: need 2*M, prefer M+M*NB) */ |
| 20833 | |
| 20834 | i__2 = *lwork - iwork + 1; |
| 20835 | dorglq_cxx . . $ dorglq_(424524679a238630).(m, n, m, &a[a_offset], lda, &work[itau], &work[ |
| 20836 | iwork], &i__2, &ierr); |
| 20837 | ie = itau; |
| 20838 | itauq = ie + *m; |
| 20839 | itaup = itauq + *m; |
| 20840 | iwork = itaup + *m; |
| 20841 | |
| 20842 | /* Bidiagonalize L in U */ |
| 20843 | /* (Workspace: need 4*M, prefer 3*M+2*M*NB) */ |
| 20844 | |
| 20845 | i__2 = *lwork - iwork + 1; |
| 20846 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(m, m, &u[u_offset], ldu, &s[1], &work[ie], &work[ |
| 20847 | itauq], &work[itaup], &work[iwork], &i__2, &ierr); |
| 20848 | |
| 20849 | /* Multiply right vectors bidiagonalizing L by Q in A */ |
| 20850 | /* (Workspace: need 3*M+N, prefer 3*M+N*NB) */ |
| 20851 | |
| 20852 | i__2 = *lwork - iwork + 1; |
| 20853 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("P", "L", "T", m, n, m, &u[u_offset], ldu, &work[ |
| 20854 | itaup], &a[a_offset], lda, &work[iwork], &i__2, & |
| 20855 | ierr); |
| 20856 | |
| 20857 | /* Generate left vectors bidiagonalizing L in U */ |
| 20858 | /* (Workspace: need 4*M, prefer 3*M+M*NB) */ |
| 20859 | |
| 20860 | i__2 = *lwork - iwork + 1; |
| 20861 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("Q", m, m, m, &u[u_offset], ldu, &work[itauq], & |
| 20862 | work[iwork], &i__2, &ierr); |
| 20863 | iwork = ie + *m; |
| 20864 | |
| 20865 | /* Perform bidiagonal QR iteration, computing left */ |
| 20866 | /* singular vectors of A in U and computing right */ |
| 20867 | /* singular vectors of A in A */ |
| 20868 | /* (Workspace: need BDSPAC) */ |
| 20869 | |
| 20870 | dbdsqr_cxx . . $ dbdsqr_(d6d10c27a7b3c412).("U", m, n, m, &c__0, &s[1], &work[ie], &a[ |
| 20871 | a_offset], lda, &u[u_offset], ldu, dum, &c__1, & |
| 20872 | work[iwork], info); |
| 20873 | |
| 20874 | } |
| 20875 | |
| 20876 | } else if (wntvs) { |
| 20877 | |
| 20878 | if (wntun) { |
| 20879 | |
| 20880 | /* Path 4t(N much larger than M, JOBU='N', JOBVT='S') */ |
| 20881 | /* M right singular vectors to be computed in VT and */ |
| 20882 | /* no left singular vectors to be computed */ |
| 20883 | |
| 20884 | /* Computing MAX */ |
| 20885 | i__2 = *m << 2; |
| 20886 | if (*lwork >= *m * *m + stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,bdspac)) { |
| 20887 | |
| 20888 | /* Sufficient workspace for a fast algorithm */ |
| 20889 | |
| 20890 | ir = 1; |
| 20891 | if (*lwork >= wrkbl + *lda * *m) { |
| 20892 | |
| 20893 | /* WORK(IR) is LDA by M */ |
| 20894 | |
| 20895 | ldwrkr = *lda; |
| 20896 | } else { |
| 20897 | |
| 20898 | /* WORK(IR) is M by M */ |
| 20899 | |
| 20900 | ldwrkr = *m; |
| 20901 | } |
| 20902 | itau = ir + ldwrkr * *m; |
| 20903 | iwork = itau + *m; |
| 20904 | |
| 20905 | /* Compute A=L*Q */ |
| 20906 | /* (Workspace: need M*M+2*M, prefer M*M+M+M*NB) */ |
| 20907 | |
| 20908 | i__2 = *lwork - iwork + 1; |
| 20909 | dgelqf_cxx . . $ dgelqf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[itau], &work[ |
| 20910 | iwork], &i__2, &ierr); |
| 20911 | |
| 20912 | /* Copy L to WORK(IR), zeroing out above it */ |
| 20913 | |
| 20914 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("L", m, m, &a[a_offset], lda, &work[ir], & |
| 20915 | ldwrkr); |
| 20916 | i__2 = *m - 1; |
| 20917 | i__3 = *m - 1; |
| 20918 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("U", &i__2, &i__3, &c_b421, &c_b421, &work[ir |
| 20919 | + ldwrkr], &ldwrkr); |
| 20920 | |
| 20921 | /* Generate Q in A */ |
| 20922 | /* (Workspace: need M*M+2*M, prefer M*M+M+M*NB) */ |
| 20923 | |
| 20924 | i__2 = *lwork - iwork + 1; |
| 20925 | dorglq_cxx . . $ dorglq_(424524679a238630).(m, n, m, &a[a_offset], lda, &work[itau], & |
| 20926 | work[iwork], &i__2, &ierr); |
| 20927 | ie = itau; |
| 20928 | itauq = ie + *m; |
| 20929 | itaup = itauq + *m; |
| 20930 | iwork = itaup + *m; |
| 20931 | |
| 20932 | /* Bidiagonalize L in WORK(IR) */ |
| 20933 | /* (Workspace: need M*M+4*M, prefer M*M+3*M+2*M*NB) */ |
| 20934 | |
| 20935 | i__2 = *lwork - iwork + 1; |
| 20936 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(m, m, &work[ir], &ldwrkr, &s[1], &work[ie], & |
| 20937 | work[itauq], &work[itaup], &work[iwork], & |
| 20938 | i__2, &ierr); |
| 20939 | |
| 20940 | /* Generate right vectors bidiagonalizing L in */ |
| 20941 | /* WORK(IR) */ |
| 20942 | /* (Workspace: need M*M+4*M, prefer M*M+3*M+(M-1)*NB) */ |
| 20943 | |
| 20944 | i__2 = *lwork - iwork + 1; |
| 20945 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("P", m, m, m, &work[ir], &ldwrkr, &work[itaup] |
| 20946 | , &work[iwork], &i__2, &ierr); |
| 20947 | iwork = ie + *m; |
| 20948 | |
| 20949 | /* Perform bidiagonal QR iteration, computing right */ |
| 20950 | /* singular vectors of L in WORK(IR) */ |
| 20951 | /* (Workspace: need M*M+BDSPAC) */ |
| 20952 | |
| 20953 | dbdsqr_cxx . . $ dbdsqr_(d6d10c27a7b3c412).("U", m, m, &c__0, &c__0, &s[1], &work[ie], & |
| 20954 | work[ir], &ldwrkr, dum, &c__1, dum, &c__1, & |
| 20955 | work[iwork], info); |
| 20956 | |
| 20957 | /* Multiply right singular vectors of L in WORK(IR) by */ |
| 20958 | /* Q in A, storing result in VT */ |
| 20959 | /* (Workspace: need M*M) */ |
| 20960 | |
| 20961 | dgemm_cxx . . $ dgemm_(7f9a15c7502022ea).("N", "N", m, n, m, &c_b443, &work[ir], &ldwrkr, |
| 20962 | &a[a_offset], lda, &c_b421, &vt[vt_offset], |
| 20963 | ldvt); |
| 20964 | |
| 20965 | } else { |
| 20966 | |
| 20967 | /* Insufficient workspace for a fast algorithm */ |
| 20968 | |
| 20969 | itau = 1; |
| 20970 | iwork = itau + *m; |
| 20971 | |
| 20972 | /* Compute A=L*Q */ |
| 20973 | /* (Workspace: need 2*M, prefer M+M*NB) */ |
| 20974 | |
| 20975 | i__2 = *lwork - iwork + 1; |
| 20976 | dgelqf_cxx . . $ dgelqf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[itau], &work[ |
| 20977 | iwork], &i__2, &ierr); |
| 20978 | |
| 20979 | /* Copy result to VT */ |
| 20980 | |
| 20981 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("U", m, n, &a[a_offset], lda, &vt[vt_offset], |
| 20982 | ldvt); |
| 20983 | |
| 20984 | /* Generate Q in VT */ |
| 20985 | /* (Workspace: need 2*M, prefer M+M*NB) */ |
| 20986 | |
| 20987 | i__2 = *lwork - iwork + 1; |
| 20988 | dorglq_cxx . . $ dorglq_(424524679a238630).(m, n, m, &vt[vt_offset], ldvt, &work[itau], & |
| 20989 | work[iwork], &i__2, &ierr); |
| 20990 | ie = itau; |
| 20991 | itauq = ie + *m; |
| 20992 | itaup = itauq + *m; |
| 20993 | iwork = itaup + *m; |
| 20994 | |
| 20995 | /* Zero out above L in A */ |
| 20996 | |
| 20997 | i__2 = *m - 1; |
| 20998 | i__3 = *m - 1; |
| 20999 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("U", &i__2, &i__3, &c_b421, &c_b421, &a[( |
| 21000 | a_dim1 << 1) + 1], lda); |
| 21001 | |
| 21002 | /* Bidiagonalize L in A */ |
| 21003 | /* (Workspace: need 4*M, prefer 3*M+2*M*NB) */ |
| 21004 | |
| 21005 | i__2 = *lwork - iwork + 1; |
| 21006 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(m, m, &a[a_offset], lda, &s[1], &work[ie], & |
| 21007 | work[itauq], &work[itaup], &work[iwork], & |
| 21008 | i__2, &ierr); |
| 21009 | |
| 21010 | /* Multiply right vectors bidiagonalizing L by Q in VT */ |
| 21011 | /* (Workspace: need 3*M+N, prefer 3*M+N*NB) */ |
| 21012 | |
| 21013 | i__2 = *lwork - iwork + 1; |
| 21014 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("P", "L", "T", m, n, m, &a[a_offset], lda, & |
| 21015 | work[itaup], &vt[vt_offset], ldvt, &work[ |
| 21016 | iwork], &i__2, &ierr); |
| 21017 | iwork = ie + *m; |
| 21018 | |
| 21019 | /* Perform bidiagonal QR iteration, computing right */ |
| 21020 | /* singular vectors of A in VT */ |
| 21021 | /* (Workspace: need BDSPAC) */ |
| 21022 | |
| 21023 | dbdsqr_cxx . . $ dbdsqr_(d6d10c27a7b3c412).("U", m, n, &c__0, &c__0, &s[1], &work[ie], & |
| 21024 | vt[vt_offset], ldvt, dum, &c__1, dum, &c__1, & |
| 21025 | work[iwork], info); |
| 21026 | |
| 21027 | } |
| 21028 | |
| 21029 | } else if (wntuo) { |
| 21030 | |
| 21031 | /* Path 5t(N much larger than M, JOBU='O', JOBVT='S') */ |
| 21032 | /* M right singular vectors to be computed in VT and */ |
| 21033 | /* M left singular vectors to be overwritten on A */ |
| 21034 | |
| 21035 | /* Computing MAX */ |
| 21036 | i__2 = *m << 2; |
| 21037 | if (*lwork >= (*m << 1) * *m + stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,bdspac)) { |
| 21038 | |
| 21039 | /* Sufficient workspace for a fast algorithm */ |
| 21040 | |
| 21041 | iu = 1; |
| 21042 | if (*lwork >= wrkbl + (*lda << 1) * *m) { |
| 21043 | |
| 21044 | /* WORK(IU) is LDA by M and WORK(IR) is LDA by M */ |
| 21045 | |
| 21046 | ldwrku = *lda; |
| 21047 | ir = iu + ldwrku * *m; |
| 21048 | ldwrkr = *lda; |
| 21049 | } else if (*lwork >= wrkbl + (*lda + *m) * *m) { |
| 21050 | |
| 21051 | /* WORK(IU) is LDA by M and WORK(IR) is M by M */ |
| 21052 | |
| 21053 | ldwrku = *lda; |
| 21054 | ir = iu + ldwrku * *m; |
| 21055 | ldwrkr = *m; |
| 21056 | } else { |
| 21057 | |
| 21058 | /* WORK(IU) is M by M and WORK(IR) is M by M */ |
| 21059 | |
| 21060 | ldwrku = *m; |
| 21061 | ir = iu + ldwrku * *m; |
| 21062 | ldwrkr = *m; |
| 21063 | } |
| 21064 | itau = ir + ldwrkr * *m; |
| 21065 | iwork = itau + *m; |
| 21066 | |
| 21067 | /* Compute A=L*Q */ |
| 21068 | /* (Workspace: need 2*M*M+2*M, prefer 2*M*M+M+M*NB) */ |
| 21069 | |
| 21070 | i__2 = *lwork - iwork + 1; |
| 21071 | dgelqf_cxx . . $ dgelqf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[itau], &work[ |
| 21072 | iwork], &i__2, &ierr); |
| 21073 | |
| 21074 | /* Copy L to WORK(IU), zeroing out below it */ |
| 21075 | |
| 21076 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("L", m, m, &a[a_offset], lda, &work[iu], & |
| 21077 | ldwrku); |
| 21078 | i__2 = *m - 1; |
| 21079 | i__3 = *m - 1; |
| 21080 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("U", &i__2, &i__3, &c_b421, &c_b421, &work[iu |
| 21081 | + ldwrku], &ldwrku); |
| 21082 | |
| 21083 | /* Generate Q in A */ |
| 21084 | /* (Workspace: need 2*M*M+2*M, prefer 2*M*M+M+M*NB) */ |
| 21085 | |
| 21086 | i__2 = *lwork - iwork + 1; |
| 21087 | dorglq_cxx . . $ dorglq_(424524679a238630).(m, n, m, &a[a_offset], lda, &work[itau], & |
| 21088 | work[iwork], &i__2, &ierr); |
| 21089 | ie = itau; |
| 21090 | itauq = ie + *m; |
| 21091 | itaup = itauq + *m; |
| 21092 | iwork = itaup + *m; |
| 21093 | |
| 21094 | /* Bidiagonalize L in WORK(IU), copying result to */ |
| 21095 | /* WORK(IR) */ |
| 21096 | /* (Workspace: need 2*M*M+4*M, */ |
| 21097 | /* prefer 2*M*M+3*M+2*M*NB) */ |
| 21098 | |
| 21099 | i__2 = *lwork - iwork + 1; |
| 21100 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(m, m, &work[iu], &ldwrku, &s[1], &work[ie], & |
| 21101 | work[itauq], &work[itaup], &work[iwork], & |
| 21102 | i__2, &ierr); |
| 21103 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("L", m, m, &work[iu], &ldwrku, &work[ir], & |
| 21104 | ldwrkr); |
| 21105 | |
| 21106 | /* Generate right bidiagonalizing vectors in WORK(IU) */ |
| 21107 | /* (Workspace: need 2*M*M+4*M-1, */ |
| 21108 | /* prefer 2*M*M+3*M+(M-1)*NB) */ |
| 21109 | |
| 21110 | i__2 = *lwork - iwork + 1; |
| 21111 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("P", m, m, m, &work[iu], &ldwrku, &work[itaup] |
| 21112 | , &work[iwork], &i__2, &ierr); |
| 21113 | |
| 21114 | /* Generate left bidiagonalizing vectors in WORK(IR) */ |
| 21115 | /* (Workspace: need 2*M*M+4*M, prefer 2*M*M+3*M+M*NB) */ |
| 21116 | |
| 21117 | i__2 = *lwork - iwork + 1; |
| 21118 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("Q", m, m, m, &work[ir], &ldwrkr, &work[itauq] |
| 21119 | , &work[iwork], &i__2, &ierr); |
| 21120 | iwork = ie + *m; |
| 21121 | |
| 21122 | /* Perform bidiagonal QR iteration, computing left */ |
| 21123 | /* singular vectors of L in WORK(IR) and computing */ |
| 21124 | /* right singular vectors of L in WORK(IU) */ |
| 21125 | /* (Workspace: need 2*M*M+BDSPAC) */ |
| 21126 | |
| 21127 | dbdsqr_cxx . . $ dbdsqr_(d6d10c27a7b3c412).("U", m, m, m, &c__0, &s[1], &work[ie], &work[ |
| 21128 | iu], &ldwrku, &work[ir], &ldwrkr, dum, &c__1, |
| 21129 | &work[iwork], info); |
| 21130 | |
| 21131 | /* Multiply right singular vectors of L in WORK(IU) by */ |
| 21132 | /* Q in A, storing result in VT */ |
| 21133 | /* (Workspace: need M*M) */ |
| 21134 | |
| 21135 | dgemm_cxx . . $ dgemm_(7f9a15c7502022ea).("N", "N", m, n, m, &c_b443, &work[iu], &ldwrku, |
| 21136 | &a[a_offset], lda, &c_b421, &vt[vt_offset], |
| 21137 | ldvt); |
| 21138 | |
| 21139 | /* Copy left singular vectors of L to A */ |
| 21140 | /* (Workspace: need M*M) */ |
| 21141 | |
| 21142 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("F", m, m, &work[ir], &ldwrkr, &a[a_offset], |
| 21143 | lda); |
| 21144 | |
| 21145 | } else { |
| 21146 | |
| 21147 | /* Insufficient workspace for a fast algorithm */ |
| 21148 | |
| 21149 | itau = 1; |
| 21150 | iwork = itau + *m; |
| 21151 | |
| 21152 | /* Compute A=L*Q, copying result to VT */ |
| 21153 | /* (Workspace: need 2*M, prefer M+M*NB) */ |
| 21154 | |
| 21155 | i__2 = *lwork - iwork + 1; |
| 21156 | dgelqf_cxx . . $ dgelqf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[itau], &work[ |
| 21157 | iwork], &i__2, &ierr); |
| 21158 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("U", m, n, &a[a_offset], lda, &vt[vt_offset], |
| 21159 | ldvt); |
| 21160 | |
| 21161 | /* Generate Q in VT */ |
| 21162 | /* (Workspace: need 2*M, prefer M+M*NB) */ |
| 21163 | |
| 21164 | i__2 = *lwork - iwork + 1; |
| 21165 | dorglq_cxx . . $ dorglq_(424524679a238630).(m, n, m, &vt[vt_offset], ldvt, &work[itau], & |
| 21166 | work[iwork], &i__2, &ierr); |
| 21167 | ie = itau; |
| 21168 | itauq = ie + *m; |
| 21169 | itaup = itauq + *m; |
| 21170 | iwork = itaup + *m; |
| 21171 | |
| 21172 | /* Zero out above L in A */ |
| 21173 | |
| 21174 | i__2 = *m - 1; |
| 21175 | i__3 = *m - 1; |
| 21176 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("U", &i__2, &i__3, &c_b421, &c_b421, &a[( |
| 21177 | a_dim1 << 1) + 1], lda); |
| 21178 | |
| 21179 | /* Bidiagonalize L in A */ |
| 21180 | /* (Workspace: need 4*M, prefer 3*M+2*M*NB) */ |
| 21181 | |
| 21182 | i__2 = *lwork - iwork + 1; |
| 21183 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(m, m, &a[a_offset], lda, &s[1], &work[ie], & |
| 21184 | work[itauq], &work[itaup], &work[iwork], & |
| 21185 | i__2, &ierr); |
| 21186 | |
| 21187 | /* Multiply right vectors bidiagonalizing L by Q in VT */ |
| 21188 | /* (Workspace: need 3*M+N, prefer 3*M+N*NB) */ |
| 21189 | |
| 21190 | i__2 = *lwork - iwork + 1; |
| 21191 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("P", "L", "T", m, n, m, &a[a_offset], lda, & |
| 21192 | work[itaup], &vt[vt_offset], ldvt, &work[ |
| 21193 | iwork], &i__2, &ierr); |
| 21194 | |
| 21195 | /* Generate left bidiagonalizing vectors of L in A */ |
| 21196 | /* (Workspace: need 4*M, prefer 3*M+M*NB) */ |
| 21197 | |
| 21198 | i__2 = *lwork - iwork + 1; |
| 21199 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("Q", m, m, m, &a[a_offset], lda, &work[itauq], |
| 21200 | &work[iwork], &i__2, &ierr); |
| 21201 | iwork = ie + *m; |
| 21202 | |
| 21203 | /* Perform bidiagonal QR iteration, compute left */ |
| 21204 | /* singular vectors of A in A and compute right */ |
| 21205 | /* singular vectors of A in VT */ |
| 21206 | /* (Workspace: need BDSPAC) */ |
| 21207 | |
| 21208 | dbdsqr_cxx . . $ dbdsqr_(d6d10c27a7b3c412).("U", m, n, m, &c__0, &s[1], &work[ie], &vt[ |
| 21209 | vt_offset], ldvt, &a[a_offset], lda, dum, & |
| 21210 | c__1, &work[iwork], info); |
| 21211 | |
| 21212 | } |
| 21213 | |
| 21214 | } else if (wntuas) { |
| 21215 | |
| 21216 | /* Path 6t(N much larger than M, JOBU='S' or 'A', */ |
| 21217 | /* JOBVT='S') */ |
| 21218 | /* M right singular vectors to be computed in VT and */ |
| 21219 | /* M left singular vectors to be computed in U */ |
| 21220 | |
| 21221 | /* Computing MAX */ |
| 21222 | i__2 = *m << 2; |
| 21223 | if (*lwork >= *m * *m + stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,bdspac)) { |
| 21224 | |
| 21225 | /* Sufficient workspace for a fast algorithm */ |
| 21226 | |
| 21227 | iu = 1; |
| 21228 | if (*lwork >= wrkbl + *lda * *m) { |
| 21229 | |
| 21230 | /* WORK(IU) is LDA by N */ |
| 21231 | |
| 21232 | ldwrku = *lda; |
| 21233 | } else { |
| 21234 | |
| 21235 | /* WORK(IU) is LDA by M */ |
| 21236 | |
| 21237 | ldwrku = *m; |
| 21238 | } |
| 21239 | itau = iu + ldwrku * *m; |
| 21240 | iwork = itau + *m; |
| 21241 | |
| 21242 | /* Compute A=L*Q */ |
| 21243 | /* (Workspace: need M*M+2*M, prefer M*M+M+M*NB) */ |
| 21244 | |
| 21245 | i__2 = *lwork - iwork + 1; |
| 21246 | dgelqf_cxx . . $ dgelqf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[itau], &work[ |
| 21247 | iwork], &i__2, &ierr); |
| 21248 | |
| 21249 | /* Copy L to WORK(IU), zeroing out above it */ |
| 21250 | |
| 21251 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("L", m, m, &a[a_offset], lda, &work[iu], & |
| 21252 | ldwrku); |
| 21253 | i__2 = *m - 1; |
| 21254 | i__3 = *m - 1; |
| 21255 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("U", &i__2, &i__3, &c_b421, &c_b421, &work[iu |
| 21256 | + ldwrku], &ldwrku); |
| 21257 | |
| 21258 | /* Generate Q in A */ |
| 21259 | /* (Workspace: need M*M+2*M, prefer M*M+M+M*NB) */ |
| 21260 | |
| 21261 | i__2 = *lwork - iwork + 1; |
| 21262 | dorglq_cxx . . $ dorglq_(424524679a238630).(m, n, m, &a[a_offset], lda, &work[itau], & |
| 21263 | work[iwork], &i__2, &ierr); |
| 21264 | ie = itau; |
| 21265 | itauq = ie + *m; |
| 21266 | itaup = itauq + *m; |
| 21267 | iwork = itaup + *m; |
| 21268 | |
| 21269 | /* Bidiagonalize L in WORK(IU), copying result to U */ |
| 21270 | /* (Workspace: need M*M+4*M, prefer M*M+3*M+2*M*NB) */ |
| 21271 | |
| 21272 | i__2 = *lwork - iwork + 1; |
| 21273 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(m, m, &work[iu], &ldwrku, &s[1], &work[ie], & |
| 21274 | work[itauq], &work[itaup], &work[iwork], & |
| 21275 | i__2, &ierr); |
| 21276 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("L", m, m, &work[iu], &ldwrku, &u[u_offset], |
| 21277 | ldu); |
| 21278 | |
| 21279 | /* Generate right bidiagonalizing vectors in WORK(IU) */ |
| 21280 | /* (Workspace: need M*M+4*M-1, */ |
| 21281 | /* prefer M*M+3*M+(M-1)*NB) */ |
| 21282 | |
| 21283 | i__2 = *lwork - iwork + 1; |
| 21284 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("P", m, m, m, &work[iu], &ldwrku, &work[itaup] |
| 21285 | , &work[iwork], &i__2, &ierr); |
| 21286 | |
| 21287 | /* Generate left bidiagonalizing vectors in U */ |
| 21288 | /* (Workspace: need M*M+4*M, prefer M*M+3*M+M*NB) */ |
| 21289 | |
| 21290 | i__2 = *lwork - iwork + 1; |
| 21291 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("Q", m, m, m, &u[u_offset], ldu, &work[itauq], |
| 21292 | &work[iwork], &i__2, &ierr); |
| 21293 | iwork = ie + *m; |
| 21294 | |
| 21295 | /* Perform bidiagonal QR iteration, computing left */ |
| 21296 | /* singular vectors of L in U and computing right */ |
| 21297 | /* singular vectors of L in WORK(IU) */ |
| 21298 | /* (Workspace: need M*M+BDSPAC) */ |
| 21299 | |
| 21300 | dbdsqr_cxx . . $ dbdsqr_(d6d10c27a7b3c412).("U", m, m, m, &c__0, &s[1], &work[ie], &work[ |
| 21301 | iu], &ldwrku, &u[u_offset], ldu, dum, &c__1, & |
| 21302 | work[iwork], info); |
| 21303 | |
| 21304 | /* Multiply right singular vectors of L in WORK(IU) by */ |
| 21305 | /* Q in A, storing result in VT */ |
| 21306 | /* (Workspace: need M*M) */ |
| 21307 | |
| 21308 | dgemm_cxx . . $ dgemm_(7f9a15c7502022ea).("N", "N", m, n, m, &c_b443, &work[iu], &ldwrku, |
| 21309 | &a[a_offset], lda, &c_b421, &vt[vt_offset], |
| 21310 | ldvt); |
| 21311 | |
| 21312 | } else { |
| 21313 | |
| 21314 | /* Insufficient workspace for a fast algorithm */ |
| 21315 | |
| 21316 | itau = 1; |
| 21317 | iwork = itau + *m; |
| 21318 | |
| 21319 | /* Compute A=L*Q, copying result to VT */ |
| 21320 | /* (Workspace: need 2*M, prefer M+M*NB) */ |
| 21321 | |
| 21322 | i__2 = *lwork - iwork + 1; |
| 21323 | dgelqf_cxx . . $ dgelqf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[itau], &work[ |
| 21324 | iwork], &i__2, &ierr); |
| 21325 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("U", m, n, &a[a_offset], lda, &vt[vt_offset], |
| 21326 | ldvt); |
| 21327 | |
| 21328 | /* Generate Q in VT */ |
| 21329 | /* (Workspace: need 2*M, prefer M+M*NB) */ |
| 21330 | |
| 21331 | i__2 = *lwork - iwork + 1; |
| 21332 | dorglq_cxx . . $ dorglq_(424524679a238630).(m, n, m, &vt[vt_offset], ldvt, &work[itau], & |
| 21333 | work[iwork], &i__2, &ierr); |
| 21334 | |
| 21335 | /* Copy L to U, zeroing out above it */ |
| 21336 | |
| 21337 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("L", m, m, &a[a_offset], lda, &u[u_offset], |
| 21338 | ldu); |
| 21339 | i__2 = *m - 1; |
| 21340 | i__3 = *m - 1; |
| 21341 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("U", &i__2, &i__3, &c_b421, &c_b421, &u[( |
| 21342 | u_dim1 << 1) + 1], ldu); |
| 21343 | ie = itau; |
| 21344 | itauq = ie + *m; |
| 21345 | itaup = itauq + *m; |
| 21346 | iwork = itaup + *m; |
| 21347 | |
| 21348 | /* Bidiagonalize L in U */ |
| 21349 | /* (Workspace: need 4*M, prefer 3*M+2*M*NB) */ |
| 21350 | |
| 21351 | i__2 = *lwork - iwork + 1; |
| 21352 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(m, m, &u[u_offset], ldu, &s[1], &work[ie], & |
| 21353 | work[itauq], &work[itaup], &work[iwork], & |
| 21354 | i__2, &ierr); |
| 21355 | |
| 21356 | /* Multiply right bidiagonalizing vectors in U by Q */ |
| 21357 | /* in VT */ |
| 21358 | /* (Workspace: need 3*M+N, prefer 3*M+N*NB) */ |
| 21359 | |
| 21360 | i__2 = *lwork - iwork + 1; |
| 21361 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("P", "L", "T", m, n, m, &u[u_offset], ldu, & |
| 21362 | work[itaup], &vt[vt_offset], ldvt, &work[ |
| 21363 | iwork], &i__2, &ierr); |
| 21364 | |
| 21365 | /* Generate left bidiagonalizing vectors in U */ |
| 21366 | /* (Workspace: need 4*M, prefer 3*M+M*NB) */ |
| 21367 | |
| 21368 | i__2 = *lwork - iwork + 1; |
| 21369 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("Q", m, m, m, &u[u_offset], ldu, &work[itauq], |
| 21370 | &work[iwork], &i__2, &ierr); |
| 21371 | iwork = ie + *m; |
| 21372 | |
| 21373 | /* Perform bidiagonal QR iteration, computing left */ |
| 21374 | /* singular vectors of A in U and computing right */ |
| 21375 | /* singular vectors of A in VT */ |
| 21376 | /* (Workspace: need BDSPAC) */ |
| 21377 | |
| 21378 | dbdsqr_cxx . . $ dbdsqr_(d6d10c27a7b3c412).("U", m, n, m, &c__0, &s[1], &work[ie], &vt[ |
| 21379 | vt_offset], ldvt, &u[u_offset], ldu, dum, & |
| 21380 | c__1, &work[iwork], info); |
| 21381 | |
| 21382 | } |
| 21383 | |
| 21384 | } |
| 21385 | |
| 21386 | } else if (wntva) { |
| 21387 | |
| 21388 | if (wntun) { |
| 21389 | |
| 21390 | /* Path 7t(N much larger than M, JOBU='N', JOBVT='A') */ |
| 21391 | /* N right singular vectors to be computed in VT and */ |
| 21392 | /* no left singular vectors to be computed */ |
| 21393 | |
| 21394 | /* Computing MAX */ |
| 21395 | i__2 = *n + *m, i__3 = *m << 2, i__2 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 21396 | if (*lwork >= *m * *m + stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,bdspac)) { |
| 21397 | |
| 21398 | /* Sufficient workspace for a fast algorithm */ |
| 21399 | |
| 21400 | ir = 1; |
| 21401 | if (*lwork >= wrkbl + *lda * *m) { |
| 21402 | |
| 21403 | /* WORK(IR) is LDA by M */ |
| 21404 | |
| 21405 | ldwrkr = *lda; |
| 21406 | } else { |
| 21407 | |
| 21408 | /* WORK(IR) is M by M */ |
| 21409 | |
| 21410 | ldwrkr = *m; |
| 21411 | } |
| 21412 | itau = ir + ldwrkr * *m; |
| 21413 | iwork = itau + *m; |
| 21414 | |
| 21415 | /* Compute A=L*Q, copying result to VT */ |
| 21416 | /* (Workspace: need M*M+2*M, prefer M*M+M+M*NB) */ |
| 21417 | |
| 21418 | i__2 = *lwork - iwork + 1; |
| 21419 | dgelqf_cxx . . $ dgelqf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[itau], &work[ |
| 21420 | iwork], &i__2, &ierr); |
| 21421 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("U", m, n, &a[a_offset], lda, &vt[vt_offset], |
| 21422 | ldvt); |
| 21423 | |
| 21424 | /* Copy L to WORK(IR), zeroing out above it */ |
| 21425 | |
| 21426 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("L", m, m, &a[a_offset], lda, &work[ir], & |
| 21427 | ldwrkr); |
| 21428 | i__2 = *m - 1; |
| 21429 | i__3 = *m - 1; |
| 21430 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("U", &i__2, &i__3, &c_b421, &c_b421, &work[ir |
| 21431 | + ldwrkr], &ldwrkr); |
| 21432 | |
| 21433 | /* Generate Q in VT */ |
| 21434 | /* (Workspace: need M*M+M+N, prefer M*M+M+N*NB) */ |
| 21435 | |
| 21436 | i__2 = *lwork - iwork + 1; |
| 21437 | dorglq_cxx . . $ dorglq_(424524679a238630).(n, n, m, &vt[vt_offset], ldvt, &work[itau], & |
| 21438 | work[iwork], &i__2, &ierr); |
| 21439 | ie = itau; |
| 21440 | itauq = ie + *m; |
| 21441 | itaup = itauq + *m; |
| 21442 | iwork = itaup + *m; |
| 21443 | |
| 21444 | /* Bidiagonalize L in WORK(IR) */ |
| 21445 | /* (Workspace: need M*M+4*M, prefer M*M+3*M+2*M*NB) */ |
| 21446 | |
| 21447 | i__2 = *lwork - iwork + 1; |
| 21448 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(m, m, &work[ir], &ldwrkr, &s[1], &work[ie], & |
| 21449 | work[itauq], &work[itaup], &work[iwork], & |
| 21450 | i__2, &ierr); |
| 21451 | |
| 21452 | /* Generate right bidiagonalizing vectors in WORK(IR) */ |
| 21453 | /* (Workspace: need M*M+4*M-1, */ |
| 21454 | /* prefer M*M+3*M+(M-1)*NB) */ |
| 21455 | |
| 21456 | i__2 = *lwork - iwork + 1; |
| 21457 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("P", m, m, m, &work[ir], &ldwrkr, &work[itaup] |
| 21458 | , &work[iwork], &i__2, &ierr); |
| 21459 | iwork = ie + *m; |
| 21460 | |
| 21461 | /* Perform bidiagonal QR iteration, computing right */ |
| 21462 | /* singular vectors of L in WORK(IR) */ |
| 21463 | /* (Workspace: need M*M+BDSPAC) */ |
| 21464 | |
| 21465 | dbdsqr_cxx . . $ dbdsqr_(d6d10c27a7b3c412).("U", m, m, &c__0, &c__0, &s[1], &work[ie], & |
| 21466 | work[ir], &ldwrkr, dum, &c__1, dum, &c__1, & |
| 21467 | work[iwork], info); |
| 21468 | |
| 21469 | /* Multiply right singular vectors of L in WORK(IR) by */ |
| 21470 | /* Q in VT, storing result in A */ |
| 21471 | /* (Workspace: need M*M) */ |
| 21472 | |
| 21473 | dgemm_cxx . . $ dgemm_(7f9a15c7502022ea).("N", "N", m, n, m, &c_b443, &work[ir], &ldwrkr, |
| 21474 | &vt[vt_offset], ldvt, &c_b421, &a[a_offset], |
| 21475 | lda); |
| 21476 | |
| 21477 | /* Copy right singular vectors of A from A to VT */ |
| 21478 | |
| 21479 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("F", m, n, &a[a_offset], lda, &vt[vt_offset], |
| 21480 | ldvt); |
| 21481 | |
| 21482 | } else { |
| 21483 | |
| 21484 | /* Insufficient workspace for a fast algorithm */ |
| 21485 | |
| 21486 | itau = 1; |
| 21487 | iwork = itau + *m; |
| 21488 | |
| 21489 | /* Compute A=L*Q, copying result to VT */ |
| 21490 | /* (Workspace: need 2*M, prefer M+M*NB) */ |
| 21491 | |
| 21492 | i__2 = *lwork - iwork + 1; |
| 21493 | dgelqf_cxx . . $ dgelqf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[itau], &work[ |
| 21494 | iwork], &i__2, &ierr); |
| 21495 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("U", m, n, &a[a_offset], lda, &vt[vt_offset], |
| 21496 | ldvt); |
| 21497 | |
| 21498 | /* Generate Q in VT */ |
| 21499 | /* (Workspace: need M+N, prefer M+N*NB) */ |
| 21500 | |
| 21501 | i__2 = *lwork - iwork + 1; |
| 21502 | dorglq_cxx . . $ dorglq_(424524679a238630).(n, n, m, &vt[vt_offset], ldvt, &work[itau], & |
| 21503 | work[iwork], &i__2, &ierr); |
| 21504 | ie = itau; |
| 21505 | itauq = ie + *m; |
| 21506 | itaup = itauq + *m; |
| 21507 | iwork = itaup + *m; |
| 21508 | |
| 21509 | /* Zero out above L in A */ |
| 21510 | |
| 21511 | i__2 = *m - 1; |
| 21512 | i__3 = *m - 1; |
| 21513 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("U", &i__2, &i__3, &c_b421, &c_b421, &a[( |
| 21514 | a_dim1 << 1) + 1], lda); |
| 21515 | |
| 21516 | /* Bidiagonalize L in A */ |
| 21517 | /* (Workspace: need 4*M, prefer 3*M+2*M*NB) */ |
| 21518 | |
| 21519 | i__2 = *lwork - iwork + 1; |
| 21520 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(m, m, &a[a_offset], lda, &s[1], &work[ie], & |
| 21521 | work[itauq], &work[itaup], &work[iwork], & |
| 21522 | i__2, &ierr); |
| 21523 | |
| 21524 | /* Multiply right bidiagonalizing vectors in A by Q */ |
| 21525 | /* in VT */ |
| 21526 | /* (Workspace: need 3*M+N, prefer 3*M+N*NB) */ |
| 21527 | |
| 21528 | i__2 = *lwork - iwork + 1; |
| 21529 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("P", "L", "T", m, n, m, &a[a_offset], lda, & |
| 21530 | work[itaup], &vt[vt_offset], ldvt, &work[ |
| 21531 | iwork], &i__2, &ierr); |
| 21532 | iwork = ie + *m; |
| 21533 | |
| 21534 | /* Perform bidiagonal QR iteration, computing right */ |
| 21535 | /* singular vectors of A in VT */ |
| 21536 | /* (Workspace: need BDSPAC) */ |
| 21537 | |
| 21538 | dbdsqr_cxx . . $ dbdsqr_(d6d10c27a7b3c412).("U", m, n, &c__0, &c__0, &s[1], &work[ie], & |
| 21539 | vt[vt_offset], ldvt, dum, &c__1, dum, &c__1, & |
| 21540 | work[iwork], info); |
| 21541 | |
| 21542 | } |
| 21543 | |
| 21544 | } else if (wntuo) { |
| 21545 | |
| 21546 | /* Path 8t(N much larger than M, JOBU='O', JOBVT='A') */ |
| 21547 | /* N right singular vectors to be computed in VT and */ |
| 21548 | /* M left singular vectors to be overwritten on A */ |
| 21549 | |
| 21550 | /* Computing MAX */ |
| 21551 | i__2 = *n + *m, i__3 = *m << 2, i__2 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 21552 | if (*lwork >= (*m << 1) * *m + stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,bdspac)) { |
| 21553 | |
| 21554 | /* Sufficient workspace for a fast algorithm */ |
| 21555 | |
| 21556 | iu = 1; |
| 21557 | if (*lwork >= wrkbl + (*lda << 1) * *m) { |
| 21558 | |
| 21559 | /* WORK(IU) is LDA by M and WORK(IR) is LDA by M */ |
| 21560 | |
| 21561 | ldwrku = *lda; |
| 21562 | ir = iu + ldwrku * *m; |
| 21563 | ldwrkr = *lda; |
| 21564 | } else if (*lwork >= wrkbl + (*lda + *m) * *m) { |
| 21565 | |
| 21566 | /* WORK(IU) is LDA by M and WORK(IR) is M by M */ |
| 21567 | |
| 21568 | ldwrku = *lda; |
| 21569 | ir = iu + ldwrku * *m; |
| 21570 | ldwrkr = *m; |
| 21571 | } else { |
| 21572 | |
| 21573 | /* WORK(IU) is M by M and WORK(IR) is M by M */ |
| 21574 | |
| 21575 | ldwrku = *m; |
| 21576 | ir = iu + ldwrku * *m; |
| 21577 | ldwrkr = *m; |
| 21578 | } |
| 21579 | itau = ir + ldwrkr * *m; |
| 21580 | iwork = itau + *m; |
| 21581 | |
| 21582 | /* Compute A=L*Q, copying result to VT */ |
| 21583 | /* (Workspace: need 2*M*M+2*M, prefer 2*M*M+M+M*NB) */ |
| 21584 | |
| 21585 | i__2 = *lwork - iwork + 1; |
| 21586 | dgelqf_cxx . . $ dgelqf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[itau], &work[ |
| 21587 | iwork], &i__2, &ierr); |
| 21588 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("U", m, n, &a[a_offset], lda, &vt[vt_offset], |
| 21589 | ldvt); |
| 21590 | |
| 21591 | /* Generate Q in VT */ |
| 21592 | /* (Workspace: need 2*M*M+M+N, prefer 2*M*M+M+N*NB) */ |
| 21593 | |
| 21594 | i__2 = *lwork - iwork + 1; |
| 21595 | dorglq_cxx . . $ dorglq_(424524679a238630).(n, n, m, &vt[vt_offset], ldvt, &work[itau], & |
| 21596 | work[iwork], &i__2, &ierr); |
| 21597 | |
| 21598 | /* Copy L to WORK(IU), zeroing out above it */ |
| 21599 | |
| 21600 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("L", m, m, &a[a_offset], lda, &work[iu], & |
| 21601 | ldwrku); |
| 21602 | i__2 = *m - 1; |
| 21603 | i__3 = *m - 1; |
| 21604 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("U", &i__2, &i__3, &c_b421, &c_b421, &work[iu |
| 21605 | + ldwrku], &ldwrku); |
| 21606 | ie = itau; |
| 21607 | itauq = ie + *m; |
| 21608 | itaup = itauq + *m; |
| 21609 | iwork = itaup + *m; |
| 21610 | |
| 21611 | /* Bidiagonalize L in WORK(IU), copying result to */ |
| 21612 | /* WORK(IR) */ |
| 21613 | /* (Workspace: need 2*M*M+4*M, */ |
| 21614 | /* prefer 2*M*M+3*M+2*M*NB) */ |
| 21615 | |
| 21616 | i__2 = *lwork - iwork + 1; |
| 21617 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(m, m, &work[iu], &ldwrku, &s[1], &work[ie], & |
| 21618 | work[itauq], &work[itaup], &work[iwork], & |
| 21619 | i__2, &ierr); |
| 21620 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("L", m, m, &work[iu], &ldwrku, &work[ir], & |
| 21621 | ldwrkr); |
| 21622 | |
| 21623 | /* Generate right bidiagonalizing vectors in WORK(IU) */ |
| 21624 | /* (Workspace: need 2*M*M+4*M-1, */ |
| 21625 | /* prefer 2*M*M+3*M+(M-1)*NB) */ |
| 21626 | |
| 21627 | i__2 = *lwork - iwork + 1; |
| 21628 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("P", m, m, m, &work[iu], &ldwrku, &work[itaup] |
| 21629 | , &work[iwork], &i__2, &ierr); |
| 21630 | |
| 21631 | /* Generate left bidiagonalizing vectors in WORK(IR) */ |
| 21632 | /* (Workspace: need 2*M*M+4*M, prefer 2*M*M+3*M+M*NB) */ |
| 21633 | |
| 21634 | i__2 = *lwork - iwork + 1; |
| 21635 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("Q", m, m, m, &work[ir], &ldwrkr, &work[itauq] |
| 21636 | , &work[iwork], &i__2, &ierr); |
| 21637 | iwork = ie + *m; |
| 21638 | |
| 21639 | /* Perform bidiagonal QR iteration, computing left */ |
| 21640 | /* singular vectors of L in WORK(IR) and computing */ |
| 21641 | /* right singular vectors of L in WORK(IU) */ |
| 21642 | /* (Workspace: need 2*M*M+BDSPAC) */ |
| 21643 | |
| 21644 | dbdsqr_cxx . . $ dbdsqr_(d6d10c27a7b3c412).("U", m, m, m, &c__0, &s[1], &work[ie], &work[ |
| 21645 | iu], &ldwrku, &work[ir], &ldwrkr, dum, &c__1, |
| 21646 | &work[iwork], info); |
| 21647 | |
| 21648 | /* Multiply right singular vectors of L in WORK(IU) by */ |
| 21649 | /* Q in VT, storing result in A */ |
| 21650 | /* (Workspace: need M*M) */ |
| 21651 | |
| 21652 | dgemm_cxx . . $ dgemm_(7f9a15c7502022ea).("N", "N", m, n, m, &c_b443, &work[iu], &ldwrku, |
| 21653 | &vt[vt_offset], ldvt, &c_b421, &a[a_offset], |
| 21654 | lda); |
| 21655 | |
| 21656 | /* Copy right singular vectors of A from A to VT */ |
| 21657 | |
| 21658 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("F", m, n, &a[a_offset], lda, &vt[vt_offset], |
| 21659 | ldvt); |
| 21660 | |
| 21661 | /* Copy left singular vectors of A from WORK(IR) to A */ |
| 21662 | |
| 21663 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("F", m, m, &work[ir], &ldwrkr, &a[a_offset], |
| 21664 | lda); |
| 21665 | |
| 21666 | } else { |
| 21667 | |
| 21668 | /* Insufficient workspace for a fast algorithm */ |
| 21669 | |
| 21670 | itau = 1; |
| 21671 | iwork = itau + *m; |
| 21672 | |
| 21673 | /* Compute A=L*Q, copying result to VT */ |
| 21674 | /* (Workspace: need 2*M, prefer M+M*NB) */ |
| 21675 | |
| 21676 | i__2 = *lwork - iwork + 1; |
| 21677 | dgelqf_cxx . . $ dgelqf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[itau], &work[ |
| 21678 | iwork], &i__2, &ierr); |
| 21679 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("U", m, n, &a[a_offset], lda, &vt[vt_offset], |
| 21680 | ldvt); |
| 21681 | |
| 21682 | /* Generate Q in VT */ |
| 21683 | /* (Workspace: need M+N, prefer M+N*NB) */ |
| 21684 | |
| 21685 | i__2 = *lwork - iwork + 1; |
| 21686 | dorglq_cxx . . $ dorglq_(424524679a238630).(n, n, m, &vt[vt_offset], ldvt, &work[itau], & |
| 21687 | work[iwork], &i__2, &ierr); |
| 21688 | ie = itau; |
| 21689 | itauq = ie + *m; |
| 21690 | itaup = itauq + *m; |
| 21691 | iwork = itaup + *m; |
| 21692 | |
| 21693 | /* Zero out above L in A */ |
| 21694 | |
| 21695 | i__2 = *m - 1; |
| 21696 | i__3 = *m - 1; |
| 21697 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("U", &i__2, &i__3, &c_b421, &c_b421, &a[( |
| 21698 | a_dim1 << 1) + 1], lda); |
| 21699 | |
| 21700 | /* Bidiagonalize L in A */ |
| 21701 | /* (Workspace: need 4*M, prefer 3*M+2*M*NB) */ |
| 21702 | |
| 21703 | i__2 = *lwork - iwork + 1; |
| 21704 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(m, m, &a[a_offset], lda, &s[1], &work[ie], & |
| 21705 | work[itauq], &work[itaup], &work[iwork], & |
| 21706 | i__2, &ierr); |
| 21707 | |
| 21708 | /* Multiply right bidiagonalizing vectors in A by Q */ |
| 21709 | /* in VT */ |
| 21710 | /* (Workspace: need 3*M+N, prefer 3*M+N*NB) */ |
| 21711 | |
| 21712 | i__2 = *lwork - iwork + 1; |
| 21713 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("P", "L", "T", m, n, m, &a[a_offset], lda, & |
| 21714 | work[itaup], &vt[vt_offset], ldvt, &work[ |
| 21715 | iwork], &i__2, &ierr); |
| 21716 | |
| 21717 | /* Generate left bidiagonalizing vectors in A */ |
| 21718 | /* (Workspace: need 4*M, prefer 3*M+M*NB) */ |
| 21719 | |
| 21720 | i__2 = *lwork - iwork + 1; |
| 21721 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("Q", m, m, m, &a[a_offset], lda, &work[itauq], |
| 21722 | &work[iwork], &i__2, &ierr); |
| 21723 | iwork = ie + *m; |
| 21724 | |
| 21725 | /* Perform bidiagonal QR iteration, computing left */ |
| 21726 | /* singular vectors of A in A and computing right */ |
| 21727 | /* singular vectors of A in VT */ |
| 21728 | /* (Workspace: need BDSPAC) */ |
| 21729 | |
| 21730 | dbdsqr_cxx . . $ dbdsqr_(d6d10c27a7b3c412).("U", m, n, m, &c__0, &s[1], &work[ie], &vt[ |
| 21731 | vt_offset], ldvt, &a[a_offset], lda, dum, & |
| 21732 | c__1, &work[iwork], info); |
| 21733 | |
| 21734 | } |
| 21735 | |
| 21736 | } else if (wntuas) { |
| 21737 | |
| 21738 | /* Path 9t(N much larger than M, JOBU='S' or 'A', */ |
| 21739 | /* JOBVT='A') */ |
| 21740 | /* N right singular vectors to be computed in VT and */ |
| 21741 | /* M left singular vectors to be computed in U */ |
| 21742 | |
| 21743 | /* Computing MAX */ |
| 21744 | i__2 = *n + *m, i__3 = *m << 2, i__2 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,i__3); |
| 21745 | if (*lwork >= *m * *m + stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2,bdspac)) { |
| 21746 | |
| 21747 | /* Sufficient workspace for a fast algorithm */ |
| 21748 | |
| 21749 | iu = 1; |
| 21750 | if (*lwork >= wrkbl + *lda * *m) { |
| 21751 | |
| 21752 | /* WORK(IU) is LDA by M */ |
| 21753 | |
| 21754 | ldwrku = *lda; |
| 21755 | } else { |
| 21756 | |
| 21757 | /* WORK(IU) is M by M */ |
| 21758 | |
| 21759 | ldwrku = *m; |
| 21760 | } |
| 21761 | itau = iu + ldwrku * *m; |
| 21762 | iwork = itau + *m; |
| 21763 | |
| 21764 | /* Compute A=L*Q, copying result to VT */ |
| 21765 | /* (Workspace: need M*M+2*M, prefer M*M+M+M*NB) */ |
| 21766 | |
| 21767 | i__2 = *lwork - iwork + 1; |
| 21768 | dgelqf_cxx . . $ dgelqf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[itau], &work[ |
| 21769 | iwork], &i__2, &ierr); |
| 21770 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("U", m, n, &a[a_offset], lda, &vt[vt_offset], |
| 21771 | ldvt); |
| 21772 | |
| 21773 | /* Generate Q in VT */ |
| 21774 | /* (Workspace: need M*M+M+N, prefer M*M+M+N*NB) */ |
| 21775 | |
| 21776 | i__2 = *lwork - iwork + 1; |
| 21777 | dorglq_cxx . . $ dorglq_(424524679a238630).(n, n, m, &vt[vt_offset], ldvt, &work[itau], & |
| 21778 | work[iwork], &i__2, &ierr); |
| 21779 | |
| 21780 | /* Copy L to WORK(IU), zeroing out above it */ |
| 21781 | |
| 21782 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("L", m, m, &a[a_offset], lda, &work[iu], & |
| 21783 | ldwrku); |
| 21784 | i__2 = *m - 1; |
| 21785 | i__3 = *m - 1; |
| 21786 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("U", &i__2, &i__3, &c_b421, &c_b421, &work[iu |
| 21787 | + ldwrku], &ldwrku); |
| 21788 | ie = itau; |
| 21789 | itauq = ie + *m; |
| 21790 | itaup = itauq + *m; |
| 21791 | iwork = itaup + *m; |
| 21792 | |
| 21793 | /* Bidiagonalize L in WORK(IU), copying result to U */ |
| 21794 | /* (Workspace: need M*M+4*M, prefer M*M+3*M+2*M*NB) */ |
| 21795 | |
| 21796 | i__2 = *lwork - iwork + 1; |
| 21797 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(m, m, &work[iu], &ldwrku, &s[1], &work[ie], & |
| 21798 | work[itauq], &work[itaup], &work[iwork], & |
| 21799 | i__2, &ierr); |
| 21800 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("L", m, m, &work[iu], &ldwrku, &u[u_offset], |
| 21801 | ldu); |
| 21802 | |
| 21803 | /* Generate right bidiagonalizing vectors in WORK(IU) */ |
| 21804 | /* (Workspace: need M*M+4*M, prefer M*M+3*M+(M-1)*NB) */ |
| 21805 | |
| 21806 | i__2 = *lwork - iwork + 1; |
| 21807 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("P", m, m, m, &work[iu], &ldwrku, &work[itaup] |
| 21808 | , &work[iwork], &i__2, &ierr); |
| 21809 | |
| 21810 | /* Generate left bidiagonalizing vectors in U */ |
| 21811 | /* (Workspace: need M*M+4*M, prefer M*M+3*M+M*NB) */ |
| 21812 | |
| 21813 | i__2 = *lwork - iwork + 1; |
| 21814 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("Q", m, m, m, &u[u_offset], ldu, &work[itauq], |
| 21815 | &work[iwork], &i__2, &ierr); |
| 21816 | iwork = ie + *m; |
| 21817 | |
| 21818 | /* Perform bidiagonal QR iteration, computing left */ |
| 21819 | /* singular vectors of L in U and computing right */ |
| 21820 | /* singular vectors of L in WORK(IU) */ |
| 21821 | /* (Workspace: need M*M+BDSPAC) */ |
| 21822 | |
| 21823 | dbdsqr_cxx . . $ dbdsqr_(d6d10c27a7b3c412).("U", m, m, m, &c__0, &s[1], &work[ie], &work[ |
| 21824 | iu], &ldwrku, &u[u_offset], ldu, dum, &c__1, & |
| 21825 | work[iwork], info); |
| 21826 | |
| 21827 | /* Multiply right singular vectors of L in WORK(IU) by */ |
| 21828 | /* Q in VT, storing result in A */ |
| 21829 | /* (Workspace: need M*M) */ |
| 21830 | |
| 21831 | dgemm_cxx . . $ dgemm_(7f9a15c7502022ea).("N", "N", m, n, m, &c_b443, &work[iu], &ldwrku, |
| 21832 | &vt[vt_offset], ldvt, &c_b421, &a[a_offset], |
| 21833 | lda); |
| 21834 | |
| 21835 | /* Copy right singular vectors of A from A to VT */ |
| 21836 | |
| 21837 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("F", m, n, &a[a_offset], lda, &vt[vt_offset], |
| 21838 | ldvt); |
| 21839 | |
| 21840 | } else { |
| 21841 | |
| 21842 | /* Insufficient workspace for a fast algorithm */ |
| 21843 | |
| 21844 | itau = 1; |
| 21845 | iwork = itau + *m; |
| 21846 | |
| 21847 | /* Compute A=L*Q, copying result to VT */ |
| 21848 | /* (Workspace: need 2*M, prefer M+M*NB) */ |
| 21849 | |
| 21850 | i__2 = *lwork - iwork + 1; |
| 21851 | dgelqf_cxx . . $ dgelqf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &work[itau], &work[ |
| 21852 | iwork], &i__2, &ierr); |
| 21853 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("U", m, n, &a[a_offset], lda, &vt[vt_offset], |
| 21854 | ldvt); |
| 21855 | |
| 21856 | /* Generate Q in VT */ |
| 21857 | /* (Workspace: need M+N, prefer M+N*NB) */ |
| 21858 | |
| 21859 | i__2 = *lwork - iwork + 1; |
| 21860 | dorglq_cxx . . $ dorglq_(424524679a238630).(n, n, m, &vt[vt_offset], ldvt, &work[itau], & |
| 21861 | work[iwork], &i__2, &ierr); |
| 21862 | |
| 21863 | /* Copy L to U, zeroing out above it */ |
| 21864 | |
| 21865 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("L", m, m, &a[a_offset], lda, &u[u_offset], |
| 21866 | ldu); |
| 21867 | i__2 = *m - 1; |
| 21868 | i__3 = *m - 1; |
| 21869 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("U", &i__2, &i__3, &c_b421, &c_b421, &u[( |
| 21870 | u_dim1 << 1) + 1], ldu); |
| 21871 | ie = itau; |
| 21872 | itauq = ie + *m; |
| 21873 | itaup = itauq + *m; |
| 21874 | iwork = itaup + *m; |
| 21875 | |
| 21876 | /* Bidiagonalize L in U */ |
| 21877 | /* (Workspace: need 4*M, prefer 3*M+2*M*NB) */ |
| 21878 | |
| 21879 | i__2 = *lwork - iwork + 1; |
| 21880 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(m, m, &u[u_offset], ldu, &s[1], &work[ie], & |
| 21881 | work[itauq], &work[itaup], &work[iwork], & |
| 21882 | i__2, &ierr); |
| 21883 | |
| 21884 | /* Multiply right bidiagonalizing vectors in U by Q */ |
| 21885 | /* in VT */ |
| 21886 | /* (Workspace: need 3*M+N, prefer 3*M+N*NB) */ |
| 21887 | |
| 21888 | i__2 = *lwork - iwork + 1; |
| 21889 | dormbr_cxx . . $ dormbr_(d0b12608155339d0).("P", "L", "T", m, n, m, &u[u_offset], ldu, & |
| 21890 | work[itaup], &vt[vt_offset], ldvt, &work[ |
| 21891 | iwork], &i__2, &ierr); |
| 21892 | |
| 21893 | /* Generate left bidiagonalizing vectors in U */ |
| 21894 | /* (Workspace: need 4*M, prefer 3*M+M*NB) */ |
| 21895 | |
| 21896 | i__2 = *lwork - iwork + 1; |
| 21897 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("Q", m, m, m, &u[u_offset], ldu, &work[itauq], |
| 21898 | &work[iwork], &i__2, &ierr); |
| 21899 | iwork = ie + *m; |
| 21900 | |
| 21901 | /* Perform bidiagonal QR iteration, computing left */ |
| 21902 | /* singular vectors of A in U and computing right */ |
| 21903 | /* singular vectors of A in VT */ |
| 21904 | /* (Workspace: need BDSPAC) */ |
| 21905 | |
| 21906 | dbdsqr_cxx . . $ dbdsqr_(d6d10c27a7b3c412).("U", m, n, m, &c__0, &s[1], &work[ie], &vt[ |
| 21907 | vt_offset], ldvt, &u[u_offset], ldu, dum, & |
| 21908 | c__1, &work[iwork], info); |
| 21909 | |
| 21910 | } |
| 21911 | |
| 21912 | } |
| 21913 | |
| 21914 | } |
| 21915 | |
| 21916 | } else { |
| 21917 | |
| 21918 | /* N .LT. MNTHR */ |
| 21919 | |
| 21920 | /* Path 10t(N greater than M, but not much larger) */ |
| 21921 | /* Reduce to bidiagonal form without LQ decomposition */ |
| 21922 | |
| 21923 | ie = 1; |
| 21924 | itauq = ie + *m; |
| 21925 | itaup = itauq + *m; |
| 21926 | iwork = itaup + *m; |
| 21927 | |
| 21928 | /* Bidiagonalize A */ |
| 21929 | /* (Workspace: need 3*M+N, prefer 3*M+(M+N)*NB) */ |
| 21930 | |
| 21931 | i__2 = *lwork - iwork + 1; |
| 21932 | dgebrd_cxx . . $ dgebrd_(18ea75f739f7fa17).(m, n, &a[a_offset], lda, &s[1], &work[ie], &work[itauq], & |
| 21933 | work[itaup], &work[iwork], &i__2, &ierr); |
| 21934 | if (wntuas) { |
| 21935 | |
| 21936 | /* If left singular vectors desired in U, copy result to U */ |
| 21937 | /* and generate left bidiagonalizing vectors in U */ |
| 21938 | /* (Workspace: need 4*M-1, prefer 3*M+(M-1)*NB) */ |
| 21939 | |
| 21940 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("L", m, m, &a[a_offset], lda, &u[u_offset], ldu); |
| 21941 | i__2 = *lwork - iwork + 1; |
| 21942 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("Q", m, m, n, &u[u_offset], ldu, &work[itauq], &work[ |
| 21943 | iwork], &i__2, &ierr); |
| 21944 | } |
| 21945 | if (wntvas) { |
| 21946 | |
| 21947 | /* If right singular vectors desired in VT, copy result to */ |
| 21948 | /* VT and generate right bidiagonalizing vectors in VT */ |
| 21949 | /* (Workspace: need 3*M+NRVT, prefer 3*M+NRVT*NB) */ |
| 21950 | |
| 21951 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("U", m, n, &a[a_offset], lda, &vt[vt_offset], ldvt); |
| 21952 | if (wntva) { |
| 21953 | nrvt = *n; |
| 21954 | } |
| 21955 | if (wntvs) { |
| 21956 | nrvt = *m; |
| 21957 | } |
| 21958 | i__2 = *lwork - iwork + 1; |
| 21959 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("P", &nrvt, n, m, &vt[vt_offset], ldvt, &work[itaup], |
| 21960 | &work[iwork], &i__2, &ierr); |
| 21961 | } |
| 21962 | if (wntuo) { |
| 21963 | |
| 21964 | /* If left singular vectors desired in A, generate left */ |
| 21965 | /* bidiagonalizing vectors in A */ |
| 21966 | /* (Workspace: need 4*M-1, prefer 3*M+(M-1)*NB) */ |
| 21967 | |
| 21968 | i__2 = *lwork - iwork + 1; |
| 21969 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("Q", m, m, n, &a[a_offset], lda, &work[itauq], &work[ |
| 21970 | iwork], &i__2, &ierr); |
| 21971 | } |
| 21972 | if (wntvo) { |
| 21973 | |
| 21974 | /* If right singular vectors desired in A, generate right */ |
| 21975 | /* bidiagonalizing vectors in A */ |
| 21976 | /* (Workspace: need 4*M, prefer 3*M+M*NB) */ |
| 21977 | |
| 21978 | i__2 = *lwork - iwork + 1; |
| 21979 | dorgbr_cxx . . $ dorgbr_(72aec383d88bf41e).("P", m, n, m, &a[a_offset], lda, &work[itaup], &work[ |
| 21980 | iwork], &i__2, &ierr); |
| 21981 | } |
| 21982 | iwork = ie + *m; |
| 21983 | if (wntuas || wntuo) { |
| 21984 | nru = *m; |
| 21985 | } |
| 21986 | if (wntun) { |
| 21987 | nru = 0; |
| 21988 | } |
| 21989 | if (wntvas || wntvo) { |
| 21990 | ncvt = *n; |
| 21991 | } |
| 21992 | if (wntvn) { |
| 21993 | ncvt = 0; |
| 21994 | } |
| 21995 | if (! wntuo && ! wntvo) { |
| 21996 | |
| 21997 | /* Perform bidiagonal QR iteration, if desired, computing */ |
| 21998 | /* left singular vectors in U and computing right singular */ |
| 21999 | /* vectors in VT */ |
| 22000 | /* (Workspace: need BDSPAC) */ |
| 22001 | |
| 22002 | dbdsqr_cxx . . $ dbdsqr_(d6d10c27a7b3c412).("L", m, &ncvt, &nru, &c__0, &s[1], &work[ie], &vt[ |
| 22003 | vt_offset], ldvt, &u[u_offset], ldu, dum, &c__1, & |
| 22004 | work[iwork], info); |
| 22005 | } else if (! wntuo && wntvo) { |
| 22006 | |
| 22007 | /* Perform bidiagonal QR iteration, if desired, computing */ |
| 22008 | /* left singular vectors in U and computing right singular */ |
| 22009 | /* vectors in A */ |
| 22010 | /* (Workspace: need BDSPAC) */ |
| 22011 | |
| 22012 | dbdsqr_cxx . . $ dbdsqr_(d6d10c27a7b3c412).("L", m, &ncvt, &nru, &c__0, &s[1], &work[ie], &a[ |
| 22013 | a_offset], lda, &u[u_offset], ldu, dum, &c__1, &work[ |
| 22014 | iwork], info); |
| 22015 | } else { |
| 22016 | |
| 22017 | /* Perform bidiagonal QR iteration, if desired, computing */ |
| 22018 | /* left singular vectors in A and computing right singular */ |
| 22019 | /* vectors in VT */ |
| 22020 | /* (Workspace: need BDSPAC) */ |
| 22021 | |
| 22022 | dbdsqr_cxx . . $ dbdsqr_(d6d10c27a7b3c412).("L", m, &ncvt, &nru, &c__0, &s[1], &work[ie], &vt[ |
| 22023 | vt_offset], ldvt, &a[a_offset], lda, dum, &c__1, & |
| 22024 | work[iwork], info); |
| 22025 | } |
| 22026 | |
| 22027 | } |
| 22028 | |
| 22029 | } |
| 22030 | |
| 22031 | /* If DBDSQR failed to converge, copy unconverged superdiagonals */ |
| 22032 | /* to WORK( 2:MINMN ) */ |
| 22033 | |
| 22034 | if (*info != 0) { |
| 22035 | if (ie > 2) { |
| 22036 | i__2 = minmn - 1; |
| 22037 | for (i__ = 1; i__ <= i__2; ++i__) { |
| 22038 | work[i__ + 1] = work[i__ + ie - 1]; |
| 22039 | /* L50: */ |
| 22040 | } |
| 22041 | } |
| 22042 | if (ie < 2) { |
| 22043 | for (i__ = minmn - 1; i__ >= 1; --i__) { |
| 22044 | work[i__ + 1] = work[i__ + ie - 1]; |
| 22045 | /* L60: */ |
| 22046 | } |
| 22047 | } |
| 22048 | } |
| 22049 | |
| 22050 | /* Undo scaling if necessary */ |
| 22051 | |
| 22052 | if (iscl == 1) { |
| 22053 | if (anrm > bignum) { |
| 22054 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &bignum, &anrm, &minmn, &c__1, &s[1], & |
| 22055 | minmn, &ierr); |
| 22056 | } |
| 22057 | if (*info != 0 && anrm > bignum) { |
| 22058 | i__2 = minmn - 1; |
| 22059 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &bignum, &anrm, &i__2, &c__1, &work[2], |
| 22060 | &minmn, &ierr); |
| 22061 | } |
| 22062 | if (anrm < smlnum) { |
| 22063 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &smlnum, &anrm, &minmn, &c__1, &s[1], & |
| 22064 | minmn, &ierr); |
| 22065 | } |
| 22066 | if (*info != 0 && anrm < smlnum) { |
| 22067 | i__2 = minmn - 1; |
| 22068 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &smlnum, &anrm, &i__2, &c__1, &work[2], |
| 22069 | &minmn, &ierr); |
| 22070 | } |
| 22071 | } |
| 22072 | |
| 22073 | /* Return optimal workspace in WORK(1) */ |
| 22074 | |
| 22075 | work[1] = (double) maxwrk; |
| 22076 | |
| 22077 | return 0; |
| 22078 | |
| 22079 | /* End of DGESVD */ |
| 22080 | |
| 22081 | } /* dgesvd_ */ |
| 22082 | |
| 22083 | |
| 22084 | /* Subroutine */ int dgesvx_cxx . . $ dgesvx_(64ea53daeea153a4).(const char *fact, const char *trans, integercxx . . $ integer# *n, integercxx . . $ integer# * |
| 22085 | nrhs, double *a, integercxx . . $ integer# *lda, double *af, integercxx . . $ integer# *ldaf, |
| 22086 | integercxx . . $ integer# *ipiv, char *equed, double *r__, double *c__, |
| 22087 | double *b, integercxx . . $ integer# *ldb, double *x, integercxx . . $ integer# *ldx, double * |
| 22088 | rcond, double *ferr, double *berr, double *work, integercxx . . $ integer# * |
| 22089 | iwork, integercxx . . $ integer# *info) |
| 22090 | { |
| 22091 | /* System generated locals */ |
| 22092 | integercxx . . $ integer# a_dim1, a_offset, af_dim1, af_offset, b_dim1, b_offset, x_dim1, |
| 22093 | x_offset, i__1, i__2; |
| 22094 | double d__1, d__2; |
| 22095 | |
| 22096 | /* Local variables */ |
| 22097 | integercxx . . $ integer# i__, j; |
| 22098 | double amax; |
| 22099 | char norm[1]; |
| 22100 | double rcmin, rcmax, anorm; |
| 22101 | bool equil; |
| 22102 | double colcnd; |
| 22103 | bool nofact; |
| 22104 | double bignum; |
| 22105 | integercxx . . $ integer# infequ; |
| 22106 | bool colequ; |
| 22107 | double rowcnd; |
| 22108 | bool notran; |
| 22109 | double smlnum; |
| 22110 | bool rowequ; |
| 22111 | double rpvgrw; |
| 22112 | |
| 22113 | |
| 22114 | /* -- LAPACK driver routine (version 3.1) -- */ |
| 22115 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 22116 | /* November 2006 */ |
| 22117 | |
| 22118 | /* .. Scalar Arguments .. */ |
| 22119 | /* .. */ |
| 22120 | /* .. Array Arguments .. */ |
| 22121 | /* .. */ |
| 22122 | |
| 22123 | /* Purpose */ |
| 22124 | /* ======= */ |
| 22125 | |
| 22126 | /* DGESVX uses the LU factorization to compute the solution to a real */ |
| 22127 | /* system of linear equations */ |
| 22128 | /* A * X = B, */ |
| 22129 | /* where A is an N-by-N matrix and X and B are N-by-NRHS matrices. */ |
| 22130 | |
| 22131 | /* Error bounds on the solution and a condition estimate are also */ |
| 22132 | /* provided. */ |
| 22133 | |
| 22134 | /* Description */ |
| 22135 | /* =========== */ |
| 22136 | |
| 22137 | /* The following steps are performed: */ |
| 22138 | |
| 22139 | /* 1. If FACT = 'E', real scaling factors are computed to equilibrate */ |
| 22140 | /* the system: */ |
| 22141 | /* TRANS = 'N': diag(R)*A*diag(C) *inv(diag(C))*X = diag(R)*B */ |
| 22142 | /* TRANS = 'T': (diag(R)*A*diag(C))**T *inv(diag(R))*X = diag(C)*B */ |
| 22143 | /* TRANS = 'C': (diag(R)*A*diag(C))**H *inv(diag(R))*X = diag(C)*B */ |
| 22144 | /* Whether or not the system will be equilibrated depends on the */ |
| 22145 | /* scaling of the matrix A, but if equilibration is used, A is */ |
| 22146 | /* overwritten by diag(R)*A*diag(C) and B by diag(R)*B (if TRANS='N') */ |
| 22147 | /* or diag(C)*B (if TRANS = 'T' or 'C'). */ |
| 22148 | |
| 22149 | /* 2. If FACT = 'N' or 'E', the LU decomposition is used to factor the */ |
| 22150 | /* matrix A (after equilibration if FACT = 'E') as */ |
| 22151 | /* A = P * L * U, */ |
| 22152 | /* where P is a permutation matrix, L is a unit lower triangular */ |
| 22153 | /* matrix, and U is upper triangular. */ |
| 22154 | |
| 22155 | /* 3. If some U(i,i)=0, so that U is exactly singular, then the routine */ |
| 22156 | /* returns with INFO = i. Otherwise, the factored form of A is used */ |
| 22157 | /* to estimate the condition number of the matrix A. If the */ |
| 22158 | /* reciprocal of the condition number is less than machine precision, */ |
| 22159 | /* INFO = N+1 is returned as a warning, but the routine still goes on */ |
| 22160 | /* to solve for X and compute error bounds as described below. */ |
| 22161 | |
| 22162 | /* 4. The system of equations is solved for X using the factored form */ |
| 22163 | /* of A. */ |
| 22164 | |
| 22165 | /* 5. Iterative refinement is applied to improve the computed solution */ |
| 22166 | /* matrix and calculate error bounds and backward error estimates */ |
| 22167 | /* for it. */ |
| 22168 | |
| 22169 | /* 6. If equilibration was used, the matrix X is premultiplied by */ |
| 22170 | /* diag(C) (if TRANS = 'N') or diag(R) (if TRANS = 'T' or 'C') so */ |
| 22171 | /* that it solves the original system before equilibration. */ |
| 22172 | |
| 22173 | /* Arguments */ |
| 22174 | /* ========= */ |
| 22175 | |
| 22176 | /* FACT (input) CHARACTER*1 */ |
| 22177 | /* Specifies whether or not the factored form of the matrix A is */ |
| 22178 | /* supplied on entry, and if not, whether the matrix A should be */ |
| 22179 | /* equilibrated before it is factored. */ |
| 22180 | /* = 'F': On entry, AF and IPIV contain the factored form of A. */ |
| 22181 | /* If EQUED is not 'N', the matrix A has been */ |
| 22182 | /* equilibrated with scaling factors given by R and C. */ |
| 22183 | /* A, AF, and IPIV are not modified. */ |
| 22184 | /* = 'N': The matrix A will be copied to AF and factored. */ |
| 22185 | /* = 'E': The matrix A will be equilibrated if necessary, then */ |
| 22186 | /* copied to AF and factored. */ |
| 22187 | |
| 22188 | /* TRANS (input) CHARACTER*1 */ |
| 22189 | /* Specifies the form of the system of equations: */ |
| 22190 | /* = 'N': A * X = B (No transpose) */ |
| 22191 | /* = 'T': A**T * X = B (Transpose) */ |
| 22192 | /* = 'C': A**H * X = B (Transpose) */ |
| 22193 | |
| 22194 | /* N (input) INTEGER */ |
| 22195 | /* The number of linear equations, i.e., the order of the */ |
| 22196 | /* matrix A. N >= 0. */ |
| 22197 | |
| 22198 | /* NRHS (input) INTEGER */ |
| 22199 | /* The number of right hand sides, i.e., the number of columns */ |
| 22200 | /* of the matrices B and X. NRHS >= 0. */ |
| 22201 | |
| 22202 | /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 22203 | /* On entry, the N-by-N matrix A. If FACT = 'F' and EQUED is */ |
| 22204 | /* not 'N', then A must have been equilibrated by the scaling */ |
| 22205 | /* factors in R and/or C. A is not modified if FACT = 'F' or */ |
| 22206 | /* 'N', or if FACT = 'E' and EQUED = 'N' on exit. */ |
| 22207 | |
| 22208 | /* On exit, if EQUED .ne. 'N', A is scaled as follows: */ |
| 22209 | /* EQUED = 'R': A := diag(R) * A */ |
| 22210 | /* EQUED = 'C': A := A * diag(C) */ |
| 22211 | /* EQUED = 'B': A := diag(R) * A * diag(C). */ |
| 22212 | |
| 22213 | /* LDA (input) INTEGER */ |
| 22214 | /* The leading dimension of the array A. LDA >= max(1,N). */ |
| 22215 | |
| 22216 | /* AF (input or output) DOUBLE PRECISION array, dimension (LDAF,N) */ |
| 22217 | /* If FACT = 'F', then AF is an input argument and on entry */ |
| 22218 | /* contains the factors L and U from the factorization */ |
| 22219 | /* A = P*L*U as computed by DGETRF. If EQUED .ne. 'N', then */ |
| 22220 | /* AF is the factored form of the equilibrated matrix A. */ |
| 22221 | |
| 22222 | /* If FACT = 'N', then AF is an output argument and on exit */ |
| 22223 | /* returns the factors L and U from the factorization A = P*L*U */ |
| 22224 | /* of the original matrix A. */ |
| 22225 | |
| 22226 | /* If FACT = 'E', then AF is an output argument and on exit */ |
| 22227 | /* returns the factors L and U from the factorization A = P*L*U */ |
| 22228 | /* of the equilibrated matrix A (see the description of A for */ |
| 22229 | /* the form of the equilibrated matrix). */ |
| 22230 | |
| 22231 | /* LDAF (input) INTEGER */ |
| 22232 | /* The leading dimension of the array AF. LDAF >= max(1,N). */ |
| 22233 | |
| 22234 | /* IPIV (input or output) INTEGER array, dimension (N) */ |
| 22235 | /* If FACT = 'F', then IPIV is an input argument and on entry */ |
| 22236 | /* contains the pivot indices from the factorization A = P*L*U */ |
| 22237 | /* as computed by DGETRF; row i of the matrix was interchanged */ |
| 22238 | /* with row IPIV(i). */ |
| 22239 | |
| 22240 | /* If FACT = 'N', then IPIV is an output argument and on exit */ |
| 22241 | /* contains the pivot indices from the factorization A = P*L*U */ |
| 22242 | /* of the original matrix A. */ |
| 22243 | |
| 22244 | /* If FACT = 'E', then IPIV is an output argument and on exit */ |
| 22245 | /* contains the pivot indices from the factorization A = P*L*U */ |
| 22246 | /* of the equilibrated matrix A. */ |
| 22247 | |
| 22248 | /* EQUED (input or output) CHARACTER*1 */ |
| 22249 | /* Specifies the form of equilibration that was done. */ |
| 22250 | /* = 'N': No equilibration (always true if FACT = 'N'). */ |
| 22251 | /* = 'R': Row equilibration, i.e., A has been premultiplied by */ |
| 22252 | /* diag(R). */ |
| 22253 | /* = 'C': Column equilibration, i.e., A has been postmultiplied */ |
| 22254 | /* by diag(C). */ |
| 22255 | /* = 'B': Both row and column equilibration, i.e., A has been */ |
| 22256 | /* replaced by diag(R) * A * diag(C). */ |
| 22257 | /* EQUED is an input argument if FACT = 'F'; otherwise, it is an */ |
| 22258 | /* output argument. */ |
| 22259 | |
| 22260 | /* R (input or output) DOUBLE PRECISION array, dimension (N) */ |
| 22261 | /* The row scale factors for A. If EQUED = 'R' or 'B', A is */ |
| 22262 | /* multiplied on the left by diag(R); if EQUED = 'N' or 'C', R */ |
| 22263 | /* is not accessed. R is an input argument if FACT = 'F'; */ |
| 22264 | /* otherwise, R is an output argument. If FACT = 'F' and */ |
| 22265 | /* EQUED = 'R' or 'B', each element of R must be positive. */ |
| 22266 | |
| 22267 | /* C (input or output) DOUBLE PRECISION array, dimension (N) */ |
| 22268 | /* The column scale factors for A. If EQUED = 'C' or 'B', A is */ |
| 22269 | /* multiplied on the right by diag(C); if EQUED = 'N' or 'R', C */ |
| 22270 | /* is not accessed. C is an input argument if FACT = 'F'; */ |
| 22271 | /* otherwise, C is an output argument. If FACT = 'F' and */ |
| 22272 | /* EQUED = 'C' or 'B', each element of C must be positive. */ |
| 22273 | |
| 22274 | /* B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */ |
| 22275 | /* On entry, the N-by-NRHS right hand side matrix B. */ |
| 22276 | /* On exit, */ |
| 22277 | /* if EQUED = 'N', B is not modified; */ |
| 22278 | /* if TRANS = 'N' and EQUED = 'R' or 'B', B is overwritten by */ |
| 22279 | /* diag(R)*B; */ |
| 22280 | /* if TRANS = 'T' or 'C' and EQUED = 'C' or 'B', B is */ |
| 22281 | /* overwritten by diag(C)*B. */ |
| 22282 | |
| 22283 | /* LDB (input) INTEGER */ |
| 22284 | /* The leading dimension of the array B. LDB >= max(1,N). */ |
| 22285 | |
| 22286 | /* X (output) DOUBLE PRECISION array, dimension (LDX,NRHS) */ |
| 22287 | /* If INFO = 0 or INFO = N+1, the N-by-NRHS solution matrix X */ |
| 22288 | /* to the original system of equations. Note that A and B are */ |
| 22289 | /* modified on exit if EQUED .ne. 'N', and the solution to the */ |
| 22290 | /* equilibrated system is inv(diag(C))*X if TRANS = 'N' and */ |
| 22291 | /* EQUED = 'C' or 'B', or inv(diag(R))*X if TRANS = 'T' or 'C' */ |
| 22292 | /* and EQUED = 'R' or 'B'. */ |
| 22293 | |
| 22294 | /* LDX (input) INTEGER */ |
| 22295 | /* The leading dimension of the array X. LDX >= max(1,N). */ |
| 22296 | |
| 22297 | /* RCOND (output) DOUBLE PRECISION */ |
| 22298 | /* The estimate of the reciprocal condition number of the matrix */ |
| 22299 | /* A after equilibration (if done). If RCOND is less than the */ |
| 22300 | /* machine precision (in particular, if RCOND = 0), the matrix */ |
| 22301 | /* is singular to working precision. This condition is */ |
| 22302 | /* indicated by a return code of INFO > 0. */ |
| 22303 | |
| 22304 | /* FERR (output) DOUBLE PRECISION array, dimension (NRHS) */ |
| 22305 | /* The estimated forward error bound for each solution vector */ |
| 22306 | /* X(j) (the j-th column of the solution matrix X). */ |
| 22307 | /* If XTRUE is the true solution corresponding to X(j), FERR(j) */ |
| 22308 | /* is an estimated upper bound for the magnitude of the largest */ |
| 22309 | /* element in (X(j) - XTRUE) divided by the magnitude of the */ |
| 22310 | /* largest element in X(j). The estimate is as reliable as */ |
| 22311 | /* the estimate for RCOND, and is almost always a slight */ |
| 22312 | /* overestimate of the true error. */ |
| 22313 | |
| 22314 | /* BERR (output) DOUBLE PRECISION array, dimension (NRHS) */ |
| 22315 | /* The componentwise relative backward error of each solution */ |
| 22316 | /* vector X(j) (i.e., the smallest relative change in */ |
| 22317 | /* any element of A or B that makes X(j) an exact solution). */ |
| 22318 | |
| 22319 | /* WORK (workspace/output) DOUBLE PRECISION array, dimension (4*N) */ |
| 22320 | /* On exit, WORK(1) contains the reciprocal pivot growth */ |
| 22321 | /* factor norm(A)/norm(U). The "max absolute element" norm is */ |
| 22322 | /* used. If WORK(1) is much less than 1, then the stability */ |
| 22323 | /* of the LU factorization of the (equilibrated) matrix A */ |
| 22324 | /* could be poor. This also means that the solution X, condition */ |
| 22325 | /* estimator RCOND, and forward error bound FERR could be */ |
| 22326 | /* unreliable. If factorization fails with 0<INFO<=N, then */ |
| 22327 | /* WORK(1) contains the reciprocal pivot growth factor for the */ |
| 22328 | /* leading INFO columns of A. */ |
| 22329 | |
| 22330 | /* IWORK (workspace) INTEGER array, dimension (N) */ |
| 22331 | |
| 22332 | /* INFO (output) INTEGER */ |
| 22333 | /* = 0: successful exit */ |
| 22334 | /* < 0: if INFO = -i, the i-th argument had an illegal value */ |
| 22335 | /* > 0: if INFO = i, and i is */ |
| 22336 | /* <= N: U(i,i) is exactly zero. The factorization has */ |
| 22337 | /* been completed, but the factor U is exactly */ |
| 22338 | /* singular, so the solution and error bounds */ |
| 22339 | /* could not be computed. RCOND = 0 is returned. */ |
| 22340 | /* = N+1: U is nonsingular, but RCOND is less than machine */ |
| 22341 | /* precision, meaning that the matrix is singular */ |
| 22342 | /* to working precision. Nevertheless, the */ |
| 22343 | /* solution and error bounds are computed because */ |
| 22344 | /* there are a number of situations where the */ |
| 22345 | /* computed solution can be more accurate than the */ |
| 22346 | /* value of RCOND would suggest. */ |
| 22347 | |
| 22348 | /* ===================================================================== */ |
| 22349 | |
| 22350 | /* .. Parameters .. */ |
| 22351 | /* .. */ |
| 22352 | /* .. Local Scalars .. */ |
| 22353 | /* .. */ |
| 22354 | /* .. External Functions .. */ |
| 22355 | /* .. */ |
| 22356 | /* .. External Subroutines .. */ |
| 22357 | /* .. */ |
| 22358 | /* .. Intrinsic Functions .. */ |
| 22359 | /* .. */ |
| 22360 | /* .. Executable Statements .. */ |
| 22361 | |
| 22362 | /* Parameter adjustments */ |
| 22363 | a_dim1 = *lda; |
| 22364 | a_offset = 1 + a_dim1; |
| 22365 | a -= a_offset; |
| 22366 | af_dim1 = *ldaf; |
| 22367 | af_offset = 1 + af_dim1; |
| 22368 | af -= af_offset; |
| 22369 | --ipiv; |
| 22370 | --r__; |
| 22371 | --c__; |
| 22372 | b_dim1 = *ldb; |
| 22373 | b_offset = 1 + b_dim1; |
| 22374 | b -= b_offset; |
| 22375 | x_dim1 = *ldx; |
| 22376 | x_offset = 1 + x_dim1; |
| 22377 | x -= x_offset; |
| 22378 | --ferr; |
| 22379 | --berr; |
| 22380 | --work; |
| 22381 | --iwork; |
| 22382 | |
| 22383 | /* Function Body */ |
| 22384 | *info = 0; |
| 22385 | nofact = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(fact, "N"); |
| 22386 | equil = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(fact, "E"); |
| 22387 | notran = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(trans, "N"); |
| 22388 | if (nofact || equil) { |
| 22389 | *(unsigned char *)equed = 'N'; |
| 22390 | rowequ = false; |
| 22391 | colequ = false; |
| 22392 | } else { |
| 22393 | rowequ = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(equed, "R") || lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(equed, |
| 22394 | "B"); |
| 22395 | colequ = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(equed, "C") || lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(equed, |
| 22396 | "B"); |
| 22397 | smlnum = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("Safe minimum"); |
| 22398 | bignum = 1. / smlnum; |
| 22399 | } |
| 22400 | |
| 22401 | /* Test the input parameters. */ |
| 22402 | |
| 22403 | if (! nofact && ! equil && ! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(fact, "F")) { |
| 22404 | *info = -1; |
| 22405 | } else if (! notran && ! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(trans, "T") && ! |
| 22406 | lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(trans, "C")) { |
| 22407 | *info = -2; |
| 22408 | } else if (*n < 0) { |
| 22409 | *info = -3; |
| 22410 | } else if (*nrhs < 0) { |
| 22411 | *info = -4; |
| 22412 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 22413 | *info = -6; |
| 22414 | } else if (*ldaf < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 22415 | *info = -8; |
| 22416 | } else if (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(fact, "F") && ! (rowequ || colequ |
| 22417 | || lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(equed, "N"))) { |
| 22418 | *info = -10; |
| 22419 | } else { |
| 22420 | if (rowequ) { |
| 22421 | rcmin = bignum; |
| 22422 | rcmax = 0.; |
| 22423 | i__1 = *n; |
| 22424 | for (j = 1; j <= i__1; ++j) { |
| 22425 | /* Computing MIN */ |
| 22426 | d__1 = rcmin, d__2 = r__[j]; |
| 22427 | rcmin = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(d__1,d__2); |
| 22428 | /* Computing MAX */ |
| 22429 | d__1 = rcmax, d__2 = r__[j]; |
| 22430 | rcmax = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__1,d__2); |
| 22431 | /* L10: */ |
| 22432 | } |
| 22433 | if (rcmin <= 0.) { |
| 22434 | *info = -11; |
| 22435 | } else if (*n > 0) { |
| 22436 | rowcnd = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(rcmin,smlnum) / stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(rcmax,bignum); |
| 22437 | } else { |
| 22438 | rowcnd = 1.; |
| 22439 | } |
| 22440 | } |
| 22441 | if (colequ && *info == 0) { |
| 22442 | rcmin = bignum; |
| 22443 | rcmax = 0.; |
| 22444 | i__1 = *n; |
| 22445 | for (j = 1; j <= i__1; ++j) { |
| 22446 | /* Computing MIN */ |
| 22447 | d__1 = rcmin, d__2 = c__[j]; |
| 22448 | rcmin = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(d__1,d__2); |
| 22449 | /* Computing MAX */ |
| 22450 | d__1 = rcmax, d__2 = c__[j]; |
| 22451 | rcmax = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__1,d__2); |
| 22452 | /* L20: */ |
| 22453 | } |
| 22454 | if (rcmin <= 0.) { |
| 22455 | *info = -12; |
| 22456 | } else if (*n > 0) { |
| 22457 | colcnd = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(rcmin,smlnum) / stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(rcmax,bignum); |
| 22458 | } else { |
| 22459 | colcnd = 1.; |
| 22460 | } |
| 22461 | } |
| 22462 | if (*info == 0) { |
| 22463 | if (*ldb < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 22464 | *info = -14; |
| 22465 | } else if (*ldx < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 22466 | *info = -16; |
| 22467 | } |
| 22468 | } |
| 22469 | } |
| 22470 | |
| 22471 | if (*info != 0) { |
| 22472 | i__1 = -(*info); |
| 22473 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGESVX", &i__1); |
| 22474 | return 0; |
| 22475 | } |
| 22476 | |
| 22477 | if (equil) { |
| 22478 | |
| 22479 | /* Compute row and column scalings to equilibrate the matrix A. */ |
| 22480 | |
| 22481 | dgeequ_cxx . . $ dgeequ_(799434dec6c8879c).(n, n, &a[a_offset], lda, &r__[1], &c__[1], &rowcnd, &colcnd, & |
| 22482 | amax, &infequ); |
| 22483 | if (infequ == 0) { |
| 22484 | |
| 22485 | /* Equilibrate the matrix. */ |
| 22486 | |
| 22487 | dlaqge_cxx . . $ dlaqge_(4c009949350fbf00).(n, n, &a[a_offset], lda, &r__[1], &c__[1], &rowcnd, & |
| 22488 | colcnd, &amax, equed); |
| 22489 | rowequ = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(equed, "R") || lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(equed, |
| 22490 | "B"); |
| 22491 | colequ = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(equed, "C") || lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(equed, |
| 22492 | "B"); |
| 22493 | } |
| 22494 | } |
| 22495 | |
| 22496 | /* Scale the right hand side. */ |
| 22497 | |
| 22498 | if (notran) { |
| 22499 | if (rowequ) { |
| 22500 | i__1 = *nrhs; |
| 22501 | for (j = 1; j <= i__1; ++j) { |
| 22502 | i__2 = *n; |
| 22503 | for (i__ = 1; i__ <= i__2; ++i__) { |
| 22504 | b[i__ + j * b_dim1] = r__[i__] * b[i__ + j * b_dim1]; |
| 22505 | /* L30: */ |
| 22506 | } |
| 22507 | /* L40: */ |
| 22508 | } |
| 22509 | } |
| 22510 | } else if (colequ) { |
| 22511 | i__1 = *nrhs; |
| 22512 | for (j = 1; j <= i__1; ++j) { |
| 22513 | i__2 = *n; |
| 22514 | for (i__ = 1; i__ <= i__2; ++i__) { |
| 22515 | b[i__ + j * b_dim1] = c__[i__] * b[i__ + j * b_dim1]; |
| 22516 | /* L50: */ |
| 22517 | } |
| 22518 | /* L60: */ |
| 22519 | } |
| 22520 | } |
| 22521 | |
| 22522 | if (nofact || equil) { |
| 22523 | |
| 22524 | /* Compute the LU factorization of A. */ |
| 22525 | |
| 22526 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("Full", n, n, &a[a_offset], lda, &af[af_offset], ldaf); |
| 22527 | dgetrf_cxx . . $ dgetrf_(7c7a27c235ac304).(n, n, &af[af_offset], ldaf, &ipiv[1], info); |
| 22528 | |
| 22529 | /* Return if INFO is non-zero. */ |
| 22530 | |
| 22531 | if (*info > 0) { |
| 22532 | |
| 22533 | /* Compute the reciprocal pivot growth factor of the */ |
| 22534 | /* leading rank-deficient INFO columns of A. */ |
| 22535 | |
| 22536 | rpvgrw = dlantr_cxx . . $ dlantr_(7eea4a72e21f75ae).("M", "U", "N", info, info, &af[af_offset], ldaf, |
| 22537 | &work[1]); |
| 22538 | if (rpvgrw == 0.) { |
| 22539 | rpvgrw = 1.; |
| 22540 | } else { |
| 22541 | rpvgrw = dlange_cxx . . $ dlange_(98d44e6417336f20).("M", n, info, &a[a_offset], lda, &work[1]) / rpvgrw; |
| 22542 | } |
| 22543 | work[1] = rpvgrw; |
| 22544 | *rcond = 0.; |
| 22545 | return 0; |
| 22546 | } |
| 22547 | } |
| 22548 | |
| 22549 | /* Compute the norm of the matrix A and the */ |
| 22550 | /* reciprocal pivot growth factor RPVGRW. */ |
| 22551 | |
| 22552 | if (notran) { |
| 22553 | *(unsigned char *)norm = '1'; |
| 22554 | } else { |
| 22555 | *(unsigned char *)norm = 'I'; |
| 22556 | } |
| 22557 | anorm = dlange_cxx . . $ dlange_(98d44e6417336f20).(norm, n, n, &a[a_offset], lda, &work[1]); |
| 22558 | rpvgrw = dlantr_cxx . . $ dlantr_(7eea4a72e21f75ae).("M", "U", "N", n, n, &af[af_offset], ldaf, &work[1]); |
| 22559 | if (rpvgrw == 0.) { |
| 22560 | rpvgrw = 1.; |
| 22561 | } else { |
| 22562 | rpvgrw = dlange_cxx . . $ dlange_(98d44e6417336f20).("M", n, n, &a[a_offset], lda, &work[1]) / |
| 22563 | rpvgrw; |
| 22564 | } |
| 22565 | |
| 22566 | /* Compute the reciprocal of the condition number of A. */ |
| 22567 | |
| 22568 | dgecon_cxx . . $ dgecon_(c4c31d5cb8de3c00).(norm, n, &af[af_offset], ldaf, &anorm, rcond, &work[1], &iwork[1], |
| 22569 | info); |
| 22570 | |
| 22571 | /* Compute the solution matrix X. */ |
| 22572 | |
| 22573 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("Full", n, nrhs, &b[b_offset], ldb, &x[x_offset], ldx); |
| 22574 | dgetrs_cxx . . $ dgetrs_(695824aa3fbf5aa2).(trans, n, nrhs, &af[af_offset], ldaf, &ipiv[1], &x[x_offset], ldx, |
| 22575 | info); |
| 22576 | |
| 22577 | /* Use iterative refinement to improve the computed solution and */ |
| 22578 | /* compute error bounds and backward error estimates for it. */ |
| 22579 | |
| 22580 | dgerfs_cxx . . $ dgerfs_(1ca1405a8fa14711).(trans, n, nrhs, &a[a_offset], lda, &af[af_offset], ldaf, &ipiv[1], |
| 22581 | &b[b_offset], ldb, &x[x_offset], ldx, &ferr[1], &berr[1], &work[ |
| 22582 | 1], &iwork[1], info); |
| 22583 | |
| 22584 | /* Transform the solution matrix X to a solution of the original */ |
| 22585 | /* system. */ |
| 22586 | |
| 22587 | if (notran) { |
| 22588 | if (colequ) { |
| 22589 | i__1 = *nrhs; |
| 22590 | for (j = 1; j <= i__1; ++j) { |
| 22591 | i__2 = *n; |
| 22592 | for (i__ = 1; i__ <= i__2; ++i__) { |
| 22593 | x[i__ + j * x_dim1] = c__[i__] * x[i__ + j * x_dim1]; |
| 22594 | /* L70: */ |
| 22595 | } |
| 22596 | /* L80: */ |
| 22597 | } |
| 22598 | i__1 = *nrhs; |
| 22599 | for (j = 1; j <= i__1; ++j) { |
| 22600 | ferr[j] /= colcnd; |
| 22601 | /* L90: */ |
| 22602 | } |
| 22603 | } |
| 22604 | } else if (rowequ) { |
| 22605 | i__1 = *nrhs; |
| 22606 | for (j = 1; j <= i__1; ++j) { |
| 22607 | i__2 = *n; |
| 22608 | for (i__ = 1; i__ <= i__2; ++i__) { |
| 22609 | x[i__ + j * x_dim1] = r__[i__] * x[i__ + j * x_dim1]; |
| 22610 | /* L100: */ |
| 22611 | } |
| 22612 | /* L110: */ |
| 22613 | } |
| 22614 | i__1 = *nrhs; |
| 22615 | for (j = 1; j <= i__1; ++j) { |
| 22616 | ferr[j] /= rowcnd; |
| 22617 | /* L120: */ |
| 22618 | } |
| 22619 | } |
| 22620 | |
| 22621 | work[1] = rpvgrw; |
| 22622 | |
| 22623 | /* Set INFO = N+1 if the matrix is singular to working precision. */ |
| 22624 | |
| 22625 | if (*rcond < dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("Epsilon")) { |
| 22626 | *info = *n + 1; |
| 22627 | } |
| 22628 | return 0; |
| 22629 | |
| 22630 | /* End of DGESVX */ |
| 22631 | |
| 22632 | } /* dgesvx_ */ |
| 22633 | |
| 22634 | /* Subroutine */ int dgetc2_cxx . . $ dgetc2_(3463a98330458138).(integercxx . . $ integer# *n, double *a, integercxx . . $ integer# *lda, integercxx . . $ integer# |
| 22635 | *ipiv, integercxx . . $ integer# *jpiv, integercxx . . $ integer# *info) |
| 22636 | { |
| 22637 | /* Table of constant values */ |
| 22638 | static integercxx . . $ integer# c__1 = 1; |
| 22639 | static double c_b10 = -1.; |
| 22640 | |
| 22641 | /* System generated locals */ |
| 22642 | integercxx . . $ integer# a_dim1, a_offset, i__1, i__2, i__3; |
| 22643 | double d__1; |
| 22644 | |
| 22645 | /* Local variables */ |
| 22646 | integercxx . . $ integer# i__, j, ip, jp; |
| 22647 | double eps; |
| 22648 | integercxx . . $ integer# ipv, jpv; |
| 22649 | double smin, xmax; |
| 22650 | double bignum, smlnum; |
| 22651 | |
| 22652 | |
| 22653 | /* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 22654 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 22655 | /* November 2006 */ |
| 22656 | |
| 22657 | /* .. Scalar Arguments .. */ |
| 22658 | /* .. */ |
| 22659 | /* .. Array Arguments .. */ |
| 22660 | /* .. */ |
| 22661 | |
| 22662 | /* Purpose */ |
| 22663 | /* ======= */ |
| 22664 | |
| 22665 | /* DGETC2 computes an LU factorization with complete pivoting of the */ |
| 22666 | /* n-by-n matrix A. The factorization has the form A = P * L * U * Q, */ |
| 22667 | /* where P and Q are permutation matrices, L is lower triangular with */ |
| 22668 | /* unit diagonal elements and U is upper triangular. */ |
| 22669 | |
| 22670 | /* This is the Level 2 BLAS algorithm. */ |
| 22671 | |
| 22672 | /* Arguments */ |
| 22673 | /* ========= */ |
| 22674 | |
| 22675 | /* N (input) INTEGER */ |
| 22676 | /* The order of the matrix A. N >= 0. */ |
| 22677 | |
| 22678 | /* A (input/output) DOUBLE PRECISION array, dimension (LDA, N) */ |
| 22679 | /* On entry, the n-by-n matrix A to be factored. */ |
| 22680 | /* On exit, the factors L and U from the factorization */ |
| 22681 | /* A = P*L*U*Q; the unit diagonal elements of L are not stored. */ |
| 22682 | /* If U(k, k) appears to be less than SMIN, U(k, k) is given the */ |
| 22683 | /* value of SMIN, i.e., giving a nonsingular perturbed system. */ |
| 22684 | |
| 22685 | /* LDA (input) INTEGER */ |
| 22686 | /* The leading dimension of the array A. LDA >= max(1,N). */ |
| 22687 | |
| 22688 | /* IPIV (output) INTEGER array, dimension(N). */ |
| 22689 | /* The pivot indices; for 1 <= i <= N, row i of the */ |
| 22690 | /* matrix has been interchanged with row IPIV(i). */ |
| 22691 | |
| 22692 | /* JPIV (output) INTEGER array, dimension(N). */ |
| 22693 | /* The pivot indices; for 1 <= j <= N, column j of the */ |
| 22694 | /* matrix has been interchanged with column JPIV(j). */ |
| 22695 | |
| 22696 | /* INFO (output) INTEGER */ |
| 22697 | /* = 0: successful exit */ |
| 22698 | /* > 0: if INFO = k, U(k, k) is likely to produce owerflow if */ |
| 22699 | /* we try to solve for x in Ax = b. So U is perturbed to */ |
| 22700 | /* avoid the overflow. */ |
| 22701 | |
| 22702 | /* Further Details */ |
| 22703 | /* =============== */ |
| 22704 | |
| 22705 | /* Based on contributions by */ |
| 22706 | /* Bo Kagstrom and Peter Poromaa, Department of Computing Science, */ |
| 22707 | /* Umea University, S-901 87 Umea, Sweden. */ |
| 22708 | |
| 22709 | /* ===================================================================== */ |
| 22710 | |
| 22711 | /* .. Parameters .. */ |
| 22712 | /* .. */ |
| 22713 | /* .. Local Scalars .. */ |
| 22714 | /* .. */ |
| 22715 | /* .. External Subroutines .. */ |
| 22716 | /* .. */ |
| 22717 | /* .. External Functions .. */ |
| 22718 | /* .. */ |
| 22719 | /* .. Intrinsic Functions .. */ |
| 22720 | /* .. */ |
| 22721 | /* .. Executable Statements .. */ |
| 22722 | |
| 22723 | /* Set constants to control overflow */ |
| 22724 | |
| 22725 | /* Parameter adjustments */ |
| 22726 | a_dim1 = *lda; |
| 22727 | a_offset = 1 + a_dim1; |
| 22728 | a -= a_offset; |
| 22729 | --ipiv; |
| 22730 | --jpiv; |
| 22731 | |
| 22732 | /* Function Body */ |
| 22733 | *info = 0; |
| 22734 | eps = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("P"); |
| 22735 | smlnum = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("S") / eps; |
| 22736 | bignum = 1. / smlnum; |
| 22737 | dlabad_cxx . . $ dlabad_(4730c933dae9b326).(&smlnum, &bignum); |
| 22738 | |
| 22739 | /* Factorize A using complete pivoting. */ |
| 22740 | /* Set pivots less than SMIN to SMIN. */ |
| 22741 | |
| 22742 | i__1 = *n - 1; |
| 22743 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 22744 | |
| 22745 | /* Find max element in matrix A */ |
| 22746 | |
| 22747 | xmax = 0.; |
| 22748 | i__2 = *n; |
| 22749 | for (ip = i__; ip <= i__2; ++ip) { |
| 22750 | i__3 = *n; |
| 22751 | for (jp = i__; jp <= i__3; ++jp) { |
| 22752 | if ((d__1 = a[ip + jp * a_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__1)) >= xmax) { |
| 22753 | xmax = (d__1 = a[ip + jp * a_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__1)); |
| 22754 | ipv = ip; |
| 22755 | jpv = jp; |
| 22756 | } |
| 22757 | /* L10: */ |
| 22758 | } |
| 22759 | /* L20: */ |
| 22760 | } |
| 22761 | if (i__ == 1) { |
| 22762 | /* Computing MAX */ |
| 22763 | d__1 = eps * xmax; |
| 22764 | smin = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__1,smlnum); |
| 22765 | } |
| 22766 | |
| 22767 | /* Swap rows */ |
| 22768 | |
| 22769 | if (ipv != i__) { |
| 22770 | dswap_cxx . . $ dswap_(ec261fd7ec3b6bf6).(n, &a[ipv + a_dim1], lda, &a[i__ + a_dim1], lda); |
| 22771 | } |
| 22772 | ipiv[i__] = ipv; |
| 22773 | |
| 22774 | /* Swap columns */ |
| 22775 | |
| 22776 | if (jpv != i__) { |
| 22777 | dswap_cxx . . $ dswap_(ec261fd7ec3b6bf6).(n, &a[jpv * a_dim1 + 1], &c__1, &a[i__ * a_dim1 + 1], & |
| 22778 | c__1); |
| 22779 | } |
| 22780 | jpiv[i__] = jpv; |
| 22781 | |
| 22782 | /* Check for singularity */ |
| 22783 | |
| 22784 | if ((d__1 = a[i__ + i__ * a_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__1)) < smin) { |
| 22785 | *info = i__; |
| 22786 | a[i__ + i__ * a_dim1] = smin; |
| 22787 | } |
| 22788 | i__2 = *n; |
| 22789 | for (j = i__ + 1; j <= i__2; ++j) { |
| 22790 | a[j + i__ * a_dim1] /= a[i__ + i__ * a_dim1]; |
| 22791 | /* L30: */ |
| 22792 | } |
| 22793 | i__2 = *n - i__; |
| 22794 | i__3 = *n - i__; |
| 22795 | dger_cxx . . $ dger_(655ac4c2f34f763a).(&i__2, &i__3, &c_b10, &a[i__ + 1 + i__ * a_dim1], &c__1, &a[i__ |
| 22796 | + (i__ + 1) * a_dim1], lda, &a[i__ + 1 + (i__ + 1) * a_dim1], |
| 22797 | lda); |
| 22798 | /* L40: */ |
| 22799 | } |
| 22800 | |
| 22801 | if ((d__1 = a[*n + *n * a_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__1)) < smin) { |
| 22802 | *info = *n; |
| 22803 | a[*n + *n * a_dim1] = smin; |
| 22804 | } |
| 22805 | |
| 22806 | return 0; |
| 22807 | |
| 22808 | /* End of DGETC2 */ |
| 22809 | |
| 22810 | } /* dgetc2_ */ |
| 22811 | |
| 22812 | /* Subroutine */ int dgetf2_cxx . . $ dgetf2_(7c7a27c235ac304).(integercxx . . $ integer# *m, integercxx . . $ integer# *n, double *a, integercxx . . $ integer# * |
| 22813 | lda, integercxx . . $ integer# *ipiv, integercxx . . $ integer# *info) |
| 22814 | { |
| 22815 | /* Table of constant values */ |
| 22816 | static integercxx . . $ integer# c__1 = 1; |
| 22817 | static double c_b8 = -1.; |
| 22818 | |
| 22819 | /* System generated locals */ |
| 22820 | integercxx . . $ integer# a_dim1, a_offset, i__1, i__2, i__3; |
| 22821 | double d__1; |
| 22822 | |
| 22823 | /* Local variables */ |
| 22824 | integercxx . . $ integer# i__, j, jp; |
| 22825 | double sfmin; |
| 22826 | |
| 22827 | /* -- LAPACK routine (version 3.1) -- */ |
| 22828 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 22829 | /* November 2006 */ |
| 22830 | |
| 22831 | /* .. Scalar Arguments .. */ |
| 22832 | /* .. */ |
| 22833 | /* .. Array Arguments .. */ |
| 22834 | /* .. */ |
| 22835 | |
| 22836 | /* Purpose */ |
| 22837 | /* ======= */ |
| 22838 | |
| 22839 | /* DGETF2 computes an LU factorization of a general m-by-n matrix A */ |
| 22840 | /* using partial pivoting with row interchanges. */ |
| 22841 | |
| 22842 | /* The factorization has the form */ |
| 22843 | /* A = P * L * U */ |
| 22844 | /* where P is a permutation matrix, L is lower triangular with unit */ |
| 22845 | /* diagonal elements (lower trapezoidal if m > n), and U is upper */ |
| 22846 | /* triangular (upper trapezoidal if m < n). */ |
| 22847 | |
| 22848 | /* This is the right-looking Level 2 BLAS version of the algorithm. */ |
| 22849 | |
| 22850 | /* Arguments */ |
| 22851 | /* ========= */ |
| 22852 | |
| 22853 | /* M (input) INTEGER */ |
| 22854 | /* The number of rows of the matrix A. M >= 0. */ |
| 22855 | |
| 22856 | /* N (input) INTEGER */ |
| 22857 | /* The number of columns of the matrix A. N >= 0. */ |
| 22858 | |
| 22859 | /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 22860 | /* On entry, the m by n matrix to be factored. */ |
| 22861 | /* On exit, the factors L and U from the factorization */ |
| 22862 | /* A = P*L*U; the unit diagonal elements of L are not stored. */ |
| 22863 | |
| 22864 | /* LDA (input) INTEGER */ |
| 22865 | /* The leading dimension of the array A. LDA >= max(1,M). */ |
| 22866 | |
| 22867 | /* IPIV (output) INTEGER array, dimension (min(M,N)) */ |
| 22868 | /* The pivot indices; for 1 <= i <= min(M,N), row i of the */ |
| 22869 | /* matrix was interchanged with row IPIV(i). */ |
| 22870 | |
| 22871 | /* INFO (output) INTEGER */ |
| 22872 | /* = 0: successful exit */ |
| 22873 | /* < 0: if INFO = -k, the k-th argument had an illegal value */ |
| 22874 | /* > 0: if INFO = k, U(k,k) is exactly zero. The factorization */ |
| 22875 | /* has been completed, but the factor U is exactly */ |
| 22876 | /* singular, and division by zero will occur if it is used */ |
| 22877 | /* to solve a system of equations. */ |
| 22878 | |
| 22879 | /* ===================================================================== */ |
| 22880 | |
| 22881 | /* .. Parameters .. */ |
| 22882 | /* .. */ |
| 22883 | /* .. Local Scalars .. */ |
| 22884 | /* .. */ |
| 22885 | /* .. External Functions .. */ |
| 22886 | /* .. */ |
| 22887 | /* .. External Subroutines .. */ |
| 22888 | /* .. */ |
| 22889 | /* .. Intrinsic Functions .. */ |
| 22890 | /* .. */ |
| 22891 | /* .. Executable Statements .. */ |
| 22892 | |
| 22893 | /* Test the input parameters. */ |
| 22894 | |
| 22895 | /* Parameter adjustments */ |
| 22896 | a_dim1 = *lda; |
| 22897 | a_offset = 1 + a_dim1; |
| 22898 | a -= a_offset; |
| 22899 | --ipiv; |
| 22900 | |
| 22901 | /* Function Body */ |
| 22902 | *info = 0; |
| 22903 | if (*m < 0) { |
| 22904 | *info = -1; |
| 22905 | } else if (*n < 0) { |
| 22906 | *info = -2; |
| 22907 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*m)) { |
| 22908 | *info = -4; |
| 22909 | } |
| 22910 | if (*info != 0) { |
| 22911 | i__1 = -(*info); |
| 22912 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGETF2", &i__1); |
| 22913 | return 0; |
| 22914 | } |
| 22915 | |
| 22916 | /* Quick return if possible */ |
| 22917 | |
| 22918 | if (*m == 0 || *n == 0) { |
| 22919 | return 0; |
| 22920 | } |
| 22921 | |
| 22922 | /* Compute machine safe minimum */ |
| 22923 | |
| 22924 | sfmin = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("S"); |
| 22925 | |
| 22926 | i__1 = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(*m,*n); |
| 22927 | for (j = 1; j <= i__1; ++j) { |
| 22928 | |
| 22929 | /* Find pivot and test for singularity. */ |
| 22930 | |
| 22931 | i__2 = *m - j + 1; |
| 22932 | jp = j - 1 + idamax_cxx . . $ idamax_(a5c31fbfbc00ee45).(&i__2, &a[j + j * a_dim1], &c__1); |
| 22933 | ipiv[j] = jp; |
| 22934 | if (a[jp + j * a_dim1] != 0.) { |
| 22935 | |
| 22936 | /* Apply the interchange to columns 1:N. */ |
| 22937 | |
| 22938 | if (jp != j) { |
| 22939 | dswap_cxx . . $ dswap_(ec261fd7ec3b6bf6).(n, &a[j + a_dim1], lda, &a[jp + a_dim1], lda); |
| 22940 | } |
| 22941 | |
| 22942 | /* Compute elements J+1:M of J-th column. */ |
| 22943 | |
| 22944 | if (j < *m) { |
| 22945 | if ((d__1 = a[j + j * a_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__1)) >= sfmin) { |
| 22946 | i__2 = *m - j; |
| 22947 | d__1 = 1. / a[j + j * a_dim1]; |
| 22948 | dscal_cxx . . $ dscal_(f22c1db71784c345).(&i__2, &d__1, &a[j + 1 + j * a_dim1], &c__1); |
| 22949 | } else { |
| 22950 | i__2 = *m - j; |
| 22951 | for (i__ = 1; i__ <= i__2; ++i__) { |
| 22952 | a[j + i__ + j * a_dim1] /= a[j + j * a_dim1]; |
| 22953 | /* L20: */ |
| 22954 | } |
| 22955 | } |
| 22956 | } |
| 22957 | |
| 22958 | } else if (*info == 0) { |
| 22959 | |
| 22960 | *info = j; |
| 22961 | } |
| 22962 | |
| 22963 | if (j < stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(*m,*n)) { |
| 22964 | |
| 22965 | /* Update trailing submatrix. */ |
| 22966 | |
| 22967 | i__2 = *m - j; |
| 22968 | i__3 = *n - j; |
| 22969 | dger_cxx . . $ dger_(655ac4c2f34f763a).(&i__2, &i__3, &c_b8, &a[j + 1 + j * a_dim1], &c__1, &a[j + ( |
| 22970 | j + 1) * a_dim1], lda, &a[j + 1 + (j + 1) * a_dim1], lda); |
| 22971 | } |
| 22972 | /* L10: */ |
| 22973 | } |
| 22974 | return 0; |
| 22975 | |
| 22976 | /* End of DGETF2 */ |
| 22977 | |
| 22978 | } /* dgetf2_ */ |
| 22979 | |
| 22980 | /* Subroutine */ int dgetrf_cxx . . $ dgetrf_(7c7a27c235ac304).(integercxx . . $ integer# *m, integercxx . . $ integer# *n, double *a, integercxx . . $ integer# * |
| 22981 | lda, integercxx . . $ integer# *ipiv, integercxx . . $ integer# *info) |
| 22982 | { |
| 22983 | /* Table of constant values */ |
| 22984 | static integercxx . . $ integer# c__1 = 1; |
| 22985 | static integercxx . . $ integer# c_n1 = -1; |
| 22986 | static double c_b16 = 1.; |
| 22987 | static double c_b19 = -1.; |
| 22988 | |
| 22989 | /* System generated locals */ |
| 22990 | integercxx . . $ integer# a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5; |
| 22991 | |
| 22992 | /* Local variables */ |
| 22993 | integercxx . . $ integer# i__, j, jb, nb; |
| 22994 | integercxx . . $ integer# iinfo; |
| 22995 | |
| 22996 | |
| 22997 | /* -- LAPACK routine (version 3.1) -- */ |
| 22998 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 22999 | /* November 2006 */ |
| 23000 | |
| 23001 | /* .. Scalar Arguments .. */ |
| 23002 | /* .. */ |
| 23003 | /* .. Array Arguments .. */ |
| 23004 | /* .. */ |
| 23005 | |
| 23006 | /* Purpose */ |
| 23007 | /* ======= */ |
| 23008 | |
| 23009 | /* DGETRF computes an LU factorization of a general M-by-N matrix A */ |
| 23010 | /* using partial pivoting with row interchanges. */ |
| 23011 | |
| 23012 | /* The factorization has the form */ |
| 23013 | /* A = P * L * U */ |
| 23014 | /* where P is a permutation matrix, L is lower triangular with unit */ |
| 23015 | /* diagonal elements (lower trapezoidal if m > n), and U is upper */ |
| 23016 | /* triangular (upper trapezoidal if m < n). */ |
| 23017 | |
| 23018 | /* This is the right-looking Level 3 BLAS version of the algorithm. */ |
| 23019 | |
| 23020 | /* Arguments */ |
| 23021 | /* ========= */ |
| 23022 | |
| 23023 | /* M (input) INTEGER */ |
| 23024 | /* The number of rows of the matrix A. M >= 0. */ |
| 23025 | |
| 23026 | /* N (input) INTEGER */ |
| 23027 | /* The number of columns of the matrix A. N >= 0. */ |
| 23028 | |
| 23029 | /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 23030 | /* On entry, the M-by-N matrix to be factored. */ |
| 23031 | /* On exit, the factors L and U from the factorization */ |
| 23032 | /* A = P*L*U; the unit diagonal elements of L are not stored. */ |
| 23033 | |
| 23034 | /* LDA (input) INTEGER */ |
| 23035 | /* The leading dimension of the array A. LDA >= max(1,M). */ |
| 23036 | |
| 23037 | /* IPIV (output) INTEGER array, dimension (min(M,N)) */ |
| 23038 | /* The pivot indices; for 1 <= i <= min(M,N), row i of the */ |
| 23039 | /* matrix was interchanged with row IPIV(i). */ |
| 23040 | |
| 23041 | /* INFO (output) INTEGER */ |
| 23042 | /* = 0: successful exit */ |
| 23043 | /* < 0: if INFO = -i, the i-th argument had an illegal value */ |
| 23044 | /* > 0: if INFO = i, U(i,i) is exactly zero. The factorization */ |
| 23045 | /* has been completed, but the factor U is exactly */ |
| 23046 | /* singular, and division by zero will occur if it is used */ |
| 23047 | /* to solve a system of equations. */ |
| 23048 | |
| 23049 | /* ===================================================================== */ |
| 23050 | |
| 23051 | /* .. Parameters .. */ |
| 23052 | /* .. */ |
| 23053 | /* .. Local Scalars .. */ |
| 23054 | /* .. */ |
| 23055 | /* .. External Subroutines .. */ |
| 23056 | /* .. */ |
| 23057 | /* .. External Functions .. */ |
| 23058 | /* .. */ |
| 23059 | /* .. Intrinsic Functions .. */ |
| 23060 | /* .. */ |
| 23061 | /* .. Executable Statements .. */ |
| 23062 | |
| 23063 | /* Test the input parameters. */ |
| 23064 | |
| 23065 | /* Parameter adjustments */ |
| 23066 | a_dim1 = *lda; |
| 23067 | a_offset = 1 + a_dim1; |
| 23068 | a -= a_offset; |
| 23069 | --ipiv; |
| 23070 | |
| 23071 | /* Function Body */ |
| 23072 | *info = 0; |
| 23073 | if (*m < 0) { |
| 23074 | *info = -1; |
| 23075 | } else if (*n < 0) { |
| 23076 | *info = -2; |
| 23077 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*m)) { |
| 23078 | *info = -4; |
| 23079 | } |
| 23080 | if (*info != 0) { |
| 23081 | i__1 = -(*info); |
| 23082 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGETRF", &i__1); |
| 23083 | return 0; |
| 23084 | } |
| 23085 | |
| 23086 | /* Quick return if possible */ |
| 23087 | |
| 23088 | if (*m == 0 || *n == 0) { |
| 23089 | return 0; |
| 23090 | } |
| 23091 | |
| 23092 | /* Determine the block size for this environment. */ |
| 23093 | |
| 23094 | nb = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGETRF", " ", m, n, &c_n1, &c_n1); |
| 23095 | if (nb <= 1 || nb >= stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(*m,*n)) { |
| 23096 | |
| 23097 | /* Use unblocked code. */ |
| 23098 | |
| 23099 | dgetf2_cxx . . $ dgetf2_(7c7a27c235ac304).(m, n, &a[a_offset], lda, &ipiv[1], info); |
| 23100 | } else { |
| 23101 | |
| 23102 | /* Use blocked code. */ |
| 23103 | |
| 23104 | i__1 = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(*m,*n); |
| 23105 | i__2 = nb; |
| 23106 | for (j = 1; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) { |
| 23107 | /* Computing MIN */ |
| 23108 | i__3 = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(*m,*n) - j + 1; |
| 23109 | jb = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__3,nb); |
| 23110 | |
| 23111 | /* Factor diagonal and subdiagonal blocks and test for exact */ |
| 23112 | /* singularity. */ |
| 23113 | |
| 23114 | i__3 = *m - j + 1; |
| 23115 | dgetf2_cxx . . $ dgetf2_(7c7a27c235ac304).(&i__3, &jb, &a[j + j * a_dim1], lda, &ipiv[j], &iinfo); |
| 23116 | |
| 23117 | /* Adjust INFO and the pivot indices. */ |
| 23118 | |
| 23119 | if (*info == 0 && iinfo > 0) { |
| 23120 | *info = iinfo + j - 1; |
| 23121 | } |
| 23122 | /* Computing MIN */ |
| 23123 | i__4 = *m, i__5 = j + jb - 1; |
| 23124 | i__3 = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__4,i__5); |
| 23125 | for (i__ = j; i__ <= i__3; ++i__) { |
| 23126 | ipiv[i__] = j - 1 + ipiv[i__]; |
| 23127 | /* L10: */ |
| 23128 | } |
| 23129 | |
| 23130 | /* Apply interchanges to columns 1:J-1. */ |
| 23131 | |
| 23132 | i__3 = j - 1; |
| 23133 | i__4 = j + jb - 1; |
| 23134 | dlaswp_cxx . . $ dlaswp_(fd840d72c89a956b).(&i__3, &a[a_offset], lda, &j, &i__4, &ipiv[1], &c__1); |
| 23135 | |
| 23136 | if (j + jb <= *n) { |
| 23137 | |
| 23138 | /* Apply interchanges to columns J+JB:N. */ |
| 23139 | |
| 23140 | i__3 = *n - j - jb + 1; |
| 23141 | i__4 = j + jb - 1; |
| 23142 | dlaswp_cxx . . $ dlaswp_(fd840d72c89a956b).(&i__3, &a[(j + jb) * a_dim1 + 1], lda, &j, &i__4, & |
| 23143 | ipiv[1], &c__1); |
| 23144 | |
| 23145 | /* Compute block row of U. */ |
| 23146 | |
| 23147 | i__3 = *n - j - jb + 1; |
| 23148 | dtrsm_cxx . . $ dtrsm_(47bcf6c639067e06).("Left", "Lower", "No transpose", "Unit", &jb, &i__3, & |
| 23149 | c_b16, &a[j + j * a_dim1], lda, &a[j + (j + jb) * |
| 23150 | a_dim1], lda); |
| 23151 | if (j + jb <= *m) { |
| 23152 | |
| 23153 | /* Update trailing submatrix. */ |
| 23154 | |
| 23155 | i__3 = *m - j - jb + 1; |
| 23156 | i__4 = *n - j - jb + 1; |
| 23157 | dgemm_cxx . . $ dgemm_(7f9a15c7502022ea).("No transpose", "No transpose", &i__3, &i__4, &jb, |
| 23158 | &c_b19, &a[j + jb + j * a_dim1], lda, &a[j + (j + |
| 23159 | jb) * a_dim1], lda, &c_b16, &a[j + jb + (j + jb) * |
| 23160 | a_dim1], lda); |
| 23161 | } |
| 23162 | } |
| 23163 | /* L20: */ |
| 23164 | } |
| 23165 | } |
| 23166 | return 0; |
| 23167 | |
| 23168 | /* End of DGETRF */ |
| 23169 | |
| 23170 | } /* dgetrf_ */ |
| 23171 | |
| 23172 | /* Subroutine */ int dgetri_cxx . . $ dgetri_(e770e8c9ee02e374).(integercxx . . $ integer# *n, double *a, integercxx . . $ integer# *lda, integercxx . . $ integer# |
| 23173 | *ipiv, double *work, integercxx . . $ integer# *lwork, integercxx . . $ integer# *info) |
| 23174 | { |
| 23175 | /* Table of constant values */ |
| 23176 | static integercxx . . $ integer# c__1 = 1; |
| 23177 | static integercxx . . $ integer# c_n1 = -1; |
| 23178 | static integercxx . . $ integer# c__2 = 2; |
| 23179 | static double c_b20 = -1.; |
| 23180 | static double c_b22 = 1.; |
| 23181 | |
| 23182 | /* System generated locals */ |
| 23183 | integercxx . . $ integer# a_dim1, a_offset, i__1, i__2, i__3; |
| 23184 | |
| 23185 | /* Local variables */ |
| 23186 | integercxx . . $ integer# i__, j, jb, nb, jj, jp, nn, iws; |
| 23187 | integercxx . . $ integer# nbmin; |
| 23188 | integercxx . . $ integer# ldwork; |
| 23189 | integercxx . . $ integer# lwkopt; |
| 23190 | bool lquery; |
| 23191 | |
| 23192 | |
| 23193 | /* -- LAPACK routine (version 3.1) -- */ |
| 23194 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 23195 | /* November 2006 */ |
| 23196 | |
| 23197 | /* .. Scalar Arguments .. */ |
| 23198 | /* .. */ |
| 23199 | /* .. Array Arguments .. */ |
| 23200 | /* .. */ |
| 23201 | |
| 23202 | /* Purpose */ |
| 23203 | /* ======= */ |
| 23204 | |
| 23205 | /* DGETRI computes the inverse of a matrix using the LU factorization */ |
| 23206 | /* computed by DGETRF. */ |
| 23207 | |
| 23208 | /* This method inverts U and then computes inv(A) by solving the system */ |
| 23209 | /* inv(A)*L = inv(U) for inv(A). */ |
| 23210 | |
| 23211 | /* Arguments */ |
| 23212 | /* ========= */ |
| 23213 | |
| 23214 | /* N (input) INTEGER */ |
| 23215 | /* The order of the matrix A. N >= 0. */ |
| 23216 | |
| 23217 | /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 23218 | /* On entry, the factors L and U from the factorization */ |
| 23219 | /* A = P*L*U as computed by DGETRF. */ |
| 23220 | /* On exit, if INFO = 0, the inverse of the original matrix A. */ |
| 23221 | |
| 23222 | /* LDA (input) INTEGER */ |
| 23223 | /* The leading dimension of the array A. LDA >= max(1,N). */ |
| 23224 | |
| 23225 | /* IPIV (input) INTEGER array, dimension (N) */ |
| 23226 | /* The pivot indices from DGETRF; for 1<=i<=N, row i of the */ |
| 23227 | /* matrix was interchanged with row IPIV(i). */ |
| 23228 | |
| 23229 | /* WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) */ |
| 23230 | /* On exit, if INFO=0, then WORK(1) returns the optimal LWORK. */ |
| 23231 | |
| 23232 | /* LWORK (input) INTEGER */ |
| 23233 | /* The dimension of the array WORK. LWORK >= max(1,N). */ |
| 23234 | /* For optimal performance LWORK >= N*NB, where NB is */ |
| 23235 | /* the optimal blocksize returned by ILAENV. */ |
| 23236 | |
| 23237 | /* If LWORK = -1, then a workspace query is assumed; the routine */ |
| 23238 | /* only calculates the optimal size of the WORK array, returns */ |
| 23239 | /* this value as the first entry of the WORK array, and no error */ |
| 23240 | /* message related to LWORK is issued by XERBLA. */ |
| 23241 | |
| 23242 | /* INFO (output) INTEGER */ |
| 23243 | /* = 0: successful exit */ |
| 23244 | /* < 0: if INFO = -i, the i-th argument had an illegal value */ |
| 23245 | /* > 0: if INFO = i, U(i,i) is exactly zero; the matrix is */ |
| 23246 | /* singular and its inverse could not be computed. */ |
| 23247 | |
| 23248 | /* ===================================================================== */ |
| 23249 | |
| 23250 | /* .. Parameters .. */ |
| 23251 | /* .. */ |
| 23252 | /* .. Local Scalars .. */ |
| 23253 | /* .. */ |
| 23254 | /* .. External Functions .. */ |
| 23255 | /* .. */ |
| 23256 | /* .. External Subroutines .. */ |
| 23257 | /* .. */ |
| 23258 | /* .. Intrinsic Functions .. */ |
| 23259 | /* .. */ |
| 23260 | /* .. Executable Statements .. */ |
| 23261 | |
| 23262 | /* Test the input parameters. */ |
| 23263 | |
| 23264 | /* Parameter adjustments */ |
| 23265 | a_dim1 = *lda; |
| 23266 | a_offset = 1 + a_dim1; |
| 23267 | a -= a_offset; |
| 23268 | --ipiv; |
| 23269 | --work; |
| 23270 | |
| 23271 | /* Function Body */ |
| 23272 | *info = 0; |
| 23273 | nb = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGETRI", " ", n, &c_n1, &c_n1, &c_n1); |
| 23274 | lwkopt = *n * nb; |
| 23275 | work[1] = (double) lwkopt; |
| 23276 | lquery = *lwork == -1; |
| 23277 | if (*n < 0) { |
| 23278 | *info = -1; |
| 23279 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 23280 | *info = -3; |
| 23281 | } else if (*lwork < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n) && ! lquery) { |
| 23282 | *info = -6; |
| 23283 | } |
| 23284 | if (*info != 0) { |
| 23285 | i__1 = -(*info); |
| 23286 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGETRI", &i__1); |
| 23287 | return 0; |
| 23288 | } else if (lquery) { |
| 23289 | return 0; |
| 23290 | } |
| 23291 | |
| 23292 | /* Quick return if possible */ |
| 23293 | |
| 23294 | if (*n == 0) { |
| 23295 | return 0; |
| 23296 | } |
| 23297 | |
| 23298 | /* Form inv(U). If INFO > 0 from DTRTRI, then U is singular, */ |
| 23299 | /* and the inverse is not computed. */ |
| 23300 | |
| 23301 | dtrtri_cxx . . $ dtrtri_(40d6d87cf85f9bc).("Upper", "Non-unit", n, &a[a_offset], lda, info); |
| 23302 | if (*info > 0) { |
| 23303 | return 0; |
| 23304 | } |
| 23305 | |
| 23306 | nbmin = 2; |
| 23307 | ldwork = *n; |
| 23308 | if (nb > 1 && nb < *n) { |
| 23309 | /* Computing MAX */ |
| 23310 | i__1 = ldwork * nb; |
| 23311 | iws = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,1_integercxx . . $ `operator""_integer`(85240eb457c3721a).); |
| 23312 | if (*lwork < iws) { |
| 23313 | nb = *lwork / ldwork; |
| 23314 | /* Computing MAX */ |
| 23315 | i__1 = 2, i__2 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__2, "DGETRI", " ", n, &c_n1, &c_n1, & |
| 23316 | c_n1); |
| 23317 | nbmin = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 23318 | } |
| 23319 | } else { |
| 23320 | iws = *n; |
| 23321 | } |
| 23322 | |
| 23323 | /* Solve the equation inv(A)*L = inv(U) for inv(A). */ |
| 23324 | |
| 23325 | if (nb < nbmin || nb >= *n) { |
| 23326 | |
| 23327 | /* Use unblocked code. */ |
| 23328 | |
| 23329 | for (j = *n; j >= 1; --j) { |
| 23330 | |
| 23331 | /* Copy current column of L to WORK and replace with zeros. */ |
| 23332 | |
| 23333 | i__1 = *n; |
| 23334 | for (i__ = j + 1; i__ <= i__1; ++i__) { |
| 23335 | work[i__] = a[i__ + j * a_dim1]; |
| 23336 | a[i__ + j * a_dim1] = 0.; |
| 23337 | /* L10: */ |
| 23338 | } |
| 23339 | |
| 23340 | /* Compute current column of inv(A). */ |
| 23341 | |
| 23342 | if (j < *n) { |
| 23343 | i__1 = *n - j; |
| 23344 | dgemv_cxx . . $ dgemv_(828a5131add94649).("No transpose", n, &i__1, &c_b20, &a[(j + 1) * a_dim1 |
| 23345 | + 1], lda, &work[j + 1], &c__1, &c_b22, &a[j * a_dim1 |
| 23346 | + 1], &c__1); |
| 23347 | } |
| 23348 | /* L20: */ |
| 23349 | } |
| 23350 | } else { |
| 23351 | |
| 23352 | /* Use blocked code. */ |
| 23353 | |
| 23354 | nn = (*n - 1) / nb * nb + 1; |
| 23355 | i__1 = -nb; |
| 23356 | for (j = nn; i__1 < 0 ? j >= 1 : j <= 1; j += i__1) { |
| 23357 | /* Computing MIN */ |
| 23358 | i__2 = nb, i__3 = *n - j + 1; |
| 23359 | jb = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__2,i__3); |
| 23360 | |
| 23361 | /* Copy current block column of L to WORK and replace with */ |
| 23362 | /* zeros. */ |
| 23363 | |
| 23364 | i__2 = j + jb - 1; |
| 23365 | for (jj = j; jj <= i__2; ++jj) { |
| 23366 | i__3 = *n; |
| 23367 | for (i__ = jj + 1; i__ <= i__3; ++i__) { |
| 23368 | work[i__ + (jj - j) * ldwork] = a[i__ + jj * a_dim1]; |
| 23369 | a[i__ + jj * a_dim1] = 0.; |
| 23370 | /* L30: */ |
| 23371 | } |
| 23372 | /* L40: */ |
| 23373 | } |
| 23374 | |
| 23375 | /* Compute current block column of inv(A). */ |
| 23376 | |
| 23377 | if (j + jb <= *n) { |
| 23378 | i__2 = *n - j - jb + 1; |
| 23379 | dgemm_cxx . . $ dgemm_(7f9a15c7502022ea).("No transpose", "No transpose", n, &jb, &i__2, &c_b20, |
| 23380 | &a[(j + jb) * a_dim1 + 1], lda, &work[j + jb], & |
| 23381 | ldwork, &c_b22, &a[j * a_dim1 + 1], lda); |
| 23382 | } |
| 23383 | dtrsm_cxx . . $ dtrsm_(47bcf6c639067e06).("Right", "Lower", "No transpose", "Unit", n, &jb, &c_b22, & |
| 23384 | work[j], &ldwork, &a[j * a_dim1 + 1], lda); |
| 23385 | /* L50: */ |
| 23386 | } |
| 23387 | } |
| 23388 | |
| 23389 | /* Apply column interchanges. */ |
| 23390 | |
| 23391 | for (j = *n - 1; j >= 1; --j) { |
| 23392 | jp = ipiv[j]; |
| 23393 | if (jp != j) { |
| 23394 | dswap_cxx . . $ dswap_(ec261fd7ec3b6bf6).(n, &a[j * a_dim1 + 1], &c__1, &a[jp * a_dim1 + 1], &c__1); |
| 23395 | } |
| 23396 | /* L60: */ |
| 23397 | } |
| 23398 | |
| 23399 | work[1] = (double) iws; |
| 23400 | return 0; |
| 23401 | |
| 23402 | /* End of DGETRI */ |
| 23403 | |
| 23404 | } /* dgetri_ */ |
| 23405 | |
| 23406 | /* Subroutine */ int dgetrs_cxx . . $ dgetrs_(695824aa3fbf5aa2).(const char *trans, integercxx . . $ integer# *n, integercxx . . $ integer# *nrhs, |
| 23407 | double *a, integercxx . . $ integer# *lda, integercxx . . $ integer# *ipiv, double *b, integercxx . . $ integer# * |
| 23408 | ldb, integercxx . . $ integer# *info) |
| 23409 | { |
| 23410 | /* Table of constant values */ |
| 23411 | static integercxx . . $ integer# c__1 = 1; |
| 23412 | static double c_b12 = 1.; |
| 23413 | static integercxx . . $ integer# c_n1 = -1; |
| 23414 | |
| 23415 | /* System generated locals */ |
| 23416 | integercxx . . $ integer# a_dim1, a_offset, b_dim1, b_offset, i__1; |
| 23417 | |
| 23418 | /* Local variables */ |
| 23419 | bool notran; |
| 23420 | |
| 23421 | |
| 23422 | /* -- LAPACK routine (version 3.1) -- */ |
| 23423 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 23424 | /* November 2006 */ |
| 23425 | |
| 23426 | /* .. Scalar Arguments .. */ |
| 23427 | /* .. */ |
| 23428 | /* .. Array Arguments .. */ |
| 23429 | /* .. */ |
| 23430 | |
| 23431 | /* Purpose */ |
| 23432 | /* ======= */ |
| 23433 | |
| 23434 | /* DGETRS solves a system of linear equations */ |
| 23435 | /* A * X = B or A' * X = B */ |
| 23436 | /* with a general N-by-N matrix A using the LU factorization computed */ |
| 23437 | /* by DGETRF. */ |
| 23438 | |
| 23439 | /* Arguments */ |
| 23440 | /* ========= */ |
| 23441 | |
| 23442 | /* TRANS (input) CHARACTER*1 */ |
| 23443 | /* Specifies the form of the system of equations: */ |
| 23444 | /* = 'N': A * X = B (No transpose) */ |
| 23445 | /* = 'T': A'* X = B (Transpose) */ |
| 23446 | /* = 'C': A'* X = B (Conjugate transpose = Transpose) */ |
| 23447 | |
| 23448 | /* N (input) INTEGER */ |
| 23449 | /* The order of the matrix A. N >= 0. */ |
| 23450 | |
| 23451 | /* NRHS (input) INTEGER */ |
| 23452 | /* The number of right hand sides, i.e., the number of columns */ |
| 23453 | /* of the matrix B. NRHS >= 0. */ |
| 23454 | |
| 23455 | /* A (input) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 23456 | /* The factors L and U from the factorization A = P*L*U */ |
| 23457 | /* as computed by DGETRF. */ |
| 23458 | |
| 23459 | /* LDA (input) INTEGER */ |
| 23460 | /* The leading dimension of the array A. LDA >= max(1,N). */ |
| 23461 | |
| 23462 | /* IPIV (input) INTEGER array, dimension (N) */ |
| 23463 | /* The pivot indices from DGETRF; for 1<=i<=N, row i of the */ |
| 23464 | /* matrix was interchanged with row IPIV(i). */ |
| 23465 | |
| 23466 | /* B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */ |
| 23467 | /* On entry, the right hand side matrix B. */ |
| 23468 | /* On exit, the solution matrix X. */ |
| 23469 | |
| 23470 | /* LDB (input) INTEGER */ |
| 23471 | /* The leading dimension of the array B. LDB >= max(1,N). */ |
| 23472 | |
| 23473 | /* INFO (output) INTEGER */ |
| 23474 | /* = 0: successful exit */ |
| 23475 | /* < 0: if INFO = -i, the i-th argument had an illegal value */ |
| 23476 | |
| 23477 | /* ===================================================================== */ |
| 23478 | |
| 23479 | /* .. Parameters .. */ |
| 23480 | /* .. */ |
| 23481 | /* .. Local Scalars .. */ |
| 23482 | /* .. */ |
| 23483 | /* .. External Functions .. */ |
| 23484 | /* .. */ |
| 23485 | /* .. External Subroutines .. */ |
| 23486 | /* .. */ |
| 23487 | /* .. Intrinsic Functions .. */ |
| 23488 | /* .. */ |
| 23489 | /* .. Executable Statements .. */ |
| 23490 | |
| 23491 | /* Test the input parameters. */ |
| 23492 | |
| 23493 | /* Parameter adjustments */ |
| 23494 | a_dim1 = *lda; |
| 23495 | a_offset = 1 + a_dim1; |
| 23496 | a -= a_offset; |
| 23497 | --ipiv; |
| 23498 | b_dim1 = *ldb; |
| 23499 | b_offset = 1 + b_dim1; |
| 23500 | b -= b_offset; |
| 23501 | |
| 23502 | /* Function Body */ |
| 23503 | *info = 0; |
| 23504 | notran = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(trans, "N"); |
| 23505 | if (! notran && ! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(trans, "T") && ! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).( |
| 23506 | trans, "C")) { |
| 23507 | *info = -1; |
| 23508 | } else if (*n < 0) { |
| 23509 | *info = -2; |
| 23510 | } else if (*nrhs < 0) { |
| 23511 | *info = -3; |
| 23512 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 23513 | *info = -5; |
| 23514 | } else if (*ldb < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 23515 | *info = -8; |
| 23516 | } |
| 23517 | if (*info != 0) { |
| 23518 | i__1 = -(*info); |
| 23519 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGETRS", &i__1); |
| 23520 | return 0; |
| 23521 | } |
| 23522 | |
| 23523 | /* Quick return if possible */ |
| 23524 | |
| 23525 | if (*n == 0 || *nrhs == 0) { |
| 23526 | return 0; |
| 23527 | } |
| 23528 | |
| 23529 | if (notran) { |
| 23530 | |
| 23531 | /* Solve A * X = B. */ |
| 23532 | |
| 23533 | /* Apply row interchanges to the right hand sides. */ |
| 23534 | |
| 23535 | dlaswp_cxx . . $ dlaswp_(fd840d72c89a956b).(nrhs, &b[b_offset], ldb, &c__1, n, &ipiv[1], &c__1); |
| 23536 | |
| 23537 | /* Solve L*X = B, overwriting B with X. */ |
| 23538 | |
| 23539 | dtrsm_cxx . . $ dtrsm_(47bcf6c639067e06).("Left", "Lower", "No transpose", "Unit", n, nrhs, &c_b12, &a[ |
| 23540 | a_offset], lda, &b[b_offset], ldb); |
| 23541 | |
| 23542 | /* Solve U*X = B, overwriting B with X. */ |
| 23543 | |
| 23544 | dtrsm_cxx . . $ dtrsm_(47bcf6c639067e06).("Left", "Upper", "No transpose", "Non-unit", n, nrhs, &c_b12, & |
| 23545 | a[a_offset], lda, &b[b_offset], ldb); |
| 23546 | } else { |
| 23547 | |
| 23548 | /* Solve A' * X = B. */ |
| 23549 | |
| 23550 | /* Solve U'*X = B, overwriting B with X. */ |
| 23551 | |
| 23552 | dtrsm_cxx . . $ dtrsm_(47bcf6c639067e06).("Left", "Upper", "Transpose", "Non-unit", n, nrhs, &c_b12, &a[ |
| 23553 | a_offset], lda, &b[b_offset], ldb); |
| 23554 | |
| 23555 | /* Solve L'*X = B, overwriting B with X. */ |
| 23556 | |
| 23557 | dtrsm_cxx . . $ dtrsm_(47bcf6c639067e06).("Left", "Lower", "Transpose", "Unit", n, nrhs, &c_b12, &a[ |
| 23558 | a_offset], lda, &b[b_offset], ldb); |
| 23559 | |
| 23560 | /* Apply row interchanges to the solution vectors. */ |
| 23561 | |
| 23562 | dlaswp_cxx . . $ dlaswp_(fd840d72c89a956b).(nrhs, &b[b_offset], ldb, &c__1, n, &ipiv[1], &c_n1); |
| 23563 | } |
| 23564 | |
| 23565 | return 0; |
| 23566 | |
| 23567 | /* End of DGETRS */ |
| 23568 | |
| 23569 | } /* dgetrs_ */ |
| 23570 | |
| 23571 | /* Subroutine */ int dggbak_cxx . . $ dggbak_(3fb2e360e620705c).(const char *job, const char *side, integercxx . . $ integer# *n, integercxx . . $ integer# *ilo, |
| 23572 | integercxx . . $ integer# *ihi, double *lscale, double *rscale, integercxx . . $ integer# *m, |
| 23573 | double *v, integercxx . . $ integer# *ldv, integercxx . . $ integer# *info) |
| 23574 | { |
| 23575 | /* System generated locals */ |
| 23576 | integercxx . . $ integer# v_dim1, v_offset, i__1; |
| 23577 | |
| 23578 | /* Local variables */ |
| 23579 | integercxx . . $ integer# i__, k; |
| 23580 | bool leftv; |
| 23581 | bool rightv; |
| 23582 | |
| 23583 | |
| 23584 | /* -- LAPACK routine (version 3.1) -- */ |
| 23585 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 23586 | /* November 2006 */ |
| 23587 | |
| 23588 | /* .. Scalar Arguments .. */ |
| 23589 | /* .. */ |
| 23590 | /* .. Array Arguments .. */ |
| 23591 | /* .. */ |
| 23592 | |
| 23593 | /* Purpose */ |
| 23594 | /* ======= */ |
| 23595 | |
| 23596 | /* DGGBAK forms the right or left eigenvectors of a real generalized */ |
| 23597 | /* eigenvalue problem A*x = lambda*B*x, by backward transformation on */ |
| 23598 | /* the computed eigenvectors of the balanced pair of matrices output by */ |
| 23599 | /* DGGBAL. */ |
| 23600 | |
| 23601 | /* Arguments */ |
| 23602 | /* ========= */ |
| 23603 | |
| 23604 | /* JOB (input) CHARACTER*1 */ |
| 23605 | /* Specifies the type of backward transformation required: */ |
| 23606 | /* = 'N': do nothing, return immediately; */ |
| 23607 | /* = 'P': do backward transformation for permutation only; */ |
| 23608 | /* = 'S': do backward transformation for scaling only; */ |
| 23609 | /* = 'B': do backward transformations for both permutation and */ |
| 23610 | /* scaling. */ |
| 23611 | /* JOB must be the same as the argument JOB supplied to DGGBAL. */ |
| 23612 | |
| 23613 | /* SIDE (input) CHARACTER*1 */ |
| 23614 | /* = 'R': V contains right eigenvectors; */ |
| 23615 | /* = 'L': V contains left eigenvectors. */ |
| 23616 | |
| 23617 | /* N (input) INTEGER */ |
| 23618 | /* The number of rows of the matrix V. N >= 0. */ |
| 23619 | |
| 23620 | /* ILO (input) INTEGER */ |
| 23621 | /* IHI (input) INTEGER */ |
| 23622 | /* The integers ILO and IHI determined by DGGBAL. */ |
| 23623 | /* 1 <= ILO <= IHI <= N, if N > 0; ILO=1 and IHI=0, if N=0. */ |
| 23624 | |
| 23625 | /* LSCALE (input) DOUBLE PRECISION array, dimension (N) */ |
| 23626 | /* Details of the permutations and/or scaling factors applied */ |
| 23627 | /* to the left side of A and B, as returned by DGGBAL. */ |
| 23628 | |
| 23629 | /* RSCALE (input) DOUBLE PRECISION array, dimension (N) */ |
| 23630 | /* Details of the permutations and/or scaling factors applied */ |
| 23631 | /* to the right side of A and B, as returned by DGGBAL. */ |
| 23632 | |
| 23633 | /* M (input) INTEGER */ |
| 23634 | /* The number of columns of the matrix V. M >= 0. */ |
| 23635 | |
| 23636 | /* V (input/output) DOUBLE PRECISION array, dimension (LDV,M) */ |
| 23637 | /* On entry, the matrix of right or left eigenvectors to be */ |
| 23638 | /* transformed, as returned by DTGEVC. */ |
| 23639 | /* On exit, V is overwritten by the transformed eigenvectors. */ |
| 23640 | |
| 23641 | /* LDV (input) INTEGER */ |
| 23642 | /* The leading dimension of the matrix V. LDV >= max(1,N). */ |
| 23643 | |
| 23644 | /* INFO (output) INTEGER */ |
| 23645 | /* = 0: successful exit. */ |
| 23646 | /* < 0: if INFO = -i, the i-th argument had an illegal value. */ |
| 23647 | |
| 23648 | /* Further Details */ |
| 23649 | /* =============== */ |
| 23650 | |
| 23651 | /* See R.C. Ward, Balancing the generalized eigenvalue problem, */ |
| 23652 | /* SIAM J. Sci. Stat. Comp. 2 (1981), 141-152. */ |
| 23653 | |
| 23654 | /* ===================================================================== */ |
| 23655 | |
| 23656 | /* .. Local Scalars .. */ |
| 23657 | /* .. */ |
| 23658 | /* .. External Functions .. */ |
| 23659 | /* .. */ |
| 23660 | /* .. External Subroutines .. */ |
| 23661 | /* .. */ |
| 23662 | /* .. Intrinsic Functions .. */ |
| 23663 | /* .. */ |
| 23664 | /* .. Executable Statements .. */ |
| 23665 | |
| 23666 | /* Test the input parameters */ |
| 23667 | |
| 23668 | /* Parameter adjustments */ |
| 23669 | --lscale; |
| 23670 | --rscale; |
| 23671 | v_dim1 = *ldv; |
| 23672 | v_offset = 1 + v_dim1; |
| 23673 | v -= v_offset; |
| 23674 | |
| 23675 | /* Function Body */ |
| 23676 | rightv = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(side, "R"); |
| 23677 | leftv = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(side, "L"); |
| 23678 | |
| 23679 | *info = 0; |
| 23680 | if (! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(job, "N") && ! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(job, "P") && ! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(job, "S") |
| 23681 | && ! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(job, "B")) { |
| 23682 | *info = -1; |
| 23683 | } else if (! rightv && ! leftv) { |
| 23684 | *info = -2; |
| 23685 | } else if (*n < 0) { |
| 23686 | *info = -3; |
| 23687 | } else if (*ilo < 1) { |
| 23688 | *info = -4; |
| 23689 | } else if (*n == 0 && *ihi == 0 && *ilo != 1) { |
| 23690 | *info = -4; |
| 23691 | } else if (*n > 0 && (*ihi < *ilo || *ihi > stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n))) { |
| 23692 | *info = -5; |
| 23693 | } else if (*n == 0 && *ilo == 1 && *ihi != 0) { |
| 23694 | *info = -5; |
| 23695 | } else if (*m < 0) { |
| 23696 | *info = -8; |
| 23697 | } else if (*ldv < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 23698 | *info = -10; |
| 23699 | } |
| 23700 | if (*info != 0) { |
| 23701 | i__1 = -(*info); |
| 23702 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGGBAK", &i__1); |
| 23703 | return 0; |
| 23704 | } |
| 23705 | |
| 23706 | /* Quick return if possible */ |
| 23707 | |
| 23708 | if (*n == 0) { |
| 23709 | return 0; |
| 23710 | } |
| 23711 | if (*m == 0) { |
| 23712 | return 0; |
| 23713 | } |
| 23714 | if (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(job, "N")) { |
| 23715 | return 0; |
| 23716 | } |
| 23717 | |
| 23718 | if (*ilo == *ihi) { |
| 23719 | goto L30; |
| 23720 | } |
| 23721 | |
| 23722 | /* Backward balance */ |
| 23723 | |
| 23724 | if (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(job, "S") || lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(job, "B")) { |
| 23725 | |
| 23726 | /* Backward transformation on right eigenvectors */ |
| 23727 | |
| 23728 | if (rightv) { |
| 23729 | i__1 = *ihi; |
| 23730 | for (i__ = *ilo; i__ <= i__1; ++i__) { |
| 23731 | dscal_cxx . . $ dscal_(f22c1db71784c345).(m, &rscale[i__], &v[i__ + v_dim1], ldv); |
| 23732 | /* L10: */ |
| 23733 | } |
| 23734 | } |
| 23735 | |
| 23736 | /* Backward transformation on left eigenvectors */ |
| 23737 | |
| 23738 | if (leftv) { |
| 23739 | i__1 = *ihi; |
| 23740 | for (i__ = *ilo; i__ <= i__1; ++i__) { |
| 23741 | dscal_cxx . . $ dscal_(f22c1db71784c345).(m, &lscale[i__], &v[i__ + v_dim1], ldv); |
| 23742 | /* L20: */ |
| 23743 | } |
| 23744 | } |
| 23745 | } |
| 23746 | |
| 23747 | /* Backward permutation */ |
| 23748 | |
| 23749 | L30: |
| 23750 | if (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(job, "P") || lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(job, "B")) { |
| 23751 | |
| 23752 | /* Backward permutation on right eigenvectors */ |
| 23753 | |
| 23754 | if (rightv) { |
| 23755 | if (*ilo == 1) { |
| 23756 | goto L50; |
| 23757 | } |
| 23758 | |
| 23759 | for (i__ = *ilo - 1; i__ >= 1; --i__) { |
| 23760 | k = (integercxx . . $ integer#) rscale[i__]; |
| 23761 | if (k == i__) { |
| 23762 | goto L40; |
| 23763 | } |
| 23764 | dswap_cxx . . $ dswap_(ec261fd7ec3b6bf6).(m, &v[i__ + v_dim1], ldv, &v[k + v_dim1], ldv); |
| 23765 | L40: |
| 23766 | ; |
| 23767 | } |
| 23768 | |
| 23769 | L50: |
| 23770 | if (*ihi == *n) { |
| 23771 | goto L70; |
| 23772 | } |
| 23773 | i__1 = *n; |
| 23774 | for (i__ = *ihi + 1; i__ <= i__1; ++i__) { |
| 23775 | k = (integercxx . . $ integer#) rscale[i__]; |
| 23776 | if (k == i__) { |
| 23777 | goto L60; |
| 23778 | } |
| 23779 | dswap_cxx . . $ dswap_(ec261fd7ec3b6bf6).(m, &v[i__ + v_dim1], ldv, &v[k + v_dim1], ldv); |
| 23780 | L60: |
| 23781 | ; |
| 23782 | } |
| 23783 | } |
| 23784 | |
| 23785 | /* Backward permutation on left eigenvectors */ |
| 23786 | |
| 23787 | L70: |
| 23788 | if (leftv) { |
| 23789 | if (*ilo == 1) { |
| 23790 | goto L90; |
| 23791 | } |
| 23792 | for (i__ = *ilo - 1; i__ >= 1; --i__) { |
| 23793 | k = (integercxx . . $ integer#) lscale[i__]; |
| 23794 | if (k == i__) { |
| 23795 | goto L80; |
| 23796 | } |
| 23797 | dswap_cxx . . $ dswap_(ec261fd7ec3b6bf6).(m, &v[i__ + v_dim1], ldv, &v[k + v_dim1], ldv); |
| 23798 | L80: |
| 23799 | ; |
| 23800 | } |
| 23801 | |
| 23802 | L90: |
| 23803 | if (*ihi == *n) { |
| 23804 | goto L110; |
| 23805 | } |
| 23806 | i__1 = *n; |
| 23807 | for (i__ = *ihi + 1; i__ <= i__1; ++i__) { |
| 23808 | k = (integercxx . . $ integer#) lscale[i__]; |
| 23809 | if (k == i__) { |
| 23810 | goto L100; |
| 23811 | } |
| 23812 | dswap_cxx . . $ dswap_(ec261fd7ec3b6bf6).(m, &v[i__ + v_dim1], ldv, &v[k + v_dim1], ldv); |
| 23813 | L100: |
| 23814 | ; |
| 23815 | } |
| 23816 | } |
| 23817 | } |
| 23818 | |
| 23819 | L110: |
| 23820 | |
| 23821 | return 0; |
| 23822 | |
| 23823 | /* End of DGGBAK */ |
| 23824 | |
| 23825 | } /* dggbak_ */ |
| 23826 | |
| 23827 | |
| 23828 | /* Subroutine */ int dggbal_cxx . . $ dggbal_(69bfde64ff0f2aeb).(const char *job, integercxx . . $ integer# *n, double *a, integercxx . . $ integer# * |
| 23829 | lda, double *b, integercxx . . $ integer# *ldb, integercxx . . $ integer# *ilo, integercxx . . $ integer# *ihi, |
| 23830 | double *lscale, double *rscale, double *work, integercxx . . $ integer# * |
| 23831 | info) |
| 23832 | { |
| 23833 | /* Table of constant values */ |
| 23834 | static integercxx . . $ integer# c__1 = 1; |
| 23835 | static double c_b35 = 10.; |
| 23836 | static double c_b71 = .5; |
| 23837 | |
| 23838 | /* System generated locals */ |
| 23839 | integercxx . . $ integer# a_dim1, a_offset, b_dim1, b_offset, i__1, i__2, i__3; |
| 23840 | double d__1, d__2, d__3; |
| 23841 | |
| 23842 | /* Local variables */ |
| 23843 | integercxx . . $ integer# i__, j, k, l, m; |
| 23844 | double t; |
| 23845 | integercxx . . $ integer# jc; |
| 23846 | double ta, tb, tc; |
| 23847 | integercxx . . $ integer# ir; |
| 23848 | double ew; |
| 23849 | integercxx . . $ integer# it, nr, ip1, jp1, lm1; |
| 23850 | double cab, rab, ewc, cor, sum; |
| 23851 | integercxx . . $ integer# nrp2, icab, lcab; |
| 23852 | double beta, coef; |
| 23853 | integercxx . . $ integer# irab, lrab; |
| 23854 | double basl, cmax; |
| 23855 | double coef2, coef5, gamma, alpha; |
| 23856 | double sfmin, sfmax; |
| 23857 | integercxx . . $ integer# iflow; |
| 23858 | integercxx . . $ integer# kount; |
| 23859 | double pgamma; |
| 23860 | integercxx . . $ integer# lsfmin, lsfmax; |
| 23861 | |
| 23862 | |
| 23863 | /* -- LAPACK routine (version 3.1) -- */ |
| 23864 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 23865 | /* November 2006 */ |
| 23866 | |
| 23867 | /* .. Scalar Arguments .. */ |
| 23868 | /* .. */ |
| 23869 | /* .. Array Arguments .. */ |
| 23870 | /* .. */ |
| 23871 | |
| 23872 | /* Purpose */ |
| 23873 | /* ======= */ |
| 23874 | |
| 23875 | /* DGGBAL balances a pair of general real matrices (A,B). This */ |
| 23876 | /* involves, first, permuting A and B by similarity transformations to */ |
| 23877 | /* isolate eigenvalues in the first 1 to ILO$-$1 and last IHI+1 to N */ |
| 23878 | /* elements on the diagonal; and second, applying a diagonal similarity */ |
| 23879 | /* transformation to rows and columns ILO to IHI to make the rows */ |
| 23880 | /* and columns as close in norm as possible. Both steps are optional. */ |
| 23881 | |
| 23882 | /* Balancing may reduce the 1-norm of the matrices, and improve the */ |
| 23883 | /* accuracy of the computed eigenvalues and/or eigenvectors in the */ |
| 23884 | /* generalized eigenvalue problem A*x = lambda*B*x. */ |
| 23885 | |
| 23886 | /* Arguments */ |
| 23887 | /* ========= */ |
| 23888 | |
| 23889 | /* JOB (input) CHARACTER*1 */ |
| 23890 | /* Specifies the operations to be performed on A and B: */ |
| 23891 | /* = 'N': none: simply set ILO = 1, IHI = N, LSCALE(I) = 1.0 */ |
| 23892 | /* and RSCALE(I) = 1.0 for i = 1,...,N. */ |
| 23893 | /* = 'P': permute only; */ |
| 23894 | /* = 'S': scale only; */ |
| 23895 | /* = 'B': both permute and scale. */ |
| 23896 | |
| 23897 | /* N (input) INTEGER */ |
| 23898 | /* The order of the matrices A and B. N >= 0. */ |
| 23899 | |
| 23900 | /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 23901 | /* On entry, the input matrix A. */ |
| 23902 | /* On exit, A is overwritten by the balanced matrix. */ |
| 23903 | /* If JOB = 'N', A is not referenced. */ |
| 23904 | |
| 23905 | /* LDA (input) INTEGER */ |
| 23906 | /* The leading dimension of the array A. LDA >= max(1,N). */ |
| 23907 | |
| 23908 | /* B (input/output) DOUBLE PRECISION array, dimension (LDB,N) */ |
| 23909 | /* On entry, the input matrix B. */ |
| 23910 | /* On exit, B is overwritten by the balanced matrix. */ |
| 23911 | /* If JOB = 'N', B is not referenced. */ |
| 23912 | |
| 23913 | /* LDB (input) INTEGER */ |
| 23914 | /* The leading dimension of the array B. LDB >= max(1,N). */ |
| 23915 | |
| 23916 | /* ILO (output) INTEGER */ |
| 23917 | /* IHI (output) INTEGER */ |
| 23918 | /* ILO and IHI are set to integers such that on exit */ |
| 23919 | /* A(i,j) = 0 and B(i,j) = 0 if i > j and */ |
| 23920 | /* j = 1,...,ILO-1 or i = IHI+1,...,N. */ |
| 23921 | /* If JOB = 'N' or 'S', ILO = 1 and IHI = N. */ |
| 23922 | |
| 23923 | /* LSCALE (output) DOUBLE PRECISION array, dimension (N) */ |
| 23924 | /* Details of the permutations and scaling factors applied */ |
| 23925 | /* to the left side of A and B. If P(j) is the index of the */ |
| 23926 | /* row interchanged with row j, and D(j) */ |
| 23927 | /* is the scaling factor applied to row j, then */ |
| 23928 | /* LSCALE(j) = P(j) for J = 1,...,ILO-1 */ |
| 23929 | /* = D(j) for J = ILO,...,IHI */ |
| 23930 | /* = P(j) for J = IHI+1,...,N. */ |
| 23931 | /* The order in which the interchanges are made is N to IHI+1, */ |
| 23932 | /* then 1 to ILO-1. */ |
| 23933 | |
| 23934 | /* RSCALE (output) DOUBLE PRECISION array, dimension (N) */ |
| 23935 | /* Details of the permutations and scaling factors applied */ |
| 23936 | /* to the right side of A and B. If P(j) is the index of the */ |
| 23937 | /* column interchanged with column j, and D(j) */ |
| 23938 | /* is the scaling factor applied to column j, then */ |
| 23939 | /* LSCALE(j) = P(j) for J = 1,...,ILO-1 */ |
| 23940 | /* = D(j) for J = ILO,...,IHI */ |
| 23941 | /* = P(j) for J = IHI+1,...,N. */ |
| 23942 | /* The order in which the interchanges are made is N to IHI+1, */ |
| 23943 | /* then 1 to ILO-1. */ |
| 23944 | |
| 23945 | /* WORK (workspace) REAL array, dimension (lwork) */ |
| 23946 | /* lwork must be at least max(1,6*N) when JOB = 'S' or 'B', and */ |
| 23947 | /* at least 1 when JOB = 'N' or 'P'. */ |
| 23948 | |
| 23949 | /* INFO (output) INTEGER */ |
| 23950 | /* = 0: successful exit */ |
| 23951 | /* < 0: if INFO = -i, the i-th argument had an illegal value. */ |
| 23952 | |
| 23953 | /* Further Details */ |
| 23954 | /* =============== */ |
| 23955 | |
| 23956 | /* See R.C. WARD, Balancing the generalized eigenvalue problem, */ |
| 23957 | /* SIAM J. Sci. Stat. Comp. 2 (1981), 141-152. */ |
| 23958 | |
| 23959 | /* ===================================================================== */ |
| 23960 | |
| 23961 | /* .. Parameters .. */ |
| 23962 | /* .. */ |
| 23963 | /* .. Local Scalars .. */ |
| 23964 | /* .. */ |
| 23965 | /* .. External Functions .. */ |
| 23966 | /* .. */ |
| 23967 | /* .. External Subroutines .. */ |
| 23968 | /* .. */ |
| 23969 | /* .. Intrinsic Functions .. */ |
| 23970 | /* .. */ |
| 23971 | /* .. Executable Statements .. */ |
| 23972 | |
| 23973 | /* Test the input parameters */ |
| 23974 | |
| 23975 | /* Parameter adjustments */ |
| 23976 | a_dim1 = *lda; |
| 23977 | a_offset = 1 + a_dim1; |
| 23978 | a -= a_offset; |
| 23979 | b_dim1 = *ldb; |
| 23980 | b_offset = 1 + b_dim1; |
| 23981 | b -= b_offset; |
| 23982 | --lscale; |
| 23983 | --rscale; |
| 23984 | --work; |
| 23985 | |
| 23986 | /* Function Body */ |
| 23987 | *info = 0; |
| 23988 | if (! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(job, "N") && ! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(job, "P") && ! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(job, "S") |
| 23989 | && ! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(job, "B")) { |
| 23990 | *info = -1; |
| 23991 | } else if (*n < 0) { |
| 23992 | *info = -2; |
| 23993 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 23994 | *info = -4; |
| 23995 | } else if (*ldb < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 23996 | *info = -6; |
| 23997 | } |
| 23998 | if (*info != 0) { |
| 23999 | i__1 = -(*info); |
| 24000 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGGBAL", &i__1); |
| 24001 | return 0; |
| 24002 | } |
| 24003 | |
| 24004 | /* Quick return if possible */ |
| 24005 | |
| 24006 | if (*n == 0) { |
| 24007 | *ilo = 1; |
| 24008 | *ihi = *n; |
| 24009 | return 0; |
| 24010 | } |
| 24011 | |
| 24012 | if (*n == 1) { |
| 24013 | *ilo = 1; |
| 24014 | *ihi = *n; |
| 24015 | lscale[1] = 1.; |
| 24016 | rscale[1] = 1.; |
| 24017 | return 0; |
| 24018 | } |
| 24019 | |
| 24020 | if (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(job, "N")) { |
| 24021 | *ilo = 1; |
| 24022 | *ihi = *n; |
| 24023 | i__1 = *n; |
| 24024 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 24025 | lscale[i__] = 1.; |
| 24026 | rscale[i__] = 1.; |
| 24027 | /* L10: */ |
| 24028 | } |
| 24029 | return 0; |
| 24030 | } |
| 24031 | |
| 24032 | k = 1; |
| 24033 | l = *n; |
| 24034 | if (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(job, "S")) { |
| 24035 | goto L190; |
| 24036 | } |
| 24037 | |
| 24038 | goto L30; |
| 24039 | |
| 24040 | /* Permute the matrices A and B to isolate the eigenvalues. */ |
| 24041 | |
| 24042 | /* Find row with one nonzero in columns 1 through L */ |
| 24043 | |
| 24044 | L20: |
| 24045 | l = lm1; |
| 24046 | if (l != 1) { |
| 24047 | goto L30; |
| 24048 | } |
| 24049 | |
| 24050 | rscale[1] = 1.; |
| 24051 | lscale[1] = 1.; |
| 24052 | goto L190; |
| 24053 | |
| 24054 | L30: |
| 24055 | lm1 = l - 1; |
| 24056 | for (i__ = l; i__ >= 1; --i__) { |
| 24057 | i__1 = lm1; |
| 24058 | for (j = 1; j <= i__1; ++j) { |
| 24059 | jp1 = j + 1; |
| 24060 | if (a[i__ + j * a_dim1] != 0. || b[i__ + j * b_dim1] != 0.) { |
| 24061 | goto L50; |
| 24062 | } |
| 24063 | /* L40: */ |
| 24064 | } |
| 24065 | j = l; |
| 24066 | goto L70; |
| 24067 | |
| 24068 | L50: |
| 24069 | i__1 = l; |
| 24070 | for (j = jp1; j <= i__1; ++j) { |
| 24071 | if (a[i__ + j * a_dim1] != 0. || b[i__ + j * b_dim1] != 0.) { |
| 24072 | goto L80; |
| 24073 | } |
| 24074 | /* L60: */ |
| 24075 | } |
| 24076 | j = jp1 - 1; |
| 24077 | |
| 24078 | L70: |
| 24079 | m = l; |
| 24080 | iflow = 1; |
| 24081 | goto L160; |
| 24082 | L80: |
| 24083 | ; |
| 24084 | } |
| 24085 | goto L100; |
| 24086 | |
| 24087 | /* Find column with one nonzero in rows K through N */ |
| 24088 | |
| 24089 | L90: |
| 24090 | ++k; |
| 24091 | |
| 24092 | L100: |
| 24093 | i__1 = l; |
| 24094 | for (j = k; j <= i__1; ++j) { |
| 24095 | i__2 = lm1; |
| 24096 | for (i__ = k; i__ <= i__2; ++i__) { |
| 24097 | ip1 = i__ + 1; |
| 24098 | if (a[i__ + j * a_dim1] != 0. || b[i__ + j * b_dim1] != 0.) { |
| 24099 | goto L120; |
| 24100 | } |
| 24101 | /* L110: */ |
| 24102 | } |
| 24103 | i__ = l; |
| 24104 | goto L140; |
| 24105 | L120: |
| 24106 | i__2 = l; |
| 24107 | for (i__ = ip1; i__ <= i__2; ++i__) { |
| 24108 | if (a[i__ + j * a_dim1] != 0. || b[i__ + j * b_dim1] != 0.) { |
| 24109 | goto L150; |
| 24110 | } |
| 24111 | /* L130: */ |
| 24112 | } |
| 24113 | i__ = ip1 - 1; |
| 24114 | L140: |
| 24115 | m = k; |
| 24116 | iflow = 2; |
| 24117 | goto L160; |
| 24118 | L150: |
| 24119 | ; |
| 24120 | } |
| 24121 | goto L190; |
| 24122 | |
| 24123 | /* Permute rows M and I */ |
| 24124 | |
| 24125 | L160: |
| 24126 | lscale[m] = (double) i__; |
| 24127 | if (i__ == m) { |
| 24128 | goto L170; |
| 24129 | } |
| 24130 | i__1 = *n - k + 1; |
| 24131 | dswap_cxx . . $ dswap_(ec261fd7ec3b6bf6).(&i__1, &a[i__ + k * a_dim1], lda, &a[m + k * a_dim1], lda); |
| 24132 | i__1 = *n - k + 1; |
| 24133 | dswap_cxx . . $ dswap_(ec261fd7ec3b6bf6).(&i__1, &b[i__ + k * b_dim1], ldb, &b[m + k * b_dim1], ldb); |
| 24134 | |
| 24135 | /* Permute columns M and J */ |
| 24136 | |
| 24137 | L170: |
| 24138 | rscale[m] = (double) j; |
| 24139 | if (j == m) { |
| 24140 | goto L180; |
| 24141 | } |
| 24142 | dswap_cxx . . $ dswap_(ec261fd7ec3b6bf6).(&l, &a[j * a_dim1 + 1], &c__1, &a[m * a_dim1 + 1], &c__1); |
| 24143 | dswap_cxx . . $ dswap_(ec261fd7ec3b6bf6).(&l, &b[j * b_dim1 + 1], &c__1, &b[m * b_dim1 + 1], &c__1); |
| 24144 | |
| 24145 | L180: |
| 24146 | switch (iflow) { |
| 24147 | case 1: goto L20; |
| 24148 | case 2: goto L90; |
| 24149 | } |
| 24150 | |
| 24151 | L190: |
| 24152 | *ilo = k; |
| 24153 | *ihi = l; |
| 24154 | |
| 24155 | if (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(job, "P")) { |
| 24156 | i__1 = *ihi; |
| 24157 | for (i__ = *ilo; i__ <= i__1; ++i__) { |
| 24158 | lscale[i__] = 1.; |
| 24159 | rscale[i__] = 1.; |
| 24160 | /* L195: */ |
| 24161 | } |
| 24162 | return 0; |
| 24163 | } |
| 24164 | |
| 24165 | if (*ilo == *ihi) { |
| 24166 | return 0; |
| 24167 | } |
| 24168 | |
| 24169 | /* Balance the submatrix in rows ILO to IHI. */ |
| 24170 | |
| 24171 | nr = *ihi - *ilo + 1; |
| 24172 | i__1 = *ihi; |
| 24173 | for (i__ = *ilo; i__ <= i__1; ++i__) { |
| 24174 | rscale[i__] = 0.; |
| 24175 | lscale[i__] = 0.; |
| 24176 | |
| 24177 | work[i__] = 0.; |
| 24178 | work[i__ + *n] = 0.; |
| 24179 | work[i__ + (*n << 1)] = 0.; |
| 24180 | work[i__ + *n * 3] = 0.; |
| 24181 | work[i__ + (*n << 2)] = 0.; |
| 24182 | work[i__ + *n * 5] = 0.; |
| 24183 | /* L200: */ |
| 24184 | } |
| 24185 | |
| 24186 | /* Compute right side vector in resulting linear equations */ |
| 24187 | |
| 24188 | basl = d_lg10cxx . . $ d_lg10(a5c8eef512f28486).(&c_b35); |
| 24189 | i__1 = *ihi; |
| 24190 | for (i__ = *ilo; i__ <= i__1; ++i__) { |
| 24191 | i__2 = *ihi; |
| 24192 | for (j = *ilo; j <= i__2; ++j) { |
| 24193 | tb = b[i__ + j * b_dim1]; |
| 24194 | ta = a[i__ + j * a_dim1]; |
| 24195 | if (ta == 0.) { |
| 24196 | goto L210; |
| 24197 | } |
| 24198 | d__1 = abscxx . . $ abs(447c67c6676f75c3).(ta); |
| 24199 | ta = d_lg10cxx . . $ d_lg10(a5c8eef512f28486).(&d__1) / basl; |
| 24200 | L210: |
| 24201 | if (tb == 0.) { |
| 24202 | goto L220; |
| 24203 | } |
| 24204 | d__1 = abscxx . . $ abs(447c67c6676f75c3).(tb); |
| 24205 | tb = d_lg10cxx . . $ d_lg10(a5c8eef512f28486).(&d__1) / basl; |
| 24206 | L220: |
| 24207 | work[i__ + (*n << 2)] = work[i__ + (*n << 2)] - ta - tb; |
| 24208 | work[j + *n * 5] = work[j + *n * 5] - ta - tb; |
| 24209 | /* L230: */ |
| 24210 | } |
| 24211 | /* L240: */ |
| 24212 | } |
| 24213 | |
| 24214 | coef = 1. / (double) (nr << 1); |
| 24215 | coef2 = coef * coef; |
| 24216 | coef5 = coef2 * .5; |
| 24217 | nrp2 = nr + 2; |
| 24218 | beta = 0.; |
| 24219 | it = 1; |
| 24220 | |
| 24221 | /* Start generalized conjugate gradient iteration */ |
| 24222 | |
| 24223 | L250: |
| 24224 | |
| 24225 | gamma = ddot_cxx . . $ ddot_(2885988431543d16).(&nr, &work[*ilo + (*n << 2)], &c__1, &work[*ilo + (*n << 2)] |
| 24226 | , &c__1) + ddot_cxx . . $ ddot_(2885988431543d16).(&nr, &work[*ilo + *n * 5], &c__1, &work[*ilo + * |
| 24227 | n * 5], &c__1); |
| 24228 | |
| 24229 | ew = 0.; |
| 24230 | ewc = 0.; |
| 24231 | i__1 = *ihi; |
| 24232 | for (i__ = *ilo; i__ <= i__1; ++i__) { |
| 24233 | ew += work[i__ + (*n << 2)]; |
| 24234 | ewc += work[i__ + *n * 5]; |
| 24235 | /* L260: */ |
| 24236 | } |
| 24237 | |
| 24238 | /* Computing 2nd power */ |
| 24239 | d__1 = ew; |
| 24240 | /* Computing 2nd power */ |
| 24241 | d__2 = ewc; |
| 24242 | /* Computing 2nd power */ |
| 24243 | d__3 = ew - ewc; |
| 24244 | gamma = coef * gamma - coef2 * (d__1 * d__1 + d__2 * d__2) - coef5 * ( |
| 24245 | d__3 * d__3); |
| 24246 | if (gamma == 0.) { |
| 24247 | goto L350; |
| 24248 | } |
| 24249 | if (it != 1) { |
| 24250 | beta = gamma / pgamma; |
| 24251 | } |
| 24252 | t = coef5 * (ewc - ew * 3.); |
| 24253 | tc = coef5 * (ew - ewc * 3.); |
| 24254 | |
| 24255 | dscal_cxx . . $ dscal_(f22c1db71784c345).(&nr, &beta, &work[*ilo], &c__1); |
| 24256 | dscal_cxx . . $ dscal_(f22c1db71784c345).(&nr, &beta, &work[*ilo + *n], &c__1); |
| 24257 | |
| 24258 | daxpy_cxx . . $ daxpy_(4b39f621356f7e14).(&nr, &coef, &work[*ilo + (*n << 2)], &c__1, &work[*ilo + *n], & |
| 24259 | c__1); |
| 24260 | daxpy_cxx . . $ daxpy_(4b39f621356f7e14).(&nr, &coef, &work[*ilo + *n * 5], &c__1, &work[*ilo], &c__1); |
| 24261 | |
| 24262 | i__1 = *ihi; |
| 24263 | for (i__ = *ilo; i__ <= i__1; ++i__) { |
| 24264 | work[i__] += tc; |
| 24265 | work[i__ + *n] += t; |
| 24266 | /* L270: */ |
| 24267 | } |
| 24268 | |
| 24269 | /* Apply matrix to vector */ |
| 24270 | |
| 24271 | i__1 = *ihi; |
| 24272 | for (i__ = *ilo; i__ <= i__1; ++i__) { |
| 24273 | kount = 0; |
| 24274 | sum = 0.; |
| 24275 | i__2 = *ihi; |
| 24276 | for (j = *ilo; j <= i__2; ++j) { |
| 24277 | if (a[i__ + j * a_dim1] == 0.) { |
| 24278 | goto L280; |
| 24279 | } |
| 24280 | ++kount; |
| 24281 | sum += work[j]; |
| 24282 | L280: |
| 24283 | if (b[i__ + j * b_dim1] == 0.) { |
| 24284 | goto L290; |
| 24285 | } |
| 24286 | ++kount; |
| 24287 | sum += work[j]; |
| 24288 | L290: |
| 24289 | ; |
| 24290 | } |
| 24291 | work[i__ + (*n << 1)] = (double) kount * work[i__ + *n] + sum; |
| 24292 | /* L300: */ |
| 24293 | } |
| 24294 | |
| 24295 | i__1 = *ihi; |
| 24296 | for (j = *ilo; j <= i__1; ++j) { |
| 24297 | kount = 0; |
| 24298 | sum = 0.; |
| 24299 | i__2 = *ihi; |
| 24300 | for (i__ = *ilo; i__ <= i__2; ++i__) { |
| 24301 | if (a[i__ + j * a_dim1] == 0.) { |
| 24302 | goto L310; |
| 24303 | } |
| 24304 | ++kount; |
| 24305 | sum += work[i__ + *n]; |
| 24306 | L310: |
| 24307 | if (b[i__ + j * b_dim1] == 0.) { |
| 24308 | goto L320; |
| 24309 | } |
| 24310 | ++kount; |
| 24311 | sum += work[i__ + *n]; |
| 24312 | L320: |
| 24313 | ; |
| 24314 | } |
| 24315 | work[j + *n * 3] = (double) kount * work[j] + sum; |
| 24316 | /* L330: */ |
| 24317 | } |
| 24318 | |
| 24319 | sum = ddot_cxx . . $ ddot_(2885988431543d16).(&nr, &work[*ilo + *n], &c__1, &work[*ilo + (*n << 1)], &c__1) |
| 24320 | + ddot_cxx . . $ ddot_(2885988431543d16).(&nr, &work[*ilo], &c__1, &work[*ilo + *n * 3], &c__1); |
| 24321 | alpha = gamma / sum; |
| 24322 | |
| 24323 | /* Determine correction to current iteration */ |
| 24324 | |
| 24325 | cmax = 0.; |
| 24326 | i__1 = *ihi; |
| 24327 | for (i__ = *ilo; i__ <= i__1; ++i__) { |
| 24328 | cor = alpha * work[i__ + *n]; |
| 24329 | if (abscxx . . $ abs(447c67c6676f75c3).(cor) > cmax) { |
| 24330 | cmax = abscxx . . $ abs(447c67c6676f75c3).(cor); |
| 24331 | } |
| 24332 | lscale[i__] += cor; |
| 24333 | cor = alpha * work[i__]; |
| 24334 | if (abscxx . . $ abs(447c67c6676f75c3).(cor) > cmax) { |
| 24335 | cmax = abscxx . . $ abs(447c67c6676f75c3).(cor); |
| 24336 | } |
| 24337 | rscale[i__] += cor; |
| 24338 | /* L340: */ |
| 24339 | } |
| 24340 | if (cmax < .5) { |
| 24341 | goto L350; |
| 24342 | } |
| 24343 | |
| 24344 | d__1 = -alpha; |
| 24345 | daxpy_cxx . . $ daxpy_(4b39f621356f7e14).(&nr, &d__1, &work[*ilo + (*n << 1)], &c__1, &work[*ilo + (*n << 2)] |
| 24346 | , &c__1); |
| 24347 | d__1 = -alpha; |
| 24348 | daxpy_cxx . . $ daxpy_(4b39f621356f7e14).(&nr, &d__1, &work[*ilo + *n * 3], &c__1, &work[*ilo + *n * 5], & |
| 24349 | c__1); |
| 24350 | |
| 24351 | pgamma = gamma; |
| 24352 | ++it; |
| 24353 | if (it <= nrp2) { |
| 24354 | goto L250; |
| 24355 | } |
| 24356 | |
| 24357 | /* End generalized conjugate gradient iteration */ |
| 24358 | |
| 24359 | L350: |
| 24360 | sfmin = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("S"); |
| 24361 | sfmax = 1. / sfmin; |
| 24362 | lsfmin = (integercxx . . $ integer#) (d_lg10cxx . . $ d_lg10(a5c8eef512f28486).(&sfmin) / basl + 1.); |
| 24363 | lsfmax = (integercxx . . $ integer#) (d_lg10cxx . . $ d_lg10(a5c8eef512f28486).(&sfmax) / basl); |
| 24364 | i__1 = *ihi; |
| 24365 | for (i__ = *ilo; i__ <= i__1; ++i__) { |
| 24366 | i__2 = *n - *ilo + 1; |
| 24367 | irab = idamax_cxx . . $ idamax_(a5c31fbfbc00ee45).(&i__2, &a[i__ + *ilo * a_dim1], lda); |
| 24368 | rab = (d__1 = a[i__ + (irab + *ilo - 1) * a_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__1)); |
| 24369 | i__2 = *n - *ilo + 1; |
| 24370 | irab = idamax_cxx . . $ idamax_(a5c31fbfbc00ee45).(&i__2, &b[i__ + *ilo * b_dim1], ldb); |
| 24371 | /* Computing MAX */ |
| 24372 | d__2 = rab, d__3 = (d__1 = b[i__ + (irab + *ilo - 1) * b_dim1], abscxx . . $ abs(447c67c6676f75c3).( |
| 24373 | d__1)); |
| 24374 | rab = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__2,d__3); |
| 24375 | d__1 = rab + sfmin; |
| 24376 | lrab = (integercxx . . $ integer#) (d_lg10cxx . . $ d_lg10(a5c8eef512f28486).(&d__1) / basl + 1.); |
| 24377 | ir = (integercxx . . $ integer#) (lscale[i__] + d_signcxx . . $ d_sign(8fcf9002b7f393aa).(&c_b71, &lscale[i__])); |
| 24378 | /* Computing MIN */ |
| 24379 | i__2 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(ir,lsfmin), i__2 = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__2,lsfmax), i__3 = lsfmax - lrab; |
| 24380 | ir = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__2,i__3); |
| 24381 | lscale[i__] = pow_dicxx . . $ pow_di(d073b4717a6ff874).(&c_b35, &ir); |
| 24382 | icab = idamax_cxx . . $ idamax_(a5c31fbfbc00ee45).(ihi, &a[i__ * a_dim1 + 1], &c__1); |
| 24383 | cab = (d__1 = a[icab + i__ * a_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__1)); |
| 24384 | icab = idamax_cxx . . $ idamax_(a5c31fbfbc00ee45).(ihi, &b[i__ * b_dim1 + 1], &c__1); |
| 24385 | /* Computing MAX */ |
| 24386 | d__2 = cab, d__3 = (d__1 = b[icab + i__ * b_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__1)); |
| 24387 | cab = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__2,d__3); |
| 24388 | d__1 = cab + sfmin; |
| 24389 | lcab = (integercxx . . $ integer#) (d_lg10cxx . . $ d_lg10(a5c8eef512f28486).(&d__1) / basl + 1.); |
| 24390 | jc = (integercxx . . $ integer#) (rscale[i__] + d_signcxx . . $ d_sign(8fcf9002b7f393aa).(&c_b71, &rscale[i__])); |
| 24391 | /* Computing MIN */ |
| 24392 | i__2 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(jc,lsfmin), i__2 = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__2,lsfmax), i__3 = lsfmax - lcab; |
| 24393 | jc = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__2,i__3); |
| 24394 | rscale[i__] = pow_dicxx . . $ pow_di(d073b4717a6ff874).(&c_b35, &jc); |
| 24395 | /* L360: */ |
| 24396 | } |
| 24397 | |
| 24398 | /* Row scaling of matrices A and B */ |
| 24399 | |
| 24400 | i__1 = *ihi; |
| 24401 | for (i__ = *ilo; i__ <= i__1; ++i__) { |
| 24402 | i__2 = *n - *ilo + 1; |
| 24403 | dscal_cxx . . $ dscal_(f22c1db71784c345).(&i__2, &lscale[i__], &a[i__ + *ilo * a_dim1], lda); |
| 24404 | i__2 = *n - *ilo + 1; |
| 24405 | dscal_cxx . . $ dscal_(f22c1db71784c345).(&i__2, &lscale[i__], &b[i__ + *ilo * b_dim1], ldb); |
| 24406 | /* L370: */ |
| 24407 | } |
| 24408 | |
| 24409 | /* Column scaling of matrices A and B */ |
| 24410 | |
| 24411 | i__1 = *ihi; |
| 24412 | for (j = *ilo; j <= i__1; ++j) { |
| 24413 | dscal_cxx . . $ dscal_(f22c1db71784c345).(ihi, &rscale[j], &a[j * a_dim1 + 1], &c__1); |
| 24414 | dscal_cxx . . $ dscal_(f22c1db71784c345).(ihi, &rscale[j], &b[j * b_dim1 + 1], &c__1); |
| 24415 | /* L380: */ |
| 24416 | } |
| 24417 | |
| 24418 | return 0; |
| 24419 | |
| 24420 | /* End of DGGBAL */ |
| 24421 | |
| 24422 | } /* dggbal_ */ |
| 24423 | |
| 24424 | /* Subroutine */ int dgges_cxx . . $ dgges_(b1e217c6559c3e73).(const char *jobvsl, const char *jobvsr, const char *sort, |
| 24425 | bool (*selctg)(const double *, const double *, const double *), |
| 24426 | integercxx . . $ integer# *n, double *a, integercxx . . $ integer# *lda, double *b, |
| 24427 | integercxx . . $ integer# *ldb, integercxx . . $ integer# *sdim, double *alphar, double *alphai, |
| 24428 | double *beta, double *vsl, integercxx . . $ integer# *ldvsl, double *vsr, |
| 24429 | integercxx . . $ integer# *ldvsr, double *work, integercxx . . $ integer# *lwork, bool *bwork, |
| 24430 | integercxx . . $ integer# *info) |
| 24431 | { |
| 24432 | /* Table of constant values */ |
| 24433 | static integercxx . . $ integer# c__1 = 1; |
| 24434 | static integercxx . . $ integer# c__0 = 0; |
| 24435 | static integercxx . . $ integer# c_n1 = -1; |
| 24436 | static double c_b38 = 0.; |
| 24437 | static double c_b39 = 1.; |
| 24438 | |
| 24439 | /* System generated locals */ |
| 24440 | integercxx . . $ integer# a_dim1, a_offset, b_dim1, b_offset, vsl_dim1, vsl_offset, |
| 24441 | vsr_dim1, vsr_offset, i__1, i__2; |
| 24442 | double d__1; |
| 24443 | |
| 24444 | /* Builtin functions |
| 24445 | double sqrt(double);*/ |
| 24446 | |
| 24447 | /* Local variables */ |
| 24448 | integercxx . . $ integer# i__, ip; |
| 24449 | double dif[2]; |
| 24450 | integercxx . . $ integer# ihi, ilo; |
| 24451 | double eps, anrm, bnrm; |
| 24452 | integercxx . . $ integer# idum[1], ierr, itau, iwrk; |
| 24453 | double pvsl, pvsr; |
| 24454 | integercxx . . $ integer# ileft, icols; |
| 24455 | bool cursl, ilvsl, ilvsr; |
| 24456 | integercxx . . $ integer# irows; |
| 24457 | bool lst2sl; |
| 24458 | bool ilascl, ilbscl; |
| 24459 | double safmin; |
| 24460 | double safmax; |
| 24461 | double bignum; |
| 24462 | integercxx . . $ integer# ijobvl, iright; |
| 24463 | integercxx . . $ integer# ijobvr; |
| 24464 | double anrmto, bnrmto; |
| 24465 | bool lastsl; |
| 24466 | integercxx . . $ integer# minwrk, maxwrk; |
| 24467 | double smlnum; |
| 24468 | bool wantst, lquery; |
| 24469 | |
| 24470 | |
| 24471 | /* -- LAPACK driver routine (version 3.1) -- */ |
| 24472 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 24473 | /* November 2006 */ |
| 24474 | |
| 24475 | /* .. Scalar Arguments .. */ |
| 24476 | /* .. */ |
| 24477 | /* .. Array Arguments .. */ |
| 24478 | /* .. */ |
| 24479 | /* .. Function Arguments .. */ |
| 24480 | /* .. */ |
| 24481 | |
| 24482 | /* Purpose */ |
| 24483 | /* ======= */ |
| 24484 | |
| 24485 | /* DGGES computes for a pair of N-by-N real nonsymmetric matrices (A,B), */ |
| 24486 | /* the generalized eigenvalues, the generalized real Schur form (S,T), */ |
| 24487 | /* optionally, the left and/or right matrices of Schur vectors (VSL and */ |
| 24488 | /* VSR). This gives the generalized Schur factorization */ |
| 24489 | |
| 24490 | /* (A,B) = ( (VSL)*S*(VSR)**T, (VSL)*T*(VSR)**T ) */ |
| 24491 | |
| 24492 | /* Optionally, it also orders the eigenvalues so that a selected cluster */ |
| 24493 | /* of eigenvalues appears in the leading diagonal blocks of the upper */ |
| 24494 | /* quasi-triangular matrix S and the upper triangular matrix T.The */ |
| 24495 | /* leading columns of VSL and VSR then form an orthonormal basis for the */ |
| 24496 | /* corresponding left and right eigenspaces (deflating subspaces). */ |
| 24497 | |
| 24498 | /* (If only the generalized eigenvalues are needed, use the driver */ |
| 24499 | /* DGGEV instead, which is faster.) */ |
| 24500 | |
| 24501 | /* A generalized eigenvalue for a pair of matrices (A,B) is a scalar w */ |
| 24502 | /* or a ratio alpha/beta = w, such that A - w*B is singular. It is */ |
| 24503 | /* usually represented as the pair (alpha,beta), as there is a */ |
| 24504 | /* reasonable interpretation for beta=0 or both being zero. */ |
| 24505 | |
| 24506 | /* A pair of matrices (S,T) is in generalized real Schur form if T is */ |
| 24507 | /* upper triangular with non-negative diagonal and S is block upper */ |
| 24508 | /* triangular with 1-by-1 and 2-by-2 blocks. 1-by-1 blocks correspond */ |
| 24509 | /* to real generalized eigenvalues, while 2-by-2 blocks of S will be */ |
| 24510 | /* "standardized" by making the corresponding elements of T have the */ |
| 24511 | /* form: */ |
| 24512 | /* [ a 0 ] */ |
| 24513 | /* [ 0 b ] */ |
| 24514 | |
| 24515 | /* and the pair of corresponding 2-by-2 blocks in S and T will have a */ |
| 24516 | /* complex conjugate pair of generalized eigenvalues. */ |
| 24517 | |
| 24518 | |
| 24519 | /* Arguments */ |
| 24520 | /* ========= */ |
| 24521 | |
| 24522 | /* JOBVSL (input) CHARACTER*1 */ |
| 24523 | /* = 'N': do not compute the left Schur vectors; */ |
| 24524 | /* = 'V': compute the left Schur vectors. */ |
| 24525 | |
| 24526 | /* JOBVSR (input) CHARACTER*1 */ |
| 24527 | /* = 'N': do not compute the right Schur vectors; */ |
| 24528 | /* = 'V': compute the right Schur vectors. */ |
| 24529 | |
| 24530 | /* SORT (input) CHARACTER*1 */ |
| 24531 | /* Specifies whether or not to order the eigenvalues on the */ |
| 24532 | /* diagonal of the generalized Schur form. */ |
| 24533 | /* = 'N': Eigenvalues are not ordered; */ |
| 24534 | /* = 'S': Eigenvalues are ordered (see SELCTG); */ |
| 24535 | |
| 24536 | /* SELCTG (external procedure) LOGICAL FUNCTION of three DOUBLE PRECISION arguments */ |
| 24537 | /* SELCTG must be declared EXTERNAL in the calling subroutine. */ |
| 24538 | /* If SORT = 'N', SELCTG is not referenced. */ |
| 24539 | /* If SORT = 'S', SELCTG is used to select eigenvalues to sort */ |
| 24540 | /* to the top left of the Schur form. */ |
| 24541 | /* An eigenvalue (ALPHAR(j)+ALPHAI(j))/BETA(j) is selected if */ |
| 24542 | /* SELCTG(ALPHAR(j),ALPHAI(j),BETA(j)) is true; i.e. if either */ |
| 24543 | /* one of a complex conjugate pair of eigenvalues is selected, */ |
| 24544 | /* then both complex eigenvalues are selected. */ |
| 24545 | |
| 24546 | /* Note that in the ill-conditioned case, a selected complex */ |
| 24547 | /* eigenvalue may no longer satisfy SELCTG(ALPHAR(j),ALPHAI(j), */ |
| 24548 | /* BETA(j)) = .TRUE. after ordering. INFO is to be set to N+2 */ |
| 24549 | /* in this case. */ |
| 24550 | |
| 24551 | /* N (input) INTEGER */ |
| 24552 | /* The order of the matrices A, B, VSL, and VSR. N >= 0. */ |
| 24553 | |
| 24554 | /* A (input/output) DOUBLE PRECISION array, dimension (LDA, N) */ |
| 24555 | /* On entry, the first of the pair of matrices. */ |
| 24556 | /* On exit, A has been overwritten by its generalized Schur */ |
| 24557 | /* form S. */ |
| 24558 | |
| 24559 | /* LDA (input) INTEGER */ |
| 24560 | /* The leading dimension of A. LDA >= max(1,N). */ |
| 24561 | |
| 24562 | /* B (input/output) DOUBLE PRECISION array, dimension (LDB, N) */ |
| 24563 | /* On entry, the second of the pair of matrices. */ |
| 24564 | /* On exit, B has been overwritten by its generalized Schur */ |
| 24565 | /* form T. */ |
| 24566 | |
| 24567 | /* LDB (input) INTEGER */ |
| 24568 | /* The leading dimension of B. LDB >= max(1,N). */ |
| 24569 | |
| 24570 | /* SDIM (output) INTEGER */ |
| 24571 | /* If SORT = 'N', SDIM = 0. */ |
| 24572 | /* If SORT = 'S', SDIM = number of eigenvalues (after sorting) */ |
| 24573 | /* for which SELCTG is true. (Complex conjugate pairs for which */ |
| 24574 | /* SELCTG is true for either eigenvalue count as 2.) */ |
| 24575 | |
| 24576 | /* ALPHAR (output) DOUBLE PRECISION array, dimension (N) */ |
| 24577 | /* ALPHAI (output) DOUBLE PRECISION array, dimension (N) */ |
| 24578 | /* BETA (output) DOUBLE PRECISION array, dimension (N) */ |
| 24579 | /* On exit, (ALPHAR(j) + ALPHAI(j)*i)/BETA(j), j=1,...,N, will */ |
| 24580 | /* be the generalized eigenvalues. ALPHAR(j) + ALPHAI(j)*i, */ |
| 24581 | /* and BETA(j),j=1,...,N are the diagonals of the complex Schur */ |
| 24582 | /* form (S,T) that would result if the 2-by-2 diagonal blocks of */ |
| 24583 | /* the real Schur form of (A,B) were further reduced to */ |
| 24584 | /* triangular form using 2-by-2 complex unitary transformations. */ |
| 24585 | /* If ALPHAI(j) is zero, then the j-th eigenvalue is real; if */ |
| 24586 | /* positive, then the j-th and (j+1)-st eigenvalues are a */ |
| 24587 | /* complex conjugate pair, with ALPHAI(j+1) negative. */ |
| 24588 | |
| 24589 | /* Note: the quotients ALPHAR(j)/BETA(j) and ALPHAI(j)/BETA(j) */ |
| 24590 | /* may easily over- or underflow, and BETA(j) may even be zero. */ |
| 24591 | /* Thus, the user should avoid naively computing the ratio. */ |
| 24592 | /* However, ALPHAR and ALPHAI will be always less than and */ |
| 24593 | /* usually comparable with norm(A) in magnitude, and BETA always */ |
| 24594 | /* less than and usually comparable with norm(B). */ |
| 24595 | |
| 24596 | /* VSL (output) DOUBLE PRECISION array, dimension (LDVSL,N) */ |
| 24597 | /* If JOBVSL = 'V', VSL will contain the left Schur vectors. */ |
| 24598 | /* Not referenced if JOBVSL = 'N'. */ |
| 24599 | |
| 24600 | /* LDVSL (input) INTEGER */ |
| 24601 | /* The leading dimension of the matrix VSL. LDVSL >=1, and */ |
| 24602 | /* if JOBVSL = 'V', LDVSL >= N. */ |
| 24603 | |
| 24604 | /* VSR (output) DOUBLE PRECISION array, dimension (LDVSR,N) */ |
| 24605 | /* If JOBVSR = 'V', VSR will contain the right Schur vectors. */ |
| 24606 | /* Not referenced if JOBVSR = 'N'. */ |
| 24607 | |
| 24608 | /* LDVSR (input) INTEGER */ |
| 24609 | /* The leading dimension of the matrix VSR. LDVSR >= 1, and */ |
| 24610 | /* if JOBVSR = 'V', LDVSR >= N. */ |
| 24611 | |
| 24612 | /* WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) */ |
| 24613 | /* On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ |
| 24614 | |
| 24615 | /* LWORK (input) INTEGER */ |
| 24616 | /* The dimension of the array WORK. */ |
| 24617 | /* If N = 0, LWORK >= 1, else LWORK >= 8*N+16. */ |
| 24618 | /* For good performance , LWORK must generally be larger. */ |
| 24619 | |
| 24620 | /* If LWORK = -1, then a workspace query is assumed; the routine */ |
| 24621 | /* only calculates the optimal size of the WORK array, returns */ |
| 24622 | /* this value as the first entry of the WORK array, and no error */ |
| 24623 | /* message related to LWORK is issued by XERBLA. */ |
| 24624 | |
| 24625 | /* BWORK (workspace) LOGICAL array, dimension (N) */ |
| 24626 | /* Not referenced if SORT = 'N'. */ |
| 24627 | |
| 24628 | /* INFO (output) INTEGER */ |
| 24629 | /* = 0: successful exit */ |
| 24630 | /* < 0: if INFO = -i, the i-th argument had an illegal value. */ |
| 24631 | /* = 1,...,N: */ |
| 24632 | /* The QZ iteration failed. (A,B) are not in Schur */ |
| 24633 | /* form, but ALPHAR(j), ALPHAI(j), and BETA(j) should */ |
| 24634 | /* be correct for j=INFO+1,...,N. */ |
| 24635 | /* > N: =N+1: other than QZ iteration failed in DHGEQZ. */ |
| 24636 | /* =N+2: after reordering, roundoff changed values of */ |
| 24637 | /* some complex eigenvalues so that leading */ |
| 24638 | /* eigenvalues in the Generalized Schur form no */ |
| 24639 | /* longer satisfy SELCTG=.TRUE. This could also */ |
| 24640 | /* be caused due to scaling. */ |
| 24641 | /* =N+3: reordering failed in DTGSEN. */ |
| 24642 | |
| 24643 | /* ===================================================================== */ |
| 24644 | |
| 24645 | /* .. Parameters .. */ |
| 24646 | /* .. */ |
| 24647 | /* .. Local Scalars .. */ |
| 24648 | /* .. */ |
| 24649 | /* .. Local Arrays .. */ |
| 24650 | /* .. */ |
| 24651 | /* .. External Subroutines .. */ |
| 24652 | /* .. */ |
| 24653 | /* .. External Functions .. */ |
| 24654 | /* .. */ |
| 24655 | /* .. Intrinsic Functions .. */ |
| 24656 | /* .. */ |
| 24657 | /* .. Executable Statements .. */ |
| 24658 | |
| 24659 | /* Decode the input arguments */ |
| 24660 | |
| 24661 | /* Parameter adjustments */ |
| 24662 | a_dim1 = *lda; |
| 24663 | a_offset = 1 + a_dim1; |
| 24664 | a -= a_offset; |
| 24665 | b_dim1 = *ldb; |
| 24666 | b_offset = 1 + b_dim1; |
| 24667 | b -= b_offset; |
| 24668 | --alphar; |
| 24669 | --alphai; |
| 24670 | --beta; |
| 24671 | vsl_dim1 = *ldvsl; |
| 24672 | vsl_offset = 1 + vsl_dim1; |
| 24673 | vsl -= vsl_offset; |
| 24674 | vsr_dim1 = *ldvsr; |
| 24675 | vsr_offset = 1 + vsr_dim1; |
| 24676 | vsr -= vsr_offset; |
| 24677 | --work; |
| 24678 | --bwork; |
| 24679 | |
| 24680 | /* Function Body */ |
| 24681 | if (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobvsl, "N")) { |
| 24682 | ijobvl = 1; |
| 24683 | ilvsl = false; |
| 24684 | } else if (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobvsl, "V")) { |
| 24685 | ijobvl = 2; |
| 24686 | ilvsl = true; |
| 24687 | } else { |
| 24688 | ijobvl = -1; |
| 24689 | ilvsl = false; |
| 24690 | } |
| 24691 | |
| 24692 | if (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobvsr, "N")) { |
| 24693 | ijobvr = 1; |
| 24694 | ilvsr = false; |
| 24695 | } else if (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobvsr, "V")) { |
| 24696 | ijobvr = 2; |
| 24697 | ilvsr = true; |
| 24698 | } else { |
| 24699 | ijobvr = -1; |
| 24700 | ilvsr = false; |
| 24701 | } |
| 24702 | |
| 24703 | wantst = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(sort, "S"); |
| 24704 | |
| 24705 | /* Test the input arguments */ |
| 24706 | |
| 24707 | *info = 0; |
| 24708 | lquery = *lwork == -1; |
| 24709 | if (ijobvl <= 0) { |
| 24710 | *info = -1; |
| 24711 | } else if (ijobvr <= 0) { |
| 24712 | *info = -2; |
| 24713 | } else if (! wantst && ! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(sort, "N")) { |
| 24714 | *info = -3; |
| 24715 | } else if (*n < 0) { |
| 24716 | *info = -5; |
| 24717 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 24718 | *info = -7; |
| 24719 | } else if (*ldb < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 24720 | *info = -9; |
| 24721 | } else if (*ldvsl < 1 || ilvsl && *ldvsl < *n) { |
| 24722 | *info = -15; |
| 24723 | } else if (*ldvsr < 1 || ilvsr && *ldvsr < *n) { |
| 24724 | *info = -17; |
| 24725 | } |
| 24726 | |
| 24727 | /* Compute workspace */ |
| 24728 | /* (Note: Comments in the code beginning "Workspace:" describe the */ |
| 24729 | /* minimal amount of workspace needed at that point in the code, */ |
| 24730 | /* as well as the preferred amount for good performance. */ |
| 24731 | /* NB refers to the optimal block size for the immediately */ |
| 24732 | /* following subroutine, as returned by ILAENV.) */ |
| 24733 | |
| 24734 | if (*info == 0) { |
| 24735 | if (*n > 0) { |
| 24736 | /* Computing MAX */ |
| 24737 | i__1 = *n << 3, i__2 = *n * 6 + 16; |
| 24738 | minwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 24739 | maxwrk = minwrk - *n + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEQRF", " ", n, & |
| 24740 | c__1, n, &c__0); |
| 24741 | /* Computing MAX */ |
| 24742 | i__1 = maxwrk, i__2 = minwrk - *n + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMQR", |
| 24743 | " ", n, &c__1, n, &c_n1); |
| 24744 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 24745 | if (ilvsl) { |
| 24746 | /* Computing MAX */ |
| 24747 | i__1 = maxwrk, i__2 = minwrk - *n + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DOR" |
| 24748 | "GQR", " ", n, &c__1, n, &c_n1); |
| 24749 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 24750 | } |
| 24751 | } else { |
| 24752 | minwrk = 1; |
| 24753 | maxwrk = 1; |
| 24754 | } |
| 24755 | work[1] = (double) maxwrk; |
| 24756 | |
| 24757 | if (*lwork < minwrk && ! lquery) { |
| 24758 | *info = -19; |
| 24759 | } |
| 24760 | } |
| 24761 | |
| 24762 | if (*info != 0) { |
| 24763 | i__1 = -(*info); |
| 24764 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGGES ", &i__1); |
| 24765 | return 0; |
| 24766 | } else if (lquery) { |
| 24767 | return 0; |
| 24768 | } |
| 24769 | |
| 24770 | /* Quick return if possible */ |
| 24771 | |
| 24772 | if (*n == 0) { |
| 24773 | *sdim = 0; |
| 24774 | return 0; |
| 24775 | } |
| 24776 | |
| 24777 | /* Get machine constants */ |
| 24778 | |
| 24779 | eps = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("P"); |
| 24780 | safmin = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("S"); |
| 24781 | safmax = 1. / safmin; |
| 24782 | dlabad_cxx . . $ dlabad_(4730c933dae9b326).(&safmin, &safmax); |
| 24783 | smlnum = sqrtcxx . . $ sqrt(fee4f1d22bc8e617).(safmin) / eps; |
| 24784 | bignum = 1. / smlnum; |
| 24785 | |
| 24786 | /* Scale A if max element outside range [SMLNUM,BIGNUM] */ |
| 24787 | |
| 24788 | anrm = dlange_cxx . . $ dlange_(98d44e6417336f20).("M", n, n, &a[a_offset], lda, &work[1]); |
| 24789 | ilascl = false; |
| 24790 | if (anrm > 0. && anrm < smlnum) { |
| 24791 | anrmto = smlnum; |
| 24792 | ilascl = true; |
| 24793 | } else if (anrm > bignum) { |
| 24794 | anrmto = bignum; |
| 24795 | ilascl = true; |
| 24796 | } |
| 24797 | if (ilascl) { |
| 24798 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &anrm, &anrmto, n, n, &a[a_offset], lda, & |
| 24799 | ierr); |
| 24800 | } |
| 24801 | |
| 24802 | /* Scale B if max element outside range [SMLNUM,BIGNUM] */ |
| 24803 | |
| 24804 | bnrm = dlange_cxx . . $ dlange_(98d44e6417336f20).("M", n, n, &b[b_offset], ldb, &work[1]); |
| 24805 | ilbscl = false; |
| 24806 | if (bnrm > 0. && bnrm < smlnum) { |
| 24807 | bnrmto = smlnum; |
| 24808 | ilbscl = true; |
| 24809 | } else if (bnrm > bignum) { |
| 24810 | bnrmto = bignum; |
| 24811 | ilbscl = true; |
| 24812 | } |
| 24813 | if (ilbscl) { |
| 24814 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &bnrm, &bnrmto, n, n, &b[b_offset], ldb, & |
| 24815 | ierr); |
| 24816 | } |
| 24817 | |
| 24818 | /* Permute the matrix to make it more nearly triangular */ |
| 24819 | /* (Workspace: need 6*N + 2*N space for storing balancing factors) */ |
| 24820 | |
| 24821 | ileft = 1; |
| 24822 | iright = *n + 1; |
| 24823 | iwrk = iright + *n; |
| 24824 | dggbal_cxx . . $ dggbal_(69bfde64ff0f2aeb).("P", n, &a[a_offset], lda, &b[b_offset], ldb, &ilo, &ihi, &work[ |
| 24825 | ileft], &work[iright], &work[iwrk], &ierr); |
| 24826 | |
| 24827 | /* Reduce B to triangular form (QR decomposition of B) */ |
| 24828 | /* (Workspace: need N, prefer N*NB) */ |
| 24829 | |
| 24830 | irows = ihi + 1 - ilo; |
| 24831 | icols = *n + 1 - ilo; |
| 24832 | itau = iwrk; |
| 24833 | iwrk = itau + irows; |
| 24834 | i__1 = *lwork + 1 - iwrk; |
| 24835 | dgeqrf_cxx . . $ dgeqrf_(b2aaa174babf002e).(&irows, &icols, &b[ilo + ilo * b_dim1], ldb, &work[itau], &work[ |
| 24836 | iwrk], &i__1, &ierr); |
| 24837 | |
| 24838 | /* Apply the orthogonal transformation to matrix A */ |
| 24839 | /* (Workspace: need N, prefer N*NB) */ |
| 24840 | |
| 24841 | i__1 = *lwork + 1 - iwrk; |
| 24842 | dormqr_cxx . . $ dormqr_(c6b7238dd97e9cf9).("L", "T", &irows, &icols, &irows, &b[ilo + ilo * b_dim1], ldb, & |
| 24843 | work[itau], &a[ilo + ilo * a_dim1], lda, &work[iwrk], &i__1, & |
| 24844 | ierr); |
| 24845 | |
| 24846 | /* Initialize VSL */ |
| 24847 | /* (Workspace: need N, prefer N*NB) */ |
| 24848 | |
| 24849 | if (ilvsl) { |
| 24850 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("Full", n, n, &c_b38, &c_b39, &vsl[vsl_offset], ldvsl); |
| 24851 | if (irows > 1) { |
| 24852 | i__1 = irows - 1; |
| 24853 | i__2 = irows - 1; |
| 24854 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("L", &i__1, &i__2, &b[ilo + 1 + ilo * b_dim1], ldb, &vsl[ |
| 24855 | ilo + 1 + ilo * vsl_dim1], ldvsl); |
| 24856 | } |
| 24857 | i__1 = *lwork + 1 - iwrk; |
| 24858 | dorgqr_cxx . . $ dorgqr_(424524679a238630).(&irows, &irows, &irows, &vsl[ilo + ilo * vsl_dim1], ldvsl, & |
| 24859 | work[itau], &work[iwrk], &i__1, &ierr); |
| 24860 | } |
| 24861 | |
| 24862 | /* Initialize VSR */ |
| 24863 | |
| 24864 | if (ilvsr) { |
| 24865 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("Full", n, n, &c_b38, &c_b39, &vsr[vsr_offset], ldvsr); |
| 24866 | } |
| 24867 | |
| 24868 | /* Reduce to generalized Hessenberg form */ |
| 24869 | /* (Workspace: none needed) */ |
| 24870 | |
| 24871 | dgghrd_cxx . . $ dgghrd_(a37938716ecaec33).(jobvsl, jobvsr, n, &ilo, &ihi, &a[a_offset], lda, &b[b_offset], |
| 24872 | ldb, &vsl[vsl_offset], ldvsl, &vsr[vsr_offset], ldvsr, &ierr); |
| 24873 | |
| 24874 | /* Perform QZ algorithm, computing Schur vectors if desired */ |
| 24875 | /* (Workspace: need N) */ |
| 24876 | |
| 24877 | iwrk = itau; |
| 24878 | i__1 = *lwork + 1 - iwrk; |
| 24879 | dhgeqz_cxx . . $ dhgeqz_(1c7cf0ed1736d01d).("S", jobvsl, jobvsr, n, &ilo, &ihi, &a[a_offset], lda, &b[ |
| 24880 | b_offset], ldb, &alphar[1], &alphai[1], &beta[1], &vsl[vsl_offset] |
| 24881 | , ldvsl, &vsr[vsr_offset], ldvsr, &work[iwrk], &i__1, &ierr); |
| 24882 | if (ierr != 0) { |
| 24883 | if (ierr > 0 && ierr <= *n) { |
| 24884 | *info = ierr; |
| 24885 | } else if (ierr > *n && ierr <= *n << 1) { |
| 24886 | *info = ierr - *n; |
| 24887 | } else { |
| 24888 | *info = *n + 1; |
| 24889 | } |
| 24890 | goto L50; |
| 24891 | } |
| 24892 | |
| 24893 | /* Sort eigenvalues ALPHA/BETA if desired */ |
| 24894 | /* (Workspace: need 4*N+16 ) */ |
| 24895 | |
| 24896 | *sdim = 0; |
| 24897 | if (wantst) { |
| 24898 | |
| 24899 | /* Undo scaling on eigenvalues before SELCTGing */ |
| 24900 | |
| 24901 | if (ilascl) { |
| 24902 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &anrmto, &anrm, n, &c__1, &alphar[1], |
| 24903 | n, &ierr); |
| 24904 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &anrmto, &anrm, n, &c__1, &alphai[1], |
| 24905 | n, &ierr); |
| 24906 | } |
| 24907 | if (ilbscl) { |
| 24908 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &bnrmto, &bnrm, n, &c__1, &beta[1], n, |
| 24909 | &ierr); |
| 24910 | } |
| 24911 | |
| 24912 | /* Select eigenvalues */ |
| 24913 | |
| 24914 | i__1 = *n; |
| 24915 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 24916 | bwork[i__] = (*selctg)(&alphar[i__], &alphai[i__], &beta[i__]); |
| 24917 | /* L10: */ |
| 24918 | } |
| 24919 | |
| 24920 | i__1 = *lwork - iwrk + 1; |
| 24921 | dtgsen_cxx . . $ dtgsen_(f355aa40bfbce1b9).(&c__0, &ilvsl, &ilvsr, &bwork[1], n, &a[a_offset], lda, &b[ |
| 24922 | b_offset], ldb, &alphar[1], &alphai[1], &beta[1], &vsl[ |
| 24923 | vsl_offset], ldvsl, &vsr[vsr_offset], ldvsr, sdim, &pvsl, & |
| 24924 | pvsr, dif, &work[iwrk], &i__1, idum, &c__1, &ierr); |
| 24925 | if (ierr == 1) { |
| 24926 | *info = *n + 3; |
| 24927 | } |
| 24928 | |
| 24929 | } |
| 24930 | |
| 24931 | /* Apply back-permutation to VSL and VSR */ |
| 24932 | /* (Workspace: none needed) */ |
| 24933 | |
| 24934 | if (ilvsl) { |
| 24935 | dggbak_cxx . . $ dggbak_(3fb2e360e620705c).("P", "L", n, &ilo, &ihi, &work[ileft], &work[iright], n, &vsl[ |
| 24936 | vsl_offset], ldvsl, &ierr); |
| 24937 | } |
| 24938 | |
| 24939 | if (ilvsr) { |
| 24940 | dggbak_cxx . . $ dggbak_(3fb2e360e620705c).("P", "R", n, &ilo, &ihi, &work[ileft], &work[iright], n, &vsr[ |
| 24941 | vsr_offset], ldvsr, &ierr); |
| 24942 | } |
| 24943 | |
| 24944 | /* Check if unscaling would cause over/underflow, if so, rescale */ |
| 24945 | /* (ALPHAR(I),ALPHAI(I),BETA(I)) so BETA(I) is on the order of */ |
| 24946 | /* B(I,I) and ALPHAR(I) and ALPHAI(I) are on the order of A(I,I) */ |
| 24947 | |
| 24948 | if (ilascl) { |
| 24949 | i__1 = *n; |
| 24950 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 24951 | if (alphai[i__] != 0.) { |
| 24952 | if (alphar[i__] / safmax > anrmto / anrm || safmin / alphar[ |
| 24953 | i__] > anrm / anrmto) { |
| 24954 | work[1] = (d__1 = a[i__ + i__ * a_dim1] / alphar[i__], |
| 24955 | abscxx . . $ abs(447c67c6676f75c3).(d__1)); |
| 24956 | beta[i__] *= work[1]; |
| 24957 | alphar[i__] *= work[1]; |
| 24958 | alphai[i__] *= work[1]; |
| 24959 | } else if (alphai[i__] / safmax > anrmto / anrm || safmin / |
| 24960 | alphai[i__] > anrm / anrmto) { |
| 24961 | work[1] = (d__1 = a[i__ + (i__ + 1) * a_dim1] / alphai[ |
| 24962 | i__], abscxx . . $ abs(447c67c6676f75c3).(d__1)); |
| 24963 | beta[i__] *= work[1]; |
| 24964 | alphar[i__] *= work[1]; |
| 24965 | alphai[i__] *= work[1]; |
| 24966 | } |
| 24967 | } |
| 24968 | /* L20: */ |
| 24969 | } |
| 24970 | } |
| 24971 | |
| 24972 | if (ilbscl) { |
| 24973 | i__1 = *n; |
| 24974 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 24975 | if (alphai[i__] != 0.) { |
| 24976 | if (beta[i__] / safmax > bnrmto / bnrm || safmin / beta[i__] |
| 24977 | > bnrm / bnrmto) { |
| 24978 | work[1] = (d__1 = b[i__ + i__ * b_dim1] / beta[i__], abscxx . . $ abs(447c67c6676f75c3).( |
| 24979 | d__1)); |
| 24980 | beta[i__] *= work[1]; |
| 24981 | alphar[i__] *= work[1]; |
| 24982 | alphai[i__] *= work[1]; |
| 24983 | } |
| 24984 | } |
| 24985 | /* L30: */ |
| 24986 | } |
| 24987 | } |
| 24988 | |
| 24989 | /* Undo scaling */ |
| 24990 | |
| 24991 | if (ilascl) { |
| 24992 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("H", &c__0, &c__0, &anrmto, &anrm, n, n, &a[a_offset], lda, & |
| 24993 | ierr); |
| 24994 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &anrmto, &anrm, n, &c__1, &alphar[1], n, & |
| 24995 | ierr); |
| 24996 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &anrmto, &anrm, n, &c__1, &alphai[1], n, & |
| 24997 | ierr); |
| 24998 | } |
| 24999 | |
| 25000 | if (ilbscl) { |
| 25001 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("U", &c__0, &c__0, &bnrmto, &bnrm, n, n, &b[b_offset], ldb, & |
| 25002 | ierr); |
| 25003 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &bnrmto, &bnrm, n, &c__1, &beta[1], n, & |
| 25004 | ierr); |
| 25005 | } |
| 25006 | |
| 25007 | if (wantst) { |
| 25008 | |
| 25009 | /* Check if reordering is correct */ |
| 25010 | |
| 25011 | lastsl = true; |
| 25012 | lst2sl = true; |
| 25013 | *sdim = 0; |
| 25014 | ip = 0; |
| 25015 | i__1 = *n; |
| 25016 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 25017 | cursl = (*selctg)(&alphar[i__], &alphai[i__], &beta[i__]); |
| 25018 | if (alphai[i__] == 0.) { |
| 25019 | if (cursl) { |
| 25020 | ++(*sdim); |
| 25021 | } |
| 25022 | ip = 0; |
| 25023 | if (cursl && ! lastsl) { |
| 25024 | *info = *n + 2; |
| 25025 | } |
| 25026 | } else { |
| 25027 | if (ip == 1) { |
| 25028 | |
| 25029 | /* Last eigenvalue of conjugate pair */ |
| 25030 | |
| 25031 | cursl = cursl || lastsl; |
| 25032 | lastsl = cursl; |
| 25033 | if (cursl) { |
| 25034 | *sdim += 2; |
| 25035 | } |
| 25036 | ip = -1; |
| 25037 | if (cursl && ! lst2sl) { |
| 25038 | *info = *n + 2; |
| 25039 | } |
| 25040 | } else { |
| 25041 | |
| 25042 | /* First eigenvalue of conjugate pair */ |
| 25043 | |
| 25044 | ip = 1; |
| 25045 | } |
| 25046 | } |
| 25047 | lst2sl = lastsl; |
| 25048 | lastsl = cursl; |
| 25049 | /* L40: */ |
| 25050 | } |
| 25051 | |
| 25052 | } |
| 25053 | |
| 25054 | L50: |
| 25055 | |
| 25056 | work[1] = (double) maxwrk; |
| 25057 | |
| 25058 | return 0; |
| 25059 | |
| 25060 | /* End of DGGES */ |
| 25061 | |
| 25062 | } /* dgges_ */ |
| 25063 | |
| 25064 | /* Subroutine */ int dggesx_cxx . . $ dggesx_(a844acc1da5f6278).(const char *jobvsl, const char *jobvsr, const char *sort, |
| 25065 | bool (*selctg)(const double *, const double *, const double *), |
| 25066 | const char *sense, integercxx . . $ integer# *n, double *a, integercxx . . $ integer# *lda, |
| 25067 | double *b, integercxx . . $ integer# *ldb, integercxx . . $ integer# *sdim, double *alphar, |
| 25068 | double *alphai, double *beta, double *vsl, integercxx . . $ integer# *ldvsl, |
| 25069 | double *vsr, integercxx . . $ integer# *ldvsr, double *rconde, double * |
| 25070 | rcondv, double *work, integercxx . . $ integer# *lwork, integercxx . . $ integer# *iwork, integercxx . . $ integer# * |
| 25071 | liwork, bool *bwork, integercxx . . $ integer# *info) |
| 25072 | { |
| 25073 | /* Table of constant values */ |
| 25074 | static integercxx . . $ integer# c__1 = 1; |
| 25075 | static integercxx . . $ integer# c__0 = 0; |
| 25076 | static integercxx . . $ integer# c_n1 = -1; |
| 25077 | static double c_b42 = 0.; |
| 25078 | static double c_b43 = 1.; |
| 25079 | |
| 25080 | /* System generated locals */ |
| 25081 | integercxx . . $ integer# a_dim1, a_offset, b_dim1, b_offset, vsl_dim1, vsl_offset, |
| 25082 | vsr_dim1, vsr_offset, i__1, i__2; |
| 25083 | double d__1; |
| 25084 | |
| 25085 | /* Local variables */ |
| 25086 | integercxx . . $ integer# i__, ip; |
| 25087 | double pl, pr, dif[2]; |
| 25088 | integercxx . . $ integer# ihi, ilo; |
| 25089 | double eps; |
| 25090 | integercxx . . $ integer# ijob; |
| 25091 | double anrm, bnrm; |
| 25092 | integercxx . . $ integer# ierr, itau, iwrk, lwrk; |
| 25093 | integercxx . . $ integer# ileft, icols; |
| 25094 | bool cursl, ilvsl, ilvsr; |
| 25095 | integercxx . . $ integer# irows; |
| 25096 | bool lst2sl; |
| 25097 | bool ilascl, ilbscl; |
| 25098 | double safmin; |
| 25099 | double safmax; |
| 25100 | double bignum; |
| 25101 | integercxx . . $ integer# ijobvl, iright; |
| 25102 | integercxx . . $ integer# ijobvr; |
| 25103 | bool wantsb; |
| 25104 | integercxx . . $ integer# liwmin; |
| 25105 | bool wantse, lastsl; |
| 25106 | double anrmto, bnrmto; |
| 25107 | integercxx . . $ integer# minwrk, maxwrk; |
| 25108 | bool wantsn; |
| 25109 | double smlnum; |
| 25110 | bool wantst, lquery, wantsv; |
| 25111 | |
| 25112 | |
| 25113 | /* -- LAPACK driver routine (version 3.1) -- */ |
| 25114 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 25115 | /* November 2006 */ |
| 25116 | |
| 25117 | /* .. Scalar Arguments .. */ |
| 25118 | /* .. */ |
| 25119 | /* .. Array Arguments .. */ |
| 25120 | /* .. */ |
| 25121 | /* .. Function Arguments .. */ |
| 25122 | /* .. */ |
| 25123 | |
| 25124 | /* Purpose */ |
| 25125 | /* ======= */ |
| 25126 | |
| 25127 | /* DGGESX computes for a pair of N-by-N real nonsymmetric matrices */ |
| 25128 | /* (A,B), the generalized eigenvalues, the real Schur form (S,T), and, */ |
| 25129 | /* optionally, the left and/or right matrices of Schur vectors (VSL and */ |
| 25130 | /* VSR). This gives the generalized Schur factorization */ |
| 25131 | |
| 25132 | /* (A,B) = ( (VSL) S (VSR)**T, (VSL) T (VSR)**T ) */ |
| 25133 | |
| 25134 | /* Optionally, it also orders the eigenvalues so that a selected cluster */ |
| 25135 | /* of eigenvalues appears in the leading diagonal blocks of the upper */ |
| 25136 | /* quasi-triangular matrix S and the upper triangular matrix T; computes */ |
| 25137 | /* a reciprocal condition number for the average of the selected */ |
| 25138 | /* eigenvalues (RCONDE); and computes a reciprocal condition number for */ |
| 25139 | /* the right and left deflating subspaces corresponding to the selected */ |
| 25140 | /* eigenvalues (RCONDV). The leading columns of VSL and VSR then form */ |
| 25141 | /* an orthonormal basis for the corresponding left and right eigenspaces */ |
| 25142 | /* (deflating subspaces). */ |
| 25143 | |
| 25144 | /* A generalized eigenvalue for a pair of matrices (A,B) is a scalar w */ |
| 25145 | /* or a ratio alpha/beta = w, such that A - w*B is singular. It is */ |
| 25146 | /* usually represented as the pair (alpha,beta), as there is a */ |
| 25147 | /* reasonable interpretation for beta=0 or for both being zero. */ |
| 25148 | |
| 25149 | /* A pair of matrices (S,T) is in generalized real Schur form if T is */ |
| 25150 | /* upper triangular with non-negative diagonal and S is block upper */ |
| 25151 | /* triangular with 1-by-1 and 2-by-2 blocks. 1-by-1 blocks correspond */ |
| 25152 | /* to real generalized eigenvalues, while 2-by-2 blocks of S will be */ |
| 25153 | /* "standardized" by making the corresponding elements of T have the */ |
| 25154 | /* form: */ |
| 25155 | /* [ a 0 ] */ |
| 25156 | /* [ 0 b ] */ |
| 25157 | |
| 25158 | /* and the pair of corresponding 2-by-2 blocks in S and T will have a */ |
| 25159 | /* complex conjugate pair of generalized eigenvalues. */ |
| 25160 | |
| 25161 | |
| 25162 | /* Arguments */ |
| 25163 | /* ========= */ |
| 25164 | |
| 25165 | /* JOBVSL (input) CHARACTER*1 */ |
| 25166 | /* = 'N': do not compute the left Schur vectors; */ |
| 25167 | /* = 'V': compute the left Schur vectors. */ |
| 25168 | |
| 25169 | /* JOBVSR (input) CHARACTER*1 */ |
| 25170 | /* = 'N': do not compute the right Schur vectors; */ |
| 25171 | /* = 'V': compute the right Schur vectors. */ |
| 25172 | |
| 25173 | /* SORT (input) CHARACTER*1 */ |
| 25174 | /* Specifies whether or not to order the eigenvalues on the */ |
| 25175 | /* diagonal of the generalized Schur form. */ |
| 25176 | /* = 'N': Eigenvalues are not ordered; */ |
| 25177 | /* = 'S': Eigenvalues are ordered (see SELCTG). */ |
| 25178 | |
| 25179 | /* SELCTG (external procedure) LOGICAL FUNCTION of three DOUBLE PRECISION arguments */ |
| 25180 | /* SELCTG must be declared EXTERNAL in the calling subroutine. */ |
| 25181 | /* If SORT = 'N', SELCTG is not referenced. */ |
| 25182 | /* If SORT = 'S', SELCTG is used to select eigenvalues to sort */ |
| 25183 | /* to the top left of the Schur form. */ |
| 25184 | /* An eigenvalue (ALPHAR(j)+ALPHAI(j))/BETA(j) is selected if */ |
| 25185 | /* SELCTG(ALPHAR(j),ALPHAI(j),BETA(j)) is true; i.e. if either */ |
| 25186 | /* one of a complex conjugate pair of eigenvalues is selected, */ |
| 25187 | /* then both complex eigenvalues are selected. */ |
| 25188 | /* Note that a selected complex eigenvalue may no longer satisfy */ |
| 25189 | /* SELCTG(ALPHAR(j),ALPHAI(j),BETA(j)) = .TRUE. after ordering, */ |
| 25190 | /* since ordering may change the value of complex eigenvalues */ |
| 25191 | /* (especially if the eigenvalue is ill-conditioned), in this */ |
| 25192 | /* case INFO is set to N+3. */ |
| 25193 | |
| 25194 | /* SENSE (input) CHARACTER*1 */ |
| 25195 | /* Determines which reciprocal condition numbers are computed. */ |
| 25196 | /* = 'N' : None are computed; */ |
| 25197 | /* = 'E' : Computed for average of selected eigenvalues only; */ |
| 25198 | /* = 'V' : Computed for selected deflating subspaces only; */ |
| 25199 | /* = 'B' : Computed for both. */ |
| 25200 | /* If SENSE = 'E', 'V', or 'B', SORT must equal 'S'. */ |
| 25201 | |
| 25202 | /* N (input) INTEGER */ |
| 25203 | /* The order of the matrices A, B, VSL, and VSR. N >= 0. */ |
| 25204 | |
| 25205 | /* A (input/output) DOUBLE PRECISION array, dimension (LDA, N) */ |
| 25206 | /* On entry, the first of the pair of matrices. */ |
| 25207 | /* On exit, A has been overwritten by its generalized Schur */ |
| 25208 | /* form S. */ |
| 25209 | |
| 25210 | /* LDA (input) INTEGER */ |
| 25211 | /* The leading dimension of A. LDA >= max(1,N). */ |
| 25212 | |
| 25213 | /* B (input/output) DOUBLE PRECISION array, dimension (LDB, N) */ |
| 25214 | /* On entry, the second of the pair of matrices. */ |
| 25215 | /* On exit, B has been overwritten by its generalized Schur */ |
| 25216 | /* form T. */ |
| 25217 | |
| 25218 | /* LDB (input) INTEGER */ |
| 25219 | /* The leading dimension of B. LDB >= max(1,N). */ |
| 25220 | |
| 25221 | /* SDIM (output) INTEGER */ |
| 25222 | /* If SORT = 'N', SDIM = 0. */ |
| 25223 | /* If SORT = 'S', SDIM = number of eigenvalues (after sorting) */ |
| 25224 | /* for which SELCTG is true. (Complex conjugate pairs for which */ |
| 25225 | /* SELCTG is true for either eigenvalue count as 2.) */ |
| 25226 | |
| 25227 | /* ALPHAR (output) DOUBLE PRECISION array, dimension (N) */ |
| 25228 | /* ALPHAI (output) DOUBLE PRECISION array, dimension (N) */ |
| 25229 | /* BETA (output) DOUBLE PRECISION array, dimension (N) */ |
| 25230 | /* On exit, (ALPHAR(j) + ALPHAI(j)*i)/BETA(j), j=1,...,N, will */ |
| 25231 | /* be the generalized eigenvalues. ALPHAR(j) + ALPHAI(j)*i */ |
| 25232 | /* and BETA(j),j=1,...,N are the diagonals of the complex Schur */ |
| 25233 | /* form (S,T) that would result if the 2-by-2 diagonal blocks of */ |
| 25234 | /* the real Schur form of (A,B) were further reduced to */ |
| 25235 | /* triangular form using 2-by-2 complex unitary transformations. */ |
| 25236 | /* If ALPHAI(j) is zero, then the j-th eigenvalue is real; if */ |
| 25237 | /* positive, then the j-th and (j+1)-st eigenvalues are a */ |
| 25238 | /* complex conjugate pair, with ALPHAI(j+1) negative. */ |
| 25239 | |
| 25240 | /* Note: the quotients ALPHAR(j)/BETA(j) and ALPHAI(j)/BETA(j) */ |
| 25241 | /* may easily over- or underflow, and BETA(j) may even be zero. */ |
| 25242 | /* Thus, the user should avoid naively computing the ratio. */ |
| 25243 | /* However, ALPHAR and ALPHAI will be always less than and */ |
| 25244 | /* usually comparable with norm(A) in magnitude, and BETA always */ |
| 25245 | /* less than and usually comparable with norm(B). */ |
| 25246 | |
| 25247 | /* VSL (output) DOUBLE PRECISION array, dimension (LDVSL,N) */ |
| 25248 | /* If JOBVSL = 'V', VSL will contain the left Schur vectors. */ |
| 25249 | /* Not referenced if JOBVSL = 'N'. */ |
| 25250 | |
| 25251 | /* LDVSL (input) INTEGER */ |
| 25252 | /* The leading dimension of the matrix VSL. LDVSL >=1, and */ |
| 25253 | /* if JOBVSL = 'V', LDVSL >= N. */ |
| 25254 | |
| 25255 | /* VSR (output) DOUBLE PRECISION array, dimension (LDVSR,N) */ |
| 25256 | /* If JOBVSR = 'V', VSR will contain the right Schur vectors. */ |
| 25257 | /* Not referenced if JOBVSR = 'N'. */ |
| 25258 | |
| 25259 | /* LDVSR (input) INTEGER */ |
| 25260 | /* The leading dimension of the matrix VSR. LDVSR >= 1, and */ |
| 25261 | /* if JOBVSR = 'V', LDVSR >= N. */ |
| 25262 | |
| 25263 | /* RCONDE (output) DOUBLE PRECISION array, dimension ( 2 ) */ |
| 25264 | /* If SENSE = 'E' or 'B', RCONDE(1) and RCONDE(2) contain the */ |
| 25265 | /* reciprocal condition numbers for the average of the selected */ |
| 25266 | /* eigenvalues. */ |
| 25267 | /* Not referenced if SENSE = 'N' or 'V'. */ |
| 25268 | |
| 25269 | /* RCONDV (output) DOUBLE PRECISION array, dimension ( 2 ) */ |
| 25270 | /* If SENSE = 'V' or 'B', RCONDV(1) and RCONDV(2) contain the */ |
| 25271 | /* reciprocal condition numbers for the selected deflating */ |
| 25272 | /* subspaces. */ |
| 25273 | /* Not referenced if SENSE = 'N' or 'E'. */ |
| 25274 | |
| 25275 | /* WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) */ |
| 25276 | /* On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ |
| 25277 | |
| 25278 | /* LWORK (input) INTEGER */ |
| 25279 | /* The dimension of the array WORK. */ |
| 25280 | /* If N = 0, LWORK >= 1, else if SENSE = 'E', 'V', or 'B', */ |
| 25281 | /* LWORK >= max( 8*N, 6*N+16, 2*SDIM*(N-SDIM) ), else */ |
| 25282 | /* LWORK >= max( 8*N, 6*N+16 ). */ |
| 25283 | /* Note that 2*SDIM*(N-SDIM) <= N*N/2. */ |
| 25284 | /* Note also that an error is only returned if */ |
| 25285 | /* LWORK < max( 8*N, 6*N+16), but if SENSE = 'E' or 'V' or 'B' */ |
| 25286 | /* this may not be large enough. */ |
| 25287 | |
| 25288 | /* If LWORK = -1, then a workspace query is assumed; the routine */ |
| 25289 | /* only calculates the bound on the optimal size of the WORK */ |
| 25290 | /* array and the minimum size of the IWORK array, returns these */ |
| 25291 | /* values as the first entries of the WORK and IWORK arrays, and */ |
| 25292 | /* no error message related to LWORK or LIWORK is issued by */ |
| 25293 | /* XERBLA. */ |
| 25294 | |
| 25295 | /* IWORK (workspace) INTEGER array, dimension (MAX(1,LIWORK)) */ |
| 25296 | /* On exit, if INFO = 0, IWORK(1) returns the minimum LIWORK. */ |
| 25297 | |
| 25298 | /* LIWORK (input) INTEGER */ |
| 25299 | /* The dimension of the array IWORK. */ |
| 25300 | /* If SENSE = 'N' or N = 0, LIWORK >= 1, otherwise */ |
| 25301 | /* LIWORK >= N+6. */ |
| 25302 | |
| 25303 | /* If LIWORK = -1, then a workspace query is assumed; the */ |
| 25304 | /* routine only calculates the bound on the optimal size of the */ |
| 25305 | /* WORK array and the minimum size of the IWORK array, returns */ |
| 25306 | /* these values as the first entries of the WORK and IWORK */ |
| 25307 | /* arrays, and no error message related to LWORK or LIWORK is */ |
| 25308 | /* issued by XERBLA. */ |
| 25309 | |
| 25310 | /* BWORK (workspace) LOGICAL array, dimension (N) */ |
| 25311 | /* Not referenced if SORT = 'N'. */ |
| 25312 | |
| 25313 | /* INFO (output) INTEGER */ |
| 25314 | /* = 0: successful exit */ |
| 25315 | /* < 0: if INFO = -i, the i-th argument had an illegal value. */ |
| 25316 | /* = 1,...,N: */ |
| 25317 | /* The QZ iteration failed. (A,B) are not in Schur */ |
| 25318 | /* form, but ALPHAR(j), ALPHAI(j), and BETA(j) should */ |
| 25319 | /* be correct for j=INFO+1,...,N. */ |
| 25320 | /* > N: =N+1: other than QZ iteration failed in DHGEQZ */ |
| 25321 | /* =N+2: after reordering, roundoff changed values of */ |
| 25322 | /* some complex eigenvalues so that leading */ |
| 25323 | /* eigenvalues in the Generalized Schur form no */ |
| 25324 | /* longer satisfy SELCTG=.TRUE. This could also */ |
| 25325 | /* be caused due to scaling. */ |
| 25326 | /* =N+3: reordering failed in DTGSEN. */ |
| 25327 | |
| 25328 | /* Further details */ |
| 25329 | /* =============== */ |
| 25330 | |
| 25331 | /* An approximate (asymptotic) bound on the average absolute error of */ |
| 25332 | /* the selected eigenvalues is */ |
| 25333 | |
| 25334 | /* EPS * norm((A, B)) / RCONDE( 1 ). */ |
| 25335 | |
| 25336 | /* An approximate (asymptotic) bound on the maximum angular error in */ |
| 25337 | /* the computed deflating subspaces is */ |
| 25338 | |
| 25339 | /* EPS * norm((A, B)) / RCONDV( 2 ). */ |
| 25340 | |
| 25341 | /* See LAPACK User's Guide, section 4.11 for more information. */ |
| 25342 | |
| 25343 | /* ===================================================================== */ |
| 25344 | |
| 25345 | /* .. Parameters .. */ |
| 25346 | /* .. */ |
| 25347 | /* .. Local Scalars .. */ |
| 25348 | /* .. */ |
| 25349 | /* .. Local Arrays .. */ |
| 25350 | /* .. */ |
| 25351 | /* .. External Subroutines .. */ |
| 25352 | /* .. */ |
| 25353 | /* .. External Functions .. */ |
| 25354 | /* .. */ |
| 25355 | /* .. Intrinsic Functions .. */ |
| 25356 | /* .. */ |
| 25357 | /* .. Executable Statements .. */ |
| 25358 | |
| 25359 | /* Decode the input arguments */ |
| 25360 | |
| 25361 | /* Parameter adjustments */ |
| 25362 | a_dim1 = *lda; |
| 25363 | a_offset = 1 + a_dim1; |
| 25364 | a -= a_offset; |
| 25365 | b_dim1 = *ldb; |
| 25366 | b_offset = 1 + b_dim1; |
| 25367 | b -= b_offset; |
| 25368 | --alphar; |
| 25369 | --alphai; |
| 25370 | --beta; |
| 25371 | vsl_dim1 = *ldvsl; |
| 25372 | vsl_offset = 1 + vsl_dim1; |
| 25373 | vsl -= vsl_offset; |
| 25374 | vsr_dim1 = *ldvsr; |
| 25375 | vsr_offset = 1 + vsr_dim1; |
| 25376 | vsr -= vsr_offset; |
| 25377 | --rconde; |
| 25378 | --rcondv; |
| 25379 | --work; |
| 25380 | --iwork; |
| 25381 | --bwork; |
| 25382 | |
| 25383 | /* Function Body */ |
| 25384 | if (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobvsl, "N")) { |
| 25385 | ijobvl = 1; |
| 25386 | ilvsl = false; |
| 25387 | } else if (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobvsl, "V")) { |
| 25388 | ijobvl = 2; |
| 25389 | ilvsl = true; |
| 25390 | } else { |
| 25391 | ijobvl = -1; |
| 25392 | ilvsl = false; |
| 25393 | } |
| 25394 | |
| 25395 | if (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobvsr, "N")) { |
| 25396 | ijobvr = 1; |
| 25397 | ilvsr = false; |
| 25398 | } else if (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobvsr, "V")) { |
| 25399 | ijobvr = 2; |
| 25400 | ilvsr = true; |
| 25401 | } else { |
| 25402 | ijobvr = -1; |
| 25403 | ilvsr = false; |
| 25404 | } |
| 25405 | |
| 25406 | wantst = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(sort, "S"); |
| 25407 | wantsn = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(sense, "N"); |
| 25408 | wantse = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(sense, "E"); |
| 25409 | wantsv = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(sense, "V"); |
| 25410 | wantsb = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(sense, "B"); |
| 25411 | lquery = *lwork == -1 || *liwork == -1; |
| 25412 | if (wantsn) { |
| 25413 | ijob = 0; |
| 25414 | } else if (wantse) { |
| 25415 | ijob = 1; |
| 25416 | } else if (wantsv) { |
| 25417 | ijob = 2; |
| 25418 | } else if (wantsb) { |
| 25419 | ijob = 4; |
| 25420 | } |
| 25421 | |
| 25422 | /* Test the input arguments */ |
| 25423 | |
| 25424 | *info = 0; |
| 25425 | if (ijobvl <= 0) { |
| 25426 | *info = -1; |
| 25427 | } else if (ijobvr <= 0) { |
| 25428 | *info = -2; |
| 25429 | } else if (! wantst && ! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(sort, "N")) { |
| 25430 | *info = -3; |
| 25431 | } else if (! (wantsn || wantse || wantsv || wantsb) || ! wantst && ! |
| 25432 | wantsn) { |
| 25433 | *info = -5; |
| 25434 | } else if (*n < 0) { |
| 25435 | *info = -6; |
| 25436 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 25437 | *info = -8; |
| 25438 | } else if (*ldb < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 25439 | *info = -10; |
| 25440 | } else if (*ldvsl < 1 || ilvsl && *ldvsl < *n) { |
| 25441 | *info = -16; |
| 25442 | } else if (*ldvsr < 1 || ilvsr && *ldvsr < *n) { |
| 25443 | *info = -18; |
| 25444 | } |
| 25445 | |
| 25446 | /* Compute workspace */ |
| 25447 | /* (Note: Comments in the code beginning "Workspace:" describe the */ |
| 25448 | /* minimal amount of workspace needed at that point in the code, */ |
| 25449 | /* as well as the preferred amount for good performance. */ |
| 25450 | /* NB refers to the optimal block size for the immediately */ |
| 25451 | /* following subroutine, as returned by ILAENV.) */ |
| 25452 | |
| 25453 | if (*info == 0) { |
| 25454 | if (*n > 0) { |
| 25455 | /* Computing MAX */ |
| 25456 | i__1 = *n << 3, i__2 = *n * 6 + 16; |
| 25457 | minwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 25458 | maxwrk = minwrk - *n + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEQRF", " ", n, & |
| 25459 | c__1, n, &c__0); |
| 25460 | /* Computing MAX */ |
| 25461 | i__1 = maxwrk, i__2 = minwrk - *n + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMQR", |
| 25462 | " ", n, &c__1, n, &c_n1); |
| 25463 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 25464 | if (ilvsl) { |
| 25465 | /* Computing MAX */ |
| 25466 | i__1 = maxwrk, i__2 = minwrk - *n + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DOR" |
| 25467 | "GQR", " ", n, &c__1, n, &c_n1); |
| 25468 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 25469 | } |
| 25470 | lwrk = maxwrk; |
| 25471 | if (ijob >= 1) { |
| 25472 | /* Computing MAX */ |
| 25473 | i__1 = lwrk, i__2 = *n * *n / 2; |
| 25474 | lwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 25475 | } |
| 25476 | } else { |
| 25477 | minwrk = 1; |
| 25478 | maxwrk = 1; |
| 25479 | lwrk = 1; |
| 25480 | } |
| 25481 | work[1] = (double) lwrk; |
| 25482 | if (wantsn || *n == 0) { |
| 25483 | liwmin = 1; |
| 25484 | } else { |
| 25485 | liwmin = *n + 6; |
| 25486 | } |
| 25487 | iwork[1] = liwmin; |
| 25488 | |
| 25489 | if (*lwork < minwrk && ! lquery) { |
| 25490 | *info = -22; |
| 25491 | } else if (*liwork < liwmin && ! lquery) { |
| 25492 | *info = -24; |
| 25493 | } |
| 25494 | } |
| 25495 | |
| 25496 | if (*info != 0) { |
| 25497 | i__1 = -(*info); |
| 25498 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGGESX", &i__1); |
| 25499 | return 0; |
| 25500 | } else if (lquery) { |
| 25501 | return 0; |
| 25502 | } |
| 25503 | |
| 25504 | /* Quick return if possible */ |
| 25505 | |
| 25506 | if (*n == 0) { |
| 25507 | *sdim = 0; |
| 25508 | return 0; |
| 25509 | } |
| 25510 | |
| 25511 | /* Get machine constants */ |
| 25512 | |
| 25513 | eps = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("P"); |
| 25514 | safmin = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("S"); |
| 25515 | safmax = 1. / safmin; |
| 25516 | dlabad_cxx . . $ dlabad_(4730c933dae9b326).(&safmin, &safmax); |
| 25517 | smlnum = sqrtcxx . . $ sqrt(fee4f1d22bc8e617).(safmin) / eps; |
| 25518 | bignum = 1. / smlnum; |
| 25519 | |
| 25520 | /* Scale A if max element outside range [SMLNUM,BIGNUM] */ |
| 25521 | |
| 25522 | anrm = dlange_cxx . . $ dlange_(98d44e6417336f20).("M", n, n, &a[a_offset], lda, &work[1]); |
| 25523 | ilascl = false; |
| 25524 | if (anrm > 0. && anrm < smlnum) { |
| 25525 | anrmto = smlnum; |
| 25526 | ilascl = true; |
| 25527 | } else if (anrm > bignum) { |
| 25528 | anrmto = bignum; |
| 25529 | ilascl = true; |
| 25530 | } |
| 25531 | if (ilascl) { |
| 25532 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &anrm, &anrmto, n, n, &a[a_offset], lda, & |
| 25533 | ierr); |
| 25534 | } |
| 25535 | |
| 25536 | /* Scale B if max element outside range [SMLNUM,BIGNUM] */ |
| 25537 | |
| 25538 | bnrm = dlange_cxx . . $ dlange_(98d44e6417336f20).("M", n, n, &b[b_offset], ldb, &work[1]); |
| 25539 | ilbscl = false; |
| 25540 | if (bnrm > 0. && bnrm < smlnum) { |
| 25541 | bnrmto = smlnum; |
| 25542 | ilbscl = true; |
| 25543 | } else if (bnrm > bignum) { |
| 25544 | bnrmto = bignum; |
| 25545 | ilbscl = true; |
| 25546 | } |
| 25547 | if (ilbscl) { |
| 25548 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &bnrm, &bnrmto, n, n, &b[b_offset], ldb, & |
| 25549 | ierr); |
| 25550 | } |
| 25551 | |
| 25552 | /* Permute the matrix to make it more nearly triangular */ |
| 25553 | /* (Workspace: need 6*N + 2*N for permutation parameters) */ |
| 25554 | |
| 25555 | ileft = 1; |
| 25556 | iright = *n + 1; |
| 25557 | iwrk = iright + *n; |
| 25558 | dggbal_cxx . . $ dggbal_(69bfde64ff0f2aeb).("P", n, &a[a_offset], lda, &b[b_offset], ldb, &ilo, &ihi, &work[ |
| 25559 | ileft], &work[iright], &work[iwrk], &ierr); |
| 25560 | |
| 25561 | /* Reduce B to triangular form (QR decomposition of B) */ |
| 25562 | /* (Workspace: need N, prefer N*NB) */ |
| 25563 | |
| 25564 | irows = ihi + 1 - ilo; |
| 25565 | icols = *n + 1 - ilo; |
| 25566 | itau = iwrk; |
| 25567 | iwrk = itau + irows; |
| 25568 | i__1 = *lwork + 1 - iwrk; |
| 25569 | dgeqrf_cxx . . $ dgeqrf_(b2aaa174babf002e).(&irows, &icols, &b[ilo + ilo * b_dim1], ldb, &work[itau], &work[ |
| 25570 | iwrk], &i__1, &ierr); |
| 25571 | |
| 25572 | /* Apply the orthogonal transformation to matrix A */ |
| 25573 | /* (Workspace: need N, prefer N*NB) */ |
| 25574 | |
| 25575 | i__1 = *lwork + 1 - iwrk; |
| 25576 | dormqr_cxx . . $ dormqr_(c6b7238dd97e9cf9).("L", "T", &irows, &icols, &irows, &b[ilo + ilo * b_dim1], ldb, & |
| 25577 | work[itau], &a[ilo + ilo * a_dim1], lda, &work[iwrk], &i__1, & |
| 25578 | ierr); |
| 25579 | |
| 25580 | /* Initialize VSL */ |
| 25581 | /* (Workspace: need N, prefer N*NB) */ |
| 25582 | |
| 25583 | if (ilvsl) { |
| 25584 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("Full", n, n, &c_b42, &c_b43, &vsl[vsl_offset], ldvsl); |
| 25585 | if (irows > 1) { |
| 25586 | i__1 = irows - 1; |
| 25587 | i__2 = irows - 1; |
| 25588 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("L", &i__1, &i__2, &b[ilo + 1 + ilo * b_dim1], ldb, &vsl[ |
| 25589 | ilo + 1 + ilo * vsl_dim1], ldvsl); |
| 25590 | } |
| 25591 | i__1 = *lwork + 1 - iwrk; |
| 25592 | dorgqr_cxx . . $ dorgqr_(424524679a238630).(&irows, &irows, &irows, &vsl[ilo + ilo * vsl_dim1], ldvsl, & |
| 25593 | work[itau], &work[iwrk], &i__1, &ierr); |
| 25594 | } |
| 25595 | |
| 25596 | /* Initialize VSR */ |
| 25597 | |
| 25598 | if (ilvsr) { |
| 25599 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("Full", n, n, &c_b42, &c_b43, &vsr[vsr_offset], ldvsr); |
| 25600 | } |
| 25601 | |
| 25602 | /* Reduce to generalized Hessenberg form */ |
| 25603 | /* (Workspace: none needed) */ |
| 25604 | |
| 25605 | dgghrd_cxx . . $ dgghrd_(a37938716ecaec33).(jobvsl, jobvsr, n, &ilo, &ihi, &a[a_offset], lda, &b[b_offset], |
| 25606 | ldb, &vsl[vsl_offset], ldvsl, &vsr[vsr_offset], ldvsr, &ierr); |
| 25607 | |
| 25608 | *sdim = 0; |
| 25609 | |
| 25610 | /* Perform QZ algorithm, computing Schur vectors if desired */ |
| 25611 | /* (Workspace: need N) */ |
| 25612 | |
| 25613 | iwrk = itau; |
| 25614 | i__1 = *lwork + 1 - iwrk; |
| 25615 | dhgeqz_cxx . . $ dhgeqz_(1c7cf0ed1736d01d).("S", jobvsl, jobvsr, n, &ilo, &ihi, &a[a_offset], lda, &b[ |
| 25616 | b_offset], ldb, &alphar[1], &alphai[1], &beta[1], &vsl[vsl_offset] |
| 25617 | , ldvsl, &vsr[vsr_offset], ldvsr, &work[iwrk], &i__1, &ierr); |
| 25618 | if (ierr != 0) { |
| 25619 | if (ierr > 0 && ierr <= *n) { |
| 25620 | *info = ierr; |
| 25621 | } else if (ierr > *n && ierr <= *n << 1) { |
| 25622 | *info = ierr - *n; |
| 25623 | } else { |
| 25624 | *info = *n + 1; |
| 25625 | } |
| 25626 | goto L60; |
| 25627 | } |
| 25628 | |
| 25629 | /* Sort eigenvalues ALPHA/BETA and compute the reciprocal of */ |
| 25630 | /* condition number(s) */ |
| 25631 | /* (Workspace: If IJOB >= 1, need MAX( 8*(N+1), 2*SDIM*(N-SDIM) ) */ |
| 25632 | /* otherwise, need 8*(N+1) ) */ |
| 25633 | |
| 25634 | if (wantst) { |
| 25635 | |
| 25636 | /* Undo scaling on eigenvalues before SELCTGing */ |
| 25637 | |
| 25638 | if (ilascl) { |
| 25639 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &anrmto, &anrm, n, &c__1, &alphar[1], |
| 25640 | n, &ierr); |
| 25641 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &anrmto, &anrm, n, &c__1, &alphai[1], |
| 25642 | n, &ierr); |
| 25643 | } |
| 25644 | if (ilbscl) { |
| 25645 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &bnrmto, &bnrm, n, &c__1, &beta[1], n, |
| 25646 | &ierr); |
| 25647 | } |
| 25648 | |
| 25649 | /* Select eigenvalues */ |
| 25650 | |
| 25651 | i__1 = *n; |
| 25652 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 25653 | bwork[i__] = (*selctg)(&alphar[i__], &alphai[i__], &beta[i__]); |
| 25654 | /* L10: */ |
| 25655 | } |
| 25656 | |
| 25657 | /* Reorder eigenvalues, transform Generalized Schur vectors, and */ |
| 25658 | /* compute reciprocal condition numbers */ |
| 25659 | |
| 25660 | i__1 = *lwork - iwrk + 1; |
| 25661 | dtgsen_cxx . . $ dtgsen_(f355aa40bfbce1b9).(&ijob, &ilvsl, &ilvsr, &bwork[1], n, &a[a_offset], lda, &b[ |
| 25662 | b_offset], ldb, &alphar[1], &alphai[1], &beta[1], &vsl[ |
| 25663 | vsl_offset], ldvsl, &vsr[vsr_offset], ldvsr, sdim, &pl, &pr, |
| 25664 | dif, &work[iwrk], &i__1, &iwork[1], liwork, &ierr); |
| 25665 | |
| 25666 | if (ijob >= 1) { |
| 25667 | /* Computing MAX */ |
| 25668 | i__1 = maxwrk, i__2 = (*sdim << 1) * (*n - *sdim); |
| 25669 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 25670 | } |
| 25671 | if (ierr == -22) { |
| 25672 | |
| 25673 | /* not enough real workspace */ |
| 25674 | |
| 25675 | *info = -22; |
| 25676 | } else { |
| 25677 | if (ijob == 1 || ijob == 4) { |
| 25678 | rconde[1] = pl; |
| 25679 | rconde[2] = pr; |
| 25680 | } |
| 25681 | if (ijob == 2 || ijob == 4) { |
| 25682 | rcondv[1] = dif[0]; |
| 25683 | rcondv[2] = dif[1]; |
| 25684 | } |
| 25685 | if (ierr == 1) { |
| 25686 | *info = *n + 3; |
| 25687 | } |
| 25688 | } |
| 25689 | |
| 25690 | } |
| 25691 | |
| 25692 | /* Apply permutation to VSL and VSR */ |
| 25693 | /* (Workspace: none needed) */ |
| 25694 | |
| 25695 | if (ilvsl) { |
| 25696 | dggbak_cxx . . $ dggbak_(3fb2e360e620705c).("P", "L", n, &ilo, &ihi, &work[ileft], &work[iright], n, &vsl[ |
| 25697 | vsl_offset], ldvsl, &ierr); |
| 25698 | } |
| 25699 | |
| 25700 | if (ilvsr) { |
| 25701 | dggbak_cxx . . $ dggbak_(3fb2e360e620705c).("P", "R", n, &ilo, &ihi, &work[ileft], &work[iright], n, &vsr[ |
| 25702 | vsr_offset], ldvsr, &ierr); |
| 25703 | } |
| 25704 | |
| 25705 | /* Check if unscaling would cause over/underflow, if so, rescale */ |
| 25706 | /* (ALPHAR(I),ALPHAI(I),BETA(I)) so BETA(I) is on the order of */ |
| 25707 | /* B(I,I) and ALPHAR(I) and ALPHAI(I) are on the order of A(I,I) */ |
| 25708 | |
| 25709 | if (ilascl) { |
| 25710 | i__1 = *n; |
| 25711 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 25712 | if (alphai[i__] != 0.) { |
| 25713 | if (alphar[i__] / safmax > anrmto / anrm || safmin / alphar[ |
| 25714 | i__] > anrm / anrmto) { |
| 25715 | work[1] = (d__1 = a[i__ + i__ * a_dim1] / alphar[i__], |
| 25716 | abscxx . . $ abs(447c67c6676f75c3).(d__1)); |
| 25717 | beta[i__] *= work[1]; |
| 25718 | alphar[i__] *= work[1]; |
| 25719 | alphai[i__] *= work[1]; |
| 25720 | } else if (alphai[i__] / safmax > anrmto / anrm || safmin / |
| 25721 | alphai[i__] > anrm / anrmto) { |
| 25722 | work[1] = (d__1 = a[i__ + (i__ + 1) * a_dim1] / alphai[ |
| 25723 | i__], abscxx . . $ abs(447c67c6676f75c3).(d__1)); |
| 25724 | beta[i__] *= work[1]; |
| 25725 | alphar[i__] *= work[1]; |
| 25726 | alphai[i__] *= work[1]; |
| 25727 | } |
| 25728 | } |
| 25729 | /* L20: */ |
| 25730 | } |
| 25731 | } |
| 25732 | |
| 25733 | if (ilbscl) { |
| 25734 | i__1 = *n; |
| 25735 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 25736 | if (alphai[i__] != 0.) { |
| 25737 | if (beta[i__] / safmax > bnrmto / bnrm || safmin / beta[i__] |
| 25738 | > bnrm / bnrmto) { |
| 25739 | work[1] = (d__1 = b[i__ + i__ * b_dim1] / beta[i__], abscxx . . $ abs(447c67c6676f75c3).( |
| 25740 | d__1)); |
| 25741 | beta[i__] *= work[1]; |
| 25742 | alphar[i__] *= work[1]; |
| 25743 | alphai[i__] *= work[1]; |
| 25744 | } |
| 25745 | } |
| 25746 | /* L30: */ |
| 25747 | } |
| 25748 | } |
| 25749 | |
| 25750 | /* Undo scaling */ |
| 25751 | |
| 25752 | if (ilascl) { |
| 25753 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("H", &c__0, &c__0, &anrmto, &anrm, n, n, &a[a_offset], lda, & |
| 25754 | ierr); |
| 25755 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &anrmto, &anrm, n, &c__1, &alphar[1], n, & |
| 25756 | ierr); |
| 25757 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &anrmto, &anrm, n, &c__1, &alphai[1], n, & |
| 25758 | ierr); |
| 25759 | } |
| 25760 | |
| 25761 | if (ilbscl) { |
| 25762 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("U", &c__0, &c__0, &bnrmto, &bnrm, n, n, &b[b_offset], ldb, & |
| 25763 | ierr); |
| 25764 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &bnrmto, &bnrm, n, &c__1, &beta[1], n, & |
| 25765 | ierr); |
| 25766 | } |
| 25767 | |
| 25768 | if (wantst) { |
| 25769 | |
| 25770 | /* Check if reordering is correct */ |
| 25771 | |
| 25772 | lastsl = true; |
| 25773 | lst2sl = true; |
| 25774 | *sdim = 0; |
| 25775 | ip = 0; |
| 25776 | i__1 = *n; |
| 25777 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 25778 | cursl = (*selctg)(&alphar[i__], &alphai[i__], &beta[i__]); |
| 25779 | if (alphai[i__] == 0.) { |
| 25780 | if (cursl) { |
| 25781 | ++(*sdim); |
| 25782 | } |
| 25783 | ip = 0; |
| 25784 | if (cursl && ! lastsl) { |
| 25785 | *info = *n + 2; |
| 25786 | } |
| 25787 | } else { |
| 25788 | if (ip == 1) { |
| 25789 | |
| 25790 | /* Last eigenvalue of conjugate pair */ |
| 25791 | |
| 25792 | cursl = cursl || lastsl; |
| 25793 | lastsl = cursl; |
| 25794 | if (cursl) { |
| 25795 | *sdim += 2; |
| 25796 | } |
| 25797 | ip = -1; |
| 25798 | if (cursl && ! lst2sl) { |
| 25799 | *info = *n + 2; |
| 25800 | } |
| 25801 | } else { |
| 25802 | |
| 25803 | /* First eigenvalue of conjugate pair */ |
| 25804 | |
| 25805 | ip = 1; |
| 25806 | } |
| 25807 | } |
| 25808 | lst2sl = lastsl; |
| 25809 | lastsl = cursl; |
| 25810 | /* L50: */ |
| 25811 | } |
| 25812 | |
| 25813 | } |
| 25814 | |
| 25815 | L60: |
| 25816 | |
| 25817 | work[1] = (double) maxwrk; |
| 25818 | iwork[1] = liwmin; |
| 25819 | |
| 25820 | return 0; |
| 25821 | |
| 25822 | /* End of DGGESX */ |
| 25823 | |
| 25824 | } /* dggesx_ */ |
| 25825 | |
| 25826 | /* Subroutine */ int dggev_cxx . . $ dggev_(6679849dbeb3d4b5).(const char *jobvl, const char *jobvr, integercxx . . $ integer# *n, double * |
| 25827 | a, integercxx . . $ integer# *lda, double *b, integercxx . . $ integer# *ldb, double *alphar, |
| 25828 | double *alphai, double *beta, double *vl, integercxx . . $ integer# *ldvl, |
| 25829 | double *vr, integercxx . . $ integer# *ldvr, double *work, integercxx . . $ integer# *lwork, |
| 25830 | integercxx . . $ integer# *info) |
| 25831 | { |
| 25832 | /* Table of constant values */ |
| 25833 | static integercxx . . $ integer# c__1 = 1; |
| 25834 | static integercxx . . $ integer# c__0 = 0; |
| 25835 | static integercxx . . $ integer# c_n1 = -1; |
| 25836 | static double c_b36 = 0.; |
| 25837 | static double c_b37 = 1.; |
| 25838 | |
| 25839 | /* System generated locals */ |
| 25840 | integercxx . . $ integer# a_dim1, a_offset, b_dim1, b_offset, vl_dim1, vl_offset, vr_dim1, |
| 25841 | vr_offset, i__1, i__2; |
| 25842 | double d__1, d__2, d__3, d__4; |
| 25843 | |
| 25844 | /* Local variables */ |
| 25845 | integercxx . . $ integer# jc, in, jr, ihi, ilo; |
| 25846 | double eps; |
| 25847 | bool ilv; |
| 25848 | double anrm, bnrm; |
| 25849 | integercxx . . $ integer# ierr, itau; |
| 25850 | double temp; |
| 25851 | bool ilvl, ilvr; |
| 25852 | integercxx . . $ integer# iwrk; |
| 25853 | integercxx . . $ integer# ileft, icols, irows; |
| 25854 | bool ilascl, ilbscl; |
| 25855 | bool ldumma[1]; |
| 25856 | char chtemp[1]; |
| 25857 | double bignum; |
| 25858 | integercxx . . $ integer# ijobvl, iright, ijobvr; |
| 25859 | double anrmto, bnrmto; |
| 25860 | integercxx . . $ integer# minwrk, maxwrk; |
| 25861 | double smlnum; |
| 25862 | bool lquery; |
| 25863 | |
| 25864 | |
| 25865 | /* -- LAPACK driver routine (version 3.1) -- */ |
| 25866 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 25867 | /* November 2006 */ |
| 25868 | |
| 25869 | /* .. Scalar Arguments .. */ |
| 25870 | /* .. */ |
| 25871 | /* .. Array Arguments .. */ |
| 25872 | /* .. */ |
| 25873 | |
| 25874 | /* Purpose */ |
| 25875 | /* ======= */ |
| 25876 | |
| 25877 | /* DGGEV computes for a pair of N-by-N real nonsymmetric matrices (A,B) */ |
| 25878 | /* the generalized eigenvalues, and optionally, the left and/or right */ |
| 25879 | /* generalized eigenvectors. */ |
| 25880 | |
| 25881 | /* A generalized eigenvalue for a pair of matrices (A,B) is a scalar */ |
| 25882 | /* lambda or a ratio alpha/beta = lambda, such that A - lambda*B is */ |
| 25883 | /* singular. It is usually represented as the pair (alpha,beta), as */ |
| 25884 | /* there is a reasonable interpretation for beta=0, and even for both */ |
| 25885 | /* being zero. */ |
| 25886 | |
| 25887 | /* The right eigenvector v(j) corresponding to the eigenvalue lambda(j) */ |
| 25888 | /* of (A,B) satisfies */ |
| 25889 | |
| 25890 | /* A * v(j) = lambda(j) * B * v(j). */ |
| 25891 | |
| 25892 | /* The left eigenvector u(j) corresponding to the eigenvalue lambda(j) */ |
| 25893 | /* of (A,B) satisfies */ |
| 25894 | |
| 25895 | /* u(j)**H * A = lambda(j) * u(j)**H * B . */ |
| 25896 | |
| 25897 | /* where u(j)**H is the conjugate-transpose of u(j). */ |
| 25898 | |
| 25899 | |
| 25900 | /* Arguments */ |
| 25901 | /* ========= */ |
| 25902 | |
| 25903 | /* JOBVL (input) CHARACTER*1 */ |
| 25904 | /* = 'N': do not compute the left generalized eigenvectors; */ |
| 25905 | /* = 'V': compute the left generalized eigenvectors. */ |
| 25906 | |
| 25907 | /* JOBVR (input) CHARACTER*1 */ |
| 25908 | /* = 'N': do not compute the right generalized eigenvectors; */ |
| 25909 | /* = 'V': compute the right generalized eigenvectors. */ |
| 25910 | |
| 25911 | /* N (input) INTEGER */ |
| 25912 | /* The order of the matrices A, B, VL, and VR. N >= 0. */ |
| 25913 | |
| 25914 | /* A (input/output) DOUBLE PRECISION array, dimension (LDA, N) */ |
| 25915 | /* On entry, the matrix A in the pair (A,B). */ |
| 25916 | /* On exit, A has been overwritten. */ |
| 25917 | |
| 25918 | /* LDA (input) INTEGER */ |
| 25919 | /* The leading dimension of A. LDA >= max(1,N). */ |
| 25920 | |
| 25921 | /* B (input/output) DOUBLE PRECISION array, dimension (LDB, N) */ |
| 25922 | /* On entry, the matrix B in the pair (A,B). */ |
| 25923 | /* On exit, B has been overwritten. */ |
| 25924 | |
| 25925 | /* LDB (input) INTEGER */ |
| 25926 | /* The leading dimension of B. LDB >= max(1,N). */ |
| 25927 | |
| 25928 | /* ALPHAR (output) DOUBLE PRECISION array, dimension (N) */ |
| 25929 | /* ALPHAI (output) DOUBLE PRECISION array, dimension (N) */ |
| 25930 | /* BETA (output) DOUBLE PRECISION array, dimension (N) */ |
| 25931 | /* On exit, (ALPHAR(j) + ALPHAI(j)*i)/BETA(j), j=1,...,N, will */ |
| 25932 | /* be the generalized eigenvalues. If ALPHAI(j) is zero, then */ |
| 25933 | /* the j-th eigenvalue is real; if positive, then the j-th and */ |
| 25934 | /* (j+1)-st eigenvalues are a complex conjugate pair, with */ |
| 25935 | /* ALPHAI(j+1) negative. */ |
| 25936 | |
| 25937 | /* Note: the quotients ALPHAR(j)/BETA(j) and ALPHAI(j)/BETA(j) */ |
| 25938 | /* may easily over- or underflow, and BETA(j) may even be zero. */ |
| 25939 | /* Thus, the user should avoid naively computing the ratio */ |
| 25940 | /* alpha/beta. However, ALPHAR and ALPHAI will be always less */ |
| 25941 | /* than and usually comparable with norm(A) in magnitude, and */ |
| 25942 | /* BETA always less than and usually comparable with norm(B). */ |
| 25943 | |
| 25944 | /* VL (output) DOUBLE PRECISION array, dimension (LDVL,N) */ |
| 25945 | /* If JOBVL = 'V', the left eigenvectors u(j) are stored one */ |
| 25946 | /* after another in the columns of VL, in the same order as */ |
| 25947 | /* their eigenvalues. If the j-th eigenvalue is real, then */ |
| 25948 | /* u(j) = VL(:,j), the j-th column of VL. If the j-th and */ |
| 25949 | /* (j+1)-th eigenvalues form a complex conjugate pair, then */ |
| 25950 | /* u(j) = VL(:,j)+i*VL(:,j+1) and u(j+1) = VL(:,j)-i*VL(:,j+1). */ |
| 25951 | /* Each eigenvector is scaled so the largest component has */ |
| 25952 | /* abs(real part)+abs(imag. part)=1. */ |
| 25953 | /* Not referenced if JOBVL = 'N'. */ |
| 25954 | |
| 25955 | /* LDVL (input) INTEGER */ |
| 25956 | /* The leading dimension of the matrix VL. LDVL >= 1, and */ |
| 25957 | /* if JOBVL = 'V', LDVL >= N. */ |
| 25958 | |
| 25959 | /* VR (output) DOUBLE PRECISION array, dimension (LDVR,N) */ |
| 25960 | /* If JOBVR = 'V', the right eigenvectors v(j) are stored one */ |
| 25961 | /* after another in the columns of VR, in the same order as */ |
| 25962 | /* their eigenvalues. If the j-th eigenvalue is real, then */ |
| 25963 | /* v(j) = VR(:,j), the j-th column of VR. If the j-th and */ |
| 25964 | /* (j+1)-th eigenvalues form a complex conjugate pair, then */ |
| 25965 | /* v(j) = VR(:,j)+i*VR(:,j+1) and v(j+1) = VR(:,j)-i*VR(:,j+1). */ |
| 25966 | /* Each eigenvector is scaled so the largest component has */ |
| 25967 | /* abs(real part)+abs(imag. part)=1. */ |
| 25968 | /* Not referenced if JOBVR = 'N'. */ |
| 25969 | |
| 25970 | /* LDVR (input) INTEGER */ |
| 25971 | /* The leading dimension of the matrix VR. LDVR >= 1, and */ |
| 25972 | /* if JOBVR = 'V', LDVR >= N. */ |
| 25973 | |
| 25974 | /* WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) */ |
| 25975 | /* On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ |
| 25976 | |
| 25977 | /* LWORK (input) INTEGER */ |
| 25978 | /* The dimension of the array WORK. LWORK >= max(1,8*N). */ |
| 25979 | /* For good performance, LWORK must generally be larger. */ |
| 25980 | |
| 25981 | /* If LWORK = -1, then a workspace query is assumed; the routine */ |
| 25982 | /* only calculates the optimal size of the WORK array, returns */ |
| 25983 | /* this value as the first entry of the WORK array, and no error */ |
| 25984 | /* message related to LWORK is issued by XERBLA. */ |
| 25985 | |
| 25986 | /* INFO (output) INTEGER */ |
| 25987 | /* = 0: successful exit */ |
| 25988 | /* < 0: if INFO = -i, the i-th argument had an illegal value. */ |
| 25989 | /* = 1,...,N: */ |
| 25990 | /* The QZ iteration failed. No eigenvectors have been */ |
| 25991 | /* calculated, but ALPHAR(j), ALPHAI(j), and BETA(j) */ |
| 25992 | /* should be correct for j=INFO+1,...,N. */ |
| 25993 | /* > N: =N+1: other than QZ iteration failed in DHGEQZ. */ |
| 25994 | /* =N+2: error return from DTGEVC. */ |
| 25995 | |
| 25996 | /* ===================================================================== */ |
| 25997 | |
| 25998 | /* .. Parameters .. */ |
| 25999 | /* .. */ |
| 26000 | /* .. Local Scalars .. */ |
| 26001 | /* .. */ |
| 26002 | /* .. Local Arrays .. */ |
| 26003 | /* .. */ |
| 26004 | /* .. External Subroutines .. */ |
| 26005 | /* .. */ |
| 26006 | /* .. External Functions .. */ |
| 26007 | /* .. */ |
| 26008 | /* .. Intrinsic Functions .. */ |
| 26009 | /* .. */ |
| 26010 | /* .. Executable Statements .. */ |
| 26011 | |
| 26012 | /* Decode the input arguments */ |
| 26013 | |
| 26014 | /* Parameter adjustments */ |
| 26015 | a_dim1 = *lda; |
| 26016 | a_offset = 1 + a_dim1; |
| 26017 | a -= a_offset; |
| 26018 | b_dim1 = *ldb; |
| 26019 | b_offset = 1 + b_dim1; |
| 26020 | b -= b_offset; |
| 26021 | --alphar; |
| 26022 | --alphai; |
| 26023 | --beta; |
| 26024 | vl_dim1 = *ldvl; |
| 26025 | vl_offset = 1 + vl_dim1; |
| 26026 | vl -= vl_offset; |
| 26027 | vr_dim1 = *ldvr; |
| 26028 | vr_offset = 1 + vr_dim1; |
| 26029 | vr -= vr_offset; |
| 26030 | --work; |
| 26031 | |
| 26032 | /* Function Body */ |
| 26033 | if (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobvl, "N")) { |
| 26034 | ijobvl = 1; |
| 26035 | ilvl = false; |
| 26036 | } else if (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobvl, "V")) { |
| 26037 | ijobvl = 2; |
| 26038 | ilvl = true; |
| 26039 | } else { |
| 26040 | ijobvl = -1; |
| 26041 | ilvl = false; |
| 26042 | } |
| 26043 | |
| 26044 | if (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobvr, "N")) { |
| 26045 | ijobvr = 1; |
| 26046 | ilvr = false; |
| 26047 | } else if (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobvr, "V")) { |
| 26048 | ijobvr = 2; |
| 26049 | ilvr = true; |
| 26050 | } else { |
| 26051 | ijobvr = -1; |
| 26052 | ilvr = false; |
| 26053 | } |
| 26054 | ilv = ilvl || ilvr; |
| 26055 | |
| 26056 | /* Test the input arguments */ |
| 26057 | |
| 26058 | *info = 0; |
| 26059 | lquery = *lwork == -1; |
| 26060 | if (ijobvl <= 0) { |
| 26061 | *info = -1; |
| 26062 | } else if (ijobvr <= 0) { |
| 26063 | *info = -2; |
| 26064 | } else if (*n < 0) { |
| 26065 | *info = -3; |
| 26066 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 26067 | *info = -5; |
| 26068 | } else if (*ldb < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 26069 | *info = -7; |
| 26070 | } else if (*ldvl < 1 || ilvl && *ldvl < *n) { |
| 26071 | *info = -12; |
| 26072 | } else if (*ldvr < 1 || ilvr && *ldvr < *n) { |
| 26073 | *info = -14; |
| 26074 | } |
| 26075 | |
| 26076 | /* Compute workspace */ |
| 26077 | /* (Note: Comments in the code beginning "Workspace:" describe the */ |
| 26078 | /* minimal amount of workspace needed at that point in the code, */ |
| 26079 | /* as well as the preferred amount for good performance. */ |
| 26080 | /* NB refers to the optimal block size for the immediately */ |
| 26081 | /* following subroutine, as returned by ILAENV. The workspace is */ |
| 26082 | /* computed assuming ILO = 1 and IHI = N, the worst case.) */ |
| 26083 | |
| 26084 | if (*info == 0) { |
| 26085 | /* Computing MAX */ |
| 26086 | i__1 = 1, i__2 = *n << 3; |
| 26087 | minwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 26088 | /* Computing MAX */ |
| 26089 | i__1 = 1, i__2 = *n * (ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEQRF", " ", n, &c__1, n, & |
| 26090 | c__0) + 7); |
| 26091 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 26092 | /* Computing MAX */ |
| 26093 | i__1 = maxwrk, i__2 = *n * (ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMQR", " ", n, &c__1, n, |
| 26094 | &c__0) + 7); |
| 26095 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 26096 | if (ilvl) { |
| 26097 | /* Computing MAX */ |
| 26098 | i__1 = maxwrk, i__2 = *n * (ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORGQR", " ", n, & |
| 26099 | c__1, n, &c_n1) + 7); |
| 26100 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 26101 | } |
| 26102 | work[1] = (double) maxwrk; |
| 26103 | |
| 26104 | if (*lwork < minwrk && ! lquery) { |
| 26105 | *info = -16; |
| 26106 | } |
| 26107 | } |
| 26108 | |
| 26109 | if (*info != 0) { |
| 26110 | i__1 = -(*info); |
| 26111 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGGEV ", &i__1); |
| 26112 | return 0; |
| 26113 | } else if (lquery) { |
| 26114 | return 0; |
| 26115 | } |
| 26116 | |
| 26117 | /* Quick return if possible */ |
| 26118 | |
| 26119 | if (*n == 0) { |
| 26120 | return 0; |
| 26121 | } |
| 26122 | |
| 26123 | /* Get machine constants */ |
| 26124 | |
| 26125 | eps = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("P"); |
| 26126 | smlnum = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("S"); |
| 26127 | bignum = 1. / smlnum; |
| 26128 | dlabad_cxx . . $ dlabad_(4730c933dae9b326).(&smlnum, &bignum); |
| 26129 | smlnum = sqrtcxx . . $ sqrt(fee4f1d22bc8e617).(smlnum) / eps; |
| 26130 | bignum = 1. / smlnum; |
| 26131 | |
| 26132 | /* Scale A if max element outside range [SMLNUM,BIGNUM] */ |
| 26133 | |
| 26134 | anrm = dlange_cxx . . $ dlange_(98d44e6417336f20).("M", n, n, &a[a_offset], lda, &work[1]); |
| 26135 | ilascl = false; |
| 26136 | if (anrm > 0. && anrm < smlnum) { |
| 26137 | anrmto = smlnum; |
| 26138 | ilascl = true; |
| 26139 | } else if (anrm > bignum) { |
| 26140 | anrmto = bignum; |
| 26141 | ilascl = true; |
| 26142 | } |
| 26143 | if (ilascl) { |
| 26144 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &anrm, &anrmto, n, n, &a[a_offset], lda, & |
| 26145 | ierr); |
| 26146 | } |
| 26147 | |
| 26148 | /* Scale B if max element outside range [SMLNUM,BIGNUM] */ |
| 26149 | |
| 26150 | bnrm = dlange_cxx . . $ dlange_(98d44e6417336f20).("M", n, n, &b[b_offset], ldb, &work[1]); |
| 26151 | ilbscl = false; |
| 26152 | if (bnrm > 0. && bnrm < smlnum) { |
| 26153 | bnrmto = smlnum; |
| 26154 | ilbscl = true; |
| 26155 | } else if (bnrm > bignum) { |
| 26156 | bnrmto = bignum; |
| 26157 | ilbscl = true; |
| 26158 | } |
| 26159 | if (ilbscl) { |
| 26160 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &bnrm, &bnrmto, n, n, &b[b_offset], ldb, & |
| 26161 | ierr); |
| 26162 | } |
| 26163 | |
| 26164 | /* Permute the matrices A, B to isolate eigenvalues if possible */ |
| 26165 | /* (Workspace: need 6*N) */ |
| 26166 | |
| 26167 | ileft = 1; |
| 26168 | iright = *n + 1; |
| 26169 | iwrk = iright + *n; |
| 26170 | dggbal_cxx . . $ dggbal_(69bfde64ff0f2aeb).("P", n, &a[a_offset], lda, &b[b_offset], ldb, &ilo, &ihi, &work[ |
| 26171 | ileft], &work[iright], &work[iwrk], &ierr); |
| 26172 | |
| 26173 | /* Reduce B to triangular form (QR decomposition of B) */ |
| 26174 | /* (Workspace: need N, prefer N*NB) */ |
| 26175 | |
| 26176 | irows = ihi + 1 - ilo; |
| 26177 | if (ilv) { |
| 26178 | icols = *n + 1 - ilo; |
| 26179 | } else { |
| 26180 | icols = irows; |
| 26181 | } |
| 26182 | itau = iwrk; |
| 26183 | iwrk = itau + irows; |
| 26184 | i__1 = *lwork + 1 - iwrk; |
| 26185 | dgeqrf_cxx . . $ dgeqrf_(b2aaa174babf002e).(&irows, &icols, &b[ilo + ilo * b_dim1], ldb, &work[itau], &work[ |
| 26186 | iwrk], &i__1, &ierr); |
| 26187 | |
| 26188 | /* Apply the orthogonal transformation to matrix A */ |
| 26189 | /* (Workspace: need N, prefer N*NB) */ |
| 26190 | |
| 26191 | i__1 = *lwork + 1 - iwrk; |
| 26192 | dormqr_cxx . . $ dormqr_(c6b7238dd97e9cf9).("L", "T", &irows, &icols, &irows, &b[ilo + ilo * b_dim1], ldb, & |
| 26193 | work[itau], &a[ilo + ilo * a_dim1], lda, &work[iwrk], &i__1, & |
| 26194 | ierr); |
| 26195 | |
| 26196 | /* Initialize VL */ |
| 26197 | /* (Workspace: need N, prefer N*NB) */ |
| 26198 | |
| 26199 | if (ilvl) { |
| 26200 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("Full", n, n, &c_b36, &c_b37, &vl[vl_offset], ldvl) |
| 26201 | ; |
| 26202 | if (irows > 1) { |
| 26203 | i__1 = irows - 1; |
| 26204 | i__2 = irows - 1; |
| 26205 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("L", &i__1, &i__2, &b[ilo + 1 + ilo * b_dim1], ldb, &vl[ |
| 26206 | ilo + 1 + ilo * vl_dim1], ldvl); |
| 26207 | } |
| 26208 | i__1 = *lwork + 1 - iwrk; |
| 26209 | dorgqr_cxx . . $ dorgqr_(424524679a238630).(&irows, &irows, &irows, &vl[ilo + ilo * vl_dim1], ldvl, &work[ |
| 26210 | itau], &work[iwrk], &i__1, &ierr); |
| 26211 | } |
| 26212 | |
| 26213 | /* Initialize VR */ |
| 26214 | |
| 26215 | if (ilvr) { |
| 26216 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("Full", n, n, &c_b36, &c_b37, &vr[vr_offset], ldvr) |
| 26217 | ; |
| 26218 | } |
| 26219 | |
| 26220 | /* Reduce to generalized Hessenberg form */ |
| 26221 | /* (Workspace: none needed) */ |
| 26222 | |
| 26223 | if (ilv) { |
| 26224 | |
| 26225 | /* Eigenvectors requested -- work on whole matrix. */ |
| 26226 | |
| 26227 | dgghrd_cxx . . $ dgghrd_(a37938716ecaec33).(jobvl, jobvr, n, &ilo, &ihi, &a[a_offset], lda, &b[b_offset], |
| 26228 | ldb, &vl[vl_offset], ldvl, &vr[vr_offset], ldvr, &ierr); |
| 26229 | } else { |
| 26230 | dgghrd_cxx . . $ dgghrd_(a37938716ecaec33).("N", "N", &irows, &c__1, &irows, &a[ilo + ilo * a_dim1], lda, |
| 26231 | &b[ilo + ilo * b_dim1], ldb, &vl[vl_offset], ldvl, &vr[ |
| 26232 | vr_offset], ldvr, &ierr); |
| 26233 | } |
| 26234 | |
| 26235 | /* Perform QZ algorithm (Compute eigenvalues, and optionally, the */ |
| 26236 | /* Schur forms and Schur vectors) */ |
| 26237 | /* (Workspace: need N) */ |
| 26238 | |
| 26239 | iwrk = itau; |
| 26240 | if (ilv) { |
| 26241 | *(unsigned char *)chtemp = 'S'; |
| 26242 | } else { |
| 26243 | *(unsigned char *)chtemp = 'E'; |
| 26244 | } |
| 26245 | i__1 = *lwork + 1 - iwrk; |
| 26246 | dhgeqz_cxx . . $ dhgeqz_(1c7cf0ed1736d01d).(chtemp, jobvl, jobvr, n, &ilo, &ihi, &a[a_offset], lda, &b[ |
| 26247 | b_offset], ldb, &alphar[1], &alphai[1], &beta[1], &vl[vl_offset], |
| 26248 | ldvl, &vr[vr_offset], ldvr, &work[iwrk], &i__1, &ierr); |
| 26249 | if (ierr != 0) { |
| 26250 | if (ierr > 0 && ierr <= *n) { |
| 26251 | *info = ierr; |
| 26252 | } else if (ierr > *n && ierr <= *n << 1) { |
| 26253 | *info = ierr - *n; |
| 26254 | } else { |
| 26255 | *info = *n + 1; |
| 26256 | } |
| 26257 | goto L110; |
| 26258 | } |
| 26259 | |
| 26260 | /* Compute Eigenvectors */ |
| 26261 | /* (Workspace: need 6*N) */ |
| 26262 | |
| 26263 | if (ilv) { |
| 26264 | if (ilvl) { |
| 26265 | if (ilvr) { |
| 26266 | *(unsigned char *)chtemp = 'B'; |
| 26267 | } else { |
| 26268 | *(unsigned char *)chtemp = 'L'; |
| 26269 | } |
| 26270 | } else { |
| 26271 | *(unsigned char *)chtemp = 'R'; |
| 26272 | } |
| 26273 | dtgevc_cxx . . $ dtgevc_(66a19661ce790798).(chtemp, "B", ldumma, n, &a[a_offset], lda, &b[b_offset], ldb, |
| 26274 | &vl[vl_offset], ldvl, &vr[vr_offset], ldvr, n, &in, &work[ |
| 26275 | iwrk], &ierr); |
| 26276 | if (ierr != 0) { |
| 26277 | *info = *n + 2; |
| 26278 | goto L110; |
| 26279 | } |
| 26280 | |
| 26281 | /* Undo balancing on VL and VR and normalization */ |
| 26282 | /* (Workspace: none needed) */ |
| 26283 | |
| 26284 | if (ilvl) { |
| 26285 | dggbak_cxx . . $ dggbak_(3fb2e360e620705c).("P", "L", n, &ilo, &ihi, &work[ileft], &work[iright], n, & |
| 26286 | vl[vl_offset], ldvl, &ierr); |
| 26287 | i__1 = *n; |
| 26288 | for (jc = 1; jc <= i__1; ++jc) { |
| 26289 | if (alphai[jc] < 0.) { |
| 26290 | goto L50; |
| 26291 | } |
| 26292 | temp = 0.; |
| 26293 | if (alphai[jc] == 0.) { |
| 26294 | i__2 = *n; |
| 26295 | for (jr = 1; jr <= i__2; ++jr) { |
| 26296 | /* Computing MAX */ |
| 26297 | d__2 = temp, d__3 = (d__1 = vl[jr + jc * vl_dim1], |
| 26298 | abscxx . . $ abs(447c67c6676f75c3).(d__1)); |
| 26299 | temp = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__2,d__3); |
| 26300 | /* L10: */ |
| 26301 | } |
| 26302 | } else { |
| 26303 | i__2 = *n; |
| 26304 | for (jr = 1; jr <= i__2; ++jr) { |
| 26305 | /* Computing MAX */ |
| 26306 | d__3 = temp, d__4 = (d__1 = vl[jr + jc * vl_dim1], |
| 26307 | abscxx . . $ abs(447c67c6676f75c3).(d__1)) + (d__2 = vl[jr + (jc + 1) * |
| 26308 | vl_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__2)); |
| 26309 | temp = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__3,d__4); |
| 26310 | /* L20: */ |
| 26311 | } |
| 26312 | } |
| 26313 | if (temp < smlnum) { |
| 26314 | goto L50; |
| 26315 | } |
| 26316 | temp = 1. / temp; |
| 26317 | if (alphai[jc] == 0.) { |
| 26318 | i__2 = *n; |
| 26319 | for (jr = 1; jr <= i__2; ++jr) { |
| 26320 | vl[jr + jc * vl_dim1] *= temp; |
| 26321 | /* L30: */ |
| 26322 | } |
| 26323 | } else { |
| 26324 | i__2 = *n; |
| 26325 | for (jr = 1; jr <= i__2; ++jr) { |
| 26326 | vl[jr + jc * vl_dim1] *= temp; |
| 26327 | vl[jr + (jc + 1) * vl_dim1] *= temp; |
| 26328 | /* L40: */ |
| 26329 | } |
| 26330 | } |
| 26331 | L50: |
| 26332 | ; |
| 26333 | } |
| 26334 | } |
| 26335 | if (ilvr) { |
| 26336 | dggbak_cxx . . $ dggbak_(3fb2e360e620705c).("P", "R", n, &ilo, &ihi, &work[ileft], &work[iright], n, & |
| 26337 | vr[vr_offset], ldvr, &ierr); |
| 26338 | i__1 = *n; |
| 26339 | for (jc = 1; jc <= i__1; ++jc) { |
| 26340 | if (alphai[jc] < 0.) { |
| 26341 | goto L100; |
| 26342 | } |
| 26343 | temp = 0.; |
| 26344 | if (alphai[jc] == 0.) { |
| 26345 | i__2 = *n; |
| 26346 | for (jr = 1; jr <= i__2; ++jr) { |
| 26347 | /* Computing MAX */ |
| 26348 | d__2 = temp, d__3 = (d__1 = vr[jr + jc * vr_dim1], |
| 26349 | abscxx . . $ abs(447c67c6676f75c3).(d__1)); |
| 26350 | temp = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__2,d__3); |
| 26351 | /* L60: */ |
| 26352 | } |
| 26353 | } else { |
| 26354 | i__2 = *n; |
| 26355 | for (jr = 1; jr <= i__2; ++jr) { |
| 26356 | /* Computing MAX */ |
| 26357 | d__3 = temp, d__4 = (d__1 = vr[jr + jc * vr_dim1], |
| 26358 | abscxx . . $ abs(447c67c6676f75c3).(d__1)) + (d__2 = vr[jr + (jc + 1) * |
| 26359 | vr_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__2)); |
| 26360 | temp = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__3,d__4); |
| 26361 | /* L70: */ |
| 26362 | } |
| 26363 | } |
| 26364 | if (temp < smlnum) { |
| 26365 | goto L100; |
| 26366 | } |
| 26367 | temp = 1. / temp; |
| 26368 | if (alphai[jc] == 0.) { |
| 26369 | i__2 = *n; |
| 26370 | for (jr = 1; jr <= i__2; ++jr) { |
| 26371 | vr[jr + jc * vr_dim1] *= temp; |
| 26372 | /* L80: */ |
| 26373 | } |
| 26374 | } else { |
| 26375 | i__2 = *n; |
| 26376 | for (jr = 1; jr <= i__2; ++jr) { |
| 26377 | vr[jr + jc * vr_dim1] *= temp; |
| 26378 | vr[jr + (jc + 1) * vr_dim1] *= temp; |
| 26379 | /* L90: */ |
| 26380 | } |
| 26381 | } |
| 26382 | L100: |
| 26383 | ; |
| 26384 | } |
| 26385 | } |
| 26386 | |
| 26387 | /* End of eigenvector calculation */ |
| 26388 | |
| 26389 | } |
| 26390 | |
| 26391 | /* Undo scaling if necessary */ |
| 26392 | |
| 26393 | if (ilascl) { |
| 26394 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &anrmto, &anrm, n, &c__1, &alphar[1], n, & |
| 26395 | ierr); |
| 26396 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &anrmto, &anrm, n, &c__1, &alphai[1], n, & |
| 26397 | ierr); |
| 26398 | } |
| 26399 | |
| 26400 | if (ilbscl) { |
| 26401 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &bnrmto, &bnrm, n, &c__1, &beta[1], n, & |
| 26402 | ierr); |
| 26403 | } |
| 26404 | |
| 26405 | L110: |
| 26406 | |
| 26407 | work[1] = (double) maxwrk; |
| 26408 | |
| 26409 | return 0; |
| 26410 | |
| 26411 | /* End of DGGEV */ |
| 26412 | |
| 26413 | } /* dggev_ */ |
| 26414 | |
| 26415 | /* Subroutine */ int dggevx_cxx . . $ dggevx_(950ff0a8f759f2fe).(const char *balanc, const char *jobvl, const char *jobvr, const char * |
| 26416 | sense, integercxx . . $ integer# *n, double *a, integercxx . . $ integer# *lda, double *b, |
| 26417 | integercxx . . $ integer# *ldb, double *alphar, double *alphai, double * |
| 26418 | beta, double *vl, integercxx . . $ integer# *ldvl, double *vr, integercxx . . $ integer# *ldvr, |
| 26419 | integercxx . . $ integer# *ilo, integercxx . . $ integer# *ihi, double *lscale, double *rscale, |
| 26420 | double *abnrm, double *bbnrm, double *rconde, double * |
| 26421 | rcondv, double *work, integercxx . . $ integer# *lwork, integercxx . . $ integer# *iwork, bool * |
| 26422 | bwork, integercxx . . $ integer# *info) |
| 26423 | { |
| 26424 | /* Table of constant values */ |
| 26425 | static integercxx . . $ integer# c__1 = 1; |
| 26426 | static integercxx . . $ integer# c__0 = 0; |
| 26427 | static double c_b59 = 0.; |
| 26428 | static double c_b60 = 1.; |
| 26429 | |
| 26430 | /* System generated locals */ |
| 26431 | integercxx . . $ integer# a_dim1, a_offset, b_dim1, b_offset, vl_dim1, vl_offset, vr_dim1, |
| 26432 | vr_offset, i__1, i__2; |
| 26433 | double d__1, d__2, d__3, d__4; |
| 26434 | |
| 26435 | /* Builtin functions |
| 26436 | double sqrt(double); */ |
| 26437 | |
| 26438 | /* Local variables */ |
| 26439 | integercxx . . $ integer# i__, j, m, jc, in, mm, jr; |
| 26440 | double eps; |
| 26441 | bool ilv, pair; |
| 26442 | double anrm, bnrm; |
| 26443 | integercxx . . $ integer# ierr, itau; |
| 26444 | double temp; |
| 26445 | bool ilvl, ilvr; |
| 26446 | integercxx . . $ integer# iwrk, iwrk1; |
| 26447 | integercxx . . $ integer# icols; |
| 26448 | bool noscl; |
| 26449 | integercxx . . $ integer# irows; |
| 26450 | bool ilascl, ilbscl; |
| 26451 | bool ldumma[1]; |
| 26452 | char chtemp[1]; |
| 26453 | double bignum; |
| 26454 | integercxx . . $ integer# ijobvl; |
| 26455 | integercxx . . $ integer# ijobvr; |
| 26456 | bool wantsb; |
| 26457 | double anrmto; |
| 26458 | bool wantse; |
| 26459 | double bnrmto; |
| 26460 | integercxx . . $ integer# minwrk, maxwrk; |
| 26461 | bool wantsn; |
| 26462 | double smlnum; |
| 26463 | bool lquery, wantsv; |
| 26464 | |
| 26465 | |
| 26466 | /* -- LAPACK driver routine (version 3.1) -- */ |
| 26467 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 26468 | /* November 2006 */ |
| 26469 | |
| 26470 | /* .. Scalar Arguments .. */ |
| 26471 | /* .. */ |
| 26472 | /* .. Array Arguments .. */ |
| 26473 | /* .. */ |
| 26474 | |
| 26475 | /* Purpose */ |
| 26476 | /* ======= */ |
| 26477 | |
| 26478 | /* DGGEVX computes for a pair of N-by-N real nonsymmetric matrices (A,B) */ |
| 26479 | /* the generalized eigenvalues, and optionally, the left and/or right */ |
| 26480 | /* generalized eigenvectors. */ |
| 26481 | |
| 26482 | /* Optionally also, it computes a balancing transformation to improve */ |
| 26483 | /* the conditioning of the eigenvalues and eigenvectors (ILO, IHI, */ |
| 26484 | /* LSCALE, RSCALE, ABNRM, and BBNRM), reciprocal condition numbers for */ |
| 26485 | /* the eigenvalues (RCONDE), and reciprocal condition numbers for the */ |
| 26486 | /* right eigenvectors (RCONDV). */ |
| 26487 | |
| 26488 | /* A generalized eigenvalue for a pair of matrices (A,B) is a scalar */ |
| 26489 | /* lambda or a ratio alpha/beta = lambda, such that A - lambda*B is */ |
| 26490 | /* singular. It is usually represented as the pair (alpha,beta), as */ |
| 26491 | /* there is a reasonable interpretation for beta=0, and even for both */ |
| 26492 | /* being zero. */ |
| 26493 | |
| 26494 | /* The right eigenvector v(j) corresponding to the eigenvalue lambda(j) */ |
| 26495 | /* of (A,B) satisfies */ |
| 26496 | |
| 26497 | /* A * v(j) = lambda(j) * B * v(j) . */ |
| 26498 | |
| 26499 | /* The left eigenvector u(j) corresponding to the eigenvalue lambda(j) */ |
| 26500 | /* of (A,B) satisfies */ |
| 26501 | |
| 26502 | /* u(j)**H * A = lambda(j) * u(j)**H * B. */ |
| 26503 | |
| 26504 | /* where u(j)**H is the conjugate-transpose of u(j). */ |
| 26505 | |
| 26506 | |
| 26507 | /* Arguments */ |
| 26508 | /* ========= */ |
| 26509 | |
| 26510 | /* BALANC (input) CHARACTER*1 */ |
| 26511 | /* Specifies the balance option to be performed. */ |
| 26512 | /* = 'N': do not diagonally scale or permute; */ |
| 26513 | /* = 'P': permute only; */ |
| 26514 | /* = 'S': scale only; */ |
| 26515 | /* = 'B': both permute and scale. */ |
| 26516 | /* Computed reciprocal condition numbers will be for the */ |
| 26517 | /* matrices after permuting and/or balancing. Permuting does */ |
| 26518 | /* not change condition numbers (in exact arithmetic), but */ |
| 26519 | /* balancing does. */ |
| 26520 | |
| 26521 | /* JOBVL (input) CHARACTER*1 */ |
| 26522 | /* = 'N': do not compute the left generalized eigenvectors; */ |
| 26523 | /* = 'V': compute the left generalized eigenvectors. */ |
| 26524 | |
| 26525 | /* JOBVR (input) CHARACTER*1 */ |
| 26526 | /* = 'N': do not compute the right generalized eigenvectors; */ |
| 26527 | /* = 'V': compute the right generalized eigenvectors. */ |
| 26528 | |
| 26529 | /* SENSE (input) CHARACTER*1 */ |
| 26530 | /* Determines which reciprocal condition numbers are computed. */ |
| 26531 | /* = 'N': none are computed; */ |
| 26532 | /* = 'E': computed for eigenvalues only; */ |
| 26533 | /* = 'V': computed for eigenvectors only; */ |
| 26534 | /* = 'B': computed for eigenvalues and eigenvectors. */ |
| 26535 | |
| 26536 | /* N (input) INTEGER */ |
| 26537 | /* The order of the matrices A, B, VL, and VR. N >= 0. */ |
| 26538 | |
| 26539 | /* A (input/output) DOUBLE PRECISION array, dimension (LDA, N) */ |
| 26540 | /* On entry, the matrix A in the pair (A,B). */ |
| 26541 | /* On exit, A has been overwritten. If JOBVL='V' or JOBVR='V' */ |
| 26542 | /* or both, then A contains the first part of the real Schur */ |
| 26543 | /* form of the "balanced" versions of the input A and B. */ |
| 26544 | |
| 26545 | /* LDA (input) INTEGER */ |
| 26546 | /* The leading dimension of A. LDA >= max(1,N). */ |
| 26547 | |
| 26548 | /* B (input/output) DOUBLE PRECISION array, dimension (LDB, N) */ |
| 26549 | /* On entry, the matrix B in the pair (A,B). */ |
| 26550 | /* On exit, B has been overwritten. If JOBVL='V' or JOBVR='V' */ |
| 26551 | /* or both, then B contains the second part of the real Schur */ |
| 26552 | /* form of the "balanced" versions of the input A and B. */ |
| 26553 | |
| 26554 | /* LDB (input) INTEGER */ |
| 26555 | /* The leading dimension of B. LDB >= max(1,N). */ |
| 26556 | |
| 26557 | /* ALPHAR (output) DOUBLE PRECISION array, dimension (N) */ |
| 26558 | /* ALPHAI (output) DOUBLE PRECISION array, dimension (N) */ |
| 26559 | /* BETA (output) DOUBLE PRECISION array, dimension (N) */ |
| 26560 | /* On exit, (ALPHAR(j) + ALPHAI(j)*i)/BETA(j), j=1,...,N, will */ |
| 26561 | /* be the generalized eigenvalues. If ALPHAI(j) is zero, then */ |
| 26562 | /* the j-th eigenvalue is real; if positive, then the j-th and */ |
| 26563 | /* (j+1)-st eigenvalues are a complex conjugate pair, with */ |
| 26564 | /* ALPHAI(j+1) negative. */ |
| 26565 | |
| 26566 | /* Note: the quotients ALPHAR(j)/BETA(j) and ALPHAI(j)/BETA(j) */ |
| 26567 | /* may easily over- or underflow, and BETA(j) may even be zero. */ |
| 26568 | /* Thus, the user should avoid naively computing the ratio */ |
| 26569 | /* ALPHA/BETA. However, ALPHAR and ALPHAI will be always less */ |
| 26570 | /* than and usually comparable with norm(A) in magnitude, and */ |
| 26571 | /* BETA always less than and usually comparable with norm(B). */ |
| 26572 | |
| 26573 | /* VL (output) DOUBLE PRECISION array, dimension (LDVL,N) */ |
| 26574 | /* If JOBVL = 'V', the left eigenvectors u(j) are stored one */ |
| 26575 | /* after another in the columns of VL, in the same order as */ |
| 26576 | /* their eigenvalues. If the j-th eigenvalue is real, then */ |
| 26577 | /* u(j) = VL(:,j), the j-th column of VL. If the j-th and */ |
| 26578 | /* (j+1)-th eigenvalues form a complex conjugate pair, then */ |
| 26579 | /* u(j) = VL(:,j)+i*VL(:,j+1) and u(j+1) = VL(:,j)-i*VL(:,j+1). */ |
| 26580 | /* Each eigenvector will be scaled so the largest component have */ |
| 26581 | /* abs(real part) + abs(imag. part) = 1. */ |
| 26582 | /* Not referenced if JOBVL = 'N'. */ |
| 26583 | |
| 26584 | /* LDVL (input) INTEGER */ |
| 26585 | /* The leading dimension of the matrix VL. LDVL >= 1, and */ |
| 26586 | /* if JOBVL = 'V', LDVL >= N. */ |
| 26587 | |
| 26588 | /* VR (output) DOUBLE PRECISION array, dimension (LDVR,N) */ |
| 26589 | /* If JOBVR = 'V', the right eigenvectors v(j) are stored one */ |
| 26590 | /* after another in the columns of VR, in the same order as */ |
| 26591 | /* their eigenvalues. If the j-th eigenvalue is real, then */ |
| 26592 | /* v(j) = VR(:,j), the j-th column of VR. If the j-th and */ |
| 26593 | /* (j+1)-th eigenvalues form a complex conjugate pair, then */ |
| 26594 | /* v(j) = VR(:,j)+i*VR(:,j+1) and v(j+1) = VR(:,j)-i*VR(:,j+1). */ |
| 26595 | /* Each eigenvector will be scaled so the largest component have */ |
| 26596 | /* abs(real part) + abs(imag. part) = 1. */ |
| 26597 | /* Not referenced if JOBVR = 'N'. */ |
| 26598 | |
| 26599 | /* LDVR (input) INTEGER */ |
| 26600 | /* The leading dimension of the matrix VR. LDVR >= 1, and */ |
| 26601 | /* if JOBVR = 'V', LDVR >= N. */ |
| 26602 | |
| 26603 | /* ILO (output) INTEGER */ |
| 26604 | /* IHI (output) INTEGER */ |
| 26605 | /* ILO and IHI are integer values such that on exit */ |
| 26606 | /* A(i,j) = 0 and B(i,j) = 0 if i > j and */ |
| 26607 | /* j = 1,...,ILO-1 or i = IHI+1,...,N. */ |
| 26608 | /* If BALANC = 'N' or 'S', ILO = 1 and IHI = N. */ |
| 26609 | |
| 26610 | /* LSCALE (output) DOUBLE PRECISION array, dimension (N) */ |
| 26611 | /* Details of the permutations and scaling factors applied */ |
| 26612 | /* to the left side of A and B. If PL(j) is the index of the */ |
| 26613 | /* row interchanged with row j, and DL(j) is the scaling */ |
| 26614 | /* factor applied to row j, then */ |
| 26615 | /* LSCALE(j) = PL(j) for j = 1,...,ILO-1 */ |
| 26616 | /* = DL(j) for j = ILO,...,IHI */ |
| 26617 | /* = PL(j) for j = IHI+1,...,N. */ |
| 26618 | /* The order in which the interchanges are made is N to IHI+1, */ |
| 26619 | /* then 1 to ILO-1. */ |
| 26620 | |
| 26621 | /* RSCALE (output) DOUBLE PRECISION array, dimension (N) */ |
| 26622 | /* Details of the permutations and scaling factors applied */ |
| 26623 | /* to the right side of A and B. If PR(j) is the index of the */ |
| 26624 | /* column interchanged with column j, and DR(j) is the scaling */ |
| 26625 | /* factor applied to column j, then */ |
| 26626 | /* RSCALE(j) = PR(j) for j = 1,...,ILO-1 */ |
| 26627 | /* = DR(j) for j = ILO,...,IHI */ |
| 26628 | /* = PR(j) for j = IHI+1,...,N */ |
| 26629 | /* The order in which the interchanges are made is N to IHI+1, */ |
| 26630 | /* then 1 to ILO-1. */ |
| 26631 | |
| 26632 | /* ABNRM (output) DOUBLE PRECISION */ |
| 26633 | /* The one-norm of the balanced matrix A. */ |
| 26634 | |
| 26635 | /* BBNRM (output) DOUBLE PRECISION */ |
| 26636 | /* The one-norm of the balanced matrix B. */ |
| 26637 | |
| 26638 | /* RCONDE (output) DOUBLE PRECISION array, dimension (N) */ |
| 26639 | /* If SENSE = 'E' or 'B', the reciprocal condition numbers of */ |
| 26640 | /* the eigenvalues, stored in consecutive elements of the array. */ |
| 26641 | /* For a complex conjugate pair of eigenvalues two consecutive */ |
| 26642 | /* elements of RCONDE are set to the same value. Thus RCONDE(j), */ |
| 26643 | /* RCONDV(j), and the j-th columns of VL and VR all correspond */ |
| 26644 | /* to the j-th eigenpair. */ |
| 26645 | /* If SENSE = 'N or 'V', RCONDE is not referenced. */ |
| 26646 | |
| 26647 | /* RCONDV (output) DOUBLE PRECISION array, dimension (N) */ |
| 26648 | /* If SENSE = 'V' or 'B', the estimated reciprocal condition */ |
| 26649 | /* numbers of the eigenvectors, stored in consecutive elements */ |
| 26650 | /* of the array. For a complex eigenvector two consecutive */ |
| 26651 | /* elements of RCONDV are set to the same value. If the */ |
| 26652 | /* eigenvalues cannot be reordered to compute RCONDV(j), */ |
| 26653 | /* RCONDV(j) is set to 0; this can only occur when the true */ |
| 26654 | /* value would be very small anyway. */ |
| 26655 | /* If SENSE = 'N' or 'E', RCONDV is not referenced. */ |
| 26656 | |
| 26657 | /* WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) */ |
| 26658 | /* On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ |
| 26659 | |
| 26660 | /* LWORK (input) INTEGER */ |
| 26661 | /* The dimension of the array WORK. LWORK >= max(1,2*N). */ |
| 26662 | /* If BALANC = 'S' or 'B', or JOBVL = 'V', or JOBVR = 'V', */ |
| 26663 | /* LWORK >= max(1,6*N). */ |
| 26664 | /* If SENSE = 'E' or 'B', LWORK >= max(1,10*N). */ |
| 26665 | /* If SENSE = 'V' or 'B', LWORK >= 2*N*N+8*N+16. */ |
| 26666 | |
| 26667 | /* If LWORK = -1, then a workspace query is assumed; the routine */ |
| 26668 | /* only calculates the optimal size of the WORK array, returns */ |
| 26669 | /* this value as the first entry of the WORK array, and no error */ |
| 26670 | /* message related to LWORK is issued by XERBLA. */ |
| 26671 | |
| 26672 | /* IWORK (workspace) INTEGER array, dimension (N+6) */ |
| 26673 | /* If SENSE = 'E', IWORK is not referenced. */ |
| 26674 | |
| 26675 | /* BWORK (workspace) LOGICAL array, dimension (N) */ |
| 26676 | /* If SENSE = 'N', BWORK is not referenced. */ |
| 26677 | |
| 26678 | /* INFO (output) INTEGER */ |
| 26679 | /* = 0: successful exit */ |
| 26680 | /* < 0: if INFO = -i, the i-th argument had an illegal value. */ |
| 26681 | /* = 1,...,N: */ |
| 26682 | /* The QZ iteration failed. No eigenvectors have been */ |
| 26683 | /* calculated, but ALPHAR(j), ALPHAI(j), and BETA(j) */ |
| 26684 | /* should be correct for j=INFO+1,...,N. */ |
| 26685 | /* > N: =N+1: other than QZ iteration failed in DHGEQZ. */ |
| 26686 | /* =N+2: error return from DTGEVC. */ |
| 26687 | |
| 26688 | /* Further Details */ |
| 26689 | /* =============== */ |
| 26690 | |
| 26691 | /* Balancing a matrix pair (A,B) includes, first, permuting rows and */ |
| 26692 | /* columns to isolate eigenvalues, second, applying diagonal similarity */ |
| 26693 | /* transformation to the rows and columns to make the rows and columns */ |
| 26694 | /* as close in norm as possible. The computed reciprocal condition */ |
| 26695 | /* numbers correspond to the balanced matrix. Permuting rows and columns */ |
| 26696 | /* will not change the condition numbers (in exact arithmetic) but */ |
| 26697 | /* diagonal scaling will. For further explanation of balancing, see */ |
| 26698 | /* section 4.11.1.2 of LAPACK Users' Guide. */ |
| 26699 | |
| 26700 | /* An approximate error bound on the chordal distance between the i-th */ |
| 26701 | /* computed generalized eigenvalue w and the corresponding exact */ |
| 26702 | /* eigenvalue lambda is */ |
| 26703 | |
| 26704 | /* chord(w, lambda) <= EPS * norm(ABNRM, BBNRM) / RCONDE(I) */ |
| 26705 | |
| 26706 | /* An approximate error bound for the angle between the i-th computed */ |
| 26707 | /* eigenvector VL(i) or VR(i) is given by */ |
| 26708 | |
| 26709 | /* EPS * norm(ABNRM, BBNRM) / DIF(i). */ |
| 26710 | |
| 26711 | /* For further explanation of the reciprocal condition numbers RCONDE */ |
| 26712 | /* and RCONDV, see section 4.11 of LAPACK User's Guide. */ |
| 26713 | |
| 26714 | /* ===================================================================== */ |
| 26715 | |
| 26716 | /* .. Parameters .. */ |
| 26717 | /* .. */ |
| 26718 | /* .. Local Scalars .. */ |
| 26719 | /* .. */ |
| 26720 | /* .. Local Arrays .. */ |
| 26721 | /* .. */ |
| 26722 | /* .. External Subroutines .. */ |
| 26723 | /* .. */ |
| 26724 | /* .. External Functions .. */ |
| 26725 | /* .. */ |
| 26726 | /* .. Intrinsic Functions .. */ |
| 26727 | /* .. */ |
| 26728 | /* .. Executable Statements .. */ |
| 26729 | |
| 26730 | /* Decode the input arguments */ |
| 26731 | |
| 26732 | /* Parameter adjustments */ |
| 26733 | a_dim1 = *lda; |
| 26734 | a_offset = 1 + a_dim1; |
| 26735 | a -= a_offset; |
| 26736 | b_dim1 = *ldb; |
| 26737 | b_offset = 1 + b_dim1; |
| 26738 | b -= b_offset; |
| 26739 | --alphar; |
| 26740 | --alphai; |
| 26741 | --beta; |
| 26742 | vl_dim1 = *ldvl; |
| 26743 | vl_offset = 1 + vl_dim1; |
| 26744 | vl -= vl_offset; |
| 26745 | vr_dim1 = *ldvr; |
| 26746 | vr_offset = 1 + vr_dim1; |
| 26747 | vr -= vr_offset; |
| 26748 | --lscale; |
| 26749 | --rscale; |
| 26750 | --rconde; |
| 26751 | --rcondv; |
| 26752 | --work; |
| 26753 | --iwork; |
| 26754 | --bwork; |
| 26755 | |
| 26756 | /* Function Body */ |
| 26757 | if (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobvl, "N")) { |
| 26758 | ijobvl = 1; |
| 26759 | ilvl = false; |
| 26760 | } else if (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobvl, "V")) { |
| 26761 | ijobvl = 2; |
| 26762 | ilvl = true; |
| 26763 | } else { |
| 26764 | ijobvl = -1; |
| 26765 | ilvl = false; |
| 26766 | } |
| 26767 | |
| 26768 | if (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobvr, "N")) { |
| 26769 | ijobvr = 1; |
| 26770 | ilvr = false; |
| 26771 | } else if (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobvr, "V")) { |
| 26772 | ijobvr = 2; |
| 26773 | ilvr = true; |
| 26774 | } else { |
| 26775 | ijobvr = -1; |
| 26776 | ilvr = false; |
| 26777 | } |
| 26778 | ilv = ilvl || ilvr; |
| 26779 | |
| 26780 | noscl = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(balanc, "N") || lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(balanc, "P"); |
| 26781 | wantsn = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(sense, "N"); |
| 26782 | wantse = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(sense, "E"); |
| 26783 | wantsv = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(sense, "V"); |
| 26784 | wantsb = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(sense, "B"); |
| 26785 | |
| 26786 | /* Test the input arguments */ |
| 26787 | |
| 26788 | *info = 0; |
| 26789 | lquery = *lwork == -1; |
| 26790 | if (! (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(balanc, "N") || lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(balanc, "S") || lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(balanc, "P") |
| 26791 | || lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(balanc, "B"))) { |
| 26792 | *info = -1; |
| 26793 | } else if (ijobvl <= 0) { |
| 26794 | *info = -2; |
| 26795 | } else if (ijobvr <= 0) { |
| 26796 | *info = -3; |
| 26797 | } else if (! (wantsn || wantse || wantsb || wantsv)) { |
| 26798 | *info = -4; |
| 26799 | } else if (*n < 0) { |
| 26800 | *info = -5; |
| 26801 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 26802 | *info = -7; |
| 26803 | } else if (*ldb < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 26804 | *info = -9; |
| 26805 | } else if (*ldvl < 1 || ilvl && *ldvl < *n) { |
| 26806 | *info = -14; |
| 26807 | } else if (*ldvr < 1 || ilvr && *ldvr < *n) { |
| 26808 | *info = -16; |
| 26809 | } |
| 26810 | |
| 26811 | /* Compute workspace */ |
| 26812 | /* (Note: Comments in the code beginning "Workspace:" describe the */ |
| 26813 | /* minimal amount of workspace needed at that point in the code, */ |
| 26814 | /* as well as the preferred amount for good performance. */ |
| 26815 | /* NB refers to the optimal block size for the immediately */ |
| 26816 | /* following subroutine, as returned by ILAENV. The workspace is */ |
| 26817 | /* computed assuming ILO = 1 and IHI = N, the worst case.) */ |
| 26818 | |
| 26819 | if (*info == 0) { |
| 26820 | if (*n == 0) { |
| 26821 | minwrk = 1; |
| 26822 | maxwrk = 1; |
| 26823 | } else { |
| 26824 | if (noscl && ! ilv) { |
| 26825 | minwrk = *n << 1; |
| 26826 | } else { |
| 26827 | minwrk = *n * 6; |
| 26828 | } |
| 26829 | if (wantse || wantsb) { |
| 26830 | minwrk = *n * 10; |
| 26831 | } |
| 26832 | if (wantsv || wantsb) { |
| 26833 | /* Computing MAX */ |
| 26834 | i__1 = minwrk, i__2 = (*n << 1) * (*n + 4) + 16; |
| 26835 | minwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 26836 | } |
| 26837 | maxwrk = minwrk; |
| 26838 | /* Computing MAX */ |
| 26839 | i__1 = maxwrk, i__2 = *n + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEQRF", " ", n, & |
| 26840 | c__1, n, &c__0); |
| 26841 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 26842 | /* Computing MAX */ |
| 26843 | i__1 = maxwrk, i__2 = *n + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMQR", " ", n, & |
| 26844 | c__1, n, &c__0); |
| 26845 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 26846 | if (ilvl) { |
| 26847 | /* Computing MAX */ |
| 26848 | i__1 = maxwrk, i__2 = *n + *n * ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORGQR", |
| 26849 | " ", n, &c__1, n, &c__0); |
| 26850 | maxwrk = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 26851 | } |
| 26852 | } |
| 26853 | work[1] = (double) maxwrk; |
| 26854 | |
| 26855 | if (*lwork < minwrk && ! lquery) { |
| 26856 | *info = -26; |
| 26857 | } |
| 26858 | } |
| 26859 | |
| 26860 | if (*info != 0) { |
| 26861 | i__1 = -(*info); |
| 26862 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGGEVX", &i__1); |
| 26863 | return 0; |
| 26864 | } else if (lquery) { |
| 26865 | return 0; |
| 26866 | } |
| 26867 | |
| 26868 | /* Quick return if possible */ |
| 26869 | |
| 26870 | if (*n == 0) { |
| 26871 | return 0; |
| 26872 | } |
| 26873 | |
| 26874 | |
| 26875 | /* Get machine constants */ |
| 26876 | |
| 26877 | eps = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("P"); |
| 26878 | smlnum = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("S"); |
| 26879 | bignum = 1. / smlnum; |
| 26880 | dlabad_cxx . . $ dlabad_(4730c933dae9b326).(&smlnum, &bignum); |
| 26881 | smlnum = sqrtcxx . . $ sqrt(fee4f1d22bc8e617).(smlnum) / eps; |
| 26882 | bignum = 1. / smlnum; |
| 26883 | |
| 26884 | /* Scale A if max element outside range [SMLNUM,BIGNUM] */ |
| 26885 | |
| 26886 | anrm = dlange_cxx . . $ dlange_(98d44e6417336f20).("M", n, n, &a[a_offset], lda, &work[1]); |
| 26887 | ilascl = false; |
| 26888 | if (anrm > 0. && anrm < smlnum) { |
| 26889 | anrmto = smlnum; |
| 26890 | ilascl = true; |
| 26891 | } else if (anrm > bignum) { |
| 26892 | anrmto = bignum; |
| 26893 | ilascl = true; |
| 26894 | } |
| 26895 | if (ilascl) { |
| 26896 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &anrm, &anrmto, n, n, &a[a_offset], lda, & |
| 26897 | ierr); |
| 26898 | } |
| 26899 | |
| 26900 | /* Scale B if max element outside range [SMLNUM,BIGNUM] */ |
| 26901 | |
| 26902 | bnrm = dlange_cxx . . $ dlange_(98d44e6417336f20).("M", n, n, &b[b_offset], ldb, &work[1]); |
| 26903 | ilbscl = false; |
| 26904 | if (bnrm > 0. && bnrm < smlnum) { |
| 26905 | bnrmto = smlnum; |
| 26906 | ilbscl = true; |
| 26907 | } else if (bnrm > bignum) { |
| 26908 | bnrmto = bignum; |
| 26909 | ilbscl = true; |
| 26910 | } |
| 26911 | if (ilbscl) { |
| 26912 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &bnrm, &bnrmto, n, n, &b[b_offset], ldb, & |
| 26913 | ierr); |
| 26914 | } |
| 26915 | |
| 26916 | /* Permute and/or balance the matrix pair (A,B) */ |
| 26917 | /* (Workspace: need 6*N if BALANC = 'S' or 'B', 1 otherwise) */ |
| 26918 | |
| 26919 | dggbal_cxx . . $ dggbal_(69bfde64ff0f2aeb).(balanc, n, &a[a_offset], lda, &b[b_offset], ldb, ilo, ihi, & |
| 26920 | lscale[1], &rscale[1], &work[1], &ierr); |
| 26921 | |
| 26922 | /* Compute ABNRM and BBNRM */ |
| 26923 | |
| 26924 | *abnrm = dlange_cxx . . $ dlange_(98d44e6417336f20).("1", n, n, &a[a_offset], lda, &work[1]); |
| 26925 | if (ilascl) { |
| 26926 | work[1] = *abnrm; |
| 26927 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &anrmto, &anrm, &c__1, &c__1, &work[1], & |
| 26928 | c__1, &ierr); |
| 26929 | *abnrm = work[1]; |
| 26930 | } |
| 26931 | |
| 26932 | *bbnrm = dlange_cxx . . $ dlange_(98d44e6417336f20).("1", n, n, &b[b_offset], ldb, &work[1]); |
| 26933 | if (ilbscl) { |
| 26934 | work[1] = *bbnrm; |
| 26935 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &bnrmto, &bnrm, &c__1, &c__1, &work[1], & |
| 26936 | c__1, &ierr); |
| 26937 | *bbnrm = work[1]; |
| 26938 | } |
| 26939 | |
| 26940 | /* Reduce B to triangular form (QR decomposition of B) */ |
| 26941 | /* (Workspace: need N, prefer N*NB ) */ |
| 26942 | |
| 26943 | irows = *ihi + 1 - *ilo; |
| 26944 | if (ilv || ! wantsn) { |
| 26945 | icols = *n + 1 - *ilo; |
| 26946 | } else { |
| 26947 | icols = irows; |
| 26948 | } |
| 26949 | itau = 1; |
| 26950 | iwrk = itau + irows; |
| 26951 | i__1 = *lwork + 1 - iwrk; |
| 26952 | dgeqrf_cxx . . $ dgeqrf_(b2aaa174babf002e).(&irows, &icols, &b[*ilo + *ilo * b_dim1], ldb, &work[itau], &work[ |
| 26953 | iwrk], &i__1, &ierr); |
| 26954 | |
| 26955 | /* Apply the orthogonal transformation to A */ |
| 26956 | /* (Workspace: need N, prefer N*NB) */ |
| 26957 | |
| 26958 | i__1 = *lwork + 1 - iwrk; |
| 26959 | dormqr_cxx . . $ dormqr_(c6b7238dd97e9cf9).("L", "T", &irows, &icols, &irows, &b[*ilo + *ilo * b_dim1], ldb, & |
| 26960 | work[itau], &a[*ilo + *ilo * a_dim1], lda, &work[iwrk], &i__1, & |
| 26961 | ierr); |
| 26962 | |
| 26963 | /* Initialize VL and/or VR */ |
| 26964 | /* (Workspace: need N, prefer N*NB) */ |
| 26965 | |
| 26966 | if (ilvl) { |
| 26967 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("Full", n, n, &c_b59, &c_b60, &vl[vl_offset], ldvl) |
| 26968 | ; |
| 26969 | if (irows > 1) { |
| 26970 | i__1 = irows - 1; |
| 26971 | i__2 = irows - 1; |
| 26972 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("L", &i__1, &i__2, &b[*ilo + 1 + *ilo * b_dim1], ldb, &vl[ |
| 26973 | *ilo + 1 + *ilo * vl_dim1], ldvl); |
| 26974 | } |
| 26975 | i__1 = *lwork + 1 - iwrk; |
| 26976 | dorgqr_cxx . . $ dorgqr_(424524679a238630).(&irows, &irows, &irows, &vl[*ilo + *ilo * vl_dim1], ldvl, & |
| 26977 | work[itau], &work[iwrk], &i__1, &ierr); |
| 26978 | } |
| 26979 | |
| 26980 | if (ilvr) { |
| 26981 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("Full", n, n, &c_b59, &c_b60, &vr[vr_offset], ldvr) |
| 26982 | ; |
| 26983 | } |
| 26984 | |
| 26985 | /* Reduce to generalized Hessenberg form */ |
| 26986 | /* (Workspace: none needed) */ |
| 26987 | |
| 26988 | if (ilv || ! wantsn) { |
| 26989 | |
| 26990 | /* Eigenvectors requested -- work on whole matrix. */ |
| 26991 | |
| 26992 | dgghrd_cxx . . $ dgghrd_(a37938716ecaec33).(jobvl, jobvr, n, ilo, ihi, &a[a_offset], lda, &b[b_offset], |
| 26993 | ldb, &vl[vl_offset], ldvl, &vr[vr_offset], ldvr, &ierr); |
| 26994 | } else { |
| 26995 | dgghrd_cxx . . $ dgghrd_(a37938716ecaec33).("N", "N", &irows, &c__1, &irows, &a[*ilo + *ilo * a_dim1], |
| 26996 | lda, &b[*ilo + *ilo * b_dim1], ldb, &vl[vl_offset], ldvl, &vr[ |
| 26997 | vr_offset], ldvr, &ierr); |
| 26998 | } |
| 26999 | |
| 27000 | /* Perform QZ algorithm (Compute eigenvalues, and optionally, the */ |
| 27001 | /* Schur forms and Schur vectors) */ |
| 27002 | /* (Workspace: need N) */ |
| 27003 | |
| 27004 | if (ilv || ! wantsn) { |
| 27005 | *(unsigned char *)chtemp = 'S'; |
| 27006 | } else { |
| 27007 | *(unsigned char *)chtemp = 'E'; |
| 27008 | } |
| 27009 | |
| 27010 | dhgeqz_cxx . . $ dhgeqz_(1c7cf0ed1736d01d).(chtemp, jobvl, jobvr, n, ilo, ihi, &a[a_offset], lda, &b[b_offset] |
| 27011 | , ldb, &alphar[1], &alphai[1], &beta[1], &vl[vl_offset], ldvl, & |
| 27012 | vr[vr_offset], ldvr, &work[1], lwork, &ierr); |
| 27013 | if (ierr != 0) { |
| 27014 | if (ierr > 0 && ierr <= *n) { |
| 27015 | *info = ierr; |
| 27016 | } else if (ierr > *n && ierr <= *n << 1) { |
| 27017 | *info = ierr - *n; |
| 27018 | } else { |
| 27019 | *info = *n + 1; |
| 27020 | } |
| 27021 | goto L130; |
| 27022 | } |
| 27023 | |
| 27024 | /* Compute Eigenvectors and estimate condition numbers if desired */ |
| 27025 | /* (Workspace: DTGEVC: need 6*N */ |
| 27026 | /* DTGSNA: need 2*N*(N+2)+16 if SENSE = 'V' or 'B', */ |
| 27027 | /* need N otherwise ) */ |
| 27028 | |
| 27029 | if (ilv || ! wantsn) { |
| 27030 | if (ilv) { |
| 27031 | if (ilvl) { |
| 27032 | if (ilvr) { |
| 27033 | *(unsigned char *)chtemp = 'B'; |
| 27034 | } else { |
| 27035 | *(unsigned char *)chtemp = 'L'; |
| 27036 | } |
| 27037 | } else { |
| 27038 | *(unsigned char *)chtemp = 'R'; |
| 27039 | } |
| 27040 | |
| 27041 | dtgevc_cxx . . $ dtgevc_(66a19661ce790798).(chtemp, "B", ldumma, n, &a[a_offset], lda, &b[b_offset], |
| 27042 | ldb, &vl[vl_offset], ldvl, &vr[vr_offset], ldvr, n, &in, & |
| 27043 | work[1], &ierr); |
| 27044 | if (ierr != 0) { |
| 27045 | *info = *n + 2; |
| 27046 | goto L130; |
| 27047 | } |
| 27048 | } |
| 27049 | |
| 27050 | if (! wantsn) { |
| 27051 | |
| 27052 | /* compute eigenvectors (DTGEVC) and estimate condition */ |
| 27053 | /* numbers (DTGSNA). Note that the definition of the condition */ |
| 27054 | /* number is not invariant under transformation (u,v) to */ |
| 27055 | /* (Q*u, Z*v), where (u,v) are eigenvectors of the generalized */ |
| 27056 | /* Schur form (S,T), Q and Z are orthogonal matrices. In order */ |
| 27057 | /* to avoid using extra 2*N*N workspace, we have to recalculate */ |
| 27058 | /* eigenvectors and estimate one condition numbers at a time. */ |
| 27059 | |
| 27060 | pair = false; |
| 27061 | i__1 = *n; |
| 27062 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 27063 | |
| 27064 | if (pair) { |
| 27065 | pair = false; |
| 27066 | goto L20; |
| 27067 | } |
| 27068 | mm = 1; |
| 27069 | if (i__ < *n) { |
| 27070 | if (a[i__ + 1 + i__ * a_dim1] != 0.) { |
| 27071 | pair = true; |
| 27072 | mm = 2; |
| 27073 | } |
| 27074 | } |
| 27075 | |
| 27076 | i__2 = *n; |
| 27077 | for (j = 1; j <= i__2; ++j) { |
| 27078 | bwork[j] = false; |
| 27079 | /* L10: */ |
| 27080 | } |
| 27081 | if (mm == 1) { |
| 27082 | bwork[i__] = true; |
| 27083 | } else if (mm == 2) { |
| 27084 | bwork[i__] = true; |
| 27085 | bwork[i__ + 1] = true; |
| 27086 | } |
| 27087 | |
| 27088 | iwrk = mm * *n + 1; |
| 27089 | iwrk1 = iwrk + mm * *n; |
| 27090 | |
| 27091 | /* Compute a pair of left and right eigenvectors. */ |
| 27092 | /* (compute workspace: need up to 4*N + 6*N) */ |
| 27093 | |
| 27094 | if (wantse || wantsb) { |
| 27095 | dtgevc_cxx . . $ dtgevc_(66a19661ce790798).("B", "S", &bwork[1], n, &a[a_offset], lda, &b[ |
| 27096 | b_offset], ldb, &work[1], n, &work[iwrk], n, &mm, |
| 27097 | &m, &work[iwrk1], &ierr); |
| 27098 | if (ierr != 0) { |
| 27099 | *info = *n + 2; |
| 27100 | goto L130; |
| 27101 | } |
| 27102 | } |
| 27103 | |
| 27104 | i__2 = *lwork - iwrk1 + 1; |
| 27105 | dtgsna_cxx . . $ dtgsna_(31b582a2b24a0f65).(sense, "S", &bwork[1], n, &a[a_offset], lda, &b[ |
| 27106 | b_offset], ldb, &work[1], n, &work[iwrk], n, &rconde[ |
| 27107 | i__], &rcondv[i__], &mm, &m, &work[iwrk1], &i__2, & |
| 27108 | iwork[1], &ierr); |
| 27109 | |
| 27110 | L20: |
| 27111 | ; |
| 27112 | } |
| 27113 | } |
| 27114 | } |
| 27115 | |
| 27116 | /* Undo balancing on VL and VR and normalization */ |
| 27117 | /* (Workspace: none needed) */ |
| 27118 | |
| 27119 | if (ilvl) { |
| 27120 | dggbak_cxx . . $ dggbak_(3fb2e360e620705c).(balanc, "L", n, ilo, ihi, &lscale[1], &rscale[1], n, &vl[ |
| 27121 | vl_offset], ldvl, &ierr); |
| 27122 | |
| 27123 | i__1 = *n; |
| 27124 | for (jc = 1; jc <= i__1; ++jc) { |
| 27125 | if (alphai[jc] < 0.) { |
| 27126 | goto L70; |
| 27127 | } |
| 27128 | temp = 0.; |
| 27129 | if (alphai[jc] == 0.) { |
| 27130 | i__2 = *n; |
| 27131 | for (jr = 1; jr <= i__2; ++jr) { |
| 27132 | /* Computing MAX */ |
| 27133 | d__2 = temp, d__3 = (d__1 = vl[jr + jc * vl_dim1], abscxx . . $ abs(447c67c6676f75c3).( |
| 27134 | d__1)); |
| 27135 | temp = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__2,d__3); |
| 27136 | /* L30: */ |
| 27137 | } |
| 27138 | } else { |
| 27139 | i__2 = *n; |
| 27140 | for (jr = 1; jr <= i__2; ++jr) { |
| 27141 | /* Computing MAX */ |
| 27142 | d__3 = temp, d__4 = (d__1 = vl[jr + jc * vl_dim1], abscxx . . $ abs(447c67c6676f75c3).( |
| 27143 | d__1)) + (d__2 = vl[jr + (jc + 1) * vl_dim1], abscxx . . $ abs(447c67c6676f75c3).( |
| 27144 | d__2)); |
| 27145 | temp = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__3,d__4); |
| 27146 | /* L40: */ |
| 27147 | } |
| 27148 | } |
| 27149 | if (temp < smlnum) { |
| 27150 | goto L70; |
| 27151 | } |
| 27152 | temp = 1. / temp; |
| 27153 | if (alphai[jc] == 0.) { |
| 27154 | i__2 = *n; |
| 27155 | for (jr = 1; jr <= i__2; ++jr) { |
| 27156 | vl[jr + jc * vl_dim1] *= temp; |
| 27157 | /* L50: */ |
| 27158 | } |
| 27159 | } else { |
| 27160 | i__2 = *n; |
| 27161 | for (jr = 1; jr <= i__2; ++jr) { |
| 27162 | vl[jr + jc * vl_dim1] *= temp; |
| 27163 | vl[jr + (jc + 1) * vl_dim1] *= temp; |
| 27164 | /* L60: */ |
| 27165 | } |
| 27166 | } |
| 27167 | L70: |
| 27168 | ; |
| 27169 | } |
| 27170 | } |
| 27171 | if (ilvr) { |
| 27172 | dggbak_cxx . . $ dggbak_(3fb2e360e620705c).(balanc, "R", n, ilo, ihi, &lscale[1], &rscale[1], n, &vr[ |
| 27173 | vr_offset], ldvr, &ierr); |
| 27174 | i__1 = *n; |
| 27175 | for (jc = 1; jc <= i__1; ++jc) { |
| 27176 | if (alphai[jc] < 0.) { |
| 27177 | goto L120; |
| 27178 | } |
| 27179 | temp = 0.; |
| 27180 | if (alphai[jc] == 0.) { |
| 27181 | i__2 = *n; |
| 27182 | for (jr = 1; jr <= i__2; ++jr) { |
| 27183 | /* Computing MAX */ |
| 27184 | d__2 = temp, d__3 = (d__1 = vr[jr + jc * vr_dim1], abscxx . . $ abs(447c67c6676f75c3).( |
| 27185 | d__1)); |
| 27186 | temp = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__2,d__3); |
| 27187 | /* L80: */ |
| 27188 | } |
| 27189 | } else { |
| 27190 | i__2 = *n; |
| 27191 | for (jr = 1; jr <= i__2; ++jr) { |
| 27192 | /* Computing MAX */ |
| 27193 | d__3 = temp, d__4 = (d__1 = vr[jr + jc * vr_dim1], abscxx . . $ abs(447c67c6676f75c3).( |
| 27194 | d__1)) + (d__2 = vr[jr + (jc + 1) * vr_dim1], abscxx . . $ abs(447c67c6676f75c3).( |
| 27195 | d__2)); |
| 27196 | temp = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__3,d__4); |
| 27197 | /* L90: */ |
| 27198 | } |
| 27199 | } |
| 27200 | if (temp < smlnum) { |
| 27201 | goto L120; |
| 27202 | } |
| 27203 | temp = 1. / temp; |
| 27204 | if (alphai[jc] == 0.) { |
| 27205 | i__2 = *n; |
| 27206 | for (jr = 1; jr <= i__2; ++jr) { |
| 27207 | vr[jr + jc * vr_dim1] *= temp; |
| 27208 | /* L100: */ |
| 27209 | } |
| 27210 | } else { |
| 27211 | i__2 = *n; |
| 27212 | for (jr = 1; jr <= i__2; ++jr) { |
| 27213 | vr[jr + jc * vr_dim1] *= temp; |
| 27214 | vr[jr + (jc + 1) * vr_dim1] *= temp; |
| 27215 | /* L110: */ |
| 27216 | } |
| 27217 | } |
| 27218 | L120: |
| 27219 | ; |
| 27220 | } |
| 27221 | } |
| 27222 | |
| 27223 | /* Undo scaling if necessary */ |
| 27224 | |
| 27225 | if (ilascl) { |
| 27226 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &anrmto, &anrm, n, &c__1, &alphar[1], n, & |
| 27227 | ierr); |
| 27228 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &anrmto, &anrm, n, &c__1, &alphai[1], n, & |
| 27229 | ierr); |
| 27230 | } |
| 27231 | |
| 27232 | if (ilbscl) { |
| 27233 | dlascl_cxx . . $ dlascl_(12f5ba640af67731).("G", &c__0, &c__0, &bnrmto, &bnrm, n, &c__1, &beta[1], n, & |
| 27234 | ierr); |
| 27235 | } |
| 27236 | |
| 27237 | L130: |
| 27238 | work[1] = (double) maxwrk; |
| 27239 | |
| 27240 | return 0; |
| 27241 | |
| 27242 | /* End of DGGEVX */ |
| 27243 | |
| 27244 | } /* dggevx_ */ |
| 27245 | |
| 27246 | /* Subroutine */ int dggglm_cxx . . $ dggglm_(3edc0d77b0e5c5a).(integercxx . . $ integer# *n, integercxx . . $ integer# *m, integercxx . . $ integer# *p, double * |
| 27247 | a, integercxx . . $ integer# *lda, double *b, integercxx . . $ integer# *ldb, double *d__, |
| 27248 | double *x, double *y, double *work, integercxx . . $ integer# *lwork, |
| 27249 | integercxx . . $ integer# *info) |
| 27250 | { |
| 27251 | /* Table of constant values */ |
| 27252 | static integercxx . . $ integer# c__1 = 1; |
| 27253 | static integercxx . . $ integer# c_n1 = -1; |
| 27254 | static double c_b32 = -1.; |
| 27255 | static double c_b34 = 1.; |
| 27256 | |
| 27257 | /* System generated locals */ |
| 27258 | integercxx . . $ integer# a_dim1, a_offset, b_dim1, b_offset, i__1, i__2, i__3, i__4; |
| 27259 | |
| 27260 | /* Local variables */ |
| 27261 | integercxx . . $ integer# i__, nb, np, nb1, nb2, nb3, nb4, lopt; |
| 27262 | integercxx . . $ integer# lwkmin; |
| 27263 | integercxx . . $ integer# lwkopt; |
| 27264 | bool lquery; |
| 27265 | |
| 27266 | |
| 27267 | /* -- LAPACK driver routine (version 3.1) -- */ |
| 27268 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 27269 | /* November 2006 */ |
| 27270 | |
| 27271 | /* .. Scalar Arguments .. */ |
| 27272 | /* .. */ |
| 27273 | /* .. Array Arguments .. */ |
| 27274 | /* .. */ |
| 27275 | |
| 27276 | /* Purpose */ |
| 27277 | /* ======= */ |
| 27278 | |
| 27279 | /* DGGGLM solves a general Gauss-Markov linear model (GLM) problem: */ |
| 27280 | |
| 27281 | /* minimize || y ||_2 subject to d = A*x + B*y */ |
| 27282 | /* x */ |
| 27283 | |
| 27284 | /* where A is an N-by-M matrix, B is an N-by-P matrix, and d is a */ |
| 27285 | /* given N-vector. It is assumed that M <= N <= M+P, and */ |
| 27286 | |
| 27287 | /* rank(A) = M and rank( A B ) = N. */ |
| 27288 | |
| 27289 | /* Under these assumptions, the constrained equation is always */ |
| 27290 | /* consistent, and there is a unique solution x and a minimal 2-norm */ |
| 27291 | /* solution y, which is obtained using a generalized QR factorization */ |
| 27292 | /* of the matrices (A, B) given by */ |
| 27293 | |
| 27294 | /* A = Q*(R), B = Q*T*Z. */ |
| 27295 | /* (0) */ |
| 27296 | |
| 27297 | /* In particular, if matrix B is square nonsingular, then the problem */ |
| 27298 | /* GLM is equivalent to the following weighted linear least squares */ |
| 27299 | /* problem */ |
| 27300 | |
| 27301 | /* minimize || inv(B)*(d-A*x) ||_2 */ |
| 27302 | /* x */ |
| 27303 | |
| 27304 | /* where inv(B) denotes the inverse of B. */ |
| 27305 | |
| 27306 | /* Arguments */ |
| 27307 | /* ========= */ |
| 27308 | |
| 27309 | /* N (input) INTEGER */ |
| 27310 | /* The number of rows of the matrices A and B. N >= 0. */ |
| 27311 | |
| 27312 | /* M (input) INTEGER */ |
| 27313 | /* The number of columns of the matrix A. 0 <= M <= N. */ |
| 27314 | |
| 27315 | /* P (input) INTEGER */ |
| 27316 | /* The number of columns of the matrix B. P >= N-M. */ |
| 27317 | |
| 27318 | /* A (input/output) DOUBLE PRECISION array, dimension (LDA,M) */ |
| 27319 | /* On entry, the N-by-M matrix A. */ |
| 27320 | /* On exit, the upper triangular part of the array A contains */ |
| 27321 | /* the M-by-M upper triangular matrix R. */ |
| 27322 | |
| 27323 | /* LDA (input) INTEGER */ |
| 27324 | /* The leading dimension of the array A. LDA >= max(1,N). */ |
| 27325 | |
| 27326 | /* B (input/output) DOUBLE PRECISION array, dimension (LDB,P) */ |
| 27327 | /* On entry, the N-by-P matrix B. */ |
| 27328 | /* On exit, if N <= P, the upper triangle of the subarray */ |
| 27329 | /* B(1:N,P-N+1:P) contains the N-by-N upper triangular matrix T; */ |
| 27330 | /* if N > P, the elements on and above the (N-P)th subdiagonal */ |
| 27331 | /* contain the N-by-P upper trapezoidal matrix T. */ |
| 27332 | |
| 27333 | /* LDB (input) INTEGER */ |
| 27334 | /* The leading dimension of the array B. LDB >= max(1,N). */ |
| 27335 | |
| 27336 | /* D (input/output) DOUBLE PRECISION array, dimension (N) */ |
| 27337 | /* On entry, D is the left hand side of the GLM equation. */ |
| 27338 | /* On exit, D is destroyed. */ |
| 27339 | |
| 27340 | /* X (output) DOUBLE PRECISION array, dimension (M) */ |
| 27341 | /* Y (output) DOUBLE PRECISION array, dimension (P) */ |
| 27342 | /* On exit, X and Y are the solutions of the GLM problem. */ |
| 27343 | |
| 27344 | /* WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) */ |
| 27345 | /* On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ |
| 27346 | |
| 27347 | /* LWORK (input) INTEGER */ |
| 27348 | /* The dimension of the array WORK. LWORK >= max(1,N+M+P). */ |
| 27349 | /* For optimum performance, LWORK >= M+min(N,P)+max(N,P)*NB, */ |
| 27350 | /* where NB is an upper bound for the optimal blocksizes for */ |
| 27351 | /* DGEQRF, SGERQF, DORMQR and SORMRQ. */ |
| 27352 | |
| 27353 | /* If LWORK = -1, then a workspace query is assumed; the routine */ |
| 27354 | /* only calculates the optimal size of the WORK array, returns */ |
| 27355 | /* this value as the first entry of the WORK array, and no error */ |
| 27356 | /* message related to LWORK is issued by XERBLA. */ |
| 27357 | |
| 27358 | /* INFO (output) INTEGER */ |
| 27359 | /* = 0: successful exit. */ |
| 27360 | /* < 0: if INFO = -i, the i-th argument had an illegal value. */ |
| 27361 | /* = 1: the upper triangular factor R associated with A in the */ |
| 27362 | /* generalized QR factorization of the pair (A, B) is */ |
| 27363 | /* singular, so that rank(A) < M; the least squares */ |
| 27364 | /* solution could not be computed. */ |
| 27365 | /* = 2: the bottom (N-M) by (N-M) part of the upper trapezoidal */ |
| 27366 | /* factor T associated with B in the generalized QR */ |
| 27367 | /* factorization of the pair (A, B) is singular, so that */ |
| 27368 | /* rank( A B ) < N; the least squares solution could not */ |
| 27369 | /* be computed. */ |
| 27370 | |
| 27371 | /* =================================================================== */ |
| 27372 | |
| 27373 | /* .. Parameters .. */ |
| 27374 | /* .. */ |
| 27375 | /* .. Local Scalars .. */ |
| 27376 | /* .. */ |
| 27377 | /* .. External Subroutines .. */ |
| 27378 | /* .. */ |
| 27379 | /* .. External Functions .. */ |
| 27380 | /* .. */ |
| 27381 | /* .. Intrinsic Functions .. */ |
| 27382 | /* .. */ |
| 27383 | /* .. Executable Statements .. */ |
| 27384 | |
| 27385 | /* Test the input parameters */ |
| 27386 | |
| 27387 | /* Parameter adjustments */ |
| 27388 | a_dim1 = *lda; |
| 27389 | a_offset = 1 + a_dim1; |
| 27390 | a -= a_offset; |
| 27391 | b_dim1 = *ldb; |
| 27392 | b_offset = 1 + b_dim1; |
| 27393 | b -= b_offset; |
| 27394 | --d__; |
| 27395 | --x; |
| 27396 | --y; |
| 27397 | --work; |
| 27398 | |
| 27399 | /* Function Body */ |
| 27400 | *info = 0; |
| 27401 | np = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(*n,*p); |
| 27402 | lquery = *lwork == -1; |
| 27403 | if (*n < 0) { |
| 27404 | *info = -1; |
| 27405 | } else if (*m < 0 || *m > *n) { |
| 27406 | *info = -2; |
| 27407 | } else if (*p < 0 || *p < *n - *m) { |
| 27408 | *info = -3; |
| 27409 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 27410 | *info = -5; |
| 27411 | } else if (*ldb < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 27412 | *info = -7; |
| 27413 | } |
| 27414 | |
| 27415 | /* Calculate workspace */ |
| 27416 | |
| 27417 | if (*info == 0) { |
| 27418 | if (*n == 0) { |
| 27419 | lwkmin = 1; |
| 27420 | lwkopt = 1; |
| 27421 | } else { |
| 27422 | nb1 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEQRF", " ", n, m, &c_n1, &c_n1); |
| 27423 | nb2 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGERQF", " ", n, m, &c_n1, &c_n1); |
| 27424 | nb3 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMQR", " ", n, m, p, &c_n1); |
| 27425 | nb4 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMRQ", " ", n, m, p, &c_n1); |
| 27426 | /* Computing MAX */ |
| 27427 | i__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(nb1,nb2), i__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,nb3); |
| 27428 | nb = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,nb4); |
| 27429 | lwkmin = *m + *n + *p; |
| 27430 | lwkopt = *m + np + stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(*n,*p) * nb; |
| 27431 | } |
| 27432 | work[1] = (double) lwkopt; |
| 27433 | |
| 27434 | if (*lwork < lwkmin && ! lquery) { |
| 27435 | *info = -12; |
| 27436 | } |
| 27437 | } |
| 27438 | |
| 27439 | if (*info != 0) { |
| 27440 | i__1 = -(*info); |
| 27441 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGGGLM", &i__1); |
| 27442 | return 0; |
| 27443 | } else if (lquery) { |
| 27444 | return 0; |
| 27445 | } |
| 27446 | |
| 27447 | /* Quick return if possible */ |
| 27448 | |
| 27449 | if (*n == 0) { |
| 27450 | return 0; |
| 27451 | } |
| 27452 | |
| 27453 | /* Compute the GQR factorization of matrices A and B: */ |
| 27454 | |
| 27455 | /* Q'*A = ( R11 ) M, Q'*B*Z' = ( T11 T12 ) M */ |
| 27456 | /* ( 0 ) N-M ( 0 T22 ) N-M */ |
| 27457 | /* M M+P-N N-M */ |
| 27458 | |
| 27459 | /* where R11 and T22 are upper triangular, and Q and Z are */ |
| 27460 | /* orthogonal. */ |
| 27461 | |
| 27462 | i__1 = *lwork - *m - np; |
| 27463 | dggqrf_cxx . . $ dggqrf_(c951bae2f1e49e56).(n, m, p, &a[a_offset], lda, &work[1], &b[b_offset], ldb, &work[*m |
| 27464 | + 1], &work[*m + np + 1], &i__1, info); |
| 27465 | lopt = (integercxx . . $ integer#) work[*m + np + 1]; |
| 27466 | |
| 27467 | /* Update left-hand-side vector d = Q'*d = ( d1 ) M */ |
| 27468 | /* ( d2 ) N-M */ |
| 27469 | |
| 27470 | i__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n); |
| 27471 | i__2 = *lwork - *m - np; |
| 27472 | dormqr_cxx . . $ dormqr_(c6b7238dd97e9cf9).("Left", "Transpose", n, &c__1, m, &a[a_offset], lda, &work[1], & |
| 27473 | d__[1], &i__1, &work[*m + np + 1], &i__2, info); |
| 27474 | /* Computing MAX */ |
| 27475 | i__1 = lopt, i__2 = (integercxx . . $ integer#) work[*m + np + 1]; |
| 27476 | lopt = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 27477 | |
| 27478 | /* Solve T22*y2 = d2 for y2 */ |
| 27479 | |
| 27480 | if (*n > *m) { |
| 27481 | i__1 = *n - *m; |
| 27482 | i__2 = *n - *m; |
| 27483 | dtrtrs_cxx . . $ dtrtrs_(dee8bd198981a606).("Upper", "No transpose", "Non unit", &i__1, &c__1, &b[*m + 1 |
| 27484 | + (*m + *p - *n + 1) * b_dim1], ldb, &d__[*m + 1], &i__2, |
| 27485 | info); |
| 27486 | |
| 27487 | if (*info > 0) { |
| 27488 | *info = 1; |
| 27489 | return 0; |
| 27490 | } |
| 27491 | |
| 27492 | i__1 = *n - *m; |
| 27493 | dcopy_cxx . . $ dcopy_(ec261fd7ec3b6bf6).(&i__1, &d__[*m + 1], &c__1, &y[*m + *p - *n + 1], &c__1); |
| 27494 | } |
| 27495 | |
| 27496 | /* Set y1 = 0 */ |
| 27497 | |
| 27498 | i__1 = *m + *p - *n; |
| 27499 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 27500 | y[i__] = 0.; |
| 27501 | /* L10: */ |
| 27502 | } |
| 27503 | |
| 27504 | /* Update d1 = d1 - T12*y2 */ |
| 27505 | |
| 27506 | i__1 = *n - *m; |
| 27507 | dgemv_cxx . . $ dgemv_(828a5131add94649).("No transpose", m, &i__1, &c_b32, &b[(*m + *p - *n + 1) * b_dim1 + |
| 27508 | 1], ldb, &y[*m + *p - *n + 1], &c__1, &c_b34, &d__[1], &c__1); |
| 27509 | |
| 27510 | /* Solve triangular system: R11*x = d1 */ |
| 27511 | |
| 27512 | if (*m > 0) { |
| 27513 | dtrtrs_cxx . . $ dtrtrs_(dee8bd198981a606).("Upper", "No Transpose", "Non unit", m, &c__1, &a[a_offset], |
| 27514 | lda, &d__[1], m, info); |
| 27515 | |
| 27516 | if (*info > 0) { |
| 27517 | *info = 2; |
| 27518 | return 0; |
| 27519 | } |
| 27520 | |
| 27521 | /* Copy D to X */ |
| 27522 | |
| 27523 | dcopy_cxx . . $ dcopy_(ec261fd7ec3b6bf6).(m, &d__[1], &c__1, &x[1], &c__1); |
| 27524 | } |
| 27525 | |
| 27526 | /* Backward transformation y = Z'*y */ |
| 27527 | |
| 27528 | /* Computing MAX */ |
| 27529 | i__1 = 1, i__2 = *n - *p + 1; |
| 27530 | i__3 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*p); |
| 27531 | i__4 = *lwork - *m - np; |
| 27532 | dormrq_cxx . . $ dormrq_(c6b7238dd97e9cf9).("Left", "Transpose", p, &c__1, &np, &b[stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1, i__2)+ b_dim1], |
| 27533 | ldb, &work[*m + 1], &y[1], &i__3, &work[*m + np + 1], &i__4, info); |
| 27534 | /* Computing MAX */ |
| 27535 | i__1 = lopt, i__2 = (integercxx . . $ integer#) work[*m + np + 1]; |
| 27536 | work[1] = (double) (*m + np + stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2)); |
| 27537 | |
| 27538 | return 0; |
| 27539 | |
| 27540 | /* End of DGGGLM */ |
| 27541 | |
| 27542 | } /* dggglm_ */ |
| 27543 | |
| 27544 | /* Subroutine */ int dgghrd_cxx . . $ dgghrd_(a37938716ecaec33).(const char *compq, const char *compz, integercxx . . $ integer# *n, integercxx . . $ integer# * |
| 27545 | ilo, integercxx . . $ integer# *ihi, double *a, integercxx . . $ integer# *lda, double *b, |
| 27546 | integercxx . . $ integer# *ldb, double *q, integercxx . . $ integer# *ldq, double *z__, integercxx . . $ integer# * |
| 27547 | ldz, integercxx . . $ integer# *info) |
| 27548 | { |
| 27549 | /* Table of constant values */ |
| 27550 | static double c_b10 = 0.; |
| 27551 | static double c_b11 = 1.; |
| 27552 | static integercxx . . $ integer# c__1 = 1; |
| 27553 | |
| 27554 | /* System generated locals */ |
| 27555 | integercxx . . $ integer# a_dim1, a_offset, b_dim1, b_offset, q_dim1, q_offset, z_dim1, |
| 27556 | z_offset, i__1, i__2, i__3; |
| 27557 | |
| 27558 | /* Local variables */ |
| 27559 | double c__, s; |
| 27560 | bool ilq, ilz; |
| 27561 | integercxx . . $ integer# jcol; |
| 27562 | double temp; |
| 27563 | integercxx . . $ integer# jrow; |
| 27564 | integercxx . . $ integer# icompq, icompz; |
| 27565 | |
| 27566 | |
| 27567 | /* -- LAPACK routine (version 3.1) -- */ |
| 27568 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 27569 | /* November 2006 */ |
| 27570 | |
| 27571 | /* .. Scalar Arguments .. */ |
| 27572 | /* .. */ |
| 27573 | /* .. Array Arguments .. */ |
| 27574 | /* .. */ |
| 27575 | |
| 27576 | /* Purpose */ |
| 27577 | /* ======= */ |
| 27578 | |
| 27579 | /* DGGHRD reduces a pair of real matrices (A,B) to generalized upper */ |
| 27580 | /* Hessenberg form using orthogonal transformations, where A is a */ |
| 27581 | /* general matrix and B is upper triangular. The form of the */ |
| 27582 | /* generalized eigenvalue problem is */ |
| 27583 | /* A*x = lambda*B*x, */ |
| 27584 | /* and B is typically made upper triangular by computing its QR */ |
| 27585 | /* factorization and moving the orthogonal matrix Q to the left side */ |
| 27586 | /* of the equation. */ |
| 27587 | |
| 27588 | /* This subroutine simultaneously reduces A to a Hessenberg matrix H: */ |
| 27589 | /* Q**T*A*Z = H */ |
| 27590 | /* and transforms B to another upper triangular matrix T: */ |
| 27591 | /* Q**T*B*Z = T */ |
| 27592 | /* in order to reduce the problem to its standard form */ |
| 27593 | /* H*y = lambda*T*y */ |
| 27594 | /* where y = Z**T*x. */ |
| 27595 | |
| 27596 | /* The orthogonal matrices Q and Z are determined as products of Givens */ |
| 27597 | /* rotations. They may either be formed explicitly, or they may be */ |
| 27598 | /* postmultiplied into input matrices Q1 and Z1, so that */ |
| 27599 | |
| 27600 | /* Q1 * A * Z1**T = (Q1*Q) * H * (Z1*Z)**T */ |
| 27601 | |
| 27602 | /* Q1 * B * Z1**T = (Q1*Q) * T * (Z1*Z)**T */ |
| 27603 | |
| 27604 | /* If Q1 is the orthogonal matrix from the QR factorization of B in the */ |
| 27605 | /* original equation A*x = lambda*B*x, then DGGHRD reduces the original */ |
| 27606 | /* problem to generalized Hessenberg form. */ |
| 27607 | |
| 27608 | /* Arguments */ |
| 27609 | /* ========= */ |
| 27610 | |
| 27611 | /* COMPQ (input) CHARACTER*1 */ |
| 27612 | /* = 'N': do not compute Q; */ |
| 27613 | /* = 'I': Q is initialized to the unit matrix, and the */ |
| 27614 | /* orthogonal matrix Q is returned; */ |
| 27615 | /* = 'V': Q must contain an orthogonal matrix Q1 on entry, */ |
| 27616 | /* and the product Q1*Q is returned. */ |
| 27617 | |
| 27618 | /* COMPZ (input) CHARACTER*1 */ |
| 27619 | /* = 'N': do not compute Z; */ |
| 27620 | /* = 'I': Z is initialized to the unit matrix, and the */ |
| 27621 | /* orthogonal matrix Z is returned; */ |
| 27622 | /* = 'V': Z must contain an orthogonal matrix Z1 on entry, */ |
| 27623 | /* and the product Z1*Z is returned. */ |
| 27624 | |
| 27625 | /* N (input) INTEGER */ |
| 27626 | /* The order of the matrices A and B. N >= 0. */ |
| 27627 | |
| 27628 | /* ILO (input) INTEGER */ |
| 27629 | /* IHI (input) INTEGER */ |
| 27630 | /* ILO and IHI mark the rows and columns of A which are to be */ |
| 27631 | /* reduced. It is assumed that A is already upper triangular */ |
| 27632 | /* in rows and columns 1:ILO-1 and IHI+1:N. ILO and IHI are */ |
| 27633 | /* normally set by a previous call to SGGBAL; otherwise they */ |
| 27634 | /* should be set to 1 and N respectively. */ |
| 27635 | /* 1 <= ILO <= IHI <= N, if N > 0; ILO=1 and IHI=0, if N=0. */ |
| 27636 | |
| 27637 | /* A (input/output) DOUBLE PRECISION array, dimension (LDA, N) */ |
| 27638 | /* On entry, the N-by-N general matrix to be reduced. */ |
| 27639 | /* On exit, the upper triangle and the first subdiagonal of A */ |
| 27640 | /* are overwritten with the upper Hessenberg matrix H, and the */ |
| 27641 | /* rest is set to zero. */ |
| 27642 | |
| 27643 | /* LDA (input) INTEGER */ |
| 27644 | /* The leading dimension of the array A. LDA >= max(1,N). */ |
| 27645 | |
| 27646 | /* B (input/output) DOUBLE PRECISION array, dimension (LDB, N) */ |
| 27647 | /* On entry, the N-by-N upper triangular matrix B. */ |
| 27648 | /* On exit, the upper triangular matrix T = Q**T B Z. The */ |
| 27649 | /* elements below the diagonal are set to zero. */ |
| 27650 | |
| 27651 | /* LDB (input) INTEGER */ |
| 27652 | /* The leading dimension of the array B. LDB >= max(1,N). */ |
| 27653 | |
| 27654 | /* Q (input/output) DOUBLE PRECISION array, dimension (LDQ, N) */ |
| 27655 | /* On entry, if COMPQ = 'V', the orthogonal matrix Q1, */ |
| 27656 | /* typically from the QR factorization of B. */ |
| 27657 | /* On exit, if COMPQ='I', the orthogonal matrix Q, and if */ |
| 27658 | /* COMPQ = 'V', the product Q1*Q. */ |
| 27659 | /* Not referenced if COMPQ='N'. */ |
| 27660 | |
| 27661 | /* LDQ (input) INTEGER */ |
| 27662 | /* The leading dimension of the array Q. */ |
| 27663 | /* LDQ >= N if COMPQ='V' or 'I'; LDQ >= 1 otherwise. */ |
| 27664 | |
| 27665 | /* Z (input/output) DOUBLE PRECISION array, dimension (LDZ, N) */ |
| 27666 | /* On entry, if COMPZ = 'V', the orthogonal matrix Z1. */ |
| 27667 | /* On exit, if COMPZ='I', the orthogonal matrix Z, and if */ |
| 27668 | /* COMPZ = 'V', the product Z1*Z. */ |
| 27669 | /* Not referenced if COMPZ='N'. */ |
| 27670 | |
| 27671 | /* LDZ (input) INTEGER */ |
| 27672 | /* The leading dimension of the array Z. */ |
| 27673 | /* LDZ >= N if COMPZ='V' or 'I'; LDZ >= 1 otherwise. */ |
| 27674 | |
| 27675 | /* INFO (output) INTEGER */ |
| 27676 | /* = 0: successful exit. */ |
| 27677 | /* < 0: if INFO = -i, the i-th argument had an illegal value. */ |
| 27678 | |
| 27679 | /* Further Details */ |
| 27680 | /* =============== */ |
| 27681 | |
| 27682 | /* This routine reduces A to Hessenberg and B to triangular form by */ |
| 27683 | /* an unblocked reduction, as described in _Matrix_Computations_, */ |
| 27684 | /* by Golub and Van Loan (Johns Hopkins Press.) */ |
| 27685 | |
| 27686 | /* ===================================================================== */ |
| 27687 | |
| 27688 | /* .. Parameters .. */ |
| 27689 | /* .. */ |
| 27690 | /* .. Local Scalars .. */ |
| 27691 | /* .. */ |
| 27692 | /* .. External Functions .. */ |
| 27693 | /* .. */ |
| 27694 | /* .. External Subroutines .. */ |
| 27695 | /* .. */ |
| 27696 | /* .. Intrinsic Functions .. */ |
| 27697 | /* .. */ |
| 27698 | /* .. Executable Statements .. */ |
| 27699 | |
| 27700 | /* Decode COMPQ */ |
| 27701 | |
| 27702 | /* Parameter adjustments */ |
| 27703 | a_dim1 = *lda; |
| 27704 | a_offset = 1 + a_dim1; |
| 27705 | a -= a_offset; |
| 27706 | b_dim1 = *ldb; |
| 27707 | b_offset = 1 + b_dim1; |
| 27708 | b -= b_offset; |
| 27709 | q_dim1 = *ldq; |
| 27710 | q_offset = 1 + q_dim1; |
| 27711 | q -= q_offset; |
| 27712 | z_dim1 = *ldz; |
| 27713 | z_offset = 1 + z_dim1; |
| 27714 | z__ -= z_offset; |
| 27715 | |
| 27716 | /* Function Body */ |
| 27717 | if (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(compq, "N")) { |
| 27718 | ilq = false; |
| 27719 | icompq = 1; |
| 27720 | } else if (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(compq, "V")) { |
| 27721 | ilq = true; |
| 27722 | icompq = 2; |
| 27723 | } else if (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(compq, "I")) { |
| 27724 | ilq = true; |
| 27725 | icompq = 3; |
| 27726 | } else { |
| 27727 | icompq = 0; |
| 27728 | } |
| 27729 | |
| 27730 | /* Decode COMPZ */ |
| 27731 | |
| 27732 | if (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(compz, "N")) { |
| 27733 | ilz = false; |
| 27734 | icompz = 1; |
| 27735 | } else if (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(compz, "V")) { |
| 27736 | ilz = true; |
| 27737 | icompz = 2; |
| 27738 | } else if (lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(compz, "I")) { |
| 27739 | ilz = true; |
| 27740 | icompz = 3; |
| 27741 | } else { |
| 27742 | icompz = 0; |
| 27743 | } |
| 27744 | |
| 27745 | /* Test the input parameters. */ |
| 27746 | |
| 27747 | *info = 0; |
| 27748 | if (icompq <= 0) { |
| 27749 | *info = -1; |
| 27750 | } else if (icompz <= 0) { |
| 27751 | *info = -2; |
| 27752 | } else if (*n < 0) { |
| 27753 | *info = -3; |
| 27754 | } else if (*ilo < 1) { |
| 27755 | *info = -4; |
| 27756 | } else if (*ihi > *n || *ihi < *ilo - 1) { |
| 27757 | *info = -5; |
| 27758 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 27759 | *info = -7; |
| 27760 | } else if (*ldb < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 27761 | *info = -9; |
| 27762 | } else if (ilq && *ldq < *n || *ldq < 1) { |
| 27763 | *info = -11; |
| 27764 | } else if (ilz && *ldz < *n || *ldz < 1) { |
| 27765 | *info = -13; |
| 27766 | } |
| 27767 | if (*info != 0) { |
| 27768 | i__1 = -(*info); |
| 27769 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGGHRD", &i__1); |
| 27770 | return 0; |
| 27771 | } |
| 27772 | |
| 27773 | /* Initialize Q and Z if desired. */ |
| 27774 | |
| 27775 | if (icompq == 3) { |
| 27776 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("Full", n, n, &c_b10, &c_b11, &q[q_offset], ldq); |
| 27777 | } |
| 27778 | if (icompz == 3) { |
| 27779 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("Full", n, n, &c_b10, &c_b11, &z__[z_offset], ldz); |
| 27780 | } |
| 27781 | |
| 27782 | /* Quick return if possible */ |
| 27783 | |
| 27784 | if (*n <= 1) { |
| 27785 | return 0; |
| 27786 | } |
| 27787 | |
| 27788 | /* Zero out lower triangle of B */ |
| 27789 | |
| 27790 | i__1 = *n - 1; |
| 27791 | for (jcol = 1; jcol <= i__1; ++jcol) { |
| 27792 | i__2 = *n; |
| 27793 | for (jrow = jcol + 1; jrow <= i__2; ++jrow) { |
| 27794 | b[jrow + jcol * b_dim1] = 0.; |
| 27795 | /* L10: */ |
| 27796 | } |
| 27797 | /* L20: */ |
| 27798 | } |
| 27799 | |
| 27800 | /* Reduce A and B */ |
| 27801 | |
| 27802 | i__1 = *ihi - 2; |
| 27803 | for (jcol = *ilo; jcol <= i__1; ++jcol) { |
| 27804 | |
| 27805 | i__2 = jcol + 2; |
| 27806 | for (jrow = *ihi; jrow >= i__2; --jrow) { |
| 27807 | |
| 27808 | /* Step 1: rotate rows JROW-1, JROW to kill A(JROW,JCOL) */ |
| 27809 | |
| 27810 | temp = a[jrow - 1 + jcol * a_dim1]; |
| 27811 | dlartg_cxx . . $ dlartg_(f2b979bf0498d687).(&temp, &a[jrow + jcol * a_dim1], &c__, &s, &a[jrow - 1 + |
| 27812 | jcol * a_dim1]); |
| 27813 | a[jrow + jcol * a_dim1] = 0.; |
| 27814 | i__3 = *n - jcol; |
| 27815 | drot_cxx . . $ drot_(31e32f39c16a90e0).(&i__3, &a[jrow - 1 + (jcol + 1) * a_dim1], lda, &a[jrow + ( |
| 27816 | jcol + 1) * a_dim1], lda, &c__, &s); |
| 27817 | i__3 = *n + 2 - jrow; |
| 27818 | drot_cxx . . $ drot_(31e32f39c16a90e0).(&i__3, &b[jrow - 1 + (jrow - 1) * b_dim1], ldb, &b[jrow + ( |
| 27819 | jrow - 1) * b_dim1], ldb, &c__, &s); |
| 27820 | if (ilq) { |
| 27821 | drot_cxx . . $ drot_(31e32f39c16a90e0).(n, &q[(jrow - 1) * q_dim1 + 1], &c__1, &q[jrow * q_dim1 |
| 27822 | + 1], &c__1, &c__, &s); |
| 27823 | } |
| 27824 | |
| 27825 | /* Step 2: rotate columns JROW, JROW-1 to kill B(JROW,JROW-1) */ |
| 27826 | |
| 27827 | temp = b[jrow + jrow * b_dim1]; |
| 27828 | dlartg_cxx . . $ dlartg_(f2b979bf0498d687).(&temp, &b[jrow + (jrow - 1) * b_dim1], &c__, &s, &b[jrow |
| 27829 | + jrow * b_dim1]); |
| 27830 | b[jrow + (jrow - 1) * b_dim1] = 0.; |
| 27831 | drot_cxx . . $ drot_(31e32f39c16a90e0).(ihi, &a[jrow * a_dim1 + 1], &c__1, &a[(jrow - 1) * a_dim1 + |
| 27832 | 1], &c__1, &c__, &s); |
| 27833 | i__3 = jrow - 1; |
| 27834 | drot_cxx . . $ drot_(31e32f39c16a90e0).(&i__3, &b[jrow * b_dim1 + 1], &c__1, &b[(jrow - 1) * b_dim1 |
| 27835 | + 1], &c__1, &c__, &s); |
| 27836 | if (ilz) { |
| 27837 | drot_cxx . . $ drot_(31e32f39c16a90e0).(n, &z__[jrow * z_dim1 + 1], &c__1, &z__[(jrow - 1) * |
| 27838 | z_dim1 + 1], &c__1, &c__, &s); |
| 27839 | } |
| 27840 | /* L30: */ |
| 27841 | } |
| 27842 | /* L40: */ |
| 27843 | } |
| 27844 | |
| 27845 | return 0; |
| 27846 | |
| 27847 | /* End of DGGHRD */ |
| 27848 | |
| 27849 | } /* dgghrd_ */ |
| 27850 | |
| 27851 | /* Subroutine */ int dgglse_cxx . . $ dgglse_(3edc0d77b0e5c5a).(integercxx . . $ integer# *m, integercxx . . $ integer# *n, integercxx . . $ integer# *p, double * |
| 27852 | a, integercxx . . $ integer# *lda, double *b, integercxx . . $ integer# *ldb, double *c__, |
| 27853 | double *d__, double *x, double *work, integercxx . . $ integer# *lwork, |
| 27854 | integercxx . . $ integer# *info) |
| 27855 | { |
| 27856 | /* Table of constant values */ |
| 27857 | static integercxx . . $ integer# c__1 = 1; |
| 27858 | static integercxx . . $ integer# c_n1 = -1; |
| 27859 | static double c_b31 = -1.; |
| 27860 | static double c_b33 = 1.; |
| 27861 | |
| 27862 | /* System generated locals */ |
| 27863 | integercxx . . $ integer# a_dim1, a_offset, b_dim1, b_offset, i__1, i__2; |
| 27864 | |
| 27865 | /* Local variables */ |
| 27866 | integercxx . . $ integer# nb, mn, nr, nb1, nb2, nb3, nb4, lopt; |
| 27867 | integercxx . . $ integer# lwkmin; |
| 27868 | integercxx . . $ integer# lwkopt; |
| 27869 | bool lquery; |
| 27870 | |
| 27871 | |
| 27872 | /* -- LAPACK driver routine (version 3.1) -- */ |
| 27873 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 27874 | /* November 2006 */ |
| 27875 | |
| 27876 | /* .. Scalar Arguments .. */ |
| 27877 | /* .. */ |
| 27878 | /* .. Array Arguments .. */ |
| 27879 | /* .. */ |
| 27880 | |
| 27881 | /* Purpose */ |
| 27882 | /* ======= */ |
| 27883 | |
| 27884 | /* DGGLSE solves the linear equality-constrained least squares (LSE) */ |
| 27885 | /* problem: */ |
| 27886 | |
| 27887 | /* minimize || c - A*x ||_2 subject to B*x = d */ |
| 27888 | |
| 27889 | /* where A is an M-by-N matrix, B is a P-by-N matrix, c is a given */ |
| 27890 | /* M-vector, and d is a given P-vector. It is assumed that */ |
| 27891 | /* P <= N <= M+P, and */ |
| 27892 | |
| 27893 | /* rank(B) = P and rank( (A) ) = N. */ |
| 27894 | /* ( (B) ) */ |
| 27895 | |
| 27896 | /* These conditions ensure that the LSE problem has a unique solution, */ |
| 27897 | /* which is obtained using a generalized RQ factorization of the */ |
| 27898 | /* matrices (B, A) given by */ |
| 27899 | |
| 27900 | /* B = (0 R)*Q, A = Z*T*Q. */ |
| 27901 | |
| 27902 | /* Arguments */ |
| 27903 | /* ========= */ |
| 27904 | |
| 27905 | /* M (input) INTEGER */ |
| 27906 | /* The number of rows of the matrix A. M >= 0. */ |
| 27907 | |
| 27908 | /* N (input) INTEGER */ |
| 27909 | /* The number of columns of the matrices A and B. N >= 0. */ |
| 27910 | |
| 27911 | /* P (input) INTEGER */ |
| 27912 | /* The number of rows of the matrix B. 0 <= P <= N <= M+P. */ |
| 27913 | |
| 27914 | /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 27915 | /* On entry, the M-by-N matrix A. */ |
| 27916 | /* On exit, the elements on and above the diagonal of the array */ |
| 27917 | /* contain the min(M,N)-by-N upper trapezoidal matrix T. */ |
| 27918 | |
| 27919 | /* LDA (input) INTEGER */ |
| 27920 | /* The leading dimension of the array A. LDA >= max(1,M). */ |
| 27921 | |
| 27922 | /* B (input/output) DOUBLE PRECISION array, dimension (LDB,N) */ |
| 27923 | /* On entry, the P-by-N matrix B. */ |
| 27924 | /* On exit, the upper triangle of the subarray B(1:P,N-P+1:N) */ |
| 27925 | /* contains the P-by-P upper triangular matrix R. */ |
| 27926 | |
| 27927 | /* LDB (input) INTEGER */ |
| 27928 | /* The leading dimension of the array B. LDB >= max(1,P). */ |
| 27929 | |
| 27930 | /* C (input/output) DOUBLE PRECISION array, dimension (M) */ |
| 27931 | /* On entry, C contains the right hand side vector for the */ |
| 27932 | /* least squares part of the LSE problem. */ |
| 27933 | /* On exit, the residual sum of squares for the solution */ |
| 27934 | /* is given by the sum of squares of elements N-P+1 to M of */ |
| 27935 | /* vector C. */ |
| 27936 | |
| 27937 | /* D (input/output) DOUBLE PRECISION array, dimension (P) */ |
| 27938 | /* On entry, D contains the right hand side vector for the */ |
| 27939 | /* constrained equation. */ |
| 27940 | /* On exit, D is destroyed. */ |
| 27941 | |
| 27942 | /* X (output) DOUBLE PRECISION array, dimension (N) */ |
| 27943 | /* On exit, X is the solution of the LSE problem. */ |
| 27944 | |
| 27945 | /* WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) */ |
| 27946 | /* On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ |
| 27947 | |
| 27948 | /* LWORK (input) INTEGER */ |
| 27949 | /* The dimension of the array WORK. LWORK >= max(1,M+N+P). */ |
| 27950 | /* For optimum performance LWORK >= P+min(M,N)+max(M,N)*NB, */ |
| 27951 | /* where NB is an upper bound for the optimal blocksizes for */ |
| 27952 | /* DGEQRF, SGERQF, DORMQR and SORMRQ. */ |
| 27953 | |
| 27954 | /* If LWORK = -1, then a workspace query is assumed; the routine */ |
| 27955 | /* only calculates the optimal size of the WORK array, returns */ |
| 27956 | /* this value as the first entry of the WORK array, and no error */ |
| 27957 | /* message related to LWORK is issued by XERBLA. */ |
| 27958 | |
| 27959 | /* INFO (output) INTEGER */ |
| 27960 | /* = 0: successful exit. */ |
| 27961 | /* < 0: if INFO = -i, the i-th argument had an illegal value. */ |
| 27962 | /* = 1: the upper triangular factor R associated with B in the */ |
| 27963 | /* generalized RQ factorization of the pair (B, A) is */ |
| 27964 | /* singular, so that rank(B) < P; the least squares */ |
| 27965 | /* solution could not be computed. */ |
| 27966 | /* = 2: the (N-P) by (N-P) part of the upper trapezoidal factor */ |
| 27967 | /* T associated with A in the generalized RQ factorization */ |
| 27968 | /* of the pair (B, A) is singular, so that */ |
| 27969 | /* rank( (A) ) < N; the least squares solution could not */ |
| 27970 | /* ( (B) ) */ |
| 27971 | /* be computed. */ |
| 27972 | |
| 27973 | /* ===================================================================== */ |
| 27974 | |
| 27975 | /* .. Parameters .. */ |
| 27976 | /* .. */ |
| 27977 | /* .. Local Scalars .. */ |
| 27978 | /* .. */ |
| 27979 | /* .. External Subroutines .. */ |
| 27980 | /* .. */ |
| 27981 | /* .. External Functions .. */ |
| 27982 | /* .. */ |
| 27983 | /* .. Intrinsic Functions .. */ |
| 27984 | /* .. */ |
| 27985 | /* .. Executable Statements .. */ |
| 27986 | |
| 27987 | /* Test the input parameters */ |
| 27988 | |
| 27989 | /* Parameter adjustments */ |
| 27990 | a_dim1 = *lda; |
| 27991 | a_offset = 1 + a_dim1; |
| 27992 | a -= a_offset; |
| 27993 | b_dim1 = *ldb; |
| 27994 | b_offset = 1 + b_dim1; |
| 27995 | b -= b_offset; |
| 27996 | --c__; |
| 27997 | --d__; |
| 27998 | --x; |
| 27999 | --work; |
| 28000 | |
| 28001 | /* Function Body */ |
| 28002 | *info = 0; |
| 28003 | mn = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(*m,*n); |
| 28004 | lquery = *lwork == -1; |
| 28005 | if (*m < 0) { |
| 28006 | *info = -1; |
| 28007 | } else if (*n < 0) { |
| 28008 | *info = -2; |
| 28009 | } else if (*p < 0 || *p > *n || *p < *n - *m) { |
| 28010 | *info = -3; |
| 28011 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*m)) { |
| 28012 | *info = -5; |
| 28013 | } else if (*ldb < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*p)) { |
| 28014 | *info = -7; |
| 28015 | } |
| 28016 | |
| 28017 | /* Calculate workspace */ |
| 28018 | |
| 28019 | if (*info == 0) { |
| 28020 | if (*n == 0) { |
| 28021 | lwkmin = 1; |
| 28022 | lwkopt = 1; |
| 28023 | } else { |
| 28024 | nb1 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEQRF", " ", m, n, &c_n1, &c_n1); |
| 28025 | nb2 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGERQF", " ", m, n, &c_n1, &c_n1); |
| 28026 | nb3 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMQR", " ", m, n, p, &c_n1); |
| 28027 | nb4 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMRQ", " ", m, n, p, &c_n1); |
| 28028 | /* Computing MAX */ |
| 28029 | i__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(nb1,nb2), i__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,nb3); |
| 28030 | nb = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,nb4); |
| 28031 | lwkmin = *m + *n + *p; |
| 28032 | lwkopt = *p + mn + stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(*m,*n) * nb; |
| 28033 | } |
| 28034 | work[1] = (double) lwkopt; |
| 28035 | |
| 28036 | if (*lwork < lwkmin && ! lquery) { |
| 28037 | *info = -12; |
| 28038 | } |
| 28039 | } |
| 28040 | |
| 28041 | if (*info != 0) { |
| 28042 | i__1 = -(*info); |
| 28043 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGGLSE", &i__1); |
| 28044 | return 0; |
| 28045 | } else if (lquery) { |
| 28046 | return 0; |
| 28047 | } |
| 28048 | |
| 28049 | /* Quick return if possible */ |
| 28050 | |
| 28051 | if (*n == 0) { |
| 28052 | return 0; |
| 28053 | } |
| 28054 | |
| 28055 | /* Compute the GRQ factorization of matrices B and A: */ |
| 28056 | |
| 28057 | /* B*Q' = ( 0 T12 ) P Z'*A*Q' = ( R11 R12 ) N-P */ |
| 28058 | /* N-P P ( 0 R22 ) M+P-N */ |
| 28059 | /* N-P P */ |
| 28060 | |
| 28061 | /* where T12 and R11 are upper triangular, and Q and Z are */ |
| 28062 | /* orthogonal. */ |
| 28063 | |
| 28064 | i__1 = *lwork - *p - mn; |
| 28065 | dggrqf_cxx . . $ dggrqf_(c951bae2f1e49e56).(p, m, n, &b[b_offset], ldb, &work[1], &a[a_offset], lda, &work[*p |
| 28066 | + 1], &work[*p + mn + 1], &i__1, info); |
| 28067 | lopt = (integercxx . . $ integer#) work[*p + mn + 1]; |
| 28068 | |
| 28069 | /* Update c = Z'*c = ( c1 ) N-P */ |
| 28070 | /* ( c2 ) M+P-N */ |
| 28071 | |
| 28072 | i__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*m); |
| 28073 | i__2 = *lwork - *p - mn; |
| 28074 | dormqr_cxx . . $ dormqr_(c6b7238dd97e9cf9).("Left", "Transpose", m, &c__1, &mn, &a[a_offset], lda, &work[*p + |
| 28075 | 1], &c__[1], &i__1, &work[*p + mn + 1], &i__2, info); |
| 28076 | /* Computing MAX */ |
| 28077 | i__1 = lopt, i__2 = (integercxx . . $ integer#) work[*p + mn + 1]; |
| 28078 | lopt = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 28079 | |
| 28080 | /* Solve T12*x2 = d for x2 */ |
| 28081 | |
| 28082 | if (*p > 0) { |
| 28083 | dtrtrs_cxx . . $ dtrtrs_(dee8bd198981a606).("Upper", "No transpose", "Non-unit", p, &c__1, &b[(*n - *p + |
| 28084 | 1) * b_dim1 + 1], ldb, &d__[1], p, info); |
| 28085 | |
| 28086 | if (*info > 0) { |
| 28087 | *info = 1; |
| 28088 | return 0; |
| 28089 | } |
| 28090 | |
| 28091 | /* Put the solution in X */ |
| 28092 | |
| 28093 | dcopy_cxx . . $ dcopy_(ec261fd7ec3b6bf6).(p, &d__[1], &c__1, &x[*n - *p + 1], &c__1); |
| 28094 | |
| 28095 | /* Update c1 */ |
| 28096 | |
| 28097 | i__1 = *n - *p; |
| 28098 | dgemv_cxx . . $ dgemv_(828a5131add94649).("No transpose", &i__1, p, &c_b31, &a[(*n - *p + 1) * a_dim1 + |
| 28099 | 1], lda, &d__[1], &c__1, &c_b33, &c__[1], &c__1); |
| 28100 | } |
| 28101 | |
| 28102 | /* Solve R11*x1 = c1 for x1 */ |
| 28103 | |
| 28104 | if (*n > *p) { |
| 28105 | i__1 = *n - *p; |
| 28106 | i__2 = *n - *p; |
| 28107 | dtrtrs_cxx . . $ dtrtrs_(dee8bd198981a606).("Upper", "No transpose", "Non-unit", &i__1, &c__1, &a[ |
| 28108 | a_offset], lda, &c__[1], &i__2, info); |
| 28109 | |
| 28110 | if (*info > 0) { |
| 28111 | *info = 2; |
| 28112 | return 0; |
| 28113 | } |
| 28114 | |
| 28115 | /* Put the solutions in X */ |
| 28116 | |
| 28117 | i__1 = *n - *p; |
| 28118 | dcopy_cxx . . $ dcopy_(ec261fd7ec3b6bf6).(&i__1, &c__[1], &c__1, &x[1], &c__1); |
| 28119 | } |
| 28120 | |
| 28121 | /* Compute the residual vector: */ |
| 28122 | |
| 28123 | if (*m < *n) { |
| 28124 | nr = *m + *p - *n; |
| 28125 | if (nr > 0) { |
| 28126 | i__1 = *n - *m; |
| 28127 | dgemv_cxx . . $ dgemv_(828a5131add94649).("No transpose", &nr, &i__1, &c_b31, &a[*n - *p + 1 + (*m + |
| 28128 | 1) * a_dim1], lda, &d__[nr + 1], &c__1, &c_b33, &c__[*n - |
| 28129 | *p + 1], &c__1); |
| 28130 | } |
| 28131 | } else { |
| 28132 | nr = *p; |
| 28133 | } |
| 28134 | if (nr > 0) { |
| 28135 | dtrmv_cxx . . $ dtrmv_(661194494df2e3e5).("Upper", "No transpose", "Non unit", &nr, &a[*n - *p + 1 + (*n |
| 28136 | - *p + 1) * a_dim1], lda, &d__[1], &c__1); |
| 28137 | daxpy_cxx . . $ daxpy_(4b39f621356f7e14).(&nr, &c_b31, &d__[1], &c__1, &c__[*n - *p + 1], &c__1); |
| 28138 | } |
| 28139 | |
| 28140 | /* Backward transformation x = Q'*x */ |
| 28141 | |
| 28142 | i__1 = *lwork - *p - mn; |
| 28143 | dormrq_cxx . . $ dormrq_(c6b7238dd97e9cf9).("Left", "Transpose", n, &c__1, p, &b[b_offset], ldb, &work[1], &x[ |
| 28144 | 1], n, &work[*p + mn + 1], &i__1, info); |
| 28145 | /* Computing MAX */ |
| 28146 | i__1 = lopt, i__2 = (integercxx . . $ integer#) work[*p + mn + 1]; |
| 28147 | work[1] = (double) (*p + mn + stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2)); |
| 28148 | |
| 28149 | return 0; |
| 28150 | |
| 28151 | /* End of DGGLSE */ |
| 28152 | |
| 28153 | } /* dgglse_ */ |
| 28154 | |
| 28155 | /* Subroutine */ int dggqrf_cxx . . $ dggqrf_(c951bae2f1e49e56).(integercxx . . $ integer# *n, integercxx . . $ integer# *m, integercxx . . $ integer# *p, double * |
| 28156 | a, integercxx . . $ integer# *lda, double *taua, double *b, integercxx . . $ integer# *ldb, |
| 28157 | double *taub, double *work, integercxx . . $ integer# *lwork, integercxx . . $ integer# *info) |
| 28158 | { |
| 28159 | /* Table of constant values */ |
| 28160 | static integercxx . . $ integer# c__1 = 1; |
| 28161 | static integercxx . . $ integer# c_n1 = -1; |
| 28162 | |
| 28163 | /* System generated locals */ |
| 28164 | integercxx . . $ integer# a_dim1, a_offset, b_dim1, b_offset, i__1, i__2; |
| 28165 | |
| 28166 | /* Local variables */ |
| 28167 | integercxx . . $ integer# nb, nb1, nb2, nb3, lopt; |
| 28168 | integercxx . . $ integer# lwkopt; |
| 28169 | bool lquery; |
| 28170 | |
| 28171 | |
| 28172 | /* -- LAPACK routine (version 3.1) -- */ |
| 28173 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 28174 | /* November 2006 */ |
| 28175 | |
| 28176 | /* .. Scalar Arguments .. */ |
| 28177 | /* .. */ |
| 28178 | /* .. Array Arguments .. */ |
| 28179 | /* .. */ |
| 28180 | |
| 28181 | /* Purpose */ |
| 28182 | /* ======= */ |
| 28183 | |
| 28184 | /* DGGQRF computes a generalized QR factorization of an N-by-M matrix A */ |
| 28185 | /* and an N-by-P matrix B: */ |
| 28186 | |
| 28187 | /* A = Q*R, B = Q*T*Z, */ |
| 28188 | |
| 28189 | /* where Q is an N-by-N orthogonal matrix, Z is a P-by-P orthogonal */ |
| 28190 | /* matrix, and R and T assume one of the forms: */ |
| 28191 | |
| 28192 | /* if N >= M, R = ( R11 ) M , or if N < M, R = ( R11 R12 ) N, */ |
| 28193 | /* ( 0 ) N-M N M-N */ |
| 28194 | /* M */ |
| 28195 | |
| 28196 | /* where R11 is upper triangular, and */ |
| 28197 | |
| 28198 | /* if N <= P, T = ( 0 T12 ) N, or if N > P, T = ( T11 ) N-P, */ |
| 28199 | /* P-N N ( T21 ) P */ |
| 28200 | /* P */ |
| 28201 | |
| 28202 | /* where T12 or T21 is upper triangular. */ |
| 28203 | |
| 28204 | /* In particular, if B is square and nonsingular, the GQR factorization */ |
| 28205 | /* of A and B implicitly gives the QR factorization of inv(B)*A: */ |
| 28206 | |
| 28207 | /* inv(B)*A = Z'*(inv(T)*R) */ |
| 28208 | |
| 28209 | /* where inv(B) denotes the inverse of the matrix B, and Z' denotes the */ |
| 28210 | /* transpose of the matrix Z. */ |
| 28211 | |
| 28212 | /* Arguments */ |
| 28213 | /* ========= */ |
| 28214 | |
| 28215 | /* N (input) INTEGER */ |
| 28216 | /* The number of rows of the matrices A and B. N >= 0. */ |
| 28217 | |
| 28218 | /* M (input) INTEGER */ |
| 28219 | /* The number of columns of the matrix A. M >= 0. */ |
| 28220 | |
| 28221 | /* P (input) INTEGER */ |
| 28222 | /* The number of columns of the matrix B. P >= 0. */ |
| 28223 | |
| 28224 | /* A (input/output) DOUBLE PRECISION array, dimension (LDA,M) */ |
| 28225 | /* On entry, the N-by-M matrix A. */ |
| 28226 | /* On exit, the elements on and above the diagonal of the array */ |
| 28227 | /* contain the min(N,M)-by-M upper trapezoidal matrix R (R is */ |
| 28228 | /* upper triangular if N >= M); the elements below the diagonal, */ |
| 28229 | /* with the array TAUA, represent the orthogonal matrix Q as a */ |
| 28230 | /* product of min(N,M) elementary reflectors (see Further */ |
| 28231 | /* Details). */ |
| 28232 | |
| 28233 | /* LDA (input) INTEGER */ |
| 28234 | /* The leading dimension of the array A. LDA >= max(1,N). */ |
| 28235 | |
| 28236 | /* TAUA (output) DOUBLE PRECISION array, dimension (min(N,M)) */ |
| 28237 | /* The scalar factors of the elementary reflectors which */ |
| 28238 | /* represent the orthogonal matrix Q (see Further Details). */ |
| 28239 | |
| 28240 | /* B (input/output) DOUBLE PRECISION array, dimension (LDB,P) */ |
| 28241 | /* On entry, the N-by-P matrix B. */ |
| 28242 | /* On exit, if N <= P, the upper triangle of the subarray */ |
| 28243 | /* B(1:N,P-N+1:P) contains the N-by-N upper triangular matrix T; */ |
| 28244 | /* if N > P, the elements on and above the (N-P)-th subdiagonal */ |
| 28245 | /* contain the N-by-P upper trapezoidal matrix T; the remaining */ |
| 28246 | /* elements, with the array TAUB, represent the orthogonal */ |
| 28247 | /* matrix Z as a product of elementary reflectors (see Further */ |
| 28248 | /* Details). */ |
| 28249 | |
| 28250 | /* LDB (input) INTEGER */ |
| 28251 | /* The leading dimension of the array B. LDB >= max(1,N). */ |
| 28252 | |
| 28253 | /* TAUB (output) DOUBLE PRECISION array, dimension (min(N,P)) */ |
| 28254 | /* The scalar factors of the elementary reflectors which */ |
| 28255 | /* represent the orthogonal matrix Z (see Further Details). */ |
| 28256 | |
| 28257 | /* WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) */ |
| 28258 | /* On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ |
| 28259 | |
| 28260 | /* LWORK (input) INTEGER */ |
| 28261 | /* The dimension of the array WORK. LWORK >= max(1,N,M,P). */ |
| 28262 | /* For optimum performance LWORK >= max(N,M,P)*max(NB1,NB2,NB3), */ |
| 28263 | /* where NB1 is the optimal blocksize for the QR factorization */ |
| 28264 | /* of an N-by-M matrix, NB2 is the optimal blocksize for the */ |
| 28265 | /* RQ factorization of an N-by-P matrix, and NB3 is the optimal */ |
| 28266 | /* blocksize for a call of DORMQR. */ |
| 28267 | |
| 28268 | /* If LWORK = -1, then a workspace query is assumed; the routine */ |
| 28269 | /* only calculates the optimal size of the WORK array, returns */ |
| 28270 | /* this value as the first entry of the WORK array, and no error */ |
| 28271 | /* message related to LWORK is issued by XERBLA. */ |
| 28272 | |
| 28273 | /* INFO (output) INTEGER */ |
| 28274 | /* = 0: successful exit */ |
| 28275 | /* < 0: if INFO = -i, the i-th argument had an illegal value. */ |
| 28276 | |
| 28277 | /* Further Details */ |
| 28278 | /* =============== */ |
| 28279 | |
| 28280 | /* The matrix Q is represented as a product of elementary reflectors */ |
| 28281 | |
| 28282 | /* Q = H(1) H(2) . . . H(k), where k = min(n,m). */ |
| 28283 | |
| 28284 | /* Each H(i) has the form */ |
| 28285 | |
| 28286 | /* H(i) = I - taua * v * v' */ |
| 28287 | |
| 28288 | /* where taua is a real scalar, and v is a real vector with */ |
| 28289 | /* v(1:i-1) = 0 and v(i) = 1; v(i+1:n) is stored on exit in A(i+1:n,i), */ |
| 28290 | /* and taua in TAUA(i). */ |
| 28291 | /* To form Q explicitly, use LAPACK subroutine DORGQR. */ |
| 28292 | /* To use Q to update another matrix, use LAPACK subroutine DORMQR. */ |
| 28293 | |
| 28294 | /* The matrix Z is represented as a product of elementary reflectors */ |
| 28295 | |
| 28296 | /* Z = H(1) H(2) . . . H(k), where k = min(n,p). */ |
| 28297 | |
| 28298 | /* Each H(i) has the form */ |
| 28299 | |
| 28300 | /* H(i) = I - taub * v * v' */ |
| 28301 | |
| 28302 | /* where taub is a real scalar, and v is a real vector with */ |
| 28303 | /* v(p-k+i+1:p) = 0 and v(p-k+i) = 1; v(1:p-k+i-1) is stored on exit in */ |
| 28304 | /* B(n-k+i,1:p-k+i-1), and taub in TAUB(i). */ |
| 28305 | /* To form Z explicitly, use LAPACK subroutine DORGRQ. */ |
| 28306 | /* To use Z to update another matrix, use LAPACK subroutine DORMRQ. */ |
| 28307 | |
| 28308 | /* ===================================================================== */ |
| 28309 | |
| 28310 | /* .. Local Scalars .. */ |
| 28311 | /* .. */ |
| 28312 | /* .. External Subroutines .. */ |
| 28313 | /* .. */ |
| 28314 | /* .. External Functions .. */ |
| 28315 | /* .. */ |
| 28316 | /* .. Intrinsic Functions .. */ |
| 28317 | /* .. */ |
| 28318 | /* .. Executable Statements .. */ |
| 28319 | |
| 28320 | /* Test the input parameters */ |
| 28321 | |
| 28322 | /* Parameter adjustments */ |
| 28323 | a_dim1 = *lda; |
| 28324 | a_offset = 1 + a_dim1; |
| 28325 | a -= a_offset; |
| 28326 | --taua; |
| 28327 | b_dim1 = *ldb; |
| 28328 | b_offset = 1 + b_dim1; |
| 28329 | b -= b_offset; |
| 28330 | --taub; |
| 28331 | --work; |
| 28332 | |
| 28333 | /* Function Body */ |
| 28334 | *info = 0; |
| 28335 | nb1 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEQRF", " ", n, m, &c_n1, &c_n1); |
| 28336 | nb2 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGERQF", " ", n, p, &c_n1, &c_n1); |
| 28337 | nb3 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMQR", " ", n, m, p, &c_n1); |
| 28338 | /* Computing MAX */ |
| 28339 | i__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(nb1,nb2); |
| 28340 | nb = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,nb3); |
| 28341 | /* Computing MAX */ |
| 28342 | i__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(*n,*m); |
| 28343 | lwkopt = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,*p) * nb; |
| 28344 | work[1] = (double) lwkopt; |
| 28345 | lquery = *lwork == -1; |
| 28346 | if (*n < 0) { |
| 28347 | *info = -1; |
| 28348 | } else if (*m < 0) { |
| 28349 | *info = -2; |
| 28350 | } else if (*p < 0) { |
| 28351 | *info = -3; |
| 28352 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 28353 | *info = -5; |
| 28354 | } else if (*ldb < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 28355 | *info = -8; |
| 28356 | } else /* if(complicated condition) */ { |
| 28357 | /* Computing MAX */ |
| 28358 | i__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n), i__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,*m); |
| 28359 | if (*lwork < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,*p) && ! lquery) { |
| 28360 | *info = -11; |
| 28361 | } |
| 28362 | } |
| 28363 | if (*info != 0) { |
| 28364 | i__1 = -(*info); |
| 28365 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGGQRF", &i__1); |
| 28366 | return 0; |
| 28367 | } else if (lquery) { |
| 28368 | return 0; |
| 28369 | } |
| 28370 | |
| 28371 | /* QR factorization of N-by-M matrix A: A = Q*R */ |
| 28372 | |
| 28373 | dgeqrf_cxx . . $ dgeqrf_(b2aaa174babf002e).(n, m, &a[a_offset], lda, &taua[1], &work[1], lwork, info); |
| 28374 | lopt = (integercxx . . $ integer#) work[1]; |
| 28375 | |
| 28376 | /* Update B := Q'*B. */ |
| 28377 | |
| 28378 | i__1 = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(*n,*m); |
| 28379 | dormqr_cxx . . $ dormqr_(c6b7238dd97e9cf9).("Left", "Transpose", n, p, &i__1, &a[a_offset], lda, &taua[1], &b[ |
| 28380 | b_offset], ldb, &work[1], lwork, info); |
| 28381 | /* Computing MAX */ |
| 28382 | i__1 = lopt, i__2 = (integercxx . . $ integer#) work[1]; |
| 28383 | lopt = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 28384 | |
| 28385 | /* RQ factorization of N-by-P matrix B: B = T*Z. */ |
| 28386 | |
| 28387 | dgerqf_cxx . . $ dgerqf_(b2aaa174babf002e).(n, p, &b[b_offset], ldb, &taub[1], &work[1], lwork, info); |
| 28388 | /* Computing MAX */ |
| 28389 | i__1 = lopt, i__2 = (integercxx . . $ integer#) work[1]; |
| 28390 | work[1] = (double) stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 28391 | |
| 28392 | return 0; |
| 28393 | |
| 28394 | /* End of DGGQRF */ |
| 28395 | |
| 28396 | } /* dggqrf_ */ |
| 28397 | |
| 28398 | /* Subroutine */ int dggrqf_cxx . . $ dggrqf_(c951bae2f1e49e56).(integercxx . . $ integer# *m, integercxx . . $ integer# *p, integercxx . . $ integer# *n, double * |
| 28399 | a, integercxx . . $ integer# *lda, double *taua, double *b, integercxx . . $ integer# *ldb, |
| 28400 | double *taub, double *work, integercxx . . $ integer# *lwork, integercxx . . $ integer# *info) |
| 28401 | { |
| 28402 | /* Table of constant values */ |
| 28403 | static integercxx . . $ integer# c__1 = 1; |
| 28404 | static integercxx . . $ integer# c_n1 = -1; |
| 28405 | |
| 28406 | /* System generated locals */ |
| 28407 | integercxx . . $ integer# a_dim1, a_offset, b_dim1, b_offset, i__1, i__2, i__3; |
| 28408 | |
| 28409 | /* Local variables */ |
| 28410 | integercxx . . $ integer# nb, nb1, nb2, nb3, lopt; |
| 28411 | integercxx . . $ integer# lwkopt; |
| 28412 | bool lquery; |
| 28413 | |
| 28414 | |
| 28415 | /* -- LAPACK routine (version 3.1) -- */ |
| 28416 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 28417 | /* November 2006 */ |
| 28418 | |
| 28419 | /* .. Scalar Arguments .. */ |
| 28420 | /* .. */ |
| 28421 | /* .. Array Arguments .. */ |
| 28422 | /* .. */ |
| 28423 | |
| 28424 | /* Purpose */ |
| 28425 | /* ======= */ |
| 28426 | |
| 28427 | /* DGGRQF computes a generalized RQ factorization of an M-by-N matrix A */ |
| 28428 | /* and a P-by-N matrix B: */ |
| 28429 | |
| 28430 | /* A = R*Q, B = Z*T*Q, */ |
| 28431 | |
| 28432 | /* where Q is an N-by-N orthogonal matrix, Z is a P-by-P orthogonal */ |
| 28433 | /* matrix, and R and T assume one of the forms: */ |
| 28434 | |
| 28435 | /* if M <= N, R = ( 0 R12 ) M, or if M > N, R = ( R11 ) M-N, */ |
| 28436 | /* N-M M ( R21 ) N */ |
| 28437 | /* N */ |
| 28438 | |
| 28439 | /* where R12 or R21 is upper triangular, and */ |
| 28440 | |
| 28441 | /* if P >= N, T = ( T11 ) N , or if P < N, T = ( T11 T12 ) P, */ |
| 28442 | /* ( 0 ) P-N P N-P */ |
| 28443 | /* N */ |
| 28444 | |
| 28445 | /* where T11 is upper triangular. */ |
| 28446 | |
| 28447 | /* In particular, if B is square and nonsingular, the GRQ factorization */ |
| 28448 | /* of A and B implicitly gives the RQ factorization of A*inv(B): */ |
| 28449 | |
| 28450 | /* A*inv(B) = (R*inv(T))*Z' */ |
| 28451 | |
| 28452 | /* where inv(B) denotes the inverse of the matrix B, and Z' denotes the */ |
| 28453 | /* transpose of the matrix Z. */ |
| 28454 | |
| 28455 | /* Arguments */ |
| 28456 | /* ========= */ |
| 28457 | |
| 28458 | /* M (input) INTEGER */ |
| 28459 | /* The number of rows of the matrix A. M >= 0. */ |
| 28460 | |
| 28461 | /* P (input) INTEGER */ |
| 28462 | /* The number of rows of the matrix B. P >= 0. */ |
| 28463 | |
| 28464 | /* N (input) INTEGER */ |
| 28465 | /* The number of columns of the matrices A and B. N >= 0. */ |
| 28466 | |
| 28467 | /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 28468 | /* On entry, the M-by-N matrix A. */ |
| 28469 | /* On exit, if M <= N, the upper triangle of the subarray */ |
| 28470 | /* A(1:M,N-M+1:N) contains the M-by-M upper triangular matrix R; */ |
| 28471 | /* if M > N, the elements on and above the (M-N)-th subdiagonal */ |
| 28472 | /* contain the M-by-N upper trapezoidal matrix R; the remaining */ |
| 28473 | /* elements, with the array TAUA, represent the orthogonal */ |
| 28474 | /* matrix Q as a product of elementary reflectors (see Further */ |
| 28475 | /* Details). */ |
| 28476 | |
| 28477 | /* LDA (input) INTEGER */ |
| 28478 | /* The leading dimension of the array A. LDA >= max(1,M). */ |
| 28479 | |
| 28480 | /* TAUA (output) DOUBLE PRECISION array, dimension (min(M,N)) */ |
| 28481 | /* The scalar factors of the elementary reflectors which */ |
| 28482 | /* represent the orthogonal matrix Q (see Further Details). */ |
| 28483 | |
| 28484 | /* B (input/output) DOUBLE PRECISION array, dimension (LDB,N) */ |
| 28485 | /* On entry, the P-by-N matrix B. */ |
| 28486 | /* On exit, the elements on and above the diagonal of the array */ |
| 28487 | /* contain the min(P,N)-by-N upper trapezoidal matrix T (T is */ |
| 28488 | /* upper triangular if P >= N); the elements below the diagonal, */ |
| 28489 | /* with the array TAUB, represent the orthogonal matrix Z as a */ |
| 28490 | /* product of elementary reflectors (see Further Details). */ |
| 28491 | |
| 28492 | /* LDB (input) INTEGER */ |
| 28493 | /* The leading dimension of the array B. LDB >= max(1,P). */ |
| 28494 | |
| 28495 | /* TAUB (output) DOUBLE PRECISION array, dimension (min(P,N)) */ |
| 28496 | /* The scalar factors of the elementary reflectors which */ |
| 28497 | /* represent the orthogonal matrix Z (see Further Details). */ |
| 28498 | |
| 28499 | /* WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) */ |
| 28500 | /* On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ |
| 28501 | |
| 28502 | /* LWORK (input) INTEGER */ |
| 28503 | /* The dimension of the array WORK. LWORK >= max(1,N,M,P). */ |
| 28504 | /* For optimum performance LWORK >= max(N,M,P)*max(NB1,NB2,NB3), */ |
| 28505 | /* where NB1 is the optimal blocksize for the RQ factorization */ |
| 28506 | /* of an M-by-N matrix, NB2 is the optimal blocksize for the */ |
| 28507 | /* QR factorization of a P-by-N matrix, and NB3 is the optimal */ |
| 28508 | /* blocksize for a call of DORMRQ. */ |
| 28509 | |
| 28510 | /* If LWORK = -1, then a workspace query is assumed; the routine */ |
| 28511 | /* only calculates the optimal size of the WORK array, returns */ |
| 28512 | /* this value as the first entry of the WORK array, and no error */ |
| 28513 | /* message related to LWORK is issued by XERBLA. */ |
| 28514 | |
| 28515 | /* INFO (output) INTEGER */ |
| 28516 | /* = 0: successful exit */ |
| 28517 | /* < 0: if INF0= -i, the i-th argument had an illegal value. */ |
| 28518 | |
| 28519 | /* Further Details */ |
| 28520 | /* =============== */ |
| 28521 | |
| 28522 | /* The matrix Q is represented as a product of elementary reflectors */ |
| 28523 | |
| 28524 | /* Q = H(1) H(2) . . . H(k), where k = min(m,n). */ |
| 28525 | |
| 28526 | /* Each H(i) has the form */ |
| 28527 | |
| 28528 | /* H(i) = I - taua * v * v' */ |
| 28529 | |
| 28530 | /* where taua is a real scalar, and v is a real vector with */ |
| 28531 | /* v(n-k+i+1:n) = 0 and v(n-k+i) = 1; v(1:n-k+i-1) is stored on exit in */ |
| 28532 | /* A(m-k+i,1:n-k+i-1), and taua in TAUA(i). */ |
| 28533 | /* To form Q explicitly, use LAPACK subroutine DORGRQ. */ |
| 28534 | /* To use Q to update another matrix, use LAPACK subroutine DORMRQ. */ |
| 28535 | |
| 28536 | /* The matrix Z is represented as a product of elementary reflectors */ |
| 28537 | |
| 28538 | /* Z = H(1) H(2) . . . H(k), where k = min(p,n). */ |
| 28539 | |
| 28540 | /* Each H(i) has the form */ |
| 28541 | |
| 28542 | /* H(i) = I - taub * v * v' */ |
| 28543 | |
| 28544 | /* where taub is a real scalar, and v is a real vector with */ |
| 28545 | /* v(1:i-1) = 0 and v(i) = 1; v(i+1:p) is stored on exit in B(i+1:p,i), */ |
| 28546 | /* and taub in TAUB(i). */ |
| 28547 | /* To form Z explicitly, use LAPACK subroutine DORGQR. */ |
| 28548 | /* To use Z to update another matrix, use LAPACK subroutine DORMQR. */ |
| 28549 | |
| 28550 | /* ===================================================================== */ |
| 28551 | |
| 28552 | /* .. Local Scalars .. */ |
| 28553 | /* .. */ |
| 28554 | /* .. External Subroutines .. */ |
| 28555 | /* .. */ |
| 28556 | /* .. External Functions .. */ |
| 28557 | /* .. */ |
| 28558 | /* .. Intrinsic Functions .. */ |
| 28559 | /* .. */ |
| 28560 | /* .. Executable Statements .. */ |
| 28561 | |
| 28562 | /* Test the input parameters */ |
| 28563 | |
| 28564 | /* Parameter adjustments */ |
| 28565 | a_dim1 = *lda; |
| 28566 | a_offset = 1 + a_dim1; |
| 28567 | a -= a_offset; |
| 28568 | --taua; |
| 28569 | b_dim1 = *ldb; |
| 28570 | b_offset = 1 + b_dim1; |
| 28571 | b -= b_offset; |
| 28572 | --taub; |
| 28573 | --work; |
| 28574 | |
| 28575 | /* Function Body */ |
| 28576 | *info = 0; |
| 28577 | nb1 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGERQF", " ", m, n, &c_n1, &c_n1); |
| 28578 | nb2 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGEQRF", " ", p, n, &c_n1, &c_n1); |
| 28579 | nb3 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DORMRQ", " ", m, n, p, &c_n1); |
| 28580 | /* Computing MAX */ |
| 28581 | i__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(nb1,nb2); |
| 28582 | nb = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,nb3); |
| 28583 | /* Computing MAX */ |
| 28584 | i__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(*n,*m); |
| 28585 | lwkopt = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,*p) * nb; |
| 28586 | work[1] = (double) lwkopt; |
| 28587 | lquery = *lwork == -1; |
| 28588 | if (*m < 0) { |
| 28589 | *info = -1; |
| 28590 | } else if (*p < 0) { |
| 28591 | *info = -2; |
| 28592 | } else if (*n < 0) { |
| 28593 | *info = -3; |
| 28594 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*m)) { |
| 28595 | *info = -5; |
| 28596 | } else if (*ldb < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*p)) { |
| 28597 | *info = -8; |
| 28598 | } else /* if(complicated condition) */ { |
| 28599 | /* Computing MAX */ |
| 28600 | i__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*m), i__1 = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,*p); |
| 28601 | if (*lwork < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,*n) && ! lquery) { |
| 28602 | *info = -11; |
| 28603 | } |
| 28604 | } |
| 28605 | if (*info != 0) { |
| 28606 | i__1 = -(*info); |
| 28607 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGGRQF", &i__1); |
| 28608 | return 0; |
| 28609 | } else if (lquery) { |
| 28610 | return 0; |
| 28611 | } |
| 28612 | |
| 28613 | /* RQ factorization of M-by-N matrix A: A = R*Q */ |
| 28614 | |
| 28615 | dgerqf_cxx . . $ dgerqf_(b2aaa174babf002e).(m, n, &a[a_offset], lda, &taua[1], &work[1], lwork, info); |
| 28616 | lopt = (integercxx . . $ integer#) work[1]; |
| 28617 | |
| 28618 | /* Update B := B*Q' */ |
| 28619 | |
| 28620 | i__1 = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(*m,*n); |
| 28621 | /* Computing MAX */ |
| 28622 | i__2 = 1, i__3 = *m - *n + 1; |
| 28623 | dormrq_cxx . . $ dormrq_(c6b7238dd97e9cf9).("Right", "Transpose", p, n, &i__1, &a[stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__2, i__3)+ a_dim1], |
| 28624 | lda, &taua[1], &b[b_offset], ldb, &work[1], lwork, info); |
| 28625 | /* Computing MAX */ |
| 28626 | i__1 = lopt, i__2 = (integercxx . . $ integer#) work[1]; |
| 28627 | lopt = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 28628 | |
| 28629 | /* QR factorization of P-by-N matrix B: B = Z*T */ |
| 28630 | |
| 28631 | dgeqrf_cxx . . $ dgeqrf_(b2aaa174babf002e).(p, n, &b[b_offset], ldb, &taub[1], &work[1], lwork, info); |
| 28632 | /* Computing MAX */ |
| 28633 | i__1 = lopt, i__2 = (integercxx . . $ integer#) work[1]; |
| 28634 | work[1] = (double) stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 28635 | |
| 28636 | return 0; |
| 28637 | |
| 28638 | /* End of DGGRQF */ |
| 28639 | |
| 28640 | } /* dggrqf_ */ |
| 28641 | |
| 28642 | /* Subroutine */ int dggsvd_cxx . . $ dggsvd_(9f9c300004473df1).(const char *jobu, const char *jobv, const char *jobq, integercxx . . $ integer# *m, |
| 28643 | integercxx . . $ integer# *n, integercxx . . $ integer# *p, integercxx . . $ integer# *k, integercxx . . $ integer# *l, double *a, |
| 28644 | integercxx . . $ integer# *lda, double *b, integercxx . . $ integer# *ldb, double *alpha, |
| 28645 | double *beta, double *u, integercxx . . $ integer# *ldu, double *v, integercxx . . $ integer# |
| 28646 | *ldv, double *q, integercxx . . $ integer# *ldq, double *work, integercxx . . $ integer# *iwork, |
| 28647 | integercxx . . $ integer# *info) |
| 28648 | { |
| 28649 | /* Table of constant values */ |
| 28650 | static integercxx . . $ integer# c__1 = 1; |
| 28651 | |
| 28652 | /* System generated locals */ |
| 28653 | integercxx . . $ integer# a_dim1, a_offset, b_dim1, b_offset, q_dim1, q_offset, u_dim1, |
| 28654 | u_offset, v_dim1, v_offset, i__1, i__2; |
| 28655 | |
| 28656 | /* Local variables */ |
| 28657 | integercxx . . $ integer# i__, j; |
| 28658 | double ulp; |
| 28659 | integercxx . . $ integer# ibnd; |
| 28660 | double tola; |
| 28661 | integercxx . . $ integer# isub; |
| 28662 | double tolb, unfl, temp, smax; |
| 28663 | double anorm, bnorm; |
| 28664 | bool wantq, wantu, wantv; |
| 28665 | integercxx . . $ integer# ncycle; |
| 28666 | |
| 28667 | /* -- LAPACK driver routine (version 3.2) -- */ |
| 28668 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 28669 | /* November 2006 */ |
| 28670 | |
| 28671 | /* .. Scalar Arguments .. */ |
| 28672 | /* .. */ |
| 28673 | /* .. Array Arguments .. */ |
| 28674 | /* .. */ |
| 28675 | |
| 28676 | /* Purpose */ |
| 28677 | /* ======= */ |
| 28678 | |
| 28679 | /* DGGSVD computes the generalized singular value decomposition (GSVD) */ |
| 28680 | /* of an M-by-N real matrix A and P-by-N real matrix B: */ |
| 28681 | |
| 28682 | /* U'*A*Q = D1*( 0 R ), V'*B*Q = D2*( 0 R ) */ |
| 28683 | |
| 28684 | /* where U, V and Q are orthogonal matrices, and Z' is the transpose */ |
| 28685 | /* of Z. Let K+L = the effective numerical rank of the matrix (A',B')', */ |
| 28686 | /* then R is a K+L-by-K+L nonsingular upper triangular matrix, D1 and */ |
| 28687 | /* D2 are M-by-(K+L) and P-by-(K+L) "diagonal" matrices and of the */ |
| 28688 | /* following structures, respectively: */ |
| 28689 | |
| 28690 | /* If M-K-L >= 0, */ |
| 28691 | |
| 28692 | /* K L */ |
| 28693 | /* D1 = K ( I 0 ) */ |
| 28694 | /* L ( 0 C ) */ |
| 28695 | /* M-K-L ( 0 0 ) */ |
| 28696 | |
| 28697 | /* K L */ |
| 28698 | /* D2 = L ( 0 S ) */ |
| 28699 | /* P-L ( 0 0 ) */ |
| 28700 | |
| 28701 | /* N-K-L K L */ |
| 28702 | /* ( 0 R ) = K ( 0 R11 R12 ) */ |
| 28703 | /* L ( 0 0 R22 ) */ |
| 28704 | |
| 28705 | /* where */ |
| 28706 | |
| 28707 | /* C = diag( ALPHA(K+1), ... , ALPHA(K+L) ), */ |
| 28708 | /* S = diag( BETA(K+1), ... , BETA(K+L) ), */ |
| 28709 | /* C**2 + S**2 = I. */ |
| 28710 | |
| 28711 | /* R is stored in A(1:K+L,N-K-L+1:N) on exit. */ |
| 28712 | |
| 28713 | /* If M-K-L < 0, */ |
| 28714 | |
| 28715 | /* K M-K K+L-M */ |
| 28716 | /* D1 = K ( I 0 0 ) */ |
| 28717 | /* M-K ( 0 C 0 ) */ |
| 28718 | |
| 28719 | /* K M-K K+L-M */ |
| 28720 | /* D2 = M-K ( 0 S 0 ) */ |
| 28721 | /* K+L-M ( 0 0 I ) */ |
| 28722 | /* P-L ( 0 0 0 ) */ |
| 28723 | |
| 28724 | /* N-K-L K M-K K+L-M */ |
| 28725 | /* ( 0 R ) = K ( 0 R11 R12 R13 ) */ |
| 28726 | /* M-K ( 0 0 R22 R23 ) */ |
| 28727 | /* K+L-M ( 0 0 0 R33 ) */ |
| 28728 | |
| 28729 | /* where */ |
| 28730 | |
| 28731 | /* C = diag( ALPHA(K+1), ... , ALPHA(M) ), */ |
| 28732 | /* S = diag( BETA(K+1), ... , BETA(M) ), */ |
| 28733 | /* C**2 + S**2 = I. */ |
| 28734 | |
| 28735 | /* (R11 R12 R13 ) is stored in A(1:M, N-K-L+1:N), and R33 is stored */ |
| 28736 | /* ( 0 R22 R23 ) */ |
| 28737 | /* in B(M-K+1:L,N+M-K-L+1:N) on exit. */ |
| 28738 | |
| 28739 | /* The routine computes C, S, R, and optionally the orthogonal */ |
| 28740 | /* transformation matrices U, V and Q. */ |
| 28741 | |
| 28742 | /* In particular, if B is an N-by-N nonsingular matrix, then the GSVD of */ |
| 28743 | /* A and B implicitly gives the SVD of A*inv(B): */ |
| 28744 | /* A*inv(B) = U*(D1*inv(D2))*V'. */ |
| 28745 | /* If ( A',B')' has orthonormal columns, then the GSVD of A and B is */ |
| 28746 | /* also equal to the CS decomposition of A and B. Furthermore, the GSVD */ |
| 28747 | /* can be used to derive the solution of the eigenvalue problem: */ |
| 28748 | /* A'*A x = lambda* B'*B x. */ |
| 28749 | /* In some literature, the GSVD of A and B is presented in the form */ |
| 28750 | /* U'*A*X = ( 0 D1 ), V'*B*X = ( 0 D2 ) */ |
| 28751 | /* where U and V are orthogonal and X is nonsingular, D1 and D2 are */ |
| 28752 | /* ``diagonal''. The former GSVD form can be converted to the latter */ |
| 28753 | /* form by taking the nonsingular matrix X as */ |
| 28754 | |
| 28755 | /* X = Q*( I 0 ) */ |
| 28756 | /* ( 0 inv(R) ). */ |
| 28757 | |
| 28758 | /* Arguments */ |
| 28759 | /* ========= */ |
| 28760 | |
| 28761 | /* JOBU (input) CHARACTER*1 */ |
| 28762 | /* = 'U': Orthogonal matrix U is computed; */ |
| 28763 | /* = 'N': U is not computed. */ |
| 28764 | |
| 28765 | /* JOBV (input) CHARACTER*1 */ |
| 28766 | /* = 'V': Orthogonal matrix V is computed; */ |
| 28767 | /* = 'N': V is not computed. */ |
| 28768 | |
| 28769 | /* JOBQ (input) CHARACTER*1 */ |
| 28770 | /* = 'Q': Orthogonal matrix Q is computed; */ |
| 28771 | /* = 'N': Q is not computed. */ |
| 28772 | |
| 28773 | /* M (input) INTEGER */ |
| 28774 | /* The number of rows of the matrix A. M >= 0. */ |
| 28775 | |
| 28776 | /* N (input) INTEGER */ |
| 28777 | /* The number of columns of the matrices A and B. N >= 0. */ |
| 28778 | |
| 28779 | /* P (input) INTEGER */ |
| 28780 | /* The number of rows of the matrix B. P >= 0. */ |
| 28781 | |
| 28782 | /* K (output) INTEGER */ |
| 28783 | /* L (output) INTEGER */ |
| 28784 | /* On exit, K and L specify the dimension of the subblocks */ |
| 28785 | /* described in the Purpose section. */ |
| 28786 | /* K + L = effective numerical rank of (A',B')'. */ |
| 28787 | |
| 28788 | /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 28789 | /* On entry, the M-by-N matrix A. */ |
| 28790 | /* On exit, A contains the triangular matrix R, or part of R. */ |
| 28791 | /* See Purpose for details. */ |
| 28792 | |
| 28793 | /* LDA (input) INTEGER */ |
| 28794 | /* The leading dimension of the array A. LDA >= max(1,M). */ |
| 28795 | |
| 28796 | /* B (input/output) DOUBLE PRECISION array, dimension (LDB,N) */ |
| 28797 | /* On entry, the P-by-N matrix B. */ |
| 28798 | /* On exit, B contains the triangular matrix R if M-K-L < 0. */ |
| 28799 | /* See Purpose for details. */ |
| 28800 | |
| 28801 | /* LDB (input) INTEGER */ |
| 28802 | /* The leading dimension of the array B. LDB >= max(1,P). */ |
| 28803 | |
| 28804 | /* ALPHA (output) DOUBLE PRECISION array, dimension (N) */ |
| 28805 | /* BETA (output) DOUBLE PRECISION array, dimension (N) */ |
| 28806 | /* On exit, ALPHA and BETA contain the generalized singular */ |
| 28807 | /* value pairs of A and B; */ |
| 28808 | /* ALPHA(1:K) = 1, */ |
| 28809 | /* BETA(1:K) = 0, */ |
| 28810 | /* and if M-K-L >= 0, */ |
| 28811 | /* ALPHA(K+1:K+L) = C, */ |
| 28812 | /* BETA(K+1:K+L) = S, */ |
| 28813 | /* or if M-K-L < 0, */ |
| 28814 | /* ALPHA(K+1:M)=C, ALPHA(M+1:K+L)=0 */ |
| 28815 | /* BETA(K+1:M) =S, BETA(M+1:K+L) =1 */ |
| 28816 | /* and */ |
| 28817 | /* ALPHA(K+L+1:N) = 0 */ |
| 28818 | /* BETA(K+L+1:N) = 0 */ |
| 28819 | |
| 28820 | /* U (output) DOUBLE PRECISION array, dimension (LDU,M) */ |
| 28821 | /* If JOBU = 'U', U contains the M-by-M orthogonal matrix U. */ |
| 28822 | /* If JOBU = 'N', U is not referenced. */ |
| 28823 | |
| 28824 | /* LDU (input) INTEGER */ |
| 28825 | /* The leading dimension of the array U. LDU >= max(1,M) if */ |
| 28826 | /* JOBU = 'U'; LDU >= 1 otherwise. */ |
| 28827 | |
| 28828 | /* V (output) DOUBLE PRECISION array, dimension (LDV,P) */ |
| 28829 | /* If JOBV = 'V', V contains the P-by-P orthogonal matrix V. */ |
| 28830 | /* If JOBV = 'N', V is not referenced. */ |
| 28831 | |
| 28832 | /* LDV (input) INTEGER */ |
| 28833 | /* The leading dimension of the array V. LDV >= max(1,P) if */ |
| 28834 | /* JOBV = 'V'; LDV >= 1 otherwise. */ |
| 28835 | |
| 28836 | /* Q (output) DOUBLE PRECISION array, dimension (LDQ,N) */ |
| 28837 | /* If JOBQ = 'Q', Q contains the N-by-N orthogonal matrix Q. */ |
| 28838 | /* If JOBQ = 'N', Q is not referenced. */ |
| 28839 | |
| 28840 | /* LDQ (input) INTEGER */ |
| 28841 | /* The leading dimension of the array Q. LDQ >= max(1,N) if */ |
| 28842 | /* JOBQ = 'Q'; LDQ >= 1 otherwise. */ |
| 28843 | |
| 28844 | /* WORK (workspace) DOUBLE PRECISION array, */ |
| 28845 | /* dimension (max(3*N,M,P)+N) */ |
| 28846 | |
| 28847 | /* IWORK (workspace/output) INTEGER array, dimension (N) */ |
| 28848 | /* On exit, IWORK stores the sorting information. More */ |
| 28849 | /* precisely, the following loop will sort ALPHA */ |
| 28850 | /* for I = K+1, min(M,K+L) */ |
| 28851 | /* swap ALPHA(I) and ALPHA(IWORK(I)) */ |
| 28852 | /* endfor */ |
| 28853 | /* such that ALPHA(1) >= ALPHA(2) >= ... >= ALPHA(N). */ |
| 28854 | |
| 28855 | /* INFO (output) INTEGER */ |
| 28856 | /* = 0: successful exit */ |
| 28857 | /* < 0: if INFO = -i, the i-th argument had an illegal value. */ |
| 28858 | /* > 0: if INFO = 1, the Jacobi-type procedure failed to */ |
| 28859 | /* converge. For further details, see subroutine DTGSJA. */ |
| 28860 | |
| 28861 | /* Internal Parameters */ |
| 28862 | /* =================== */ |
| 28863 | |
| 28864 | /* TOLA DOUBLE PRECISION */ |
| 28865 | /* TOLB DOUBLE PRECISION */ |
| 28866 | /* TOLA and TOLB are the thresholds to determine the effective */ |
| 28867 | /* rank of (A',B')'. Generally, they are set to */ |
| 28868 | /* TOLA = MAX(M,N)*norm(A)*MAZHEPS, */ |
| 28869 | /* TOLB = MAX(P,N)*norm(B)*MAZHEPS. */ |
| 28870 | /* The size of TOLA and TOLB may affect the size of backward */ |
| 28871 | /* errors of the decomposition. */ |
| 28872 | |
| 28873 | /* Further Details */ |
| 28874 | /* =============== */ |
| 28875 | |
| 28876 | /* 2-96 Based on modifications by */ |
| 28877 | /* Ming Gu and Huan Ren, Computer Science Division, University of */ |
| 28878 | /* California at Berkeley, USA */ |
| 28879 | |
| 28880 | /* ===================================================================== */ |
| 28881 | |
| 28882 | /* .. Local Scalars .. */ |
| 28883 | /* .. */ |
| 28884 | /* .. External Functions .. */ |
| 28885 | /* .. */ |
| 28886 | /* .. External Subroutines .. */ |
| 28887 | /* .. */ |
| 28888 | /* .. Intrinsic Functions .. */ |
| 28889 | /* .. */ |
| 28890 | /* .. Executable Statements .. */ |
| 28891 | |
| 28892 | /* Test the input parameters */ |
| 28893 | |
| 28894 | /* Parameter adjustments */ |
| 28895 | a_dim1 = *lda; |
| 28896 | a_offset = 1 + a_dim1; |
| 28897 | a -= a_offset; |
| 28898 | b_dim1 = *ldb; |
| 28899 | b_offset = 1 + b_dim1; |
| 28900 | b -= b_offset; |
| 28901 | --alpha; |
| 28902 | --beta; |
| 28903 | u_dim1 = *ldu; |
| 28904 | u_offset = 1 + u_dim1; |
| 28905 | u -= u_offset; |
| 28906 | v_dim1 = *ldv; |
| 28907 | v_offset = 1 + v_dim1; |
| 28908 | v -= v_offset; |
| 28909 | q_dim1 = *ldq; |
| 28910 | q_offset = 1 + q_dim1; |
| 28911 | q -= q_offset; |
| 28912 | --work; |
| 28913 | --iwork; |
| 28914 | |
| 28915 | /* Function Body */ |
| 28916 | wantu = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobu, "U"); |
| 28917 | wantv = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobv, "V"); |
| 28918 | wantq = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobq, "Q"); |
| 28919 | |
| 28920 | *info = 0; |
| 28921 | if (! (wantu || lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobu, "N"))) { |
| 28922 | *info = -1; |
| 28923 | } else if (! (wantv || lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobv, "N"))) { |
| 28924 | *info = -2; |
| 28925 | } else if (! (wantq || lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobq, "N"))) { |
| 28926 | *info = -3; |
| 28927 | } else if (*m < 0) { |
| 28928 | *info = -4; |
| 28929 | } else if (*n < 0) { |
| 28930 | *info = -5; |
| 28931 | } else if (*p < 0) { |
| 28932 | *info = -6; |
| 28933 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*m)) { |
| 28934 | *info = -10; |
| 28935 | } else if (*ldb < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*p)) { |
| 28936 | *info = -12; |
| 28937 | } else if (*ldu < 1 || wantu && *ldu < *m) { |
| 28938 | *info = -16; |
| 28939 | } else if (*ldv < 1 || wantv && *ldv < *p) { |
| 28940 | *info = -18; |
| 28941 | } else if (*ldq < 1 || wantq && *ldq < *n) { |
| 28942 | *info = -20; |
| 28943 | } |
| 28944 | if (*info != 0) { |
| 28945 | i__1 = -(*info); |
| 28946 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGGSVD", &i__1); |
| 28947 | return 0; |
| 28948 | } |
| 28949 | |
| 28950 | /* Compute the Frobenius norm of matrices A and B */ |
| 28951 | |
| 28952 | anorm = dlange_cxx . . $ dlange_(98d44e6417336f20).("1", m, n, &a[a_offset], lda, &work[1]); |
| 28953 | bnorm = dlange_cxx . . $ dlange_(98d44e6417336f20).("1", p, n, &b[b_offset], ldb, &work[1]); |
| 28954 | |
| 28955 | /* Get machine precision and set up threshold for determining */ |
| 28956 | /* the effective numerical rank of the matrices A and B. */ |
| 28957 | |
| 28958 | ulp = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("Precision"); |
| 28959 | unfl = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("Safe Minimum"); |
| 28960 | tola = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(*m,*n) * stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(anorm,unfl) * ulp; |
| 28961 | tolb = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(*p,*n) * stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(bnorm,unfl) * ulp; |
| 28962 | |
| 28963 | /* Preprocessing */ |
| 28964 | |
| 28965 | dggsvp_cxx . . $ dggsvp_(cc947dfbbdc4d5de).(jobu, jobv, jobq, m, p, n, &a[a_offset], lda, &b[b_offset], ldb, & |
| 28966 | tola, &tolb, k, l, &u[u_offset], ldu, &v[v_offset], ldv, &q[ |
| 28967 | q_offset], ldq, &iwork[1], &work[1], &work[*n + 1], info); |
| 28968 | |
| 28969 | /* Compute the GSVD of two upper "triangular" matrices */ |
| 28970 | |
| 28971 | dtgsja_cxx . . $ dtgsja_(1dca1756b130af98).(jobu, jobv, jobq, m, p, n, k, l, &a[a_offset], lda, &b[b_offset], |
| 28972 | ldb, &tola, &tolb, &alpha[1], &beta[1], &u[u_offset], ldu, &v[ |
| 28973 | v_offset], ldv, &q[q_offset], ldq, &work[1], &ncycle, info); |
| 28974 | |
| 28975 | /* Sort the singular values and store the pivot indices in IWORK */ |
| 28976 | /* Copy ALPHA to WORK, then sort ALPHA in WORK */ |
| 28977 | |
| 28978 | dcopy_cxx . . $ dcopy_(ec261fd7ec3b6bf6).(n, &alpha[1], &c__1, &work[1], &c__1); |
| 28979 | /* Computing MIN */ |
| 28980 | i__1 = *l, i__2 = *m - *k; |
| 28981 | ibnd = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__1,i__2); |
| 28982 | i__1 = ibnd; |
| 28983 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 28984 | |
| 28985 | /* Scan for largest ALPHA(K+I) */ |
| 28986 | |
| 28987 | isub = i__; |
| 28988 | smax = work[*k + i__]; |
| 28989 | i__2 = ibnd; |
| 28990 | for (j = i__ + 1; j <= i__2; ++j) { |
| 28991 | temp = work[*k + j]; |
| 28992 | if (temp > smax) { |
| 28993 | isub = j; |
| 28994 | smax = temp; |
| 28995 | } |
| 28996 | /* L10: */ |
| 28997 | } |
| 28998 | if (isub != i__) { |
| 28999 | work[*k + isub] = work[*k + i__]; |
| 29000 | work[*k + i__] = smax; |
| 29001 | iwork[*k + i__] = *k + isub; |
| 29002 | } else { |
| 29003 | iwork[*k + i__] = *k + i__; |
| 29004 | } |
| 29005 | /* L20: */ |
| 29006 | } |
| 29007 | |
| 29008 | return 0; |
| 29009 | |
| 29010 | /* End of DGGSVD */ |
| 29011 | |
| 29012 | } /* dggsvd_ */ |
| 29013 | |
| 29014 | /* Subroutine */ int dggsvp_cxx . . $ dggsvp_(cc947dfbbdc4d5de).(const char *jobu, const char *jobv, const char *jobq, integercxx . . $ integer# *m, |
| 29015 | integercxx . . $ integer# *p, integercxx . . $ integer# *n, double *a, integercxx . . $ integer# *lda, double *b, |
| 29016 | integercxx . . $ integer# *ldb, double *tola, double *tolb, integercxx . . $ integer# *k, integercxx . . $ integer# |
| 29017 | *l, double *u, integercxx . . $ integer# *ldu, double *v, integercxx . . $ integer# *ldv, |
| 29018 | double *q, integercxx . . $ integer# *ldq, integercxx . . $ integer# *iwork, double *tau, |
| 29019 | double *work, integercxx . . $ integer# *info) |
| 29020 | { |
| 29021 | /* Table of constant values */ |
| 29022 | static double c_b12 = 0.; |
| 29023 | static double c_b22 = 1.; |
| 29024 | |
| 29025 | /* System generated locals */ |
| 29026 | integercxx . . $ integer# a_dim1, a_offset, b_dim1, b_offset, q_dim1, q_offset, u_dim1, |
| 29027 | u_offset, v_dim1, v_offset, i__1, i__2, i__3; |
| 29028 | double d__1; |
| 29029 | |
| 29030 | /* Local variables */ |
| 29031 | integercxx . . $ integer# i__, j; |
| 29032 | bool wantq, wantu, wantv; |
| 29033 | bool forwrd; |
| 29034 | |
| 29035 | |
| 29036 | /* -- LAPACK routine (version 3.1) -- */ |
| 29037 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 29038 | /* November 2006 */ |
| 29039 | |
| 29040 | /* .. Scalar Arguments .. */ |
| 29041 | /* .. */ |
| 29042 | /* .. Array Arguments .. */ |
| 29043 | /* .. */ |
| 29044 | |
| 29045 | /* Purpose */ |
| 29046 | /* ======= */ |
| 29047 | |
| 29048 | /* DGGSVP computes orthogonal matrices U, V and Q such that */ |
| 29049 | |
| 29050 | /* N-K-L K L */ |
| 29051 | /* U'*A*Q = K ( 0 A12 A13 ) if M-K-L >= 0; */ |
| 29052 | /* L ( 0 0 A23 ) */ |
| 29053 | /* M-K-L ( 0 0 0 ) */ |
| 29054 | |
| 29055 | /* N-K-L K L */ |
| 29056 | /* = K ( 0 A12 A13 ) if M-K-L < 0; */ |
| 29057 | /* M-K ( 0 0 A23 ) */ |
| 29058 | |
| 29059 | /* N-K-L K L */ |
| 29060 | /* V'*B*Q = L ( 0 0 B13 ) */ |
| 29061 | /* P-L ( 0 0 0 ) */ |
| 29062 | |
| 29063 | /* where the K-by-K matrix A12 and L-by-L matrix B13 are nonsingular */ |
| 29064 | /* upper triangular; A23 is L-by-L upper triangular if M-K-L >= 0, */ |
| 29065 | /* otherwise A23 is (M-K)-by-L upper trapezoidal. K+L = the effective */ |
| 29066 | /* numerical rank of the (M+P)-by-N matrix (A',B')'. Z' denotes the */ |
| 29067 | /* transpose of Z. */ |
| 29068 | |
| 29069 | /* This decomposition is the preprocessing step for computing the */ |
| 29070 | /* Generalized Singular Value Decomposition (GSVD), see subroutine */ |
| 29071 | /* DGGSVD. */ |
| 29072 | |
| 29073 | /* Arguments */ |
| 29074 | /* ========= */ |
| 29075 | |
| 29076 | /* JOBU (input) CHARACTER*1 */ |
| 29077 | /* = 'U': Orthogonal matrix U is computed; */ |
| 29078 | /* = 'N': U is not computed. */ |
| 29079 | |
| 29080 | /* JOBV (input) CHARACTER*1 */ |
| 29081 | /* = 'V': Orthogonal matrix V is computed; */ |
| 29082 | /* = 'N': V is not computed. */ |
| 29083 | |
| 29084 | /* JOBQ (input) CHARACTER*1 */ |
| 29085 | /* = 'Q': Orthogonal matrix Q is computed; */ |
| 29086 | /* = 'N': Q is not computed. */ |
| 29087 | |
| 29088 | /* M (input) INTEGER */ |
| 29089 | /* The number of rows of the matrix A. M >= 0. */ |
| 29090 | |
| 29091 | /* P (input) INTEGER */ |
| 29092 | /* The number of rows of the matrix B. P >= 0. */ |
| 29093 | |
| 29094 | /* N (input) INTEGER */ |
| 29095 | /* The number of columns of the matrices A and B. N >= 0. */ |
| 29096 | |
| 29097 | /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ |
| 29098 | /* On entry, the M-by-N matrix A. */ |
| 29099 | /* On exit, A contains the triangular (or trapezoidal) matrix */ |
| 29100 | /* described in the Purpose section. */ |
| 29101 | |
| 29102 | /* LDA (input) INTEGER */ |
| 29103 | /* The leading dimension of the array A. LDA >= max(1,M). */ |
| 29104 | |
| 29105 | /* B (input/output) DOUBLE PRECISION array, dimension (LDB,N) */ |
| 29106 | /* On entry, the P-by-N matrix B. */ |
| 29107 | /* On exit, B contains the triangular matrix described in */ |
| 29108 | /* the Purpose section. */ |
| 29109 | |
| 29110 | /* LDB (input) INTEGER */ |
| 29111 | /* The leading dimension of the array B. LDB >= max(1,P). */ |
| 29112 | |
| 29113 | /* TOLA (input) DOUBLE PRECISION */ |
| 29114 | /* TOLB (input) DOUBLE PRECISION */ |
| 29115 | /* TOLA and TOLB are the thresholds to determine the effective */ |
| 29116 | /* numerical rank of matrix B and a subblock of A. Generally, */ |
| 29117 | /* they are set to */ |
| 29118 | /* TOLA = MAX(M,N)*norm(A)*MAZHEPS, */ |
| 29119 | /* TOLB = MAX(P,N)*norm(B)*MAZHEPS. */ |
| 29120 | /* The size of TOLA and TOLB may affect the size of backward */ |
| 29121 | /* errors of the decomposition. */ |
| 29122 | |
| 29123 | /* K (output) INTEGER */ |
| 29124 | /* L (output) INTEGER */ |
| 29125 | /* On exit, K and L specify the dimension of the subblocks */ |
| 29126 | /* described in Purpose. */ |
| 29127 | /* K + L = effective numerical rank of (A',B')'. */ |
| 29128 | |
| 29129 | /* U (output) DOUBLE PRECISION array, dimension (LDU,M) */ |
| 29130 | /* If JOBU = 'U', U contains the orthogonal matrix U. */ |
| 29131 | /* If JOBU = 'N', U is not referenced. */ |
| 29132 | |
| 29133 | /* LDU (input) INTEGER */ |
| 29134 | /* The leading dimension of the array U. LDU >= max(1,M) if */ |
| 29135 | /* JOBU = 'U'; LDU >= 1 otherwise. */ |
| 29136 | |
| 29137 | /* V (output) DOUBLE PRECISION array, dimension (LDV,M) */ |
| 29138 | /* If JOBV = 'V', V contains the orthogonal matrix V. */ |
| 29139 | /* If JOBV = 'N', V is not referenced. */ |
| 29140 | |
| 29141 | /* LDV (input) INTEGER */ |
| 29142 | /* The leading dimension of the array V. LDV >= max(1,P) if */ |
| 29143 | /* JOBV = 'V'; LDV >= 1 otherwise. */ |
| 29144 | |
| 29145 | /* Q (output) DOUBLE PRECISION array, dimension (LDQ,N) */ |
| 29146 | /* If JOBQ = 'Q', Q contains the orthogonal matrix Q. */ |
| 29147 | /* If JOBQ = 'N', Q is not referenced. */ |
| 29148 | |
| 29149 | /* LDQ (input) INTEGER */ |
| 29150 | /* The leading dimension of the array Q. LDQ >= max(1,N) if */ |
| 29151 | /* JOBQ = 'Q'; LDQ >= 1 otherwise. */ |
| 29152 | |
| 29153 | /* IWORK (workspace) INTEGER array, dimension (N) */ |
| 29154 | |
| 29155 | /* TAU (workspace) DOUBLE PRECISION array, dimension (N) */ |
| 29156 | |
| 29157 | /* WORK (workspace) DOUBLE PRECISION array, dimension (max(3*N,M,P)) */ |
| 29158 | |
| 29159 | /* INFO (output) INTEGER */ |
| 29160 | /* = 0: successful exit */ |
| 29161 | /* < 0: if INFO = -i, the i-th argument had an illegal value. */ |
| 29162 | |
| 29163 | |
| 29164 | /* Further Details */ |
| 29165 | /* =============== */ |
| 29166 | |
| 29167 | /* The subroutine uses LAPACK subroutine DGEQPF for the QR factorization */ |
| 29168 | /* with column pivoting to detect the effective numerical rank of the */ |
| 29169 | /* a matrix. It may be replaced by a better rank determination strategy. */ |
| 29170 | |
| 29171 | /* ===================================================================== */ |
| 29172 | |
| 29173 | /* .. Parameters .. */ |
| 29174 | /* .. */ |
| 29175 | /* .. Local Scalars .. */ |
| 29176 | /* .. */ |
| 29177 | /* .. External Functions .. */ |
| 29178 | /* .. */ |
| 29179 | /* .. External Subroutines .. */ |
| 29180 | /* .. */ |
| 29181 | /* .. Intrinsic Functions .. */ |
| 29182 | /* .. */ |
| 29183 | /* .. Executable Statements .. */ |
| 29184 | |
| 29185 | /* Test the input parameters */ |
| 29186 | |
| 29187 | /* Parameter adjustments */ |
| 29188 | a_dim1 = *lda; |
| 29189 | a_offset = 1 + a_dim1; |
| 29190 | a -= a_offset; |
| 29191 | b_dim1 = *ldb; |
| 29192 | b_offset = 1 + b_dim1; |
| 29193 | b -= b_offset; |
| 29194 | u_dim1 = *ldu; |
| 29195 | u_offset = 1 + u_dim1; |
| 29196 | u -= u_offset; |
| 29197 | v_dim1 = *ldv; |
| 29198 | v_offset = 1 + v_dim1; |
| 29199 | v -= v_offset; |
| 29200 | q_dim1 = *ldq; |
| 29201 | q_offset = 1 + q_dim1; |
| 29202 | q -= q_offset; |
| 29203 | --iwork; |
| 29204 | --tau; |
| 29205 | --work; |
| 29206 | |
| 29207 | /* Function Body */ |
| 29208 | wantu = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobu, "U"); |
| 29209 | wantv = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobv, "V"); |
| 29210 | wantq = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobq, "Q"); |
| 29211 | forwrd = true; |
| 29212 | |
| 29213 | *info = 0; |
| 29214 | if (! (wantu || lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobu, "N"))) { |
| 29215 | *info = -1; |
| 29216 | } else if (! (wantv || lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobv, "N"))) { |
| 29217 | *info = -2; |
| 29218 | } else if (! (wantq || lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(jobq, "N"))) { |
| 29219 | *info = -3; |
| 29220 | } else if (*m < 0) { |
| 29221 | *info = -4; |
| 29222 | } else if (*p < 0) { |
| 29223 | *info = -5; |
| 29224 | } else if (*n < 0) { |
| 29225 | *info = -6; |
| 29226 | } else if (*lda < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*m)) { |
| 29227 | *info = -8; |
| 29228 | } else if (*ldb < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*p)) { |
| 29229 | *info = -10; |
| 29230 | } else if (*ldu < 1 || wantu && *ldu < *m) { |
| 29231 | *info = -16; |
| 29232 | } else if (*ldv < 1 || wantv && *ldv < *p) { |
| 29233 | *info = -18; |
| 29234 | } else if (*ldq < 1 || wantq && *ldq < *n) { |
| 29235 | *info = -20; |
| 29236 | } |
| 29237 | if (*info != 0) { |
| 29238 | i__1 = -(*info); |
| 29239 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGGSVP", &i__1); |
| 29240 | return 0; |
| 29241 | } |
| 29242 | |
| 29243 | /* QR with column pivoting of B: B*P = V*( S11 S12 ) */ |
| 29244 | /* ( 0 0 ) */ |
| 29245 | |
| 29246 | i__1 = *n; |
| 29247 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 29248 | iwork[i__] = 0; |
| 29249 | /* L10: */ |
| 29250 | } |
| 29251 | dgeqpf_cxx . . $ dgeqpf_(89014a123b88d601).(p, n, &b[b_offset], ldb, &iwork[1], &tau[1], &work[1], info); |
| 29252 | |
| 29253 | /* Update A := A*P */ |
| 29254 | |
| 29255 | dlapmt_cxx . . $ dlapmt_(e33ef504d4853763).(&forwrd, m, n, &a[a_offset], lda, &iwork[1]); |
| 29256 | |
| 29257 | /* Determine the effective rank of matrix B. */ |
| 29258 | |
| 29259 | *l = 0; |
| 29260 | i__1 = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(*p,*n); |
| 29261 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 29262 | if ((d__1 = b[i__ + i__ * b_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__1)) > *tolb) { |
| 29263 | ++(*l); |
| 29264 | } |
| 29265 | /* L20: */ |
| 29266 | } |
| 29267 | |
| 29268 | if (wantv) { |
| 29269 | |
| 29270 | /* Copy the details of V, and form V. */ |
| 29271 | |
| 29272 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("Full", p, p, &c_b12, &c_b12, &v[v_offset], ldv); |
| 29273 | if (*p > 1) { |
| 29274 | i__1 = *p - 1; |
| 29275 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("Lower", &i__1, n, &b[b_dim1 + 2], ldb, &v[v_dim1 + 2], |
| 29276 | ldv); |
| 29277 | } |
| 29278 | i__1 = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(*p,*n); |
| 29279 | dorg2r_cxx . . $ dorg2r_(75bc6169f7761452).(p, p, &i__1, &v[v_offset], ldv, &tau[1], &work[1], info); |
| 29280 | } |
| 29281 | |
| 29282 | /* Clean up B */ |
| 29283 | |
| 29284 | i__1 = *l - 1; |
| 29285 | for (j = 1; j <= i__1; ++j) { |
| 29286 | i__2 = *l; |
| 29287 | for (i__ = j + 1; i__ <= i__2; ++i__) { |
| 29288 | b[i__ + j * b_dim1] = 0.; |
| 29289 | /* L30: */ |
| 29290 | } |
| 29291 | /* L40: */ |
| 29292 | } |
| 29293 | if (*p > *l) { |
| 29294 | i__1 = *p - *l; |
| 29295 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("Full", &i__1, n, &c_b12, &c_b12, &b[*l + 1 + b_dim1], ldb); |
| 29296 | } |
| 29297 | |
| 29298 | if (wantq) { |
| 29299 | |
| 29300 | /* Set Q = I and Update Q := Q*P */ |
| 29301 | |
| 29302 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("Full", n, n, &c_b12, &c_b22, &q[q_offset], ldq); |
| 29303 | dlapmt_cxx . . $ dlapmt_(e33ef504d4853763).(&forwrd, n, n, &q[q_offset], ldq, &iwork[1]); |
| 29304 | } |
| 29305 | |
| 29306 | if (*p >= *l && *n != *l) { |
| 29307 | |
| 29308 | /* RQ factorization of (S11 S12): ( S11 S12 ) = ( 0 S12 )*Z */ |
| 29309 | |
| 29310 | dgerq2_cxx . . $ dgerq2_(19b4abe06ca5e75b).(l, n, &b[b_offset], ldb, &tau[1], &work[1], info); |
| 29311 | |
| 29312 | /* Update A := A*Z' */ |
| 29313 | |
| 29314 | dormr2_cxx . . $ dormr2_(2f7504592752aead).("Right", "Transpose", m, n, l, &b[b_offset], ldb, &tau[1], &a[ |
| 29315 | a_offset], lda, &work[1], info); |
| 29316 | |
| 29317 | if (wantq) { |
| 29318 | |
| 29319 | /* Update Q := Q*Z' */ |
| 29320 | |
| 29321 | dormr2_cxx . . $ dormr2_(2f7504592752aead).("Right", "Transpose", n, n, l, &b[b_offset], ldb, &tau[1], |
| 29322 | &q[q_offset], ldq, &work[1], info); |
| 29323 | } |
| 29324 | |
| 29325 | /* Clean up B */ |
| 29326 | |
| 29327 | i__1 = *n - *l; |
| 29328 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("Full", l, &i__1, &c_b12, &c_b12, &b[b_offset], ldb); |
| 29329 | i__1 = *n; |
| 29330 | for (j = *n - *l + 1; j <= i__1; ++j) { |
| 29331 | i__2 = *l; |
| 29332 | for (i__ = j - *n + *l + 1; i__ <= i__2; ++i__) { |
| 29333 | b[i__ + j * b_dim1] = 0.; |
| 29334 | /* L50: */ |
| 29335 | } |
| 29336 | /* L60: */ |
| 29337 | } |
| 29338 | |
| 29339 | } |
| 29340 | |
| 29341 | /* Let N-L L */ |
| 29342 | /* A = ( A11 A12 ) M, */ |
| 29343 | |
| 29344 | /* then the following does the complete QR decomposition of A11: */ |
| 29345 | |
| 29346 | /* A11 = U*( 0 T12 )*P1' */ |
| 29347 | /* ( 0 0 ) */ |
| 29348 | |
| 29349 | i__1 = *n - *l; |
| 29350 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 29351 | iwork[i__] = 0; |
| 29352 | /* L70: */ |
| 29353 | } |
| 29354 | i__1 = *n - *l; |
| 29355 | dgeqpf_cxx . . $ dgeqpf_(89014a123b88d601).(m, &i__1, &a[a_offset], lda, &iwork[1], &tau[1], &work[1], info); |
| 29356 | |
| 29357 | /* Determine the effective rank of A11 */ |
| 29358 | |
| 29359 | *k = 0; |
| 29360 | /* Computing MIN */ |
| 29361 | i__2 = *m, i__3 = *n - *l; |
| 29362 | i__1 = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__2,i__3); |
| 29363 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 29364 | if ((d__1 = a[i__ + i__ * a_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__1)) > *tola) { |
| 29365 | ++(*k); |
| 29366 | } |
| 29367 | /* L80: */ |
| 29368 | } |
| 29369 | |
| 29370 | /* Update A12 := U'*A12, where A12 = A( 1:M, N-L+1:N ) */ |
| 29371 | |
| 29372 | /* Computing MIN */ |
| 29373 | i__2 = *m, i__3 = *n - *l; |
| 29374 | i__1 = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__2,i__3); |
| 29375 | dorm2r_cxx . . $ dorm2r_(2f7504592752aead).("Left", "Transpose", m, l, &i__1, &a[a_offset], lda, &tau[1], &a[( |
| 29376 | *n - *l + 1) * a_dim1 + 1], lda, &work[1], info); |
| 29377 | |
| 29378 | if (wantu) { |
| 29379 | |
| 29380 | /* Copy the details of U, and form U */ |
| 29381 | |
| 29382 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("Full", m, m, &c_b12, &c_b12, &u[u_offset], ldu); |
| 29383 | if (*m > 1) { |
| 29384 | i__1 = *m - 1; |
| 29385 | i__2 = *n - *l; |
| 29386 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("Lower", &i__1, &i__2, &a[a_dim1 + 2], lda, &u[u_dim1 + 2] |
| 29387 | , ldu); |
| 29388 | } |
| 29389 | /* Computing MIN */ |
| 29390 | i__2 = *m, i__3 = *n - *l; |
| 29391 | i__1 = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__2,i__3); |
| 29392 | dorg2r_cxx . . $ dorg2r_(75bc6169f7761452).(m, m, &i__1, &u[u_offset], ldu, &tau[1], &work[1], info); |
| 29393 | } |
| 29394 | |
| 29395 | if (wantq) { |
| 29396 | |
| 29397 | /* Update Q( 1:N, 1:N-L ) = Q( 1:N, 1:N-L )*P1 */ |
| 29398 | |
| 29399 | i__1 = *n - *l; |
| 29400 | dlapmt_cxx . . $ dlapmt_(e33ef504d4853763).(&forwrd, n, &i__1, &q[q_offset], ldq, &iwork[1]); |
| 29401 | } |
| 29402 | |
| 29403 | /* Clean up A: set the strictly lower triangular part of */ |
| 29404 | /* A(1:K, 1:K) = 0, and A( K+1:M, 1:N-L ) = 0. */ |
| 29405 | |
| 29406 | i__1 = *k - 1; |
| 29407 | for (j = 1; j <= i__1; ++j) { |
| 29408 | i__2 = *k; |
| 29409 | for (i__ = j + 1; i__ <= i__2; ++i__) { |
| 29410 | a[i__ + j * a_dim1] = 0.; |
| 29411 | /* L90: */ |
| 29412 | } |
| 29413 | /* L100: */ |
| 29414 | } |
| 29415 | if (*m > *k) { |
| 29416 | i__1 = *m - *k; |
| 29417 | i__2 = *n - *l; |
| 29418 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("Full", &i__1, &i__2, &c_b12, &c_b12, &a[*k + 1 + a_dim1], |
| 29419 | lda); |
| 29420 | } |
| 29421 | |
| 29422 | if (*n - *l > *k) { |
| 29423 | |
| 29424 | /* RQ factorization of ( T11 T12 ) = ( 0 T12 )*Z1 */ |
| 29425 | |
| 29426 | i__1 = *n - *l; |
| 29427 | dgerq2_cxx . . $ dgerq2_(19b4abe06ca5e75b).(k, &i__1, &a[a_offset], lda, &tau[1], &work[1], info); |
| 29428 | |
| 29429 | if (wantq) { |
| 29430 | |
| 29431 | /* Update Q( 1:N,1:N-L ) = Q( 1:N,1:N-L )*Z1' */ |
| 29432 | |
| 29433 | i__1 = *n - *l; |
| 29434 | dormr2_cxx . . $ dormr2_(2f7504592752aead).("Right", "Transpose", n, &i__1, k, &a[a_offset], lda, & |
| 29435 | tau[1], &q[q_offset], ldq, &work[1], info); |
| 29436 | } |
| 29437 | |
| 29438 | /* Clean up A */ |
| 29439 | |
| 29440 | i__1 = *n - *l - *k; |
| 29441 | dlaset_cxx . . $ dlaset_(6e7b8c513fce09af).("Full", k, &i__1, &c_b12, &c_b12, &a[a_offset], lda); |
| 29442 | i__1 = *n - *l; |
| 29443 | for (j = *n - *l - *k + 1; j <= i__1; ++j) { |
| 29444 | i__2 = *k; |
| 29445 | for (i__ = j - *n + *l + *k + 1; i__ <= i__2; ++i__) { |
| 29446 | a[i__ + j * a_dim1] = 0.; |
| 29447 | /* L110: */ |
| 29448 | } |
| 29449 | /* L120: */ |
| 29450 | } |
| 29451 | |
| 29452 | } |
| 29453 | |
| 29454 | if (*m > *k) { |
| 29455 | |
| 29456 | /* QR factorization of A( K+1:M,N-L+1:N ) */ |
| 29457 | |
| 29458 | i__1 = *m - *k; |
| 29459 | dgeqr2_cxx . . $ dgeqr2_(19b4abe06ca5e75b).(&i__1, l, &a[*k + 1 + (*n - *l + 1) * a_dim1], lda, &tau[1], & |
| 29460 | work[1], info); |
| 29461 | |
| 29462 | if (wantu) { |
| 29463 | |
| 29464 | /* Update U(:,K+1:M) := U(:,K+1:M)*U1 */ |
| 29465 | |
| 29466 | i__1 = *m - *k; |
| 29467 | /* Computing MIN */ |
| 29468 | i__3 = *m - *k; |
| 29469 | i__2 = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__3,*l); |
| 29470 | dorm2r_cxx . . $ dorm2r_(2f7504592752aead).("Right", "No transpose", m, &i__1, &i__2, &a[*k + 1 + (*n |
| 29471 | - *l + 1) * a_dim1], lda, &tau[1], &u[(*k + 1) * u_dim1 + |
| 29472 | 1], ldu, &work[1], info); |
| 29473 | } |
| 29474 | |
| 29475 | /* Clean up */ |
| 29476 | |
| 29477 | i__1 = *n; |
| 29478 | for (j = *n - *l + 1; j <= i__1; ++j) { |
| 29479 | i__2 = *m; |
| 29480 | for (i__ = j - *n + *k + *l + 1; i__ <= i__2; ++i__) { |
| 29481 | a[i__ + j * a_dim1] = 0.; |
| 29482 | /* L130: */ |
| 29483 | } |
| 29484 | /* L140: */ |
| 29485 | } |
| 29486 | |
| 29487 | } |
| 29488 | |
| 29489 | return 0; |
| 29490 | |
| 29491 | /* End of DGGSVP */ |
| 29492 | |
| 29493 | } /* dggsvp_ */ |
| 29494 | |
| 29495 | /* Subroutine */ int dgtcon_cxx . . $ dgtcon_(9aed0b834527e25).(const char *norm, integercxx . . $ integer# *n, double *dl, |
| 29496 | double *d__, double *du, double *du2, integercxx . . $ integer# *ipiv, |
| 29497 | double *anorm, double *rcond, double *work, integercxx . . $ integer# * |
| 29498 | iwork, integercxx . . $ integer# *info) |
| 29499 | { |
| 29500 | /* Table of constant values */ |
| 29501 | static integercxx . . $ integer# c__1 = 1; |
| 29502 | |
| 29503 | /* System generated locals */ |
| 29504 | integercxx . . $ integer# i__1; |
| 29505 | |
| 29506 | /* Local variables */ |
| 29507 | integercxx . . $ integer# i__, kase, kase1; |
| 29508 | integercxx . . $ integer# isave[3]; |
| 29509 | double ainvnm; |
| 29510 | bool onenrm; |
| 29511 | |
| 29512 | /* -- LAPACK routine (version 3.1) -- */ |
| 29513 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 29514 | /* November 2006 */ |
| 29515 | |
| 29516 | /* Modified to call DLACN2 in place of DLACON, 5 Feb 03, SJH. */ |
| 29517 | |
| 29518 | /* .. Scalar Arguments .. */ |
| 29519 | /* .. */ |
| 29520 | /* .. Array Arguments .. */ |
| 29521 | /* .. */ |
| 29522 | |
| 29523 | /* Purpose */ |
| 29524 | /* ======= */ |
| 29525 | |
| 29526 | /* DGTCON estimates the reciprocal of the condition number of a real */ |
| 29527 | /* tridiagonal matrix A using the LU factorization as computed by */ |
| 29528 | /* DGTTRF. */ |
| 29529 | |
| 29530 | /* An estimate is obtained for norm(inv(A)), and the reciprocal of the */ |
| 29531 | /* condition number is computed as RCOND = 1 / (ANORM * norm(inv(A))). */ |
| 29532 | |
| 29533 | /* Arguments */ |
| 29534 | /* ========= */ |
| 29535 | |
| 29536 | /* NORM (input) CHARACTER*1 */ |
| 29537 | /* Specifies whether the 1-norm condition number or the */ |
| 29538 | /* infinity-norm condition number is required: */ |
| 29539 | /* = '1' or 'O': 1-norm; */ |
| 29540 | /* = 'I': Infinity-norm. */ |
| 29541 | |
| 29542 | /* N (input) INTEGER */ |
| 29543 | /* The order of the matrix A. N >= 0. */ |
| 29544 | |
| 29545 | /* DL (input) DOUBLE PRECISION array, dimension (N-1) */ |
| 29546 | /* The (n-1) multipliers that define the matrix L from the */ |
| 29547 | /* LU factorization of A as computed by DGTTRF. */ |
| 29548 | |
| 29549 | /* D (input) DOUBLE PRECISION array, dimension (N) */ |
| 29550 | /* The n diagonal elements of the upper triangular matrix U from */ |
| 29551 | /* the LU factorization of A. */ |
| 29552 | |
| 29553 | /* DU (input) DOUBLE PRECISION array, dimension (N-1) */ |
| 29554 | /* The (n-1) elements of the first superdiagonal of U. */ |
| 29555 | |
| 29556 | /* DU2 (input) DOUBLE PRECISION array, dimension (N-2) */ |
| 29557 | /* The (n-2) elements of the second superdiagonal of U. */ |
| 29558 | |
| 29559 | /* IPIV (input) INTEGER array, dimension (N) */ |
| 29560 | /* The pivot indices; for 1 <= i <= n, row i of the matrix was */ |
| 29561 | /* interchanged with row IPIV(i). IPIV(i) will always be either */ |
| 29562 | /* i or i+1; IPIV(i) = i indicates a row interchange was not */ |
| 29563 | /* required. */ |
| 29564 | |
| 29565 | /* ANORM (input) DOUBLE PRECISION */ |
| 29566 | /* If NORM = '1' or 'O', the 1-norm of the original matrix A. */ |
| 29567 | /* If NORM = 'I', the infinity-norm of the original matrix A. */ |
| 29568 | |
| 29569 | /* RCOND (output) DOUBLE PRECISION */ |
| 29570 | /* The reciprocal of the condition number of the matrix A, */ |
| 29571 | /* computed as RCOND = 1/(ANORM * AINVNM), where AINVNM is an */ |
| 29572 | /* estimate of the 1-norm of inv(A) computed in this routine. */ |
| 29573 | |
| 29574 | /* WORK (workspace) DOUBLE PRECISION array, dimension (2*N) */ |
| 29575 | |
| 29576 | /* IWORK (workspace) INTEGER array, dimension (N) */ |
| 29577 | |
| 29578 | /* INFO (output) INTEGER */ |
| 29579 | /* = 0: successful exit */ |
| 29580 | /* < 0: if INFO = -i, the i-th argument had an illegal value */ |
| 29581 | |
| 29582 | /* ===================================================================== */ |
| 29583 | |
| 29584 | /* .. Parameters .. */ |
| 29585 | /* .. */ |
| 29586 | /* .. Local Scalars .. */ |
| 29587 | /* .. */ |
| 29588 | /* .. Local Arrays .. */ |
| 29589 | /* .. */ |
| 29590 | /* .. External Functions .. */ |
| 29591 | /* .. */ |
| 29592 | /* .. External Subroutines .. */ |
| 29593 | /* .. */ |
| 29594 | /* .. Executable Statements .. */ |
| 29595 | |
| 29596 | /* Test the input arguments. */ |
| 29597 | |
| 29598 | /* Parameter adjustments */ |
| 29599 | --iwork; |
| 29600 | --work; |
| 29601 | --ipiv; |
| 29602 | --du2; |
| 29603 | --du; |
| 29604 | --d__; |
| 29605 | --dl; |
| 29606 | |
| 29607 | /* Function Body */ |
| 29608 | *info = 0; |
| 29609 | onenrm = *(unsigned char *)norm == '1' || lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(norm, "O"); |
| 29610 | if (! onenrm && ! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(norm, "I")) { |
| 29611 | *info = -1; |
| 29612 | } else if (*n < 0) { |
| 29613 | *info = -2; |
| 29614 | } else if (*anorm < 0.) { |
| 29615 | *info = -8; |
| 29616 | } |
| 29617 | if (*info != 0) { |
| 29618 | i__1 = -(*info); |
| 29619 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGTCON", &i__1); |
| 29620 | return 0; |
| 29621 | } |
| 29622 | |
| 29623 | /* Quick return if possible */ |
| 29624 | |
| 29625 | *rcond = 0.; |
| 29626 | if (*n == 0) { |
| 29627 | *rcond = 1.; |
| 29628 | return 0; |
| 29629 | } else if (*anorm == 0.) { |
| 29630 | return 0; |
| 29631 | } |
| 29632 | |
| 29633 | /* Check that D(1:N) is non-zero. */ |
| 29634 | |
| 29635 | i__1 = *n; |
| 29636 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 29637 | if (d__[i__] == 0.) { |
| 29638 | return 0; |
| 29639 | } |
| 29640 | /* L10: */ |
| 29641 | } |
| 29642 | |
| 29643 | ainvnm = 0.; |
| 29644 | if (onenrm) { |
| 29645 | kase1 = 1; |
| 29646 | } else { |
| 29647 | kase1 = 2; |
| 29648 | } |
| 29649 | kase = 0; |
| 29650 | L20: |
| 29651 | dlacn2_cxx . . $ dlacn2_(2d9e0fe6bd3e0917).(n, &work[*n + 1], &work[1], &iwork[1], &ainvnm, &kase, isave); |
| 29652 | if (kase != 0) { |
| 29653 | if (kase == kase1) { |
| 29654 | |
| 29655 | /* Multiply by inv(U)*inv(L). */ |
| 29656 | |
| 29657 | dgttrs_cxx . . $ dgttrs_(9ad804120c20c64).("No transpose", n, &c__1, &dl[1], &d__[1], &du[1], &du2[1] |
| 29658 | , &ipiv[1], &work[1], n, info); |
| 29659 | } else { |
| 29660 | |
| 29661 | /* Multiply by inv(L')*inv(U'). */ |
| 29662 | |
| 29663 | dgttrs_cxx . . $ dgttrs_(9ad804120c20c64).("Transpose", n, &c__1, &dl[1], &d__[1], &du[1], &du2[1], & |
| 29664 | ipiv[1], &work[1], n, info); |
| 29665 | } |
| 29666 | goto L20; |
| 29667 | } |
| 29668 | |
| 29669 | /* Compute the estimate of the reciprocal condition number. */ |
| 29670 | |
| 29671 | if (ainvnm != 0.) { |
| 29672 | *rcond = 1. / ainvnm / *anorm; |
| 29673 | } |
| 29674 | |
| 29675 | return 0; |
| 29676 | |
| 29677 | /* End of DGTCON */ |
| 29678 | |
| 29679 | } /* dgtcon_ */ |
| 29680 | |
| 29681 | /* Subroutine */ int dgtrfs_cxx . . $ dgtrfs_(2e3bde1a117b7848).(const char *trans, integercxx . . $ integer# *n, integercxx . . $ integer# *nrhs, |
| 29682 | double *dl, double *d__, double *du, double *dlf, |
| 29683 | double *df, double *duf, double *du2, integercxx . . $ integer# *ipiv, |
| 29684 | double *b, integercxx . . $ integer# *ldb, double *x, integercxx . . $ integer# *ldx, double * |
| 29685 | ferr, double *berr, double *work, integercxx . . $ integer# *iwork, integercxx . . $ integer# * |
| 29686 | info) |
| 29687 | { |
| 29688 | /* Table of constant values */ |
| 29689 | static integercxx . . $ integer# c__1 = 1; |
| 29690 | static double c_b18 = -1.; |
| 29691 | static double c_b19 = 1.; |
| 29692 | |
| 29693 | /* System generated locals */ |
| 29694 | integercxx . . $ integer# b_dim1, b_offset, x_dim1, x_offset, i__1, i__2; |
| 29695 | double d__1, d__2, d__3, d__4; |
| 29696 | |
| 29697 | /* Local variables */ |
| 29698 | integercxx . . $ integer# i__, j; |
| 29699 | double s; |
| 29700 | integercxx . . $ integer# nz; |
| 29701 | double eps; |
| 29702 | integercxx . . $ integer# kase; |
| 29703 | double safe1, safe2; |
| 29704 | integercxx . . $ integer# isave[3]; |
| 29705 | integercxx . . $ integer# count; |
| 29706 | double safmin; |
| 29707 | bool notran; |
| 29708 | char transn[1]; |
| 29709 | char transt[1]; |
| 29710 | double lstres; |
| 29711 | |
| 29712 | |
| 29713 | /* -- LAPACK routine (version 3.1) -- */ |
| 29714 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 29715 | /* November 2006 */ |
| 29716 | |
| 29717 | /* Modified to call DLACN2 in place of DLACON, 5 Feb 03, SJH. */ |
| 29718 | |
| 29719 | /* .. Scalar Arguments .. */ |
| 29720 | /* .. */ |
| 29721 | /* .. Array Arguments .. */ |
| 29722 | /* .. */ |
| 29723 | |
| 29724 | /* Purpose */ |
| 29725 | /* ======= */ |
| 29726 | |
| 29727 | /* DGTRFS improves the computed solution to a system of linear */ |
| 29728 | /* equations when the coefficient matrix is tridiagonal, and provides */ |
| 29729 | /* error bounds and backward error estimates for the solution. */ |
| 29730 | |
| 29731 | /* Arguments */ |
| 29732 | /* ========= */ |
| 29733 | |
| 29734 | /* TRANS (input) CHARACTER*1 */ |
| 29735 | /* Specifies the form of the system of equations: */ |
| 29736 | /* = 'N': A * X = B (No transpose) */ |
| 29737 | /* = 'T': A**T * X = B (Transpose) */ |
| 29738 | /* = 'C': A**H * X = B (Conjugate transpose = Transpose) */ |
| 29739 | |
| 29740 | /* N (input) INTEGER */ |
| 29741 | /* The order of the matrix A. N >= 0. */ |
| 29742 | |
| 29743 | /* NRHS (input) INTEGER */ |
| 29744 | /* The number of right hand sides, i.e., the number of columns */ |
| 29745 | /* of the matrix B. NRHS >= 0. */ |
| 29746 | |
| 29747 | /* DL (input) DOUBLE PRECISION array, dimension (N-1) */ |
| 29748 | /* The (n-1) subdiagonal elements of A. */ |
| 29749 | |
| 29750 | /* D (input) DOUBLE PRECISION array, dimension (N) */ |
| 29751 | /* The diagonal elements of A. */ |
| 29752 | |
| 29753 | /* DU (input) DOUBLE PRECISION array, dimension (N-1) */ |
| 29754 | /* The (n-1) superdiagonal elements of A. */ |
| 29755 | |
| 29756 | /* DLF (input) DOUBLE PRECISION array, dimension (N-1) */ |
| 29757 | /* The (n-1) multipliers that define the matrix L from the */ |
| 29758 | /* LU factorization of A as computed by DGTTRF. */ |
| 29759 | |
| 29760 | /* DF (input) DOUBLE PRECISION array, dimension (N) */ |
| 29761 | /* The n diagonal elements of the upper triangular matrix U from */ |
| 29762 | /* the LU factorization of A. */ |
| 29763 | |
| 29764 | /* DUF (input) DOUBLE PRECISION array, dimension (N-1) */ |
| 29765 | /* The (n-1) elements of the first superdiagonal of U. */ |
| 29766 | |
| 29767 | /* DU2 (input) DOUBLE PRECISION array, dimension (N-2) */ |
| 29768 | /* The (n-2) elements of the second superdiagonal of U. */ |
| 29769 | |
| 29770 | /* IPIV (input) INTEGER array, dimension (N) */ |
| 29771 | /* The pivot indices; for 1 <= i <= n, row i of the matrix was */ |
| 29772 | /* interchanged with row IPIV(i). IPIV(i) will always be either */ |
| 29773 | /* i or i+1; IPIV(i) = i indicates a row interchange was not */ |
| 29774 | /* required. */ |
| 29775 | |
| 29776 | /* B (input) DOUBLE PRECISION array, dimension (LDB,NRHS) */ |
| 29777 | /* The right hand side matrix B. */ |
| 29778 | |
| 29779 | /* LDB (input) INTEGER */ |
| 29780 | /* The leading dimension of the array B. LDB >= max(1,N). */ |
| 29781 | |
| 29782 | /* X (input/output) DOUBLE PRECISION array, dimension (LDX,NRHS) */ |
| 29783 | /* On entry, the solution matrix X, as computed by DGTTRS. */ |
| 29784 | /* On exit, the improved solution matrix X. */ |
| 29785 | |
| 29786 | /* LDX (input) INTEGER */ |
| 29787 | /* The leading dimension of the array X. LDX >= max(1,N). */ |
| 29788 | |
| 29789 | /* FERR (output) DOUBLE PRECISION array, dimension (NRHS) */ |
| 29790 | /* The estimated forward error bound for each solution vector */ |
| 29791 | /* X(j) (the j-th column of the solution matrix X). */ |
| 29792 | /* If XTRUE is the true solution corresponding to X(j), FERR(j) */ |
| 29793 | /* is an estimated upper bound for the magnitude of the largest */ |
| 29794 | /* element in (X(j) - XTRUE) divided by the magnitude of the */ |
| 29795 | /* largest element in X(j). The estimate is as reliable as */ |
| 29796 | /* the estimate for RCOND, and is almost always a slight */ |
| 29797 | /* overestimate of the true error. */ |
| 29798 | |
| 29799 | /* BERR (output) DOUBLE PRECISION array, dimension (NRHS) */ |
| 29800 | /* The componentwise relative backward error of each solution */ |
| 29801 | /* vector X(j) (i.e., the smallest relative change in */ |
| 29802 | /* any element of A or B that makes X(j) an exact solution). */ |
| 29803 | |
| 29804 | /* WORK (workspace) DOUBLE PRECISION array, dimension (3*N) */ |
| 29805 | |
| 29806 | /* IWORK (workspace) INTEGER array, dimension (N) */ |
| 29807 | |
| 29808 | /* INFO (output) INTEGER */ |
| 29809 | /* = 0: successful exit */ |
| 29810 | /* < 0: if INFO = -i, the i-th argument had an illegal value */ |
| 29811 | |
| 29812 | /* Internal Parameters */ |
| 29813 | /* =================== */ |
| 29814 | |
| 29815 | /* ITMAX is the maximum number of steps of iterative refinement. */ |
| 29816 | |
| 29817 | /* ===================================================================== */ |
| 29818 | |
| 29819 | /* .. Parameters .. */ |
| 29820 | /* .. */ |
| 29821 | /* .. Local Scalars .. */ |
| 29822 | /* .. */ |
| 29823 | /* .. Local Arrays .. */ |
| 29824 | /* .. */ |
| 29825 | /* .. External Subroutines .. */ |
| 29826 | /* .. */ |
| 29827 | /* .. Intrinsic Functions .. */ |
| 29828 | /* .. */ |
| 29829 | /* .. External Functions .. */ |
| 29830 | /* .. */ |
| 29831 | /* .. Executable Statements .. */ |
| 29832 | |
| 29833 | /* Test the input parameters. */ |
| 29834 | |
| 29835 | /* Parameter adjustments */ |
| 29836 | --dl; |
| 29837 | --d__; |
| 29838 | --du; |
| 29839 | --dlf; |
| 29840 | --df; |
| 29841 | --duf; |
| 29842 | --du2; |
| 29843 | --ipiv; |
| 29844 | b_dim1 = *ldb; |
| 29845 | b_offset = 1 + b_dim1; |
| 29846 | b -= b_offset; |
| 29847 | x_dim1 = *ldx; |
| 29848 | x_offset = 1 + x_dim1; |
| 29849 | x -= x_offset; |
| 29850 | --ferr; |
| 29851 | --berr; |
| 29852 | --work; |
| 29853 | --iwork; |
| 29854 | |
| 29855 | /* Function Body */ |
| 29856 | *info = 0; |
| 29857 | notran = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(trans, "N"); |
| 29858 | if (! notran && ! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(trans, "T") && ! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).( |
| 29859 | trans, "C")) { |
| 29860 | *info = -1; |
| 29861 | } else if (*n < 0) { |
| 29862 | *info = -2; |
| 29863 | } else if (*nrhs < 0) { |
| 29864 | *info = -3; |
| 29865 | } else if (*ldb < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 29866 | *info = -13; |
| 29867 | } else if (*ldx < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 29868 | *info = -15; |
| 29869 | } |
| 29870 | if (*info != 0) { |
| 29871 | i__1 = -(*info); |
| 29872 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGTRFS", &i__1); |
| 29873 | return 0; |
| 29874 | } |
| 29875 | |
| 29876 | /* Quick return if possible */ |
| 29877 | |
| 29878 | if (*n == 0 || *nrhs == 0) { |
| 29879 | i__1 = *nrhs; |
| 29880 | for (j = 1; j <= i__1; ++j) { |
| 29881 | ferr[j] = 0.; |
| 29882 | berr[j] = 0.; |
| 29883 | /* L10: */ |
| 29884 | } |
| 29885 | return 0; |
| 29886 | } |
| 29887 | |
| 29888 | if (notran) { |
| 29889 | *(unsigned char *)transn = 'N'; |
| 29890 | *(unsigned char *)transt = 'T'; |
| 29891 | } else { |
| 29892 | *(unsigned char *)transn = 'T'; |
| 29893 | *(unsigned char *)transt = 'N'; |
| 29894 | } |
| 29895 | |
| 29896 | /* NZ = maximum number of nonzero elements in each row of A, plus 1 */ |
| 29897 | |
| 29898 | nz = 4; |
| 29899 | eps = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("Epsilon"); |
| 29900 | safmin = dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("Safe minimum"); |
| 29901 | safe1 = nz * safmin; |
| 29902 | safe2 = safe1 / eps; |
| 29903 | |
| 29904 | /* Do for each right hand side */ |
| 29905 | |
| 29906 | i__1 = *nrhs; |
| 29907 | for (j = 1; j <= i__1; ++j) { |
| 29908 | |
| 29909 | count = 1; |
| 29910 | lstres = 3.; |
| 29911 | L20: |
| 29912 | |
| 29913 | /* Loop until stopping criterion is satisfied. */ |
| 29914 | |
| 29915 | /* Compute residual R = B - op(A) * X, */ |
| 29916 | /* where op(A) = A, A**T, or A**H, depending on TRANS. */ |
| 29917 | |
| 29918 | dcopy_cxx . . $ dcopy_(ec261fd7ec3b6bf6).(n, &b[j * b_dim1 + 1], &c__1, &work[*n + 1], &c__1); |
| 29919 | dlagtm_cxx . . $ dlagtm_(f67ba57b36a5f3c5).(trans, n, &c__1, &c_b18, &dl[1], &d__[1], &du[1], &x[j * |
| 29920 | x_dim1 + 1], ldx, &c_b19, &work[*n + 1], n); |
| 29921 | |
| 29922 | /* Compute abs(op(A))*abs(x) + abs(b) for use in the backward */ |
| 29923 | /* error bound. */ |
| 29924 | |
| 29925 | if (notran) { |
| 29926 | if (*n == 1) { |
| 29927 | work[1] = (d__1 = b[j * b_dim1 + 1], abscxx . . $ abs(447c67c6676f75c3).(d__1)) + (d__2 = d__[ |
| 29928 | 1] * x[j * x_dim1 + 1], abscxx . . $ abs(447c67c6676f75c3).(d__2)); |
| 29929 | } else { |
| 29930 | work[1] = (d__1 = b[j * b_dim1 + 1], abscxx . . $ abs(447c67c6676f75c3).(d__1)) + (d__2 = d__[ |
| 29931 | 1] * x[j * x_dim1 + 1], abscxx . . $ abs(447c67c6676f75c3).(d__2)) + (d__3 = du[1] * |
| 29932 | x[j * x_dim1 + 2], abscxx . . $ abs(447c67c6676f75c3).(d__3)); |
| 29933 | i__2 = *n - 1; |
| 29934 | for (i__ = 2; i__ <= i__2; ++i__) { |
| 29935 | work[i__] = (d__1 = b[i__ + j * b_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__1)) + ( |
| 29936 | d__2 = dl[i__ - 1] * x[i__ - 1 + j * x_dim1], abscxx . . $ abs(447c67c6676f75c3).( |
| 29937 | d__2)) + (d__3 = d__[i__] * x[i__ + j * x_dim1], |
| 29938 | abscxx . . $ abs(447c67c6676f75c3).(d__3)) + (d__4 = du[i__] * x[i__ + 1 + j * |
| 29939 | x_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__4)); |
| 29940 | /* L30: */ |
| 29941 | } |
| 29942 | work[*n] = (d__1 = b[*n + j * b_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__1)) + (d__2 = |
| 29943 | dl[*n - 1] * x[*n - 1 + j * x_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__2)) + ( |
| 29944 | d__3 = d__[*n] * x[*n + j * x_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__3)); |
| 29945 | } |
| 29946 | } else { |
| 29947 | if (*n == 1) { |
| 29948 | work[1] = (d__1 = b[j * b_dim1 + 1], abscxx . . $ abs(447c67c6676f75c3).(d__1)) + (d__2 = d__[ |
| 29949 | 1] * x[j * x_dim1 + 1], abscxx . . $ abs(447c67c6676f75c3).(d__2)); |
| 29950 | } else { |
| 29951 | work[1] = (d__1 = b[j * b_dim1 + 1], abscxx . . $ abs(447c67c6676f75c3).(d__1)) + (d__2 = d__[ |
| 29952 | 1] * x[j * x_dim1 + 1], abscxx . . $ abs(447c67c6676f75c3).(d__2)) + (d__3 = dl[1] * |
| 29953 | x[j * x_dim1 + 2], abscxx . . $ abs(447c67c6676f75c3).(d__3)); |
| 29954 | i__2 = *n - 1; |
| 29955 | for (i__ = 2; i__ <= i__2; ++i__) { |
| 29956 | work[i__] = (d__1 = b[i__ + j * b_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__1)) + ( |
| 29957 | d__2 = du[i__ - 1] * x[i__ - 1 + j * x_dim1], abscxx . . $ abs(447c67c6676f75c3).( |
| 29958 | d__2)) + (d__3 = d__[i__] * x[i__ + j * x_dim1], |
| 29959 | abscxx . . $ abs(447c67c6676f75c3).(d__3)) + (d__4 = dl[i__] * x[i__ + 1 + j * |
| 29960 | x_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__4)); |
| 29961 | /* L40: */ |
| 29962 | } |
| 29963 | work[*n] = (d__1 = b[*n + j * b_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__1)) + (d__2 = |
| 29964 | du[*n - 1] * x[*n - 1 + j * x_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__2)) + ( |
| 29965 | d__3 = d__[*n] * x[*n + j * x_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__3)); |
| 29966 | } |
| 29967 | } |
| 29968 | |
| 29969 | /* Compute componentwise relative backward error from formula */ |
| 29970 | |
| 29971 | /* max(i) ( abs(R(i)) / ( abs(op(A))*abs(X) + abs(B) )(i) ) */ |
| 29972 | |
| 29973 | /* where abs(Z) is the componentwise absolute value of the matrix */ |
| 29974 | /* or vector Z. If the i-th component of the denominator is less */ |
| 29975 | /* than SAFE2, then SAFE1 is added to the i-th components of the */ |
| 29976 | /* numerator and denominator before dividing. */ |
| 29977 | |
| 29978 | s = 0.; |
| 29979 | i__2 = *n; |
| 29980 | for (i__ = 1; i__ <= i__2; ++i__) { |
| 29981 | if (work[i__] > safe2) { |
| 29982 | /* Computing MAX */ |
| 29983 | d__2 = s, d__3 = (d__1 = work[*n + i__], abscxx . . $ abs(447c67c6676f75c3).(d__1)) / work[ |
| 29984 | i__]; |
| 29985 | s = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__2,d__3); |
| 29986 | } else { |
| 29987 | /* Computing MAX */ |
| 29988 | d__2 = s, d__3 = ((d__1 = work[*n + i__], abscxx . . $ abs(447c67c6676f75c3).(d__1)) + safe1) |
| 29989 | / (work[i__] + safe1); |
| 29990 | s = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__2,d__3); |
| 29991 | } |
| 29992 | /* L50: */ |
| 29993 | } |
| 29994 | berr[j] = s; |
| 29995 | |
| 29996 | /* Test stopping criterion. Continue iterating if */ |
| 29997 | /* 1) The residual BERR(J) is larger than machine epsilon, and */ |
| 29998 | /* 2) BERR(J) decreased by at least a factor of 2 during the */ |
| 29999 | /* last iteration, and */ |
| 30000 | /* 3) At most ITMAX iterations tried. */ |
| 30001 | |
| 30002 | if (berr[j] > eps && berr[j] * 2. <= lstres && count <= 5) { |
| 30003 | |
| 30004 | /* Update solution and try again. */ |
| 30005 | |
| 30006 | dgttrs_cxx . . $ dgttrs_(9ad804120c20c64).(trans, n, &c__1, &dlf[1], &df[1], &duf[1], &du2[1], &ipiv[ |
| 30007 | 1], &work[*n + 1], n, info); |
| 30008 | daxpy_cxx . . $ daxpy_(4b39f621356f7e14).(n, &c_b19, &work[*n + 1], &c__1, &x[j * x_dim1 + 1], &c__1) |
| 30009 | ; |
| 30010 | lstres = berr[j]; |
| 30011 | ++count; |
| 30012 | goto L20; |
| 30013 | } |
| 30014 | |
| 30015 | /* Bound error from formula */ |
| 30016 | |
| 30017 | /* norm(X - XTRUE) / norm(X) .le. FERR = */ |
| 30018 | /* norm( abs(inv(op(A)))* */ |
| 30019 | /* ( abs(R) + NZ*EPS*( abs(op(A))*abs(X)+abs(B) ))) / norm(X) */ |
| 30020 | |
| 30021 | /* where */ |
| 30022 | /* norm(Z) is the magnitude of the largest component of Z */ |
| 30023 | /* inv(op(A)) is the inverse of op(A) */ |
| 30024 | /* abs(Z) is the componentwise absolute value of the matrix or */ |
| 30025 | /* vector Z */ |
| 30026 | /* NZ is the maximum number of nonzeros in any row of A, plus 1 */ |
| 30027 | /* EPS is machine epsilon */ |
| 30028 | |
| 30029 | /* The i-th component of abs(R)+NZ*EPS*(abs(op(A))*abs(X)+abs(B)) */ |
| 30030 | /* is incremented by SAFE1 if the i-th component of */ |
| 30031 | /* abs(op(A))*abs(X) + abs(B) is less than SAFE2. */ |
| 30032 | |
| 30033 | /* Use DLACN2 to estimate the infinity-norm of the matrix */ |
| 30034 | /* inv(op(A)) * diag(W), */ |
| 30035 | /* where W = abs(R) + NZ*EPS*( abs(op(A))*abs(X)+abs(B) ))) */ |
| 30036 | |
| 30037 | i__2 = *n; |
| 30038 | for (i__ = 1; i__ <= i__2; ++i__) { |
| 30039 | if (work[i__] > safe2) { |
| 30040 | work[i__] = (d__1 = work[*n + i__], abscxx . . $ abs(447c67c6676f75c3).(d__1)) + nz * eps * |
| 30041 | work[i__]; |
| 30042 | } else { |
| 30043 | work[i__] = (d__1 = work[*n + i__], abscxx . . $ abs(447c67c6676f75c3).(d__1)) + nz * eps * |
| 30044 | work[i__] + safe1; |
| 30045 | } |
| 30046 | /* L60: */ |
| 30047 | } |
| 30048 | |
| 30049 | kase = 0; |
| 30050 | L70: |
| 30051 | dlacn2_cxx . . $ dlacn2_(2d9e0fe6bd3e0917).(n, &work[(*n << 1) + 1], &work[*n + 1], &iwork[1], &ferr[j], & |
| 30052 | kase, isave); |
| 30053 | if (kase != 0) { |
| 30054 | if (kase == 1) { |
| 30055 | |
| 30056 | /* Multiply by diag(W)*inv(op(A)**T). */ |
| 30057 | |
| 30058 | dgttrs_cxx . . $ dgttrs_(9ad804120c20c64).(transt, n, &c__1, &dlf[1], &df[1], &duf[1], &du2[1], & |
| 30059 | ipiv[1], &work[*n + 1], n, info); |
| 30060 | i__2 = *n; |
| 30061 | for (i__ = 1; i__ <= i__2; ++i__) { |
| 30062 | work[*n + i__] = work[i__] * work[*n + i__]; |
| 30063 | /* L80: */ |
| 30064 | } |
| 30065 | } else { |
| 30066 | |
| 30067 | /* Multiply by inv(op(A))*diag(W). */ |
| 30068 | |
| 30069 | i__2 = *n; |
| 30070 | for (i__ = 1; i__ <= i__2; ++i__) { |
| 30071 | work[*n + i__] = work[i__] * work[*n + i__]; |
| 30072 | /* L90: */ |
| 30073 | } |
| 30074 | dgttrs_cxx . . $ dgttrs_(9ad804120c20c64).(transn, n, &c__1, &dlf[1], &df[1], &duf[1], &du2[1], & |
| 30075 | ipiv[1], &work[*n + 1], n, info); |
| 30076 | } |
| 30077 | goto L70; |
| 30078 | } |
| 30079 | |
| 30080 | /* Normalize error. */ |
| 30081 | |
| 30082 | lstres = 0.; |
| 30083 | i__2 = *n; |
| 30084 | for (i__ = 1; i__ <= i__2; ++i__) { |
| 30085 | /* Computing MAX */ |
| 30086 | d__2 = lstres, d__3 = (d__1 = x[i__ + j * x_dim1], abscxx . . $ abs(447c67c6676f75c3).(d__1)); |
| 30087 | lstres = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(d__2,d__3); |
| 30088 | /* L100: */ |
| 30089 | } |
| 30090 | if (lstres != 0.) { |
| 30091 | ferr[j] /= lstres; |
| 30092 | } |
| 30093 | |
| 30094 | /* L110: */ |
| 30095 | } |
| 30096 | |
| 30097 | return 0; |
| 30098 | |
| 30099 | /* End of DGTRFS */ |
| 30100 | |
| 30101 | } /* dgtrfs_ */ |
| 30102 | |
| 30103 | /* Subroutine */ int dgtsv_cxx . . $ dgtsv_(916c3f7b16e51090).(integercxx . . $ integer# *n, integercxx . . $ integer# *nrhs, double *dl, |
| 30104 | double *d__, double *du, double *b, integercxx . . $ integer# *ldb, integercxx . . $ integer# |
| 30105 | *info) |
| 30106 | { |
| 30107 | /* System generated locals */ |
| 30108 | integercxx . . $ integer# b_dim1, b_offset, i__1, i__2; |
| 30109 | double d__1, d__2; |
| 30110 | |
| 30111 | /* Local variables */ |
| 30112 | integercxx . . $ integer# i__, j; |
| 30113 | double fact, temp; |
| 30114 | |
| 30115 | |
| 30116 | /* -- LAPACK routine (version 3.1) -- */ |
| 30117 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 30118 | /* November 2006 */ |
| 30119 | |
| 30120 | /* .. Scalar Arguments .. */ |
| 30121 | /* .. */ |
| 30122 | /* .. Array Arguments .. */ |
| 30123 | /* .. */ |
| 30124 | |
| 30125 | /* Purpose */ |
| 30126 | /* ======= */ |
| 30127 | |
| 30128 | /* DGTSV solves the equation */ |
| 30129 | |
| 30130 | /* A*X = B, */ |
| 30131 | |
| 30132 | /* where A is an n by n tridiagonal matrix, by Gaussian elimination with */ |
| 30133 | /* partial pivoting. */ |
| 30134 | |
| 30135 | /* Note that the equation A'*X = B may be solved by interchanging the */ |
| 30136 | /* order of the arguments DU and DL. */ |
| 30137 | |
| 30138 | /* Arguments */ |
| 30139 | /* ========= */ |
| 30140 | |
| 30141 | /* N (input) INTEGER */ |
| 30142 | /* The order of the matrix A. N >= 0. */ |
| 30143 | |
| 30144 | /* NRHS (input) INTEGER */ |
| 30145 | /* The number of right hand sides, i.e., the number of columns */ |
| 30146 | /* of the matrix B. NRHS >= 0. */ |
| 30147 | |
| 30148 | /* DL (input/output) DOUBLE PRECISION array, dimension (N-1) */ |
| 30149 | /* On entry, DL must contain the (n-1) sub-diagonal elements of */ |
| 30150 | /* A. */ |
| 30151 | |
| 30152 | /* On exit, DL is overwritten by the (n-2) elements of the */ |
| 30153 | /* second super-diagonal of the upper triangular matrix U from */ |
| 30154 | /* the LU factorization of A, in DL(1), ..., DL(n-2). */ |
| 30155 | |
| 30156 | /* D (input/output) DOUBLE PRECISION array, dimension (N) */ |
| 30157 | /* On entry, D must contain the diagonal elements of A. */ |
| 30158 | |
| 30159 | /* On exit, D is overwritten by the n diagonal elements of U. */ |
| 30160 | |
| 30161 | /* DU (input/output) DOUBLE PRECISION array, dimension (N-1) */ |
| 30162 | /* On entry, DU must contain the (n-1) super-diagonal elements */ |
| 30163 | /* of A. */ |
| 30164 | |
| 30165 | /* On exit, DU is overwritten by the (n-1) elements of the first */ |
| 30166 | /* super-diagonal of U. */ |
| 30167 | |
| 30168 | /* B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */ |
| 30169 | /* On entry, the N by NRHS matrix of right hand side matrix B. */ |
| 30170 | /* On exit, if INFO = 0, the N by NRHS solution matrix X. */ |
| 30171 | |
| 30172 | /* LDB (input) INTEGER */ |
| 30173 | /* The leading dimension of the array B. LDB >= max(1,N). */ |
| 30174 | |
| 30175 | /* INFO (output) INTEGER */ |
| 30176 | /* = 0: successful exit */ |
| 30177 | /* < 0: if INFO = -i, the i-th argument had an illegal value */ |
| 30178 | /* > 0: if INFO = i, U(i,i) is exactly zero, and the solution */ |
| 30179 | /* has not been computed. The factorization has not been */ |
| 30180 | /* completed unless i = N. */ |
| 30181 | |
| 30182 | /* ===================================================================== */ |
| 30183 | |
| 30184 | /* .. Parameters .. */ |
| 30185 | /* .. */ |
| 30186 | /* .. Local Scalars .. */ |
| 30187 | /* .. */ |
| 30188 | /* .. Intrinsic Functions .. */ |
| 30189 | /* .. */ |
| 30190 | /* .. External Subroutines .. */ |
| 30191 | /* .. */ |
| 30192 | /* .. Executable Statements .. */ |
| 30193 | |
| 30194 | /* Parameter adjustments */ |
| 30195 | --dl; |
| 30196 | --d__; |
| 30197 | --du; |
| 30198 | b_dim1 = *ldb; |
| 30199 | b_offset = 1 + b_dim1; |
| 30200 | b -= b_offset; |
| 30201 | |
| 30202 | /* Function Body */ |
| 30203 | *info = 0; |
| 30204 | if (*n < 0) { |
| 30205 | *info = -1; |
| 30206 | } else if (*nrhs < 0) { |
| 30207 | *info = -2; |
| 30208 | } else if (*ldb < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 30209 | *info = -7; |
| 30210 | } |
| 30211 | if (*info != 0) { |
| 30212 | i__1 = -(*info); |
| 30213 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGTSV ", &i__1); |
| 30214 | return 0; |
| 30215 | } |
| 30216 | |
| 30217 | if (*n == 0) { |
| 30218 | return 0; |
| 30219 | } |
| 30220 | |
| 30221 | if (*nrhs == 1) { |
| 30222 | i__1 = *n - 2; |
| 30223 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 30224 | if ((d__1 = d__[i__], abscxx . . $ abs(447c67c6676f75c3).(d__1)) >= (d__2 = dl[i__], abscxx . . $ abs(447c67c6676f75c3).(d__2))) { |
| 30225 | |
| 30226 | /* No row interchange required */ |
| 30227 | |
| 30228 | if (d__[i__] != 0.) { |
| 30229 | fact = dl[i__] / d__[i__]; |
| 30230 | d__[i__ + 1] -= fact * du[i__]; |
| 30231 | b[i__ + 1 + b_dim1] -= fact * b[i__ + b_dim1]; |
| 30232 | } else { |
| 30233 | *info = i__; |
| 30234 | return 0; |
| 30235 | } |
| 30236 | dl[i__] = 0.; |
| 30237 | } else { |
| 30238 | |
| 30239 | /* Interchange rows I and I+1 */ |
| 30240 | |
| 30241 | fact = d__[i__] / dl[i__]; |
| 30242 | d__[i__] = dl[i__]; |
| 30243 | temp = d__[i__ + 1]; |
| 30244 | d__[i__ + 1] = du[i__] - fact * temp; |
| 30245 | dl[i__] = du[i__ + 1]; |
| 30246 | du[i__ + 1] = -fact * dl[i__]; |
| 30247 | du[i__] = temp; |
| 30248 | temp = b[i__ + b_dim1]; |
| 30249 | b[i__ + b_dim1] = b[i__ + 1 + b_dim1]; |
| 30250 | b[i__ + 1 + b_dim1] = temp - fact * b[i__ + 1 + b_dim1]; |
| 30251 | } |
| 30252 | /* L10: */ |
| 30253 | } |
| 30254 | if (*n > 1) { |
| 30255 | i__ = *n - 1; |
| 30256 | if ((d__1 = d__[i__], abscxx . . $ abs(447c67c6676f75c3).(d__1)) >= (d__2 = dl[i__], abscxx . . $ abs(447c67c6676f75c3).(d__2))) { |
| 30257 | if (d__[i__] != 0.) { |
| 30258 | fact = dl[i__] / d__[i__]; |
| 30259 | d__[i__ + 1] -= fact * du[i__]; |
| 30260 | b[i__ + 1 + b_dim1] -= fact * b[i__ + b_dim1]; |
| 30261 | } else { |
| 30262 | *info = i__; |
| 30263 | return 0; |
| 30264 | } |
| 30265 | } else { |
| 30266 | fact = d__[i__] / dl[i__]; |
| 30267 | d__[i__] = dl[i__]; |
| 30268 | temp = d__[i__ + 1]; |
| 30269 | d__[i__ + 1] = du[i__] - fact * temp; |
| 30270 | du[i__] = temp; |
| 30271 | temp = b[i__ + b_dim1]; |
| 30272 | b[i__ + b_dim1] = b[i__ + 1 + b_dim1]; |
| 30273 | b[i__ + 1 + b_dim1] = temp - fact * b[i__ + 1 + b_dim1]; |
| 30274 | } |
| 30275 | } |
| 30276 | if (d__[*n] == 0.) { |
| 30277 | *info = *n; |
| 30278 | return 0; |
| 30279 | } |
| 30280 | } else { |
| 30281 | i__1 = *n - 2; |
| 30282 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 30283 | if ((d__1 = d__[i__], abscxx . . $ abs(447c67c6676f75c3).(d__1)) >= (d__2 = dl[i__], abscxx . . $ abs(447c67c6676f75c3).(d__2))) { |
| 30284 | |
| 30285 | /* No row interchange required */ |
| 30286 | |
| 30287 | if (d__[i__] != 0.) { |
| 30288 | fact = dl[i__] / d__[i__]; |
| 30289 | d__[i__ + 1] -= fact * du[i__]; |
| 30290 | i__2 = *nrhs; |
| 30291 | for (j = 1; j <= i__2; ++j) { |
| 30292 | b[i__ + 1 + j * b_dim1] -= fact * b[i__ + j * b_dim1]; |
| 30293 | /* L20: */ |
| 30294 | } |
| 30295 | } else { |
| 30296 | *info = i__; |
| 30297 | return 0; |
| 30298 | } |
| 30299 | dl[i__] = 0.; |
| 30300 | } else { |
| 30301 | |
| 30302 | /* Interchange rows I and I+1 */ |
| 30303 | |
| 30304 | fact = d__[i__] / dl[i__]; |
| 30305 | d__[i__] = dl[i__]; |
| 30306 | temp = d__[i__ + 1]; |
| 30307 | d__[i__ + 1] = du[i__] - fact * temp; |
| 30308 | dl[i__] = du[i__ + 1]; |
| 30309 | du[i__ + 1] = -fact * dl[i__]; |
| 30310 | du[i__] = temp; |
| 30311 | i__2 = *nrhs; |
| 30312 | for (j = 1; j <= i__2; ++j) { |
| 30313 | temp = b[i__ + j * b_dim1]; |
| 30314 | b[i__ + j * b_dim1] = b[i__ + 1 + j * b_dim1]; |
| 30315 | b[i__ + 1 + j * b_dim1] = temp - fact * b[i__ + 1 + j * |
| 30316 | b_dim1]; |
| 30317 | /* L30: */ |
| 30318 | } |
| 30319 | } |
| 30320 | /* L40: */ |
| 30321 | } |
| 30322 | if (*n > 1) { |
| 30323 | i__ = *n - 1; |
| 30324 | if ((d__1 = d__[i__], abscxx . . $ abs(447c67c6676f75c3).(d__1)) >= (d__2 = dl[i__], abscxx . . $ abs(447c67c6676f75c3).(d__2))) { |
| 30325 | if (d__[i__] != 0.) { |
| 30326 | fact = dl[i__] / d__[i__]; |
| 30327 | d__[i__ + 1] -= fact * du[i__]; |
| 30328 | i__1 = *nrhs; |
| 30329 | for (j = 1; j <= i__1; ++j) { |
| 30330 | b[i__ + 1 + j * b_dim1] -= fact * b[i__ + j * b_dim1]; |
| 30331 | /* L50: */ |
| 30332 | } |
| 30333 | } else { |
| 30334 | *info = i__; |
| 30335 | return 0; |
| 30336 | } |
| 30337 | } else { |
| 30338 | fact = d__[i__] / dl[i__]; |
| 30339 | d__[i__] = dl[i__]; |
| 30340 | temp = d__[i__ + 1]; |
| 30341 | d__[i__ + 1] = du[i__] - fact * temp; |
| 30342 | du[i__] = temp; |
| 30343 | i__1 = *nrhs; |
| 30344 | for (j = 1; j <= i__1; ++j) { |
| 30345 | temp = b[i__ + j * b_dim1]; |
| 30346 | b[i__ + j * b_dim1] = b[i__ + 1 + j * b_dim1]; |
| 30347 | b[i__ + 1 + j * b_dim1] = temp - fact * b[i__ + 1 + j * |
| 30348 | b_dim1]; |
| 30349 | /* L60: */ |
| 30350 | } |
| 30351 | } |
| 30352 | } |
| 30353 | if (d__[*n] == 0.) { |
| 30354 | *info = *n; |
| 30355 | return 0; |
| 30356 | } |
| 30357 | } |
| 30358 | |
| 30359 | /* Back solve with the matrix U from the factorization. */ |
| 30360 | |
| 30361 | if (*nrhs <= 2) { |
| 30362 | j = 1; |
| 30363 | L70: |
| 30364 | b[*n + j * b_dim1] /= d__[*n]; |
| 30365 | if (*n > 1) { |
| 30366 | b[*n - 1 + j * b_dim1] = (b[*n - 1 + j * b_dim1] - du[*n - 1] * b[ |
| 30367 | *n + j * b_dim1]) / d__[*n - 1]; |
| 30368 | } |
| 30369 | for (i__ = *n - 2; i__ >= 1; --i__) { |
| 30370 | b[i__ + j * b_dim1] = (b[i__ + j * b_dim1] - du[i__] * b[i__ + 1 |
| 30371 | + j * b_dim1] - dl[i__] * b[i__ + 2 + j * b_dim1]) / d__[ |
| 30372 | i__]; |
| 30373 | /* L80: */ |
| 30374 | } |
| 30375 | if (j < *nrhs) { |
| 30376 | ++j; |
| 30377 | goto L70; |
| 30378 | } |
| 30379 | } else { |
| 30380 | i__1 = *nrhs; |
| 30381 | for (j = 1; j <= i__1; ++j) { |
| 30382 | b[*n + j * b_dim1] /= d__[*n]; |
| 30383 | if (*n > 1) { |
| 30384 | b[*n - 1 + j * b_dim1] = (b[*n - 1 + j * b_dim1] - du[*n - 1] |
| 30385 | * b[*n + j * b_dim1]) / d__[*n - 1]; |
| 30386 | } |
| 30387 | for (i__ = *n - 2; i__ >= 1; --i__) { |
| 30388 | b[i__ + j * b_dim1] = (b[i__ + j * b_dim1] - du[i__] * b[i__ |
| 30389 | + 1 + j * b_dim1] - dl[i__] * b[i__ + 2 + j * b_dim1]) |
| 30390 | / d__[i__]; |
| 30391 | /* L90: */ |
| 30392 | } |
| 30393 | /* L100: */ |
| 30394 | } |
| 30395 | } |
| 30396 | |
| 30397 | return 0; |
| 30398 | |
| 30399 | /* End of DGTSV */ |
| 30400 | |
| 30401 | } /* dgtsv_ */ |
| 30402 | |
| 30403 | /* Subroutine */ int dgtsvx_cxx . . $ dgtsvx_(2a606092c4e0f184).(const char *fact, const char *trans, integercxx . . $ integer# *n, integercxx . . $ integer# * |
| 30404 | nrhs, double *dl, double *d__, double *du, double * |
| 30405 | dlf, double *df, double *duf, double *du2, integercxx . . $ integer# *ipiv, |
| 30406 | double *b, integercxx . . $ integer# *ldb, double *x, integercxx . . $ integer# *ldx, double * |
| 30407 | rcond, double *ferr, double *berr, double *work, integercxx . . $ integer# * |
| 30408 | iwork, integercxx . . $ integer# *info) |
| 30409 | { |
| 30410 | /* Table of constant values */ |
| 30411 | static integercxx . . $ integer# c__1 = 1; |
| 30412 | |
| 30413 | /* System generated locals */ |
| 30414 | integercxx . . $ integer# b_dim1, b_offset, x_dim1, x_offset, i__1; |
| 30415 | |
| 30416 | /* Local variables */ |
| 30417 | char norm[1]; |
| 30418 | double anorm; |
| 30419 | bool nofact; |
| 30420 | bool notran; |
| 30421 | |
| 30422 | /* -- LAPACK routine (version 3.1) -- */ |
| 30423 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 30424 | /* November 2006 */ |
| 30425 | |
| 30426 | /* .. Scalar Arguments .. */ |
| 30427 | /* .. */ |
| 30428 | /* .. Array Arguments .. */ |
| 30429 | /* .. */ |
| 30430 | |
| 30431 | /* Purpose */ |
| 30432 | /* ======= */ |
| 30433 | |
| 30434 | /* DGTSVX uses the LU factorization to compute the solution to a real */ |
| 30435 | /* system of linear equations A * X = B or A**T * X = B, */ |
| 30436 | /* where A is a tridiagonal matrix of order N and X and B are N-by-NRHS */ |
| 30437 | /* matrices. */ |
| 30438 | |
| 30439 | /* Error bounds on the solution and a condition estimate are also */ |
| 30440 | /* provided. */ |
| 30441 | |
| 30442 | /* Description */ |
| 30443 | /* =========== */ |
| 30444 | |
| 30445 | /* The following steps are performed: */ |
| 30446 | |
| 30447 | /* 1. If FACT = 'N', the LU decomposition is used to factor the matrix A */ |
| 30448 | /* as A = L * U, where L is a product of permutation and unit lower */ |
| 30449 | /* bidiagonal matrices and U is upper triangular with nonzeros in */ |
| 30450 | /* only the main diagonal and first two superdiagonals. */ |
| 30451 | |
| 30452 | /* 2. If some U(i,i)=0, so that U is exactly singular, then the routine */ |
| 30453 | /* returns with INFO = i. Otherwise, the factored form of A is used */ |
| 30454 | /* to estimate the condition number of the matrix A. If the */ |
| 30455 | /* reciprocal of the condition number is less than machine precision, */ |
| 30456 | /* INFO = N+1 is returned as a warning, but the routine still goes on */ |
| 30457 | /* to solve for X and compute error bounds as described below. */ |
| 30458 | |
| 30459 | /* 3. The system of equations is solved for X using the factored form */ |
| 30460 | /* of A. */ |
| 30461 | |
| 30462 | /* 4. Iterative refinement is applied to improve the computed solution */ |
| 30463 | /* matrix and calculate error bounds and backward error estimates */ |
| 30464 | /* for it. */ |
| 30465 | |
| 30466 | /* Arguments */ |
| 30467 | /* ========= */ |
| 30468 | |
| 30469 | /* FACT (input) CHARACTER*1 */ |
| 30470 | /* Specifies whether or not the factored form of A has been */ |
| 30471 | /* supplied on entry. */ |
| 30472 | /* = 'F': DLF, DF, DUF, DU2, and IPIV contain the factored */ |
| 30473 | /* form of A; DL, D, DU, DLF, DF, DUF, DU2 and IPIV */ |
| 30474 | /* will not be modified. */ |
| 30475 | /* = 'N': The matrix will be copied to DLF, DF, and DUF */ |
| 30476 | /* and factored. */ |
| 30477 | |
| 30478 | /* TRANS (input) CHARACTER*1 */ |
| 30479 | /* Specifies the form of the system of equations: */ |
| 30480 | /* = 'N': A * X = B (No transpose) */ |
| 30481 | /* = 'T': A**T * X = B (Transpose) */ |
| 30482 | /* = 'C': A**H * X = B (Conjugate transpose = Transpose) */ |
| 30483 | |
| 30484 | /* N (input) INTEGER */ |
| 30485 | /* The order of the matrix A. N >= 0. */ |
| 30486 | |
| 30487 | /* NRHS (input) INTEGER */ |
| 30488 | /* The number of right hand sides, i.e., the number of columns */ |
| 30489 | /* of the matrix B. NRHS >= 0. */ |
| 30490 | |
| 30491 | /* DL (input) DOUBLE PRECISION array, dimension (N-1) */ |
| 30492 | /* The (n-1) subdiagonal elements of A. */ |
| 30493 | |
| 30494 | /* D (input) DOUBLE PRECISION array, dimension (N) */ |
| 30495 | /* The n diagonal elements of A. */ |
| 30496 | |
| 30497 | /* DU (input) DOUBLE PRECISION array, dimension (N-1) */ |
| 30498 | /* The (n-1) superdiagonal elements of A. */ |
| 30499 | |
| 30500 | /* DLF (input or output) DOUBLE PRECISION array, dimension (N-1) */ |
| 30501 | /* If FACT = 'F', then DLF is an input argument and on entry */ |
| 30502 | /* contains the (n-1) multipliers that define the matrix L from */ |
| 30503 | /* the LU factorization of A as computed by DGTTRF. */ |
| 30504 | |
| 30505 | /* If FACT = 'N', then DLF is an output argument and on exit */ |
| 30506 | /* contains the (n-1) multipliers that define the matrix L from */ |
| 30507 | /* the LU factorization of A. */ |
| 30508 | |
| 30509 | /* DF (input or output) DOUBLE PRECISION array, dimension (N) */ |
| 30510 | /* If FACT = 'F', then DF is an input argument and on entry */ |
| 30511 | /* contains the n diagonal elements of the upper triangular */ |
| 30512 | /* matrix U from the LU factorization of A. */ |
| 30513 | |
| 30514 | /* If FACT = 'N', then DF is an output argument and on exit */ |
| 30515 | /* contains the n diagonal elements of the upper triangular */ |
| 30516 | /* matrix U from the LU factorization of A. */ |
| 30517 | |
| 30518 | /* DUF (input or output) DOUBLE PRECISION array, dimension (N-1) */ |
| 30519 | /* If FACT = 'F', then DUF is an input argument and on entry */ |
| 30520 | /* contains the (n-1) elements of the first superdiagonal of U. */ |
| 30521 | |
| 30522 | /* If FACT = 'N', then DUF is an output argument and on exit */ |
| 30523 | /* contains the (n-1) elements of the first superdiagonal of U. */ |
| 30524 | |
| 30525 | /* DU2 (input or output) DOUBLE PRECISION array, dimension (N-2) */ |
| 30526 | /* If FACT = 'F', then DU2 is an input argument and on entry */ |
| 30527 | /* contains the (n-2) elements of the second superdiagonal of */ |
| 30528 | /* U. */ |
| 30529 | |
| 30530 | /* If FACT = 'N', then DU2 is an output argument and on exit */ |
| 30531 | /* contains the (n-2) elements of the second superdiagonal of */ |
| 30532 | /* U. */ |
| 30533 | |
| 30534 | /* IPIV (input or output) INTEGER array, dimension (N) */ |
| 30535 | /* If FACT = 'F', then IPIV is an input argument and on entry */ |
| 30536 | /* contains the pivot indices from the LU factorization of A as */ |
| 30537 | /* computed by DGTTRF. */ |
| 30538 | |
| 30539 | /* If FACT = 'N', then IPIV is an output argument and on exit */ |
| 30540 | /* contains the pivot indices from the LU factorization of A; */ |
| 30541 | /* row i of the matrix was interchanged with row IPIV(i). */ |
| 30542 | /* IPIV(i) will always be either i or i+1; IPIV(i) = i indicates */ |
| 30543 | /* a row interchange was not required. */ |
| 30544 | |
| 30545 | /* B (input) DOUBLE PRECISION array, dimension (LDB,NRHS) */ |
| 30546 | /* The N-by-NRHS right hand side matrix B. */ |
| 30547 | |
| 30548 | /* LDB (input) INTEGER */ |
| 30549 | /* The leading dimension of the array B. LDB >= max(1,N). */ |
| 30550 | |
| 30551 | /* X (output) DOUBLE PRECISION array, dimension (LDX,NRHS) */ |
| 30552 | /* If INFO = 0 or INFO = N+1, the N-by-NRHS solution matrix X. */ |
| 30553 | |
| 30554 | /* LDX (input) INTEGER */ |
| 30555 | /* The leading dimension of the array X. LDX >= max(1,N). */ |
| 30556 | |
| 30557 | /* RCOND (output) DOUBLE PRECISION */ |
| 30558 | /* The estimate of the reciprocal condition number of the matrix */ |
| 30559 | /* A. If RCOND is less than the machine precision (in */ |
| 30560 | /* particular, if RCOND = 0), the matrix is singular to working */ |
| 30561 | /* precision. This condition is indicated by a return code of */ |
| 30562 | /* INFO > 0. */ |
| 30563 | |
| 30564 | /* FERR (output) DOUBLE PRECISION array, dimension (NRHS) */ |
| 30565 | /* The estimated forward error bound for each solution vector */ |
| 30566 | /* X(j) (the j-th column of the solution matrix X). */ |
| 30567 | /* If XTRUE is the true solution corresponding to X(j), FERR(j) */ |
| 30568 | /* is an estimated upper bound for the magnitude of the largest */ |
| 30569 | /* element in (X(j) - XTRUE) divided by the magnitude of the */ |
| 30570 | /* largest element in X(j). The estimate is as reliable as */ |
| 30571 | /* the estimate for RCOND, and is almost always a slight */ |
| 30572 | /* overestimate of the true error. */ |
| 30573 | |
| 30574 | /* BERR (output) DOUBLE PRECISION array, dimension (NRHS) */ |
| 30575 | /* The componentwise relative backward error of each solution */ |
| 30576 | /* vector X(j) (i.e., the smallest relative change in */ |
| 30577 | /* any element of A or B that makes X(j) an exact solution). */ |
| 30578 | |
| 30579 | /* WORK (workspace) DOUBLE PRECISION array, dimension (3*N) */ |
| 30580 | |
| 30581 | /* IWORK (workspace) INTEGER array, dimension (N) */ |
| 30582 | |
| 30583 | /* INFO (output) INTEGER */ |
| 30584 | /* = 0: successful exit */ |
| 30585 | /* < 0: if INFO = -i, the i-th argument had an illegal value */ |
| 30586 | /* > 0: if INFO = i, and i is */ |
| 30587 | /* <= N: U(i,i) is exactly zero. The factorization */ |
| 30588 | /* has not been completed unless i = N, but the */ |
| 30589 | /* factor U is exactly singular, so the solution */ |
| 30590 | /* and error bounds could not be computed. */ |
| 30591 | /* RCOND = 0 is returned. */ |
| 30592 | /* = N+1: U is nonsingular, but RCOND is less than machine */ |
| 30593 | /* precision, meaning that the matrix is singular */ |
| 30594 | /* to working precision. Nevertheless, the */ |
| 30595 | /* solution and error bounds are computed because */ |
| 30596 | /* there are a number of situations where the */ |
| 30597 | /* computed solution can be more accurate than the */ |
| 30598 | /* value of RCOND would suggest. */ |
| 30599 | |
| 30600 | /* ===================================================================== */ |
| 30601 | |
| 30602 | /* .. Parameters .. */ |
| 30603 | /* .. */ |
| 30604 | /* .. Local Scalars .. */ |
| 30605 | /* .. */ |
| 30606 | /* .. External Functions .. */ |
| 30607 | /* .. */ |
| 30608 | /* .. External Subroutines .. */ |
| 30609 | /* .. */ |
| 30610 | /* .. Intrinsic Functions .. */ |
| 30611 | /* .. */ |
| 30612 | /* .. Executable Statements .. */ |
| 30613 | |
| 30614 | /* Parameter adjustments */ |
| 30615 | --dl; |
| 30616 | --d__; |
| 30617 | --du; |
| 30618 | --dlf; |
| 30619 | --df; |
| 30620 | --duf; |
| 30621 | --du2; |
| 30622 | --ipiv; |
| 30623 | b_dim1 = *ldb; |
| 30624 | b_offset = 1 + b_dim1; |
| 30625 | b -= b_offset; |
| 30626 | x_dim1 = *ldx; |
| 30627 | x_offset = 1 + x_dim1; |
| 30628 | x -= x_offset; |
| 30629 | --ferr; |
| 30630 | --berr; |
| 30631 | --work; |
| 30632 | --iwork; |
| 30633 | |
| 30634 | /* Function Body */ |
| 30635 | *info = 0; |
| 30636 | nofact = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(fact, "N"); |
| 30637 | notran = lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(trans, "N"); |
| 30638 | if (! nofact && ! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(fact, "F")) { |
| 30639 | *info = -1; |
| 30640 | } else if (! notran && ! lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(trans, "T") && ! |
| 30641 | lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(trans, "C")) { |
| 30642 | *info = -2; |
| 30643 | } else if (*n < 0) { |
| 30644 | *info = -3; |
| 30645 | } else if (*nrhs < 0) { |
| 30646 | *info = -4; |
| 30647 | } else if (*ldb < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 30648 | *info = -14; |
| 30649 | } else if (*ldx < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(1_integercxx . . $ `operator""_integer`(85240eb457c3721a).,*n)) { |
| 30650 | *info = -16; |
| 30651 | } |
| 30652 | if (*info != 0) { |
| 30653 | i__1 = -(*info); |
| 30654 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGTSVX", &i__1); |
| 30655 | return 0; |
| 30656 | } |
| 30657 | |
| 30658 | if (nofact) { |
| 30659 | |
| 30660 | /* Compute the LU factorization of A. */ |
| 30661 | |
| 30662 | dcopy_cxx . . $ dcopy_(ec261fd7ec3b6bf6).(n, &d__[1], &c__1, &df[1], &c__1); |
| 30663 | if (*n > 1) { |
| 30664 | i__1 = *n - 1; |
| 30665 | dcopy_cxx . . $ dcopy_(ec261fd7ec3b6bf6).(&i__1, &dl[1], &c__1, &dlf[1], &c__1); |
| 30666 | i__1 = *n - 1; |
| 30667 | dcopy_cxx . . $ dcopy_(ec261fd7ec3b6bf6).(&i__1, &du[1], &c__1, &duf[1], &c__1); |
| 30668 | } |
| 30669 | dgttrf_cxx . . $ dgttrf_(3cbff4db757ecfc4).(n, &dlf[1], &df[1], &duf[1], &du2[1], &ipiv[1], info); |
| 30670 | |
| 30671 | /* Return if INFO is non-zero. */ |
| 30672 | |
| 30673 | if (*info > 0) { |
| 30674 | *rcond = 0.; |
| 30675 | return 0; |
| 30676 | } |
| 30677 | } |
| 30678 | |
| 30679 | /* Compute the norm of the matrix A. */ |
| 30680 | |
| 30681 | if (notran) { |
| 30682 | *(unsigned char *)norm = '1'; |
| 30683 | } else { |
| 30684 | *(unsigned char *)norm = 'I'; |
| 30685 | } |
| 30686 | anorm = dlangt_cxx . . $ dlangt_(b3182b10f2e92eda).(norm, n, &dl[1], &d__[1], &du[1]); |
| 30687 | |
| 30688 | /* Compute the reciprocal of the condition number of A. */ |
| 30689 | |
| 30690 | dgtcon_cxx . . $ dgtcon_(9aed0b834527e25).(norm, n, &dlf[1], &df[1], &duf[1], &du2[1], &ipiv[1], &anorm, |
| 30691 | rcond, &work[1], &iwork[1], info); |
| 30692 | |
| 30693 | /* Compute the solution vectors X. */ |
| 30694 | |
| 30695 | dlacpy_cxx . . $ dlacpy_(c4e4bddb669ff896).("Full", n, nrhs, &b[b_offset], ldb, &x[x_offset], ldx); |
| 30696 | dgttrs_cxx . . $ dgttrs_(9ad804120c20c64).(trans, n, nrhs, &dlf[1], &df[1], &duf[1], &du2[1], &ipiv[1], &x[ |
| 30697 | x_offset], ldx, info); |
| 30698 | |
| 30699 | /* Use iterative refinement to improve the computed solutions and */ |
| 30700 | /* compute error bounds and backward error estimates for them. */ |
| 30701 | |
| 30702 | dgtrfs_cxx . . $ dgtrfs_(2e3bde1a117b7848).(trans, n, nrhs, &dl[1], &d__[1], &du[1], &dlf[1], &df[1], &duf[1], |
| 30703 | &du2[1], &ipiv[1], &b[b_offset], ldb, &x[x_offset], ldx, &ferr[1] |
| 30704 | , &berr[1], &work[1], &iwork[1], info); |
| 30705 | |
| 30706 | /* Set INFO = N+1 if the matrix is singular to working precision. */ |
| 30707 | |
| 30708 | if (*rcond < dlamch_cxx . . $ dlamch_(9a18bdb0e56c1bc2).("Epsilon")) { |
| 30709 | *info = *n + 1; |
| 30710 | } |
| 30711 | |
| 30712 | return 0; |
| 30713 | |
| 30714 | /* End of DGTSVX */ |
| 30715 | |
| 30716 | } /* dgtsvx_ */ |
| 30717 | |
| 30718 | /* Subroutine */ int dgttrf_cxx . . $ dgttrf_(3cbff4db757ecfc4).(integercxx . . $ integer# *n, double *dl, double *d__, |
| 30719 | double *du, double *du2, integercxx . . $ integer# *ipiv, integercxx . . $ integer# *info) |
| 30720 | { |
| 30721 | /* System generated locals */ |
| 30722 | integercxx . . $ integer# i__1; |
| 30723 | double d__1, d__2; |
| 30724 | |
| 30725 | /* Local variables */ |
| 30726 | integercxx . . $ integer# i__; |
| 30727 | double fact, temp; |
| 30728 | |
| 30729 | |
| 30730 | /* -- LAPACK routine (version 3.1) -- */ |
| 30731 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 30732 | /* November 2006 */ |
| 30733 | |
| 30734 | /* .. Scalar Arguments .. */ |
| 30735 | /* .. */ |
| 30736 | /* .. Array Arguments .. */ |
| 30737 | /* .. */ |
| 30738 | |
| 30739 | /* Purpose */ |
| 30740 | /* ======= */ |
| 30741 | |
| 30742 | /* DGTTRF computes an LU factorization of a real tridiagonal matrix A */ |
| 30743 | /* using elimination with partial pivoting and row interchanges. */ |
| 30744 | |
| 30745 | /* The factorization has the form */ |
| 30746 | /* A = L * U */ |
| 30747 | /* where L is a product of permutation and unit lower bidiagonal */ |
| 30748 | /* matrices and U is upper triangular with nonzeros in only the main */ |
| 30749 | /* diagonal and first two superdiagonals. */ |
| 30750 | |
| 30751 | /* Arguments */ |
| 30752 | /* ========= */ |
| 30753 | |
| 30754 | /* N (input) INTEGER */ |
| 30755 | /* The order of the matrix A. */ |
| 30756 | |
| 30757 | /* DL (input/output) DOUBLE PRECISION array, dimension (N-1) */ |
| 30758 | /* On entry, DL must contain the (n-1) sub-diagonal elements of */ |
| 30759 | /* A. */ |
| 30760 | |
| 30761 | /* On exit, DL is overwritten by the (n-1) multipliers that */ |
| 30762 | /* define the matrix L from the LU factorization of A. */ |
| 30763 | |
| 30764 | /* D (input/output) DOUBLE PRECISION array, dimension (N) */ |
| 30765 | /* On entry, D must contain the diagonal elements of A. */ |
| 30766 | |
| 30767 | /* On exit, D is overwritten by the n diagonal elements of the */ |
| 30768 | /* upper triangular matrix U from the LU factorization of A. */ |
| 30769 | |
| 30770 | /* DU (input/output) DOUBLE PRECISION array, dimension (N-1) */ |
| 30771 | /* On entry, DU must contain the (n-1) super-diagonal elements */ |
| 30772 | /* of A. */ |
| 30773 | |
| 30774 | /* On exit, DU is overwritten by the (n-1) elements of the first */ |
| 30775 | /* super-diagonal of U. */ |
| 30776 | |
| 30777 | /* DU2 (output) DOUBLE PRECISION array, dimension (N-2) */ |
| 30778 | /* On exit, DU2 is overwritten by the (n-2) elements of the */ |
| 30779 | /* second super-diagonal of U. */ |
| 30780 | |
| 30781 | /* IPIV (output) INTEGER array, dimension (N) */ |
| 30782 | /* The pivot indices; for 1 <= i <= n, row i of the matrix was */ |
| 30783 | /* interchanged with row IPIV(i). IPIV(i) will always be either */ |
| 30784 | /* i or i+1; IPIV(i) = i indicates a row interchange was not */ |
| 30785 | /* required. */ |
| 30786 | |
| 30787 | /* INFO (output) INTEGER */ |
| 30788 | /* = 0: successful exit */ |
| 30789 | /* < 0: if INFO = -k, the k-th argument had an illegal value */ |
| 30790 | /* > 0: if INFO = k, U(k,k) is exactly zero. The factorization */ |
| 30791 | /* has been completed, but the factor U is exactly */ |
| 30792 | /* singular, and division by zero will occur if it is used */ |
| 30793 | /* to solve a system of equations. */ |
| 30794 | |
| 30795 | /* ===================================================================== */ |
| 30796 | |
| 30797 | /* .. Parameters .. */ |
| 30798 | /* .. */ |
| 30799 | /* .. Local Scalars .. */ |
| 30800 | /* .. */ |
| 30801 | /* .. Intrinsic Functions .. */ |
| 30802 | /* .. */ |
| 30803 | /* .. External Subroutines .. */ |
| 30804 | /* .. */ |
| 30805 | /* .. Executable Statements .. */ |
| 30806 | |
| 30807 | /* Parameter adjustments */ |
| 30808 | --ipiv; |
| 30809 | --du2; |
| 30810 | --du; |
| 30811 | --d__; |
| 30812 | --dl; |
| 30813 | |
| 30814 | /* Function Body */ |
| 30815 | *info = 0; |
| 30816 | if (*n < 0) { |
| 30817 | *info = -1; |
| 30818 | i__1 = -(*info); |
| 30819 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGTTRF", &i__1); |
| 30820 | return 0; |
| 30821 | } |
| 30822 | |
| 30823 | /* Quick return if possible */ |
| 30824 | |
| 30825 | if (*n == 0) { |
| 30826 | return 0; |
| 30827 | } |
| 30828 | |
| 30829 | /* Initialize IPIV(i) = i and DU2(I) = 0 */ |
| 30830 | |
| 30831 | i__1 = *n; |
| 30832 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 30833 | ipiv[i__] = i__; |
| 30834 | /* L10: */ |
| 30835 | } |
| 30836 | i__1 = *n - 2; |
| 30837 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 30838 | du2[i__] = 0.; |
| 30839 | /* L20: */ |
| 30840 | } |
| 30841 | |
| 30842 | i__1 = *n - 2; |
| 30843 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 30844 | if ((d__1 = d__[i__], abscxx . . $ abs(447c67c6676f75c3).(d__1)) >= (d__2 = dl[i__], abscxx . . $ abs(447c67c6676f75c3).(d__2))) { |
| 30845 | |
| 30846 | /* No row interchange required, eliminate DL(I) */ |
| 30847 | |
| 30848 | if (d__[i__] != 0.) { |
| 30849 | fact = dl[i__] / d__[i__]; |
| 30850 | dl[i__] = fact; |
| 30851 | d__[i__ + 1] -= fact * du[i__]; |
| 30852 | } |
| 30853 | } else { |
| 30854 | |
| 30855 | /* Interchange rows I and I+1, eliminate DL(I) */ |
| 30856 | |
| 30857 | fact = d__[i__] / dl[i__]; |
| 30858 | d__[i__] = dl[i__]; |
| 30859 | dl[i__] = fact; |
| 30860 | temp = du[i__]; |
| 30861 | du[i__] = d__[i__ + 1]; |
| 30862 | d__[i__ + 1] = temp - fact * d__[i__ + 1]; |
| 30863 | du2[i__] = du[i__ + 1]; |
| 30864 | du[i__ + 1] = -fact * du[i__ + 1]; |
| 30865 | ipiv[i__] = i__ + 1; |
| 30866 | } |
| 30867 | /* L30: */ |
| 30868 | } |
| 30869 | if (*n > 1) { |
| 30870 | i__ = *n - 1; |
| 30871 | if ((d__1 = d__[i__], abscxx . . $ abs(447c67c6676f75c3).(d__1)) >= (d__2 = dl[i__], abscxx . . $ abs(447c67c6676f75c3).(d__2))) { |
| 30872 | if (d__[i__] != 0.) { |
| 30873 | fact = dl[i__] / d__[i__]; |
| 30874 | dl[i__] = fact; |
| 30875 | d__[i__ + 1] -= fact * du[i__]; |
| 30876 | } |
| 30877 | } else { |
| 30878 | fact = d__[i__] / dl[i__]; |
| 30879 | d__[i__] = dl[i__]; |
| 30880 | dl[i__] = fact; |
| 30881 | temp = du[i__]; |
| 30882 | du[i__] = d__[i__ + 1]; |
| 30883 | d__[i__ + 1] = temp - fact * d__[i__ + 1]; |
| 30884 | ipiv[i__] = i__ + 1; |
| 30885 | } |
| 30886 | } |
| 30887 | |
| 30888 | /* Check for a zero on the diagonal of U. */ |
| 30889 | |
| 30890 | i__1 = *n; |
| 30891 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 30892 | if (d__[i__] == 0.) { |
| 30893 | *info = i__; |
| 30894 | goto L50; |
| 30895 | } |
| 30896 | /* L40: */ |
| 30897 | } |
| 30898 | L50: |
| 30899 | |
| 30900 | return 0; |
| 30901 | |
| 30902 | /* End of DGTTRF */ |
| 30903 | |
| 30904 | } /* dgttrf_ */ |
| 30905 | |
| 30906 | /* Subroutine */ int dgttrs_cxx . . $ dgttrs_(9ad804120c20c64).(const char *trans, integercxx . . $ integer# *n, integercxx . . $ integer# *nrhs, |
| 30907 | double *dl, double *d__, double *du, double *du2, |
| 30908 | integercxx . . $ integer# *ipiv, double *b, integercxx . . $ integer# *ldb, integercxx . . $ integer# *info) |
| 30909 | { |
| 30910 | /* Table of constant values */ |
| 30911 | static integercxx . . $ integer# c__1 = 1; |
| 30912 | static integercxx . . $ integer# c_n1 = -1; |
| 30913 | |
| 30914 | /* System generated locals */ |
| 30915 | integercxx . . $ integer# b_dim1, b_offset, i__1, i__2, i__3; |
| 30916 | |
| 30917 | /* Local variables */ |
| 30918 | integercxx . . $ integer# j, jb, nb; |
| 30919 | integercxx . . $ integer# itrans; |
| 30920 | bool notran; |
| 30921 | |
| 30922 | |
| 30923 | /* -- LAPACK routine (version 3.1) -- */ |
| 30924 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 30925 | /* November 2006 */ |
| 30926 | |
| 30927 | /* .. Scalar Arguments .. */ |
| 30928 | /* .. */ |
| 30929 | /* .. Array Arguments .. */ |
| 30930 | /* .. */ |
| 30931 | |
| 30932 | /* Purpose */ |
| 30933 | /* ======= */ |
| 30934 | |
| 30935 | /* DGTTRS solves one of the systems of equations */ |
| 30936 | /* A*X = B or A'*X = B, */ |
| 30937 | /* with a tridiagonal matrix A using the LU factorization computed */ |
| 30938 | /* by DGTTRF. */ |
| 30939 | |
| 30940 | /* Arguments */ |
| 30941 | /* ========= */ |
| 30942 | |
| 30943 | /* TRANS (input) CHARACTER*1 */ |
| 30944 | /* Specifies the form of the system of equations. */ |
| 30945 | /* = 'N': A * X = B (No transpose) */ |
| 30946 | /* = 'T': A'* X = B (Transpose) */ |
| 30947 | /* = 'C': A'* X = B (Conjugate transpose = Transpose) */ |
| 30948 | |
| 30949 | /* N (input) INTEGER */ |
| 30950 | /* The order of the matrix A. */ |
| 30951 | |
| 30952 | /* NRHS (input) INTEGER */ |
| 30953 | /* The number of right hand sides, i.e., the number of columns */ |
| 30954 | /* of the matrix B. NRHS >= 0. */ |
| 30955 | |
| 30956 | /* DL (input) DOUBLE PRECISION array, dimension (N-1) */ |
| 30957 | /* The (n-1) multipliers that define the matrix L from the */ |
| 30958 | /* LU factorization of A. */ |
| 30959 | |
| 30960 | /* D (input) DOUBLE PRECISION array, dimension (N) */ |
| 30961 | /* The n diagonal elements of the upper triangular matrix U from */ |
| 30962 | /* the LU factorization of A. */ |
| 30963 | |
| 30964 | /* DU (input) DOUBLE PRECISION array, dimension (N-1) */ |
| 30965 | /* The (n-1) elements of the first super-diagonal of U. */ |
| 30966 | |
| 30967 | /* DU2 (input) DOUBLE PRECISION array, dimension (N-2) */ |
| 30968 | /* The (n-2) elements of the second super-diagonal of U. */ |
| 30969 | |
| 30970 | /* IPIV (input) INTEGER array, dimension (N) */ |
| 30971 | /* The pivot indices; for 1 <= i <= n, row i of the matrix was */ |
| 30972 | /* interchanged with row IPIV(i). IPIV(i) will always be either */ |
| 30973 | /* i or i+1; IPIV(i) = i indicates a row interchange was not */ |
| 30974 | /* required. */ |
| 30975 | |
| 30976 | /* B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */ |
| 30977 | /* On entry, the matrix of right hand side vectors B. */ |
| 30978 | /* On exit, B is overwritten by the solution vectors X. */ |
| 30979 | |
| 30980 | /* LDB (input) INTEGER */ |
| 30981 | /* The leading dimension of the array B. LDB >= max(1,N). */ |
| 30982 | |
| 30983 | /* INFO (output) INTEGER */ |
| 30984 | /* = 0: successful exit */ |
| 30985 | /* < 0: if INFO = -i, the i-th argument had an illegal value */ |
| 30986 | |
| 30987 | /* ===================================================================== */ |
| 30988 | |
| 30989 | /* .. Local Scalars .. */ |
| 30990 | /* .. */ |
| 30991 | /* .. External Functions .. */ |
| 30992 | /* .. */ |
| 30993 | /* .. External Subroutines .. */ |
| 30994 | /* .. */ |
| 30995 | /* .. Intrinsic Functions .. */ |
| 30996 | /* .. */ |
| 30997 | /* .. Executable Statements .. */ |
| 30998 | |
| 30999 | /* Parameter adjustments */ |
| 31000 | --dl; |
| 31001 | --d__; |
| 31002 | --du; |
| 31003 | --du2; |
| 31004 | --ipiv; |
| 31005 | b_dim1 = *ldb; |
| 31006 | b_offset = 1 + b_dim1; |
| 31007 | b -= b_offset; |
| 31008 | |
| 31009 | /* Function Body */ |
| 31010 | *info = 0; |
| 31011 | notran = *(unsigned char *)trans == 'N' || *(unsigned char *)trans == 'n'; |
| 31012 | if (! notran && ! (*(unsigned char *)trans == 'T' || *(unsigned char *) |
| 31013 | trans == 't') && ! (*(unsigned char *)trans == 'C' || *(unsigned |
| 31014 | char *)trans == 'c')) { |
| 31015 | *info = -1; |
| 31016 | } else if (*n < 0) { |
| 31017 | *info = -2; |
| 31018 | } else if (*nrhs < 0) { |
| 31019 | *info = -3; |
| 31020 | } else if (*ldb < stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(*n,1_integercxx . . $ `operator""_integer`(85240eb457c3721a).)) { |
| 31021 | *info = -10; |
| 31022 | } |
| 31023 | if (*info != 0) { |
| 31024 | i__1 = -(*info); |
| 31025 | xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6).("DGTTRS", &i__1); |
| 31026 | return 0; |
| 31027 | } |
| 31028 | |
| 31029 | /* Quick return if possible */ |
| 31030 | |
| 31031 | if (*n == 0 || *nrhs == 0) { |
| 31032 | return 0; |
| 31033 | } |
| 31034 | |
| 31035 | /* Decode TRANS */ |
| 31036 | |
| 31037 | if (notran) { |
| 31038 | itrans = 0; |
| 31039 | } else { |
| 31040 | itrans = 1; |
| 31041 | } |
| 31042 | |
| 31043 | /* Determine the number of right-hand sides to solve at a time. */ |
| 31044 | |
| 31045 | if (*nrhs == 1) { |
| 31046 | nb = 1; |
| 31047 | } else { |
| 31048 | /* Computing MAX */ |
| 31049 | i__1 = 1, i__2 = ilaenv_cxx . . $ ilaenv_(7938461e606256b7).(&c__1, "DGTTRS", trans, n, nrhs, &c_n1, & |
| 31050 | c_n1); |
| 31051 | nb = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(i__1,i__2); |
| 31052 | } |
| 31053 | |
| 31054 | if (nb >= *nrhs) { |
| 31055 | dgtts2_cxx . . $ dgtts2_(cd574877fc69a291).(&itrans, n, nrhs, &dl[1], &d__[1], &du[1], &du2[1], &ipiv[1], |
| 31056 | &b[b_offset], ldb); |
| 31057 | } else { |
| 31058 | i__1 = *nrhs; |
| 31059 | i__2 = nb; |
| 31060 | for (j = 1; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) { |
| 31061 | /* Computing MIN */ |
| 31062 | i__3 = *nrhs - j + 1; |
| 31063 | jb = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(i__3,nb); |
| 31064 | dgtts2_cxx . . $ dgtts2_(cd574877fc69a291).(&itrans, n, &jb, &dl[1], &d__[1], &du[1], &du2[1], &ipiv[ |
| 31065 | 1], &b[j * b_dim1 + 1], ldb); |
| 31066 | /* L10: */ |
| 31067 | } |
| 31068 | } |
| 31069 | |
| 31070 | /* End of DGTTRS */ |
| 31071 | |
| 31072 | return 0; |
| 31073 | } /* dgttrs_ */ |
| 31074 | |
| 31075 | /* Subroutine */ int dgtts2_cxx . . $ dgtts2_(cd574877fc69a291).(integercxx . . $ integer# *itrans, integercxx . . $ integer# *n, integercxx . . $ integer# *nrhs, |
| 31076 | double *dl, double *d__, double *du, double *du2, |
| 31077 | integercxx . . $ integer# *ipiv, double *b, integercxx . . $ integer# *ldb) |
| 31078 | { |
| 31079 | /* System generated locals */ |
| 31080 | integercxx . . $ integer# b_dim1, b_offset, i__1, i__2; |
| 31081 | |
| 31082 | /* Local variables */ |
| 31083 | integercxx . . $ integer# i__, j, ip; |
| 31084 | double temp; |
| 31085 | |
| 31086 | |
| 31087 | /* -- LAPACK auxiliary routine (version 3.1) -- */ |
| 31088 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ |
| 31089 | /* November 2006 */ |
| 31090 | |
| 31091 | /* .. Scalar Arguments .. */ |
| 31092 | /* .. */ |
| 31093 | /* .. Array Arguments .. */ |
| 31094 | /* .. */ |
| 31095 | |
| 31096 | /* Purpose */ |
| 31097 | /* ======= */ |
| 31098 | |
| 31099 | /* DGTTS2 solves one of the systems of equations */ |
| 31100 | /* A*X = B or A'*X = B, */ |
| 31101 | /* with a tridiagonal matrix A using the LU factorization computed */ |
| 31102 | /* by DGTTRF. */ |
| 31103 | |
| 31104 | /* Arguments */ |
| 31105 | /* ========= */ |
| 31106 | |
| 31107 | /* ITRANS (input) INTEGER */ |
| 31108 | /* Specifies the form of the system of equations. */ |
| 31109 | /* = 0: A * X = B (No transpose) */ |
| 31110 | /* = 1: A'* X = B (Transpose) */ |
| 31111 | /* = 2: A'* X = B (Conjugate transpose = Transpose) */ |
| 31112 | |
| 31113 | /* N (input) INTEGER */ |
| 31114 | /* The order of the matrix A. */ |
| 31115 | |
| 31116 | /* NRHS (input) INTEGER */ |
| 31117 | /* The number of right hand sides, i.e., the number of columns */ |
| 31118 | /* of the matrix B. NRHS >= 0. */ |
| 31119 | |
| 31120 | /* DL (input) DOUBLE PRECISION array, dimension (N-1) */ |
| 31121 | /* The (n-1) multipliers that define the matrix L from the */ |
| 31122 | /* LU factorization of A. */ |
| 31123 | |
| 31124 | /* D (input) DOUBLE PRECISION array, dimension (N) */ |
| 31125 | /* The n diagonal elements of the upper triangular matrix U from */ |
| 31126 | /* the LU factorization of A. */ |
| 31127 | |
| 31128 | /* DU (input) DOUBLE PRECISION array, dimension (N-1) */ |
| 31129 | /* The (n-1) elements of the first super-diagonal of U. */ |
| 31130 | |
| 31131 | /* DU2 (input) DOUBLE PRECISION array, dimension (N-2) */ |
| 31132 | /* The (n-2) elements of the second super-diagonal of U. */ |
| 31133 | |
| 31134 | /* IPIV (input) INTEGER array, dimension (N) */ |
| 31135 | /* The pivot indices; for 1 <= i <= n, row i of the matrix was */ |
| 31136 | /* interchanged with row IPIV(i). IPIV(i) will always be either */ |
| 31137 | /* i or i+1; IPIV(i) = i indicates a row interchange was not */ |
| 31138 | /* required. */ |
| 31139 | |
| 31140 | /* B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */ |
| 31141 | /* On entry, the matrix of right hand side vectors B. */ |
| 31142 | /* On exit, B is overwritten by the solution vectors X. */ |
| 31143 | |
| 31144 | /* LDB (input) INTEGER */ |
| 31145 | /* The leading dimension of the array B. LDB >= max(1,N). */ |
| 31146 | |
| 31147 | /* ===================================================================== */ |
| 31148 | |
| 31149 | /* .. Local Scalars .. */ |
| 31150 | /* .. */ |
| 31151 | /* .. Executable Statements .. */ |
| 31152 | |
| 31153 | /* Quick return if possible */ |
| 31154 | |
| 31155 | /* Parameter adjustments */ |
| 31156 | --dl; |
| 31157 | --d__; |
| 31158 | --du; |
| 31159 | --du2; |
| 31160 | --ipiv; |
| 31161 | b_dim1 = *ldb; |
| 31162 | b_offset = 1 + b_dim1; |
| 31163 | b -= b_offset; |
| 31164 | |
| 31165 | /* Function Body */ |
| 31166 | if (*n == 0 || *nrhs == 0) { |
| 31167 | return 0; |
| 31168 | } |
| 31169 | |
| 31170 | if (*itrans == 0) { |
| 31171 | |
| 31172 | /* Solve A*X = B using the LU factorization of A, */ |
| 31173 | /* overwriting each right hand side vector with its solution. */ |
| 31174 | |
| 31175 | if (*nrhs <= 1) { |
| 31176 | j = 1; |
| 31177 | L10: |
| 31178 | |
| 31179 | /* Solve L*x = b. */ |
| 31180 | |
| 31181 | i__1 = *n - 1; |
| 31182 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 31183 | ip = ipiv[i__]; |
| 31184 | temp = b[i__ + 1 - ip + i__ + j * b_dim1] - dl[i__] * b[ip + |
| 31185 | j * b_dim1]; |
| 31186 | b[i__ + j * b_dim1] = b[ip + j * b_dim1]; |
| 31187 | b[i__ + 1 + j * b_dim1] = temp; |
| 31188 | /* L20: */ |
| 31189 | } |
| 31190 | |
| 31191 | /* Solve U*x = b. */ |
| 31192 | |
| 31193 | b[*n + j * b_dim1] /= d__[*n]; |
| 31194 | if (*n > 1) { |
| 31195 | b[*n - 1 + j * b_dim1] = (b[*n - 1 + j * b_dim1] - du[*n - 1] |
| 31196 | * b[*n + j * b_dim1]) / d__[*n - 1]; |
| 31197 | } |
| 31198 | for (i__ = *n - 2; i__ >= 1; --i__) { |
| 31199 | b[i__ + j * b_dim1] = (b[i__ + j * b_dim1] - du[i__] * b[i__ |
| 31200 | + 1 + j * b_dim1] - du2[i__] * b[i__ + 2 + j * b_dim1] |
| 31201 | ) / d__[i__]; |
| 31202 | /* L30: */ |
| 31203 | } |
| 31204 | if (j < *nrhs) { |
| 31205 | ++j; |
| 31206 | goto L10; |
| 31207 | } |
| 31208 | } else { |
| 31209 | i__1 = *nrhs; |
| 31210 | for (j = 1; j <= i__1; ++j) { |
| 31211 | |
| 31212 | /* Solve L*x = b. */ |
| 31213 | |
| 31214 | i__2 = *n - 1; |
| 31215 | for (i__ = 1; i__ <= i__2; ++i__) { |
| 31216 | if (ipiv[i__] == i__) { |
| 31217 | b[i__ + 1 + j * b_dim1] -= dl[i__] * b[i__ + j * |
| 31218 | b_dim1]; |
| 31219 | } else { |
| 31220 | temp = b[i__ + j * b_dim1]; |
| 31221 | b[i__ + j * b_dim1] = b[i__ + 1 + j * b_dim1]; |
| 31222 | b[i__ + 1 + j * b_dim1] = temp - dl[i__] * b[i__ + j * |
| 31223 | b_dim1]; |
| 31224 | } |
| 31225 | /* L40: */ |
| 31226 | } |
| 31227 | |
| 31228 | /* Solve U*x = b. */ |
| 31229 | |
| 31230 | b[*n + j * b_dim1] /= d__[*n]; |
| 31231 | if (*n > 1) { |
| 31232 | b[*n - 1 + j * b_dim1] = (b[*n - 1 + j * b_dim1] - du[*n |
| 31233 | - 1] * b[*n + j * b_dim1]) / d__[*n - 1]; |
| 31234 | } |
| 31235 | for (i__ = *n - 2; i__ >= 1; --i__) { |
| 31236 | b[i__ + j * b_dim1] = (b[i__ + j * b_dim1] - du[i__] * b[ |
| 31237 | i__ + 1 + j * b_dim1] - du2[i__] * b[i__ + 2 + j * |
| 31238 | b_dim1]) / d__[i__]; |
| 31239 | /* L50: */ |
| 31240 | } |
| 31241 | /* L60: */ |
| 31242 | } |
| 31243 | } |
| 31244 | } else { |
| 31245 | |
| 31246 | /* Solve A' * X = B. */ |
| 31247 | |
| 31248 | if (*nrhs <= 1) { |
| 31249 | |
| 31250 | /* Solve U'*x = b. */ |
| 31251 | |
| 31252 | j = 1; |
| 31253 | L70: |
| 31254 | b[j * b_dim1 + 1] /= d__[1]; |
| 31255 | if (*n > 1) { |
| 31256 | b[j * b_dim1 + 2] = (b[j * b_dim1 + 2] - du[1] * b[j * b_dim1 |
| 31257 | + 1]) / d__[2]; |
| 31258 | } |
| 31259 | i__1 = *n; |
| 31260 | for (i__ = 3; i__ <= i__1; ++i__) { |
| 31261 | b[i__ + j * b_dim1] = (b[i__ + j * b_dim1] - du[i__ - 1] * b[ |
| 31262 | i__ - 1 + j * b_dim1] - du2[i__ - 2] * b[i__ - 2 + j * |
| 31263 | b_dim1]) / d__[i__]; |
| 31264 | /* L80: */ |
| 31265 | } |
| 31266 | |
| 31267 | /* Solve L'*x = b. */ |
| 31268 | |
| 31269 | for (i__ = *n - 1; i__ >= 1; --i__) { |
| 31270 | ip = ipiv[i__]; |
| 31271 | temp = b[i__ + j * b_dim1] - dl[i__] * b[i__ + 1 + j * b_dim1] |
| 31272 | ; |
| 31273 | b[i__ + j * b_dim1] = b[ip + j * b_dim1]; |
| 31274 | b[ip + j * b_dim1] = temp; |
| 31275 | /* L90: */ |
| 31276 | } |
| 31277 | if (j < *nrhs) { |
| 31278 | ++j; |
| 31279 | goto L70; |
| 31280 | } |
| 31281 | |
| 31282 | } else { |
| 31283 | i__1 = *nrhs; |
| 31284 | for (j = 1; j <= i__1; ++j) { |
| 31285 | |
| 31286 | /* Solve U'*x = b. */ |
| 31287 | |
| 31288 | b[j * b_dim1 + 1] /= d__[1]; |
| 31289 | if (*n > 1) { |
| 31290 | b[j * b_dim1 + 2] = (b[j * b_dim1 + 2] - du[1] * b[j * |
| 31291 | b_dim1 + 1]) / d__[2]; |
| 31292 | } |
| 31293 | i__2 = *n; |
| 31294 | for (i__ = 3; i__ <= i__2; ++i__) { |
| 31295 | b[i__ + j * b_dim1] = (b[i__ + j * b_dim1] - du[i__ - 1] * |
| 31296 | b[i__ - 1 + j * b_dim1] - du2[i__ - 2] * b[i__ - |
| 31297 | 2 + j * b_dim1]) / d__[i__]; |
| 31298 | /* L100: */ |
| 31299 | } |
| 31300 | for (i__ = *n - 1; i__ >= 1; --i__) { |
| 31301 | if (ipiv[i__] == i__) { |
| 31302 | b[i__ + j * b_dim1] -= dl[i__] * b[i__ + 1 + j * |
| 31303 | b_dim1]; |
| 31304 | } else { |
| 31305 | temp = b[i__ + 1 + j * b_dim1]; |
| 31306 | b[i__ + 1 + j * b_dim1] = b[i__ + j * b_dim1] - dl[ |
| 31307 | i__] * temp; |
| 31308 | b[i__ + j * b_dim1] = temp; |
| 31309 | } |
| 31310 | /* L110: */ |
| 31311 | } |
| 31312 | /* L120: */ |
| 31313 | } |
| 31314 | } |
| 31315 | } |
| 31316 | |
| 31317 | /* End of DGTTS2 */ |
| 31318 | |
| 31319 | return 0; |
| 31320 | } /* dgtts2_ */ |