3 /* Subroutine */ int dlasr_(char *side, char *pivot, char *direct, integer *m,
4 integer *n, doublereal *c__, doublereal *s, doublereal *a, integer *
7 /* System generated locals */
8 integer a_dim1, a_offset, i__1, i__2;
13 extern logical lsame_(char *, char *);
14 doublereal ctemp, stemp;
15 extern /* Subroutine */ int xerbla_(char *, integer *);
18 /* -- LAPACK auxiliary routine (version 3.1) -- */
19 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
22 /* .. Scalar Arguments .. */
24 /* .. Array Arguments .. */
30 /* DLASR applies a sequence of plane rotations to a real matrix A, */
31 /* from either the left or the right. */
33 /* When SIDE = 'L', the transformation takes the form */
37 /* and when SIDE = 'R', the transformation takes the form */
41 /* where P is an orthogonal matrix consisting of a sequence of z plane */
42 /* rotations, with z = M when SIDE = 'L' and z = N when SIDE = 'R', */
43 /* and P**T is the transpose of P. */
45 /* When DIRECT = 'F' (Forward sequence), then */
47 /* P = P(z-1) * ... * P(2) * P(1) */
49 /* and when DIRECT = 'B' (Backward sequence), then */
51 /* P = P(1) * P(2) * ... * P(z-1) */
53 /* where P(k) is a plane rotation matrix defined by the 2-by-2 rotation */
55 /* R(k) = ( c(k) s(k) ) */
56 /* = ( -s(k) c(k) ). */
58 /* When PIVOT = 'V' (Variable pivot), the rotation is performed */
59 /* for the plane (k,k+1), i.e., P(k) has the form */
70 /* where R(k) appears as a rank-2 modification to the identity matrix in */
71 /* rows and columns k and k+1. */
73 /* When PIVOT = 'T' (Top pivot), the rotation is performed for the */
74 /* plane (1,k+1), so P(k) has the form */
76 /* P(k) = ( c(k) s(k) ) */
85 /* where R(k) appears in rows and columns 1 and k+1. */
87 /* Similarly, when PIVOT = 'B' (Bottom pivot), the rotation is */
88 /* performed for the plane (k,z), giving P(k) the form */
99 /* where R(k) appears in rows and columns k and z. The rotations are */
100 /* performed without ever forming P(k) explicitly. */
105 /* SIDE (input) CHARACTER*1 */
106 /* Specifies whether the plane rotation matrix P is applied to */
107 /* A on the left or the right. */
108 /* = 'L': Left, compute A := P*A */
109 /* = 'R': Right, compute A:= A*P**T */
111 /* PIVOT (input) CHARACTER*1 */
112 /* Specifies the plane for which P(k) is a plane rotation */
114 /* = 'V': Variable pivot, the plane (k,k+1) */
115 /* = 'T': Top pivot, the plane (1,k+1) */
116 /* = 'B': Bottom pivot, the plane (k,z) */
118 /* DIRECT (input) CHARACTER*1 */
119 /* Specifies whether P is a forward or backward sequence of */
120 /* plane rotations. */
121 /* = 'F': Forward, P = P(z-1)*...*P(2)*P(1) */
122 /* = 'B': Backward, P = P(1)*P(2)*...*P(z-1) */
124 /* M (input) INTEGER */
125 /* The number of rows of the matrix A. If m <= 1, an immediate */
126 /* return is effected. */
128 /* N (input) INTEGER */
129 /* The number of columns of the matrix A. If n <= 1, an */
130 /* immediate return is effected. */
132 /* C (input) DOUBLE PRECISION array, dimension */
133 /* (M-1) if SIDE = 'L' */
134 /* (N-1) if SIDE = 'R' */
135 /* The cosines c(k) of the plane rotations. */
137 /* S (input) DOUBLE PRECISION array, dimension */
138 /* (M-1) if SIDE = 'L' */
139 /* (N-1) if SIDE = 'R' */
140 /* The sines s(k) of the plane rotations. The 2-by-2 plane */
141 /* rotation part of the matrix P(k), R(k), has the form */
142 /* R(k) = ( c(k) s(k) ) */
143 /* ( -s(k) c(k) ). */
145 /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
146 /* The M-by-N matrix A. On exit, A is overwritten by P*A if */
147 /* SIDE = 'R' or by A*P**T if SIDE = 'L'. */
149 /* LDA (input) INTEGER */
150 /* The leading dimension of the array A. LDA >= max(1,M). */
152 /* ===================================================================== */
154 /* .. Parameters .. */
156 /* .. Local Scalars .. */
158 /* .. External Functions .. */
160 /* .. External Subroutines .. */
162 /* .. Intrinsic Functions .. */
164 /* .. Executable Statements .. */
166 /* Test the input parameters */
168 /* Parameter adjustments */
172 a_offset = 1 + a_dim1;
177 if (! (lsame_(side, "L") || lsame_(side, "R"))) {
179 } else if (! (lsame_(pivot, "V") || lsame_(pivot,
180 "T") || lsame_(pivot, "B"))) {
182 } else if (! (lsame_(direct, "F") || lsame_(direct,
189 } else if (*lda < max(1,*m)) {
193 xerbla_("DLASR ", &info);
197 /* Quick return if possible */
199 if (*m == 0 || *n == 0) {
202 if (lsame_(side, "L")) {
206 if (lsame_(pivot, "V")) {
207 if (lsame_(direct, "F")) {
209 for (j = 1; j <= i__1; ++j) {
212 if (ctemp != 1. || stemp != 0.) {
214 for (i__ = 1; i__ <= i__2; ++i__) {
215 temp = a[j + 1 + i__ * a_dim1];
216 a[j + 1 + i__ * a_dim1] = ctemp * temp - stemp *
218 a[j + i__ * a_dim1] = stemp * temp + ctemp * a[j
225 } else if (lsame_(direct, "B")) {
226 for (j = *m - 1; j >= 1; --j) {
229 if (ctemp != 1. || stemp != 0.) {
231 for (i__ = 1; i__ <= i__1; ++i__) {
232 temp = a[j + 1 + i__ * a_dim1];
233 a[j + 1 + i__ * a_dim1] = ctemp * temp - stemp *
235 a[j + i__ * a_dim1] = stemp * temp + ctemp * a[j
243 } else if (lsame_(pivot, "T")) {
244 if (lsame_(direct, "F")) {
246 for (j = 2; j <= i__1; ++j) {
249 if (ctemp != 1. || stemp != 0.) {
251 for (i__ = 1; i__ <= i__2; ++i__) {
252 temp = a[j + i__ * a_dim1];
253 a[j + i__ * a_dim1] = ctemp * temp - stemp * a[
255 a[i__ * a_dim1 + 1] = stemp * temp + ctemp * a[
262 } else if (lsame_(direct, "B")) {
263 for (j = *m; j >= 2; --j) {
266 if (ctemp != 1. || stemp != 0.) {
268 for (i__ = 1; i__ <= i__1; ++i__) {
269 temp = a[j + i__ * a_dim1];
270 a[j + i__ * a_dim1] = ctemp * temp - stemp * a[
272 a[i__ * a_dim1 + 1] = stemp * temp + ctemp * a[
280 } else if (lsame_(pivot, "B")) {
281 if (lsame_(direct, "F")) {
283 for (j = 1; j <= i__1; ++j) {
286 if (ctemp != 1. || stemp != 0.) {
288 for (i__ = 1; i__ <= i__2; ++i__) {
289 temp = a[j + i__ * a_dim1];
290 a[j + i__ * a_dim1] = stemp * a[*m + i__ * a_dim1]
292 a[*m + i__ * a_dim1] = ctemp * a[*m + i__ *
293 a_dim1] - stemp * temp;
299 } else if (lsame_(direct, "B")) {
300 for (j = *m - 1; j >= 1; --j) {
303 if (ctemp != 1. || stemp != 0.) {
305 for (i__ = 1; i__ <= i__1; ++i__) {
306 temp = a[j + i__ * a_dim1];
307 a[j + i__ * a_dim1] = stemp * a[*m + i__ * a_dim1]
309 a[*m + i__ * a_dim1] = ctemp * a[*m + i__ *
310 a_dim1] - stemp * temp;
318 } else if (lsame_(side, "R")) {
322 if (lsame_(pivot, "V")) {
323 if (lsame_(direct, "F")) {
325 for (j = 1; j <= i__1; ++j) {
328 if (ctemp != 1. || stemp != 0.) {
330 for (i__ = 1; i__ <= i__2; ++i__) {
331 temp = a[i__ + (j + 1) * a_dim1];
332 a[i__ + (j + 1) * a_dim1] = ctemp * temp - stemp *
334 a[i__ + j * a_dim1] = stemp * temp + ctemp * a[
341 } else if (lsame_(direct, "B")) {
342 for (j = *n - 1; j >= 1; --j) {
345 if (ctemp != 1. || stemp != 0.) {
347 for (i__ = 1; i__ <= i__1; ++i__) {
348 temp = a[i__ + (j + 1) * a_dim1];
349 a[i__ + (j + 1) * a_dim1] = ctemp * temp - stemp *
351 a[i__ + j * a_dim1] = stemp * temp + ctemp * a[
359 } else if (lsame_(pivot, "T")) {
360 if (lsame_(direct, "F")) {
362 for (j = 2; j <= i__1; ++j) {
365 if (ctemp != 1. || stemp != 0.) {
367 for (i__ = 1; i__ <= i__2; ++i__) {
368 temp = a[i__ + j * a_dim1];
369 a[i__ + j * a_dim1] = ctemp * temp - stemp * a[
371 a[i__ + a_dim1] = stemp * temp + ctemp * a[i__ +
378 } else if (lsame_(direct, "B")) {
379 for (j = *n; j >= 2; --j) {
382 if (ctemp != 1. || stemp != 0.) {
384 for (i__ = 1; i__ <= i__1; ++i__) {
385 temp = a[i__ + j * a_dim1];
386 a[i__ + j * a_dim1] = ctemp * temp - stemp * a[
388 a[i__ + a_dim1] = stemp * temp + ctemp * a[i__ +
396 } else if (lsame_(pivot, "B")) {
397 if (lsame_(direct, "F")) {
399 for (j = 1; j <= i__1; ++j) {
402 if (ctemp != 1. || stemp != 0.) {
404 for (i__ = 1; i__ <= i__2; ++i__) {
405 temp = a[i__ + j * a_dim1];
406 a[i__ + j * a_dim1] = stemp * a[i__ + *n * a_dim1]
408 a[i__ + *n * a_dim1] = ctemp * a[i__ + *n *
409 a_dim1] - stemp * temp;
415 } else if (lsame_(direct, "B")) {
416 for (j = *n - 1; j >= 1; --j) {
419 if (ctemp != 1. || stemp != 0.) {
421 for (i__ = 1; i__ <= i__1; ++i__) {
422 temp = a[i__ + j * a_dim1];
423 a[i__ + j * a_dim1] = stemp * a[i__ + *n * a_dim1]
425 a[i__ + *n * a_dim1] = ctemp * a[i__ + *n *
426 a_dim1] - stemp * temp;