]> www.ginac.de Git - ginac.git/blobdiff - ginac/numeric.h
- added Bernoulli numbers
[ginac.git] / ginac / numeric.h
index 0b2d28e3e2d71f47202764186f82dade1bc715c9..b1f4871805b5d02d7f4d64dec61dc51d4d933e1a 100644 (file)
@@ -2,17 +2,37 @@
  *
  *  Makes the interface to the underlying bignum package available. */
 
-#ifndef _NUMERIC_H_
-#define _NUMERIC_H_
+/*
+ *  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 <strstream>
+#ifndef __GINAC_NUMERIC_H__
+#define __GINAC_NUMERIC_H__
 
-#define HASHVALUE_NUMERIC 0x80000001U
+#include <strstream>
+#include <ginac/basic.h>
+#include <ginac/ex.h>
 
-class numeric;  // Forward declaration, so basic doesn't argue...
 class cl_N;     // We want to include cln.h only in numeric.cpp in order to 
                 // avoid namespace pollution and keep compile-time low.
-#include "basic.h"
+
+namespace GiNaC {
+
+#define HASHVALUE_NUMERIC 0x80000001U
 
 /** This class is used to instantiate a global object Digits which
  *  behaves just like Maple's Digits.  We need an object rather than a
@@ -57,6 +77,7 @@ class numeric : public basic
     friend numeric asinh(numeric const & x);
     friend numeric acosh(numeric const & x);
     friend numeric atanh(numeric const & x);
+    friend numeric bernoulli(numeric const & n);
     friend numeric abs(numeric const & x);
     friend numeric mod(numeric const & a, numeric const & b);
     friend numeric smod(numeric const & a, numeric const & b);
@@ -150,6 +171,7 @@ public:
     numeric power_dyn(numeric const & other) const { return power(other); }
     */
     numeric inverse(void) const;
+    int csgn(void) const;
     int compare(numeric const & other) const;
     bool is_equal(numeric const & other) const;
     bool is_zero(void) const;
@@ -217,10 +239,13 @@ 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);
+numeric bernoulli(numeric const & n);
 
 numeric abs(numeric const & x);
 numeric mod(numeric const & a, numeric const & b);
@@ -246,6 +271,9 @@ struct numeric_fail
 inline numeric inverse(numeric const & x)
 { return x.inverse(); }
 
+inline bool csgn(numeric const & x)
+{ return x.csgn(); }
+
 inline bool is_zero(numeric const & x)
 { return x.is_zero(); }
 
@@ -301,7 +329,12 @@ ex PiEvalf(void);
 ex EulerGammaEvalf(void);
 ex CatalanEvalf(void);
 
-#define ex_to_numeric(X) static_cast<numeric const &>(*(X).bp)
+// utility functions
+inline const numeric &ex_to_numeric(const ex &e)
+{
+       return static_cast<const numeric &>(*e.bp);
+}
 
+} // namespace GiNaC
 
-#endif // ndef _NUMERIC_H_
+#endif // ndef __GINAC_NUMERIC_H__