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 integer c__2 = 2;
00021 static integer c__65 = 65;
00022
00023 int zunmqr_(char *side, char *trans, integer *m, integer *n,
00024 integer *k, doublecomplex *a, integer *lda, doublecomplex *tau,
00025 doublecomplex *c__, integer *ldc, doublecomplex *work, integer *lwork,
00026 integer *info)
00027 {
00028
00029 address a__1[2];
00030 integer a_dim1, a_offset, c_dim1, c_offset, i__1, i__2, i__3[2], i__4,
00031 i__5;
00032 char ch__1[2];
00033
00034
00035 int s_cat(char *, char **, integer *, integer *, ftnlen);
00036
00037
00038 integer i__;
00039 doublecomplex t[4160] ;
00040 integer i1, i2, i3, ib, ic, jc, nb, mi, ni, nq, nw, iws;
00041 logical left;
00042 extern logical lsame_(char *, char *);
00043 integer nbmin, iinfo;
00044 extern int zunm2r_(char *, char *, integer *, integer *,
00045 integer *, doublecomplex *, integer *, doublecomplex *,
00046 doublecomplex *, integer *, doublecomplex *, integer *), xerbla_(char *, integer *);
00047 extern integer ilaenv_(integer *, char *, char *, integer *, integer *,
00048 integer *, integer *);
00049 extern int zlarfb_(char *, char *, char *, char *,
00050 integer *, integer *, integer *, doublecomplex *, integer *,
00051 doublecomplex *, integer *, doublecomplex *, integer *,
00052 doublecomplex *, integer *);
00053 logical notran;
00054 integer ldwork;
00055 extern int zlarft_(char *, char *, integer *, integer *,
00056 doublecomplex *, integer *, doublecomplex *, doublecomplex *,
00057 integer *);
00058 integer lwkopt;
00059 logical lquery;
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 a_dim1 = *lda;
00173 a_offset = 1 + a_dim1;
00174 a -= a_offset;
00175 --tau;
00176 c_dim1 = *ldc;
00177 c_offset = 1 + c_dim1;
00178 c__ -= c_offset;
00179 --work;
00180
00181
00182 *info = 0;
00183 left = lsame_(side, "L");
00184 notran = lsame_(trans, "N");
00185 lquery = *lwork == -1;
00186
00187
00188
00189 if (left) {
00190 nq = *m;
00191 nw = *n;
00192 } else {
00193 nq = *n;
00194 nw = *m;
00195 }
00196 if (! left && ! lsame_(side, "R")) {
00197 *info = -1;
00198 } else if (! notran && ! lsame_(trans, "C")) {
00199 *info = -2;
00200 } else if (*m < 0) {
00201 *info = -3;
00202 } else if (*n < 0) {
00203 *info = -4;
00204 } else if (*k < 0 || *k > nq) {
00205 *info = -5;
00206 } else if (*lda < max(1,nq)) {
00207 *info = -7;
00208 } else if (*ldc < max(1,*m)) {
00209 *info = -10;
00210 } else if (*lwork < max(1,nw) && ! lquery) {
00211 *info = -12;
00212 }
00213
00214 if (*info == 0) {
00215
00216
00217
00218
00219
00220
00221 i__3[0] = 1, a__1[0] = side;
00222 i__3[1] = 1, a__1[1] = trans;
00223 s_cat(ch__1, a__1, i__3, &c__2, (ftnlen)2);
00224 i__1 = 64, i__2 = ilaenv_(&c__1, "ZUNMQR", ch__1, m, n, k, &c_n1);
00225 nb = min(i__1,i__2);
00226 lwkopt = max(1,nw) * nb;
00227 work[1].r = (doublereal) lwkopt, work[1].i = 0.;
00228 }
00229
00230 if (*info != 0) {
00231 i__1 = -(*info);
00232 xerbla_("ZUNMQR", &i__1);
00233 return 0;
00234 } else if (lquery) {
00235 return 0;
00236 }
00237
00238
00239
00240 if (*m == 0 || *n == 0 || *k == 0) {
00241 work[1].r = 1., work[1].i = 0.;
00242 return 0;
00243 }
00244
00245 nbmin = 2;
00246 ldwork = nw;
00247 if (nb > 1 && nb < *k) {
00248 iws = nw * nb;
00249 if (*lwork < iws) {
00250 nb = *lwork / ldwork;
00251
00252
00253 i__3[0] = 1, a__1[0] = side;
00254 i__3[1] = 1, a__1[1] = trans;
00255 s_cat(ch__1, a__1, i__3, &c__2, (ftnlen)2);
00256 i__1 = 2, i__2 = ilaenv_(&c__2, "ZUNMQR", ch__1, m, n, k, &c_n1);
00257 nbmin = max(i__1,i__2);
00258 }
00259 } else {
00260 iws = nw;
00261 }
00262
00263 if (nb < nbmin || nb >= *k) {
00264
00265
00266
00267 zunm2r_(side, trans, m, n, k, &a[a_offset], lda, &tau[1], &c__[
00268 c_offset], ldc, &work[1], &iinfo);
00269 } else {
00270
00271
00272
00273 if (left && ! notran || ! left && notran) {
00274 i1 = 1;
00275 i2 = *k;
00276 i3 = nb;
00277 } else {
00278 i1 = (*k - 1) / nb * nb + 1;
00279 i2 = 1;
00280 i3 = -nb;
00281 }
00282
00283 if (left) {
00284 ni = *n;
00285 jc = 1;
00286 } else {
00287 mi = *m;
00288 ic = 1;
00289 }
00290
00291 i__1 = i2;
00292 i__2 = i3;
00293 for (i__ = i1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) {
00294
00295 i__4 = nb, i__5 = *k - i__ + 1;
00296 ib = min(i__4,i__5);
00297
00298
00299
00300
00301 i__4 = nq - i__ + 1;
00302 zlarft_("Forward", "Columnwise", &i__4, &ib, &a[i__ + i__ *
00303 a_dim1], lda, &tau[i__], t, &c__65)
00304 ;
00305 if (left) {
00306
00307
00308
00309 mi = *m - i__ + 1;
00310 ic = i__;
00311 } else {
00312
00313
00314
00315 ni = *n - i__ + 1;
00316 jc = i__;
00317 }
00318
00319
00320
00321 zlarfb_(side, trans, "Forward", "Columnwise", &mi, &ni, &ib, &a[
00322 i__ + i__ * a_dim1], lda, t, &c__65, &c__[ic + jc *
00323 c_dim1], ldc, &work[1], &ldwork);
00324
00325 }
00326 }
00327 work[1].r = (doublereal) lwkopt, work[1].i = 0.;
00328 return 0;
00329
00330
00331
00332 }