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,

 

 

 

 

 

yi is stored in y((i−1)⋅incy+1).

 

 

incy < 0

y is stored backward in array y; that

 

 

 

 

 

is, yi is stored in y((in)⋅incy+1).

 

 

Use incy = 1 if the vector y is stored contiguously in

 

 

array y; that is, if yi 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,

 

 

n

 

 

 

s = wi xi yi

 

 

 

i = 1

 

 

 

unless the subprogram name is CWDOTC or

 

 

ZWDOTC, in which case

 

 

n

 

 

 

s = wi

x

i yi.

 

 

 

i = 1

 

Notes

If incw = 0, then wi

= w(1) for all i. If incx = 0, then xi = x(1) for all i. If

 

incy = 0, then yi = y(1) for all i. In any of these cases, another VECLIB dot

 

product subprogram would be more efficient.

Fortran

REAL*4 FUNCTION SWDOT (N, W,INCW, X,INCX, Y,INCY)

Equivalent

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

148HP MLIB User’s Guide