X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Finifcns.cpp;h=70eaf758a104bf0564d78a647e1e0e4960fc42ec;hp=28cadfb174ecf16680dd18d37d9af8ad0f1af1d2;hb=83911244e28161e51b863851726e574c792b1f4c;hpb=4afb5bbe2c0b0a60928120a042997ba7d89e8f5c diff --git a/ginac/inifcns.cpp b/ginac/inifcns.cpp index 28cadfb1..70eaf758 100644 --- a/ginac/inifcns.cpp +++ b/ginac/inifcns.cpp @@ -3,7 +3,7 @@ * Implementation of GiNaC's initially known functions. */ /* - * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2000 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -33,19 +33,42 @@ #include "numeric.h" #include "power.h" #include "relational.h" -#include "series.h" +#include "pseries.h" #include "symbol.h" #include "utils.h" -#ifndef NO_GINAC_NAMESPACE +#ifndef NO_NAMESPACE_GINAC namespace GiNaC { -#endif // ndef NO_GINAC_NAMESPACE +#endif // ndef NO_NAMESPACE_GINAC + +////////// +// absolute value +////////// + +static ex abs_evalf(const ex & x) +{ + BEGIN_TYPECHECK + TYPECHECK(x,numeric) + END_TYPECHECK(abs(x)) + + return abs(ex_to_numeric(x)); +} + +static ex abs_eval(const ex & x) +{ + if (is_ex_exactly_of_type(x, numeric)) + return abs(ex_to_numeric(x)); + else + return abs(x).hold(); +} + +REGISTER_FUNCTION(abs, abs_eval, abs_evalf, NULL, NULL); ////////// // dilogarithm ////////// -static ex Li2_eval(ex const & x) +static ex Li2_eval(const ex & x) { if (x.is_zero()) return x; @@ -62,7 +85,7 @@ REGISTER_FUNCTION(Li2, Li2_eval, NULL, NULL, NULL); // trilogarithm ////////// -static ex Li3_eval(ex const & x) +static ex Li3_eval(const ex & x) { if (x.is_zero()) return x; @@ -75,12 +98,12 @@ REGISTER_FUNCTION(Li3, Li3_eval, NULL, NULL, NULL); // factorial ////////// -static ex factorial_evalf(ex const & x) +static ex factorial_evalf(const ex & x) { return factorial(x).hold(); } -static ex factorial_eval(ex const & x) +static ex factorial_eval(const ex & x) { if (is_ex_exactly_of_type(x, numeric)) return factorial(ex_to_numeric(x)); @@ -94,12 +117,12 @@ REGISTER_FUNCTION(factorial, factorial_eval, factorial_evalf, NULL, NULL); // binomial ////////// -static ex binomial_evalf(ex const & x, ex const & y) +static ex binomial_evalf(const ex & x, const ex & y) { return binomial(x, y).hold(); } -static ex binomial_eval(ex const & x, ex const &y) +static ex binomial_eval(const ex & x, const ex &y) { if (is_ex_exactly_of_type(x, numeric) && is_ex_exactly_of_type(y, numeric)) return binomial(ex_to_numeric(x), ex_to_numeric(y)); @@ -113,7 +136,7 @@ REGISTER_FUNCTION(binomial, binomial_eval, binomial_evalf, NULL, NULL); // Order term function (for truncated power series) ////////// -static ex Order_eval(ex const & x) +static ex Order_eval(const ex & x) { if (is_ex_exactly_of_type(x, numeric)) { @@ -132,12 +155,12 @@ static ex Order_eval(ex const & x) return Order(x).hold(); } -static ex Order_series(ex const & x, symbol const & s, ex const & point, int order) +static ex Order_series(const ex & x, const symbol & s, const ex & point, int order) { - // Just wrap the function into a series object + // Just wrap the function into a pseries object epvector new_seq; new_seq.push_back(expair(Order(_ex1()), numeric(min(x.ldegree(s), order)))); - return series(s, point, new_seq); + return pseries(s, point, new_seq); } REGISTER_FUNCTION(Order, Order_eval, NULL, NULL, Order_series); @@ -146,7 +169,7 @@ REGISTER_FUNCTION(Order, Order_eval, NULL, NULL, Order_series); // Solve linear system ////////// -ex lsolve(ex const &eqns, ex const &symbols) +ex lsolve(const ex &eqns, const ex &symbols) { // solve a system of linear equations if (eqns.info(info_flags::relation_equal)) { @@ -165,7 +188,7 @@ ex lsolve(ex const &eqns, ex const &symbols) if (!eqns.info(info_flags::list)) { throw(std::invalid_argument("lsolve: 1st argument must be a list")); } - for (int i=0; i