| 23 |
#ifndef __GINAC_NUMERIC_H__ |
#ifndef __GINAC_NUMERIC_H__ |
| 24 |
#define __GINAC_NUMERIC_H__ |
#define __GINAC_NUMERIC_H__ |
| 25 |
|
|
|
#include <strstream> |
|
| 26 |
#include "basic.h" |
#include "basic.h" |
| 27 |
#include "ex.h" |
#include "ex.h" |
| 28 |
|
|
| 37 |
#include <cln/complex_class.h> |
#include <cln/complex_class.h> |
| 38 |
#endif |
#endif |
| 39 |
|
|
|
#ifndef NO_NAMESPACE_GINAC |
|
| 40 |
namespace GiNaC { |
namespace GiNaC { |
|
#endif // ndef NO_NAMESPACE_GINAC |
|
| 41 |
|
|
| 42 |
#define HASHVALUE_NUMERIC 0x80000001U |
#define HASHVALUE_NUMERIC 0x80000001U |
| 43 |
|
|
| 44 |
/** This class is used to instantiate a global object Digits which |
/** This class is used to instantiate a global singleton object Digits |
| 45 |
* behaves just like Maple's Digits. We need an object rather than a |
* which behaves just like Maple's Digits. We need an object rather |
| 46 |
* dumber basic type since as a side-effect we let it change |
* than a dumber basic type since as a side-effect we let it change |
| 47 |
* cl_default_float_format when it gets changed. The only other |
* cl_default_float_format when it gets changed. The only other |
| 48 |
* meaningful thing to do with it is converting it to an unsigned, |
* meaningful thing to do with it is converting it to an unsigned, |
| 49 |
* for temprary storing its value e.g. The user must not create an |
* for temprary storing its value e.g. The user must not create an |
| 60 |
void print(std::ostream & os) const; |
void print(std::ostream & os) const; |
| 61 |
// member variables |
// member variables |
| 62 |
private: |
private: |
| 63 |
long digits; |
long digits; ///< Number of decimal digits |
| 64 |
static bool too_late; |
static bool too_late; ///< Already one object present |
| 65 |
}; |
}; |
| 66 |
|
|
| 67 |
/** This class is a wrapper around CLN-numbers within the GiNaC class |
/** This class is a wrapper around CLN-numbers within the GiNaC class |
| 72 |
|
|
| 73 |
// member functions |
// member functions |
| 74 |
|
|
| 75 |
// other constructors |
// other ctors |
| 76 |
public: |
public: |
| 77 |
explicit numeric(int i); |
explicit numeric(int i); |
| 78 |
explicit numeric(unsigned int i); |
explicit numeric(unsigned int i); |
| 84 |
|
|
| 85 |
// functions overriding virtual functions from bases classes |
// functions overriding virtual functions from bases classes |
| 86 |
public: |
public: |
| 87 |
basic * duplicate() const; |
void print(const print_context & c, unsigned level = 0) const; |
| 88 |
void print(std::ostream & os, unsigned precedence=0) const; |
unsigned precedence(void) const {return 30;} |
|
void printraw(std::ostream & os) const; |
|
|
void printtree(std::ostream & os, unsigned indent) const; |
|
|
void printcsrc(std::ostream & os, unsigned type, unsigned precedence=0) const; |
|
| 89 |
bool info(unsigned inf) const; |
bool info(unsigned inf) const; |
| 90 |
bool has(const ex & other) const; |
bool has(const ex & other) const; |
| 91 |
ex eval(int level=0) const; |
ex eval(int level=0) const; |
| 96 |
ex smod(const numeric &xi) const; |
ex smod(const numeric &xi) const; |
| 97 |
numeric max_coefficient(void) const; |
numeric max_coefficient(void) const; |
| 98 |
protected: |
protected: |
| 99 |
ex derivative(const symbol & s) const; |
/** Implementation of ex::diff for a numeric always returns 0. |
| 100 |
int compare_same_type(const basic & other) const; |
* @see ex::diff */ |
| 101 |
|
ex derivative(const symbol &s) const { return _ex0(); } |
| 102 |
bool is_equal_same_type(const basic & other) const; |
bool is_equal_same_type(const basic & other) const; |
| 103 |
unsigned calchash(void) const; |
unsigned calchash(void) const; |
| 104 |
|
|
| 161 |
// member variables |
// member variables |
| 162 |
|
|
| 163 |
protected: |
protected: |
|
static unsigned precedence; |
|
| 164 |
cln::cl_number value; |
cln::cl_number value; |
| 165 |
}; |
}; |
| 166 |
|
|
| 169 |
extern const numeric I; |
extern const numeric I; |
| 170 |
extern _numeric_digits Digits; |
extern _numeric_digits Digits; |
| 171 |
|
|
| 172 |
//#define is_a_numeric_hash(x) ((x)==HASHVALUE_NUMERIC) |
// deprecated macro, for internal use only |
| 173 |
// may have to be changed to ((x)>=0x80000000U) |
#define is_a_numeric_hash(x) ((x)&0x80000000U) |
|
|
|
|
// has been changed |
|
|
//#define is_a_numeric_hash(x) ((x)&0x80000000U) |
|
| 174 |
|
|
| 175 |
// global functions |
// global functions |
| 176 |
|
|
| 200 |
const numeric binomial(const numeric & n, const numeric & k); |
const numeric binomial(const numeric & n, const numeric & k); |
| 201 |
const numeric bernoulli(const numeric & n); |
const numeric bernoulli(const numeric & n); |
| 202 |
const numeric fibonacci(const numeric & n); |
const numeric fibonacci(const numeric & n); |
|
const numeric abs(const numeric & x); |
|
| 203 |
const numeric isqrt(const numeric & x); |
const numeric isqrt(const numeric & x); |
| 204 |
const numeric sqrt(const numeric & x); |
const numeric sqrt(const numeric & x); |
| 205 |
const numeric abs(const numeric & x); |
const numeric abs(const numeric & x); |
| 292 |
return static_cast<const numeric &>(*e.bp); |
return static_cast<const numeric &>(*e.bp); |
| 293 |
} |
} |
| 294 |
|
|
|
|
|
|
#ifndef NO_NAMESPACE_GINAC |
|
| 295 |
} // namespace GiNaC |
} // namespace GiNaC |
|
#endif // ndef NO_NAMESPACE_GINAC |
|
| 296 |
|
|
| 297 |
#ifdef __MAKECINT__ |
#ifdef __MAKECINT__ |
| 298 |
#pragma link off defined_in cln/number.h; |
#pragma link off defined_in cln/number.h; |