herwig
is hosted by
Hepforge
,
IPPP Durham
Herwig
7.3.0
Utilities
tests
utilitiesTestMaths.h
1
// -*- C++ -*-
2
//
3
// utilitiesTestMaths.h is a part of Herwig - A multi-purpose Monte Carlo event generator
4
// Copyright (C) 2002-2019 The Herwig Collaboration, 2015 Marco A. Harrendorf
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_Utilities_Test_Maths_H
10
#define HERWIG_Utilities_Test_Maths_H
11
12
#include <boost/test/unit_test.hpp>
13
14
#include "Herwig/Utilities/Maths.h"
15
16
/*
17
* Start of boost unit tests for Maths.h
18
*
19
*/
20
BOOST_AUTO_TEST_SUITE(utilitiesMathsTest)
21
22
/*
23
* Boost unit tests
24
*
25
*/
26
BOOST_AUTO_TEST_CASE(dilogFunction)
27
{
28
BOOST_CHECK_EQUAL(
Herwig::Math::Li2
(0.), 0.);
29
BOOST_CHECK_CLOSE(
Herwig::Math::Li2
(-1).real(), -1./12. * M_PI * M_PI, 1e-5);
30
BOOST_CHECK_CLOSE(
Herwig::Math::Li2
(-1).imag(), 0., 1e-5);
31
BOOST_CHECK_CLOSE(
Herwig::Math::Li2
(1).real(), 1./6. * M_PI * M_PI, 1e-5);
32
BOOST_CHECK_CLOSE(
Herwig::Math::Li2
(1).imag(), 0., 1e-5);
33
34
BOOST_CHECK_CLOSE(
Herwig::Math::Li2
(
Herwig::Complex
(0.5, 1)).real(), 0.203354, 2e-4);
35
BOOST_CHECK_CLOSE(
Herwig::Math::Li2
(
Herwig::Complex
(0.5, 1)).imag(), 1.13194, 1e-4);
36
BOOST_CHECK_CLOSE(
Herwig::Math::Li2
(
Herwig::Complex
(-0.5, -1)).real(), -0.578503, 1e-4);
37
BOOST_CHECK_CLOSE(
Herwig::Math::Li2
(
Herwig::Complex
(-0.5, -1)).imag(), -0.772714, 1e-4);
38
}
39
40
BOOST_AUTO_TEST_CASE(realDilogFunction)
41
{
42
BOOST_CHECK_EQUAL(
Herwig::Math::ReLi2
(0.), 0.);
43
BOOST_CHECK_CLOSE(
Herwig::Math::ReLi2
(-1), -1./12. * M_PI * M_PI, 1e-5);
44
BOOST_CHECK_CLOSE(
Herwig::Math::ReLi2
(1), 1./6. * M_PI * M_PI, 1e-5);
45
}
46
47
48
BOOST_AUTO_TEST_CASE(angleZeroTo2Pi)
49
{
50
BOOST_CHECK_EQUAL(
Herwig::Math::angleZeroTo2Pi
(0.), 0.);
51
BOOST_CHECK_EQUAL(
Herwig::Math::angleZeroTo2Pi
(-0.5*M_PI), 1.5*M_PI);
52
BOOST_CHECK_EQUAL(
Herwig::Math::angleZeroTo2Pi
(-2.5*M_PI), 1.5*M_PI);
53
BOOST_CHECK_EQUAL(
Herwig::Math::angleZeroTo2Pi
( 2.5*M_PI), 0.5*M_PI);
54
BOOST_CHECK(
Herwig::Math::angleZeroTo2Pi
( 2.5*M_PI) != 1*M_PI);
55
}
56
57
BOOST_AUTO_TEST_CASE(angleMinusPiToPi)
58
{
59
BOOST_CHECK_EQUAL(
Herwig::Math::angleMinusPiToPi
(0.), 0.);
60
BOOST_CHECK_EQUAL(
Herwig::Math::angleMinusPiToPi
(-0.5*M_PI), -0.5*M_PI);
61
BOOST_CHECK_EQUAL(
Herwig::Math::angleMinusPiToPi
(-2.5*M_PI), -0.5*M_PI);
62
BOOST_CHECK_EQUAL(
Herwig::Math::angleMinusPiToPi
( 2.5*M_PI), 0.5*M_PI);
63
BOOST_CHECK(
Herwig::Math::angleMinusPiToPi
( 2.5*M_PI) != 1*M_PI);
64
}
65
66
BOOST_AUTO_TEST_CASE(median)
67
{
68
std::vector<double> medianTest1;
69
medianTest1.push_back(10);
70
medianTest1.push_back(-1);
71
medianTest1.push_back(5);
72
BOOST_CHECK_EQUAL(Herwig::Math::median<double>(medianTest1), 5);
73
74
std::vector<double> medianTest2;
75
medianTest2.push_back(-10);
76
medianTest2.push_back(-1);
77
medianTest2.push_back(-5);
78
medianTest2.push_back(-6);
79
BOOST_CHECK_EQUAL(Herwig::Math::median<double>(medianTest2), -6);
80
}
81
82
BOOST_AUTO_TEST_SUITE_END()
83
84
#endif
/* HERWIG_Utilities_Test_Maths_H */
Herwig::Math::angleZeroTo2Pi
double angleZeroTo2Pi(double angle)
Fold angles into the range (0,2 Pi)
Definition:
Maths.h:39
Herwig::Math::ReLi2
long double ReLi2(long double)
The real part of the dilog function taken from FORTRAN Herwig.
Herwig::Math::Li2
Complex Li2(Complex)
The dilog function taken from FORTRAN Herwig.
Herwig::Math::angleMinusPiToPi
double angleMinusPiToPi(double angle)
Fold angles into the range (-Pi,Pi)
Definition:
Maths.h:48
ThePEG::Complex
std::complex< double > Complex
Generated on Thu Jun 20 2024 17:50:53 for Herwig by
1.9.6