Add

Adds matrix to another matrix.

Syntax

Case 1: Matrix - matrix operation

IppStatus ippmAdd_mm_32f(const Ipp32f* pSrc1, int src1Stride1, int src1Stride2, const Ipp32f* pSrc2, int src2Stride1, int src2Stride2, Ipp32f* pDst, int dstStride1, int dstStride2, int width, int height);

IppStatus ippmAdd_mm_64f(const Ipp64f* pSrc1, int src1Stride1, int src1Stride2, const Ipp64f* pSrc2, int src2Stride1, int src2Stride2, Ipp64f* pDst, int dstStride1, int dstStride2, int width, int height);

IppStatus ippmAdd_mm_32f_P(const Ipp32f** ppSrc1, int src1RoiShift, const Ipp32f** ppSrc2, int src2RoiShift, Ipp32f** ppDst, int dstRoiShift, int width, int height);

IppStatus ippmAdd_mm_64f_P(const Ipp64f** ppSrc1, int src1RoiShift, const Ipp64f** ppSrc2, int src2RoiShift, Ipp64f** pDst, int dstRoiShift, int width, int height);

Case 2: Transposed matrix - matrix operation

IppStatus ippmAdd_tm_32f(const Ipp32f* pSrc1, int src1Stride1, int src1Stride2, const Ipp32f* pSrc2, int src2Stride1, int src2Stride2, Ipp32f* pDst, int dstStride1, int dstStride2, int width, int height);

IppStatus ippmAdd_tm_64f(const Ipp64f* pSrc1, int src1Stride1, int src1Stride2, const Ipp64f* pSrc2, int src2Stride1, int src2Stride2, Ipp64f* pDst, int dstStride1, int dstStride2, int width, int height);

IppStatus ippmAdd_tm_32f_P(const Ipp32f** ppSrc1, int src1RoiShift, const Ipp32f** ppSrc2, int src2RoiShift, Ipp32f** ppDst, int dstRoiShift, int width, int height);

IppStatus ippmAdd_tm_64f_P(const Ipp64f** ppSrc1, int src1RoiShift, const Ipp64f** ppSrc2, int src2RoiShift, Ipp64f** ppDst, int dstRoiShift, int width, int height);

Case 3: Transposed matrix - transposed matrix operation

IppStatus ippmAdd_tt_32f(const Ipp32f* pSrc1, int src1Stride1, int src1Stride2, const Ipp32f* pSrc2, int src2Stride1, int src2Stride2, Ipp32f* pDst, int dstStride1, int dstStride2, int width, int height);

IppStatus ippmAdd_tt_64f(const Ipp64f* pSrc1, int src1Stride1, int src1Stride2, const Ipp64f* pSrc2, int src2Stride1, int src2Stride2, Ipp64f* pDst, int dstStride1, int dstStride2, int width, int height);

IppStatus ippmAdd_tt_32f_P(const Ipp32f** ppSrc1, int src1RoiShift, const Ipp32f** ppSrc2, int src2RoiShift, Ipp32f** ppDst, int dstRoiShift, int width, int height);

IppStatus ippmAdd_tt_64f_P(const Ipp64f** ppSrc1, int src1RoiShift, const Ipp64f** ppSrc2, int src2RoiShift, Ipp64f** ppDst, int dstRoiShift, int width, int height);

Case 4: Matrix array - matrix operation

IppStatus ippmAdd_mam_32f(const Ipp32f* pSrc1, int src1Stride0, int src1Stride1, int src1Stride2, const Ipp32f* pSrc2, int src2Stride1, int src2Stride2, Ipp32f* pDst, int dstStride0, int dstStride1, int dstStride2, int width, int height, int count);

IppStatus ippmAdd_mam_64f(const Ipp64f* pSrc1, int src1Stride0, int src1Stride1, int src1Stride2, const Ipp64f* pSrc2, int src2Stride1, int src2Stride2, Ipp64f* pDst, int dstStride0, int dstStride1, int dstStride2, int width, int height, int count);

IppStatus ippmAdd_mam_32f_P(const Ipp32f** ppSrc1, int src1RoiShift, int src1Stride0, const Ipp32f** ppSrc2, int src2RoiShift, Ipp32f** ppDst, int dstRoiShift, int dstStride0, int width, int height, int count);

IppStatus ippmAdd_mam_64f_P(const Ipp64f** ppSrc1, int src1RoiShift, int src1Stride0, const Ipp64f** ppSrc2, int src2RoiShift, Ipp64f** ppDst, int dstRoiShift, int dstStride0, int width, int height, int count);

IppStatus ippmAdd_mam_32f_L(const Ipp32f** ppSrc1, int src1RoiShift, int src1Stride1, int src1Stride2, const Ipp32f* pSrc2, int src2Stride1, int src2Stride2, Ipp32f** ppDst, int dstRoiShift, int dstStride1, int dstStride2, int width, int height, int count);

IppStatus ippmAdd_mam_64f_L(const Ipp64f** ppSrc1, int src1RoiShift, int src1Stride1, int src1Stride2, const Ipp64f* pSrc2, int src2Stride1, int src2Stride2, Ipp64f** ppDst, int dstRoiShift, int dstStride1, int dstStride2, int width, int height, int count);

Case 5: Transposed matrix array - matrix operation

IppStatus ippmAdd_tam_32f(const Ipp32f* pSrc1, int src1Stride0, int src1Stride1, int src1Stride2, const Ipp32f* pSrc2, int src2Stride1, int src2Stride2, Ipp32f* pDst, int dstStride0, int dstStride1, int dstStride2, int width, int height, int count);

IppStatus ippmAdd_tam_64f(const Ipp64f* pSrc1, int src1Stride0, int src1Stride1, int src1Stride2, const Ipp64f* pSrc2, int src2Stride1, int src2Stride2, Ipp64f* pDst, int dstStride0, int dstStride1, int dstStride2, int width, int height, int count);

IppStatus ippmAdd_tam_32f_P(const Ipp32f** ppSrc1, int src1RoiShift, int src1Stride0, const Ipp32f** ppSrc2, int src2RoiShift, Ipp32f** ppDst, int dstRoiShift, int dstStride0, int width, int height, int count);

IppStatus ippmAdd_tam_64f_P(const Ipp64f** ppSrc1, int src1RoiShift, int src1Stride0, const Ipp64f** ppSrc2, int src2RoiShift, Ipp64f** ppDst, int dstRoiShift, int dstStride0, int width, int height, int count);

IppStatus ippmAdd_tam_32f_L(const Ipp32f** ppSrc1, int src1RoiShift, int src1Stride1, int src1Stride2, const Ipp32f* pSrc2, int src2Stride1, int src2Stride2, Ipp32f** ppDst, int dstRoiShift, int dstStride1, int dstStride2, int width, int height, int count);

IppStatus ippmAdd_tam_64f_L(const Ipp64f** ppSrc1, int src1RoiShift, int src1Stride1, int src1Stride2, const Ipp64f* pSrc2, int src2Stride1, int src2Stride2, Ipp64f** ppDst, int dstRoiShift, int dstStride1, int dstStride2, int width, int height, int count);

Case 6: Matrix array - transposed matrix operation

IppStatus ippmAdd_mat_32f(const Ipp32f* pSrc1, int src1Stride0, int src1Stride1, int src1Stride2, const Ipp32f* pSrc2, int src2Stride1, int src2Stride2, Ipp32f* pDst, int dstStride0, int dstStride1, int dstStride2, int width, int height, int count);

IppStatus ippmAdd_mat_64f(const Ipp64f* pSrc1, int src1Stride0, int src1Stride1, int src1Stride2, const Ipp64f* pSrc2, int src2Stride1, int src2Stride2, Ipp64f* pDst, int dstStride0, int dstStride1, int dstStride2, int width, int height, int count);

IppStatus ippmAdd_mat_32f_P(const Ipp32f** ppSrc1, int src1RoiShift, int src1Stride0, const Ipp32f** ppSrc2, int src2RoiShift, Ipp32f** ppDst, int dstRoiShift, int dstStride0, int width, int height, int count);

IppStatus ippmAdd_mat_64f_P(const Ipp64f** ppSrc1, int src1RoiShift, int src1Stride0, const Ipp64f** ppSrc2, int src2RoiShift, Ipp64f** ppDst, int dstRoiShift, int dstStride0, int width, int height, int count);

IppStatus ippmAdd_mat_32f_L(const Ipp32f** ppSrc1, int src1RoiShift, int src1Stride1, int src1Stride2, const Ipp32f* pSrc2, int src2Stride1, int src2Stride2, Ipp32f** ppDst, int dstRoiShift, int dstStride1, int dstStride2, int width, int height, int count);

IppStatus ippmAdd_mat_64f_L(const Ipp64f** ppSrc1, int src1RoiShift, int src1Stride1, int src1Stride2, const Ipp64f* pSrc2, int src2Stride1, int src2Stride2, Ipp64f** ppDst, int dstRoiShift, int dstStride1, int dstStride2, int width, int height, int count);

Case 7: Transposed matrix array - transposed matrix operation

IppStatus ippmAdd_tat_32f(const Ipp32f* pSrc1, int src1Stride0, int src1Stride1, int src1Stride2, const Ipp32f* pSrc2, int src2Stride1, int src2Stride2, Ipp32f* pDst, int dstStride0, int dstStride1, int dstStride2, int width, int height, int count);

IppStatus ippmAdd_tat_64f(const Ipp64f* pSrc1, int src1Stride0, int src1Stride1, int src1Stride2, const Ipp64f* pSrc2, int src2Stride1, int src2Stride2, Ipp64f* pDst, int dstStride0, int dstStride1, int dstStride2, int width, int height, int count);

IppStatus ippmAdd_tat_32f_P(const Ipp32f** ppSrc1, int src1RoiShift, int src1Stride0, const Ipp32f** ppSrc2, int src2RoiShift, Ipp32f** ppDst, int dstRoiShift, int dstStride0, int width, int height, int count);

IppStatus ippmAdd_tat_64f_P(const Ipp64f** ppSrc1, int src1RoiShift, int src1Stride0, const Ipp64f** ppSrc2, int src2RoiShift, Ipp64f** ppDst, int dstRoiShift, int dstStride0, int width, int height, int count);

IppStatus ippmAdd_tat_32f_L(const Ipp32f** ppSrc1, int src1RoiShift, int src1Stride1, int src1Stride2, const Ipp32f* pSrc2, int src2Stride1, int src2Stride2, Ipp32f** ppDst, int dstRoiShift, int dstStride1, int dstStride2, int width, int height, int count);

IppStatus ippmAdd_tat_64f_L(const Ipp64f** ppSrc1, int src1RoiShift, int src1Stride1, int src1Stride2, const Ipp64f* pSrc2, int src2Stride1, int src2Stride2, Ipp64f** ppDst, int dstRoiShift, int dstStride1, int dstStride2, int width, int height, int count);

Case 8: Matrix array - matrix array operation

IppStatus ippmAdd_mama_32f(const Ipp32f* pSrc1, int src1Stride0, int src1Stride1, int src1Stride2, const Ipp32f* pSrc2, int src2Stride0, int src2Stride1, int src2Stride2, Ipp32f* pDst, int dstStride0, int dstStride1, int dstStride2, int width, int height, int count);

IppStatus ippmAdd_mama_64f(const Ipp64f* pSrc1, int src1Stride0, int src1Stride1, int src1Stride2, const Ipp64f* pSrc2, int src2Stride0, int src2Stride1, int src2Stride2, Ipp64f* pDst, int dstStride0, int dstStride1, int dstStride2, int width, int height, int count);

IppStatus ippmAdd_mama_32f_P(const Ipp32f** ppSrc1, int src1RoiShift, int src1Stride0, const Ipp32f** ppSrc2, int src2RoiShift, int src2Stride0, Ipp32f** ppDst, int dstRoiShift, int dstStride0, int width, int height, int count);

IppStatus ippmAdd_mama_64f_P(const Ipp64f** ppSrc1, int src1RoiShift, int src1Stride0, const Ipp64f** ppSrc2, int src2RoiShift, int src2Stride0, Ipp64f** ppDst, int dstRoiShift, int dstStride0, int width, int height, int count);

IppStatus ippmAdd_mama_32f_L(const Ipp32f** ppSrc1, int src1RoiShift, int src1Stride1, int src1Stride2, const Ipp32f** ppSrc2, int src2RoiShift, int src2Stride1, int src2Stride2, Ipp32f** ppDst, int dstRoiShift, int dstStride1, int dstStride2, int width, int height, int count);

IppStatus ippmAdd_mama_64f_L(const Ipp64f** ppSrc1, int src1RoiShift, int src1Stride1, int src1Stride2, const Ipp64f** ppSrc2, int src2RoiShift, int src2Stride1, int src2Stride2, Ipp64f** ppDst, int dstRoiShift, int dstStride1, int dstStride2, int width, int height, int count);

Case 9: Transposed matrix array - matrix array operation

IppStatus ippmAdd_tama_32f(const Ipp32f* pSrc1, int src1Stride0, int src1Stride1, int src1Stride2, const Ipp32f* pSrc2, int src2Stride0, int src2Stride1, int src2Stride2, Ipp32f* pDst, int dstStride0, int dstStride1, int dstStride2, int width, int height, int count);

IppStatus ippmAdd_tama_64f(const Ipp64f* pSrc1, int src1Stride0, int src1Stride1, int src1Stride2, const Ipp64f* pSrc2, int src2Stride0, int src2Stride1, int src2Stride2, Ipp64f* pDst, int dstStride0, int dstStride1, int dstStride2, int width, int height, int count);

IppStatus ippmAdd_tama_32f_P(const Ipp32f** ppSrc1, int src1RoiShift, int src1Stride0, const Ipp32f** ppSrc2, int src2RoiShift, int src2Stride0, Ipp32f** ppDst, int dstRoiShift, int dstStride0, int width, int height, int count);

IppStatus ippmAdd_tama_64f_P(const Ipp64f** ppSrc1, int src1RoiShift, int src1Stride0, const Ipp64f** ppSrc2, int src2RoiShift, int src2Stride0, Ipp64f** ppDst, int dstRoiShift, int dstStride0, int width, int height, int count);

IppStatus ippmAdd_tama_32f_L(const Ipp32f** ppSrc1, int src1RoiShift, int src1Stride1, int src1Stride2, const Ipp32f** ppSrc2, int src2RoiShift, int src2Stride1, int src2Stride2, Ipp32f** ppDst, int dstRoiShift, int dstStride1, int dstStride2, int width, int height, int count);

IppStatus ippmAdd_tama_64f_L(const Ipp64f** ppSrc1, int src1RoiShift, int src1Stride1, int src1Stride2, const Ipp64f** ppSrc2, int src2RoiShift, int src2Stride1, int src2Stride2, Ipp64f** ppDst, int dstRoiShift, int dstStride1, int dstStride2, int width, int height, int count);

Case 10: Transposed matrix array - transposed matrix array operation

IppStatus ippmAdd_tata_32f(const Ipp32f* pSrc1, int src1Stride0, int src1Stride1, int src1Stride2, const Ipp32f* pSrc2, int src2Stride0, int src2Stride1, int src2Stride2, Ipp32f* pDst, int dstStride0, int dstStride1, int dstStride2, int width, int height, int count);

IppStatus ippmAdd_tata_64f(const Ipp64f* pSrc1, int src1Stride0, int src1Stride1, int src1Stride2, const Ipp64f* pSrc2, int src2Stride0, int src2Stride1, int src2Stride2, Ipp64f* pDst, int dstStride0, int dstStride1, int dstStride2, int width, int height, int count);

IppStatus ippmAdd_tata_32f_P(const Ipp32f** ppSrc1, int src1RoiShift, int src1Stride0, const Ipp32f** ppSrc2, int src2RoiShift, int src2Stride0, Ipp32f** ppDst, int dstRoiShift, int dstStride0, int width, int height, int count);

IppStatus ippmAdd_tata_64f_P(const Ipp64f** ppSrc1, int src1RoiShift, int src1Stride0, const Ipp64f** ppSrc2, int src2RoiShift, int src2Stride0, Ipp64f** ppDst, int dstRoiShift, int dstStride0, int width, int height, int count);

IppStatus ippmAdd_tata_32f_L(const Ipp32f** ppSrc1, int src1RoiShift, int src1Stride1, int src1Stride2, const Ipp32f** ppSrc2, int src2RoiShift, int src2Stride1, int src2Stride2, Ipp32f** ppDst, int dstRoiShift, int dstStride1, int dstStride2, int width, int height, int count);

IppStatus ippmAdd_tata_64f_L(const Ipp64f** ppSrc1, int src1RoiShift, int src1Stride1, int src1Stride2, const Ipp64f** ppSrc2, int src2RoiShift, int src2Stride1, int src2Stride2, Ipp64f** ppDst, int dstRoiShift, int dstStride1, int dstStride2, int width, int height, int count);

Parameters

pSrc1, ppSrc1

Pointer to the first source matrix or array of matrices.

src1Stride0

Stride between the matrices in the first source array.

src1Stride1

Stride between the rows in the first source matrix(ces).

src1Stride2

Stride between the elements in the first source matrix(ces).

src1RoiShift

ROI shift in the first source matrix(ces).

pSrc2, ppSrc2

Pointer to the second source matrix or array of matrices.

src2Stride0

Stride between the matrices in the second source array.

src2Stride1

Stride between the rows in the second source matrix(ces).

src2Stride2

Stride between the elements in the second source matrix(ces).

src2RoiShift

ROI shift in the second source matrix(ces).

pDst, ppDst

Pointer to the destination matrix or array of matrices.

dstStride0

Stride between the matrices in the destination array.

dstStride1

Stride between the rows in the destination matrix.

dstStride2

Stride between the elements in the destination matrix.

dstRoiShift

ROI shift in the destination matrix.

width

Matrix width.

height

Matrix height.

count

Number of matrices in the array.

Description

The function ippmAdd is declared in the ippm.h header file.

When performed on two matrices (cases 1, 4, 8), the function adds together the respective elements of the first and the second source matrices and stores the result in pDst:

dst[i][j] = src1[i][j] + src2[i][j],

0 i < height, 0 j < width.

When performed on a transposed matrix and a matrix (cases 2, 5, 9), the function adds together the respective elements of the transposed matrix and the second source matrix and stores the result in pDst:

dst[i][j] = src1[j][i] + src2[i][j],

0 i < height, 0 j < width.

Note that the first source matrix must have the number of rows equal to width and the number of columns equal to height.

The following example demonstrates how to use the function ippmAdd_tm_32f. To clarify pointer descriptor for transposed matrices, see examples for ippmSub. For more information, see also examples in Getting Started.

ippmAdd_tm_32f  

IppStatus add_tm_32f(void) {
    /* Src1 matrix with width=4 and height=3 */
    Ipp32f pSrc1[3*4] = { 1, 2, 3, 4,
                          5, 6, 7, 8,
                          4, 3, 2, 1 };
    int src1Stride2 = sizeof(Ipp32f);
    int src1Stride1 = 4*sizeof(Ipp32f);

    /* Src2 and Dst matrices have width=3 and height=4 */
    Ipp32f pSrc2[4*3] = { 1, 5, 4,
                          2, 6, 3,
                          3, 7, 2,
                          4, 8, 1 };
    int src2Stride2 = sizeof(Ipp32f);
    int src2Stride1 = 3*sizeof(Ipp32f);
    Ipp32f pDst[4*3]; /* Destination location */
    int dstStride2 = sizeof(Ipp32f);
    int dstStride1 = 3*sizeof(Ipp32f);
    int width  = 3;
    int height = 4;

    IppStatus status = ippmAdd_tm_32f((const Ipp32f*)pSrc1, src1Stride1,
         src1Stride2, (const Ipp32f*)pSrc2, src2Stride1, src2Stride2,
         pDst, dstStride1, dstStride2, width, height);

    /*
    // It is recommended to check return status
    // to detect wrong input parameters, if any
    */
    if (status == ippStsNoErr) {
        printf_m_Ipp32f("Destination matrix:", pDst, 3, 4, status);
    } else {
        printf("Function returns status: %s \n", ippGetStatusString(status));
    }
    return status;
}
 

The program above produces the following output:

Destination matrix:

2.000000  10.000000  8.000000

4.000000  12.000000  6.000000

6.000000  14.000000  4.000000

8.000000  16.000000  2.000000

When performed on a matrix array and a transposed matrix (case 6), the function adds together the respective elements of the first matrix in the array and the transposed matrix and stores the result in pDst:

dst[i][j] = src1[i][j] + src2[j][i],

0 i < height, 0 j < width.

Note that the second source matrix must have the number of rows equal to width and the number of columns equal to height.

When performed on two transposed matrices (cases 3, 7, 10), the function adds together the respective elements of the first and the second transposed matrices and stores the result in pDst:

dst[i][j] = src1[j][i] + src2[j][i],

0 i < height, 0 j < width.

Note that both source matrices must have the number of rows equal to width and the number of columns equal to height.

The following example demonstrates how to use the function ippmAdd_tt_32f. To clarify pointer descriptor for transposed matrices, see examples for ippmSub. For more information, see also examples in Getting Started.

ippmAdd_tt_32f  

IppStatus add_tt_32f(void) {
    /* Src1 and Src2 matrices have width=4 and height=3 */
    Ipp32f pSrc1[3*4] = { 1, 2, 3, 1,
                          4, 5, 6, 1,
                          7, 8, 9, 1 };
    int src1Stride2 = sizeof(Ipp32f);
    int src1Stride1 = 4*sizeof(Ipp32f);

    Ipp32f pSrc2[3*4] = { 9, 8, 7, -1,
                          6, 5, 4, -1,
                          3, 2, 1, -1 };
    int src2Stride2 = sizeof(Ipp32f);
    int src2Stride1 = 4*sizeof(Ipp32f);

    /* Dst matrices have width=3 and height=4 */
    Ipp32f pDst[4*3];
    int dstStride2 = sizeof(Ipp32f);
    int dstStride1 = 3*sizeof(Ipp32f);
    int width  = 3;
    int height = 4;
    IppStatus status = ippmAdd_tt_32f((const Ipp32f*)pSrc1, src1Stride1,
         src1Stride2, (const Ipp32f*)pSrc2, src2Stride1, src2Stride2,
         pDst, dstStride1, dstStride2, width, height);

    /*
    // It is recommended to check return status
    // to detect wrong input parameters, if any
    */
    if(status == ippStsNoErr){
        printf_m_Ipp32f("Destination matrix:", pDst, 3, 4, status);
    } else {
        printf("Function returns status: %s \n", ippGetStatusString(status));
    }
    return status;
}
 

The program above produces the following output:

Destination matrix:

10.000000  10.000000  10.000000

10.000000  10.000000  10.000000

10.000000  10.000000  10.000000

0.000000   0.000000   0.000000

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 the size of the data type.

ippStsRoiShiftMatrixErr

Returns an error when the roiShift value is negative or not divisible by the size of the 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.