Add

Adds constant to vector or vector to another vector.

Syntax

Case 1: Vector - constant operation

IppStatus ippmAdd_vc_32f(const Ipp32f* pSrc, int srcStride2, Ipp32f val, Ipp32f* pDst, int dstStride2, int len);

IppStatus ippmAdd_vc_64f(const Ipp64f* pSrc, int srcStride2, Ipp64f val, Ipp64f* pDst, int dstStride2, int len);

IppStatus ippmAdd_vc_32f_P(const Ipp32f** ppSrc, int srcRoiShift, Ipp32f val, Ipp32f** ppDst, int dstRoiShift, int len);

IppStatus ippmAdd_vc_64f_P(const Ipp64f** ppSrc, int srcRoiShift, Ipp64f val, Ipp64f** ppDst, int dstRoiShift, int len);

Case 2: Vector array - constant operation

IppStatus ippmAdd_vac_32f(const Ipp32f* pSrc, int srcStride0, int srcStride2, Ipp32f val, Ipp32f* pDst, int dstStride0, int dstStride2, int len, int count);

IppStatus ippmAdd_vac_64f(const Ipp64f* pSrc, int srcStride0, int srcStride2, Ipp64f val, Ipp64f* pDst, int dstStride0, int dstStride2, int len, int count);

IppStatus ippmAdd_vac_32f_P(const Ipp32f** ppSrc, int srcRoiShift, int srcStride0, Ipp32f val, Ipp32f** ppDst, int dstRoiShift, int dstStride0, int len, int count);

IppStatus ippmAdd_vac_64f_P(const Ipp64f** ppSrc, int srcRoiShift, int srcStride0, Ipp64f val, Ipp64f** ppDst, int dstRoiShift, int dstStride0, int len, int count);

IppStatus ippmAdd_vac_32f_L(const Ipp32f** ppSrc, int srcRoiShift, int srcStride2, Ipp32f val, Ipp32f** ppDst, int dstRoiShift, int dstStride2, int len, int count);

IppStatus ippmAdd_vac_64f_L(const Ipp64f** ppSrc, int srcRoiShift, int srcStride2, Ipp64f val, Ipp64f** ppDst, int dstRoiShift, int dstStride2, int len, int count);

Case 3: Vector array - constant array operation

IppStatus ippmAdd_vaca_32f (const Ipp32f* pSrc, int srcStride0, int srcStride2, const Ipp32f* pVal, int valStride0, Ipp32f* pDst, int dstStride0, int dstStride2, int len, int count);

IppStatus ippmAdd_vaca_64f (const Ipp64f* pSrc, int srcStride0, int srcStride2, const Ipp64f* pVal, int valStride0, Ipp64f* pDst, int dstStride0, int dstStride2, int len, int count);

IppStatus ippmAdd_vaca_32f_P (const Ipp32f** ppSrc, int srcRoiShift, int srcStride0, const Ipp32f* pVal, int valStride0, Ipp32f** ppDst, int dstRoiShift, int dstStride0, int len, int count);

IppStatus ippmAdd_vaca_64f_P (const Ipp64f** ppSrc, int srcRoiShift, int srcStride0, const Ipp64f* pVal, int valStride0, Ipp64f** ppDst, int dstRoiShift, int dstStride0, int len, int count);

IppStatus ippmAdd_vaca_32f_L (const Ipp32f** ppSrc, int srcRoiShift, int srcStride2, const Ipp32f** ppVal, int valRoiShift, Ipp32f** ppDst, int dstRoiShift, int dstStride2, int len, int count);

IppStatus ippmAdd_vaca_64f_L (const Ipp64f** ppSrc, int srcRoiShift, int srcStride2, const Ipp64f** ppVal, int valRoiShift, Ipp64f** ppDst, int dstRoiShift, int dstStride2, int len, int count);

Case 4: Vector - constant array operation

IppStatus ippmAdd_vca_32f (const Ipp32f* pSrc, int srcStride2, const Ipp32f* pVal, int valStride0, Ipp32f* pDst, int dstStride0, int dstStride2, int len, int count);

IppStatus ippmAdd_vca_64f (const Ipp64f* pSrc, int srcStride2, const Ipp64f* pVal, int valStride0, Ipp64f* pDst, int dstStride0, int dstStride2, int len, int count);

IppStatus ippmAdd_vca_32f_P (const Ipp32f** ppSrc, int srcRoiShift, const Ipp32f* pVal, int valStride0, Ipp32f** ppDst, int dstRoiShift, int dstStride0, int len, int count);

IppStatus ippmAdd_vca_64f_P (const Ipp64f** ppSrc, int srcRoiShift, const Ipp64f* pVal, int valStride0, Ipp64f** ppDst, int dstRoiShift, int dstStride0, int len, int count);

IppStatus ippmAdd_vca_32f_L (const Ipp32f* pSrc, int srcStride2, const Ipp32f** ppVal, int valRoiShift, Ipp32f** ppDst, int dstRoiShift, int dstStride2, int len, int count);

IppStatus ippmAdd_vca_64f_L (const Ipp64f* pSrc, int srcStride2, const Ipp64f** ppVal, int valRoiShift, Ipp64f** ppDst, int dstRoiShift, int dstStride2, int len, int count);

Case 5: Vector array - vector operation

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

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

IppStatus ippmAdd_vv_32f_P(const Ipp32f** ppSrc1, int src1RoiShift, const Ipp32f** ppSrc2, int src2RoiShift, Ipp32f** ppDst, int dstRoiShift, int len);

IppStatus ippmAdd_vv_64f_P(const Ipp64f** ppSrc1, int src1RoiShift, const Ipp64f** ppSrc2, int src2RoiShift, Ipp64f** ppDst, int dstRoiShift, int len);

Case 6: Vector array - vector operation

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

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

IppStatus ippmAdd_vav_32f_P(const Ipp32f** ppSrc1, int src1RoiShift, int src1Stride0, const Ipp32f** ppSrc2, int src2RoiShift, Ipp32f** ppDst, int dstRoiShift, int dstStride0, int len, int count);

IppStatus ippmAdd_vav_64f_P(const Ipp64f** ppSrc1, int src1RoiShift, int src1Stride0, const Ipp64f** ppSrc2, int src2RoiShift, Ipp64f** ppDst, int dstRoiShift, int dstStride0, int len, int count);

IppStatus ippmAdd_vav_32f_L(const Ipp32f** ppSrc1, int src1RoiShift, int src1Stride2, const Ipp32f* pSrc2, int src2Stride2, Ipp32f** ppDst, int dstRoiShift, int dstStride2, int len, int count);

IppStatus ippmAdd_vav_64f_L(const Ipp64f** ppSrc1, int src1RoiShift, int src1Stride2, const Ipp64f* pSrc2, int src2Stride2, Ipp64f** ppDst, int dstRoiShift, int dstStride2, int len, int count);

Case 7: Vector array - vector array operation

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

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

IppStatus ippmAdd_vava_32f_P(const Ipp32f** ppSrc1, int src1RoiShift, int src1Stride0, const Ipp32f** ppSrc2, int src2RoiShift, int src2Stride0, Ipp32f** ppDst, int dstRoiShift, int dstStride0, int len, int count);

IppStatus ippmAdd_vava_64f_P(const Ipp64f** ppSrc1, int src1RoiShift, int src1Stride0, const Ipp64f** ppSrc2, int src2RoiShift, int src2Stride0, Ipp64f** ppDst, int dstRoiShift, int dstStride0, int len, int count);

IppStatus ippmAdd_vava_32f_L(const Ipp32f** ppSrc1, int src1RoiShift, int src1Stride2, const Ipp32f** ppSrc2, int src2RoiShift, int src2Stride2, Ipp32f** ppDst, int dstRoiShift, int dstStride2, int len, int count);

IppStatus ippmAdd_vava_64f_L(const Ipp64f** ppSrc1, int src1RoiShift, int src1Stride2, const Ipp64f** ppSrc2, int src2RoiShift, int src2Stride2, Ipp64f** ppDst, int dstRoiShift, int dstStride2, int len, int count);

Parameters

pSrc, ppSrc

Pointer to the source vector or vector array.

srcStride0

Stride between the vectors in the source array.

srcStride2

Stride between the elements in the source vector(s).

srcRoiShift

ROI shift in the first source vector.

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).

val

The constant.

pVal, ppVal

Pointer to the source array of constants.

valStride0

Stride between the constants in the source array of constants.

valRoiShift

ROI shift in the source array of constants.

pDst, ppDst

Pointer to the destination vector or vector array.

dstStride0

Stride between the vectors in the destination array.

dstStride2

Stride between the elements in the destination vector.

dstRoiShift

ROI shift in the destination vector.

len

Vector length.

count

The number of vectors (constants) in the array.

Description

The function ippmAdd is declared in the ippm.h header file. Like all other functions in Intel IPP for small matrices, this function is parameter sensitive. All input parameters that follow the function name immediately after the underscore determine the way in which the function performs and the arguments it takes, whether it is a constant or another vector. This implies that with every complete function name, only some of the listed arguments appear in the input list, while others are omitted.

When performed on a constant together with a vector, the function adds val to each element of the source vector and stores the result into destination vector:

To clarify how the function operates on arrays of vectors and constants, see Operations with arrays of objects.

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

ippmAdd_vc_32f_P

IppStatus add_vc_32f_P(void) {
    /* Source data:  */
    Ipp32f a[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; 
    Ipp32f val = 10.0;
    /* 
    // Pointer description for source data of interest a[0], a[6], a[7]:
    */
    Ipp32f* ppSrc[3] = { a, a+6, a+7 }; /* pointers array */
    int srcRoiShift = 0;
  

    /* 
    // Pointer description for destination data of interest a[0], a[6], a[7]:
    */
    Ipp32f* ppDst[3] = { a, a+6, a+7 }; /* pointers array */
    int dstRoiShift  = 0;   
 
    int length = 3;
 
    IppStatus status = ippmAdd_vc_32f_P((const Ipp32f**)ppSrc, 
        srcRoiShift, val, ppDst, dstRoiShift, length);
 
    /*
    // It is recommended to check return status 
    // to detect wrong input parameters, if any  
    */
    if (status == ippStsNoErr){
        printf_va_Ipp32f("Destination vector:", a, 10, 1, status);
    } else {
        printf("Function returns status: %s \n", ippGetStatusString(status));
    } 
    return status;
}
 

The program above produces the following output:

Destination vector:

10.000000  1.000000  2.000000  3.000000  4.000000  5.000000  16.000000  17.000000  8.000000  9.000000

Example “ippmAdd_vaca_32f”, Example “ippmAdd_vaca_32f_L”, and Example “ippmAdd_vca_32f_P” below illustrate the use of the ippmAdd function operating on arrays of constants.

The following example demonstrates how to use function ippmAdd_vaca_32f when all elements in the data vectors, all vectors and constants in the arrays are regularly spaced in memory.

For more information, see also examples in Getting Started.

ippmAdd_vaca_32f

IppStatus add_vaca_32f(void)  {
 
    /* Src data: 4 vectors on length=3, vector elements 
    are spaced with step */
    Ipp32f pSrc[4*6] = { 1, 0, 2, 0, 3, 0,
                         4, 0, 5, 0, 6, 0,
                         7, 0, 8, 0, 9, 0,
                        10, 0,11, 0,12, 0 };
    /* Standart description for Src vector array */
    int srcStride2 = 2*sizeof(Ipp32f);
    int srcStride0 = 3*2*sizeof(Ipp32f);
    /* Standart description for Val constant array */
    Ipp32f pVal[9] = { 10, 0, 0, 9, 0, 0, 8, 0, 0};
    int valStride0 = 3*sizeof(Ipp32f);

    /* Standard description for Dst vector array*/
    Ipp32f pDst[4*3]; 
    int dstStride2 = sizeof(Ipp32f);
    int dstStride0 = 3*sizeof(Ipp32f);   
  
    int length = 3; 
    int count  = 4; 

    IppStatus status = ippmAdd_vaca_32f ((const Ipp32f*)pSrc,
        srcStride0, srcStride2, (const Ipp32f*)pVal, valStride0, 
        pDst, dstStride0, dstStride2, length, count);
 
    /*
    // It is recommended to check return status
    // to detect wrong input parameters, if any
    */
    if(status == ippStsOk){
        printf_va_Ipp32f("4 destination vectors:", pDst, 3, 4, status);

    } else {
       printf("Function returns status: %s \n", ippGetStatusString(status));

    } 

    return status;
}
 

The program above produces the following output:

4 destination vectors:

11.000000  12.000000  13.000000

13.000000  14.000000  15.000000

15.000000  16.000000  17.000000

10.000000  11.000000  12.000000

The following example demonstrates how to use the function ippmAdd_vaca_32f_L when vector elements are regularly spaced but vectors and constants in the arrays are irregularly spaced in memory.

For more information, see also examples in Getting Started.

ippmAdd_vaca_32f_L

IppStatus add_vaca_32f_L (void) {
    /* Src data: 4 vectors with length=3, Stride2=2*sizeof(Ipp32f) */
    Ipp32f src_a[2*3] = { 1, 0, 2, 0, 3, 0 };
    Ipp32f src_b[2*3] = { 4, 0, 5, 0, 6, 0 };
    Ipp32f src_c[2*3] = { 7, 0, 8, 0, 9, 0 };
    Ipp32f src_d[2*3] = {10, 0,11, 0,12, 0 };
 

    /* Layout description for Src */
    Ipp32f* ppSrc[4] = { src_a, src_b, src_c, src_d };
    int srcRoiShift = 0;
    int srcStride2 = 2*sizeof(Ipp32f);
 
    /* Val data array */
    Ipp32f pVal[10] = { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 };
 
    /*
    // Layout description for Val 
    // 4 constants with irregular layout
    */
    Ipp32f* ppVal[4] = { pVal, pVal+1, pVal+3, pVal+9 };
    int valRoiShift = 0;
 
    /* Destination memory location */
    Ipp32f dst[4*3];
 
    /* Layout description for Dst */
    Ipp32f* ppDst[4] = { dst, dst+3, dst+6, dst+9 };
    int dstRoiShift = 0;
    int dstStride2 = sizeof(Ipp32f);
 
    int length = 3;
    int count  = 4;
 
 
    IppStatus status = ippmAdd_vaca_32f_L ((const Ipp32f**)ppSrc,
        srcRoiShift, srcStride2, (const Ipp32f**)ppVal, valRoiShift,
        ppDst, dstRoiShift, dstStride2, length, count);
 
    /*
    // It is recommended to check return status 
    // to detect wrong input parameters, if any
    */
    if(status == ippStsOk){
        printf_va_Ipp32f("4 destination vectors:", dst, 3, 4, status);
    } else {
        printf("Function returns status: %s \n", ippGetStatusString(status));
    } 
    return status;
}
 

The program above produces the following output:

4 destination vectors:

11.000000  12.000000  13.000000

13.000000  14.000000  15.000000

14.000000  15.000000  16.000000

11.000000  12.000000  13.000000

The following example demonstrates how to use the function ippmAdd_vca_32f_P when vector elements are irregularly spaced but constants in the arrays are regularly spaced in memory.

For more information, see also examples in Getting Started.

ippmAdd_vca_32f_P

IppStatus add_vca_32f_P (void) {

    /* Source data location */
    Ipp32f src[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
    Ipp32f pVal[4] = {2.0, 5.0, 8.0, 10.0};

    /*
    // Pointer description for source data of interest a[0], a[6], a[7]:
    // Src is a vector with irregular layout, length=3
    */
    Ipp32f* ppSrc[3] = { src, src+6, src+7 };
    int srcRoiShift = 0;
 
    /* 
    // Standard description for array of constants
    */
    int valStride0 = sizeof(Ipp32f);
 
    /* Destination memory location */
    Ipp32f dst[3*4];
 

    /* Pointer description for the destination vector */
    Ipp32f* ppDst[3] = { dst, dst+4, dst+8 };
    int dstRoiShift  = 0;
    int dstStride0   = sizeof(Ipp32f);
 
    int length = 3;
    int count = 4;
 
    IppStatus status = ippmAdd_vca_32f_P ((const Ipp32f**)ppSrc,
        srcRoiShift, (const Ipp32f*)pVal, valStride0, ppDst,
        dstRoiShift, dstStride0, length, count);
 
    /*
    // It is recommended to check return status
    // to detect wrong input parameters, if any
    */
    if(status == ippStsNoErr){
       printf_va_Ipp32f("4 destination vectors:", dst, 3, 4, status);
    } else {
        printf("Function returns status: %s \n", ippGetStatusString(status));
    }
    return status;
}
 

The program above produces the following output:

4 destination vectors:

 2.000000  5.000000  8.000000

10.000000  8.000000 11.000000

14.000000 16.000000  9.000000

12.000000 15.000000 17.000000

When performed on two vectors, the function adds together the respective elements of the first and the second source vectors and stores the result in the destination vector:

To clarify how the function operates on two arrays of vectors, see Operations with arrays of objects.

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

ippmAdd_vava_32f_L  

IppStatus add_vava_32f_L(void) {
    /* Src1 data: 4 vectors with length=3, Stride2=2*sizeof(Ipp32f) */
    Ipp32f src1_a[2*3] = { 1, 0, 2, 0, 3, 0 };
    Ipp32f src1_b[2*3] = { 4, 0, 5, 0, 6, 0 };
    Ipp32f src1_c[2*3] = { 7, 0, 8, 0, 9, 0 };
    Ipp32f src1_d[2*3] = { 10, 0, 11, 0, 12, 0 };
 
 
    /* Src2 data: 4 vectors with length=3, Stride2=sizeof(Ipp32f) */
    Ipp32f src2_a[3] = { 10, 11, 12 };
    Ipp32f src2_b[3] = { 7, 8, 9 };
    Ipp32f src2_c[3] = { 4, 5, 6 };
    Ipp32f src2_d[3] = { 1, 2, 3 };
 
    /* Layout description for Src1, Src2 and Dst */
    Ipp32f* ppSrc1[4] = { src1_a, src1_b, src1_c, src1_d };
    Ipp32f* ppSrc2[4] = { src2_d, src2_c, src2_b, src2_a };
    int src1RoiShift = 0;
    int src2RoiShift = 0;
 
    Ipp32f dst[4*3]; /* destination memory location */
    Ipp32f* ppDst[4] = { dst, dst+3, dst+6, dst+9 };
    int dstRoiShift  = 0;
 
    int src1Stride2 = 2*sizeof(Ipp32f);
    int src2Stride2 = sizeof(Ipp32f);
    int dstStride2  = sizeof(Ipp32f);
 
    int length = 3;
    int count  = 4;
 
    IppStatus status = ippmAdd_vava_32f_L((const Ipp32f**)ppSrc1,
        src1RoiShift, src1Stride2, (const Ipp32f**)ppSrc2, src2RoiShift,
        src2Stride2, ppDst, dstRoiShift, dstStride2, length, count);
 
    /*
    // It is recommended to check return status 
    // to detect wrong input parameters, if any  
    */
    if (status == ippStsNoErr){
        printf_va_Ipp32f("4 destination vectors:", dst, 3, 4, status);
    } else {
        printf("Function returns status: %s \n", ippGetStatusString(status));
    }
    return status;
}
 

The program above produces the following output:

4 destination vectors:

 2.000000  4.000000  6.000000

 8.000000 10.000000 12.000000

14.000000 16.000000 18.000000

20.000000 22.000000 24.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.