1 /** @file integration_kernel.h
3 * Interface to GiNaC's integration kernels for iterated integrals. */
6 * GiNaC Copyright (C) 1999-2023 Johannes Gutenberg University Mainz, Germany
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.
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.
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
23 #ifndef GINAC_INTEGRATION_KERNEL_H
24 #define GINAC_INTEGRATION_KERNEL_H
31 #include <cln/complex.h>
36 ex ifactor(const numeric & n);
37 bool is_discriminant_of_quadratic_number_field(const numeric & n);
38 numeric kronecker_symbol(const numeric & a, const numeric & n);
39 numeric primitive_dirichlet_character(const numeric & n, const numeric & a);
40 numeric dirichlet_character(const numeric & n, const numeric & a, const numeric & N);
41 numeric generalised_Bernoulli_number(const numeric & k, const numeric & b);
42 ex Bernoulli_polynomial(const numeric & k, const ex & x);
46 * The base class for integration kernels for iterated integrals.
48 * This class represents the differential one-form
52 * The integration variable is a dummy variable and does not need to be specified.
55 class integration_kernel : public basic
57 GINAC_DECLARE_REGISTERED_CLASS(integration_kernel, basic)
62 // functions overriding virtual functions from base classes
64 ex series(const relational & r, int order, unsigned options = 0) const override;
68 // new virtual functions which can be overridden by derived classes
70 virtual bool has_trailing_zero(void) const;
71 virtual bool is_numeric(void) const;
72 virtual ex Laurent_series(const ex & x, int order) const;
73 virtual ex get_numerical_value(const ex & lambda, int N_trunc = 0) const;
76 virtual bool uses_Laurent_series() const;
77 virtual cln::cl_N series_coeff_impl(int i) const;
79 // non-virtual functions
81 size_t get_cache_size(void) const;
82 void set_cache_step(int cache_steps) const;
83 ex get_series_coeff(int i) const;
84 cln::cl_N series_coeff(int i) const;
87 ex get_numerical_value_impl(const ex & lambda, const ex & pre, int shift, int N_trunc) const;
88 void do_print(const print_context & c, unsigned level) const;
95 // cache is increased by steps of cache_step_size
96 mutable int cache_step_size;
97 // cache already computed series coefficients
98 mutable std::vector<cln::cl_N> series_vec;
102 GINAC_DECLARE_UNARCHIVER(integration_kernel);
106 * The basic integration kernel with a logarithmic singularity at the origin.
108 * This class represents the differential one-form
110 * L_0 = \frac{d\lambda}{\lambda}
114 class basic_log_kernel : public integration_kernel
116 GINAC_DECLARE_REGISTERED_CLASS(basic_log_kernel, integration_kernel)
121 // functions overriding virtual functions from base classes
125 cln::cl_N series_coeff_impl(int i) const override;
127 // new virtual functions which can be overridden by derived classes
132 // non-virtual functions
136 void do_print(const print_context & c, unsigned level) const;
140 // member variables :
146 GINAC_DECLARE_UNARCHIVER(basic_log_kernel);
150 * The integration kernel for multiple polylogarithms.
152 * This class represents the differential one-form
154 * \omega^{\mathrm{mpl}}(z) = \frac{d\lambda}{\lambda-z}
157 * For the case \f$ z=0 \f$ the class basic_log_kernel should be used.
160 class multiple_polylog_kernel : public integration_kernel
162 GINAC_DECLARE_REGISTERED_CLASS(multiple_polylog_kernel, integration_kernel)
166 multiple_polylog_kernel(const ex & z);
168 // functions overriding virtual functions from base classes
170 size_t nops() const override;
171 ex op(size_t i) const override;
172 ex & let_op(size_t i) override;
174 bool is_numeric(void) const override;
177 cln::cl_N series_coeff_impl(int i) const override;
179 // new virtual functions which can be overridden by derived classes
184 // non-virtual functions
188 void do_print(const print_context & c, unsigned level) const;
192 // member variables :
199 GINAC_DECLARE_UNARCHIVER(multiple_polylog_kernel);
205 * This class represents the differential one-form
207 * \omega^{\mathrm{ELi}}_{n;m}(x;y) = \mathrm{ELi}_{n;m}(x;y;\bar{q}) \frac{d\bar{q}}{\bar{q}}
211 class ELi_kernel : public integration_kernel
213 GINAC_DECLARE_REGISTERED_CLASS(ELi_kernel, integration_kernel)
217 ELi_kernel(const ex & n, const ex & m, const ex & x, const ex & y);
219 // functions overriding virtual functions from base classes
221 size_t nops() const override;
222 ex op(size_t i) const override;
223 ex & let_op(size_t i) override;
225 bool is_numeric(void) const override;
226 ex get_numerical_value(const ex & qbar, int N_trunc = 0) const override;
229 cln::cl_N series_coeff_impl(int i) const override;
231 // new virtual functions which can be overridden by derived classes
236 // non-virtual functions
240 void do_print(const print_context & c, unsigned level) const;
244 // member variables :
254 GINAC_DECLARE_UNARCHIVER(ELi_kernel);
260 * This class represents the differential one-form
262 * \omega^{\overline{\mathrm{E}}}_{n;m}(x;y) = \overline{\mathrm{E}}_{n;m}(x;y;\bar{q}) \frac{d\bar{q}}{\bar{q}}
266 class Ebar_kernel : public integration_kernel
268 GINAC_DECLARE_REGISTERED_CLASS(Ebar_kernel, integration_kernel)
272 Ebar_kernel(const ex & n, const ex & m, const ex & x, const ex & y);
274 // functions overriding virtual functions from base classes
276 size_t nops() const override;
277 ex op(size_t i) const override;
278 ex & let_op(size_t i) override;
280 bool is_numeric(void) const override;
281 ex get_numerical_value(const ex & qbar, int N_trunc = 0) const override;
284 cln::cl_N series_coeff_impl(int i) const override;
286 // new virtual functions which can be overridden by derived classes
291 // non-virtual functions
295 void do_print(const print_context & c, unsigned level) const;
299 // member variables :
309 GINAC_DECLARE_UNARCHIVER(Ebar_kernel);
313 * The kernel corresponding to integrating the Kronecker coefficient function \f$ g^{(n)}(z_j,K \tau) \f$
314 * in \f$ \tau \f$ (or equivalently in \f$ \bar{q} \f$).
316 * This class represents the differential one-form
318 * \omega^{\mathrm{Kronecker},\tau}_{n,K}(z_j) = \frac{C_n K (n-1)}{(2\pi i)^n} g^{(n)}(z_j,K \tau) \frac{d\bar{q}}{\bar{q}}
322 class Kronecker_dtau_kernel : public integration_kernel
324 GINAC_DECLARE_REGISTERED_CLASS(Kronecker_dtau_kernel, integration_kernel)
328 Kronecker_dtau_kernel(const ex & n, const ex & z, const ex & K = numeric(1), const ex & C_norm = numeric(1));
330 // functions overriding virtual functions from base classes
332 size_t nops() const override;
333 ex op(size_t i) const override;
334 ex & let_op(size_t i) override;
336 bool is_numeric(void) const override;
337 ex get_numerical_value(const ex & qbar, int N_trunc = 0) const override;
340 cln::cl_N series_coeff_impl(int i) const override;
342 // new virtual functions which can be overridden by derived classes
347 // non-virtual functions
351 void do_print(const print_context & c, unsigned level) const;
355 // member variables :
364 GINAC_DECLARE_UNARCHIVER(Kronecker_dtau_kernel);
369 * The kernel corresponding to integrating the Kronecker coefficient function \f$ g^{(n-1)}(z-z_j, K \tau) \f$
372 * This class represents the differential one-form
374 * \omega^{\mathrm{Kronecker},z}_{n,K}(z_j,\tau) = C_n (2\pi i)^{2-n} g^{(n-1)}(z-z_j, K \tau) dz
378 class Kronecker_dz_kernel : public integration_kernel
380 GINAC_DECLARE_REGISTERED_CLASS(Kronecker_dz_kernel, integration_kernel)
384 Kronecker_dz_kernel(const ex & n, const ex & z_j, const ex & tau, const ex & K = numeric(1), const ex & C_norm = numeric(1));
386 // functions overriding virtual functions from base classes
388 size_t nops() const override;
389 ex op(size_t i) const override;
390 ex & let_op(size_t i) override;
392 bool is_numeric(void) const override;
393 ex get_numerical_value(const ex & z, int N_trunc = 0) const override;
396 cln::cl_N series_coeff_impl(int i) const override;
398 // new virtual functions which can be overridden by derived classes
403 // non-virtual functions
407 void do_print(const print_context & c, unsigned level) const;
411 // member variables :
422 GINAC_DECLARE_UNARCHIVER(Kronecker_dz_kernel);
427 * The kernel corresponding to the Eisenstein series \f$ E_{k,N,a,b,K}(\tau) \f$.
429 * This class represents the differential one-form
431 * \omega^{\mathrm{Eisenstein}}_{k,N,a,b,K} = C_k E_{k,N,a,b,K}(\tau) \frac{d\bar{q}_N}{\bar{q}_N}
434 * The integers a and b are either one or the discriminant of a quadratic number field.
435 * This class represents Eisenstein series, which can be defined by primitive Dirichlet characters from the Kronecker symbol.
436 * This implies that the characters take the values -1,0,1, i.e. no higher roots of unity occur.
437 * The \f[ \bar{q} \f]-expansion has then rational coefficients.
439 * Ref.: W. Stein, Modular Forms: A Computational Approach, Chapter 5
442 class Eisenstein_kernel : public integration_kernel
444 GINAC_DECLARE_REGISTERED_CLASS(Eisenstein_kernel, integration_kernel)
448 Eisenstein_kernel(const ex & k, const ex & N, const ex & a, const ex & b, const ex & K, const ex & C_norm = numeric(1));
450 // functions overriding virtual functions from base classes
452 ex series(const relational & r, int order, unsigned options = 0) const override;
454 size_t nops() const override;
455 ex op(size_t i) const override;
456 ex & let_op(size_t i) override;
458 bool is_numeric(void) const override;
459 ex Laurent_series(const ex & x, int order) const override;
460 ex get_numerical_value(const ex & qbar, int N_trunc = 0) const override;
463 bool uses_Laurent_series() const override;
465 // new virtual functions which can be overridden by derived classes
470 // non-virtual functions
472 ex q_expansion_modular_form(const ex & q, int order) const;
475 void do_print(const print_context & c, unsigned level) const;
479 // member variables :
491 GINAC_DECLARE_UNARCHIVER(Eisenstein_kernel);
496 * The kernel corresponding to the Eisenstein series \f$ h_{k,N,r,s}(\tau) \f$.
498 * This class represents the differential one-form
500 * \omega^{\mathrm{Eisenstein,h}}_{k,N,r,s} = C_k h_{k,N,r,s}(\tau) \frac{d\bar{q}_N}{\bar{q}_N}
504 class Eisenstein_h_kernel : public integration_kernel
506 GINAC_DECLARE_REGISTERED_CLASS(Eisenstein_h_kernel, integration_kernel)
510 Eisenstein_h_kernel(const ex & k, const ex & N, const ex & r, const ex & s, const ex & C_norm = numeric(1));
512 // functions overriding virtual functions from base classes
514 ex series(const relational & r, int order, unsigned options = 0) const override;
516 size_t nops() const override;
517 ex op(size_t i) const override;
518 ex & let_op(size_t i) override;
520 bool is_numeric(void) const override;
521 ex Laurent_series(const ex & x, int order) const override;
522 ex get_numerical_value(const ex & qbar, int N_trunc = 0) const override;
525 bool uses_Laurent_series() const override;
527 // new virtual functions which can be overridden by derived classes
532 // non-virtual functions
534 ex coefficient_a0(const numeric & k, const numeric & r, const numeric & s, const numeric & N) const;
535 ex coefficient_an(const numeric & n, const numeric & k, const numeric & r, const numeric & s, const numeric & N) const;
536 ex q_expansion_modular_form(const ex & q, int order) const;
539 void do_print(const print_context & c, unsigned level) const;
543 // member variables :
554 GINAC_DECLARE_UNARCHIVER(Eisenstein_h_kernel);
559 * A kernel corresponding to a polynomial in Eisenstein series.
561 * This class represents the differential one-form
563 * \omega^{\mathrm{modular}}(P_k(\eta^{(1)}_{k_1}, \dots, \eta^{(r)}_{k_r})) = C_k P_k(\eta^{(1)}_{k_1}, \dots, \eta^{(r)}_{k_r}) \frac{d\bar{q}_N}{\bar{q}_N}.
567 class modular_form_kernel : public integration_kernel
569 GINAC_DECLARE_REGISTERED_CLASS(modular_form_kernel, integration_kernel)
573 modular_form_kernel(const ex & k, const ex & P, const ex & C_norm = numeric(1));
575 // functions overriding virtual functions from base classes
577 ex series(const relational & r, int order, unsigned options = 0) const override;
579 size_t nops() const override;
580 ex op(size_t i) const override;
581 ex & let_op(size_t i) override;
583 bool is_numeric(void) const override;
584 ex Laurent_series(const ex & qbar, int order) const override;
585 ex get_numerical_value(const ex & qbar, int N_trunc = 0) const override;
588 bool uses_Laurent_series() const override;
590 // new virtual functions which can be overridden by derived classes
595 // non-virtual functions
597 ex q_expansion_modular_form(const ex & q, int order) const;
600 void do_print(const print_context & c, unsigned level) const;
604 // member variables :
613 GINAC_DECLARE_UNARCHIVER(modular_form_kernel);
618 * A user-defined integration kernel.
619 * The input is an expression \f$ f \f$, depending on a variable \f$ x \f$.
620 * It is assumed that \f$ f \f$ has a Laurent expansion around \f$ x=0 \f$ and
621 * maximally a simple pole at \f$ x=0 \f$.
624 class user_defined_kernel : public integration_kernel
626 GINAC_DECLARE_REGISTERED_CLASS(user_defined_kernel, integration_kernel)
630 user_defined_kernel(const ex & f, const ex & x);
632 // functions overriding virtual functions from base classes
634 size_t nops() const override;
635 ex op(size_t i) const override;
636 ex & let_op(size_t i) override;
638 bool is_numeric(void) const override;
639 ex Laurent_series(const ex & x, int order) const override;
642 bool uses_Laurent_series() const override;
644 // new virtual functions which can be overridden by derived classes
649 // non-virtual functions
653 void do_print(const print_context & c, unsigned level) const;
657 // member variables :
665 GINAC_DECLARE_UNARCHIVER(user_defined_kernel);
669 #endif // ndef GINAC_INTEGRATION_KERNEL_H