00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015
00016 int zlascl_(char *type__, integer *kl, integer *ku,
00017 doublereal *cfrom, doublereal *cto, integer *m, integer *n,
00018 doublecomplex *a, integer *lda, integer *info)
00019 {
00020
00021 integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5;
00022 doublecomplex z__1;
00023
00024
00025 integer i__, j, k1, k2, k3, k4;
00026 doublereal mul, cto1;
00027 logical done;
00028 doublereal ctoc;
00029 extern logical lsame_(char *, char *);
00030 integer itype;
00031 doublereal cfrom1;
00032 extern doublereal dlamch_(char *);
00033 doublereal cfromc;
00034 extern logical disnan_(doublereal *);
00035 extern int xerbla_(char *, integer *);
00036 doublereal bignum, smlnum;
00037
00038
00039
00040
00041
00042
00043
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 a_dim1 = *lda;
00125 a_offset = 1 + a_dim1;
00126 a -= a_offset;
00127
00128
00129 *info = 0;
00130
00131 if (lsame_(type__, "G")) {
00132 itype = 0;
00133 } else if (lsame_(type__, "L")) {
00134 itype = 1;
00135 } else if (lsame_(type__, "U")) {
00136 itype = 2;
00137 } else if (lsame_(type__, "H")) {
00138 itype = 3;
00139 } else if (lsame_(type__, "B")) {
00140 itype = 4;
00141 } else if (lsame_(type__, "Q")) {
00142 itype = 5;
00143 } else if (lsame_(type__, "Z")) {
00144 itype = 6;
00145 } else {
00146 itype = -1;
00147 }
00148
00149 if (itype == -1) {
00150 *info = -1;
00151 } else if (*cfrom == 0. || disnan_(cfrom)) {
00152 *info = -4;
00153 } else if (disnan_(cto)) {
00154 *info = -5;
00155 } else if (*m < 0) {
00156 *info = -6;
00157 } else if (*n < 0 || itype == 4 && *n != *m || itype == 5 && *n != *m) {
00158 *info = -7;
00159 } else if (itype <= 3 && *lda < max(1,*m)) {
00160 *info = -9;
00161 } else if (itype >= 4) {
00162
00163 i__1 = *m - 1;
00164 if (*kl < 0 || *kl > max(i__1,0)) {
00165 *info = -2;
00166 } else {
00167
00168 i__1 = *n - 1;
00169 if (*ku < 0 || *ku > max(i__1,0) || (itype == 4 || itype == 5) &&
00170 *kl != *ku) {
00171 *info = -3;
00172 } else if (itype == 4 && *lda < *kl + 1 || itype == 5 && *lda < *
00173 ku + 1 || itype == 6 && *lda < (*kl << 1) + *ku + 1) {
00174 *info = -9;
00175 }
00176 }
00177 }
00178
00179 if (*info != 0) {
00180 i__1 = -(*info);
00181 xerbla_("ZLASCL", &i__1);
00182 return 0;
00183 }
00184
00185
00186
00187 if (*n == 0 || *m == 0) {
00188 return 0;
00189 }
00190
00191
00192
00193 smlnum = dlamch_("S");
00194 bignum = 1. / smlnum;
00195
00196 cfromc = *cfrom;
00197 ctoc = *cto;
00198
00199 L10:
00200 cfrom1 = cfromc * smlnum;
00201 if (cfrom1 == cfromc) {
00202
00203
00204 mul = ctoc / cfromc;
00205 done = TRUE_;
00206 cto1 = ctoc;
00207 } else {
00208 cto1 = ctoc / bignum;
00209 if (cto1 == ctoc) {
00210
00211
00212 mul = ctoc;
00213 done = TRUE_;
00214 cfromc = 1.;
00215 } else if (abs(cfrom1) > abs(ctoc) && ctoc != 0.) {
00216 mul = smlnum;
00217 done = FALSE_;
00218 cfromc = cfrom1;
00219 } else if (abs(cto1) > abs(cfromc)) {
00220 mul = bignum;
00221 done = FALSE_;
00222 ctoc = cto1;
00223 } else {
00224 mul = ctoc / cfromc;
00225 done = TRUE_;
00226 }
00227 }
00228
00229 if (itype == 0) {
00230
00231
00232
00233 i__1 = *n;
00234 for (j = 1; j <= i__1; ++j) {
00235 i__2 = *m;
00236 for (i__ = 1; i__ <= i__2; ++i__) {
00237 i__3 = i__ + j * a_dim1;
00238 i__4 = i__ + j * a_dim1;
00239 z__1.r = mul * a[i__4].r, z__1.i = mul * a[i__4].i;
00240 a[i__3].r = z__1.r, a[i__3].i = z__1.i;
00241
00242 }
00243
00244 }
00245
00246 } else if (itype == 1) {
00247
00248
00249
00250 i__1 = *n;
00251 for (j = 1; j <= i__1; ++j) {
00252 i__2 = *m;
00253 for (i__ = j; i__ <= i__2; ++i__) {
00254 i__3 = i__ + j * a_dim1;
00255 i__4 = i__ + j * a_dim1;
00256 z__1.r = mul * a[i__4].r, z__1.i = mul * a[i__4].i;
00257 a[i__3].r = z__1.r, a[i__3].i = z__1.i;
00258
00259 }
00260
00261 }
00262
00263 } else if (itype == 2) {
00264
00265
00266
00267 i__1 = *n;
00268 for (j = 1; j <= i__1; ++j) {
00269 i__2 = min(j,*m);
00270 for (i__ = 1; i__ <= i__2; ++i__) {
00271 i__3 = i__ + j * a_dim1;
00272 i__4 = i__ + j * a_dim1;
00273 z__1.r = mul * a[i__4].r, z__1.i = mul * a[i__4].i;
00274 a[i__3].r = z__1.r, a[i__3].i = z__1.i;
00275
00276 }
00277
00278 }
00279
00280 } else if (itype == 3) {
00281
00282
00283
00284 i__1 = *n;
00285 for (j = 1; j <= i__1; ++j) {
00286
00287 i__3 = j + 1;
00288 i__2 = min(i__3,*m);
00289 for (i__ = 1; i__ <= i__2; ++i__) {
00290 i__3 = i__ + j * a_dim1;
00291 i__4 = i__ + j * a_dim1;
00292 z__1.r = mul * a[i__4].r, z__1.i = mul * a[i__4].i;
00293 a[i__3].r = z__1.r, a[i__3].i = z__1.i;
00294
00295 }
00296
00297 }
00298
00299 } else if (itype == 4) {
00300
00301
00302
00303 k3 = *kl + 1;
00304 k4 = *n + 1;
00305 i__1 = *n;
00306 for (j = 1; j <= i__1; ++j) {
00307
00308 i__3 = k3, i__4 = k4 - j;
00309 i__2 = min(i__3,i__4);
00310 for (i__ = 1; i__ <= i__2; ++i__) {
00311 i__3 = i__ + j * a_dim1;
00312 i__4 = i__ + j * a_dim1;
00313 z__1.r = mul * a[i__4].r, z__1.i = mul * a[i__4].i;
00314 a[i__3].r = z__1.r, a[i__3].i = z__1.i;
00315
00316 }
00317
00318 }
00319
00320 } else if (itype == 5) {
00321
00322
00323
00324 k1 = *ku + 2;
00325 k3 = *ku + 1;
00326 i__1 = *n;
00327 for (j = 1; j <= i__1; ++j) {
00328
00329 i__2 = k1 - j;
00330 i__3 = k3;
00331 for (i__ = max(i__2,1); i__ <= i__3; ++i__) {
00332 i__2 = i__ + j * a_dim1;
00333 i__4 = i__ + j * a_dim1;
00334 z__1.r = mul * a[i__4].r, z__1.i = mul * a[i__4].i;
00335 a[i__2].r = z__1.r, a[i__2].i = z__1.i;
00336
00337 }
00338
00339 }
00340
00341 } else if (itype == 6) {
00342
00343
00344
00345 k1 = *kl + *ku + 2;
00346 k2 = *kl + 1;
00347 k3 = (*kl << 1) + *ku + 1;
00348 k4 = *kl + *ku + 1 + *m;
00349 i__1 = *n;
00350 for (j = 1; j <= i__1; ++j) {
00351
00352 i__3 = k1 - j;
00353
00354 i__4 = k3, i__5 = k4 - j;
00355 i__2 = min(i__4,i__5);
00356 for (i__ = max(i__3,k2); i__ <= i__2; ++i__) {
00357 i__3 = i__ + j * a_dim1;
00358 i__4 = i__ + j * a_dim1;
00359 z__1.r = mul * a[i__4].r, z__1.i = mul * a[i__4].i;
00360 a[i__3].r = z__1.r, a[i__3].i = z__1.i;
00361
00362 }
00363
00364 }
00365
00366 }
00367
00368 if (! done) {
00369 goto L10;
00370 }
00371
00372 return 0;
00373
00374
00375
00376 }