3 /* Table of constant values */
5 static integer c__1 = 1;
7 /* Subroutine */ int sorg2r_(integer *m, integer *n, integer *k, real *a,
8 integer *lda, real *tau, real *work, integer *info)
10 /* System generated locals */
11 integer a_dim1, a_offset, i__1, i__2;
16 extern /* Subroutine */ int sscal_(integer *, real *, real *, integer *),
17 slarf_(char *, integer *, integer *, real *, integer *, real *,
18 real *, integer *, real *), xerbla_(char *, integer *);
21 /* -- LAPACK routine (version 3.1) -- */
22 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
25 /* .. Scalar Arguments .. */
27 /* .. Array Arguments .. */
33 /* SORG2R generates an m by n real matrix Q with orthonormal columns, */
34 /* which is defined as the first n columns of a product of k elementary */
35 /* reflectors of order m */
37 /* Q = H(1) H(2) . . . H(k) */
39 /* as returned by SGEQRF. */
44 /* M (input) INTEGER */
45 /* The number of rows of the matrix Q. M >= 0. */
47 /* N (input) INTEGER */
48 /* The number of columns of the matrix Q. M >= N >= 0. */
50 /* K (input) INTEGER */
51 /* The number of elementary reflectors whose product defines the */
52 /* matrix Q. N >= K >= 0. */
54 /* A (input/output) REAL array, dimension (LDA,N) */
55 /* On entry, the i-th column must contain the vector which */
56 /* defines the elementary reflector H(i), for i = 1,2,...,k, as */
57 /* returned by SGEQRF in the first k columns of its array */
59 /* On exit, the m-by-n matrix Q. */
61 /* LDA (input) INTEGER */
62 /* The first dimension of the array A. LDA >= max(1,M). */
64 /* TAU (input) REAL array, dimension (K) */
65 /* TAU(i) must contain the scalar factor of the elementary */
66 /* reflector H(i), as returned by SGEQRF. */
68 /* WORK (workspace) REAL array, dimension (N) */
70 /* INFO (output) INTEGER */
71 /* = 0: successful exit */
72 /* < 0: if INFO = -i, the i-th argument has an illegal value */
74 /* ===================================================================== */
76 /* .. Parameters .. */
78 /* .. Local Scalars .. */
80 /* .. External Subroutines .. */
82 /* .. Intrinsic Functions .. */
84 /* .. Executable Statements .. */
86 /* Test the input arguments */
88 /* Parameter adjustments */
90 a_offset = 1 + a_dim1;
99 } else if (*n < 0 || *n > *m) {
101 } else if (*k < 0 || *k > *n) {
103 } else if (*lda < max(1,*m)) {
108 xerbla_("SORG2R", &i__1);
112 /* Quick return if possible */
118 /* Initialise columns k+1:n to columns of the unit matrix */
121 for (j = *k + 1; j <= i__1; ++j) {
123 for (l = 1; l <= i__2; ++l) {
124 a[l + j * a_dim1] = 0.f;
127 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 left */
136 a[i__ + i__ * a_dim1] = 1.f;
139 slarf_("Left", &i__1, &i__2, &a[i__ + i__ * a_dim1], &c__1, &tau[
140 i__], &a[i__ + (i__ + 1) * a_dim1], lda, &work[1]);
145 sscal_(&i__1, &r__1, &a[i__ + 1 + i__ * a_dim1], &c__1);
147 a[i__ + i__ * a_dim1] = 1.f - tau[i__];
149 /* Set A(1:i-1,i) to zero */
152 for (l = 1; l <= i__1; ++l) {
153 a[l + i__ * a_dim1] = 0.f;