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

◆ srscl()

subroutine srscl ( integer n,
real sa,
real, dimension( * ) sx,
integer incx )

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

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

Purpose:
!>
!> SRSCL 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 REAL
!>          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 REAL 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 srscl.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 REAL SA
90* ..
91* .. Array Arguments ..
92 REAL SX( * )
93* ..
94*
95* =====================================================================
96*
97* .. Parameters ..
98 REAL ONE, ZERO
99 parameter( one = 1.0e+0, zero = 0.0e+0 )
100* ..
101* .. Local Scalars ..
102 LOGICAL DONE
103 REAL BIGNUM, CDEN, CDEN1, CNUM, CNUM1, MUL, SMLNUM
104* ..
105* .. External Functions ..
106 REAL SLAMCH
107 EXTERNAL slamch
108* ..
109* .. External Subroutines ..
110 EXTERNAL sscal
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 = slamch( '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 sscal( n, mul, sx, incx )
160*
161 IF( .NOT.done )
162 $ GO TO 10
163*
164 RETURN
165*
166* End of SRSCL
167*
real function slamch(cmach)
SLAMCH
Definition slamch.f:68
subroutine sscal(n, sa, sx, incx)
SSCAL
Definition sscal.f:79
Here is the call graph for this function:
Here is the caller graph for this function: