1 *> \brief \b DLASR applies a sequence of plane rotations to a general rectangular matrix.
3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download DLASR + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlasr.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlasr.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlasr.f">
21 * SUBROUTINE DLASR( SIDE, PIVOT, DIRECT, M, N, C, S, A, LDA )
23 * .. Scalar Arguments ..
24 * CHARACTER DIRECT, PIVOT, SIDE
27 * .. Array Arguments ..
28 * DOUBLE PRECISION A( LDA, * ), C( * ), S( * )
37 *> DLASR applies a sequence of plane rotations to a real matrix A,
38 *> from either the left or the right.
40 *> When SIDE = 'L', the transformation takes the form
44 *> and when SIDE = 'R', the transformation takes the form
48 *> where P is an orthogonal matrix consisting of a sequence of z plane
49 *> rotations, with z = M when SIDE = 'L' and z = N when SIDE = 'R',
50 *> and P**T is the transpose of P.
52 *> When DIRECT = 'F' (Forward sequence), then
54 *> P = P(z-1) * ... * P(2) * P(1)
56 *> and when DIRECT = 'B' (Backward sequence), then
58 *> P = P(1) * P(2) * ... * P(z-1)
60 *> where P(k) is a plane rotation matrix defined by the 2-by-2 rotation
62 *> R(k) = ( c(k) s(k) )
65 *> When PIVOT = 'V' (Variable pivot), the rotation is performed
66 *> for the plane (k,k+1), i.e., P(k) has the form
77 *> where R(k) appears as a rank-2 modification to the identity matrix in
78 *> rows and columns k and k+1.
80 *> When PIVOT = 'T' (Top pivot), the rotation is performed for the
81 *> plane (1,k+1), so P(k) has the form
83 *> P(k) = ( c(k) s(k) )
92 *> where R(k) appears in rows and columns 1 and k+1.
94 *> Similarly, when PIVOT = 'B' (Bottom pivot), the rotation is
95 *> performed for the plane (k,z), giving P(k) the form
106 *> where R(k) appears in rows and columns k and z. The rotations are
107 *> performed without ever forming P(k) explicitly.
115 *> SIDE is CHARACTER*1
116 *> Specifies whether the plane rotation matrix P is applied to
117 *> A on the left or the right.
118 *> = 'L': Left, compute A := P*A
119 *> = 'R': Right, compute A:= A*P**T
124 *> PIVOT is CHARACTER*1
125 *> Specifies the plane for which P(k) is a plane rotation
127 *> = 'V': Variable pivot, the plane (k,k+1)
128 *> = 'T': Top pivot, the plane (1,k+1)
129 *> = 'B': Bottom pivot, the plane (k,z)
134 *> DIRECT is CHARACTER*1
135 *> Specifies whether P is a forward or backward sequence of
137 *> = 'F': Forward, P = P(z-1)*...*P(2)*P(1)
138 *> = 'B': Backward, P = P(1)*P(2)*...*P(z-1)
144 *> The number of rows of the matrix A. If m <= 1, an immediate
145 *> return is effected.
151 *> The number of columns of the matrix A. If n <= 1, an
152 *> immediate return is effected.
157 *> C is DOUBLE PRECISION array, dimension
158 *> (M-1) if SIDE = 'L'
159 *> (N-1) if SIDE = 'R'
160 *> The cosines c(k) of the plane rotations.
165 *> S is DOUBLE PRECISION array, dimension
166 *> (M-1) if SIDE = 'L'
167 *> (N-1) if SIDE = 'R'
168 *> The sines s(k) of the plane rotations. The 2-by-2 plane
169 *> rotation part of the matrix P(k), R(k), has the form
170 *> R(k) = ( c(k) s(k) )
176 *> A is DOUBLE PRECISION array, dimension (LDA,N)
177 *> The M-by-N matrix A. On exit, A is overwritten by P*A if
178 *> SIDE = 'R' or by A*P**T if SIDE = 'L'.
184 *> The leading dimension of the array A. LDA >= max(1,M).
190 *> \author Univ. of Tennessee
191 *> \author Univ. of California Berkeley
192 *> \author Univ. of Colorado Denver
195 *> \date September 2012
197 *> \ingroup auxOTHERauxiliary
199 * =====================================================================
200 SUBROUTINE DLASR( SIDE, PIVOT, DIRECT, M, N, C, S, A, LDA )
202 * -- LAPACK auxiliary routine (version 3.4.2) --
203 * -- LAPACK is a software package provided by Univ. of Tennessee, --
204 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
207 * .. Scalar Arguments ..
208 CHARACTER DIRECT, PIVOT, SIDE
211 * .. Array Arguments ..
212 DOUBLE PRECISION A( LDA, * ), C( * ), S( * )
215 * =====================================================================
218 DOUBLE PRECISION ONE, ZERO
219 PARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 )
221 * .. Local Scalars ..
223 DOUBLE PRECISION CTEMP, STEMP, TEMP
225 * .. External Functions ..
229 * .. External Subroutines ..
232 * .. Intrinsic Functions ..
235 * .. Executable Statements ..
237 * Test the input parameters
240 IF( .NOT.( LSAME( SIDE, 'L' ) .OR. LSAME( SIDE, 'R' ) ) ) THEN
242 ELSE IF( .NOT.( LSAME( PIVOT, 'V' ) .OR. LSAME( PIVOT,
243 $ 'T' ) .OR. LSAME( PIVOT, 'B' ) ) ) THEN
245 ELSE IF( .NOT.( LSAME( DIRECT, 'F' ) .OR. LSAME( DIRECT, 'B' ) ) )
248 ELSE IF( M.LT.0 ) THEN
250 ELSE IF( N.LT.0 ) THEN
252 ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
256 CALL XERBLA( 'DLASR ', INFO )
260 * Quick return if possible
262 IF( ( M.EQ.0 ) .OR. ( N.EQ.0 ) )
264 IF( LSAME( SIDE, 'L' ) ) THEN
268 IF( LSAME( PIVOT, 'V' ) ) THEN
269 IF( LSAME( DIRECT, 'F' ) ) THEN
273 IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THEN
276 A( J+1, I ) = CTEMP*TEMP - STEMP*A( J, I )
277 A( J, I ) = STEMP*TEMP + CTEMP*A( J, I )
281 ELSE IF( LSAME( DIRECT, 'B' ) ) THEN
282 DO 40 J = M - 1, 1, -1
285 IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THEN
288 A( J+1, I ) = CTEMP*TEMP - STEMP*A( J, I )
289 A( J, I ) = STEMP*TEMP + CTEMP*A( J, I )
294 ELSE IF( LSAME( PIVOT, 'T' ) ) THEN
295 IF( LSAME( DIRECT, 'F' ) ) THEN
299 IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THEN
302 A( J, I ) = CTEMP*TEMP - STEMP*A( 1, I )
303 A( 1, I ) = STEMP*TEMP + CTEMP*A( 1, I )
307 ELSE IF( LSAME( DIRECT, 'B' ) ) THEN
311 IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THEN
314 A( J, I ) = CTEMP*TEMP - STEMP*A( 1, I )
315 A( 1, I ) = STEMP*TEMP + CTEMP*A( 1, I )
320 ELSE IF( LSAME( PIVOT, 'B' ) ) THEN
321 IF( LSAME( DIRECT, 'F' ) ) THEN
325 IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THEN
328 A( J, I ) = STEMP*A( M, I ) + CTEMP*TEMP
329 A( M, I ) = CTEMP*A( M, I ) - STEMP*TEMP
333 ELSE IF( LSAME( DIRECT, 'B' ) ) THEN
334 DO 120 J = M - 1, 1, -1
337 IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THEN
340 A( J, I ) = STEMP*A( M, I ) + CTEMP*TEMP
341 A( M, I ) = CTEMP*A( M, I ) - STEMP*TEMP
347 ELSE IF( LSAME( SIDE, 'R' ) ) THEN
351 IF( LSAME( PIVOT, 'V' ) ) THEN
352 IF( LSAME( DIRECT, 'F' ) ) THEN
356 IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THEN
359 A( I, J+1 ) = CTEMP*TEMP - STEMP*A( I, J )
360 A( I, J ) = STEMP*TEMP + CTEMP*A( I, J )
364 ELSE IF( LSAME( DIRECT, 'B' ) ) THEN
365 DO 160 J = N - 1, 1, -1
368 IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THEN
371 A( I, J+1 ) = CTEMP*TEMP - STEMP*A( I, J )
372 A( I, J ) = STEMP*TEMP + CTEMP*A( I, J )
377 ELSE IF( LSAME( PIVOT, 'T' ) ) THEN
378 IF( LSAME( DIRECT, 'F' ) ) THEN
382 IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THEN
385 A( I, J ) = CTEMP*TEMP - STEMP*A( I, 1 )
386 A( I, 1 ) = STEMP*TEMP + CTEMP*A( I, 1 )
390 ELSE IF( LSAME( DIRECT, 'B' ) ) THEN
394 IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THEN
397 A( I, J ) = CTEMP*TEMP - STEMP*A( I, 1 )
398 A( I, 1 ) = STEMP*TEMP + CTEMP*A( I, 1 )
403 ELSE IF( LSAME( PIVOT, 'B' ) ) THEN
404 IF( LSAME( DIRECT, 'F' ) ) THEN
408 IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THEN
411 A( I, J ) = STEMP*A( I, N ) + CTEMP*TEMP
412 A( I, N ) = CTEMP*A( I, N ) - STEMP*TEMP
416 ELSE IF( LSAME( DIRECT, 'B' ) ) THEN
417 DO 240 J = N - 1, 1, -1
420 IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THEN
423 A( I, J ) = STEMP*A( I, N ) + CTEMP*TEMP
424 A( I, N ) = CTEMP*A( I, N ) - STEMP*TEMP