Computes matrix trace.
Case 1: Matrix operation
IppStatus ippmTrace_m_32f(const Ipp32f* pSrc, int srcStride1, int srcStride2, int widthHeight, Ipp32f* pDst);
IppStatus ippmTrace_m_64f(const Ipp64f* pSrc, int srcStride1, int srcStride2, int widthHeight, Ipp64f* pDst);
IppStatus ippmTrace_m_32f_P(const Ipp32f** ppSrc, int srcRoiShift, int widthHeight, Ipp32f* pDst);
IppStatus ippmTrace_m_64f_P(const Ipp64f** ppSrc, int srcRoiShift, int widthHeight, Ipp64f* pDst);
Case 2: Matrix array operation
IppStatus ippmTrace_ma_32f(const Ipp32f* pSrc, int srcStride0, int srcStride1, int srcStride2, int widthHeight, Ipp32f* pDst, int count);
IppStatus ippmTrace_ma_64f(const Ipp64f* pSrc, int srcStride0, int srcStride1, int srcStride2, int widthHeight, Ipp64f* pDst, int count);
IppStatus ippmTrace_ma_32f_P(const Ipp32f** ppSrc, int srcRoiShift, int srcStride0, int widthHeight, Ipp32f* pDst, int count);
IppStatus ippmTrace_ma_64f_P(const Ipp64f** ppSrc, int srcRoiShift, int srcStride0, int widthHeight, Ipp64f* pDst, int count);
IppStatus ippmTrace_ma_32f_L(const Ipp32f** ppSrc, int srcRoiShift, int srcStride1, int srcStride2, int widthHeight, Ipp32f* pDst, int count);
IppStatus ippmTrace_ma_64f_L(const Ipp64f** ppSrc, int srcRoiShift, int srcStride1, int srcStride2, int widthHeight, Ipp64f* pDst, int count);
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). |
pDst |
Pointer to the destination value or array of values. |
widthHeight |
Size of the square matrix. |
count |
Number of matrices in the array. |
The function ippmTrace is declared in the
ippm.h header file. The function sums up the elements
along the principal diagonal of the source matrix and stores the
result in pDst. The following formula illustrates
how trace is calculated:
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 ippmTrace_ma_32f_P. For more information, see also examples in Getting Started.
IppStatus trace_ma_32f_P(void) { /* // Source data: // 2 matrices with widthHeight=3 */
Ipp32f src[6*6] = { 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 2, 0, 0, 2, 0, 2, 0, 2, 2, 0, 0, 2, 0, 0, 2, 2, 0, 2}; /* // Nonzero elements of interest are referred by mask using // pointer descriptor */ int widthHeight=3; int count=2; int srcRoiShift= 0; int srcStride0 = 3*6*sizeof(Ipp32f); Ipp32f* ppSrc[3*3] = { src, src+3, src+5, src+7, src+8, src+11, src+14, src+15, src+17 }; Ipp32f pDst[2]; /* Destination is array of values */ IppStatus status = ippmTrace_ma_32f_P((const Ipp32f**)ppSrc, srcRoiShift, srcStride0, widthHeight, pDst, 2); /*
// It is recommended to check return status
// to detect wrong input parameters, if any
*/
if (status == ippStsNoErr) {
printf_va_Ipp32f("Dst is 2 values:", pDst, 2, 1, status);
} else {
printf("Function returns status: %s \n", ippGetStatusString(status));
}
return status; }
The program above produces the following output:
Dst is 2 values:
3.000000 6.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 a roiShift value is negative or not divisible by the size of the data type. |
ippStsCountMatrixErr |
Returns an error when a count value is less or equal to zero. |
Copyright © 2000 - 2011, Intel Corporation. All rights reserved.