CXML
sdot, ddot, dsdot, cdotc, zdotc, cdotu, zdotu
INNER PRODUCT OF TWO
VECTORS
FORMAT
{S,D}DOT (n, x, incx, y, incy) DSDOT (n, x, incx, y, incy) {C,Z}DOT{C,U}
(n, x, incx, y, incy)
Function Value
dotpr: real*4 | real*8 | complex*8 | complex*16
The dot product of the two vectors x and y.
For real vectors, if n <= 0 , dotpr returns the value 0.0.
For complex vectors, if n <= 0 , dotpr returns (0.0, 0.0).
Arguments
n integer*4
On entry, the number of elements in the vectors x and
y.
On exit, n is unchanged.
X real*4 | real*8 | complex*8 | complex*16
On entry, a one-dimensional array X of length at least
(1+(n-1)*|incx|), containing the elements of the vector
x.
On exit, x is unchanged.
incx integer*4
On entry, the increment for the array X.
If incx >= 0, vector x is stored forward in the array,
so that x(i) is stored in location X(1+(i-1)*incx).
If incx < 0, vector x is stored backward in the array,
so that x(i) is stored in location X(1+(n-i)*|incx|).
On exit, incx is unchanged.
y real*4 | real*8 | complex*8 | complex*16
On entry, a one-dimensional array Y of length at least
(1+(n-1)*|incx|), containing the elements of the vector
y.
On exit, y is unchanged.
incy integer*4
On entry, the increment for the array Y.
If incy >= 0, vector y is stored forward in the array,
so that y(i) is stored in location Y(1+(i-1)*incy).
If incy < 0, vector y is stored backward in the array,
so that y(i) is stored in location Y(1+(n-i)*|incy|).
On exit, incy is unchanged.
Description
SDOT, DDOT, and DSDOT compute the dot product of two real vectors. CDOTC
and ZDOTC compute the conjugated dot product of two complex vectors. CDOTU
and ZDOTU compute the unconjugated dot product of two complex vectors.
SDOT, DDOT, DSDOT are functions that compute the dot product of two n-
element real vectors, x and y:
x dot y = SUM(i=1...n,x(i)y(i)) = x(1)y(1) + x(2)y(2) + ... + x(n)y(n)
The order of operations is different from the order in a sequential
evaluation of the dot product. The final result can differ from the result
of a sequential evaluation. The DSDOT functions returns the value in
double-precision.
CDOTC and ZDOTC are functions that compute the conjugated dot product of
two complex vectors, x and y, that is, the complex conjugate of the first
vector is used to compute the dot product.
Each element x(j) of the vector x is a complex number and each element y(j)
of the vector y is a complex number. The conjugated dot product of two
complex vectors, x and y, is expressed as follows:
conjugate(x) dot y = SUM(i=1...n,conjugate(x(i))y(i)) =
= conjugate(x)(1)y(1) + conjugate(x)(2)y(2) + ... + conjugate(x)(n)y(n)
For example, x and y each have two complex elements:
x = (1 + i, 2 - i), y = (3 + i, 3 + 2i)
The conjugate of vector x is
conjugate(x) = (1 - i, 2 + i), and the dot product is
conjugate(x) dot y = (1-i)(3+i) + (2+i)(3+2i) = (4-2i) + (4+7i) = (8+5i))
CDOTU and ZDOTU compute the unconjugated dot product of two complex
vectors. The unconjugated dot product of two complex vectors, x and y, is
expressed as follows:
x dot y = SUM(i=1...n,x(i)y(i)) = x(1)y(1) + x(2)y(2) + ... + x(n)y(n)
For example, for the same complex vectors x and y:
x dot y = (1+i)(2+i) + (2-i)(3+2i) = (1+3i) + (8+i) = 9+4i
Example
INTEGER*4 INCX, INCY
REAL*4 X(20), Y(20), DOTPR
INCX = 1
INCY = 1
N = 20
DOTPR = SDOT(N,X,INCX,Y,INCY)
This FORTRAN code shows how to compute the dot product of two vectors, x
and y, and return the result in dotpr.
INTEGER*4 INCX, INCY
COMPLEX*8 X(20), Y(20), DOTPR
INCX = 1
INCY = 1
N = 20
DOTPR = CDOTU(N,X,INCX,Y,INCY)
This FORTRAN code shows how to compute the unconjugated dot product of two
complex vectors, x and y, and return the result in dotpr.
CXML Home Page Index of CXML Routines