MCPcopy Create free account
hub / github.com/creatale/node-dv / Exp_64f

Function Exp_64f

deps/opencv/modules/core/src/mathfuncs.cpp:967–1138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

965
966
967static void Exp_64f( const double *_x, double *y, int n )
968{
969 static const double
970 A5 = .99999999999999999998285227504999 / EXPPOLY_32F_A0,
971 A4 = .69314718055994546743029643825322 / EXPPOLY_32F_A0,
972 A3 = .24022650695886477918181338054308 / EXPPOLY_32F_A0,
973 A2 = .55504108793649567998466049042729e-1 / EXPPOLY_32F_A0,
974 A1 = .96180973140732918010002372686186e-2 / EXPPOLY_32F_A0,
975 A0 = .13369713757180123244806654839424e-2 / EXPPOLY_32F_A0;
976
977#undef EXPPOLY
978#define EXPPOLY(x) (((((A0*(x) + A1)*(x) + A2)*(x) + A3)*(x) + A4)*(x) + A5)
979
980 int i = 0;
981 Cv64suf buf[4];
982 const Cv64suf* x = (const Cv64suf*)_x;
983
984#if CV_SSE2
985 if( USE_SSE2 )
986 {
987 static const __m128d prescale2 = _mm_set1_pd(exp_prescale);
988 static const __m128d postscale2 = _mm_set1_pd(exp_postscale);
989 static const __m128d maxval2 = _mm_set1_pd(exp_max_val);
990 static const __m128d minval2 = _mm_set1_pd(-exp_max_val);
991
992 static const __m128d mA0 = _mm_set1_pd(A0);
993 static const __m128d mA1 = _mm_set1_pd(A1);
994 static const __m128d mA2 = _mm_set1_pd(A2);
995 static const __m128d mA3 = _mm_set1_pd(A3);
996 static const __m128d mA4 = _mm_set1_pd(A4);
997 static const __m128d mA5 = _mm_set1_pd(A5);
998
999 int CV_DECL_ALIGNED(16) tab_idx[4];
1000
1001 for( ; i <= n - 4; i += 4 )
1002 {
1003 __m128d xf0 = _mm_loadu_pd(&x[i].f), xf1 = _mm_loadu_pd(&x[i+2].f);
1004 __m128i xi0, xi1;
1005 xf0 = _mm_min_pd(_mm_max_pd(xf0, minval2), maxval2);
1006 xf1 = _mm_min_pd(_mm_max_pd(xf1, minval2), maxval2);
1007 xf0 = _mm_mul_pd(xf0, prescale2);
1008 xf1 = _mm_mul_pd(xf1, prescale2);
1009
1010 xi0 = _mm_cvtpd_epi32(xf0);
1011 xi1 = _mm_cvtpd_epi32(xf1);
1012 xf0 = _mm_mul_pd(_mm_sub_pd(xf0, _mm_cvtepi32_pd(xi0)), postscale2);
1013 xf1 = _mm_mul_pd(_mm_sub_pd(xf1, _mm_cvtepi32_pd(xi1)), postscale2);
1014
1015 xi0 = _mm_unpacklo_epi64(xi0, xi1);
1016 _mm_store_si128((__m128i*)tab_idx, _mm_and_si128(xi0, _mm_set1_epi32(EXPTAB_MASK)));
1017
1018 xi0 = _mm_add_epi32(_mm_srai_epi32(xi0, EXPTAB_SCALE), _mm_set1_epi32(1023));
1019 xi0 = _mm_packs_epi32(xi0, xi0);
1020 xi0 = _mm_max_epi16(xi0, _mm_setzero_si128());
1021 xi0 = _mm_min_epi16(xi0, _mm_set1_epi16(2047));
1022 xi0 = _mm_unpacklo_epi16(xi0, _mm_setzero_si128());
1023 xi1 = _mm_unpackhi_epi32(xi0, _mm_setzero_si128());
1024 xi0 = _mm_unpacklo_epi32(xi0, _mm_setzero_si128());

Callers 2

expFunction · 0.85
powFunction · 0.85

Calls 1

cvRoundFunction · 0.85

Tested by

no test coverage detected