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
00022 int dormbr_(char *vect, char *side, char *trans, integer *m,
00023 integer *n, integer *k, doublereal *a, integer *lda, doublereal *tau,
00024 doublereal *c__, integer *ldc, doublereal *work, integer *lwork,
00025 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];
00030 char ch__1[2];
00031
00032
00033 int s_cat(char *, char **, integer *, integer *, ftnlen);
00034
00035
00036 integer i1, i2, nb, mi, ni, nq, nw;
00037 logical left;
00038 extern logical lsame_(char *, char *);
00039 integer iinfo;
00040 extern int xerbla_(char *, integer *);
00041 extern integer ilaenv_(integer *, char *, char *, integer *, integer *,
00042 integer *, integer *);
00043 extern int dormlq_(char *, char *, integer *, integer *,
00044 integer *, doublereal *, integer *, doublereal *, doublereal *,
00045 integer *, doublereal *, integer *, integer *);
00046 logical notran;
00047 extern int dormqr_(char *, char *, integer *, integer *,
00048 integer *, doublereal *, integer *, doublereal *, doublereal *,
00049 integer *, doublereal *, integer *, integer *);
00050 logical applyq;
00051 char transt[1];
00052 integer lwkopt;
00053 logical lquery;
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
00177
00178
00179
00180
00181
00182
00183
00184 a_dim1 = *lda;
00185 a_offset = 1 + a_dim1;
00186 a -= a_offset;
00187 --tau;
00188 c_dim1 = *ldc;
00189 c_offset = 1 + c_dim1;
00190 c__ -= c_offset;
00191 --work;
00192
00193
00194 *info = 0;
00195 applyq = lsame_(vect, "Q");
00196 left = lsame_(side, "L");
00197 notran = lsame_(trans, "N");
00198 lquery = *lwork == -1;
00199
00200
00201
00202 if (left) {
00203 nq = *m;
00204 nw = *n;
00205 } else {
00206 nq = *n;
00207 nw = *m;
00208 }
00209 if (! applyq && ! lsame_(vect, "P")) {
00210 *info = -1;
00211 } else if (! left && ! lsame_(side, "R")) {
00212 *info = -2;
00213 } else if (! notran && ! lsame_(trans, "T")) {
00214 *info = -3;
00215 } else if (*m < 0) {
00216 *info = -4;
00217 } else if (*n < 0) {
00218 *info = -5;
00219 } else if (*k < 0) {
00220 *info = -6;
00221 } else {
00222
00223 i__1 = 1, i__2 = min(nq,*k);
00224 if (applyq && *lda < max(1,nq) || ! applyq && *lda < max(i__1,i__2)) {
00225 *info = -8;
00226 } else if (*ldc < max(1,*m)) {
00227 *info = -11;
00228 } else if (*lwork < max(1,nw) && ! lquery) {
00229 *info = -13;
00230 }
00231 }
00232
00233 if (*info == 0) {
00234 if (applyq) {
00235 if (left) {
00236
00237 i__3[0] = 1, a__1[0] = side;
00238 i__3[1] = 1, a__1[1] = trans;
00239 s_cat(ch__1, a__1, i__3, &c__2, (ftnlen)2);
00240 i__1 = *m - 1;
00241 i__2 = *m - 1;
00242 nb = ilaenv_(&c__1, "DORMQR", ch__1, &i__1, n, &i__2, &c_n1);
00243 } else {
00244
00245 i__3[0] = 1, a__1[0] = side;
00246 i__3[1] = 1, a__1[1] = trans;
00247 s_cat(ch__1, a__1, i__3, &c__2, (ftnlen)2);
00248 i__1 = *n - 1;
00249 i__2 = *n - 1;
00250 nb = ilaenv_(&c__1, "DORMQR", ch__1, m, &i__1, &i__2, &c_n1);
00251 }
00252 } else {
00253 if (left) {
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 = *m - 1;
00259 i__2 = *m - 1;
00260 nb = ilaenv_(&c__1, "DORMLQ", ch__1, &i__1, n, &i__2, &c_n1);
00261 } else {
00262
00263 i__3[0] = 1, a__1[0] = side;
00264 i__3[1] = 1, a__1[1] = trans;
00265 s_cat(ch__1, a__1, i__3, &c__2, (ftnlen)2);
00266 i__1 = *n - 1;
00267 i__2 = *n - 1;
00268 nb = ilaenv_(&c__1, "DORMLQ", ch__1, m, &i__1, &i__2, &c_n1);
00269 }
00270 }
00271 lwkopt = max(1,nw) * nb;
00272 work[1] = (doublereal) lwkopt;
00273 }
00274
00275 if (*info != 0) {
00276 i__1 = -(*info);
00277 xerbla_("DORMBR", &i__1);
00278 return 0;
00279 } else if (lquery) {
00280 return 0;
00281 }
00282
00283
00284
00285 work[1] = 1.;
00286 if (*m == 0 || *n == 0) {
00287 return 0;
00288 }
00289
00290 if (applyq) {
00291
00292
00293
00294 if (nq >= *k) {
00295
00296
00297
00298 dormqr_(side, trans, m, n, k, &a[a_offset], lda, &tau[1], &c__[
00299 c_offset], ldc, &work[1], lwork, &iinfo);
00300 } else if (nq > 1) {
00301
00302
00303
00304 if (left) {
00305 mi = *m - 1;
00306 ni = *n;
00307 i1 = 2;
00308 i2 = 1;
00309 } else {
00310 mi = *m;
00311 ni = *n - 1;
00312 i1 = 1;
00313 i2 = 2;
00314 }
00315 i__1 = nq - 1;
00316 dormqr_(side, trans, &mi, &ni, &i__1, &a[a_dim1 + 2], lda, &tau[1]
00317 , &c__[i1 + i2 * c_dim1], ldc, &work[1], lwork, &iinfo);
00318 }
00319 } else {
00320
00321
00322
00323 if (notran) {
00324 *(unsigned char *)transt = 'T';
00325 } else {
00326 *(unsigned char *)transt = 'N';
00327 }
00328 if (nq > *k) {
00329
00330
00331
00332 dormlq_(side, transt, m, n, k, &a[a_offset], lda, &tau[1], &c__[
00333 c_offset], ldc, &work[1], lwork, &iinfo);
00334 } else if (nq > 1) {
00335
00336
00337
00338 if (left) {
00339 mi = *m - 1;
00340 ni = *n;
00341 i1 = 2;
00342 i2 = 1;
00343 } else {
00344 mi = *m;
00345 ni = *n - 1;
00346 i1 = 1;
00347 i2 = 2;
00348 }
00349 i__1 = nq - 1;
00350 dormlq_(side, transt, &mi, &ni, &i__1, &a[(a_dim1 << 1) + 1], lda,
00351 &tau[1], &c__[i1 + i2 * c_dim1], ldc, &work[1], lwork, &
00352 iinfo);
00353 }
00354 }
00355 work[1] = (doublereal) lwkopt;
00356 return 0;
00357
00358
00359
00360 }