GiNaC 1.8.7
|
This class is a wrapper around CLN-numbers within the GiNaC class hierarchy. More...
#include <numeric.h>
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 numeric & | add_dyn (const numeric &other) const |
Numerical addition method. More... | |
const numeric & | sub_dyn (const numeric &other) const |
Numerical subtraction method. More... | |
const numeric & | mul_dyn (const numeric &other) const |
Numerical multiplication method. More... | |
const numeric & | div_dyn (const numeric &other) const |
Numerical division method. More... | |
const numeric & | power_dyn (const numeric &other) const |
Numerical exponentiation. More... | |
const numeric & | operator= (int i) |
const numeric & | operator= (unsigned int i) |
const numeric & | operator= (long i) |
const numeric & | operator= (unsigned long i) |
const numeric & | operator= (double d) |
const numeric & | operator= (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 basic & | operator= (const basic &other) |
basic assignment operator: the other object might be of a derived class. More... | |
virtual basic * | duplicate () 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 ex & | let_op (size_t i) |
Return modifiable operand/member at position i. More... | |
virtual ex & | operator[] (const ex &index) |
virtual ex & | operator[] (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 basic & | hold () const |
Stop further evaluation. More... | |
unsigned | gethash () const |
const basic & | setflag (unsigned f) const |
Set some status_flags. More... | |
const basic & | clearflag (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... | |
This class is a wrapper around CLN-numbers within the GiNaC class hierarchy.
Objects of this type may directly be created by the user.
GiNaC::numeric::numeric | ( | int | i | ) |
Definition at line 85 of file numeric.cpp.
References GiNaC::status_flags::evaluated, GiNaC::status_flags::expanded, GiNaC::basic::setflag(), and value.
Referenced by add(), conjugate(), denom(), div(), evalf(), imag(), imag_part(), inverse(), mul(), numer(), operator=(), power(), real(), real_part(), step(), and sub().
GiNaC::numeric::numeric | ( | unsigned int | i | ) |
Definition at line 106 of file numeric.cpp.
References GiNaC::status_flags::evaluated, GiNaC::status_flags::expanded, GiNaC::basic::setflag(), and value.
GiNaC::numeric::numeric | ( | long | i | ) |
Definition at line 127 of file numeric.cpp.
References GiNaC::status_flags::evaluated, GiNaC::status_flags::expanded, GiNaC::basic::setflag(), and value.
GiNaC::numeric::numeric | ( | unsigned long | i | ) |
Definition at line 134 of file numeric.cpp.
References GiNaC::status_flags::evaluated, GiNaC::status_flags::expanded, GiNaC::basic::setflag(), and value.
GiNaC::numeric::numeric | ( | long long | i | ) |
Definition at line 140 of file numeric.cpp.
References GiNaC::status_flags::evaluated, GiNaC::status_flags::expanded, GiNaC::basic::setflag(), and value.
GiNaC::numeric::numeric | ( | unsigned long long | i | ) |
Definition at line 146 of file numeric.cpp.
References GiNaC::status_flags::evaluated, GiNaC::status_flags::expanded, GiNaC::basic::setflag(), and value.
GiNaC::numeric::numeric | ( | long | numer, |
long | denom | ||
) |
Constructor for rational numerics a/b.
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.
GiNaC::numeric::numeric | ( | double | d | ) |
Definition at line 164 of file numeric.cpp.
References GiNaC::status_flags::evaluated, GiNaC::status_flags::expanded, GiNaC::basic::setflag(), and value.
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.
|
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.
|
inlineoverridevirtual |
Return relative operator precedence (for parenthezing output).
Reimplemented from GiNaC::basic.
Definition at line 101 of file numeric.h.
Referenced by print_numeric().
|
overridevirtual |
Information about the object.
Reimplemented from GiNaC::basic.
Definition at line 684 of file numeric.cpp.
References GiNaC::info_flags::cinteger, GiNaC::info_flags::cinteger_polynomial, GiNaC::info_flags::crational, GiNaC::info_flags::crational_polynomial, GiNaC::info_flags::even, GiNaC::info_flags::expanded, GiNaC::info_flags::integer, GiNaC::info_flags::integer_polynomial, is_cinteger(), is_crational(), is_even(), is_integer(), is_negative(), is_nonneg_integer(), is_odd(), is_pos_integer(), is_positive(), is_prime(), is_rational(), is_real(), is_zero(), GiNaC::info_flags::negative, GiNaC::info_flags::negint, GiNaC::info_flags::nonnegative, GiNaC::info_flags::nonnegint, GiNaC::info_flags::numeric, GiNaC::info_flags::odd, GiNaC::info_flags::polynomial, GiNaC::info_flags::posint, GiNaC::info_flags::positive, GiNaC::info_flags::prime, GiNaC::info_flags::rational, GiNaC::info_flags::rational_function, GiNaC::info_flags::rational_polynomial, and GiNaC::info_flags::real.
Referenced by GiNaC::abs_power(), GiNaC::csgn_power(), and GiNaC::zeta1_eval().
|
overridevirtual |
Check whether this is a polynomial in the given variables.
Reimplemented from GiNaC::basic.
Definition at line 728 of file numeric.cpp.
|
overridevirtual |
Return degree of highest power in object s.
Reimplemented from GiNaC::basic.
Definition at line 733 of file numeric.cpp.
|
overridevirtual |
Return degree of lowest power in object s.
Reimplemented from GiNaC::basic.
Definition at line 738 of file numeric.cpp.
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().
|
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().
|
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().
|
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.
Reimplemented from GiNaC::basic.
Definition at line 795 of file numeric.cpp.
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().
|
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.
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().
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().
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().
|
overridevirtual |
Reimplemented from GiNaC::basic.
Definition at line 328 of file normal.cpp.
References GiNaC::abs().
Apply symmetric modular homomorphism to an expanded multivariate polynomial.
This function is usually used internally by heur_gcd().
xi | modulus |
Reimplemented from GiNaC::basic.
Definition at line 1208 of file normal.cpp.
References GiNaC::smod().
|
overridevirtual |
Implementation ex::max_coefficient().
Reimplemented from GiNaC::basic.
Definition at line 1166 of file normal.cpp.
References GiNaC::abs().
|
overridevirtual |
Reimplemented from GiNaC::basic.
Definition at line 800 of file numeric.cpp.
References GiNaC::conjugate(), is_real(), numeric(), and value.
|
overridevirtual |
Reimplemented from GiNaC::basic.
Definition at line 808 of file numeric.cpp.
|
overridevirtual |
Reimplemented from GiNaC::basic.
Definition at line 813 of file numeric.cpp.
|
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().
|
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.
Implementation of ex::diff for a numeric always returns 0.
Reimplemented from GiNaC::basic.
|
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().
|
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.
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--().
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-=().
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-().
Numerical division method.
Divides *this by argument and returns result as a numeric object.
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().
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().
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.
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.
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().
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.
overflow_error | (division by zero) |
Definition at line 976 of file numeric.cpp.
References GiNaC::_num1_p, and value.
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.
const numeric & GiNaC::numeric::operator= | ( | int | i | ) |
Definition at line 1016 of file numeric.cpp.
References numeric(), and operator=().
Referenced by operator=().
const numeric & GiNaC::numeric::operator= | ( | unsigned int | i | ) |
Definition at line 1022 of file numeric.cpp.
References numeric(), and operator=().
const numeric & GiNaC::numeric::operator= | ( | long | i | ) |
Definition at line 1028 of file numeric.cpp.
References numeric(), and operator=().
const numeric & GiNaC::numeric::operator= | ( | unsigned long | i | ) |
Definition at line 1034 of file numeric.cpp.
References numeric(), and operator=().
const numeric & GiNaC::numeric::operator= | ( | double | d | ) |
Definition at line 1040 of file numeric.cpp.
References numeric(), and operator=().
const numeric & GiNaC::numeric::operator= | ( | const char * | s | ) |
Definition at line 1046 of file numeric.cpp.
References numeric(), and operator=().
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().
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.
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.
Definition at line 1078 of file numeric.cpp.
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.
Definition at line 1104 of file numeric.cpp.
References value.
Referenced by GiNaC::power::eval().
bool GiNaC::numeric::is_equal | ( | const numeric & | other | ) | const |
Definition at line 1122 of file numeric.cpp.
References value.
Referenced by GiNaC::atan(), GiNaC::cos_eval(), GiNaC::power::eval(), GiNaC::exp_eval(), has(), is_equal_same_type(), GiNaC::psi2_eval(), GiNaC::sin_eval(), GiNaC::tan_eval(), and GiNaC::zeta1_eval().
bool GiNaC::numeric::is_zero | ( | ) | const |
True if object is zero.
Definition at line 1129 of file numeric.cpp.
References value.
Referenced by GiNaC::asinh_conjugate(), GiNaC::atan(), GiNaC::atan_conjugate(), GiNaC::expairseq::construct_from_2_expairseq(), GiNaC::expairseq::construct_from_expairseq_ex(), GiNaC::csgn_eval(), GiNaC::power::eval(), GiNaC::fsolve(), GiNaC::gcd(), has(), info(), GiNaC::iquo(), GiNaC::irem(), GiNaC::matrix::pivot(), GiNaC::matrix::pow(), GiNaC::pseries::power_const(), GiNaC::step_eval(), and GiNaC::zeta1_eval().
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().
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().
bool GiNaC::numeric::is_integer | ( | ) | const |
True if object is a non-complex integer.
Definition at line 1154 of file numeric.cpp.
References value.
Referenced by GiNaC::bernoulli(), GiNaC::beta_eval(), GiNaC::binomial_sym(), GiNaC::mul::eval(), GiNaC::power::eval(), GiNaC::gcd(), info(), GiNaC::iquo(), GiNaC::irem(), GiNaC::lcm(), GiNaC::mod(), normal(), GiNaC::psi1_eval(), GiNaC::psi2_eval(), GiNaC::smod(), GiNaC::tgamma_eval(), to_int(), to_long(), to_polynomial(), and GiNaC::zeta1_eval().
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().
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().
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().
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().
bool GiNaC::numeric::is_prime | ( | ) | const |
Probabilistic primality test.
Definition at line 1191 of file numeric.cpp.
References value.
Referenced by info().
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().
bool GiNaC::numeric::is_real | ( | ) | const |
True if object is a real integer, rational or float (but not complex).
Definition at line 1208 of file numeric.cpp.
References value.
Referenced by GiNaC::atan(), GiNaC::beta_eval(), conjugate(), GiNaC::csgn_eval(), denom(), do_print_csrc(), do_print_csrc_cl_N(), GiNaC::eta_eval(), GiNaC::eta_evalf(), GiNaC::power::eval(), GiNaC::fsolve(), has(), info(), is_cinteger(), is_crational(), normal(), numer(), operator<(), operator<=(), operator>(), operator>=(), GiNaC::step_eval(), to_double(), to_polynomial(), and to_rational().
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().
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().
bool GiNaC::numeric::operator== | ( | const numeric & | other | ) | const |
Definition at line 1214 of file numeric.cpp.
References value.
bool GiNaC::numeric::operator!= | ( | const numeric & | other | ) | const |
Definition at line 1220 of file numeric.cpp.
References value.
bool GiNaC::numeric::operator< | ( | const numeric & | other | ) | const |
Numerical comparison: less.
invalid_argument | (complex inequality) |
Definition at line 1259 of file numeric.cpp.
bool GiNaC::numeric::operator<= | ( | const numeric & | other | ) | const |
Numerical comparison: less or equal.
invalid_argument | (complex inequality) |
Definition at line 1270 of file numeric.cpp.
bool GiNaC::numeric::operator> | ( | const numeric & | other | ) | const |
Numerical comparison: greater.
invalid_argument | (complex inequality) |
Definition at line 1281 of file numeric.cpp.
bool GiNaC::numeric::operator>= | ( | const numeric & | other | ) | const |
Numerical comparison: greater or equal.
invalid_argument | (complex inequality) |
Definition at line 1292 of file numeric.cpp.
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().
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().
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.
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().
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().
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().
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().
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 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.
Definition at line 1418 of file numeric.cpp.
References value.
Referenced by GiNaC::heur_gcd_z().
|
protected |
Definition at line 542 of file numeric.cpp.
References c, is_nonneg_integer(), precedence(), GiNaC::print_real_number(), r, GiNaC::print_context::s, and value.
Referenced by do_print(), do_print_latex(), and do_print_python_repr().
|
protected |
Definition at line 605 of file numeric.cpp.
References c, and print_numeric().
|
protected |
Definition at line 610 of file numeric.cpp.
References c, and print_numeric().
|
protected |
Definition at line 615 of file numeric.cpp.
References c, is_real(), GiNaC::print_real_csrc(), and value.
|
protected |
Definition at line 651 of file numeric.cpp.
References c, is_real(), GiNaC::print_real_cl_N(), and value.
|
protected |
Definition at line 669 of file numeric.cpp.
References c, GiNaC::basic::flags, GiNaC::basic::hashvalue, and value.
|
protected |
Definition at line 677 of file numeric.cpp.
References c, and print_numeric().
|
protected |
Definition at line 200 of file numeric.h.
Referenced by add(), add_dyn(), archive(), calchash(), compare(), conjugate(), csgn(), denom(), div(), div_dyn(), do_print_csrc(), do_print_csrc_cl_N(), do_print_tree(), evalf(), GiNaC::GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(), imag(), imag_part(), int_length(), inverse(), is_cinteger(), is_crational(), is_equal(), is_even(), is_integer(), is_negative(), is_nonneg_integer(), is_odd(), is_pos_integer(), is_positive(), is_prime(), is_rational(), is_real(), is_zero(), mul(), mul_dyn(), numer(), numeric(), operator!=(), operator<(), operator<=(), operator==(), operator>(), operator>=(), power(), power_dyn(), print_numeric(), read_archive(), real(), real_part(), step(), sub(), sub_dyn(), to_cl_N(), to_double(), to_int(), and to_long().