LAPACK  3.10.1 LAPACK: Linear Algebra PACKage

## ◆ srscl()

 subroutine srscl ( integer N, real SA, real, dimension( * ) SX, integer INCX )

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

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```

Definition at line 83 of file srscl.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  REAL SA
92 * ..
93 * .. Array Arguments ..
94  REAL SX( * )
95 * ..
96 *
97 * =====================================================================
98 *
99 * .. Parameters ..
100  REAL ONE, ZERO
101  parameter( one = 1.0e+0, zero = 0.0e+0 )
102 * ..
103 * .. Local Scalars ..
104  LOGICAL DONE
105  REAL BIGNUM, CDEN, CDEN1, CNUM, CNUM1, MUL, SMLNUM
106 * ..
107 * .. External Functions ..
108  REAL SLAMCH
109  EXTERNAL slamch
110 * ..
111 * .. External Subroutines ..
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  smlnum = slamch( 'S' )
127  bignum = one / smlnum
128  CALL slabad( smlnum, bignum )
129 *
130 * Initialize the denominator to SA and the numerator to 1.
131 *
132  cden = sa
133  cnum = one
134 *
135  10 CONTINUE
136  cden1 = cden*smlnum
137  cnum1 = cnum / bignum
138  IF( abs( cden1 ).GT.abs( cnum ) .AND. cnum.NE.zero ) THEN
139 *
140 * Pre-multiply X by SMLNUM if CDEN is large compared to CNUM.
141 *
142  mul = smlnum
143  done = .false.
144  cden = cden1
145  ELSE IF( abs( cnum1 ).GT.abs( cden ) ) THEN
146 *
147 * Pre-multiply X by BIGNUM if CDEN is small compared to CNUM.
148 *
149  mul = bignum
150  done = .false.
151  cnum = cnum1
152  ELSE
153 *
154 * Multiply X by CNUM / CDEN and return.
155 *
156  mul = cnum / cden
157  done = .true.
158  END IF
159 *
160 * Scale the vector X by MUL
161 *
162  CALL sscal( n, mul, sx, incx )
163 *
164  IF( .NOT.done )
165  \$ GO TO 10
166 *
167  RETURN
168 *
169 * End of SRSCL
170 *