File indexing completed on 2025-01-18 10:06:24
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083 #ifndef __FJCORE_HH__
0084 #define __FJCORE_HH__
0085 #define __FJCORE__
0086 #define __FJCORE_DROP_CGAL
0087 #ifndef _INCLUDE_FJCORE_CONFIG_AUTO_H
0088 #define _INCLUDE_FJCORE_CONFIG_AUTO_H 1
0089 #ifndef FJCORE_HAVE_AUTO_PTR_INTERFACE
0090 #endif
0091 #ifndef FJCORE_HAVE_CXX14_DEPRECATED
0092 #endif
0093 #ifndef FJCORE_HAVE_DLFCN_H
0094 # define FJCORE_HAVE_DLFCN_H 1
0095 #endif
0096 #ifndef FJCORE_HAVE_EXECINFO_H
0097 #endif
0098 #ifndef FJCORE_HAVE_EXPLICIT_FOR_OPERATORS
0099 #endif
0100 #ifndef FJCORE_HAVE_GNUCXX_DEPRECATED
0101 #endif
0102 #ifndef FJCORE_HAVE_INTTYPES_H
0103 # define FJCORE_HAVE_INTTYPES_H 1
0104 #endif
0105 #ifndef FJCORE_HAVE_LIBM
0106 # define FJCORE_HAVE_LIBM 1
0107 #endif
0108 #ifndef FJCORE_HAVE_MEMORY_H
0109 # define FJCORE_HAVE_MEMORY_H 1
0110 #endif
0111 #ifndef FJCORE_HAVE_OVERRIDE
0112 #endif
0113 #ifndef FJCORE_HAVE_STDINT_H
0114 # define FJCORE_HAVE_STDINT_H 1
0115 #endif
0116 #ifndef FJCORE_HAVE_STDLIB_H
0117 # define FJCORE_HAVE_STDLIB_H 1
0118 #endif
0119 #ifndef FJCORE_HAVE_STRINGS_H
0120 # define FJCORE_HAVE_STRINGS_H 1
0121 #endif
0122 #ifndef FJCORE_HAVE_STRING_H
0123 # define FJCORE_HAVE_STRING_H 1
0124 #endif
0125 #ifndef FJCORE_HAVE_SYS_STAT_H
0126 # define FJCORE_HAVE_SYS_STAT_H 1
0127 #endif
0128 #ifndef FJCORE_HAVE_SYS_TYPES_H
0129 # define FJCORE_HAVE_SYS_TYPES_H 1
0130 #endif
0131 #ifndef FJCORE_HAVE_UNISTD_H
0132 # define FJCORE_HAVE_UNISTD_H 1
0133 #endif
0134 #ifndef FJCORE_LT_OBJDIR
0135 # define FJCORE_LT_OBJDIR ".libs/"
0136 #endif
0137 #ifndef FJCORE_PACKAGE
0138 # define FJCORE_PACKAGE "fastjet"
0139 #endif
0140 #ifndef FJCORE_PACKAGE_BUGREPORT
0141 # define FJCORE_PACKAGE_BUGREPORT ""
0142 #endif
0143 #ifndef FJCORE_PACKAGE_NAME
0144 # define FJCORE_PACKAGE_NAME "FastJet"
0145 #endif
0146 #ifndef FJCORE_PACKAGE_STRING
0147 # define FJCORE_PACKAGE_STRING "FastJet 3.4.0"
0148 #endif
0149 #ifndef FJCORE_PACKAGE_TARNAME
0150 # define FJCORE_PACKAGE_TARNAME "fastjet"
0151 #endif
0152 #ifndef FJCORE_PACKAGE_URL
0153 # define FJCORE_PACKAGE_URL ""
0154 #endif
0155 #ifndef FJCORE_PACKAGE_VERSION
0156 # define FJCORE_PACKAGE_VERSION "3.4.0"
0157 #endif
0158 #ifndef FJCORE_STDC_HEADERS
0159 # define FJCORE_STDC_HEADERS 1
0160 #endif
0161 #ifndef FJCORE_VERSION
0162 # define FJCORE_VERSION "3.4.0"
0163 #endif
0164 #ifndef FJCORE_VERSION_MAJOR
0165 # define FJCORE_VERSION_MAJOR 3
0166 #endif
0167 #ifndef FJCORE_VERSION_MINOR
0168 # define FJCORE_VERSION_MINOR 4
0169 #endif
0170 #ifndef FJCORE_VERSION_NUMBER
0171 # define FJCORE_VERSION_NUMBER 30400
0172 #endif
0173 #ifndef FJCORE_VERSION_PATCHLEVEL
0174 # define FJCORE_VERSION_PATCHLEVEL 0
0175 #endif
0176 #endif
0177 #ifndef __FJCORE_CONFIG_H__
0178 #define __FJCORE_CONFIG_H__
0179 #endif
0180 #ifndef __FJCORE_FASTJET_BASE_HH__
0181 #define __FJCORE_FASTJET_BASE_HH__
0182 #define FJCORE_BEGIN_NAMESPACE namespace fjcore {
0183 #define FJCORE_END_NAMESPACE }
0184 #ifdef FJCORE_HAVE_OVERRIDE
0185 # define FJCORE_OVERRIDE override
0186 #else
0187 # define FJCORE_OVERRIDE
0188 #endif
0189 #endif
0190 #ifndef __FJCORE_THREAD_SAFETY_HELPERS_HH__
0191 #define __FJCORE_THREAD_SAFETY_HELPERS_HH__
0192 #include <limits>
0193 #ifdef FJCORE_HAVE_LIMITED_THREAD_SAFETY
0194 #include <atomic>
0195 FJCORE_BEGIN_NAMESPACE
0196 namespace thread_safety_helpers{
0197 template<typename T>
0198 class AtomicCounter{
0199 public:
0200 AtomicCounter() : _count{0}{}
0201 AtomicCounter(const T &count) : _count{count}{}
0202 AtomicCounter(const AtomicCounter &other) : _count{other._count.load()}{}
0203 operator T() const{ return _count.load();}
0204 T get() const{ return _count.load();}
0205 void set(const T new_value){
0206 _count.store(new_value);
0207 }
0208 T step(){
0209 T count = _count;
0210 while (_count < std::numeric_limits<T>::max()
0211 && !(_count.compare_exchange_strong(count, count+1)));
0212 return count;
0213 }
0214 inline T operator++(){
0215 return step()+1;
0216 }
0217 inline T operator++(int){
0218 return step();
0219 }
0220 private:
0221 std::atomic<T> _count;
0222 };
0223 class FirstTimeTrue{
0224 public:
0225 FirstTimeTrue(): _first_time{true}{}
0226 FirstTimeTrue(const FirstTimeTrue &other) : _first_time{other._first_time.load()}{}
0227 bool operator()(){
0228 bool expected = true;
0229 return _first_time.compare_exchange_strong(expected, false,
0230 std::memory_order_seq_cst,
0231 std::memory_order_relaxed);
0232 }
0233 private:
0234 std::atomic<bool> _first_time;
0235 };
0236 }
0237 FJCORE_END_NAMESPACE
0238 #else
0239 FJCORE_BEGIN_NAMESPACE
0240 namespace thread_safety_helpers{
0241 template<typename T>
0242 class AtomicCounter{
0243 public:
0244 AtomicCounter() : _count(0){}
0245 AtomicCounter(const T &count) : _count(count){}
0246 AtomicCounter(const AtomicCounter &other) : _count(other._count){}
0247 operator T() const{ return _count;}
0248 T get() const{ return _count;}
0249 void set(const T new_value){
0250 _count = new_value;
0251 }
0252 T step(){
0253 unsigned int count = _count;
0254 if (_count < std::numeric_limits<T>::max()){ _count++; }
0255 return count;
0256 }
0257 inline T operator++(){
0258 return step()+1;
0259 }
0260 inline T operator++(int){
0261 return step();
0262 }
0263 private:
0264 T _count;
0265 };
0266 class FirstTimeTrue{
0267 public:
0268 FirstTimeTrue(): _first_time(true){}
0269 bool operator()(){
0270 if (!_first_time) {return false;}
0271 _first_time = false;
0272 return true;
0273 }
0274 private:
0275 bool _first_time;
0276 };
0277 }
0278 FJCORE_END_NAMESPACE
0279 #endif
0280 #endif
0281 #ifndef __FJCORE_NUMCONSTS__
0282 #define __FJCORE_NUMCONSTS__
0283 FJCORE_BEGIN_NAMESPACE
0284 const double pi = 3.141592653589793238462643383279502884197;
0285 const double twopi = 6.283185307179586476925286766559005768394;
0286 const double pisq = 9.869604401089358618834490999876151135314;
0287 const double zeta2 = 1.644934066848226436472415166646025189219;
0288 const double zeta3 = 1.202056903159594285399738161511449990765;
0289 const double eulergamma = 0.577215664901532860606512090082402431042;
0290 const double ln2 = 0.693147180559945309417232121458176568076;
0291 FJCORE_END_NAMESPACE
0292 #endif
0293 #ifndef __FJCORE_INTERNAL_IS_BASE_HH__
0294 #define __FJCORE_INTERNAL_IS_BASE_HH__
0295 FJCORE_BEGIN_NAMESPACE
0296 template<typename T, T _t>
0297 struct integral_type{
0298 static const T value = _t;
0299 typedef T value_type;
0300 typedef integral_type<T,_t> type;
0301 };
0302 template<typename T, T _t>
0303 const T integral_type<T, _t>::value;
0304 typedef integral_type<bool, true> true_type;
0305 typedef integral_type<bool, false> false_type;
0306 typedef char (&__yes_type)[1];
0307 typedef char (&__no_type) [2];
0308 template<typename B, typename D>
0309 struct __inheritance_helper{
0310 #if !((_MSC_VER !=0 ) && (_MSC_VER == 1310))
0311 template <typename T>
0312 static __yes_type check_sig(D const volatile *, T);
0313 #else
0314 static __yes_type check_sig(D const volatile *, long);
0315 #endif
0316 static __no_type check_sig(B const volatile *, int);
0317 };
0318 template<typename B, typename D>
0319 struct IsBaseAndDerived{
0320 #if ((_MSC_FULL_VER != 0) && (_MSC_FULL_VER >= 140050000))
0321 #pragma warning(push)
0322 #pragma warning(disable:6334)
0323 #endif
0324 struct Host{
0325 #if !((_MSC_VER !=0 ) && (_MSC_VER == 1310))
0326 operator B const volatile *() const;
0327 #else
0328 operator B const volatile * const&() const;
0329 #endif
0330 operator D const volatile *();
0331 };
0332 static const bool value = ((sizeof(B)!=0) &&
0333 (sizeof(D)!=0) &&
0334 (sizeof(__inheritance_helper<B,D>::check_sig(Host(), 0)) == sizeof(__yes_type)));
0335 #if ((_MSC_FULL_VER != 0) && (_MSC_FULL_VER >= 140050000))
0336 #pragma warning(pop)
0337 #endif
0338 };
0339 template<class B, class D>
0340 B* cast_if_derived(D* d){
0341 return IsBaseAndDerived<B,D>::value ? (B*)(d) : 0;
0342 }
0343 FJCORE_END_NAMESPACE
0344 #endif
0345 #ifndef __FJCORE_FJCORE_DEPRECATED_HH__
0346 #define __FJCORE_FJCORE_DEPRECATED_HH__
0347 #ifndef SWIG
0348 #if defined(FJCORE_HAVE_CXX14_DEPRECATED) && (!defined(__FJCORE__))
0349 # define FJCORE_DEPRECATED(func) [[deprecated]] func
0350 # define FJCORE_DEPRECATED_MSG(message,func) [[deprecated(message)]] func
0351 #elif defined(FJCORE_HAVE_GNUCXX_DEPRECATED)
0352 # define FJCORE_DEPRECATED(func) func __attribute__((__deprecated__))
0353 # define FJCORE_DEPRECATED_MSG(message,func) func __attribute__((__deprecated__))
0354 #else
0355 # define FJCORE_DEPRECATED(func) func
0356 # define FJCORE_DEPRECATED_MSG(message,func) func
0357 #endif
0358 #else
0359 # define FJCORE_DEPRECATED(func) func
0360 # define FJCORE_DEPRECATED_MSG(message,func) func
0361 #endif
0362 #endif
0363 #ifndef __FJCORE_SHARED_PTR_HH__
0364 #define __FJCORE_SHARED_PTR_HH__
0365 #include <cstdlib> // for NULL!!!
0366 #ifdef FJCORE_HAVE_THREAD_SAFETY
0367 #include <atomic>
0368 #endif
0369 FJCORE_BEGIN_NAMESPACE
0370 #ifdef FJCORE_HAVE_THREAD_SAFETY
0371 template<class T>
0372 class SharedPtr{
0373 public:
0374 class __SharedCountingPtr;
0375 SharedPtr() : _ptr(NULL){}
0376 template<class Y> explicit SharedPtr(Y* ptr){
0377 _ptr = new __SharedCountingPtr(ptr);
0378 }
0379 SharedPtr(SharedPtr const & share) : _ptr(share._get_container()){
0380 if (_ptr!=NULL) (*_ptr)++;
0381 }
0382 ~SharedPtr(){
0383 if (_ptr==NULL) return;
0384 _decrease_count();
0385 }
0386 void reset(){
0387 SharedPtr().swap(*this);
0388 }
0389 template<class Y> void reset(Y * ptr){
0390 SharedPtr(ptr).swap(*this);
0391 }
0392 template<class Y> void reset(SharedPtr<Y> const & share){
0393 if (_ptr!=NULL){
0394 if (_ptr == share._get_container()) return;
0395 _decrease_count();
0396 }
0397 _ptr = share._get_container();
0398 if (_ptr!=NULL) (*_ptr)++;
0399 }
0400 SharedPtr& operator=(SharedPtr const & share){
0401 reset(share);
0402 return *this;
0403 }
0404 template<class Y> SharedPtr& operator=(SharedPtr<Y> const & share){
0405 reset(share);
0406 return *this;
0407 }
0408 inline T& operator*() const{
0409 return *(_ptr->get());
0410 }
0411 inline T* operator->() const{
0412 if (_ptr==NULL) return NULL;
0413 return _ptr->get();
0414 }
0415 inline T* get() const{
0416 if (_ptr==NULL) return NULL;
0417 return _ptr->get();
0418 }
0419 T* operator ()() const{
0420 if (_ptr==NULL) return NULL;
0421 return _ptr->get();
0422 }
0423 inline bool unique() const{
0424 return (use_count()==1);
0425 }
0426 inline long use_count() const{
0427 if (_ptr==NULL) return 0;
0428 return _ptr->use_count();
0429 }
0430 inline operator bool() const{
0431 return (get()!=NULL);
0432 }
0433 inline void swap(SharedPtr & share){
0434 __SharedCountingPtr* share_container = share._ptr;
0435 share._ptr = _ptr;
0436 _ptr = share_container;
0437 }
0438 void set_count(const long & count){
0439 if (_ptr==NULL) return;
0440 _ptr->set_count(count);
0441 }
0442 class __SharedCountingPtr : public std::atomic<long>{
0443 public:
0444 __SharedCountingPtr() : std::atomic<long>(0), _ptr(NULL){}
0445 template<class Y> explicit __SharedCountingPtr(Y* ptr)
0446 : std::atomic<long>(1), _ptr(ptr){}
0447 ~__SharedCountingPtr(){
0448 if (_ptr!=NULL){ delete _ptr;}
0449 }
0450 inline T* get() const {return _ptr;}
0451 inline long use_count() const {return (long)(*this);}
0452 inline void set_count(const long & count){ store(count);}
0453 private:
0454 T *_ptr;
0455 };
0456 private:
0457 inline __SharedCountingPtr* _get_container() const{
0458 return _ptr;
0459 }
0460 void _decrease_count(){
0461 if (((*_ptr)--) == 1)
0462 delete _ptr;
0463 }
0464 __SharedCountingPtr *_ptr;
0465 };
0466 template<class T,class U>
0467 inline bool operator==(SharedPtr<T> const & t, SharedPtr<U> const & u){
0468 return t.get() == u.get();
0469 }
0470 template<class T,class U>
0471 inline bool operator!=(SharedPtr<T> const & t, SharedPtr<U> const & u){
0472 return t.get() != u.get();
0473 }
0474 template<class T,class U>
0475 inline bool operator<(SharedPtr<T> const & t, SharedPtr<U> const & u){
0476 return t.get() < u.get();
0477 }
0478 template<class T>
0479 inline void swap(SharedPtr<T> & a, SharedPtr<T> & b){
0480 return a.swap(b);
0481 }
0482 template<class T>
0483 inline T* get_pointer(SharedPtr<T> const & t){
0484 return t.get();
0485 }
0486 #else
0487 template<class T>
0488 class SharedPtr{
0489 public:
0490 class __SharedCountingPtr;
0491 SharedPtr() : _ptr(NULL){}
0492 template<class Y> explicit SharedPtr(Y* ptr){
0493 _ptr = new __SharedCountingPtr(ptr);
0494 }
0495 SharedPtr(SharedPtr const & share) : _ptr(share._get_container()){
0496 if (_ptr!=NULL) ++(*_ptr);
0497 }
0498 ~SharedPtr(){
0499 if (_ptr==NULL) return;
0500 _decrease_count();
0501 }
0502 void reset(){
0503 SharedPtr().swap(*this);
0504 }
0505 template<class Y> void reset(Y * ptr){
0506 SharedPtr(ptr).swap(*this);
0507 }
0508 template<class Y> void reset(SharedPtr<Y> const & share){
0509 if (_ptr!=NULL){
0510 if (_ptr == share._get_container()) return;
0511 _decrease_count();
0512 }
0513 _ptr = share._get_container();
0514 if (_ptr!=NULL) ++(*_ptr);
0515 }
0516 SharedPtr& operator=(SharedPtr const & share){
0517 reset(share);
0518 return *this;
0519 }
0520 template<class Y> SharedPtr& operator=(SharedPtr<Y> const & share){
0521 reset(share);
0522 return *this;
0523 }
0524 FJCORE_DEPRECATED_MSG("Use SharedPtr<T>::get() instead",
0525 T* operator ()() const){
0526 if (_ptr==NULL) return NULL;
0527 return _ptr->get();
0528 }
0529 inline T& operator*() const{
0530 return *(_ptr->get());
0531 }
0532 inline T* operator->() const{
0533 if (_ptr==NULL) return NULL;
0534 return _ptr->get();
0535 }
0536 inline T* get() const{
0537 if (_ptr==NULL) return NULL;
0538 return _ptr->get();
0539 }
0540 inline bool unique() const{
0541 return (use_count()==1);
0542 }
0543 inline long use_count() const{
0544 if (_ptr==NULL) return 0;
0545 return _ptr->use_count();
0546 }
0547 #ifdef FJCORE_HAVE_EXPLICIT_FOR_OPERATORS
0548 explicit
0549 #endif
0550 inline operator bool() const{
0551 return (get()!=NULL);
0552 }
0553 inline void swap(SharedPtr & share){
0554 __SharedCountingPtr* share_container = share._ptr;
0555 share._ptr = _ptr;
0556 _ptr = share_container;
0557 }
0558 void set_count(const long & count){
0559 if (_ptr==NULL) return;
0560 _ptr->set_count(count);
0561 }
0562 class __SharedCountingPtr{
0563 public:
0564 __SharedCountingPtr() : _ptr(NULL), _count(0){}
0565 template<class Y> explicit __SharedCountingPtr(Y* ptr) : _ptr(ptr), _count(1){}
0566 ~__SharedCountingPtr(){
0567 if (_ptr!=NULL){ delete _ptr;}
0568 }
0569 inline T* get() const {return _ptr;}
0570 inline long use_count() const {return _count;}
0571 inline long operator++(){return ++_count;}
0572 inline long operator--(){return --_count;}
0573 inline long operator++(int){return _count++;}
0574 inline long operator--(int){return _count--;}
0575 void set_count(const long & count){
0576 _count = count;
0577 }
0578 private:
0579 T *_ptr;
0580 long _count;
0581 };
0582 private:
0583 inline __SharedCountingPtr* _get_container() const{
0584 return _ptr;
0585 }
0586 void _decrease_count(){
0587 (*_ptr)--;
0588 if (_ptr->use_count()==0)
0589 delete _ptr;
0590 }
0591 __SharedCountingPtr *_ptr;
0592 };
0593 template<class T,class U>
0594 inline bool operator==(SharedPtr<T> const & t, SharedPtr<U> const & u){
0595 return t.get() == u.get();
0596 }
0597 template<class T,class U>
0598 inline bool operator!=(SharedPtr<T> const & t, SharedPtr<U> const & u){
0599 return t.get() != u.get();
0600 }
0601 template<class T,class U>
0602 inline bool operator<(SharedPtr<T> const & t, SharedPtr<U> const & u){
0603 return t.get() < u.get();
0604 }
0605 template<class T>
0606 inline void swap(SharedPtr<T> & a, SharedPtr<T> & b){
0607 return a.swap(b);
0608 }
0609 template<class T>
0610 inline T* get_pointer(SharedPtr<T> const & t){
0611 return t.get();
0612 }
0613 #endif
0614 FJCORE_END_NAMESPACE
0615 #endif
0616 #ifndef __FJCORE_LIMITEDWARNING_HH__
0617 #define __FJCORE_LIMITEDWARNING_HH__
0618 #include <iostream>
0619 #include <string>
0620 #include <list>
0621 #ifdef FJCORE_HAVE_LIMITED_THREAD_SAFETY
0622 #include <atomic>
0623 #include <mutex>
0624 #endif
0625 FJCORE_BEGIN_NAMESPACE
0626 class LimitedWarning {
0627 public:
0628 LimitedWarning() : _max_warn(_max_warn_default),_this_warning_summary(0) {}
0629 LimitedWarning(int max_warn_in) : _max_warn(max_warn_in), _this_warning_summary(0) {}
0630 #ifdef FJCORE_HAVE_LIMITED_THREAD_SAFETY
0631 LimitedWarning(const LimitedWarning &other)
0632 : _max_warn(other._max_warn), _this_warning_summary{other._this_warning_summary.load()} {}
0633 #endif
0634 void warn(const char * warning) {warn(warning, _default_ostr);}
0635 void warn(const std::string & warning) {warn(warning.c_str(), _default_ostr);}
0636 void warn(const char * warning, std::ostream * ostr);
0637 void warn(const std::string & warning, std::ostream * ostr) {warn(warning.c_str(), ostr);}
0638 static void set_default_stream(std::ostream * ostr) {
0639 _default_ostr = ostr;
0640 }
0641 #ifdef FJCORE_HAVE_LIMITED_THREAD_SAFETY
0642 static void set_default_stream_and_mutex(std::ostream * ostr,
0643 std::mutex * warnings_mutex) {
0644 _default_ostr = ostr;
0645 _stream_mutex = warnings_mutex;
0646 }
0647 #endif
0648 static void set_default_max_warn(int max_warn) {
0649 _max_warn_default = max_warn;
0650 }
0651 int max_warn() const {return _max_warn;}
0652 int n_warn_so_far() const;
0653 static std::string summary();
0654 private:
0655 const int _max_warn;
0656 typedef std::pair<std::string, thread_safety_helpers::AtomicCounter<unsigned int> > Summary;
0657 #ifdef FJCORE_HAVE_LIMITED_THREAD_SAFETY
0658 static std::atomic<int> _max_warn_default;
0659 static std::atomic<std::ostream *> _default_ostr;
0660 static std::atomic<std::mutex *> _stream_mutex;
0661 static std::mutex _global_warnings_summary_mutex;
0662 std::atomic<Summary*> _this_warning_summary;
0663 #else
0664 static int _max_warn_default;
0665 static std::ostream * _default_ostr;
0666 Summary* _this_warning_summary;
0667 #endif
0668 static std::list< Summary > _global_warnings_summary;
0669 };
0670 FJCORE_END_NAMESPACE
0671 #endif
0672 #ifndef __FJCORE_ERROR_HH__
0673 #define __FJCORE_ERROR_HH__
0674 #include