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__3 = 3;
00021 static integer c__2 = 2;
00022
00023 int cungqr_(integer *m, integer *n, integer *k, complex *a,
00024 integer *lda, complex *tau, complex *work, integer *lwork, integer *
00025 info)
00026 {
00027
00028 integer a_dim1, a_offset, i__1, i__2, i__3, i__4;
00029
00030
00031 integer i__, j, l, ib, nb, ki, kk, nx, iws, nbmin, iinfo;
00032 extern int cung2r_(integer *, integer *, integer *,
00033 complex *, integer *, complex *, complex *, integer *), clarfb_(
00034 char *, char *, char *, char *, integer *, integer *, integer *,
00035 complex *, integer *, complex *, integer *, complex *, integer *,
00036 complex *, integer *), clarft_(
00037 char *, char *, integer *, integer *, complex *, integer *,
00038 complex *, complex *, integer *), xerbla_(char *,
00039 integer *);
00040 extern integer ilaenv_(integer *, char *, char *, integer *, integer *,
00041 integer *, integer *);
00042 integer ldwork, lwkopt;
00043 logical lquery;
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
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 a_dim1 = *lda;
00128 a_offset = 1 + a_dim1;
00129 a -= a_offset;
00130 --tau;
00131 --work;
00132
00133
00134 *info = 0;
00135 nb = ilaenv_(&c__1, "CUNGQR", " ", m, n, k, &c_n1);
00136 lwkopt = max(1,*n) * nb;
00137 work[1].r = (real) lwkopt, work[1].i = 0.f;
00138 lquery = *lwork == -1;
00139 if (*m < 0) {
00140 *info = -1;
00141 } else if (*n < 0 || *n > *m) {
00142 *info = -2;
00143 } else if (*k < 0 || *k > *n) {
00144 *info = -3;
00145 } else if (*lda < max(1,*m)) {
00146 *info = -5;
00147 } else if (*lwork < max(1,*n) && ! lquery) {
00148 *info = -8;
00149 }
00150 if (*info != 0) {
00151 i__1 = -(*info);
00152 xerbla_("CUNGQR", &i__1);
00153 return 0;
00154 } else if (lquery) {
00155 return 0;
00156 }
00157
00158
00159
00160 if (*n <= 0) {
00161 work[1].r = 1.f, work[1].i = 0.f;
00162 return 0;
00163 }
00164
00165 nbmin = 2;
00166 nx = 0;
00167 iws = *n;
00168 if (nb > 1 && nb < *k) {
00169
00170
00171
00172
00173 i__1 = 0, i__2 = ilaenv_(&c__3, "CUNGQR", " ", m, n, k, &c_n1);
00174 nx = max(i__1,i__2);
00175 if (nx < *k) {
00176
00177
00178
00179 ldwork = *n;
00180 iws = ldwork * nb;
00181 if (*lwork < iws) {
00182
00183
00184
00185
00186 nb = *lwork / ldwork;
00187
00188 i__1 = 2, i__2 = ilaenv_(&c__2, "CUNGQR", " ", m, n, k, &c_n1);
00189 nbmin = max(i__1,i__2);
00190 }
00191 }
00192 }
00193
00194 if (nb >= nbmin && nb < *k && nx < *k) {
00195
00196
00197
00198
00199 ki = (*k - nx - 1) / nb * nb;
00200
00201 i__1 = *k, i__2 = ki + nb;
00202 kk = min(i__1,i__2);
00203
00204
00205
00206 i__1 = *n;
00207 for (j = kk + 1; j <= i__1; ++j) {
00208 i__2 = kk;
00209 for (i__ = 1; i__ <= i__2; ++i__) {
00210 i__3 = i__ + j * a_dim1;
00211 a[i__3].r = 0.f, a[i__3].i = 0.f;
00212
00213 }
00214
00215 }
00216 } else {
00217 kk = 0;
00218 }
00219
00220
00221
00222 if (kk < *n) {
00223 i__1 = *m - kk;
00224 i__2 = *n - kk;
00225 i__3 = *k - kk;
00226 cung2r_(&i__1, &i__2, &i__3, &a[kk + 1 + (kk + 1) * a_dim1], lda, &
00227 tau[kk + 1], &work[1], &iinfo);
00228 }
00229
00230 if (kk > 0) {
00231
00232
00233
00234 i__1 = -nb;
00235 for (i__ = ki + 1; i__1 < 0 ? i__ >= 1 : i__ <= 1; i__ += i__1) {
00236
00237 i__2 = nb, i__3 = *k - i__ + 1;
00238 ib = min(i__2,i__3);
00239 if (i__ + ib <= *n) {
00240
00241
00242
00243
00244 i__2 = *m - i__ + 1;
00245 clarft_("Forward", "Columnwise", &i__2, &ib, &a[i__ + i__ *
00246 a_dim1], lda, &tau[i__], &work[1], &ldwork);
00247
00248
00249
00250 i__2 = *m - i__ + 1;
00251 i__3 = *n - i__ - ib + 1;
00252 clarfb_("Left", "No transpose", "Forward", "Columnwise", &
00253 i__2, &i__3, &ib, &a[i__ + i__ * a_dim1], lda, &work[
00254 1], &ldwork, &a[i__ + (i__ + ib) * a_dim1], lda, &
00255 work[ib + 1], &ldwork);
00256 }
00257
00258
00259
00260 i__2 = *m - i__ + 1;
00261 cung2r_(&i__2, &ib, &ib, &a[i__ + i__ * a_dim1], lda, &tau[i__], &
00262 work[1], &iinfo);
00263
00264
00265
00266 i__2 = i__ + ib - 1;
00267 for (j = i__; j <= i__2; ++j) {
00268 i__3 = i__ - 1;
00269 for (l = 1; l <= i__3; ++l) {
00270 i__4 = l + j * a_dim1;
00271 a[i__4].r = 0.f, a[i__4].i = 0.f;
00272
00273 }
00274
00275 }
00276
00277 }
00278 }
00279
00280 work[1].r = (real) iws, work[1].i = 0.f;
00281 return 0;
00282
00283
00284
00285 }