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__9 = 9;
00019 static integer c__0 = 0;
00020 static integer c__2 = 2;
00021 static doublereal c_b23 = 1.;
00022 static doublereal c_b24 = 0.;
00023 static integer c__1 = 1;
00024
00025 int dlaed0_(integer *icompq, integer *qsiz, integer *n,
00026 doublereal *d__, doublereal *e, doublereal *q, integer *ldq,
00027 doublereal *qstore, integer *ldqs, doublereal *work, integer *iwork,
00028 integer *info)
00029 {
00030
00031 integer q_dim1, q_offset, qstore_dim1, qstore_offset, i__1, i__2;
00032 doublereal d__1;
00033
00034
00035 double log(doublereal);
00036 integer pow_ii(integer *, integer *);
00037
00038
00039 integer i__, j, k, iq, lgn, msd2, smm1, spm1, spm2;
00040 doublereal temp;
00041 integer curr;
00042 extern int dgemm_(char *, char *, integer *, integer *,
00043 integer *, doublereal *, doublereal *, integer *, doublereal *,
00044 integer *, doublereal *, doublereal *, integer *);
00045 integer iperm;
00046 extern int dcopy_(integer *, doublereal *, integer *,
00047 doublereal *, integer *);
00048 integer indxq, iwrem;
00049 extern int dlaed1_(integer *, doublereal *, doublereal *,
00050 integer *, integer *, doublereal *, integer *, doublereal *,
00051 integer *, integer *);
00052 integer iqptr;
00053 extern int dlaed7_(integer *, integer *, integer *,
00054 integer *, integer *, integer *, doublereal *, doublereal *,
00055 integer *, integer *, doublereal *, integer *, doublereal *,
00056 integer *, integer *, integer *, integer *, integer *, doublereal
00057 *, doublereal *, integer *, integer *);
00058 integer tlvls;
00059 extern int dlacpy_(char *, integer *, integer *,
00060 doublereal *, integer *, doublereal *, integer *);
00061 integer igivcl;
00062 extern int xerbla_(char *, integer *);
00063 extern integer ilaenv_(integer *, char *, char *, integer *, integer *,
00064 integer *, integer *);
00065 integer igivnm, submat, curprb, subpbs, igivpt;
00066 extern int dsteqr_(char *, integer *, doublereal *,
00067 doublereal *, doublereal *, integer *, doublereal *, integer *);
00068 integer curlvl, matsiz, iprmpt, smlsiz;
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 --d__;
00185 --e;
00186 q_dim1 = *ldq;
00187 q_offset = 1 + q_dim1;
00188 q -= q_offset;
00189 qstore_dim1 = *ldqs;
00190 qstore_offset = 1 + qstore_dim1;
00191 qstore -= qstore_offset;
00192 --work;
00193 --iwork;
00194
00195
00196 *info = 0;
00197
00198 if (*icompq < 0 || *icompq > 2) {
00199 *info = -1;
00200 } else if (*icompq == 1 && *qsiz < max(0,*n)) {
00201 *info = -2;
00202 } else if (*n < 0) {
00203 *info = -3;
00204 } else if (*ldq < max(1,*n)) {
00205 *info = -7;
00206 } else if (*ldqs < max(1,*n)) {
00207 *info = -9;
00208 }
00209 if (*info != 0) {
00210 i__1 = -(*info);
00211 xerbla_("DLAED0", &i__1);
00212 return 0;
00213 }
00214
00215
00216
00217 if (*n == 0) {
00218 return 0;
00219 }
00220
00221 smlsiz = ilaenv_(&c__9, "DLAED0", " ", &c__0, &c__0, &c__0, &c__0);
00222
00223
00224
00225
00226 iwork[1] = *n;
00227 subpbs = 1;
00228 tlvls = 0;
00229 L10:
00230 if (iwork[subpbs] > smlsiz) {
00231 for (j = subpbs; j >= 1; --j) {
00232 iwork[j * 2] = (iwork[j] + 1) / 2;
00233 iwork[(j << 1) - 1] = iwork[j] / 2;
00234
00235 }
00236 ++tlvls;
00237 subpbs <<= 1;
00238 goto L10;
00239 }
00240 i__1 = subpbs;
00241 for (j = 2; j <= i__1; ++j) {
00242 iwork[j] += iwork[j - 1];
00243
00244 }
00245
00246
00247
00248
00249 spm1 = subpbs - 1;
00250 i__1 = spm1;
00251 for (i__ = 1; i__ <= i__1; ++i__) {
00252 submat = iwork[i__] + 1;
00253 smm1 = submat - 1;
00254 d__[smm1] -= (d__1 = e[smm1], abs(d__1));
00255 d__[submat] -= (d__1 = e[smm1], abs(d__1));
00256
00257 }
00258
00259 indxq = (*n << 2) + 3;
00260 if (*icompq != 2) {
00261
00262
00263
00264
00265 temp = log((doublereal) (*n)) / log(2.);
00266 lgn = (integer) temp;
00267 if (pow_ii(&c__2, &lgn) < *n) {
00268 ++lgn;
00269 }
00270 if (pow_ii(&c__2, &lgn) < *n) {
00271 ++lgn;
00272 }
00273 iprmpt = indxq + *n + 1;
00274 iperm = iprmpt + *n * lgn;
00275 iqptr = iperm + *n * lgn;
00276 igivpt = iqptr + *n + 2;
00277 igivcl = igivpt + *n * lgn;
00278
00279 igivnm = 1;
00280 iq = igivnm + (*n << 1) * lgn;
00281
00282 i__1 = *n;
00283 iwrem = iq + i__1 * i__1 + 1;
00284
00285
00286
00287 i__1 = subpbs;
00288 for (i__ = 0; i__ <= i__1; ++i__) {
00289 iwork[iprmpt + i__] = 1;
00290 iwork[igivpt + i__] = 1;
00291
00292 }
00293 iwork[iqptr] = 1;
00294 }
00295
00296
00297
00298
00299 curr = 0;
00300 i__1 = spm1;
00301 for (i__ = 0; i__ <= i__1; ++i__) {
00302 if (i__ == 0) {
00303 submat = 1;
00304 matsiz = iwork[1];
00305 } else {
00306 submat = iwork[i__] + 1;
00307 matsiz = iwork[i__ + 1] - iwork[i__];
00308 }
00309 if (*icompq == 2) {
00310 dsteqr_("I", &matsiz, &d__[submat], &e[submat], &q[submat +
00311 submat * q_dim1], ldq, &work[1], info);
00312 if (*info != 0) {
00313 goto L130;
00314 }
00315 } else {
00316 dsteqr_("I", &matsiz, &d__[submat], &e[submat], &work[iq - 1 +
00317 iwork[iqptr + curr]], &matsiz, &work[1], info);
00318 if (*info != 0) {
00319 goto L130;
00320 }
00321 if (*icompq == 1) {
00322 dgemm_("N", "N", qsiz, &matsiz, &matsiz, &c_b23, &q[submat *
00323 q_dim1 + 1], ldq, &work[iq - 1 + iwork[iqptr + curr]],
00324 &matsiz, &c_b24, &qstore[submat * qstore_dim1 + 1],
00325 ldqs);
00326 }
00327
00328 i__2 = matsiz;
00329 iwork[iqptr + curr + 1] = iwork[iqptr + curr] + i__2 * i__2;
00330 ++curr;
00331 }
00332 k = 1;
00333 i__2 = iwork[i__ + 1];
00334 for (j = submat; j <= i__2; ++j) {
00335 iwork[indxq + j] = k;
00336 ++k;
00337
00338 }
00339
00340 }
00341
00342
00343
00344
00345
00346
00347 curlvl = 1;
00348 L80:
00349 if (subpbs > 1) {
00350 spm2 = subpbs - 2;
00351 i__1 = spm2;
00352 for (i__ = 0; i__ <= i__1; i__ += 2) {
00353 if (i__ == 0) {
00354 submat = 1;
00355 matsiz = iwork[2];
00356 msd2 = iwork[1];
00357 curprb = 0;
00358 } else {
00359 submat = iwork[i__] + 1;
00360 matsiz = iwork[i__ + 2] - iwork[i__];
00361 msd2 = matsiz / 2;
00362 ++curprb;
00363 }
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373 if (*icompq == 2) {
00374 dlaed1_(&matsiz, &d__[submat], &q[submat + submat * q_dim1],
00375 ldq, &iwork[indxq + submat], &e[submat + msd2 - 1], &
00376 msd2, &work[1], &iwork[subpbs + 1], info);
00377 } else {
00378 dlaed7_(icompq, &matsiz, qsiz, &tlvls, &curlvl, &curprb, &d__[
00379 submat], &qstore[submat * qstore_dim1 + 1], ldqs, &
00380 iwork[indxq + submat], &e[submat + msd2 - 1], &msd2, &
00381 work[iq], &iwork[iqptr], &iwork[iprmpt], &iwork[iperm]
00382 , &iwork[igivpt], &iwork[igivcl], &work[igivnm], &
00383 work[iwrem], &iwork[subpbs + 1], info);
00384 }
00385 if (*info != 0) {
00386 goto L130;
00387 }
00388 iwork[i__ / 2 + 1] = iwork[i__ + 2];
00389
00390 }
00391 subpbs /= 2;
00392 ++curlvl;
00393 goto L80;
00394 }
00395
00396
00397
00398
00399
00400
00401 if (*icompq == 1) {
00402 i__1 = *n;
00403 for (i__ = 1; i__ <= i__1; ++i__) {
00404 j = iwork[indxq + i__];
00405 work[i__] = d__[j];
00406 dcopy_(qsiz, &qstore[j * qstore_dim1 + 1], &c__1, &q[i__ * q_dim1
00407 + 1], &c__1);
00408
00409 }
00410 dcopy_(n, &work[1], &c__1, &d__[1], &c__1);
00411 } else if (*icompq == 2) {
00412 i__1 = *n;
00413 for (i__ = 1; i__ <= i__1; ++i__) {
00414 j = iwork[indxq + i__];
00415 work[i__] = d__[j];
00416 dcopy_(n, &q[j * q_dim1 + 1], &c__1, &work[*n * i__ + 1], &c__1);
00417
00418 }
00419 dcopy_(n, &work[1], &c__1, &d__[1], &c__1);
00420 dlacpy_("A", n, n, &work[*n + 1], n, &q[q_offset], ldq);
00421 } else {
00422 i__1 = *n;
00423 for (i__ = 1; i__ <= i__1; ++i__) {
00424 j = iwork[indxq + i__];
00425 work[i__] = d__[j];
00426
00427 }
00428 dcopy_(n, &work[1], &c__1, &d__[1], &c__1);
00429 }
00430 goto L140;
00431
00432 L130:
00433 *info = submat * (*n + 1) + submat + matsiz - 1;
00434
00435 L140:
00436 return 0;
00437
00438
00439
00440 }