Previous Next Contents Generated Index Doc Set Home



Scale a Vector

The subroutines described in this section compute

Calling Sequence

CALL DSCAL 
(N, DALPHA, DY, INCY)
CALL SSCAL 
(N, SALPHA, SY, INCY)
CALL ZSCAL 
(N, ZALPHA, ZY, INCY)
CALL CSCAL 
(N, CALPHA, CY, INCY)
CALL ZDSCAL
 (N, DALPHA, ZY, INCY)
CALL CSSCAL
 (N, SALPHA, CY, INCY)






void dscal
(int n, double da, double *dx, int incx)
void sscal
(int n, float sa, float *sx, int incx)
void zscal
(int n, doublecomplex *za, doublecomplex *zx, int incx)
void cscal
(int n, complex *ca, complex *cx, int incx)
void zdscal
(int n, double da, doublecomplex *zx, int incx)
void csscal
 (int n, float sa, complex *cx, int incx)

Arguments

N

Number of elements in the vector. N 0.

xALPHA

Scalar that will be applied to Y.

xY

Input vector Y; the size of array Y must be at least max(1,N*|INCY|).

INCY

Specifies the storage spacing between successive elements of the vector Y. A value of one indicates that the elements of the vector are consecutive in memory. INCY > 0.

If Y refers to a two-dimensional array and the value of INCY is equal to the leading dimension of Y then the elements of the vector will be a row of Y.

If Y refers to a two-dimensional array and the value of INCY is equal to the leading dimension of Y plus one then the elements of the vector will be a diagonal of Y.

Sample Program

 
      PROGRAM TEST
      IMPLICIT NONE
C
      INTEGER           N
      PARAMETER        (N = 3)
C
      INTEGER           ICOL, INCX, IROW
      DOUBLE PRECISION  SCALE, X(N,N)
C
      EXTERNAL          DSCAL
C
C     Initialize the array X to store the vector x shown below.
C
C         5.0  5.5  6.0
C     x = 2.5  3.0  3.5
C         1.0  1.5  2.0
C
      DATA X / 5.0D0, 2.5D0, 1.0D0, 5.5D0, 3.0D0, 1.5D0,
     $         6.0D0, 3.5D0, 2.0D0 /
C
      PRINT 1000
      PRINT 1010, ((X(IROW,ICOL), ICOL = 1, N), IROW = 1, N)
      INCX = N
      SCALE = X(1,1) / X(2,1)
      CALL DSCAL (N, SCALE, X(2,1), INCX)
      PRINT 1020
      PRINT 1010, ((X(IROW,ICOL), ICOL = 1, N), IROW = 1, N)






C
 1000 FORMAT (1X, 'Before scaling row 2:')
 1010 FORMAT (3(3X, F3.1))
 1020 FORMAT (/1X, 'After scaling row 2:')
C
      END
 

Sample Output

 
 Before scaling row 2:
   5.0   5.5   6.0
   2.5   3.0   3.5
   1.0   1.5   2.0



 After scaling row 2:
   5.0   5.5   6.0
   5.0   6.0   7.0
   1.0   1.5   2.0






Previous Next Contents Generated Index Doc Set Home