File indexing completed on 2026-08-06 09:24:28
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef HERWIG_Math_H
0010 #define HERWIG_Math_H
0011
0012 #include <cmath>
0013 #include <vector>
0014 #include "ThePEG/Config/Complex.h"
0015 #include "ThePEG/Utilities/Maths.h"
0016 #include "ThePEG/Config/TemplateTools.h"
0017
0018 namespace Herwig {
0019 using ThePEG::Complex;
0020 using std::complex;
0021
0022
0023
0024 namespace Math {
0025
0026
0027
0028
0029 Complex Li2(Complex);
0030
0031
0032
0033
0034 long double ReLi2(long double);
0035
0036
0037
0038
0039 inline double angleZeroTo2Pi(double angle) {
0040 double ret = fmod(angle, 2 * M_PI);
0041 if (ret < 0) ret += 2 * M_PI;
0042 return ret;
0043 }
0044
0045
0046
0047
0048 inline double angleMinusPiToPi(double angle) {
0049 double ret = angleZeroTo2Pi(angle);
0050 if (ret > M_PI) ret -= 2 * M_PI;
0051 return ret;
0052 }
0053
0054
0055
0056
0057
0058 template <typename T>
0059 inline T median(std::vector<T> v) {
0060 if (v.empty()) return T();
0061 sort ( v.begin(), v.end() );
0062 const size_t N = v.size();
0063 return (N % 2) ? v.at((N+1)/2 - 1) : v.at(N/2 - 1);
0064 }
0065
0066 }
0067
0068 }
0069
0070 #endif