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