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