23 #ifndef __IPSDKMATH_HISTOGRAM_H__ 24 #define __IPSDKMATH_HISTOGRAM_H__ 26 #include <IPSDKMath/Statistics/BaseHistogram.h> 27 #include <boost/type_traits.hpp> 35 template <ipBool g_bDataIntegral>
62 typename boost::enable_if_c<boost::is_arithmetic<T>::value,
64 initWithBinWidth(
const T firstHistoValue,
const T lastHistoValue,
74 typename boost::enable_if_c<boost::is_arithmetic<T>::value,
76 initWithNbClasses(
const T firstHistoValue,
const T lastHistoValue,
90 template <
typename IteratorType>
91 typename boost::enable_if_c<boost::has_dereference<IteratorType>::value,
93 initWithBinWidth(
const IteratorType& iterBegin,
94 const IteratorType& iterEnd,
95 const typename std::iterator_traits<IteratorType>::value_type firstHistoValue,
96 const typename std::iterator_traits<IteratorType>::value_type lastHistoValue,
97 const typename std::iterator_traits<IteratorType>::value_type binWidth,
110 template <
typename ContainerType>
111 typename boost::enable_if_c<boost::is_arithmetic<ContainerType>::value ==
false &&
112 boost::has_dereference<ContainerType>::value ==
false,
114 initWithBinWidth(
const ContainerType& coll,
115 const typename ContainerType::value_type firstHistoValue,
116 const typename ContainerType::value_type lastHistoValue,
117 const typename ContainerType::value_type binWidth,
127 template <
typename IteratorType>
128 typename boost::enable_if_c<boost::has_dereference<IteratorType>::value,
130 initWithBinWidth(
const IteratorType& iterBegin,
131 const IteratorType& iterEnd,
132 const typename std::iterator_traits<IteratorType>::value_type binWidth);
141 template <
typename ContainerType>
142 typename boost::enable_if_c<boost::is_arithmetic<ContainerType>::value ==
false &&
143 boost::has_dereference<ContainerType>::value ==
false,
145 initWithBinWidth(
const ContainerType& coll,
146 const typename ContainerType::value_type binWidth);
158 template <
typename IteratorType>
159 typename boost::enable_if_c<boost::has_dereference<IteratorType>::value,
161 initWithNbClasses(
const IteratorType& iterBegin,
162 const IteratorType& iterEnd,
163 const typename std::iterator_traits<IteratorType>::value_type firstHistoValue,
164 const typename std::iterator_traits<IteratorType>::value_type lastHistoValue,
178 template <
typename ContainerType>
179 typename boost::enable_if_c<boost::is_arithmetic<ContainerType>::value ==
false &&
180 boost::has_dereference<ContainerType>::value ==
false,
182 initWithNbClasses(
const ContainerType& coll,
183 const typename ContainerType::value_type firstHistoValue,
184 const typename ContainerType::value_type lastHistoValue,
195 template <
typename IteratorType>
196 typename boost::enable_if_c<boost::has_dereference<IteratorType>::value,
198 initWithNbClasses(
const IteratorType& iterBegin,
199 const IteratorType& iterEnd,
209 template <
typename ContainerType>
210 typename boost::enable_if_c<boost::is_arithmetic<ContainerType>::value ==
false &&
211 boost::has_dereference<ContainerType>::value ==
false,
213 initWithNbClasses(
const ContainerType& coll,
226 template <
typename IteratorType>
227 typename boost::enable_if_c<boost::has_dereference<IteratorType>::value,
229 insertData(
const IteratorType& iterBegin,
230 const IteratorType& iterEnd);
236 template <
typename ContainerType>
237 typename boost::enable_if_c<boost::is_arithmetic<ContainerType>::value ==
false &&
238 boost::has_dereference<ContainerType>::value ==
false,
240 insertData(
const ContainerType& coll);
246 template <
typename T>
247 typename boost::enable_if_c<boost::is_arithmetic<T>::value,
249 insertValue(
const T value);
258 inline ipBool areDataIntegral()
const;
269 template <ipBool g_bDataIntegral>
270 template <
typename T>
272 typename boost::enable_if_c<boost::is_arithmetic<T>::value,
void>::type
274 const T lastHistoValue,
279 BOOST_STATIC_ASSERT(boost::is_integral<T>::value == g_bDataIntegral);
282 updateHistogramParams(static_cast<ipReal64>(firstHistoValue),
283 static_cast<ipReal64>(lastHistoValue),
284 static_cast<ipReal64>(binWidth),
288 template <ipBool g_bDataIntegral>
289 template <
typename T>
291 typename boost::enable_if_c<boost::is_arithmetic<T>::value,
void>::type
293 const T lastHistoValue,
298 BOOST_STATIC_ASSERT(boost::is_integral<T>::value == g_bDataIntegral);
301 updateHistogramParams(static_cast<ipReal64>(firstHistoValue),
302 static_cast<ipReal64>(lastHistoValue),
307 template <ipBool g_bDataIntegral>
308 template <
typename IteratorType>
310 typename boost::enable_if_c<boost::has_dereference<IteratorType>::value,
313 const IteratorType& iterEnd,
314 const typename std::iterator_traits<IteratorType>::value_type firstHistoValue,
315 const typename std::iterator_traits<IteratorType>::value_type lastHistoValue,
316 const typename std::iterator_traits<IteratorType>::value_type binWidth,
320 typedef typename std::iterator_traits<IteratorType>::value_type T;
321 BOOST_STATIC_ASSERT(boost::is_arithmetic<T>::value);
322 BOOST_STATIC_ASSERT(boost::is_integral<T>::value == g_bDataIntegral);
325 updateHistogramParams(static_cast<ipReal64>(firstHistoValue),
326 static_cast<ipReal64>(lastHistoValue),
327 static_cast<ipReal64>(binWidth),
331 return insertData(iterBegin, iterEnd);
334 template <ipBool g_bDataIntegral>
335 template <
typename ContainerType>
337 typename boost::enable_if_c<boost::is_arithmetic<ContainerType>::value ==
false &&
338 boost::has_dereference<ContainerType>::value ==
false,
341 const typename ContainerType::value_type firstHistoValue,
342 const typename ContainerType::value_type lastHistoValue,
343 const typename ContainerType::value_type binWidth,
347 typedef typename ContainerType::value_type T;
348 BOOST_STATIC_ASSERT(boost::is_arithmetic<T>::value);
349 BOOST_STATIC_ASSERT(boost::is_integral<T>::value == g_bDataIntegral);
351 return initWithBinWidth(coll.begin(), coll.end(), firstHistoValue, lastHistoValue, binWidth, outOfBoundsPolicy);
354 template <ipBool g_bDataIntegral>
355 template <
typename IteratorType>
357 typename boost::enable_if_c<boost::has_dereference<IteratorType>::value,
360 const IteratorType& iterEnd,
361 const typename std::iterator_traits<IteratorType>::value_type binWidth)
364 typedef typename std::iterator_traits<IteratorType>::value_type T;
365 BOOST_STATIC_ASSERT(boost::is_arithmetic<T>::value);
366 BOOST_STATIC_ASSERT(boost::is_integral<T>::value == g_bDataIntegral);
369 T firstHistoValue, lastHistoValue;
370 extractMinMax(iterBegin, iterEnd, firstHistoValue, lastHistoValue);
373 initWithBinWidth(iterBegin, iterEnd, firstHistoValue, lastHistoValue, binWidth);
376 template <ipBool g_bDataIntegral>
377 template <
typename ContainerType>
379 typename boost::enable_if_c<boost::is_arithmetic<ContainerType>::value ==
false &&
380 boost::has_dereference<ContainerType>::value ==
false,
383 const typename ContainerType::value_type binWidth)
386 typedef typename ContainerType::value_type T;
387 BOOST_STATIC_ASSERT(boost::is_arithmetic<T>::value);
388 BOOST_STATIC_ASSERT(boost::is_integral<T>::value == g_bDataIntegral);
390 initWithBinWidth(coll.begin(), coll.end(), binWidth);
393 template <ipBool g_bDataIntegral>
394 template <
typename IteratorType>
396 typename boost::enable_if_c<boost::has_dereference<IteratorType>::value,
399 const IteratorType& iterEnd,
400 const typename std::iterator_traits<IteratorType>::value_type firstHistoValue,
401 const typename std::iterator_traits<IteratorType>::value_type lastHistoValue,
406 typedef typename std::iterator_traits<IteratorType>::value_type T;
407 BOOST_STATIC_ASSERT(boost::is_arithmetic<T>::value);
408 BOOST_STATIC_ASSERT(boost::is_integral<T>::value == g_bDataIntegral);
411 updateHistogramParams(static_cast<ipReal64>(firstHistoValue),
412 static_cast<ipReal64>(lastHistoValue),
417 return insertData(iterBegin, iterEnd);
420 template <ipBool g_bDataIntegral>
421 template <
typename ContainerType>
423 typename boost::enable_if_c<boost::is_arithmetic<ContainerType>::value ==
false &&
424 boost::has_dereference<ContainerType>::value ==
false,
427 const typename ContainerType::value_type firstHistoValue,
428 const typename ContainerType::value_type lastHistoValue,
433 typedef typename ContainerType::value_type T;
434 BOOST_STATIC_ASSERT(boost::is_arithmetic<T>::value);
435 BOOST_STATIC_ASSERT(boost::is_integral<T>::value == g_bDataIntegral);
437 return initWithNbClasses(coll.begin(), coll.end(), firstHistoValue, lastHistoValue, nbClasses, outOfBoundsPolicy);
440 template <ipBool g_bDataIntegral>
441 template <
typename IteratorType>
443 typename boost::enable_if_c<boost::has_dereference<IteratorType>::value,
446 const IteratorType& iterEnd,
450 typedef typename std::iterator_traits<IteratorType>::value_type T;
451 BOOST_STATIC_ASSERT(boost::is_arithmetic<T>::value);
452 BOOST_STATIC_ASSERT(boost::is_integral<T>::value == g_bDataIntegral);
455 T firstHistoValue, lastHistoValue;
456 extractMinMax(iterBegin, iterEnd, firstHistoValue, lastHistoValue);
459 initWithNbClasses(iterBegin, iterEnd, firstHistoValue, lastHistoValue, nbClasses);
462 template <ipBool g_bDataIntegral>
463 template <
typename ContainerType>
465 typename boost::enable_if_c<boost::is_arithmetic<ContainerType>::value ==
false &&
466 boost::has_dereference<ContainerType>::value ==
false,
472 typedef typename ContainerType::value_type T;
473 BOOST_STATIC_ASSERT(boost::is_arithmetic<T>::value);
474 BOOST_STATIC_ASSERT(boost::is_integral<T>::value == g_bDataIntegral);
476 initWithNbClasses(coll.begin(), coll.end(), nbClasses);
479 template <ipBool g_bDataIntegral>
480 template <
typename IteratorType>
482 typename boost::enable_if_c<boost::has_dereference<IteratorType>::value,
485 const IteratorType& iterEnd)
488 typedef typename std::iterator_traits<IteratorType>::value_type T;
489 BOOST_STATIC_ASSERT(boost::is_arithmetic<T>::value);
490 BOOST_STATIC_ASSERT(boost::is_integral<T>::value == g_bDataIntegral);
496 clearCumulatedData();
500 IteratorType iter = iterBegin;
501 while (iter != iterEnd) {
504 if (insertDataInternal(static_cast<ipReal64>(*iter)) ==
true)
513 template <ipBool g_bDataIntegral>
514 template <
typename ContainerType>
516 typename boost::enable_if_c<boost::is_arithmetic<ContainerType>::value ==
false &&
517 boost::has_dereference<ContainerType>::value ==
false,
522 typedef typename ContainerType::value_type T;
523 BOOST_STATIC_ASSERT(boost::is_arithmetic<T>::value);
524 BOOST_STATIC_ASSERT(boost::is_integral<T>::value == g_bDataIntegral);
526 return insertData(coll.begin(), coll.end());
529 template <ipBool g_bDataIntegral>
530 template <
typename T>
532 typename boost::enable_if_c<boost::is_arithmetic<T>::value,
537 BOOST_STATIC_ASSERT(boost::is_integral<T>::value == g_bDataIntegral);
543 clearCumulatedData();
547 return insertDataInternal(value);
550 template <ipBool g_bDataIntegral>
554 return g_bDataIntegral;
563 #endif // __IPSDKMATH_HISTOGRAM_H__ #define IPSDK_DECLARE_SERIAL_WITH_COPY(libraryName, className)
macro enabling serialization on class
Definition: SerializationHdrMacro.h:73
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
void extractMinMax(const IteratorType &iterBegin, const IteratorType &iterEnd, typename std::iterator_traits< IteratorType >::value_type &minValue, typename std::iterator_traits< IteratorType >::value_type &maxValue)
function allowing to compute minimum and maximum value for a collection
Definition: BasicStatistics.h:35
uint64_t ipUInt64
Base types definition.
Definition: BaseTypes.h:55
ipBool areDataIntegral() const
check whether histogram data are integral
Definition: Histogram.h:552
Base class for histogram data management.
Definition: BaseHistogram.h:40
boost::enable_if_c< boost::has_dereference< IteratorType >::value, ipUInt64 >::type insertData(const IteratorType &iterBegin, const IteratorType &iterEnd)
method allowing to insert a set of data into histogram
boost::enable_if_c< boost::is_arithmetic< T >::value, void >::type initWithBinWidth(const T firstHistoValue, const T lastHistoValue, const T binWidth, const eHistogramOutOfBoundsPolicy &outOfBoundsPolicy=eHistogramOutOfBoundsPolicy::eHOOBP_Ignored)
initialization of histogram with a bin with value and for data type with integral type ...
#define IPSDKMATH_API
Import/Export macro for library IPSDKMath.
Definition: IPSDKMathExports.h:27
Class allowing to encapsulated histogram data and to compute several associated indicators.
Definition: Histogram.h:36
bool ipBool
Base types definition.
Definition: BaseTypes.h:47
eHistogramOutOfBoundsPolicy
enumerate use to describe histogram policy used to process out of bounds data
Definition: HistogramTypes.h:37
boost::enable_if_c< boost::is_arithmetic< T >::value, void >::type initWithNbClasses(const T firstHistoValue, const T lastHistoValue, const ipUInt32 nbClasses, const eHistogramOutOfBoundsPolicy &outOfBoundsPolicy=eHistogramOutOfBoundsPolicy::eHOOBP_Ignored)
initialization of histogram with a number of classes
Data with values not in [firstHistoValue, lastHistoValue] are ignored.
Definition: HistogramTypes.h:39
boost::enable_if_c< boost::is_arithmetic< T >::value, ipBool >::type insertValue(const T value)
method allowing to insert a single value into histogram
uint32_t ipUInt32
Base types definition.
Definition: BaseTypes.h:53