APFEL 4.8.0
A PDF evolution library in C++
Loading...
Searching...
No Matches
set.h
Go to the documentation of this file.
1//
2// APFEL++ 2017
3//
4// Author: Valerio Bertone: valerio.bertone@cern.ch
5//
6
7#pragma once
8
10
11#include <functional>
12
13namespace apfel
14{
20 template<class T>
21 class Set
22 {
23 public:
29 Set(ConvolutionMap const& Map = ConvolutionMap{"UNDEFINED"}, std::map<int, T> const& in = std::map<int, T> {});
30
37 Set(std::map<int, T> const& in);
38
43
48 template<class V> Set<V> operator *= (Set<V> const& d) const;
49
50 Set<T>& operator *= (double const& s);
51 Set<T>& operator *= (std::function<double(double const&)> f);
52 Set<T>& operator *= (std::function<std::vector<double>(double const&)> f);
53 Set<T>& operator *= (std::vector<double> const& v);
54 Set<T>& operator *= (std::map<int, double> const& v);
55 Set<T>& operator /= (double const& s);
59
64
68 T const& at(int const& id) const { return _objects.at(id); }
72 ConvolutionMap const& GetMap() const { return _map; }
76 std::map<int, T> const& GetObjects() const { return _objects; }
78
82 void SetMap(ConvolutionMap const& map) { _map = map; }
83
88 void SetObjects(std::map<int, T> const& objects) { _objects = objects; }
89
94 T Combine() const;
95
101 T Combine(std::vector<double> const& weigths) const;
102
106 void Print() const { std::cout << *this << std::endl; }
107
108 private:
110 std::map<int, T> _objects;
111
112 template<class U>
113 friend std::ostream& operator << (std::ostream& os, Set<U> const& s);
114 };
115
120 template<class A, class B>
121 Set<B> operator * (Set<A> lhs, Set<B> const& rhs) { return lhs *= rhs; }
122
123 // other operators
124 template<class T>
125 Set<T> operator * (double const& s, Set<T> rhs) { return rhs *= s; }
126
127 template<class T>
128 Set<T> operator * (Set<T> lhs, double const& s) { return lhs *= s; }
129
130 template<class T>
131 Set<T> operator * (std::function<double(double const&)> f, Set<T> rhs) { return rhs *= f; }
132
133 template<class T>
134 Set<T> operator * (std::function<std::vector<double>(double const&)> f, Set<T> rhs) { return rhs *= f; }
135
136 template<class T>
137 Set<T> operator * (Set<T> lhs, std::function<double(double const&)> f) { return lhs *= f; }
138
139 template<class T>
140 Set<T> operator * (std::vector<double> const& v, Set<T> rhs) { return rhs *= v; }
141
142 template<class T>
143 Set<T> operator * (Set<T> lhs, std::vector<double> const& v) { return lhs *= v; }
144
145 template<class T>
146 Set<T> operator * (std::map<int, double> const& v, Set<T> rhs) { return rhs *= v; }
147
148 template<class T>
149 Set<T> operator * (Set<T> lhs, std::map<int, double> const& v) { return lhs *= v; }
150
151 template<class T>
152 Set<T> operator / (Set<T> lhs, double const& s) { return lhs /= s; }
153
154 template<class T>
155 Set<T> operator * (Set<T> lhs, Set<T> const& rhs) { return lhs *= rhs; }
156
157 template<class T>
158 Set<T> operator + (Set<T> lhs, Set<T> const& rhs) { return lhs += rhs; }
159
160 template<class T>
161 Set<T> operator - (Set<T> lhs, Set<T> const& rhs) { return lhs -= rhs; }
163}
The ConvolutionMap class encapsulates the set of rules to multiply a sets of operators with a set of ...
Definition convolutionmap.h:22
The Set template class allocates a collection of objects of type T along the ConvolutionMap and provi...
Definition set.h:22
Set< T > & operator-=(Set< T > const &d)
this -= Set
ConvolutionMap _map
The shared pointer containing the convolution map.
Definition set.h:109
Set< T > & operator+=(Set< T > const &d)
this += Set
Set(ConvolutionMap const &Map=ConvolutionMap{"UNDEFINED"}, std::map< int, T > const &in=std::map< int, T > {})
The Set constructor.
T Combine(std::vector< double > const &weigths) const
This function sums up all the objects of the set into one using the components of input vector as wei...
Set< V > operator*=(Set< V > const &d) const
operator *= product object
void Print() const
Print the Operator object.
Definition set.h:106
T const & at(int const &id) const
This returns object with ID "id" in the map.
Definition set.h:68
T Combine() const
This function sums up all the objects of the set into one.
void SetObjects(std::map< int, T > const &objects)
This function (re)sets the map of objects.
Definition set.h:88
friend std::ostream & operator<<(std::ostream &os, Set< U > const &s)
Set(std::map< int, T > const &in)
The Set constructor.
Set< T > & operator/=(double const &s)
this /= scalar
std::map< int, T > _objects
The container for the map.
Definition set.h:110
void SetMap(ConvolutionMap const &map)
This function (re)sets the convolution map.
Definition set.h:82
std::map< int, T > const & GetObjects() const
This returns the full map of objects.
Definition set.h:76
ConvolutionMap const & GetMap() const
This returns the convolution map.
Definition set.h:72
Namespace for all APFEL++ functions and classes.
Definition alphaqcd.h:14
Distribution operator/(Distribution lhs, double const &s)
Distribution/Scalar.
Distribution operator*(double const &s, Distribution rhs)
Scalar*Distribution.
Distribution operator+(Distribution lhs, Distribution const &rhs)
Distribution+Distribution.
Distribution operator-(Distribution lhs, Distribution const &rhs)
Distribution-Distribution.