Listing 2: Template policy class.
// just a placeholder template <typename T> struct IntelIppPolicy { typedef T elem_type; }; // specialization for float type template<> struct IntelIppPolicy<Ipp32f> { // 'traits' typedef Ipp32f elem_type; static Ipp32f *malloc(int len) { return ippsMalloc_32f(len); } static void free(void *ptr) { return ippsFree(ptr); } static IppStatus maxIndx(const Ipp32f *pSrc, int len, Ipp32f *pMax, int *pIndx) { return ippsMaxIndx_32f(pSrc, len, pMax, pIndx); } static IppStatus minIndx(const Ipp32f *pSrc, int len, Ipp32f *pMin, int *pIndx) { return ippsMinIndx_32f(pSrc, len, pMin, pIndx); } }; // specialization for double type template<> struct IntelIppPolicy<Ipp64f> { // 'traits' typedef Ipp64f elem_type; static Ipp64f *malloc(int len) { return ippsMalloc_64f(len); } static void free(void *ptr) { return ippsFree(ptr); } static IppStatus maxIndx(const Ipp64f *pSrc, int len, Ipp64f *pMax, int *pIndx) { return ippsMaxIndx_64f(pSrc, len, pMax, pIndx); } static IppStatus minIndx(const Ipp64f *pSrc, int len, Ipp64f *pMin, int *pIndx) { return ippsMinIndx_64f(pSrc, len, pMin, pIndx); } };