23 #ifndef GINAC_NUMERIC_H 24 #define GINAC_NUMERIC_H 30 #include <cln/complex.h> 58 void print(std::ostream& os)
const;
102 bool info(
unsigned inf)
const override;
104 int degree(
const ex & s)
const override;
105 int ldegree(
const ex & s)
const override;
106 ex coeff(
const ex & s,
int n = 1)
const override;
107 bool has(
const ex &other,
unsigned options = 0)
const override;
186 explicit numeric(
const cln::cl_N &z);
189 void print_numeric(
const print_context &
c,
const char *par_open,
const char *par_close,
const char *imag_sym,
const char *mul_sym,
unsigned level)
const;
252 {
return x.power(y); }
255 {
return x.inverse(); }
267 {
return x.is_positive(); }
270 {
return x.is_negative(); }
273 {
return x.is_integer(); }
276 {
return x.is_pos_integer(); }
279 {
return x.is_nonneg_integer(); }
282 {
return x.is_even(); }
285 {
return x.is_odd(); }
288 {
return x.is_prime(); }
291 {
return x.is_rational(); }
294 {
return x.is_real(); }
297 {
return x.is_cinteger(); }
300 {
return x.is_crational(); }
303 {
return x.to_int(); }
306 {
return x.to_long(); }
309 {
return x.to_double(); }
332 #endif // ndef GINAC_NUMERIC_H bool is_cinteger() const
True if object is element of the domain of integers extended by I, i.e.
bool is_crational() const
True if object is an exact rational number, may even be complex (denominator may be unity)...
bool is_pos_integer(const numeric &x)
const numeric exp(const numeric &x)
Exponential function.
const numeric asinh(const numeric &x)
Numeric inverse hyperbolic sine (trigonometric function).
bool is_negative() const
True if object is not complex and less than zero.
double to_double(const numeric &x)
unsigned calchash() const override
Compute the hash value of an object and if it makes sense to store it in the objects status_flags...
const numeric sinh(const numeric &x)
Numeric hyperbolic sine (trigonometric function).
long to_long(const numeric &x)
ex derivative(const symbol &s) const override
Implementation of ex::diff for a numeric always returns 0.
int to_int(const numeric &x)
int csgn(const numeric &x)
int degree() const
Return the degree of the pole_error exception class.
ex PiEvalf()
Floating point evaluation of Archimedes' constant Pi.
bool operator>(const numeric &other) const
Numerical comparison: greater.
const numeric acos(const numeric &x)
Numeric inverse cosine (trigonometric function).
const numeric & sub_dyn(const numeric &other) const
Numerical subtraction method.
bool is_pos_integer() const
True if object is an exact integer greater than zero.
ex denom() const
Get denominator of an expression.
numeric max_coefficient() const override
Implementation ex::max_coefficient().
const numeric bernoulli(const numeric &nn)
Bernoulli number.
void do_print_csrc_cl_N(const print_csrc_cl_N &c, unsigned level) const
bool operator<(const numeric &other) const
Numerical comparison: less.
ex EulerEvalf()
Floating point evaluation of Euler's constant gamma.
ex normal(exmap &repl, exmap &rev_lookup, lst &modifier) const override
Implementation of ex::normal() for a numeric.
const numeric doublefactorial(const numeric &n)
The double factorial combinatorial function.
ex denom(const ex &thisex)
void print_numeric(const print_context &c, const char *par_open, const char *par_close, const char *imag_sym, const char *mul_sym, unsigned level) const
bool is_even() const
True if object is an exact even integer.
ex lcm(const ex &a, const ex &b, bool check_args)
Compute LCM (Least Common Multiple) of multivariate polynomials in Z[X].
ex imag_part() const override
const numeric sin(const numeric &x)
Numeric sine (trigonometric function).
const cln::cl_N lgamma(const cln::cl_N &x)
The Gamma function.
std::vector< digits_changed_callback > callbacklist
const numeric power(const numeric &other) const
Numerical exponentiation.
const numeric fibonacci(const numeric &n)
Fibonacci number.
Archiving of GiNaC expressions.
bool is_crational(const numeric &x)
bool is_negative(const numeric &x)
This class is the ABC (abstract base class) of GiNaC's class hierarchy.
Context for python-parsable output.
const numeric denom() const
Denominator.
const cln::cl_N tgamma(const cln::cl_N &x)
function zeta(const T1 &p1)
void do_print_tree(const print_tree &c, unsigned level) const
int ldegree(const ex &s) const override
Return degree of lowest power in object s.
_numeric_digits & operator=(long prec)
Assign a native long to global Digits object.
bool is_polynomial(const ex &var) const override
Check whether this is a polynomial in the given variables.
const numeric asin(const numeric &x)
Numeric inverse sine (trigonometric function).
function psi(const T1 &p1)
const numeric add(const numeric &other) const
Numerical addition method.
ex real_part() const override
bool is_integer(const numeric &x)
const numeric irem(const numeric &a, const numeric &b)
Numeric integer remainder.
int compare(const numeric &other) const
This method establishes a canonical order on all numbers.
bool info(unsigned inf) const override
Information about the object.
bool is_equal(const numeric &other) const
bool is_zero(const ex &thisex)
bool is_even(const numeric &x)
int to_int() const
Converts numeric types to machine's int.
bool operator<=(const numeric &other) const
Numerical comparison: less or equal.
ex numer(const ex &thisex)
void do_print_python_repr(const print_python_repr &c, unsigned level) const
ex gcd(const ex &a, const ex &b, ex *ca, ex *cb, bool check_args, unsigned options)
Compute GCD (Greatest Common Divisor) of multivariate polynomials a(X) and b(X) in Z[X]...
ex evalf() const override
Cast numeric into a floating-point object.
int degree(const ex &s) const override
Return degree of highest power in object s.
This class is a wrapper around CLN-numbers within the GiNaC class hierarchy.
Context for latex-parsable output.
const numeric & power_dyn(const numeric &other) const
Numerical exponentiation.
bool is_equal_same_type(const basic &other) const override
Returns true if two objects of same type are equal.
bool is_integer() const
True if object is a non-complex integer.
const numeric mul(const numeric &other) const
Numerical multiplication method.
int csgn() const
Return the complex half-plane (left or right) in which the number lies.
pole_error(const std::string &what_arg, int degree)
ctor for pole_error exception class.
bool is_positive() const
True if object is not complex and greater than zero.
static bool too_late
Already one object present.
const numeric div(const numeric &other) const
Numerical division method.
ex subs_one_level(const exmap &m, unsigned options) const
Helper function for subs().
_numeric_digits Digits
Accuracy in decimal digits.
ex conjugate() const override
const numeric acosh(const numeric &x)
Numeric inverse hyperbolic cosine (trigonometric function).
ex eval() const override
Evaluation of numbers doesn't do anything at all.
long to_long() const
Converts numeric types to machine's long.
ex to_rational(exmap &repl) const override
Implementation of ex::to_rational() for a numeric.
bool is_odd() const
True if object is an exact odd integer.
ex coeff(const ex &s, int n=1) const override
Return coefficient of degree n in object s.
const numeric log(const numeric &x)
Natural logarithm.
const numeric tanh(const numeric &x)
Numeric hyperbolic tangent (trigonometric function).
const numeric real() const
Real part of a number.
ex to_polynomial(exmap &repl) const override
Implementation of ex::to_polynomial() for a numeric.
const numeric smod(const numeric &a_, const numeric &b_)
Modulus (in symmetric representation).
const numeric numer() const
Numerator.
const numeric abs(const numeric &x)
Absolute value.
This class is used to instantiate a global singleton object Digits which behaves just like Maple's Di...
std::map< ex, ex, ex_is_less > exmap
void read_archive(const archive_node &n, lst &syms) override
Read (a.k.a.
const numeric cosh(const numeric &x)
Numeric hyperbolic cosine (trigonometric function).
const numeric isqrt(const numeric &x)
Integer numeric square root.
bool is_real() const
True if object is a real integer, rational or float (but not complex).
const numeric & mul_dyn(const numeric &other) const
Numerical multiplication method.
const numeric sqrt(const numeric &x)
Numeric square root.
const numeric & div_dyn(const numeric &other) const
Numerical division method.
const numeric binomial(const numeric &n, const numeric &k)
The Binomial coefficients.
bool is_prime(const numeric &x)
numeric step() const
Return the step function of a numeric.
bool operator==(const numeric &other) const
const numeric Li2(const numeric &x)
ex smod(const numeric &xi) const override
Apply symmetric modular homomorphism to an expanded multivariate polynomial.
Interface to GiNaC's light-weight expression handles.
Base class for print_contexts.
void print(std::ostream &os) const
Append global Digits object to ostream.
const numeric I
Imaginary unit.
const numeric cos(const numeric &x)
Numeric cosine (trigonometric function).
const numeric & operator=(int i)
bool is_cinteger(const numeric &x)
void archive(archive_node &n) const override
Save (a.k.a.
ex CatalanEvalf()
Floating point evaluation of Catalan's constant.
const numeric pow(const numeric &x, const numeric &y)
Exception class thrown when a singularity is encountered.
ex subs(const exmap &m, unsigned options=0) const override
Substitute a set of objects by arbitrary expressions.
_numeric_digits()
_numeric_digits default ctor, checking for singleton invariance.
Interface to GiNaC's ABC.
bool is_prime() const
Probabilistic primality test.
void do_print_latex(const print_latex &c, unsigned level) const
ex numer() const
Get numerator of an expression.
bool is_zero() const
True if object is zero.
numeric integer_content() const override
This class stores all properties needed to record/retrieve the state of one object of class basic (or...
Lightweight wrapper for GiNaC's symbolic objects.
const numeric atanh(const numeric &x)
Numeric inverse hyperbolic tangent (trigonometric function).
cln::cl_N to_cl_N() const
Returns a new CLN object of type cl_N, representing the value of *this.
void do_print_csrc(const print_csrc &c, unsigned level) const
const numeric mod(const numeric &a, const numeric &b)
Modulus (in positive representation).
const numeric & add_dyn(const numeric &other) const
Numerical addition method.
bool is_nonneg_integer() const
True if object is an exact integer greater or equal zero.
Context for C source output using CLN numbers.
Wrapper template for making GiNaC classes out of STL containers.
#define GINAC_DECLARE_REGISTERED_CLASS(classname, supername)
Macro for inclusion in the declaration of each registered class.
Base context for C source output.
const numeric real(const numeric &x)
const numeric imag() const
Imaginary part of a number.
void do_print(const print_context &c, unsigned level) const
const numeric atan(const numeric &x)
Numeric arcustangent.
double to_double() const
Converts numeric types to machine's double.
void add_callback(digits_changed_callback callback)
Add a new callback function.
void(* digits_changed_callback)(long)
Function pointer to implement callbacks in the case 'Digits' gets changed.
long digits
Number of decimal digits.
unsigned precedence() const override
Return relative operator precedence (for parenthezing output).
GINAC_DECLARE_UNARCHIVER(add)
const numeric factorial(const numeric &n)
Factorial combinatorial function.
const numeric inverse() const
Inverse of a number.
const numeric sub(const numeric &other) const
Numerical subtraction method.
bool operator>=(const numeric &other) const
Numerical comparison: greater or equal.
bool is_rational(const numeric &x)
bool is_real(const numeric &x)
bool is_rational() const
True if object is an exact rational number, may even be complex (denominator may be unity)...
bool is_nonneg_integer(const numeric &x)
bool has(const ex &other, unsigned options=0) const override
Disassemble real part and imaginary part to scan for the occurrence of a single number.
bool is_odd(const numeric &x)
numeric step(const numeric &x)
const numeric imag(const numeric &x)
matrix inverse(const matrix &m)
Context for tree-like output for debugging.
bool operator!=(const numeric &other) const
bool is_positive(const numeric &x)
const numeric tan(const numeric &x)
Numeric tangent (trigonometric function).
int int_length() const
Size in binary notation.
const numeric iquo(const numeric &a, const numeric &b)
Numeric integer quotient.