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::vector<double> const& v);
53 Set<T>& operator *= (std::map<int, double> const& v);
54 Set<T>& operator /= (double const& s);
58
63
67 T const& at(int const& id) const { return _objects.at(id); }
71 ConvolutionMap const& GetMap() const { return _map; }
75 std::map<int, T> const& GetObjects() const { return _objects; }
77
81 void SetMap(ConvolutionMap const& map) { _map = map; }
82
87 void SetObjects(std::map<int, T> const& objects) { _objects = objects; }
88
93 T Combine() const;
94
100 T Combine(std::vector<double> const& weigths) const;
101
105 void Print() const { std::cout << *this << std::endl; }
106
107 private:
109 std::map<int, T> _objects;
110
111 template<class U>
112 friend std::ostream& operator << (std::ostream& os, Set<U> const& s);
113 };
114
119 template<class A, class B>
120 Set<B> operator * (Set<A> lhs, Set<B> const& rhs) { return lhs *= rhs; }
121
122 // other operators
123 template<class T>
124 Set<T> operator * (double const& s, Set<T> rhs) { return rhs *= s; }
125
126 template<class T>
127 Set<T> operator * (Set<T> lhs, double const& s) { return lhs *= s; }
128
129 template<class T>
130 Set<T> operator * (std::function<double(double const&)> f, Set<T> rhs) { return rhs *= f; }
131
132 template<class T>
133 Set<T> operator * (Set<T> lhs, std::function<double(double const&)> f) { return lhs *= f; }
134
135 template<class T>
136 Set<T> operator * (std::vector<double> const& v, Set<T> rhs) { return rhs *= v; }
137
138 template<class T>
139 Set<T> operator * (Set<T> lhs, std::vector<double> const& v) { return lhs *= v; }
140
141 template<class T>
142 Set<T> operator * (std::map<int, double> const& v, Set<T> rhs) { return rhs *= v; }
143
144 template<class T>
145 Set<T> operator * (Set<T> lhs, std::map<int, double> const& v) { return lhs *= v; }
146
147 template<class T>
148 Set<T> operator / (Set<T> lhs, double const& s) { return lhs /= s; }
149
150 template<class T>
151 Set<T> operator * (Set<T> lhs, Set<T> const& rhs) { return lhs *= rhs; }
152
153 template<class T>
154 Set<T> operator + (Set<T> lhs, Set<T> const& rhs) { return lhs += rhs; }
155
156 template<class T>
157 Set<T> operator - (Set<T> lhs, Set<T> const& rhs) { return lhs -= rhs; }
159}
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:108
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:105
T const & at(int const &id) const
This returns object with ID "id" in the map.
Definition set.h:67
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:87
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:109
void SetMap(ConvolutionMap const &map)
This function (re)sets the convolution map.
Definition set.h:81
std::map< int, T > const & GetObjects() const
This returns the full map of objects.
Definition set.h:75
ConvolutionMap const & GetMap() const
This returns the convolution map.
Definition set.h:71
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.