From: Richard Kreckel Date: Fri, 19 Nov 1999 18:46:19 +0000 (+0000) Subject: - architectural checkpoint for zeta-function. X-Git-Tag: release_0-5-0~148 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=commitdiff_plain;h=68c28e9c4381f874acf0cd7a690d36098ac9db23;ds=sidebyside - architectural checkpoint for zeta-function. --- diff --git a/ginac/Makefile.am b/ginac/Makefile.am index db760a02..d2f9570b 100644 --- a/ginac/Makefile.am +++ b/ginac/Makefile.am @@ -3,12 +3,12 @@ lib_LTLIBRARIES = libginac.la libginac_la_SOURCES = add.cpp basic.cpp constant.cpp diff.cpp ex.cpp \ expairseq.cpp exprseq.cpp fail.cpp function.cpp inifcns.cpp \ - inifcns_trans.cpp inifcns_gamma.cpp matrix.cpp mul.cpp normal.cpp \ - numeric.cpp operators.cpp power.cpp print.cpp printraw.cpp printtree.cpp \ - printcsrc.cpp relational.cpp symbol.cpp utils.cpp series.cpp ncmul.cpp \ - clifford.cpp structure.cpp color.cpp indexed.cpp idx.cpp isospin.cpp \ - exprseq_suppl.cpp lst.cpp lst_suppl.cpp simp_lor.cpp coloridx.cpp \ - lorentzidx.cpp debugmsg.h utils.h + inifcns_trans.cpp inifcns_zeta.cpp inifcns_gamma.cpp matrix.cpp mul.cpp \ + normal.cpp numeric.cpp operators.cpp power.cpp print.cpp printraw.cpp \ + printtree.cpp printcsrc.cpp relational.cpp symbol.cpp utils.cpp series.cpp \ + ncmul.cpp clifford.cpp structure.cpp color.cpp indexed.cpp idx.cpp \ + isospin.cpp exprseq_suppl.cpp lst.cpp lst_suppl.cpp simp_lor.cpp \ + coloridx.cpp lorentzidx.cpp debugmsg.h utils.h libginac_la_LDFLAGS = -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \ -release $(LT_RELEASE) ginacincludedir = $(includedir)/ginac diff --git a/ginac/Makefile.in b/ginac/Makefile.in index 6e5d6b66..380b2133 100644 --- a/ginac/Makefile.in +++ b/ginac/Makefile.in @@ -97,12 +97,12 @@ YACC = @YACC@ lib_LTLIBRARIES = libginac.la libginac_la_SOURCES = add.cpp basic.cpp constant.cpp diff.cpp ex.cpp \ expairseq.cpp exprseq.cpp fail.cpp function.cpp inifcns.cpp \ - inifcns_trans.cpp inifcns_gamma.cpp matrix.cpp mul.cpp normal.cpp \ - numeric.cpp operators.cpp power.cpp print.cpp printraw.cpp printtree.cpp \ - printcsrc.cpp relational.cpp symbol.cpp utils.cpp series.cpp ncmul.cpp \ - clifford.cpp structure.cpp color.cpp indexed.cpp idx.cpp isospin.cpp \ - exprseq_suppl.cpp lst.cpp lst_suppl.cpp simp_lor.cpp coloridx.cpp \ - lorentzidx.cpp debugmsg.h utils.h + inifcns_trans.cpp inifcns_zeta.cpp inifcns_gamma.cpp matrix.cpp mul.cpp \ + normal.cpp numeric.cpp operators.cpp power.cpp print.cpp printraw.cpp \ + printtree.cpp printcsrc.cpp relational.cpp symbol.cpp utils.cpp series.cpp \ + ncmul.cpp clifford.cpp structure.cpp color.cpp indexed.cpp idx.cpp \ + isospin.cpp exprseq_suppl.cpp lst.cpp lst_suppl.cpp simp_lor.cpp \ + coloridx.cpp lorentzidx.cpp debugmsg.h utils.h libginac_la_LDFLAGS = -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \ -release $(LT_RELEASE) ginacincludedir = $(includedir)/ginac @@ -125,11 +125,11 @@ LIBS = @LIBS@ libginac_la_LIBADD = libginac_la_OBJECTS = add.lo basic.lo constant.lo diff.lo ex.lo \ expairseq.lo exprseq.lo fail.lo function.lo inifcns.lo inifcns_trans.lo \ -inifcns_gamma.lo matrix.lo mul.lo normal.lo numeric.lo operators.lo \ -power.lo print.lo printraw.lo printtree.lo printcsrc.lo relational.lo \ -symbol.lo utils.lo series.lo ncmul.lo clifford.lo structure.lo color.lo \ -indexed.lo idx.lo isospin.lo exprseq_suppl.lo lst.lo lst_suppl.lo \ -simp_lor.lo coloridx.lo lorentzidx.lo +inifcns_zeta.lo inifcns_gamma.lo matrix.lo mul.lo normal.lo numeric.lo \ +operators.lo power.lo print.lo printraw.lo printtree.lo printcsrc.lo \ +relational.lo symbol.lo utils.lo series.lo ncmul.lo clifford.lo \ +structure.lo color.lo indexed.lo idx.lo isospin.lo exprseq_suppl.lo \ +lst.lo lst_suppl.lo simp_lor.lo coloridx.lo lorentzidx.lo CXXFLAGS = @CXXFLAGS@ CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) --mode=compile $(CXX) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS) @@ -147,9 +147,9 @@ DEP_FILES = .deps/add.P .deps/basic.P .deps/clifford.P .deps/color.P \ .deps/coloridx.P .deps/constant.P .deps/diff.P .deps/ex.P \ .deps/expairseq.P .deps/exprseq.P .deps/exprseq_suppl.P .deps/fail.P \ .deps/function.P .deps/idx.P .deps/indexed.P .deps/inifcns.P \ -.deps/inifcns_gamma.P .deps/inifcns_trans.P .deps/isospin.P \ -.deps/lorentzidx.P .deps/lst.P .deps/lst_suppl.P .deps/matrix.P \ -.deps/mul.P .deps/ncmul.P .deps/normal.P .deps/numeric.P \ +.deps/inifcns_gamma.P .deps/inifcns_trans.P .deps/inifcns_zeta.P \ +.deps/isospin.P .deps/lorentzidx.P .deps/lst.P .deps/lst_suppl.P \ +.deps/matrix.P .deps/mul.P .deps/ncmul.P .deps/normal.P .deps/numeric.P \ .deps/operators.P .deps/power.P .deps/print.P .deps/printcsrc.P \ .deps/printraw.P .deps/printtree.P .deps/relational.P .deps/series.P \ .deps/simp_lor.P .deps/structure.P .deps/symbol.P .deps/utils.P diff --git a/ginac/inifcns.h b/ginac/inifcns.h index 0ccde8de..f7622dd4 100644 --- a/ginac/inifcns.h +++ b/ginac/inifcns.h @@ -79,10 +79,15 @@ DECLARE_FUNCTION_1P(Li2) /** Trilogarithm. */ DECLARE_FUNCTION_1P(Li3) -/** Gamma function. */ +/** Riemann's Zeta-function. */ +DECLARE_FUNCTION_1P(zeta) +DECLARE_FUNCTION_2P(zeta) + +/** Gamma-function. */ DECLARE_FUNCTION_1P(gamma) -/** Psi function (aka polygamma-function) */ +/** Psi-function (aka polygamma-function). */ +DECLARE_FUNCTION_1P(psi) DECLARE_FUNCTION_2P(psi) /** Factorial function. */ diff --git a/ginac/inifcns_gamma.cpp b/ginac/inifcns_gamma.cpp index 7bd6669b..c9173877 100644 --- a/ginac/inifcns_gamma.cpp +++ b/ginac/inifcns_gamma.cpp @@ -1,6 +1,7 @@ /** @file inifcns_gamma.cpp * - * Implementation of Gamma function and some related stuff. */ + * Implementation of Gamma-function, Polygamma-functions, and some related + * stuff. */ /* * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany @@ -33,7 +34,7 @@ namespace GiNaC { ////////// -// gamma function +// Gamma-function ////////// /** Evaluation of gamma(x). Knows about integer arguments, half-integer @@ -44,7 +45,6 @@ namespace GiNaC { static ex gamma_eval(ex const & x) { if (x.info(info_flags::numeric)) { - // trap integer arguments: if ( x.info(info_flags::integer) ) { // gamma(n+1) -> n! for postitive n @@ -88,8 +88,8 @@ static ex gamma_evalf(ex const & x) static ex gamma_diff(ex const & x, unsigned diff_param) { ASSERT(diff_param==0); - - return psi(exZERO(),x)*gamma(x); + + return psi(exZERO(),x)*gamma(x); // diff(log(gamma(x)),x)==psi(0,x) } static ex gamma_series(ex const & x, symbol const & s, ex const & point, int order) @@ -105,7 +105,7 @@ static ex gamma_series(ex const & x, symbol const & s, ex const & point, int ord REGISTER_FUNCTION(gamma, gamma_eval, gamma_evalf, gamma_diff, gamma_series); ////////// -// psi function (aka polygamma function) +// Psi-function (aka polygamma-function) ////////// /** Evaluation of polygamma-function psi(n,x). diff --git a/ginac/inifcns_zeta.cpp b/ginac/inifcns_zeta.cpp new file mode 100644 index 00000000..d4890f28 --- /dev/null +++ b/ginac/inifcns_zeta.cpp @@ -0,0 +1,77 @@ +/** @file inifcns_zeta.cpp + * + * Implementation of the Zeta-function and some related stuff. */ + +/* + * GiNaC Copyright (C) 1999 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include + +#include "inifcns.h" +#include "ex.h" +#include "constant.h" +#include "numeric.h" +#include "power.h" +#include "symbol.h" + +namespace GiNaC { + +////////// +// Riemann's Zeta-function +////////// + +static ex zeta_eval(ex const & x) +{ + if (x.info(info_flags::numeric)) { + // trap integer arguments: + if ( x.info(info_flags::integer) ) { + if ( x.info(info_flags::posint) ) { + return numZERO(); // FIXME + } else { + return numZERO(); // FIXME + } + } + } + return zeta(x).hold(); +} + +static ex zeta_evalf(ex const & x) +{ + BEGIN_TYPECHECK + TYPECHECK(x,numeric) + END_TYPECHECK(zeta(x)) + + return zeta(ex_to_numeric(x)); +} + +static ex zeta_diff(ex const & x, unsigned diff_param) +{ + ASSERT(diff_param==0); + + return exZERO(); // should return zeta(numONE(),x); +} + +static ex zeta_series(ex const & x, symbol const & s, ex const & point, int order) +{ + throw(std::logic_error("don't know the series expansion of the zeta function")); +} + +REGISTER_FUNCTION(zeta, zeta_eval, zeta_evalf, zeta_diff, zeta_series); + +} // namespace GiNaC diff --git a/ginac/numeric.cpp b/ginac/numeric.cpp index ef278417..faffb6c5 100644 --- a/ginac/numeric.cpp +++ b/ginac/numeric.cpp @@ -1062,6 +1062,17 @@ numeric atanh(numeric const & x) return ::atanh(*x.value); // -> CLN } +/** Numeric evaluation of Riemann's Zeta function. Currently works only for + * integer arguments. */ +numeric zeta(numeric const & x) +{ + if (x.is_integer()) + return ::cl_zeta(x.to_int()); // -> CLN + else + clog << "zeta(): Does anybody know good way to calculate this numerically?" << endl; + return numeric(0); +} + /** The gamma function. * This is only a stub! */ numeric gamma(numeric const & x) diff --git a/ginac/numeric.h b/ginac/numeric.h index fce1f196..92755b3e 100644 --- a/ginac/numeric.h +++ b/ginac/numeric.h @@ -238,7 +238,9 @@ numeric tanh(numeric const & x); numeric asinh(numeric const & x); numeric acosh(numeric const & x); numeric atanh(numeric const & x); +numeric zeta(numeric const & x); numeric gamma(numeric const & x); +numeric psi(numeric const & n, numeric const & x); numeric factorial(numeric const & n); numeric doublefactorial(numeric const & n); numeric binomial(numeric const & n, numeric const & k);