3 /* Subroutine */ int dorgl2_(integer *m, integer *n, integer *k, doublereal *
4 a, integer *lda, doublereal *tau, doublereal *work, integer *info)
6 /* System generated locals */
7 integer a_dim1, a_offset, i__1, i__2;
12 extern /* Subroutine */ int dscal_(integer *, doublereal *, doublereal *,
13 integer *), dlarf_(char *, integer *, integer *, doublereal *,
14 integer *, doublereal *, doublereal *, integer *, doublereal *), xerbla_(char *, integer *);
17 /* -- LAPACK routine (version 3.1) -- */
18 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
21 /* .. Scalar Arguments .. */
23 /* .. Array Arguments .. */
29 /* DORGL2 generates an m by n real matrix Q with orthonormal rows, */
30 /* which is defined as the first m rows of a product of k elementary */
31 /* reflectors of order n */
33 /* Q = H(k) . . . H(2) H(1) */
35 /* as returned by DGELQF. */
40 /* M (input) INTEGER */
41 /* The number of rows of the matrix Q. M >= 0. */
43 /* N (input) INTEGER */
44 /* The number of columns of the matrix Q. N >= M. */
46 /* K (input) INTEGER */
47 /* The number of elementary reflectors whose product defines the */
48 /* matrix Q. M >= K >= 0. */
50 /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
51 /* On entry, the i-th row must contain the vector which defines */
52 /* the elementary reflector H(i), for i = 1,2,...,k, as returned */
53 /* by DGELQF in the first k rows of its array argument A. */
54 /* On exit, the m-by-n matrix Q. */
56 /* LDA (input) INTEGER */
57 /* The first dimension of the array A. LDA >= max(1,M). */
59 /* TAU (input) DOUBLE PRECISION array, dimension (K) */
60 /* TAU(i) must contain the scalar factor of the elementary */
61 /* reflector H(i), as returned by DGELQF. */
63 /* WORK (workspace) DOUBLE PRECISION array, dimension (M) */
65 /* INFO (output) INTEGER */
66 /* = 0: successful exit */
67 /* < 0: if INFO = -i, the i-th argument has an illegal value */
69 /* ===================================================================== */
71 /* .. Parameters .. */
73 /* .. Local Scalars .. */
75 /* .. External Subroutines .. */
77 /* .. Intrinsic Functions .. */
79 /* .. Executable Statements .. */
81 /* Test the input arguments */
83 /* Parameter adjustments */
85 a_offset = 1 + a_dim1;
96 } else if (*k < 0 || *k > *m) {
98 } else if (*lda < max(1,*m)) {
103 xerbla_("DORGL2", &i__1);
107 /* Quick return if possible */
115 /* Initialise rows k+1:m to rows of the unit matrix */
118 for (j = 1; j <= i__1; ++j) {
120 for (l = *k + 1; l <= i__2; ++l) {
121 a[l + j * a_dim1] = 0.;
124 if (j > *k && j <= *m) {
125 a[j + j * a_dim1] = 1.;
131 for (i__ = *k; i__ >= 1; --i__) {
133 /* Apply H(i) to A(i:m,i:n) from the right */
137 a[i__ + i__ * a_dim1] = 1.;
140 dlarf_("Right", &i__1, &i__2, &a[i__ + i__ * a_dim1], lda, &
141 tau[i__], &a[i__ + 1 + i__ * a_dim1], lda, &work[1]);
145 dscal_(&i__1, &d__1, &a[i__ + (i__ + 1) * a_dim1], lda);
147 a[i__ + i__ * a_dim1] = 1. - tau[i__];
149 /* Set A(i,1:i-1) to zero */
152 for (l = 1; l <= i__1; ++l) {
153 a[i__ + l * a_dim1] = 0.;