cepgen
is hosted by
Hepforge
,
IPPP Durham
CepGen
1.2.5
Central exclusive processes event generator
Loading...
Searching...
No Matches
Value.cpp
Go to the documentation of this file.
1
/*
2
* CepGen: a central exclusive processes event generator
3
* Copyright (C) 2023 Laurent Forthomme
4
*
5
* This program is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation, either version 3 of the License, or
8
* any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17
*/
18
19
#include <cmath>
20
#include <iostream>
21
22
#include "
CepGen/Utils/Math.h
"
23
#include "
CepGen/Utils/Value.h
"
24
25
namespace
cepgen
{
26
Value::Value
(
double
val,
double
unc) : val_(val), unc_(unc) {}
27
28
double
Value::relativeUncertainty
()
const
{
return
val_ == 0. ? 0. : unc_ / val_; }
29
30
Value
Value::operator+
(
const
Value
& oth)
const
{
return
Value
{val_ + oth.val_,
utils::fastHypot
(unc_, oth.unc_)}; }
31
32
Value
Value::operator-
(
const
Value
& oth)
const
{
return
Value
{val_ - oth.val_,
utils::fastHypot
(unc_, oth.unc_)}; }
33
34
Value
Value::operator*
(
const
Value
& oth)
const
{
35
const
auto
prod = val_ * oth.val_;
36
return
Value
{prod, prod *
utils::fastHypot
(
relativeUncertainty
(), oth.
relativeUncertainty
())};
37
}
38
39
Value
Value::operator/
(
const
Value
& oth)
const
{
40
const
auto
ratio = val_ / oth.val_;
41
return
Value
{ratio, ratio *
utils::fastHypot
(
relativeUncertainty
(), oth.
relativeUncertainty
())};
42
}
43
44
std::ostream&
operator<<
(std::ostream& os,
const
Value
& value) {
return
os << value.val_ <<
" +/- "
<< value.unc_; }
45
}
// namespace cepgen
Math.h
Value.h
cepgen::Value
A scalar value with its uncertainty.
Definition
Value.h:26
cepgen::Value::operator+
Value operator+(const Value &) const
Definition
Value.cpp:30
cepgen::Value::operator*
Value operator*(const Value &) const
Definition
Value.cpp:34
cepgen::Value::operator/
Value operator/(const Value &) const
Definition
Value.cpp:39
cepgen::Value::relativeUncertainty
double relativeUncertainty() const
Relative uncertainty around the central value.
Definition
Value.cpp:28
cepgen::Value::operator-
Value operator-(const Value &) const
Definition
Value.cpp:32
cepgen::Value::Value
Value(double val=0., double unc=0.)
Definition
Value.cpp:26
cepgen::utils::fastHypot
double fastHypot(double x, double y)
Definition
Math.cpp:33
cepgen
Common namespace for this Monte Carlo generator.
Definition
CommandLineHandler.cpp:36
cepgen::operator<<
std::ostream & operator<<(std::ostream &os, const Exception::Type &type)
Definition
Exception.cpp:59
CepGen
Utils
Value.cpp
Generated on Mon Jul 29 2024 for CepGen by
1.9.7