## Developer Reference

• 2021
• 06/28/2021
• Public Content
Contents

# DotProd

Computes the dot product of two vectors.

## Syntax

Include Files
ipps.h
Domain Dependencies
ippcore.h
,
ippvm.h
Libraries:
ippcore.lib
,
ippvm.lib
Parameters
pSrc1
Pointer to the first vector to compute the dot product value.
pSrc2
Pointer to the second vector to compute the dot product value.
pDp
Pointer to the output result.
len
Number of elements in the vector.
scaleFactor
Scale factor, refer to Integer Scaling.
Description
This function computes the dot product (scalar value) of two vectors,
pSrc1
and
pSrc2
, and stores the result in
pDp
.
The computation is performed as follows: To compute the dot product of complex data, use the function
ippsConj
to conjugate one of the operands. The vectors
pSrc1
and
pSrc2
must be of equal length.
Return Values
ippStsNoErr
Indicates no error.
ippStsNullPtrErr
Indicates an error when the
pDp
,
pSrc1
, or
pSrc
2 pointer is
NULL
.
ippStsSizeErr
Indicates an error when
len
is less than or equal to 0.

## Example

The example below shows how to use the function
ippsDotProd_64f
to verify orthogonality of the sine and cosine functions. Two vectors are orthogonal to each other when the dot product of the two vectors is zero.
```
void dotprod(void) {
Ipp64f x, dp;
int n;
for (n = 0; n<10; ++n) x[n] = sin(IPP_2PI * n / 8);
ippsDotProd_64f(x, x+2, 8, &dp);
printf_64f(“dp =”, &dp, 1, ippStsNoErr);
}```
Output:
``` dp = 0.000000
Matlab* Analog:
>> n = 0:9; x = sin(2*pi*n/8); a = x(1:8); b = x(3:10); a*b'```

#### Product and Performance Information

1

Performance varies by use, configuration and other factors. Learn more at www.Intel.com/PerformanceIndex.