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