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