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

Function Log_64f

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

Source from the content-addressed store, hash-verified

1598
1599
1600static void Log_64f( const double *x, double *y, int n )
1601{
1602 static const double shift[] = { 0, -1./512 };
1603 static const double
1604 A7 = 1.0,
1605 A6 = -0.5,
1606 A5 = 0.333333333333333314829616256247390992939472198486328125,
1607 A4 = -0.25,
1608 A3 = 0.2,
1609 A2 = -0.1666666666666666574148081281236954964697360992431640625,
1610 A1 = 0.1428571428571428769682682968777953647077083587646484375,
1611 A0 = -0.125;
1612
1613 #undef LOGPOLY
1614 #define LOGPOLY(x,k) ((x)+=shift[k], xq = (x)*(x),\
1615 (((A0*xq + A2)*xq + A4)*xq + A6)*xq + \
1616 (((A1*xq + A3)*xq + A5)*xq + A7)*(x))
1617
1618 int i = 0;
1619 DBLINT buf[4];
1620 DBLINT *X = (DBLINT *) x;
1621
1622#if CV_SSE2
1623 if( USE_SSE2 )
1624 {
1625 static const __m128d ln2_2 = _mm_set1_pd(ln_2);
1626 static const __m128d _1_2 = _mm_set1_pd(1.);
1627 static const __m128d shift2 = _mm_set1_pd(-1./512);
1628
1629 static const __m128i log_and_mask2 = _mm_set_epi32(LOGTAB_MASK2, 0xffffffff, LOGTAB_MASK2, 0xffffffff);
1630 static const __m128i log_or_mask2 = _mm_set_epi32(1023 << 20, 0, 1023 << 20, 0);
1631
1632 static const __m128d mA0 = _mm_set1_pd(A0);
1633 static const __m128d mA1 = _mm_set1_pd(A1);
1634 static const __m128d mA2 = _mm_set1_pd(A2);
1635 static const __m128d mA3 = _mm_set1_pd(A3);
1636 static const __m128d mA4 = _mm_set1_pd(A4);
1637 static const __m128d mA5 = _mm_set1_pd(A5);
1638 static const __m128d mA6 = _mm_set1_pd(A6);
1639 static const __m128d mA7 = _mm_set1_pd(A7);
1640
1641 int CV_DECL_ALIGNED(16) idx[4];
1642
1643 for( ; i <= n - 4; i += 4 )
1644 {
1645 __m128i h0 = _mm_loadu_si128((const __m128i*)(x + i));
1646 __m128i h1 = _mm_loadu_si128((const __m128i*)(x + i + 2));
1647
1648 __m128d xd0 = _mm_castsi128_pd(_mm_or_si128(_mm_and_si128(h0, log_and_mask2), log_or_mask2));
1649 __m128d xd1 = _mm_castsi128_pd(_mm_or_si128(_mm_and_si128(h1, log_and_mask2), log_or_mask2));
1650
1651 h0 = _mm_unpackhi_epi32(_mm_unpacklo_epi32(h0, h1), _mm_unpackhi_epi32(h0, h1));
1652
1653 __m128i yi0 = _mm_sub_epi32(_mm_and_si128(_mm_srli_epi32(h0, 20),
1654 _mm_set1_epi32(2047)), _mm_set1_epi32(1023));
1655 __m128d yd0 = _mm_mul_pd(_mm_cvtepi32_pd(yi0), ln2_2);
1656 __m128d yd1 = _mm_mul_pd(_mm_cvtepi32_pd(_mm_unpackhi_epi64(yi0, yi0)), ln2_2);
1657

Callers 2

logFunction · 0.85
powFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected