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__1 = 1;
00019 static integer c_n1 = -1;
00020 static integer c__0 = 0;
00021 static doublereal c_b227 = 0.;
00022 static doublereal c_b248 = 1.;
00023
00024 int dgesdd_(char *jobz, integer *m, integer *n, doublereal *
00025 a, integer *lda, doublereal *s, doublereal *u, integer *ldu,
00026 doublereal *vt, integer *ldvt, doublereal *work, integer *lwork,
00027 integer *iwork, integer *info)
00028 {
00029
00030 integer a_dim1, a_offset, u_dim1, u_offset, vt_dim1, vt_offset, i__1,
00031 i__2, i__3;
00032
00033
00034 double sqrt(doublereal);
00035
00036
00037 integer i__, ie, il, ir, iu, blk;
00038 doublereal dum[1], eps;
00039 integer ivt, iscl;
00040 doublereal anrm;
00041 integer idum[1], ierr, itau;
00042 extern int dgemm_(char *, char *, integer *, integer *,
00043 integer *, doublereal *, doublereal *, integer *, doublereal *,
00044 integer *, doublereal *, doublereal *, integer *);
00045 extern logical lsame_(char *, char *);
00046 integer chunk, minmn, wrkbl, itaup, itauq, mnthr;
00047 logical wntqa;
00048 integer nwork;
00049 logical wntqn, wntqo, wntqs;
00050 extern int dbdsdc_(char *, char *, integer *, doublereal
00051 *, doublereal *, doublereal *, integer *, doublereal *, integer *,
00052 doublereal *, integer *, doublereal *, integer *, integer *), dgebrd_(integer *, integer *, doublereal *,
00053 integer *, doublereal *, doublereal *, doublereal *, doublereal *,
00054 doublereal *, integer *, integer *);
00055 extern doublereal dlamch_(char *), dlange_(char *, integer *,
00056 integer *, doublereal *, integer *, doublereal *);
00057 integer bdspac;
00058 extern int dgelqf_(integer *, integer *, doublereal *,
00059 integer *, doublereal *, doublereal *, integer *, integer *),
00060 dlascl_(char *, integer *, integer *, doublereal *, doublereal *,
00061 integer *, integer *, doublereal *, integer *, integer *),
00062 dgeqrf_(integer *, integer *, doublereal *, integer *,
00063 doublereal *, doublereal *, integer *, integer *), dlacpy_(char *,
00064 integer *, integer *, doublereal *, integer *, doublereal *,
00065 integer *), dlaset_(char *, integer *, integer *,
00066 doublereal *, doublereal *, doublereal *, integer *),
00067 xerbla_(char *, integer *), dorgbr_(char *, integer *,
00068 integer *, integer *, doublereal *, integer *, doublereal *,
00069 doublereal *, integer *, integer *);
00070 extern integer ilaenv_(integer *, char *, char *, integer *, integer *,
00071 integer *, integer *);
00072 doublereal bignum;
00073 extern int dormbr_(char *, char *, char *, integer *,
00074 integer *, integer *, doublereal *, integer *, doublereal *,
00075 doublereal *, integer *, doublereal *, integer *, integer *), dorglq_(integer *, integer *, integer *,
00076 doublereal *, integer *, doublereal *, doublereal *, integer *,
00077 integer *), dorgqr_(integer *, integer *, integer *, doublereal *,
00078 integer *, doublereal *, doublereal *, integer *, integer *);
00079 integer ldwrkl, ldwrkr, minwrk, ldwrku, maxwrk, ldwkvt;
00080 doublereal smlnum;
00081 logical wntqas, lquery;
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
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238 a_dim1 = *lda;
00239 a_offset = 1 + a_dim1;
00240 a -= a_offset;
00241 --s;
00242 u_dim1 = *ldu;
00243 u_offset = 1 + u_dim1;
00244 u -= u_offset;
00245 vt_dim1 = *ldvt;
00246 vt_offset = 1 + vt_dim1;
00247 vt -= vt_offset;
00248 --work;
00249 --iwork;
00250
00251
00252 *info = 0;
00253 minmn = min(*m,*n);
00254 wntqa = lsame_(jobz, "A");
00255 wntqs = lsame_(jobz, "S");
00256 wntqas = wntqa || wntqs;
00257 wntqo = lsame_(jobz, "O");
00258 wntqn = lsame_(jobz, "N");
00259 lquery = *lwork == -1;
00260
00261 if (! (wntqa || wntqs || wntqo || wntqn)) {
00262 *info = -1;
00263 } else if (*m < 0) {
00264 *info = -2;
00265 } else if (*n < 0) {
00266 *info = -3;
00267 } else if (*lda < max(1,*m)) {
00268 *info = -5;
00269 } else if (*ldu < 1 || wntqas && *ldu < *m || wntqo && *m < *n && *ldu < *
00270 m) {
00271 *info = -8;
00272 } else if (*ldvt < 1 || wntqa && *ldvt < *n || wntqs && *ldvt < minmn ||
00273 wntqo && *m >= *n && *ldvt < *n) {
00274 *info = -10;
00275 }
00276
00277
00278
00279
00280
00281
00282
00283
00284 if (*info == 0) {
00285 minwrk = 1;
00286 maxwrk = 1;
00287 if (*m >= *n && minmn > 0) {
00288
00289
00290
00291 mnthr = (integer) (minmn * 11. / 6.);
00292 if (wntqn) {
00293 bdspac = *n * 7;
00294 } else {
00295 bdspac = *n * 3 * *n + (*n << 2);
00296 }
00297 if (*m >= mnthr) {
00298 if (wntqn) {
00299
00300
00301
00302 wrkbl = *n + *n * ilaenv_(&c__1, "DGEQRF", " ", m, n, &
00303 c_n1, &c_n1);
00304
00305 i__1 = wrkbl, i__2 = *n * 3 + (*n << 1) * ilaenv_(&c__1,
00306 "DGEBRD", " ", n, n, &c_n1, &c_n1);
00307 wrkbl = max(i__1,i__2);
00308
00309 i__1 = wrkbl, i__2 = bdspac + *n;
00310 maxwrk = max(i__1,i__2);
00311 minwrk = bdspac + *n;
00312 } else if (wntqo) {
00313
00314
00315
00316 wrkbl = *n + *n * ilaenv_(&c__1, "DGEQRF", " ", m, n, &
00317 c_n1, &c_n1);
00318
00319 i__1 = wrkbl, i__2 = *n + *n * ilaenv_(&c__1, "DORGQR",
00320 " ", m, n, n, &c_n1);
00321 wrkbl = max(i__1,i__2);
00322
00323 i__1 = wrkbl, i__2 = *n * 3 + (*n << 1) * ilaenv_(&c__1,
00324 "DGEBRD", " ", n, n, &c_n1, &c_n1);
00325 wrkbl = max(i__1,i__2);
00326
00327 i__1 = wrkbl, i__2 = *n * 3 + *n * ilaenv_(&c__1, "DORMBR"
00328 , "QLN", n, n, n, &c_n1);
00329 wrkbl = max(i__1,i__2);
00330
00331 i__1 = wrkbl, i__2 = *n * 3 + *n * ilaenv_(&c__1, "DORMBR"
00332 , "PRT", n, n, n, &c_n1);
00333 wrkbl = max(i__1,i__2);
00334
00335 i__1 = wrkbl, i__2 = bdspac + *n * 3;
00336 wrkbl = max(i__1,i__2);
00337 maxwrk = wrkbl + (*n << 1) * *n;
00338 minwrk = bdspac + (*n << 1) * *n + *n * 3;
00339 } else if (wntqs) {
00340
00341
00342
00343 wrkbl = *n + *n * ilaenv_(&c__1, "DGEQRF", " ", m, n, &
00344 c_n1, &c_n1);
00345
00346 i__1 = wrkbl, i__2 = *n + *n * ilaenv_(&c__1, "DORGQR",
00347 " ", m, n, n, &c_n1);
00348 wrkbl = max(i__1,i__2);
00349
00350 i__1 = wrkbl, i__2 = *n * 3 + (*n << 1) * ilaenv_(&c__1,
00351 "DGEBRD", " ", n, n, &c_n1, &c_n1);
00352 wrkbl = max(i__1,i__2);
00353
00354 i__1 = wrkbl, i__2 = *n * 3 + *n * ilaenv_(&c__1, "DORMBR"
00355 , "QLN", n, n, n, &c_n1);
00356 wrkbl = max(i__1,i__2);
00357
00358 i__1 = wrkbl, i__2 = *n * 3 + *n * ilaenv_(&c__1, "DORMBR"
00359 , "PRT", n, n, n, &c_n1);
00360 wrkbl = max(i__1,i__2);
00361
00362 i__1 = wrkbl, i__2 = bdspac + *n * 3;
00363 wrkbl = max(i__1,i__2);
00364 maxwrk = wrkbl + *n * *n;
00365 minwrk = bdspac + *n * *n + *n * 3;
00366 } else if (wntqa) {
00367
00368
00369
00370 wrkbl = *n + *n * ilaenv_(&c__1, "DGEQRF", " ", m, n, &
00371 c_n1, &c_n1);
00372
00373 i__1 = wrkbl, i__2 = *n + *m * ilaenv_(&c__1, "DORGQR",
00374 " ", m, m, n, &c_n1);
00375 wrkbl = max(i__1,i__2);
00376
00377 i__1 = wrkbl, i__2 = *n * 3 + (*n << 1) * ilaenv_(&c__1,
00378 "DGEBRD", " ", n, n, &c_n1, &c_n1);
00379 wrkbl = max(i__1,i__2);
00380
00381 i__1 = wrkbl, i__2 = *n * 3 + *n * ilaenv_(&c__1, "DORMBR"
00382 , "QLN", n, n, n, &c_n1);
00383 wrkbl = max(i__1,i__2);
00384
00385 i__1 = wrkbl, i__2 = *n * 3 + *n * ilaenv_(&c__1, "DORMBR"
00386 , "PRT", n, n, n, &c_n1);
00387 wrkbl = max(i__1,i__2);
00388
00389 i__1 = wrkbl, i__2 = bdspac + *n * 3;
00390 wrkbl = max(i__1,i__2);
00391 maxwrk = wrkbl + *n * *n;
00392 minwrk = bdspac + *n * *n + *n * 3;
00393 }
00394 } else {
00395
00396
00397
00398 wrkbl = *n * 3 + (*m + *n) * ilaenv_(&c__1, "DGEBRD", " ", m,
00399 n, &c_n1, &c_n1);
00400 if (wntqn) {
00401
00402 i__1 = wrkbl, i__2 = bdspac + *n * 3;
00403 maxwrk = max(i__1,i__2);
00404 minwrk = *n * 3 + max(*m,bdspac);
00405 } else if (wntqo) {
00406
00407 i__1 = wrkbl, i__2 = *n * 3 + *n * ilaenv_(&c__1, "DORMBR"
00408 , "QLN", m, n, n, &c_n1);
00409 wrkbl = max(i__1,i__2);
00410
00411 i__1 = wrkbl, i__2 = *n * 3 + *n * ilaenv_(&c__1, "DORMBR"
00412 , "PRT", n, n, n, &c_n1);
00413 wrkbl = max(i__1,i__2);
00414
00415 i__1 = wrkbl, i__2 = bdspac + *n * 3;
00416 wrkbl = max(i__1,i__2);
00417 maxwrk = wrkbl + *m * *n;
00418
00419 i__1 = *m, i__2 = *n * *n + bdspac;
00420 minwrk = *n * 3 + max(i__1,i__2);
00421 } else if (wntqs) {
00422
00423 i__1 = wrkbl, i__2 = *n * 3 + *n * ilaenv_(&c__1, "DORMBR"
00424 , "QLN", m, n, n, &c_n1);
00425 wrkbl = max(i__1,i__2);
00426
00427 i__1 = wrkbl, i__2 = *n * 3 + *n * ilaenv_(&c__1, "DORMBR"
00428 , "PRT", n, n, n, &c_n1);
00429 wrkbl = max(i__1,i__2);
00430
00431 i__1 = wrkbl, i__2 = bdspac + *n * 3;
00432 maxwrk = max(i__1,i__2);
00433 minwrk = *n * 3 + max(*m,bdspac);
00434 } else if (wntqa) {
00435
00436 i__1 = wrkbl, i__2 = *n * 3 + *m * ilaenv_(&c__1, "DORMBR"
00437 , "QLN", m, m, n, &c_n1);
00438 wrkbl = max(i__1,i__2);
00439
00440 i__1 = wrkbl, i__2 = *n * 3 + *n * ilaenv_(&c__1, "DORMBR"
00441 , "PRT", n, n, n, &c_n1);
00442 wrkbl = max(i__1,i__2);
00443
00444 i__1 = maxwrk, i__2 = bdspac + *n * 3;
00445 maxwrk = max(i__1,i__2);
00446 minwrk = *n * 3 + max(*m,bdspac);
00447 }
00448 }
00449 } else if (minmn > 0) {
00450
00451
00452
00453 mnthr = (integer) (minmn * 11. / 6.);
00454 if (wntqn) {
00455 bdspac = *m * 7;
00456 } else {
00457 bdspac = *m * 3 * *m + (*m << 2);
00458 }
00459 if (*n >= mnthr) {
00460 if (wntqn) {
00461
00462
00463
00464 wrkbl = *m + *m * ilaenv_(&c__1, "DGELQF", " ", m, n, &
00465 c_n1, &c_n1);
00466
00467 i__1 = wrkbl, i__2 = *m * 3 + (*m << 1) * ilaenv_(&c__1,
00468 "DGEBRD", " ", m, m, &c_n1, &c_n1);
00469 wrkbl = max(i__1,i__2);
00470
00471 i__1 = wrkbl, i__2 = bdspac + *m;
00472 maxwrk = max(i__1,i__2);
00473 minwrk = bdspac + *m;
00474 } else if (wntqo) {
00475
00476
00477
00478 wrkbl = *m + *m * ilaenv_(&c__1, "DGELQF", " ", m, n, &
00479 c_n1, &c_n1);
00480
00481 i__1 = wrkbl, i__2 = *m + *m * ilaenv_(&c__1, "DORGLQ",
00482 " ", m, n, m, &c_n1);
00483 wrkbl = max(i__1,i__2);
00484
00485 i__1 = wrkbl, i__2 = *m * 3 + (*m << 1) * ilaenv_(&c__1,
00486 "DGEBRD", " ", m, m, &c_n1, &c_n1);
00487 wrkbl = max(i__1,i__2);
00488
00489 i__1 = wrkbl, i__2 = *m * 3 + *m * ilaenv_(&c__1, "DORMBR"
00490 , "QLN", m, m, m, &c_n1);
00491 wrkbl = max(i__1,i__2);
00492
00493 i__1 = wrkbl, i__2 = *m * 3 + *m * ilaenv_(&c__1, "DORMBR"
00494 , "PRT", m, m, m, &c_n1);
00495 wrkbl = max(i__1,i__2);
00496
00497 i__1 = wrkbl, i__2 = bdspac + *m * 3;
00498 wrkbl = max(i__1,i__2);
00499 maxwrk = wrkbl + (*m << 1) * *m;
00500 minwrk = bdspac + (*m << 1) * *m + *m * 3;
00501 } else if (wntqs) {
00502
00503
00504
00505 wrkbl = *m + *m * ilaenv_(&c__1, "DGELQF", " ", m, n, &
00506 c_n1, &c_n1);
00507
00508 i__1 = wrkbl, i__2 = *m + *m * ilaenv_(&c__1, "DORGLQ",
00509 " ", m, n, m, &c_n1);
00510 wrkbl = max(i__1,i__2);
00511
00512 i__1 = wrkbl, i__2 = *m * 3 + (*m << 1) * ilaenv_(&c__1,
00513 "DGEBRD", " ", m, m, &c_n1, &c_n1);
00514 wrkbl = max(i__1,i__2);
00515
00516 i__1 = wrkbl, i__2 = *m * 3 + *m * ilaenv_(&c__1, "DORMBR"
00517 , "QLN", m, m, m, &c_n1);
00518 wrkbl = max(i__1,i__2);
00519
00520 i__1 = wrkbl, i__2 = *m * 3 + *m * ilaenv_(&c__1, "DORMBR"
00521 , "PRT", m, m, m, &c_n1);
00522 wrkbl = max(i__1,i__2);
00523
00524 i__1 = wrkbl, i__2 = bdspac + *m * 3;
00525 wrkbl = max(i__1,i__2);
00526 maxwrk = wrkbl + *m * *m;
00527 minwrk = bdspac + *m * *m + *m * 3;
00528 } else if (wntqa) {
00529
00530
00531
00532 wrkbl = *m + *m * ilaenv_(&c__1, "DGELQF", " ", m, n, &
00533 c_n1, &c_n1);
00534
00535 i__1 = wrkbl, i__2 = *m + *n * ilaenv_(&c__1, "DORGLQ",
00536 " ", n, n, m, &c_n1);
00537 wrkbl = max(i__1,i__2);
00538
00539 i__1 = wrkbl, i__2 = *m * 3 + (*m << 1) * ilaenv_(&c__1,
00540 "DGEBRD", " ", m, m, &c_n1, &c_n1);
00541 wrkbl = max(i__1,i__2);
00542
00543 i__1 = wrkbl, i__2 = *m * 3 + *m * ilaenv_(&c__1, "DORMBR"
00544 , "QLN", m, m, m, &c_n1);
00545 wrkbl = max(i__1,i__2);
00546
00547 i__1 = wrkbl, i__2 = *m * 3 + *m * ilaenv_(&c__1, "DORMBR"
00548 , "PRT", m, m, m, &c_n1);
00549 wrkbl = max(i__1,i__2);
00550
00551 i__1 = wrkbl, i__2 = bdspac + *m * 3;
00552 wrkbl = max(i__1,i__2);
00553 maxwrk = wrkbl + *m * *m;
00554 minwrk = bdspac + *m * *m + *m * 3;
00555 }
00556 } else {
00557
00558
00559
00560 wrkbl = *m * 3 + (*m + *n) * ilaenv_(&c__1, "DGEBRD", " ", m,
00561 n, &c_n1, &c_n1);
00562 if (wntqn) {
00563
00564 i__1 = wrkbl, i__2 = bdspac + *m * 3;
00565 maxwrk = max(i__1,i__2);
00566 minwrk = *m * 3 + max(*n,bdspac);
00567 } else if (wntqo) {
00568
00569 i__1 = wrkbl, i__2 = *m * 3 + *m * ilaenv_(&c__1, "DORMBR"
00570 , "QLN", m, m, n, &c_n1);
00571 wrkbl = max(i__1,i__2);
00572
00573 i__1 = wrkbl, i__2 = *m * 3 + *m * ilaenv_(&c__1, "DORMBR"
00574 , "PRT", m, n, m, &c_n1);
00575 wrkbl = max(i__1,i__2);
00576
00577 i__1 = wrkbl, i__2 = bdspac + *m * 3;
00578 wrkbl = max(i__1,i__2);
00579 maxwrk = wrkbl + *m * *n;
00580
00581 i__1 = *n, i__2 = *m * *m + bdspac;
00582 minwrk = *m * 3 + max(i__1,i__2);
00583 } else if (wntqs) {
00584
00585 i__1 = wrkbl, i__2 = *m * 3 + *m * ilaenv_(&c__1, "DORMBR"
00586 , "QLN", m, m, n, &c_n1);
00587 wrkbl = max(i__1,i__2);
00588
00589 i__1 = wrkbl, i__2 = *m * 3 + *m * ilaenv_(&c__1, "DORMBR"
00590 , "PRT", m, n, m, &c_n1);
00591 wrkbl = max(i__1,i__2);
00592
00593 i__1 = wrkbl, i__2 = bdspac + *m * 3;
00594 maxwrk = max(i__1,i__2);
00595 minwrk = *m * 3 + max(*n,bdspac);
00596 } else if (wntqa) {
00597
00598 i__1 = wrkbl, i__2 = *m * 3 + *m * ilaenv_(&c__1, "DORMBR"
00599 , "QLN", m, m, n, &c_n1);
00600 wrkbl = max(i__1,i__2);
00601
00602 i__1 = wrkbl, i__2 = *m * 3 + *m * ilaenv_(&c__1, "DORMBR"
00603 , "PRT", n, n, m, &c_n1);
00604 wrkbl = max(i__1,i__2);
00605
00606 i__1 = wrkbl, i__2 = bdspac + *m * 3;
00607 maxwrk = max(i__1,i__2);
00608 minwrk = *m * 3 + max(*n,bdspac);
00609 }
00610 }
00611 }
00612 maxwrk = max(maxwrk,minwrk);
00613 work[1] = (doublereal) maxwrk;
00614
00615 if (*lwork < minwrk && ! lquery) {
00616 *info = -12;
00617 }
00618 }
00619
00620 if (*info != 0) {
00621 i__1 = -(*info);
00622 xerbla_("DGESDD", &i__1);
00623 return 0;
00624 } else if (lquery) {
00625 return 0;
00626 }
00627
00628
00629
00630 if (*m == 0 || *n == 0) {
00631 return 0;
00632 }
00633
00634
00635
00636 eps = dlamch_("P");
00637 smlnum = sqrt(dlamch_("S")) / eps;
00638 bignum = 1. / smlnum;
00639
00640
00641
00642 anrm = dlange_("M", m, n, &a[a_offset], lda, dum);
00643 iscl = 0;
00644 if (anrm > 0. && anrm < smlnum) {
00645 iscl = 1;
00646 dlascl_("G", &c__0, &c__0, &anrm, &smlnum, m, n, &a[a_offset], lda, &
00647 ierr);
00648 } else if (anrm > bignum) {
00649 iscl = 1;
00650 dlascl_("G", &c__0, &c__0, &anrm, &bignum, m, n, &a[a_offset], lda, &
00651 ierr);
00652 }
00653
00654 if (*m >= *n) {
00655
00656
00657
00658
00659
00660 if (*m >= mnthr) {
00661
00662 if (wntqn) {
00663
00664
00665
00666
00667 itau = 1;
00668 nwork = itau + *n;
00669
00670
00671
00672
00673 i__1 = *lwork - nwork + 1;
00674 dgeqrf_(m, n, &a[a_offset], lda, &work[itau], &work[nwork], &
00675 i__1, &ierr);
00676
00677
00678
00679 i__1 = *n - 1;
00680 i__2 = *n - 1;
00681 dlaset_("L", &i__1, &i__2, &c_b227, &c_b227, &a[a_dim1 + 2],
00682 lda);
00683 ie = 1;
00684 itauq = ie + *n;
00685 itaup = itauq + *n;
00686 nwork = itaup + *n;
00687
00688
00689
00690
00691 i__1 = *lwork - nwork + 1;
00692 dgebrd_(n, n, &a[a_offset], lda, &s[1], &work[ie], &work[
00693 itauq], &work[itaup], &work[nwork], &i__1, &ierr);
00694 nwork = ie + *n;
00695
00696
00697
00698
00699 dbdsdc_("U", "N", n, &s[1], &work[ie], dum, &c__1, dum, &c__1,
00700 dum, idum, &work[nwork], &iwork[1], info);
00701
00702 } else if (wntqo) {
00703
00704
00705
00706
00707
00708 ir = 1;
00709
00710
00711
00712 if (*lwork >= *lda * *n + *n * *n + *n * 3 + bdspac) {
00713 ldwrkr = *lda;
00714 } else {
00715 ldwrkr = (*lwork - *n * *n - *n * 3 - bdspac) / *n;
00716 }
00717 itau = ir + ldwrkr * *n;
00718 nwork = itau + *n;
00719
00720
00721
00722
00723 i__1 = *lwork - nwork + 1;
00724 dgeqrf_(m, n, &a[a_offset], lda, &work[itau], &work[nwork], &
00725 i__1, &ierr);
00726
00727
00728
00729 dlacpy_("U", n, n, &a[a_offset], lda, &work[ir], &ldwrkr);
00730 i__1 = *n - 1;
00731 i__2 = *n - 1;
00732 dlaset_("L", &i__1, &i__2, &c_b227, &c_b227, &work[ir + 1], &
00733 ldwrkr);
00734
00735
00736
00737
00738 i__1 = *lwork - nwork + 1;
00739 dorgqr_(m, n, n, &a[a_offset], lda, &work[itau], &work[nwork],
00740 &i__1, &ierr);
00741 ie = itau;
00742 itauq = ie + *n;
00743 itaup = itauq + *n;
00744 nwork = itaup + *n;
00745
00746
00747
00748
00749 i__1 = *lwork - nwork + 1;
00750 dgebrd_(n, n, &work[ir], &ldwrkr, &s[1], &work[ie], &work[
00751 itauq], &work[itaup], &work[nwork], &i__1, &ierr);
00752
00753
00754
00755 iu = nwork;
00756 nwork = iu + *n * *n;
00757
00758
00759
00760
00761
00762
00763 dbdsdc_("U", "I", n, &s[1], &work[ie], &work[iu], n, &vt[
00764 vt_offset], ldvt, dum, idum, &work[nwork], &iwork[1],
00765 info);
00766
00767
00768
00769
00770
00771 i__1 = *lwork - nwork + 1;
00772 dormbr_("Q", "L", "N", n, n, n, &work[ir], &ldwrkr, &work[
00773 itauq], &work[iu], n, &work[nwork], &i__1, &ierr);
00774 i__1 = *lwork - nwork + 1;
00775 dormbr_("P", "R", "T", n, n, n, &work[ir], &ldwrkr, &work[
00776 itaup], &vt[vt_offset], ldvt, &work[nwork], &i__1, &
00777 ierr);
00778
00779
00780
00781
00782
00783 i__1 = *m;
00784 i__2 = ldwrkr;
00785 for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ +=
00786 i__2) {
00787
00788 i__3 = *m - i__ + 1;
00789 chunk = min(i__3,ldwrkr);
00790 dgemm_("N", "N", &chunk, n, n, &c_b248, &a[i__ + a_dim1],
00791 lda, &work[iu], n, &c_b227, &work[ir], &ldwrkr);
00792 dlacpy_("F", &chunk, n, &work[ir], &ldwrkr, &a[i__ +
00793 a_dim1], lda);
00794
00795 }
00796
00797 } else if (wntqs) {
00798
00799
00800
00801
00802
00803 ir = 1;
00804
00805
00806
00807 ldwrkr = *n;
00808 itau = ir + ldwrkr * *n;
00809 nwork = itau + *n;
00810
00811
00812
00813
00814 i__2 = *lwork - nwork + 1;
00815 dgeqrf_(m, n, &a[a_offset], lda, &work[itau], &work[nwork], &
00816 i__2, &ierr);
00817
00818
00819
00820 dlacpy_("U", n, n, &a[a_offset], lda, &work[ir], &ldwrkr);
00821 i__2 = *n - 1;
00822 i__1 = *n - 1;
00823 dlaset_("L", &i__2, &i__1, &c_b227, &c_b227, &work[ir + 1], &
00824 ldwrkr);
00825
00826
00827
00828
00829 i__2 = *lwork - nwork + 1;
00830 dorgqr_(m, n, n, &a[a_offset], lda, &work[itau], &work[nwork],
00831 &i__2, &ierr);
00832 ie = itau;
00833 itauq = ie + *n;
00834 itaup = itauq + *n;
00835 nwork = itaup + *n;
00836
00837
00838
00839
00840 i__2 = *lwork - nwork + 1;
00841 dgebrd_(n, n, &work[ir], &ldwrkr, &s[1], &work[ie], &work[
00842 itauq], &work[itaup], &work[nwork], &i__2, &ierr);
00843
00844
00845
00846
00847
00848
00849 dbdsdc_("U", "I", n, &s[1], &work[ie], &u[u_offset], ldu, &vt[
00850 vt_offset], ldvt, dum, idum, &work[nwork], &iwork[1],
00851 info);
00852
00853
00854
00855
00856
00857 i__2 = *lwork - nwork + 1;
00858 dormbr_("Q", "L", "N", n, n, n, &work[ir], &ldwrkr, &work[
00859 itauq], &u[u_offset], ldu, &work[nwork], &i__2, &ierr);
00860
00861 i__2 = *lwork - nwork + 1;
00862 dormbr_("P", "R", "T", n, n, n, &work[ir], &ldwrkr, &work[
00863 itaup], &vt[vt_offset], ldvt, &work[nwork], &i__2, &
00864 ierr);
00865
00866
00867
00868
00869
00870 dlacpy_("F", n, n, &u[u_offset], ldu, &work[ir], &ldwrkr);
00871 dgemm_("N", "N", m, n, n, &c_b248, &a[a_offset], lda, &work[
00872 ir], &ldwrkr, &c_b227, &u[u_offset], ldu);
00873
00874 } else if (wntqa) {
00875
00876
00877
00878
00879
00880 iu = 1;
00881
00882
00883
00884 ldwrku = *n;
00885 itau = iu + ldwrku * *n;
00886 nwork = itau + *n;
00887
00888
00889
00890
00891 i__2 = *lwork - nwork + 1;
00892 dgeqrf_(m, n, &a[a_offset], lda, &work[itau], &work[nwork], &
00893 i__2, &ierr);
00894 dlacpy_("L", m, n, &a[a_offset], lda, &u[u_offset], ldu);
00895
00896
00897
00898 i__2 = *lwork - nwork + 1;
00899 dorgqr_(m, m, n, &u[u_offset], ldu, &work[itau], &work[nwork],
00900 &i__2, &ierr);
00901
00902
00903
00904 i__2 = *n - 1;
00905 i__1 = *n - 1;
00906 dlaset_("L", &i__2, &i__1, &c_b227, &c_b227, &a[a_dim1 + 2],
00907 lda);
00908 ie = itau;
00909 itauq = ie + *n;
00910 itaup = itauq + *n;
00911 nwork = itaup + *n;
00912
00913
00914
00915
00916 i__2 = *lwork - nwork + 1;
00917 dgebrd_(n, n, &a[a_offset], lda, &s[1], &work[ie], &work[
00918 itauq], &work[itaup], &work[nwork], &i__2, &ierr);
00919
00920
00921
00922
00923
00924
00925 dbdsdc_("U", "I", n, &s[1], &work[ie], &work[iu], n, &vt[
00926 vt_offset], ldvt, dum, idum, &work[nwork], &iwork[1],
00927 info);
00928
00929
00930
00931
00932
00933 i__2 = *lwork - nwork + 1;
00934 dormbr_("Q", "L", "N", n, n, n, &a[a_offset], lda, &work[
00935 itauq], &work[iu], &ldwrku, &work[nwork], &i__2, &
00936 ierr);
00937 i__2 = *lwork - nwork + 1;
00938 dormbr_("P", "R", "T", n, n, n, &a[a_offset], lda, &work[
00939 itaup], &vt[vt_offset], ldvt, &work[nwork], &i__2, &
00940 ierr);
00941
00942
00943
00944
00945
00946 dgemm_("N", "N", m, n, n, &c_b248, &u[u_offset], ldu, &work[
00947 iu], &ldwrku, &c_b227, &a[a_offset], lda);
00948
00949
00950
00951 dlacpy_("F", m, n, &a[a_offset], lda, &u[u_offset], ldu);
00952
00953 }
00954
00955 } else {
00956
00957
00958
00959
00960
00961
00962 ie = 1;
00963 itauq = ie + *n;
00964 itaup = itauq + *n;
00965 nwork = itaup + *n;
00966
00967
00968
00969
00970 i__2 = *lwork - nwork + 1;
00971 dgebrd_(m, n, &a[a_offset], lda, &s[1], &work[ie], &work[itauq], &
00972 work[itaup], &work[nwork], &i__2, &ierr);
00973 if (wntqn) {
00974
00975
00976
00977
00978 dbdsdc_("U", "N", n, &s[1], &work[ie], dum, &c__1, dum, &c__1,
00979 dum, idum, &work[nwork], &iwork[1], info);
00980 } else if (wntqo) {
00981 iu = nwork;
00982 if (*lwork >= *m * *n + *n * 3 + bdspac) {
00983
00984
00985
00986 ldwrku = *m;
00987 nwork = iu + ldwrku * *n;
00988 dlaset_("F", m, n, &c_b227, &c_b227, &work[iu], &ldwrku);
00989 } else {
00990
00991
00992
00993 ldwrku = *n;
00994 nwork = iu + ldwrku * *n;
00995
00996
00997
00998 ir = nwork;
00999 ldwrkr = (*lwork - *n * *n - *n * 3) / *n;
01000 }
01001 nwork = iu + ldwrku * *n;
01002
01003
01004
01005
01006
01007
01008 dbdsdc_("U", "I", n, &s[1], &work[ie], &work[iu], &ldwrku, &
01009 vt[vt_offset], ldvt, dum, idum, &work[nwork], &iwork[
01010 1], info);
01011
01012
01013
01014
01015 i__2 = *lwork - nwork + 1;
01016 dormbr_("P", "R", "T", n, n, n, &a[a_offset], lda, &work[
01017 itaup], &vt[vt_offset], ldvt, &work[nwork], &i__2, &
01018 ierr);
01019
01020 if (*lwork >= *m * *n + *n * 3 + bdspac) {
01021
01022
01023
01024
01025 i__2 = *lwork - nwork + 1;
01026 dormbr_("Q", "L", "N", m, n, n, &a[a_offset], lda, &work[
01027 itauq], &work[iu], &ldwrku, &work[nwork], &i__2, &
01028 ierr);
01029
01030
01031
01032 dlacpy_("F", m, n, &work[iu], &ldwrku, &a[a_offset], lda);
01033 } else {
01034
01035
01036
01037
01038 i__2 = *lwork - nwork + 1;
01039 dorgbr_("Q", m, n, n, &a[a_offset], lda, &work[itauq], &
01040 work[nwork], &i__2, &ierr);
01041
01042
01043
01044
01045
01046
01047 i__2 = *m;
01048 i__1 = ldwrkr;
01049 for (i__ = 1; i__1 < 0 ? i__ >= i__2 : i__ <= i__2; i__ +=
01050 i__1) {
01051
01052 i__3 = *m - i__ + 1;
01053 chunk = min(i__3,ldwrkr);
01054 dgemm_("N", "N", &chunk, n, n, &c_b248, &a[i__ +
01055 a_dim1], lda, &work[iu], &ldwrku, &c_b227, &
01056 work[ir], &ldwrkr);
01057 dlacpy_("F", &chunk, n, &work[ir], &ldwrkr, &a[i__ +
01058 a_dim1], lda);
01059
01060 }
01061 }
01062
01063 } else if (wntqs) {
01064
01065
01066
01067
01068
01069
01070 dlaset_("F", m, n, &c_b227, &c_b227, &u[u_offset], ldu);
01071 dbdsdc_("U", "I", n, &s[1], &work[ie], &u[u_offset], ldu, &vt[
01072 vt_offset], ldvt, dum, idum, &work[nwork], &iwork[1],
01073 info);
01074
01075
01076
01077
01078
01079 i__1 = *lwork - nwork + 1;
01080 dormbr_("Q", "L", "N", m, n, n, &a[a_offset], lda, &work[
01081 itauq], &u[u_offset], ldu, &work[nwork], &i__1, &ierr);
01082 i__1 = *lwork - nwork + 1;
01083 dormbr_("P", "R", "T", n, n, n, &a[a_offset], lda, &work[
01084 itaup], &vt[vt_offset], ldvt, &work[nwork], &i__1, &
01085 ierr);
01086 } else if (wntqa) {
01087
01088
01089
01090
01091
01092
01093 dlaset_("F", m, m, &c_b227, &c_b227, &u[u_offset], ldu);
01094 dbdsdc_("U", "I", n, &s[1], &work[ie], &u[u_offset], ldu, &vt[
01095 vt_offset], ldvt, dum, idum, &work[nwork], &iwork[1],
01096 info);
01097
01098
01099
01100 if (*m > *n) {
01101 i__1 = *m - *n;
01102 i__2 = *m - *n;
01103 dlaset_("F", &i__1, &i__2, &c_b227, &c_b248, &u[*n + 1 + (
01104 *n + 1) * u_dim1], ldu);
01105 }
01106
01107
01108
01109
01110
01111 i__1 = *lwork - nwork + 1;
01112 dormbr_("Q", "L", "N", m, m, n, &a[a_offset], lda, &work[
01113 itauq], &u[u_offset], ldu, &work[nwork], &i__1, &ierr);
01114 i__1 = *lwork - nwork + 1;
01115 dormbr_("P", "R", "T", n, n, m, &a[a_offset], lda, &work[
01116 itaup], &vt[vt_offset], ldvt, &work[nwork], &i__1, &
01117 ierr);
01118 }
01119
01120 }
01121
01122 } else {
01123
01124
01125
01126
01127
01128 if (*n >= mnthr) {
01129
01130 if (wntqn) {
01131
01132
01133
01134
01135 itau = 1;
01136 nwork = itau + *m;
01137
01138
01139
01140
01141 i__1 = *lwork - nwork + 1;
01142 dgelqf_(m, n, &a[a_offset], lda, &work[itau], &work[nwork], &
01143 i__1, &ierr);
01144
01145
01146
01147 i__1 = *m - 1;
01148 i__2 = *m - 1;
01149 dlaset_("U", &i__1, &i__2, &c_b227, &c_b227, &a[(a_dim1 << 1)
01150 + 1], lda);
01151 ie = 1;
01152 itauq = ie + *m;
01153 itaup = itauq + *m;
01154 nwork = itaup + *m;
01155
01156
01157
01158
01159 i__1 = *lwork - nwork + 1;
01160 dgebrd_(m, m, &a[a_offset], lda, &s[1], &work[ie], &work[
01161 itauq], &work[itaup], &work[nwork], &i__1, &ierr);
01162 nwork = ie + *m;
01163
01164
01165
01166
01167 dbdsdc_("U", "N", m, &s[1], &work[ie], dum, &c__1, dum, &c__1,
01168 dum, idum, &work[nwork], &iwork[1], info);
01169
01170 } else if (wntqo) {
01171
01172
01173
01174
01175
01176 ivt = 1;
01177
01178
01179
01180 il = ivt + *m * *m;
01181 if (*lwork >= *m * *n + *m * *m + *m * 3 + bdspac) {
01182
01183
01184
01185 ldwrkl = *m;
01186 chunk = *n;
01187 } else {
01188 ldwrkl = *m;
01189 chunk = (*lwork - *m * *m) / *m;
01190 }
01191 itau = il + ldwrkl * *m;
01192 nwork = itau + *m;
01193
01194
01195
01196
01197 i__1 = *lwork - nwork + 1;
01198 dgelqf_(m, n, &a[a_offset], lda, &work[itau], &work[nwork], &
01199 i__1, &ierr);
01200
01201
01202
01203 dlacpy_("L", m, m, &a[a_offset], lda, &work[il], &ldwrkl);
01204 i__1 = *m - 1;
01205 i__2 = *m - 1;
01206 dlaset_("U", &i__1, &i__2, &c_b227, &c_b227, &work[il +
01207 ldwrkl], &ldwrkl);
01208
01209
01210
01211
01212 i__1 = *lwork - nwork + 1;
01213 dorglq_(m, n, m, &a[a_offset], lda, &work[itau], &work[nwork],
01214 &i__1, &ierr);
01215 ie = itau;
01216 itauq = ie + *m;
01217 itaup = itauq + *m;
01218 nwork = itaup + *m;
01219
01220
01221
01222
01223 i__1 = *lwork - nwork + 1;
01224 dgebrd_(m, m, &work[il], &ldwrkl, &s[1], &work[ie], &work[
01225 itauq], &work[itaup], &work[nwork], &i__1, &ierr);
01226
01227
01228
01229
01230
01231
01232 dbdsdc_("U", "I", m, &s[1], &work[ie], &u[u_offset], ldu, &
01233 work[ivt], m, dum, idum, &work[nwork], &iwork[1],
01234 info);
01235
01236
01237
01238
01239
01240 i__1 = *lwork - nwork + 1;
01241 dormbr_("Q", "L", "N", m, m, m, &work[il], &ldwrkl, &work[
01242 itauq], &u[u_offset], ldu, &work[nwork], &i__1, &ierr);
01243 i__1 = *lwork - nwork + 1;
01244 dormbr_("P", "R", "T", m, m, m, &work[il], &ldwrkl, &work[
01245 itaup], &work[ivt], m, &work[nwork], &i__1, &ierr);
01246
01247
01248
01249
01250
01251 i__1 = *n;
01252 i__2 = chunk;
01253 for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ +=
01254 i__2) {
01255
01256 i__3 = *n - i__ + 1;
01257 blk = min(i__3,chunk);
01258 dgemm_("N", "N", m, &blk, m, &c_b248, &work[ivt], m, &a[
01259 i__ * a_dim1 + 1], lda, &c_b227, &work[il], &
01260 ldwrkl);
01261 dlacpy_("F", m, &blk, &work[il], &ldwrkl, &a[i__ * a_dim1
01262 + 1], lda);
01263
01264 }
01265
01266 } else if (wntqs) {
01267
01268
01269
01270
01271
01272 il = 1;
01273
01274
01275
01276 ldwrkl = *m;
01277 itau = il + ldwrkl * *m;
01278 nwork = itau + *m;
01279
01280
01281
01282
01283 i__2 = *lwork - nwork + 1;
01284 dgelqf_(m, n, &a[a_offset], lda, &work[itau], &work[nwork], &
01285 i__2, &ierr);
01286
01287
01288
01289 dlacpy_("L", m, m, &a[a_offset], lda, &work[il], &ldwrkl);
01290 i__2 = *m - 1;
01291 i__1 = *m - 1;
01292 dlaset_("U", &i__2, &i__1, &c_b227, &c_b227, &work[il +
01293 ldwrkl], &ldwrkl);
01294
01295
01296
01297
01298 i__2 = *lwork - nwork + 1;
01299 dorglq_(m, n, m, &a[a_offset], lda, &work[itau], &work[nwork],
01300 &i__2, &ierr);
01301 ie = itau;
01302 itauq = ie + *m;
01303 itaup = itauq + *m;
01304 nwork = itaup + *m;
01305
01306
01307
01308
01309 i__2 = *lwork - nwork + 1;
01310 dgebrd_(m, m, &work[il], &ldwrkl, &s[1], &work[ie], &work[
01311 itauq], &work[itaup], &work[nwork], &i__2, &ierr);
01312
01313
01314
01315
01316
01317
01318 dbdsdc_("U", "I", m, &s[1], &work[ie], &u[u_offset], ldu, &vt[
01319 vt_offset], ldvt, dum, idum, &work[nwork], &iwork[1],
01320 info);
01321
01322
01323
01324
01325
01326 i__2 = *lwork - nwork + 1;
01327 dormbr_("Q", "L", "N", m, m, m, &work[il], &ldwrkl, &work[
01328 itauq], &u[u_offset], ldu, &work[nwork], &i__2, &ierr);
01329 i__2 = *lwork - nwork + 1;
01330 dormbr_("P", "R", "T", m, m, m, &work[il], &ldwrkl, &work[
01331 itaup], &vt[vt_offset], ldvt, &work[nwork], &i__2, &
01332 ierr);
01333
01334
01335
01336
01337
01338 dlacpy_("F", m, m, &vt[vt_offset], ldvt, &work[il], &ldwrkl);
01339 dgemm_("N", "N", m, n, m, &c_b248, &work[il], &ldwrkl, &a[
01340 a_offset], lda, &c_b227, &vt[vt_offset], ldvt);
01341
01342 } else if (wntqa) {
01343
01344
01345
01346
01347
01348 ivt = 1;
01349
01350
01351
01352 ldwkvt = *m;
01353 itau = ivt + ldwkvt * *m;
01354 nwork = itau + *m;
01355
01356
01357
01358
01359 i__2 = *lwork - nwork + 1;
01360 dgelqf_(m, n, &a[a_offset], lda, &work[itau], &work[nwork], &
01361 i__2, &ierr);
01362 dlacpy_("U", m, n, &a[a_offset], lda, &vt[vt_offset], ldvt);
01363
01364
01365
01366
01367 i__2 = *lwork - nwork + 1;
01368 dorglq_(n, n, m, &vt[vt_offset], ldvt, &work[itau], &work[
01369 nwork], &i__2, &ierr);
01370
01371
01372
01373 i__2 = *m - 1;
01374 i__1 = *m - 1;
01375 dlaset_("U", &i__2, &i__1, &c_b227, &c_b227, &a[(a_dim1 << 1)
01376 + 1], lda);
01377 ie = itau;
01378 itauq = ie + *m;
01379 itaup = itauq + *m;
01380 nwork = itaup + *m;
01381
01382
01383
01384
01385 i__2 = *lwork - nwork + 1;
01386 dgebrd_(m, m, &a[a_offset], lda, &s[1], &work[ie], &work[
01387 itauq], &work[itaup], &work[nwork], &i__2, &ierr);
01388
01389
01390
01391
01392
01393
01394 dbdsdc_("U", "I", m, &s[1], &work[ie], &u[u_offset], ldu, &
01395 work[ivt], &ldwkvt, dum, idum, &work[nwork], &iwork[1]
01396 , info);
01397
01398
01399
01400
01401
01402 i__2 = *lwork - nwork + 1;
01403 dormbr_("Q", "L", "N", m, m, m, &a[a_offset], lda, &work[
01404 itauq], &u[u_offset], ldu, &work[nwork], &i__2, &ierr);
01405 i__2 = *lwork - nwork + 1;
01406 dormbr_("P", "R", "T", m, m, m, &a[a_offset], lda, &work[
01407 itaup], &work[ivt], &ldwkvt, &work[nwork], &i__2, &
01408 ierr);
01409
01410
01411
01412
01413
01414 dgemm_("N", "N", m, n, m, &c_b248, &work[ivt], &ldwkvt, &vt[
01415 vt_offset], ldvt, &c_b227, &a[a_offset], lda);
01416
01417
01418
01419 dlacpy_("F", m, n, &a[a_offset], lda, &vt[vt_offset], ldvt);
01420
01421 }
01422
01423 } else {
01424
01425
01426
01427
01428
01429
01430 ie = 1;
01431 itauq = ie + *m;
01432 itaup = itauq + *m;
01433 nwork = itaup + *m;
01434
01435
01436
01437
01438 i__2 = *lwork - nwork + 1;
01439 dgebrd_(m, n, &a[a_offset], lda, &s[1], &work[ie], &work[itauq], &
01440 work[itaup], &work[nwork], &i__2, &ierr);
01441 if (wntqn) {
01442
01443
01444
01445
01446 dbdsdc_("L", "N", m, &s[1], &work[ie], dum, &c__1, dum, &c__1,
01447 dum, idum, &work[nwork], &iwork[1], info);
01448 } else if (wntqo) {
01449 ldwkvt = *m;
01450 ivt = nwork;
01451 if (*lwork >= *m * *n + *m * 3 + bdspac) {
01452
01453
01454
01455 dlaset_("F", m, n, &c_b227, &c_b227, &work[ivt], &ldwkvt);
01456 nwork = ivt + ldwkvt * *n;
01457 } else {
01458
01459
01460
01461 nwork = ivt + ldwkvt * *m;
01462 il = nwork;
01463
01464
01465
01466 chunk = (*lwork - *m * *m - *m * 3) / *m;
01467 }
01468
01469
01470
01471
01472
01473
01474 dbdsdc_("L", "I", m, &s[1], &work[ie], &u[u_offset], ldu, &
01475 work[ivt], &ldwkvt, dum, idum, &work[nwork], &iwork[1]
01476 , info);
01477
01478
01479
01480
01481 i__2 = *lwork - nwork + 1;
01482 dormbr_("Q", "L", "N", m, m, n, &a[a_offset], lda, &work[
01483 itauq], &u[u_offset], ldu, &work[nwork], &i__2, &ierr);
01484
01485 if (*lwork >= *m * *n + *m * 3 + bdspac) {
01486
01487
01488
01489
01490 i__2 = *lwork - nwork + 1;
01491 dormbr_("P", "R", "T", m, n, m, &a[a_offset], lda, &work[
01492 itaup], &work[ivt], &ldwkvt, &work[nwork], &i__2,
01493 &ierr);
01494
01495
01496
01497 dlacpy_("F", m, n, &work[ivt], &ldwkvt, &a[a_offset], lda);
01498 } else {
01499
01500
01501
01502
01503 i__2 = *lwork - nwork + 1;
01504 dorgbr_("P", m, n, m, &a[a_offset], lda, &work[itaup], &
01505 work[nwork], &i__2, &ierr);
01506
01507
01508
01509
01510
01511
01512 i__2 = *n;
01513 i__1 = chunk;
01514 for (i__ = 1; i__1 < 0 ? i__ >= i__2 : i__ <= i__2; i__ +=
01515 i__1) {
01516
01517 i__3 = *n - i__ + 1;
01518 blk = min(i__3,chunk);
01519 dgemm_("N", "N", m, &blk, m, &c_b248, &work[ivt], &
01520 ldwkvt, &a[i__ * a_dim1 + 1], lda, &c_b227, &
01521 work[il], m);
01522 dlacpy_("F", m, &blk, &work[il], m, &a[i__ * a_dim1 +
01523 1], lda);
01524
01525 }
01526 }
01527 } else if (wntqs) {
01528
01529
01530
01531
01532
01533
01534 dlaset_("F", m, n, &c_b227, &c_b227, &vt[vt_offset], ldvt);
01535 dbdsdc_("L", "I", m, &s[1], &work[ie], &u[u_offset], ldu, &vt[
01536 vt_offset], ldvt, dum, idum, &work[nwork], &iwork[1],
01537 info);
01538
01539
01540
01541
01542
01543 i__1 = *lwork - nwork + 1;
01544 dormbr_("Q", "L", "N", m, m, n, &a[a_offset], lda, &work[
01545 itauq], &u[u_offset], ldu, &work[nwork], &i__1, &ierr);
01546 i__1 = *lwork - nwork + 1;
01547 dormbr_("P", "R", "T", m, n, m, &a[a_offset], lda, &work[
01548 itaup], &vt[vt_offset], ldvt, &work[nwork], &i__1, &
01549 ierr);
01550 } else if (wntqa) {
01551
01552
01553
01554
01555
01556
01557 dlaset_("F", n, n, &c_b227, &c_b227, &vt[vt_offset], ldvt);
01558 dbdsdc_("L", "I", m, &s[1], &work[ie], &u[u_offset], ldu, &vt[
01559 vt_offset], ldvt, dum, idum, &work[nwork], &iwork[1],
01560 info);
01561
01562
01563
01564 if (*n > *m) {
01565 i__1 = *n - *m;
01566 i__2 = *n - *m;
01567 dlaset_("F", &i__1, &i__2, &c_b227, &c_b248, &vt[*m + 1 +
01568 (*m + 1) * vt_dim1], ldvt);
01569 }
01570
01571
01572
01573
01574
01575 i__1 = *lwork - nwork + 1;
01576 dormbr_("Q", "L", "N", m, m, n, &a[a_offset], lda, &work[
01577 itauq], &u[u_offset], ldu, &work[nwork], &i__1, &ierr);
01578 i__1 = *lwork - nwork + 1;
01579 dormbr_("P", "R", "T", n, n, m, &a[a_offset], lda, &work[
01580 itaup], &vt[vt_offset], ldvt, &work[nwork], &i__1, &
01581 ierr);
01582 }
01583
01584 }
01585
01586 }
01587
01588
01589
01590 if (iscl == 1) {
01591 if (anrm > bignum) {
01592 dlascl_("G", &c__0, &c__0, &bignum, &anrm, &minmn, &c__1, &s[1], &
01593 minmn, &ierr);
01594 }
01595 if (anrm < smlnum) {
01596 dlascl_("G", &c__0, &c__0, &smlnum, &anrm, &minmn, &c__1, &s[1], &
01597 minmn, &ierr);
01598 }
01599 }
01600
01601
01602
01603 work[1] = (doublereal) maxwrk;
01604
01605 return 0;
01606
01607
01608
01609 }