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 integer c__2 = 2;
00020
00021 int slasd0_(integer *n, integer *sqre, real *d__, real *e,
00022 real *u, integer *ldu, real *vt, integer *ldvt, integer *smlsiz,
00023 integer *iwork, real *work, integer *info)
00024 {
00025
00026 integer u_dim1, u_offset, vt_dim1, vt_offset, i__1, i__2;
00027
00028
00029 integer pow_ii(integer *, integer *);
00030
00031
00032 integer i__, j, m, i1, ic, lf, nd, ll, nl, nr, im1, ncc, nlf, nrf, iwk,
00033 lvl, ndb1, nlp1, nrp1;
00034 real beta;
00035 integer idxq, nlvl;
00036 real alpha;
00037 integer inode, ndiml, idxqc, ndimr, itemp, sqrei;
00038 extern int slasd1_(integer *, integer *, integer *, real
00039 *, real *, real *, real *, integer *, real *, integer *, integer *
00040 , integer *, real *, integer *), xerbla_(char *, integer *), slasdq_(char *, integer *, integer *, integer *, integer
00041 *, integer *, real *, real *, real *, integer *, real *, integer *
00042 , real *, integer *, real *, integer *), slasdt_(integer *
00043 , integer *, integer *, integer *, integer *, integer *, integer *
00044 );
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
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 --d__;
00133 --e;
00134 u_dim1 = *ldu;
00135 u_offset = 1 + u_dim1;
00136 u -= u_offset;
00137 vt_dim1 = *ldvt;
00138 vt_offset = 1 + vt_dim1;
00139 vt -= vt_offset;
00140 --iwork;
00141 --work;
00142
00143
00144 *info = 0;
00145
00146 if (*n < 0) {
00147 *info = -1;
00148 } else if (*sqre < 0 || *sqre > 1) {
00149 *info = -2;
00150 }
00151
00152 m = *n + *sqre;
00153
00154 if (*ldu < *n) {
00155 *info = -6;
00156 } else if (*ldvt < m) {
00157 *info = -8;
00158 } else if (*smlsiz < 3) {
00159 *info = -9;
00160 }
00161 if (*info != 0) {
00162 i__1 = -(*info);
00163 xerbla_("SLASD0", &i__1);
00164 return 0;
00165 }
00166
00167
00168
00169 if (*n <= *smlsiz) {
00170 slasdq_("U", sqre, n, &m, n, &c__0, &d__[1], &e[1], &vt[vt_offset],
00171 ldvt, &u[u_offset], ldu, &u[u_offset], ldu, &work[1], info);
00172 return 0;
00173 }
00174
00175
00176
00177 inode = 1;
00178 ndiml = inode + *n;
00179 ndimr = ndiml + *n;
00180 idxq = ndimr + *n;
00181 iwk = idxq + *n;
00182 slasdt_(n, &nlvl, &nd, &iwork[inode], &iwork[ndiml], &iwork[ndimr],
00183 smlsiz);
00184
00185
00186
00187
00188 ndb1 = (nd + 1) / 2;
00189 ncc = 0;
00190 i__1 = nd;
00191 for (i__ = ndb1; i__ <= i__1; ++i__) {
00192
00193
00194
00195
00196
00197
00198
00199 i1 = i__ - 1;
00200 ic = iwork[inode + i1];
00201 nl = iwork[ndiml + i1];
00202 nlp1 = nl + 1;
00203 nr = iwork[ndimr + i1];
00204 nrp1 = nr + 1;
00205 nlf = ic - nl;
00206 nrf = ic + 1;
00207 sqrei = 1;
00208 slasdq_("U", &sqrei, &nl, &nlp1, &nl, &ncc, &d__[nlf], &e[nlf], &vt[
00209 nlf + nlf * vt_dim1], ldvt, &u[nlf + nlf * u_dim1], ldu, &u[
00210 nlf + nlf * u_dim1], ldu, &work[1], info);
00211 if (*info != 0) {
00212 return 0;
00213 }
00214 itemp = idxq + nlf - 2;
00215 i__2 = nl;
00216 for (j = 1; j <= i__2; ++j) {
00217 iwork[itemp + j] = j;
00218
00219 }
00220 if (i__ == nd) {
00221 sqrei = *sqre;
00222 } else {
00223 sqrei = 1;
00224 }
00225 nrp1 = nr + sqrei;
00226 slasdq_("U", &sqrei, &nr, &nrp1, &nr, &ncc, &d__[nrf], &e[nrf], &vt[
00227 nrf + nrf * vt_dim1], ldvt, &u[nrf + nrf * u_dim1], ldu, &u[
00228 nrf + nrf * u_dim1], ldu, &work[1], info);
00229 if (*info != 0) {
00230 return 0;
00231 }
00232 itemp = idxq + ic;
00233 i__2 = nr;
00234 for (j = 1; j <= i__2; ++j) {
00235 iwork[itemp + j - 1] = j;
00236
00237 }
00238
00239 }
00240
00241
00242
00243 for (lvl = nlvl; lvl >= 1; --lvl) {
00244
00245
00246
00247
00248 if (lvl == 1) {
00249 lf = 1;
00250 ll = 1;
00251 } else {
00252 i__1 = lvl - 1;
00253 lf = pow_ii(&c__2, &i__1);
00254 ll = (lf << 1) - 1;
00255 }
00256 i__1 = ll;
00257 for (i__ = lf; i__ <= i__1; ++i__) {
00258 im1 = i__ - 1;
00259 ic = iwork[inode + im1];
00260 nl = iwork[ndiml + im1];
00261 nr = iwork[ndimr + im1];
00262 nlf = ic - nl;
00263 if (*sqre == 0 && i__ == ll) {
00264 sqrei = *sqre;
00265 } else {
00266 sqrei = 1;
00267 }
00268 idxqc = idxq + nlf - 1;
00269 alpha = d__[ic];
00270 beta = e[ic];
00271 slasd1_(&nl, &nr, &sqrei, &d__[nlf], &alpha, &beta, &u[nlf + nlf *
00272 u_dim1], ldu, &vt[nlf + nlf * vt_dim1], ldvt, &iwork[
00273 idxqc], &iwork[iwk], &work[1], info);
00274 if (*info != 0) {
00275 return 0;
00276 }
00277
00278 }
00279
00280 }
00281
00282 return 0;
00283
00284
00285
00286 }