47 #include <visp3/core/vpMath.h>
48 #include <visp3/core/vpException.h>
51 #if defined(VISP_HAVE_FUNC__ISNAN)
55 #if !(defined(VISP_HAVE_FUNC_ISNAN) || defined(VISP_HAVE_FUNC_STD_ISNAN)) || !(defined(VISP_HAVE_FUNC_ISINF) || defined(VISP_HAVE_FUNC_STD_ISINF))
56 # if defined _MSC_VER || defined __BORLANDC__
57 typedef __int64 int64;
58 typedef unsigned __int64 uint64;
60 typedef int64_t int64;
61 typedef uint64_t uint64;
64 #ifndef DOXYGEN_SHOULD_SKIP_THIS
75 const double vpMath::ang_min_sinc = 1.0e-8;
76 const double vpMath::ang_min_mc = 2.5e-4;
86 #if defined(VISP_HAVE_FUNC_ISNAN)
88 #elif defined(VISP_HAVE_FUNC_STD_ISNAN)
89 return std::isnan(value);
90 #elif defined(VISP_HAVE_FUNC__ISNAN)
91 return (_isnan(value) != 0);
96 return (value != value);
101 return (((
unsigned)(ieee754.u >> 32) & 0x7fffffff) +
102 ((
unsigned)ieee754.u != 0) > 0x7ff00000) != 0;
113 #if defined(VISP_HAVE_FUNC_ISINF)
115 #elif defined(VISP_HAVE_FUNC_STD_ISINF)
116 return std::isinf(value);
117 #elif defined(VISP_HAVE_FUNC__FINITE)
118 return !_finite(value);
123 return ((
unsigned)(ieee754.u >> 32) & 0x7fffffff) == 0x7ff00000 &&
124 (unsigned)ieee754.u == 0;
139 if (fabs(x) < ang_min_mc)
return 0.5 ;
140 else return ((1.0-cosx)/x/x) ;
155 if (fabs(x) < ang_min_mc)
return (1./6.0) ;
156 else return ((1.0-sinx/x)/x/x) ;
170 if (fabs(x) < ang_min_sinc)
return 1.0 ;
171 else return sin(x)/x ;
185 if (fabs(x) < ang_min_sinc)
return 1.0 ;
186 else return (sinx/x) ;
203 size_t size = v.size();
205 sum = std::accumulate(v.begin(), v.end(), 0.0);
207 return sum / (double) size;
223 std::vector<double> v_copy = v;
224 size_t size = v_copy.size();
227 sort(v_copy.begin(), v_copy.end());
228 median = (v_copy[size / 2 - 1] + v_copy[size / 2]) / 2.0;
230 std::nth_element(v_copy.begin(), v_copy.begin() + (int) (size/2), v_copy.end());
231 median = v_copy[size/2];
252 std::vector<double> diff(v.size());
253 std::transform(v.begin(), v.end(), diff.begin(),
254 std::bind2nd(std::minus<double>(), mean));
255 double sq_sum = std::inner_product(diff.begin(), diff.end(), diff.begin(), 0.0);
256 double divisor = (double) v.size();
257 if(useBesselCorrection && v.size() > 1) {
261 return std::sqrt(sq_sum / divisor);
static double getStdev(const std::vector< double > &v, const bool useBesselCorrection=false)
static double getMedian(const std::vector< double > &v)
static bool isNaN(const double value)
error that can be emited by ViSP classes.
static bool isInf(const double value)
static double sinc(double x)
static double getMean(const std::vector< double > &v)
static double mcosc(double cosx, double x)
static double msinc(double sinx, double x)