You are here: Symbol Reference > clMtxExpr Namespace > Classes > clVector Record > public > DotProd Method > clVector.DotProd Method (integer, TOpenCLMtxVec, TOpenCLMtxVec, TOpenCLMtxVec)
MtxVec VCL
ContentsIndex
PreviousUpNext
clVector.DotProd Method (integer, TOpenCLMtxVec, TOpenCLMtxVec, TOpenCLMtxVec)

Scalar product of two real arrays.

Pascal
procedure DotProd(DstIndex: integer; const Vec1: TOpenCLMtxVec; const Vec2: TOpenCLMtxVec; const Buffer: TOpenCLMtxVec); overload;

Calculates the dot product (scalar value) of the calling object and Vec object and returns a real scalar value. The result is stored at specified index in the calling vector in the GPU memory. This variant of the function is non-blocking (faster), because the result does not have to be copied to the CPU memory to be used. 

The dot product is defined by the equation: 

 

Both objects must be of equal size. If they are not, the method will return the dot product of the largest sub-array.

var a,b: TOpenCLVector; ac: TDoubleArray; prod: double; begin CreateIt(a,b,c); try a.CopyFromAray(TDoubleArray.Create(1,2,3,4)); b.CopyFromAray(TDoubleArray.Create(5,6,7,8)); c.Size(3); c.DotProd(0, a,b); // c[0] = 1*5 + 2*6 + * 3*7 + 4*8 c.DotProd(1, a,b); // c[1] = 1*5 + 2*6 + * 3*7 + 4*8 c.DotProd(2, a,b); // c[2] = 1*5 + 2*6 + * 3*7 + 4*8 c.CopyToArray(ac); //ac = [70, 70, 70] finally FreeIt(a,b,c); end; end;
Examples on GitHub
Copyright (c) 1999-2025 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!