Transpose

Performs matrix transposition.

Syntax

Case 1: Matrix operation

IppStatus ippmTranspose_m_32f(const Ipp32f* pSrc, int srcStride1, int srcStride2, int width, int height, Ipp32f* pDst, int dstStride1, int dstStride2);

IppStatus ippmTranspose_m_64f(const Ipp64f* pSrc, int srcStride1, int srcStride2, int width, int height, Ipp64f* pDst, int dstStride1, int dstStride2);

IppStatus ippmTranspose_m_32f_P(const Ipp32f** ppSrc, int srcRoiShift, int width, int height, Ipp32f** ppDst, int dstRoiShift);

IppStatus ippmTranspose_m_64f_P(const Ipp64f** ppSrc, int srcRoiShift, int width, int height, Ipp64f** ppDst, int dstRoiShift);

Case 2: Matrix array operation

IppStatus ippmTranspose_ma_32f(const Ipp32f* pSrc, int srcStride0, int srcStride1, int srcStride2, int width, int height, Ipp32f* pDst, int dstStride0, int dstStride1, int dstStride2, int count);

IppStatus ippmTranspose_ma_64f(const Ipp64f* pSrc, int srcStride0, int srcStride1, int srcStride2, int width, int height, Ipp64f* pDst, int dstStride0, int dstStride1, int dstStride2, int count);

IppStatus ippmTranspose_ma_32f_P(const Ipp32f** ppSrc, int srcRoiShift, int srcStride0, int width, int height, Ipp32f** ppDst, int dstRoiShift, int dstStride0, int count);

IppStatus ippmTranspose_ma_64f_P(const Ipp64f** ppSrc, int srcRoiShift, int srcStride0, int width, int height, Ipp64f** ppDst, int dstRoiShift, int dstStride0, int count);

IppStatus ippmTranspose_ma_32f_L(const Ipp32f** ppSrc, int srcRoiShift, int srcStride1, int srcStride2, int width, int height, Ipp32f** ppDst, int dstRoiShift, int dstStride1, int dstStride2, int count);

IppStatus ippmTranspose_ma_64f_L(const Ipp64f** ppSrc, int srcRoiShift, int srcStride1, int srcStride2, int width, int height, Ipp64f** ppDst, int dstRoiShift, int dstStride1, int dstStride2, int count);

Parameters

pSrc, ppSrc

Pointer to the source matrix or array of matrices.

srcStride0

Stride between the matrices in the source array.

srcStride1

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

srcStride2

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

srcRoiShift

ROI shift in the source matrix(ces).

width

Source matrix width.

height

Source matrix height.

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.

count

Number of matrices in the array.

Description

The function ippmTranspose is declared in the ippm.h header file. The function transposes the source matrix and stores the result in pDst or ppDst. The destination is obtained from the source matrix by transforming the columns of the source to the rows in the destination for each matrix element:

dst[j][i] = src[i][j],

0 i < height, 0 j < width.

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

The following examples demonstrate how to use the functions ippmTranspose_m_32f, ippmTranspose_m_32f_P, and ippmTranspose_ma_32f_L. For more information, see also examples in Getting Started.

ippmTranspose_m_32f  

IppStatus transpose_m_32f(void) {
    /* Source matrix with width=4 and height=3 */
    Ipp32f pSrc[3*4] = { 1,  2, 3, 4,
                         5,  6, 7, 8,
                         9,  0, 1, 2 };

    /* Destination matrix with width=3 and height=4 */
    Ipp32f pDst[4*3];
    /* Standard description for source and destination matrices */
    int srcStride2 = sizeof(Ipp32f);
    int srcStride1 = 4*sizeof(Ipp32f);
    int dstStride2 = sizeof(Ipp32f);
    int dstStride1 = 3*sizeof(Ipp32f);

    IppStatus status = ippmTranspose_m_32f((const Ipp32f*)pSrc,
        srcStride1, srcStride2, 4, 3, pDst, dstStride1, dstStride2);

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

The program above produces the following output:

Transposed matrix:

1.000000  5.000000  9.000000

2.000000  6.000000  0.000000

3.000000  7.000000  1.000000

4.000000  8.000000  2.000000

ippmTranspose_m_32f_P

IppStatus transpose_m_32f_P(void) {
    /* Source data */
    Ipp32f src[2*6] = { 1, 0, 0, 2, 0, 3,
                        0, 4, 5, 0, 0, 6 };
    /*
    // Nonzero elements of interest are referred by mask using 
    // Poiner descriptor:
    // Src width=3, height=2 
    */ int srcRoiShift = 0;
    Ipp32f* ppSrc[2*3] = { src,   src+3, src+5,
                           src+7, src+8, src+11 };

    /* 
    // Pointer description for destination matrix:
    // Dst width=2, height=3 
    */

    Ipp32f  dst[3*2];
    int dstRoiShift = 0;
    Ipp32f* ppDst[3*2] = { dst,   dst+1,
                           dst+2, dst+3,
                           dst+4, dst+5 };

    IppStatus status = ippmTranspose_m_32f_P((const Ipp32f**)ppSrc,
        srcRoiShift, 3, 2, ppDst, dstRoiShift);

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

The program above produces the following output:

Transposed matrix:

1.000000 4.000000

2.000000 5.000000

3.000000 6.000000

ippmTranspose_ma_32f_L  

IppStatus transpose_ma_32f_L(void) {
    /* Source data:
    // 3 matrices with width=4 and height=2 
    */
    Ipp32f src_a[2*4] = { 10, 11, 12, 13, 24, 25, 26, 27 };
    Ipp32f src_b[2*4] = { 30, 31, 32, 33, 44, 45, 46, 47 };
    Ipp32f src_c[2*4] = { 50, 51, 52, 53, 64, 65, 66, 67 };
    /*
    // Layout description for 3 source matrices 
    */
    int srcRoiShift = 0;
    int srcStride2  = sizeof(Ipp32f);
    int srcStride1  = 4*sizeof(Ipp32f);

    Ipp32f* ppSrc[3] = { src_a, src_b, src_c };
    /*
    // Layout description for destination matrices:
    // width=2, height=4, count=3 
    */
    Ipp32f dst_a[4*2];
    Ipp32f dst_b[4*2];
    Ipp32f dst_c[4*2];

    Ipp32f* ppDst[3] = { dst_a, dst_b, dst_c };

 
    int dstRoiShift = 0;
    int dstStride2  = sizeof(Ipp32f);
    int dstStride1  = 2*sizeof(Ipp32f);
 
    IppStatus status = ippmTranspose_ma_32f_L((const Ipp32f**)ppSrc,
        srcRoiShift, srcStride1, srcStride2, 4, 2,
        ppDst, dstRoiShift, dstStride1, dstStride2, 3);

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

The program above produces the following output:

3 transposed matrices:

10.000000 24.000000     30.000000 44.000000     50.000000 64.000000

11.000000 25.000000     31.000000 45.000000     51.000000 65.000000

12.000000 26.000000     32.000000 46.000000     52.000000 66.000000

13.000000 27.000000     33.000000 47.000000     53.000000 67.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 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 - 2010, Intel Corporation. All rights reserved.