CGAL 6.1.3 - Number Types
Loading...
Searching...
No Matches
CGAL Namespace Reference

Classes

class  Gmpfi
 An object of the class Gmpfi is a closed interval, with endpoints represented as Gmpfr floating-point numbers. More...
class  Gmpfr
 An object of the class Gmpfr is a fixed precision floating-point number, based on the MPFR library. More...
class  Gmpq
 An object of the class Gmpq is an arbitrary precision rational number based on the GMP library. More...
class  Gmpz
 An object of the class Gmpz is an arbitrary precision integer based on the GMP Library. More...
class  Gmpzf
 An object of the class Gmpzf is a multiple-precision floating-point number which can represent numbers of the form \( m*2^e\), where \( m\) is an arbitrary precision integer based on the GMP library, and \( e\) is of type long. More...
class  Interval_nt
 The class Interval_nt provides an interval arithmetic number type. More...
class  Is_valid
 Not all values of a type need to be valid. More...
class  Lazy_exact_nt
 An object of the class Lazy_exact_nt<NT> is able to represent any real embeddable number which NT is able to represent. More...
struct  Max
 The function object class Max returns the larger of two values. More...
struct  Min
 The function object class Min returns the smaller of two values. More...
class  MP_Float
 An object of the class MP_Float is able to represent a floating point value with arbitrary precision. More...
struct  Mpzf
 An object of the class Mpzf is a multiple-precision floating-point number which can represent numbers of the form \( m*2^e\), where \(m\) is an arbitrary precision integer based on the GMP library, and \( e\) is of type int. More...
struct  NT_converter
 A number type converter usable as default, for Cartesian_converter and Homogeneous_converter. More...
class  Number_type_checker
 Number_type_checker is a number type whose instances store two numbers of types NT1 and NT2. More...
struct  Protect_FPU_rounding
 The class Protect_FPU_rounding allows to reduce the number of rounding mode changes when evaluating sequences of interval arithmetic operations. More...
class  Quotient
 An object of the class Quotient<NT> is an element of the field of quotients of the integral domain type NT. More...
class  Rational_traits
 The class Rational_traits can be used to determine the type of the numerator and denominator of a rational number type as Quotient, Gmpq, mpq_class or leda_rational. More...
struct  Root_of_traits
 For a RealEmbeddable IntegralDomain RT, the class template Root_of_traits<RT> associates a type Root_of_2, which represents algebraic numbers of degree 2 over RT. More...
class  Set_ieee_double_precision
 The class Set_ieee_double_precision provides a mechanism to set the correct 53 bits precision for a block of code. More...
class  Sqrt_extension
 An instance of this class represents an extension of the type NT by one square root of the type Root. More...

Typedefs

typedef Interval_nt< false > Interval_nt_advanced
 This typedef (at namespace CGAL scope) exists for backward compatibility, as well as removing the need to remember the Boolean value for the template parameter.
typedef unspecified_type Exact_integer
 Exact_integer is an exact integer number type.
typedef unspecified_type Exact_rational
 Exact_rational is an exact rational number type, constructible from double.

Functions

bool is_finite (double x)
 Determines whether the argument represents a value in \( \mathbb{R}\).
bool is_finite (float x)
 Determines whether the argument represents a value in \( \mathbb{R}\).
bool is_finite (long double x)
 Determines whether the argument represents a value in \( \mathbb{R}\).
template<typename RT, typename OutputIterator>
OutputIterator compute_roots_of_2 (const RT &a, const RT &b, const RT &c, OutputIterator oit)
 The function compute_roots_of_2() solves a univariate polynomial as it is defined by the coefficients given to the function.
template<typename RT>
Root_of_traits< RT >::Root_of_2 make_root_of_2 (const RT &a, const RT &b, const RT &c, bool s)
 The function make_root_of_2() constructs an algebraic number of degree 2 over a ring number type.
template<typename RT>
Root_of_traits< RT >::Root_of_2 make_root_of_2 (RT alpha, RT beta, RT gamma)
 The function make_root_of_2() constructs an algebraic number of degree 2 over a ring number type.
template<typename RT>
Root_of_traits< RT >::Root_of_2 make_sqrt (const RT &x)
 The function make_sqrt() constructs a square root of a given value of type RT.
template<typename Rational>
Rational simplest_rational_in_interval (double d1, double d2)
 computes the rational number with the smallest denominator in the interval [d1,d2].
template<typename Rational>
Rational to_rational (double d)
 computes the rational number that equals d.
template<typename T>
bool is_valid (const T &x)
 Not all values of a type need to be valid.
template<typename T>
max (const T &x, const T &y)
 Returns the larger of two values.
template<typename T>
min (const T &x, const T &y)
 Returns the smaller of two values.
void force_ieee_double_precision ()
 Sets the precision of operations on double to 53bits.
std::istream & operator>> (std::istream &is, Gmpfi i)
 Reads i from is.
std::ostream & operator<< (std::ostream &os, const Gmpfi &i)
 Writes i to os, in the form [i.inf(),i.sup()].
std::istream & operator>> (std::istream &in, Gmpfr &f)
 Reads a floating-point number from in.
std::ostream & operator<< (std::ostream &out, const Gmpfr &f)
 If the ostream out is in pretty-print mode, writes a decimal approximation of f to out.
std::ostream & operator<< (std::ostream &out, const Gmpq &q)
 writes q to the ostream out, in the form n/d.
std::istream & operator>> (std::istream &in, Gmpq &q)
 reads a number from in, then converts it to a Gmpq.
Gmpz operator>> (const Gmpz &a, unsigned long i)
 rightshift by i.
Gmpz operator<< (const Gmpz &a, unsigned long i)
 leftshift by i.
Gmpz operator& (const Gmpz &a, const Gmpz &b)
 bitwise AND.
Gmpz operator| (const Gmpz &a, const Gmpz &b)
 bitwise IOR.
Gmpz operator^ (const Gmpz &a, const Gmpz &b)
 bitwise XOR.
std::ostream & operator<< (std::ostream &out, const Gmpz &z)
 writes z to the ostream out.
std::istream & operator>> (std::istream &in, Gmpz &z)
 reads an integer from in, then converts it to a Gmpz.
std::ostream & operator<< (std::ostream &out, const Gmpzf &f)
 writes a double approximation of f to the ostream out.
std::ostream & print (std::ostream &out, const Gmpzf &f)
 writes an exact representation of f to the ostream out.
std::istream & operator>> (std::istream &in, Gmpzf &f)
 reads a double from in, then converts it to a Gmpzf.
Interval_nt sqrt (Interval_nt I)
 returns [0; \( \sqrt{upper\_bound(I)}\)] when only the lower bound is negative (expectable case with roundoff errors), and is unspecified when the upper bound also is negative (unexpected case).
double to_double (Interval_nt I)
 returns the middle of the interval, as a double approximation of the interval.
Uncertain< Sign > sign (Interval_nt i)
void FPU_set_cw (FPU_CW_t R)
 sets the rounding mode to R.
FPU_CW_t FPU_get_cw (void)
 returns the current rounding mode.
FPU_CW_t FPU_get_and_set_cw (FPU_CW_t R)
 sets the rounding mode to R and returns the old one.
std::ostream & operator<< (std::ostream &out, const Lazy_exact_nt< NT > &m)
 writes m to ostream out in an interval format.
std::istream & operator>> (std::istream &in, Lazy_exact_nt< NT > &m)
 reads a NT from in, then converts it to a Lazy_exact_nt<NT>.
std::ostream & operator<< (std::ostream &out, const MP_Float &m)
 writes a double approximation of m to the ostream out.
std::istream & operator>> (std::istream &in, MP_Float &m)
 reads a double from in, then converts it to an MP_Float.
MP_Float approximate_division (const MP_Float &a, const MP_Float &b)
 computes an approximation of the division by converting the operands to double, performing the division on double, and converting back to MP_Float.
MP_Float approximate_sqrt (const MP_Float &a)
 computes an approximation of the square root by converting the operand to double, performing the square root on double, and converting back to MP_Float.
std::ostream & operator<< (std::ostream &out, const Mpzf &f)
 writes a double approximation of f to the ostream out.
std::istream & operator>> (std::istream &in, Mpzf &f)
 reads a double from in, then converts it to a Mpzf.
std::ostream & operator<< (std::ostream &out, const Number_type_checker &c)
 writes c.n1() to the ostream out.
std::istream & operator>> (std::istream &in, Number_type_checker &c)
 reads an NT1 from in, then converts it to an NT2, so a conversion from NT1 to NT2 is required here.
std::ostream & operator<< (std::ostream &out, const Quotient< NT > &q)
 writes q to ostream out in format n/d, where n \( ==\)q.numerator() and d \( ==\)q.denominator().
std::istream & operator>> (std::istream &in, Quotient< NT > &q)
 reads q from istream in.
double to_double (const Quotient< NT > &q)
 returns some double approximation to q.
bool is_valid (const Quotient< NT > &q)
 returns true, if numerator and denominator are valid.
bool is_finite (const Quotient< NT > &q)
 returns true, if numerator and denominator are finite.
Quotient< NT > sqrt (const Quotient< NT > &q)
 returns the square root of q.
Sqrt_extension operator+ (const Sqrt_extension &a, const Sqrt_extension &b)
Sqrt_extension operator- (const Sqrt_extension &a, const Sqrt_extension &b)
Sqrt_extension operator* (const Sqrt_extension &a, const Sqrt_extension &b)
Sqrt_extension operator/ (const Sqrt_extension &a, const Sqrt_extension &b)
bool operator== (const Sqrt_extension &a, const Sqrt_extension &b)
bool operator!= (const Sqrt_extension &a, const Sqrt_extension &b)
bool operator< (const Sqrt_extension &a, const Sqrt_extension &b)
bool operator<= (const Sqrt_extension &a, const Sqrt_extension &b)
bool operator> (const Sqrt_extension &a, const Sqrt_extension &b)
bool operator>= (const Sqrt_extension &a, const Sqrt_extension &b)
std::ostream & operator<< (std::ostream &os, const Sqrt_extension< NT, Root > &ext)
 writes ext to ostream os.
std::istream & operator>> (std::istream &is, const Sqrt_extension< NT, Root > &ext)
 reads ext from istream is in format EXT[a0,a1,root], the output format in mode CGAL::IO::ASCII

Comparisons

The comparison operators ( \( <\), \( >\), \( <=\), \( >=\), \( ==\), \( !=\), sign() and compare()) have the following semantic: it is the intuitive one when for all couples of values in both intervals, the comparison is identical (case of non-overlapping intervals).

This can be expressed by the following formula ( \( x\) and \( y\) are real, \( X\) and \( Y\) are intervals, \( \mathcal{OP}\) is a comparison operator):

\[ \left(\forall x \in X, \forall y \in Y, (x\ \mathcal{OP}\ y) = true\right) \Rightarrow (X\ \mathcal{OP}\ Y) = true \]

and

\[ \left(\forall x \in X, \forall y \in Y, (x\ \mathcal{OP}\ y) = false\right) \Rightarrow (X\ \mathcal{OP}\ Y) =false \]

Otherwise, the comparison is not safe, and we specify this by returning a type encoding this uncertainty, namely using Uncertain<bool> or Uncertain<Sign>, which can be probed for uncertainty explicitly, and which has a conversion to the normal type (e.g. bool) which throws an exception when the conversion is not certain. Note that each failed conversion increments a profiling counter (see CGAL_PROFILE), and then throws the exception of type unsafe_comparison.

Uncertain< bool > operator< (Interval_nt i, Interval_nt j)
Uncertain< bool > operator> (Interval_nt i, Interval_nt j)
Uncertain< bool > operator<= (Interval_nt i, Interval_nt j)
Uncertain< bool > operator>= (Interval_nt i, Interval_nt j)
Uncertain< bool > operator== (Interval_nt i, Interval_nt j)
Uncertain< bool > operator!= (Interval_nt i, Interval_nt j)
Uncertain< Comparison_result > compare (Interval_nt i, Interval_nt j)