| 27 |
#include "basic.h" |
#include "basic.h" |
| 28 |
#include "ex.h" |
#include "ex.h" |
| 29 |
|
|
| 30 |
class cl_N; // We want to include cln.h only in numeric.cpp in order to |
#include <cln/number.h> |
| 31 |
// avoid namespace pollution and keep compile-time low. |
// forward decln of cln::cl_N, since cln/complex_class.h is not included: |
| 32 |
|
namespace cln { class cl_N; } |
| 33 |
|
|
| 34 |
|
#if defined(G__CINTVERSION) && !defined(__MAKECINT__) |
| 35 |
|
// Cint @$#$! doesn't like forward declaring classes used for casting operators |
| 36 |
|
// so we have to include the definition of cln::cl_N here, but it is enough to |
| 37 |
|
// do so for the compiler, hence the !defined(__MAKECINT__). |
| 38 |
|
#include <cln/complex_class.h> |
| 39 |
|
#endif |
| 40 |
|
|
| 41 |
#ifndef NO_NAMESPACE_GINAC |
#ifndef NO_NAMESPACE_GINAC |
| 42 |
namespace GiNaC { |
namespace GiNaC { |
| 74 |
GINAC_DECLARE_REGISTERED_CLASS(numeric, basic) |
GINAC_DECLARE_REGISTERED_CLASS(numeric, basic) |
| 75 |
|
|
| 76 |
// friends |
// friends |
| 77 |
friend const numeric exp(const numeric & x); |
// (none) |
|
friend const numeric log(const numeric & x); |
|
|
friend const numeric sin(const numeric & x); |
|
|
friend const numeric cos(const numeric & x); |
|
|
friend const numeric tan(const numeric & x); |
|
|
friend const numeric asin(const numeric & x); |
|
|
friend const numeric acos(const numeric & x); |
|
|
friend const numeric atan(const numeric & x); |
|
|
friend const numeric atan(const numeric & y, const numeric & x); |
|
|
friend const numeric sinh(const numeric & x); |
|
|
friend const numeric cosh(const numeric & x); |
|
|
friend const numeric tanh(const numeric & x); |
|
|
friend const numeric asinh(const numeric & x); |
|
|
friend const numeric acosh(const numeric & x); |
|
|
friend const numeric atanh(const numeric & x); |
|
|
friend const numeric Li2(const numeric & x); |
|
|
friend const numeric zeta(const numeric & x); |
|
|
friend const numeric fibonacci(const numeric & n); |
|
|
friend numeric abs(const numeric & x); |
|
|
friend numeric mod(const numeric & a, const numeric & b); |
|
|
friend numeric smod(const numeric & a, const numeric & b); |
|
|
friend numeric irem(const numeric & a, const numeric & b); |
|
|
friend numeric irem(const numeric & a, const numeric & b, numeric & q); |
|
|
friend numeric iquo(const numeric & a, const numeric & b); |
|
|
friend numeric iquo(const numeric & a, const numeric & b, numeric & r); |
|
|
friend numeric sqrt(const numeric & x); |
|
|
friend numeric isqrt(const numeric & x); |
|
|
friend numeric gcd(const numeric & a, const numeric & b); |
|
|
friend numeric lcm(const numeric & a, const numeric & b); |
|
| 78 |
|
|
| 79 |
// member functions |
// member functions |
| 80 |
|
|
| 98 |
explicit numeric(long numer, long denom); |
explicit numeric(long numer, long denom); |
| 99 |
explicit numeric(double d); |
explicit numeric(double d); |
| 100 |
explicit numeric(const char *); |
explicit numeric(const char *); |
|
numeric(const cl_N & z); |
|
| 101 |
|
|
| 102 |
// functions overriding virtual functions from bases classes |
// functions overriding virtual functions from bases classes |
| 103 |
public: |
public: |
| 126 |
|
|
| 127 |
// non-virtual functions in this class |
// non-virtual functions in this class |
| 128 |
public: |
public: |
| 129 |
numeric add(const numeric & other) const; |
const numeric add(const numeric & other) const; |
| 130 |
numeric sub(const numeric & other) const; |
const numeric sub(const numeric & other) const; |
| 131 |
numeric mul(const numeric & other) const; |
const numeric mul(const numeric & other) const; |
| 132 |
numeric div(const numeric & other) const; |
const numeric div(const numeric & other) const; |
| 133 |
numeric power(const numeric & other) const; |
const numeric power(const numeric & other) const; |
| 134 |
const numeric & add_dyn(const numeric & other) const; |
const numeric & add_dyn(const numeric & other) const; |
| 135 |
const numeric & sub_dyn(const numeric & other) const; |
const numeric & sub_dyn(const numeric & other) const; |
| 136 |
const numeric & mul_dyn(const numeric & other) const; |
const numeric & mul_dyn(const numeric & other) const; |
| 142 |
const numeric & operator=(unsigned long i); |
const numeric & operator=(unsigned long i); |
| 143 |
const numeric & operator=(double d); |
const numeric & operator=(double d); |
| 144 |
const numeric & operator=(const char * s); |
const numeric & operator=(const char * s); |
| 145 |
numeric inverse(void) const; |
const numeric inverse(void) const; |
| 146 |
int csgn(void) const; |
int csgn(void) const; |
|
::cl_N* clnptr(void) const { return value; } /**< ptr to representation. */ |
|
| 147 |
int compare(const numeric & other) const; |
int compare(const numeric & other) const; |
| 148 |
bool is_equal(const numeric & other) const; |
bool is_equal(const numeric & other) const; |
| 149 |
bool is_zero(void) const; |
bool is_zero(void) const; |
| 173 |
const numeric numer(void) const; |
const numeric numer(void) const; |
| 174 |
const numeric denom(void) const; |
const numeric denom(void) const; |
| 175 |
int int_length(void) const; |
int int_length(void) const; |
| 176 |
|
// converting routines for interfacing with CLN: |
| 177 |
|
numeric(const cln::cl_N & z); |
| 178 |
|
operator cln::cl_N() const; |
| 179 |
|
|
| 180 |
// member variables |
// member variables |
| 181 |
|
|
| 182 |
protected: |
protected: |
| 183 |
static unsigned precedence; |
static unsigned precedence; |
| 184 |
::cl_N *value; |
cln::cl_number value; |
| 185 |
}; |
}; |
| 186 |
|
|
| 187 |
// global constants |
// global constants |
| 225 |
const numeric binomial(const numeric & n, const numeric & k); |
const numeric binomial(const numeric & n, const numeric & k); |
| 226 |
const numeric bernoulli(const numeric & n); |
const numeric bernoulli(const numeric & n); |
| 227 |
const numeric fibonacci(const numeric & n); |
const numeric fibonacci(const numeric & n); |
| 228 |
|
const numeric abs(const numeric & x); |
| 229 |
numeric abs(const numeric & x); |
const numeric isqrt(const numeric & x); |
| 230 |
numeric mod(const numeric & a, const numeric & b); |
const numeric sqrt(const numeric & x); |
| 231 |
numeric smod(const numeric & a, const numeric & b); |
const numeric abs(const numeric & x); |
| 232 |
numeric irem(const numeric & a, const numeric & b); |
const numeric mod(const numeric & a, const numeric & b); |
| 233 |
numeric irem(const numeric & a, const numeric & b, numeric & q); |
const numeric smod(const numeric & a, const numeric & b); |
| 234 |
numeric iquo(const numeric & a, const numeric & b); |
const numeric irem(const numeric & a, const numeric & b); |
| 235 |
numeric iquo(const numeric & a, const numeric & b, numeric & r); |
const numeric irem(const numeric & a, const numeric & b, numeric & q); |
| 236 |
numeric sqrt(const numeric & x); |
const numeric iquo(const numeric & a, const numeric & b); |
| 237 |
numeric isqrt(const numeric & x); |
const numeric iquo(const numeric & a, const numeric & b, numeric & r); |
| 238 |
|
const numeric gcd(const numeric & a, const numeric & b); |
| 239 |
numeric gcd(const numeric & a, const numeric & b); |
const numeric lcm(const numeric & a, const numeric & b); |
|
numeric lcm(const numeric & a, const numeric & b); |
|
| 240 |
|
|
| 241 |
// wrapper functions around member functions |
// wrapper functions around member functions |
| 242 |
inline numeric pow(const numeric & x, const numeric & y) |
inline const numeric pow(const numeric & x, const numeric & y) |
| 243 |
{ return x.power(y); } |
{ return x.power(y); } |
| 244 |
|
|
| 245 |
inline numeric inverse(const numeric & x) |
inline const numeric inverse(const numeric & x) |
| 246 |
{ return x.inverse(); } |
{ return x.inverse(); } |
| 247 |
|
|
| 248 |
inline int csgn(const numeric & x) |
inline int csgn(const numeric & x) |
| 314 |
} // namespace GiNaC |
} // namespace GiNaC |
| 315 |
#endif // ndef NO_NAMESPACE_GINAC |
#endif // ndef NO_NAMESPACE_GINAC |
| 316 |
|
|
| 317 |
|
#ifdef __MAKECINT__ |
| 318 |
|
#pragma link off defined_in cln/number.h; |
| 319 |
|
#pragma link off defined_in cln/complex_class.h; |
| 320 |
|
#endif |
| 321 |
|
|
| 322 |
#endif // ndef __GINAC_NUMERIC_H__ |
#endif // ndef __GINAC_NUMERIC_H__ |