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