3 /* Subroutine */ int sorml2_(char *side, char *trans, integer *m, integer *n,
4 integer *k, real *a, integer *lda, real *tau, real *c__, integer *ldc,
5 real *work, integer *info)
7 /* System generated locals */
8 integer a_dim1, a_offset, c_dim1, c_offset, i__1, i__2;
11 integer i__, i1, i2, i3, ic, jc, mi, ni, nq;
14 extern logical lsame_(char *, char *);
15 extern /* Subroutine */ int slarf_(char *, integer *, integer *, real *,
16 integer *, real *, real *, integer *, real *), xerbla_(
21 /* -- LAPACK routine (version 3.1) -- */
22 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
25 /* .. Scalar Arguments .. */
27 /* .. Array Arguments .. */
33 /* SORML2 overwrites the general real m by n matrix C with */
35 /* Q * C if SIDE = 'L' and TRANS = 'N', or */
37 /* Q'* C if SIDE = 'L' and TRANS = 'T', or */
39 /* C * Q if SIDE = 'R' and TRANS = 'N', or */
41 /* C * Q' if SIDE = 'R' and TRANS = 'T', */
43 /* where Q is a real orthogonal matrix defined as the product of k */
44 /* elementary reflectors */
46 /* Q = H(k) . . . H(2) H(1) */
48 /* as returned by SGELQF. Q is of order m if SIDE = 'L' and of order n */
54 /* SIDE (input) CHARACTER*1 */
55 /* = 'L': apply Q or Q' from the Left */
56 /* = 'R': apply Q or Q' from the Right */
58 /* TRANS (input) CHARACTER*1 */
59 /* = 'N': apply Q (No transpose) */
60 /* = 'T': apply Q' (Transpose) */
62 /* M (input) INTEGER */
63 /* The number of rows of the matrix C. M >= 0. */
65 /* N (input) INTEGER */
66 /* The number of columns of the matrix C. N >= 0. */
68 /* K (input) INTEGER */
69 /* The number of elementary reflectors whose product defines */
71 /* If SIDE = 'L', M >= K >= 0; */
72 /* if SIDE = 'R', N >= K >= 0. */
74 /* A (input) REAL array, dimension */
75 /* (LDA,M) if SIDE = 'L', */
76 /* (LDA,N) if SIDE = 'R' */
77 /* The i-th row must contain the vector which defines the */
78 /* elementary reflector H(i), for i = 1,2,...,k, as returned by */
79 /* SGELQF in the first k rows of its array argument A. */
80 /* A is modified by the routine but restored on exit. */
82 /* LDA (input) INTEGER */
83 /* The leading dimension of the array A. LDA >= max(1,K). */
85 /* TAU (input) REAL array, dimension (K) */
86 /* TAU(i) must contain the scalar factor of the elementary */
87 /* reflector H(i), as returned by SGELQF. */
89 /* C (input/output) REAL array, dimension (LDC,N) */
90 /* On entry, the m by n matrix C. */
91 /* On exit, C is overwritten by Q*C or Q'*C or C*Q' or C*Q. */
93 /* LDC (input) INTEGER */
94 /* The leading dimension of the array C. LDC >= max(1,M). */
96 /* WORK (workspace) REAL array, dimension */
97 /* (N) if SIDE = 'L', */
98 /* (M) if SIDE = 'R' */
100 /* INFO (output) INTEGER */
101 /* = 0: successful exit */
102 /* < 0: if INFO = -i, the i-th argument had an illegal value */
104 /* ===================================================================== */
106 /* .. Parameters .. */
108 /* .. Local Scalars .. */
110 /* .. External Functions .. */
112 /* .. External Subroutines .. */
114 /* .. Intrinsic Functions .. */
116 /* .. Executable Statements .. */
118 /* Test the input arguments */
120 /* Parameter adjustments */
122 a_offset = 1 + a_dim1;
126 c_offset = 1 + c_dim1;
132 left = lsame_(side, "L");
133 notran = lsame_(trans, "N");
135 /* NQ is the order of Q */
142 if (! left && ! lsame_(side, "R")) {
144 } else if (! notran && ! lsame_(trans, "T")) {
150 } else if (*k < 0 || *k > nq) {
152 } else if (*lda < max(1,*k)) {
154 } else if (*ldc < max(1,*m)) {
159 xerbla_("SORML2", &i__1);
163 /* Quick return if possible */
165 if (*m == 0 || *n == 0 || *k == 0) {
169 if (left && notran || ! left && ! notran) {
189 for (i__ = i1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) {
192 /* H(i) is applied to C(i:m,1:n) */
198 /* H(i) is applied to C(1:m,i:n) */
206 aii = a[i__ + i__ * a_dim1];
207 a[i__ + i__ * a_dim1] = 1.f;
208 slarf_(side, &mi, &ni, &a[i__ + i__ * a_dim1], lda, &tau[i__], &c__[
209 ic + jc * c_dim1], ldc, &work[1]);
210 a[i__ + i__ * a_dim1] = aii;