]> www.ginac.de Git - ginac.git/blobdiff - ginac/numeric.h
- introduced info_flags::cinteger, info_flags::crational,
[ginac.git] / ginac / numeric.h
index 0b2d28e3e2d71f47202764186f82dade1bc715c9..68c227d1abacb4948261f61541470575d3694c05 100644 (file)
@@ -2,17 +2,39 @@
  *
  *  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"
+
+#ifndef NO_GINAC_NAMESPACE
+namespace GiNaC {
+#endif // ndef NO_GINAC_NAMESPACE
+
+#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 +79,8 @@ class numeric : public basic
     friend numeric asinh(numeric const & x);
     friend numeric acosh(numeric const & x);
     friend numeric atanh(numeric const & x);
+    friend numeric zeta(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);
@@ -102,9 +126,9 @@ public:
     // functions overriding virtual functions from bases classes
 public:
     basic * duplicate() const;
+    void print(ostream & os, unsigned precedence=0) const;
     void printraw(ostream & os) const;
     void printtree(ostream & os, unsigned indent) const;
-    void print(ostream & os, unsigned precedence=0) const;
     void printcsrc(ostream & os, unsigned type, unsigned precedence=0) const;
     bool info(unsigned inf) const;
     ex evalf(int level=0) const;
@@ -150,6 +174,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;
@@ -163,6 +188,8 @@ public:
     bool is_prime(void) const;
     bool is_rational(void) const;
     bool is_real(void) const;
+    bool is_cinteger(void) const;
+    bool is_crational(void) const;
     bool operator==(numeric const & other) const;
     bool operator!=(numeric const & other) const;
     bool operator<(numeric const & other) const;
@@ -217,10 +244,14 @@ 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 & 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 +277,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(); }
 
@@ -276,6 +310,12 @@ inline bool is_rational(numeric const & x)
 inline bool is_real(numeric const & x)
 { return x.is_real(); }
 
+inline bool is_cinteger(numeric const & x)
+{ return x.is_cinteger(); }
+
+inline bool is_crational(numeric const & x)
+{ return x.is_crational(); }
+
 inline numeric real(numeric const & x)
 { return x.real(); }
 
@@ -288,20 +328,20 @@ inline numeric numer(numeric const & x)
 inline numeric denom(numeric const & x)
 { return x.denom(); }
 
-/* do we need this any more? */
-//inline numeric factorial(int n)
-//{ return factorial(numeric(n)); }
+// numeric evaluation functions for class constant objects:
 
-/* do we need this any more? */
-//inline numeric binomial(int n, int k)
-//{ return binomial(numeric(n), numeric(k)); }
-
-ex IEvalf(void);
 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);
+}
 
+#ifndef NO_GINAC_NAMESPACE
+} // namespace GiNaC
+#endif // ndef NO_GINAC_NAMESPACE
 
-#endif // ndef _NUMERIC_H_
+#endif // ndef __GINAC_NUMERIC_H__