yoda is hosted by Hepforge, IPPP Durham
YODA - Yet more Objects for Data Analysis 2.0.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 31 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 38 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 36 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 37 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 35 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 49 of file Transformation.h.

49: _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 52 of file Transformation.h.

52: _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 56 of file Transformation.h.

56{ 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 77 of file Transformation.h.

77 {
78 // keep track of original central value
79 const double oldval = val;
80 // transform central value
81 transform(val, std::forward<Args>(args)...);
82 // transform errors
83 for (auto& item : signed_errs) {
84 item.second.first = _Fn(oldval + item.second.first, std::forward<Args>(args)...) - val;
85 item.second.second = _Fn(oldval + item.second.second, std::forward<Args>(args)...) - val;
86 }
87 }
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 90 of file Transformation.h.

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

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 68 of file Transformation.h.

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

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 103 of file Transformation.h.

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

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


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