00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015
00016
00017
00018 static doublecomplex c_b1 = {0.,0.};
00019 static doublecomplex c_b2 = {1.,0.};
00020 static integer c__1 = 1;
00021 static integer c_n1 = -1;
00022 static integer c__0 = 0;
00023
00024 int zgesdd_(char *jobz, integer *m, integer *n,
00025 doublecomplex *a, integer *lda, doublereal *s, doublecomplex *u,
00026 integer *ldu, doublecomplex *vt, integer *ldvt, doublecomplex *work,
00027 integer *lwork, doublereal *rwork, integer *iwork, integer *info)
00028 {
00029
00030 integer a_dim1, a_offset, u_dim1, u_offset, vt_dim1, vt_offset, i__1,
00031 i__2, i__3;
00032
00033
00034 double sqrt(doublereal);
00035
00036
00037 integer i__, ie, il, ir, iu, blk;
00038 doublereal dum[1], eps;
00039 integer iru, ivt, iscl;
00040 doublereal anrm;
00041 integer idum[1], ierr, itau, irvt;
00042 extern logical lsame_(char *, char *);
00043 integer chunk, minmn;
00044 extern int zgemm_(char *, char *, integer *, integer *,
00045 integer *, doublecomplex *, doublecomplex *, integer *,
00046 doublecomplex *, integer *, doublecomplex *, doublecomplex *,
00047 integer *);
00048 integer wrkbl, itaup, itauq;
00049 logical wntqa;
00050 integer nwork;
00051 logical wntqn, wntqo, wntqs;
00052 extern int zlacp2_(char *, integer *, integer *,
00053 doublereal *, integer *, doublecomplex *, integer *);
00054 integer mnthr1, mnthr2;
00055 extern int dbdsdc_(char *, char *, integer *, doublereal
00056 *, doublereal *, doublereal *, integer *, doublereal *, integer *,
00057 doublereal *, integer *, doublereal *, integer *, integer *);
00058 extern doublereal dlamch_(char *);
00059 extern int dlascl_(char *, integer *, integer *,
00060 doublereal *, doublereal *, integer *, integer *, doublereal *,
00061 integer *, integer *), xerbla_(char *, integer *),
00062 zgebrd_(integer *, integer *, doublecomplex *, integer *,
00063 doublereal *, doublereal *, doublecomplex *, doublecomplex *,
00064 doublecomplex *, integer *, integer *);
00065 extern integer ilaenv_(integer *, char *, char *, integer *, integer *,
00066 integer *, integer *);
00067 doublereal bignum;
00068 extern doublereal zlange_(char *, integer *, integer *, doublecomplex *,
00069 integer *, doublereal *);
00070 extern int zgelqf_(integer *, integer *, doublecomplex *,
00071 integer *, doublecomplex *, doublecomplex *, integer *, integer *
00072 ), zlacrm_(integer *, integer *, doublecomplex *, integer *,
00073 doublereal *, integer *, doublecomplex *, integer *, doublereal *)
00074 , zlarcm_(integer *, integer *, doublereal *, integer *,
00075 doublecomplex *, integer *, doublecomplex *, integer *,
00076 doublereal *), zlascl_(char *, integer *, integer *, doublereal *,
00077 doublereal *, integer *, integer *, doublecomplex *, integer *,
00078 integer *), zgeqrf_(integer *, integer *, doublecomplex *,
00079 integer *, doublecomplex *, doublecomplex *, integer *, integer *
00080 );
00081 integer ldwrkl;
00082 extern int zlacpy_(char *, integer *, integer *,
00083 doublecomplex *, integer *, doublecomplex *, integer *),
00084 zlaset_(char *, integer *, integer *, doublecomplex *,
00085 doublecomplex *, doublecomplex *, integer *);
00086 integer ldwrkr, minwrk, ldwrku, maxwrk;
00087 extern int zungbr_(char *, integer *, integer *, integer
00088 *, doublecomplex *, integer *, doublecomplex *, doublecomplex *,
00089 integer *, integer *);
00090 integer ldwkvt;
00091 doublereal smlnum;
00092 logical wntqas;
00093 extern int zunmbr_(char *, char *, char *, integer *,
00094 integer *, integer *, doublecomplex *, integer *, doublecomplex *,
00095 doublecomplex *, integer *, doublecomplex *, integer *, integer *
00096 ), zunglq_(integer *, integer *, integer *
00097 , doublecomplex *, integer *, doublecomplex *, doublecomplex *,
00098 integer *, integer *);
00099 integer nrwork;
00100 extern int zungqr_(integer *, integer *, integer *,
00101 doublecomplex *, integer *, doublecomplex *, doublecomplex *,
00102 integer *, integer *);
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259 a_dim1 = *lda;
00260 a_offset = 1 + a_dim1;
00261 a -= a_offset;
00262 --s;
00263 u_dim1 = *ldu;
00264 u_offset = 1 + u_dim1;
00265 u -= u_offset;
00266 vt_dim1 = *ldvt;
00267 vt_offset = 1 + vt_dim1;
00268 vt -= vt_offset;
00269 --work;
00270 --rwork;
00271 --iwork;
00272
00273
00274 *info = 0;
00275 minmn = min(*m,*n);
00276 mnthr1 = (integer) (minmn * 17. / 9.);
00277 mnthr2 = (integer) (minmn * 5. / 3.);
00278 wntqa = lsame_(jobz, "A");
00279 wntqs = lsame_(jobz, "S");
00280 wntqas = wntqa || wntqs;
00281 wntqo = lsame_(jobz, "O");
00282 wntqn = lsame_(jobz, "N");
00283 minwrk = 1;
00284 maxwrk = 1;
00285
00286 if (! (wntqa || wntqs || wntqo || wntqn)) {
00287 *info = -1;
00288 } else if (*m < 0) {
00289 *info = -2;
00290 } else if (*n < 0) {
00291 *info = -3;
00292 } else if (*lda < max(1,*m)) {
00293 *info = -5;
00294 } else if (*ldu < 1 || wntqas && *ldu < *m || wntqo && *m < *n && *ldu < *
00295 m) {
00296 *info = -8;
00297 } else if (*ldvt < 1 || wntqa && *ldvt < *n || wntqs && *ldvt < minmn ||
00298 wntqo && *m >= *n && *ldvt < *n) {
00299 *info = -10;
00300 }
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310 if (*info == 0 && *m > 0 && *n > 0) {
00311 if (*m >= *n) {
00312
00313
00314
00315
00316
00317
00318
00319
00320 if (*m >= mnthr1) {
00321 if (wntqn) {
00322
00323
00324
00325 maxwrk = *n + *n * ilaenv_(&c__1, "ZGEQRF", " ", m, n, &
00326 c_n1, &c_n1);
00327
00328 i__1 = maxwrk, i__2 = (*n << 1) + (*n << 1) * ilaenv_(&
00329 c__1, "ZGEBRD", " ", n, n, &c_n1, &c_n1);
00330 maxwrk = max(i__1,i__2);
00331 minwrk = *n * 3;
00332 } else if (wntqo) {
00333
00334
00335
00336 wrkbl = *n + *n * ilaenv_(&c__1, "ZGEQRF", " ", m, n, &
00337 c_n1, &c_n1);
00338
00339 i__1 = wrkbl, i__2 = *n + *n * ilaenv_(&c__1, "ZUNGQR",
00340 " ", m, n, n, &c_n1);
00341 wrkbl = max(i__1,i__2);
00342
00343 i__1 = wrkbl, i__2 = (*n << 1) + (*n << 1) * ilaenv_(&
00344 c__1, "ZGEBRD", " ", n, n, &c_n1, &c_n1);
00345 wrkbl = max(i__1,i__2);
00346
00347 i__1 = wrkbl, i__2 = (*n << 1) + *n * ilaenv_(&c__1,
00348 "ZUNMBR", "QLN", n, n, n, &c_n1);
00349 wrkbl = max(i__1,i__2);
00350
00351 i__1 = wrkbl, i__2 = (*n << 1) + *n * ilaenv_(&c__1,
00352 "ZUNMBR", "PRC", n, n, n, &c_n1);
00353 wrkbl = max(i__1,i__2);
00354 maxwrk = *m * *n + *n * *n + wrkbl;
00355 minwrk = (*n << 1) * *n + *n * 3;
00356 } else if (wntqs) {
00357
00358
00359
00360 wrkbl = *n + *n * ilaenv_(&c__1, "ZGEQRF", " ", m, n, &
00361 c_n1, &c_n1);
00362
00363 i__1 = wrkbl, i__2 = *n + *n * ilaenv_(&c__1, "ZUNGQR",
00364 " ", m, n, n, &c_n1);
00365 wrkbl = max(i__1,i__2);
00366
00367 i__1 = wrkbl, i__2 = (*n << 1) + (*n << 1) * ilaenv_(&
00368 c__1, "ZGEBRD", " ", n, n, &c_n1, &c_n1);
00369 wrkbl = max(i__1,i__2);
00370
00371 i__1 = wrkbl, i__2 = (*n << 1) + *n * ilaenv_(&c__1,
00372 "ZUNMBR", "QLN", n, n, n, &c_n1);
00373 wrkbl = max(i__1,i__2);
00374
00375 i__1 = wrkbl, i__2 = (*n << 1) + *n * ilaenv_(&c__1,
00376 "ZUNMBR", "PRC", n, n, n, &c_n1);
00377 wrkbl = max(i__1,i__2);
00378 maxwrk = *n * *n + wrkbl;
00379 minwrk = *n * *n + *n * 3;
00380 } else if (wntqa) {
00381
00382
00383
00384 wrkbl = *n + *n * ilaenv_(&c__1, "ZGEQRF", " ", m, n, &
00385 c_n1, &c_n1);
00386
00387 i__1 = wrkbl, i__2 = *n + *m * ilaenv_(&c__1, "ZUNGQR",
00388 " ", m, m, n, &c_n1);
00389 wrkbl = max(i__1,i__2);
00390
00391 i__1 = wrkbl, i__2 = (*n << 1) + (*n << 1) * ilaenv_(&
00392 c__1, "ZGEBRD", " ", n, n, &c_n1, &c_n1);
00393 wrkbl = max(i__1,i__2);
00394
00395 i__1 = wrkbl, i__2 = (*n << 1) + *n * ilaenv_(&c__1,
00396 "ZUNMBR", "QLN", n, n, n, &c_n1);
00397 wrkbl = max(i__1,i__2);
00398
00399 i__1 = wrkbl, i__2 = (*n << 1) + *n * ilaenv_(&c__1,
00400 "ZUNMBR", "PRC", n, n, n, &c_n1);
00401 wrkbl = max(i__1,i__2);
00402 maxwrk = *n * *n + wrkbl;
00403 minwrk = *n * *n + (*n << 1) + *m;
00404 }
00405 } else if (*m >= mnthr2) {
00406
00407
00408
00409 maxwrk = (*n << 1) + (*m + *n) * ilaenv_(&c__1, "ZGEBRD",
00410 " ", m, n, &c_n1, &c_n1);
00411 minwrk = (*n << 1) + *m;
00412 if (wntqo) {
00413
00414 i__1 = maxwrk, i__2 = (*n << 1) + *n * ilaenv_(&c__1,
00415 "ZUNGBR", "P", n, n, n, &c_n1);
00416 maxwrk = max(i__1,i__2);
00417
00418 i__1 = maxwrk, i__2 = (*n << 1) + *n * ilaenv_(&c__1,
00419 "ZUNGBR", "Q", m, n, n, &c_n1);
00420 maxwrk = max(i__1,i__2);
00421 maxwrk += *m * *n;
00422 minwrk += *n * *n;
00423 } else if (wntqs) {
00424
00425 i__1 = maxwrk, i__2 = (*n << 1) + *n * ilaenv_(&c__1,
00426 "ZUNGBR", "P", n, n, n, &c_n1);
00427 maxwrk = max(i__1,i__2);
00428
00429 i__1 = maxwrk, i__2 = (*n << 1) + *n * ilaenv_(&c__1,
00430 "ZUNGBR", "Q", m, n, n, &c_n1);
00431 maxwrk = max(i__1,i__2);
00432 } else if (wntqa) {
00433
00434 i__1 = maxwrk, i__2 = (*n << 1) + *n * ilaenv_(&c__1,
00435 "ZUNGBR", "P", n, n, n, &c_n1);
00436 maxwrk = max(i__1,i__2);
00437
00438 i__1 = maxwrk, i__2 = (*n << 1) + *m * ilaenv_(&c__1,
00439 "ZUNGBR", "Q", m, m, n, &c_n1);
00440 maxwrk = max(i__1,i__2);
00441 }
00442 } else {
00443
00444
00445
00446 maxwrk = (*n << 1) + (*m + *n) * ilaenv_(&c__1, "ZGEBRD",
00447 " ", m, n, &c_n1, &c_n1);
00448 minwrk = (*n << 1) + *m;
00449 if (wntqo) {
00450
00451 i__1 = maxwrk, i__2 = (*n << 1) + *n * ilaenv_(&c__1,
00452 "ZUNMBR", "PRC", n, n, n, &c_n1);
00453 maxwrk = max(i__1,i__2);
00454
00455 i__1 = maxwrk, i__2 = (*n << 1) + *n * ilaenv_(&c__1,
00456 "ZUNMBR", "QLN", m, n, n, &c_n1);
00457 maxwrk = max(i__1,i__2);
00458 maxwrk += *m * *n;
00459 minwrk += *n * *n;
00460 } else if (wntqs) {
00461
00462 i__1 = maxwrk, i__2 = (*n << 1) + *n * ilaenv_(&c__1,
00463 "ZUNMBR", "PRC", n, n, n, &c_n1);
00464 maxwrk = max(i__1,i__2);
00465
00466 i__1 = maxwrk, i__2 = (*n << 1) + *n * ilaenv_(&c__1,
00467 "ZUNMBR", "QLN", m, n, n, &c_n1);
00468 maxwrk = max(i__1,i__2);
00469 } else if (wntqa) {
00470
00471 i__1 = maxwrk, i__2 = (*n << 1) + *n * ilaenv_(&c__1,
00472 "ZUNGBR", "PRC", n, n, n, &c_n1);
00473 maxwrk = max(i__1,i__2);
00474
00475 i__1 = maxwrk, i__2 = (*n << 1) + *m * ilaenv_(&c__1,
00476 "ZUNGBR", "QLN", m, m, n, &c_n1);
00477 maxwrk = max(i__1,i__2);
00478 }
00479 }
00480 } else {
00481
00482
00483
00484
00485
00486
00487
00488
00489 if (*n >= mnthr1) {
00490 if (wntqn) {
00491
00492
00493
00494 maxwrk = *m + *m * ilaenv_(&c__1, "ZGELQF", " ", m, n, &
00495 c_n1, &c_n1);
00496
00497 i__1 = maxwrk, i__2 = (*m << 1) + (*m << 1) * ilaenv_(&
00498 c__1, "ZGEBRD", " ", m, m, &c_n1, &c_n1);
00499 maxwrk = max(i__1,i__2);
00500 minwrk = *m * 3;
00501 } else if (wntqo) {
00502
00503
00504
00505 wrkbl = *m + *m * ilaenv_(&c__1, "ZGELQF", " ", m, n, &
00506 c_n1, &c_n1);
00507
00508 i__1 = wrkbl, i__2 = *m + *m * ilaenv_(&c__1, "ZUNGLQ",
00509 " ", m, n, m, &c_n1);
00510 wrkbl = max(i__1,i__2);
00511
00512 i__1 = wrkbl, i__2 = (*m << 1) + (*m << 1) * ilaenv_(&
00513 c__1, "ZGEBRD", " ", m, m, &c_n1, &c_n1);
00514 wrkbl = max(i__1,i__2);
00515
00516 i__1 = wrkbl, i__2 = (*m << 1) + *m * ilaenv_(&c__1,
00517 "ZUNMBR", "PRC", m, m, m, &c_n1);
00518 wrkbl = max(i__1,i__2);
00519
00520 i__1 = wrkbl, i__2 = (*m << 1) + *m * ilaenv_(&c__1,
00521 "ZUNMBR", "QLN", m, m, m, &c_n1);
00522 wrkbl = max(i__1,i__2);
00523 maxwrk = *m * *n + *m * *m + wrkbl;
00524 minwrk = (*m << 1) * *m + *m * 3;
00525 } else if (wntqs) {
00526
00527
00528
00529 wrkbl = *m + *m * ilaenv_(&c__1, "ZGELQF", " ", m, n, &
00530 c_n1, &c_n1);
00531
00532 i__1 = wrkbl, i__2 = *m + *m * ilaenv_(&c__1, "ZUNGLQ",
00533 " ", m, n, m, &c_n1);
00534 wrkbl = max(i__1,i__2);
00535
00536 i__1 = wrkbl, i__2 = (*m << 1) + (*m << 1) * ilaenv_(&
00537 c__1, "ZGEBRD", " ", m, m, &c_n1, &c_n1);
00538 wrkbl = max(i__1,i__2);
00539
00540 i__1 = wrkbl, i__2 = (*m << 1) + *m * ilaenv_(&c__1,
00541 "ZUNMBR", "PRC", m, m, m, &c_n1);
00542 wrkbl = max(i__1,i__2);
00543
00544 i__1 = wrkbl, i__2 = (*m << 1) + *m * ilaenv_(&c__1,
00545 "ZUNMBR", "QLN", m, m, m, &c_n1);
00546 wrkbl = max(i__1,i__2);
00547 maxwrk = *m * *m + wrkbl;
00548 minwrk = *m * *m + *m * 3;
00549 } else if (wntqa) {
00550
00551
00552
00553 wrkbl = *m + *m * ilaenv_(&c__1, "ZGELQF", " ", m, n, &
00554 c_n1, &c_n1);
00555
00556 i__1 = wrkbl, i__2 = *m + *n * ilaenv_(&c__1, "ZUNGLQ",
00557 " ", n, n, m, &c_n1);
00558 wrkbl = max(i__1,i__2);
00559
00560 i__1 = wrkbl, i__2 = (*m << 1) + (*m << 1) * ilaenv_(&
00561 c__1, "ZGEBRD", " ", m, m, &c_n1, &c_n1);
00562 wrkbl = max(i__1,i__2);
00563
00564 i__1 = wrkbl, i__2 = (*m << 1) + *m * ilaenv_(&c__1,
00565 "ZUNMBR", "PRC", m, m, m, &c_n1);
00566 wrkbl = max(i__1,i__2);
00567
00568 i__1 = wrkbl, i__2 = (*m << 1) + *m * ilaenv_(&c__1,
00569 "ZUNMBR", "QLN", m, m, m, &c_n1);
00570 wrkbl = max(i__1,i__2);
00571 maxwrk = *m * *m + wrkbl;
00572 minwrk = *m * *m + (*m << 1) + *n;
00573 }
00574 } else if (*n >= mnthr2) {
00575
00576
00577
00578 maxwrk = (*m << 1) + (*m + *n) * ilaenv_(&c__1, "ZGEBRD",
00579 " ", m, n, &c_n1, &c_n1);
00580 minwrk = (*m << 1) + *n;
00581 if (wntqo) {
00582
00583 i__1 = maxwrk, i__2 = (*m << 1) + *m * ilaenv_(&c__1,
00584 "ZUNGBR", "P", m, n, m, &c_n1);
00585 maxwrk = max(i__1,i__2);
00586
00587 i__1 = maxwrk, i__2 = (*m << 1) + *m * ilaenv_(&c__1,
00588 "ZUNGBR", "Q", m, m, n, &c_n1);
00589 maxwrk = max(i__1,i__2);
00590 maxwrk += *m * *n;
00591 minwrk += *m * *m;
00592 } else if (wntqs) {
00593
00594 i__1 = maxwrk, i__2 = (*m << 1) + *m * ilaenv_(&c__1,
00595 "ZUNGBR", "P", m, n, m, &c_n1);
00596 maxwrk = max(i__1,i__2);
00597
00598 i__1 = maxwrk, i__2 = (*m << 1) + *m * ilaenv_(&c__1,
00599 "ZUNGBR", "Q", m, m, n, &c_n1);
00600 maxwrk = max(i__1,i__2);
00601 } else if (wntqa) {
00602
00603 i__1 = maxwrk, i__2 = (*m << 1) + *n * ilaenv_(&c__1,
00604 "ZUNGBR", "P", n, n, m, &c_n1);
00605 maxwrk = max(i__1,i__2);
00606
00607 i__1 = maxwrk, i__2 = (*m << 1) + *m * ilaenv_(&c__1,
00608 "ZUNGBR", "Q", m, m, n, &c_n1);
00609 maxwrk = max(i__1,i__2);
00610 }
00611 } else {
00612
00613
00614
00615 maxwrk = (*m << 1) + (*m + *n) * ilaenv_(&c__1, "ZGEBRD",
00616 " ", m, n, &c_n1, &c_n1);
00617 minwrk = (*m << 1) + *n;
00618 if (wntqo) {
00619
00620 i__1 = maxwrk, i__2 = (*m << 1) + *m * ilaenv_(&c__1,
00621 "ZUNMBR", "PRC", m, n, m, &c_n1);
00622 maxwrk = max(i__1,i__2);
00623
00624 i__1 = maxwrk, i__2 = (*m << 1) + *m * ilaenv_(&c__1,
00625 "ZUNMBR", "QLN", m, m, n, &c_n1);
00626 maxwrk = max(i__1,i__2);
00627 maxwrk += *m * *n;
00628 minwrk += *m * *m;
00629 } else if (wntqs) {
00630
00631 i__1 = maxwrk, i__2 = (*m << 1) + *m * ilaenv_(&c__1,
00632 "ZUNGBR", "PRC", m, n, m, &c_n1);
00633 maxwrk = max(i__1,i__2);
00634
00635 i__1 = maxwrk, i__2 = (*m << 1) + *m * ilaenv_(&c__1,
00636 "ZUNGBR", "QLN", m, m, n, &c_n1);
00637 maxwrk = max(i__1,i__2);
00638 } else if (wntqa) {
00639
00640 i__1 = maxwrk, i__2 = (*m << 1) + *n * ilaenv_(&c__1,
00641 "ZUNGBR", "PRC", n, n, m, &c_n1);
00642 maxwrk = max(i__1,i__2);
00643
00644 i__1 = maxwrk, i__2 = (*m << 1) + *m * ilaenv_(&c__1,
00645 "ZUNGBR", "QLN", m, m, n, &c_n1);
00646 maxwrk = max(i__1,i__2);
00647 }
00648 }
00649 }
00650 maxwrk = max(maxwrk,minwrk);
00651 }
00652 if (*info == 0) {
00653 work[1].r = (doublereal) maxwrk, work[1].i = 0.;
00654 if (*lwork < minwrk && *lwork != -1) {
00655 *info = -13;
00656 }
00657 }
00658
00659
00660
00661 if (*info != 0) {
00662 i__1 = -(*info);
00663 xerbla_("ZGESDD", &i__1);
00664 return 0;
00665 }
00666 if (*lwork == -1) {
00667 return 0;
00668 }
00669 if (*m == 0 || *n == 0) {
00670 return 0;
00671 }
00672
00673
00674
00675 eps = dlamch_("P");
00676 smlnum = sqrt(dlamch_("S")) / eps;
00677 bignum = 1. / smlnum;
00678
00679
00680
00681 anrm = zlange_("M", m, n, &a[a_offset], lda, dum);
00682 iscl = 0;
00683 if (anrm > 0. && anrm < smlnum) {
00684 iscl = 1;
00685 zlascl_("G", &c__0, &c__0, &anrm, &smlnum, m, n, &a[a_offset], lda, &
00686 ierr);
00687 } else if (anrm > bignum) {
00688 iscl = 1;
00689 zlascl_("G", &c__0, &c__0, &anrm, &bignum, m, n, &a[a_offset], lda, &
00690 ierr);
00691 }
00692
00693 if (*m >= *n) {
00694
00695
00696
00697
00698
00699 if (*m >= mnthr1) {
00700
00701 if (wntqn) {
00702
00703
00704
00705
00706 itau = 1;
00707 nwork = itau + *n;
00708
00709
00710
00711
00712
00713 i__1 = *lwork - nwork + 1;
00714 zgeqrf_(m, n, &a[a_offset], lda, &work[itau], &work[nwork], &
00715 i__1, &ierr);
00716
00717
00718
00719 i__1 = *n - 1;
00720 i__2 = *n - 1;
00721 zlaset_("L", &i__1, &i__2, &c_b1, &c_b1, &a[a_dim1 + 2], lda);
00722 ie = 1;
00723 itauq = 1;
00724 itaup = itauq + *n;
00725 nwork = itaup + *n;
00726
00727
00728
00729
00730
00731 i__1 = *lwork - nwork + 1;
00732 zgebrd_(n, n, &a[a_offset], lda, &s[1], &rwork[ie], &work[
00733 itauq], &work[itaup], &work[nwork], &i__1, &ierr);
00734 nrwork = ie + *n;
00735
00736
00737
00738
00739
00740 dbdsdc_("U", "N", n, &s[1], &rwork[ie], dum, &c__1, dum, &
00741 c__1, dum, idum, &rwork[nrwork], &iwork[1], info);
00742
00743 } else if (wntqo) {
00744
00745
00746
00747
00748
00749 iu = 1;
00750
00751
00752
00753 ldwrku = *n;
00754 ir = iu + ldwrku * *n;
00755 if (*lwork >= *m * *n + *n * *n + *n * 3) {
00756
00757
00758
00759 ldwrkr = *m;
00760 } else {
00761 ldwrkr = (*lwork - *n * *n - *n * 3) / *n;
00762 }
00763 itau = ir + ldwrkr * *n;
00764 nwork = itau + *n;
00765
00766
00767
00768
00769
00770 i__1 = *lwork - nwork + 1;
00771 zgeqrf_(m, n, &a[a_offset], lda, &work[itau], &work[nwork], &
00772 i__1, &ierr);
00773
00774
00775
00776 zlacpy_("U", n, n, &a[a_offset], lda, &work[ir], &ldwrkr);
00777 i__1 = *n - 1;
00778 i__2 = *n - 1;
00779 zlaset_("L", &i__1, &i__2, &c_b1, &c_b1, &work[ir + 1], &
00780 ldwrkr);
00781
00782
00783
00784
00785
00786 i__1 = *lwork - nwork + 1;
00787 zungqr_(m, n, n, &a[a_offset], lda, &work[itau], &work[nwork],
00788 &i__1, &ierr);
00789 ie = 1;
00790 itauq = itau;
00791 itaup = itauq + *n;
00792 nwork = itaup + *n;
00793
00794
00795
00796
00797
00798 i__1 = *lwork - nwork + 1;
00799 zgebrd_(n, n, &work[ir], &ldwrkr, &s[1], &rwork[ie], &work[
00800 itauq], &work[itaup], &work[nwork], &i__1, &ierr);
00801
00802
00803
00804
00805
00806
00807
00808 iru = ie + *n;
00809 irvt = iru + *n * *n;
00810 nrwork = irvt + *n * *n;
00811 dbdsdc_("U", "I", n, &s[1], &rwork[ie], &rwork[iru], n, &
00812 rwork[irvt], n, dum, idum, &rwork[nrwork], &iwork[1],
00813 info);
00814
00815
00816
00817
00818
00819
00820 zlacp2_("F", n, n, &rwork[iru], n, &work[iu], &ldwrku);
00821 i__1 = *lwork - nwork + 1;
00822 zunmbr_("Q", "L", "N", n, n, n, &work[ir], &ldwrkr, &work[
00823 itauq], &work[iu], &ldwrku, &work[nwork], &i__1, &
00824 ierr);
00825
00826
00827
00828
00829
00830
00831 zlacp2_("F", n, n, &rwork[irvt], n, &vt[vt_offset], ldvt);
00832 i__1 = *lwork - nwork + 1;
00833 zunmbr_("P", "R", "C", n, n, n, &work[ir], &ldwrkr, &work[
00834 itaup], &vt[vt_offset], ldvt, &work[nwork], &i__1, &
00835 ierr);
00836
00837
00838
00839
00840
00841
00842 i__1 = *m;
00843 i__2 = ldwrkr;
00844 for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ +=
00845 i__2) {
00846
00847 i__3 = *m - i__ + 1;
00848 chunk = min(i__3,ldwrkr);
00849 zgemm_("N", "N", &chunk, n, n, &c_b2, &a[i__ + a_dim1],
00850 lda, &work[iu], &ldwrku, &c_b1, &work[ir], &
00851 ldwrkr);
00852 zlacpy_("F", &chunk, n, &work[ir], &ldwrkr, &a[i__ +
00853 a_dim1], lda);
00854
00855 }
00856
00857 } else if (wntqs) {
00858
00859
00860
00861
00862
00863 ir = 1;
00864
00865
00866
00867 ldwrkr = *n;
00868 itau = ir + ldwrkr * *n;
00869 nwork = itau + *n;
00870
00871
00872
00873
00874
00875 i__2 = *lwork - nwork + 1;
00876 zgeqrf_(m, n, &a[a_offset], lda, &work[itau], &work[nwork], &
00877 i__2, &ierr);
00878
00879
00880
00881 zlacpy_("U", n, n, &a[a_offset], lda, &work[ir], &ldwrkr);
00882 i__2 = *n - 1;
00883 i__1 = *n - 1;
00884 zlaset_("L", &i__2, &i__1, &c_b1, &c_b1, &work[ir + 1], &
00885 ldwrkr);
00886
00887
00888
00889
00890
00891 i__2 = *lwork - nwork + 1;
00892 zungqr_(m, n, n, &a[a_offset], lda, &work[itau], &work[nwork],
00893 &i__2, &ierr);
00894 ie = 1;
00895 itauq = itau;
00896 itaup = itauq + *n;
00897 nwork = itaup + *n;
00898
00899
00900
00901
00902
00903 i__2 = *lwork - nwork + 1;
00904 zgebrd_(n, n, &work[ir], &ldwrkr, &s[1], &rwork[ie], &work[
00905 itauq], &work[itaup], &work[nwork], &i__2, &ierr);
00906
00907
00908
00909
00910
00911
00912
00913 iru = ie + *n;
00914 irvt = iru + *n * *n;
00915 nrwork = irvt + *n * *n;
00916 dbdsdc_("U", "I", n, &s[1], &rwork[ie], &rwork[iru], n, &
00917 rwork[irvt], n, dum, idum, &rwork[nrwork], &iwork[1],
00918 info);
00919
00920
00921
00922
00923
00924
00925 zlacp2_("F", n, n, &rwork[iru], n, &u[u_offset], ldu);
00926 i__2 = *lwork - nwork + 1;
00927 zunmbr_("Q", "L", "N", n, n, n, &work[ir], &ldwrkr, &work[
00928 itauq], &u[u_offset], ldu, &work[nwork], &i__2, &ierr);
00929
00930
00931
00932
00933
00934
00935 zlacp2_("F", n, n, &rwork[irvt], n, &vt[vt_offset], ldvt);
00936 i__2 = *lwork - nwork + 1;
00937 zunmbr_("P", "R", "C", n, n, n, &work[ir], &ldwrkr, &work[
00938 itaup], &vt[vt_offset], ldvt, &work[nwork], &i__2, &
00939 ierr);
00940
00941
00942
00943
00944
00945
00946 zlacpy_("F", n, n, &u[u_offset], ldu, &work[ir], &ldwrkr);
00947 zgemm_("N", "N", m, n, n, &c_b2, &a[a_offset], lda, &work[ir],
00948 &ldwrkr, &c_b1, &u[u_offset], ldu);
00949
00950 } else if (wntqa) {
00951
00952
00953
00954
00955
00956 iu = 1;
00957
00958
00959
00960 ldwrku = *n;
00961 itau = iu + ldwrku * *n;
00962 nwork = itau + *n;
00963
00964
00965
00966
00967
00968 i__2 = *lwork - nwork + 1;
00969 zgeqrf_(m, n, &a[a_offset], lda, &work[itau], &work[nwork], &
00970 i__2, &ierr);
00971 zlacpy_("L", m, n, &a[a_offset], lda, &u[u_offset], ldu);
00972
00973
00974
00975
00976
00977 i__2 = *lwork - nwork + 1;
00978 zungqr_(m, m, n, &u[u_offset], ldu, &work[itau], &work[nwork],
00979 &i__2, &ierr);
00980
00981
00982
00983 i__2 = *n - 1;
00984 i__1 = *n - 1;
00985 zlaset_("L", &i__2, &i__1, &c_b1, &c_b1, &a[a_dim1 + 2], lda);
00986 ie = 1;
00987 itauq = itau;
00988 itaup = itauq + *n;
00989 nwork = itaup + *n;
00990
00991
00992
00993
00994
00995 i__2 = *lwork - nwork + 1;
00996 zgebrd_(n, n, &a[a_offset], lda, &s[1], &rwork[ie], &work[
00997 itauq], &work[itaup], &work[nwork], &i__2, &ierr);
00998 iru = ie + *n;
00999 irvt = iru + *n * *n;
01000 nrwork = irvt + *n * *n;
01001
01002
01003
01004
01005
01006
01007
01008 dbdsdc_("U", "I", n, &s[1], &rwork[ie], &rwork[iru], n, &
01009 rwork[irvt], n, dum, idum, &rwork[nrwork], &iwork[1],
01010 info);
01011
01012
01013
01014
01015
01016
01017 zlacp2_("F", n, n, &rwork[iru], n, &work[iu], &ldwrku);
01018 i__2 = *lwork - nwork + 1;
01019 zunmbr_("Q", "L", "N", n, n, n, &a[a_offset], lda, &work[
01020 itauq], &work[iu], &ldwrku, &work[nwork], &i__2, &
01021 ierr);
01022
01023
01024
01025
01026
01027
01028 zlacp2_("F", n, n, &rwork[irvt], n, &vt[vt_offset], ldvt);
01029 i__2 = *lwork - nwork + 1;
01030 zunmbr_("P", "R", "C", n, n, n, &a[a_offset], lda, &work[
01031 itaup], &vt[vt_offset], ldvt, &work[nwork], &i__2, &
01032 ierr);
01033
01034
01035
01036
01037
01038
01039 zgemm_("N", "N", m, n, n, &c_b2, &u[u_offset], ldu, &work[iu],
01040 &ldwrku, &c_b1, &a[a_offset], lda);
01041
01042
01043
01044 zlacpy_("F", m, n, &a[a_offset], lda, &u[u_offset], ldu);
01045
01046 }
01047
01048 } else if (*m >= mnthr2) {
01049
01050
01051
01052
01053
01054
01055
01056 ie = 1;
01057 nrwork = ie + *n;
01058 itauq = 1;
01059 itaup = itauq + *n;
01060 nwork = itaup + *n;
01061
01062
01063
01064
01065
01066 i__2 = *lwork - nwork + 1;
01067 zgebrd_(m, n, &a[a_offset], lda, &s[1], &rwork[ie], &work[itauq],
01068 &work[itaup], &work[nwork], &i__2, &ierr);
01069 if (wntqn) {
01070
01071
01072
01073
01074
01075 dbdsdc_("U", "N", n, &s[1], &rwork[ie], dum, &c__1, dum, &
01076 c__1, dum, idum, &rwork[nrwork], &iwork[1], info);
01077 } else if (wntqo) {
01078 iu = nwork;
01079 iru = nrwork;
01080 irvt = iru + *n * *n;
01081 nrwork = irvt + *n * *n;
01082
01083
01084
01085
01086
01087 zlacpy_("U", n, n, &a[a_offset], lda, &vt[vt_offset], ldvt);
01088 i__2 = *lwork - nwork + 1;
01089 zungbr_("P", n, n, n, &vt[vt_offset], ldvt, &work[itaup], &
01090 work[nwork], &i__2, &ierr);
01091
01092
01093
01094
01095
01096 i__2 = *lwork - nwork + 1;
01097 zungbr_("Q", m, n, n, &a[a_offset], lda, &work[itauq], &work[
01098 nwork], &i__2, &ierr);
01099
01100 if (*lwork >= *m * *n + *n * 3) {
01101
01102
01103
01104 ldwrku = *m;
01105 } else {
01106
01107
01108
01109 ldwrku = (*lwork - *n * 3) / *n;
01110 }
01111 nwork = iu + ldwrku * *n;
01112
01113
01114
01115
01116
01117
01118
01119 dbdsdc_("U", "I", n, &s[1], &rwork[ie], &rwork[iru], n, &
01120 rwork[irvt], n, dum, idum, &rwork[nrwork], &iwork[1],
01121 info);
01122
01123
01124
01125
01126
01127
01128 zlarcm_(n, n, &rwork[irvt], n, &vt[vt_offset], ldvt, &work[iu]
01129 , &ldwrku, &rwork[nrwork]);
01130 zlacpy_("F", n, n, &work[iu], &ldwrku, &vt[vt_offset], ldvt);
01131
01132
01133
01134
01135
01136
01137 nrwork = irvt;
01138 i__2 = *m;
01139 i__1 = ldwrku;
01140 for (i__ = 1; i__1 < 0 ? i__ >= i__2 : i__ <= i__2; i__ +=
01141 i__1) {
01142
01143 i__3 = *m - i__ + 1;
01144 chunk = min(i__3,ldwrku);
01145 zlacrm_(&chunk, n, &a[i__ + a_dim1], lda, &rwork[iru], n,
01146 &work[iu], &ldwrku, &rwork[nrwork]);
01147 zlacpy_("F", &chunk, n, &work[iu], &ldwrku, &a[i__ +
01148 a_dim1], lda);
01149
01150 }
01151
01152 } else if (wntqs) {
01153
01154
01155
01156
01157
01158 zlacpy_("U", n, n, &a[a_offset], lda, &vt[vt_offset], ldvt);
01159 i__1 = *lwork - nwork + 1;
01160 zungbr_("P", n, n, n, &vt[vt_offset], ldvt, &work[itaup], &
01161 work[nwork], &i__1, &ierr);
01162
01163
01164
01165
01166
01167 zlacpy_("L", m, n, &a[a_offset], lda, &u[u_offset], ldu);
01168 i__1 = *lwork - nwork + 1;
01169 zungbr_("Q", m, n, n, &u[u_offset], ldu, &work[itauq], &work[
01170 nwork], &i__1, &ierr);
01171
01172
01173
01174
01175
01176
01177
01178 iru = nrwork;
01179 irvt = iru + *n * *n;
01180 nrwork = irvt + *n * *n;
01181 dbdsdc_("U", "I", n, &s[1], &rwork[ie], &rwork[iru], n, &
01182 rwork[irvt], n, dum, idum, &rwork[nrwork], &iwork[1],
01183 info);
01184
01185
01186
01187
01188
01189
01190 zlarcm_(n, n, &rwork[irvt], n, &vt[vt_offset], ldvt, &a[
01191 a_offset], lda, &rwork[nrwork]);
01192 zlacpy_("F", n, n, &a[a_offset], lda, &vt[vt_offset], ldvt);
01193
01194
01195
01196
01197
01198
01199 nrwork = irvt;
01200 zlacrm_(m, n, &u[u_offset], ldu, &rwork[iru], n, &a[a_offset],
01201 lda, &rwork[nrwork]);
01202 zlacpy_("F", m, n, &a[a_offset], lda, &u[u_offset], ldu);
01203 } else {
01204
01205
01206
01207
01208
01209 zlacpy_("U", n, n, &a[a_offset], lda, &vt[vt_offset], ldvt);
01210 i__1 = *lwork - nwork + 1;
01211 zungbr_("P", n, n, n, &vt[vt_offset], ldvt, &work[itaup], &
01212 work[nwork], &i__1, &ierr);
01213
01214
01215
01216
01217
01218 zlacpy_("L", m, n, &a[a_offset], lda, &u[u_offset], ldu);
01219 i__1 = *lwork - nwork + 1;
01220 zungbr_("Q", m, m, n, &u[u_offset], ldu, &work[itauq], &work[
01221 nwork], &i__1, &ierr);
01222
01223
01224
01225
01226
01227
01228
01229 iru = nrwork;
01230 irvt = iru + *n * *n;
01231 nrwork = irvt + *n * *n;
01232 dbdsdc_("U", "I", n, &s[1], &rwork[ie], &rwork[iru], n, &
01233 rwork[irvt], n, dum, idum, &rwork[nrwork], &iwork[1],
01234 info);
01235
01236
01237
01238
01239
01240
01241 zlarcm_(n, n, &rwork[irvt], n, &vt[vt_offset], ldvt, &a[
01242 a_offset], lda, &rwork[nrwork]);
01243 zlacpy_("F", n, n, &a[a_offset], lda, &vt[vt_offset], ldvt);
01244
01245
01246
01247
01248
01249
01250 nrwork = irvt;
01251 zlacrm_(m, n, &u[u_offset], ldu, &rwork[iru], n, &a[a_offset],
01252 lda, &rwork[nrwork]);
01253 zlacpy_("F", m, n, &a[a_offset], lda, &u[u_offset], ldu);
01254 }
01255
01256 } else {
01257
01258
01259
01260
01261
01262
01263
01264 ie = 1;
01265 nrwork = ie + *n;
01266 itauq = 1;
01267 itaup = itauq + *n;
01268 nwork = itaup + *n;
01269
01270
01271
01272
01273
01274 i__1 = *lwork - nwork + 1;
01275 zgebrd_(m, n, &a[a_offset], lda, &s[1], &rwork[ie], &work[itauq],
01276 &work[itaup], &work[nwork], &i__1, &ierr);
01277 if (wntqn) {
01278
01279
01280
01281
01282
01283 dbdsdc_("U", "N", n, &s[1], &rwork[ie], dum, &c__1, dum, &
01284 c__1, dum, idum, &rwork[nrwork], &iwork[1], info);
01285 } else if (wntqo) {
01286 iu = nwork;
01287 iru = nrwork;
01288 irvt = iru + *n * *n;
01289 nrwork = irvt + *n * *n;
01290 if (*lwork >= *m * *n + *n * 3) {
01291
01292
01293
01294 ldwrku = *m;
01295 } else {
01296
01297
01298
01299 ldwrku = (*lwork - *n * 3) / *n;
01300 }
01301 nwork = iu + ldwrku * *n;
01302
01303
01304
01305
01306
01307
01308
01309 dbdsdc_("U", "I", n, &s[1], &rwork[ie], &rwork[iru], n, &
01310 rwork[irvt], n, dum, idum, &rwork[nrwork], &iwork[1],
01311 info);
01312
01313
01314
01315
01316
01317
01318 zlacp2_("F", n, n, &rwork[irvt], n, &vt[vt_offset], ldvt);
01319 i__1 = *lwork - nwork + 1;
01320 zunmbr_("P", "R", "C", n, n, n, &a[a_offset], lda, &work[
01321 itaup], &vt[vt_offset], ldvt, &work[nwork], &i__1, &
01322 ierr);
01323
01324 if (*lwork >= *m * *n + *n * 3) {
01325
01326
01327
01328
01329
01330
01331
01332 zlaset_("F", m, n, &c_b1, &c_b1, &work[iu], &ldwrku);
01333 zlacp2_("F", n, n, &rwork[iru], n, &work[iu], &ldwrku);
01334 i__1 = *lwork - nwork + 1;
01335 zunmbr_("Q", "L", "N", m, n, n, &a[a_offset], lda, &work[
01336 itauq], &work[iu], &ldwrku, &work[nwork], &i__1, &
01337 ierr);
01338 zlacpy_("F", m, n, &work[iu], &ldwrku, &a[a_offset], lda);
01339 } else {
01340
01341
01342
01343
01344
01345 i__1 = *lwork - nwork + 1;
01346 zungbr_("Q", m, n, n, &a[a_offset], lda, &work[itauq], &
01347 work[nwork], &i__1, &ierr);
01348
01349
01350
01351
01352
01353
01354 nrwork = irvt;
01355 i__1 = *m;
01356 i__2 = ldwrku;
01357 for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ +=
01358 i__2) {
01359
01360 i__3 = *m - i__ + 1;
01361 chunk = min(i__3,ldwrku);
01362 zlacrm_(&chunk, n, &a[i__ + a_dim1], lda, &rwork[iru],
01363 n, &work[iu], &ldwrku, &rwork[nrwork]);
01364 zlacpy_("F", &chunk, n, &work[iu], &ldwrku, &a[i__ +
01365 a_dim1], lda);
01366
01367 }
01368 }
01369
01370 } else if (wntqs) {
01371
01372
01373
01374
01375
01376
01377
01378 iru = nrwork;
01379 irvt = iru + *n * *n;
01380 nrwork = irvt + *n * *n;
01381 dbdsdc_("U", "I", n, &s[1], &rwork[ie], &rwork[iru], n, &
01382 rwork[irvt], n, dum, idum, &rwork[nrwork], &iwork[1],
01383 info);
01384
01385
01386
01387
01388
01389
01390 zlaset_("F", m, n, &c_b1, &c_b1, &u[u_offset], ldu)
01391 ;
01392 zlacp2_("F", n, n, &rwork[iru], n, &u[u_offset], ldu);
01393 i__2 = *lwork - nwork + 1;
01394 zunmbr_("Q", "L", "N", m, n, n, &a[a_offset], lda, &work[
01395 itauq], &u[u_offset], ldu, &work[nwork], &i__2, &ierr);
01396
01397
01398
01399
01400
01401
01402 zlacp2_("F", n, n, &rwork[irvt], n, &vt[vt_offset], ldvt);
01403 i__2 = *lwork - nwork + 1;
01404 zunmbr_("P", "R", "C", n, n, n, &a[a_offset], lda, &work[
01405 itaup], &vt[vt_offset], ldvt, &work[nwork], &i__2, &
01406 ierr);
01407 } else {
01408
01409
01410
01411
01412
01413
01414
01415 iru = nrwork;
01416 irvt = iru + *n * *n;
01417 nrwork = irvt + *n * *n;
01418 dbdsdc_("U", "I", n, &s[1], &rwork[ie], &rwork[iru], n, &
01419 rwork[irvt], n, dum, idum, &rwork[nrwork], &iwork[1],
01420 info);
01421
01422
01423
01424 zlaset_("F", m, m, &c_b1, &c_b1, &u[u_offset], ldu)
01425 ;
01426 if (*m > *n) {
01427 i__2 = *m - *n;
01428 i__1 = *m - *n;
01429 zlaset_("F", &i__2, &i__1, &c_b1, &c_b2, &u[*n + 1 + (*n
01430 + 1) * u_dim1], ldu);
01431 }
01432
01433
01434
01435
01436
01437
01438 zlacp2_("F", n, n, &rwork[iru], n, &u[u_offset], ldu);
01439 i__2 = *lwork - nwork + 1;
01440 zunmbr_("Q", "L", "N", m, m, n, &a[a_offset], lda, &work[
01441 itauq], &u[u_offset], ldu, &work[nwork], &i__2, &ierr);
01442
01443
01444
01445
01446
01447
01448 zlacp2_("F", n, n, &rwork[irvt], n, &vt[vt_offset], ldvt);
01449 i__2 = *lwork - nwork + 1;
01450 zunmbr_("P", "R", "C", n, n, n, &a[a_offset], lda, &work[
01451 itaup], &vt[vt_offset], ldvt, &work[nwork], &i__2, &
01452 ierr);
01453 }
01454
01455 }
01456
01457 } else {
01458
01459
01460
01461
01462
01463 if (*n >= mnthr1) {
01464
01465 if (wntqn) {
01466
01467
01468
01469
01470 itau = 1;
01471 nwork = itau + *m;
01472
01473
01474
01475
01476
01477 i__2 = *lwork - nwork + 1;
01478 zgelqf_(m, n, &a[a_offset], lda, &work[itau], &work[nwork], &
01479 i__2, &ierr);
01480
01481
01482
01483 i__2 = *m - 1;
01484 i__1 = *m - 1;
01485 zlaset_("U", &i__2, &i__1, &c_b1, &c_b1, &a[(a_dim1 << 1) + 1]
01486 , lda);
01487 ie = 1;
01488 itauq = 1;
01489 itaup = itauq + *m;
01490 nwork = itaup + *m;
01491
01492
01493
01494
01495
01496 i__2 = *lwork - nwork + 1;
01497 zgebrd_(m, m, &a[a_offset], lda, &s[1], &rwork[ie], &work[
01498 itauq], &work[itaup], &work[nwork], &i__2, &ierr);
01499 nrwork = ie + *m;
01500
01501
01502
01503
01504
01505 dbdsdc_("U", "N", m, &s[1], &rwork[ie], dum, &c__1, dum, &
01506 c__1, dum, idum, &rwork[nrwork], &iwork[1], info);
01507
01508 } else if (wntqo) {
01509
01510
01511
01512
01513
01514 ivt = 1;
01515 ldwkvt = *m;
01516
01517
01518
01519 il = ivt + ldwkvt * *m;
01520 if (*lwork >= *m * *n + *m * *m + *m * 3) {
01521
01522
01523
01524 ldwrkl = *m;
01525 chunk = *n;
01526 } else {
01527
01528
01529
01530 ldwrkl = *m;
01531 chunk = (*lwork - *m * *m - *m * 3) / *m;
01532 }
01533 itau = il + ldwrkl * chunk;
01534 nwork = itau + *m;
01535
01536
01537
01538
01539
01540 i__2 = *lwork - nwork + 1;
01541 zgelqf_(m, n, &a[a_offset], lda, &work[itau], &work[nwork], &
01542 i__2, &ierr);
01543
01544
01545
01546 zlacpy_("L", m, m, &a[a_offset], lda, &work[il], &ldwrkl);
01547 i__2 = *m - 1;
01548 i__1 = *m - 1;
01549 zlaset_("U", &i__2, &i__1, &c_b1, &c_b1, &work[il + ldwrkl], &
01550 ldwrkl);
01551
01552
01553
01554
01555
01556 i__2 = *lwork - nwork + 1;
01557 zunglq_(m, n, m, &a[a_offset], lda, &work[itau], &work[nwork],
01558 &i__2, &ierr);
01559 ie = 1;
01560 itauq = itau;
01561 itaup = itauq + *m;
01562 nwork = itaup + *m;
01563
01564
01565
01566
01567
01568 i__2 = *lwork - nwork + 1;
01569 zgebrd_(m, m, &work[il], &ldwrkl, &s[1], &rwork[ie], &work[
01570 itauq], &work[itaup], &work[nwork], &i__2, &ierr);
01571
01572
01573
01574
01575
01576
01577
01578 iru = ie + *m;
01579 irvt = iru + *m * *m;
01580 nrwork = irvt + *m * *m;
01581 dbdsdc_("U", "I", m, &s[1], &rwork[ie], &rwork[iru], m, &
01582 rwork[irvt], m, dum, idum, &rwork[nrwork], &iwork[1],
01583 info);
01584
01585
01586
01587
01588
01589
01590 zlacp2_("F", m, m, &rwork[iru], m, &u[u_offset], ldu);
01591 i__2 = *lwork - nwork + 1;
01592 zunmbr_("Q", "L", "N", m, m, m, &work[il], &ldwrkl, &work[
01593 itauq], &u[u_offset], ldu, &work[nwork], &i__2, &ierr);
01594
01595
01596
01597
01598
01599
01600 zlacp2_("F", m, m, &rwork[irvt], m, &work[ivt], &ldwkvt);
01601 i__2 = *lwork - nwork + 1;
01602 zunmbr_("P", "R", "C", m, m, m, &work[il], &ldwrkl, &work[
01603 itaup], &work[ivt], &ldwkvt, &work[nwork], &i__2, &
01604 ierr);
01605
01606
01607
01608
01609
01610
01611 i__2 = *n;
01612 i__1 = chunk;
01613 for (i__ = 1; i__1 < 0 ? i__ >= i__2 : i__ <= i__2; i__ +=
01614 i__1) {
01615
01616 i__3 = *n - i__ + 1;
01617 blk = min(i__3,chunk);
01618 zgemm_("N", "N", m, &blk, m, &c_b2, &work[ivt], m, &a[i__
01619 * a_dim1 + 1], lda, &c_b1, &work[il], &ldwrkl);
01620 zlacpy_("F", m, &blk, &work[il], &ldwrkl, &a[i__ * a_dim1
01621 + 1], lda);
01622
01623 }
01624
01625 } else if (wntqs) {
01626
01627
01628
01629
01630
01631 il = 1;
01632
01633
01634
01635 ldwrkl = *m;
01636 itau = il + ldwrkl * *m;
01637 nwork = itau + *m;
01638
01639
01640
01641
01642
01643 i__1 = *lwork - nwork + 1;
01644 zgelqf_(m, n, &a[a_offset], lda, &work[itau], &work[nwork], &
01645 i__1, &ierr);
01646
01647
01648
01649 zlacpy_("L", m, m, &a[a_offset], lda, &work[il], &ldwrkl);
01650 i__1 = *m - 1;
01651 i__2 = *m - 1;
01652 zlaset_("U", &i__1, &i__2, &c_b1, &c_b1, &work[il + ldwrkl], &
01653 ldwrkl);
01654
01655
01656
01657
01658
01659 i__1 = *lwork - nwork + 1;
01660 zunglq_(m, n, m, &a[a_offset], lda, &work[itau], &work[nwork],
01661 &i__1, &ierr);
01662 ie = 1;
01663 itauq = itau;
01664 itaup = itauq + *m;
01665 nwork = itaup + *m;
01666
01667
01668
01669
01670
01671 i__1 = *lwork - nwork + 1;
01672 zgebrd_(m, m, &work[il], &ldwrkl, &s[1], &rwork[ie], &work[
01673 itauq], &work[itaup], &work[nwork], &i__1, &ierr);
01674
01675
01676
01677
01678
01679
01680
01681 iru = ie + *m;
01682 irvt = iru + *m * *m;
01683 nrwork = irvt + *m * *m;
01684 dbdsdc_("U", "I", m, &s[1], &rwork[ie], &rwork[iru], m, &
01685 rwork[irvt], m, dum, idum, &rwork[nrwork], &iwork[1],
01686 info);
01687
01688
01689
01690
01691
01692
01693 zlacp2_("F", m, m, &rwork[iru], m, &u[u_offset], ldu);
01694 i__1 = *lwork - nwork + 1;
01695 zunmbr_("Q", "L", "N", m, m, m, &work[il], &ldwrkl, &work[
01696 itauq], &u[u_offset], ldu, &work[nwork], &i__1, &ierr);
01697
01698
01699
01700
01701
01702
01703 zlacp2_("F", m, m, &rwork[irvt], m, &vt[vt_offset], ldvt);
01704 i__1 = *lwork - nwork + 1;
01705 zunmbr_("P", "R", "C", m, m, m, &work[il], &ldwrkl, &work[
01706 itaup], &vt[vt_offset], ldvt, &work[nwork], &i__1, &
01707 ierr);
01708
01709
01710
01711
01712
01713
01714 zlacpy_("F", m, m, &vt[vt_offset], ldvt, &work[il], &ldwrkl);
01715 zgemm_("N", "N", m, n, m, &c_b2, &work[il], &ldwrkl, &a[
01716 a_offset], lda, &c_b1, &vt[vt_offset], ldvt);
01717
01718 } else if (wntqa) {
01719
01720
01721
01722
01723
01724 ivt = 1;
01725
01726
01727
01728 ldwkvt = *m;
01729 itau = ivt + ldwkvt * *m;
01730 nwork = itau + *m;
01731
01732
01733
01734
01735
01736 i__1 = *lwork - nwork + 1;
01737 zgelqf_(m, n, &a[a_offset], lda, &work[itau], &work[nwork], &
01738 i__1, &ierr);
01739 zlacpy_("U", m, n, &a[a_offset], lda, &vt[vt_offset], ldvt);
01740
01741
01742
01743
01744
01745 i__1 = *lwork - nwork + 1;
01746 zunglq_(n, n, m, &vt[vt_offset], ldvt, &work[itau], &work[
01747 nwork], &i__1, &ierr);
01748
01749
01750
01751 i__1 = *m - 1;
01752 i__2 = *m - 1;
01753 zlaset_("U", &i__1, &i__2, &c_b1, &c_b1, &a[(a_dim1 << 1) + 1]
01754 , lda);
01755 ie = 1;
01756 itauq = itau;
01757 itaup = itauq + *m;
01758 nwork = itaup + *m;
01759
01760
01761
01762
01763
01764 i__1 = *lwork - nwork + 1;
01765 zgebrd_(m, m, &a[a_offset], lda, &s[1], &rwork[ie], &work[
01766 itauq], &work[itaup], &work[nwork], &i__1, &ierr);
01767
01768
01769
01770
01771
01772
01773
01774 iru = ie + *m;
01775 irvt = iru + *m * *m;
01776 nrwork = irvt + *m * *m;
01777 dbdsdc_("U", "I", m, &s[1], &rwork[ie], &rwork[iru], m, &
01778 rwork[irvt], m, dum, idum, &rwork[nrwork], &iwork[1],
01779 info);
01780
01781
01782
01783
01784
01785
01786 zlacp2_("F", m, m, &rwork[iru], m, &u[u_offset], ldu);
01787 i__1 = *lwork - nwork + 1;
01788 zunmbr_("Q", "L", "N", m, m, m, &a[a_offset], lda, &work[
01789 itauq], &u[u_offset], ldu, &work[nwork], &i__1, &ierr);
01790
01791
01792
01793
01794
01795
01796 zlacp2_("F", m, m, &rwork[irvt], m, &work[ivt], &ldwkvt);
01797 i__1 = *lwork - nwork + 1;
01798 zunmbr_("P", "R", "C", m, m, m, &a[a_offset], lda, &work[
01799 itaup], &work[ivt], &ldwkvt, &work[nwork], &i__1, &
01800 ierr);
01801
01802
01803
01804
01805
01806
01807 zgemm_("N", "N", m, n, m, &c_b2, &work[ivt], &ldwkvt, &vt[
01808 vt_offset], ldvt, &c_b1, &a[a_offset], lda);
01809
01810
01811
01812 zlacpy_("F", m, n, &a[a_offset], lda, &vt[vt_offset], ldvt);
01813
01814 }
01815
01816 } else if (*n >= mnthr2) {
01817
01818
01819
01820
01821
01822
01823
01824
01825 ie = 1;
01826 nrwork = ie + *m;
01827 itauq = 1;
01828 itaup = itauq + *m;
01829 nwork = itaup + *m;
01830
01831
01832
01833
01834
01835 i__1 = *lwork - nwork + 1;
01836 zgebrd_(m, n, &a[a_offset], lda, &s[1], &rwork[ie], &work[itauq],
01837 &work[itaup], &work[nwork], &i__1, &ierr);
01838
01839 if (wntqn) {
01840
01841
01842
01843
01844
01845 dbdsdc_("L", "N", m, &s[1], &rwork[ie], dum, &c__1, dum, &
01846 c__1, dum, idum, &rwork[nrwork], &iwork[1], info);
01847 } else if (wntqo) {
01848 irvt = nrwork;
01849 iru = irvt + *m * *m;
01850 nrwork = iru + *m * *m;
01851 ivt = nwork;
01852
01853
01854
01855
01856
01857 zlacpy_("L", m, m, &a[a_offset], lda, &u[u_offset], ldu);
01858 i__1 = *lwork - nwork + 1;
01859 zungbr_("Q", m, m, n, &u[u_offset], ldu, &work[itauq], &work[
01860 nwork], &i__1, &ierr);
01861
01862
01863
01864
01865
01866 i__1 = *lwork - nwork + 1;
01867 zungbr_("P", m, n, m, &a[a_offset], lda, &work[itaup], &work[
01868 nwork], &i__1, &ierr);
01869
01870 ldwkvt = *m;
01871 if (*lwork >= *m * *n + *m * 3) {
01872
01873
01874
01875 nwork = ivt + ldwkvt * *n;
01876 chunk = *n;
01877 } else {
01878
01879
01880
01881 chunk = (*lwork - *m * 3) / *m;
01882 nwork = ivt + ldwkvt * chunk;
01883 }
01884
01885
01886
01887
01888
01889
01890
01891 dbdsdc_("L", "I", m, &s[1], &rwork[ie], &rwork[iru], m, &
01892 rwork[irvt], m, dum, idum, &rwork[nrwork], &iwork[1],
01893 info);
01894
01895
01896
01897
01898
01899
01900 zlacrm_(m, m, &u[u_offset], ldu, &rwork[iru], m, &work[ivt], &
01901 ldwkvt, &rwork[nrwork]);
01902 zlacpy_("F", m, m, &work[ivt], &ldwkvt, &u[u_offset], ldu);
01903
01904
01905
01906
01907
01908
01909 nrwork = iru;
01910 i__1 = *n;
01911 i__2 = chunk;
01912 for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ +=
01913 i__2) {
01914
01915 i__3 = *n - i__ + 1;
01916 blk = min(i__3,chunk);
01917 zlarcm_(m, &blk, &rwork[irvt], m, &a[i__ * a_dim1 + 1],
01918 lda, &work[ivt], &ldwkvt, &rwork[nrwork]);
01919 zlacpy_("F", m, &blk, &work[ivt], &ldwkvt, &a[i__ *
01920 a_dim1 + 1], lda);
01921
01922 }
01923 } else if (wntqs) {
01924
01925
01926
01927
01928
01929 zlacpy_("L", m, m, &a[a_offset], lda, &u[u_offset], ldu);
01930 i__2 = *lwork - nwork + 1;
01931 zungbr_("Q", m, m, n, &u[u_offset], ldu, &work[itauq], &work[
01932 nwork], &i__2, &ierr);
01933
01934
01935
01936
01937
01938 zlacpy_("U", m, n, &a[a_offset], lda, &vt[vt_offset], ldvt);
01939 i__2 = *lwork - nwork + 1;
01940 zungbr_("P", m, n, m, &vt[vt_offset], ldvt, &work[itaup], &
01941 work[nwork], &i__2, &ierr);
01942
01943
01944
01945
01946
01947
01948
01949 irvt = nrwork;
01950 iru = irvt + *m * *m;
01951 nrwork = iru + *m * *m;
01952 dbdsdc_("L", "I", m, &s[1], &rwork[ie], &rwork[iru], m, &
01953 rwork[irvt], m, dum, idum, &rwork[nrwork], &iwork[1],
01954 info);
01955
01956
01957
01958
01959
01960
01961 zlacrm_(m, m, &u[u_offset], ldu, &rwork[iru], m, &a[a_offset],
01962 lda, &rwork[nrwork]);
01963 zlacpy_("F", m, m, &a[a_offset], lda, &u[u_offset], ldu);
01964
01965
01966
01967
01968
01969
01970 nrwork = iru;
01971 zlarcm_(m, n, &rwork[irvt], m, &vt[vt_offset], ldvt, &a[
01972 a_offset], lda, &rwork[nrwork]);
01973 zlacpy_("F", m, n, &a[a_offset], lda, &vt[vt_offset], ldvt);
01974 } else {
01975
01976
01977
01978
01979
01980 zlacpy_("L", m, m, &a[a_offset], lda, &u[u_offset], ldu);
01981 i__2 = *lwork - nwork + 1;
01982 zungbr_("Q", m, m, n, &u[u_offset], ldu, &work[itauq], &work[
01983 nwork], &i__2, &ierr);
01984
01985
01986
01987
01988
01989 zlacpy_("U", m, n, &a[a_offset], lda, &vt[vt_offset], ldvt);
01990 i__2 = *lwork - nwork + 1;
01991 zungbr_("P", n, n, m, &vt[vt_offset], ldvt, &work[itaup], &
01992 work[nwork], &i__2, &ierr);
01993
01994
01995
01996
01997
01998
01999
02000 irvt = nrwork;
02001 iru = irvt + *m * *m;
02002 nrwork = iru + *m * *m;
02003 dbdsdc_("L", "I", m, &s[1], &rwork[ie], &rwork[iru], m, &
02004 rwork[irvt], m, dum, idum, &rwork[nrwork], &iwork[1],
02005 info);
02006
02007
02008
02009
02010
02011
02012 zlacrm_(m, m, &u[u_offset], ldu, &rwork[iru], m, &a[a_offset],
02013 lda, &rwork[nrwork]);
02014 zlacpy_("F", m, m, &a[a_offset], lda, &u[u_offset], ldu);
02015
02016
02017
02018
02019
02020
02021 zlarcm_(m, n, &rwork[irvt], m, &vt[vt_offset], ldvt, &a[
02022 a_offset], lda, &rwork[nrwork]);
02023 zlacpy_("F", m, n, &a[a_offset], lda, &vt[vt_offset], ldvt);
02024 }
02025
02026 } else {
02027
02028
02029
02030
02031
02032
02033
02034 ie = 1;
02035 nrwork = ie + *m;
02036 itauq = 1;
02037 itaup = itauq + *m;
02038 nwork = itaup + *m;
02039
02040
02041
02042
02043
02044 i__2 = *lwork - nwork + 1;
02045 zgebrd_(m, n, &a[a_offset], lda, &s[1], &rwork[ie], &work[itauq],
02046 &work[itaup], &work[nwork], &i__2, &ierr);
02047 if (wntqn) {
02048
02049
02050
02051
02052
02053 dbdsdc_("L", "N", m, &s[1], &rwork[ie], dum, &c__1, dum, &
02054 c__1, dum, idum, &rwork[nrwork], &iwork[1], info);
02055 } else if (wntqo) {
02056 ldwkvt = *m;
02057 ivt = nwork;
02058 if (*lwork >= *m * *n + *m * 3) {
02059
02060
02061
02062 zlaset_("F", m, n, &c_b1, &c_b1, &work[ivt], &ldwkvt);
02063 nwork = ivt + ldwkvt * *n;
02064 } else {
02065
02066
02067
02068 chunk = (*lwork - *m * 3) / *m;
02069 nwork = ivt + ldwkvt * chunk;
02070 }
02071
02072
02073
02074
02075
02076
02077
02078 irvt = nrwork;
02079 iru = irvt + *m * *m;
02080 nrwork = iru + *m * *m;
02081 dbdsdc_("L", "I", m, &s[1], &rwork[ie], &rwork[iru], m, &
02082 rwork[irvt], m, dum, idum, &rwork[nrwork], &iwork[1],
02083 info);
02084
02085
02086
02087
02088
02089
02090 zlacp2_("F", m, m, &rwork[iru], m, &u[u_offset], ldu);
02091 i__2 = *lwork - nwork + 1;
02092 zunmbr_("Q", "L", "N", m, m, n, &a[a_offset], lda, &work[
02093 itauq], &u[u_offset], ldu, &work[nwork], &i__2, &ierr);
02094
02095 if (*lwork >= *m * *n + *m * 3) {
02096
02097
02098
02099
02100
02101
02102
02103 zlacp2_("F", m, m, &rwork[irvt], m, &work[ivt], &ldwkvt);
02104 i__2 = *lwork - nwork + 1;
02105 zunmbr_("P", "R", "C", m, n, m, &a[a_offset], lda, &work[
02106 itaup], &work[ivt], &ldwkvt, &work[nwork], &i__2,
02107 &ierr);
02108 zlacpy_("F", m, n, &work[ivt], &ldwkvt, &a[a_offset], lda);
02109 } else {
02110
02111
02112
02113
02114
02115 i__2 = *lwork - nwork + 1;
02116 zungbr_("P", m, n, m, &a[a_offset], lda, &work[itaup], &
02117 work[nwork], &i__2, &ierr);
02118
02119
02120
02121
02122
02123
02124 nrwork = iru;
02125 i__2 = *n;
02126 i__1 = chunk;
02127 for (i__ = 1; i__1 < 0 ? i__ >= i__2 : i__ <= i__2; i__ +=
02128 i__1) {
02129
02130 i__3 = *n - i__ + 1;
02131 blk = min(i__3,chunk);
02132 zlarcm_(m, &blk, &rwork[irvt], m, &a[i__ * a_dim1 + 1]
02133 , lda, &work[ivt], &ldwkvt, &rwork[nrwork]);
02134 zlacpy_("F", m, &blk, &work[ivt], &ldwkvt, &a[i__ *
02135 a_dim1 + 1], lda);
02136
02137 }
02138 }
02139 } else if (wntqs) {
02140
02141
02142
02143
02144
02145
02146
02147 irvt = nrwork;
02148 iru = irvt + *m * *m;
02149 nrwork = iru + *m * *m;
02150 dbdsdc_("L", "I", m, &s[1], &rwork[ie], &rwork[iru], m, &
02151 rwork[irvt], m, dum, idum, &rwork[nrwork], &iwork[1],
02152 info);
02153
02154
02155
02156
02157
02158
02159 zlacp2_("F", m, m, &rwork[iru], m, &u[u_offset], ldu);
02160 i__1 = *lwork - nwork + 1;
02161 zunmbr_("Q", "L", "N", m, m, n, &a[a_offset], lda, &work[
02162 itauq], &u[u_offset], ldu, &work[nwork], &i__1, &ierr);
02163
02164
02165
02166
02167
02168
02169 zlaset_("F", m, n, &c_b1, &c_b1, &vt[vt_offset], ldvt);
02170 zlacp2_("F", m, m, &rwork[irvt], m, &vt[vt_offset], ldvt);
02171 i__1 = *lwork - nwork + 1;
02172 zunmbr_("P", "R", "C", m, n, m, &a[a_offset], lda, &work[
02173 itaup], &vt[vt_offset], ldvt, &work[nwork], &i__1, &
02174 ierr);
02175 } else {
02176
02177
02178
02179
02180
02181
02182
02183 irvt = nrwork;
02184 iru = irvt + *m * *m;
02185 nrwork = iru + *m * *m;
02186
02187 dbdsdc_("L", "I", m, &s[1], &rwork[ie], &rwork[iru], m, &
02188 rwork[irvt], m, dum, idum, &rwork[nrwork], &iwork[1],
02189 info);
02190
02191
02192
02193
02194
02195
02196 zlacp2_("F", m, m, &rwork[iru], m, &u[u_offset], ldu);
02197 i__1 = *lwork - nwork + 1;
02198 zunmbr_("Q", "L", "N", m, m, n, &a[a_offset], lda, &work[
02199 itauq], &u[u_offset], ldu, &work[nwork], &i__1, &ierr);
02200
02201
02202
02203 zlaset_("F", n, n, &c_b1, &c_b2, &vt[vt_offset], ldvt);
02204
02205
02206
02207
02208
02209
02210 zlacp2_("F", m, m, &rwork[irvt], m, &vt[vt_offset], ldvt);
02211 i__1 = *lwork - nwork + 1;
02212 zunmbr_("P", "R", "C", n, n, m, &a[a_offset], lda, &work[
02213 itaup], &vt[vt_offset], ldvt, &work[nwork], &i__1, &
02214 ierr);
02215 }
02216
02217 }
02218
02219 }
02220
02221
02222
02223 if (iscl == 1) {
02224 if (anrm > bignum) {
02225 dlascl_("G", &c__0, &c__0, &bignum, &anrm, &minmn, &c__1, &s[1], &
02226 minmn, &ierr);
02227 }
02228 if (*info != 0 && anrm > bignum) {
02229 i__1 = minmn - 1;
02230 dlascl_("G", &c__0, &c__0, &bignum, &anrm, &i__1, &c__1, &rwork[
02231 ie], &minmn, &ierr);
02232 }
02233 if (anrm < smlnum) {
02234 dlascl_("G", &c__0, &c__0, &smlnum, &anrm, &minmn, &c__1, &s[1], &
02235 minmn, &ierr);
02236 }
02237 if (*info != 0 && anrm < smlnum) {
02238 i__1 = minmn - 1;
02239 dlascl_("G", &c__0, &c__0, &smlnum, &anrm, &i__1, &c__1, &rwork[
02240 ie], &minmn, &ierr);
02241 }
02242 }
02243
02244
02245
02246 work[1].r = (doublereal) maxwrk, work[1].i = 0.;
02247
02248 return 0;
02249
02250
02251
02252 }