LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
zrscl.f
Go to the documentation of this file.
1*> \brief \b ZDRSCL multiplies a vector by the reciprocal of a real scalar.
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download ZDRSCL + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zdrscl.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zdrscl.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zdrscl.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE ZRSCL( N, A, X, INCX )
20*
21* .. Scalar Arguments ..
22* INTEGER INCX, N
23* COMPLEX*16 A
24* ..
25* .. Array Arguments ..
26* COMPLEX*16 X( * )
27* ..
28*
29*
30*> \par Purpose:
31* =============
32*>
33*> \verbatim
34*>
35*> ZRSCL multiplies an n-element complex vector x by the complex scalar
36*> 1/a. This is done without overflow or underflow as long as
37*> the final result x/a does not overflow or underflow.
38*> \endverbatim
39*
40* Arguments:
41* ==========
42*
43*> \param[in] N
44*> \verbatim
45*> N is INTEGER
46*> The number of components of the vector x.
47*> \endverbatim
48*>
49*> \param[in] A
50*> \verbatim
51*> A is COMPLEX*16
52*> The scalar a which is used to divide each component of x.
53*> A must not be 0, or the subroutine will divide by zero.
54*> \endverbatim
55*>
56*> \param[in,out] X
57*> \verbatim
58*> X is COMPLEX*16 array, dimension
59*> (1+(N-1)*abs(INCX))
60*> The n-element vector x.
61*> \endverbatim
62*>
63*> \param[in] INCX
64*> \verbatim
65*> INCX is INTEGER
66*> The increment between successive values of the vector SX.
67*> > 0: SX(1) = X(1) and SX(1+(i-1)*INCX) = x(i), 1< i<= n
68*> \endverbatim
69*
70* Authors:
71* ========
72*
73*> \author Univ. of Tennessee
74*> \author Univ. of California Berkeley
75*> \author Univ. of Colorado Denver
76*> \author NAG Ltd.
77*
78*> \ingroup complex16OTHERauxiliary
79*
80* =====================================================================
81 SUBROUTINE zrscl( N, A, X, INCX )
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*
202 END
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
subroutine zrscl(n, a, x, incx)
ZDRSCL multiplies a vector by the reciprocal of a real scalar.
Definition zrscl.f:82