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
00020 int zlatm1_(integer *mode, doublereal *cond, integer *irsign,
00021 integer *idist, integer *iseed, doublecomplex *d__, integer *n,
00022 integer *info)
00023 {
00024
00025 integer i__1, i__2, i__3;
00026 doublereal d__1;
00027 doublecomplex z__1, z__2;
00028
00029
00030 double pow_dd(doublereal *, doublereal *), pow_di(doublereal *, integer *)
00031 , log(doublereal), exp(doublereal), z_abs(doublecomplex *);
00032
00033
00034 integer i__;
00035 doublereal temp, alpha;
00036 doublecomplex ctemp;
00037 extern doublereal dlaran_(integer *);
00038 extern int xerbla_(char *, integer *);
00039 extern VOID zlarnd_(doublecomplex *, integer *,
00040 integer *);
00041 extern int zlarnv_(integer *, integer *, integer *,
00042 doublecomplex *);
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
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146 --d__;
00147 --iseed;
00148
00149
00150 *info = 0;
00151
00152
00153
00154 if (*n == 0) {
00155 return 0;
00156 }
00157
00158
00159
00160 if (*mode < -6 || *mode > 6) {
00161 *info = -1;
00162 } else if (*mode != -6 && *mode != 0 && *mode != 6 && (*irsign != 0 && *
00163 irsign != 1)) {
00164 *info = -2;
00165 } else if (*mode != -6 && *mode != 0 && *mode != 6 && *cond < 1.) {
00166 *info = -3;
00167 } else if ((*mode == 6 || *mode == -6) && (*idist < 1 || *idist > 4)) {
00168 *info = -4;
00169 } else if (*n < 0) {
00170 *info = -7;
00171 }
00172
00173 if (*info != 0) {
00174 i__1 = -(*info);
00175 xerbla_("ZLATM1", &i__1);
00176 return 0;
00177 }
00178
00179
00180
00181 if (*mode != 0) {
00182 switch (abs(*mode)) {
00183 case 1: goto L10;
00184 case 2: goto L30;
00185 case 3: goto L50;
00186 case 4: goto L70;
00187 case 5: goto L90;
00188 case 6: goto L110;
00189 }
00190
00191
00192
00193 L10:
00194 i__1 = *n;
00195 for (i__ = 1; i__ <= i__1; ++i__) {
00196 i__2 = i__;
00197 d__1 = 1. / *cond;
00198 d__[i__2].r = d__1, d__[i__2].i = 0.;
00199
00200 }
00201 d__[1].r = 1., d__[1].i = 0.;
00202 goto L120;
00203
00204
00205
00206 L30:
00207 i__1 = *n;
00208 for (i__ = 1; i__ <= i__1; ++i__) {
00209 i__2 = i__;
00210 d__[i__2].r = 1., d__[i__2].i = 0.;
00211
00212 }
00213 i__1 = *n;
00214 d__1 = 1. / *cond;
00215 d__[i__1].r = d__1, d__[i__1].i = 0.;
00216 goto L120;
00217
00218
00219
00220 L50:
00221 d__[1].r = 1., d__[1].i = 0.;
00222 if (*n > 1) {
00223 d__1 = -1. / (doublereal) (*n - 1);
00224 alpha = pow_dd(cond, &d__1);
00225 i__1 = *n;
00226 for (i__ = 2; i__ <= i__1; ++i__) {
00227 i__2 = i__;
00228 i__3 = i__ - 1;
00229 d__1 = pow_di(&alpha, &i__3);
00230 d__[i__2].r = d__1, d__[i__2].i = 0.;
00231
00232 }
00233 }
00234 goto L120;
00235
00236
00237
00238 L70:
00239 d__[1].r = 1., d__[1].i = 0.;
00240 if (*n > 1) {
00241 temp = 1. / *cond;
00242 alpha = (1. - temp) / (doublereal) (*n - 1);
00243 i__1 = *n;
00244 for (i__ = 2; i__ <= i__1; ++i__) {
00245 i__2 = i__;
00246 d__1 = (doublereal) (*n - i__) * alpha + temp;
00247 d__[i__2].r = d__1, d__[i__2].i = 0.;
00248
00249 }
00250 }
00251 goto L120;
00252
00253
00254
00255 L90:
00256 alpha = log(1. / *cond);
00257 i__1 = *n;
00258 for (i__ = 1; i__ <= i__1; ++i__) {
00259 i__2 = i__;
00260 d__1 = exp(alpha * dlaran_(&iseed[1]));
00261 d__[i__2].r = d__1, d__[i__2].i = 0.;
00262
00263 }
00264 goto L120;
00265
00266
00267
00268 L110:
00269 zlarnv_(idist, &iseed[1], n, &d__[1]);
00270
00271 L120:
00272
00273
00274
00275
00276 if (*mode != -6 && *mode != 0 && *mode != 6 && *irsign == 1) {
00277 i__1 = *n;
00278 for (i__ = 1; i__ <= i__1; ++i__) {
00279 zlarnd_(&z__1, &c__3, &iseed[1]);
00280 ctemp.r = z__1.r, ctemp.i = z__1.i;
00281 i__2 = i__;
00282 i__3 = i__;
00283 d__1 = z_abs(&ctemp);
00284 z__2.r = ctemp.r / d__1, z__2.i = ctemp.i / d__1;
00285 z__1.r = d__[i__3].r * z__2.r - d__[i__3].i * z__2.i, z__1.i =
00286 d__[i__3].r * z__2.i + d__[i__3].i * z__2.r;
00287 d__[i__2].r = z__1.r, d__[i__2].i = z__1.i;
00288
00289 }
00290 }
00291
00292
00293
00294 if (*mode < 0) {
00295 i__1 = *n / 2;
00296 for (i__ = 1; i__ <= i__1; ++i__) {
00297 i__2 = i__;
00298 ctemp.r = d__[i__2].r, ctemp.i = d__[i__2].i;
00299 i__2 = i__;
00300 i__3 = *n + 1 - i__;
00301 d__[i__2].r = d__[i__3].r, d__[i__2].i = d__[i__3].i;
00302 i__2 = *n + 1 - i__;
00303 d__[i__2].r = ctemp.r, d__[i__2].i = ctemp.i;
00304
00305 }
00306 }
00307
00308 }
00309
00310 return 0;
00311
00312
00313
00314 }