-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdiff.hpp
45 lines (31 loc) · 828 Bytes
/
diff.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "group.hpp"
template<class LHS, class RHS>
struct compose {
using domain = typename RHS::domain;
const LHS lhs;
const RHS rhs;
auto operator()(const domain& x) const {
return lhs(rhs(x));
}
auto push(const domain& x) const {
return lhs.push(rhs(x)) >> rhs.push(x);
}
auto pull(const domain& x) const {
return rhs.pull(x) >> lhs.pull(rhs(x)) ;
}
};
template<class LHS, class RHS>
static compose<LHS, RHS> operator>>(LHS lhs, RHS rhs) {
return {lhs, rhs};
}
template<class G>
struct identity {
using domain = G;
G operator()(const domain& self) const { return self; }
auto push(const domain& self) const {
return identity<typename group<G>::algebra>();
}
auto pull(const domain& self) const {
return identity<typename group<G>::algebra>();
}
};