X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fnumeric.h;h=c56c56bd84dee5ae85715c7ca70ee0879d218ee3;hp=4f2ba1a1e3b4fa9c7c147f8f5082e27513e6357f;hb=dbd9c306a74f1cb258c0d15a346b973b39deaad2;hpb=7ece13ddcc174e28b7b333e5d09900bc90f3dd78 diff --git a/ginac/numeric.h b/ginac/numeric.h index 4f2ba1a1..c56c56bd 100644 --- a/ginac/numeric.h +++ b/ginac/numeric.h @@ -3,7 +3,7 @@ * Makes the interface to the underlying bignum package available. */ /* - * GiNaC Copyright (C) 1999-2001 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 @@ -39,8 +39,6 @@ namespace cln { class cl_N; } namespace GiNaC { -#define HASHVALUE_NUMERIC 0x80000001U - /** This class is used to instantiate a global singleton object Digits * which behaves just like Maple's Digits. We need an object rather * than a dumber basic type since as a side-effect we let it change @@ -74,18 +72,22 @@ class numeric : public basic // other ctors public: - explicit numeric(int i); - explicit numeric(unsigned int i); - explicit numeric(long i); - explicit numeric(unsigned long i); - explicit numeric(long numer, long denom); - explicit numeric(double d); - explicit numeric(const char *); + numeric(int i); + numeric(unsigned int i); + numeric(long i); + numeric(unsigned long i); + numeric(long numer, long denom); + numeric(double d); + numeric(const char *); - // functions overriding virtual functions from bases classes + // functions overriding virtual functions from base classes public: void print(const print_context & c, unsigned level = 0) const; + unsigned precedence(void) const {return 30;} bool info(unsigned inf) const; + int degree(const ex & s) const; + int ldegree(const ex & s) const; + ex coeff(const ex & s, int n = 1) const; bool has(const ex &other) const; ex eval(int level = 0) const; ex evalf(int level = 0) const; @@ -97,7 +99,7 @@ public: protected: /** Implementation of ex::diff for a numeric always returns 0. * @see ex::diff */ - ex derivative(const symbol &s) const { return _ex0(); } + ex derivative(const symbol &s) const { return 0; } bool is_equal_same_type(const basic &other) const; unsigned calchash(void) const; @@ -160,7 +162,6 @@ public: // member variables protected: - static unsigned precedence; cln::cl_number value; }; @@ -200,7 +201,6 @@ const numeric doublefactorial(const numeric &n); const numeric binomial(const numeric &n, const numeric &k); const numeric bernoulli(const numeric &n); const numeric fibonacci(const numeric &n); -const numeric abs(const numeric &x); const numeric isqrt(const numeric &x); const numeric sqrt(const numeric &x); const numeric abs(const numeric &x); @@ -288,9 +288,11 @@ ex CatalanEvalf(void); // utility functions -inline const numeric &ex_to_numeric(const ex &e) + +/** Specialization of is_exactly_a(obj) for numeric objects. */ +template<> inline bool is_exactly_a(const basic & obj) { - return static_cast(*e.bp); + return obj.tinfo()==TINFO_numeric; } } // namespace GiNaC