Previous Next Contents Generated Index Doc Set Home



Dot Product (Inner Product)

The subroutines described in this section compute variations on the dot product of the vectors x and y. DDOT, SDOT, ZDOTU, and CDOTU compute:

ZDOTC and CDOTC compute the dot product of the complex conjugate of x with y:

DSDOT computes the dot product of two real vectors x and y and accumulates the sum into a double precision accumulator.

SDSDOT computes the dot product of two real vectors x and y, adds a real constant to the result, and then returns the result rounded to single precision.

DQDOTI computes the dot product of two double precision vectors x and y, adds a real constant, stores the result in the extended precision variable C, and then returns the value of C rounded to double precision as the result of the function.

DQDOTA computes the dot product of two double precision vectors x and y, adds B and C, stores the result in the extended precision variable C, and then returns the value of C rounded to double precision as the result of the function.

Calling Sequence

DINNER = DDOT (N, DX, INCX, DY, INCY)
SINNER = SDOT (N, SX, INCX, SY, INCY)
ZINNER = ZDOTU (N, ZX, INCX, ZY, INCY)
CINNER = CDOTU (N, CX, INCX, CY, INCY)
ZINNER = ZDOTC (N, ZX, INCX, ZY, INCY)
CINNER = CDOTC (N, CX, INCX, CY, INCY)
DINNER = DSDOT (N, SX, INCX, SY, INCY)
SINNER = SDSDOT (N, SB, SX, INCX, SY, INCY)
DINNER = DQDOTI (N, DB, QC, DX, INCX, DY, INCY)
DINNER = DQDOTA (N, DB, QC, DX, INCX, DY, INCY)



double ddot(int n, double *dx, int incx, double *dy, int incy)
float sdot(int n, float *sx, int incx, float *sy, int incy)
doublecomplex *zdotu(int n, doublecomplex *cx, int incx, 
doublecomplex *cy, int incy)
complex *cdotu(int n, complex *cx, int incx, complex *cy, int incy)
doublecomplex *zdotc(int n, doublecomplex *cx, int incx, 
doublecomplex *cy, int incy)
complex *cdotc (int n, complex *cx, int incx, complex *cy, int incy)

Arguments

N

Number of elements in the vector. N 0.

xB

Only used in SDSDOT, DQDOTI, and DQDOTA. Scalar added to dot product in extended precision.

QC

Only used in DQDOTI and DQDOTA. Extended precision result of an operation. The representation of QC varies from one machine to the next, so directly using the value of QC in a way that depends on the representation of QC can inhibit portability.

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           I, INCX, INCY
      DOUBLE PRECISION  DOTPRD, X(N), Y(N)
C
      DOUBLE PRECISION  DDOT
      EXTERNAL          DDOT
C
C     Initialize the arrays X and Y to store the vectors x and y 
C     shown below.
C
C         1         3
C     x = 2    y =  0
C         3        -1
C
      DATA X / 1.0D0, 2.0D0, 3.0D0 /
      DATA Y / 3.0D0, 0.0D0, -1.0D0 /
C
      PRINT 1000
      PRINT 1010, (X(I), Y(I), I = 1, 3)
      INCX = 1
      INCY = 1
      DOTPRD = DDOT (N, X, INCX, Y, INCY)
      IF (DOTPRD .EQ. 0.0D0) THEN
        PRINT 1020
      ELSE
        PRINT 1030, DOTPRD
      END IF
C
 1000 FORMAT (3X, 'x', 5X, 'y')
 1010 FORMAT (1X, F4.1, 2X, F4.1)
 1020 FORMAT (/1X, 'Vectors x and y are orthogonal.')
 1030 FORMAT (/1X, 'dot (x,y) = ', F5.1)
C
      END
 

Sample Output

 
   x     y
  1.0   3.0
  2.0   0.0
  3.0  -1.0



 Vectors x and y are orthogonal.






Previous Next Contents Generated Index Doc Set Home