Previous Next Contents Generated Index Doc Set Home



Product of a Scalar and Vector Plus a Vector

The subroutines in this section compute

Calling Sequence

CALL DAXPY 
(N, DALPHA, DX, INCX, DY, INCY)
CALL SAXPY 
(N, SALPHA, SX, INCX, SY, INCY)
CALL ZAXPY 
(N, ZALPHA, ZX, INCX, ZY, INCY)
CALL CAXPY 
(N, CALPHA, CX, INCX, CY, INCY)






void daxpy 
(int n, double da, double *dx, int incx, double *dy, 
(int incy)
void saxpy 
(int n, float sa, float *sx, int incx, float *sy, int 
incy)
void zaxpy 
(int n, doublecomplex *za, doublecomplex *zx, int incx, 
doublecomplex *zy, int incy)
void caxpy 
(int n, complex *ca, complex *cx, int incx, complex 
*cy, int incy)

Arguments

N

Number of elements in the vector. N 0.

xALPHA

Scalar that will be applied to vector X.

xX

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

INCX

Specifies the storage spacing between successive elements of the vector X. A value of one indicates that the elements of the vector are consecutive in memory.

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

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

xY

Result 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.

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, INCY, IROW
      DOUBLE PRECISION  SCALE, X(N,N)
C
      EXTERNAL          DAXPY
C
C     Initialize the array X to contain the matrix X shown below.
C
C         5.0  4.0  3.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, 4.0D0, 3.0D0, 1.5D0,
     $         3.0D0, 3.5D0, 2.0D0 /
C
      PRINT 1000
      PRINT 1010, ((X(IROW,ICOL), ICOL = 1, N), IROW = 1, N)
      INCX = N
      INCY = N
      SCALE = - X(2,1) / X(1,1)
      CALL DAXPY (N, SCALE, X(1,1), INCX, X(2,1), INCY)
      PRINT 1020
      PRINT 1010, ((X(IROW,ICOL), ICOL = 1, N), IROW = 1, N)
C
 1000 FORMAT (1X, 'X:')
 1010 FORMAT (3(2X, F4.2))
 1020 FORMAT (/1X, 'After one elimination:')
C
      END
 

Sample Output

 
 X:
  5.00  4.00  3.00
  2.50  3.00  3.50
  1.00  1.50  2.00



 After one elimination:
  5.00  4.00  3.00
  0.00  1.00  2.00
  1.00  1.50  2.00






Previous Next Contents Generated Index Doc Set Home