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__0 = 0;
00019 static doublereal c_b11 = 0.;
00020 static doublereal c_b12 = 1.;
00021 static integer c__1 = 1;
00022 static integer c__2 = 2;
00023
00024 int dlasda_(integer *icompq, integer *smlsiz, integer *n,
00025 integer *sqre, doublereal *d__, doublereal *e, doublereal *u, integer
00026 *ldu, doublereal *vt, integer *k, doublereal *difl, doublereal *difr,
00027 doublereal *z__, doublereal *poles, integer *givptr, integer *givcol,
00028 integer *ldgcol, integer *perm, doublereal *givnum, doublereal *c__,
00029 doublereal *s, doublereal *work, integer *iwork, integer *info)
00030 {
00031
00032 integer givcol_dim1, givcol_offset, perm_dim1, perm_offset, difl_dim1,
00033 difl_offset, difr_dim1, difr_offset, givnum_dim1, givnum_offset,
00034 poles_dim1, poles_offset, u_dim1, u_offset, vt_dim1, vt_offset,
00035 z_dim1, z_offset, i__1, i__2;
00036
00037
00038 integer pow_ii(integer *, integer *);
00039
00040
00041 integer i__, j, m, i1, ic, lf, nd, ll, nl, vf, nr, vl, im1, ncc, nlf, nrf,
00042 vfi, iwk, vli, lvl, nru, ndb1, nlp1, lvl2, nrp1;
00043 doublereal beta;
00044 integer idxq, nlvl;
00045 doublereal alpha;
00046 integer inode, ndiml, ndimr, idxqi, itemp;
00047 extern int dcopy_(integer *, doublereal *, integer *,
00048 doublereal *, integer *);
00049 integer sqrei;
00050 extern int dlasd6_(integer *, integer *, integer *,
00051 integer *, doublereal *, doublereal *, doublereal *, doublereal *,
00052 doublereal *, integer *, integer *, integer *, integer *,
00053 integer *, doublereal *, integer *, doublereal *, doublereal *,
00054 doublereal *, doublereal *, integer *, doublereal *, doublereal *,
00055 doublereal *, integer *, integer *);
00056 integer nwork1, nwork2;
00057 extern int dlasdq_(char *, integer *, integer *, integer
00058 *, integer *, integer *, doublereal *, doublereal *, doublereal *,
00059 integer *, doublereal *, integer *, doublereal *, integer *,
00060 doublereal *, integer *), dlasdt_(integer *, integer *,
00061 integer *, integer *, integer *, integer *, integer *), dlaset_(
00062 char *, integer *, integer *, doublereal *, doublereal *,
00063 doublereal *, integer *), xerbla_(char *, integer *);
00064 integer smlszp;
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
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 --d__;
00238 --e;
00239 givnum_dim1 = *ldu;
00240 givnum_offset = 1 + givnum_dim1;
00241 givnum -= givnum_offset;
00242 poles_dim1 = *ldu;
00243 poles_offset = 1 + poles_dim1;
00244 poles -= poles_offset;
00245 z_dim1 = *ldu;
00246 z_offset = 1 + z_dim1;
00247 z__ -= z_offset;
00248 difr_dim1 = *ldu;
00249 difr_offset = 1 + difr_dim1;
00250 difr -= difr_offset;
00251 difl_dim1 = *ldu;
00252 difl_offset = 1 + difl_dim1;
00253 difl -= difl_offset;
00254 vt_dim1 = *ldu;
00255 vt_offset = 1 + vt_dim1;
00256 vt -= vt_offset;
00257 u_dim1 = *ldu;
00258 u_offset = 1 + u_dim1;
00259 u -= u_offset;
00260 --k;
00261 --givptr;
00262 perm_dim1 = *ldgcol;
00263 perm_offset = 1 + perm_dim1;
00264 perm -= perm_offset;
00265 givcol_dim1 = *ldgcol;
00266 givcol_offset = 1 + givcol_dim1;
00267 givcol -= givcol_offset;
00268 --c__;
00269 --s;
00270 --work;
00271 --iwork;
00272
00273
00274 *info = 0;
00275
00276 if (*icompq < 0 || *icompq > 1) {
00277 *info = -1;
00278 } else if (*smlsiz < 3) {
00279 *info = -2;
00280 } else if (*n < 0) {
00281 *info = -3;
00282 } else if (*sqre < 0 || *sqre > 1) {
00283 *info = -4;
00284 } else if (*ldu < *n + *sqre) {
00285 *info = -8;
00286 } else if (*ldgcol < *n) {
00287 *info = -17;
00288 }
00289 if (*info != 0) {
00290 i__1 = -(*info);
00291 xerbla_("DLASDA", &i__1);
00292 return 0;
00293 }
00294
00295 m = *n + *sqre;
00296
00297
00298
00299 if (*n <= *smlsiz) {
00300 if (*icompq == 0) {
00301 dlasdq_("U", sqre, n, &c__0, &c__0, &c__0, &d__[1], &e[1], &vt[
00302 vt_offset], ldu, &u[u_offset], ldu, &u[u_offset], ldu, &
00303 work[1], info);
00304 } else {
00305 dlasdq_("U", sqre, n, &m, n, &c__0, &d__[1], &e[1], &vt[vt_offset]
00306 , ldu, &u[u_offset], ldu, &u[u_offset], ldu, &work[1],
00307 info);
00308 }
00309 return 0;
00310 }
00311
00312
00313
00314 inode = 1;
00315 ndiml = inode + *n;
00316 ndimr = ndiml + *n;
00317 idxq = ndimr + *n;
00318 iwk = idxq + *n;
00319
00320 ncc = 0;
00321 nru = 0;
00322
00323 smlszp = *smlsiz + 1;
00324 vf = 1;
00325 vl = vf + m;
00326 nwork1 = vl + m;
00327 nwork2 = nwork1 + smlszp * smlszp;
00328
00329 dlasdt_(n, &nlvl, &nd, &iwork[inode], &iwork[ndiml], &iwork[ndimr],
00330 smlsiz);
00331
00332
00333
00334
00335 ndb1 = (nd + 1) / 2;
00336 i__1 = nd;
00337 for (i__ = ndb1; i__ <= i__1; ++i__) {
00338
00339
00340
00341
00342
00343
00344
00345 i1 = i__ - 1;
00346 ic = iwork[inode + i1];
00347 nl = iwork[ndiml + i1];
00348 nlp1 = nl + 1;
00349 nr = iwork[ndimr + i1];
00350 nlf = ic - nl;
00351 nrf = ic + 1;
00352 idxqi = idxq + nlf - 2;
00353 vfi = vf + nlf - 1;
00354 vli = vl + nlf - 1;
00355 sqrei = 1;
00356 if (*icompq == 0) {
00357 dlaset_("A", &nlp1, &nlp1, &c_b11, &c_b12, &work[nwork1], &smlszp);
00358 dlasdq_("U", &sqrei, &nl, &nlp1, &nru, &ncc, &d__[nlf], &e[nlf], &
00359 work[nwork1], &smlszp, &work[nwork2], &nl, &work[nwork2],
00360 &nl, &work[nwork2], info);
00361 itemp = nwork1 + nl * smlszp;
00362 dcopy_(&nlp1, &work[nwork1], &c__1, &work[vfi], &c__1);
00363 dcopy_(&nlp1, &work[itemp], &c__1, &work[vli], &c__1);
00364 } else {
00365 dlaset_("A", &nl, &nl, &c_b11, &c_b12, &u[nlf + u_dim1], ldu);
00366 dlaset_("A", &nlp1, &nlp1, &c_b11, &c_b12, &vt[nlf + vt_dim1],
00367 ldu);
00368 dlasdq_("U", &sqrei, &nl, &nlp1, &nl, &ncc, &d__[nlf], &e[nlf], &
00369 vt[nlf + vt_dim1], ldu, &u[nlf + u_dim1], ldu, &u[nlf +
00370 u_dim1], ldu, &work[nwork1], info);
00371 dcopy_(&nlp1, &vt[nlf + vt_dim1], &c__1, &work[vfi], &c__1);
00372 dcopy_(&nlp1, &vt[nlf + nlp1 * vt_dim1], &c__1, &work[vli], &c__1)
00373 ;
00374 }
00375 if (*info != 0) {
00376 return 0;
00377 }
00378 i__2 = nl;
00379 for (j = 1; j <= i__2; ++j) {
00380 iwork[idxqi + j] = j;
00381
00382 }
00383 if (i__ == nd && *sqre == 0) {
00384 sqrei = 0;
00385 } else {
00386 sqrei = 1;
00387 }
00388 idxqi += nlp1;
00389 vfi += nlp1;
00390 vli += nlp1;
00391 nrp1 = nr + sqrei;
00392 if (*icompq == 0) {
00393 dlaset_("A", &nrp1, &nrp1, &c_b11, &c_b12, &work[nwork1], &smlszp);
00394 dlasdq_("U", &sqrei, &nr, &nrp1, &nru, &ncc, &d__[nrf], &e[nrf], &
00395 work[nwork1], &smlszp, &work[nwork2], &nr, &work[nwork2],
00396 &nr, &work[nwork2], info);
00397 itemp = nwork1 + (nrp1 - 1) * smlszp;
00398 dcopy_(&nrp1, &work[nwork1], &c__1, &work[vfi], &c__1);
00399 dcopy_(&nrp1, &work[itemp], &c__1, &work[vli], &c__1);
00400 } else {
00401 dlaset_("A", &nr, &nr, &c_b11, &c_b12, &u[nrf + u_dim1], ldu);
00402 dlaset_("A", &nrp1, &nrp1, &c_b11, &c_b12, &vt[nrf + vt_dim1],
00403 ldu);
00404 dlasdq_("U", &sqrei, &nr, &nrp1, &nr, &ncc, &d__[nrf], &e[nrf], &
00405 vt[nrf + vt_dim1], ldu, &u[nrf + u_dim1], ldu, &u[nrf +
00406 u_dim1], ldu, &work[nwork1], info);
00407 dcopy_(&nrp1, &vt[nrf + vt_dim1], &c__1, &work[vfi], &c__1);
00408 dcopy_(&nrp1, &vt[nrf + nrp1 * vt_dim1], &c__1, &work[vli], &c__1)
00409 ;
00410 }
00411 if (*info != 0) {
00412 return 0;
00413 }
00414 i__2 = nr;
00415 for (j = 1; j <= i__2; ++j) {
00416 iwork[idxqi + j] = j;
00417
00418 }
00419
00420 }
00421
00422
00423
00424 j = pow_ii(&c__2, &nlvl);
00425 for (lvl = nlvl; lvl >= 1; --lvl) {
00426 lvl2 = (lvl << 1) - 1;
00427
00428
00429
00430
00431 if (lvl == 1) {
00432 lf = 1;
00433 ll = 1;
00434 } else {
00435 i__1 = lvl - 1;
00436 lf = pow_ii(&c__2, &i__1);
00437 ll = (lf << 1) - 1;
00438 }
00439 i__1 = ll;
00440 for (i__ = lf; i__ <= i__1; ++i__) {
00441 im1 = i__ - 1;
00442 ic = iwork[inode + im1];
00443 nl = iwork[ndiml + im1];
00444 nr = iwork[ndimr + im1];
00445 nlf = ic - nl;
00446 nrf = ic + 1;
00447 if (i__ == ll) {
00448 sqrei = *sqre;
00449 } else {
00450 sqrei = 1;
00451 }
00452 vfi = vf + nlf - 1;
00453 vli = vl + nlf - 1;
00454 idxqi = idxq + nlf - 1;
00455 alpha = d__[ic];
00456 beta = e[ic];
00457 if (*icompq == 0) {
00458 dlasd6_(icompq, &nl, &nr, &sqrei, &d__[nlf], &work[vfi], &
00459 work[vli], &alpha, &beta, &iwork[idxqi], &perm[
00460 perm_offset], &givptr[1], &givcol[givcol_offset],
00461 ldgcol, &givnum[givnum_offset], ldu, &poles[
00462 poles_offset], &difl[difl_offset], &difr[difr_offset],
00463 &z__[z_offset], &k[1], &c__[1], &s[1], &work[nwork1],
00464 &iwork[iwk], info);
00465 } else {
00466 --j;
00467 dlasd6_(icompq, &nl, &nr, &sqrei, &d__[nlf], &work[vfi], &
00468 work[vli], &alpha, &beta, &iwork[idxqi], &perm[nlf +
00469 lvl * perm_dim1], &givptr[j], &givcol[nlf + lvl2 *
00470 givcol_dim1], ldgcol, &givnum[nlf + lvl2 *
00471 givnum_dim1], ldu, &poles[nlf + lvl2 * poles_dim1], &
00472 difl[nlf + lvl * difl_dim1], &difr[nlf + lvl2 *
00473 difr_dim1], &z__[nlf + lvl * z_dim1], &k[j], &c__[j],
00474 &s[j], &work[nwork1], &iwork[iwk], info);
00475 }
00476 if (*info != 0) {
00477 return 0;
00478 }
00479
00480 }
00481
00482 }
00483
00484 return 0;
00485
00486
00487
00488 }