GiNaC 1.8.10
Gt.h
Go to the documentation of this file.
1
5/*
6 * GiNaC Copyright (C) 1999-2026 Johannes Gutenberg University Mainz, Germany
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23#ifndef GINAC_EMPL_H
24#define GINAC_EMPL_H
25
26#include "archive.h"
27#include "basic.h"
28#include "ex.h"
29
30namespace GiNaC {
31
32#if !defined(GINAC_LST_H) && !defined(GINAC_REGISTRAR_H)
33class lst;
34#endif
35class numeric;
36class matrix;
37class G2_SERIAL;
38namespace Gt_detail {
39 template<typename Type>
41};
42
44class Gt : public basic
45{
47
48public:
49 struct kernel
50 {
52 kernel(size_t ni, ex zi, int deform = 0);
53 kernel(lst arg);
54
55 size_t ni; // weight
56 ex zi; // argument (may be symbolic)
57 int deform; // if the argument becomes a pole and the integration contour passes over
58 // it, deform the integration contour towards (zi*exp(i*epsilon*deform))
59
60 private:
61 void check();
62 friend class Gt;
63 };
64
65 // other constructors
66public:
67 Gt(const ex& args, const ex& z, const ex& tau);
68private:
69 Gt(std::vector<kernel> args, ex z, ex tau);
70 void setArgs(const ex& args);
71
72 // functions overriding virtual functions from base classes
73public:
74 const ex& getTau() const { return tau; }
75 const ex& getZ() const { return z; }
76 const std::vector<kernel>& getArgs() const { return args; }
77 unsigned precedence() const override {return 45;}
78 ex eval() const override;
79 ex evalf() const override;
80
81 // We do not support other functions modifying our members, so we set nops=0
82 // This breaks certain features though, so we need to re-implement them manually
83 size_t nops() const override { return 0; }
84 ex subs(const exmap & m, unsigned options = 0) const override;
85 unsigned calchash() const override;
86 bool has(const ex & other, unsigned options = 0) const override;
87 bool match(const ex & pattern, exmap& repl_lst) const override;
88
90 void archive(archive_node& n) const override;
92 void read_archive(const archive_node& n, lst& syms) override;
93
94 // Functions that operate on a single Gt
95 ex zisToFundamental(const ex* points = nullptr) const;
96 ex regularise(const ex* points = nullptr) const;
97 matrix findMoebiusTransform(const ex* points = nullptr) const;
98 ex tauToFundamental(const ex* points = nullptr) const;
99 std::vector<ex> decomposeIntegrationPath(const ex* points = nullptr) const;
100 ex applyIntegrationPath(const std::vector<ex>& endpoints) const;
101 numeric qExpand(const ex* points = nullptr) const;
102 numeric evaluate(const ex* points = nullptr) const;
103
104 // Functions that operate on expressions containing Gts
105 static ex ex_zisToFundamental(const ex& expr, const ex* points = nullptr);
106 static ex ex_regularise(const ex& expr, const ex* points = nullptr);
107 static ex ex_tauToFundamental(const ex& expr, const ex* points = nullptr);
108 static ex ex_cutIntegrationPath(const ex& expr, const ex* points = nullptr);
109 static numeric ex_qExpand(const ex& expr, const ex* points = nullptr);
110 static ex ex_prepare(const ex& expr, const ex* points = nullptr);
111 static numeric ex_evaluate(const ex& expr, const ex* points = nullptr);
112 static lst lst_evaluate(const lst& list, const ex* points = nullptr);
113 // Pass replacements by reference, rather than by pointer
114 static ex ex_zisToFundamental(const ex& expr, const ex& points);
115 static ex ex_regularise(const ex& expr, const ex& points);
116 static ex ex_tauToFundamental(const ex& expr, const ex& points);
117 static ex ex_cutIntegrationPath(const ex& expr, const ex& points);
118 static numeric ex_qExpand(const ex& expr, const ex& points);
119 static ex ex_prepare(const ex& expr, const ex& points);
120 static numeric ex_evaluate(const ex& expr, const ex& points);
121 static lst lst_evaluate(const lst& list, const ex& points);
122
123 // Apply a transformation recursively to every Gt in an expression; use caching for repeated appearances
124 static ex apply_function_recursive(const ex& input, const std::function<ex(const Gt&)>& func);
125
126 // Clear global cache of numerical values of regular MPLs
127 static void clear_polylog_cache();
128
129protected:
130 void do_print(const print_context & c, unsigned level) const;
131 void do_print_latex(const print_latex & c, unsigned level) const;
132
133private:
134 static numeric to_numeric(const ex& expr, const ex* points = nullptr);
135 static long to_integer(const ex& expr, const bool allow_negative);
136
137public:
138 // Parameter in (0,0.5) that defines how close the integration path is allowed to get to
139 // the boundary of the fundamental domain before being cut.
140 // Smaller values result in more Gt terms, but each q-expansion will converge faster.
141 // For Gts with many kernels, smaller values might be preferable, as the q-expansion
142 // takes up a larger chunk of the runtime for such Gts.
145
146 // Minimum order to which q-expansion should be performed. This should never make a difference,
147 // as the starting order is estimated based on the properties of the kernels.
148 static size_t qExpand_minOrder;
149
150 // Sometimes, a specific individual order of the q-expansion has very little numerical effect.
151 // If we just check for the numerical change after each order, we might assume convergence and
152 // terminate the expansion prematurely.
153 // By expanding multiple orders at each step (i.e. qExpand_stepSize >= 2), we avoid this issue.
154 // This also decreases bookkeeping work, in case the initial expansion order was too low.
155 static size_t qExpand_stepSize;
156
157 // Clear polylog cache after each call to ex_evaluate
159
160 // Toggle whether to shift tau to its fundamental domain. In certain cases it can be faster to
161 // omit this step.
163
164private:
165 size_t nargs; // number of arguments
166 std::vector<kernel> args; // arguments (ni as integer, zi symbolic)
167 ex z, tau; // z and tau (symbolic)
168
169 // Global cache for numeric evaluation of MPLs in qExpand
171};
173
174} // namespace GiNaC
175
176#endif // ndef GINAC_EMPL_H
Archiving of GiNaC expressions.
#define GINAC_DECLARE_UNARCHIVER(classname)
Helper macros to register a class with (un)archiving (a.k.a.
Definition archive.h:218
Interface to GiNaC's ABC.
Elliptic Multiple Polylogarithm.
Definition Gt.h:45
std::vector< ex > decomposeIntegrationPath(const ex *points=nullptr) const
Definition Gt.cpp:623
static void clear_polylog_cache()
Definition Gt.cpp:1115
std::vector< kernel > args
Definition Gt.h:166
static ex ex_zisToFundamental(const ex &expr, const ex *points=nullptr)
Definition Gt.cpp:998
static numeric ex_qExpand(const ex &expr, const ex *points=nullptr)
Definition Gt.cpp:1022
bool match(const ex &pattern, exmap &repl_lst) const override
Check whether the expression matches a given pattern.
Definition Gt.cpp:313
ex z
Definition Gt.h:167
static ex ex_prepare(const ex &expr, const ex *points=nullptr)
Definition Gt.cpp:1030
matrix findMoebiusTransform(const ex *points=nullptr) const
Definition Gt.cpp:489
ex subs(const exmap &m, unsigned options=0) const override
Substitute a set of objects by arbitrary expressions.
Definition Gt.cpp:275
const std::vector< kernel > & getArgs() const
Definition Gt.h:76
static ex apply_function_recursive(const ex &input, const std::function< ex(const Gt &)> &func)
Definition Gt.cpp:1110
const ex & getTau() const
Definition Gt.h:74
unsigned precedence() const override
Return relative operator precedence (for parenthezing output).
Definition Gt.h:77
static ex ex_cutIntegrationPath(const ex &expr, const ex *points=nullptr)
Definition Gt.cpp:1016
void setArgs(const ex &args)
Definition Gt.cpp:133
static long to_integer(const ex &expr, const bool allow_negative)
Definition Gt.cpp:1133
numeric qExpand(const ex *points=nullptr) const
Definition Gt.cpp:690
unsigned calchash() const override
Compute the hash value of an object and if it makes sense to store it in the objects status_flags,...
Definition Gt.cpp:285
size_t nops() const override
Number of operands/members.
Definition Gt.h:83
static double cutIntegrationPath_threshold_imag
Definition Gt.h:144
ex eval() const override
Perform automatic non-interruptive term rewriting rules.
Definition Gt.cpp:224
void do_print_latex(const print_latex &c, unsigned level) const
Definition Gt.cpp:193
ex regularise(const ex *points=nullptr) const
Definition Gt.cpp:417
static lst lst_evaluate(const lst &list, const ex *points=nullptr)
Definition Gt.cpp:1079
static ex ex_tauToFundamental(const ex &expr, const ex *points=nullptr)
Definition Gt.cpp:1010
ex evalf() const override
Evaluate object numerically.
Definition Gt.cpp:248
void do_print(const print_context &c, unsigned level) const
Definition Gt.cpp:181
static Gt_detail::TransformExpressionWithCache< G2_SERIAL > nqexand_transformer
Definition Gt.h:170
void read_archive(const archive_node &n, lst &syms) override
Read (a.k.a.
Definition Gt.cpp:156
static size_t qExpand_minOrder
Definition Gt.h:148
static numeric to_numeric(const ex &expr, const ex *points=nullptr)
Definition Gt.cpp:1123
static bool auto_clear_polylog_cache
Definition Gt.h:158
static bool enable_tauToFundamental
Definition Gt.h:162
ex tauToFundamental(const ex *points=nullptr) const
Definition Gt.cpp:522
ex zisToFundamental(const ex *points=nullptr) const
Definition Gt.cpp:322
static size_t qExpand_stepSize
Definition Gt.h:155
const ex & getZ() const
Definition Gt.h:75
numeric evaluate(const ex *points=nullptr) const
Definition Gt.cpp:992
bool has(const ex &other, unsigned options=0) const override
Test for occurrence of a pattern.
Definition Gt.cpp:305
static numeric ex_evaluate(const ex &expr, const ex *points=nullptr)
Definition Gt.cpp:1064
static double cutIntegrationPath_threshold_real
Definition Gt.h:143
size_t nargs
Definition Gt.h:165
ex applyIntegrationPath(const std::vector< ex > &endpoints) const
Definition Gt.cpp:680
ex tau
Definition Gt.h:167
static ex ex_regularise(const ex &expr, const ex *points=nullptr)
Definition Gt.cpp:1004
This class stores all properties needed to record/retrieve the state of one object of class basic (or...
Definition archive.h:48
This class holds archived versions of GiNaC expressions (class ex).
Definition archive.h:254
This class is the ABC (abstract base class) of GiNaC's class hierarchy.
Definition basic.h:104
friend class ex
Definition basic.h:107
Wrapper template for making GiNaC classes out of STL containers.
Definition container.h:72
Lightweight wrapper for GiNaC's symbolic objects.
Definition ex.h:72
Symbolic matrices.
Definition matrix.h:37
This class is a wrapper around CLN-numbers within the GiNaC class hierarchy.
Definition numeric.h:81
Base class for print_contexts.
Definition print.h:101
Context for latex-parsable output.
Definition print.h:121
Interface to GiNaC's light-weight expression handles.
unsigned options
Definition factor.cpp:2473
size_t n
Definition factor.cpp:1431
size_t c
Definition factor.cpp:756
exset syms
Definition factor.cpp:2427
mvec m
Definition factor.cpp:757
Definition add.cpp:35
container< std::list > lst
Definition lst.h:31
std::map< ex, ex, ex_is_less > exmap
Definition basic.h:49
#define GINAC_DECLARE_REGISTERED_CLASS(classname, supername)
Macro for inclusion in the declaration of each registered class.
Definition registrar.h:151
size_t ni
Definition Gt.h:55
void check()
Definition Gt.cpp:79

This page is part of the GiNaC developer's reference. It was generated automatically by doxygen. For an introduction, see the tutorial.