]> www.ginac.de Git - ginac.git/blob - ginac/inifcns.h
registered_class_info: use typeid() instead of tinfo_static.
[ginac.git] / ginac / inifcns.h
1 /** @file inifcns.h
2  *
3  *  Interface to GiNaC's initially known functions. */
4
5 /*
6  *  GiNaC Copyright (C) 1999-2008 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_INIFCNS_H__
24 #define __GINAC_INIFCNS_H__
25
26 #include "numeric.h"
27 #include "function.h"
28 #include "ex.h"
29
30 namespace GiNaC {
31
32 /** Complex conjugate. */
33 DECLARE_FUNCTION_1P(conjugate_function)
34
35 /** Real part. */
36 DECLARE_FUNCTION_1P(real_part_function)
37
38 /** Imaginary part. */
39 DECLARE_FUNCTION_1P(imag_part_function)
40         
41 /** Absolute value. */
42 DECLARE_FUNCTION_1P(abs)
43         
44 /** Step function. */
45 DECLARE_FUNCTION_1P(step)
46         
47 /** Complex sign. */
48 DECLARE_FUNCTION_1P(csgn)
49
50 /** Eta function: log(a*b) == log(a) + log(b) + eta(a, b). */
51 DECLARE_FUNCTION_2P(eta)
52
53 /** Sine. */
54 DECLARE_FUNCTION_1P(sin)
55
56 /** Cosine. */
57 DECLARE_FUNCTION_1P(cos)
58
59 /** Tangent. */
60 DECLARE_FUNCTION_1P(tan)
61
62 /** Exponential function. */
63 DECLARE_FUNCTION_1P(exp)
64
65 /** Natural logarithm. */
66 DECLARE_FUNCTION_1P(log)
67
68 /** Inverse sine (arc sine). */
69 DECLARE_FUNCTION_1P(asin)
70
71 /** Inverse cosine (arc cosine). */
72 DECLARE_FUNCTION_1P(acos)
73
74 /** Inverse tangent (arc tangent). */
75 DECLARE_FUNCTION_1P(atan)
76
77 /** Inverse tangent with two arguments. */
78 DECLARE_FUNCTION_2P(atan2)
79
80 /** Hyperbolic Sine. */
81 DECLARE_FUNCTION_1P(sinh)
82
83 /** Hyperbolic Cosine. */
84 DECLARE_FUNCTION_1P(cosh)
85
86 /** Hyperbolic Tangent. */
87 DECLARE_FUNCTION_1P(tanh)
88
89 /** Inverse hyperbolic Sine (area hyperbolic sine). */
90 DECLARE_FUNCTION_1P(asinh)
91
92 /** Inverse hyperbolic Cosine (area hyperbolic cosine). */
93 DECLARE_FUNCTION_1P(acosh)
94
95 /** Inverse hyperbolic Tangent (area hyperbolic tangent). */
96 DECLARE_FUNCTION_1P(atanh)
97
98 /** Dilogarithm. */
99 DECLARE_FUNCTION_1P(Li2)
100
101 /** Trilogarithm. */
102 DECLARE_FUNCTION_1P(Li3)
103
104 /** Derivatives of Riemann's Zeta-function. */
105 DECLARE_FUNCTION_2P(zetaderiv)
106
107 // overloading at work: we cannot use the macros here
108 /** Multiple zeta value including Riemann's zeta-function. */
109 class zeta1_SERIAL { public: static unsigned serial; };
110 template<typename T1>
111 inline function zeta(const T1& p1) {
112         return function(zeta1_SERIAL::serial, ex(p1));
113 }
114 /** Alternating Euler sum or colored MZV. */
115 class zeta2_SERIAL { public: static unsigned serial; };
116 template<typename T1, typename T2>
117 inline function zeta(const T1& p1, const T2& p2) {
118         return function(zeta2_SERIAL::serial, ex(p1), ex(p2));
119 }
120 class zeta_SERIAL;
121 template<> inline bool is_the_function<zeta_SERIAL>(const ex& x)
122 {
123         return is_the_function<zeta1_SERIAL>(x) || is_the_function<zeta2_SERIAL>(x);
124 }
125
126 // overloading at work: we cannot use the macros here
127 /** Generalized multiple polylogarithm. */
128 class G2_SERIAL { public: static unsigned serial; };
129 template<typename T1, typename T2>
130 inline function G(const T1& x, const T2& y) {
131         return function(G2_SERIAL::serial, ex(x), ex(y));
132 }
133 /** Generalized multiple polylogarithm with explicit imaginary parts. */
134 class G3_SERIAL { public: static unsigned serial; };
135 template<typename T1, typename T2, typename T3>
136 inline function G(const T1& x, const T2& s, const T3& y) {
137         return function(G3_SERIAL::serial, ex(x), ex(s), ex(y));
138 }
139 class G_SERIAL;
140 template<> inline bool is_the_function<G_SERIAL>(const ex& x)
141 {
142         return is_the_function<G2_SERIAL>(x) || is_the_function<G3_SERIAL>(x);
143 }
144
145 /** Polylogarithm and multiple polylogarithm. */
146 DECLARE_FUNCTION_2P(Li)
147
148 /** Nielsen's generalized polylogarithm. */
149 DECLARE_FUNCTION_3P(S)
150
151 /** Harmonic polylogarithm. */
152 DECLARE_FUNCTION_2P(H)
153
154 /** Gamma-function. */
155 DECLARE_FUNCTION_1P(lgamma)
156 DECLARE_FUNCTION_1P(tgamma)
157
158 /** Beta-function. */
159 DECLARE_FUNCTION_2P(beta)
160
161 // overloading at work: we cannot use the macros here
162 /** Psi-function (aka digamma-function). */
163 class psi1_SERIAL { public: static unsigned serial; };
164 template<typename T1>
165 inline function psi(const T1 & p1) {
166         return function(psi1_SERIAL::serial, ex(p1));
167 }
168 /** Derivatives of Psi-function (aka polygamma-functions). */
169 class psi2_SERIAL { public: static unsigned serial; };
170 template<typename T1, typename T2>
171 inline function psi(const T1 & p1, const T2 & p2) {
172         return function(psi2_SERIAL::serial, ex(p1), ex(p2));
173 }
174 class psi_SERIAL;
175 template<> inline bool is_the_function<psi_SERIAL>(const ex & x)
176 {
177         return is_the_function<psi1_SERIAL>(x) || is_the_function<psi2_SERIAL>(x);
178 }
179         
180 /** Factorial function. */
181 DECLARE_FUNCTION_1P(factorial)
182
183 /** Binomial function. */
184 DECLARE_FUNCTION_2P(binomial)
185
186 /** Order term function (for truncated power series). */
187 DECLARE_FUNCTION_1P(Order)
188
189 ex lsolve(const ex &eqns, const ex &symbols, unsigned options = solve_algo::automatic);
190
191 /** Find a real root of real-valued function f(x) numerically within a given
192  *  interval. The function must change sign across interval. Uses Newton-
193  *  Raphson method combined with bisection in order to guarantee convergence.
194  *
195  *  @param f  Function f(x)
196  *  @param x  Symbol f(x)
197  *  @param x1  lower interval limit
198  *  @param x2  upper interval limit
199  *  @exception runtime_error (if interval is invalid). */
200 const numeric fsolve(const ex& f, const symbol& x, const numeric& x1, const numeric& x2);
201
202 /** Check whether a function is the Order (O(n)) function. */
203 inline bool is_order_function(const ex & e)
204 {
205         return is_ex_the_function(e, Order);
206 }
207
208 /** Converts a given list containing parameters for H in Remiddi/Vermaseren notation into
209  *  the corresponding GiNaC functions.
210  */
211 ex convert_H_to_Li(const ex& parameterlst, const ex& arg);
212
213 } // namespace GiNaC
214
215 #endif // ndef __GINAC_INIFCNS_H__