3 /* Subroutine */ int sorgl2_(integer *m, integer *n, integer *k, real *a,
4 integer *lda, real *tau, real *work, integer *info)
6 /* System generated locals */
7 integer a_dim1, a_offset, i__1, i__2;
12 extern /* Subroutine */ int sscal_(integer *, real *, real *, integer *),
13 slarf_(char *, integer *, integer *, real *, integer *, real *,
14 real *, integer *, real *), 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 /* SORGL2 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 SGELQF. */
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) REAL 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 SGELQF 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) REAL array, dimension (K) */
60 /* TAU(i) must contain the scalar factor of the elementary */
61 /* reflector H(i), as returned by SGELQF. */
63 /* WORK (workspace) REAL 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_("SORGL2", &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.f;
124 if (j > *k && j <= *m) {
125 a[j + j * a_dim1] = 1.f;
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.f;
140 slarf_("Right", &i__1, &i__2, &a[i__ + i__ * a_dim1], lda, &
141 tau[i__], &a[i__ + 1 + i__ * a_dim1], lda, &work[1]);
145 sscal_(&i__1, &r__1, &a[i__ + (i__ + 1) * a_dim1], lda);
147 a[i__ + i__ * a_dim1] = 1.f - 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.f;