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__1 = 1;
00019 static integer c_n1 = -1;
00020 static doublereal c_b31 = -1.;
00021 static doublereal c_b33 = 1.;
00022
00023 int dgglse_(integer *m, integer *n, integer *p, doublereal *
00024 a, integer *lda, doublereal *b, integer *ldb, doublereal *c__,
00025 doublereal *d__, doublereal *x, doublereal *work, integer *lwork,
00026 integer *info)
00027 {
00028
00029 integer a_dim1, a_offset, b_dim1, b_offset, i__1, i__2;
00030
00031
00032 integer nb, mn, nr, nb1, nb2, nb3, nb4, lopt;
00033 extern int dgemv_(char *, integer *, integer *,
00034 doublereal *, doublereal *, integer *, doublereal *, integer *,
00035 doublereal *, doublereal *, integer *), dcopy_(integer *,
00036 doublereal *, integer *, doublereal *, integer *), daxpy_(integer
00037 *, doublereal *, doublereal *, integer *, doublereal *, integer *)
00038 , dtrmv_(char *, char *, char *, integer *, doublereal *, integer
00039 *, doublereal *, integer *), dggrqf_(
00040 integer *, integer *, integer *, doublereal *, integer *,
00041 doublereal *, doublereal *, integer *, doublereal *, doublereal *,
00042 integer *, integer *), xerbla_(char *, integer *);
00043 extern integer ilaenv_(integer *, char *, char *, integer *, integer *,
00044 integer *, integer *);
00045 integer lwkmin;
00046 extern int dormqr_(char *, char *, integer *, integer *,
00047 integer *, doublereal *, integer *, doublereal *, doublereal *,
00048 integer *, doublereal *, integer *, integer *),
00049 dormrq_(char *, char *, integer *, integer *, integer *,
00050 doublereal *, integer *, doublereal *, doublereal *, integer *,
00051 doublereal *, integer *, integer *);
00052 integer lwkopt;
00053 logical lquery;
00054 extern int dtrtrs_(char *, char *, char *, integer *,
00055 integer *, doublereal *, integer *, doublereal *, integer *,
00056 integer *);
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 b_dim1 = *ldb;
00181 b_offset = 1 + b_dim1;
00182 b -= b_offset;
00183 --c__;
00184 --d__;
00185 --x;
00186 --work;
00187
00188
00189 *info = 0;
00190 mn = min(*m,*n);
00191 lquery = *lwork == -1;
00192 if (*m < 0) {
00193 *info = -1;
00194 } else if (*n < 0) {
00195 *info = -2;
00196 } else if (*p < 0 || *p > *n || *p < *n - *m) {
00197 *info = -3;
00198 } else if (*lda < max(1,*m)) {
00199 *info = -5;
00200 } else if (*ldb < max(1,*p)) {
00201 *info = -7;
00202 }
00203
00204
00205
00206 if (*info == 0) {
00207 if (*n == 0) {
00208 lwkmin = 1;
00209 lwkopt = 1;
00210 } else {
00211 nb1 = ilaenv_(&c__1, "DGEQRF", " ", m, n, &c_n1, &c_n1);
00212 nb2 = ilaenv_(&c__1, "DGERQF", " ", m, n, &c_n1, &c_n1);
00213 nb3 = ilaenv_(&c__1, "DORMQR", " ", m, n, p, &c_n1);
00214 nb4 = ilaenv_(&c__1, "DORMRQ", " ", m, n, p, &c_n1);
00215
00216 i__1 = max(nb1,nb2), i__1 = max(i__1,nb3);
00217 nb = max(i__1,nb4);
00218 lwkmin = *m + *n + *p;
00219 lwkopt = *p + mn + max(*m,*n) * nb;
00220 }
00221 work[1] = (doublereal) lwkopt;
00222
00223 if (*lwork < lwkmin && ! lquery) {
00224 *info = -12;
00225 }
00226 }
00227
00228 if (*info != 0) {
00229 i__1 = -(*info);
00230 xerbla_("DGGLSE", &i__1);
00231 return 0;
00232 } else if (lquery) {
00233 return 0;
00234 }
00235
00236
00237
00238 if (*n == 0) {
00239 return 0;
00240 }
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251 i__1 = *lwork - *p - mn;
00252 dggrqf_(p, m, n, &b[b_offset], ldb, &work[1], &a[a_offset], lda, &work[*p
00253 + 1], &work[*p + mn + 1], &i__1, info);
00254 lopt = (integer) work[*p + mn + 1];
00255
00256
00257
00258
00259 i__1 = max(1,*m);
00260 i__2 = *lwork - *p - mn;
00261 dormqr_("Left", "Transpose", m, &c__1, &mn, &a[a_offset], lda, &work[*p +
00262 1], &c__[1], &i__1, &work[*p + mn + 1], &i__2, info);
00263
00264 i__1 = lopt, i__2 = (integer) work[*p + mn + 1];
00265 lopt = max(i__1,i__2);
00266
00267
00268
00269 if (*p > 0) {
00270 dtrtrs_("Upper", "No transpose", "Non-unit", p, &c__1, &b[(*n - *p +
00271 1) * b_dim1 + 1], ldb, &d__[1], p, info);
00272
00273 if (*info > 0) {
00274 *info = 1;
00275 return 0;
00276 }
00277
00278
00279
00280 dcopy_(p, &d__[1], &c__1, &x[*n - *p + 1], &c__1);
00281
00282
00283
00284 i__1 = *n - *p;
00285 dgemv_("No transpose", &i__1, p, &c_b31, &a[(*n - *p + 1) * a_dim1 +
00286 1], lda, &d__[1], &c__1, &c_b33, &c__[1], &c__1);
00287 }
00288
00289
00290
00291 if (*n > *p) {
00292 i__1 = *n - *p;
00293 i__2 = *n - *p;
00294 dtrtrs_("Upper", "No transpose", "Non-unit", &i__1, &c__1, &a[
00295 a_offset], lda, &c__[1], &i__2, info);
00296
00297 if (*info > 0) {
00298 *info = 2;
00299 return 0;
00300 }
00301
00302
00303
00304 i__1 = *n - *p;
00305 dcopy_(&i__1, &c__[1], &c__1, &x[1], &c__1);
00306 }
00307
00308
00309
00310 if (*m < *n) {
00311 nr = *m + *p - *n;
00312 if (nr > 0) {
00313 i__1 = *n - *m;
00314 dgemv_("No transpose", &nr, &i__1, &c_b31, &a[*n - *p + 1 + (*m +
00315 1) * a_dim1], lda, &d__[nr + 1], &c__1, &c_b33, &c__[*n -
00316 *p + 1], &c__1);
00317 }
00318 } else {
00319 nr = *p;
00320 }
00321 if (nr > 0) {
00322 dtrmv_("Upper", "No transpose", "Non unit", &nr, &a[*n - *p + 1 + (*n
00323 - *p + 1) * a_dim1], lda, &d__[1], &c__1);
00324 daxpy_(&nr, &c_b31, &d__[1], &c__1, &c__[*n - *p + 1], &c__1);
00325 }
00326
00327
00328
00329 i__1 = *lwork - *p - mn;
00330 dormrq_("Left", "Transpose", n, &c__1, p, &b[b_offset], ldb, &work[1], &x[
00331 1], n, &work[*p + mn + 1], &i__1, info);
00332
00333 i__1 = lopt, i__2 = (integer) work[*p + mn + 1];
00334 work[1] = (doublereal) (*p + mn + max(i__1,i__2));
00335
00336 return 0;
00337
00338
00339
00340 }