GiNaC  1.6.2
Public Member Functions | Protected Member Functions | Protected Attributes
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

List of all members.

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.
 numeric (double d)
 numeric (const char *)
 ctor from C-style string.
unsigned precedence () const
 Return relative operator precedence (for parenthezing output).
bool info (unsigned inf) const
 Information about the object.
bool is_polynomial (const ex &var) const
 Check whether this is a polynomial in the given variables.
int degree (const ex &s) const
 Return degree of highest power in object s.
int ldegree (const ex &s) const
 Return degree of lowest power in object s.
ex coeff (const ex &s, int n=1) const
 Return coefficient of degree n in object s.
bool has (const ex &other, unsigned options=0) const
 Disassemble real part and imaginary part to scan for the occurrence of a single number.
ex eval (int level=0) const
 Evaluation of numbers doesn't do anything at all.
ex evalf (int level=0) const
 Cast numeric into a floating-point object.
ex subs (const exmap &m, unsigned options=0) const
 Substitute a set of objects by arbitrary expressions.
ex normal (exmap &repl, exmap &rev_lookup, int level=0) const
 Implementation of ex::normal() for a numeric.
ex to_rational (exmap &repl) const
 Implementation of ex::to_rational() for a numeric.
ex to_polynomial (exmap &repl) const
 Implementation of ex::to_polynomial() for a numeric.
numeric integer_content () const
ex smod (const numeric &xi) const
 Apply symmetric modular homomorphism to an expanded multivariate polynomial.
numeric max_coefficient () const
 Implementation ex::max_coefficient().
ex conjugate () const
ex real_part () const
ex imag_part () const
void archive (archive_node &n) const
 Save (a.k.a.
void read_archive (const archive_node &n, lst &syms)
 Read (a.k.a.
const numeric add (const numeric &other) const
 Numerical addition method.
const numeric sub (const numeric &other) const
 Numerical subtraction method.
const numeric mul (const numeric &other) const
 Numerical multiplication method.
const numeric div (const numeric &other) const
 Numerical division method.
const numeric power (const numeric &other) const
 Numerical exponentiation.
const numericadd_dyn (const numeric &other) const
 Numerical addition method.
const numericsub_dyn (const numeric &other) const
 Numerical subtraction method.
const numericmul_dyn (const numeric &other) const
 Numerical multiplication method.
const numericdiv_dyn (const numeric &other) const
 Numerical division method.
const numericpower_dyn (const numeric &other) const
 Numerical exponentiation.
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.
numeric step () const
 Return the step function of a numeric.
int csgn () const
 Return the complex half-plane (left or right) in which the number lies.
int compare (const numeric &other) const
 This method establishes a canonical order on all numbers.
bool is_equal (const numeric &other) const
bool is_zero () const
 True if object is zero.
bool is_positive () const
 True if object is not complex and greater than zero.
bool is_negative () const
 True if object is not complex and less than zero.
bool is_integer () const
 True if object is a non-complex integer.
bool is_pos_integer () const
 True if object is an exact integer greater than zero.
bool is_nonneg_integer () const
 True if object is an exact integer greater or equal zero.
bool is_even () const
 True if object is an exact even integer.
bool is_odd () const
 True if object is an exact odd integer.
bool is_prime () const
 Probabilistic primality test.
bool is_rational () const
 True if object is an exact rational number, may even be complex (denominator may be unity).
bool is_real () const
 True if object is a real integer, rational or float (but not complex).
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 operator== (const numeric &other) const
bool operator!= (const numeric &other) const
bool operator< (const numeric &other) const
 Numerical comparison: less.
bool operator<= (const numeric &other) const
 Numerical comparison: less or equal.
bool operator> (const numeric &other) const
 Numerical comparison: greater.
bool operator>= (const numeric &other) const
 Numerical comparison: greater or equal.
int to_int () const
 Converts numeric types to machine's int.
long to_long () const
 Converts numeric types to machine's long.
double to_double () const
 Converts numeric types to machine's double.
cln::cl_N to_cl_N () const
 Returns a new CLN object of type cl_N, representing the value of *this.
const numeric real () const
 Real part of a number.
const numeric imag () const
 Imaginary part of a number.
const numeric numer () const
 Numerator.
const numeric denom () const
 Denominator.
int int_length () const
 Size in binary notation.
 numeric (const cln::cl_N &z)
 Ctor from CLN types.

Protected Member Functions

ex derivative (const symbol &s) const
 Implementation of ex::diff for a numeric always returns 0.
bool is_equal_same_type (const basic &other) const
 Returns true if two objects of same type are equal.
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.
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
 Default output to stream.
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
 Tree output to stream.
void do_print_python_repr (const print_python_repr &c, unsigned level) const
 Python parsable output to stream.

Protected Attributes

cln::cl_N value

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


Constructor & Destructor Documentation

GiNaC::numeric::numeric ( int  i)
GiNaC::numeric::numeric ( unsigned int  i)
GiNaC::numeric::numeric ( long  i)
GiNaC::numeric::numeric ( unsigned long  i)
GiNaC::numeric::numeric ( long  numer,
long  denom 
)

Constructor for rational numerics a/b.

Exceptions:
overflow_error(division by zero)

Definition at line 147 of file numeric.cpp.

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

GiNaC::numeric::numeric ( double  d)
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 168 of file numeric.cpp.

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

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

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


Member Function Documentation

unsigned GiNaC::numeric::precedence ( ) const [inline, virtual]

Return relative operator precedence (for parenthezing output).

Reimplemented from GiNaC::basic.

Definition at line 105 of file numeric.h.

Referenced by print_numeric().

bool GiNaC::numeric::info ( unsigned  inf) const [virtual]
bool GiNaC::numeric::is_polynomial ( const ex var) const [virtual]

Check whether this is a polynomial in the given variables.

Reimplemented from GiNaC::basic.

Definition at line 722 of file numeric.cpp.

int GiNaC::numeric::degree ( const ex s) const [virtual]

Return degree of highest power in object s.

Reimplemented from GiNaC::basic.

Definition at line 727 of file numeric.cpp.

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

int GiNaC::numeric::ldegree ( const ex s) const [virtual]

Return degree of lowest power in object s.

Reimplemented from GiNaC::basic.

Definition at line 732 of file numeric.cpp.

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

ex GiNaC::numeric::coeff ( const ex s,
int  n = 1 
) const [virtual]

Return coefficient of degree n in object s.

Reimplemented from GiNaC::basic.

Definition at line 737 of file numeric.cpp.

References GiNaC::_ex0.

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

bool GiNaC::numeric::has ( const ex other,
unsigned  options = 0 
) const [virtual]

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

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

ex GiNaC::numeric::eval ( int  level = 0) const [virtual]

Evaluation of numbers doesn't do anything at all.

Reimplemented from GiNaC::basic.

Definition at line 777 of file numeric.cpp.

References GiNaC::basic::hold().

ex GiNaC::numeric::evalf ( int  level = 0) const [virtual]

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.

Parameters:
levelignored, only needed for overriding basic::evalf.
Returns:
an ex-handle to a numeric.

Reimplemented from GiNaC::basic.

Definition at line 792 of file numeric.cpp.

References numeric(), and value.

ex GiNaC::numeric::subs ( const exmap m,
unsigned  options = 0 
) const [inline, virtual]

Substitute a set of objects by arbitrary expressions.

The ex returned will already be evaluated.

Reimplemented from GiNaC::basic.

Definition at line 114 of file numeric.h.

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

ex GiNaC::numeric::normal ( exmap repl,
exmap rev_lookup,
int  level = 0 
) const [virtual]

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 2085 of file normal.cpp.

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

ex GiNaC::numeric::to_rational ( exmap repl) const [virtual]

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 2508 of file normal.cpp.

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

ex GiNaC::numeric::to_polynomial ( exmap repl) const [virtual]

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 2526 of file normal.cpp.

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

numeric GiNaC::numeric::integer_content ( ) const [virtual]

Reimplemented from GiNaC::basic.

Definition at line 317 of file normal.cpp.

References GiNaC::abs().

Referenced by GiNaC::gcd().

ex GiNaC::numeric::smod ( const numeric xi) const [virtual]

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 1209 of file normal.cpp.

numeric GiNaC::numeric::max_coefficient ( ) const [virtual]

Implementation ex::max_coefficient().

See also:
heur_gcd

Reimplemented from GiNaC::basic.

Definition at line 1161 of file normal.cpp.

References GiNaC::abs().

ex GiNaC::numeric::conjugate ( ) const [virtual]

Reimplemented from GiNaC::basic.

Definition at line 798 of file numeric.cpp.

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

ex GiNaC::numeric::real_part ( ) const [virtual]

Reimplemented from GiNaC::basic.

Definition at line 806 of file numeric.cpp.

References numeric(), and value.

ex GiNaC::numeric::imag_part ( ) const [virtual]

Reimplemented from GiNaC::basic.

Definition at line 811 of file numeric.cpp.

References numeric(), and value.

void GiNaC::numeric::archive ( archive_node n) const [virtual]

Save (a.k.a.

serialize) object into archive.

Reimplemented from GiNaC::basic.

Definition at line 336 of file numeric.cpp.

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

void GiNaC::numeric::read_archive ( const archive_node n,
lst syms 
) [virtual]

Read (a.k.a.

deserialize) object from archive.

Reimplemented from GiNaC::basic.

Definition at line 281 of file numeric.cpp.

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

ex GiNaC::numeric::derivative ( const symbol s) const [inline, protected, virtual]

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

See also:
ex::diff

Reimplemented from GiNaC::basic.

Definition at line 131 of file numeric.h.

bool GiNaC::numeric::is_equal_same_type ( const basic other) const [protected, virtual]

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

References GINAC_ASSERT, and is_equal().

unsigned GiNaC::numeric::calchash ( ) const [protected, virtual]

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

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

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

References numeric(), and value.

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

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

References numeric(), and value.

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

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

References numeric(), and value.

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

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

References numeric(), and value.

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

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

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

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

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

References GiNaC::_num0_p, GiNaC::status_flags::dynallocated, numeric(), GiNaC::basic::setflag(), and value.

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

References GiNaC::_num0_p, GiNaC::status_flags::dynallocated, numeric(), GiNaC::basic::setflag(), and value.

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, GiNaC::status_flags::dynallocated, numeric(), GiNaC::basic::setflag(), and value.

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

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

References GiNaC::_num1_p, GiNaC::status_flags::dynallocated, numeric(), GiNaC::basic::setflag(), and value.

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

References GiNaC::_num0_p, GiNaC::_num1_p, GiNaC::status_flags::dynallocated, numeric(), GiNaC::basic::setflag(), and value.

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

Definition at line 1017 of file numeric.cpp.

References numeric().

Referenced by operator=().

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

Definition at line 1023 of file numeric.cpp.

References numeric(), and operator=().

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

Definition at line 1029 of file numeric.cpp.

References numeric(), and operator=().

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

Definition at line 1035 of file numeric.cpp.

References numeric(), and operator=().

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

Definition at line 1041 of file numeric.cpp.

References numeric(), and operator=().

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

Definition at line 1047 of file numeric.cpp.

References numeric(), and operator=().

const numeric GiNaC::numeric::inverse ( ) const
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 1065 of file numeric.cpp.

References numeric(), r, and value.

Referenced by GiNaC::step().

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

References r, and value.

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

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

References value.

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

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

True if object is not complex and greater than zero.

Definition at line 1137 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().

bool GiNaC::numeric::is_negative ( ) const
bool GiNaC::numeric::is_integer ( ) const
bool GiNaC::numeric::is_pos_integer ( ) const

True if object is an exact integer greater than zero.

Definition at line 1162 of file numeric.cpp.

References value.

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

bool GiNaC::numeric::is_nonneg_integer ( ) const

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

Definition at line 1169 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().

bool GiNaC::numeric::is_even ( ) const

True if object is an exact even integer.

Definition at line 1176 of file numeric.cpp.

References value.

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

bool GiNaC::numeric::is_odd ( ) const

True if object is an exact odd integer.

Definition at line 1183 of file numeric.cpp.

References value.

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

bool GiNaC::numeric::is_prime ( ) const

Probabilistic primality test.

Returns:
true if object is exact integer and prime.

Definition at line 1192 of file numeric.cpp.

References value.

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

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

References value.

Referenced by GiNaC::power::eval(), info(), GiNaC::is_rational(), normal(), GiNaC::add::print_add(), GiNaC::mul::print_overall_coeff(), and to_rational().

bool GiNaC::numeric::is_real ( ) const
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 1229 of file numeric.cpp.

References is_real(), and value.

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

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

References is_real(), and value.

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

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

Definition at line 1215 of file numeric.cpp.

References value.

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

Definition at line 1221 of file numeric.cpp.

References value.

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

Numerical comparison: less.

Exceptions:
invalid_argument(complex inequality)

Definition at line 1260 of file numeric.cpp.

References is_real(), and value.

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

Numerical comparison: less or equal.

Exceptions:
invalid_argument(complex inequality)

Definition at line 1271 of file numeric.cpp.

References is_real(), and value.

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

Numerical comparison: greater.

Exceptions:
invalid_argument(complex inequality)

Definition at line 1282 of file numeric.cpp.

References is_real(), and value.

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

Numerical comparison: greater or equal.

Exceptions:
invalid_argument(complex inequality)

Definition at line 1293 of file numeric.cpp.

References is_real(), and value.

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

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

References GINAC_ASSERT, is_integer(), and value.

Referenced by GiNaC::to_long().

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

References GINAC_ASSERT, is_real(), and value.

Referenced by GiNaC::to_double().

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

Imaginary part of a number.

Definition at line 1347 of file numeric.cpp.

References numeric(), and value.

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

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

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

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

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 1388 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 normal().

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

References value.

Referenced by GiNaC::heur_gcd_z().

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]
void GiNaC::numeric::do_print ( const print_context c,
unsigned  level 
) const [protected]

Default output to stream.

Reimplemented from GiNaC::basic.

Definition at line 597 of file numeric.cpp.

References print_numeric().

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

Definition at line 602 of file numeric.cpp.

References print_numeric().

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

Definition at line 607 of file numeric.cpp.

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

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

Definition at line 643 of file numeric.cpp.

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

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

Tree output to stream.

Reimplemented from GiNaC::basic.

Definition at line 661 of file numeric.cpp.

References GiNaC::basic::flags, GiNaC::basic::hashvalue, GiNaC::print_context::s, and value.

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

Python parsable output to stream.

Reimplemented from GiNaC::basic.

Definition at line 669 of file numeric.cpp.

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


Member Data Documentation

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.