DotProduct

Computes dot product of two vectors.

Syntax

Case 1: Vector - vector operation

IppStatus ippmDotProduct_vv_32f(const Ipp32f* pSrc1, int src1Stride2, const Ipp32f* pSrc2, int src2Stride2, Ipp32f* pDst, int len);

IppStatus ippmDotProduct_vv_64f(const Ipp64f* pSrc1, int src1Stride2, const Ipp64f* pSrc2, int src2Stride2, Ipp64f* pDst, int len);

IppStatus ippmDotProduct_vv_32f_P(const Ipp32f** ppSrc1, int src1RoiShift, const Ipp32f** ppSrc2, int src2RoiShift, Ipp32f* pDst, int len);

IppStatus ippmDotProduct_vv_64f_P(const Ipp64f** ppSrc1, int src1RoiShift, const Ipp64f** ppSrc2, int src2RoiShift, Ipp64f* pDst, int len);

Case 2: Vector array - vector operation

IppStatus ippmDotProduct_vav_32f(const Ipp32f* pSrc1, int src1Stride0, int src1Stride2, const Ipp32f* pSrc2, int src2Stride2, Ipp32f* pDst, int len, int count);

IppStatus ippmDotProduct_vav_64f(const Ipp64f* pSrc1, int src1Stride0, int src1Stride2, const Ipp64f* pSrc2, int src2Stride2, Ipp64f* pDst, int len, int count);

IppStatus ippmDotProduct_vav_32f_P(const Ipp32f** ppSrc1, int src1RoiShift, int src1Stride0, const Ipp32f** ppSrc2, int src2RoiShift, Ipp32f* pDst, int len, int count);

IppStatus ippmDotProduct_vav_64f_P(const Ipp64f** ppSrc1, int src1RoiShift, int src1Stride0, const Ipp64f** ppSrc2, int src2RoiShift, Ipp64f* pDst, int len, int count);

IppStatus ippmDotProduct_vav_32f_L(const Ipp32f** ppSrc1, int src1RoiShift, int src1Stride2, const Ipp32f* pSrc2, int src2Stride2, Ipp32f* pDst, int len, int count);

IppStatus ippmDotProduct_vav_64f_L(const Ipp64f** ppSrc1, int src1RoiShift, int src1Stride2, const Ipp64f* pSrc2, int src2Stride2, Ipp64f* pDst, int len, int count);

Case 3: Vector array - vector array operation

IppStatus ippmDotProduct_vava_32f(const Ipp32f* pSrc1, int src1Stride0, int src1Stride2, const Ipp32f* pSrc2, int src2Stride0, int src2Stride2, Ipp32f* pDst, int len, int count);

IppStatus ippmDotProduct_vava_64f(const Ipp64f* pSrc1, int src1Stride0, int src1Stride2, const Ipp64f* pSrc2, int src2Stride0, int src2Stride2, Ipp64f* pDst, int len, int count);

IppStatus ippmDotProduct_vava_32f_P(const Ipp32f** ppSrc1, int src1RoiShift, int src1Stride0, const Ipp32f** ppSrc2, int src2RoiShift, int src2Stride0, Ipp32f* pDst, int len, int count);

IppStatus ippmDotProduct_vava_64f_P(const Ipp64f** ppSrc1, int src1RoiShift, int src1Stride0, const Ipp64f** ppSrc2, int src2RoiShift, int src2Stride0, Ipp64f* pDst, int len, int count);

IppStatus ippmDotProduct_vava_32f_L(const Ipp32f** ppSrc1, int src1RoiShift, int src1Stride2, const Ipp32f** ppSrc2, int src2RoiShift, int src2Stride2, Ipp32f* pDst, int len, int count);

IppStatus ippmDotProduct_vava_64f_L(const Ipp64f** ppSrc1, int src1RoiShift, int src1Stride2, const Ipp64f** ppSrc2, int src2RoiShift, int src2Stride2, Ipp64f* pDst, int len, int count);

Parameters

pSrc1, ppSrc1
Pointer to the first source vector or vector array.
src1Stride0
Stride between the vectors in the first source vector array.
src1Stride2
Stride between the elements in the first source vector(s).
src1RoiShift
ROI shift in the first source vector.
pSrc2, ppSrc2
Pointer to the second source vector or vector array.
src2Stride0
Stride between the vectors in the second source vector array.
src2Stride2
Stride between the elements in the second source vector(s).
src2RoiShift
ROI shift in the second source vector(s).
pDst
Pointer to the destination value or array of values.
len
Vector length.
count
Number of vectors in the array.

Description

The function ippmDotProduct is declared in the ippm.h header file. The function computes the inner (dot) product of two source vectors by adding together the products of their respective elements and storing the resulting value in pDst:

If the operation is performed on a vector array, the resulting values are stored sequentially in the array with the pointer pDst.

The following example demonstrates how to use the function ippmDotProduct_vav_32f. For more information, see also examples in Getting Started.

ippmDotProduct_vav_32f  

IppStatus dotProduct_vav_32f(void) {
    /* Src1 is 3 vectors with length=4 */
    Ipp32f pSrc1[3*4] = { 1,  2,  4,  8,
                          11, 22, 44, 88,
                          22, 44, 88, 176 };
 
    /* Src2 is vector with length=4 */
    Ipp32f pSrc2[4] = { 1, 0.5, 0.25 , 0.125 };
    /* Standard description for source vectors */
    int src1Stride2 = sizeof(Ipp32f);
    int src1Stride0 = 4*sizeof(Ipp32f);
    int src2Stride2 = sizeof(Ipp32f);
 
 
    int length = 4;
    int count  = 3;
 
    Ipp32f pDst[3];  /* Destination is array of values */
 
    IppStatus status = ippmDotProduct_vav_32f((const Ipp32f*)pSrc1,
        src1Stride0, src1Stride2, (const Ipp32f*)pSrc2, src2Stride2,
        pDst, length, count);
 
    /*
    // It is recommended to check return status 
    // to detect wrong input parameters, if any  
    */
    if (status == ippStsNoErr) {
        printf_va_Ipp32f("Src1 is 3 vectors:", pSrc1, 4, 3, status);
        printf_va_Ipp32f("Src2 is vector:", pSrc2, 4, 1, status);
        printf_va_Ipp32f("Dst is 3 values:", pDst, 3, 1, status);
    } else {
        printf("Function returns status: %s \n", ippGetStatusString(status));
    } 
 
    return status;
}

The program above produces the following output:

Src1 is 3 vectors:

1.000000  2.000000  4.000000  8.000000

11.000000  22.000000  44.000000  88.000000

22.000000  44.000000  88.000000  176.000000

Src2 is vector:

1.000000  0.500000  0.250000  0.125000

Dst is 3 values:

4.000000  44.000000  88.000000

Return Values

ippStsOk

Returns no error.

ippStsNullPtrErr

Returns an error when at least one input pointer is NULL.

ippStsSizeErr

Returns an error when the input size parameter is equal to 0.

ippStsStrideMatrixErr

Returns an error when the stride value is not positive or not divisible by size of data type.

ippStsRoiShiftMatrixErr

Returns an error when the roiShift value is negative or not divisible by size of data type.

ippStsCountMatrixErr

Returns an error when the count value is less or equal to zero.

Submit feedback on this help topic

Copyright © 2000 - 2011, Intel Corporation. All rights reserved.