| 64 |
class numeric : public basic |
class numeric : public basic |
| 65 |
{ |
{ |
| 66 |
// friends |
// friends |
| 67 |
friend numeric exp(numeric const & x); |
friend numeric exp(const numeric & x); |
| 68 |
friend numeric log(numeric const & x); |
friend numeric log(const numeric & x); |
| 69 |
friend numeric sin(numeric const & x); |
friend numeric sin(const numeric & x); |
| 70 |
friend numeric cos(numeric const & x); |
friend numeric cos(const numeric & x); |
| 71 |
friend numeric tan(numeric const & x); |
friend numeric tan(const numeric & x); |
| 72 |
friend numeric asin(numeric const & x); |
friend numeric asin(const numeric & x); |
| 73 |
friend numeric acos(numeric const & x); |
friend numeric acos(const numeric & x); |
| 74 |
friend numeric atan(numeric const & x); |
friend numeric atan(const numeric & x); |
| 75 |
friend numeric atan(numeric const & y, numeric const & x); |
friend numeric atan(const numeric & y, const numeric & x); |
| 76 |
friend numeric sinh(numeric const & x); |
friend numeric sinh(const numeric & x); |
| 77 |
friend numeric cosh(numeric const & x); |
friend numeric cosh(const numeric & x); |
| 78 |
friend numeric tanh(numeric const & x); |
friend numeric tanh(const numeric & x); |
| 79 |
friend numeric asinh(numeric const & x); |
friend numeric asinh(const numeric & x); |
| 80 |
friend numeric acosh(numeric const & x); |
friend numeric acosh(const numeric & x); |
| 81 |
friend numeric atanh(numeric const & x); |
friend numeric atanh(const numeric & x); |
| 82 |
friend numeric zeta(numeric const & x); |
friend numeric zeta(const numeric & x); |
| 83 |
friend numeric bernoulli(numeric const & n); |
friend numeric bernoulli(const numeric & n); |
| 84 |
friend numeric abs(numeric const & x); |
friend numeric abs(const numeric & x); |
| 85 |
friend numeric mod(numeric const & a, numeric const & b); |
friend numeric mod(const numeric & a, const numeric & b); |
| 86 |
friend numeric smod(numeric const & a, numeric const & b); |
friend numeric smod(const numeric & a, const numeric & b); |
| 87 |
friend numeric irem(numeric const & a, numeric const & b); |
friend numeric irem(const numeric & a, const numeric & b); |
| 88 |
friend numeric irem(numeric const & a, numeric const & b, numeric & q); |
friend numeric irem(const numeric & a, const numeric & b, numeric & q); |
| 89 |
friend numeric iquo(numeric const & a, numeric const & b); |
friend numeric iquo(const numeric & a, const numeric & b); |
| 90 |
friend numeric iquo(numeric const & a, numeric const & b, numeric & r); |
friend numeric iquo(const numeric & a, const numeric & b, numeric & r); |
| 91 |
friend numeric sqrt(numeric const & x); |
friend numeric sqrt(const numeric & x); |
| 92 |
friend numeric isqrt(numeric const & x); |
friend numeric isqrt(const numeric & x); |
| 93 |
friend numeric gcd(numeric const & a, numeric const & b); |
friend numeric gcd(const numeric & a, const numeric & b); |
| 94 |
friend numeric lcm(numeric const & a, numeric const & b); |
friend numeric lcm(const numeric & a, const numeric & b); |
| 95 |
|
|
| 96 |
// member functions |
// member functions |
| 97 |
|
|
| 100 |
public: |
public: |
| 101 |
numeric(); |
numeric(); |
| 102 |
~numeric(); |
~numeric(); |
| 103 |
numeric(numeric const & other); |
numeric(const numeric & other); |
| 104 |
numeric const & operator=(numeric const & other); |
const numeric & operator=(const numeric & other); |
| 105 |
protected: |
protected: |
| 106 |
void copy(numeric const & other); |
void copy(const numeric & other); |
| 107 |
void destroy(bool call_parent); |
void destroy(bool call_parent); |
| 108 |
|
|
| 109 |
// other constructors |
// other constructors |
| 129 |
ex diff(symbol const & s) const; |
ex diff(symbol const & s) const; |
| 130 |
ex normal(lst &sym_lst, lst &repl_lst, int level=0) const; |
ex normal(lst &sym_lst, lst &repl_lst, int level=0) const; |
| 131 |
numeric integer_content(void) const; |
numeric integer_content(void) const; |
| 132 |
ex smod(numeric const &xi) const; |
ex smod(const numeric &xi) const; |
| 133 |
numeric max_coefficient(void) const; |
numeric max_coefficient(void) const; |
| 134 |
protected: |
protected: |
| 135 |
int compare_same_type(basic const & other) const; |
int compare_same_type(basic const & other) const; |
| 144 |
|
|
| 145 |
// non-virtual functions in this class |
// non-virtual functions in this class |
| 146 |
public: |
public: |
| 147 |
numeric add(numeric const & other) const; |
numeric add(const numeric & other) const; |
| 148 |
numeric sub(numeric const & other) const; |
numeric sub(const numeric & other) const; |
| 149 |
numeric mul(numeric const & other) const; |
numeric mul(const numeric & other) const; |
| 150 |
numeric div(numeric const & other) const; |
numeric div(const numeric & other) const; |
| 151 |
numeric power(numeric const & other) const; |
numeric power(const numeric & other) const; |
| 152 |
numeric const & add_dyn(numeric const & other) const; |
const numeric & add_dyn(const numeric & other) const; |
| 153 |
numeric const & sub_dyn(numeric const & other) const; |
const numeric & sub_dyn(const numeric & other) const; |
| 154 |
numeric const & mul_dyn(numeric const & other) const; |
const numeric & mul_dyn(const numeric & other) const; |
| 155 |
numeric const & div_dyn(numeric const & other) const; |
const numeric & div_dyn(const numeric & other) const; |
| 156 |
numeric const & power_dyn(numeric const & other) const; |
const numeric & power_dyn(const numeric & other) const; |
| 157 |
numeric const & operator=(int i); |
const numeric & operator=(int i); |
| 158 |
numeric const & operator=(unsigned int i); |
const numeric & operator=(unsigned int i); |
| 159 |
numeric const & operator=(long i); |
const numeric & operator=(long i); |
| 160 |
numeric const & operator=(unsigned long i); |
const numeric & operator=(unsigned long i); |
| 161 |
numeric const & operator=(double d); |
const numeric & operator=(double d); |
| 162 |
numeric const & operator=(char const * s); |
const numeric & operator=(char const * s); |
|
/* |
|
|
numeric add_dyn(numeric const & other) const { return add(other); } |
|
|
numeric sub_dyn(numeric const & other) const { return sub(other); } |
|
|
numeric mul_dyn(numeric const & other) const { return mul(other); } |
|
|
numeric div_dyn(numeric const & other) const { return div(other); } |
|
|
numeric power_dyn(numeric const & other) const { return power(other); } |
|
|
*/ |
|
| 163 |
numeric inverse(void) const; |
numeric inverse(void) const; |
| 164 |
int csgn(void) const; |
int csgn(void) const; |
| 165 |
int compare(numeric const & other) const; |
int compare(const numeric & other) const; |
| 166 |
bool is_equal(numeric const & other) const; |
bool is_equal(const numeric & other) const; |
| 167 |
bool is_zero(void) const; |
bool is_zero(void) const; |
| 168 |
bool is_positive(void) const; |
bool is_positive(void) const; |
| 169 |
bool is_negative(void) const; |
bool is_negative(void) const; |
| 177 |
bool is_real(void) const; |
bool is_real(void) const; |
| 178 |
bool is_cinteger(void) const; |
bool is_cinteger(void) const; |
| 179 |
bool is_crational(void) const; |
bool is_crational(void) const; |
| 180 |
bool operator==(numeric const & other) const; |
bool operator==(const numeric & other) const; |
| 181 |
bool operator!=(numeric const & other) const; |
bool operator!=(const numeric & other) const; |
| 182 |
bool operator<(numeric const & other) const; |
bool operator<(const numeric & other) const; |
| 183 |
bool operator<=(numeric const & other) const; |
bool operator<=(const numeric & other) const; |
| 184 |
bool operator>(numeric const & other) const; |
bool operator>(const numeric & other) const; |
| 185 |
bool operator>=(numeric const & other) const; |
bool operator>=(const numeric & other) const; |
| 186 |
int to_int(void) const; |
int to_int(void) const; |
| 187 |
double to_double(void) const; |
double to_double(void) const; |
| 188 |
numeric real(void) const; |
numeric real(void) const; |
| 210 |
|
|
| 211 |
// global functions |
// global functions |
| 212 |
|
|
| 213 |
numeric exp(numeric const & x); |
numeric exp(const numeric & x); |
| 214 |
numeric log(numeric const & x); |
numeric log(const numeric & x); |
| 215 |
numeric sin(numeric const & x); |
numeric sin(const numeric & x); |
| 216 |
numeric cos(numeric const & x); |
numeric cos(const numeric & x); |
| 217 |
numeric tan(numeric const & x); |
numeric tan(const numeric & x); |
| 218 |
numeric asin(numeric const & x); |
numeric asin(const numeric & x); |
| 219 |
numeric acos(numeric const & x); |
numeric acos(const numeric & x); |
| 220 |
numeric atan(numeric const & x); |
numeric atan(const numeric & x); |
| 221 |
numeric atan(numeric const & y, numeric const & x); |
numeric atan(const numeric & y, const numeric & x); |
| 222 |
numeric sinh(numeric const & x); |
numeric sinh(const numeric & x); |
| 223 |
numeric cosh(numeric const & x); |
numeric cosh(const numeric & x); |
| 224 |
numeric tanh(numeric const & x); |
numeric tanh(const numeric & x); |
| 225 |
numeric asinh(numeric const & x); |
numeric asinh(const numeric & x); |
| 226 |
numeric acosh(numeric const & x); |
numeric acosh(const numeric & x); |
| 227 |
numeric atanh(numeric const & x); |
numeric atanh(const numeric & x); |
| 228 |
numeric zeta(numeric const & x); |
numeric zeta(const numeric & x); |
| 229 |
numeric gamma(numeric const & x); |
numeric gamma(const numeric & x); |
| 230 |
numeric psi(numeric const & x); |
numeric psi(const numeric & x); |
| 231 |
numeric psi(numeric const & n, numeric const & x); |
numeric psi(const numeric & n, const numeric & x); |
| 232 |
numeric factorial(numeric const & n); |
numeric factorial(const numeric & n); |
| 233 |
numeric doublefactorial(numeric const & n); |
numeric doublefactorial(const numeric & n); |
| 234 |
numeric binomial(numeric const & n, numeric const & k); |
numeric binomial(const numeric & n, const numeric & k); |
| 235 |
numeric bernoulli(numeric const & n); |
numeric bernoulli(const numeric & n); |
| 236 |
|
|
| 237 |
numeric abs(numeric const & x); |
numeric abs(const numeric & x); |
| 238 |
numeric mod(numeric const & a, numeric const & b); |
numeric mod(const numeric & a, const numeric & b); |
| 239 |
numeric smod(numeric const & a, numeric const & b); |
numeric smod(const numeric & a, const numeric & b); |
| 240 |
numeric irem(numeric const & a, numeric const & b); |
numeric irem(const numeric & a, const numeric & b); |
| 241 |
numeric irem(numeric const & a, numeric const & b, numeric & q); |
numeric irem(const numeric & a, const numeric & b, numeric & q); |
| 242 |
numeric iquo(numeric const & a, numeric const & b); |
numeric iquo(const numeric & a, const numeric & b); |
| 243 |
numeric iquo(numeric const & a, numeric const & b, numeric & r); |
numeric iquo(const numeric & a, const numeric & b, numeric & r); |
| 244 |
numeric sqrt(numeric const & x); |
numeric sqrt(const numeric & x); |
| 245 |
numeric isqrt(numeric const & x); |
numeric isqrt(const numeric & x); |
| 246 |
|
|
| 247 |
numeric gcd(numeric const & a, numeric const & b); |
numeric gcd(const numeric & a, const numeric & b); |
| 248 |
numeric lcm(numeric const & a, numeric const & b); |
numeric lcm(const numeric & a, const numeric & b); |
| 249 |
|
|
| 250 |
/** Exception thrown by numeric members to signal failure */ |
/** Exception thrown by numeric members to signal failure */ |
| 251 |
struct numeric_fail |
struct numeric_fail |
| 255 |
}; |
}; |
| 256 |
|
|
| 257 |
// wrapper functions around member functions |
// wrapper functions around member functions |
| 258 |
inline numeric inverse(numeric const & x) |
inline numeric pow(const numeric & x, const numeric & y) |
| 259 |
|
{ return x.power(y); } |
| 260 |
|
|
| 261 |
|
inline numeric inverse(const numeric & x) |
| 262 |
{ return x.inverse(); } |
{ return x.inverse(); } |
| 263 |
|
|
| 264 |
inline bool csgn(numeric const & x) |
inline bool csgn(const numeric & x) |
| 265 |
{ return x.csgn(); } |
{ return x.csgn(); } |
| 266 |
|
|
| 267 |
inline bool is_zero(numeric const & x) |
inline bool is_zero(const numeric & x) |
| 268 |
{ return x.is_zero(); } |
{ return x.is_zero(); } |
| 269 |
|
|
| 270 |
inline bool is_positive(numeric const & x) |
inline bool is_positive(const numeric & x) |
| 271 |
{ return x.is_positive(); } |
{ return x.is_positive(); } |
| 272 |
|
|
| 273 |
inline bool is_integer(numeric const & x) |
inline bool is_integer(const numeric & x) |
| 274 |
{ return x.is_integer(); } |
{ return x.is_integer(); } |
| 275 |
|
|
| 276 |
inline bool is_pos_integer(numeric const & x) |
inline bool is_pos_integer(const numeric & x) |
| 277 |
{ return x.is_pos_integer(); } |
{ return x.is_pos_integer(); } |
| 278 |
|
|
| 279 |
inline bool is_nonneg_integer(numeric const & x) |
inline bool is_nonneg_integer(const numeric & x) |
| 280 |
{ return x.is_nonneg_integer(); } |
{ return x.is_nonneg_integer(); } |
| 281 |
|
|
| 282 |
inline bool is_even(numeric const & x) |
inline bool is_even(const numeric & x) |
| 283 |
{ return x.is_even(); } |
{ return x.is_even(); } |
| 284 |
|
|
| 285 |
inline bool is_odd(numeric const & x) |
inline bool is_odd(const numeric & x) |
| 286 |
{ return x.is_odd(); } |
{ return x.is_odd(); } |
| 287 |
|
|
| 288 |
inline bool is_prime(numeric const & x) |
inline bool is_prime(const numeric & x) |
| 289 |
{ return x.is_prime(); } |
{ return x.is_prime(); } |
| 290 |
|
|
| 291 |
inline bool is_rational(numeric const & x) |
inline bool is_rational(const numeric & x) |
| 292 |
{ return x.is_rational(); } |
{ return x.is_rational(); } |
| 293 |
|
|
| 294 |
inline bool is_real(numeric const & x) |
inline bool is_real(const numeric & x) |
| 295 |
{ return x.is_real(); } |
{ return x.is_real(); } |
| 296 |
|
|
| 297 |
inline bool is_cinteger(numeric const & x) |
inline bool is_cinteger(const numeric & x) |
| 298 |
{ return x.is_cinteger(); } |
{ return x.is_cinteger(); } |
| 299 |
|
|
| 300 |
inline bool is_crational(numeric const & x) |
inline bool is_crational(const numeric & x) |
| 301 |
{ return x.is_crational(); } |
{ return x.is_crational(); } |
| 302 |
|
|
| 303 |
inline numeric real(numeric const & x) |
inline numeric real(const numeric & x) |
| 304 |
{ return x.real(); } |
{ return x.real(); } |
| 305 |
|
|
| 306 |
inline numeric imag(numeric const & x) |
inline numeric imag(const numeric & x) |
| 307 |
{ return x.imag(); } |
{ return x.imag(); } |
| 308 |
|
|
| 309 |
inline numeric numer(numeric const & x) |
inline numeric numer(const numeric & x) |
| 310 |
{ return x.numer(); } |
{ return x.numer(); } |
| 311 |
|
|
| 312 |
inline numeric denom(numeric const & x) |
inline numeric denom(const numeric & x) |
| 313 |
{ return x.denom(); } |
{ return x.denom(); } |
| 314 |
|
|
| 315 |
// numeric evaluation functions for class constant objects: |
// numeric evaluation functions for class constant objects: |