1 /** @file integration_kernel.h
3 * Interface to GiNaC's integration kernels for iterated integrals. */
6 * GiNaC Copyright (C) 1999-2020 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
30 #include <cln/complex.h>
35 ex ifactor(const numeric & n);
36 bool is_discriminant_of_quadratic_number_field(const numeric & n);
37 numeric kronecker_symbol(const numeric & a, const numeric & n);
38 numeric primitive_dirichlet_character(const numeric & n, const numeric & a);
39 numeric dirichlet_character(const numeric & n, const numeric & a, const numeric & N);
40 numeric generalised_Bernoulli_number(const numeric & k, const numeric & b);
41 ex Bernoulli_polynomial(const numeric & k, const ex & x);
45 * The base class for integration kernels for iterated integrals.
47 * This class represents the differential one-form
51 * The integration variable is a dummy variable and does not need to be specified.
54 class integration_kernel : public basic
56 GINAC_DECLARE_REGISTERED_CLASS(integration_kernel, basic)
61 // functions overriding virtual functions from base classes
63 ex series(const relational & r, int order, unsigned options = 0) const override;
67 // new virtual functions which can be overridden by derived classes
69 virtual bool has_trailing_zero(void) const;
70 virtual bool is_numeric(void) const;
71 virtual ex Laurent_series(const ex & x, int order) const;
72 virtual ex get_numerical_value(const ex & lambda, int N_trunc = 0) const;
75 virtual bool uses_Laurent_series() const;
76 virtual cln::cl_N series_coeff_impl(int i) const;
78 // non-virtual functions
80 size_t get_cache_size(void) const;
81 void set_cache_step(int cache_steps) const;
82 ex get_series_coeff(int i) const;
83 cln::cl_N series_coeff(int i) const;
86 ex get_numerical_value_impl(const ex & lambda, const ex & pre, int shift, int N_trunc) const;
87 void do_print(const print_context & c, unsigned level) const;
94 // cache is increased by steps of cache_step_size
95 mutable int cache_step_size;
96 // cache already computed series coefficients
97 mutable std::vector<cln::cl_N> series_vec;
101 GINAC_DECLARE_UNARCHIVER(integration_kernel);
105 * The basic integration kernel with a logarithmic singularity at the origin.
107 * This class represents the differential one-form
109 * L_0 = \frac{d\lambda}{\lambda}
113 class basic_log_kernel : public integration_kernel
115 GINAC_DECLARE_REGISTERED_CLASS(basic_log_kernel, integration_kernel)
120 // functions overriding virtual functions from base classes
124 cln::cl_N series_coeff_impl(int i) const override;
126 // new virtual functions which can be overridden by derived classes
131 // non-virtual functions
135 void do_print(const print_context & c, unsigned level) const;
139 // member variables :
145 GINAC_DECLARE_UNARCHIVER(basic_log_kernel);
149 * The integration kernel for multiple polylogarithms.
151 * This class represents the differential one-form
153 * \omega^{\mathrm{mpl}}(z) = \frac{d\lambda}{\lambda-z}
156 * For the case \f$ z=0 \f$ the class basic_log_kernel should be used.
159 class multiple_polylog_kernel : public integration_kernel
161 GINAC_DECLARE_REGISTERED_CLASS(multiple_polylog_kernel, integration_kernel)
165 multiple_polylog_kernel(const ex & z);
167 // functions overriding virtual functions from base classes
169 size_t nops() const override;
170 ex op(size_t i) const override;
171 ex & let_op(size_t i) override;
173 bool is_numeric(void) const override;
176 cln::cl_N series_coeff_impl(int i) const override;
178 // new virtual functions which can be overridden by derived classes
183 // non-virtual functions
187 void do_print(const print_context & c, unsigned level) const;
191 // member variables :
198 GINAC_DECLARE_UNARCHIVER(multiple_polylog_kernel);
204 * This class represents the differential one-form
206 * \omega^{\mathrm{ELi}}_{n;m}(x;y) = \mathrm{ELi}_{n;m}(x;y;\bar{q}) \frac{d\bar{q}}{\bar{q}}
210 class ELi_kernel : public integration_kernel
212 GINAC_DECLARE_REGISTERED_CLASS(ELi_kernel, integration_kernel)
216 ELi_kernel(const ex & n, const ex & m, const ex & x, const ex & y);
218 // functions overriding virtual functions from base classes
220 size_t nops() const override;
221 ex op(size_t i) const override;
222 ex & let_op(size_t i) override;
224 bool is_numeric(void) const override;
225 ex get_numerical_value(const ex & qbar, int N_trunc = 0) const override;
228 cln::cl_N series_coeff_impl(int i) const override;
230 // new virtual functions which can be overridden by derived classes
235 // non-virtual functions
239 void do_print(const print_context & c, unsigned level) const;
243 // member variables :
253 GINAC_DECLARE_UNARCHIVER(ELi_kernel);
259 * This class represents the differential one-form
261 * \omega^{\overline{\mathrm{E}}}_{n;m}(x;y) = \overline{\mathrm{E}}_{n;m}(x;y;\bar{q}) \frac{d\bar{q}}{\bar{q}}
265 class Ebar_kernel : public integration_kernel
267 GINAC_DECLARE_REGISTERED_CLASS(Ebar_kernel, integration_kernel)
271 Ebar_kernel(const ex & n, const ex & m, const ex & x, const ex & y);
273 // functions overriding virtual functions from base classes
275 size_t nops() const override;
276 ex op(size_t i) const override;
277 ex & let_op(size_t i) override;
279 bool is_numeric(void) const override;
280 ex get_numerical_value(const ex & qbar, int N_trunc = 0) const override;
283 cln::cl_N series_coeff_impl(int i) const override;
285 // new virtual functions which can be overridden by derived classes
290 // non-virtual functions
294 void do_print(const print_context & c, unsigned level) const;
298 // member variables :
308 GINAC_DECLARE_UNARCHIVER(Ebar_kernel);
312 * The kernel corresponding to integrating the Kronecker coefficient function \f$ g^{(n)}(z_j,K \tau) \f$
313 * in \f$ \tau \f$ (or equivalently in \f$ \bar{q} \f$).
315 * This class represents the differential one-form
317 * \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}}
321 class Kronecker_dtau_kernel : public integration_kernel
323 GINAC_DECLARE_REGISTERED_CLASS(Kronecker_dtau_kernel, integration_kernel)
327 Kronecker_dtau_kernel(const ex & n, const ex & z, const ex & K = numeric(1), const ex & C_norm = numeric(1));
329 // functions overriding virtual functions from base classes
331 size_t nops() const override;
332 ex op(size_t i) const override;
333 ex & let_op(size_t i) override;
335 bool is_numeric(void) const override;
336 ex get_numerical_value(const ex & qbar, int N_trunc = 0) const override;
339 cln::cl_N series_coeff_impl(int i) const override;
341 // new virtual functions which can be overridden by derived classes
346 // non-virtual functions
350 void do_print(const print_context & c, unsigned level) const;
354 // member variables :
363 GINAC_DECLARE_UNARCHIVER(Kronecker_dtau_kernel);
368 * The kernel corresponding to integrating the Kronecker coefficient function \f$ g^{(n-1)}(z-z_j, K \tau) \f$
371 * This class represents the differential one-form
373 * \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
377 class Kronecker_dz_kernel : public integration_kernel
379 GINAC_DECLARE_REGISTERED_CLASS(Kronecker_dz_kernel, integration_kernel)
383 Kronecker_dz_kernel(const ex & n, const ex & z_j, const ex & tau, const ex & K = numeric(1), const ex & C_norm = numeric(1));
385 // functions overriding virtual functions from base classes
387 size_t nops() const override;
388 ex op(size_t i) const override;
389 ex & let_op(size_t i) override;
391 bool is_numeric(void) const override;
392 ex get_numerical_value(const ex & z, int N_trunc = 0) const override;
395 cln::cl_N series_coeff_impl(int i) const override;
397 // new virtual functions which can be overridden by derived classes
402 // non-virtual functions
406 void do_print(const print_context & c, unsigned level) const;
410 // member variables :
421 GINAC_DECLARE_UNARCHIVER(Kronecker_dz_kernel);
426 * The kernel corresponding to the Eisenstein series \f$ E_{k,N,a,b,K}(\tau) \f$.
428 * This class represents the differential one-form
430 * \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}
433 * The integers a and b are either one or the discriminant of a quadratic number field.
434 * This class represents Eisenstein series, which can be defined by primitive Dirichlet characters from the Kronecker symbol.
435 * This implies that the characters take the values -1,0,1, i.e. no higher roots of unity occur.
436 * The \f[ \bar{q} \f]-expansion has then rational coefficients.
438 * Ref.: W. Stein, Modular Forms: A Computational Approach, Chapter 5
441 class Eisenstein_kernel : public integration_kernel
443 GINAC_DECLARE_REGISTERED_CLASS(Eisenstein_kernel, integration_kernel)
447 Eisenstein_kernel(const ex & k, const ex & N, const ex & a, const ex & b, const ex & K, const ex & C_norm = numeric(1));
449 // functions overriding virtual functions from base classes
451 ex series(const relational & r, int order, unsigned options = 0) const override;
453 size_t nops() const override;
454 ex op(size_t i) const override;
455 ex & let_op(size_t i) override;
457 bool is_numeric(void) const override;
458 ex Laurent_series(const ex & x, int order) const override;
459 ex get_numerical_value(const ex & qbar, int N_trunc = 0) const override;
462 bool uses_Laurent_series() const override;
464 // new virtual functions which can be overridden by derived classes
469 // non-virtual functions
471 ex q_expansion_modular_form(const ex & q, int order) const;
474 void do_print(const print_context & c, unsigned level) const;
478 // member variables :
490 GINAC_DECLARE_UNARCHIVER(Eisenstein_kernel);
495 * The kernel corresponding to the Eisenstein series \f$ h_{k,N,r,s}(\tau) \f$.
497 * This class represents the differential one-form
499 * \omega^{\mathrm{Eisenstein,h}}_{k,N,r,s} = C_k h_{k,N,r,s}(\tau) \frac{d\bar{q}_N}{\bar{q}_N}
503 class Eisenstein_h_kernel : public integration_kernel
505 GINAC_DECLARE_REGISTERED_CLASS(Eisenstein_h_kernel, integration_kernel)
509 Eisenstein_h_kernel(const ex & k, const ex & N, const ex & r, const ex & s, const ex & C_norm = numeric(1));
511 // functions overriding virtual functions from base classes
513 ex series(const relational & r, int order, unsigned options = 0) const override;
515 size_t nops() const override;
516 ex op(size_t i) const override;
517 ex & let_op(size_t i) override;
519 bool is_numeric(void) const override;
520 ex Laurent_series(const ex & x, int order) const override;
521 ex get_numerical_value(const ex & qbar, int N_trunc = 0) const override;
524 bool uses_Laurent_series() const override;
526 // new virtual functions which can be overridden by derived classes
531 // non-virtual functions
533 ex coefficient_a0(const numeric & k, const numeric & r, const numeric & s, const numeric & N) const;
534 ex coefficient_an(const numeric & n, const numeric & k, const numeric & r, const numeric & s, const numeric & N) const;
535 ex q_expansion_modular_form(const ex & q, int order) const;
538 void do_print(const print_context & c, unsigned level) const;
542 // member variables :
553 GINAC_DECLARE_UNARCHIVER(Eisenstein_h_kernel);
558 * A kernel corresponding to a polynomial in Eisenstein series.
560 * This class represents the differential one-form
562 * \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}.
566 class modular_form_kernel : public integration_kernel
568 GINAC_DECLARE_REGISTERED_CLASS(modular_form_kernel, integration_kernel)
572 modular_form_kernel(const ex & k, const ex & P, const ex & C_norm = numeric(1));
574 // functions overriding virtual functions from base classes
576 ex series(const relational & r, int order, unsigned options = 0) const override;
578 size_t nops() const override;
579 ex op(size_t i) const override;
580 ex & let_op(size_t i) override;
582 bool is_numeric(void) const override;
583 ex Laurent_series(const ex & qbar, int order) const override;
584 ex get_numerical_value(const ex & qbar, int N_trunc = 0) const override;
587 bool uses_Laurent_series() const override;
589 // new virtual functions which can be overridden by derived classes
594 // non-virtual functions
596 ex q_expansion_modular_form(const ex & q, int order) const;
599 void do_print(const print_context & c, unsigned level) const;
603 // member variables :
612 GINAC_DECLARE_UNARCHIVER(modular_form_kernel);
617 * A user-defined integration kernel.
618 * The input is an expression \f$ f \f$, depending on a variable \f$ x \f$.
619 * It is assumed that \f$ f \f$ has a Laurent expansion around \f$ x=0 \f$ and
620 * maximally a simple pole at \f$ x=0 \f$.
623 class user_defined_kernel : public integration_kernel
625 GINAC_DECLARE_REGISTERED_CLASS(user_defined_kernel, integration_kernel)
629 user_defined_kernel(const ex & f, const ex & x);
631 // functions overriding virtual functions from base classes
633 size_t nops() const override;
634 ex op(size_t i) const override;
635 ex & let_op(size_t i) override;
637 bool is_numeric(void) const override;
638 ex Laurent_series(const ex & x, int order) const override;
641 bool uses_Laurent_series() const override;
643 // new virtual functions which can be overridden by derived classes
648 // non-virtual functions
652 void do_print(const print_context & c, unsigned level) const;
656 // member variables :
664 GINAC_DECLARE_UNARCHIVER(user_defined_kernel);
668 #endif // ndef GINAC_INTEGRATION_KERNEL_H