GiNaC  1.7.5
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 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) 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 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 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 match (const ex &pattern, exmap &repls) const
 Check whether the expression matches a given pattern. 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 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 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
 
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...
 
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 int compare_same_type (const basic &other) const
 Returns order relation between two objects of same type. 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/8]

GiNaC::numeric::numeric ( int  i)

◆ numeric() [2/8]

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

◆ numeric() [3/8]

GiNaC::numeric::numeric ( long  i)

◆ numeric() [4/8]

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

◆ numeric() [5/8]

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

Constructor for rational numerics a/b.

Exceptions
overflow_error(division by zero)

Definition at line 148 of file numeric.cpp.

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

◆ numeric() [6/8]

GiNaC::numeric::numeric ( double  d)

◆ numeric() [7/8]

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 169 of file numeric.cpp.

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

◆ numeric() [8/8]

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 248 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 99 of file numeric.h.

References GiNaC::coeff(), GiNaC::degree(), GiNaC::eval(), GiNaC::evalf(), GiNaC::has(), GiNaC::is_polynomial(), GiNaC::ldegree(), n, and options.

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 721 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 726 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 731 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 736 of file numeric.cpp.

References GiNaC::_ex0.

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 747 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 776 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 788 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 108 of file numeric.h.

References GiNaC::conjugate(), GiNaC::imag_part(), n, GiNaC::normal(), options, GiNaC::real_part(), GiNaC::smod(), syms, GiNaC::to_polynomial(), and GiNaC::to_rational().

◆ normal()

ex GiNaC::numeric::normal ( exmap repl,
exmap rev_lookup 
) 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 2084 of file normal.cpp.

References GiNaC::denom(), GiNaC::I, imag(), is_integer(), is_rational(), is_real(), GiNaC::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 2448 of file normal.cpp.

References GiNaC::I, GiNaC::imag(), is_rational(), GiNaC::is_rational(), GiNaC::is_real(), GiNaC::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 2466 of file normal.cpp.

References GiNaC::I, GiNaC::imag(), is_integer(), GiNaC::is_integer(), GiNaC::is_real(), GiNaC::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().

Referenced by GiNaC::ex::integer_content().

◆ 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().

Referenced by GiNaC::ex::max_coefficient().

◆ conjugate()

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

Reimplemented from GiNaC::basic.

Definition at line 793 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 801 of file numeric.cpp.

References numeric(), and value.

◆ imag_part()

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

Reimplemented from GiNaC::basic.

Definition at line 806 of file numeric.cpp.

References compare(), GiNaC::basic::compare_same_type(), GINAC_ASSERT, 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 337 of file numeric.cpp.

References GiNaC::archive_node::add_string(), value, and GiNaC::write_real_float().

◆ read_archive()

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

◆ derivative()

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

◆ 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 822 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 831 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 857 of file numeric.cpp.

References numeric(), and value.

Referenced by GiNaC::multinomial_coefficient(), 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 865 of file numeric.cpp.

References numeric(), and value.

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

◆ 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 873 of file numeric.cpp.

References numeric(), and value.

Referenced by GiNaC::mul::eval(), GiNaC::power::eval(), GiNaC::power::expand_add(), GiNaC::power::expand_add_2(), GiNaC::lcm(), GiNaC::multinomial_coefficient(), GiNaC::operator*(), GiNaC::operator*=(), GiNaC::operator-(), GiNaC::matrix::pow(), and GiNaC::tgamma_eval().

◆ 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 883 of file numeric.cpp.

References numeric(), and value.

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

◆ 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 893 of file numeric.cpp.

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

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

◆ 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 918 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 935 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 950 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 969 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 986 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 1009 of file numeric.cpp.

References numeric().

Referenced by operator=().

◆ operator=() [2/6]

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

Definition at line 1015 of file numeric.cpp.

References numeric(), and operator=().

◆ operator=() [3/6]

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

Definition at line 1021 of file numeric.cpp.

References numeric(), and operator=().

◆ operator=() [4/6]

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

Definition at line 1027 of file numeric.cpp.

References numeric(), and operator=().

◆ operator=() [5/6]

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

Definition at line 1033 of file numeric.cpp.

References numeric(), and operator=().

◆ operator=() [6/6]

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

Definition at line 1039 of file numeric.cpp.

References numeric(), and operator=().

◆ inverse()

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

Inverse of a number.

Definition at line 1046 of file numeric.cpp.

References numeric(), and value.

Referenced by GiNaC::divide_in_z(), GiNaC::power::eval(), GiNaC::heur_gcd_z(), GiNaC::interpolate(), GiNaC::inverse(), 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 1057 of file numeric.cpp.

References numeric(), r, and value.

Referenced by GiNaC::step().

◆ 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 1071 of file numeric.cpp.

References r, and value.

Referenced by GiNaC::csgn(), GiNaC::add::print_add(), and GiNaC::mul::print_overall_coeff().

◆ 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 1097 of file numeric.cpp.

References value.

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

◆ 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 1129 of file numeric.cpp.

References value.

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

◆ is_negative()

bool GiNaC::numeric::is_negative ( ) 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 1154 of file numeric.cpp.

References value.

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

◆ is_nonneg_integer()

bool GiNaC::numeric::is_nonneg_integer ( ) const

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

Definition at line 1161 of file numeric.cpp.

References value.

Referenced by GiNaC::binomial(), GiNaC::binomial_sym(), GiNaC::doublefactorial(), GiNaC::factorial(), info(), GiNaC::is_nonneg_integer(), and print_numeric().

◆ is_even()

bool GiNaC::numeric::is_even ( ) const

True if object is an exact even integer.

Definition at line 1168 of file numeric.cpp.

References value.

Referenced by GiNaC::fibonacci(), info(), GiNaC::is_even(), and GiNaC::tgamma_eval().

◆ is_odd()

bool GiNaC::numeric::is_odd ( ) const

True if object is an exact odd integer.

Definition at line 1175 of file numeric.cpp.

References value.

Referenced by info(), GiNaC::is_odd(), 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 1184 of file numeric.cpp.

References value.

Referenced by info(), and GiNaC::is_prime().

◆ 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 1194 of file numeric.cpp.

References value.

Referenced by GiNaC::power::eval(), info(), GiNaC::is_rational(), GiNaC::multiply_lcm(), normal(), GiNaC::add::print_add(), GiNaC::mul::print_overall_coeff(), 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 1221 of file numeric.cpp.

References is_real(), and value.

Referenced by info(), and GiNaC::is_cinteger().

◆ 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 1236 of file numeric.cpp.

References is_real(), and value.

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

◆ operator==()

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

Definition at line 1207 of file numeric.cpp.

References value.

◆ operator!=()

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

Definition at line 1213 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 1252 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 1263 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 1274 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 1285 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 1296 of file numeric.cpp.

References GINAC_ASSERT, is_integer(), and value.

Referenced by GiNaC::bernoulli(), GiNaC::binomial(), GiNaC::binomial_sym(), GiNaC::doublefactorial(), GiNaC::power::eval(), GiNaC::power::expand(), GiNaC::power::expand_mul(), GiNaC::factorial(), and GiNaC::to_int().

◆ 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 1306 of file numeric.cpp.

References GINAC_ASSERT, is_integer(), and value.

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

◆ 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 1315 of file numeric.cpp.

References GINAC_ASSERT, is_real(), and value.

Referenced by GiNaC::to_double().

◆ to_cl_N()

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

◆ real()

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

Real part of a number.

Definition at line 1332 of file numeric.cpp.

References numeric(), and value.

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

◆ imag()

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

Imaginary part of a number.

Definition at line 1339 of file numeric.cpp.

References numeric(), and value.

Referenced by GiNaC::atan(), GiNaC::csgn_eval(), has(), GiNaC::imag(), normal(), and GiNaC::step_eval().

◆ 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 1349 of file numeric.cpp.

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

Referenced by GiNaC::power::eval(), GiNaC::frac_cancel(), GiNaC::numer(), and GiNaC::print_real_csrc().

◆ 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 1380 of file numeric.cpp.

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

Referenced by GiNaC::denom(), GiNaC::power::eval(), GiNaC::frac_cancel(), and GiNaC::print_real_csrc().

◆ 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 1411 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 598 of file numeric.cpp.

References print_numeric().

◆ do_print_latex()

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

Definition at line 603 of file numeric.cpp.

References print_numeric().

◆ do_print_csrc()

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

Definition at line 608 of file numeric.cpp.

References is_real(), GiNaC::print_real_csrc(), GiNaC::print_context::s, 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 644 of file numeric.cpp.

References is_real(), GiNaC::print_real_cl_N(), GiNaC::print_context::s, and value.

◆ do_print_tree()

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

◆ do_print_python_repr()

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

Definition at line 670 of file numeric.cpp.

References print_numeric(), and GiNaC::print_context::s.

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.