HP MLIB User's Guide Vol. 1 7th Ed.
Chapter 2 Basic Vector Operations 149
Weighted dot product SWDOT/DWDOT/CWDOTC/CWDOTU/ZWDOTC/ZWDOTU
Example 1 Compute the REAL*8 weighted dot product
where w, x, and y are vectors 10 elements long stored in one-dimensional arrays
W, X, and Y, of dimension 20.
INTEGER*4 N,INCW,INCX,INCY
REAL*8 S,DWDOT,W(20),X(20),Y(20)
N = 10
INCW = 1
INCX = 1
INCY = 1
S = DWDOT (N,W,INCW,X,INCX,Y,INCY)
Example 2 Compute the REAL*8 weighted dot product
where w and y are vectors 10 elements long stored in one-dimensional arrays W
and Y of dimension 20, and x is the 4th row of a 10-by-10 matrix stored in a
two-dimensional array X of dimension 20-by-21.
INTEGER*4 N
REAL*8 S,DWDOT,W(20),X(20,21),Y(20)
N = 10
S = DWDOT (N,W,1,X(I,1),20,Y,1)
sw
i
x
i
y
i,
i 1=
10
∑
=
sw
i
x
i
y
i,
i 1=
10
∑
=