3 * Interface to GiNaC's initially known functions. */
6 * GiNaC Copyright (C) 1999-2006 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_INIFCNS_H__
24 #define __GINAC_INIFCNS_H__
32 /** Absolute value. */
33 class abs_function : public function
35 GINAC_DECLARE_FUNCTION_1P(abs_function)
37 virtual ex conjugate() const;
38 virtual ex eval(int level = 0) const;
39 virtual ex evalf(int level = 0) const;
40 virtual ex power_law(const ex& exp) const;
42 void do_print_csrc_float(const print_context& c, unsigned level) const;
43 void do_print_latex(const print_context& c, unsigned level) const;
46 template<typename T1> inline abs_function abs(const T1& x1) { return abs_function(x1); }
47 inline abs_function abs(double x1) { return abs_function(x1); }
48 inline abs_function abs(float x1) { return abs_function(x1); }
50 /** Complex conjugate. */
51 GINAC_FUNCTION_1P(conjugate,
52 GINAC_FUNCTION_conjugate
55 GINAC_FUNCTION_print_latex)
58 GINAC_FUNCTION_1P(csgn,
59 GINAC_FUNCTION_conjugate
62 GINAC_FUNCTION_power_law
63 GINAC_FUNCTION_series)
66 class step_function : public function
68 GINAC_DECLARE_FUNCTION_1P(step_function)
70 virtual ex conjugate() const;
71 virtual ex eval(int level = 0) const;
72 virtual ex evalf(int level = 0) const;
73 virtual ex series(const relational& r, int order, unsigned options = 0) const;
76 template<typename T1> inline step_function step(const T1& x1) { return step_function(x1); }
78 /** Factorial function. */
79 class factorial_function : public function
81 GINAC_DECLARE_FUNCTION_1P(factorial_function)
83 virtual ex conjugate() const;
84 virtual ex eval(int level = 0) const;
85 virtual ex evalf(int level = 0) const;
87 void do_print_dflt_latex(const print_context& c, unsigned level) const;
90 template<typename T1> inline factorial_function factorial(const T1& x1) { return factorial_function(x1); }
92 /** Binomial function. */
93 class binomial_function : public function
95 GINAC_DECLARE_FUNCTION_2P(binomial_function)
97 virtual ex conjugate() const;
98 virtual ex eval(int level = 0) const;
99 virtual ex evalf(int level = 0) const;
101 ex sym(const ex& x, const numeric& y) const;
104 template<typename T1, typename T2> inline binomial_function binomial(const T1& x1, const T2& x2) { return binomial_function(x1, x2); }
106 /** Order term function (for truncated power series). */
107 class Order_function : public function
109 GINAC_DECLARE_FUNCTION_1P(Order_function)
111 virtual ex conjugate() const;
112 virtual ex derivative(const symbol& s) const;
113 virtual ex eval(int level = 0) const;
114 virtual ex series(const relational& r, int order, unsigned options = 0) const;
116 void do_print_latex(const print_context& c, unsigned level) const;
119 template<typename T1> inline Order_function Order(const T1& x1) { return Order_function(x1); }
121 /** Abstract derivative of functions. */
122 class function_derivative_function : public function
124 GINAC_DECLARE_FUNCTION_2P(function_derivative_function)
126 virtual ex derivative(const symbol& s) const;
127 virtual ex eval(int level = 0) const;
129 void do_print_dflt(const print_context& c, unsigned level) const;
130 void do_print_tree(const print_tree& c, unsigned level) const;
133 template<typename T1, typename T2>
134 inline function_derivative_function function_derivative(const T1& x1, const T2& x2) { return function_derivative_function(x1, x2); }
136 ex lsolve(const ex& eqns, const ex& symbols, unsigned options = solve_algo::automatic);
138 /** Find a real root of real-valued function f(x) numerically within a given
139 * interval. The function must change sign across interval. Uses Newton-
140 * Raphson method combined with bisection in order to guarantee convergence.
142 * @param f Function f(x)
143 * @param x Symbol f(x)
144 * @param x1 lower interval limit
145 * @param x2 upper interval limit
146 * @exception runtime_error (if interval is invalid). */
147 const numeric fsolve(const ex& f, const symbol& x, const numeric& x1, const numeric& x2);
151 #endif // ndef __GINAC_INIFCNS_H__