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

Function Exp_32f

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

Source from the content-addressed store, hash-verified

765static const double exp_max_val = 3000.*(1 << EXPTAB_SCALE); // log10(DBL_MAX) < 3000
766
767static void Exp_32f( const float *_x, float *y, int n )
768{
769 static const float
770 A4 = (float)(1.000000000000002438532970795181890933776 / EXPPOLY_32F_A0),
771 A3 = (float)(.6931471805521448196800669615864773144641 / EXPPOLY_32F_A0),
772 A2 = (float)(.2402265109513301490103372422686535526573 / EXPPOLY_32F_A0),
773 A1 = (float)(.5550339366753125211915322047004666939128e-1 / EXPPOLY_32F_A0);
774
775#undef EXPPOLY
776#define EXPPOLY(x) \
777 (((((x) + A1)*(x) + A2)*(x) + A3)*(x) + A4)
778
779 int i = 0;
780 const Cv32suf* x = (const Cv32suf*)_x;
781 Cv32suf buf[4];
782
783#if CV_SSE2
784 if( n >= 8 && USE_SSE2 )
785 {
786 static const __m128d prescale2 = _mm_set1_pd(exp_prescale);
787 static const __m128 postscale4 = _mm_set1_ps((float)exp_postscale);
788 static const __m128 maxval4 = _mm_set1_ps((float)(exp_max_val/exp_prescale));
789 static const __m128 minval4 = _mm_set1_ps((float)(-exp_max_val/exp_prescale));
790
791 static const __m128 mA1 = _mm_set1_ps(A1);
792 static const __m128 mA2 = _mm_set1_ps(A2);
793 static const __m128 mA3 = _mm_set1_ps(A3);
794 static const __m128 mA4 = _mm_set1_ps(A4);
795 bool y_aligned = (size_t)(void*)y % 16 == 0;
796
797 ushort CV_DECL_ALIGNED(16) tab_idx[8];
798
799 for( ; i <= n - 8; i += 8 )
800 {
801 __m128 xf0, xf1;
802 xf0 = _mm_loadu_ps(&x[i].f);
803 xf1 = _mm_loadu_ps(&x[i+4].f);
804 __m128i xi0, xi1, xi2, xi3;
805
806 xf0 = _mm_min_ps(_mm_max_ps(xf0, minval4), maxval4);
807 xf1 = _mm_min_ps(_mm_max_ps(xf1, minval4), maxval4);
808
809 __m128d xd0 = _mm_cvtps_pd(xf0);
810 __m128d xd2 = _mm_cvtps_pd(_mm_movehl_ps(xf0, xf0));
811 __m128d xd1 = _mm_cvtps_pd(xf1);
812 __m128d xd3 = _mm_cvtps_pd(_mm_movehl_ps(xf1, xf1));
813
814 xd0 = _mm_mul_pd(xd0, prescale2);
815 xd2 = _mm_mul_pd(xd2, prescale2);
816 xd1 = _mm_mul_pd(xd1, prescale2);
817 xd3 = _mm_mul_pd(xd3, prescale2);
818
819 xi0 = _mm_cvtpd_epi32(xd0);
820 xi2 = _mm_cvtpd_epi32(xd2);
821
822 xi1 = _mm_cvtpd_epi32(xd1);
823 xi3 = _mm_cvtpd_epi32(xd3);
824

Callers 2

expFunction · 0.85
powFunction · 0.85

Calls 1

cvRoundFunction · 0.85

Tested by

no test coverage detected