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 doublecomplex c_b1 = {0.,0.};
00019 static doublecomplex c_b2 = {1.,0.};
00020 static integer c__16 = 16;
00021 static integer c__2 = 2;
00022 static integer c__1 = 1;
00023 static doublecomplex c_b22 = {2.,0.};
00024 static integer c__0 = 0;
00025
00026 int zqrt15_(integer *scale, integer *rksel, integer *m,
00027 integer *n, integer *nrhs, doublecomplex *a, integer *lda,
00028 doublecomplex *b, integer *ldb, doublereal *s, integer *rank,
00029 doublereal *norma, doublereal *normb, integer *iseed, doublecomplex *
00030 work, integer *lwork)
00031 {
00032
00033 integer a_dim1, a_offset, b_dim1, b_offset, i__1, i__2;
00034 doublereal d__1;
00035
00036
00037 integer j, mn;
00038 doublereal eps;
00039 integer info;
00040 doublereal temp;
00041 extern doublereal dasum_(integer *, doublereal *, integer *);
00042 extern int zlarf_(char *, integer *, integer *,
00043 doublecomplex *, integer *, doublecomplex *, doublecomplex *,
00044 integer *, doublecomplex *), zgemm_(char *, char *,
00045 integer *, integer *, integer *, doublecomplex *, doublecomplex *,
00046 integer *, doublecomplex *, integer *, doublecomplex *,
00047 doublecomplex *, integer *);
00048 doublereal dummy[1];
00049 extern int dlabad_(doublereal *, doublereal *);
00050 extern doublereal dznrm2_(integer *, doublecomplex *, integer *), dlamch_(
00051 char *);
00052 extern int dlascl_(char *, integer *, integer *,
00053 doublereal *, doublereal *, integer *, integer *, doublereal *,
00054 integer *, integer *);
00055 extern doublereal dlarnd_(integer *, integer *);
00056 extern int dlaord_(char *, integer *, doublereal *,
00057 integer *), xerbla_(char *, integer *);
00058 extern doublereal zlange_(char *, integer *, integer *, doublecomplex *,
00059 integer *, doublereal *);
00060 doublereal bignum;
00061 extern int zdscal_(integer *, doublereal *,
00062 doublecomplex *, integer *), zlascl_(char *, integer *, integer *,
00063 doublereal *, doublereal *, integer *, integer *, doublecomplex *
00064 , integer *, integer *), zlaset_(char *, integer *,
00065 integer *, doublecomplex *, doublecomplex *, doublecomplex *,
00066 integer *), zlaror_(char *, char *, integer *, integer *,
00067 doublecomplex *, integer *, integer *, doublecomplex *, integer *);
00068 doublereal smlnum;
00069 extern int zlarnv_(integer *, integer *, integer *,
00070 doublecomplex *);
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 a_dim1 = *lda;
00160 a_offset = 1 + a_dim1;
00161 a -= a_offset;
00162 b_dim1 = *ldb;
00163 b_offset = 1 + b_dim1;
00164 b -= b_offset;
00165 --s;
00166 --iseed;
00167 --work;
00168
00169
00170 mn = min(*m,*n);
00171
00172 i__1 = *m + mn, i__2 = mn * *nrhs, i__1 = max(i__1,i__2), i__2 = (*n << 1)
00173 + *m;
00174 if (*lwork < max(i__1,i__2)) {
00175 xerbla_("ZQRT15", &c__16);
00176 return 0;
00177 }
00178
00179 smlnum = dlamch_("Safe minimum");
00180 bignum = 1. / smlnum;
00181 dlabad_(&smlnum, &bignum);
00182 eps = dlamch_("Epsilon");
00183 smlnum = smlnum / eps / eps;
00184 bignum = 1. / smlnum;
00185
00186
00187
00188 if (*rksel == 1) {
00189 *rank = mn;
00190 } else if (*rksel == 2) {
00191 *rank = mn * 3 / 4;
00192 i__1 = mn;
00193 for (j = *rank + 1; j <= i__1; ++j) {
00194 s[j] = 0.;
00195
00196 }
00197 } else {
00198 xerbla_("ZQRT15", &c__2);
00199 }
00200
00201 if (*rank > 0) {
00202
00203
00204
00205 s[1] = 1.;
00206 i__1 = *rank;
00207 for (j = 2; j <= i__1; ++j) {
00208 L20:
00209 temp = dlarnd_(&c__1, &iseed[1]);
00210 if (temp > .1) {
00211 s[j] = abs(temp);
00212 } else {
00213 goto L20;
00214 }
00215
00216 }
00217 dlaord_("Decreasing", rank, &s[1], &c__1);
00218
00219
00220
00221 zlarnv_(&c__2, &iseed[1], m, &work[1]);
00222 d__1 = 1. / dznrm2_(m, &work[1], &c__1);
00223 zdscal_(m, &d__1, &work[1], &c__1);
00224 zlaset_("Full", m, rank, &c_b1, &c_b2, &a[a_offset], lda);
00225 zlarf_("Left", m, rank, &work[1], &c__1, &c_b22, &a[a_offset], lda, &
00226 work[*m + 1]);
00227
00228
00229
00230
00231
00232 i__1 = *rank * *nrhs;
00233 zlarnv_(&c__2, &iseed[1], &i__1, &work[1]);
00234 zgemm_("No transpose", "No transpose", m, nrhs, rank, &c_b2, &a[
00235 a_offset], lda, &work[1], rank, &c_b1, &b[b_offset], ldb);
00236
00237
00238
00239
00240
00241 i__1 = *rank;
00242 for (j = 1; j <= i__1; ++j) {
00243 zdscal_(m, &s[j], &a[j * a_dim1 + 1], &c__1);
00244
00245 }
00246 if (*rank < *n) {
00247 i__1 = *n - *rank;
00248 zlaset_("Full", m, &i__1, &c_b1, &c_b1, &a[(*rank + 1) * a_dim1 +
00249 1], lda);
00250 }
00251 zlaror_("Right", "No initialization", m, n, &a[a_offset], lda, &iseed[
00252 1], &work[1], &info);
00253
00254 } else {
00255
00256
00257
00258
00259
00260 i__1 = mn;
00261 for (j = 1; j <= i__1; ++j) {
00262 s[j] = 0.;
00263
00264 }
00265 zlaset_("Full", m, n, &c_b1, &c_b1, &a[a_offset], lda);
00266 zlaset_("Full", m, nrhs, &c_b1, &c_b1, &b[b_offset], ldb);
00267
00268 }
00269
00270
00271
00272 if (*scale != 1) {
00273 *norma = zlange_("Max", m, n, &a[a_offset], lda, dummy);
00274 if (*norma != 0.) {
00275 if (*scale == 2) {
00276
00277
00278
00279 zlascl_("General", &c__0, &c__0, norma, &bignum, m, n, &a[
00280 a_offset], lda, &info);
00281 dlascl_("General", &c__0, &c__0, norma, &bignum, &mn, &c__1, &
00282 s[1], &mn, &info);
00283 zlascl_("General", &c__0, &c__0, norma, &bignum, m, nrhs, &b[
00284 b_offset], ldb, &info);
00285 } else if (*scale == 3) {
00286
00287
00288
00289 zlascl_("General", &c__0, &c__0, norma, &smlnum, m, n, &a[
00290 a_offset], lda, &info);
00291 dlascl_("General", &c__0, &c__0, norma, &smlnum, &mn, &c__1, &
00292 s[1], &mn, &info);
00293 zlascl_("General", &c__0, &c__0, norma, &smlnum, m, nrhs, &b[
00294 b_offset], ldb, &info);
00295 } else {
00296 xerbla_("ZQRT15", &c__1);
00297 return 0;
00298 }
00299 }
00300 }
00301
00302 *norma = dasum_(&mn, &s[1], &c__1);
00303 *normb = zlange_("One-norm", m, nrhs, &b[b_offset], ldb, dummy)
00304 ;
00305
00306 return 0;
00307
00308
00309
00310 }