LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
subroutine zlargv ( integer  N,
complex*16, dimension( * )  X,
integer  INCX,
complex*16, dimension( * )  Y,
integer  INCY,
double precision, dimension( * )  C,
integer  INCC 
)

ZLARGV generates a vector of plane rotations with real cosines and complex sines.

Download ZLARGV + dependencies [TGZ] [ZIP] [TXT]

Purpose:
 ZLARGV generates a vector of complex plane rotations with real
 cosines, determined by elements of the complex vectors x and y.
 For i = 1,2,...,n

    (        c(i)   s(i) ) ( x(i) ) = ( r(i) )
    ( -conjg(s(i))  c(i) ) ( y(i) ) = (   0  )

    where c(i)**2 + ABS(s(i))**2 = 1

 The following conventions are used (these are the same as in ZLARTG,
 but differ from the BLAS1 routine ZROTG):
    If y(i)=0, then c(i)=1 and s(i)=0.
    If x(i)=0, then c(i)=0 and s(i) is chosen so that r(i) is real.
Parameters
[in]N
          N is INTEGER
          The number of plane rotations to be generated.
[in,out]X
          X is COMPLEX*16 array, dimension (1+(N-1)*INCX)
          On entry, the vector x.
          On exit, x(i) is overwritten by r(i), for i = 1,...,n.
[in]INCX
          INCX is INTEGER
          The increment between elements of X. INCX > 0.
[in,out]Y
          Y is COMPLEX*16 array, dimension (1+(N-1)*INCY)
          On entry, the vector y.
          On exit, the sines of the plane rotations.
[in]INCY
          INCY is INTEGER
          The increment between elements of Y. INCY > 0.
[out]C
          C is DOUBLE PRECISION array, dimension (1+(N-1)*INCC)
          The cosines of the plane rotations.
[in]INCC
          INCC is INTEGER
          The increment between elements of C. INCC > 0.
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Date
September 2012
Further Details:
  6-6-96 - Modified with a new algorithm by W. Kahan and J. Demmel

  This version has a few statements commented out for thread safety
  (machine parameters are computed on each entry). 10 feb 03, SJH.

Definition at line 124 of file zlargv.f.

124 *
125 * -- LAPACK auxiliary routine (version 3.4.2) --
126 * -- LAPACK is a software package provided by Univ. of Tennessee, --
127 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
128 * September 2012
129 *
130 * .. Scalar Arguments ..
131  INTEGER incc, incx, incy, n
132 * ..
133 * .. Array Arguments ..
134  DOUBLE PRECISION c( * )
135  COMPLEX*16 x( * ), y( * )
136 * ..
137 *
138 * =====================================================================
139 *
140 * .. Parameters ..
141  DOUBLE PRECISION two, one, zero
142  parameter ( two = 2.0d+0, one = 1.0d+0, zero = 0.0d+0 )
143  COMPLEX*16 czero
144  parameter ( czero = ( 0.0d+0, 0.0d+0 ) )
145 * ..
146 * .. Local Scalars ..
147 * LOGICAL FIRST
148 
149  INTEGER count, i, ic, ix, iy, j
150  DOUBLE PRECISION cs, d, di, dr, eps, f2, f2s, g2, g2s, safmin,
151  $ safmn2, safmx2, scale
152  COMPLEX*16 f, ff, fs, g, gs, r, sn
153 * ..
154 * .. External Functions ..
155  DOUBLE PRECISION dlamch, dlapy2
156  EXTERNAL dlamch, dlapy2
157 * ..
158 * .. Intrinsic Functions ..
159  INTRINSIC abs, dble, dcmplx, dconjg, dimag, int, log,
160  $ max, sqrt
161 * ..
162 * .. Statement Functions ..
163  DOUBLE PRECISION abs1, abssq
164 * ..
165 * .. Save statement ..
166 * SAVE FIRST, SAFMX2, SAFMIN, SAFMN2
167 * ..
168 * .. Data statements ..
169 * DATA FIRST / .TRUE. /
170 * ..
171 * .. Statement Function definitions ..
172  abs1( ff ) = max( abs( dble( ff ) ), abs( dimag( ff ) ) )
173  abssq( ff ) = dble( ff )**2 + dimag( ff )**2
174 * ..
175 * .. Executable Statements ..
176 *
177 * IF( FIRST ) THEN
178 * FIRST = .FALSE.
179  safmin = dlamch( 'S' )
180  eps = dlamch( 'E' )
181  safmn2 = dlamch( 'B' )**int( log( safmin / eps ) /
182  $ log( dlamch( 'B' ) ) / two )
183  safmx2 = one / safmn2
184 * END IF
185  ix = 1
186  iy = 1
187  ic = 1
188  DO 60 i = 1, n
189  f = x( ix )
190  g = y( iy )
191 *
192 * Use identical algorithm as in ZLARTG
193 *
194  scale = max( abs1( f ), abs1( g ) )
195  fs = f
196  gs = g
197  count = 0
198  IF( scale.GE.safmx2 ) THEN
199  10 CONTINUE
200  count = count + 1
201  fs = fs*safmn2
202  gs = gs*safmn2
203  scale = scale*safmn2
204  IF( scale.GE.safmx2 )
205  $ GO TO 10
206  ELSE IF( scale.LE.safmn2 ) THEN
207  IF( g.EQ.czero ) THEN
208  cs = one
209  sn = czero
210  r = f
211  GO TO 50
212  END IF
213  20 CONTINUE
214  count = count - 1
215  fs = fs*safmx2
216  gs = gs*safmx2
217  scale = scale*safmx2
218  IF( scale.LE.safmn2 )
219  $ GO TO 20
220  END IF
221  f2 = abssq( fs )
222  g2 = abssq( gs )
223  IF( f2.LE.max( g2, one )*safmin ) THEN
224 *
225 * This is a rare case: F is very small.
226 *
227  IF( f.EQ.czero ) THEN
228  cs = zero
229  r = dlapy2( dble( g ), dimag( g ) )
230 * Do complex/real division explicitly with two real
231 * divisions
232  d = dlapy2( dble( gs ), dimag( gs ) )
233  sn = dcmplx( dble( gs ) / d, -dimag( gs ) / d )
234  GO TO 50
235  END IF
236  f2s = dlapy2( dble( fs ), dimag( fs ) )
237 * G2 and G2S are accurate
238 * G2 is at least SAFMIN, and G2S is at least SAFMN2
239  g2s = sqrt( g2 )
240 * Error in CS from underflow in F2S is at most
241 * UNFL / SAFMN2 .lt. sqrt(UNFL*EPS) .lt. EPS
242 * If MAX(G2,ONE)=G2, then F2 .lt. G2*SAFMIN,
243 * and so CS .lt. sqrt(SAFMIN)
244 * If MAX(G2,ONE)=ONE, then F2 .lt. SAFMIN
245 * and so CS .lt. sqrt(SAFMIN)/SAFMN2 = sqrt(EPS)
246 * Therefore, CS = F2S/G2S / sqrt( 1 + (F2S/G2S)**2 ) = F2S/G2S
247  cs = f2s / g2s
248 * Make sure abs(FF) = 1
249 * Do complex/real division explicitly with 2 real divisions
250  IF( abs1( f ).GT.one ) THEN
251  d = dlapy2( dble( f ), dimag( f ) )
252  ff = dcmplx( dble( f ) / d, dimag( f ) / d )
253  ELSE
254  dr = safmx2*dble( f )
255  di = safmx2*dimag( f )
256  d = dlapy2( dr, di )
257  ff = dcmplx( dr / d, di / d )
258  END IF
259  sn = ff*dcmplx( dble( gs ) / g2s, -dimag( gs ) / g2s )
260  r = cs*f + sn*g
261  ELSE
262 *
263 * This is the most common case.
264 * Neither F2 nor F2/G2 are less than SAFMIN
265 * F2S cannot overflow, and it is accurate
266 *
267  f2s = sqrt( one+g2 / f2 )
268 * Do the F2S(real)*FS(complex) multiply with two real
269 * multiplies
270  r = dcmplx( f2s*dble( fs ), f2s*dimag( fs ) )
271  cs = one / f2s
272  d = f2 + g2
273 * Do complex/real division explicitly with two real divisions
274  sn = dcmplx( dble( r ) / d, dimag( r ) / d )
275  sn = sn*dconjg( gs )
276  IF( count.NE.0 ) THEN
277  IF( count.GT.0 ) THEN
278  DO 30 j = 1, count
279  r = r*safmx2
280  30 CONTINUE
281  ELSE
282  DO 40 j = 1, -count
283  r = r*safmn2
284  40 CONTINUE
285  END IF
286  END IF
287  END IF
288  50 CONTINUE
289  c( ic ) = cs
290  y( iy ) = sn
291  x( ix ) = r
292  ic = ic + incc
293  iy = iy + incy
294  ix = ix + incx
295  60 CONTINUE
296  RETURN
297 *
298 * End of ZLARGV
299 *
double precision function dlamch(CMACH)
DLAMCH
Definition: dlamch.f:65
double precision function dlapy2(X, Y)
DLAPY2 returns sqrt(x2+y2).
Definition: dlapy2.f:65

Here is the caller graph for this function: