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