58 #include <pcl/Diagnostics.h>
60 #include <pcl/Memory.h>
71 # include <emmintrin.h>
74 # include <xmmintrin.h>
75 # include <immintrin.h>
77 # define __PCL_HAVE_SSE2 1
82 # if defined( __x86_64__ ) || defined( _M_X64 )
83 # define __PCL_HAVE_SSE2 1
84 # include <emmintrin.h>
96 #if !defined( _MSC_VER ) && !defined( __clang__ ) && defined( __GNUC__ )
97 # define __PCL_HAVE_SINCOS 1
100 #ifdef __PCL_QT_INTERFACE
101 # include <QtWidgets/QtWidgets>
108 #define __PCL_MEDIAN_HISTOGRAM_LENGTH 8192
114 #define __PCL_MEDIAN_HISTOGRAM_OVERHEAD (64*1024)
150 __cpuid( cpuInfo, 1 );
151 edxFlags = cpuInfo[3];
152 ecxFlags = cpuInfo[2];
154 asm volatile(
"mov $0x00000001, %%eax\n\t"
158 :
"=r" (edxFlags),
"=r" (ecxFlags)
160 :
"%eax",
"%ebx",
"%ecx",
"%edx" );
163 if ( ecxFlags & (1u << 20) )
165 if ( ecxFlags & (1u << 19) )
169 if ( edxFlags & (1u << 26) )
171 if ( edxFlags & (1u << 25) )
182 #define __PCL_FLOAT_SGNMASK 0x80000000
183 #define __PCL_FLOAT_EXPMASK 0x7f800000
184 #define __PCL_FLOAT_SIGMASK 0x007fffff
196 union {
float f;
uint32 u; } v = { x };
197 return (v.u & __PCL_FLOAT_EXPMASK) != __PCL_FLOAT_EXPMASK;
210 inline bool IsNaN(
float x ) noexcept
212 union {
float f;
uint32 u; } v = { x };
213 return (v.u & __PCL_FLOAT_EXPMASK) == __PCL_FLOAT_EXPMASK &&
214 (v.u & __PCL_FLOAT_SIGMASK) != 0;
234 union {
float f;
uint32 u; } v = { x };
235 if ( (v.u & __PCL_FLOAT_EXPMASK) == __PCL_FLOAT_EXPMASK &&
236 (v.u & __PCL_FLOAT_SIGMASK) == 0 )
237 return ((v.u & __PCL_FLOAT_SGNMASK) == 0) ? +1 : -1;
249 union {
float f;
uint32 u; } v = { x };
250 return v.u == __PCL_FLOAT_SGNMASK;
253 #define __PCL_DOUBLE_SGNMASK 0x80000000
254 #define __PCL_DOUBLE_EXPMASK 0x7ff00000
255 #define __PCL_DOUBLE_SIGMASK 0x000fffff
267 union {
double d;
uint32 u[2]; } v = { x };
268 return (v.u[1] & __PCL_DOUBLE_EXPMASK) != __PCL_DOUBLE_EXPMASK;
281 inline bool IsNaN(
double x ) noexcept
283 union {
double d;
uint32 u[2]; } v = { x };
284 return (v.u[1] & __PCL_DOUBLE_EXPMASK) == __PCL_DOUBLE_EXPMASK &&
285 (v.u[0] != 0 || (v.u[1] & __PCL_DOUBLE_SIGMASK) != 0);
305 union {
double d;
uint32 u[2]; } v = { x };
307 (v.u[1] & __PCL_DOUBLE_SIGMASK) == 0 &&
308 (v.u[1] & __PCL_DOUBLE_EXPMASK) == __PCL_DOUBLE_EXPMASK )
309 return ((v.u[1] & __PCL_DOUBLE_SGNMASK) == 0) ? +1 : -1;
321 union {
double d;
uint32 u[2]; } v = { x };
322 return v.u[1] == __PCL_DOUBLE_SGNMASK &&
344 inline float __pcl_hsum128_ps( __m128 v )
346 __m128 shuf = _mm_movehdup_ps( v );
347 __m128 sums = _mm_add_ps( v, shuf );
348 shuf = _mm_movehl_ps( shuf, sums );
349 sums = _mm_add_ss( sums, shuf );
350 return _mm_cvtss_f32( sums );
353 inline float __pcl_hsum256_ps( __m256 v )
355 __m128 vlow = _mm256_castps256_ps128( v );
356 __m128 vhigh = _mm256_extractf128_ps( v, 1 );
357 vlow = _mm_add_ps( vlow, vhigh );
358 return __pcl_hsum128_ps( vlow );
361 inline double __pcl_hsum128_pd( __m128d v )
363 __m128 undef = _mm_undefined_ps();
364 __m128 shuftmp = _mm_movehl_ps( undef, _mm_castpd_ps( v ) );
365 __m128d shuf = _mm_castps_pd( shuftmp );
366 return _mm_cvtsd_f64( _mm_add_sd( v, shuf ) );
369 inline double __pcl_hsum256_pd( __m256d v )
371 __m128d vlow = _mm256_castpd256_pd128( v );
372 __m128d vhigh = _mm256_extractf128_pd( v, 1 );
373 vlow = _mm_add_pd( vlow, vhigh );
374 __m128d high64 = _mm_unpackhi_pd( vlow, vlow );
375 return _mm_cvtsd_f64( _mm_add_sd( vlow, high64 ) );
390 inline float Abs(
float x ) noexcept
392 return std::fabs( x );
398 inline double Abs(
double x ) noexcept
400 return std::fabs( x );
406 inline long double Abs(
long double x ) noexcept
408 return std::fabs( x );
414 inline signed int Abs(
signed int x ) noexcept
422 #if defined( __PCL_MACOSX ) && defined( __clang__ )
423 _Pragma(
"clang diagnostic push")
424 _Pragma("clang diagnostic ignored \"-Wabsolute-value\"")
426 inline signed long Abs(
signed long x ) noexcept
430 #if defined( __PCL_MACOSX ) && defined( __clang__ )
431 _Pragma(
"clang diagnostic pop")
437 #if defined( _MSC_VER )
438 inline __int64
Abs( __int64 x ) noexcept
440 return (x < 0) ? -x : +x;
442 #elif defined( __PCL_MACOSX ) && defined( __clang__ )
443 inline constexpr
signed long long Abs(
signed long long x ) noexcept
445 return (x < 0) ? -x : +x;
448 inline signed long long Abs(
signed long long x ) noexcept
457 inline signed short Abs(
signed short x ) noexcept
459 return (
signed short)::abs(
int( x ) );
465 inline signed char Abs(
signed char x ) noexcept
467 return (
signed char)::abs(
int( x ) );
473 inline wchar_t Abs(
wchar_t x ) noexcept
475 return (
wchar_t)::abs(
int( x ) );
481 inline constexpr
unsigned int Abs(
unsigned int x ) noexcept
489 inline constexpr
unsigned long Abs(
unsigned long x ) noexcept
498 inline unsigned __int64
Abs(
unsigned __int64 x ) noexcept
503 inline constexpr
unsigned long long Abs(
unsigned long long x ) noexcept
512 inline constexpr
unsigned short Abs(
unsigned short x ) noexcept
520 inline constexpr
unsigned char Abs(
unsigned char x ) noexcept
531 inline constexpr
long double Pi() noexcept
533 return (
long double)( 0.31415926535897932384626433832795029e+01L );
540 inline constexpr
long double TwoPi() noexcept
542 return (
long double)( 0.62831853071795864769252867665590058e+01L );
552 template <
typename T>
inline constexpr T
Angle(
int d, T m ) noexcept
562 template <
typename T>
inline constexpr T
Angle(
int d,
int m, T s ) noexcept
564 return Angle( d, m + s/60 );
573 template <
typename T>
inline constexpr T
ArcCos( T x ) noexcept
575 PCL_PRECONDITION( T( -1 ) <= x && x <= T( 1 ) )
576 return std::acos( x );
585 template <
typename T>
inline constexpr T
ArcSin( T x ) noexcept
587 PCL_PRECONDITION( T( -1 ) <= x && x <= T( 1 ) )
588 return std::asin( x );
597 template <
typename T>
inline constexpr T
ArcTan( T x ) noexcept
599 return std::atan( x );
608 template <
typename T>
inline constexpr T
ArcTan( T y, T x ) noexcept
610 return std::atan2( y, x );
619 template <
typename T>
inline T
ArcTan2Pi( T y, T x ) noexcept
623 r =
static_cast<T
>( r +
TwoPi() );
633 template <
typename T>
inline constexpr T
Ceil( T x ) noexcept
635 return std::ceil( x );
644 template <
typename T>
inline constexpr T
Cos( T x ) noexcept
646 return std::cos( x );
655 template <
typename T>
inline constexpr T
Cosh( T x ) noexcept
657 return std::cosh( x );
666 template <
typename T>
inline constexpr T
Cotan( T x ) noexcept
668 return T( 1 )/std::tan( x );
677 template <
typename T>
inline constexpr T
Deg( T x ) noexcept
679 return static_cast<T
>( 0.572957795130823208767981548141051700441964e+02L * x );
688 template <
typename T>
inline constexpr T
Exp( T x ) noexcept
690 return std::exp( x );
699 template <
typename T>
inline constexpr T
Floor( T x ) noexcept
701 return std::floor( x );
711 template <
typename T>
inline constexpr T
Frac( T x ) noexcept
713 return std::modf( x, &x );
724 template <
typename T>
inline void Frexp( T x, T& m,
int& p ) noexcept
726 m = std::frexp( x, &p );
740 template <
typename T>
inline constexpr T
Hav( T x ) noexcept
742 return (1 -
Cos( x ))/2;
751 template <
typename T>
inline constexpr T
Ldexp( T m,
int p ) noexcept
753 return std::ldexp( m, p );
762 template <
typename T>
inline constexpr T
Ln( T x ) noexcept
764 PCL_PRECONDITION( x >= 0 )
765 return std::log( x );
770 struct PCL_CLASS FactorialCache
772 constexpr
static int s_cacheSize = 127;
773 static const double s_lut[ s_cacheSize+1 ];
785 PCL_PRECONDITION( n >= 0 )
786 if ( n <= FactorialCache::s_cacheSize )
787 return FactorialCache::s_lut[n];
788 double x = FactorialCache::s_lut[FactorialCache::s_cacheSize];
789 for (
int m = FactorialCache::s_cacheSize; ++m <= n; )
805 PCL_PRECONDITION( n >= 0 )
806 if ( n <= FactorialCache::s_cacheSize )
807 return Ln( FactorialCache::s_lut[n] );
810 return (x - 0.5)*
Ln( x ) - x + 0.91893853320467267 + 1/12/x - 1/(360*x*x*x);
831 template <
typename T>
struct PCL_CLASS
Fact :
public FactorialCache
836 T operator()(
int n )
const noexcept
838 PCL_PRECONDITION( n >= 0 )
839 if ( n <= s_cacheSize )
840 return T( s_lut[n] );
841 double x = s_lut[s_cacheSize];
842 for (
int m = s_cacheSize; ++m <= n; )
853 T
Ln(
int n )
const noexcept
855 PCL_PRECONDITION( n >= 0 )
856 if ( n <= s_cacheSize )
857 return T(
pcl::Ln( s_lut[n] ) );
860 return T( (x - 0.5)*
pcl::Ln( x ) - x + 0.91893853320467267 + 1/12/x - 1/(360*x*x*x) );
870 inline constexpr
long double Ln2() noexcept
872 return (
long double)( 0.6931471805599453094172321214581766e+00L );
881 template <
typename T>
inline constexpr T
Log( T x ) noexcept
883 PCL_PRECONDITION( x >= 0 )
884 return std::log10( x );
893 inline constexpr
long double Log2() noexcept
897 return (
long double)( 0.3010299956639811952137388947244930416265e+00L );
906 template <
typename T>
inline constexpr T
Log2( T x ) noexcept
910 PCL_PRECONDITION( x >= 0 )
911 return std::log( x )/
Ln2();
920 inline constexpr
long double Log2e() noexcept
924 return (
long double)( 0.14426950408889634073599246810018920709799e+01L );
933 inline constexpr
long double Log2T() noexcept
937 return (
long double)( 0.33219280948873623478703194294893900118996e+01L );
946 template <
typename T>
inline constexpr T
LogN( T n, T x ) noexcept
948 PCL_PRECONDITION( x >= 0 )
949 return std::log( x )/std::log( n );
958 template <
typename T>
inline constexpr T
Mod( T x, T y ) noexcept
960 return std::fmod( x, y );
979 template <
typename T,
typename C>
inline T
Poly( T x, C c,
int n ) noexcept
981 PCL_PRECONDITION( n >= 0 )
983 for ( c += n, y = *c; n > 0; --n )
1003 template <
typename T>
inline T
Poly( T x, std::initializer_list<T> c ) noexcept
1005 PCL_PRECONDITION( c.size() > 0 )
1006 return Poly( x, c.begin(),
int( c.size() )-1 );
1022 template <
typename T>
inline constexpr
int Sign( T x ) noexcept
1024 return (x < 0) ? -1 : ((x > 0) ? +1 : 0);
1040 template <
typename T>
inline constexpr
char SignChar( T x ) noexcept
1042 return (x < 0) ?
'-' : ((x > 0) ?
'+' :
' ');
1051 template <
typename T>
inline constexpr T
Sin( T x ) noexcept
1053 return std::sin( x );
1062 template <
typename T>
inline constexpr T
Sinh( T x ) noexcept
1064 return std::sinh( x );
1069 #ifdef __PCL_HAVE_SINCOS
1071 inline void __pcl_sincos(
float x,
float& sx,
float& cx ) noexcept
1073 ::sincosf( x, &sx, &cx );
1076 inline void __pcl_sincos(
double x,
double& sx,
double& cx ) noexcept
1078 ::sincos( x, &sx, &cx );
1081 inline void __pcl_sincos(
long double x,
long double& sx,
long double& cx ) noexcept
1083 ::sincosl( x, &sx, &cx );
1101 template <
typename T>
inline void SinCos( T x, T& sx, T& cx ) noexcept
1103 #ifdef __PCL_HAVE_SINCOS
1104 __pcl_sincos( x, sx, cx );
1122 template <
typename T>
inline void Split( T x, T& i, T& f ) noexcept
1124 f = std::modf( x, &i );
1133 template <
typename T>
inline constexpr T
Sqrt( T x ) noexcept
1144 template <
typename T>
inline constexpr T
Tan( T x ) noexcept
1146 return std::tan( x );
1155 template <
typename T>
inline constexpr T
Tanh( T x ) noexcept
1157 return std::tanh( x );
1166 template <
typename T>
inline T
Trunc( T x ) noexcept
1168 (void)std::modf( x, &x );
1174 template <
typename T>
inline int __pcl_trunc_i32( T x ) noexcept
1179 #ifdef __PCL_HAVE_SSE2
1181 inline int __pcl_trunc_i32(
float x ) noexcept
1183 return _mm_cvtt_ss2si( _mm_load_ss( &x ) );
1186 inline int __pcl_trunc_i32(
double x ) noexcept
1188 return _mm_cvttsd_si32( _mm_load_sd( &x ) );
1203 template <
typename T>
inline int TruncInt( T x ) noexcept
1205 PCL_PRECONDITION( x >= int_min && x <= int_max )
1206 #ifdef __PCL_NO_PERFORMANCE_CRITICAL_MATH_ROUTINES
1209 return __pcl_trunc_i32( x );
1221 template <
typename T>
inline int TruncI( T x ) noexcept
1226 #define TruncInt32( x ) TruncInt( x )
1227 #define TruncI32( x ) TruncInt( x )
1231 template <
typename T>
inline int64 __pcl_trunc_i64( T x ) noexcept
1236 #ifdef __PCL_HAVE_SSE2
1238 inline int64 __pcl_trunc_i64(
float x ) noexcept
1240 return _mm_cvttss_si64( _mm_load_ss( &x ) );
1243 inline int64 __pcl_trunc_i64(
double x ) noexcept
1245 return _mm_cvttsd_si64( _mm_load_sd( &x ) );
1263 #ifdef __PCL_NO_PERFORMANCE_CRITICAL_MATH_ROUTINES
1266 return __pcl_trunc_i64( x );
1298 template <
typename T>
inline constexpr T
Pow( T x, T y ) noexcept
1300 PCL_PRECONDITION( y < T( int_max ) )
1301 return std::pow( x, y );
1316 template <
typename T>
struct PCL_CLASS
Pow10I
1318 T operator ()(
int n )
const noexcept
1321 static const T lut[] =
1323 #define ___( x ) static_cast<T>( x )
1324 ___( 1.0e+00 ), ___( 1.0e+01 ), ___( 1.0e+02 ), ___( 1.0e+03 ), ___( 1.0e+04 ),
1325 ___( 1.0e+05 ), ___( 1.0e+06 ), ___( 1.0e+07 ), ___( 1.0e+08 ), ___( 1.0e+09 ),
1326 ___( 1.0e+10 ), ___( 1.0e+11 ), ___( 1.0e+12 ), ___( 1.0e+13 ), ___( 1.0e+14 ),
1327 ___( 1.0e+15 ), ___( 1.0e+16 ), ___( 1.0e+17 ), ___( 1.0e+18 ), ___( 1.0e+19 ),
1328 ___( 1.0e+20 ), ___( 1.0e+21 ), ___( 1.0e+22 ), ___( 1.0e+23 ), ___( 1.0e+24 ),
1329 ___( 1.0e+25 ), ___( 1.0e+26 ), ___( 1.0e+27 ), ___( 1.0e+28 ), ___( 1.0e+29 ),
1330 ___( 1.0e+30 ), ___( 1.0e+31 ), ___( 1.0e+32 ), ___( 1.0e+33 ), ___( 1.0e+34 ),
1331 ___( 1.0e+35 ), ___( 1.0e+36 ), ___( 1.0e+37 ), ___( 1.0e+38 ), ___( 1.0e+39 ),
1332 ___( 1.0e+40 ), ___( 1.0e+41 ), ___( 1.0e+42 ), ___( 1.0e+43 ), ___( 1.0e+44 ),
1333 ___( 1.0e+45 ), ___( 1.0e+46 ), ___( 1.0e+47 ), ___( 1.0e+48 ), ___( 1.0e+49 )
1344 while ( (i -= N-1) >= N )
1349 return T( (n >= 0) ? x : 1/x );
1359 template <
typename T>
inline T
Pow10( T x ) noexcept
1362 return (i == x) ?
Pow10I<T>()( i ) : T( std::pow( 10, x ) );
1379 static_assert( std::is_unsigned<T>::value,
1380 "RotL() can only be used for unsigned integer scalar types" );
1381 const uint8 mask = 8*
sizeof( x ) - 1;
1383 return (x << r) | (x >> ((-r) & mask));
1400 static_assert( std::is_unsigned<T>::value,
1401 "RotR() can only be used for unsigned integer scalar types" );
1402 const uint8 mask = 8*
sizeof( x ) - 1;
1404 return (x >> r) | (x << ((-r) & mask));
1420 inline double Round(
double x ) noexcept
1422 #ifdef __PCL_NO_PERFORMANCE_CRITICAL_MATH_ROUTINES
1424 return floor( x + 0.5 );
1430 return double( _mm_cvtsd_si64( _mm_load_sd( &x ) ) );
1437 asm volatile(
"frndint\n":
"=t" (r) :
"0" (x) );
1455 #ifdef __PCL_NO_PERFORMANCE_CRITICAL_MATH_ROUTINES
1457 return floorf( x + 0.5F );
1463 return float( _mm_cvtss_si32( _mm_load_ss( &x ) ) );
1470 asm volatile(
"frndint\n":
"=t" (r) :
"0" (x) );
1486 inline long double Round(
long double x ) noexcept
1488 #ifdef __PCL_NO_PERFORMANCE_CRITICAL_MATH_ROUTINES
1490 return floorl( x + 0.5L );
1497 return (
long double)_mm_cvtsd_si64( _mm_load_sd( &_x ) );
1504 asm volatile(
"frndint\n":
"=t" (r) :
"0" (x) );
1550 template <
typename T>
inline int RoundInt( T x ) noexcept
1552 PCL_PRECONDITION( x >= int_min && x <= int_max )
1554 #ifdef __PCL_NO_PERFORMANCE_CRITICAL_MATH_ROUTINES
1556 return int(
Round( x ) );
1560 static const double magic = 6755399441055744.0;
1561 volatile union {
double d;
int32 i; } v = { double( x ) + magic };
1575 template <
typename T>
inline int RoundI( T x ) noexcept
1619 PCL_PRECONDITION( x >= int_min && x <= int_max )
1624 if ( x - i <= T( -0.5 ) )
1629 if ( x - i >= T( +0.5 ) )
1653 #ifdef __PCL_NO_PERFORMANCE_CRITICAL_MATH_ROUTINES
1663 return _mm_cvtsd_si64( _mm_load_sd( &x ) );
1667 __asm fistp qword ptr r
1672 asm volatile(
"fistpll %0\n" :
"=m" (r) :
"t" (x) :
"st" );
1719 if ( x - i <= -0.5 )
1724 if ( x - i >= +0.5 )
1736 template <
typename T>
inline T
Round( T x,
int n ) noexcept
1738 PCL_PRECONDITION( n >= 0 )
1748 template <
typename T>
inline constexpr T
Pow2( T x ) noexcept
1767 template <
typename T>
struct PCL_CLASS
Pow2I
1769 T operator ()(
int n )
const noexcept
1772 int i = ::abs( n ), p;
1773 double x =
uint32( 1 ) << (p =
Min( i, 31 ));
1774 while ( (i -= p) != 0 )
1776 return T( (n >= 0) ? x : 1/x );
1786 template <
typename T>
inline T
PowI( T x,
int n ) noexcept
1797 while ( (i >>= 1) > 1 );
1801 return (n > 0) ? r : T( 1/r );
1808 template <
typename T>
inline T
PowI4( T x ) noexcept
1817 template <
typename T>
inline T
PowI6( T x ) noexcept
1819 x *= x*x;
return x*x;
1826 template <
typename T>
inline T
PowI8( T x ) noexcept
1828 x *= x*x*x;
return x*x;
1835 template <
typename T>
inline T
PowI10( T x ) noexcept
1837 x *= x*x*x*x;
return x*x;
1844 template <
typename T>
inline T
PowI12( T x ) noexcept
1846 x *= x*x*x*x*x;
return x*x;
1858 template <
typename T>
inline constexpr T
ArcSinh( T x ) noexcept
1860 #ifndef __PCL_NO_STD_INV_HYP_TRIG_FUNCTIONS
1861 return std::asinh( x );
1863 return Ln( x +
Sqrt( 1 + x*x ) );
1876 template <
typename T>
inline constexpr T
ArcCosh( T x ) noexcept
1878 #ifndef __PCL_NO_STD_INV_HYP_TRIG_FUNCTIONS
1879 return std::acosh( x );
1881 return 2*
Ln(
Sqrt( (x + 1)/2 ) +
Sqrt( (x - 1)/2 ) );
1894 template <
typename T>
inline constexpr T
ArcTanh( T x ) noexcept
1896 #ifndef __PCL_NO_STD_INV_HYP_TRIG_FUNCTIONS
1897 return std::atanh( x );
1899 return (
Ln( 1 + x ) -
Ln( 1 - x ))/2;
1914 template <
typename T>
inline constexpr T
ArcHav( T x ) noexcept
1925 template <
typename T>
inline constexpr T
Rad( T x ) noexcept
1927 return static_cast<T
>( 0.174532925199432957692369076848861272222e-01L * x );
1936 template <
typename T>
inline constexpr T
RadMin( T x ) noexcept
1947 template <
typename T>
inline constexpr T
RadSec( T x ) noexcept
1949 return Deg( x )*3600;
1958 template <
typename T>
inline constexpr T
MinRad( T x ) noexcept
1969 template <
typename T>
inline constexpr T
SecRad( T x ) noexcept
1971 return Rad( x/3600 );
1978 template <
typename T>
inline constexpr T
AsRad( T x ) noexcept
1989 template <
typename T>
inline constexpr T
MasRad( T x ) noexcept
1991 return Rad( x/3600000 );
2000 template <
typename T>
inline constexpr T
UasRad( T x ) noexcept
2002 return Rad( x/3600000000 );
2011 template <
typename T>
inline constexpr T
ModPi( T x ) noexcept
2013 x =
Mod( x +
static_cast<T
>(
Pi() ),
static_cast<T
>(
TwoPi() ) ) -
static_cast<T
>(
Pi() );
2014 return (x < -
static_cast<T
>(
Pi() )) ? x +
static_cast<T
>(
TwoPi() ) : x;
2024 template <
typename T>
inline constexpr T
Mod2Pi( T x ) noexcept
2026 return Mod( x,
static_cast<T
>(
TwoPi() ) );
2035 template <
typename T>
inline constexpr T
Norm2Pi( T x ) noexcept
2037 return ((x =
Mod2Pi( x )) < 0) ? x +
static_cast<T
>(
TwoPi() ) : x;
2054 template <
typename T,
typename T1,
typename T2>
2055 inline void Rotate( T& x, T& y, T1 sa, T1 ca, T2 xc, T2 yc ) noexcept
2057 T1 dx = T1( x ) - T1( xc );
2058 T1 dy = T1( y ) - T1( yc );
2059 x = T( T1( xc ) + ca*dx - sa*dy );
2060 y = T( T1( yc ) + sa*dx + ca*dy );
2073 template <
typename T1,
typename T2>
2074 inline void Rotate(
int& x,
int& y, T1 sa, T1 ca, T2 xc, T2 yc ) noexcept
2076 T1 dx = T1( x ) - T1( xc );
2077 T1 dy = T1( y ) - T1( yc );
2078 x =
RoundInt( T1( xc ) + ca*dx - sa*dy );
2079 y =
RoundInt( T1( yc ) + sa*dx + ca*dy );
2092 template <
typename T1,
typename T2>
2093 inline void Rotate(
long& x,
long& y, T1 sa, T1 ca, T2 xc, T2 yc ) noexcept
2095 T1 dx = T1( x ) - T1( xc );
2096 T1 dy = T1( y ) - T1( yc );
2097 x = (long)
RoundInt( T1( xc ) + ca*dx - sa*dy );
2098 y = (long)
RoundInt( T1( yc ) + sa*dx + ca*dy );
2111 template <
typename T1,
typename T2>
2114 T1 dx = T1( x ) - T1( xc );
2115 T1 dy = T1( y ) - T1( yc );
2135 template <
typename T,
typename T1,
typename T2>
2136 inline void Rotate( T& x, T& y, T1 a, T2 xc, T2 yc ) noexcept
2138 T1 sa, ca;
SinCos( a, sa, ca );
Rotate( x, y, sa, ca, xc, yc );
2143 template <
typename T,
typename P,
typename N>
inline
2144 N __pcl_norm(
const T* i,
const T* j,
const P& p, N* ) noexcept
2146 PCL_PRECONDITION( p > P( 0 ) )
2148 for ( ; i < j; ++i )
2149 n +=
Pow(
Abs( N( *i ) ), N( p ) );
2150 return
Pow( n, N( 1/p ) );
2166 template <typename T, typename P> inline T
Norm( const T* i, const T* j, const P& p ) noexcept
2168 return __pcl_norm( i, j, p, (T*)( 0 ) );
2171 template <
typename P>
inline double Norm(
const float* i,
const float* j,
const P& p ) noexcept
2173 return __pcl_norm( i, j, p, (
double*)( 0 ) );
2175 template <
typename P>
inline double Norm(
const int* i,
const int* j,
const P& p ) noexcept
2177 return __pcl_norm( i, j, p, (
double*)( 0 ) );
2179 template <
typename P>
inline double Norm(
const unsigned* i,
const unsigned* j,
const P& p ) noexcept
2181 return __pcl_norm( i, j, p, (
double*)( 0 ) );
2183 template <
typename P>
inline double Norm(
const int8* i,
const int8* j,
const P& p ) noexcept
2185 return __pcl_norm( i, j, p, (
double*)( 0 ) );
2187 template <
typename P>
inline double Norm(
const uint8* i,
const uint8* j,
const P& p ) noexcept
2189 return __pcl_norm( i, j, p, (
double*)( 0 ) );
2191 template <
typename P>
inline double Norm(
const int16* i,
const int16* j,
const P& p ) noexcept
2193 return __pcl_norm( i, j, p, (
double*)( 0 ) );
2195 template <
typename P>
inline double Norm(
const uint16* i,
const uint16* j,
const P& p ) noexcept
2197 return __pcl_norm( i, j, p, (
double*)( 0 ) );
2199 template <
typename P>
inline double Norm(
const int64* i,
const int64* j,
const P& p ) noexcept
2201 return __pcl_norm( i, j, p, (
double*)( 0 ) );
2203 template <
typename P>
inline double Norm(
const uint64* i,
const uint64* j,
const P& p ) noexcept
2205 return __pcl_norm( i, j, p, (
double*)( 0 ) );
2210 template <
typename T,
typename N>
inline
2211 N __pcl_l1norm(
const T* i,
const T* j, N* ) noexcept
2214 for ( ; i < j; ++i )
2215 n += N(
Abs( *i ) );
2225 template <
typename T>
inline T
L1Norm(
const T* i,
const T* j ) noexcept
2227 return __pcl_l1norm( i, j, (T*)( 0 ) );
2230 inline double L1Norm(
const float* i,
const float* j ) noexcept
2232 return __pcl_l1norm( i, j, (
double*)( 0 ) );
2234 inline double L1Norm(
const int* i,
const int* j ) noexcept
2236 return __pcl_l1norm( i, j, (
double*)( 0 ) );
2238 inline double L1Norm(
const unsigned* i,
const unsigned* j ) noexcept
2240 return __pcl_l1norm( i, j, (
double*)( 0 ) );
2244 return __pcl_l1norm( i, j, (
double*)( 0 ) );
2248 return __pcl_l1norm( i, j, (
double*)( 0 ) );
2252 return __pcl_l1norm( i, j, (
double*)( 0 ) );
2256 return __pcl_l1norm( i, j, (
double*)( 0 ) );
2260 return __pcl_l1norm( i, j, (
double*)( 0 ) );
2264 return __pcl_l1norm( i, j, (
double*)( 0 ) );
2269 template <
typename T,
typename N>
inline
2270 N __pcl_l2norm(
const T* i,
const T* j, N* ) noexcept
2273 for ( ; i < j; ++i )
2274 n += N( *i ) * N( *i );
2284 template <
typename T>
inline T
L2Norm(
const T* i,
const T* j ) noexcept
2286 return __pcl_l2norm( i, j, (T*)( 0 ) );
2289 inline double L2Norm(
const float* i,
const float* j ) noexcept
2291 return __pcl_l2norm( i, j, (
double*)( 0 ) );
2293 inline double L2Norm(
const int* i,
const int* j ) noexcept
2295 return __pcl_l2norm( i, j, (
double*)( 0 ) );
2297 inline double L2Norm(
const unsigned* i,
const unsigned* j ) noexcept
2299 return __pcl_l2norm( i, j, (
double*)( 0 ) );
2303 return __pcl_l2norm( i, j, (
double*)( 0 ) );
2307 return __pcl_l2norm( i, j, (
double*)( 0 ) );
2311 return __pcl_l2norm( i, j, (
double*)( 0 ) );
2315 return __pcl_l2norm( i, j, (
double*)( 0 ) );
2319 return __pcl_l2norm( i, j, (
double*)( 0 ) );
2323 return __pcl_l2norm( i, j, (
double*)( 0 ) );
2334 template <
typename T>
inline T
Norm(
const T* i,
const T* j ) noexcept
2339 inline double Norm(
const float* i,
const float* j ) noexcept
2341 return __pcl_l2norm( i, j, (
double*)( 0 ) );
2343 inline double Norm(
const int* i,
const int* j ) noexcept
2345 return __pcl_l2norm( i, j, (
double*)( 0 ) );
2347 inline double Norm(
const unsigned* i,
const unsigned* j ) noexcept
2349 return __pcl_l2norm( i, j, (
double*)( 0 ) );
2351 inline double Norm(
const int8* i,
const int8* j ) noexcept
2353 return __pcl_l2norm( i, j, (
double*)( 0 ) );
2357 return __pcl_l2norm( i, j, (
double*)( 0 ) );
2361 return __pcl_l2norm( i, j, (
double*)( 0 ) );
2365 return __pcl_l2norm( i, j, (
double*)( 0 ) );
2369 return __pcl_l2norm( i, j, (
double*)( 0 ) );
2373 return __pcl_l2norm( i, j, (
double*)( 0 ) );
2418 void PCL_FUNC
CalendarTimeToJD(
int& jdi,
double& jdf,
int year,
int month,
int day,
double dayf = 0 ) noexcept;
2497 void PCL_FUNC
JDToCalendarTime(
int& year,
int& month,
int& day,
double& dayf,
int jdi,
double jdf ) noexcept;
2528 inline void JDToCalendarTime(
int& year,
int& month,
int& day,
double& dayf,
double jd ) noexcept
2555 template <
typename S1,
typename S2,
typename S3,
typename D>
2558 double t1 =
Abs( d );
2559 double t2 =
Frac( t1 )*60;
2560 double t3 =
Frac( t2 )*60;
2561 sign = (d < 0) ? -1 : +1;
2577 template <
typename S1,
typename S2,
typename S3>
2578 inline double SexagesimalToDecimal(
int sign,
const S1& s1,
const S2& s2 = S2( 0 ),
const S3& s3 = S3( 0 ) ) noexcept
2580 double d =
Abs( s1 ) + (s2 + s3/60)/60;
2581 return (sign < 0) ? -d : d;
2604 template <
typename T>
inline double Sum(
const T* __restrict__ i,
const T* __restrict__ j ) noexcept
2608 sum += double( *i++ );
2623 template <
typename T>
inline double StableSum(
const T* __restrict__ i,
const T* __restrict__ j ) noexcept
2629 double y = double( *i++ ) - eps;
2631 eps = (t - sum) - y;
2648 template <
typename T>
inline double Modulus(
const T* __restrict__ i,
const T* __restrict__ j ) noexcept
2652 S +=
Abs(
double( *i++ ) );
2667 template <
typename T>
inline double StableModulus(
const T* __restrict__ i,
const T* __restrict__ j ) noexcept
2673 double y =
Abs(
double( *i++ ) ) - eps;
2675 eps = (t - sum) - y;
2692 template <
typename T>
inline double SumOfSquares(
const T* __restrict__ i,
const T* __restrict__ j ) noexcept
2697 double f = double( *i++ );
2714 template <
typename T>
inline double StableSumOfSquares(
const T* __restrict__ i,
const T* __restrict__ j ) noexcept
2720 double f = double( *i++ );
2721 double y = f*f - eps;
2723 eps = (t - sum) - y;
2740 template <
typename T>
inline double Mean(
const T* __restrict__ i,
const T* __restrict__ j ) noexcept
2745 return Sum( i, j )/n;
2759 template <
typename T>
inline double StableMean(
const T* __restrict__ i,
const T* __restrict__ j ) noexcept
2784 template <
typename T>
inline double Variance(
const T* __restrict__ i,
const T* __restrict__ j,
double center ) noexcept
2789 double var = 0, eps = 0;
2792 double d = double( *i++ ) - center;
2797 return (var - eps*eps/n)/(n - 1);
2816 template <
typename T>
inline double Variance(
const T* __restrict__ i,
const T* __restrict__ j ) noexcept
2822 for (
const T* f = i; f < j; ++f )
2825 double var = 0, eps = 0;
2828 double d = double( *i++ ) - m;
2833 return (var - eps*eps/n)/(n - 1);
2844 template <
typename T>
inline double StdDev(
const T* __restrict__ i,
const T* __restrict__ j,
double center ) noexcept
2856 template <
typename T>
inline double StdDev(
const T* __restrict__ i,
const T* __restrict__ j ) noexcept
2917 template <
class T>
inline double Median(
const T* __restrict__ i,
const T* __restrict__ j,
double eps = 0 )
2923 return double( *i );
2924 double* d =
new double[ n ];
2925 double* __restrict__ t = d;
2927 *t++ = double( *i++ );
2929 double m = double( *
pcl::Select( d, t, n >> 1 ) );
2931 m = (m + double( *
pcl::Select( d, t, (n >> 1)-1 ) ))/2;
2936 double PCL_FUNC
Median(
const unsigned char* __restrict__ i,
const unsigned char* __restrict__ j,
double eps = 0 );
2937 double PCL_FUNC
Median(
const signed char* __restrict__ i,
const signed char* __restrict__ j,
double eps = 0 );
2938 double PCL_FUNC
Median(
const wchar_t* __restrict__ i,
const wchar_t* __restrict__ j,
double eps = 0 );
2939 double PCL_FUNC
Median(
const unsigned short* __restrict__ i,
const unsigned short* __restrict__ j,
double eps = 0 );
2940 double PCL_FUNC
Median(
const signed short* __restrict__ i,
const signed short* __restrict__ j,
double eps = 0 );
2941 double PCL_FUNC
Median(
const unsigned int* __restrict__ i,
const unsigned int* __restrict__ j,
double eps = 0 );
2942 double PCL_FUNC
Median(
const signed int* __restrict__ i,
const signed int* __restrict__ j,
double eps = 0 );
2943 double PCL_FUNC
Median(
const unsigned long* __restrict__ i,
const unsigned long* __restrict__ j,
double eps = 0 );
2944 double PCL_FUNC
Median(
const signed long* __restrict__ i,
const signed long* __restrict__ j,
double eps = 0 );
2945 double PCL_FUNC
Median(
const unsigned long long* __restrict__ i,
const unsigned long long* __restrict__ j,
double eps = 0 );
2946 double PCL_FUNC
Median(
const signed long long* __restrict__ i,
const signed long long* __restrict__ j,
double eps = 0 );
2947 double PCL_FUNC
Median(
const float* __restrict__ i,
const float* __restrict__ j,
double eps = 0 );
2948 double PCL_FUNC
Median(
const double* __restrict__ i,
const double* __restrict__ j,
double eps = 0 );
2949 double PCL_FUNC
Median(
const long double* __restrict__ i,
const long double* __restrict__ j,
double eps = 0 );
2951 #define __PCL_SMALL_MEDIAN_MAX_LENGTH 32
2953 double PCL_FUNC SmallMedianDestructive(
unsigned char* __restrict__ i,
unsigned char* __restrict__ j );
2954 double PCL_FUNC SmallMedianDestructive(
signed char* __restrict__ i,
signed char* __restrict__ j );
2955 double PCL_FUNC SmallMedianDestructive(
wchar_t* __restrict__ i,
wchar_t* __restrict__ j );
2956 double PCL_FUNC SmallMedianDestructive(
unsigned short* __restrict__ i,
unsigned short* __restrict__ j );
2957 double PCL_FUNC SmallMedianDestructive(
signed short* __restrict__ i,
signed short* __restrict__ j );
2958 double PCL_FUNC SmallMedianDestructive(
unsigned int* __restrict__ i,
unsigned int* __restrict__ j );
2959 double PCL_FUNC SmallMedianDestructive(
signed int* __restrict__ i,
signed int* __restrict__ j );
2960 double PCL_FUNC SmallMedianDestructive(
unsigned long* __restrict__ i,
unsigned long* __restrict__ j );
2961 double PCL_FUNC SmallMedianDestructive(
signed long* __restrict__ i,
signed long* __restrict__ j );
2962 double PCL_FUNC SmallMedianDestructive(
unsigned long long* __restrict__ i,
unsigned long long* __restrict__ j );
2963 double PCL_FUNC SmallMedianDestructive(
signed long long* __restrict__ i,
signed long long* __restrict__ j );
2964 double PCL_FUNC SmallMedianDestructive(
float* __restrict__ i,
float* __restrict__ j );
2965 double PCL_FUNC SmallMedianDestructive(
double* __restrict__ i,
double* __restrict__ j );
2966 double PCL_FUNC SmallMedianDestructive(
long double* __restrict__ i,
long double* __restrict__ j );
2968 #define CMPXCHG( a, b ) \
2969 if ( i[b] < i[a] ) pcl::Swap( i[a], i[b] )
2971 #define MEAN( a, b ) \
2972 (double( a ) + double( b ))/2
3016 template <
typename T>
inline double MedianDestructive( T* __restrict__ i, T* __restrict__ j ) noexcept
3027 return MEAN( i[0], i[1] );
3029 CMPXCHG( 0, 1 ); CMPXCHG( 1, 2 );
3032 CMPXCHG( 0, 1 ); CMPXCHG( 2, 3 ); CMPXCHG( 0, 2 );
3034 return MEAN( i[1], i[2] );
3036 CMPXCHG( 0, 1 ); CMPXCHG( 3, 4 ); CMPXCHG( 0, 3 );
3037 CMPXCHG( 1, 4 ); CMPXCHG( 1, 2 ); CMPXCHG( 2, 3 );
3040 CMPXCHG( 0, 1 ); CMPXCHG( 2, 3 ); CMPXCHG( 0, 2 );
3041 CMPXCHG( 1, 3 ); CMPXCHG( 1, 2 ); CMPXCHG( 4, 5 );
3042 CMPXCHG( 0, 4 ); CMPXCHG( 1, 5 ); CMPXCHG( 1, 4 );
3043 CMPXCHG( 2, 4 ); CMPXCHG( 3, 5 ); CMPXCHG( 3, 4 );
3044 return MEAN( i[2], i[3] );
3046 CMPXCHG( 0, 5 ); CMPXCHG( 0, 3 ); CMPXCHG( 1, 6 );
3047 CMPXCHG( 2, 4 ); CMPXCHG( 0, 1 ); CMPXCHG( 3, 5 );
3048 CMPXCHG( 2, 6 ); CMPXCHG( 2, 3 ); CMPXCHG( 3, 6 );
3049 CMPXCHG( 4, 5 ); CMPXCHG( 1, 4 ); CMPXCHG( 1, 3 );
3052 CMPXCHG( 0, 4 ); CMPXCHG( 1, 5 ); CMPXCHG( 2, 6 );
3053 CMPXCHG( 3, 7 ); CMPXCHG( 0, 2 ); CMPXCHG( 1, 3 );
3054 CMPXCHG( 4, 6 ); CMPXCHG( 5, 7 ); CMPXCHG( 2, 4 );
3055 CMPXCHG( 3, 5 ); CMPXCHG( 0, 1 ); CMPXCHG( 2, 3 );
3056 CMPXCHG( 4, 5 ); CMPXCHG( 6, 7 ); CMPXCHG( 1, 4 );
3058 return MEAN( i[3], i[4] );
3060 CMPXCHG( 1, 2 ); CMPXCHG( 4, 5 ); CMPXCHG( 7, 8 );
3061 CMPXCHG( 0, 1 ); CMPXCHG( 3, 4 ); CMPXCHG( 6, 7 );
3062 CMPXCHG( 1, 2 ); CMPXCHG( 4, 5 ); CMPXCHG( 7, 8 );
3063 CMPXCHG( 0, 3 ); CMPXCHG( 5, 8 ); CMPXCHG( 4, 7 );
3064 CMPXCHG( 3, 6 ); CMPXCHG( 1, 4 ); CMPXCHG( 2, 5 );
3065 CMPXCHG( 4, 7 ); CMPXCHG( 4, 2 ); CMPXCHG( 6, 4 );
3069 double m = double( *
pcl::Select( i, j, n >> 1 ) );
3072 return MEAN( m,
double( *
pcl::Select( i, j, (n >> 1)-1 ) ) );
3079 #define CMPXCHG( a, b ) \
3080 if ( p( i[b], i[a] ) ) pcl::Swap( i[a], i[b] )
3097 template <
typename T,
class BP>
inline double MedianDestructive( T* __restrict__ i, T* __restrict__ j, BP p ) noexcept
3108 return MEAN( i[0], i[1] );
3110 CMPXCHG( 0, 1 ); CMPXCHG( 1, 2 );
3113 CMPXCHG( 0, 1 ); CMPXCHG( 2, 3 ); CMPXCHG( 0, 2 );
3115 return MEAN( i[1], i[2] );
3117 CMPXCHG( 0, 1 ); CMPXCHG( 3, 4 ); CMPXCHG( 0, 3 );
3118 CMPXCHG( 1, 4 ); CMPXCHG( 1, 2 ); CMPXCHG( 2, 3 );
3121 CMPXCHG( 0, 1 ); CMPXCHG( 2, 3 ); CMPXCHG( 0, 2 );
3122 CMPXCHG( 1, 3 ); CMPXCHG( 1, 2 ); CMPXCHG( 4, 5 );
3123 CMPXCHG( 0, 4 ); CMPXCHG( 1, 5 ); CMPXCHG( 1, 4 );
3124 CMPXCHG( 2, 4 ); CMPXCHG( 3, 5 ); CMPXCHG( 3, 4 );
3125 return MEAN( i[2], i[3] );
3127 CMPXCHG( 0, 5 ); CMPXCHG( 0, 3 ); CMPXCHG( 1, 6 );
3128 CMPXCHG( 2, 4 ); CMPXCHG( 0, 1 ); CMPXCHG( 3, 5 );
3129 CMPXCHG( 2, 6 ); CMPXCHG( 2, 3 ); CMPXCHG( 3, 6 );
3130 CMPXCHG( 4, 5 ); CMPXCHG( 1, 4 ); CMPXCHG( 1, 3 );
3133 CMPXCHG( 0, 4 ); CMPXCHG( 1, 5 ); CMPXCHG( 2, 6 );
3134 CMPXCHG( 3, 7 ); CMPXCHG( 0, 2 ); CMPXCHG( 1, 3 );
3135 CMPXCHG( 4, 6 ); CMPXCHG( 5, 7 ); CMPXCHG( 2, 4 );
3136 CMPXCHG( 3, 5 ); CMPXCHG( 0, 1 ); CMPXCHG( 2, 3 );
3137 CMPXCHG( 4, 5 ); CMPXCHG( 6, 7 ); CMPXCHG( 1, 4 );
3139 return MEAN( i[3], i[4] );
3141 CMPXCHG( 1, 2 ); CMPXCHG( 4, 5 ); CMPXCHG( 7, 8 );
3142 CMPXCHG( 0, 1 ); CMPXCHG( 3, 4 ); CMPXCHG( 6, 7 );
3143 CMPXCHG( 1, 2 ); CMPXCHG( 4, 5 ); CMPXCHG( 7, 8 );
3144 CMPXCHG( 0, 3 ); CMPXCHG( 5, 8 ); CMPXCHG( 4, 7 );
3145 CMPXCHG( 3, 6 ); CMPXCHG( 1, 4 ); CMPXCHG( 2, 5 );
3146 CMPXCHG( 4, 7 ); CMPXCHG( 4, 2 ); CMPXCHG( 6, 4 );
3150 double m = double( *
pcl::Select( i, j, n >> 1, p ) );
3153 return MEAN( m,
double( *
pcl::Select( i, j, (n >> 1)-1, p ) ) );
3205 if ( n < 1 || k < 0 || k >= n )
3208 return double( *i );
3209 double* d =
new double[ n ];
3212 *t++ = double( *i++ );
3219 double PCL_FUNC
OrderStatistic(
const unsigned char* __restrict__ i,
const unsigned char* __restrict__ j,
distance_type k,
double eps = 0 );
3220 double PCL_FUNC
OrderStatistic(
const signed char* __restrict__ i,
const signed char* __restrict__ j,
distance_type k,
double eps = 0 );
3222 double PCL_FUNC
OrderStatistic(
const unsigned short* __restrict__ i,
const unsigned short* __restrict__ j,
distance_type k,
double eps = 0 );
3223 double PCL_FUNC
OrderStatistic(
const signed short* __restrict__ i,
const signed short* __restrict__ j,
distance_type k,
double eps = 0 );
3224 double PCL_FUNC
OrderStatistic(
const unsigned int* __restrict__ i,
const unsigned int* __restrict__ j,
distance_type k,
double eps = 0 );
3225 double PCL_FUNC
OrderStatistic(
const signed int* __restrict__ i,
const signed int* __restrict__ j,
distance_type k,
double eps = 0 );
3226 double PCL_FUNC
OrderStatistic(
const unsigned long* __restrict__ i,
const unsigned long* __restrict__ j,
distance_type k,
double eps = 0 );
3227 double PCL_FUNC
OrderStatistic(
const signed long* __restrict__ i,
const signed long* __restrict__ j,
distance_type k,
double eps = 0 );
3228 double PCL_FUNC
OrderStatistic(
const unsigned long long* __restrict__ i,
const unsigned long long* __restrict__ j,
distance_type k,
double eps = 0 );
3229 double PCL_FUNC
OrderStatistic(
const signed long long* __restrict__ i,
const signed long long* __restrict__ j,
distance_type k,
double eps = 0 );
3232 double PCL_FUNC
OrderStatistic(
const long double* __restrict__ i,
const long double* __restrict__ j,
distance_type k,
double eps = 0 );
3264 if ( n < 1 || k < 0 || k >= n )
3267 return double( *i );
3286 if ( n < 1 || k < 0 || k >= n )
3289 return double( *i );
3312 return Sum( i, j )/n;
3319 double x = double( *i );
3324 return s/(n - l - h);
3351 return Sum( i, j )/n;
3358 double x = double( *i );
3363 return s/(n - l - h);
3389 return Sum( i, j )/n;
3396 double x = double( *i );
3401 return s/(n - l - h);
3432 return Sum( i, j )/n;
3439 double x = double( *i );
3444 return s/(n - l - h);
3468 template <
typename T>
inline double AvgDev(
const T* __restrict__ i,
const T* __restrict__ j,
double center ) noexcept
3475 d +=
Abs(
double( *i++ ) - center );
3500 template <
typename T>
inline double StableAvgDev(
const T* __restrict__ i,
const T* __restrict__ j,
double center ) noexcept
3509 double y =
Abs(
double( *i++ ) - center ) - eps;
3511 eps = (t - sum) - y;
3537 template <
typename T>
inline double AvgDev(
const T* __restrict__ i,
const T* __restrict__ j )
3542 double m =
Median( i, j );
3545 d +=
Abs(
double( *i++ ) - m );
3569 template <
typename T>
inline double StableAvgDev(
const T* __restrict__ i,
const T* __restrict__ j )
3624 template <
typename T1,
typename T2>
3626 :
low( double( l ) )
3627 ,
high( double( h ) )
3635 template <
typename T>
3649 return IsFinite(
low ) &&
low > std::numeric_limits<double>::epsilon()
3679 explicit operator double() const noexcept
3738 return {
low/e.low,
high/e.high };
3748 return {
Sqrt( e.low ),
Sqrt( e.high ) };
3757 double x_ = double( x );
3758 return {
Pow( e.low, x_ ),
Pow( e.high, x_ ) };
3783 double dl = 0, dh = 0;
3787 double x = double( *i++ );
3799 return { (nl > 1) ? dl/nl : 0.0,
3800 (nh > 1) ? dh/nh : 0.0 };
3844 template <
typename T>
inline double MAD(
const T* __restrict__ i,
const T* __restrict__ j,
double center,
double eps = 0 )
3849 double* d =
new double[ n ];
3852 *p++ =
Abs(
double( *i++ ) - center );
3859 double PCL_FUNC
MAD(
const unsigned char* __restrict__ i,
const unsigned char* __restrict__ j,
double center,
double eps = 0 );
3860 double PCL_FUNC
MAD(
const signed char* __restrict__ i,
const signed char* __restrict__ j,
double center,
double eps = 0 );
3861 double PCL_FUNC
MAD(
const wchar_t* __restrict__ i,
const wchar_t* __restrict__ j,
double center,
double eps = 0 );
3862 double PCL_FUNC
MAD(
const unsigned short* __restrict__ i,
const unsigned short* __restrict__ j,
double center,
double eps = 0 );
3863 double PCL_FUNC
MAD(
const signed short* __restrict__ i,
const signed short* __restrict__ j,
double center,
double eps = 0 );
3864 double PCL_FUNC
MAD(
const unsigned int* __restrict__ i,
const unsigned int* __restrict__ j,
double center,
double eps = 0 );
3865 double PCL_FUNC
MAD(
const signed int* __restrict__ i,
const signed int* __restrict__ j,
double center,
double eps = 0 );
3866 double PCL_FUNC
MAD(
const unsigned long* __restrict__ i,
const unsigned long* __restrict__ j,
double center,
double eps = 0 );
3867 double PCL_FUNC
MAD(
const signed long* __restrict__ i,
const signed long* __restrict__ j,
double center,
double eps = 0 );
3868 double PCL_FUNC
MAD(
const unsigned long long* __restrict__ i,
const unsigned long long* __restrict__ j,
double center,
double eps = 0 );
3869 double PCL_FUNC
MAD(
const signed long long* __restrict__ i,
const signed long long* __restrict__ j,
double center,
double eps = 0 );
3870 double PCL_FUNC
MAD(
const float* __restrict__ i,
const float* __restrict__ j,
double center,
double eps = 0 );
3871 double PCL_FUNC
MAD(
const double* __restrict__ i,
const double* __restrict__ j,
double center,
double eps = 0 );
3872 double PCL_FUNC
MAD(
const long double* __restrict__ i,
const long double* __restrict__ j,
double center,
double eps = 0 );
3891 template <
typename T>
inline double MAD(
const T* __restrict__ i,
const T* __restrict__ j,
double eps = 0 )
3918 double* d =
new double[ n ];
3919 double* __restrict__ p = d;
3920 double* __restrict__ q = d + n;
3923 double x = double( *i++ );
3936 TwoSidedEstimate PCL_FUNC
TwoSidedMAD(
const unsigned char* __restrict__ i,
const unsigned char* __restrict__ j,
double center,
double eps = 0 );
3937 TwoSidedEstimate PCL_FUNC
TwoSidedMAD(
const signed char* __restrict__ i,
const signed char* __restrict__ j,
double center,
double eps = 0 );
3938 TwoSidedEstimate PCL_FUNC
TwoSidedMAD(
const wchar_t* __restrict__ i,
const wchar_t* __restrict__ j,
double center,
double eps = 0 );
3939 TwoSidedEstimate PCL_FUNC
TwoSidedMAD(
const unsigned short* __restrict__ i,
const unsigned short* __restrict__ j,
double center,
double eps = 0 );
3940 TwoSidedEstimate PCL_FUNC
TwoSidedMAD(
const signed short* __restrict__ i,
const signed short* __restrict__ j,
double center,
double eps = 0 );
3941 TwoSidedEstimate PCL_FUNC
TwoSidedMAD(
const unsigned int* __restrict__ i,
const unsigned int* __restrict__ j,
double center,
double eps = 0 );
3942 TwoSidedEstimate PCL_FUNC
TwoSidedMAD(
const signed int* __restrict__ i,
const signed int* __restrict__ j,
double center,
double eps = 0 );
3943 TwoSidedEstimate PCL_FUNC
TwoSidedMAD(
const unsigned long* __restrict__ i,
const unsigned long* __restrict__ j,
double center,
double eps = 0 );
3944 TwoSidedEstimate PCL_FUNC
TwoSidedMAD(
const signed long* __restrict__ i,
const signed long* __restrict__ j,
double center,
double eps = 0 );
3945 TwoSidedEstimate PCL_FUNC
TwoSidedMAD(
const unsigned long long* __restrict__ i,
const unsigned long long* __restrict__ j,
double center,
double eps = 0 );
3946 TwoSidedEstimate PCL_FUNC
TwoSidedMAD(
const signed long long* __restrict__ i,
const signed long long* __restrict__ j,
double center,
double eps = 0 );
3947 TwoSidedEstimate PCL_FUNC
TwoSidedMAD(
const float* __restrict__ i,
const float* __restrict__ j,
double center,
double eps = 0 );
3948 TwoSidedEstimate PCL_FUNC
TwoSidedMAD(
const double* __restrict__ i,
const double* __restrict__ j,
double center,
double eps = 0 );
3949 TwoSidedEstimate PCL_FUNC
TwoSidedMAD(
const long double* __restrict__ i,
const long double* __restrict__ j,
double center,
double eps = 0 );
4004 template <
typename T>
double Sn( T* __restrict__ x, T* __restrict__ xn )
4018 double* a2 =
new double[ n ];
4019 a2[0] = double( x[n >> 1] ) - double( x[0] );
4034 while ( leftA < rightA )
4043 leftA = tryA + even;
4049 leftB = tryB + even;
4053 double medA = double( x[i-1] ) - double( x[i-2 - tryA + Amin] );
4054 double medB = double( x[tryB + i-1] ) - double( x[i-1] );
4058 leftB = tryB + even;
4061 leftA = tryA + even;
4067 a2[i-1] = double( x[leftB + i-1] ) - double( x[i-1] );
4070 double medA = double( x[i-1] ) - double( x[i-2 - leftA + Amin] );
4071 double medB = double( x[leftB + i-1] ) - double( x[i-1] );
4087 while ( leftA < rightA )
4096 leftA = tryA + even;
4102 leftB = tryB + even;
4106 double medA = double( x[i + tryA - Amin] ) - double( x[i-1] );
4107 double medB = double( x[i-1] ) - double( x[i-1 - tryB] );
4111 leftB = tryB + even;
4114 leftA = tryA + even;
4120 a2[i-1] = double( x[i-1] ) - double( x[i-1 - leftB] );
4123 double medA = double( x[i + leftA - Amin] ) - double( x[i-1] );
4124 double medB = double( x[i-1] ) - double( x[i-1 - leftB] );
4129 a2[n-1] = double( x[n-1] ) - double( x[nh-1] );
4137 case 2: cn = 0.743;
break;
4138 case 3: cn = 1.851;
break;
4139 case 4: cn = 0.954;
break;
4140 case 5: cn = 1.351;
break;
4141 case 6: cn = 0.993;
break;
4142 case 7: cn = 1.198;
break;
4143 case 8: cn = 1.005;
break;
4144 case 9: cn = 1.131;
break;
4145 default: cn = (n & 1) ? n/(n - 0.9) : 1.0;
break;
4180 else if ( a[i] == trial )
4183 if ( 2*(wrest + wleft) > wtotal )
4189 acand[kcand] = a[i];
4190 iwcand[kcand] = iw[i];
4197 if ( 2*(wrest + wleft + wmid) > wtotal )
4204 acand[kcand] = a[i];
4205 iwcand[kcand] = iw[i];
4209 wrest += wleft + wmid;
4250 template <
typename T>
double Qn( T* __restrict__ x, T* __restrict__ xn )
4256 double* y =
new double[ n ];
4257 double* work =
new double[ n ];
4258 double* acand =
new double[ n ];
4270 y[i] = double( x[i] );
4271 left[i] = n - i + 1;
4272 right[i] = (i <= h) ? n : n - i + h;
4288 if ( left[i] <= right[i] )
4290 weight[j] = right[i] - left[i] + 1;
4291 work[j] = double( y[i] ) - y[n - left[i] - (weight[j] >> 1)];
4294 qn = __pcl_whimed( work, weight, j, acand, iwcand );
4298 while ( j < n &&
double( y[i] ) - y[n-j-1] < qn )
4305 while (
double( y[i] ) - y[n-j+1] > qn )
4324 else if ( knew > sumQ )
4341 for (
distance_type jj = left[i]; jj <= right[i]; ++jj, ++j )
4342 work[j] =
double( y[i] ) - y[n-jj];
4352 case 2: dn = 0.399;
break;
4353 case 3: dn = 0.994;
break;
4354 case 4: dn = 0.512;
break;
4355 case 5: dn = 0.844;
break;
4356 case 6: dn = 0.611;
break;
4357 case 7: dn = 0.857;
break;
4358 case 8: dn = 0.669;
break;
4359 case 9: dn = 0.872;
break;
4360 default: dn = (n & 1) ? n/(n + 1.4) : n/(n + 3.8);
break;
4420 template <
typename T>
4422 double sigma,
int k = 9,
bool reducedLength =
false ) noexcept
4428 double kd = k * sigma;
4429 if ( kd < 0 || 1 + kd == 1 )
4432 double num = 0, den = 0;
4434 for ( ; x < xn; ++x )
4436 double xc = double( *x ) - center;
4441 double y21 = 1 - y2;
4442 num += xc*xc * y21*y21*y21*y21;
4443 den += y21 * (1 - 5*y2);
4449 return (1 + den != 1) ? (reducedLength ? nr : n)*num/den : 0.0;
4483 template <
typename T>
4485 const TwoSidedEstimate& sigma,
int k = 9,
bool reducedLength =
false ) noexcept
4487 double kd0 = k * sigma.
low;
4488 double kd1 = k * sigma.
high;
4489 if ( kd0 < 0 || 1 + kd0 == 1 || kd1 < 0 || 1 + kd1 == 1 )
4492 double num0 = 0, den0 = 0, num1 = 0, den1 = 0;
4493 size_type n0 = 0, n1 = 0, nr0 = 0, nr1 = 0;
4494 for ( ; x < xn; ++x )
4496 double xc = double( *x ) - center;
4503 double y = xc/(low ? kd0 : kd1);
4507 double y21 = 1 - y2;
4508 double num = xc*xc * y21*y21*y21*y21;
4509 double den = y21 * (1 - 5*y2);
4527 return { (n0 >= 2 && 1 + den0 != 1) ? (reducedLength ? nr0 : n0)*num0/den0 : 0.0,
4528 (n1 >= 2 && 1 + den1 != 1) ? (reducedLength ? nr1 : n1)*num1/den1 : 0.0 };
4559 template <
typename T>
4560 double BendMidvariance(
const T* __restrict__ x,
const T* __restrict__ xn,
double center,
double beta = 0.2 )
4566 beta =
Range( beta, 0.0, 0.5 );
4569 double* w =
new double[ n ];
4571 w[i] =
Abs(
double( x[i] ) - center );
4579 for ( ; x < xn; ++x )
4581 double y = (double( *x ) - center)/wb;
4582 double f =
Max( -1.0,
Min( 1.0, y ) );
4589 return (1 + den != 1) ? n*wb*wb*num/den : 0.0;
4620 inline double IncompleteBeta(
double a,
double b,
double x,
double eps = 1.0e-8 ) noexcept
4622 if ( x < 0 || x > 1 )
4623 return std::numeric_limits<double>::infinity();
4628 if ( x > (a + 1)/(a + b + 2) )
4634 double lbeta_ab = lgamma( a ) + lgamma( b ) - lgamma( a + b );
4635 double front =
Exp(
Ln( x )*a +
Ln( 1 - x )*b - lbeta_ab )/a;
4640 const double tiny = 1.0e-30;
4641 double f = 1, c = 1, d = 0;
4642 for (
int i = 0; i <= 200; ++i )
4647 numerator = -((a + m)*(a + b + m)*x)/((a + 2*m)*(a + 2*m + 1));
4649 numerator = (m*(b - m)*x)/((a + 2*m - 1)*(a + 2*m));
4656 d = 1 + numerator*d;
4657 if (
Abs( d ) < tiny )
4660 c = 1 + numerator/c;
4661 if (
Abs( c ) < tiny )
4665 if (
Abs( 1 - cd ) < eps )
4666 return front*(f - 1);
4670 return std::numeric_limits<double>::infinity();
4679 template <
typename T>
inline constexpr T
Erf( T x ) noexcept
4681 return std::erf( x );
4696 template <
typename T>
inline constexpr T
ErfInv( T x ) noexcept
4698 if ( x < -1 || x > 1 )
4699 return std::numeric_limits<T>::quiet_NaN();
4701 return std::numeric_limits<T>::infinity();
4703 return -std::numeric_limits<T>::infinity();
4705 const long double A0 = 1.1975323115670912564578e0L;
4706 const long double A1 = 4.7072688112383978012285e1L;
4707 const long double A2 = 6.9706266534389598238465e2L;
4708 const long double A3 = 4.8548868893843886794648e3L;
4709 const long double A4 = 1.6235862515167575384252e4L;
4710 const long double A5 = 2.3782041382114385731252e4L;
4711 const long double A6 = 1.1819493347062294404278e4L;
4712 const long double A7 = 8.8709406962545514830200e2L;
4714 const long double B0 = 1.0000000000000000000e0L;
4715 const long double B1 = 4.2313330701600911252e1L;
4716 const long double B2 = 6.8718700749205790830e2L;
4717 const long double B3 = 5.3941960214247511077e3L;
4718 const long double B4 = 2.1213794301586595867e4L;
4719 const long double B5 = 3.9307895800092710610e4L;
4720 const long double B6 = 2.8729085735721942674e4L;
4721 const long double B7 = 5.2264952788528545610e3L;
4723 const long double C0 = 1.42343711074968357734e0L;
4724 const long double C1 = 4.63033784615654529590e0L;
4725 const long double C2 = 5.76949722146069140550e0L;
4726 const long double C3 = 3.64784832476320460504e0L;
4727 const long double C4 = 1.27045825245236838258e0L;
4728 const long double C5 = 2.41780725177450611770e-1L;
4729 const long double C6 = 2.27238449892691845833e-2L;
4730 const long double C7 = 7.74545014278341407640e-4L;
4732 const long double D0 = 1.4142135623730950488016887e0L;
4733 const long double D1 = 2.9036514445419946173133295e0L;
4734 const long double D2 = 2.3707661626024532365971225e0L;
4735 const long double D3 = 9.7547832001787427186894837e-1L;
4736 const long double D4 = 2.0945065210512749128288442e-1L;
4737 const long double D5 = 2.1494160384252876777097297e-2L;
4738 const long double D6 = 7.7441459065157709165577218e-4L;
4739 const long double D7 = 1.4859850019840355905497876e-9L;
4741 const long double E0 = 6.65790464350110377720e0L;
4742 const long double E1 = 5.46378491116411436990e0L;
4743 const long double E2 = 1.78482653991729133580e0L;
4744 const long double E3 = 2.96560571828504891230e-1L;
4745 const long double E4 = 2.65321895265761230930e-2L;
4746 const long double E5 = 1.24266094738807843860e-3L;
4747 const long double E6 = 2.71155556874348757815e-5L;
4748 const long double E7 = 2.01033439929228813265e-7L;
4750 const long double F0 = 1.414213562373095048801689e0L;
4751 const long double F1 = 8.482908416595164588112026e-1L;
4752 const long double F2 = 1.936480946950659106176712e-1L;
4753 const long double F3 = 2.103693768272068968719679e-2L;
4754 const long double F4 = 1.112800997078859844711555e-3L;
4755 const long double F5 = 2.611088405080593625138020e-5L;
4756 const long double F6 = 2.010321207683943062279931e-7L;
4757 const long double F7 = 2.891024605872965461538222e-15L;
4759 long double abs_x =
Abs( x );
4761 if ( abs_x <= 0.85L )
4763 long double r = 0.180625L - 0.25L * x*x;
4764 long double num = (((((((A7*r + A6)*r + A5)*r + A4)*r + A3)*r + A2)*r + A1)*r + A0);
4765 long double den = (((((((B7*r + B6)*r + B5)*r + B4)*r + B3)*r + B2)*r + B1)*r + B0);
4766 return T( x * num/den );
4769 long double r =
Sqrt(
Ln2() -
Ln( 1 - abs_x ) );
4770 long double num = 0, den = 0;
4774 num = (((((((C7*r + C6)*r + C5)*r + C4)*r + C3)*r + C2)*r + C1)*r + C0);
4775 den = (((((((D7*r + D6)*r + D5)*r + D4)*r + D3)*r + D2)*r + D1)*r + D0);
4780 num = (((((((E7*r + E6)*r + E5)*r + E4)*r + E3)*r + E2)*r + E1)*r + E0);
4781 den = (((((((F7*r + F6)*r + F5)*r + F4)*r + F3)*r + F2)*r + F1)*r + F0);
4784 return T( std::copysign( num/den, x ) );
4832 #define PRIME64_1 11400714785074694791ULL
4833 #define PRIME64_2 14029467366897019727ULL
4834 #define PRIME64_3 1609587929392839161ULL
4835 #define PRIME64_4 9650029242287828579ULL
4836 #define PRIME64_5 2870177450012600261ULL
4839 const uint8* end = p + size;
4847 const uint8* limit = end - 32;
4848 uint64 v1 = seed + PRIME64_1 + PRIME64_2;
4849 uint64 v2 = seed + PRIME64_2;
4851 uint64 v4 = seed - PRIME64_1;
4855 v1 += *(
uint64*)p * PRIME64_2;
4857 v1 =
RotL( v1, 31 );
4859 v2 += *(
uint64*)p * PRIME64_2;
4861 v2 =
RotL( v2, 31 );
4863 v3 += *(
uint64*)p * PRIME64_2;
4865 v3 =
RotL( v3, 31 );
4867 v4 += *(
uint64*)p * PRIME64_2;
4869 v4 =
RotL( v4, 31 );
4872 while ( p <= limit );
4877 v1 =
RotL( v1, 31 );
4880 h64 = h64 * PRIME64_1 + PRIME64_4;
4883 v2 =
RotL( v2, 31 );
4886 h64 = h64 * PRIME64_1 + PRIME64_4;
4889 v3 =
RotL( v3, 31 );
4892 h64 = h64 * PRIME64_1 + PRIME64_4;
4895 v4 =
RotL( v4, 31 );
4898 h64 = h64 * PRIME64_1 + PRIME64_4;
4902 h64 = seed + PRIME64_5;
4907 while ( p+8 <= end )
4911 k1 =
RotL( k1, 31 );
4914 h64 =
RotL( h64, 27 ) * PRIME64_1 + PRIME64_4;
4921 h64 =
RotL( h64, 23 ) * PRIME64_2 + PRIME64_3;
4927 h64 ^= *p * PRIME64_5;
4928 h64 =
RotL( h64, 11 ) * PRIME64_1;
4986 #define PRIME32_1 2654435761U
4987 #define PRIME32_2 2246822519U
4988 #define PRIME32_3 3266489917U
4989 #define PRIME32_4 668265263U
4990 #define PRIME32_5 374761393U
4993 const uint8* end = p + size;
5001 const uint8* limit = end - 16;
5002 uint32 v1 = seed + PRIME32_1 + PRIME32_2;
5003 uint32 v2 = seed + PRIME32_2;
5005 uint32 v4 = seed - PRIME32_1;
5009 v1 += *(
uint32*)p * PRIME32_2;
5010 v1 =
RotL( v1, 13 );
5013 v2 += *(
uint32*)p * PRIME32_2;
5014 v2 =
RotL( v2, 13 );
5017 v3 += *(
uint32*)p * PRIME32_2;
5018 v3 =
RotL( v3, 13 );
5021 v4 += *(
uint32*)p * PRIME32_2;
5022 v4 =
RotL( v4, 13 );
5026 while ( p <= limit );
5032 h32 = seed + PRIME32_5;
5037 while ( p+4 <= end )
5039 h32 += *(
uint32*)p * PRIME32_3;
5040 h32 =
RotL( h32, 17 ) * PRIME32_4 ;
5046 h32 += *p * PRIME32_5;
5047 h32 =
RotL( h32, 11 ) * PRIME32_1 ;
Complex< T1 > Pow(const Complex< T1 > &c, T2 x) noexcept
Complex< T > Sqrt(const Complex< T > &c) noexcept
Complex< T > Exp(const Complex< T > &c) noexcept
Complex< T > Log(const Complex< T > &c) noexcept
Complex< T > Ln(const Complex< T > &c) noexcept
T Abs(const Complex< T > &c) noexcept
Complex< T > Round(const Complex< T > &c) noexcept
Complex< T > Sinh(const Complex< T > &c) noexcept
Complex< T > Tanh(const Complex< T > &c) noexcept
Complex< T > Sin(const Complex< T > &c) noexcept
Complex< T > Cosh(const Complex< T > &c) noexcept
Complex< T > Cos(const Complex< T > &c) noexcept
Complex< T > Tan(const Complex< T > &c) noexcept
bool IsNegativeZero(float x) noexcept
bool IsFinite(float x) noexcept
int IsInfinity(float x) noexcept
bool IsNaN(float x) noexcept
uint64 Hash64(const void *data, size_type size, uint64 seed=0) noexcept
uint32 Hash32(const void *data, size_type size, uint32 seed=0) noexcept
int MaxSSEInstructionSetSupported() noexcept
constexpr T RadSec(T x) noexcept
void SinCos(T x, T &sx, T &cx) noexcept
T L1Norm(const T *i, const T *j) noexcept
constexpr T Mod2Pi(T x) noexcept
constexpr char SignChar(T x) noexcept
constexpr T AsRad(T x) noexcept
constexpr T ArcTan(T x) noexcept
constexpr long double Log2T() noexcept
constexpr T LogN(T n, T x) noexcept
constexpr T Norm2Pi(T x) noexcept
T RotL(T x, uint32 n) noexcept
constexpr T ModPi(T x) noexcept
constexpr int Sign(T x) noexcept
void Rotate(T &x, T &y, T1 sa, T1 ca, T2 xc, T2 yc) noexcept
constexpr T Hav(T x) noexcept
void PCL_FUNC CalendarTimeToJD(int &jdi, double &jdf, int year, int month, int day, double dayf=0) noexcept
void Frexp(T x, T &m, int &p) noexcept
constexpr T ArcCosh(T x) noexcept
constexpr T Frac(T x) noexcept
constexpr T SecRad(T x) noexcept
constexpr T Ceil(T x) noexcept
constexpr T ArcTanh(T x) noexcept
constexpr long double TwoPi() noexcept
void Split(T x, T &i, T &f) noexcept
constexpr T MasRad(T x) noexcept
T ArcTan2Pi(T y, T x) noexcept
double LnFactorial(int n) noexcept
constexpr T Cotan(T x) noexcept
int RoundIntArithmetic(T x) noexcept
int64 RoundInt64(double x) noexcept
constexpr T UasRad(T x) noexcept
int64 TruncI64(T x) noexcept
double SexagesimalToDecimal(int sign, const S1 &s1, const S2 &s2=S2(0), const S3 &s3=S3(0)) noexcept
void PCL_FUNC JDToCalendarTime(int &year, int &month, int &day, double &dayf, int jdi, double jdf) noexcept
constexpr T RadMin(T x) noexcept
T PowI(T x, int n) noexcept
constexpr T ArcSinh(T x) noexcept
constexpr long double Log2() noexcept
constexpr T Ldexp(T m, int p) noexcept
constexpr T ArcSin(T x) noexcept
constexpr T Rad(T x) noexcept
constexpr long double Ln2() noexcept
double Factorial(int n) noexcept
constexpr T ErfInv(T x) noexcept
constexpr T Angle(int d, T m) noexcept
void DecimalToSexagesimal(int &sign, S1 &s1, S2 &s2, S3 &s3, const D &d) noexcept
constexpr T Erf(T x) noexcept
T Poly(T x, C c, int n) noexcept
constexpr T ArcCos(T x) noexcept
int64 TruncInt64(T x) noexcept
int RoundInt(T x) noexcept
T Norm(const T *i, const T *j, const P &p) noexcept
constexpr T Mod(T x, T y) noexcept
constexpr T ArcHav(T x) noexcept
constexpr T MinRad(T x) noexcept
int TruncInt(T x) noexcept
T L2Norm(const T *i, const T *j) noexcept
constexpr T Floor(T x) noexcept
constexpr T Deg(T x) noexcept
int64 RoundInt64Arithmetic(double x) noexcept
constexpr long double Pi() noexcept
int RoundIntBanker(T x) noexcept
T RotR(T x, uint32 n) noexcept
constexpr T Pow2(T x) noexcept
constexpr long double Log2e() noexcept
unsigned long long uint64
RI Select(RI i, RI j, distance_type k)
double IncompleteBeta(double a, double b, double x, double eps=1.0e-8) noexcept
double TrimmedMeanDestructive(T *__restrict__ i, T *__restrict__ j, distance_type l=1, distance_type h=1) noexcept
double Qn(T *__restrict__ x, T *__restrict__ xn)
double BendMidvariance(const T *__restrict__ x, const T *__restrict__ xn, double center, double beta=0.2)
double StableModulus(const T *__restrict__ i, const T *__restrict__ j) noexcept
double MAD(const T *__restrict__ i, const T *__restrict__ j, double center, double eps=0)
double SumOfSquares(const T *__restrict__ i, const T *__restrict__ j) noexcept
double StableMean(const T *__restrict__ i, const T *__restrict__ j) noexcept
double TrimmedMean(const T *__restrict__ i, const T *__restrict__ j, distance_type l=1, distance_type h=1)
double MedianDestructive(T *__restrict__ i, T *__restrict__ j) noexcept
TwoSidedEstimate TwoSidedMAD(const T *__restrict__ i, const T *__restrict__ j, double center, double eps=0)
double StableSum(const T *__restrict__ i, const T *__restrict__ j) noexcept
double Variance(const T *__restrict__ i, const T *__restrict__ j, double center) noexcept
double TrimmedMeanOfSquaresDestructive(T *__restrict__ i, T *__restrict__ j, distance_type l=1, distance_type h=1) noexcept
TwoSidedEstimate TwoSidedBiweightMidvariance(const T *__restrict__ x, const T *__restrict__ xn, double center, const TwoSidedEstimate &sigma, int k=9, bool reducedLength=false) noexcept
double Sum(const T *__restrict__ i, const T *__restrict__ j) noexcept
double StableSumOfSquares(const T *__restrict__ i, const T *__restrict__ j) noexcept
double BiweightMidvariance(const T *__restrict__ x, const T *__restrict__ xn, double center, double sigma, int k=9, bool reducedLength=false) noexcept
double StdDev(const T *__restrict__ i, const T *__restrict__ j, double center) noexcept
double TrimmedMeanOfSquares(const T *__restrict__ i, const T *__restrict__ j, distance_type l=1, distance_type h=1)
double AvgDev(const T *__restrict__ i, const T *__restrict__ j, double center) noexcept
double Median(const T *__restrict__ i, const T *__restrict__ j, double eps=0)
double OrderStatisticDestructive(T *__restrict__ i, T *__restrict__ j, distance_type k) noexcept
double OrderStatistic(const T *__restrict__ i, const T *__restrict__ j, distance_type k, double eps=0)
double Mean(const T *__restrict__ i, const T *__restrict__ j) noexcept
double StableAvgDev(const T *__restrict__ i, const T *__restrict__ j, double center) noexcept
TwoSidedEstimate TwoSidedAvgDev(const T *__restrict__ i, const T *__restrict__ j, double center) noexcept
double Modulus(const T *__restrict__ i, const T *__restrict__ j) noexcept
double Sn(T *__restrict__ x, T *__restrict__ xn)
constexpr const T & Min(const T &a, const T &b) noexcept
constexpr const T & Range(const T &x, const T &a, const T &b) noexcept
constexpr const T & Max(const T &a, const T &b) noexcept
int64 RoundI64(double x) noexcept
Exponential function 10**n, n being a signed integer.
Exponential function 2**n, n being a signed integer.
Two-sided descriptive statistical estimate.
double Total() const noexcept
TwoSidedEstimate(TwoSidedEstimate &&)=default
bool IsValid() const noexcept
TwoSidedEstimate(const T1 &l, const T2 &h)
TwoSidedEstimate & operator*=(double x) noexcept
TwoSidedEstimate operator/(double x) const noexcept
double high
High estimate component.
TwoSidedEstimate(const T &x)
double Mean() const noexcept
TwoSidedEstimate(const TwoSidedEstimate &)=default
double low
Low estimate component.
TwoSidedEstimate operator*(double x) const noexcept
TwoSidedEstimate & operator=(const TwoSidedEstimate &)=default
TwoSidedEstimate()=default
TwoSidedEstimate & operator/=(double x) noexcept