3 /* Table of constant values */
5 static integer c__1 = 1;
7 /* Subroutine */ int sorm2r_(char *side, char *trans, integer *m, integer *n,
8 integer *k, real *a, integer *lda, real *tau, real *c__, integer *ldc,
9 real *work, integer *info)
11 /* System generated locals */
12 integer a_dim1, a_offset, c_dim1, c_offset, i__1, i__2;
15 integer i__, i1, i2, i3, ic, jc, mi, ni, nq;
18 extern logical lsame_(char *, char *);
19 extern /* Subroutine */ int slarf_(char *, integer *, integer *, real *,
20 integer *, real *, real *, integer *, real *), xerbla_(
25 /* -- LAPACK routine (version 3.1) -- */
26 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
29 /* .. Scalar Arguments .. */
31 /* .. Array Arguments .. */
37 /* SORM2R overwrites the general real m by n matrix C with */
39 /* Q * C if SIDE = 'L' and TRANS = 'N', or */
41 /* Q'* C if SIDE = 'L' and TRANS = 'T', or */
43 /* C * Q if SIDE = 'R' and TRANS = 'N', or */
45 /* C * Q' if SIDE = 'R' and TRANS = 'T', */
47 /* where Q is a real orthogonal matrix defined as the product of k */
48 /* elementary reflectors */
50 /* Q = H(1) H(2) . . . H(k) */
52 /* as returned by SGEQRF. Q is of order m if SIDE = 'L' and of order n */
58 /* SIDE (input) CHARACTER*1 */
59 /* = 'L': apply Q or Q' from the Left */
60 /* = 'R': apply Q or Q' from the Right */
62 /* TRANS (input) CHARACTER*1 */
63 /* = 'N': apply Q (No transpose) */
64 /* = 'T': apply Q' (Transpose) */
66 /* M (input) INTEGER */
67 /* The number of rows of the matrix C. M >= 0. */
69 /* N (input) INTEGER */
70 /* The number of columns of the matrix C. N >= 0. */
72 /* K (input) INTEGER */
73 /* The number of elementary reflectors whose product defines */
75 /* If SIDE = 'L', M >= K >= 0; */
76 /* if SIDE = 'R', N >= K >= 0. */
78 /* A (input) REAL array, dimension (LDA,K) */
79 /* The i-th column must contain the vector which defines the */
80 /* elementary reflector H(i), for i = 1,2,...,k, as returned by */
81 /* SGEQRF in the first k columns of its array argument A. */
82 /* A is modified by the routine but restored on exit. */
84 /* LDA (input) INTEGER */
85 /* The leading dimension of the array A. */
86 /* If SIDE = 'L', LDA >= max(1,M); */
87 /* if SIDE = 'R', LDA >= max(1,N). */
89 /* TAU (input) REAL array, dimension (K) */
90 /* TAU(i) must contain the scalar factor of the elementary */
91 /* reflector H(i), as returned by SGEQRF. */
93 /* C (input/output) REAL array, dimension (LDC,N) */
94 /* On entry, the m by n matrix C. */
95 /* On exit, C is overwritten by Q*C or Q'*C or C*Q' or C*Q. */
97 /* LDC (input) INTEGER */
98 /* The leading dimension of the array C. LDC >= max(1,M). */
100 /* WORK (workspace) REAL array, dimension */
101 /* (N) if SIDE = 'L', */
102 /* (M) if SIDE = 'R' */
104 /* INFO (output) INTEGER */
105 /* = 0: successful exit */
106 /* < 0: if INFO = -i, the i-th argument had an illegal value */
108 /* ===================================================================== */
110 /* .. Parameters .. */
112 /* .. Local Scalars .. */
114 /* .. External Functions .. */
116 /* .. External Subroutines .. */
118 /* .. Intrinsic Functions .. */
120 /* .. Executable Statements .. */
122 /* Test the input arguments */
124 /* Parameter adjustments */
126 a_offset = 1 + a_dim1;
130 c_offset = 1 + c_dim1;
136 left = lsame_(side, "L");
137 notran = lsame_(trans, "N");
139 /* NQ is the order of Q */
146 if (! left && ! lsame_(side, "R")) {
148 } else if (! notran && ! lsame_(trans, "T")) {
154 } else if (*k < 0 || *k > nq) {
156 } else if (*lda < max(1,nq)) {
158 } else if (*ldc < max(1,*m)) {
163 xerbla_("SORM2R", &i__1);
167 /* Quick return if possible */
169 if (*m == 0 || *n == 0 || *k == 0) {
173 if (left && ! notran || ! left && notran) {
193 for (i__ = i1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) {
196 /* H(i) is applied to C(i:m,1:n) */
202 /* H(i) is applied to C(1:m,i:n) */
210 aii = a[i__ + i__ * a_dim1];
211 a[i__ + i__ * a_dim1] = 1.f;
212 slarf_(side, &mi, &ni, &a[i__ + i__ * a_dim1], &c__1, &tau[i__], &c__[
213 ic + jc * c_dim1], ldc, &work[1]);
214 a[i__ + i__ * a_dim1] = aii;