HP MLIB User's Guide Vol. 1 7th Ed.
Chapter 2 Basic Vector Operations 135
Scale vector SSCAL/DSCAL/CSCAL/CSSCAL/CSCALC/ZSCAL/ZDSCAL/ZSCALC
and ZSCALC and in unconjugated form by the other
subprograms. Refer to “Purpose.”
incx Increment for the array x, incx ≠ 0. x is stored forward
in array x with increment |incx|; that is, x
i
is stored in
x((i−1)×|incx|+1).
Use incx = 1 if the vector x is stored contiguously in
array x; that is, if x
i
is stored in x(i). Refer to “BLAS
Indexing Conventions” in the introduction to this
chapter.
Output x If n ≤ 0, then x is unchanged. Otherwise, ax replaces
the input.
Notes The result is unspecified if incx = 0.
Fortran
Equivalent
SUBROUTINE SSCAL (N,A, X,INCX)
REAL*4 A,X(*)
IF ( N .LE. 0 ) RETURN
IX = 1
INCXA = ABS ( INCX )
DO 10 I = 1, N
X(IX) = A * X(IX)
IX = IX + INCXA
10 CONTINUE
RETURN
END
Example Scale the REAL*8 vector x by 2, where x is a vector 10 elements long stored in a
one-dimensional array X of dimension 20.
INTEGER*4 N,INCX
REAL*8 A,X(20)
N = 10
INCX = 1
A = 2.0D0
CALL DSCAL (N,A,X,INCX)