GiNaC 1.8.7
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
GiNaC::numeric Class Reference

This class is a wrapper around CLN-numbers within the GiNaC class hierarchy. More...

#include <numeric.h>

Inheritance diagram for GiNaC::numeric:
GiNaC::basic GiNaC::refcounted

Public Member Functions

 numeric (int i)
 
 numeric (unsigned int i)
 
 numeric (long i)
 
 numeric (unsigned long i)
 
 numeric (long long i)
 
 numeric (unsigned long long i)
 
 numeric (long numer, long denom)
 Constructor for rational numerics a/b. More...
 
 numeric (double d)
 
 numeric (const char *)
 ctor from C-style string. More...
 
unsigned precedence () const override
 Return relative operator precedence (for parenthezing output). More...
 
bool info (unsigned inf) const override
 Information about the object. More...
 
bool is_polynomial (const ex &var) const override
 Check whether this is a polynomial in the given variables. More...
 
int degree (const ex &s) const override
 Return degree of highest power in object s. More...
 
int ldegree (const ex &s) const override
 Return degree of lowest power in object s. More...
 
ex coeff (const ex &s, int n=1) const override
 Return coefficient of degree n in object s. More...
 
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. More...
 
ex eval () const override
 Evaluation of numbers doesn't do anything at all. More...
 
ex evalf () const override
 Cast numeric into a floating-point object. More...
 
ex subs (const exmap &m, unsigned options=0) const override
 Substitute a set of objects by arbitrary expressions. More...
 
ex normal (exmap &repl, exmap &rev_lookup, lst &modifier) const override
 Implementation of ex::normal() for a numeric. More...
 
ex to_rational (exmap &repl) const override
 Implementation of ex::to_rational() for a numeric. More...
 
ex to_polynomial (exmap &repl) const override
 Implementation of ex::to_polynomial() for a numeric. More...
 
numeric integer_content () const override
 
ex smod (const numeric &xi) const override
 Apply symmetric modular homomorphism to an expanded multivariate polynomial. More...
 
numeric max_coefficient () const override
 Implementation ex::max_coefficient(). More...
 
ex conjugate () const override
 
ex real_part () const override
 
ex imag_part () const override
 
void archive (archive_node &n) const override
 Save (a.k.a. More...
 
void read_archive (const archive_node &n, lst &syms) override
 Read (a.k.a. More...
 
const numeric add (const numeric &other) const
 Numerical addition method. More...
 
const numeric sub (const numeric &other) const
 Numerical subtraction method. More...
 
const numeric mul (const numeric &other) const
 Numerical multiplication method. More...
 
const numeric div (const numeric &other) const
 Numerical division method. More...
 
const numeric power (const numeric &other) const
 Numerical exponentiation. More...
 
const numericadd_dyn (const numeric &other) const
 Numerical addition method. More...
 
const numericsub_dyn (const numeric &other) const
 Numerical subtraction method. More...
 
const numericmul_dyn (const numeric &other) const
 Numerical multiplication method. More...
 
const numericdiv_dyn (const numeric &other) const
 Numerical division method. More...
 
const numericpower_dyn (const numeric &other) const
 Numerical exponentiation. More...
 
const numericoperator= (int i)
 
const numericoperator= (unsigned int i)
 
const numericoperator= (long i)
 
const numericoperator= (unsigned long i)
 
const numericoperator= (double d)
 
const numericoperator= (const char *s)
 
const numeric inverse () const
 Inverse of a number. More...
 
numeric step () const
 Return the step function of a numeric. More...
 
int csgn () const
 Return the complex half-plane (left or right) in which the number lies. More...
 
int compare (const numeric &other) const
 This method establishes a canonical order on all numbers. More...
 
bool is_equal (const numeric &other) const
 
bool is_zero () const
 True if object is zero. More...
 
bool is_positive () const
 True if object is not complex and greater than zero. More...
 
bool is_negative () const
 True if object is not complex and less than zero. More...
 
bool is_integer () const
 True if object is a non-complex integer. More...
 
bool is_pos_integer () const
 True if object is an exact integer greater than zero. More...
 
bool is_nonneg_integer () const
 True if object is an exact integer greater or equal zero. More...
 
bool is_even () const
 True if object is an exact even integer. More...
 
bool is_odd () const
 True if object is an exact odd integer. More...
 
bool is_prime () const
 Probabilistic primality test. More...
 
bool is_rational () const
 True if object is an exact rational number, may even be complex (denominator may be unity). More...
 
bool is_real () const
 True if object is a real integer, rational or float (but not complex). More...
 
bool is_cinteger () const
 True if object is element of the domain of integers extended by I, i.e. More...
 
bool is_crational () const
 True if object is an exact rational number, may even be complex (denominator may be unity). More...
 
bool operator== (const numeric &other) const
 
bool operator!= (const numeric &other) const
 
bool operator< (const numeric &other) const
 Numerical comparison: less. More...
 
bool operator<= (const numeric &other) const
 Numerical comparison: less or equal. More...
 
bool operator> (const numeric &other) const
 Numerical comparison: greater. More...
 
bool operator>= (const numeric &other) const
 Numerical comparison: greater or equal. More...
 
int to_int () const
 Converts numeric types to machine's int. More...
 
long to_long () const
 Converts numeric types to machine's long. More...
 
double to_double () const
 Converts numeric types to machine's double. More...
 
cln::cl_N to_cl_N () const
 Returns a new CLN object of type cl_N, representing the value of *this. More...
 
const numeric real () const
 Real part of a number. More...
 
const numeric imag () const
 Imaginary part of a number. More...
 
const numeric numer () const
 Numerator. More...
 
const numeric denom () const
 Denominator. More...
 
int int_length () const
 Size in binary notation. More...
 
 numeric (const cln::cl_N &z)
 Ctor from CLN types. More...
 
- Public Member Functions inherited from GiNaC::basic
virtual ~basic ()
 basic destructor, virtual because class ex will delete objects of derived classes via a basic*. More...
 
 basic (const basic &other)
 
const basicoperator= (const basic &other)
 basic assignment operator: the other object might be of a derived class. More...
 
virtual basicduplicate () const
 Create a clone of this object on the heap. More...
 
virtual ex eval () const
 Perform automatic non-interruptive term rewriting rules. More...
 
virtual ex evalf () const
 Evaluate object numerically. More...
 
virtual ex evalm () const
 Evaluate sums, products and integer powers of matrices. More...
 
virtual ex eval_integ () const
 Evaluate integrals, if result is known. More...
 
virtual ex eval_indexed (const basic &i) const
 Perform automatic symbolic evaluations on indexed expression that contains this object as the base expression. More...
 
virtual void print (const print_context &c, unsigned level=0) const
 Output to stream. More...
 
virtual void dbgprint () const
 Little wrapper around print to be called within a debugger. More...
 
virtual void dbgprinttree () const
 Little wrapper around printtree to be called within a debugger. More...
 
virtual unsigned precedence () const
 Return relative operator precedence (for parenthezing output). More...
 
virtual bool info (unsigned inf) const
 Information about the object. More...
 
virtual size_t nops () const
 Number of operands/members. More...
 
virtual ex op (size_t i) const
 Return operand/member at position i. More...
 
virtual ex operator[] (const ex &index) const
 
virtual ex operator[] (size_t i) const
 
virtual exlet_op (size_t i)
 Return modifiable operand/member at position i. More...
 
virtual exoperator[] (const ex &index)
 
virtual exoperator[] (size_t i)
 
virtual bool has (const ex &other, unsigned options=0) const
 Test for occurrence of a pattern. More...
 
virtual bool match (const ex &pattern, exmap &repls) const
 Check whether the expression matches a given pattern. More...
 
virtual ex subs (const exmap &m, unsigned options=0) const
 Substitute a set of objects by arbitrary expressions. More...
 
virtual ex map (map_function &f) const
 Construct new expression by applying the specified function to all sub-expressions (one level only, not recursively). More...
 
virtual void accept (GiNaC::visitor &v) const
 
virtual bool is_polynomial (const ex &var) const
 Check whether this is a polynomial in the given variables. More...
 
virtual int degree (const ex &s) const
 Return degree of highest power in object s. More...
 
virtual int ldegree (const ex &s) const
 Return degree of lowest power in object s. More...
 
virtual ex coeff (const ex &s, int n=1) const
 Return coefficient of degree n in object s. More...
 
virtual ex expand (unsigned options=0) const
 Expand expression, i.e. More...
 
virtual ex collect (const ex &s, bool distributed=false) const
 Sort expanded expression in terms of powers of some object(s). More...
 
virtual ex series (const relational &r, int order, unsigned options=0) const
 Default implementation of ex::series(). More...
 
virtual ex normal (exmap &repl, exmap &rev_lookup, lst &modifier) const
 Default implementation of ex::normal(). More...
 
virtual ex to_rational (exmap &repl) const
 Default implementation of ex::to_rational(). More...
 
virtual ex to_polynomial (exmap &repl) const
 
virtual numeric integer_content () const
 
virtual ex smod (const numeric &xi) const
 Apply symmetric modular homomorphism to an expanded multivariate polynomial. More...
 
virtual numeric max_coefficient () const
 Implementation ex::max_coefficient(). More...
 
virtual exvector get_free_indices () const
 Return a vector containing the free indices of an expression. More...
 
virtual ex add_indexed (const ex &self, const ex &other) const
 Add two indexed expressions. More...
 
virtual ex scalar_mul_indexed (const ex &self, const numeric &other) const
 Multiply an indexed expression with a scalar. More...
 
virtual bool contract_with (exvector::iterator self, exvector::iterator other, exvector &v) const
 Try to contract two indexed expressions that appear in the same product. More...
 
virtual unsigned return_type () const
 
virtual return_type_t return_type_tinfo () const
 
virtual ex conjugate () const
 
virtual ex real_part () const
 
virtual ex imag_part () const
 
template<class T >
void print_dispatch (const print_context &c, unsigned level) const
 Like print(), but dispatch to the specified class. More...
 
void print_dispatch (const registered_class_info &ri, const print_context &c, unsigned level) const
 Like print(), but dispatch to the specified class. More...
 
virtual void archive (archive_node &n) const
 Save (serialize) the object into archive node. More...
 
virtual void read_archive (const archive_node &n, lst &syms)
 Load (deserialize) the object from an archive node. More...
 
ex subs_one_level (const exmap &m, unsigned options) const
 Helper function for subs(). More...
 
ex diff (const symbol &s, unsigned nth=1) const
 Default interface of nth derivative ex::diff(s, n). More...
 
int compare (const basic &other) const
 Compare objects syntactically to establish canonical ordering. More...
 
bool is_equal (const basic &other) const
 Test for syntactic equality. More...
 
const basichold () const
 Stop further evaluation. More...
 
unsigned gethash () const
 
const basicsetflag (unsigned f) const
 Set some status_flags. More...
 
const basicclearflag (unsigned f) const
 Clear some status_flags. More...
 
- Public Member Functions inherited from GiNaC::refcounted
 refcounted () noexcept
 
unsigned int add_reference () noexcept
 
unsigned int remove_reference () noexcept
 
unsigned int get_refcount () const noexcept
 
void set_refcount (unsigned int r) noexcept
 

Protected Member Functions

ex derivative (const symbol &s) const override
 Implementation of ex::diff for a numeric always returns 0. More...
 
bool is_equal_same_type (const basic &other) const override
 Returns true if two objects of same type are equal. More...
 
unsigned calchash () const override
 Compute the hash value of an object and if it makes sense to store it in the objects status_flags, do so. More...
 
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 (const print_context &c, unsigned level) const
 
void do_print_latex (const print_latex &c, unsigned level) const
 
void do_print_csrc (const print_csrc &c, unsigned level) const
 
void do_print_csrc_cl_N (const print_csrc_cl_N &c, unsigned level) const
 
void do_print_tree (const print_tree &c, unsigned level) const
 
void do_print_python_repr (const print_python_repr &c, unsigned level) const
 
- Protected Member Functions inherited from GiNaC::basic
 basic ()
 
virtual ex eval_ncmul (const exvector &v) const
 
virtual bool match_same_type (const basic &other) const
 Returns true if the attributes of two objects are similar enough for a match. More...
 
virtual ex derivative (const symbol &s) const
 Default implementation of ex::diff(). More...
 
virtual int compare_same_type (const basic &other) const
 Returns order relation between two objects of same type. More...
 
virtual bool is_equal_same_type (const basic &other) const
 Returns true if two objects of same type are equal. More...
 
virtual unsigned calchash () const
 Compute the hash value of an object and if it makes sense to store it in the objects status_flags, do so. More...
 
void ensure_if_modifiable () const
 Ensure the object may be modified without hurting others, throws if this is not the case. More...
 
void do_print (const print_context &c, unsigned level) const
 Default output to stream. More...
 
void do_print_tree (const print_tree &c, unsigned level) const
 Tree output to stream. More...
 
void do_print_python_repr (const print_python_repr &c, unsigned level) const
 Python parsable output to stream. More...
 

Protected Attributes

cln::cl_N value
 
- Protected Attributes inherited from GiNaC::basic
unsigned flags
 of type status_flags More...
 
unsigned hashvalue
 hash value More...
 

Detailed Description

This class is a wrapper around CLN-numbers within the GiNaC class hierarchy.

Objects of this type may directly be created by the user.

Definition at line 81 of file numeric.h.

Constructor & Destructor Documentation

◆ numeric() [1/10]

GiNaC::numeric::numeric ( int  i)

◆ numeric() [2/10]

GiNaC::numeric::numeric ( unsigned int  i)

◆ numeric() [3/10]

GiNaC::numeric::numeric ( long  i)

◆ numeric() [4/10]

GiNaC::numeric::numeric ( unsigned long  i)

◆ numeric() [5/10]

GiNaC::numeric::numeric ( long long  i)

◆ numeric() [6/10]

GiNaC::numeric::numeric ( unsigned long long  i)

◆ numeric() [7/10]

GiNaC::numeric::numeric ( long  numer,
long  denom 
)

Constructor for rational numerics a/b.

Exceptions
overflow_error(division by zero)

Definition at line 155 of file numeric.cpp.

References denom(), GiNaC::status_flags::evaluated, GiNaC::status_flags::expanded, numer(), GiNaC::basic::setflag(), and value.

◆ numeric() [8/10]

GiNaC::numeric::numeric ( double  d)

◆ numeric() [9/10]

GiNaC::numeric::numeric ( const char *  s)

ctor from C-style string.

It also accepts complex numbers in GiNaC notation like "2+5*I".

Definition at line 176 of file numeric.cpp.

References GiNaC::Digits, GiNaC::status_flags::evaluated, GiNaC::status_flags::expanded, GiNaC::basic::setflag(), and value.

◆ numeric() [10/10]

GiNaC::numeric::numeric ( const cln::cl_N &  z)
explicit

Ctor from CLN types.

This is for the initiated user or internal use only.

Definition at line 255 of file numeric.cpp.

References GiNaC::status_flags::evaluated, GiNaC::status_flags::expanded, GiNaC::basic::setflag(), and value.

Member Function Documentation

◆ precedence()

unsigned GiNaC::numeric::precedence ( ) const
inlineoverridevirtual

Return relative operator precedence (for parenthezing output).

Reimplemented from GiNaC::basic.

Definition at line 101 of file numeric.h.

Referenced by print_numeric().

◆ info()

bool GiNaC::numeric::info ( unsigned  inf) const
overridevirtual

◆ is_polynomial()

bool GiNaC::numeric::is_polynomial ( const ex var) const
overridevirtual

Check whether this is a polynomial in the given variables.

Reimplemented from GiNaC::basic.

Definition at line 728 of file numeric.cpp.

◆ degree()

int GiNaC::numeric::degree ( const ex s) const
overridevirtual

Return degree of highest power in object s.

Reimplemented from GiNaC::basic.

Definition at line 733 of file numeric.cpp.

◆ ldegree()

int GiNaC::numeric::ldegree ( const ex s) const
overridevirtual

Return degree of lowest power in object s.

Reimplemented from GiNaC::basic.

Definition at line 738 of file numeric.cpp.

◆ coeff()

ex GiNaC::numeric::coeff ( const ex s,
int  n = 1 
) const
overridevirtual

Return coefficient of degree n in object s.

Reimplemented from GiNaC::basic.

Definition at line 743 of file numeric.cpp.

References GiNaC::_ex0, and n.

Referenced by GiNaC::pseries::mul_const().

◆ has()

bool GiNaC::numeric::has ( const ex other,
unsigned  options = 0 
) const
overridevirtual

Disassemble real part and imaginary part to scan for the occurrence of a single number.

Also handles the imaginary unit. It ignores the sign on both this and the argument, which may lead to what might appear as funny results: (2+I).has(-2) -> true. But this is consistent, since we also would like to have (-2+I).has(2) -> true and we want to think about the sign as a multiplicative factor.

Reimplemented from GiNaC::basic.

Definition at line 754 of file numeric.cpp.

References GiNaC::_num0_p, GiNaC::I, imag(), is_equal(), is_real(), is_zero(), and real().

◆ eval()

ex GiNaC::numeric::eval ( ) const
overridevirtual

Evaluation of numbers doesn't do anything at all.

Reimplemented from GiNaC::basic.

Definition at line 783 of file numeric.cpp.

References GiNaC::basic::hold().

◆ evalf()

ex GiNaC::numeric::evalf ( ) const
overridevirtual

Cast numeric into a floating-point object.

For example exact numeric(1) is returned as a 1.0000000000000000000000 and so on according to how Digits is currently set. In case the object already was a floating point number the precision is trimmed to match the currently set default.

Returns
an ex-handle to a numeric.

Reimplemented from GiNaC::basic.

Definition at line 795 of file numeric.cpp.

References numeric(), and value.

◆ subs()

ex GiNaC::numeric::subs ( const exmap m,
unsigned  options = 0 
) const
inlineoverridevirtual

Substitute a set of objects by arbitrary expressions.

The ex returned will already be evaluated.

Reimplemented from GiNaC::basic.

Definition at line 110 of file numeric.h.

References m, options, and GiNaC::basic::subs_one_level().

◆ normal()

ex GiNaC::numeric::normal ( exmap repl,
exmap rev_lookup,
lst modifier 
) const
overridevirtual

Implementation of ex::normal() for a numeric.

It splits complex numbers into re+I*im and replaces I and non-rational real numbers with a temporary symbol.

See also
ex::normal

Reimplemented from GiNaC::basic.

Definition at line 2252 of file normal.cpp.

References denom(), GiNaC::I, imag(), is_integer(), is_rational(), is_real(), numer(), real(), and GiNaC::replace_with_symbol().

◆ to_rational()

ex GiNaC::numeric::to_rational ( exmap repl) const
overridevirtual

Implementation of ex::to_rational() for a numeric.

It splits complex numbers into re+I*im and replaces I and non-rational real numbers with a temporary symbol.

Reimplemented from GiNaC::basic.

Definition at line 2668 of file normal.cpp.

References GiNaC::I, imag(), is_rational(), is_real(), real(), and GiNaC::replace_with_symbol().

◆ to_polynomial()

ex GiNaC::numeric::to_polynomial ( exmap repl) const
overridevirtual

Implementation of ex::to_polynomial() for a numeric.

It splits complex numbers into re+I*im and replaces I and non-integer real numbers with a temporary symbol.

Reimplemented from GiNaC::basic.

Definition at line 2686 of file normal.cpp.

References GiNaC::I, imag(), is_integer(), is_real(), real(), and GiNaC::replace_with_symbol().

◆ integer_content()

numeric GiNaC::numeric::integer_content ( ) const
overridevirtual

Reimplemented from GiNaC::basic.

Definition at line 328 of file normal.cpp.

References GiNaC::abs().

◆ smod()

ex GiNaC::numeric::smod ( const numeric xi) const
overridevirtual

Apply symmetric modular homomorphism to an expanded multivariate polynomial.

This function is usually used internally by heur_gcd().

Parameters
ximodulus
Returns
mapped polynomial
See also
heur_gcd

Reimplemented from GiNaC::basic.

Definition at line 1208 of file normal.cpp.

References GiNaC::smod().

◆ max_coefficient()

numeric GiNaC::numeric::max_coefficient ( ) const
overridevirtual

Implementation ex::max_coefficient().

See also
heur_gcd

Reimplemented from GiNaC::basic.

Definition at line 1166 of file normal.cpp.

References GiNaC::abs().

◆ conjugate()

ex GiNaC::numeric::conjugate ( ) const
overridevirtual

Reimplemented from GiNaC::basic.

Definition at line 800 of file numeric.cpp.

References GiNaC::conjugate(), is_real(), numeric(), and value.

◆ real_part()

ex GiNaC::numeric::real_part ( ) const
overridevirtual

Reimplemented from GiNaC::basic.

Definition at line 808 of file numeric.cpp.

References numeric(), and value.

◆ imag_part()

ex GiNaC::numeric::imag_part ( ) const
overridevirtual

Reimplemented from GiNaC::basic.

Definition at line 813 of file numeric.cpp.

References numeric(), and value.

◆ archive()

void GiNaC::numeric::archive ( archive_node n) const
overridevirtual

Save (a.k.a.

serialize) object into archive.

Reimplemented from GiNaC::basic.

Definition at line 344 of file numeric.cpp.

References n, value, and GiNaC::write_real_float().

◆ read_archive()

void GiNaC::numeric::read_archive ( const archive_node n,
lst syms 
)
overridevirtual

Read (a.k.a.

deserialize) object from archive.

Reimplemented from GiNaC::basic.

Definition at line 289 of file numeric.cpp.

References c, GiNaC::status_flags::evaluated, GiNaC::status_flags::expanded, n, GiNaC::read_real_float(), GiNaC::basic::setflag(), and value.

◆ derivative()

ex GiNaC::numeric::derivative ( const symbol s) const
inlineoverrideprotectedvirtual

Implementation of ex::diff for a numeric always returns 0.

See also
ex::diff

Reimplemented from GiNaC::basic.

Definition at line 127 of file numeric.h.

◆ is_equal_same_type()

bool GiNaC::numeric::is_equal_same_type ( const basic other) const
overrideprotectedvirtual

Returns true if two objects of same type are equal.

Normally needs not be reimplemented as long as it wasn't overwritten by some parent class, since it just calls compare_same_type(). The reason why this function exists is that sometimes it is easier to determine equality than an order relation and then it can be overridden.

Reimplemented from GiNaC::basic.

Definition at line 829 of file numeric.cpp.

References GINAC_ASSERT, and is_equal().

◆ calchash()

unsigned GiNaC::numeric::calchash ( ) const
overrideprotectedvirtual

Compute the hash value of an object and if it makes sense to store it in the objects status_flags, do so.

The method inherited from class basic computes a hash value based on the type and hash values of possible members. For this reason it is well suited for container classes but atomic classes should override this implementation because otherwise they would all end up with the same hashvalue.

Reimplemented from GiNaC::basic.

Definition at line 838 of file numeric.cpp.

References GiNaC::golden_ratio_hash(), GiNaC::status_flags::hash_calculated, GiNaC::basic::hashvalue, GiNaC::basic::setflag(), and value.

◆ add()

const numeric GiNaC::numeric::add ( const numeric other) const

Numerical addition method.

Adds argument to *this and returns result as a numeric object.

Definition at line 864 of file numeric.cpp.

References numeric(), and value.

Referenced by GiNaC::operator+(), GiNaC::operator++(), GiNaC::operator+=(), and GiNaC::operator--().

◆ sub()

const numeric GiNaC::numeric::sub ( const numeric other) const

Numerical subtraction method.

Subtracts argument from *this and returns result as a numeric object.

Definition at line 872 of file numeric.cpp.

References numeric(), and value.

Referenced by GiNaC::operator-(), and GiNaC::operator-=().

◆ mul()

const numeric GiNaC::numeric::mul ( const numeric other) const

Numerical multiplication method.

Multiplies *this and argument and returns result as a numeric object.

Definition at line 880 of file numeric.cpp.

References numeric(), and value.

Referenced by GiNaC::mul::eval(), GiNaC::power::eval(), GiNaC::mul::expand(), GiNaC::power::expand_add_2(), GiNaC::lcm(), GiNaC::operator*(), GiNaC::operator*=(), and GiNaC::operator-().

◆ div()

const numeric GiNaC::numeric::div ( const numeric other) const

Numerical division method.

Divides *this by argument and returns result as a numeric object.

Exceptions
overflow_error(division by zero)

Definition at line 890 of file numeric.cpp.

References numeric(), and value.

Referenced by GiNaC::mul::eval(), GiNaC::power::eval(), GiNaC::multinomial_coefficient(), GiNaC::operator/(), GiNaC::operator/=(), GiNaC::basic::series(), and GiNaC::tgamma_eval().

◆ power()

const numeric GiNaC::numeric::power ( const numeric other) const

Numerical exponentiation.

Raises *this to the power given as argument and returns result as a numeric object.

Definition at line 900 of file numeric.cpp.

References GiNaC::_num0_p, GiNaC::_num1_p, numeric(), and value.

Referenced by GiNaC::binomial(), and GiNaC::power::eval().

◆ add_dyn()

const numeric & GiNaC::numeric::add_dyn ( const numeric other) const

Numerical addition method.

Adds argument to *this and returns result as a numeric object on the heap. Use internally only for direct wrapping into an ex object, where the result would end up on the heap anyways.

Definition at line 925 of file numeric.cpp.

References GiNaC::_num0_p, and value.

◆ sub_dyn()

const numeric & GiNaC::numeric::sub_dyn ( const numeric other) const

Numerical subtraction method.

Subtracts argument from *this and returns result as a numeric object on the heap. Use internally only for direct wrapping into an ex object, where the result would end up on the heap anyways.

Definition at line 942 of file numeric.cpp.

References GiNaC::_num0_p, and value.

◆ mul_dyn()

const numeric & GiNaC::numeric::mul_dyn ( const numeric other) const

Numerical multiplication method.

Multiplies *this and argument and returns result as a numeric object on the heap. Use internally only for direct wrapping into an ex object, where the result would end up on the heap anyways.

Definition at line 957 of file numeric.cpp.

References GiNaC::_num1_p, and value.

Referenced by GiNaC::power::expand_add_2().

◆ div_dyn()

const numeric & GiNaC::numeric::div_dyn ( const numeric other) const

Numerical division method.

Divides *this by argument and returns result as a numeric object on the heap. Use internally only for direct wrapping into an ex object, where the result would end up on the heap anyways.

Exceptions
overflow_error(division by zero)

Definition at line 976 of file numeric.cpp.

References GiNaC::_num1_p, and value.

◆ power_dyn()

const numeric & GiNaC::numeric::power_dyn ( const numeric other) const

Numerical exponentiation.

Raises *this to the power given as argument and returns result as a numeric object on the heap. Use internally only for direct wrapping into an ex object, where the result would end up on the heap anyways.

Definition at line 993 of file numeric.cpp.

References GiNaC::_num0_p, GiNaC::_num1_p, and value.

◆ operator=() [1/6]

const numeric & GiNaC::numeric::operator= ( int  i)

Definition at line 1016 of file numeric.cpp.

References numeric(), and operator=().

Referenced by operator=().

◆ operator=() [2/6]

const numeric & GiNaC::numeric::operator= ( unsigned int  i)

Definition at line 1022 of file numeric.cpp.

References numeric(), and operator=().

◆ operator=() [3/6]

const numeric & GiNaC::numeric::operator= ( long  i)

Definition at line 1028 of file numeric.cpp.

References numeric(), and operator=().

◆ operator=() [4/6]

const numeric & GiNaC::numeric::operator= ( unsigned long  i)

Definition at line 1034 of file numeric.cpp.

References numeric(), and operator=().

◆ operator=() [5/6]

const numeric & GiNaC::numeric::operator= ( double  d)

Definition at line 1040 of file numeric.cpp.

References numeric(), and operator=().

◆ operator=() [6/6]

const numeric & GiNaC::numeric::operator= ( const char *  s)

Definition at line 1046 of file numeric.cpp.

References numeric(), and operator=().

◆ inverse()

const numeric GiNaC::numeric::inverse ( ) const

Inverse of a number.

Definition at line 1053 of file numeric.cpp.

References numeric(), and value.

Referenced by GiNaC::divide_in_z(), GiNaC::power::eval(), GiNaC::heur_gcd_z(), GiNaC::interpolate(), and GiNaC::psi1_eval().

◆ step()

numeric GiNaC::numeric::step ( ) const

Return the step function of a numeric.

The imaginary part of it is ignored because the step function is generally considered real but a numeric may develop a small imaginary part due to rounding errors.

Definition at line 1064 of file numeric.cpp.

References numeric(), r, and value.

◆ csgn()

int GiNaC::numeric::csgn ( ) const

Return the complex half-plane (left or right) in which the number lies.

csgn(x)==0 for x==0, csgn(x)==1 for Re(x)>0 or Re(x)=0 and Im(x)>0, csgn(x)==-1 for Re(x)<0 or Re(x)=0 and Im(x)<0.

See also
numeric::compare(const numeric &other)

Definition at line 1078 of file numeric.cpp.

References r, and value.

◆ compare()

int GiNaC::numeric::compare ( const numeric other) const

This method establishes a canonical order on all numbers.

For complex numbers this is not possible in a mathematically consistent way but we need to establish some order and it ought to be fast. So we simply define it to be compatible with our method csgn.

Returns
csgn(*this-other)
See also
numeric::csgn()

Definition at line 1104 of file numeric.cpp.

References value.

Referenced by GiNaC::power::eval().

◆ is_equal()

bool GiNaC::numeric::is_equal ( const numeric other) const

◆ is_zero()

bool GiNaC::numeric::is_zero ( ) const

◆ is_positive()

bool GiNaC::numeric::is_positive ( ) const

True if object is not complex and greater than zero.

Definition at line 1136 of file numeric.cpp.

References value.

Referenced by GiNaC::power::eval(), info(), GiNaC::psi1_eval(), GiNaC::psi2_eval(), and GiNaC::tgamma_eval().

◆ is_negative()

bool GiNaC::numeric::is_negative ( ) const

True if object is not complex and less than zero.

Definition at line 1145 of file numeric.cpp.

References value.

Referenced by GiNaC::bernoulli(), GiNaC::beta_eval(), GiNaC::eta_eval(), GiNaC::eta_evalf(), info(), and GiNaC::pseries::power_const().

◆ is_integer()

bool GiNaC::numeric::is_integer ( ) const

◆ is_pos_integer()

bool GiNaC::numeric::is_pos_integer ( ) const

True if object is an exact integer greater than zero.

Definition at line 1161 of file numeric.cpp.

References value.

Referenced by GiNaC::mul::eval(), GiNaC::power::eval(), info(), and GiNaC::pseries::power_const().

◆ is_nonneg_integer()

bool GiNaC::numeric::is_nonneg_integer ( ) const

True if object is an exact integer greater or equal zero.

Definition at line 1168 of file numeric.cpp.

References value.

Referenced by GiNaC::binomial_sym(), info(), and print_numeric().

◆ is_even()

bool GiNaC::numeric::is_even ( ) const

True if object is an exact even integer.

Definition at line 1175 of file numeric.cpp.

References value.

Referenced by info(), GiNaC::kronecker_symbol(), and GiNaC::tgamma_eval().

◆ is_odd()

bool GiNaC::numeric::is_odd ( ) const

True if object is an exact odd integer.

Definition at line 1182 of file numeric.cpp.

References value.

Referenced by info(), GiNaC::is_discriminant_of_quadratic_number_field(), and GiNaC::matrix::pow().

◆ is_prime()

bool GiNaC::numeric::is_prime ( ) const

Probabilistic primality test.

Returns
true if object is exact integer and prime.

Definition at line 1191 of file numeric.cpp.

References value.

Referenced by info().

◆ is_rational()

bool GiNaC::numeric::is_rational ( ) const

True if object is an exact rational number, may even be complex (denominator may be unity).

Definition at line 1201 of file numeric.cpp.

References value.

Referenced by GiNaC::power::eval(), info(), GiNaC::multiply_lcm(), normal(), and to_rational().

◆ is_real()

bool GiNaC::numeric::is_real ( ) const

◆ is_cinteger()

bool GiNaC::numeric::is_cinteger ( ) const

True if object is element of the domain of integers extended by I, i.e.

is of the form a+b*I, where a and b are integers.

Definition at line 1228 of file numeric.cpp.

References is_real(), and value.

Referenced by info().

◆ is_crational()

bool GiNaC::numeric::is_crational ( ) const

True if object is an exact rational number, may even be complex (denominator may be unity).

Definition at line 1243 of file numeric.cpp.

References is_real(), and value.

Referenced by GiNaC::power::eval(), and info().

◆ operator==()

bool GiNaC::numeric::operator== ( const numeric other) const

Definition at line 1214 of file numeric.cpp.

References value.

◆ operator!=()

bool GiNaC::numeric::operator!= ( const numeric other) const

Definition at line 1220 of file numeric.cpp.

References value.

◆ operator<()

bool GiNaC::numeric::operator< ( const numeric other) const

Numerical comparison: less.

Exceptions
invalid_argument(complex inequality)

Definition at line 1259 of file numeric.cpp.

References is_real(), and value.

◆ operator<=()

bool GiNaC::numeric::operator<= ( const numeric other) const

Numerical comparison: less or equal.

Exceptions
invalid_argument(complex inequality)

Definition at line 1270 of file numeric.cpp.

References is_real(), and value.

◆ operator>()

bool GiNaC::numeric::operator> ( const numeric other) const

Numerical comparison: greater.

Exceptions
invalid_argument(complex inequality)

Definition at line 1281 of file numeric.cpp.

References is_real(), and value.

◆ operator>=()

bool GiNaC::numeric::operator>= ( const numeric other) const

Numerical comparison: greater or equal.

Exceptions
invalid_argument(complex inequality)

Definition at line 1292 of file numeric.cpp.

References is_real(), and value.

◆ to_int()

int GiNaC::numeric::to_int ( ) const

Converts numeric types to machine's int.

You should check with is_integer() if the number is really an integer before calling this method. You may also consider checking the range first.

Definition at line 1303 of file numeric.cpp.

References GINAC_ASSERT, is_integer(), and value.

Referenced by GiNaC::bernoulli(), GiNaC::binomial_sym(), GiNaC::power::do_print_csrc(), GiNaC::power::eval(), GiNaC::power::expand(), GiNaC::Li_eval(), GiNaC::Kronecker_dtau_kernel::series_coeff_impl(), and GiNaC::Kronecker_dz_kernel::series_coeff_impl().

◆ to_long()

long GiNaC::numeric::to_long ( ) const

Converts numeric types to machine's long.

You should check with is_integer() if the number is really an integer before calling this method. You may also consider checking the range first.

Definition at line 1313 of file numeric.cpp.

References GINAC_ASSERT, is_integer(), and value.

Referenced by GiNaC::power::expand(), and GiNaC::power::expand_add().

◆ to_double()

double GiNaC::numeric::to_double ( ) const

Converts numeric types to machine's double.

You should check with is_real() if the number is really not complex before calling this method.

Definition at line 1322 of file numeric.cpp.

References GINAC_ASSERT, is_real(), and value.

◆ to_cl_N()

cln::cl_N GiNaC::numeric::to_cl_N ( ) const

Returns a new CLN object of type cl_N, representing the value of *this.

This method may be used when mixing GiNaC and CLN in one project.

Definition at line 1332 of file numeric.cpp.

References value.

Referenced by GiNaC::atan(), GiNaC::gcd(), GiNaC::iquo(), GiNaC::irem(), GiNaC::lcm(), GiNaC::mod(), GiNaC::Kronecker_dtau_kernel::series_coeff_impl(), and GiNaC::smod().

◆ real()

const numeric GiNaC::numeric::real ( ) const

Real part of a number.

Definition at line 1339 of file numeric.cpp.

References numeric(), and value.

Referenced by GiNaC::csgn_eval(), GiNaC::power::eval(), has(), normal(), GiNaC::pseries::power_const(), GiNaC::step_eval(), to_polynomial(), and to_rational().

◆ imag()

const numeric GiNaC::numeric::imag ( ) const

Imaginary part of a number.

Definition at line 1346 of file numeric.cpp.

References numeric(), and value.

Referenced by GiNaC::csgn_eval(), has(), normal(), GiNaC::step_eval(), to_polynomial(), and to_rational().

◆ numer()

const numeric GiNaC::numeric::numer ( ) const

Numerator.

Computes the numerator of rational numbers, rationalized numerator of complex if real and imaginary part are both rational numbers (i.e numer(4/3+5/6*I) == 8+5*I), the number carrying the sign in all other cases.

Definition at line 1356 of file numeric.cpp.

References is_real(), GiNaC::lcm(), numeric(), r, and value.

Referenced by GiNaC::power::eval(), GiNaC::frac_cancel(), normal(), and numeric().

◆ denom()

const numeric GiNaC::numeric::denom ( ) const

Denominator.

Computes the denominator of rational numbers, common integer denominator of complex if real and imaginary part are both rational numbers (i.e denom(4/3+5/6*I) == 6), one in all other cases.

Definition at line 1387 of file numeric.cpp.

References GiNaC::_num1_p, is_real(), GiNaC::lcm(), numeric(), r, and value.

Referenced by GiNaC::power::eval(), GiNaC::frac_cancel(), normal(), and numeric().

◆ int_length()

int GiNaC::numeric::int_length ( ) const

Size in binary notation.

For integers, this is the smallest n >= 0 such that -2^n <= x < 2^n. If x > 0, this is the unique n > 0 such that 2^(n-1) <= x < 2^n.

Returns
number of bits (excluding sign) needed to represent that number in two's complement if it is an integer, 0 otherwise.

Definition at line 1418 of file numeric.cpp.

References value.

Referenced by GiNaC::heur_gcd_z().

◆ print_numeric()

void GiNaC::numeric::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
protected

◆ do_print()

void GiNaC::numeric::do_print ( const print_context c,
unsigned  level 
) const
protected

Definition at line 605 of file numeric.cpp.

References c, and print_numeric().

◆ do_print_latex()

void GiNaC::numeric::do_print_latex ( const print_latex c,
unsigned  level 
) const
protected

Definition at line 610 of file numeric.cpp.

References c, and print_numeric().

◆ do_print_csrc()

void GiNaC::numeric::do_print_csrc ( const print_csrc c,
unsigned  level 
) const
protected

Definition at line 615 of file numeric.cpp.

References c, is_real(), GiNaC::print_real_csrc(), and value.

◆ do_print_csrc_cl_N()

void GiNaC::numeric::do_print_csrc_cl_N ( const print_csrc_cl_N c,
unsigned  level 
) const
protected

Definition at line 651 of file numeric.cpp.

References c, is_real(), GiNaC::print_real_cl_N(), and value.

◆ do_print_tree()

void GiNaC::numeric::do_print_tree ( const print_tree c,
unsigned  level 
) const
protected

Definition at line 669 of file numeric.cpp.

References c, GiNaC::basic::flags, GiNaC::basic::hashvalue, and value.

◆ do_print_python_repr()

void GiNaC::numeric::do_print_python_repr ( const print_python_repr c,
unsigned  level 
) const
protected

Definition at line 677 of file numeric.cpp.

References c, and print_numeric().

Member Data Documentation

◆ value

cln::cl_N GiNaC::numeric::value
protected

The documentation for this class was generated from the following files:

This page is part of the GiNaC developer's reference. It was generated automatically by doxygen. For an introduction, see the tutorial.