yoda is hosted by Hepforge, IPPP Durham
YODA - Yet more Objects for Data Analysis 2.1.0
YODA::Transformation< N, Args > Class Template Reference

#include <Transformation.h>

Public Types

using Pair = std::pair< double, double >
 Convenient aliases.
 
using NdVal = typename Utils::ndarray< double, N >
 
using NdValPair = typename Utils::ndarray< Pair, N >
 
using Breakdown = std::map< std::string, std::pair< double, double > >
 

Public Member Functions

Constructors
 Transformation ()=delete
 
 Transformation (const std::function< double(double, Args...)> &fn)
 Default constructor setting the trf method.
 
 Transformation (std::function< double(double, Args...)> &&fn)
 Default constructor setting the trf method.
 
double operator() (const double v, Args &&... args) const
 Operator calling the functor.
 
Modifiers
void transform (double &val, Args &&... args) const
 Transform value val.
 
void transform (NdVal &vals, Args &&... args) const
 Transform values vals.
 
void transform (double &val, Breakdown &signed_errs, Args &&... args) const
 Transform value val and breakdown of signed error pairs signed_errs.
 
void transform (double &val, Pair &errs, Args &&... args) const
 Transform value val and error pair errs.
 
void transform (NdVal &vals, NdValPair &errs, Args &&... args) const
 Transform values vals and error pairs errs.
 

Detailed Description

template<size_t N, typename... Args>
class YODA::Transformation< N, Args >

Generalised transformation

The tranformation uses a functor that acts on a double (possibly with additional arguments) and returns a double. The generalisation is in the number of dimensions in which the trf can be applied.

Definition at line 29 of file Transformation.h.

Member Typedef Documentation

◆ Breakdown

template<size_t N, typename... Args>
using YODA::Transformation< N, Args >::Breakdown = std::map<std::string,std::pair<double,double> >

Definition at line 36 of file Transformation.h.

◆ NdVal

template<size_t N, typename... Args>
using YODA::Transformation< N, Args >::NdVal = typename Utils::ndarray<double, N>

Definition at line 34 of file Transformation.h.

◆ NdValPair

template<size_t N, typename... Args>
using YODA::Transformation< N, Args >::NdValPair = typename Utils::ndarray<Pair, N>

Definition at line 35 of file Transformation.h.

◆ Pair

template<size_t N, typename... Args>
using YODA::Transformation< N, Args >::Pair = std::pair<double,double>

Convenient aliases.

Definition at line 33 of file Transformation.h.

Constructor & Destructor Documentation

◆ Transformation() [1/3]

template<size_t N, typename... Args>
YODA::Transformation< N, Args >::Transformation ( )
delete

No nullary constructor since a trf method should always be supplied

◆ Transformation() [2/3]

template<size_t N, typename... Args>
YODA::Transformation< N, Args >::Transformation ( const std::function< double(double, Args...)> &  fn)
inline

Default constructor setting the trf method.

Definition at line 47 of file Transformation.h.

47: _Fn(fn) { }

◆ Transformation() [3/3]

template<size_t N, typename... Args>
YODA::Transformation< N, Args >::Transformation ( std::function< double(double, Args...)> &&  fn)
inline

Default constructor setting the trf method.

Definition at line 50 of file Transformation.h.

50: _Fn(std::move(fn)) { }

Member Function Documentation

◆ operator()()

template<size_t N, typename... Args>
double YODA::Transformation< N, Args >::operator() ( const double  v,
Args &&...  args 
) const
inline

Operator calling the functor.

Definition at line 54 of file Transformation.h.

54{ return _Fn(v, std::forward<Args>(args)...); }

◆ transform() [1/5]

template<size_t N, typename... Args>
void YODA::Transformation< N, Args >::transform ( double &  val,
Args &&...  args 
) const
inline

◆ transform() [2/5]

template<size_t N, typename... Args>
void YODA::Transformation< N, Args >::transform ( double &  val,
Breakdown signed_errs,
Args &&...  args 
) const
inline

Transform value val and breakdown of signed error pairs signed_errs.

Definition at line 75 of file Transformation.h.

75 {
76 // keep track of original central value
77 const double oldval = val;
78 // transform central value
79 transform(val, std::forward<Args>(args)...);
80 // transform errors
81 for (auto& item : signed_errs) {
82 item.second.first = _Fn(oldval + item.second.first, std::forward<Args>(args)...) - val;
83 item.second.second = _Fn(oldval + item.second.second, std::forward<Args>(args)...) - val;
84 }
85 }
void transform(double &val, Args &&... args) const
Transform value val.

References YODA::Transformation< N, Args >::transform().

◆ transform() [3/5]

template<size_t N, typename... Args>
void YODA::Transformation< N, Args >::transform ( double &  val,
Pair errs,
Args &&...  args 
) const
inline

Transform value val and error pair errs.

Definition at line 88 of file Transformation.h.

88 {
89 // transform errors
90 const double trf_min = _Fn(val - errs.first, std::forward<Args>(args)...);
91 const double trf_max = _Fn(val + errs.second, std::forward<Args>(args)...);
92 // transform central value
93 transform(val, std::forward<Args>(args)...);
94 // Deal with possible inversions of min/max ordering under the transformation
95 const double new_min = std::min(trf_min, trf_max);
96 const double new_max = std::max(trf_min, trf_max);
97 errs = std::make_pair(val - new_min, new_max - val);
98 }

References YODA::Transformation< N, Args >::transform().

◆ transform() [4/5]

template<size_t N, typename... Args>
void YODA::Transformation< N, Args >::transform ( NdVal vals,
Args &&...  args 
) const
inline

Transform values vals.

Definition at line 66 of file Transformation.h.

66 {
67 for (double& val : vals) {
68 transform(val, std::forward<Args>(args)...);
69 }
70 }

References YODA::Transformation< N, Args >::transform().

◆ transform() [5/5]

template<size_t N, typename... Args>
void YODA::Transformation< N, Args >::transform ( NdVal vals,
NdValPair errs,
Args &&...  args 
) const
inline

Transform values vals and error pairs errs.

Definition at line 101 of file Transformation.h.

101 {
102 for (size_t i = 0; i < N; ++i) {
103 transform(vals[i], errs[i], std::forward<Args>(args)...);
104 }
105 }

References YODA::Transformation< N, Args >::transform().


The documentation for this class was generated from the following file: