KTH framework for Nek5000 toolboxes; testing version  0.0.1
dlasr.f
Go to the documentation of this file.
1  SUBROUTINE dlasr( SIDE, PIVOT, DIRECT, M, N, C, S, A, LDA )
2 *
3 * -- LAPACK auxiliary routine (version 3.0) --
4 * Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
5 * Courant Institute, Argonne National Lab, and Rice University
6 * October 31, 1992
7 *
8 * .. Scalar Arguments ..
9  CHARACTER DIRECT, PIVOT, SIDE
10  INTEGER LDA, M, N
11 * ..
12 * .. Array Arguments ..
13  DOUBLE PRECISION A( LDA, * ), C( * ), S( * )
14 * ..
15 *
16 * Purpose
17 * =======
18 *
19 * DLASR performs the transformation
20 *
21 * A := P*A, when SIDE = 'L' or 'l' ( Left-hand side )
22 *
23 * A := A*P', when SIDE = 'R' or 'r' ( Right-hand side )
24 *
25 * where A is an m by n real matrix and P is an orthogonal matrix,
26 * consisting of a sequence of plane rotations determined by the
27 * parameters PIVOT and DIRECT as follows ( z = m when SIDE = 'L' or 'l'
28 * and z = n when SIDE = 'R' or 'r' ):
29 *
30 * When DIRECT = 'F' or 'f' ( Forward sequence ) then
31 *
32 * P = P( z - 1 )*...*P( 2 )*P( 1 ),
33 *
34 * and when DIRECT = 'B' or 'b' ( Backward sequence ) then
35 *
36 * P = P( 1 )*P( 2 )*...*P( z - 1 ),
37 *
38 * where P( k ) is a plane rotation matrix for the following planes:
39 *
40 * when PIVOT = 'V' or 'v' ( Variable pivot ),
41 * the plane ( k, k + 1 )
42 *
43 * when PIVOT = 'T' or 't' ( Top pivot ),
44 * the plane ( 1, k + 1 )
45 *
46 * when PIVOT = 'B' or 'b' ( Bottom pivot ),
47 * the plane ( k, z )
48 *
49 * c( k ) and s( k ) must contain the cosine and sine that define the
50 * matrix P( k ). The two by two plane rotation part of the matrix
51 * P( k ), R( k ), is assumed to be of the form
52 *
53 * R( k ) = ( c( k ) s( k ) ).
54 * ( -s( k ) c( k ) )
55 *
56 * This version vectorises across rows of the array A when SIDE = 'L'.
57 *
58 * Arguments
59 * =========
60 *
61 * SIDE (input) CHARACTER*1
62 * Specifies whether the plane rotation matrix P is applied to
63 * A on the left or the right.
64 * = 'L': Left, compute A := P*A
65 * = 'R': Right, compute A:= A*P'
66 *
67 * DIRECT (input) CHARACTER*1
68 * Specifies whether P is a forward or backward sequence of
69 * plane rotations.
70 * = 'F': Forward, P = P( z - 1 )*...*P( 2 )*P( 1 )
71 * = 'B': Backward, P = P( 1 )*P( 2 )*...*P( z - 1 )
72 *
73 * PIVOT (input) CHARACTER*1
74 * Specifies the plane for which P(k) is a plane rotation
75 * matrix.
76 * = 'V': Variable pivot, the plane (k,k+1)
77 * = 'T': Top pivot, the plane (1,k+1)
78 * = 'B': Bottom pivot, the plane (k,z)
79 *
80 * M (input) INTEGER
81 * The number of rows of the matrix A. If m <= 1, an immediate
82 * return is effected.
83 *
84 * N (input) INTEGER
85 * The number of columns of the matrix A. If n <= 1, an
86 * immediate return is effected.
87 *
88 * C, S (input) DOUBLE PRECISION arrays, dimension
89 * (M-1) if SIDE = 'L'
90 * (N-1) if SIDE = 'R'
91 * c(k) and s(k) contain the cosine and sine that define the
92 * matrix P(k). The two by two plane rotation part of the
93 * matrix P(k), R(k), is assumed to be of the form
94 * R( k ) = ( c( k ) s( k ) ).
95 * ( -s( k ) c( k ) )
96 *
97 * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
98 * The m by n matrix A. On exit, A is overwritten by P*A if
99 * SIDE = 'R' or by A*P' if SIDE = 'L'.
100 *
101 * LDA (input) INTEGER
102 * The leading dimension of the array A. LDA >= max(1,M).
103 *
104 * =====================================================================
105 *
106 * .. Parameters ..
107  DOUBLE PRECISION ONE, ZERO
108  parameter( one = 1.0d+0, zero = 0.0d+0 )
109 * ..
110 * .. Local Scalars ..
111  INTEGER I, INFO, J
112  DOUBLE PRECISION CTEMP, STEMP, TEMP
113 * ..
114 * .. External Functions ..
115  LOGICAL LSAME
116  EXTERNAL lsame
117 * ..
118 * .. External Subroutines ..
119  EXTERNAL xerbla
120 * ..
121 * .. Intrinsic Functions ..
122  INTRINSIC max
123 * ..
124 * .. Executable Statements ..
125 *
126 * Test the input parameters
127 *
128  info = 0
129  IF( .NOT.( lsame( side, 'L' ) .OR. lsame( side, 'R' ) ) ) THEN
130  info = 1
131  ELSE IF( .NOT.( lsame( pivot, 'V' ) .OR. lsame( pivot,
132  $ 'T' ) .OR. lsame( pivot, 'B' ) ) ) THEN
133  info = 2
134  ELSE IF( .NOT.( lsame( direct, 'F' ) .OR. lsame( direct, 'B' ) ) )
135  $ THEN
136  info = 3
137  ELSE IF( m.LT.0 ) THEN
138  info = 4
139  ELSE IF( n.LT.0 ) THEN
140  info = 5
141  ELSE IF( lda.LT.max( 1, m ) ) THEN
142  info = 9
143  END IF
144  IF( info.NE.0 ) THEN
145  CALL xerbla( 'DLASR ', info )
146  RETURN
147  END IF
148 *
149 * Quick return if possible
150 *
151  IF( ( m.EQ.0 ) .OR. ( n.EQ.0 ) )
152  $ RETURN
153  IF( lsame( side, 'L' ) ) THEN
154 *
155 * Form P * A
156 *
157  IF( lsame( pivot, 'V' ) ) THEN
158  IF( lsame( direct, 'F' ) ) THEN
159  DO 20 j = 1, m - 1
160  ctemp = c( j )
161  stemp = s( j )
162  IF( ( ctemp.NE.one ) .OR. ( stemp.NE.zero ) ) THEN
163  DO 10 i = 1, n
164  temp = a( j+1, i )
165  a( j+1, i ) = ctemp*temp - stemp*a( j, i )
166  a( j, i ) = stemp*temp + ctemp*a( j, i )
167  10 CONTINUE
168  END IF
169  20 CONTINUE
170  ELSE IF( lsame( direct, 'B' ) ) THEN
171  DO 40 j = m - 1, 1, -1
172  ctemp = c( j )
173  stemp = s( j )
174  IF( ( ctemp.NE.one ) .OR. ( stemp.NE.zero ) ) THEN
175  DO 30 i = 1, n
176  temp = a( j+1, i )
177  a( j+1, i ) = ctemp*temp - stemp*a( j, i )
178  a( j, i ) = stemp*temp + ctemp*a( j, i )
179  30 CONTINUE
180  END IF
181  40 CONTINUE
182  END IF
183  ELSE IF( lsame( pivot, 'T' ) ) THEN
184  IF( lsame( direct, 'F' ) ) THEN
185  DO 60 j = 2, m
186  ctemp = c( j-1 )
187  stemp = s( j-1 )
188  IF( ( ctemp.NE.one ) .OR. ( stemp.NE.zero ) ) THEN
189  DO 50 i = 1, n
190  temp = a( j, i )
191  a( j, i ) = ctemp*temp - stemp*a( 1, i )
192  a( 1, i ) = stemp*temp + ctemp*a( 1, i )
193  50 CONTINUE
194  END IF
195  60 CONTINUE
196  ELSE IF( lsame( direct, 'B' ) ) THEN
197  DO 80 j = m, 2, -1
198  ctemp = c( j-1 )
199  stemp = s( j-1 )
200  IF( ( ctemp.NE.one ) .OR. ( stemp.NE.zero ) ) THEN
201  DO 70 i = 1, n
202  temp = a( j, i )
203  a( j, i ) = ctemp*temp - stemp*a( 1, i )
204  a( 1, i ) = stemp*temp + ctemp*a( 1, i )
205  70 CONTINUE
206  END IF
207  80 CONTINUE
208  END IF
209  ELSE IF( lsame( pivot, 'B' ) ) THEN
210  IF( lsame( direct, 'F' ) ) THEN
211  DO 100 j = 1, m - 1
212  ctemp = c( j )
213  stemp = s( j )
214  IF( ( ctemp.NE.one ) .OR. ( stemp.NE.zero ) ) THEN
215  DO 90 i = 1, n
216  temp = a( j, i )
217  a( j, i ) = stemp*a( m, i ) + ctemp*temp
218  a( m, i ) = ctemp*a( m, i ) - stemp*temp
219  90 CONTINUE
220  END IF
221  100 CONTINUE
222  ELSE IF( lsame( direct, 'B' ) ) THEN
223  DO 120 j = m - 1, 1, -1
224  ctemp = c( j )
225  stemp = s( j )
226  IF( ( ctemp.NE.one ) .OR. ( stemp.NE.zero ) ) THEN
227  DO 110 i = 1, n
228  temp = a( j, i )
229  a( j, i ) = stemp*a( m, i ) + ctemp*temp
230  a( m, i ) = ctemp*a( m, i ) - stemp*temp
231  110 CONTINUE
232  END IF
233  120 CONTINUE
234  END IF
235  END IF
236  ELSE IF( lsame( side, 'R' ) ) THEN
237 *
238 * Form A * P'
239 *
240  IF( lsame( pivot, 'V' ) ) THEN
241  IF( lsame( direct, 'F' ) ) THEN
242  DO 140 j = 1, n - 1
243  ctemp = c( j )
244  stemp = s( j )
245  IF( ( ctemp.NE.one ) .OR. ( stemp.NE.zero ) ) THEN
246  DO 130 i = 1, m
247  temp = a( i, j+1 )
248  a( i, j+1 ) = ctemp*temp - stemp*a( i, j )
249  a( i, j ) = stemp*temp + ctemp*a( i, j )
250  130 CONTINUE
251  END IF
252  140 CONTINUE
253  ELSE IF( lsame( direct, 'B' ) ) THEN
254  DO 160 j = n - 1, 1, -1
255  ctemp = c( j )
256  stemp = s( j )
257  IF( ( ctemp.NE.one ) .OR. ( stemp.NE.zero ) ) THEN
258  DO 150 i = 1, m
259  temp = a( i, j+1 )
260  a( i, j+1 ) = ctemp*temp - stemp*a( i, j )
261  a( i, j ) = stemp*temp + ctemp*a( i, j )
262  150 CONTINUE
263  END IF
264  160 CONTINUE
265  END IF
266  ELSE IF( lsame( pivot, 'T' ) ) THEN
267  IF( lsame( direct, 'F' ) ) THEN
268  DO 180 j = 2, n
269  ctemp = c( j-1 )
270  stemp = s( j-1 )
271  IF( ( ctemp.NE.one ) .OR. ( stemp.NE.zero ) ) THEN
272  DO 170 i = 1, m
273  temp = a( i, j )
274  a( i, j ) = ctemp*temp - stemp*a( i, 1 )
275  a( i, 1 ) = stemp*temp + ctemp*a( i, 1 )
276  170 CONTINUE
277  END IF
278  180 CONTINUE
279  ELSE IF( lsame( direct, 'B' ) ) THEN
280  DO 200 j = n, 2, -1
281  ctemp = c( j-1 )
282  stemp = s( j-1 )
283  IF( ( ctemp.NE.one ) .OR. ( stemp.NE.zero ) ) THEN
284  DO 190 i = 1, m
285  temp = a( i, j )
286  a( i, j ) = ctemp*temp - stemp*a( i, 1 )
287  a( i, 1 ) = stemp*temp + ctemp*a( i, 1 )
288  190 CONTINUE
289  END IF
290  200 CONTINUE
291  END IF
292  ELSE IF( lsame( pivot, 'B' ) ) THEN
293  IF( lsame( direct, 'F' ) ) THEN
294  DO 220 j = 1, n - 1
295  ctemp = c( j )
296  stemp = s( j )
297  IF( ( ctemp.NE.one ) .OR. ( stemp.NE.zero ) ) THEN
298  DO 210 i = 1, m
299  temp = a( i, j )
300  a( i, j ) = stemp*a( i, n ) + ctemp*temp
301  a( i, n ) = ctemp*a( i, n ) - stemp*temp
302  210 CONTINUE
303  END IF
304  220 CONTINUE
305  ELSE IF( lsame( direct, 'B' ) ) THEN
306  DO 240 j = n - 1, 1, -1
307  ctemp = c( j )
308  stemp = s( j )
309  IF( ( ctemp.NE.one ) .OR. ( stemp.NE.zero ) ) THEN
310  DO 230 i = 1, m
311  temp = a( i, j )
312  a( i, j ) = stemp*a( i, n ) + ctemp*temp
313  a( i, n ) = ctemp*a( i, n ) - stemp*temp
314  230 CONTINUE
315  END IF
316  240 CONTINUE
317  END IF
318  END IF
319  END IF
320 *
321  RETURN
322 *
323 * End of DLASR
324 *
325  END
subroutine dlasr(SIDE, PIVOT, DIRECT, M, N, C, S, A, LDA)
Definition: dlasr.f:2
subroutine xerbla(SRNAME, INFO)
Definition: xerbla.f:2