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__3 = 3;
00019 static integer c__1 = 1;
00020 static real c_b11 = 1.f;
00021 static real c_b13 = 0.f;
00022
00023 int slagge_(integer *m, integer *n, integer *kl, integer *ku,
00024 real *d__, real *a, integer *lda, integer *iseed, real *work,
00025 integer *info)
00026 {
00027
00028 integer a_dim1, a_offset, i__1, i__2, i__3;
00029 real r__1;
00030
00031
00032 double r_sign(real *, real *);
00033
00034
00035 integer i__, j;
00036 real wa, wb, wn, tau;
00037 extern int sger_(integer *, integer *, real *, real *,
00038 integer *, real *, integer *, real *, integer *);
00039 extern doublereal snrm2_(integer *, real *, integer *);
00040 extern int sscal_(integer *, real *, real *, integer *),
00041 sgemv_(char *, integer *, integer *, real *, real *, integer *,
00042 real *, integer *, real *, real *, integer *), xerbla_(
00043 char *, integer *), slarnv_(integer *, integer *, integer
00044 *, real *);
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 --d__;
00120 a_dim1 = *lda;
00121 a_offset = 1 + a_dim1;
00122 a -= a_offset;
00123 --iseed;
00124 --work;
00125
00126
00127 *info = 0;
00128 if (*m < 0) {
00129 *info = -1;
00130 } else if (*n < 0) {
00131 *info = -2;
00132 } else if (*kl < 0 || *kl > *m - 1) {
00133 *info = -3;
00134 } else if (*ku < 0 || *ku > *n - 1) {
00135 *info = -4;
00136 } else if (*lda < max(1,*m)) {
00137 *info = -7;
00138 }
00139 if (*info < 0) {
00140 i__1 = -(*info);
00141 xerbla_("SLAGGE", &i__1);
00142 return 0;
00143 }
00144
00145
00146
00147 i__1 = *n;
00148 for (j = 1; j <= i__1; ++j) {
00149 i__2 = *m;
00150 for (i__ = 1; i__ <= i__2; ++i__) {
00151 a[i__ + j * a_dim1] = 0.f;
00152
00153 }
00154
00155 }
00156 i__1 = min(*m,*n);
00157 for (i__ = 1; i__ <= i__1; ++i__) {
00158 a[i__ + i__ * a_dim1] = d__[i__];
00159
00160 }
00161
00162
00163
00164 for (i__ = min(*m,*n); i__ >= 1; --i__) {
00165 if (i__ < *m) {
00166
00167
00168
00169 i__1 = *m - i__ + 1;
00170 slarnv_(&c__3, &iseed[1], &i__1, &work[1]);
00171 i__1 = *m - i__ + 1;
00172 wn = snrm2_(&i__1, &work[1], &c__1);
00173 wa = r_sign(&wn, &work[1]);
00174 if (wn == 0.f) {
00175 tau = 0.f;
00176 } else {
00177 wb = work[1] + wa;
00178 i__1 = *m - i__;
00179 r__1 = 1.f / wb;
00180 sscal_(&i__1, &r__1, &work[2], &c__1);
00181 work[1] = 1.f;
00182 tau = wb / wa;
00183 }
00184
00185
00186
00187 i__1 = *m - i__ + 1;
00188 i__2 = *n - i__ + 1;
00189 sgemv_("Transpose", &i__1, &i__2, &c_b11, &a[i__ + i__ * a_dim1],
00190 lda, &work[1], &c__1, &c_b13, &work[*m + 1], &c__1);
00191 i__1 = *m - i__ + 1;
00192 i__2 = *n - i__ + 1;
00193 r__1 = -tau;
00194 sger_(&i__1, &i__2, &r__1, &work[1], &c__1, &work[*m + 1], &c__1,
00195 &a[i__ + i__ * a_dim1], lda);
00196 }
00197 if (i__ < *n) {
00198
00199
00200
00201 i__1 = *n - i__ + 1;
00202 slarnv_(&c__3, &iseed[1], &i__1, &work[1]);
00203 i__1 = *n - i__ + 1;
00204 wn = snrm2_(&i__1, &work[1], &c__1);
00205 wa = r_sign(&wn, &work[1]);
00206 if (wn == 0.f) {
00207 tau = 0.f;
00208 } else {
00209 wb = work[1] + wa;
00210 i__1 = *n - i__;
00211 r__1 = 1.f / wb;
00212 sscal_(&i__1, &r__1, &work[2], &c__1);
00213 work[1] = 1.f;
00214 tau = wb / wa;
00215 }
00216
00217
00218
00219 i__1 = *m - i__ + 1;
00220 i__2 = *n - i__ + 1;
00221 sgemv_("No transpose", &i__1, &i__2, &c_b11, &a[i__ + i__ *
00222 a_dim1], lda, &work[1], &c__1, &c_b13, &work[*n + 1], &
00223 c__1);
00224 i__1 = *m - i__ + 1;
00225 i__2 = *n - i__ + 1;
00226 r__1 = -tau;
00227 sger_(&i__1, &i__2, &r__1, &work[*n + 1], &c__1, &work[1], &c__1,
00228 &a[i__ + i__ * a_dim1], lda);
00229 }
00230
00231 }
00232
00233
00234
00235
00236
00237 i__2 = *m - 1 - *kl, i__3 = *n - 1 - *ku;
00238 i__1 = max(i__2,i__3);
00239 for (i__ = 1; i__ <= i__1; ++i__) {
00240 if (*kl <= *ku) {
00241
00242
00243
00244
00245 i__2 = *m - 1 - *kl;
00246 if (i__ <= min(i__2,*n)) {
00247
00248
00249
00250 i__2 = *m - *kl - i__ + 1;
00251 wn = snrm2_(&i__2, &a[*kl + i__ + i__ * a_dim1], &c__1);
00252 wa = r_sign(&wn, &a[*kl + i__ + i__ * a_dim1]);
00253 if (wn == 0.f) {
00254 tau = 0.f;
00255 } else {
00256 wb = a[*kl + i__ + i__ * a_dim1] + wa;
00257 i__2 = *m - *kl - i__;
00258 r__1 = 1.f / wb;
00259 sscal_(&i__2, &r__1, &a[*kl + i__ + 1 + i__ * a_dim1], &
00260 c__1);
00261 a[*kl + i__ + i__ * a_dim1] = 1.f;
00262 tau = wb / wa;
00263 }
00264
00265
00266
00267 i__2 = *m - *kl - i__ + 1;
00268 i__3 = *n - i__;
00269 sgemv_("Transpose", &i__2, &i__3, &c_b11, &a[*kl + i__ + (i__
00270 + 1) * a_dim1], lda, &a[*kl + i__ + i__ * a_dim1], &
00271 c__1, &c_b13, &work[1], &c__1);
00272 i__2 = *m - *kl - i__ + 1;
00273 i__3 = *n - i__;
00274 r__1 = -tau;
00275 sger_(&i__2, &i__3, &r__1, &a[*kl + i__ + i__ * a_dim1], &
00276 c__1, &work[1], &c__1, &a[*kl + i__ + (i__ + 1) *
00277 a_dim1], lda);
00278 a[*kl + i__ + i__ * a_dim1] = -wa;
00279 }
00280
00281
00282 i__2 = *n - 1 - *ku;
00283 if (i__ <= min(i__2,*m)) {
00284
00285
00286
00287 i__2 = *n - *ku - i__ + 1;
00288 wn = snrm2_(&i__2, &a[i__ + (*ku + i__) * a_dim1], lda);
00289 wa = r_sign(&wn, &a[i__ + (*ku + i__) * a_dim1]);
00290 if (wn == 0.f) {
00291 tau = 0.f;
00292 } else {
00293 wb = a[i__ + (*ku + i__) * a_dim1] + wa;
00294 i__2 = *n - *ku - i__;
00295 r__1 = 1.f / wb;
00296 sscal_(&i__2, &r__1, &a[i__ + (*ku + i__ + 1) * a_dim1],
00297 lda);
00298 a[i__ + (*ku + i__) * a_dim1] = 1.f;
00299 tau = wb / wa;
00300 }
00301
00302
00303
00304 i__2 = *m - i__;
00305 i__3 = *n - *ku - i__ + 1;
00306 sgemv_("No transpose", &i__2, &i__3, &c_b11, &a[i__ + 1 + (*
00307 ku + i__) * a_dim1], lda, &a[i__ + (*ku + i__) *
00308 a_dim1], lda, &c_b13, &work[1], &c__1);
00309 i__2 = *m - i__;
00310 i__3 = *n - *ku - i__ + 1;
00311 r__1 = -tau;
00312 sger_(&i__2, &i__3, &r__1, &work[1], &c__1, &a[i__ + (*ku +
00313 i__) * a_dim1], lda, &a[i__ + 1 + (*ku + i__) *
00314 a_dim1], lda);
00315 a[i__ + (*ku + i__) * a_dim1] = -wa;
00316 }
00317 } else {
00318
00319
00320
00321
00322
00323 i__2 = *n - 1 - *ku;
00324 if (i__ <= min(i__2,*m)) {
00325
00326
00327
00328 i__2 = *n - *ku - i__ + 1;
00329 wn = snrm2_(&i__2, &a[i__ + (*ku + i__) * a_dim1], lda);
00330 wa = r_sign(&wn, &a[i__ + (*ku + i__) * a_dim1]);
00331 if (wn == 0.f) {
00332 tau = 0.f;
00333 } else {
00334 wb = a[i__ + (*ku + i__) * a_dim1] + wa;
00335 i__2 = *n - *ku - i__;
00336 r__1 = 1.f / wb;
00337 sscal_(&i__2, &r__1, &a[i__ + (*ku + i__ + 1) * a_dim1],
00338 lda);
00339 a[i__ + (*ku + i__) * a_dim1] = 1.f;
00340 tau = wb / wa;
00341 }
00342
00343
00344
00345 i__2 = *m - i__;
00346 i__3 = *n - *ku - i__ + 1;
00347 sgemv_("No transpose", &i__2, &i__3, &c_b11, &a[i__ + 1 + (*
00348 ku + i__) * a_dim1], lda, &a[i__ + (*ku + i__) *
00349 a_dim1], lda, &c_b13, &work[1], &c__1);
00350 i__2 = *m - i__;
00351 i__3 = *n - *ku - i__ + 1;
00352 r__1 = -tau;
00353 sger_(&i__2, &i__3, &r__1, &work[1], &c__1, &a[i__ + (*ku +
00354 i__) * a_dim1], lda, &a[i__ + 1 + (*ku + i__) *
00355 a_dim1], lda);
00356 a[i__ + (*ku + i__) * a_dim1] = -wa;
00357 }
00358
00359
00360 i__2 = *m - 1 - *kl;
00361 if (i__ <= min(i__2,*n)) {
00362
00363
00364
00365 i__2 = *m - *kl - i__ + 1;
00366 wn = snrm2_(&i__2, &a[*kl + i__ + i__ * a_dim1], &c__1);
00367 wa = r_sign(&wn, &a[*kl + i__ + i__ * a_dim1]);
00368 if (wn == 0.f) {
00369 tau = 0.f;
00370 } else {
00371 wb = a[*kl + i__ + i__ * a_dim1] + wa;
00372 i__2 = *m - *kl - i__;
00373 r__1 = 1.f / wb;
00374 sscal_(&i__2, &r__1, &a[*kl + i__ + 1 + i__ * a_dim1], &
00375 c__1);
00376 a[*kl + i__ + i__ * a_dim1] = 1.f;
00377 tau = wb / wa;
00378 }
00379
00380
00381
00382 i__2 = *m - *kl - i__ + 1;
00383 i__3 = *n - i__;
00384 sgemv_("Transpose", &i__2, &i__3, &c_b11, &a[*kl + i__ + (i__
00385 + 1) * a_dim1], lda, &a[*kl + i__ + i__ * a_dim1], &
00386 c__1, &c_b13, &work[1], &c__1);
00387 i__2 = *m - *kl - i__ + 1;
00388 i__3 = *n - i__;
00389 r__1 = -tau;
00390 sger_(&i__2, &i__3, &r__1, &a[*kl + i__ + i__ * a_dim1], &
00391 c__1, &work[1], &c__1, &a[*kl + i__ + (i__ + 1) *
00392 a_dim1], lda);
00393 a[*kl + i__ + i__ * a_dim1] = -wa;
00394 }
00395 }
00396
00397 i__2 = *m;
00398 for (j = *kl + i__ + 1; j <= i__2; ++j) {
00399 a[j + i__ * a_dim1] = 0.f;
00400
00401 }
00402
00403 i__2 = *n;
00404 for (j = *ku + i__ + 1; j <= i__2; ++j) {
00405 a[i__ + j * a_dim1] = 0.f;
00406
00407 }
00408
00409 }
00410 return 0;
00411
00412
00413
00414 }