LAPACK 3.11.0
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
clargv.f
Go to the documentation of this file.
1*> \brief \b CLARGV generates a vector of plane rotations with real cosines and complex sines.
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> \htmlonly
9*> Download CLARGV + dependencies
10*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/clargv.f">
11*> [TGZ]</a>
12*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/clargv.f">
13*> [ZIP]</a>
14*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/clargv.f">
15*> [TXT]</a>
16*> \endhtmlonly
17*
18* Definition:
19* ===========
20*
21* SUBROUTINE CLARGV( N, X, INCX, Y, INCY, C, INCC )
22*
23* .. Scalar Arguments ..
24* INTEGER INCC, INCX, INCY, N
25* ..
26* .. Array Arguments ..
27* REAL C( * )
28* COMPLEX X( * ), Y( * )
29* ..
30*
31*
32*> \par Purpose:
33* =============
34*>
35*> \verbatim
36*>
37*> CLARGV generates a vector of complex plane rotations with real
38*> cosines, determined by elements of the complex vectors x and y.
39*> For i = 1,2,...,n
40*>
41*> ( c(i) s(i) ) ( x(i) ) = ( r(i) )
42*> ( -conjg(s(i)) c(i) ) ( y(i) ) = ( 0 )
43*>
44*> where c(i)**2 + ABS(s(i))**2 = 1
45*>
46*> The following conventions are used (these are the same as in CLARTG,
47*> but differ from the BLAS1 routine CROTG):
48*> If y(i)=0, then c(i)=1 and s(i)=0.
49*> If x(i)=0, then c(i)=0 and s(i) is chosen so that r(i) is real.
50*> \endverbatim
51*
52* Arguments:
53* ==========
54*
55*> \param[in] N
56*> \verbatim
57*> N is INTEGER
58*> The number of plane rotations to be generated.
59*> \endverbatim
60*>
61*> \param[in,out] X
62*> \verbatim
63*> X is COMPLEX array, dimension (1+(N-1)*INCX)
64*> On entry, the vector x.
65*> On exit, x(i) is overwritten by r(i), for i = 1,...,n.
66*> \endverbatim
67*>
68*> \param[in] INCX
69*> \verbatim
70*> INCX is INTEGER
71*> The increment between elements of X. INCX > 0.
72*> \endverbatim
73*>
74*> \param[in,out] Y
75*> \verbatim
76*> Y is COMPLEX array, dimension (1+(N-1)*INCY)
77*> On entry, the vector y.
78*> On exit, the sines of the plane rotations.
79*> \endverbatim
80*>
81*> \param[in] INCY
82*> \verbatim
83*> INCY is INTEGER
84*> The increment between elements of Y. INCY > 0.
85*> \endverbatim
86*>
87*> \param[out] C
88*> \verbatim
89*> C is REAL array, dimension (1+(N-1)*INCC)
90*> The cosines of the plane rotations.
91*> \endverbatim
92*>
93*> \param[in] INCC
94*> \verbatim
95*> INCC is INTEGER
96*> The increment between elements of C. INCC > 0.
97*> \endverbatim
98*
99* Authors:
100* ========
101*
102*> \author Univ. of Tennessee
103*> \author Univ. of California Berkeley
104*> \author Univ. of Colorado Denver
105*> \author NAG Ltd.
106*
107*> \ingroup complexOTHERauxiliary
108*
109*> \par Further Details:
110* =====================
111*>
112*> \verbatim
113*>
114*> 6-6-96 - Modified with a new algorithm by W. Kahan and J. Demmel
115*>
116*> This version has a few statements commented out for thread safety
117*> (machine parameters are computed on each entry). 10 feb 03, SJH.
118*> \endverbatim
119*>
120* =====================================================================
121 SUBROUTINE clargv( N, X, INCX, Y, INCY, C, INCC )
122*
123* -- LAPACK auxiliary routine --
124* -- LAPACK is a software package provided by Univ. of Tennessee, --
125* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
126*
127* .. Scalar Arguments ..
128 INTEGER INCC, INCX, INCY, N
129* ..
130* .. Array Arguments ..
131 REAL C( * )
132 COMPLEX X( * ), Y( * )
133* ..
134*
135* =====================================================================
136*
137* .. Parameters ..
138 REAL TWO, ONE, ZERO
139 parameter( two = 2.0e+0, one = 1.0e+0, zero = 0.0e+0 )
140 COMPLEX CZERO
141 parameter( czero = ( 0.0e+0, 0.0e+0 ) )
142* ..
143* .. Local Scalars ..
144* LOGICAL FIRST
145 INTEGER COUNT, I, IC, IX, IY, J
146 REAL CS, D, DI, DR, EPS, F2, F2S, G2, G2S, SAFMIN,
147 $ SAFMN2, SAFMX2, SCALE
148 COMPLEX F, FF, FS, G, GS, R, SN
149* ..
150* .. External Functions ..
151 REAL SLAMCH, SLAPY2
152 EXTERNAL slamch, slapy2
153* ..
154* .. Intrinsic Functions ..
155 INTRINSIC abs, aimag, cmplx, conjg, int, log, max, real,
156 $ sqrt
157* ..
158* .. Statement Functions ..
159 REAL ABS1, ABSSQ
160* ..
161* .. Save statement ..
162* SAVE FIRST, SAFMX2, SAFMIN, SAFMN2
163* ..
164* .. Data statements ..
165* DATA FIRST / .TRUE. /
166* ..
167* .. Statement Function definitions ..
168 abs1( ff ) = max( abs( real( ff ) ), abs( aimag( ff ) ) )
169 abssq( ff ) = real( ff )**2 + aimag( ff )**2
170* ..
171* .. Executable Statements ..
172*
173* IF( FIRST ) THEN
174* FIRST = .FALSE.
175 safmin = slamch( 'S' )
176 eps = slamch( 'E' )
177 safmn2 = slamch( 'B' )**int( log( safmin / eps ) /
178 $ log( slamch( 'B' ) ) / two )
179 safmx2 = one / safmn2
180* END IF
181 ix = 1
182 iy = 1
183 ic = 1
184 DO 60 i = 1, n
185 f = x( ix )
186 g = y( iy )
187*
188* Use identical algorithm as in CLARTG
189*
190 scale = max( abs1( f ), abs1( g ) )
191 fs = f
192 gs = g
193 count = 0
194 IF( scale.GE.safmx2 ) THEN
195 10 CONTINUE
196 count = count + 1
197 fs = fs*safmn2
198 gs = gs*safmn2
199 scale = scale*safmn2
200 IF( scale.GE.safmx2 .AND. count .LT. 20 )
201 $ GO TO 10
202 ELSE IF( scale.LE.safmn2 ) THEN
203 IF( g.EQ.czero ) THEN
204 cs = one
205 sn = czero
206 r = f
207 GO TO 50
208 END IF
209 20 CONTINUE
210 count = count - 1
211 fs = fs*safmx2
212 gs = gs*safmx2
213 scale = scale*safmx2
214 IF( scale.LE.safmn2 )
215 $ GO TO 20
216 END IF
217 f2 = abssq( fs )
218 g2 = abssq( gs )
219 IF( f2.LE.max( g2, one )*safmin ) THEN
220*
221* This is a rare case: F is very small.
222*
223 IF( f.EQ.czero ) THEN
224 cs = zero
225 r = slapy2( real( g ), aimag( g ) )
226* Do complex/real division explicitly with two real
227* divisions
228 d = slapy2( real( gs ), aimag( gs ) )
229 sn = cmplx( real( gs ) / d, -aimag( gs ) / d )
230 GO TO 50
231 END IF
232 f2s = slapy2( real( fs ), aimag( fs ) )
233* G2 and G2S are accurate
234* G2 is at least SAFMIN, and G2S is at least SAFMN2
235 g2s = sqrt( g2 )
236* Error in CS from underflow in F2S is at most
237* UNFL / SAFMN2 .lt. sqrt(UNFL*EPS) .lt. EPS
238* If MAX(G2,ONE)=G2, then F2 .lt. G2*SAFMIN,
239* and so CS .lt. sqrt(SAFMIN)
240* If MAX(G2,ONE)=ONE, then F2 .lt. SAFMIN
241* and so CS .lt. sqrt(SAFMIN)/SAFMN2 = sqrt(EPS)
242* Therefore, CS = F2S/G2S / sqrt( 1 + (F2S/G2S)**2 ) = F2S/G2S
243 cs = f2s / g2s
244* Make sure abs(FF) = 1
245* Do complex/real division explicitly with 2 real divisions
246 IF( abs1( f ).GT.one ) THEN
247 d = slapy2( real( f ), aimag( f ) )
248 ff = cmplx( real( f ) / d, aimag( f ) / d )
249 ELSE
250 dr = safmx2*real( f )
251 di = safmx2*aimag( f )
252 d = slapy2( dr, di )
253 ff = cmplx( dr / d, di / d )
254 END IF
255 sn = ff*cmplx( real( gs ) / g2s, -aimag( gs ) / g2s )
256 r = cs*f + sn*g
257 ELSE
258*
259* This is the most common case.
260* Neither F2 nor F2/G2 are less than SAFMIN
261* F2S cannot overflow, and it is accurate
262*
263 f2s = sqrt( one+g2 / f2 )
264* Do the F2S(real)*FS(complex) multiply with two real
265* multiplies
266 r = cmplx( f2s*real( fs ), f2s*aimag( fs ) )
267 cs = one / f2s
268 d = f2 + g2
269* Do complex/real division explicitly with two real divisions
270 sn = cmplx( real( r ) / d, aimag( r ) / d )
271 sn = sn*conjg( gs )
272 IF( count.NE.0 ) THEN
273 IF( count.GT.0 ) THEN
274 DO 30 j = 1, count
275 r = r*safmx2
276 30 CONTINUE
277 ELSE
278 DO 40 j = 1, -count
279 r = r*safmn2
280 40 CONTINUE
281 END IF
282 END IF
283 END IF
284 50 CONTINUE
285 c( ic ) = cs
286 y( iy ) = sn
287 x( ix ) = r
288 ic = ic + incc
289 iy = iy + incy
290 ix = ix + incx
291 60 CONTINUE
292 RETURN
293*
294* End of CLARGV
295*
296 END
subroutine clargv(N, X, INCX, Y, INCY, C, INCC)
CLARGV generates a vector of plane rotations with real cosines and complex sines.
Definition: clargv.f:122