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 complex c_b1 = {0.f,0.f};
00019 static complex c_b2 = {1.f,0.f};
00020 static integer c__3 = 3;
00021 static integer c__1 = 1;
00022
00023 int claror_(char *side, char *init, integer *m, integer *n,
00024 complex *a, integer *lda, integer *iseed, complex *x, integer *info)
00025 {
00026
00027 integer a_dim1, a_offset, i__1, i__2, i__3;
00028 complex q__1, q__2;
00029
00030
00031 double c_abs(complex *);
00032 void r_cnjg(complex *, complex *);
00033
00034
00035 integer j, kbeg, jcol;
00036 real xabs;
00037 integer irow;
00038 extern int cgerc_(integer *, integer *, complex *,
00039 complex *, integer *, complex *, integer *, complex *, integer *),
00040 cscal_(integer *, complex *, complex *, integer *);
00041 extern logical lsame_(char *, char *);
00042 extern int cgemv_(char *, integer *, integer *, complex *
00043 , complex *, integer *, complex *, integer *, complex *, complex *
00044 , integer *);
00045 complex csign;
00046 integer ixfrm, itype, nxfrm;
00047 real xnorm;
00048 extern doublereal scnrm2_(integer *, complex *, integer *);
00049 extern int clacgv_(integer *, complex *, integer *);
00050 extern VOID clarnd_(complex *, integer *, integer *);
00051 extern int claset_(char *, integer *, integer *, complex
00052 *, complex *, complex *, integer *), xerbla_(char *,
00053 integer *);
00054 real factor;
00055 complex xnorms;
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
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 a_dim1 = *lda;
00178 a_offset = 1 + a_dim1;
00179 a -= a_offset;
00180 --iseed;
00181 --x;
00182
00183
00184 if (*n == 0 || *m == 0) {
00185 return 0;
00186 }
00187
00188 itype = 0;
00189 if (lsame_(side, "L")) {
00190 itype = 1;
00191 } else if (lsame_(side, "R")) {
00192 itype = 2;
00193 } else if (lsame_(side, "C")) {
00194 itype = 3;
00195 } else if (lsame_(side, "T")) {
00196 itype = 4;
00197 }
00198
00199
00200
00201 *info = 0;
00202 if (itype == 0) {
00203 *info = -1;
00204 } else if (*m < 0) {
00205 *info = -3;
00206 } else if (*n < 0 || itype == 3 && *n != *m) {
00207 *info = -4;
00208 } else if (*lda < *m) {
00209 *info = -6;
00210 }
00211 if (*info != 0) {
00212 i__1 = -(*info);
00213 xerbla_("CLAROR", &i__1);
00214 return 0;
00215 }
00216
00217 if (itype == 1) {
00218 nxfrm = *m;
00219 } else {
00220 nxfrm = *n;
00221 }
00222
00223
00224
00225 if (lsame_(init, "I")) {
00226 claset_("Full", m, n, &c_b1, &c_b2, &a[a_offset], lda);
00227 }
00228
00229
00230
00231
00232
00233
00234
00235
00236 i__1 = nxfrm;
00237 for (j = 1; j <= i__1; ++j) {
00238 i__2 = j;
00239 x[i__2].r = 0.f, x[i__2].i = 0.f;
00240
00241 }
00242
00243 i__1 = nxfrm;
00244 for (ixfrm = 2; ixfrm <= i__1; ++ixfrm) {
00245 kbeg = nxfrm - ixfrm + 1;
00246
00247
00248
00249 i__2 = nxfrm;
00250 for (j = kbeg; j <= i__2; ++j) {
00251 i__3 = j;
00252 clarnd_(&q__1, &c__3, &iseed[1]);
00253 x[i__3].r = q__1.r, x[i__3].i = q__1.i;
00254
00255 }
00256
00257
00258
00259 xnorm = scnrm2_(&ixfrm, &x[kbeg], &c__1);
00260 xabs = c_abs(&x[kbeg]);
00261 if (xabs != 0.f) {
00262 i__2 = kbeg;
00263 q__1.r = x[i__2].r / xabs, q__1.i = x[i__2].i / xabs;
00264 csign.r = q__1.r, csign.i = q__1.i;
00265 } else {
00266 csign.r = 1.f, csign.i = 0.f;
00267 }
00268 q__1.r = xnorm * csign.r, q__1.i = xnorm * csign.i;
00269 xnorms.r = q__1.r, xnorms.i = q__1.i;
00270 i__2 = nxfrm + kbeg;
00271 q__1.r = -csign.r, q__1.i = -csign.i;
00272 x[i__2].r = q__1.r, x[i__2].i = q__1.i;
00273 factor = xnorm * (xnorm + xabs);
00274 if (dabs(factor) < 1e-20f) {
00275 *info = 1;
00276 i__2 = -(*info);
00277 xerbla_("CLAROR", &i__2);
00278 return 0;
00279 } else {
00280 factor = 1.f / factor;
00281 }
00282 i__2 = kbeg;
00283 i__3 = kbeg;
00284 q__1.r = x[i__3].r + xnorms.r, q__1.i = x[i__3].i + xnorms.i;
00285 x[i__2].r = q__1.r, x[i__2].i = q__1.i;
00286
00287
00288
00289 if (itype == 1 || itype == 3 || itype == 4) {
00290
00291
00292
00293 cgemv_("C", &ixfrm, n, &c_b2, &a[kbeg + a_dim1], lda, &x[kbeg], &
00294 c__1, &c_b1, &x[(nxfrm << 1) + 1], &c__1);
00295 q__2.r = factor, q__2.i = 0.f;
00296 q__1.r = -q__2.r, q__1.i = -q__2.i;
00297 cgerc_(&ixfrm, n, &q__1, &x[kbeg], &c__1, &x[(nxfrm << 1) + 1], &
00298 c__1, &a[kbeg + a_dim1], lda);
00299
00300 }
00301
00302 if (itype >= 2 && itype <= 4) {
00303
00304
00305
00306 if (itype == 4) {
00307 clacgv_(&ixfrm, &x[kbeg], &c__1);
00308 }
00309
00310 cgemv_("N", m, &ixfrm, &c_b2, &a[kbeg * a_dim1 + 1], lda, &x[kbeg]
00311 , &c__1, &c_b1, &x[(nxfrm << 1) + 1], &c__1);
00312 q__2.r = factor, q__2.i = 0.f;
00313 q__1.r = -q__2.r, q__1.i = -q__2.i;
00314 cgerc_(m, &ixfrm, &q__1, &x[(nxfrm << 1) + 1], &c__1, &x[kbeg], &
00315 c__1, &a[kbeg * a_dim1 + 1], lda);
00316
00317 }
00318
00319 }
00320
00321 clarnd_(&q__1, &c__3, &iseed[1]);
00322 x[1].r = q__1.r, x[1].i = q__1.i;
00323 xabs = c_abs(&x[1]);
00324 if (xabs != 0.f) {
00325 q__1.r = x[1].r / xabs, q__1.i = x[1].i / xabs;
00326 csign.r = q__1.r, csign.i = q__1.i;
00327 } else {
00328 csign.r = 1.f, csign.i = 0.f;
00329 }
00330 i__1 = nxfrm << 1;
00331 x[i__1].r = csign.r, x[i__1].i = csign.i;
00332
00333
00334
00335 if (itype == 1 || itype == 3 || itype == 4) {
00336 i__1 = *m;
00337 for (irow = 1; irow <= i__1; ++irow) {
00338 r_cnjg(&q__1, &x[nxfrm + irow]);
00339 cscal_(n, &q__1, &a[irow + a_dim1], lda);
00340
00341 }
00342 }
00343
00344 if (itype == 2 || itype == 3) {
00345 i__1 = *n;
00346 for (jcol = 1; jcol <= i__1; ++jcol) {
00347 cscal_(m, &x[nxfrm + jcol], &a[jcol * a_dim1 + 1], &c__1);
00348
00349 }
00350 }
00351
00352 if (itype == 4) {
00353 i__1 = *n;
00354 for (jcol = 1; jcol <= i__1; ++jcol) {
00355 r_cnjg(&q__1, &x[nxfrm + jcol]);
00356 cscal_(m, &q__1, &a[jcol * a_dim1 + 1], &c__1);
00357
00358 }
00359 }
00360 return 0;
00361
00362
00363
00364 }