HP MLIB User's Guide Vol. 1 7th Ed.
148 HP MLIB User’s Guide
SWDOT/DWDOT/CWDOTC/CWDOTU/ZWDOTC/ZWDOTU Weighted dot product
incy Increment for the array y:
incy ≥ 0 y is stored forward in array y; that is,
y
i
is stored in y((i−1)×incy+1).
incy < 0 y is stored backward in array y; that
is, y
i
is stored in y((i−n)×incy+1).
Use incy = 1 if the vector y is stored contiguously in
array y; that is, if y
i
is stored in y(i). Refer to “BLAS
Indexing Conventions” in the introduction to this
chapter.
Output s The resulting value of the weighted dot product. If
n ≤ 0, then s = 0. Otherwise,
unless the subprogram name is CWDOTC or
ZWDOTC, in which case
Notes If incw = 0, then w
i
= w(1) for all i. If incx = 0, then x
i
= x(1) for all i. If
incy = 0, then y
i
= y(1) for all i. In any of these cases, another VECLIB dot
product subprogram would be more efficient.
Fortran
Equivalent
REAL*4 FUNCTION SWDOT (N, W,INCW, X,INCX, Y,INCY)
REAL*4 W(*),X(*),Y(*)
SWDOT = 0.0
IF ( N .LE. 0 ) RETURN
IW = 1
IX = 1
IY = 1
IF ( INCW .LT. 0 ) IW = 1 - (N-1) * INCW
IF ( INCX .LT. 0 ) IX = 1 - (N-1) * INCX
IF ( INCY .LT. 0 ) IY = 1 - (N-1) * INCY
DO 10 I = 1, N
SWDOT = SWDOT + W(IW) * X(IX) * Y(IY)
IW = IW + INCW
IX = IX + INCX
IY = IY + INCY
10 CONTINUE
RETURN
END
s w
i
x
i
y
i
i 1=
n
∑
=
s w
i
x
i
y
i.
i 1=
n
∑
=