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