Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

Computing a moving average/sum

thorsan1
Beginner
486 Views
Hi
In one of my algorithms I am computing a moving sum of a vector. Say my vector( VEC ) is length N and my window size is W I compute it like this:

ippsSum_32f(VEC+1,W,VEC,ippAlgHintFast);
int endIndx = FULL_WINDOW_SIZE+1,frontIndx = 0;
for(int k=1;k(N-W);k++,endIndx++,frontIndx++)
{
VEC = VEC[frontIndx] - VEC + VEC[endIndx];
}

Is there a faster way? Thank you for any help. Thorsan
0 Kudos
1 Reply
Vladimir_Dudnik
Employee
486 Views

Hello,

you can use IPP function:

/* ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Name: ippsSumWindow_8u32f ippsSumWindow_16s32f
// Purpose:
// Return:
// ippStsNoErr Ok
// ippStsNullPtrErr one or more pointers are NULL
// ippStsMaskSizeErr maskSize has a field with zero, or negative value
// Arguments:
// pSrc Pointer to the source vector
// pDst Pointer to the destination vector
// maskSize Size of the mask in pixels
*/

IPPAPI(IppStatus,ippsSumWindow_8u32f ,(const Ipp8u* pSrc,Ipp32f* pDst,int len, int maskSize ))
IPPAPI(IppStatus,ippsSumWindow_16s32f,(const Ipp16s* pSrc,Ipp32f* pDst,int len, int maskSize ))

Regards,
Vladimir

0 Kudos
Reply