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