34 #define ELEMENT_COUNT(x) c7x::element_count_of<x>::value
50 template <
typename vecType>
static inline vecType
MATHLIB_exp2_div(vecType a, vecType b)
55 X = X * (TWO - (b * X));
56 X = X * (TWO - (b * X));
68 size_t remNumBlocks = 0;
71 typedef typename c7x::make_full_vector<T>::type vec;
73 __SE_TEMPLATE_v1 se0Params = __gen_SE_TEMPLATE_v1();
74 __SA_TEMPLATE_v1 sa0Params = __gen_SA_TEMPLATE_v1();
84 numBlocks = length / c7x::element_count_of<vec>::value;
85 remNumBlocks = length % c7x::element_count_of<vec>::value;
97 vec zero, half, epsilon, minInput, maxVal, maxInput, A0, A1, B0, B1, CC1, CC2, ln2E, lnE2;
101 epsilon = (vec) 9.313225746e-10f;
102 minInput = (vec) -126.0f;
103 maxVal = (vec) 3.40282347e+38f;
104 maxInput = (vec) 128.0f;
105 A0 = (vec) 2.499999995e-1f;
106 A1 = (vec) 4.1602886268e-3f;
108 B1 = (vec) 4.9987178778e-2f;
109 CC1 = (vec) 0.693359375f;
110 CC2 = (vec) -2.12194440055e-4f;
111 ln2E = (vec) 1.442695040889f;
112 lnE2 = (vec) 0.69314718056f;
115 for (
size_t i = 0; i < numBlocks; i++) {
116 vec inVec = c7x::strm_eng<0, vec>::get_adv();
122 vec Y, X, W, R, S, B, C, D, absY;
124 c7x::uint_vec uN, uNShift;
133 __vpred cmp_Y = __cmp_lt_pred(absY, epsilon);
134 Y = __select(cmp_Y, zero, Y);
140 N = __float_to_int(C);
141 S = __int_to_float(N);
144 X = (Y - (S * CC1)) - (S * CC2);
151 D = ((A1 * W) + A0) * X;
154 uN = c7x::convert<c7x::uint_vec>(N);
157 S = c7x::reinterpret<c7x::float_vec>(uNShift);
169 __vpred cmp_min = __cmp_lt_pred(inVec, minInput);
170 C = __select(cmp_min, zero, C);
175 __vpred cmp_max = __cmp_lt_pred(maxInput, inVec);
176 C = __select(cmp_max, maxVal, C);
178 __vpred tmp = c7x::strm_agen<0, vec>::get_vpred();
179 vec *addr = c7x::strm_agen<0, vec>::get_adv(pDst);
180 __vstore_pred(tmp, addr, C);
template MATHLIB_STATUS MATHLIB_exp2< float >(size_t length, float *pSrc, float *pDst)
static vecType MATHLIB_exp2_div(vecType a, vecType b)
MATHLIB_STATUS MATHLIB_exp2(size_t length, T *pSrc, T *pDst)
Performs the elementwise 2^x for all x in the input vector. Function can be overloaded with float poi...
MATHLIB_STATUS MATHLIB_exp2_sp(size_t length, float *pSrc, float *pDst)
This function is the C interface for MATHLIB_exp2. Function accepts float pointers.
static void MATHLIB_SE0SA0Close()
This method performs SE0 and SA0 close.
static void MATHLIB_SE0SA01DSequentialInit(__SE_TEMPLATE_v1 *se0Params, __SA_TEMPLATE_v1 *sa0Params, size_t length, T *pSrc, T *pDst)
static MATHLIB_STATUS MATHLIB_checkParams(size_t length, T *pSrc, T *pDst)
This method performs parameter checks for MATHLIB function.
static void MATHLIB_SE0SA0Open(__SE_TEMPLATE_v1 *se0Params, __SA_TEMPLATE_v1 *sa0Params, T *pSrc)
This method performs SE0 and SA0 open.
MATHLIB_STATUS_NAME
The enumeration of all status codes.