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