]> www.ginac.de Git - ginac.git/commitdiff
- architectural checkpoint for zeta-function.
authorRichard Kreckel <Richard.Kreckel@uni-mainz.de>
Fri, 19 Nov 1999 18:46:19 +0000 (18:46 +0000)
committerRichard Kreckel <Richard.Kreckel@uni-mainz.de>
Fri, 19 Nov 1999 18:46:19 +0000 (18:46 +0000)
ginac/Makefile.am
ginac/Makefile.in
ginac/inifcns.h
ginac/inifcns_gamma.cpp
ginac/inifcns_zeta.cpp [new file with mode: 0644]
ginac/numeric.cpp
ginac/numeric.h

index db760a02e1292ab064c40acfbd3ff1aca1d1696c..d2f9570ba9c47d7fad0655293f17e79b6a763de3 100644 (file)
@@ -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
index 6e5d6b6600d24509c7cb8cb2cc233f966d221da4..380b213396b616340f3b3ab4dfb0e6e40a05b4a5 100644 (file)
@@ -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
index 0ccde8de774a9d2900581d905908fc17b82325cc..f7622dd43b9500e3099387c136db4bc168b38616 100644 (file)
@@ -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. */
index 7bd6669bb8b5eb8c817fd016718c5e3bfdaa2546..c917387765d0044a46027d8207510646e4f3e2cf 100644 (file)
@@ -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 (file)
index 0000000..d4890f2
--- /dev/null
@@ -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 <vector>
+#include <stdexcept>
+
+#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
index ef2784172107f22965381b271e2fafcd92d7bbca..faffb6c5896a6fdadf1d7fd2c38cdea25a66dcf2 100644 (file)
@@ -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)
index fce1f196c0fc34896386e1e77b056ada390c6908..92755b3eb390978e263646552a15fec02a0a54de 100644 (file)
@@ -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);