42template<
typename Type>
44typename std::enable_if<std::is_base_of<basic, T>::value,
bool>::type
47 return is_exactly_a<Type>(expr);
49template<
typename Type>
51typename std::enable_if<!std::is_base_of<basic, T>::value,
bool>::type
54 return is_the_function<Type>(expr);
57template<
typename Type>
60 std::cout <<
"Cache" << std::endl;
61 for (
const auto&
n :
cache)
62 std::cout <<
" " <<
n.first <<
" -> " <<
n.second << std::endl;
65template<
typename Type>
69 if (check_type(expr)) {
71 if (pos !=
cache.end())
73 return cache.emplace(expr, func_obj(expr)).first->second;
77 if (is_exactly_a<add>(expr) || is_exactly_a<mul>(expr)) {
78 std::vector<ex> terms;
79 terms.reserve(expr.
nops());
80 for (
size_t i = 0; i < expr.
nops(); i++)
81 terms.emplace_back(impl(expr.
op(i)));
82 if (is_exactly_a<add>(expr))
87 if (is_exactly_a<lst>(expr)) {
89 for (
size_t i = 0; i < expr.
nops(); i++)
93 if (is_exactly_a<power>(expr))
94 return power(impl(expr.
op(0)), expr.
op(1));
97 return func_default(expr);
111 std::vector<std::vector<int>> result;
112 std::vector<int> hlp(
m, 0);
116 int x = hlp[
k-1] + 1;
119 while (
x <= y &&
k <
m-1) {
126 std::vector<int> decomposition(
m, 0);
127 for (
size_t i = 0; i <
k+1; i++)
128 decomposition[i] = hlp[i];
129 std::sort(decomposition.begin(), decomposition.end());
131 result.emplace_back(decomposition);
132 }
while (next_permutation(decomposition.begin(), decomposition.end()));
138template<
typename Kernel>
140 const std::vector<Kernel>& args,
141 const std::vector<ex>& endpoints,
142 const std::function<
ex(std::vector<Kernel>& new_args,
const ex& start,
const ex& end)>& construct
146 const size_t n_segments = endpoints.size()-1;
147 const std::vector<std::vector<int>> partitions =
integer_partition(args.size(), n_segments);
148 std::vector<ex> terms;
149 terms.reserve(partitions.size());
150 for (
const std::vector<int>& partition : partitions) {
151 size_t kernel_count = 0;
154 for (
size_t i = 0; i < n_segments; i++) {
155 if (partition[i] == 0)
158 std::vector<Kernel> new_args(args.begin()+kernel_count, args.begin()+kernel_count+partition[i]);
159 kernel_count += partition[i];
161 factors.emplace_back(construct(new_args, endpoints[n_segments-1-i], endpoints[n_segments-i]));
169 const std::vector<ex>& args,
170 const std::vector<ex>& endpoints,
171 const std::function<
ex(std::vector<ex>& new_args,
const ex& start,
const ex& end)>& construct
174 const std::vector<Gt::kernel>& args,
175 const std::vector<ex>& endpoints,
176 const std::function<
ex(std::vector<Gt::kernel>& new_args,
const ex& start,
const ex& end)>& construct
186 : prefactor(a.prefactor * b.prefactor),
188 polylog(a.polylog.empty() ? b.polylog : a.polylog),
192 throw std::logic_error(
"Gt: Cannot multiply these terms");
198 for (
int i = std::min(0,
power); i < std::max(0,
power); i++)
215 std::vector<ex> args =
polylog;
218 args.insert(args.begin(),
ex{0});
223 args.erase(args.begin());
236 std::vector<ex> args =
polylog;
237 args.insert(args.begin(),
denom);
242 throw std::logic_error(
"Gt: Invalid integration");
249 result /=
denom - upper_bound;
258 if (path.size() > 2) {
260 return G_path(new_args,start,end);
263 return G_path(args, path[0], path[1]);
268 bool all_args_same = args.size() >= 2;
269 for (
size_t i = 1; i < args.size() && all_args_same; i++)
270 all_args_same = (args[i] == args[0]);
272 return (
pow(
G((args[0] - start)/(end - start),1).hold(), args.size()) /
factorial(args.size()));
276 for (
const ex& arg : args)
277 new_args.
append((arg - start)/(end - start));
278 return G(new_args,1).
hold();
285 os <<
"*[int.var.]^" << term.
power;
290 os <<
"},[int.var.],[path])";
293 os <<
"/([int.var.]-(" << term.
denom <<
"))";
313 if (cmpval < 0)
return true;
314 if (cmpval > 0)
return false;
316 for (
size_t i = 0; i < a.
polylog.size(); i++) {
318 if (cmpval < 0)
return true;
319 if (cmpval > 0)
return false;
329 std::set<pathintegral_term>::iterator pos =
terms.find(term);
331 terms.insert(std::move(term));
333 pos->prefactor += term.prefactor;
334 if (pos->prefactor.is_zero())
Interface to GiNaC's elliptic multiple polylogarithms.
Interface to helper functions for elliptic multiple polylogarithms.
Interface to GiNaC's sums of expressions.
std::set< pathintegral_term >::const_iterator begin() const
void add(pathintegral_term &&term)
std::set< pathintegral_term > terms
std::set< pathintegral_term >::const_iterator end() const
pathintegral_term(ex prefactor, int power, const std::vector< ex > &polylog={}, ex denom=0)
void integrate(const ex &start, pathintegral_term_list &integrand, pathintegral_term_list &result) const
static ex G_path(const std::vector< ex > &args, const std::vector< ex > &path)
std::vector< ex > polylog
ex evaluate(const ex &upper_bound, const std::vector< ex > &path) const
const basic & hold() const
Stop further evaluation.
Wrapper template for making GiNaC classes out of STL containers.
container & append(const ex &b)
Add element at back.
Lightweight wrapper for GiNaC's symbolic objects.
bool find(const ex &pattern, exset &found) const
Find all occurrences of a pattern.
int compare(const ex &other) const
This class holds a two-component object, a basis and and exponent representing exponentiation.
vector< vector< umodpoly > > cache
Interface to class of symbolic functions.
Interface to GiNaC's initially known functions.
Definition of GiNaC's lst.
Interface to GiNaC's products of expressions.
template ex deconcatenate_path< Gt::kernel >(const std::vector< Gt::kernel > &args, const std::vector< ex > &endpoints, const std::function< ex(std::vector< Gt::kernel > &new_args, const ex &start, const ex &end)> &construct)
template ex deconcatenate_path< ex >(const std::vector< ex > &args, const std::vector< ex > &endpoints, const std::function< ex(std::vector< ex > &new_args, const ex &start, const ex &end)> &construct)
ex deconcatenate_path(const std::vector< Kernel > &args, const std::vector< ex > &endpoints, const std::function< ex(std::vector< Kernel > &new_args, const ex &start, const ex &end)> &construct)
bool operator<(const pathintegral_term &a, const pathintegral_term &b)
std::ostream & operator<<(std::ostream &os, const pathintegral_term &term)
std::vector< std::vector< int > > integer_partition(const int n, const int m)
bool is_zero(const ex &thisex)
ex denom(const ex &thisex)
const numeric pow(const numeric &x, const numeric &y)
const numeric factorial(const numeric &n)
Factorial combinatorial function.
function G(const T1 &x, const T2 &y)
Interface to GiNaC's overloaded operators.
Interface to GiNaC's symbolic exponentiation (basis^exponent).
Interface to relations between expressions.