3 /* Table of constant values */
5 static integer c__1 = 1;
6 static real c_b8 = 0.f;
8 /* Subroutine */ int slarft_(char *direct, char *storev, integer *n, integer *
9 k, real *v, integer *ldv, real *tau, real *t, integer *ldt)
11 /* System generated locals */
12 integer t_dim1, t_offset, v_dim1, v_offset, i__1, i__2, i__3;
18 extern logical lsame_(char *, char *);
19 extern /* Subroutine */ int sgemv_(char *, integer *, integer *, real *,
20 real *, integer *, real *, integer *, real *, real *, integer *), strmv_(char *, char *, char *, integer *, real *,
21 integer *, real *, integer *);
24 /* -- LAPACK auxiliary routine (version 3.1) -- */
25 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
28 /* .. Scalar Arguments .. */
30 /* .. Array Arguments .. */
36 /* SLARFT forms the triangular factor T of a real block reflector H */
37 /* of order n, which is defined as a product of k elementary reflectors. */
39 /* If DIRECT = 'F', H = H(1) H(2) . . . H(k) and T is upper triangular; */
41 /* If DIRECT = 'B', H = H(k) . . . H(2) H(1) and T is lower triangular. */
43 /* If STOREV = 'C', the vector which defines the elementary reflector */
44 /* H(i) is stored in the i-th column of the array V, and */
46 /* H = I - V * T * V' */
48 /* If STOREV = 'R', the vector which defines the elementary reflector */
49 /* H(i) is stored in the i-th row of the array V, and */
51 /* H = I - V' * T * V */
56 /* DIRECT (input) CHARACTER*1 */
57 /* Specifies the order in which the elementary reflectors are */
58 /* multiplied to form the block reflector: */
59 /* = 'F': H = H(1) H(2) . . . H(k) (Forward) */
60 /* = 'B': H = H(k) . . . H(2) H(1) (Backward) */
62 /* STOREV (input) CHARACTER*1 */
63 /* Specifies how the vectors which define the elementary */
64 /* reflectors are stored (see also Further Details): */
65 /* = 'C': columnwise */
68 /* N (input) INTEGER */
69 /* The order of the block reflector H. N >= 0. */
71 /* K (input) INTEGER */
72 /* The order of the triangular factor T (= the number of */
73 /* elementary reflectors). K >= 1. */
75 /* V (input/output) REAL array, dimension */
76 /* (LDV,K) if STOREV = 'C' */
77 /* (LDV,N) if STOREV = 'R' */
78 /* The matrix V. See further details. */
80 /* LDV (input) INTEGER */
81 /* The leading dimension of the array V. */
82 /* If STOREV = 'C', LDV >= max(1,N); if STOREV = 'R', LDV >= K. */
84 /* TAU (input) REAL array, dimension (K) */
85 /* TAU(i) must contain the scalar factor of the elementary */
88 /* T (output) REAL array, dimension (LDT,K) */
89 /* The k by k triangular factor T of the block reflector. */
90 /* If DIRECT = 'F', T is upper triangular; if DIRECT = 'B', T is */
91 /* lower triangular. The rest of the array is not used. */
93 /* LDT (input) INTEGER */
94 /* The leading dimension of the array T. LDT >= K. */
99 /* The shape of the matrix V and the storage of the vectors which define */
100 /* the H(i) is best illustrated by the following example with n = 5 and */
101 /* k = 3. The elements equal to 1 are not stored; the corresponding */
102 /* array elements are modified but restored on exit. The rest of the */
103 /* array is not used. */
105 /* DIRECT = 'F' and STOREV = 'C': DIRECT = 'F' and STOREV = 'R': */
107 /* V = ( 1 ) V = ( 1 v1 v1 v1 v1 ) */
108 /* ( v1 1 ) ( 1 v2 v2 v2 ) */
109 /* ( v1 v2 1 ) ( 1 v3 v3 ) */
113 /* DIRECT = 'B' and STOREV = 'C': DIRECT = 'B' and STOREV = 'R': */
115 /* V = ( v1 v2 v3 ) V = ( v1 v1 1 ) */
116 /* ( v1 v2 v3 ) ( v2 v2 v2 1 ) */
117 /* ( 1 v2 v3 ) ( v3 v3 v3 v3 1 ) */
121 /* ===================================================================== */
123 /* .. Parameters .. */
125 /* .. Local Scalars .. */
127 /* .. External Subroutines .. */
129 /* .. External Functions .. */
131 /* .. Executable Statements .. */
133 /* Quick return if possible */
135 /* Parameter adjustments */
137 v_offset = 1 + v_dim1;
141 t_offset = 1 + t_dim1;
149 if (lsame_(direct, "F")) {
151 for (i__ = 1; i__ <= i__1; ++i__) {
152 if (tau[i__] == 0.f) {
157 for (j = 1; j <= i__2; ++j) {
158 t[j + i__ * t_dim1] = 0.f;
165 vii = v[i__ + i__ * v_dim1];
166 v[i__ + i__ * v_dim1] = 1.f;
167 if (lsame_(storev, "C")) {
169 /* T(1:i-1,i) := - tau(i) * V(i:n,1:i-1)' * V(i:n,i) */
174 sgemv_("Transpose", &i__2, &i__3, &r__1, &v[i__ + v_dim1],
175 ldv, &v[i__ + i__ * v_dim1], &c__1, &c_b8, &t[
176 i__ * t_dim1 + 1], &c__1);
179 /* T(1:i-1,i) := - tau(i) * V(1:i-1,i:n) * V(i,i:n)' */
184 sgemv_("No transpose", &i__2, &i__3, &r__1, &v[i__ *
185 v_dim1 + 1], ldv, &v[i__ + i__ * v_dim1], ldv, &
186 c_b8, &t[i__ * t_dim1 + 1], &c__1);
188 v[i__ + i__ * v_dim1] = vii;
190 /* T(1:i-1,i) := T(1:i-1,1:i-1) * T(1:i-1,i) */
193 strmv_("Upper", "No transpose", "Non-unit", &i__2, &t[
194 t_offset], ldt, &t[i__ * t_dim1 + 1], &c__1);
195 t[i__ + i__ * t_dim1] = tau[i__];
200 for (i__ = *k; i__ >= 1; --i__) {
201 if (tau[i__] == 0.f) {
206 for (j = i__; j <= i__1; ++j) {
207 t[j + i__ * t_dim1] = 0.f;
215 if (lsame_(storev, "C")) {
216 vii = v[*n - *k + i__ + i__ * v_dim1];
217 v[*n - *k + i__ + i__ * v_dim1] = 1.f;
220 /* - tau(i) * V(1:n-k+i,i+1:k)' * V(1:n-k+i,i) */
222 i__1 = *n - *k + i__;
225 sgemv_("Transpose", &i__1, &i__2, &r__1, &v[(i__ + 1)
226 * v_dim1 + 1], ldv, &v[i__ * v_dim1 + 1], &
227 c__1, &c_b8, &t[i__ + 1 + i__ * t_dim1], &
229 v[*n - *k + i__ + i__ * v_dim1] = vii;
231 vii = v[i__ + (*n - *k + i__) * v_dim1];
232 v[i__ + (*n - *k + i__) * v_dim1] = 1.f;
235 /* - tau(i) * V(i+1:k,1:n-k+i) * V(i,1:n-k+i)' */
238 i__2 = *n - *k + i__;
240 sgemv_("No transpose", &i__1, &i__2, &r__1, &v[i__ +
241 1 + v_dim1], ldv, &v[i__ + v_dim1], ldv, &
242 c_b8, &t[i__ + 1 + i__ * t_dim1], &c__1);
243 v[i__ + (*n - *k + i__) * v_dim1] = vii;
246 /* T(i+1:k,i) := T(i+1:k,i+1:k) * T(i+1:k,i) */
249 strmv_("Lower", "No transpose", "Non-unit", &i__1, &t[i__
250 + 1 + (i__ + 1) * t_dim1], ldt, &t[i__ + 1 + i__ *
254 t[i__ + i__ * t_dim1] = tau[i__];