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

◆ drscl()

subroutine drscl ( integer n,
double precision sa,
double precision, dimension( * ) sx,
integer incx )

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

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

Purpose:
!>
!> DRSCL multiplies an n-element real vector x by the real 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]SA
!>          SA is DOUBLE PRECISION
!>          The scalar a which is used to divide each component of x.
!>          SA must be >= 0, or the subroutine will divide by zero.
!> 
[in,out]SX
!>          SX is DOUBLE PRECISION 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 drscl.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 DOUBLE PRECISION SA
90* ..
91* .. Array Arguments ..
92 DOUBLE PRECISION SX( * )
93* ..
94*
95* =====================================================================
96*
97* .. Parameters ..
98 DOUBLE PRECISION ONE, ZERO
99 parameter( one = 1.0d+0, zero = 0.0d+0 )
100* ..
101* .. Local Scalars ..
102 LOGICAL DONE
103 DOUBLE PRECISION BIGNUM, CDEN, CDEN1, CNUM, CNUM1, MUL, SMLNUM
104* ..
105* .. External Functions ..
106 DOUBLE PRECISION DLAMCH
107 EXTERNAL dlamch
108* ..
109* .. External Subroutines ..
110 EXTERNAL dscal
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 smlnum = dlamch( 'S' )
125 bignum = one / smlnum
126*
127* Initialize the denominator to SA and the numerator to 1.
128*
129 cden = sa
130 cnum = one
131*
132 10 CONTINUE
133 cden1 = cden*smlnum
134 cnum1 = cnum / bignum
135 IF( abs( cden1 ).GT.abs( cnum ) .AND. cnum.NE.zero ) THEN
136*
137* Pre-multiply X by SMLNUM if CDEN is large compared to CNUM.
138*
139 mul = smlnum
140 done = .false.
141 cden = cden1
142 ELSE IF( abs( cnum1 ).GT.abs( cden ) ) THEN
143*
144* Pre-multiply X by BIGNUM if CDEN is small compared to CNUM.
145*
146 mul = bignum
147 done = .false.
148 cnum = cnum1
149 ELSE
150*
151* Multiply X by CNUM / CDEN and return.
152*
153 mul = cnum / cden
154 done = .true.
155 END IF
156*
157* Scale the vector X by MUL
158*
159 CALL dscal( n, mul, sx, incx )
160*
161 IF( .NOT.done )
162 $ GO TO 10
163*
164 RETURN
165*
166* End of DRSCL
167*
double precision function dlamch(cmach)
DLAMCH
Definition dlamch.f:69
subroutine dscal(n, da, dx, incx)
DSCAL
Definition dscal.f:79
Here is the call graph for this function:
Here is the caller graph for this function: