X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Finifcns_gamma.cpp;h=8d01127b9fc53490ab1d633e45342839b4739733;hp=15b1a9a5e851ea19dc68992a576de7eee5c0febe;hb=ba0b56c5ac76274c5d748eaa29fbd83cb1d4fb9e;hpb=e7cc6a764ff67b5885d6633385fac23ccc1dc9a7 diff --git a/ginac/inifcns_gamma.cpp b/ginac/inifcns_gamma.cpp index 15b1a9a5..8d01127b 100644 --- a/ginac/inifcns_gamma.cpp +++ b/ginac/inifcns_gamma.cpp @@ -4,7 +4,7 @@ * some related stuff. */ /* - * GiNaC Copyright (C) 1999-2002 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2004 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 @@ -30,6 +30,7 @@ #include "numeric.h" #include "power.h" #include "relational.h" +#include "operators.h" #include "symbol.h" #include "symmetry.h" #include "utils.h" @@ -97,7 +98,7 @@ static ex lgamma_series(const ex & arg, // from which follows // series(lgamma(x),x==-m,order) == // series(lgamma(x+m+1)-log(x)...-log(x+m)),x==-m,order); - const ex arg_pt = arg.subs(rel); + const ex arg_pt = arg.subs(rel, subs_options::no_pattern); if (!arg_pt.info(info_flags::integer) || arg_pt.info(info_flags::positive)) throw do_taylor(); // caught by function::series() // if we got here we have to care for a simple pole of tgamma(-m): @@ -192,8 +193,8 @@ static ex tgamma_series(const ex & arg, // tgamma(x) == tgamma(x+1) / x // from which follows // series(tgamma(x),x==-m,order) == - // series(tgamma(x+m+1)/(x*(x+1)*...*(x+m)),x==-m,order+1); - const ex arg_pt = arg.subs(rel); + // series(tgamma(x+m+1)/(x*(x+1)*...*(x+m)),x==-m,order); + const ex arg_pt = arg.subs(rel, subs_options::no_pattern); if (!arg_pt.info(info_flags::integer) || arg_pt.info(info_flags::positive)) throw do_taylor(); // caught by function::series() // if we got here we have to care for a simple pole at -m: @@ -201,7 +202,7 @@ static ex tgamma_series(const ex & arg, ex ser_denom = _ex1; for (numeric p; p<=m; ++p) ser_denom *= arg+p; - return (tgamma(arg+m+_ex1)/ser_denom).series(rel, order+1, options); + return (tgamma(arg+m+_ex1)/ser_denom).series(rel, order, options); } @@ -230,6 +231,10 @@ static ex beta_evalf(const ex & x, const ex & y) static ex beta_eval(const ex & x, const ex & y) { + if (x.is_equal(_ex1)) + return 1/y; + if (y.is_equal(_ex1)) + return 1/x; if (x.info(info_flags::numeric) && y.info(info_flags::numeric)) { // treat all problematic x and y that may not be passed into tgamma, // because they would throw there although beta(x,y) is well-defined @@ -289,9 +294,9 @@ static ex beta_series(const ex & arg1, // Taylor series where there is no pole of one of the tgamma functions // falls back to beta function evaluation. Otherwise, fall back to // tgamma series directly. - const ex arg1_pt = arg1.subs(rel); - const ex arg2_pt = arg2.subs(rel); - GINAC_ASSERT(is_exactly_a(rel.lhs())); + const ex arg1_pt = arg1.subs(rel, subs_options::no_pattern); + const ex arg2_pt = arg2.subs(rel, subs_options::no_pattern); + GINAC_ASSERT(is_a(rel.lhs())); const symbol &s = ex_to(rel.lhs()); ex arg1_ser, arg2_ser, arg1arg2_ser; if ((!arg1_pt.info(info_flags::integer) || arg1_pt.info(info_flags::positive)) && @@ -299,19 +304,19 @@ static ex beta_series(const ex & arg1, throw do_taylor(); // caught by function::series() // trap the case where arg1 is on a pole: if (arg1.info(info_flags::integer) && !arg1.info(info_flags::positive)) - arg1_ser = tgamma(arg1+s).series(rel, order, options); + arg1_ser = tgamma(arg1+s); else - arg1_ser = tgamma(arg1).series(rel,order); + arg1_ser = tgamma(arg1); // trap the case where arg2 is on a pole: if (arg2.info(info_flags::integer) && !arg2.info(info_flags::positive)) - arg2_ser = tgamma(arg2+s).series(rel, order, options); + arg2_ser = tgamma(arg2+s); else - arg2_ser = tgamma(arg2).series(rel,order); + arg2_ser = tgamma(arg2); // trap the case where arg1+arg2 is on a pole: if ((arg1+arg2).info(info_flags::integer) && !(arg1+arg2).info(info_flags::positive)) - arg1arg2_ser = tgamma(arg2+arg1+s).series(rel, order, options); + arg1arg2_ser = tgamma(arg2+arg1+s); else - arg1arg2_ser = tgamma(arg2+arg1).series(rel,order); + arg1arg2_ser = tgamma(arg2+arg1); // compose the result (expanding all the terms): return (arg1_ser*arg2_ser/arg1arg2_ser).series(rel, order, options).expand(); } @@ -406,7 +411,7 @@ static ex psi1_series(const ex & arg, // from which follows // series(psi(x),x==-m,order) == // series(psi(x+m+1) - 1/x - 1/(x+1) - 1/(x+m)),x==-m,order); - const ex arg_pt = arg.subs(rel); + const ex arg_pt = arg.subs(rel, subs_options::no_pattern); if (!arg_pt.info(info_flags::integer) || arg_pt.info(info_flags::positive)) throw do_taylor(); // caught by function::series() // if we got here we have to care for a simple pole at -m: @@ -417,8 +422,8 @@ static ex psi1_series(const ex & arg, return (psi(arg+m+_ex1)-recur).series(rel, order, options); } -const unsigned function_index_psi1 = - function::register_new(function_options("psi"). +unsigned psi1_SERIAL::serial = + function::register_new(function_options("psi", 1). eval_func(psi1_eval). evalf_func(psi1_evalf). derivative_func(psi1_deriv). @@ -533,7 +538,7 @@ static ex psi2_series(const ex & n, // series(psi(x),x==-m,order) == // series(psi(x+m+1) - (-1)^n * n! * ((x)^(-n-1) + (x+1)^(-n-1) + ... // ... + (x+m)^(-n-1))),x==-m,order); - const ex arg_pt = arg.subs(rel); + const ex arg_pt = arg.subs(rel, subs_options::no_pattern); if (!arg_pt.info(info_flags::integer) || arg_pt.info(info_flags::positive)) throw do_taylor(); // caught by function::series() // if we got here we have to care for a pole of order n+1 at -m: @@ -545,8 +550,8 @@ static ex psi2_series(const ex & n, return (psi(n, arg+m+_ex1)-recur).series(rel, order, options); } -const unsigned function_index_psi2 = - function::register_new(function_options("psi"). +unsigned psi2_SERIAL::serial = + function::register_new(function_options("psi", 2). eval_func(psi2_eval). evalf_func(psi2_evalf). derivative_func(psi2_deriv).