1 *> \brief \b ZLASR 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 ZLASR + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlasr.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlasr.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlasr.f">
21 * SUBROUTINE ZLASR( SIDE, PIVOT, DIRECT, M, N, C, S, A, LDA )
23 * .. Scalar Arguments ..
24 * CHARACTER DIRECT, PIVOT, SIDE
27 * .. Array Arguments ..
28 * DOUBLE PRECISION C( * ), S( * )
29 * COMPLEX*16 A( LDA, * )
38 *> ZLASR applies a sequence of real plane rotations to a complex matrix
39 *> A, from either the left or the right.
41 *> When SIDE = 'L', the transformation takes the form
45 *> and when SIDE = 'R', the transformation takes the form
49 *> where P is an orthogonal matrix consisting of a sequence of z plane
50 *> rotations, with z = M when SIDE = 'L' and z = N when SIDE = 'R',
51 *> and P**T is the transpose of P.
53 *> When DIRECT = 'F' (Forward sequence), then
55 *> P = P(z-1) * ... * P(2) * P(1)
57 *> and when DIRECT = 'B' (Backward sequence), then
59 *> P = P(1) * P(2) * ... * P(z-1)
61 *> where P(k) is a plane rotation matrix defined by the 2-by-2 rotation
63 *> R(k) = ( c(k) s(k) )
66 *> When PIVOT = 'V' (Variable pivot), the rotation is performed
67 *> for the plane (k,k+1), i.e., P(k) has the form
78 *> where R(k) appears as a rank-2 modification to the identity matrix in
79 *> rows and columns k and k+1.
81 *> When PIVOT = 'T' (Top pivot), the rotation is performed for the
82 *> plane (1,k+1), so P(k) has the form
84 *> P(k) = ( c(k) s(k) )
93 *> where R(k) appears in rows and columns 1 and k+1.
95 *> Similarly, when PIVOT = 'B' (Bottom pivot), the rotation is
96 *> performed for the plane (k,z), giving P(k) the form
107 *> where R(k) appears in rows and columns k and z. The rotations are
108 *> performed without ever forming P(k) explicitly.
116 *> SIDE is CHARACTER*1
117 *> Specifies whether the plane rotation matrix P is applied to
118 *> A on the left or the right.
119 *> = 'L': Left, compute A := P*A
120 *> = 'R': Right, compute A:= A*P**T
125 *> PIVOT is CHARACTER*1
126 *> Specifies the plane for which P(k) is a plane rotation
128 *> = 'V': Variable pivot, the plane (k,k+1)
129 *> = 'T': Top pivot, the plane (1,k+1)
130 *> = 'B': Bottom pivot, the plane (k,z)
135 *> DIRECT is CHARACTER*1
136 *> Specifies whether P is a forward or backward sequence of
138 *> = 'F': Forward, P = P(z-1)*...*P(2)*P(1)
139 *> = 'B': Backward, P = P(1)*P(2)*...*P(z-1)
145 *> The number of rows of the matrix A. If m <= 1, an immediate
146 *> return is effected.
152 *> The number of columns of the matrix A. If n <= 1, an
153 *> immediate return is effected.
158 *> C is DOUBLE PRECISION array, dimension
159 *> (M-1) if SIDE = 'L'
160 *> (N-1) if SIDE = 'R'
161 *> The cosines c(k) of the plane rotations.
166 *> S is DOUBLE PRECISION array, dimension
167 *> (M-1) if SIDE = 'L'
168 *> (N-1) if SIDE = 'R'
169 *> The sines s(k) of the plane rotations. The 2-by-2 plane
170 *> rotation part of the matrix P(k), R(k), has the form
171 *> R(k) = ( c(k) s(k) )
177 *> A is COMPLEX*16 array, dimension (LDA,N)
178 *> The M-by-N matrix A. On exit, A is overwritten by P*A if
179 *> SIDE = 'R' or by A*P**T if SIDE = 'L'.
185 *> The leading dimension of the array A. LDA >= max(1,M).
191 *> \author Univ. of Tennessee
192 *> \author Univ. of California Berkeley
193 *> \author Univ. of Colorado Denver
196 *> \date September 2012
198 *> \ingroup complex16OTHERauxiliary
200 * =====================================================================
201 SUBROUTINE ZLASR( SIDE, PIVOT, DIRECT, M, N, C, S, A, LDA )
203 * -- LAPACK auxiliary routine (version 3.4.2) --
204 * -- LAPACK is a software package provided by Univ. of Tennessee, --
205 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
208 * .. Scalar Arguments ..
209 CHARACTER DIRECT, PIVOT, SIDE
212 * .. Array Arguments ..
213 DOUBLE PRECISION C( * ), S( * )
214 COMPLEX*16 A( LDA, * )
217 * =====================================================================
220 DOUBLE PRECISION ONE, ZERO
221 PARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 )
223 * .. Local Scalars ..
225 DOUBLE PRECISION CTEMP, STEMP
228 * .. Intrinsic Functions ..
231 * .. External Functions ..
235 * .. External Subroutines ..
238 * .. Executable Statements ..
240 * Test the input parameters
243 IF( .NOT.( LSAME( SIDE, 'L' ) .OR. LSAME( SIDE, 'R' ) ) ) THEN
245 ELSE IF( .NOT.( LSAME( PIVOT, 'V' ) .OR. LSAME( PIVOT,
246 $ 'T' ) .OR. LSAME( PIVOT, 'B' ) ) ) THEN
248 ELSE IF( .NOT.( LSAME( DIRECT, 'F' ) .OR. LSAME( DIRECT, 'B' ) ) )
251 ELSE IF( M.LT.0 ) THEN
253 ELSE IF( N.LT.0 ) THEN
255 ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
259 CALL XERBLA( 'ZLASR ', INFO )
263 * Quick return if possible
265 IF( ( M.EQ.0 ) .OR. ( N.EQ.0 ) )
267 IF( LSAME( SIDE, 'L' ) ) THEN
271 IF( LSAME( PIVOT, 'V' ) ) THEN
272 IF( LSAME( DIRECT, 'F' ) ) THEN
276 IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THEN
279 A( J+1, I ) = CTEMP*TEMP - STEMP*A( J, I )
280 A( J, I ) = STEMP*TEMP + CTEMP*A( J, I )
284 ELSE IF( LSAME( DIRECT, 'B' ) ) THEN
285 DO 40 J = M - 1, 1, -1
288 IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THEN
291 A( J+1, I ) = CTEMP*TEMP - STEMP*A( J, I )
292 A( J, I ) = STEMP*TEMP + CTEMP*A( J, I )
297 ELSE IF( LSAME( PIVOT, 'T' ) ) THEN
298 IF( LSAME( DIRECT, 'F' ) ) THEN
302 IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THEN
305 A( J, I ) = CTEMP*TEMP - STEMP*A( 1, I )
306 A( 1, I ) = STEMP*TEMP + CTEMP*A( 1, I )
310 ELSE IF( LSAME( DIRECT, 'B' ) ) THEN
314 IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THEN
317 A( J, I ) = CTEMP*TEMP - STEMP*A( 1, I )
318 A( 1, I ) = STEMP*TEMP + CTEMP*A( 1, I )
323 ELSE IF( LSAME( PIVOT, 'B' ) ) THEN
324 IF( LSAME( DIRECT, 'F' ) ) THEN
328 IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THEN
331 A( J, I ) = STEMP*A( M, I ) + CTEMP*TEMP
332 A( M, I ) = CTEMP*A( M, I ) - STEMP*TEMP
336 ELSE IF( LSAME( DIRECT, 'B' ) ) THEN
337 DO 120 J = M - 1, 1, -1
340 IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THEN
343 A( J, I ) = STEMP*A( M, I ) + CTEMP*TEMP
344 A( M, I ) = CTEMP*A( M, I ) - STEMP*TEMP
350 ELSE IF( LSAME( SIDE, 'R' ) ) THEN
354 IF( LSAME( PIVOT, 'V' ) ) THEN
355 IF( LSAME( DIRECT, 'F' ) ) THEN
359 IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THEN
362 A( I, J+1 ) = CTEMP*TEMP - STEMP*A( I, J )
363 A( I, J ) = STEMP*TEMP + CTEMP*A( I, J )
367 ELSE IF( LSAME( DIRECT, 'B' ) ) THEN
368 DO 160 J = N - 1, 1, -1
371 IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THEN
374 A( I, J+1 ) = CTEMP*TEMP - STEMP*A( I, J )
375 A( I, J ) = STEMP*TEMP + CTEMP*A( I, J )
380 ELSE IF( LSAME( PIVOT, 'T' ) ) THEN
381 IF( LSAME( DIRECT, 'F' ) ) THEN
385 IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THEN
388 A( I, J ) = CTEMP*TEMP - STEMP*A( I, 1 )
389 A( I, 1 ) = STEMP*TEMP + CTEMP*A( I, 1 )
393 ELSE IF( LSAME( DIRECT, 'B' ) ) THEN
397 IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THEN
400 A( I, J ) = CTEMP*TEMP - STEMP*A( I, 1 )
401 A( I, 1 ) = STEMP*TEMP + CTEMP*A( I, 1 )
406 ELSE IF( LSAME( PIVOT, 'B' ) ) THEN
407 IF( LSAME( DIRECT, 'F' ) ) THEN
411 IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THEN
414 A( I, J ) = STEMP*A( I, N ) + CTEMP*TEMP
415 A( I, N ) = CTEMP*A( I, N ) - STEMP*TEMP
419 ELSE IF( LSAME( DIRECT, 'B' ) ) THEN
420 DO 240 J = N - 1, 1, -1
423 IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THEN
426 A( I, J ) = STEMP*A( I, N ) + CTEMP*TEMP
427 A( I, N ) = CTEMP*A( I, N ) - STEMP*TEMP