/root/doris/contrib/openblas/lapack-netlib/SRC/sgelqf.c
Line | Count | Source |
1 | | #include <math.h> |
2 | | #include <stdlib.h> |
3 | | #include <string.h> |
4 | | #include <stdio.h> |
5 | | #include <complex.h> |
6 | | #ifdef complex |
7 | | #undef complex |
8 | | #endif |
9 | | #ifdef I |
10 | | #undef I |
11 | | #endif |
12 | | |
13 | | #if defined(_WIN64) |
14 | | typedef long long BLASLONG; |
15 | | typedef unsigned long long BLASULONG; |
16 | | #else |
17 | | typedef long BLASLONG; |
18 | | typedef unsigned long BLASULONG; |
19 | | #endif |
20 | | |
21 | | #ifdef LAPACK_ILP64 |
22 | | typedef BLASLONG blasint; |
23 | | #if defined(_WIN64) |
24 | | #define blasabs(x) llabs(x) |
25 | | #else |
26 | | #define blasabs(x) labs(x) |
27 | | #endif |
28 | | #else |
29 | | typedef int blasint; |
30 | | #define blasabs(x) abs(x) |
31 | | #endif |
32 | | |
33 | | typedef blasint integer; |
34 | | |
35 | | typedef unsigned int uinteger; |
36 | | typedef char *address; |
37 | | typedef short int shortint; |
38 | | typedef float real; |
39 | | typedef double doublereal; |
40 | | typedef struct { real r, i; } complex; |
41 | | typedef struct { doublereal r, i; } doublecomplex; |
42 | | #ifdef _MSC_VER |
43 | | static inline _Fcomplex Cf(complex *z) {_Fcomplex zz={z->r , z->i}; return zz;} |
44 | | static inline _Dcomplex Cd(doublecomplex *z) {_Dcomplex zz={z->r , z->i};return zz;} |
45 | | static inline _Fcomplex * _pCf(complex *z) {return (_Fcomplex*)z;} |
46 | | static inline _Dcomplex * _pCd(doublecomplex *z) {return (_Dcomplex*)z;} |
47 | | #else |
48 | 0 | static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} |
49 | 0 | static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} |
50 | 0 | static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} |
51 | 0 | static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} |
52 | | #endif |
53 | | #define pCf(z) (*_pCf(z)) |
54 | | #define pCd(z) (*_pCd(z)) |
55 | | typedef blasint logical; |
56 | | |
57 | | typedef char logical1; |
58 | | typedef char integer1; |
59 | | |
60 | | #define TRUE_ (1) |
61 | | #define FALSE_ (0) |
62 | | |
63 | | /* Extern is for use with -E */ |
64 | | #ifndef Extern |
65 | | #define Extern extern |
66 | | #endif |
67 | | |
68 | | /* I/O stuff */ |
69 | | |
70 | | typedef int flag; |
71 | | typedef int ftnlen; |
72 | | typedef int ftnint; |
73 | | |
74 | | /*external read, write*/ |
75 | | typedef struct |
76 | | { flag cierr; |
77 | | ftnint ciunit; |
78 | | flag ciend; |
79 | | char *cifmt; |
80 | | ftnint cirec; |
81 | | } cilist; |
82 | | |
83 | | /*internal read, write*/ |
84 | | typedef struct |
85 | | { flag icierr; |
86 | | char *iciunit; |
87 | | flag iciend; |
88 | | char *icifmt; |
89 | | ftnint icirlen; |
90 | | ftnint icirnum; |
91 | | } icilist; |
92 | | |
93 | | /*open*/ |
94 | | typedef struct |
95 | | { flag oerr; |
96 | | ftnint ounit; |
97 | | char *ofnm; |
98 | | ftnlen ofnmlen; |
99 | | char *osta; |
100 | | char *oacc; |
101 | | char *ofm; |
102 | | ftnint orl; |
103 | | char *oblnk; |
104 | | } olist; |
105 | | |
106 | | /*close*/ |
107 | | typedef struct |
108 | | { flag cerr; |
109 | | ftnint cunit; |
110 | | char *csta; |
111 | | } cllist; |
112 | | |
113 | | /*rewind, backspace, endfile*/ |
114 | | typedef struct |
115 | | { flag aerr; |
116 | | ftnint aunit; |
117 | | } alist; |
118 | | |
119 | | /* inquire */ |
120 | | typedef struct |
121 | | { flag inerr; |
122 | | ftnint inunit; |
123 | | char *infile; |
124 | | ftnlen infilen; |
125 | | ftnint *inex; /*parameters in standard's order*/ |
126 | | ftnint *inopen; |
127 | | ftnint *innum; |
128 | | ftnint *innamed; |
129 | | char *inname; |
130 | | ftnlen innamlen; |
131 | | char *inacc; |
132 | | ftnlen inacclen; |
133 | | char *inseq; |
134 | | ftnlen inseqlen; |
135 | | char *indir; |
136 | | ftnlen indirlen; |
137 | | char *infmt; |
138 | | ftnlen infmtlen; |
139 | | char *inform; |
140 | | ftnint informlen; |
141 | | char *inunf; |
142 | | ftnlen inunflen; |
143 | | ftnint *inrecl; |
144 | | ftnint *innrec; |
145 | | char *inblank; |
146 | | ftnlen inblanklen; |
147 | | } inlist; |
148 | | |
149 | | #define VOID void |
150 | | |
151 | | union Multitype { /* for multiple entry points */ |
152 | | integer1 g; |
153 | | shortint h; |
154 | | integer i; |
155 | | /* longint j; */ |
156 | | real r; |
157 | | doublereal d; |
158 | | complex c; |
159 | | doublecomplex z; |
160 | | }; |
161 | | |
162 | | typedef union Multitype Multitype; |
163 | | |
164 | | struct Vardesc { /* for Namelist */ |
165 | | char *name; |
166 | | char *addr; |
167 | | ftnlen *dims; |
168 | | int type; |
169 | | }; |
170 | | typedef struct Vardesc Vardesc; |
171 | | |
172 | | struct Namelist { |
173 | | char *name; |
174 | | Vardesc **vars; |
175 | | int nvars; |
176 | | }; |
177 | | typedef struct Namelist Namelist; |
178 | | |
179 | | #define abs(x) ((x) >= 0 ? (x) : -(x)) |
180 | | #define dabs(x) (fabs(x)) |
181 | 0 | #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) |
182 | 0 | #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) |
183 | | #define dmin(a,b) (f2cmin(a,b)) |
184 | | #define dmax(a,b) (f2cmax(a,b)) |
185 | | #define bit_test(a,b) ((a) >> (b) & 1) |
186 | | #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) |
187 | | #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) |
188 | | |
189 | | #define abort_() { sig_die("Fortran abort routine called", 1); } |
190 | | #define c_abs(z) (cabsf(Cf(z))) |
191 | | #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } |
192 | | #ifdef _MSC_VER |
193 | | #define c_div(c, a, b) {Cf(c)._Val[0] = (Cf(a)._Val[0]/Cf(b)._Val[0]); Cf(c)._Val[1]=(Cf(a)._Val[1]/Cf(b)._Val[1]);} |
194 | | #define z_div(c, a, b) {Cd(c)._Val[0] = (Cd(a)._Val[0]/Cd(b)._Val[0]); Cd(c)._Val[1]=(Cd(a)._Val[1]/df(b)._Val[1]);} |
195 | | #else |
196 | | #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} |
197 | | #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} |
198 | | #endif |
199 | | #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} |
200 | | #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} |
201 | | #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} |
202 | | //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} |
203 | | #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} |
204 | | #define d_abs(x) (fabs(*(x))) |
205 | | #define d_acos(x) (acos(*(x))) |
206 | | #define d_asin(x) (asin(*(x))) |
207 | | #define d_atan(x) (atan(*(x))) |
208 | | #define d_atn2(x, y) (atan2(*(x),*(y))) |
209 | | #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } |
210 | | #define r_cnjg(R, Z) { pCf(R) = conjf(Cf(Z)); } |
211 | | #define d_cos(x) (cos(*(x))) |
212 | | #define d_cosh(x) (cosh(*(x))) |
213 | | #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) |
214 | | #define d_exp(x) (exp(*(x))) |
215 | | #define d_imag(z) (cimag(Cd(z))) |
216 | | #define r_imag(z) (cimagf(Cf(z))) |
217 | | #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) |
218 | | #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) |
219 | | #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) |
220 | | #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) |
221 | | #define d_log(x) (log(*(x))) |
222 | | #define d_mod(x, y) (fmod(*(x), *(y))) |
223 | | #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) |
224 | | #define d_nint(x) u_nint(*(x)) |
225 | | #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) |
226 | | #define d_sign(a,b) u_sign(*(a),*(b)) |
227 | | #define r_sign(a,b) u_sign(*(a),*(b)) |
228 | | #define d_sin(x) (sin(*(x))) |
229 | | #define d_sinh(x) (sinh(*(x))) |
230 | | #define d_sqrt(x) (sqrt(*(x))) |
231 | | #define d_tan(x) (tan(*(x))) |
232 | | #define d_tanh(x) (tanh(*(x))) |
233 | | #define i_abs(x) abs(*(x)) |
234 | | #define i_dnnt(x) ((integer)u_nint(*(x))) |
235 | | #define i_len(s, n) (n) |
236 | | #define i_nint(x) ((integer)u_nint(*(x))) |
237 | | #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) |
238 | | #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } |
239 | | #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) |
240 | | #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } |
241 | | #define sig_die(s, kill) { exit(1); } |
242 | | #define s_stop(s, n) {exit(0);} |
243 | | #define z_abs(z) (cabs(Cd(z))) |
244 | | #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} |
245 | | #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} |
246 | | #define myexit_() break; |
247 | | #define mycycle() continue; |
248 | | #define myceiling(w) {ceil(w)} |
249 | | #define myhuge(w) {HUGE_VAL} |
250 | | //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} |
251 | | #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} |
252 | | |
253 | | /* -- translated by f2c (version 20000121). |
254 | | You must link the resulting object file with the libraries: |
255 | | -lf2c -lm (in that order) |
256 | | */ |
257 | | |
258 | | |
259 | | |
260 | | |
261 | | /* Table of constant values */ |
262 | | |
263 | | static integer c__1 = 1; |
264 | | static integer c_n1 = -1; |
265 | | static integer c__3 = 3; |
266 | | static integer c__2 = 2; |
267 | | |
268 | | /* > \brief \b SGELQF */ |
269 | | |
270 | | /* =========== DOCUMENTATION =========== */ |
271 | | |
272 | | /* Online html documentation available at */ |
273 | | /* http://www.netlib.org/lapack/explore-html/ */ |
274 | | |
275 | | /* > \htmlonly */ |
276 | | /* > Download SGELQF + dependencies */ |
277 | | /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sgelqf. |
278 | | f"> */ |
279 | | /* > [TGZ]</a> */ |
280 | | /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sgelqf. |
281 | | f"> */ |
282 | | /* > [ZIP]</a> */ |
283 | | /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sgelqf. |
284 | | f"> */ |
285 | | /* > [TXT]</a> */ |
286 | | /* > \endhtmlonly */ |
287 | | |
288 | | /* Definition: */ |
289 | | /* =========== */ |
290 | | |
291 | | /* SUBROUTINE SGELQF( M, N, A, LDA, TAU, WORK, LWORK, INFO ) */ |
292 | | |
293 | | /* INTEGER INFO, LDA, LWORK, M, N */ |
294 | | /* REAL A( LDA, * ), TAU( * ), WORK( * ) */ |
295 | | |
296 | | |
297 | | /* > \par Purpose: */ |
298 | | /* ============= */ |
299 | | /* > */ |
300 | | /* > \verbatim */ |
301 | | /* > */ |
302 | | /* > SGELQF computes an LQ factorization of a real M-by-N matrix A: */ |
303 | | /* > */ |
304 | | /* > A = ( L 0 ) * Q */ |
305 | | /* > */ |
306 | | /* > where: */ |
307 | | /* > */ |
308 | | /* > Q is a N-by-N orthogonal matrix; */ |
309 | | /* > L is an lower-triangular M-by-M matrix; */ |
310 | | /* > 0 is a M-by-(N-M) zero matrix, if M < N. */ |
311 | | /* > */ |
312 | | /* > \endverbatim */ |
313 | | |
314 | | /* Arguments: */ |
315 | | /* ========== */ |
316 | | |
317 | | /* > \param[in] M */ |
318 | | /* > \verbatim */ |
319 | | /* > M is INTEGER */ |
320 | | /* > The number of rows of the matrix A. M >= 0. */ |
321 | | /* > \endverbatim */ |
322 | | /* > */ |
323 | | /* > \param[in] N */ |
324 | | /* > \verbatim */ |
325 | | /* > N is INTEGER */ |
326 | | /* > The number of columns of the matrix A. N >= 0. */ |
327 | | /* > \endverbatim */ |
328 | | /* > */ |
329 | | /* > \param[in,out] A */ |
330 | | /* > \verbatim */ |
331 | | /* > A is REAL array, dimension (LDA,N) */ |
332 | | /* > On entry, the M-by-N matrix A. */ |
333 | | /* > On exit, the elements on and below the diagonal of the array */ |
334 | | /* > contain the m-by-f2cmin(m,n) lower trapezoidal matrix L (L is */ |
335 | | /* > lower triangular if m <= n); the elements above the diagonal, */ |
336 | | /* > with the array TAU, represent the orthogonal matrix Q as a */ |
337 | | /* > product of elementary reflectors (see Further Details). */ |
338 | | /* > \endverbatim */ |
339 | | /* > */ |
340 | | /* > \param[in] LDA */ |
341 | | /* > \verbatim */ |
342 | | /* > LDA is INTEGER */ |
343 | | /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ |
344 | | /* > \endverbatim */ |
345 | | /* > */ |
346 | | /* > \param[out] TAU */ |
347 | | /* > \verbatim */ |
348 | | /* > TAU is REAL array, dimension (f2cmin(M,N)) */ |
349 | | /* > The scalar factors of the elementary reflectors (see Further */ |
350 | | /* > Details). */ |
351 | | /* > \endverbatim */ |
352 | | /* > */ |
353 | | /* > \param[out] WORK */ |
354 | | /* > \verbatim */ |
355 | | /* > WORK is REAL array, dimension (MAX(1,LWORK)) */ |
356 | | /* > On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ |
357 | | /* > \endverbatim */ |
358 | | /* > */ |
359 | | /* > \param[in] LWORK */ |
360 | | /* > \verbatim */ |
361 | | /* > LWORK is INTEGER */ |
362 | | /* > The dimension of the array WORK. LWORK >= f2cmax(1,M). */ |
363 | | /* > For optimum performance LWORK >= M*NB, where NB is the */ |
364 | | /* > optimal blocksize. */ |
365 | | /* > */ |
366 | | /* > If LWORK = -1, then a workspace query is assumed; the routine */ |
367 | | /* > only calculates the optimal size of the WORK array, returns */ |
368 | | /* > this value as the first entry of the WORK array, and no error */ |
369 | | /* > message related to LWORK is issued by XERBLA. */ |
370 | | /* > \endverbatim */ |
371 | | /* > */ |
372 | | /* > \param[out] INFO */ |
373 | | /* > \verbatim */ |
374 | | /* > INFO is INTEGER */ |
375 | | /* > = 0: successful exit */ |
376 | | /* > < 0: if INFO = -i, the i-th argument had an illegal value */ |
377 | | /* > \endverbatim */ |
378 | | |
379 | | /* Authors: */ |
380 | | /* ======== */ |
381 | | |
382 | | /* > \author Univ. of Tennessee */ |
383 | | /* > \author Univ. of California Berkeley */ |
384 | | /* > \author Univ. of Colorado Denver */ |
385 | | /* > \author NAG Ltd. */ |
386 | | |
387 | | /* > \date November 2019 */ |
388 | | |
389 | | /* > \ingroup realGEcomputational */ |
390 | | |
391 | | /* > \par Further Details: */ |
392 | | /* ===================== */ |
393 | | /* > */ |
394 | | /* > \verbatim */ |
395 | | /* > */ |
396 | | /* > The matrix Q is represented as a product of elementary reflectors */ |
397 | | /* > */ |
398 | | /* > Q = H(k) . . . H(2) H(1), where k = f2cmin(m,n). */ |
399 | | /* > */ |
400 | | /* > Each H(i) has the form */ |
401 | | /* > */ |
402 | | /* > H(i) = I - tau * v * v**T */ |
403 | | /* > */ |
404 | | /* > where tau is a real scalar, and v is a real vector with */ |
405 | | /* > v(1:i-1) = 0 and v(i) = 1; v(i+1:n) is stored on exit in A(i,i+1:n), */ |
406 | | /* > and tau in TAU(i). */ |
407 | | /* > \endverbatim */ |
408 | | /* > */ |
409 | | /* ===================================================================== */ |
410 | | /* Subroutine */ void sgelqf_(integer *m, integer *n, real *a, integer *lda, |
411 | | real *tau, real *work, integer *lwork, integer *info) |
412 | 0 | { |
413 | | /* System generated locals */ |
414 | 0 | integer a_dim1, a_offset, i__1, i__2, i__3, i__4; |
415 | | |
416 | | /* Local variables */ |
417 | 0 | integer i__, k, nbmin, iinfo; |
418 | 0 | extern /* Subroutine */ void sgelq2_(integer *, integer *, real *, integer |
419 | 0 | *, real *, real *, integer *); |
420 | 0 | integer ib, nb, nx; |
421 | 0 | extern /* Subroutine */ void slarfb_(char *, char *, char *, char *, |
422 | 0 | integer *, integer *, integer *, real *, integer *, real *, |
423 | 0 | integer *, real *, integer *, real *, integer *); |
424 | 0 | extern int xerbla_(char *, integer *, ftnlen); |
425 | 0 | extern integer ilaenv_(integer *, char *, char *, integer *, integer *, |
426 | 0 | integer *, integer *, ftnlen, ftnlen); |
427 | 0 | extern /* Subroutine */ void slarft_(char *, char *, integer *, integer *, |
428 | 0 | real *, integer *, real *, real *, integer *); |
429 | 0 | integer ldwork, lwkopt; |
430 | 0 | logical lquery; |
431 | 0 | integer iws; |
432 | | |
433 | | |
434 | | /* -- LAPACK computational routine (version 3.9.0) -- */ |
435 | | /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ |
436 | | /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ |
437 | | /* November 2019 */ |
438 | | |
439 | | |
440 | | /* ===================================================================== */ |
441 | | |
442 | | |
443 | | /* Test the input arguments */ |
444 | | |
445 | | /* Parameter adjustments */ |
446 | 0 | a_dim1 = *lda; |
447 | 0 | a_offset = 1 + a_dim1 * 1; |
448 | 0 | a -= a_offset; |
449 | 0 | --tau; |
450 | 0 | --work; |
451 | | |
452 | | /* Function Body */ |
453 | 0 | *info = 0; |
454 | 0 | nb = ilaenv_(&c__1, "SGELQF", " ", m, n, &c_n1, &c_n1, (ftnlen)6, (ftnlen) |
455 | 0 | 1); |
456 | 0 | lwkopt = *m * nb; |
457 | 0 | work[1] = (real) lwkopt; |
458 | 0 | lquery = *lwork == -1; |
459 | 0 | if (*m < 0) { |
460 | 0 | *info = -1; |
461 | 0 | } else if (*n < 0) { |
462 | 0 | *info = -2; |
463 | 0 | } else if (*lda < f2cmax(1,*m)) { |
464 | 0 | *info = -4; |
465 | 0 | } else if (*lwork < f2cmax(1,*m) && ! lquery) { |
466 | 0 | *info = -7; |
467 | 0 | } |
468 | 0 | if (*info != 0) { |
469 | 0 | i__1 = -(*info); |
470 | 0 | xerbla_("SGELQF", &i__1, (ftnlen)6); |
471 | 0 | return; |
472 | 0 | } else if (lquery) { |
473 | 0 | return; |
474 | 0 | } |
475 | | |
476 | | /* Quick return if possible */ |
477 | | |
478 | 0 | k = f2cmin(*m,*n); |
479 | 0 | if (k == 0) { |
480 | 0 | work[1] = 1.f; |
481 | 0 | return; |
482 | 0 | } |
483 | | |
484 | 0 | nbmin = 2; |
485 | 0 | nx = 0; |
486 | 0 | iws = *m; |
487 | 0 | if (nb > 1 && nb < k) { |
488 | | |
489 | | /* Determine when to cross over from blocked to unblocked code. */ |
490 | | |
491 | | /* Computing MAX */ |
492 | 0 | i__1 = 0, i__2 = ilaenv_(&c__3, "SGELQF", " ", m, n, &c_n1, &c_n1, ( |
493 | 0 | ftnlen)6, (ftnlen)1); |
494 | 0 | nx = f2cmax(i__1,i__2); |
495 | 0 | if (nx < k) { |
496 | | |
497 | | /* Determine if workspace is large enough for blocked code. */ |
498 | |
|
499 | 0 | ldwork = *m; |
500 | 0 | iws = ldwork * nb; |
501 | 0 | if (*lwork < iws) { |
502 | | |
503 | | /* Not enough workspace to use optimal NB: reduce NB and */ |
504 | | /* determine the minimum value of NB. */ |
505 | |
|
506 | 0 | nb = *lwork / ldwork; |
507 | | /* Computing MAX */ |
508 | 0 | i__1 = 2, i__2 = ilaenv_(&c__2, "SGELQF", " ", m, n, &c_n1, & |
509 | 0 | c_n1, (ftnlen)6, (ftnlen)1); |
510 | 0 | nbmin = f2cmax(i__1,i__2); |
511 | 0 | } |
512 | 0 | } |
513 | 0 | } |
514 | |
|
515 | 0 | if (nb >= nbmin && nb < k && nx < k) { |
516 | | |
517 | | /* Use blocked code initially */ |
518 | |
|
519 | 0 | i__1 = k - nx; |
520 | 0 | i__2 = nb; |
521 | 0 | for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) { |
522 | | /* Computing MIN */ |
523 | 0 | i__3 = k - i__ + 1; |
524 | 0 | ib = f2cmin(i__3,nb); |
525 | | |
526 | | /* Compute the LQ factorization of the current block */ |
527 | | /* A(i:i+ib-1,i:n) */ |
528 | |
|
529 | 0 | i__3 = *n - i__ + 1; |
530 | 0 | sgelq2_(&ib, &i__3, &a[i__ + i__ * a_dim1], lda, &tau[i__], &work[ |
531 | 0 | 1], &iinfo); |
532 | 0 | if (i__ + ib <= *m) { |
533 | | |
534 | | /* Form the triangular factor of the block reflector */ |
535 | | /* H = H(i) H(i+1) . . . H(i+ib-1) */ |
536 | |
|
537 | 0 | i__3 = *n - i__ + 1; |
538 | 0 | slarft_("Forward", "Rowwise", &i__3, &ib, &a[i__ + i__ * |
539 | 0 | a_dim1], lda, &tau[i__], &work[1], &ldwork); |
540 | | |
541 | | /* Apply H to A(i+ib:m,i:n) from the right */ |
542 | |
|
543 | 0 | i__3 = *m - i__ - ib + 1; |
544 | 0 | i__4 = *n - i__ + 1; |
545 | 0 | slarfb_("Right", "No transpose", "Forward", "Rowwise", &i__3, |
546 | 0 | &i__4, &ib, &a[i__ + i__ * a_dim1], lda, &work[1], & |
547 | 0 | ldwork, &a[i__ + ib + i__ * a_dim1], lda, &work[ib + |
548 | 0 | 1], &ldwork); |
549 | 0 | } |
550 | | /* L10: */ |
551 | 0 | } |
552 | 0 | } else { |
553 | 0 | i__ = 1; |
554 | 0 | } |
555 | | |
556 | | /* Use unblocked code to factor the last or only block. */ |
557 | |
|
558 | 0 | if (i__ <= k) { |
559 | 0 | i__2 = *m - i__ + 1; |
560 | 0 | i__1 = *n - i__ + 1; |
561 | 0 | sgelq2_(&i__2, &i__1, &a[i__ + i__ * a_dim1], lda, &tau[i__], &work[1] |
562 | 0 | , &iinfo); |
563 | 0 | } |
564 | |
|
565 | 0 | work[1] = (real) iws; |
566 | 0 | return; |
567 | | |
568 | | /* End of SGELQF */ |
569 | |
|
570 | 0 | } /* sgelqf_ */ |
571 | | |