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 integer c__6 = 6;
00019 static integer c__0 = 0;
00020 static integer c__2 = 2;
00021 static integer c__1 = 1;
00022 static integer c_n1 = -1;
00023 static doublereal c_b421 = 0.;
00024 static doublereal c_b443 = 1.;
00025
00026 int dgesvd_(char *jobu, char *jobvt, integer *m, integer *n,
00027 doublereal *a, integer *lda, doublereal *s, doublereal *u, integer *
00028 ldu, doublereal *vt, integer *ldvt, doublereal *work, integer *lwork,
00029 integer *info)
00030 {
00031
00032 address a__1[2];
00033 integer a_dim1, a_offset, u_dim1, u_offset, vt_dim1, vt_offset, i__1[2],
00034 i__2, i__3, i__4;
00035 char ch__1[2];
00036
00037
00038 int s_cat(char *, char **, integer *, integer *, ftnlen);
00039 double sqrt(doublereal);
00040
00041
00042 integer i__, ie, ir, iu, blk, ncu;
00043 doublereal dum[1], eps;
00044 integer nru, iscl;
00045 doublereal anrm;
00046 integer ierr, itau, ncvt, nrvt;
00047 extern int dgemm_(char *, char *, integer *, integer *,
00048 integer *, doublereal *, doublereal *, integer *, doublereal *,
00049 integer *, doublereal *, doublereal *, integer *);
00050 extern logical lsame_(char *, char *);
00051 integer chunk, minmn, wrkbl, itaup, itauq, mnthr, iwork;
00052 logical wntua, wntva, wntun, wntuo, wntvn, wntvo, wntus, wntvs;
00053 extern int dgebrd_(integer *, integer *, doublereal *,
00054 integer *, doublereal *, doublereal *, doublereal *, doublereal *,
00055 doublereal *, integer *, integer *);
00056 extern doublereal dlamch_(char *), dlange_(char *, integer *,
00057 integer *, doublereal *, integer *, doublereal *);
00058 integer bdspac;
00059 extern int dgelqf_(integer *, integer *, doublereal *,
00060 integer *, doublereal *, doublereal *, integer *, integer *),
00061 dlascl_(char *, integer *, integer *, doublereal *, doublereal *,
00062 integer *, integer *, doublereal *, integer *, integer *),
00063 dgeqrf_(integer *, integer *, doublereal *, integer *,
00064 doublereal *, doublereal *, integer *, integer *), dlacpy_(char *,
00065 integer *, integer *, doublereal *, integer *, doublereal *,
00066 integer *), dlaset_(char *, integer *, integer *,
00067 doublereal *, doublereal *, doublereal *, integer *),
00068 dbdsqr_(char *, integer *, integer *, integer *, integer *,
00069 doublereal *, doublereal *, doublereal *, integer *, doublereal *,
00070 integer *, doublereal *, integer *, doublereal *, integer *), dorgbr_(char *, integer *, integer *, integer *,
00071 doublereal *, integer *, doublereal *, doublereal *, integer *,
00072 integer *);
00073 doublereal bignum;
00074 extern int xerbla_(char *, integer *);
00075 extern integer ilaenv_(integer *, char *, char *, integer *, integer *,
00076 integer *, integer *);
00077 extern int dormbr_(char *, char *, char *, integer *,
00078 integer *, integer *, doublereal *, integer *, doublereal *,
00079 doublereal *, integer *, doublereal *, integer *, integer *), dorglq_(integer *, integer *, integer *,
00080 doublereal *, integer *, doublereal *, doublereal *, integer *,
00081 integer *), dorgqr_(integer *, integer *, integer *, doublereal *,
00082 integer *, doublereal *, doublereal *, integer *, integer *);
00083 integer ldwrkr, minwrk, ldwrku, maxwrk;
00084 doublereal smlnum;
00085 logical lquery, wntuas, wntvas;
00086
00087
00088
00089
00090
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 a_dim1 = *lda;
00233 a_offset = 1 + a_dim1;
00234 a -= a_offset;
00235 --s;
00236 u_dim1 = *ldu;
00237 u_offset = 1 + u_dim1;
00238 u -= u_offset;
00239 vt_dim1 = *ldvt;
00240 vt_offset = 1 + vt_dim1;
00241 vt -= vt_offset;
00242 --work;
00243
00244
00245 *info = 0;
00246 minmn = min(*m,*n);
00247 wntua = lsame_(jobu, "A");
00248 wntus = lsame_(jobu, "S");
00249 wntuas = wntua || wntus;
00250 wntuo = lsame_(jobu, "O");
00251 wntun = lsame_(jobu, "N");
00252 wntva = lsame_(jobvt, "A");
00253 wntvs = lsame_(jobvt, "S");
00254 wntvas = wntva || wntvs;
00255 wntvo = lsame_(jobvt, "O");
00256 wntvn = lsame_(jobvt, "N");
00257 lquery = *lwork == -1;
00258
00259 if (! (wntua || wntus || wntuo || wntun)) {
00260 *info = -1;
00261 } else if (! (wntva || wntvs || wntvo || wntvn) || wntvo && wntuo) {
00262 *info = -2;
00263 } else if (*m < 0) {
00264 *info = -3;
00265 } else if (*n < 0) {
00266 *info = -4;
00267 } else if (*lda < max(1,*m)) {
00268 *info = -6;
00269 } else if (*ldu < 1 || wntuas && *ldu < *m) {
00270 *info = -9;
00271 } else if (*ldvt < 1 || wntva && *ldvt < *n || wntvs && *ldvt < minmn) {
00272 *info = -11;
00273 }
00274
00275
00276
00277
00278
00279
00280
00281
00282 if (*info == 0) {
00283 minwrk = 1;
00284 maxwrk = 1;
00285 if (*m >= *n && minmn > 0) {
00286
00287
00288
00289
00290 i__1[0] = 1, a__1[0] = jobu;
00291 i__1[1] = 1, a__1[1] = jobvt;
00292 s_cat(ch__1, a__1, i__1, &c__2, (ftnlen)2);
00293 mnthr = ilaenv_(&c__6, "DGESVD", ch__1, m, n, &c__0, &c__0);
00294 bdspac = *n * 5;
00295 if (*m >= mnthr) {
00296 if (wntun) {
00297
00298
00299
00300 maxwrk = *n + *n * ilaenv_(&c__1, "DGEQRF", " ", m, n, &
00301 c_n1, &c_n1);
00302
00303 i__2 = maxwrk, i__3 = *n * 3 + (*n << 1) * ilaenv_(&c__1,
00304 "DGEBRD", " ", n, n, &c_n1, &c_n1);
00305 maxwrk = max(i__2,i__3);
00306 if (wntvo || wntvas) {
00307
00308 i__2 = maxwrk, i__3 = *n * 3 + (*n - 1) * ilaenv_(&
00309 c__1, "DORGBR", "P", n, n, n, &c_n1);
00310 maxwrk = max(i__2,i__3);
00311 }
00312 maxwrk = max(maxwrk,bdspac);
00313
00314 i__2 = *n << 2;
00315 minwrk = max(i__2,bdspac);
00316 } else if (wntuo && wntvn) {
00317
00318
00319
00320 wrkbl = *n + *n * ilaenv_(&c__1, "DGEQRF", " ", m, n, &
00321 c_n1, &c_n1);
00322
00323 i__2 = wrkbl, i__3 = *n + *n * ilaenv_(&c__1, "DORGQR",
00324 " ", m, n, n, &c_n1);
00325 wrkbl = max(i__2,i__3);
00326
00327 i__2 = wrkbl, i__3 = *n * 3 + (*n << 1) * ilaenv_(&c__1,
00328 "DGEBRD", " ", n, n, &c_n1, &c_n1);
00329 wrkbl = max(i__2,i__3);
00330
00331 i__2 = wrkbl, i__3 = *n * 3 + *n * ilaenv_(&c__1, "DORGBR"
00332 , "Q", n, n, n, &c_n1);
00333 wrkbl = max(i__2,i__3);
00334 wrkbl = max(wrkbl,bdspac);
00335
00336 i__2 = *n * *n + wrkbl, i__3 = *n * *n + *m * *n + *n;
00337 maxwrk = max(i__2,i__3);
00338
00339 i__2 = *n * 3 + *m;
00340 minwrk = max(i__2,bdspac);
00341 } else if (wntuo && wntvas) {
00342
00343
00344
00345
00346 wrkbl = *n + *n * ilaenv_(&c__1, "DGEQRF", " ", m, n, &
00347 c_n1, &c_n1);
00348
00349 i__2 = wrkbl, i__3 = *n + *n * ilaenv_(&c__1, "DORGQR",
00350 " ", m, n, n, &c_n1);
00351 wrkbl = max(i__2,i__3);
00352
00353 i__2 = wrkbl, i__3 = *n * 3 + (*n << 1) * ilaenv_(&c__1,
00354 "DGEBRD", " ", n, n, &c_n1, &c_n1);
00355 wrkbl = max(i__2,i__3);
00356
00357 i__2 = wrkbl, i__3 = *n * 3 + *n * ilaenv_(&c__1, "DORGBR"
00358 , "Q", n, n, n, &c_n1);
00359 wrkbl = max(i__2,i__3);
00360
00361 i__2 = wrkbl, i__3 = *n * 3 + (*n - 1) * ilaenv_(&c__1,
00362 "DORGBR", "P", n, n, n, &c_n1);
00363 wrkbl = max(i__2,i__3);
00364 wrkbl = max(wrkbl,bdspac);
00365
00366 i__2 = *n * *n + wrkbl, i__3 = *n * *n + *m * *n + *n;
00367 maxwrk = max(i__2,i__3);
00368
00369 i__2 = *n * 3 + *m;
00370 minwrk = max(i__2,bdspac);
00371 } else if (wntus && wntvn) {
00372
00373
00374
00375 wrkbl = *n + *n * ilaenv_(&c__1, "DGEQRF", " ", m, n, &
00376 c_n1, &c_n1);
00377
00378 i__2 = wrkbl, i__3 = *n + *n * ilaenv_(&c__1, "DORGQR",
00379 " ", m, n, n, &c_n1);
00380 wrkbl = max(i__2,i__3);
00381
00382 i__2 = wrkbl, i__3 = *n * 3 + (*n << 1) * ilaenv_(&c__1,
00383 "DGEBRD", " ", n, n, &c_n1, &c_n1);
00384 wrkbl = max(i__2,i__3);
00385
00386 i__2 = wrkbl, i__3 = *n * 3 + *n * ilaenv_(&c__1, "DORGBR"
00387 , "Q", n, n, n, &c_n1);
00388 wrkbl = max(i__2,i__3);
00389 wrkbl = max(wrkbl,bdspac);
00390 maxwrk = *n * *n + wrkbl;
00391
00392 i__2 = *n * 3 + *m;
00393 minwrk = max(i__2,bdspac);
00394 } else if (wntus && wntvo) {
00395
00396
00397
00398 wrkbl = *n + *n * ilaenv_(&c__1, "DGEQRF", " ", m, n, &
00399 c_n1, &c_n1);
00400
00401 i__2 = wrkbl, i__3 = *n + *n * ilaenv_(&c__1, "DORGQR",
00402 " ", m, n, n, &c_n1);
00403 wrkbl = max(i__2,i__3);
00404
00405 i__2 = wrkbl, i__3 = *n * 3 + (*n << 1) * ilaenv_(&c__1,
00406 "DGEBRD", " ", n, n, &c_n1, &c_n1);
00407 wrkbl = max(i__2,i__3);
00408
00409 i__2 = wrkbl, i__3 = *n * 3 + *n * ilaenv_(&c__1, "DORGBR"
00410 , "Q", n, n, n, &c_n1);
00411 wrkbl = max(i__2,i__3);
00412
00413 i__2 = wrkbl, i__3 = *n * 3 + (*n - 1) * ilaenv_(&c__1,
00414 "DORGBR", "P", n, n, n, &c_n1);
00415 wrkbl = max(i__2,i__3);
00416 wrkbl = max(wrkbl,bdspac);
00417 maxwrk = (*n << 1) * *n + wrkbl;
00418
00419 i__2 = *n * 3 + *m;
00420 minwrk = max(i__2,bdspac);
00421 } else if (wntus && wntvas) {
00422
00423
00424
00425
00426 wrkbl = *n + *n * ilaenv_(&c__1, "DGEQRF", " ", m, n, &
00427 c_n1, &c_n1);
00428
00429 i__2 = wrkbl, i__3 = *n + *n * ilaenv_(&c__1, "DORGQR",
00430 " ", m, n, n, &c_n1);
00431 wrkbl = max(i__2,i__3);
00432
00433 i__2 = wrkbl, i__3 = *n * 3 + (*n << 1) * ilaenv_(&c__1,
00434 "DGEBRD", " ", n, n, &c_n1, &c_n1);
00435 wrkbl = max(i__2,i__3);
00436
00437 i__2 = wrkbl, i__3 = *n * 3 + *n * ilaenv_(&c__1, "DORGBR"
00438 , "Q", n, n, n, &c_n1);
00439 wrkbl = max(i__2,i__3);
00440
00441 i__2 = wrkbl, i__3 = *n * 3 + (*n - 1) * ilaenv_(&c__1,
00442 "DORGBR", "P", n, n, n, &c_n1);
00443 wrkbl = max(i__2,i__3);
00444 wrkbl = max(wrkbl,bdspac);
00445 maxwrk = *n * *n + wrkbl;
00446
00447 i__2 = *n * 3 + *m;
00448 minwrk = max(i__2,bdspac);
00449 } else if (wntua && wntvn) {
00450
00451
00452
00453 wrkbl = *n + *n * ilaenv_(&c__1, "DGEQRF", " ", m, n, &
00454 c_n1, &c_n1);
00455
00456 i__2 = wrkbl, i__3 = *n + *m * ilaenv_(&c__1, "DORGQR",
00457 " ", m, m, n, &c_n1);
00458 wrkbl = max(i__2,i__3);
00459
00460 i__2 = wrkbl, i__3 = *n * 3 + (*n << 1) * ilaenv_(&c__1,
00461 "DGEBRD", " ", n, n, &c_n1, &c_n1);
00462 wrkbl = max(i__2,i__3);
00463
00464 i__2 = wrkbl, i__3 = *n * 3 + *n * ilaenv_(&c__1, "DORGBR"
00465 , "Q", n, n, n, &c_n1);
00466 wrkbl = max(i__2,i__3);
00467 wrkbl = max(wrkbl,bdspac);
00468 maxwrk = *n * *n + wrkbl;
00469
00470 i__2 = *n * 3 + *m;
00471 minwrk = max(i__2,bdspac);
00472 } else if (wntua && wntvo) {
00473
00474
00475
00476 wrkbl = *n + *n * ilaenv_(&c__1, "DGEQRF", " ", m, n, &
00477 c_n1, &c_n1);
00478
00479 i__2 = wrkbl, i__3 = *n + *m * ilaenv_(&c__1, "DORGQR",
00480 " ", m, m, n, &c_n1);
00481 wrkbl = max(i__2,i__3);
00482
00483 i__2 = wrkbl, i__3 = *n * 3 + (*n << 1) * ilaenv_(&c__1,
00484 "DGEBRD", " ", n, n, &c_n1, &c_n1);
00485 wrkbl = max(i__2,i__3);
00486
00487 i__2 = wrkbl, i__3 = *n * 3 + *n * ilaenv_(&c__1, "DORGBR"
00488 , "Q", n, n, n, &c_n1);
00489 wrkbl = max(i__2,i__3);
00490
00491 i__2 = wrkbl, i__3 = *n * 3 + (*n - 1) * ilaenv_(&c__1,
00492 "DORGBR", "P", n, n, n, &c_n1);
00493 wrkbl = max(i__2,i__3);
00494 wrkbl = max(wrkbl,bdspac);
00495 maxwrk = (*n << 1) * *n + wrkbl;
00496
00497 i__2 = *n * 3 + *m;
00498 minwrk = max(i__2,bdspac);
00499 } else if (wntua && wntvas) {
00500
00501
00502
00503
00504 wrkbl = *n + *n * ilaenv_(&c__1, "DGEQRF", " ", m, n, &
00505 c_n1, &c_n1);
00506
00507 i__2 = wrkbl, i__3 = *n + *m * ilaenv_(&c__1, "DORGQR",
00508 " ", m, m, n, &c_n1);
00509 wrkbl = max(i__2,i__3);
00510
00511 i__2 = wrkbl, i__3 = *n * 3 + (*n << 1) * ilaenv_(&c__1,
00512 "DGEBRD", " ", n, n, &c_n1, &c_n1);
00513 wrkbl = max(i__2,i__3);
00514
00515 i__2 = wrkbl, i__3 = *n * 3 + *n * ilaenv_(&c__1, "DORGBR"
00516 , "Q", n, n, n, &c_n1);
00517 wrkbl = max(i__2,i__3);
00518
00519 i__2 = wrkbl, i__3 = *n * 3 + (*n - 1) * ilaenv_(&c__1,
00520 "DORGBR", "P", n, n, n, &c_n1);
00521 wrkbl = max(i__2,i__3);
00522 wrkbl = max(wrkbl,bdspac);
00523 maxwrk = *n * *n + wrkbl;
00524
00525 i__2 = *n * 3 + *m;
00526 minwrk = max(i__2,bdspac);
00527 }
00528 } else {
00529
00530
00531
00532 maxwrk = *n * 3 + (*m + *n) * ilaenv_(&c__1, "DGEBRD", " ", m,
00533 n, &c_n1, &c_n1);
00534 if (wntus || wntuo) {
00535
00536 i__2 = maxwrk, i__3 = *n * 3 + *n * ilaenv_(&c__1, "DORG"
00537 "BR", "Q", m, n, n, &c_n1);
00538 maxwrk = max(i__2,i__3);
00539 }
00540 if (wntua) {
00541
00542 i__2 = maxwrk, i__3 = *n * 3 + *m * ilaenv_(&c__1, "DORG"
00543 "BR", "Q", m, m, n, &c_n1);
00544 maxwrk = max(i__2,i__3);
00545 }
00546 if (! wntvn) {
00547
00548 i__2 = maxwrk, i__3 = *n * 3 + (*n - 1) * ilaenv_(&c__1,
00549 "DORGBR", "P", n, n, n, &c_n1);
00550 maxwrk = max(i__2,i__3);
00551 }
00552 maxwrk = max(maxwrk,bdspac);
00553
00554 i__2 = *n * 3 + *m;
00555 minwrk = max(i__2,bdspac);
00556 }
00557 } else if (minmn > 0) {
00558
00559
00560
00561
00562 i__1[0] = 1, a__1[0] = jobu;
00563 i__1[1] = 1, a__1[1] = jobvt;
00564 s_cat(ch__1, a__1, i__1, &c__2, (ftnlen)2);
00565 mnthr = ilaenv_(&c__6, "DGESVD", ch__1, m, n, &c__0, &c__0);
00566 bdspac = *m * 5;
00567 if (*n >= mnthr) {
00568 if (wntvn) {
00569
00570
00571
00572 maxwrk = *m + *m * ilaenv_(&c__1, "DGELQF", " ", m, n, &
00573 c_n1, &c_n1);
00574
00575 i__2 = maxwrk, i__3 = *m * 3 + (*m << 1) * ilaenv_(&c__1,
00576 "DGEBRD", " ", m, m, &c_n1, &c_n1);
00577 maxwrk = max(i__2,i__3);
00578 if (wntuo || wntuas) {
00579
00580 i__2 = maxwrk, i__3 = *m * 3 + *m * ilaenv_(&c__1,
00581 "DORGBR", "Q", m, m, m, &c_n1);
00582 maxwrk = max(i__2,i__3);
00583 }
00584 maxwrk = max(maxwrk,bdspac);
00585
00586 i__2 = *m << 2;
00587 minwrk = max(i__2,bdspac);
00588 } else if (wntvo && wntun) {
00589
00590
00591
00592 wrkbl = *m + *m * ilaenv_(&c__1, "DGELQF", " ", m, n, &
00593 c_n1, &c_n1);
00594
00595 i__2 = wrkbl, i__3 = *m + *m * ilaenv_(&c__1, "DORGLQ",
00596 " ", m, n, m, &c_n1);
00597 wrkbl = max(i__2,i__3);
00598
00599 i__2 = wrkbl, i__3 = *m * 3 + (*m << 1) * ilaenv_(&c__1,
00600 "DGEBRD", " ", m, m, &c_n1, &c_n1);
00601 wrkbl = max(i__2,i__3);
00602
00603 i__2 = wrkbl, i__3 = *m * 3 + (*m - 1) * ilaenv_(&c__1,
00604 "DORGBR", "P", m, m, m, &c_n1);
00605 wrkbl = max(i__2,i__3);
00606 wrkbl = max(wrkbl,bdspac);
00607
00608 i__2 = *m * *m + wrkbl, i__3 = *m * *m + *m * *n + *m;
00609 maxwrk = max(i__2,i__3);
00610
00611 i__2 = *m * 3 + *n;
00612 minwrk = max(i__2,bdspac);
00613 } else if (wntvo && wntuas) {
00614
00615
00616
00617
00618 wrkbl = *m + *m * ilaenv_(&c__1, "DGELQF", " ", m, n, &
00619 c_n1, &c_n1);
00620
00621 i__2 = wrkbl, i__3 = *m + *m * ilaenv_(&c__1, "DORGLQ",
00622 " ", m, n, m, &c_n1);
00623 wrkbl = max(i__2,i__3);
00624
00625 i__2 = wrkbl, i__3 = *m * 3 + (*m << 1) * ilaenv_(&c__1,
00626 "DGEBRD", " ", m, m, &c_n1, &c_n1);
00627 wrkbl = max(i__2,i__3);
00628
00629 i__2 = wrkbl, i__3 = *m * 3 + (*m - 1) * ilaenv_(&c__1,
00630 "DORGBR", "P", m, m, m, &c_n1);
00631 wrkbl = max(i__2,i__3);
00632
00633 i__2 = wrkbl, i__3 = *m * 3 + *m * ilaenv_(&c__1, "DORGBR"
00634 , "Q", m, m, m, &c_n1);
00635 wrkbl = max(i__2,i__3);
00636 wrkbl = max(wrkbl,bdspac);
00637
00638 i__2 = *m * *m + wrkbl, i__3 = *m * *m + *m * *n + *m;
00639 maxwrk = max(i__2,i__3);
00640
00641 i__2 = *m * 3 + *n;
00642 minwrk = max(i__2,bdspac);
00643 } else if (wntvs && wntun) {
00644
00645
00646
00647 wrkbl = *m + *m * ilaenv_(&c__1, "DGELQF", " ", m, n, &
00648 c_n1, &c_n1);
00649
00650 i__2 = wrkbl, i__3 = *m + *m * ilaenv_(&c__1, "DORGLQ",
00651 " ", m, n, m, &c_n1);
00652 wrkbl = max(i__2,i__3);
00653
00654 i__2 = wrkbl, i__3 = *m * 3 + (*m << 1) * ilaenv_(&c__1,
00655 "DGEBRD", " ", m, m, &c_n1, &c_n1);
00656 wrkbl = max(i__2,i__3);
00657
00658 i__2 = wrkbl, i__3 = *m * 3 + (*m - 1) * ilaenv_(&c__1,
00659 "DORGBR", "P", m, m, m, &c_n1);
00660 wrkbl = max(i__2,i__3);
00661 wrkbl = max(wrkbl,bdspac);
00662 maxwrk = *m * *m + wrkbl;
00663
00664 i__2 = *m * 3 + *n;
00665 minwrk = max(i__2,bdspac);
00666 } else if (wntvs && wntuo) {
00667
00668
00669
00670 wrkbl = *m + *m * ilaenv_(&c__1, "DGELQF", " ", m, n, &
00671 c_n1, &c_n1);
00672
00673 i__2 = wrkbl, i__3 = *m + *m * ilaenv_(&c__1, "DORGLQ",
00674 " ", m, n, m, &c_n1);
00675 wrkbl = max(i__2,i__3);
00676
00677 i__2 = wrkbl, i__3 = *m * 3 + (*m << 1) * ilaenv_(&c__1,
00678 "DGEBRD", " ", m, m, &c_n1, &c_n1);
00679 wrkbl = max(i__2,i__3);
00680
00681 i__2 = wrkbl, i__3 = *m * 3 + (*m - 1) * ilaenv_(&c__1,
00682 "DORGBR", "P", m, m, m, &c_n1);
00683 wrkbl = max(i__2,i__3);
00684
00685 i__2 = wrkbl, i__3 = *m * 3 + *m * ilaenv_(&c__1, "DORGBR"
00686 , "Q", m, m, m, &c_n1);
00687 wrkbl = max(i__2,i__3);
00688 wrkbl = max(wrkbl,bdspac);
00689 maxwrk = (*m << 1) * *m + wrkbl;
00690
00691 i__2 = *m * 3 + *n;
00692 minwrk = max(i__2,bdspac);
00693 } else if (wntvs && wntuas) {
00694
00695
00696
00697
00698 wrkbl = *m + *m * ilaenv_(&c__1, "DGELQF", " ", m, n, &
00699 c_n1, &c_n1);
00700
00701 i__2 = wrkbl, i__3 = *m + *m * ilaenv_(&c__1, "DORGLQ",
00702 " ", m, n, m, &c_n1);
00703 wrkbl = max(i__2,i__3);
00704
00705 i__2 = wrkbl, i__3 = *m * 3 + (*m << 1) * ilaenv_(&c__1,
00706 "DGEBRD", " ", m, m, &c_n1, &c_n1);
00707 wrkbl = max(i__2,i__3);
00708
00709 i__2 = wrkbl, i__3 = *m * 3 + (*m - 1) * ilaenv_(&c__1,
00710 "DORGBR", "P", m, m, m, &c_n1);
00711 wrkbl = max(i__2,i__3);
00712
00713 i__2 = wrkbl, i__3 = *m * 3 + *m * ilaenv_(&c__1, "DORGBR"
00714 , "Q", m, m, m, &c_n1);
00715 wrkbl = max(i__2,i__3);
00716 wrkbl = max(wrkbl,bdspac);
00717 maxwrk = *m * *m + wrkbl;
00718
00719 i__2 = *m * 3 + *n;
00720 minwrk = max(i__2,bdspac);
00721 } else if (wntva && wntun) {
00722
00723
00724
00725 wrkbl = *m + *m * ilaenv_(&c__1, "DGELQF", " ", m, n, &
00726 c_n1, &c_n1);
00727
00728 i__2 = wrkbl, i__3 = *m + *n * ilaenv_(&c__1, "DORGLQ",
00729 " ", n, n, m, &c_n1);
00730 wrkbl = max(i__2,i__3);
00731
00732 i__2 = wrkbl, i__3 = *m * 3 + (*m << 1) * ilaenv_(&c__1,
00733 "DGEBRD", " ", m, m, &c_n1, &c_n1);
00734 wrkbl = max(i__2,i__3);
00735
00736 i__2 = wrkbl, i__3 = *m * 3 + (*m - 1) * ilaenv_(&c__1,
00737 "DORGBR", "P", m, m, m, &c_n1);
00738 wrkbl = max(i__2,i__3);
00739 wrkbl = max(wrkbl,bdspac);
00740 maxwrk = *m * *m + wrkbl;
00741
00742 i__2 = *m * 3 + *n;
00743 minwrk = max(i__2,bdspac);
00744 } else if (wntva && wntuo) {
00745
00746
00747
00748 wrkbl = *m + *m * ilaenv_(&c__1, "DGELQF", " ", m, n, &
00749 c_n1, &c_n1);
00750
00751 i__2 = wrkbl, i__3 = *m + *n * ilaenv_(&c__1, "DORGLQ",
00752 " ", n, n, m, &c_n1);
00753 wrkbl = max(i__2,i__3);
00754
00755 i__2 = wrkbl, i__3 = *m * 3 + (*m << 1) * ilaenv_(&c__1,
00756 "DGEBRD", " ", m, m, &c_n1, &c_n1);
00757 wrkbl = max(i__2,i__3);
00758
00759 i__2 = wrkbl, i__3 = *m * 3 + (*m - 1) * ilaenv_(&c__1,
00760 "DORGBR", "P", m, m, m, &c_n1);
00761 wrkbl = max(i__2,i__3);
00762
00763 i__2 = wrkbl, i__3 = *m * 3 + *m * ilaenv_(&c__1, "DORGBR"
00764 , "Q", m, m, m, &c_n1);
00765 wrkbl = max(i__2,i__3);
00766 wrkbl = max(wrkbl,bdspac);
00767 maxwrk = (*m << 1) * *m + wrkbl;
00768
00769 i__2 = *m * 3 + *n;
00770 minwrk = max(i__2,bdspac);
00771 } else if (wntva && wntuas) {
00772
00773
00774
00775
00776 wrkbl = *m + *m * ilaenv_(&c__1, "DGELQF", " ", m, n, &
00777 c_n1, &c_n1);
00778
00779 i__2 = wrkbl, i__3 = *m + *n * ilaenv_(&c__1, "DORGLQ",
00780 " ", n, n, m, &c_n1);
00781 wrkbl = max(i__2,i__3);
00782
00783 i__2 = wrkbl, i__3 = *m * 3 + (*m << 1) * ilaenv_(&c__1,
00784 "DGEBRD", " ", m, m, &c_n1, &c_n1);
00785 wrkbl = max(i__2,i__3);
00786
00787 i__2 = wrkbl, i__3 = *m * 3 + (*m - 1) * ilaenv_(&c__1,
00788 "DORGBR", "P", m, m, m, &c_n1);
00789 wrkbl = max(i__2,i__3);
00790
00791 i__2 = wrkbl, i__3 = *m * 3 + *m * ilaenv_(&c__1, "DORGBR"
00792 , "Q", m, m, m, &c_n1);
00793 wrkbl = max(i__2,i__3);
00794 wrkbl = max(wrkbl,bdspac);
00795 maxwrk = *m * *m + wrkbl;
00796
00797 i__2 = *m * 3 + *n;
00798 minwrk = max(i__2,bdspac);
00799 }
00800 } else {
00801
00802
00803
00804 maxwrk = *m * 3 + (*m + *n) * ilaenv_(&c__1, "DGEBRD", " ", m,
00805 n, &c_n1, &c_n1);
00806 if (wntvs || wntvo) {
00807
00808 i__2 = maxwrk, i__3 = *m * 3 + *m * ilaenv_(&c__1, "DORG"
00809 "BR", "P", m, n, m, &c_n1);
00810 maxwrk = max(i__2,i__3);
00811 }
00812 if (wntva) {
00813
00814 i__2 = maxwrk, i__3 = *m * 3 + *n * ilaenv_(&c__1, "DORG"
00815 "BR", "P", n, n, m, &c_n1);
00816 maxwrk = max(i__2,i__3);
00817 }
00818 if (! wntun) {
00819
00820 i__2 = maxwrk, i__3 = *m * 3 + (*m - 1) * ilaenv_(&c__1,
00821 "DORGBR", "Q", m, m, m, &c_n1);
00822 maxwrk = max(i__2,i__3);
00823 }
00824 maxwrk = max(maxwrk,bdspac);
00825
00826 i__2 = *m * 3 + *n;
00827 minwrk = max(i__2,bdspac);
00828 }
00829 }
00830 maxwrk = max(maxwrk,minwrk);
00831 work[1] = (doublereal) maxwrk;
00832
00833 if (*lwork < minwrk && ! lquery) {
00834 *info = -13;
00835 }
00836 }
00837
00838 if (*info != 0) {
00839 i__2 = -(*info);
00840 xerbla_("DGESVD", &i__2);
00841 return 0;
00842 } else if (lquery) {
00843 return 0;
00844 }
00845
00846
00847
00848 if (*m == 0 || *n == 0) {
00849 return 0;
00850 }
00851
00852
00853
00854 eps = dlamch_("P");
00855 smlnum = sqrt(dlamch_("S")) / eps;
00856 bignum = 1. / smlnum;
00857
00858
00859
00860 anrm = dlange_("M", m, n, &a[a_offset], lda, dum);
00861 iscl = 0;
00862 if (anrm > 0. && anrm < smlnum) {
00863 iscl = 1;
00864 dlascl_("G", &c__0, &c__0, &anrm, &smlnum, m, n, &a[a_offset], lda, &
00865 ierr);
00866 } else if (anrm > bignum) {
00867 iscl = 1;
00868 dlascl_("G", &c__0, &c__0, &anrm, &bignum, m, n, &a[a_offset], lda, &
00869 ierr);
00870 }
00871
00872 if (*m >= *n) {
00873
00874
00875
00876
00877
00878 if (*m >= mnthr) {
00879
00880 if (wntun) {
00881
00882
00883
00884
00885 itau = 1;
00886 iwork = itau + *n;
00887
00888
00889
00890
00891 i__2 = *lwork - iwork + 1;
00892 dgeqrf_(m, n, &a[a_offset], lda, &work[itau], &work[iwork], &
00893 i__2, &ierr);
00894
00895
00896
00897 i__2 = *n - 1;
00898 i__3 = *n - 1;
00899 dlaset_("L", &i__2, &i__3, &c_b421, &c_b421, &a[a_dim1 + 2],
00900 lda);
00901 ie = 1;
00902 itauq = ie + *n;
00903 itaup = itauq + *n;
00904 iwork = itaup + *n;
00905
00906
00907
00908
00909 i__2 = *lwork - iwork + 1;
00910 dgebrd_(n, n, &a[a_offset], lda, &s[1], &work[ie], &work[
00911 itauq], &work[itaup], &work[iwork], &i__2, &ierr);
00912 ncvt = 0;
00913 if (wntvo || wntvas) {
00914
00915
00916
00917
00918 i__2 = *lwork - iwork + 1;
00919 dorgbr_("P", n, n, n, &a[a_offset], lda, &work[itaup], &
00920 work[iwork], &i__2, &ierr);
00921 ncvt = *n;
00922 }
00923 iwork = ie + *n;
00924
00925
00926
00927
00928
00929 dbdsqr_("U", n, &ncvt, &c__0, &c__0, &s[1], &work[ie], &a[
00930 a_offset], lda, dum, &c__1, dum, &c__1, &work[iwork],
00931 info);
00932
00933
00934
00935 if (wntvas) {
00936 dlacpy_("F", n, n, &a[a_offset], lda, &vt[vt_offset],
00937 ldvt);
00938 }
00939
00940 } else if (wntuo && wntvn) {
00941
00942
00943
00944
00945
00946
00947 i__2 = *n << 2;
00948 if (*lwork >= *n * *n + max(i__2,bdspac)) {
00949
00950
00951
00952 ir = 1;
00953
00954 i__2 = wrkbl, i__3 = *lda * *n + *n;
00955 if (*lwork >= max(i__2,i__3) + *lda * *n) {
00956
00957
00958
00959 ldwrku = *lda;
00960 ldwrkr = *lda;
00961 } else {
00962
00963 i__2 = wrkbl, i__3 = *lda * *n + *n;
00964 if (*lwork >= max(i__2,i__3) + *n * *n) {
00965
00966
00967
00968 ldwrku = *lda;
00969 ldwrkr = *n;
00970 } else {
00971
00972
00973
00974 ldwrku = (*lwork - *n * *n - *n) / *n;
00975 ldwrkr = *n;
00976 }
00977 }
00978 itau = ir + ldwrkr * *n;
00979 iwork = itau + *n;
00980
00981
00982
00983
00984 i__2 = *lwork - iwork + 1;
00985 dgeqrf_(m, n, &a[a_offset], lda, &work[itau], &work[iwork]
00986 , &i__2, &ierr);
00987
00988
00989
00990 dlacpy_("U", n, n, &a[a_offset], lda, &work[ir], &ldwrkr);
00991 i__2 = *n - 1;
00992 i__3 = *n - 1;
00993 dlaset_("L", &i__2, &i__3, &c_b421, &c_b421, &work[ir + 1]
00994 , &ldwrkr);
00995
00996
00997
00998
00999 i__2 = *lwork - iwork + 1;
01000 dorgqr_(m, n, n, &a[a_offset], lda, &work[itau], &work[
01001 iwork], &i__2, &ierr);
01002 ie = itau;
01003 itauq = ie + *n;
01004 itaup = itauq + *n;
01005 iwork = itaup + *n;
01006
01007
01008
01009
01010 i__2 = *lwork - iwork + 1;
01011 dgebrd_(n, n, &work[ir], &ldwrkr, &s[1], &work[ie], &work[
01012 itauq], &work[itaup], &work[iwork], &i__2, &ierr);
01013
01014
01015
01016
01017 i__2 = *lwork - iwork + 1;
01018 dorgbr_("Q", n, n, n, &work[ir], &ldwrkr, &work[itauq], &
01019 work[iwork], &i__2, &ierr);
01020 iwork = ie + *n;
01021
01022
01023
01024
01025
01026 dbdsqr_("U", n, &c__0, n, &c__0, &s[1], &work[ie], dum, &
01027 c__1, &work[ir], &ldwrkr, dum, &c__1, &work[iwork]
01028 , info);
01029 iu = ie + *n;
01030
01031
01032
01033
01034
01035 i__2 = *m;
01036 i__3 = ldwrku;
01037 for (i__ = 1; i__3 < 0 ? i__ >= i__2 : i__ <= i__2; i__ +=
01038 i__3) {
01039
01040 i__4 = *m - i__ + 1;
01041 chunk = min(i__4,ldwrku);
01042 dgemm_("N", "N", &chunk, n, n, &c_b443, &a[i__ +
01043 a_dim1], lda, &work[ir], &ldwrkr, &c_b421, &
01044 work[iu], &ldwrku);
01045 dlacpy_("F", &chunk, n, &work[iu], &ldwrku, &a[i__ +
01046 a_dim1], lda);
01047
01048 }
01049
01050 } else {
01051
01052
01053
01054 ie = 1;
01055 itauq = ie + *n;
01056 itaup = itauq + *n;
01057 iwork = itaup + *n;
01058
01059
01060
01061
01062 i__3 = *lwork - iwork + 1;
01063 dgebrd_(m, n, &a[a_offset], lda, &s[1], &work[ie], &work[
01064 itauq], &work[itaup], &work[iwork], &i__3, &ierr);
01065
01066
01067
01068
01069 i__3 = *lwork - iwork + 1;
01070 dorgbr_("Q", m, n, n, &a[a_offset], lda, &work[itauq], &
01071 work[iwork], &i__3, &ierr);
01072 iwork = ie + *n;
01073
01074
01075
01076
01077
01078 dbdsqr_("U", n, &c__0, m, &c__0, &s[1], &work[ie], dum, &
01079 c__1, &a[a_offset], lda, dum, &c__1, &work[iwork],
01080 info);
01081
01082 }
01083
01084 } else if (wntuo && wntvas) {
01085
01086
01087
01088
01089
01090
01091 i__3 = *n << 2;
01092 if (*lwork >= *n * *n + max(i__3,bdspac)) {
01093
01094
01095
01096 ir = 1;
01097
01098 i__3 = wrkbl, i__2 = *lda * *n + *n;
01099 if (*lwork >= max(i__3,i__2) + *lda * *n) {
01100
01101
01102
01103 ldwrku = *lda;
01104 ldwrkr = *lda;
01105 } else {
01106
01107 i__3 = wrkbl, i__2 = *lda * *n + *n;
01108 if (*lwork >= max(i__3,i__2) + *n * *n) {
01109
01110
01111
01112 ldwrku = *lda;
01113 ldwrkr = *n;
01114 } else {
01115
01116
01117
01118 ldwrku = (*lwork - *n * *n - *n) / *n;
01119 ldwrkr = *n;
01120 }
01121 }
01122 itau = ir + ldwrkr * *n;
01123 iwork = itau + *n;
01124
01125
01126
01127
01128 i__3 = *lwork - iwork + 1;
01129 dgeqrf_(m, n, &a[a_offset], lda, &work[itau], &work[iwork]
01130 , &i__3, &ierr);
01131
01132
01133
01134 dlacpy_("U", n, n, &a[a_offset], lda, &vt[vt_offset],
01135 ldvt);
01136 if (*n > 1) {
01137 i__3 = *n - 1;
01138 i__2 = *n - 1;
01139 dlaset_("L", &i__3, &i__2, &c_b421, &c_b421, &vt[
01140 vt_dim1 + 2], ldvt);
01141 }
01142
01143
01144
01145
01146 i__3 = *lwork - iwork + 1;
01147 dorgqr_(m, n, n, &a[a_offset], lda, &work[itau], &work[
01148 iwork], &i__3, &ierr);
01149 ie = itau;
01150 itauq = ie + *n;
01151 itaup = itauq + *n;
01152 iwork = itaup + *n;
01153
01154
01155
01156
01157 i__3 = *lwork - iwork + 1;
01158 dgebrd_(n, n, &vt[vt_offset], ldvt, &s[1], &work[ie], &
01159 work[itauq], &work[itaup], &work[iwork], &i__3, &
01160 ierr);
01161 dlacpy_("L", n, n, &vt[vt_offset], ldvt, &work[ir], &
01162 ldwrkr);
01163
01164
01165
01166
01167 i__3 = *lwork - iwork + 1;
01168 dorgbr_("Q", n, n, n, &work[ir], &ldwrkr, &work[itauq], &
01169 work[iwork], &i__3, &ierr);
01170
01171
01172
01173
01174 i__3 = *lwork - iwork + 1;
01175 dorgbr_("P", n, n, n, &vt[vt_offset], ldvt, &work[itaup],
01176 &work[iwork], &i__3, &ierr);
01177 iwork = ie + *n;
01178
01179
01180
01181
01182
01183
01184 dbdsqr_("U", n, n, n, &c__0, &s[1], &work[ie], &vt[
01185 vt_offset], ldvt, &work[ir], &ldwrkr, dum, &c__1,
01186 &work[iwork], info);
01187 iu = ie + *n;
01188
01189
01190
01191
01192
01193 i__3 = *m;
01194 i__2 = ldwrku;
01195 for (i__ = 1; i__2 < 0 ? i__ >= i__3 : i__ <= i__3; i__ +=
01196 i__2) {
01197
01198 i__4 = *m - i__ + 1;
01199 chunk = min(i__4,ldwrku);
01200 dgemm_("N", "N", &chunk, n, n, &c_b443, &a[i__ +
01201 a_dim1], lda, &work[ir], &ldwrkr, &c_b421, &
01202 work[iu], &ldwrku);
01203 dlacpy_("F", &chunk, n, &work[iu], &ldwrku, &a[i__ +
01204 a_dim1], lda);
01205
01206 }
01207
01208 } else {
01209
01210
01211
01212 itau = 1;
01213 iwork = itau + *n;
01214
01215
01216
01217
01218 i__2 = *lwork - iwork + 1;
01219 dgeqrf_(m, n, &a[a_offset], lda, &work[itau], &work[iwork]
01220 , &i__2, &ierr);
01221
01222
01223
01224 dlacpy_("U", n, n, &a[a_offset], lda, &vt[vt_offset],
01225 ldvt);
01226 if (*n > 1) {
01227 i__2 = *n - 1;
01228 i__3 = *n - 1;
01229 dlaset_("L", &i__2, &i__3, &c_b421, &c_b421, &vt[
01230 vt_dim1 + 2], ldvt);
01231 }
01232
01233
01234
01235
01236 i__2 = *lwork - iwork + 1;
01237 dorgqr_(m, n, n, &a[a_offset], lda, &work[itau], &work[
01238 iwork], &i__2, &ierr);
01239 ie = itau;
01240 itauq = ie + *n;
01241 itaup = itauq + *n;
01242 iwork = itaup + *n;
01243
01244
01245
01246
01247 i__2 = *lwork - iwork + 1;
01248 dgebrd_(n, n, &vt[vt_offset], ldvt, &s[1], &work[ie], &
01249 work[itauq], &work[itaup], &work[iwork], &i__2, &
01250 ierr);
01251
01252
01253
01254
01255 i__2 = *lwork - iwork + 1;
01256 dormbr_("Q", "R", "N", m, n, n, &vt[vt_offset], ldvt, &
01257 work[itauq], &a[a_offset], lda, &work[iwork], &
01258 i__2, &ierr);
01259
01260
01261
01262
01263 i__2 = *lwork - iwork + 1;
01264 dorgbr_("P", n, n, n, &vt[vt_offset], ldvt, &work[itaup],
01265 &work[iwork], &i__2, &ierr);
01266 iwork = ie + *n;
01267
01268
01269
01270
01271
01272
01273 dbdsqr_("U", n, n, m, &c__0, &s[1], &work[ie], &vt[
01274 vt_offset], ldvt, &a[a_offset], lda, dum, &c__1, &
01275 work[iwork], info);
01276
01277 }
01278
01279 } else if (wntus) {
01280
01281 if (wntvn) {
01282
01283
01284
01285
01286
01287
01288 i__2 = *n << 2;
01289 if (*lwork >= *n * *n + max(i__2,bdspac)) {
01290
01291
01292
01293 ir = 1;
01294 if (*lwork >= wrkbl + *lda * *n) {
01295
01296
01297
01298 ldwrkr = *lda;
01299 } else {
01300
01301
01302
01303 ldwrkr = *n;
01304 }
01305 itau = ir + ldwrkr * *n;
01306 iwork = itau + *n;
01307
01308
01309
01310
01311 i__2 = *lwork - iwork + 1;
01312 dgeqrf_(m, n, &a[a_offset], lda, &work[itau], &work[
01313 iwork], &i__2, &ierr);
01314
01315
01316
01317 dlacpy_("U", n, n, &a[a_offset], lda, &work[ir], &
01318 ldwrkr);
01319 i__2 = *n - 1;
01320 i__3 = *n - 1;
01321 dlaset_("L", &i__2, &i__3, &c_b421, &c_b421, &work[ir
01322 + 1], &ldwrkr);
01323
01324
01325
01326
01327 i__2 = *lwork - iwork + 1;
01328 dorgqr_(m, n, n, &a[a_offset], lda, &work[itau], &
01329 work[iwork], &i__2, &ierr);
01330 ie = itau;
01331 itauq = ie + *n;
01332 itaup = itauq + *n;
01333 iwork = itaup + *n;
01334
01335
01336
01337
01338 i__2 = *lwork - iwork + 1;
01339 dgebrd_(n, n, &work[ir], &ldwrkr, &s[1], &work[ie], &
01340 work[itauq], &work[itaup], &work[iwork], &
01341 i__2, &ierr);
01342
01343
01344
01345
01346 i__2 = *lwork - iwork + 1;
01347 dorgbr_("Q", n, n, n, &work[ir], &ldwrkr, &work[itauq]
01348 , &work[iwork], &i__2, &ierr);
01349 iwork = ie + *n;
01350
01351
01352
01353
01354
01355 dbdsqr_("U", n, &c__0, n, &c__0, &s[1], &work[ie],
01356 dum, &c__1, &work[ir], &ldwrkr, dum, &c__1, &
01357 work[iwork], info);
01358
01359
01360
01361
01362
01363 dgemm_("N", "N", m, n, n, &c_b443, &a[a_offset], lda,
01364 &work[ir], &ldwrkr, &c_b421, &u[u_offset],
01365 ldu);
01366
01367 } else {
01368
01369
01370
01371 itau = 1;
01372 iwork = itau + *n;
01373
01374
01375
01376
01377 i__2 = *lwork - iwork + 1;
01378 dgeqrf_(m, n, &a[a_offset], lda, &work[itau], &work[
01379 iwork], &i__2, &ierr);
01380 dlacpy_("L", m, n, &a[a_offset], lda, &u[u_offset],
01381 ldu);
01382
01383
01384
01385
01386 i__2 = *lwork - iwork + 1;
01387 dorgqr_(m, n, n, &u[u_offset], ldu, &work[itau], &
01388 work[iwork], &i__2, &ierr);
01389 ie = itau;
01390 itauq = ie + *n;
01391 itaup = itauq + *n;
01392 iwork = itaup + *n;
01393
01394
01395
01396 i__2 = *n - 1;
01397 i__3 = *n - 1;
01398 dlaset_("L", &i__2, &i__3, &c_b421, &c_b421, &a[
01399 a_dim1 + 2], lda);
01400
01401
01402
01403
01404 i__2 = *lwork - iwork + 1;
01405 dgebrd_(n, n, &a[a_offset], lda, &s[1], &work[ie], &
01406 work[itauq], &work[itaup], &work[iwork], &
01407 i__2, &ierr);
01408
01409
01410
01411
01412 i__2 = *lwork - iwork + 1;
01413 dormbr_("Q", "R", "N", m, n, n, &a[a_offset], lda, &
01414 work[itauq], &u[u_offset], ldu, &work[iwork],
01415 &i__2, &ierr)
01416 ;
01417 iwork = ie + *n;
01418
01419
01420
01421
01422
01423 dbdsqr_("U", n, &c__0, m, &c__0, &s[1], &work[ie],
01424 dum, &c__1, &u[u_offset], ldu, dum, &c__1, &
01425 work[iwork], info);
01426
01427 }
01428
01429 } else if (wntvo) {
01430
01431
01432
01433
01434
01435
01436 i__2 = *n << 2;
01437 if (*lwork >= (*n << 1) * *n + max(i__2,bdspac)) {
01438
01439
01440
01441 iu = 1;
01442 if (*lwork >= wrkbl + (*lda << 1) * *n) {
01443
01444
01445
01446 ldwrku = *lda;
01447 ir = iu + ldwrku * *n;
01448 ldwrkr = *lda;
01449 } else if (*lwork >= wrkbl + (*lda + *n) * *n) {
01450
01451
01452
01453 ldwrku = *lda;
01454 ir = iu + ldwrku * *n;
01455 ldwrkr = *n;
01456 } else {
01457
01458
01459
01460 ldwrku = *n;
01461 ir = iu + ldwrku * *n;
01462 ldwrkr = *n;
01463 }
01464 itau = ir + ldwrkr * *n;
01465 iwork = itau + *n;
01466
01467
01468
01469
01470 i__2 = *lwork - iwork + 1;
01471 dgeqrf_(m, n, &a[a_offset], lda, &work[itau], &work[
01472 iwork], &i__2, &ierr);
01473
01474
01475
01476 dlacpy_("U", n, n, &a[a_offset], lda, &work[iu], &
01477 ldwrku);
01478 i__2 = *n - 1;
01479 i__3 = *n - 1;
01480 dlaset_("L", &i__2, &i__3, &c_b421, &c_b421, &work[iu
01481 + 1], &ldwrku);
01482
01483
01484
01485
01486 i__2 = *lwork - iwork + 1;
01487 dorgqr_(m, n, n, &a[a_offset], lda, &work[itau], &
01488 work[iwork], &i__2, &ierr);
01489 ie = itau;
01490 itauq = ie + *n;
01491 itaup = itauq + *n;
01492 iwork = itaup + *n;
01493
01494
01495
01496
01497
01498
01499 i__2 = *lwork - iwork + 1;
01500 dgebrd_(n, n, &work[iu], &ldwrku, &s[1], &work[ie], &
01501 work[itauq], &work[itaup], &work[iwork], &
01502 i__2, &ierr);
01503 dlacpy_("U", n, n, &work[iu], &ldwrku, &work[ir], &
01504 ldwrkr);
01505
01506
01507
01508
01509 i__2 = *lwork - iwork + 1;
01510 dorgbr_("Q", n, n, n, &work[iu], &ldwrku, &work[itauq]
01511 , &work[iwork], &i__2, &ierr);
01512
01513
01514
01515
01516
01517 i__2 = *lwork - iwork + 1;
01518 dorgbr_("P", n, n, n, &work[ir], &ldwrkr, &work[itaup]
01519 , &work[iwork], &i__2, &ierr);
01520 iwork = ie + *n;
01521
01522
01523
01524
01525
01526
01527 dbdsqr_("U", n, n, n, &c__0, &s[1], &work[ie], &work[
01528 ir], &ldwrkr, &work[iu], &ldwrku, dum, &c__1,
01529 &work[iwork], info);
01530
01531
01532
01533
01534
01535 dgemm_("N", "N", m, n, n, &c_b443, &a[a_offset], lda,
01536 &work[iu], &ldwrku, &c_b421, &u[u_offset],
01537 ldu);
01538
01539
01540
01541
01542 dlacpy_("F", n, n, &work[ir], &ldwrkr, &a[a_offset],
01543 lda);
01544
01545 } else {
01546
01547
01548
01549 itau = 1;
01550 iwork = itau + *n;
01551
01552
01553
01554
01555 i__2 = *lwork - iwork + 1;
01556 dgeqrf_(m, n, &a[a_offset], lda, &work[itau], &work[
01557 iwork], &i__2, &ierr);
01558 dlacpy_("L", m, n, &a[a_offset], lda, &u[u_offset],
01559 ldu);
01560
01561
01562
01563
01564 i__2 = *lwork - iwork + 1;
01565 dorgqr_(m, n, n, &u[u_offset], ldu, &work[itau], &
01566 work[iwork], &i__2, &ierr);
01567 ie = itau;
01568 itauq = ie + *n;
01569 itaup = itauq + *n;
01570 iwork = itaup + *n;
01571
01572
01573
01574 i__2 = *n - 1;
01575 i__3 = *n - 1;
01576 dlaset_("L", &i__2, &i__3, &c_b421, &c_b421, &a[
01577 a_dim1 + 2], lda);
01578
01579
01580
01581
01582 i__2 = *lwork - iwork + 1;
01583 dgebrd_(n, n, &a[a_offset], lda, &s[1], &work[ie], &
01584 work[itauq], &work[itaup], &work[iwork], &
01585 i__2, &ierr);
01586
01587
01588
01589
01590 i__2 = *lwork - iwork + 1;
01591 dormbr_("Q", "R", "N", m, n, n, &a[a_offset], lda, &
01592 work[itauq], &u[u_offset], ldu, &work[iwork],
01593 &i__2, &ierr)
01594 ;
01595
01596
01597
01598
01599 i__2 = *lwork - iwork + 1;
01600 dorgbr_("P", n, n, n, &a[a_offset], lda, &work[itaup],
01601 &work[iwork], &i__2, &ierr);
01602 iwork = ie + *n;
01603
01604
01605
01606
01607
01608
01609 dbdsqr_("U", n, n, m, &c__0, &s[1], &work[ie], &a[
01610 a_offset], lda, &u[u_offset], ldu, dum, &c__1,
01611 &work[iwork], info);
01612
01613 }
01614
01615 } else if (wntvas) {
01616
01617
01618
01619
01620
01621
01622
01623 i__2 = *n << 2;
01624 if (*lwork >= *n * *n + max(i__2,bdspac)) {
01625
01626
01627
01628 iu = 1;
01629 if (*lwork >= wrkbl + *lda * *n) {
01630
01631
01632
01633 ldwrku = *lda;
01634 } else {
01635
01636
01637
01638 ldwrku = *n;
01639 }
01640 itau = iu + ldwrku * *n;
01641 iwork = itau + *n;
01642
01643
01644
01645
01646 i__2 = *lwork - iwork + 1;
01647 dgeqrf_(m, n, &a[a_offset], lda, &work[itau], &work[
01648 iwork], &i__2, &ierr);
01649
01650
01651
01652 dlacpy_("U", n, n, &a[a_offset], lda, &work[iu], &
01653 ldwrku);
01654 i__2 = *n - 1;
01655 i__3 = *n - 1;
01656 dlaset_("L", &i__2, &i__3, &c_b421, &c_b421, &work[iu
01657 + 1], &ldwrku);
01658
01659
01660
01661
01662 i__2 = *lwork - iwork + 1;
01663 dorgqr_(m, n, n, &a[a_offset], lda, &work[itau], &
01664 work[iwork], &i__2, &ierr);
01665 ie = itau;
01666 itauq = ie + *n;
01667 itaup = itauq + *n;
01668 iwork = itaup + *n;
01669
01670
01671
01672
01673 i__2 = *lwork - iwork + 1;
01674 dgebrd_(n, n, &work[iu], &ldwrku, &s[1], &work[ie], &
01675 work[itauq], &work[itaup], &work[iwork], &
01676 i__2, &ierr);
01677 dlacpy_("U", n, n, &work[iu], &ldwrku, &vt[vt_offset],
01678 ldvt);
01679
01680
01681
01682
01683 i__2 = *lwork - iwork + 1;
01684 dorgbr_("Q", n, n, n, &work[iu], &ldwrku, &work[itauq]
01685 , &work[iwork], &i__2, &ierr);
01686
01687
01688
01689
01690
01691 i__2 = *lwork - iwork + 1;
01692 dorgbr_("P", n, n, n, &vt[vt_offset], ldvt, &work[
01693 itaup], &work[iwork], &i__2, &ierr)
01694 ;
01695 iwork = ie + *n;
01696
01697
01698
01699
01700
01701
01702 dbdsqr_("U", n, n, n, &c__0, &s[1], &work[ie], &vt[
01703 vt_offset], ldvt, &work[iu], &ldwrku, dum, &
01704 c__1, &work[iwork], info);
01705
01706
01707
01708
01709
01710 dgemm_("N", "N", m, n, n, &c_b443, &a[a_offset], lda,
01711 &work[iu], &ldwrku, &c_b421, &u[u_offset],
01712 ldu);
01713
01714 } else {
01715
01716
01717
01718 itau = 1;
01719 iwork = itau + *n;
01720
01721
01722
01723
01724 i__2 = *lwork - iwork + 1;
01725 dgeqrf_(m, n, &a[a_offset], lda, &work[itau], &work[
01726 iwork], &i__2, &ierr);
01727 dlacpy_("L", m, n, &a[a_offset], lda, &u[u_offset],
01728 ldu);
01729
01730
01731
01732
01733 i__2 = *lwork - iwork + 1;
01734 dorgqr_(m, n, n, &u[u_offset], ldu, &work[itau], &
01735 work[iwork], &i__2, &ierr);
01736
01737
01738
01739 dlacpy_("U", n, n, &a[a_offset], lda, &vt[vt_offset],
01740 ldvt);
01741 if (*n > 1) {
01742 i__2 = *n - 1;
01743 i__3 = *n - 1;
01744 dlaset_("L", &i__2, &i__3, &c_b421, &c_b421, &vt[
01745 vt_dim1 + 2], ldvt);
01746 }
01747 ie = itau;
01748 itauq = ie + *n;
01749 itaup = itauq + *n;
01750 iwork = itaup + *n;
01751
01752
01753
01754
01755 i__2 = *lwork - iwork + 1;
01756 dgebrd_(n, n, &vt[vt_offset], ldvt, &s[1], &work[ie],
01757 &work[itauq], &work[itaup], &work[iwork], &
01758 i__2, &ierr);
01759
01760
01761
01762
01763
01764 i__2 = *lwork - iwork + 1;
01765 dormbr_("Q", "R", "N", m, n, n, &vt[vt_offset], ldvt,
01766 &work[itauq], &u[u_offset], ldu, &work[iwork],
01767 &i__2, &ierr);
01768
01769
01770
01771
01772 i__2 = *lwork - iwork + 1;
01773 dorgbr_("P", n, n, n, &vt[vt_offset], ldvt, &work[
01774 itaup], &work[iwork], &i__2, &ierr)
01775 ;
01776 iwork = ie + *n;
01777
01778
01779
01780
01781
01782
01783 dbdsqr_("U", n, n, m, &c__0, &s[1], &work[ie], &vt[
01784 vt_offset], ldvt, &u[u_offset], ldu, dum, &
01785 c__1, &work[iwork], info);
01786
01787 }
01788
01789 }
01790
01791 } else if (wntua) {
01792
01793 if (wntvn) {
01794
01795
01796
01797
01798
01799
01800 i__2 = *n + *m, i__3 = *n << 2, i__2 = max(i__2,i__3);
01801 if (*lwork >= *n * *n + max(i__2,bdspac)) {
01802
01803
01804
01805 ir = 1;
01806 if (*lwork >= wrkbl + *lda * *n) {
01807
01808
01809
01810 ldwrkr = *lda;
01811 } else {
01812
01813
01814
01815 ldwrkr = *n;
01816 }
01817 itau = ir + ldwrkr * *n;
01818 iwork = itau + *n;
01819
01820
01821
01822
01823 i__2 = *lwork - iwork + 1;
01824 dgeqrf_(m, n, &a[a_offset], lda, &work[itau], &work[
01825 iwork], &i__2, &ierr);
01826 dlacpy_("L", m, n, &a[a_offset], lda, &u[u_offset],
01827 ldu);
01828
01829
01830
01831 dlacpy_("U", n, n, &a[a_offset], lda, &work[ir], &
01832 ldwrkr);
01833 i__2 = *n - 1;
01834 i__3 = *n - 1;
01835 dlaset_("L", &i__2, &i__3, &c_b421, &c_b421, &work[ir
01836 + 1], &ldwrkr);
01837
01838
01839
01840
01841 i__2 = *lwork - iwork + 1;
01842 dorgqr_(m, m, n, &u[u_offset], ldu, &work[itau], &
01843 work[iwork], &i__2, &ierr);
01844 ie = itau;
01845 itauq = ie + *n;
01846 itaup = itauq + *n;
01847 iwork = itaup + *n;
01848
01849
01850
01851
01852 i__2 = *lwork - iwork + 1;
01853 dgebrd_(n, n, &work[ir], &ldwrkr, &s[1], &work[ie], &
01854 work[itauq], &work[itaup], &work[iwork], &
01855 i__2, &ierr);
01856
01857
01858
01859
01860 i__2 = *lwork - iwork + 1;
01861 dorgbr_("Q", n, n, n, &work[ir], &ldwrkr, &work[itauq]
01862 , &work[iwork], &i__2, &ierr);
01863 iwork = ie + *n;
01864
01865
01866
01867
01868
01869 dbdsqr_("U", n, &c__0, n, &c__0, &s[1], &work[ie],
01870 dum, &c__1, &work[ir], &ldwrkr, dum, &c__1, &
01871 work[iwork], info);
01872
01873
01874
01875
01876
01877 dgemm_("N", "N", m, n, n, &c_b443, &u[u_offset], ldu,
01878 &work[ir], &ldwrkr, &c_b421, &a[a_offset],
01879 lda);
01880
01881
01882
01883 dlacpy_("F", m, n, &a[a_offset], lda, &u[u_offset],
01884 ldu);
01885
01886 } else {
01887
01888
01889
01890 itau = 1;
01891 iwork = itau + *n;
01892
01893
01894
01895
01896 i__2 = *lwork - iwork + 1;
01897 dgeqrf_(m, n, &a[a_offset], lda, &work[itau], &work[
01898 iwork], &i__2, &ierr);
01899 dlacpy_("L", m, n, &a[a_offset], lda, &u[u_offset],
01900 ldu);
01901
01902
01903
01904
01905 i__2 = *lwork - iwork + 1;
01906 dorgqr_(m, m, n, &u[u_offset], ldu, &work[itau], &
01907 work[iwork], &i__2, &ierr);
01908 ie = itau;
01909 itauq = ie + *n;
01910 itaup = itauq + *n;
01911 iwork = itaup + *n;
01912
01913
01914
01915 i__2 = *n - 1;
01916 i__3 = *n - 1;
01917 dlaset_("L", &i__2, &i__3, &c_b421, &c_b421, &a[
01918 a_dim1 + 2], lda);
01919
01920
01921
01922
01923 i__2 = *lwork - iwork + 1;
01924 dgebrd_(n, n, &a[a_offset], lda, &s[1], &work[ie], &
01925 work[itauq], &work[itaup], &work[iwork], &
01926 i__2, &ierr);
01927
01928
01929
01930
01931
01932 i__2 = *lwork - iwork + 1;
01933 dormbr_("Q", "R", "N", m, n, n, &a[a_offset], lda, &
01934 work[itauq], &u[u_offset], ldu, &work[iwork],
01935 &i__2, &ierr)
01936 ;
01937 iwork = ie + *n;
01938
01939
01940
01941
01942
01943 dbdsqr_("U", n, &c__0, m, &c__0, &s[1], &work[ie],
01944 dum, &c__1, &u[u_offset], ldu, dum, &c__1, &
01945 work[iwork], info);
01946
01947 }
01948
01949 } else if (wntvo) {
01950
01951
01952
01953
01954
01955
01956 i__2 = *n + *m, i__3 = *n << 2, i__2 = max(i__2,i__3);
01957 if (*lwork >= (*n << 1) * *n + max(i__2,bdspac)) {
01958
01959
01960
01961 iu = 1;
01962 if (*lwork >= wrkbl + (*lda << 1) * *n) {
01963
01964
01965
01966 ldwrku = *lda;
01967 ir = iu + ldwrku * *n;
01968 ldwrkr = *lda;
01969 } else if (*lwork >= wrkbl + (*lda + *n) * *n) {
01970
01971
01972
01973 ldwrku = *lda;
01974 ir = iu + ldwrku * *n;
01975 ldwrkr = *n;
01976 } else {
01977
01978
01979
01980 ldwrku = *n;
01981 ir = iu + ldwrku * *n;
01982 ldwrkr = *n;
01983 }
01984 itau = ir + ldwrkr * *n;
01985 iwork = itau + *n;
01986
01987
01988
01989
01990 i__2 = *lwork - iwork + 1;
01991 dgeqrf_(m, n, &a[a_offset], lda, &work[itau], &work[
01992 iwork], &i__2, &ierr);
01993 dlacpy_("L", m, n, &a[a_offset], lda, &u[u_offset],
01994 ldu);
01995
01996
01997
01998
01999 i__2 = *lwork - iwork + 1;
02000 dorgqr_(m, m, n, &u[u_offset], ldu, &work[itau], &
02001 work[iwork], &i__2, &ierr);
02002
02003
02004
02005 dlacpy_("U", n, n, &a[a_offset], lda, &work[iu], &
02006 ldwrku);
02007 i__2 = *n - 1;
02008 i__3 = *n - 1;
02009 dlaset_("L", &i__2, &i__3, &c_b421, &c_b421, &work[iu
02010 + 1], &ldwrku);
02011 ie = itau;
02012 itauq = ie + *n;
02013 itaup = itauq + *n;
02014 iwork = itaup + *n;
02015
02016
02017
02018
02019
02020
02021 i__2 = *lwork - iwork + 1;
02022 dgebrd_(n, n, &work[iu], &ldwrku, &s[1], &work[ie], &
02023 work[itauq], &work[itaup], &work[iwork], &
02024 i__2, &ierr);
02025 dlacpy_("U", n, n, &work[iu], &ldwrku, &work[ir], &
02026 ldwrkr);
02027
02028
02029
02030
02031 i__2 = *lwork - iwork + 1;
02032 dorgbr_("Q", n, n, n, &work[iu], &ldwrku, &work[itauq]
02033 , &work[iwork], &i__2, &ierr);
02034
02035
02036
02037
02038
02039 i__2 = *lwork - iwork + 1;
02040 dorgbr_("P", n, n, n, &work[ir], &ldwrkr, &work[itaup]
02041 , &work[iwork], &i__2, &ierr);
02042 iwork = ie + *n;
02043
02044
02045
02046
02047
02048
02049 dbdsqr_("U", n, n, n, &c__0, &s[1], &work[ie], &work[
02050 ir], &ldwrkr, &work[iu], &ldwrku, dum, &c__1,
02051 &work[iwork], info);
02052
02053
02054
02055
02056
02057 dgemm_("N", "N", m, n, n, &c_b443, &u[u_offset], ldu,
02058 &work[iu], &ldwrku, &c_b421, &a[a_offset],
02059 lda);
02060
02061
02062
02063 dlacpy_("F", m, n, &a[a_offset], lda, &u[u_offset],
02064 ldu);
02065
02066
02067
02068 dlacpy_("F", n, n, &work[ir], &ldwrkr, &a[a_offset],
02069 lda);
02070
02071 } else {
02072
02073
02074
02075 itau = 1;
02076 iwork = itau + *n;
02077
02078
02079
02080
02081 i__2 = *lwork - iwork + 1;
02082 dgeqrf_(m, n, &a[a_offset], lda, &work[itau], &work[
02083 iwork], &i__2, &ierr);
02084 dlacpy_("L", m, n, &a[a_offset], lda, &u[u_offset],
02085 ldu);
02086
02087
02088
02089
02090 i__2 = *lwork - iwork + 1;
02091 dorgqr_(m, m, n, &u[u_offset], ldu, &work[itau], &
02092 work[iwork], &i__2, &ierr);
02093 ie = itau;
02094 itauq = ie + *n;
02095 itaup = itauq + *n;
02096 iwork = itaup + *n;
02097
02098
02099
02100 i__2 = *n - 1;
02101 i__3 = *n - 1;
02102 dlaset_("L", &i__2, &i__3, &c_b421, &c_b421, &a[
02103 a_dim1 + 2], lda);
02104
02105
02106
02107
02108 i__2 = *lwork - iwork + 1;
02109 dgebrd_(n, n, &a[a_offset], lda, &s[1], &work[ie], &
02110 work[itauq], &work[itaup], &work[iwork], &
02111 i__2, &ierr);
02112
02113
02114
02115
02116
02117 i__2 = *lwork - iwork + 1;
02118 dormbr_("Q", "R", "N", m, n, n, &a[a_offset], lda, &
02119 work[itauq], &u[u_offset], ldu, &work[iwork],
02120 &i__2, &ierr)
02121 ;
02122
02123
02124
02125
02126 i__2 = *lwork - iwork + 1;
02127 dorgbr_("P", n, n, n, &a[a_offset], lda, &work[itaup],
02128 &work[iwork], &i__2, &ierr);
02129 iwork = ie + *n;
02130
02131
02132
02133
02134
02135
02136 dbdsqr_("U", n, n, m, &c__0, &s[1], &work[ie], &a[
02137 a_offset], lda, &u[u_offset], ldu, dum, &c__1,
02138 &work[iwork], info);
02139
02140 }
02141
02142 } else if (wntvas) {
02143
02144
02145
02146
02147
02148
02149
02150 i__2 = *n + *m, i__3 = *n << 2, i__2 = max(i__2,i__3);
02151 if (*lwork >= *n * *n + max(i__2,bdspac)) {
02152
02153
02154
02155 iu = 1;
02156 if (*lwork >= wrkbl + *lda * *n) {
02157
02158
02159
02160 ldwrku = *lda;
02161 } else {
02162
02163
02164
02165 ldwrku = *n;
02166 }
02167 itau = iu + ldwrku * *n;
02168 iwork = itau + *n;
02169
02170
02171
02172
02173 i__2 = *lwork - iwork + 1;
02174 dgeqrf_(m, n, &a[a_offset], lda, &work[itau], &work[
02175 iwork], &i__2, &ierr);
02176 dlacpy_("L", m, n, &a[a_offset], lda, &u[u_offset],
02177 ldu);
02178
02179
02180
02181
02182 i__2 = *lwork - iwork + 1;
02183 dorgqr_(m, m, n, &u[u_offset], ldu, &work[itau], &
02184 work[iwork], &i__2, &ierr);
02185
02186
02187
02188 dlacpy_("U", n, n, &a[a_offset], lda, &work[iu], &
02189 ldwrku);
02190 i__2 = *n - 1;
02191 i__3 = *n - 1;
02192 dlaset_("L", &i__2, &i__3, &c_b421, &c_b421, &work[iu
02193 + 1], &ldwrku);
02194 ie = itau;
02195 itauq = ie + *n;
02196 itaup = itauq + *n;
02197 iwork = itaup + *n;
02198
02199
02200
02201
02202 i__2 = *lwork - iwork + 1;
02203 dgebrd_(n, n, &work[iu], &ldwrku, &s[1], &work[ie], &
02204 work[itauq], &work[itaup], &work[iwork], &
02205 i__2, &ierr);
02206 dlacpy_("U", n, n, &work[iu], &ldwrku, &vt[vt_offset],
02207 ldvt);
02208
02209
02210
02211
02212 i__2 = *lwork - iwork + 1;
02213 dorgbr_("Q", n, n, n, &work[iu], &ldwrku, &work[itauq]
02214 , &work[iwork], &i__2, &ierr);
02215
02216
02217
02218
02219
02220 i__2 = *lwork - iwork + 1;
02221 dorgbr_("P", n, n, n, &vt[vt_offset], ldvt, &work[
02222 itaup], &work[iwork], &i__2, &ierr)
02223 ;
02224 iwork = ie + *n;
02225
02226
02227
02228
02229
02230
02231 dbdsqr_("U", n, n, n, &c__0, &s[1], &work[ie], &vt[
02232 vt_offset], ldvt, &work[iu], &ldwrku, dum, &
02233 c__1, &work[iwork], info);
02234
02235
02236
02237
02238
02239 dgemm_("N", "N", m, n, n, &c_b443, &u[u_offset], ldu,
02240 &work[iu], &ldwrku, &c_b421, &a[a_offset],
02241 lda);
02242
02243
02244
02245 dlacpy_("F", m, n, &a[a_offset], lda, &u[u_offset],
02246 ldu);
02247
02248 } else {
02249
02250
02251
02252 itau = 1;
02253 iwork = itau + *n;
02254
02255
02256
02257
02258 i__2 = *lwork - iwork + 1;
02259 dgeqrf_(m, n, &a[a_offset], lda, &work[itau], &work[
02260 iwork], &i__2, &ierr);
02261 dlacpy_("L", m, n, &a[a_offset], lda, &u[u_offset],
02262 ldu);
02263
02264
02265
02266
02267 i__2 = *lwork - iwork + 1;
02268 dorgqr_(m, m, n, &u[u_offset], ldu, &work[itau], &
02269 work[iwork], &i__2, &ierr);
02270
02271
02272
02273 dlacpy_("U", n, n, &a[a_offset], lda, &vt[vt_offset],
02274 ldvt);
02275 if (*n > 1) {
02276 i__2 = *n - 1;
02277 i__3 = *n - 1;
02278 dlaset_("L", &i__2, &i__3, &c_b421, &c_b421, &vt[
02279 vt_dim1 + 2], ldvt);
02280 }
02281 ie = itau;
02282 itauq = ie + *n;
02283 itaup = itauq + *n;
02284 iwork = itaup + *n;
02285
02286
02287
02288
02289 i__2 = *lwork - iwork + 1;
02290 dgebrd_(n, n, &vt[vt_offset], ldvt, &s[1], &work[ie],
02291 &work[itauq], &work[itaup], &work[iwork], &
02292 i__2, &ierr);
02293
02294
02295
02296
02297
02298 i__2 = *lwork - iwork + 1;
02299 dormbr_("Q", "R", "N", m, n, n, &vt[vt_offset], ldvt,
02300 &work[itauq], &u[u_offset], ldu, &work[iwork],
02301 &i__2, &ierr);
02302
02303
02304
02305
02306 i__2 = *lwork - iwork + 1;
02307 dorgbr_("P", n, n, n, &vt[vt_offset], ldvt, &work[
02308 itaup], &work[iwork], &i__2, &ierr)
02309 ;
02310 iwork = ie + *n;
02311
02312
02313
02314
02315
02316
02317 dbdsqr_("U", n, n, m, &c__0, &s[1], &work[ie], &vt[
02318 vt_offset], ldvt, &u[u_offset], ldu, dum, &
02319 c__1, &work[iwork], info);
02320
02321 }
02322
02323 }
02324
02325 }
02326
02327 } else {
02328
02329
02330
02331
02332
02333
02334 ie = 1;
02335 itauq = ie + *n;
02336 itaup = itauq + *n;
02337 iwork = itaup + *n;
02338
02339
02340
02341
02342 i__2 = *lwork - iwork + 1;
02343 dgebrd_(m, n, &a[a_offset], lda, &s[1], &work[ie], &work[itauq], &
02344 work[itaup], &work[iwork], &i__2, &ierr);
02345 if (wntuas) {
02346
02347
02348
02349
02350
02351 dlacpy_("L", m, n, &a[a_offset], lda, &u[u_offset], ldu);
02352 if (wntus) {
02353 ncu = *n;
02354 }
02355 if (wntua) {
02356 ncu = *m;
02357 }
02358 i__2 = *lwork - iwork + 1;
02359 dorgbr_("Q", m, &ncu, n, &u[u_offset], ldu, &work[itauq], &
02360 work[iwork], &i__2, &ierr);
02361 }
02362 if (wntvas) {
02363
02364
02365
02366
02367
02368 dlacpy_("U", n, n, &a[a_offset], lda, &vt[vt_offset], ldvt);
02369 i__2 = *lwork - iwork + 1;
02370 dorgbr_("P", n, n, n, &vt[vt_offset], ldvt, &work[itaup], &
02371 work[iwork], &i__2, &ierr);
02372 }
02373 if (wntuo) {
02374
02375
02376
02377
02378
02379 i__2 = *lwork - iwork + 1;
02380 dorgbr_("Q", m, n, n, &a[a_offset], lda, &work[itauq], &work[
02381 iwork], &i__2, &ierr);
02382 }
02383 if (wntvo) {
02384
02385
02386
02387
02388
02389 i__2 = *lwork - iwork + 1;
02390 dorgbr_("P", n, n, n, &a[a_offset], lda, &work[itaup], &work[
02391 iwork], &i__2, &ierr);
02392 }
02393 iwork = ie + *n;
02394 if (wntuas || wntuo) {
02395 nru = *m;
02396 }
02397 if (wntun) {
02398 nru = 0;
02399 }
02400 if (wntvas || wntvo) {
02401 ncvt = *n;
02402 }
02403 if (wntvn) {
02404 ncvt = 0;
02405 }
02406 if (! wntuo && ! wntvo) {
02407
02408
02409
02410
02411
02412
02413 dbdsqr_("U", n, &ncvt, &nru, &c__0, &s[1], &work[ie], &vt[
02414 vt_offset], ldvt, &u[u_offset], ldu, dum, &c__1, &
02415 work[iwork], info);
02416 } else if (! wntuo && wntvo) {
02417
02418
02419
02420
02421
02422
02423 dbdsqr_("U", n, &ncvt, &nru, &c__0, &s[1], &work[ie], &a[
02424 a_offset], lda, &u[u_offset], ldu, dum, &c__1, &work[
02425 iwork], info);
02426 } else {
02427
02428
02429
02430
02431
02432
02433 dbdsqr_("U", n, &ncvt, &nru, &c__0, &s[1], &work[ie], &vt[
02434 vt_offset], ldvt, &a[a_offset], lda, dum, &c__1, &
02435 work[iwork], info);
02436 }
02437
02438 }
02439
02440 } else {
02441
02442
02443
02444
02445
02446 if (*n >= mnthr) {
02447
02448 if (wntvn) {
02449
02450
02451
02452
02453 itau = 1;
02454 iwork = itau + *m;
02455
02456
02457
02458
02459 i__2 = *lwork - iwork + 1;
02460 dgelqf_(m, n, &a[a_offset], lda, &work[itau], &work[iwork], &
02461 i__2, &ierr);
02462
02463
02464
02465 i__2 = *m - 1;
02466 i__3 = *m - 1;
02467 dlaset_("U", &i__2, &i__3, &c_b421, &c_b421, &a[(a_dim1 << 1)
02468 + 1], lda);
02469 ie = 1;
02470 itauq = ie + *m;
02471 itaup = itauq + *m;
02472 iwork = itaup + *m;
02473
02474
02475
02476
02477 i__2 = *lwork - iwork + 1;
02478 dgebrd_(m, m, &a[a_offset], lda, &s[1], &work[ie], &work[
02479 itauq], &work[itaup], &work[iwork], &i__2, &ierr);
02480 if (wntuo || wntuas) {
02481
02482
02483
02484
02485 i__2 = *lwork - iwork + 1;
02486 dorgbr_("Q", m, m, m, &a[a_offset], lda, &work[itauq], &
02487 work[iwork], &i__2, &ierr);
02488 }
02489 iwork = ie + *m;
02490 nru = 0;
02491 if (wntuo || wntuas) {
02492 nru = *m;
02493 }
02494
02495
02496
02497
02498
02499 dbdsqr_("U", m, &c__0, &nru, &c__0, &s[1], &work[ie], dum, &
02500 c__1, &a[a_offset], lda, dum, &c__1, &work[iwork],
02501 info);
02502
02503
02504
02505 if (wntuas) {
02506 dlacpy_("F", m, m, &a[a_offset], lda, &u[u_offset], ldu);
02507 }
02508
02509 } else if (wntvo && wntun) {
02510
02511
02512
02513
02514
02515
02516 i__2 = *m << 2;
02517 if (*lwork >= *m * *m + max(i__2,bdspac)) {
02518
02519
02520
02521 ir = 1;
02522
02523 i__2 = wrkbl, i__3 = *lda * *n + *m;
02524 if (*lwork >= max(i__2,i__3) + *lda * *m) {
02525
02526
02527
02528 ldwrku = *lda;
02529 chunk = *n;
02530 ldwrkr = *lda;
02531 } else {
02532
02533 i__2 = wrkbl, i__3 = *lda * *n + *m;
02534 if (*lwork >= max(i__2,i__3) + *m * *m) {
02535
02536
02537
02538 ldwrku = *lda;
02539 chunk = *n;
02540 ldwrkr = *m;
02541 } else {
02542
02543
02544
02545 ldwrku = *m;
02546 chunk = (*lwork - *m * *m - *m) / *m;
02547 ldwrkr = *m;
02548 }
02549 }
02550 itau = ir + ldwrkr * *m;
02551 iwork = itau + *m;
02552
02553
02554
02555
02556 i__2 = *lwork - iwork + 1;
02557 dgelqf_(m, n, &a[a_offset], lda, &work[itau], &work[iwork]
02558 , &i__2, &ierr);
02559
02560
02561
02562 dlacpy_("L", m, m, &a[a_offset], lda, &work[ir], &ldwrkr);
02563 i__2 = *m - 1;
02564 i__3 = *m - 1;
02565 dlaset_("U", &i__2, &i__3, &c_b421, &c_b421, &work[ir +
02566 ldwrkr], &ldwrkr);
02567
02568
02569
02570
02571 i__2 = *lwork - iwork + 1;
02572 dorglq_(m, n, m, &a[a_offset], lda, &work[itau], &work[
02573 iwork], &i__2, &ierr);
02574 ie = itau;
02575 itauq = ie + *m;
02576 itaup = itauq + *m;
02577 iwork = itaup + *m;
02578
02579
02580
02581
02582 i__2 = *lwork - iwork + 1;
02583 dgebrd_(m, m, &work[ir], &ldwrkr, &s[1], &work[ie], &work[
02584 itauq], &work[itaup], &work[iwork], &i__2, &ierr);
02585
02586
02587
02588
02589 i__2 = *lwork - iwork + 1;
02590 dorgbr_("P", m, m, m, &work[ir], &ldwrkr, &work[itaup], &
02591 work[iwork], &i__2, &ierr);
02592 iwork = ie + *m;
02593
02594
02595
02596
02597
02598 dbdsqr_("U", m, m, &c__0, &c__0, &s[1], &work[ie], &work[
02599 ir], &ldwrkr, dum, &c__1, dum, &c__1, &work[iwork]
02600 , info);
02601 iu = ie + *m;
02602
02603
02604
02605
02606
02607 i__2 = *n;
02608 i__3 = chunk;
02609 for (i__ = 1; i__3 < 0 ? i__ >= i__2 : i__ <= i__2; i__ +=
02610 i__3) {
02611
02612 i__4 = *n - i__ + 1;
02613 blk = min(i__4,chunk);
02614 dgemm_("N", "N", m, &blk, m, &c_b443, &work[ir], &
02615 ldwrkr, &a[i__ * a_dim1 + 1], lda, &c_b421, &
02616 work[iu], &ldwrku);
02617 dlacpy_("F", m, &blk, &work[iu], &ldwrku, &a[i__ *
02618 a_dim1 + 1], lda);
02619
02620 }
02621
02622 } else {
02623
02624
02625
02626 ie = 1;
02627 itauq = ie + *m;
02628 itaup = itauq + *m;
02629 iwork = itaup + *m;
02630
02631
02632
02633
02634 i__3 = *lwork - iwork + 1;
02635 dgebrd_(m, n, &a[a_offset], lda, &s[1], &work[ie], &work[
02636 itauq], &work[itaup], &work[iwork], &i__3, &ierr);
02637
02638
02639
02640
02641 i__3 = *lwork - iwork + 1;
02642 dorgbr_("P", m, n, m, &a[a_offset], lda, &work[itaup], &
02643 work[iwork], &i__3, &ierr);
02644 iwork = ie + *m;
02645
02646
02647
02648
02649
02650 dbdsqr_("L", m, n, &c__0, &c__0, &s[1], &work[ie], &a[
02651 a_offset], lda, dum, &c__1, dum, &c__1, &work[
02652 iwork], info);
02653
02654 }
02655
02656 } else if (wntvo && wntuas) {
02657
02658
02659
02660
02661
02662
02663 i__3 = *m << 2;
02664 if (*lwork >= *m * *m + max(i__3,bdspac)) {
02665
02666
02667
02668 ir = 1;
02669
02670 i__3 = wrkbl, i__2 = *lda * *n + *m;
02671 if (*lwork >= max(i__3,i__2) + *lda * *m) {
02672
02673
02674
02675 ldwrku = *lda;
02676 chunk = *n;
02677 ldwrkr = *lda;
02678 } else {
02679
02680 i__3 = wrkbl, i__2 = *lda * *n + *m;
02681 if (*lwork >= max(i__3,i__2) + *m * *m) {
02682
02683
02684
02685 ldwrku = *lda;
02686 chunk = *n;
02687 ldwrkr = *m;
02688 } else {
02689
02690
02691
02692 ldwrku = *m;
02693 chunk = (*lwork - *m * *m - *m) / *m;
02694 ldwrkr = *m;
02695 }
02696 }
02697 itau = ir + ldwrkr * *m;
02698 iwork = itau + *m;
02699
02700
02701
02702
02703 i__3 = *lwork - iwork + 1;
02704 dgelqf_(m, n, &a[a_offset], lda, &work[itau], &work[iwork]
02705 , &i__3, &ierr);
02706
02707
02708
02709 dlacpy_("L", m, m, &a[a_offset], lda, &u[u_offset], ldu);
02710 i__3 = *m - 1;
02711 i__2 = *m - 1;
02712 dlaset_("U", &i__3, &i__2, &c_b421, &c_b421, &u[(u_dim1 <<
02713 1) + 1], ldu);
02714
02715
02716
02717
02718 i__3 = *lwork - iwork + 1;
02719 dorglq_(m, n, m, &a[a_offset], lda, &work[itau], &work[
02720 iwork], &i__3, &ierr);
02721 ie = itau;
02722 itauq = ie + *m;
02723 itaup = itauq + *m;
02724 iwork = itaup + *m;
02725
02726
02727
02728
02729 i__3 = *lwork - iwork + 1;
02730 dgebrd_(m, m, &u[u_offset], ldu, &s[1], &work[ie], &work[
02731 itauq], &work[itaup], &work[iwork], &i__3, &ierr);
02732 dlacpy_("U", m, m, &u[u_offset], ldu, &work[ir], &ldwrkr);
02733
02734
02735
02736
02737 i__3 = *lwork - iwork + 1;
02738 dorgbr_("P", m, m, m, &work[ir], &ldwrkr, &work[itaup], &
02739 work[iwork], &i__3, &ierr);
02740
02741
02742
02743
02744 i__3 = *lwork - iwork + 1;
02745 dorgbr_("Q", m, m, m, &u[u_offset], ldu, &work[itauq], &
02746 work[iwork], &i__3, &ierr);
02747 iwork = ie + *m;
02748
02749
02750
02751
02752
02753
02754 dbdsqr_("U", m, m, m, &c__0, &s[1], &work[ie], &work[ir],
02755 &ldwrkr, &u[u_offset], ldu, dum, &c__1, &work[
02756 iwork], info);
02757 iu = ie + *m;
02758
02759
02760
02761
02762
02763 i__3 = *n;
02764 i__2 = chunk;
02765 for (i__ = 1; i__2 < 0 ? i__ >= i__3 : i__ <= i__3; i__ +=
02766 i__2) {
02767
02768 i__4 = *n - i__ + 1;
02769 blk = min(i__4,chunk);
02770 dgemm_("N", "N", m, &blk, m, &c_b443, &work[ir], &
02771 ldwrkr, &a[i__ * a_dim1 + 1], lda, &c_b421, &
02772 work[iu], &ldwrku);
02773 dlacpy_("F", m, &blk, &work[iu], &ldwrku, &a[i__ *
02774 a_dim1 + 1], lda);
02775
02776 }
02777
02778 } else {
02779
02780
02781
02782 itau = 1;
02783 iwork = itau + *m;
02784
02785
02786
02787
02788 i__2 = *lwork - iwork + 1;
02789 dgelqf_(m, n, &a[a_offset], lda, &work[itau], &work[iwork]
02790 , &i__2, &ierr);
02791
02792
02793
02794 dlacpy_("L", m, m, &a[a_offset], lda, &u[u_offset], ldu);
02795 i__2 = *m - 1;
02796 i__3 = *m - 1;
02797 dlaset_("U", &i__2, &i__3, &c_b421, &c_b421, &u[(u_dim1 <<
02798 1) + 1], ldu);
02799
02800
02801
02802
02803 i__2 = *lwork - iwork + 1;
02804 dorglq_(m, n, m, &a[a_offset], lda, &work[itau], &work[
02805 iwork], &i__2, &ierr);
02806 ie = itau;
02807 itauq = ie + *m;
02808 itaup = itauq + *m;
02809 iwork = itaup + *m;
02810
02811
02812
02813
02814 i__2 = *lwork - iwork + 1;
02815 dgebrd_(m, m, &u[u_offset], ldu, &s[1], &work[ie], &work[
02816 itauq], &work[itaup], &work[iwork], &i__2, &ierr);
02817
02818
02819
02820
02821 i__2 = *lwork - iwork + 1;
02822 dormbr_("P", "L", "T", m, n, m, &u[u_offset], ldu, &work[
02823 itaup], &a[a_offset], lda, &work[iwork], &i__2, &
02824 ierr);
02825
02826
02827
02828
02829 i__2 = *lwork - iwork + 1;
02830 dorgbr_("Q", m, m, m, &u[u_offset], ldu, &work[itauq], &
02831 work[iwork], &i__2, &ierr);
02832 iwork = ie + *m;
02833
02834
02835
02836
02837
02838
02839 dbdsqr_("U", m, n, m, &c__0, &s[1], &work[ie], &a[
02840 a_offset], lda, &u[u_offset], ldu, dum, &c__1, &
02841 work[iwork], info);
02842
02843 }
02844
02845 } else if (wntvs) {
02846
02847 if (wntun) {
02848
02849
02850
02851
02852
02853
02854 i__2 = *m << 2;
02855 if (*lwork >= *m * *m + max(i__2,bdspac)) {
02856
02857
02858
02859 ir = 1;
02860 if (*lwork >= wrkbl + *lda * *m) {
02861
02862
02863
02864 ldwrkr = *lda;
02865 } else {
02866
02867
02868
02869 ldwrkr = *m;
02870 }
02871 itau = ir + ldwrkr * *m;
02872 iwork = itau + *m;
02873
02874
02875
02876
02877 i__2 = *lwork - iwork + 1;
02878 dgelqf_(m, n, &a[a_offset], lda, &work[itau], &work[
02879 iwork], &i__2, &ierr);
02880
02881
02882
02883 dlacpy_("L", m, m, &a[a_offset], lda, &work[ir], &
02884 ldwrkr);
02885 i__2 = *m - 1;
02886 i__3 = *m - 1;
02887 dlaset_("U", &i__2, &i__3, &c_b421, &c_b421, &work[ir
02888 + ldwrkr], &ldwrkr);
02889
02890
02891
02892
02893 i__2 = *lwork - iwork + 1;
02894 dorglq_(m, n, m, &a[a_offset], lda, &work[itau], &
02895 work[iwork], &i__2, &ierr);
02896 ie = itau;
02897 itauq = ie + *m;
02898 itaup = itauq + *m;
02899 iwork = itaup + *m;
02900
02901
02902
02903
02904 i__2 = *lwork - iwork + 1;
02905 dgebrd_(m, m, &work[ir], &ldwrkr, &s[1], &work[ie], &
02906 work[itauq], &work[itaup], &work[iwork], &
02907 i__2, &ierr);
02908
02909
02910
02911
02912
02913 i__2 = *lwork - iwork + 1;
02914 dorgbr_("P", m, m, m, &work[ir], &ldwrkr, &work[itaup]
02915 , &work[iwork], &i__2, &ierr);
02916 iwork = ie + *m;
02917
02918
02919
02920
02921
02922 dbdsqr_("U", m, m, &c__0, &c__0, &s[1], &work[ie], &
02923 work[ir], &ldwrkr, dum, &c__1, dum, &c__1, &
02924 work[iwork], info);
02925
02926
02927
02928
02929
02930 dgemm_("N", "N", m, n, m, &c_b443, &work[ir], &ldwrkr,
02931 &a[a_offset], lda, &c_b421, &vt[vt_offset],
02932 ldvt);
02933
02934 } else {
02935
02936
02937
02938 itau = 1;
02939 iwork = itau + *m;
02940
02941
02942
02943
02944 i__2 = *lwork - iwork + 1;
02945 dgelqf_(m, n, &a[a_offset], lda, &work[itau], &work[
02946 iwork], &i__2, &ierr);
02947
02948
02949
02950 dlacpy_("U", m, n, &a[a_offset], lda, &vt[vt_offset],
02951 ldvt);
02952
02953
02954
02955
02956 i__2 = *lwork - iwork + 1;
02957 dorglq_(m, n, m, &vt[vt_offset], ldvt, &work[itau], &
02958 work[iwork], &i__2, &ierr);
02959 ie = itau;
02960 itauq = ie + *m;
02961 itaup = itauq + *m;
02962 iwork = itaup + *m;
02963
02964
02965
02966 i__2 = *m - 1;
02967 i__3 = *m - 1;
02968 dlaset_("U", &i__2, &i__3, &c_b421, &c_b421, &a[(
02969 a_dim1 << 1) + 1], lda);
02970
02971
02972
02973
02974 i__2 = *lwork - iwork + 1;
02975 dgebrd_(m, m, &a[a_offset], lda, &s[1], &work[ie], &
02976 work[itauq], &work[itaup], &work[iwork], &
02977 i__2, &ierr);
02978
02979
02980
02981
02982 i__2 = *lwork - iwork + 1;
02983 dormbr_("P", "L", "T", m, n, m, &a[a_offset], lda, &
02984 work[itaup], &vt[vt_offset], ldvt, &work[
02985 iwork], &i__2, &ierr);
02986 iwork = ie + *m;
02987
02988
02989
02990
02991
02992 dbdsqr_("U", m, n, &c__0, &c__0, &s[1], &work[ie], &
02993 vt[vt_offset], ldvt, dum, &c__1, dum, &c__1, &
02994 work[iwork], info);
02995
02996 }
02997
02998 } else if (wntuo) {
02999
03000
03001
03002
03003
03004
03005 i__2 = *m << 2;
03006 if (*lwork >= (*m << 1) * *m + max(i__2,bdspac)) {
03007
03008
03009
03010 iu = 1;
03011 if (*lwork >= wrkbl + (*lda << 1) * *m) {
03012
03013
03014
03015 ldwrku = *lda;
03016 ir = iu + ldwrku * *m;
03017 ldwrkr = *lda;
03018 } else if (*lwork >= wrkbl + (*lda + *m) * *m) {
03019
03020
03021
03022 ldwrku = *lda;
03023 ir = iu + ldwrku * *m;
03024 ldwrkr = *m;
03025 } else {
03026
03027
03028
03029 ldwrku = *m;
03030 ir = iu + ldwrku * *m;
03031 ldwrkr = *m;
03032 }
03033 itau = ir + ldwrkr * *m;
03034 iwork = itau + *m;
03035
03036
03037
03038
03039 i__2 = *lwork - iwork + 1;
03040 dgelqf_(m, n, &a[a_offset], lda, &work[itau], &work[
03041 iwork], &i__2, &ierr);
03042
03043
03044
03045 dlacpy_("L", m, m, &a[a_offset], lda, &work[iu], &
03046 ldwrku);
03047 i__2 = *m - 1;
03048 i__3 = *m - 1;
03049 dlaset_("U", &i__2, &i__3, &c_b421, &c_b421, &work[iu
03050 + ldwrku], &ldwrku);
03051
03052
03053
03054
03055 i__2 = *lwork - iwork + 1;
03056 dorglq_(m, n, m, &a[a_offset], lda, &work[itau], &
03057 work[iwork], &i__2, &ierr);
03058 ie = itau;
03059 itauq = ie + *m;
03060 itaup = itauq + *m;
03061 iwork = itaup + *m;
03062
03063
03064
03065
03066
03067
03068 i__2 = *lwork - iwork + 1;
03069 dgebrd_(m, m, &work[iu], &ldwrku, &s[1], &work[ie], &
03070 work[itauq], &work[itaup], &work[iwork], &
03071 i__2, &ierr);
03072 dlacpy_("L", m, m, &work[iu], &ldwrku, &work[ir], &
03073 ldwrkr);
03074
03075
03076
03077
03078
03079 i__2 = *lwork - iwork + 1;
03080 dorgbr_("P", m, m, m, &work[iu], &ldwrku, &work[itaup]
03081 , &work[iwork], &i__2, &ierr);
03082
03083
03084
03085
03086 i__2 = *lwork - iwork + 1;
03087 dorgbr_("Q", m, m, m, &work[ir], &ldwrkr, &work[itauq]
03088 , &work[iwork], &i__2, &ierr);
03089 iwork = ie + *m;
03090
03091
03092
03093
03094
03095
03096 dbdsqr_("U", m, m, m, &c__0, &s[1], &work[ie], &work[
03097 iu], &ldwrku, &work[ir], &ldwrkr, dum, &c__1,
03098 &work[iwork], info);
03099
03100
03101
03102
03103
03104 dgemm_("N", "N", m, n, m, &c_b443, &work[iu], &ldwrku,
03105 &a[a_offset], lda, &c_b421, &vt[vt_offset],
03106 ldvt);
03107
03108
03109
03110
03111 dlacpy_("F", m, m, &work[ir], &ldwrkr, &a[a_offset],
03112 lda);
03113
03114 } else {
03115
03116
03117
03118 itau = 1;
03119 iwork = itau + *m;
03120
03121
03122
03123
03124 i__2 = *lwork - iwork + 1;
03125 dgelqf_(m, n, &a[a_offset], lda, &work[itau], &work[
03126 iwork], &i__2, &ierr);
03127 dlacpy_("U", m, n, &a[a_offset], lda, &vt[vt_offset],
03128 ldvt);
03129
03130
03131
03132
03133 i__2 = *lwork - iwork + 1;
03134 dorglq_(m, n, m, &vt[vt_offset], ldvt, &work[itau], &
03135 work[iwork], &i__2, &ierr);
03136 ie = itau;
03137 itauq = ie + *m;
03138 itaup = itauq + *m;
03139 iwork = itaup + *m;
03140
03141
03142
03143 i__2 = *m - 1;
03144 i__3 = *m - 1;
03145 dlaset_("U", &i__2, &i__3, &c_b421, &c_b421, &a[(
03146 a_dim1 << 1) + 1], lda);
03147
03148
03149
03150
03151 i__2 = *lwork - iwork + 1;
03152 dgebrd_(m, m, &a[a_offset], lda, &s[1], &work[ie], &
03153 work[itauq], &work[itaup], &work[iwork], &
03154 i__2, &ierr);
03155
03156
03157
03158
03159 i__2 = *lwork - iwork + 1;
03160 dormbr_("P", "L", "T", m, n, m, &a[a_offset], lda, &
03161 work[itaup], &vt[vt_offset], ldvt, &work[
03162 iwork], &i__2, &ierr);
03163
03164
03165
03166
03167 i__2 = *lwork - iwork + 1;
03168 dorgbr_("Q", m, m, m, &a[a_offset], lda, &work[itauq],
03169 &work[iwork], &i__2, &ierr);
03170 iwork = ie + *m;
03171
03172
03173
03174
03175
03176
03177 dbdsqr_("U", m, n, m, &c__0, &s[1], &work[ie], &vt[
03178 vt_offset], ldvt, &a[a_offset], lda, dum, &
03179 c__1, &work[iwork], info);
03180
03181 }
03182
03183 } else if (wntuas) {
03184
03185
03186
03187
03188
03189
03190
03191 i__2 = *m << 2;
03192 if (*lwork >= *m * *m + max(i__2,bdspac)) {
03193
03194
03195
03196 iu = 1;
03197 if (*lwork >= wrkbl + *lda * *m) {
03198
03199
03200
03201 ldwrku = *lda;
03202 } else {
03203
03204
03205
03206 ldwrku = *m;
03207 }
03208 itau = iu + ldwrku * *m;
03209 iwork = itau + *m;
03210
03211
03212
03213
03214 i__2 = *lwork - iwork + 1;
03215 dgelqf_(m, n, &a[a_offset], lda, &work[itau], &work[
03216 iwork], &i__2, &ierr);
03217
03218
03219
03220 dlacpy_("L", m, m, &a[a_offset], lda, &work[iu], &
03221 ldwrku);
03222 i__2 = *m - 1;
03223 i__3 = *m - 1;
03224 dlaset_("U", &i__2, &i__3, &c_b421, &c_b421, &work[iu
03225 + ldwrku], &ldwrku);
03226
03227
03228
03229
03230 i__2 = *lwork - iwork + 1;
03231 dorglq_(m, n, m, &a[a_offset], lda, &work[itau], &
03232 work[iwork], &i__2, &ierr);
03233 ie = itau;
03234 itauq = ie + *m;
03235 itaup = itauq + *m;
03236 iwork = itaup + *m;
03237
03238
03239
03240
03241 i__2 = *lwork - iwork + 1;
03242 dgebrd_(m, m, &work[iu], &ldwrku, &s[1], &work[ie], &
03243 work[itauq], &work[itaup], &work[iwork], &
03244 i__2, &ierr);
03245 dlacpy_("L", m, m, &work[iu], &ldwrku, &u[u_offset],
03246 ldu);
03247
03248
03249
03250
03251
03252 i__2 = *lwork - iwork + 1;
03253 dorgbr_("P", m, m, m, &work[iu], &ldwrku, &work[itaup]
03254 , &work[iwork], &i__2, &ierr);
03255
03256
03257
03258
03259 i__2 = *lwork - iwork + 1;
03260 dorgbr_("Q", m, m, m, &u[u_offset], ldu, &work[itauq],
03261 &work[iwork], &i__2, &ierr);
03262 iwork = ie + *m;
03263
03264
03265
03266
03267
03268
03269 dbdsqr_("U", m, m, m, &c__0, &s[1], &work[ie], &work[
03270 iu], &ldwrku, &u[u_offset], ldu, dum, &c__1, &
03271 work[iwork], info);
03272
03273
03274
03275
03276
03277 dgemm_("N", "N", m, n, m, &c_b443, &work[iu], &ldwrku,
03278 &a[a_offset], lda, &c_b421, &vt[vt_offset],
03279 ldvt);
03280
03281 } else {
03282
03283
03284
03285 itau = 1;
03286 iwork = itau + *m;
03287
03288
03289
03290
03291 i__2 = *lwork - iwork + 1;
03292 dgelqf_(m, n, &a[a_offset], lda, &work[itau], &work[
03293 iwork], &i__2, &ierr);
03294 dlacpy_("U", m, n, &a[a_offset], lda, &vt[vt_offset],
03295 ldvt);
03296
03297
03298
03299
03300 i__2 = *lwork - iwork + 1;
03301 dorglq_(m, n, m, &vt[vt_offset], ldvt, &work[itau], &
03302 work[iwork], &i__2, &ierr);
03303
03304
03305
03306 dlacpy_("L", m, m, &a[a_offset], lda, &u[u_offset],
03307 ldu);
03308 i__2 = *m - 1;
03309 i__3 = *m - 1;
03310 dlaset_("U", &i__2, &i__3, &c_b421, &c_b421, &u[(
03311 u_dim1 << 1) + 1], ldu);
03312 ie = itau;
03313 itauq = ie + *m;
03314 itaup = itauq + *m;
03315 iwork = itaup + *m;
03316
03317
03318
03319
03320 i__2 = *lwork - iwork + 1;
03321 dgebrd_(m, m, &u[u_offset], ldu, &s[1], &work[ie], &
03322 work[itauq], &work[itaup], &work[iwork], &
03323 i__2, &ierr);
03324
03325
03326
03327
03328
03329 i__2 = *lwork - iwork + 1;
03330 dormbr_("P", "L", "T", m, n, m, &u[u_offset], ldu, &
03331 work[itaup], &vt[vt_offset], ldvt, &work[
03332 iwork], &i__2, &ierr);
03333
03334
03335
03336
03337 i__2 = *lwork - iwork + 1;
03338 dorgbr_("Q", m, m, m, &u[u_offset], ldu, &work[itauq],
03339 &work[iwork], &i__2, &ierr);
03340 iwork = ie + *m;
03341
03342
03343
03344
03345
03346
03347 dbdsqr_("U", m, n, m, &c__0, &s[1], &work[ie], &vt[
03348 vt_offset], ldvt, &u[u_offset], ldu, dum, &
03349 c__1, &work[iwork], info);
03350
03351 }
03352
03353 }
03354
03355 } else if (wntva) {
03356
03357 if (wntun) {
03358
03359
03360
03361
03362
03363
03364 i__2 = *n + *m, i__3 = *m << 2, i__2 = max(i__2,i__3);
03365 if (*lwork >= *m * *m + max(i__2,bdspac)) {
03366
03367
03368
03369 ir = 1;
03370 if (*lwork >= wrkbl + *lda * *m) {
03371
03372
03373
03374 ldwrkr = *lda;
03375 } else {
03376
03377
03378
03379 ldwrkr = *m;
03380 }
03381 itau = ir + ldwrkr * *m;
03382 iwork = itau + *m;
03383
03384
03385
03386
03387 i__2 = *lwork - iwork + 1;
03388 dgelqf_(m, n, &a[a_offset], lda, &work[itau], &work[
03389 iwork], &i__2, &ierr);
03390 dlacpy_("U", m, n, &a[a_offset], lda, &vt[vt_offset],
03391 ldvt);
03392
03393
03394
03395 dlacpy_("L", m, m, &a[a_offset], lda, &work[ir], &
03396 ldwrkr);
03397 i__2 = *m - 1;
03398 i__3 = *m - 1;
03399 dlaset_("U", &i__2, &i__3, &c_b421, &c_b421, &work[ir
03400 + ldwrkr], &ldwrkr);
03401
03402
03403
03404
03405 i__2 = *lwork - iwork + 1;
03406 dorglq_(n, n, m, &vt[vt_offset], ldvt, &work[itau], &
03407 work[iwork], &i__2, &ierr);
03408 ie = itau;
03409 itauq = ie + *m;
03410 itaup = itauq + *m;
03411 iwork = itaup + *m;
03412
03413
03414
03415
03416 i__2 = *lwork - iwork + 1;
03417 dgebrd_(m, m, &work[ir], &ldwrkr, &s[1], &work[ie], &
03418 work[itauq], &work[itaup], &work[iwork], &
03419 i__2, &ierr);
03420
03421
03422
03423
03424
03425 i__2 = *lwork - iwork + 1;
03426 dorgbr_("P", m, m, m, &work[ir], &ldwrkr, &work[itaup]
03427 , &work[iwork], &i__2, &ierr);
03428 iwork = ie + *m;
03429
03430
03431
03432
03433
03434 dbdsqr_("U", m, m, &c__0, &c__0, &s[1], &work[ie], &
03435 work[ir], &ldwrkr, dum, &c__1, dum, &c__1, &
03436 work[iwork], info);
03437
03438
03439
03440
03441
03442 dgemm_("N", "N", m, n, m, &c_b443, &work[ir], &ldwrkr,
03443 &vt[vt_offset], ldvt, &c_b421, &a[a_offset],
03444 lda);
03445
03446
03447
03448 dlacpy_("F", m, n, &a[a_offset], lda, &vt[vt_offset],
03449 ldvt);
03450
03451 } else {
03452
03453
03454
03455 itau = 1;
03456 iwork = itau + *m;
03457
03458
03459
03460
03461 i__2 = *lwork - iwork + 1;
03462 dgelqf_(m, n, &a[a_offset], lda, &work[itau], &work[
03463 iwork], &i__2, &ierr);
03464 dlacpy_("U", m, n, &a[a_offset], lda, &vt[vt_offset],
03465 ldvt);
03466
03467
03468
03469
03470 i__2 = *lwork - iwork + 1;
03471 dorglq_(n, n, m, &vt[vt_offset], ldvt, &work[itau], &
03472 work[iwork], &i__2, &ierr);
03473 ie = itau;
03474 itauq = ie + *m;
03475 itaup = itauq + *m;
03476 iwork = itaup + *m;
03477
03478
03479
03480 i__2 = *m - 1;
03481 i__3 = *m - 1;
03482 dlaset_("U", &i__2, &i__3, &c_b421, &c_b421, &a[(
03483 a_dim1 << 1) + 1], lda);
03484
03485
03486
03487
03488 i__2 = *lwork - iwork + 1;
03489 dgebrd_(m, m, &a[a_offset], lda, &s[1], &work[ie], &
03490 work[itauq], &work[itaup], &work[iwork], &
03491 i__2, &ierr);
03492
03493
03494
03495
03496
03497 i__2 = *lwork - iwork + 1;
03498 dormbr_("P", "L", "T", m, n, m, &a[a_offset], lda, &
03499 work[itaup], &vt[vt_offset], ldvt, &work[
03500 iwork], &i__2, &ierr);
03501 iwork = ie + *m;
03502
03503
03504
03505
03506
03507 dbdsqr_("U", m, n, &c__0, &c__0, &s[1], &work[ie], &
03508 vt[vt_offset], ldvt, dum, &c__1, dum, &c__1, &
03509 work[iwork], info);
03510
03511 }
03512
03513 } else if (wntuo) {
03514
03515
03516
03517
03518
03519
03520 i__2 = *n + *m, i__3 = *m << 2, i__2 = max(i__2,i__3);
03521 if (*lwork >= (*m << 1) * *m + max(i__2,bdspac)) {
03522
03523
03524
03525 iu = 1;
03526 if (*lwork >= wrkbl + (*lda << 1) * *m) {
03527
03528
03529
03530 ldwrku = *lda;
03531 ir = iu + ldwrku * *m;
03532 ldwrkr = *lda;
03533 } else if (*lwork >= wrkbl + (*lda + *m) * *m) {
03534
03535
03536
03537 ldwrku = *lda;
03538 ir = iu + ldwrku * *m;
03539 ldwrkr = *m;
03540 } else {
03541
03542
03543
03544 ldwrku = *m;
03545 ir = iu + ldwrku * *m;
03546 ldwrkr = *m;
03547 }
03548 itau = ir + ldwrkr * *m;
03549 iwork = itau + *m;
03550
03551
03552
03553
03554 i__2 = *lwork - iwork + 1;
03555 dgelqf_(m, n, &a[a_offset], lda, &work[itau], &work[
03556 iwork], &i__2, &ierr);
03557 dlacpy_("U", m, n, &a[a_offset], lda, &vt[vt_offset],
03558 ldvt);
03559
03560
03561
03562
03563 i__2 = *lwork - iwork + 1;
03564 dorglq_(n, n, m, &vt[vt_offset], ldvt, &work[itau], &
03565 work[iwork], &i__2, &ierr);
03566
03567
03568
03569 dlacpy_("L", m, m, &a[a_offset], lda, &work[iu], &
03570 ldwrku);
03571 i__2 = *m - 1;
03572 i__3 = *m - 1;
03573 dlaset_("U", &i__2, &i__3, &c_b421, &c_b421, &work[iu
03574 + ldwrku], &ldwrku);
03575 ie = itau;
03576 itauq = ie + *m;
03577 itaup = itauq + *m;
03578 iwork = itaup + *m;
03579
03580
03581
03582
03583
03584
03585 i__2 = *lwork - iwork + 1;
03586 dgebrd_(m, m, &work[iu], &ldwrku, &s[1], &work[ie], &
03587 work[itauq], &work[itaup], &work[iwork], &
03588 i__2, &ierr);
03589 dlacpy_("L", m, m, &work[iu], &ldwrku, &work[ir], &
03590 ldwrkr);
03591
03592
03593
03594
03595
03596 i__2 = *lwork - iwork + 1;
03597 dorgbr_("P", m, m, m, &work[iu], &ldwrku, &work[itaup]
03598 , &work[iwork], &i__2, &ierr);
03599
03600
03601
03602
03603 i__2 = *lwork - iwork + 1;
03604 dorgbr_("Q", m, m, m, &work[ir], &ldwrkr, &work[itauq]
03605 , &work[iwork], &i__2, &ierr);
03606 iwork = ie + *m;
03607
03608
03609
03610
03611
03612
03613 dbdsqr_("U", m, m, m, &c__0, &s[1], &work[ie], &work[
03614 iu], &ldwrku, &work[ir], &ldwrkr, dum, &c__1,
03615 &work[iwork], info);
03616
03617
03618
03619
03620
03621 dgemm_("N", "N", m, n, m, &c_b443, &work[iu], &ldwrku,
03622 &vt[vt_offset], ldvt, &c_b421, &a[a_offset],
03623 lda);
03624
03625
03626
03627 dlacpy_("F", m, n, &a[a_offset], lda, &vt[vt_offset],
03628 ldvt);
03629
03630
03631
03632 dlacpy_("F", m, m, &work[ir], &ldwrkr, &a[a_offset],
03633 lda);
03634
03635 } else {
03636
03637
03638
03639 itau = 1;
03640 iwork = itau + *m;
03641
03642
03643
03644
03645 i__2 = *lwork - iwork + 1;
03646 dgelqf_(m, n, &a[a_offset], lda, &work[itau], &work[
03647 iwork], &i__2, &ierr);
03648 dlacpy_("U", m, n, &a[a_offset], lda, &vt[vt_offset],
03649 ldvt);
03650
03651
03652
03653
03654 i__2 = *lwork - iwork + 1;
03655 dorglq_(n, n, m, &vt[vt_offset], ldvt, &work[itau], &
03656 work[iwork], &i__2, &ierr);
03657 ie = itau;
03658 itauq = ie + *m;
03659 itaup = itauq + *m;
03660 iwork = itaup + *m;
03661
03662
03663
03664 i__2 = *m - 1;
03665 i__3 = *m - 1;
03666 dlaset_("U", &i__2, &i__3, &c_b421, &c_b421, &a[(
03667 a_dim1 << 1) + 1], lda);
03668
03669
03670
03671
03672 i__2 = *lwork - iwork + 1;
03673 dgebrd_(m, m, &a[a_offset], lda, &s[1], &work[ie], &
03674 work[itauq], &work[itaup], &work[iwork], &
03675 i__2, &ierr);
03676
03677
03678
03679
03680
03681 i__2 = *lwork - iwork + 1;
03682 dormbr_("P", "L", "T", m, n, m, &a[a_offset], lda, &
03683 work[itaup], &vt[vt_offset], ldvt, &work[
03684 iwork], &i__2, &ierr);
03685
03686
03687
03688
03689 i__2 = *lwork - iwork + 1;
03690 dorgbr_("Q", m, m, m, &a[a_offset], lda, &work[itauq],
03691 &work[iwork], &i__2, &ierr);
03692 iwork = ie + *m;
03693
03694
03695
03696
03697
03698
03699 dbdsqr_("U", m, n, m, &c__0, &s[1], &work[ie], &vt[
03700 vt_offset], ldvt, &a[a_offset], lda, dum, &
03701 c__1, &work[iwork], info);
03702
03703 }
03704
03705 } else if (wntuas) {
03706
03707
03708
03709
03710
03711
03712
03713 i__2 = *n + *m, i__3 = *m << 2, i__2 = max(i__2,i__3);
03714 if (*lwork >= *m * *m + max(i__2,bdspac)) {
03715
03716
03717
03718 iu = 1;
03719 if (*lwork >= wrkbl + *lda * *m) {
03720
03721
03722
03723 ldwrku = *lda;
03724 } else {
03725
03726
03727
03728 ldwrku = *m;
03729 }
03730 itau = iu + ldwrku * *m;
03731 iwork = itau + *m;
03732
03733
03734
03735
03736 i__2 = *lwork - iwork + 1;
03737 dgelqf_(m, n, &a[a_offset], lda, &work[itau], &work[
03738 iwork], &i__2, &ierr);
03739 dlacpy_("U", m, n, &a[a_offset], lda, &vt[vt_offset],
03740 ldvt);
03741
03742
03743
03744
03745 i__2 = *lwork - iwork + 1;
03746 dorglq_(n, n, m, &vt[vt_offset], ldvt, &work[itau], &
03747 work[iwork], &i__2, &ierr);
03748
03749
03750
03751 dlacpy_("L", m, m, &a[a_offset], lda, &work[iu], &
03752 ldwrku);
03753 i__2 = *m - 1;
03754 i__3 = *m - 1;
03755 dlaset_("U", &i__2, &i__3, &c_b421, &c_b421, &work[iu
03756 + ldwrku], &ldwrku);
03757 ie = itau;
03758 itauq = ie + *m;
03759 itaup = itauq + *m;
03760 iwork = itaup + *m;
03761
03762
03763
03764
03765 i__2 = *lwork - iwork + 1;
03766 dgebrd_(m, m, &work[iu], &ldwrku, &s[1], &work[ie], &
03767 work[itauq], &work[itaup], &work[iwork], &
03768 i__2, &ierr);
03769 dlacpy_("L", m, m, &work[iu], &ldwrku, &u[u_offset],
03770 ldu);
03771
03772
03773
03774
03775 i__2 = *lwork - iwork + 1;
03776 dorgbr_("P", m, m, m, &work[iu], &ldwrku, &work[itaup]
03777 , &work[iwork], &i__2, &ierr);
03778
03779
03780
03781
03782 i__2 = *lwork - iwork + 1;
03783 dorgbr_("Q", m, m, m, &u[u_offset], ldu, &work[itauq],
03784 &work[iwork], &i__2, &ierr);
03785 iwork = ie + *m;
03786
03787
03788
03789
03790
03791
03792 dbdsqr_("U", m, m, m, &c__0, &s[1], &work[ie], &work[
03793 iu], &ldwrku, &u[u_offset], ldu, dum, &c__1, &
03794 work[iwork], info);
03795
03796
03797
03798
03799
03800 dgemm_("N", "N", m, n, m, &c_b443, &work[iu], &ldwrku,
03801 &vt[vt_offset], ldvt, &c_b421, &a[a_offset],
03802 lda);
03803
03804
03805
03806 dlacpy_("F", m, n, &a[a_offset], lda, &vt[vt_offset],
03807 ldvt);
03808
03809 } else {
03810
03811
03812
03813 itau = 1;
03814 iwork = itau + *m;
03815
03816
03817
03818
03819 i__2 = *lwork - iwork + 1;
03820 dgelqf_(m, n, &a[a_offset], lda, &work[itau], &work[
03821 iwork], &i__2, &ierr);
03822 dlacpy_("U", m, n, &a[a_offset], lda, &vt[vt_offset],
03823 ldvt);
03824
03825
03826
03827
03828 i__2 = *lwork - iwork + 1;
03829 dorglq_(n, n, m, &vt[vt_offset], ldvt, &work[itau], &
03830 work[iwork], &i__2, &ierr);
03831
03832
03833
03834 dlacpy_("L", m, m, &a[a_offset], lda, &u[u_offset],
03835 ldu);
03836 i__2 = *m - 1;
03837 i__3 = *m - 1;
03838 dlaset_("U", &i__2, &i__3, &c_b421, &c_b421, &u[(
03839 u_dim1 << 1) + 1], ldu);
03840 ie = itau;
03841 itauq = ie + *m;
03842 itaup = itauq + *m;
03843 iwork = itaup + *m;
03844
03845
03846
03847
03848 i__2 = *lwork - iwork + 1;
03849 dgebrd_(m, m, &u[u_offset], ldu, &s[1], &work[ie], &
03850 work[itauq], &work[itaup], &work[iwork], &
03851 i__2, &ierr);
03852
03853
03854
03855
03856
03857 i__2 = *lwork - iwork + 1;
03858 dormbr_("P", "L", "T", m, n, m, &u[u_offset], ldu, &
03859 work[itaup], &vt[vt_offset], ldvt, &work[
03860 iwork], &i__2, &ierr);
03861
03862
03863
03864
03865 i__2 = *lwork - iwork + 1;
03866 dorgbr_("Q", m, m, m, &u[u_offset], ldu, &work[itauq],
03867 &work[iwork], &i__2, &ierr);
03868 iwork = ie + *m;
03869
03870
03871
03872
03873
03874
03875 dbdsqr_("U", m, n, m, &c__0, &s[1], &work[ie], &vt[
03876 vt_offset], ldvt, &u[u_offset], ldu, dum, &
03877 c__1, &work[iwork], info);
03878
03879 }
03880
03881 }
03882
03883 }
03884
03885 } else {
03886
03887
03888
03889
03890
03891
03892 ie = 1;
03893 itauq = ie + *m;
03894 itaup = itauq + *m;
03895 iwork = itaup + *m;
03896
03897
03898
03899
03900 i__2 = *lwork - iwork + 1;
03901 dgebrd_(m, n, &a[a_offset], lda, &s[1], &work[ie], &work[itauq], &
03902 work[itaup], &work[iwork], &i__2, &ierr);
03903 if (wntuas) {
03904
03905
03906
03907
03908
03909 dlacpy_("L", m, m, &a[a_offset], lda, &u[u_offset], ldu);
03910 i__2 = *lwork - iwork + 1;
03911 dorgbr_("Q", m, m, n, &u[u_offset], ldu, &work[itauq], &work[
03912 iwork], &i__2, &ierr);
03913 }
03914 if (wntvas) {
03915
03916
03917
03918
03919
03920 dlacpy_("U", m, n, &a[a_offset], lda, &vt[vt_offset], ldvt);
03921 if (wntva) {
03922 nrvt = *n;
03923 }
03924 if (wntvs) {
03925 nrvt = *m;
03926 }
03927 i__2 = *lwork - iwork + 1;
03928 dorgbr_("P", &nrvt, n, m, &vt[vt_offset], ldvt, &work[itaup],
03929 &work[iwork], &i__2, &ierr);
03930 }
03931 if (wntuo) {
03932
03933
03934
03935
03936
03937 i__2 = *lwork - iwork + 1;
03938 dorgbr_("Q", m, m, n, &a[a_offset], lda, &work[itauq], &work[
03939 iwork], &i__2, &ierr);
03940 }
03941 if (wntvo) {
03942
03943
03944
03945
03946
03947 i__2 = *lwork - iwork + 1;
03948 dorgbr_("P", m, n, m, &a[a_offset], lda, &work[itaup], &work[
03949 iwork], &i__2, &ierr);
03950 }
03951 iwork = ie + *m;
03952 if (wntuas || wntuo) {
03953 nru = *m;
03954 }
03955 if (wntun) {
03956 nru = 0;
03957 }
03958 if (wntvas || wntvo) {
03959 ncvt = *n;
03960 }
03961 if (wntvn) {
03962 ncvt = 0;
03963 }
03964 if (! wntuo && ! wntvo) {
03965
03966
03967
03968
03969
03970
03971 dbdsqr_("L", m, &ncvt, &nru, &c__0, &s[1], &work[ie], &vt[
03972 vt_offset], ldvt, &u[u_offset], ldu, dum, &c__1, &
03973 work[iwork], info);
03974 } else if (! wntuo && wntvo) {
03975
03976
03977
03978
03979
03980
03981 dbdsqr_("L", m, &ncvt, &nru, &c__0, &s[1], &work[ie], &a[
03982 a_offset], lda, &u[u_offset], ldu, dum, &c__1, &work[
03983 iwork], info);
03984 } else {
03985
03986
03987
03988
03989
03990
03991 dbdsqr_("L", m, &ncvt, &nru, &c__0, &s[1], &work[ie], &vt[
03992 vt_offset], ldvt, &a[a_offset], lda, dum, &c__1, &
03993 work[iwork], info);
03994 }
03995
03996 }
03997
03998 }
03999
04000
04001
04002
04003 if (*info != 0) {
04004 if (ie > 2) {
04005 i__2 = minmn - 1;
04006 for (i__ = 1; i__ <= i__2; ++i__) {
04007 work[i__ + 1] = work[i__ + ie - 1];
04008
04009 }
04010 }
04011 if (ie < 2) {
04012 for (i__ = minmn - 1; i__ >= 1; --i__) {
04013 work[i__ + 1] = work[i__ + ie - 1];
04014
04015 }
04016 }
04017 }
04018
04019
04020
04021 if (iscl == 1) {
04022 if (anrm > bignum) {
04023 dlascl_("G", &c__0, &c__0, &bignum, &anrm, &minmn, &c__1, &s[1], &
04024 minmn, &ierr);
04025 }
04026 if (*info != 0 && anrm > bignum) {
04027 i__2 = minmn - 1;
04028 dlascl_("G", &c__0, &c__0, &bignum, &anrm, &i__2, &c__1, &work[2],
04029 &minmn, &ierr);
04030 }
04031 if (anrm < smlnum) {
04032 dlascl_("G", &c__0, &c__0, &smlnum, &anrm, &minmn, &c__1, &s[1], &
04033 minmn, &ierr);
04034 }
04035 if (*info != 0 && anrm < smlnum) {
04036 i__2 = minmn - 1;
04037 dlascl_("G", &c__0, &c__0, &smlnum, &anrm, &i__2, &c__1, &work[2],
04038 &minmn, &ierr);
04039 }
04040 }
04041
04042
04043
04044 work[1] = (doublereal) maxwrk;
04045
04046 return 0;
04047
04048
04049
04050 }