]> www.ginac.de Git - ginac.git/blobdiff - ginac/inifcns_zeta.cpp
Added a document about the coding conventions used in GiNaC. Corrections,
[ginac.git] / ginac / inifcns_zeta.cpp
index d4890f2863c28205e64931f50e7f2b5074f8239d..2dba976bf4c2faf365aca062ab5de1a453b13f52 100644 (file)
@@ -3,7 +3,7 @@
  *  Implementation of the Zeta-function and some related stuff. */
 
 /*
- *  GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2003 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
 #include <stdexcept>
 
 #include "inifcns.h"
-#include "ex.h"
 #include "constant.h"
 #include "numeric.h"
 #include "power.h"
 #include "symbol.h"
+#include "operators.h"
+#include "utils.h"
 
 namespace GiNaC {
 
 //////////
-// Riemann's Zeta-function
+// Derivatives of Riemann's Zeta-function  zeta(0,x)==zeta(x)
 //////////
 
-static ex zeta_eval(ex const & x)
+static ex zeta2_eval(const ex & n, const ex & 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);
+       if (n.info(info_flags::numeric)) {
+               // zeta(0,x) -> zeta(x)
+               if (n.is_zero())
+                       return zeta(x);
+       }
+       
+       return zeta(n, x).hold();
 }
 
-static ex zeta_series(ex const & x, symbol const & s, ex const & point, int order)
+static ex zeta2_deriv(const ex & n, const ex & x, unsigned deriv_param)
 {
-    throw(std::logic_error("don't know the series expansion of the zeta function"));
+       GINAC_ASSERT(deriv_param<2);
+       
+       if (deriv_param==0) {
+               // d/dn zeta(n,x)
+               throw(std::logic_error("cannot diff zeta(n,x) with respect to n"));
+       }
+       // d/dx psi(n,x)
+       return zeta(n+1,x);
 }
 
-REGISTER_FUNCTION(zeta, zeta_eval, zeta_evalf, zeta_diff, zeta_series);
+unsigned zeta2_SERIAL::serial =
+       function::register_new(function_options("zeta").
+                              eval_func(zeta2_eval).
+                              derivative_func(zeta2_deriv).
+                              latex_name("\\zeta").
+                              overloaded(2));
 
 } // namespace GiNaC