| 27 |
#include "ex.h" |
#include "ex.h" |
| 28 |
|
|
| 29 |
#include <stdexcept> |
#include <stdexcept> |
| 30 |
|
#include <vector> |
| 31 |
|
|
| 32 |
#include <cln/complex.h> |
#include <cln/complex.h> |
| 33 |
|
|
| 40 |
|
|
| 41 |
namespace GiNaC { |
namespace GiNaC { |
| 42 |
|
|
| 43 |
|
/** Function pointer to implement callbacks in the case 'Digits' gets changed. |
| 44 |
|
* Main purpose of such callbacks is to adjust look-up tables of certain |
| 45 |
|
* functions to the new precision. Parameter contains the signed difference |
| 46 |
|
* between new Digits and old Digits. */ |
| 47 |
|
typedef void (* digits_changed_callback)(long); |
| 48 |
|
|
| 49 |
/** This class is used to instantiate a global singleton object Digits |
/** This class is used to instantiate a global singleton object Digits |
| 50 |
* which behaves just like Maple's Digits. We need an object rather |
* which behaves just like Maple's Digits. We need an object rather |
| 51 |
* than a 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 |
| 63 |
_numeric_digits& operator=(long prec); |
_numeric_digits& operator=(long prec); |
| 64 |
operator long(); |
operator long(); |
| 65 |
void print(std::ostream &os) const; |
void print(std::ostream &os) const; |
| 66 |
|
void add_callback(digits_changed_callback callback); |
| 67 |
// member variables |
// member variables |
| 68 |
private: |
private: |
| 69 |
long digits; ///< Number of decimal digits |
long digits; ///< Number of decimal digits |
| 70 |
static bool too_late; ///< Already one object present |
static bool too_late; ///< Already one object present |
| 71 |
|
// Holds a list of functions that get called when digits is changed. |
| 72 |
|
std::vector<digits_changed_callback> callbacklist; |
| 73 |
}; |
}; |
| 74 |
|
|
| 75 |
|
|