LAPACK 3.12.1
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 81 of file zrscl.f.

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