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