herwig is hosted by Hepforge, IPPP Durham
Herwig 7.3.0
Maths.h
1// -*- C++ -*-
2//
3// Maths.h is a part of Herwig - A multi-purpose Monte Carlo event generator
4// Copyright (C) 2002-2019 The Herwig Collaboration
5//
6// Herwig is licenced under version 3 of the GPL, see COPYING for details.
7// Please respect the MCnet academic guidelines, see GUIDELINES for details.
8//
9#ifndef HERWIG_Math_H
10#define HERWIG_Math_H
11
12#include <cmath>
13#include <vector>
14#include "ThePEG/Config/Complex.h"
15#include "ThePEG/Utilities/Maths.h"
17
18namespace Herwig {
19using ThePEG::Complex;
20using std::complex;
21
24namespace Math {
25
30
34 long double ReLi2(long double);
35
39 inline double angleZeroTo2Pi(double angle) {
40 double ret = fmod(angle, 2 * M_PI);
41 if (ret < 0) ret += 2 * M_PI;
42 return ret;
43 }
44
48 inline double angleMinusPiToPi(double angle) {
49 double ret = angleZeroTo2Pi(angle);
50 if (ret > M_PI) ret -= 2 * M_PI;
51 return ret;
52 }
53
58 template <typename T>
59 inline T median(std::vector<T> v) {
60 if (v.empty()) return T();
61 sort ( v.begin(), v.end() );
62 const size_t N = v.size();
63 return (N % 2) ? v.at((N+1)/2 - 1) : v.at(N/2 - 1);
64 }
65
66}
67
68}
69
70#endif /* HERWIG_Math_H */
double angleZeroTo2Pi(double angle)
Fold angles into the range (0,2 Pi)
Definition: Maths.h:39
long double ReLi2(long double)
The real part of the dilog function taken from FORTRAN Herwig.
double angleMinusPiToPi(double angle)
Fold angles into the range (-Pi,Pi)
Definition: Maths.h:48
T median(std::vector< T > v)
Calculates the (lower) median of a vector of T objects.
Definition: Maths.h:59
-*- C++ -*-
std::complex< double > Complex