LAPACK 3.12.0
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ zrscl()

subroutine zrscl ( integer  n,
complex*16  a,
complex*16, dimension( * )  x,
integer  incx 
)

ZDRSCL multiplies a vector by the reciprocal of a real scalar.

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

Purpose:
 ZRSCL multiplies an n-element complex vector x by the complex scalar
 1/a.  This is done without overflow or underflow as long as
 the final result x/a does not overflow or underflow.
Parameters
[in]N
          N is INTEGER
          The number of components of the vector x.
[in]A
          A is COMPLEX*16
          The scalar a which is used to divide each component of x.
          A must not be 0, or the subroutine will divide by zero.
[in,out]X
          X is COMPLEX*16 array, dimension
                         (1+(N-1)*abs(INCX))
          The n-element vector x.
[in]INCX
          INCX is INTEGER
          The increment between successive values of the vector SX.
          > 0:  SX(1) = X(1) and SX(1+(i-1)*INCX) = x(i),     1< i<= n
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.

Definition at line 83 of file zrscl.f.

84*
85* -- LAPACK auxiliary routine --
86* -- LAPACK is a software package provided by Univ. of Tennessee, --
87* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
88*
89* .. Scalar Arguments ..
90 INTEGER INCX, N
91 COMPLEX*16 A
92* ..
93* .. Array Arguments ..
94 COMPLEX*16 X( * )
95* ..
96*
97* =====================================================================
98*
99* .. Parameters ..
100 DOUBLE PRECISION ZERO, ONE
101 parameter( zero = 0.0d+0, one = 1.0d+0 )
102* ..
103* .. Local Scalars ..
104 DOUBLE PRECISION SAFMAX, SAFMIN, OV, AR, AI, ABSR, ABSI, UR, UI
105* ..
106* .. External Functions ..
107 DOUBLE PRECISION DLAMCH
108 COMPLEX*16 ZLADIV
109 EXTERNAL dlamch, zladiv
110* ..
111* .. External Subroutines ..
112 EXTERNAL dscal, zdscal, zdrscl
113* ..
114* .. Intrinsic Functions ..
115 INTRINSIC abs
116* ..
117* .. Executable Statements ..
118*
119* Quick return if possible
120*
121 IF( n.LE.0 )
122 $ RETURN
123*
124* Get machine parameters
125*
126 safmin = dlamch( 'S' )
127 safmax = one / safmin
128 ov = dlamch( 'O' )
129*
130* Initialize constants related to A.
131*
132 ar = dble( a )
133 ai = dimag( a )
134 absr = abs( ar )
135 absi = abs( ai )
136*
137 IF( ai.EQ.zero ) THEN
138* If alpha is real, then we can use csrscl
139 CALL zdrscl( n, ar, x, incx )
140*
141 ELSE IF( ar.EQ.zero ) THEN
142* If alpha has a zero real part, then we follow the same rules as if
143* alpha were real.
144 IF( absi.GT.safmax ) THEN
145 CALL zdscal( n, safmin, x, incx )
146 CALL zscal( n, dcmplx( zero, -safmax / ai ), x, incx )
147 ELSE IF( absi.LT.safmin ) THEN
148 CALL zscal( n, dcmplx( zero, -safmin / ai ), x, incx )
149 CALL zdscal( n, safmax, x, incx )
150 ELSE
151 CALL zscal( n, dcmplx( zero, -one / ai ), x, incx )
152 END IF
153*
154 ELSE
155* The following numbers can be computed.
156* They are the inverse of the real and imaginary parts of 1/alpha.
157* Note that a and b are always different from zero.
158* NaNs are only possible if either:
159* 1. alphaR or alphaI is NaN.
160* 2. alphaR and alphaI are both infinite, in which case it makes sense
161* to propagate a NaN.
162 ur = ar + ai * ( ai / ar )
163 ui = ai + ar * ( ar / ai )
164*
165 IF( (abs( ur ).LT.safmin).OR.(abs( ui ).LT.safmin) ) THEN
166* This means that both alphaR and alphaI are very small.
167 CALL zscal( n, dcmplx( safmin / ur, -safmin / ui ), x,
168 $ incx )
169 CALL zdscal( n, safmax, x, incx )
170 ELSE IF( (abs( ur ).GT.safmax).OR.(abs( ui ).GT.safmax) ) THEN
171 IF( (absr.GT.ov).OR.(absi.GT.ov) ) THEN
172* This means that a and b are both Inf. No need for scaling.
173 CALL zscal( n, dcmplx( one / ur, -one / ui ), x, incx )
174 ELSE
175 CALL zdscal( n, safmin, x, incx )
176 IF( (abs( ur ).GT.ov).OR.(abs( ui ).GT.ov) ) THEN
177* Infs were generated. We do proper scaling to avoid them.
178 IF( absr.GE.absi ) THEN
179* ABS( UR ) <= ABS( UI )
180 ur = (safmin * ar) + safmin * (ai * ( ai / ar ))
181 ui = (safmin * ai) + ar * ( (safmin * ar) / ai )
182 ELSE
183* ABS( UR ) > ABS( UI )
184 ur = (safmin * ar) + ai * ( (safmin * ai) / ar )
185 ui = (safmin * ai) + safmin * (ar * ( ar / ai ))
186 END IF
187 CALL zscal( n, dcmplx( one / ur, -one / ui ), x,
188 $ incx )
189 ELSE
190 CALL zscal( n, dcmplx( safmax / ur, -safmax / ui ),
191 $ x, incx )
192 END IF
193 END IF
194 ELSE
195 CALL zscal( n, dcmplx( one / ur, -one / ui ), x, incx )
196 END IF
197 END IF
198*
199 RETURN
200*
201* End of ZRSCL
202*
complex *16 function zladiv(x, y)
ZLADIV performs complex division in real arithmetic, avoiding unnecessary overflow.
Definition zladiv.f:64
double precision function dlamch(cmach)
DLAMCH
Definition dlamch.f:69
subroutine zdrscl(n, sa, sx, incx)
ZDRSCL multiplies a vector by the reciprocal of a real scalar.
Definition zdrscl.f:84
subroutine dscal(n, da, dx, incx)
DSCAL
Definition dscal.f:79
subroutine zdscal(n, da, zx, incx)
ZDSCAL
Definition zdscal.f:78
subroutine zscal(n, za, zx, incx)
ZSCAL
Definition zscal.f:78
Here is the call graph for this function:
Here is the caller graph for this function: