3 /* Subroutine */ int dgelq2_(integer *m, integer *n, doublereal *a, integer *
4 lda, doublereal *tau, doublereal *work, integer *info)
6 /* System generated locals */
7 integer a_dim1, a_offset, i__1, i__2, i__3;
12 extern /* Subroutine */ int dlarf_(char *, integer *, integer *,
13 doublereal *, integer *, doublereal *, doublereal *, integer *,
14 doublereal *), dlarfg_(integer *, doublereal *,
15 doublereal *, integer *, doublereal *), xerbla_(char *, integer *);
18 /* -- LAPACK routine (version 3.1) -- */
19 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
22 /* .. Scalar Arguments .. */
24 /* .. Array Arguments .. */
30 /* DGELQ2 computes an LQ factorization of a real m by n matrix A: */
36 /* M (input) INTEGER */
37 /* The number of rows of the matrix A. M >= 0. */
39 /* N (input) INTEGER */
40 /* The number of columns of the matrix A. N >= 0. */
42 /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
43 /* On entry, the m by n matrix A. */
44 /* On exit, the elements on and below the diagonal of the array */
45 /* contain the m by min(m,n) lower trapezoidal matrix L (L is */
46 /* lower triangular if m <= n); the elements above the diagonal, */
47 /* with the array TAU, represent the orthogonal matrix Q as a */
48 /* product of elementary reflectors (see Further Details). */
50 /* LDA (input) INTEGER */
51 /* The leading dimension of the array A. LDA >= max(1,M). */
53 /* TAU (output) DOUBLE PRECISION array, dimension (min(M,N)) */
54 /* The scalar factors of the elementary reflectors (see Further */
57 /* WORK (workspace) DOUBLE PRECISION array, dimension (M) */
59 /* INFO (output) INTEGER */
60 /* = 0: successful exit */
61 /* < 0: if INFO = -i, the i-th argument had an illegal value */
66 /* The matrix Q is represented as a product of elementary reflectors */
68 /* Q = H(k) . . . H(2) H(1), where k = min(m,n). */
70 /* Each H(i) has the form */
72 /* H(i) = I - tau * v * v' */
74 /* where tau is a real scalar, and v is a real vector with */
75 /* v(1:i-1) = 0 and v(i) = 1; v(i+1:n) is stored on exit in A(i,i+1:n), */
76 /* and tau in TAU(i). */
78 /* ===================================================================== */
80 /* .. Parameters .. */
82 /* .. Local Scalars .. */
84 /* .. External Subroutines .. */
86 /* .. Intrinsic Functions .. */
88 /* .. Executable Statements .. */
90 /* Test the input arguments */
92 /* Parameter adjustments */
94 a_offset = 1 + a_dim1;
105 } else if (*lda < max(1,*m)) {
110 xerbla_("DGELQ2", &i__1);
117 for (i__ = 1; i__ <= i__1; ++i__) {
119 /* Generate elementary reflector H(i) to annihilate A(i,i+1:n) */
124 dlarfg_(&i__2, &a[i__ + i__ * a_dim1], &a[i__ + min(i__3, *n)* a_dim1]
128 /* Apply H(i) to A(i+1:m,i:n) from the right */
130 aii = a[i__ + i__ * a_dim1];
131 a[i__ + i__ * a_dim1] = 1.;
134 dlarf_("Right", &i__2, &i__3, &a[i__ + i__ * a_dim1], lda, &tau[
135 i__], &a[i__ + 1 + i__ * a_dim1], lda, &work[1]);
136 a[i__ + i__ * a_dim1] = aii;