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