PPL  0.12.1
Parma_Polyhedra_Library::Checked Namespace Reference

Types and functions implementing checked numbers. More...

Classes

struct  number_struct
struct  Safe_Conversion
struct  Safe_Conversion< T, T >
struct  Safe_Int_Comparison
struct  Safe_Int_Comparison< T1, T2, typename Enable_If<(C_Integer< T1 >::value &&C_Integer< T2 >::value)>::type >
struct  Float_2exp
struct  Extended_Int
struct  Larger< char >
struct  Larger< signed char >
struct  Larger< unsigned char >
struct  Larger< signed short >
struct  Larger< unsigned short >
struct  Larger< signed int >
struct  Larger< unsigned int >
struct  Larger< signed long >
struct  Larger< unsigned long >
struct  Larger< signed long long >
struct  Larger< unsigned long long >

Typedefs

typedef int16_t int_fast16_t
typedef int32_t int_fast32_t
typedef int64_t int_fast64_t
typedef uint16_t uint_fast16_t
typedef uint32_t uint_fast32_t
typedef uint64_t uint_fast64_t
typedef int mp_size_field_t
 This is assumed to be the type of the _mp_size field of GMP's __mpz_struct.

Functions

int get_digit (char c, unsigned int base=10)
 Returns the integer value associated with the ASCII code c, in the base base positional number system, if there is such an association; returns $-1$ otherwise.
bool sum_sign (bool &a_neg, unsigned long &a_mod, bool b_neg, unsigned long b_mod)
 Adds the number represented (in the modulus-and-sign representation) by b_neg and b_mod to the number represented by a_neg and a_mod, assigning the result to the latter. Returns false is the result cannot be represented; returns true otherwise.
Result parse_number_part (std::istream &is, number_struct &numer)
 Helper function for parse_number(): reads the numerator or denominator part of a number from is into numer, returning the appropriate Result value.
Result parse_number (std::istream &is, number_struct &numer, number_struct &denom)
Result input_mpq (mpq_class &to, std::istream &is)
 PPL_DECLARE_FUN2_0_0 (copy, void, nonconst, Type1, const, Type2) PPL_DECLARE_FUN1_0_0(sgn
From PPL_DECLARE_FUN2_0_0 (cmp, Result_Relation, const, Type1, const, Type2) PPL_DECLARE_FUN1_0_3(classify
From bool PPL_DECLARE_FUN1_0_0 (is_nan, bool, const, Type) PPL_DECLARE_FUN1_0_0(is_minf
From bool Type PPL_DECLARE_FUN1_0_0 (is_pinf, bool, const, Type) PPL_DECLARE_FUN1_0_0(is_int
From bool Type Type PPL_DECLARE_FUN1_0_2 (assign_special, Result, nonconst, Type, Result_Class, Rounding_Dir) PPL_DECLARE_FUN1_0_2(construct_special
From bool Type Type Rounding_Dir PPL_DECLARE_FUN2_0_1 (construct, Result, nonconst, To, const, From, Rounding_Dir) PPL_DECLARE_FUN2_0_1(assign
From bool Type Type
Rounding_Dir Rounding_Dir 
PPL_DECLARE_FUN2_0_1 (floor, Result, nonconst, To, const, From, Rounding_Dir) PPL_DECLARE_FUN2_0_1(ceil
From bool Type Type
Rounding_Dir Rounding_Dir
Rounding_Dir 
PPL_DECLARE_FUN2_0_1 (trunc, Result, nonconst, To, const, From, Rounding_Dir) PPL_DECLARE_FUN2_0_1(neg
From bool Type Type
Rounding_Dir Rounding_Dir
Rounding_Dir Rounding_Dir 
PPL_DECLARE_FUN2_0_1 (abs, Result, nonconst, To, const, From, Rounding_Dir) PPL_DECLARE_FUN2_0_1(sqrt
From bool Type Type
Rounding_Dir Rounding_Dir
Rounding_Dir Rounding_Dir
Rounding_Dir 
PPL_DECLARE_FUN3_0_1 (add, Result, nonconst, To, const, From1, const, From2, Rounding_Dir) PPL_DECLARE_FUN3_0_1(sub
From bool Type Type
Rounding_Dir Rounding_Dir
Rounding_Dir Rounding_Dir
Rounding_Dir Rounding_Dir 
PPL_DECLARE_FUN3_0_1 (mul, Result, nonconst, To, const, From1, const, From2, Rounding_Dir) PPL_DECLARE_FUN3_0_1(div
From bool Type Type
Rounding_Dir Rounding_Dir
Rounding_Dir Rounding_Dir
Rounding_Dir Rounding_Dir
Rounding_Dir 
PPL_DECLARE_FUN3_0_1 (rem, Result, nonconst, To, const, From1, const, From2, Rounding_Dir) PPL_DECLARE_FUN3_0_1(idiv
From bool Type Type
Rounding_Dir Rounding_Dir
Rounding_Dir Rounding_Dir
Rounding_Dir Rounding_Dir
Rounding_Dir Rounding_Dir 
PPL_DECLARE_FUN2_0_2 (add_2exp, Result, nonconst, To, const, From, unsigned int, Rounding_Dir) PPL_DECLARE_FUN2_0_2(sub_2exp
From bool Type Type
Rounding_Dir Rounding_Dir
Rounding_Dir Rounding_Dir
Rounding_Dir Rounding_Dir
Rounding_Dir Rounding_Dir
unsigned Rounding_Dir 
PPL_DECLARE_FUN2_0_2 (mul_2exp, Result, nonconst, To, const, From, unsigned int, Rounding_Dir) PPL_DECLARE_FUN2_0_2(div_2exp
From bool Type Type
Rounding_Dir Rounding_Dir
Rounding_Dir Rounding_Dir
Rounding_Dir Rounding_Dir
Rounding_Dir Rounding_Dir
unsigned Rounding_Dir unsigned
Rounding_Dir 
PPL_DECLARE_FUN2_0_2 (smod_2exp, Result, nonconst, To, const, From, unsigned int, Rounding_Dir) PPL_DECLARE_FUN2_0_2(umod_2exp
From bool Type Type
Rounding_Dir Rounding_Dir
Rounding_Dir Rounding_Dir
Rounding_Dir Rounding_Dir
Rounding_Dir Rounding_Dir
unsigned Rounding_Dir unsigned
Rounding_Dir unsigned
Rounding_Dir 
PPL_DECLARE_FUN3_0_1 (add_mul, Result, nonconst, To, const, From1, const, From2, Rounding_Dir) PPL_DECLARE_FUN3_0_1(sub_mul
From bool Type Type
Rounding_Dir Rounding_Dir
Rounding_Dir Rounding_Dir
Rounding_Dir Rounding_Dir
Rounding_Dir Rounding_Dir
unsigned Rounding_Dir unsigned
Rounding_Dir unsigned
Rounding_Dir Rounding_Dir 
PPL_DECLARE_FUN3_0_1 (gcd, Result, nonconst, To, const, From1, const, From2, Rounding_Dir) PPL_DECLARE_FUN5_0_1(gcdext
From bool Type Type
Rounding_Dir Rounding_Dir
Rounding_Dir Rounding_Dir
Rounding_Dir Rounding_Dir
Rounding_Dir Rounding_Dir
unsigned Rounding_Dir unsigned
Rounding_Dir unsigned
Rounding_Dir Rounding_Dir
Rounding_Dir 
PPL_DECLARE_FUN3_0_1 (lcm, Result, nonconst, To, const, From1, const, From2, Rounding_Dir) PPL_DECLARE_FUN1_0_2(input
From bool Type Type
Rounding_Dir Rounding_Dir
Rounding_Dir Rounding_Dir
Rounding_Dir Rounding_Dir
Rounding_Dir Rounding_Dir
unsigned Rounding_Dir unsigned
Rounding_Dir unsigned
Rounding_Dir Rounding_Dir
Rounding_Dir std::istream
Rounding_Dir 
PPL_DECLARE_FUN1_1_2 (output, Result, std::ostream &, const, Type, const Numeric_Format &, Rounding_Dir) template< typename Policy
From bool Type Type
Rounding_Dir Rounding_Dir
Rounding_Dir Rounding_Dir
Rounding_Dir Rounding_Dir
Rounding_Dir Rounding_Dir
unsigned Rounding_Dir unsigned
Rounding_Dir unsigned
Rounding_Dir Rounding_Dir
Rounding_Dir std::istream
Rounding_Dir To Result 
round (To &to, Result r, Rounding_Dir dir)
 PPL_SAFE_CONVERSION (signed short, signed char)
 PPL_SAFE_CONVERSION (signed long long, signed char)
 PPL_SAFE_CONVERSION (signed long long, signed short)
 PPL_SAFE_CONVERSION (unsigned short, char)
 PPL_SAFE_CONVERSION (unsigned short, unsigned char)
 PPL_SAFE_CONVERSION (unsigned long, char)
 PPL_SAFE_CONVERSION (unsigned long, unsigned char)
 PPL_SAFE_CONVERSION (unsigned long long, char)
 PPL_SAFE_CONVERSION (unsigned long long, unsigned char)
 PPL_SAFE_CONVERSION (double, float)
 PPL_SAFE_CONVERSION (long double, float)
 PPL_SAFE_CONVERSION (long double, double)
 PPL_SAFE_CONVERSION (mpz_class, char)
 PPL_SAFE_CONVERSION (mpz_class, signed char)
 PPL_SAFE_CONVERSION (mpz_class, unsigned char)
 PPL_SAFE_CONVERSION (mpq_class, char)
 PPL_SAFE_CONVERSION (mpq_class, signed char)
 PPL_SAFE_CONVERSION (mpq_class, unsigned char)
 PPL_SAFE_CONVERSION (mpq_class, float)
 PPL_SAFE_CONVERSION (mpq_class, double)
template<typename Policy , typename Type >
struct PPL_FUNCTION_CLASS (construct)< Policy
template<typename To_Policy , typename From_Policy , typename To , typename From >
struct PPL_FUNCTION_CLASS (construct)
template<typename To_Policy , typename To >
struct PPL_FUNCTION_CLASS (construct_special)
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result assign_exact (To &to, const From &from, Rounding_Dir)
template<typename To_Policy , typename From_Policy , typename Type >
Enable_If< Is_Same< To_Policy,
From_Policy >::value, void >
::type 
copy_generic (Type &to, const Type &from)
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result abs_generic (To &to, const From &from, Rounding_Dir dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename To , typename From >
void gcd_exact_no_abs (To &to, const From &x, const From &y)
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename To , typename From1 , typename From2 >
Result gcd_exact (To &to, const From1 &x, const From2 &y, Rounding_Dir dir)
template<typename To1_Policy , typename To2_Policy , typename To3_Policy , typename From1_Policy , typename From2_Policy , typename To1 , typename To2 , typename To3 , typename From1 , typename From2 >
Result gcdext_exact (To1 &to, To2 &s, To3 &t, const From1 &x, const From2 &y, Rounding_Dir dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename To , typename From1 , typename From2 >
Result lcm_gcd_exact (To &to, const From1 &x, const From2 &y, Rounding_Dir dir)
template<typename Policy , typename Type >
Result_Relation sgn_generic (const Type &x)
template<typename T1 , typename T2 >
Enable_If<(Safe_Int_Comparison
< T1, T2 >::value||Safe_Conversion
< T1, T2 >::value||Safe_Conversion
< T2, T1 >::value), bool >
::type 
lt (const T1 &x, const T2 &y)
template<typename T1 , typename T2 >
Enable_If<(Safe_Int_Comparison
< T1, T2 >::value||Safe_Conversion
< T1, T2 >::value||Safe_Conversion
< T2, T1 >::value), bool >
::type 
le (const T1 &x, const T2 &y)
template<typename T1 , typename T2 >
Enable_If<(Safe_Int_Comparison
< T1, T2 >::value||Safe_Conversion
< T1, T2 >::value||Safe_Conversion
< T2, T1 >::value), bool >
::type 
eq (const T1 &x, const T2 &y)
template<typename Policy1 , typename Policy2 , typename Type1 , typename Type2 >
bool lt_p (const Type1 &x, const Type2 &y)
template<typename Policy1 , typename Policy2 , typename Type1 , typename Type2 >
bool le_p (const Type1 &x, const Type2 &y)
template<typename Policy1 , typename Policy2 , typename Type1 , typename Type2 >
bool eq_p (const Type1 &x, const Type2 &y)
template<typename Policy1 , typename Policy2 , typename Type1 , typename Type2 >
Result_Relation cmp_generic (const Type1 &x, const Type2 &y)
template<typename Policy , typename Type >
Result assign_nan (Type &to, Result r)
template<typename Policy , typename Type >
Result input_generic (Type &to, std::istream &is, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result assign_ext (To &to, const From &from, Rounding_Dir dir)
template<typename Policy , typename Type >
Result sgn_ext (const Type &x)
template<typename Policy1 , typename Policy2 , typename Type1 , typename Type2 >
Result cmp_ext (const Type1 &x, const Type2 &y)
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result neg_ext (To &to, const From &x, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result abs_ext (To &to, const From &x, Rounding_Dir dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename To , typename From1 , typename From2 >
Result add_ext (To &to, const From1 &x, const From2 &y, Rounding_Dir dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename To , typename From1 , typename From2 >
Result sub_ext (To &to, const From1 &x, const From2 &y, Rounding_Dir dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename To , typename From1 , typename From2 >
Result mul_ext (To &to, const From1 &x, const From2 &y, Rounding_Dir dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename To , typename From1 , typename From2 >
Result div_ext (To &to, const From1 &x, const From2 &y, Rounding_Dir dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename To , typename From1 , typename From2 >
Result rem_ext (To &to, const From1 &x, const From2 &y, Rounding_Dir dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename To , typename From1 , typename From2 >
Result add_mul_ext (To &to, const From1 &x, const From2 &y, Rounding_Dir dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename To , typename From1 , typename From2 >
Result sub_mul_ext (To &to, const From1 &x, const From2 &y, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result sqrt_ext (To &to, const From &x, Rounding_Dir dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename To , typename From1 , typename From2 >
Result gcd_ext (To &to, const From1 &x, const From2 &y, Rounding_Dir dir)
template<typename To1_Policy , typename To2_Policy , typename To3_Policy , typename From1_Policy , typename From2_Policy , typename To1 , typename To2 , typename To3 , typename From1 , typename From2 >
Result gcdext_ext (To1 &to, To2 &s, To3 &t, const From1 &x, const From2 &y, Rounding_Dir dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename To , typename From1 , typename From2 >
Result lcm_ext (To &to, const From1 &x, const From2 &y, Rounding_Dir dir)
template<typename Policy , typename Type >
Result output_ext (std::ostream &os, const Type &x, const Numeric_Format &format, Rounding_Dir dir)
template<typename Policy , typename Type >
Result input_ext (Type &x, std::istream &is, Rounding_Dir dir)
template<typename T >
bool handle_ext_natively (const T &)
template<typename Policy , typename Type >
bool ext_to_handle (const Type &x)
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result construct_ext (To &to, const From &x, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result floor_ext (To &to, const From &x, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result ceil_ext (To &to, const From &x, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result trunc_ext (To &to, const From &x, Rounding_Dir dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename To , typename From1 , typename From2 >
Result idiv_ext (To &to, const From1 &x, const From2 &y, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result add_2exp_ext (To &to, const From &x, unsigned int exp, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result sub_2exp_ext (To &to, const From &x, unsigned int exp, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result mul_2exp_ext (To &to, const From &x, unsigned int exp, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result div_2exp_ext (To &to, const From &x, unsigned int exp, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result smod_2exp_ext (To &to, const From &x, unsigned int exp, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result umod_2exp_ext (To &to, const From &x, unsigned int exp, Rounding_Dir dir)
template<typename Policy1 , typename Policy2 , typename Type1 , typename Type2 >
bool lt_ext (const Type1 &x, const Type2 &y)
template<typename Policy1 , typename Policy2 , typename Type1 , typename Type2 >
bool gt_ext (const Type1 &x, const Type2 &y)
template<typename Policy1 , typename Policy2 , typename Type1 , typename Type2 >
bool le_ext (const Type1 &x, const Type2 &y)
template<typename Policy1 , typename Policy2 , typename Type1 , typename Type2 >
bool ge_ext (const Type1 &x, const Type2 &y)
template<typename Policy1 , typename Policy2 , typename Type1 , typename Type2 >
bool eq_ext (const Type1 &x, const Type2 &y)
template<typename Policy1 , typename Policy2 , typename Type1 , typename Type2 >
bool ne_ext (const Type1 &x, const Type2 &y)
template<typename To_Policy , typename To >
Result input_ext (To &to, std::istream &is, Rounding_Dir dir)
float multiply_add (float x, float y, float z)
double multiply_add (double x, double y, double z)
long double multiply_add (long double x, long double y, long double z)
double round_to_integer (double x)
long double round_to_integer (long double x)
bool fpu_direct_rounding (Rounding_Dir dir)
bool fpu_inverse_rounding (Rounding_Dir dir)
void limit_precision (const float &v)
void limit_precision (const double &v)
void limit_precision (const long double &)
template<typename Policy , typename T >
Result classify_float (const T v, bool nan, bool inf, bool sign)
template<typename Policy , typename T >
bool is_nan_float (const T v)
template<typename Policy , typename T >
bool is_inf_float (const T v)
template<typename Policy , typename T >
bool is_minf_float (const T v)
template<typename Policy , typename T >
bool is_pinf_float (const T v)
template<typename Policy , typename T >
bool is_int_float (const T v)
template<typename Policy , typename T >
Result assign_special_float (T &v, Result_Class c, Rounding_Dir)
template<typename T >
void pred_float (T &v)
template<typename T >
void succ_float (T &v)
template<typename Policy , typename To >
Result round_lt_float (To &to, Rounding_Dir dir)
template<typename Policy , typename To >
Result round_gt_float (To &to, Rounding_Dir dir)
template<typename Policy >
void prepare_inexact (Rounding_Dir dir)
template<typename Policy >
Result result_relation (Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result assign_float_float_exact (To &to, const From from, Rounding_Dir)
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result assign_float_float_inexact (To &to, const From from, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result assign_float_float (To &to, const From from, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename Type >
Result floor_float (Type &to, const Type from, Rounding_Dir)
template<typename To_Policy , typename From_Policy , typename Type >
Result ceil_float (Type &to, const Type from, Rounding_Dir)
template<typename To_Policy , typename From_Policy , typename Type >
Result trunc_float (Type &to, const Type from, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename Type >
Result neg_float (Type &to, const Type from, Rounding_Dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename Type >
Result add_float (Type &to, const Type x, const Type y, Rounding_Dir dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename Type >
Result sub_float (Type &to, const Type x, const Type y, Rounding_Dir dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename Type >
Result mul_float (Type &to, const Type x, const Type y, Rounding_Dir dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename Type >
Result div_float (Type &to, const Type x, const Type y, Rounding_Dir dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename Type >
Result idiv_float (Type &to, const Type x, const Type y, Rounding_Dir dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename Type >
Result rem_float (Type &to, const Type x, const Type y, Rounding_Dir)
template<typename To_Policy , typename From_Policy , typename Type >
Result add_2exp_float (Type &to, const Type x, unsigned int exp, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename Type >
Result sub_2exp_float (Type &to, const Type x, unsigned int exp, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename Type >
Result mul_2exp_float (Type &to, const Type x, unsigned int exp, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename Type >
Result div_2exp_float (Type &to, const Type x, unsigned int exp, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename Type >
Result smod_2exp_float (Type &to, const Type x, unsigned int exp, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename Type >
Result umod_2exp_float (Type &to, const Type x, unsigned int exp, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename Type >
Result abs_float (Type &to, const Type from, Rounding_Dir)
template<typename To_Policy , typename From_Policy , typename Type >
Result sqrt_float (Type &to, const Type from, Rounding_Dir dir)
template<typename Policy , typename Type >
Result_Relation sgn_float (const Type x)
template<typename Policy1 , typename Policy2 , typename Type >
Result_Relation cmp_float (const Type x, const Type y)
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result assign_float_int_inexact (To &to, const From from, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result assign_float_int (To &to, const From from, Rounding_Dir dir)
template<typename Policy , typename T >
Result set_neg_overflow_float (T &to, Rounding_Dir dir)
template<typename Policy , typename T >
Result set_pos_overflow_float (T &to, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename T >
Result assign_float_mpz (T &to, const mpz_class &from, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename T >
Result assign_float_mpq (T &to, const mpq_class &from, Rounding_Dir dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename Type >
Result add_mul_float (Type &to, const Type x, const Type y, Rounding_Dir dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename Type >
Result sub_mul_float (Type &to, const Type x, const Type y, Rounding_Dir dir)
template<typename Policy , typename Type >
Result output_float (std::ostream &os, const Type from, const Numeric_Format &, Rounding_Dir)
template<typename Policy , typename To >
Result set_neg_overflow_int (To &to, Rounding_Dir dir)
template<typename Policy , typename To >
Result set_pos_overflow_int (To &to, Rounding_Dir dir)
template<typename Policy , typename To >
Result round_lt_int_no_overflow (To &to, Rounding_Dir dir)
template<typename Policy , typename To >
Result round_gt_int_no_overflow (To &to, Rounding_Dir dir)
template<typename Policy , typename To >
Result round_lt_int (To &to, Rounding_Dir dir)
template<typename Policy , typename To >
Result round_gt_int (To &to, Rounding_Dir dir)
template<typename Policy , typename Type >
Result classify_int (const Type v, bool nan, bool inf, bool sign)
template<typename Policy , typename Type >
bool is_nan_int (const Type v)
template<typename Policy , typename Type >
bool is_minf_int (const Type v)
template<typename Policy , typename Type >
bool is_pinf_int (const Type v)
template<typename Policy , typename Type >
bool is_int_int (const Type v)
template<typename Policy , typename Type >
Result assign_special_int (Type &v, Result_Class c, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result assign_signed_int_signed_int (To &to, const From from, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result assign_signed_int_unsigned_int (To &to, const From from, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result assign_unsigned_int_signed_int (To &to, const From from, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result assign_unsigned_int_unsigned_int (To &to, const From from, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result assign_int_float (To &to, const From from, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename To >
Result assign_signed_int_mpz (To &to, const mpz_class &from, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename To >
Result assign_unsigned_int_mpz (To &to, const mpz_class &from, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename To >
Result assign_int_mpq (To &to, const mpq_class &from, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename Type >
Result neg_int_larger (Type &to, const Type x, Rounding_Dir dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename Type >
Result add_int_larger (Type &to, const Type x, const Type y, Rounding_Dir dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename Type >
Result sub_int_larger (Type &to, const Type x, const Type y, Rounding_Dir dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename Type >
Result mul_int_larger (Type &to, const Type x, const Type y, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename Type >
Result neg_signed_int (Type &to, const Type from, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename Type >
Result neg_unsigned_int (Type &to, const Type from, Rounding_Dir dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename Type >
Result add_signed_int (Type &to, const Type x, const Type y, Rounding_Dir dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename Type >
Result add_unsigned_int (Type &to, const Type x, const Type y, Rounding_Dir dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename Type >
Result sub_signed_int (Type &to, const Type x, const Type y, Rounding_Dir dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename Type >
Result sub_unsigned_int (Type &to, const Type x, const Type y, Rounding_Dir dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename Type >
Result mul_signed_int (Type &to, const Type x, const Type y, Rounding_Dir dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename Type >
Result mul_unsigned_int (Type &to, const Type x, const Type y, Rounding_Dir dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename Type >
Result div_signed_int (Type &to, const Type x, const Type y, Rounding_Dir dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename Type >
Result div_unsigned_int (Type &to, const Type x, const Type y, Rounding_Dir dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename Type >
Result idiv_signed_int (Type &to, const Type x, const Type y, Rounding_Dir dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename Type >
Result idiv_unsigned_int (Type &to, const Type x, const Type y, Rounding_Dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename Type >
Result rem_signed_int (Type &to, const Type x, const Type y, Rounding_Dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename Type >
Result rem_unsigned_int (Type &to, const Type x, const Type y, Rounding_Dir)
template<typename To_Policy , typename From_Policy , typename Type >
Result div_2exp_unsigned_int (Type &to, const Type x, unsigned int exp, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename Type >
Result div_2exp_signed_int (Type &to, const Type x, unsigned int exp, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename Type >
Result add_2exp_unsigned_int (Type &to, const Type x, unsigned int exp, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename Type >
Result add_2exp_signed_int (Type &to, const Type x, unsigned int exp, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename Type >
Result sub_2exp_unsigned_int (Type &to, const Type x, unsigned int exp, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename Type >
Result sub_2exp_signed_int (Type &to, const Type x, unsigned int exp, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename Type >
Result mul_2exp_unsigned_int (Type &to, const Type x, unsigned int exp, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename Type >
Result mul_2exp_signed_int (Type &to, const Type x, unsigned int exp, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename Type >
Result smod_2exp_unsigned_int (Type &to, const Type x, unsigned int exp, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename Type >
Result smod_2exp_signed_int (Type &to, const Type x, unsigned int exp, Rounding_Dir)
template<typename To_Policy , typename From_Policy , typename Type >
Result umod_2exp_unsigned_int (Type &to, const Type x, unsigned int exp, Rounding_Dir)
template<typename To_Policy , typename From_Policy , typename Type >
Result umod_2exp_signed_int (Type &to, const Type x, unsigned int exp, Rounding_Dir dir)
template<typename Type >
void isqrt_rem (Type &q, Type &r, const Type from)
template<typename To_Policy , typename From_Policy , typename Type >
Result sqrt_unsigned_int (Type &to, const Type from, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename Type >
Result sqrt_signed_int (Type &to, const Type from, Rounding_Dir dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename Type >
Result add_mul_int (Type &to, const Type x, const Type y, Rounding_Dir dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename Type >
Result sub_mul_int (Type &to, const Type x, const Type y, Rounding_Dir dir)
template<typename Policy , typename Type >
Result output_char (std::ostream &os, Type &from, const Numeric_Format &, Rounding_Dir)
template<typename Policy , typename Type >
Result output_int (std::ostream &os, Type &from, const Numeric_Format &, Rounding_Dir)
template<typename Policy >
Result classify_mpq (const mpq_class &v, bool nan, bool inf, bool sign)
template<typename Policy >
bool is_nan_mpq (const mpq_class &v)
template<typename Policy >
bool is_minf_mpq (const mpq_class &v)
template<typename Policy >
bool is_pinf_mpq (const mpq_class &v)
template<typename Policy >
bool is_int_mpq (const mpq_class &v)
template<typename Policy >
Result assign_special_mpq (mpq_class &v, Result_Class c, Rounding_Dir)
template<typename To_Policy , typename From_Policy , typename From >
Result construct_mpq_base (mpq_class &to, const From &from, Rounding_Dir)
template<typename To_Policy , typename From_Policy , typename From >
Result construct_mpq_float (mpq_class &to, const From &from, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename From >
Result assign_mpq_float (mpq_class &to, const From &from, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename From >
Result assign_mpq_signed_int (mpq_class &to, const From from, Rounding_Dir)
template<typename To_Policy , typename From_Policy , typename From >
Result assign_mpq_unsigned_int (mpq_class &to, const From from, Rounding_Dir)
template<typename To_Policy , typename From_Policy >
Result floor_mpq (mpq_class &to, const mpq_class &from, Rounding_Dir)
template<typename To_Policy , typename From_Policy >
Result ceil_mpq (mpq_class &to, const mpq_class &from, Rounding_Dir)
template<typename To_Policy , typename From_Policy >
Result trunc_mpq (mpq_class &to, const mpq_class &from, Rounding_Dir)
template<typename To_Policy , typename From_Policy >
Result neg_mpq (mpq_class &to, const mpq_class &from, Rounding_Dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy >
Result add_mpq (mpq_class &to, const mpq_class &x, const mpq_class &y, Rounding_Dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy >
Result sub_mpq (mpq_class &to, const mpq_class &x, const mpq_class &y, Rounding_Dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy >
Result mul_mpq (mpq_class &to, const mpq_class &x, const mpq_class &y, Rounding_Dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy >
Result div_mpq (mpq_class &to, const mpq_class &x, const mpq_class &y, Rounding_Dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy >
Result idiv_mpq (mpq_class &to, const mpq_class &x, const mpq_class &y, Rounding_Dir dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy >
Result rem_mpq (mpq_class &to, const mpq_class &x, const mpq_class &y, Rounding_Dir)
template<typename To_Policy , typename From_Policy >
Result add_2exp_mpq (mpq_class &to, const mpq_class &x, unsigned int exp, Rounding_Dir)
template<typename To_Policy , typename From_Policy >
Result sub_2exp_mpq (mpq_class &to, const mpq_class &x, unsigned int exp, Rounding_Dir)
template<typename To_Policy , typename From_Policy >
Result mul_2exp_mpq (mpq_class &to, const mpq_class &x, unsigned int exp, Rounding_Dir)
template<typename To_Policy , typename From_Policy >
Result div_2exp_mpq (mpq_class &to, const mpq_class &x, unsigned int exp, Rounding_Dir)
template<typename To_Policy , typename From_Policy >
Result smod_2exp_mpq (mpq_class &to, const mpq_class &x, unsigned int exp, Rounding_Dir)
template<typename To_Policy , typename From_Policy >
Result umod_2exp_mpq (mpq_class &to, const mpq_class &x, unsigned int exp, Rounding_Dir)
template<typename To_Policy , typename From_Policy >
Result abs_mpq (mpq_class &to, const mpq_class &from, Rounding_Dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy >
Result add_mul_mpq (mpq_class &to, const mpq_class &x, const mpq_class &y, Rounding_Dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy >
Result sub_mul_mpq (mpq_class &to, const mpq_class &x, const mpq_class &y, Rounding_Dir)
template<typename To_Policy , typename From_Policy >
Result sqrt_mpq (mpq_class &to, const mpq_class &from, Rounding_Dir dir)
template<typename Policy >
Result input_mpq (mpq_class &to, std::istream &is, Rounding_Dir dir)
template<typename Policy >
Result output_mpq (std::ostream &os, const mpq_class &from, const Numeric_Format &, Rounding_Dir)
template<typename To_Policy , typename From_Policy , typename From >
Result assign_mpq_long_double (mpq_class &to, const From &from, Rounding_Dir dir)
template<typename Policy >
Result round_lt_mpz (mpz_class &to, Rounding_Dir dir)
template<typename Policy >
Result round_gt_mpz (mpz_class &to, Rounding_Dir dir)
mp_size_field_t get_mp_size (const mpz_class &v)
void set_mp_size (mpz_class &v, mp_size_field_t size)
template<typename Policy >
Result classify_mpz (const mpz_class &v, bool nan, bool inf, bool sign)
template<typename Policy >
bool is_nan_mpz (const mpz_class &v)
template<typename Policy >
bool is_minf_mpz (const mpz_class &v)
template<typename Policy >
bool is_pinf_mpz (const mpz_class &v)
template<typename Policy >
bool is_int_mpz (const mpz_class &v)
template<typename Policy >
Result assign_special_mpz (mpz_class &v, Result_Class c, Rounding_Dir)
template<typename To_Policy , typename From_Policy >
void copy_mpz (mpz_class &to, const mpz_class &from)
template<typename To_Policy , typename From_Policy , typename From >
Result construct_mpz_base (mpz_class &to, const From from, Rounding_Dir)
template<typename To_Policy , typename From_Policy , typename From >
Result construct_mpz_float (mpz_class &to, const From &from, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename From >
Result assign_mpz_signed_int (mpz_class &to, const From from, Rounding_Dir)
template<typename To_Policy , typename From_Policy , typename From >
Result assign_mpz_unsigned_int (mpz_class &to, const From from, Rounding_Dir)
template<typename To_Policy , typename From_Policy , typename From >
Result assign_mpz_float (mpz_class &to, const From from, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy , typename From >
Result assign_mpz_long_double (mpz_class &to, const From &from, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy >
Result assign_mpz_mpq (mpz_class &to, const mpq_class &from, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy >
Result neg_mpz (mpz_class &to, const mpz_class &from, Rounding_Dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy >
Result add_mpz (mpz_class &to, const mpz_class &x, const mpz_class &y, Rounding_Dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy >
Result sub_mpz (mpz_class &to, const mpz_class &x, const mpz_class &y, Rounding_Dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy >
Result mul_mpz (mpz_class &to, const mpz_class &x, const mpz_class &y, Rounding_Dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy >
Result div_mpz (mpz_class &to, const mpz_class &x, const mpz_class &y, Rounding_Dir dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy >
Result idiv_mpz (mpz_class &to, const mpz_class &x, const mpz_class &y, Rounding_Dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy >
Result rem_mpz (mpz_class &to, const mpz_class &x, const mpz_class &y, Rounding_Dir)
template<typename To_Policy , typename From_Policy >
Result add_2exp_mpz (mpz_class &to, const mpz_class &x, unsigned int exp, Rounding_Dir)
template<typename To_Policy , typename From_Policy >
Result sub_2exp_mpz (mpz_class &to, const mpz_class &x, unsigned int exp, Rounding_Dir)
template<typename To_Policy , typename From_Policy >
Result mul_2exp_mpz (mpz_class &to, const mpz_class &x, unsigned int exp, Rounding_Dir)
template<typename To_Policy , typename From_Policy >
Result div_2exp_mpz (mpz_class &to, const mpz_class &x, unsigned int exp, Rounding_Dir dir)
template<typename To_Policy , typename From_Policy >
Result smod_2exp_mpz (mpz_class &to, const mpz_class &x, unsigned int exp, Rounding_Dir)
template<typename To_Policy , typename From_Policy >
Result umod_2exp_mpz (mpz_class &to, const mpz_class &x, unsigned int exp, Rounding_Dir)
template<typename To_Policy , typename From_Policy >
Result abs_mpz (mpz_class &to, const mpz_class &from, Rounding_Dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy >
Result add_mul_mpz (mpz_class &to, const mpz_class &x, const mpz_class &y, Rounding_Dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy >
Result sub_mul_mpz (mpz_class &to, const mpz_class &x, const mpz_class &y, Rounding_Dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy >
Result gcd_mpz (mpz_class &to, const mpz_class &x, const mpz_class &y, Rounding_Dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy >
Result gcdext_mpz (mpz_class &to, mpz_class &s, mpz_class &t, const mpz_class &x, const mpz_class &y, Rounding_Dir)
template<typename To_Policy , typename From1_Policy , typename From2_Policy >
Result lcm_mpz (mpz_class &to, const mpz_class &x, const mpz_class &y, Rounding_Dir)
template<typename To_Policy , typename From_Policy >
Result sqrt_mpz (mpz_class &to, const mpz_class &from, Rounding_Dir dir)
template<typename Policy , typename Type >
Result_Relation sgn_mp (const Type &x)
template<typename Policy1 , typename Policy2 , typename Type >
Result_Relation cmp_mp (const Type &x, const Type &y)
template<typename Policy >
Result output_mpz (std::ostream &os, const mpz_class &from, const Numeric_Format &, Rounding_Dir)

Variables

unsigned irrational_precision
 Holds the precision parameter used for irrational calculations.
 Result_Relation
 const
From Result
From Type
From bool
From bool Type Type nonconst
From bool Type Type Result_Class
From bool Type Type Rounding_Dir To
From bool Type Type Rounding_Dir From
From bool Type Type
Rounding_Dir Rounding_Dir
Rounding_Dir Rounding_Dir
Rounding_Dir 
From1
From bool Type Type
Rounding_Dir Rounding_Dir
Rounding_Dir Rounding_Dir
Rounding_Dir 
From2
From bool Type Type
Rounding_Dir Rounding_Dir
Rounding_Dir Rounding_Dir
Rounding_Dir Rounding_Dir
Rounding_Dir Rounding_Dir
unsigned 
int
From bool Type Type
Rounding_Dir Rounding_Dir
Rounding_Dir Rounding_Dir
Rounding_Dir Rounding_Dir
Rounding_Dir Rounding_Dir
unsigned Rounding_Dir unsigned
Rounding_Dir unsigned
Rounding_Dir Rounding_Dir 
To1
From bool Type Type
Rounding_Dir Rounding_Dir
Rounding_Dir Rounding_Dir
Rounding_Dir Rounding_Dir
Rounding_Dir Rounding_Dir
unsigned Rounding_Dir unsigned
Rounding_Dir unsigned
Rounding_Dir Rounding_Dir 
To2
From bool Type Type
Rounding_Dir Rounding_Dir
Rounding_Dir Rounding_Dir
Rounding_Dir Rounding_Dir
Rounding_Dir Rounding_Dir
unsigned Rounding_Dir unsigned
Rounding_Dir unsigned
Rounding_Dir Rounding_Dir 
To3
Enable_If
<(!Safe_Int_Comparison< S, U >
::value &&C_Integer< U >
::value &&C_Integer< S >
::is_signed), bool >::type 
lt (const S &x, const U &y)
Enable_If
<(!Safe_Int_Comparison< S, U >
::value &&C_Integer< U >
::value &&C_Integer< S >
::is_signed), bool >::type 
le (const S &x, const U &y)
Enable_If
<(!Safe_Int_Comparison< S, U >
::value &&C_Integer< U >
::value &&C_Integer< S >
::is_signed), bool >::type 
eq (const S &x, const U &y)

Detailed Description

Types and functions implementing checked numbers.


Typedef Documentation

Definition at line 48 of file checked_int.inlines.hh.

Definition at line 52 of file checked_int.inlines.hh.

Definition at line 56 of file checked_int.inlines.hh.

This is assumed to be the type of the _mp_size field of GMP's __mpz_struct.

Definition at line 58 of file checked_mpz.inlines.hh.

Definition at line 60 of file checked_int.inlines.hh.

Definition at line 64 of file checked_int.inlines.hh.

Definition at line 68 of file checked_int.inlines.hh.


Function Documentation

template<typename To_Policy , typename From_Policy , typename To , typename From >
Result Parma_Polyhedra_Library::Checked::abs_ext ( To &  to,
const From &  x,
Rounding_Dir  dir 
)
inline

Definition at line 177 of file checked_ext.inlines.hh.

References Parma_Polyhedra_Library::ROUND_IGNORE, Parma_Polyhedra_Library::VC_NAN, and Parma_Polyhedra_Library::VC_PLUS_INFINITY.

                                                 {
  if (!ext_to_handle<From_Policy>(x))
    goto native;
  if (is_nan<From_Policy>(x))
    return assign_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
  else if (is_minf<From_Policy>(x) || is_pinf<From_Policy>(x))
    return assign_special<To_Policy>(to, VC_PLUS_INFINITY, dir);
  else {
  native:
    return abs<To_Policy, From_Policy>(to, x, dir);
  }
}
template<typename To_Policy , typename From_Policy , typename Type >
Result Parma_Polyhedra_Library::Checked::abs_float ( Type &  to,
const Type  from,
Rounding_Dir   
)
inline

Definition at line 696 of file checked_float.inlines.hh.

References Parma_Polyhedra_Library::ROUND_IGNORE, Parma_Polyhedra_Library::V_EQ, and Parma_Polyhedra_Library::VC_NAN.

                                                   {
  if (To_Policy::fpu_check_nan_result && is_nan<From_Policy>(from))
    return assign_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
  to = std::abs(from);
  return V_EQ;
}
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result Parma_Polyhedra_Library::Checked::abs_generic ( To &  to,
const From &  from,
Rounding_Dir  dir 
)
inline

Definition at line 288 of file checked.inlines.hh.

                                                        {
  if (from < 0)
    return neg<To_Policy, From_Policy>(to, from, dir);
  else
    return assign<To_Policy, From_Policy>(to, from, dir);
}
template<typename To_Policy , typename From_Policy >
Result Parma_Polyhedra_Library::Checked::abs_mpq ( mpq_class &  to,
const mpq_class &  from,
Rounding_Dir   
)
inline

Definition at line 424 of file checked_mpq.inlines.hh.

References Parma_Polyhedra_Library::V_EQ.

                                                            {
  to = abs(from);
  return V_EQ;
}
template<typename To_Policy , typename From_Policy >
Result Parma_Polyhedra_Library::Checked::abs_mpz ( mpz_class &  to,
const mpz_class &  from,
Rounding_Dir   
)
inline

Definition at line 534 of file checked_mpz.inlines.hh.

References Parma_Polyhedra_Library::V_EQ.

                                                            {
  to = abs(from);
  return V_EQ;
}
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result Parma_Polyhedra_Library::Checked::add_2exp_ext ( To &  to,
const From &  x,
unsigned int  exp,
Rounding_Dir  dir 
)
inline

Definition at line 624 of file checked_ext.inlines.hh.

References Parma_Polyhedra_Library::ROUND_IGNORE, Parma_Polyhedra_Library::VC_MINUS_INFINITY, Parma_Polyhedra_Library::VC_NAN, and Parma_Polyhedra_Library::VC_PLUS_INFINITY.

                                                                        {
  if (!ext_to_handle<From_Policy>(x))
    goto native;
  if (is_nan<From_Policy>(x))
    return assign_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
  else if (is_minf<From_Policy>(x))
    return assign_special<To_Policy>(to, VC_MINUS_INFINITY, dir);
  else if (is_pinf<From_Policy>(x))
    return assign_special<To_Policy>(to, VC_PLUS_INFINITY, dir);
  else {
  native:
    return add_2exp<To_Policy, From_Policy>(to, x, exp, dir);
  }
}
template<typename To_Policy , typename From_Policy , typename Type >
Result Parma_Polyhedra_Library::Checked::add_2exp_float ( Type &  to,
const Type  x,
unsigned int  exp,
Rounding_Dir  dir 
)
inline

Definition at line 609 of file checked_float.inlines.hh.

References PPL_ASSERT, Parma_Polyhedra_Library::ROUND_IGNORE, sizeof_to_bits, Type, and Parma_Polyhedra_Library::VC_NAN.

                                                                           {
  if (To_Policy::fpu_check_nan_result && is_nan<From_Policy>(x))
    return assign_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
  PPL_ASSERT(exp < sizeof_to_bits(sizeof(unsigned long long)));
  return
    add<To_Policy, From_Policy, Float_2exp>(to,
                                            x,
                                            Type(1ULL << exp),
                                            dir);
}
template<typename To_Policy , typename From_Policy >
Result Parma_Polyhedra_Library::Checked::add_2exp_mpq ( mpq_class &  to,
const mpq_class &  x,
unsigned int  exp,
Rounding_Dir   
)
inline

Definition at line 343 of file checked_mpq.inlines.hh.

References PPL_DIRTY_TEMP, and Parma_Polyhedra_Library::V_EQ.

                           {
  PPL_DIRTY_TEMP(mpz_class, v);
  v = 1;
  mpz_mul_2exp(v.get_mpz_t(), v.get_mpz_t(), exp);
  to = x + v;
  return V_EQ;
}
template<typename To_Policy , typename From_Policy >
Result Parma_Polyhedra_Library::Checked::add_2exp_mpz ( mpz_class &  to,
const mpz_class &  x,
unsigned int  exp,
Rounding_Dir   
)
inline

Definition at line 449 of file checked_mpz.inlines.hh.

References PPL_DIRTY_TEMP, and Parma_Polyhedra_Library::V_EQ.

                           {
  PPL_DIRTY_TEMP(mpz_class, v);
  v = 1;
  mpz_mul_2exp(v.get_mpz_t(), v.get_mpz_t(), exp);
  to = x + v;
  return V_EQ;
}
template<typename To_Policy , typename From_Policy , typename Type >
Result Parma_Polyhedra_Library::Checked::add_2exp_signed_int ( Type &  to,
const Type  x,
unsigned int  exp,
Rounding_Dir  dir 
)
inline

Definition at line 1273 of file checked_int.inlines.hh.

References sizeof_to_bits, Type, and Parma_Polyhedra_Library::V_EQ.

                                      {
  if (!To_Policy::check_overflow) {
    to = x + (Type(1) << exp);
    return V_EQ;
  }
  if (exp >= sizeof_to_bits(sizeof(Type)))
    return set_pos_overflow_int<To_Policy>(to, dir);
  if (exp == sizeof_to_bits(sizeof(Type)) - 1) {
    Type n = -2 * (Type(1) << (exp - 1));
    return sub_signed_int<To_Policy, From_Policy, void>(to, x, n, dir);
  }
  else {
    Type n = Type(1) << exp;
    return add_signed_int<To_Policy, From_Policy, void>(to, x, n, dir);
  }
}
template<typename To_Policy , typename From_Policy , typename Type >
Result Parma_Polyhedra_Library::Checked::add_2exp_unsigned_int ( Type &  to,
const Type  x,
unsigned int  exp,
Rounding_Dir  dir 
)
inline

Definition at line 1259 of file checked_int.inlines.hh.

References sizeof_to_bits, Type, and Parma_Polyhedra_Library::V_EQ.

                                        {
  if (!To_Policy::check_overflow) {
    to = x + (Type(1) << exp);
    return V_EQ;
  }
  if (exp >= sizeof_to_bits(sizeof(Type)))
    return set_pos_overflow_int<To_Policy>(to, dir);
  Type n = Type(1) << exp;
  return add_unsigned_int<To_Policy, From_Policy, void>(to, x, n, dir);
}
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename To , typename From1 , typename From2 >
Result Parma_Polyhedra_Library::Checked::add_ext ( To &  to,
const From1 &  x,
const From2 &  y,
Rounding_Dir  dir 
)
inline

Definition at line 193 of file checked_ext.inlines.hh.

References CHECK_P, Parma_Polyhedra_Library::ROUND_IGNORE, Parma_Polyhedra_Library::V_INF_ADD_INF, Parma_Polyhedra_Library::VC_MINUS_INFINITY, Parma_Polyhedra_Library::VC_NAN, and Parma_Polyhedra_Library::VC_PLUS_INFINITY.

                                                                  {
  if (!ext_to_handle<From1_Policy>(x) && !ext_to_handle<From2_Policy>(y))
    goto native;
  if (is_nan<From1_Policy>(x) || is_nan<From2_Policy>(y))
    return assign_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
  else if (is_minf<From1_Policy>(x)) {
    if (CHECK_P(To_Policy::check_inf_add_inf, is_pinf<From2_Policy>(y)))
      goto inf_add_inf;
    else
      goto minf;
  }
  else if (is_pinf<From1_Policy>(x)) {
    if (CHECK_P(To_Policy::check_inf_add_inf, is_minf<From2_Policy>(y))) {
    inf_add_inf:
      return assign_nan<To_Policy>(to, V_INF_ADD_INF);
    }
    else
      goto pinf;
  }
  else {
    if (is_minf<From2_Policy>(y)) {
    minf:
      return assign_special<To_Policy>(to, VC_MINUS_INFINITY, dir);
    }
    else if (is_pinf<From2_Policy>(y)) {
    pinf:
      return assign_special<To_Policy>(to, VC_PLUS_INFINITY, dir);
    }
    else {
    native:
      return add<To_Policy, From1_Policy, From2_Policy>(to, x, y, dir);
    }
  }
}
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename Type >
Result Parma_Polyhedra_Library::Checked::add_float ( Type &  to,
const Type  x,
const Type  y,
Rounding_Dir  dir 
)
inline

Definition at line 444 of file checked_float.inlines.hh.

References fpu_direct_rounding(), fpu_inverse_rounding(), Parma_Polyhedra_Library::fpu_restore_rounding_direction(), Parma_Polyhedra_Library::fpu_save_rounding_direction(), limit_precision(), Parma_Polyhedra_Library::round_fpu_dir(), Parma_Polyhedra_Library::V_INF_ADD_INF, and Parma_Polyhedra_Library::V_NAN.

                                                                  {
  if (To_Policy::check_inf_add_inf
      && is_inf_float<From1_Policy>(x) && x == -y) {
    return assign_nan<To_Policy>(to, V_INF_ADD_INF);
  }
  prepare_inexact<To_Policy>(dir);
  if (fpu_direct_rounding(dir))
    to = x + y;
  else if (fpu_inverse_rounding(dir)) {
    to = -x - y;
    limit_precision(to);
    to = -to;
  }
  else {
    fpu_rounding_control_word_type old
      = fpu_save_rounding_direction(round_fpu_dir(dir));
    limit_precision(x);
    limit_precision(y);
    to = x + y;
    limit_precision(to);
    fpu_restore_rounding_direction(old);
  }
  if (To_Policy::fpu_check_nan_result && is_nan<To_Policy>(to))
    return V_NAN;
  return result_relation<To_Policy>(dir);
}
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename Type >
Result Parma_Polyhedra_Library::Checked::add_int_larger ( Type &  to,
const Type  x,
const Type  y,
Rounding_Dir  dir 
)
inline

Definition at line 937 of file checked_int.inlines.hh.

                                                                       {
  typename Larger<Type>::type_for_add l = x;
  l += y;
  return assign<To_Policy, To_Policy>(to, l, dir);
}
template<typename To_Policy , typename From1_Policy , typename From2_Policy >
Result Parma_Polyhedra_Library::Checked::add_mpq ( mpq_class &  to,
const mpq_class &  x,
const mpq_class &  y,
Rounding_Dir   
)
inline

Definition at line 277 of file checked_mpq.inlines.hh.

References Parma_Polyhedra_Library::V_EQ.

                                                                             {
  to = x + y;
  return V_EQ;
}
template<typename To_Policy , typename From1_Policy , typename From2_Policy >
Result Parma_Polyhedra_Library::Checked::add_mpz ( mpz_class &  to,
const mpz_class &  x,
const mpz_class &  y,
Rounding_Dir   
)
inline

Definition at line 361 of file checked_mpz.inlines.hh.

References Parma_Polyhedra_Library::V_EQ.

                                                                             {
  to = x + y;
  return V_EQ;
}
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename To , typename From1 , typename From2 >
Result Parma_Polyhedra_Library::Checked::add_mul_ext ( To &  to,
const From1 &  x,
const From2 &  y,
Rounding_Dir  dir 
)
inline

Definition at line 330 of file checked_ext.inlines.hh.

References CHECK_P, PPL_ASSERT, Parma_Polyhedra_Library::ROUND_IGNORE, Parma_Polyhedra_Library::V_INF_ADD_INF, Parma_Polyhedra_Library::V_INF_MUL_ZERO, Parma_Polyhedra_Library::VC_MINUS_INFINITY, Parma_Polyhedra_Library::VC_NAN, Parma_Polyhedra_Library::VC_PLUS_INFINITY, Parma_Polyhedra_Library::VR_GT, and Parma_Polyhedra_Library::VR_LT.

                                                                      {
  if (!ext_to_handle<To_Policy>(to)
      && !ext_to_handle<From1_Policy>(x) && !ext_to_handle<From2_Policy>(y))
    goto native;
  if (is_nan<To_Policy>(to)
      || is_nan<From1_Policy>(x) || is_nan<From2_Policy>(y))
    return assign_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
  if (is_minf<From1_Policy>(x)) {
    switch (sgn_ext<From2_Policy>(y)) {
    case VR_LT:
      goto a_pinf;
    case VR_GT:
      goto a_minf;
    default:
      goto inf_mul_zero;
    }
  }
  else if (is_pinf<From1_Policy>(x)) {
    switch (sgn_ext<From2_Policy>(y)) {
    case VR_LT:
      goto a_minf;
    case VR_GT:
      goto a_pinf;
    default:
      goto inf_mul_zero;
    }
  }
  else {
    if (is_minf<From2_Policy>(y)) {
      switch (sgn<From1_Policy>(x)) {
      case VR_LT:
        goto a_pinf;
      case VR_GT:
        goto a_minf;
      default:
        goto inf_mul_zero;
      }
    }
    else if (is_pinf<From2_Policy>(y)) {
      switch (sgn<From1_Policy>(x)) {
      case VR_LT:
      a_minf:
        if (CHECK_P(To_Policy::check_inf_add_inf, is_pinf<To_Policy>(to)))
          goto inf_add_inf;
        else
          goto minf;
      case VR_GT:
      a_pinf:
        if (CHECK_P(To_Policy::check_inf_add_inf, is_minf<To_Policy>(to))) {
        inf_add_inf:
          return assign_nan<To_Policy>(to, V_INF_ADD_INF);
        }
        else
          goto pinf;
      default:
      inf_mul_zero:
        PPL_ASSERT(To_Policy::check_inf_mul_zero);
        return assign_nan<To_Policy>(to, V_INF_MUL_ZERO);
      }
    }
    else {
      if (is_minf<To_Policy>(to)) {
      minf:
        return assign_special<To_Policy>(to, VC_MINUS_INFINITY, dir);
      }
      if (is_pinf<To_Policy>(to)) {
      pinf:
        return assign_special<To_Policy>(to, VC_PLUS_INFINITY, dir);
      }
    native:
      return add_mul<To_Policy, From1_Policy, From2_Policy>(to, x, y, dir);
    }
  }
}
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename Type >
Result Parma_Polyhedra_Library::Checked::add_mul_float ( Type &  to,
const Type  x,
const Type  y,
Rounding_Dir  dir 
)
inline

Definition at line 933 of file checked_float.inlines.hh.

References fpu_direct_rounding(), fpu_inverse_rounding(), Parma_Polyhedra_Library::fpu_restore_rounding_direction(), Parma_Polyhedra_Library::fpu_save_rounding_direction(), limit_precision(), multiply_add(), Parma_Polyhedra_Library::round_fpu_dir(), Parma_Polyhedra_Library::V_INF_MUL_ZERO, and Parma_Polyhedra_Library::V_NAN.

                                                                      {
  if (To_Policy::check_inf_mul_zero
      && ((x == 0 && is_inf_float<From2_Policy>(y))
          ||
          (y == 0 && is_inf_float<From1_Policy>(x)))) {
    return assign_nan<To_Policy>(to, V_INF_MUL_ZERO);
  }
  // FIXME: missing check_inf_add_inf
  prepare_inexact<To_Policy>(dir);
  if (fpu_direct_rounding(dir))
    to = multiply_add(x, y, to);
  else if (fpu_inverse_rounding(dir)) {
    to = multiply_add(-x, y, -to);
    limit_precision(to);
    to = -to;
  }
  else {
    fpu_rounding_control_word_type old
      = fpu_save_rounding_direction(round_fpu_dir(dir));
    limit_precision(x);
    limit_precision(y);
    limit_precision(to);
    to = multiply_add(x, y, to);
    limit_precision(to);
    fpu_restore_rounding_direction(old);
  }
  if (To_Policy::fpu_check_nan_result && is_nan<To_Policy>(to))
    return V_NAN;
  return result_relation<To_Policy>(dir);
}
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename Type >
Result Parma_Polyhedra_Library::Checked::add_mul_int ( Type &  to,
const Type  x,
const Type  y,
Rounding_Dir  dir 
)
inline

Definition at line 1481 of file checked_int.inlines.hh.

References PPL_UNREACHABLE, Parma_Polyhedra_Library::result_overflow(), Type, Parma_Polyhedra_Library::V_NAN, Parma_Polyhedra_Library::V_UNKNOWN_NEG_OVERFLOW, and Parma_Polyhedra_Library::V_UNKNOWN_POS_OVERFLOW.

                                                                    {
  Type z;
  Result r = mul<To_Policy, From1_Policy, From2_Policy>(z, x, y, dir);
  switch (result_overflow(r)) {
  case 0:
    return add<To_Policy, To_Policy, To_Policy>(to, to, z, dir);
  case -1:
    if (to <= 0)
      return set_neg_overflow_int<To_Policy>(to, dir);
    return assign_nan<To_Policy>(to, V_UNKNOWN_NEG_OVERFLOW);
  case 1:
    if (to >= 0)
      return set_pos_overflow_int<To_Policy>(to, dir);
    return assign_nan<To_Policy>(to, V_UNKNOWN_POS_OVERFLOW);
  default:
    PPL_UNREACHABLE;
    return V_NAN;
  }
}
template<typename To_Policy , typename From1_Policy , typename From2_Policy >
Result Parma_Polyhedra_Library::Checked::add_mul_mpq ( mpq_class &  to,
const mpq_class &  x,
const mpq_class &  y,
Rounding_Dir   
)
inline

Definition at line 433 of file checked_mpq.inlines.hh.

References Parma_Polyhedra_Library::V_EQ.

                          {
  to += x * y;
  return V_EQ;
}
template<typename To_Policy , typename From1_Policy , typename From2_Policy >
Result Parma_Polyhedra_Library::Checked::add_mul_mpz ( mpz_class &  to,
const mpz_class &  x,
const mpz_class &  y,
Rounding_Dir   
)
inline

Definition at line 543 of file checked_mpz.inlines.hh.

References Parma_Polyhedra_Library::V_EQ.

                          {
  mpz_addmul(to.get_mpz_t(), x.get_mpz_t(), y.get_mpz_t());
  return V_EQ;
}
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename Type >
Result Parma_Polyhedra_Library::Checked::add_signed_int ( Type &  to,
const Type  x,
const Type  y,
Rounding_Dir  dir 
)
inline

Definition at line 987 of file checked_int.inlines.hh.

References Parma_Polyhedra_Library::V_EQ.

                                                                       {
  if (To_Policy::check_overflow && Larger<Type>::use_for_add)
    return add_int_larger<To_Policy, From1_Policy, From2_Policy>(to, x, y, dir);
  if (To_Policy::check_overflow) {
    if (y >= 0) {
      if (x > Extended_Int<To_Policy, Type>::max - y)
        return set_pos_overflow_int<To_Policy>(to, dir);
    }
    else if (x < Extended_Int<To_Policy, Type>::min - y)
      return set_neg_overflow_int<To_Policy>(to, dir);
  }
  to = x + y;
  return V_EQ;
}
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename Type >
Result Parma_Polyhedra_Library::Checked::add_unsigned_int ( Type &  to,
const Type  x,
const Type  y,
Rounding_Dir  dir 
)
inline

Definition at line 1005 of file checked_int.inlines.hh.

References CHECK_P, and Parma_Polyhedra_Library::V_EQ.

                                                                         {
  if (To_Policy::check_overflow && Larger<Type>::use_for_add)
    return add_int_larger<To_Policy, From1_Policy, From2_Policy>(to, x, y, dir);
  if (CHECK_P(To_Policy::check_overflow,
              (x > Extended_Int<To_Policy, Type>::max - y)))
    return set_pos_overflow_int<To_Policy>(to, dir);
  to = x + y;
  return V_EQ;
}
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result Parma_Polyhedra_Library::Checked::assign_exact ( To &  to,
const From &  from,
Rounding_Dir   
)
inline

Definition at line 275 of file checked.inlines.hh.

References Parma_Polyhedra_Library::V_EQ.

                                                     {
  to = from;
  return V_EQ;
}
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result Parma_Polyhedra_Library::Checked::assign_ext ( To &  to,
const From &  from,
Rounding_Dir  dir 
)
inline

Definition at line 87 of file checked_ext.inlines.hh.

References Parma_Polyhedra_Library::ROUND_IGNORE, Parma_Polyhedra_Library::VC_MINUS_INFINITY, Parma_Polyhedra_Library::VC_NAN, and Parma_Polyhedra_Library::VC_PLUS_INFINITY.

                                                    {
  if (!ext_to_handle<From_Policy>(x))
    goto native;
  if (is_nan<From_Policy>(x))
    return assign_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
  else if (is_minf<From_Policy>(x))
    return assign_special<To_Policy>(to, VC_MINUS_INFINITY, dir);
  else if (is_pinf<From_Policy>(x))
    return assign_special<To_Policy>(to, VC_PLUS_INFINITY, dir);
  else {
  native:
    return assign<To_Policy, From_Policy>(to, x, dir);
  }
}
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result Parma_Polyhedra_Library::Checked::assign_float_float ( To &  to,
const From  from,
Rounding_Dir  dir 
)
inline

Definition at line 368 of file checked_float.inlines.hh.

References From, and To.

                                                              {
  if (sizeof(From) > sizeof(To))
    return assign_float_float_inexact<To_Policy, From_Policy>(to, from, dir);
  else
    return assign_float_float_exact<To_Policy, From_Policy>(to, from, dir);
}
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result Parma_Polyhedra_Library::Checked::assign_float_float_exact ( To &  to,
const From  from,
Rounding_Dir   
)
inline

Definition at line 334 of file checked_float.inlines.hh.

References Parma_Polyhedra_Library::ROUND_IGNORE, Parma_Polyhedra_Library::V_EQ, and Parma_Polyhedra_Library::VC_NAN.

                                                                {
  if (To_Policy::fpu_check_nan_result && is_nan<From_Policy>(from))
    return assign_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
  to = from;
  return V_EQ;
}
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result Parma_Polyhedra_Library::Checked::assign_float_float_inexact ( To &  to,
const From  from,
Rounding_Dir  dir 
)
inline

Definition at line 343 of file checked_float.inlines.hh.

References fpu_direct_rounding(), fpu_inverse_rounding(), Parma_Polyhedra_Library::fpu_restore_rounding_direction(), Parma_Polyhedra_Library::fpu_save_rounding_direction(), From, limit_precision(), Parma_Polyhedra_Library::round_fpu_dir(), Parma_Polyhedra_Library::ROUND_IGNORE, and Parma_Polyhedra_Library::VC_NAN.

                                                                      {
  if (To_Policy::fpu_check_nan_result && is_nan<From_Policy>(from))
    return assign_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
  prepare_inexact<To_Policy>(dir);
  if (fpu_direct_rounding(dir))
    to = from;
  else if (fpu_inverse_rounding(dir)) {
    From tmp = -from;
    to = tmp;
    limit_precision(to);
    to = -to;
  }
  else {
    fpu_rounding_control_word_type old
      = fpu_save_rounding_direction(round_fpu_dir(dir));
    limit_precision(from);
    to = from;
    limit_precision(to);
    fpu_restore_rounding_direction(old);
  }
  return result_relation<To_Policy>(dir);
}
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result Parma_Polyhedra_Library::Checked::assign_float_int ( To &  to,
const From  from,
Rounding_Dir  dir 
)
inline

Definition at line 767 of file checked_float.inlines.hh.

References From, and sizeof_to_bits.

                                                            {
  if (sizeof_to_bits(sizeof(From)) > Float<To>::Binary::MANTISSA_BITS)
    return assign_float_int_inexact<To_Policy, From_Policy>(to, from, dir);
  else
    return assign_exact<To_Policy, From_Policy>(to, from, dir);
}
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result Parma_Polyhedra_Library::Checked::assign_float_int_inexact ( To &  to,
const From  from,
Rounding_Dir  dir 
)
inline
template<typename To_Policy , typename From_Policy , typename T >
Result Parma_Polyhedra_Library::Checked::assign_float_mpq ( T &  to,
const mpq_class &  from,
Rounding_Dir  dir 
)
inline

Definition at line 857 of file checked_float.inlines.hh.

References Parma_Polyhedra_Library::Boundary_NS::sgn(), Parma_Polyhedra_Library::V_EQ, and Parma_Polyhedra_Library::Bool< false >::value.

                                                                 {
  const mpz_class& numer = from.get_num();
  const mpz_class& denom = from.get_den();
  if (denom == 1)
    return assign_float_mpz<To_Policy, From_Policy>(to, numer, dir);
  mpz_srcptr numer_z = numer.get_mpz_t();
  mpz_srcptr denom_z = denom.get_mpz_t();
  int sign = sgn(numer);
  long exponent = static_cast<long>(mpz_sizeinbase(numer_z, 2))
    - static_cast<long>(mpz_sizeinbase(denom_z, 2));
  if (exponent < Float<T>::Binary::EXPONENT_MIN_DENORM) {
    to = 0;
  inexact:
    if (sign < 0)
      return round_lt_float<To_Policy>(to, dir);
    else
      return round_gt_float<To_Policy>(to, dir);
  }
  if (exponent > Float<T>::Binary::EXPONENT_MAX + 1) {
  overflow:
    if (sign < 0)
      return set_neg_overflow_float<To_Policy>(to, dir);
    else
      return set_pos_overflow_float<To_Policy>(to, dir);
  }
  unsigned int needed_bits = Float<T>::Binary::MANTISSA_BITS + 1;
  if (exponent < Float<T>::Binary::EXPONENT_MIN) {
    long diff = Float<T>::Binary::EXPONENT_MIN - exponent;
    needed_bits -= static_cast<unsigned int>(diff);
  }
  mpz_t mantissa;
  mpz_init(mantissa);
  {
    long shift = static_cast<long>(needed_bits) - exponent;
    if (shift > 0) {
      mpz_mul_2exp(mantissa, numer_z, static_cast<unsigned long>(shift));
      numer_z = mantissa;
    }
    else if (shift < 0) {
      shift = -shift;
      mpz_mul_2exp(mantissa, denom_z, static_cast<unsigned long>(shift));
      denom_z = mantissa;
    }
  }
  mpz_t r;
  mpz_init(r);
  mpz_tdiv_qr(mantissa, r, numer_z, denom_z);
  size_t bits = mpz_sizeinbase(mantissa, 2);
  bool inexact = (mpz_sgn(r) != 0);
  mpz_clear(r);
  if (bits == needed_bits + 1) {
    inexact = (inexact || mpz_odd_p(mantissa));
    mpz_tdiv_q_2exp(mantissa, mantissa, 1);
  }
  else
    --exponent;
  if (exponent > Float<T>::Binary::EXPONENT_MAX) {
    mpz_clear(mantissa);
    goto overflow;
  }
  else if (exponent < Float<T>::Binary::EXPONENT_MIN - 1) {
    // Denormalized.
    exponent = Float<T>::Binary::EXPONENT_MIN - 1;
  }
  Float<T> f;
  f.u.binary.build(sign < 0, mantissa, exponent);
  mpz_clear(mantissa);
  to = f.value();
  if (inexact)
    goto inexact;
  return V_EQ;
}
template<typename To_Policy , typename From_Policy , typename T >
Result Parma_Polyhedra_Library::Checked::assign_float_mpz ( T &  to,
const mpz_class &  from,
Rounding_Dir  dir 
)
inline

Definition at line 818 of file checked_float.inlines.hh.

References Parma_Polyhedra_Library::Boundary_NS::sgn(), Parma_Polyhedra_Library::V_EQ, and Parma_Polyhedra_Library::Bool< false >::value.

                                                                 {
  int sign = sgn(from);
  if (sign == 0) {
    to = 0;
    return V_EQ;
  }
  mpz_srcptr from_z = from.get_mpz_t();
  size_t exponent = mpz_sizeinbase(from_z, 2) - 1;
  if (exponent > size_t(Float<T>::Binary::EXPONENT_MAX)) {
    if (sign < 0)
      return set_neg_overflow_float<To_Policy>(to, dir);
    else
      return set_pos_overflow_float<To_Policy>(to, dir);
  }
  unsigned long zeroes = mpn_scan1(from_z->_mp_d, 0);
  size_t meaningful_bits = exponent - zeroes;
  mpz_t mantissa;
  mpz_init(mantissa);
  if (exponent > Float<T>::Binary::MANTISSA_BITS)
    mpz_tdiv_q_2exp(mantissa,
                    from_z,
                    exponent - Float<T>::Binary::MANTISSA_BITS);
  else
    mpz_mul_2exp(mantissa, from_z, Float<T>::Binary::MANTISSA_BITS - exponent);
  Float<T> f;
  f.u.binary.build(sign < 0, mantissa, static_cast<long>(exponent));
  mpz_clear(mantissa);
  to = f.value();
  if (meaningful_bits > Float<T>::Binary::MANTISSA_BITS) {
    if (sign < 0)
      return round_lt_float<To_Policy>(to, dir);
    else
      return round_gt_float<To_Policy>(to, dir);
  }
  return V_EQ;
}
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result Parma_Polyhedra_Library::Checked::assign_int_float ( To &  to,
const From  from,
Rounding_Dir  dir 
)
inline

Definition at line 530 of file checked_int.inlines.hh.

References CHECK_P, From, le, lt, PPL_ASSERT, Parma_Polyhedra_Library::round_direct(), Parma_Polyhedra_Library::ROUND_DOWN, Parma_Polyhedra_Library::ROUND_IGNORE, Parma_Polyhedra_Library::round_not_requested(), Parma_Polyhedra_Library::ROUND_UP, Parma_Polyhedra_Library::V_EQ, Parma_Polyhedra_Library::V_LGE, Parma_Polyhedra_Library::VC_MINUS_INFINITY, Parma_Polyhedra_Library::VC_NAN, and Parma_Polyhedra_Library::VC_PLUS_INFINITY.

                                                            {
  if (is_nan<From_Policy>(from))
    return assign_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
  else if (is_minf<From_Policy>(from))
    return assign_special<To_Policy>(to, VC_MINUS_INFINITY, dir);
  else if (is_pinf<From_Policy>(from))
    return assign_special<To_Policy>(to, VC_PLUS_INFINITY, dir);
#if 0
  // FIXME: this is correct but it is inefficient and breaks the build
  // for the missing definition of static const members (a problem present
  // also in other areas of the PPL).
  if (CHECK_P(To_Policy::check_overflow, lt(from, Extended_Int<To_Policy, To>::min)))
    return set_neg_overflow_int<To_Policy>(to, dir);
  if (CHECK_P(To_Policy::check_overflow, !le(from, Extended_Int<To_Policy, To>::max)))
    return set_pos_overflow_int<To_Policy>(to, dir);
#else
  if (CHECK_P(To_Policy::check_overflow, (from < Extended_Int<To_Policy, To>::min)))
    return set_neg_overflow_int<To_Policy>(to, dir);
  if (CHECK_P(To_Policy::check_overflow, (from > Extended_Int<To_Policy, To>::max)))
    return set_pos_overflow_int<To_Policy>(to, dir);
#endif
  if (round_not_requested(dir)) {
    to = from;
    return V_LGE;
  }
  From i_from = rint(from);
  to = i_from;
  if (from == i_from)
    return V_EQ;
  if (round_direct(ROUND_UP))
    return round_lt_int<To_Policy>(to, dir);
  if (round_direct(ROUND_DOWN))
    return round_gt_int<To_Policy>(to, dir);
  if (from < i_from)
    return round_lt_int<To_Policy>(to, dir);
  PPL_ASSERT(from > i_from);
  return round_gt_int<To_Policy>(to, dir);
}
template<typename To_Policy , typename From_Policy , typename To >
Result Parma_Polyhedra_Library::Checked::assign_int_mpq ( To &  to,
const mpq_class &  from,
Rounding_Dir  dir 
)
inline

Definition at line 705 of file checked_int.inlines.hh.

References PPL_DIRTY_TEMP, Parma_Polyhedra_Library::round_not_requested(), Parma_Polyhedra_Library::V_EQ, and Parma_Polyhedra_Library::V_LGE.

                                                                {
  mpz_srcptr n = from.get_num().get_mpz_t();
  mpz_srcptr d = from.get_den().get_mpz_t();
  PPL_DIRTY_TEMP(mpz_class, q);
  mpz_ptr q_z = q.get_mpz_t();
  if (round_not_requested(dir)) {
    mpz_tdiv_q(q_z, n, d);
    Result r = assign<To_Policy, void>(to, q, dir);
    if (r != V_EQ)
      return r;
    return V_LGE;
  }
  mpz_t rem;
  int sign;
  mpz_init(rem);
  mpz_tdiv_qr(q_z, rem, n, d);
  sign = mpz_sgn(rem);
  mpz_clear(rem);
  Result r = assign<To_Policy, void>(to, q, dir);
  if (r != V_EQ)
    return r;
  switch (sign) {
  case -1:
    return round_lt_int<To_Policy>(to, dir);
  case 1:
    return round_gt_int<To_Policy>(to, dir);
  default:
    return V_EQ;
  }
}
template<typename To_Policy , typename From_Policy , typename From >
Result Parma_Polyhedra_Library::Checked::assign_mpq_float ( mpq_class &  to,
const From &  from,
Rounding_Dir  dir 
)
inline

Definition at line 184 of file checked_mpq.inlines.hh.

References Parma_Polyhedra_Library::ROUND_IGNORE, Parma_Polyhedra_Library::V_EQ, Parma_Polyhedra_Library::VC_MINUS_INFINITY, Parma_Polyhedra_Library::VC_NAN, and Parma_Polyhedra_Library::VC_PLUS_INFINITY.

                                                                    {
  if (is_nan<From_Policy>(from))
    return assign_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
  else if (is_minf<From_Policy>(from))
    return assign_special<To_Policy>(to, VC_MINUS_INFINITY, dir);
  else if (is_pinf<From_Policy>(from))
    return assign_special<To_Policy>(to, VC_PLUS_INFINITY, dir);
  to = from;
  return V_EQ;
}
template<typename To_Policy , typename From_Policy , typename From >
Result Parma_Polyhedra_Library::Checked::assign_mpq_long_double ( mpq_class &  to,
const From &  from,
Rounding_Dir  dir 
)
inline

Definition at line 515 of file checked_mpq.inlines.hh.

References input_mpq(), Parma_Polyhedra_Library::ROUND_IGNORE, Parma_Polyhedra_Library::VC_MINUS_INFINITY, Parma_Polyhedra_Library::VC_NAN, and Parma_Polyhedra_Library::VC_PLUS_INFINITY.

                                                                          {
  if (is_nan<From_Policy>(from))
    return assign_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
  else if (is_minf<From_Policy>(from))
    return assign_special<To_Policy>(to, VC_MINUS_INFINITY, dir);
  else if (is_pinf<From_Policy>(from))
    return assign_special<To_Policy>(to, VC_PLUS_INFINITY, dir);
  // FIXME: this is an incredibly inefficient implementation!
  std::stringstream ss;
  output<From_Policy>(ss, from, Numeric_Format(), dir);
  return input_mpq(to, ss);
}
template<typename To_Policy , typename From_Policy , typename From >
Result Parma_Polyhedra_Library::Checked::assign_mpq_signed_int ( mpq_class &  to,
const From  from,
Rounding_Dir   
)
inline

Definition at line 200 of file checked_mpq.inlines.hh.

References From, and Parma_Polyhedra_Library::V_EQ.

                                                                    {
  if (sizeof(From) <= sizeof(signed long))
    to = static_cast<signed long>(from);
  else {
    mpz_ptr m = to.get_num().get_mpz_t();
    if (from >= 0)
      mpz_import(m, 1, 1, sizeof(From), 0, 0, &from);
    else {
      From n = -from;
      mpz_import(m, 1, 1, sizeof(From), 0, 0, &n);
      mpz_neg(m, m);
    }
    to.get_den() = 1;
  }
  return V_EQ;
}
template<typename To_Policy , typename From_Policy , typename From >
Result Parma_Polyhedra_Library::Checked::assign_mpq_unsigned_int ( mpq_class &  to,
const From  from,
Rounding_Dir   
)
inline

Definition at line 221 of file checked_mpq.inlines.hh.

References From, and Parma_Polyhedra_Library::V_EQ.

                                                                      {
  if (sizeof(From) <= sizeof(unsigned long))
    to = static_cast<unsigned long>(from);
  else {
    mpz_import(to.get_num().get_mpz_t(), 1, 1, sizeof(From), 0, 0, &from);
    to.get_den() = 1;
  }
  return V_EQ;
}
template<typename To_Policy , typename From_Policy , typename From >
Result Parma_Polyhedra_Library::Checked::assign_mpz_float ( mpz_class &  to,
const From  from,
Rounding_Dir  dir 
)
inline

Definition at line 263 of file checked_mpz.inlines.hh.

References From, PPL_UNREACHABLE, Parma_Polyhedra_Library::round_direct(), Parma_Polyhedra_Library::ROUND_DOWN, Parma_Polyhedra_Library::ROUND_IGNORE, Parma_Polyhedra_Library::round_not_requested(), Parma_Polyhedra_Library::ROUND_UP, Parma_Polyhedra_Library::V_EQ, Parma_Polyhedra_Library::V_LGE, Parma_Polyhedra_Library::V_NAN, Parma_Polyhedra_Library::VC_MINUS_INFINITY, Parma_Polyhedra_Library::VC_NAN, and Parma_Polyhedra_Library::VC_PLUS_INFINITY.

                                                                   {
  if (is_nan<From_Policy>(from))
    return assign_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
  else if (is_minf<From_Policy>(from))
    return assign_special<To_Policy>(to, VC_MINUS_INFINITY, dir);
  else if (is_pinf<From_Policy>(from))
    return assign_special<To_Policy>(to, VC_PLUS_INFINITY, dir);
  if (round_not_requested(dir)) {
    to = from;
    return V_LGE;
  }
  From i_from = rint(from);
  to = i_from;
  if (from == i_from)
    return V_EQ;
  if (round_direct(ROUND_UP))
    return round_lt_mpz<To_Policy>(to, dir);
  if (round_direct(ROUND_DOWN))
    return round_gt_mpz<To_Policy>(to, dir);
  if (from < i_from)
    return round_lt_mpz<To_Policy>(to, dir);
  if (from > i_from)
    return round_gt_mpz<To_Policy>(to, dir);
  PPL_UNREACHABLE;
  return V_NAN;
}
template<typename To_Policy , typename From_Policy , typename From >
Result Parma_Polyhedra_Library::Checked::assign_mpz_long_double ( mpz_class &  to,
const From &  from,
Rounding_Dir  dir 
)
inline

Definition at line 295 of file checked_mpz.inlines.hh.

References input_mpq(), PPL_ASSERT, PPL_DIRTY_TEMP, Parma_Polyhedra_Library::ROUND_IGNORE, Parma_Polyhedra_Library::V_EQ, Parma_Polyhedra_Library::VC_MINUS_INFINITY, Parma_Polyhedra_Library::VC_NAN, and Parma_Polyhedra_Library::VC_PLUS_INFINITY.

                                                                          {
  if (is_nan<From_Policy>(from))
    return assign_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
  else if (is_minf<From_Policy>(from))
    return assign_special<To_Policy>(to, VC_MINUS_INFINITY, dir);
  else if (is_pinf<From_Policy>(from))
    return assign_special<To_Policy>(to, VC_PLUS_INFINITY, dir);
  // FIXME: this is an incredibly inefficient implementation!
  std::stringstream ss;
  output<From_Policy>(ss, from, Numeric_Format(), dir);
  PPL_DIRTY_TEMP(mpq_class, tmp);
#ifndef NDEBUG
  Result r =
#endif
    input_mpq(tmp, ss);
  PPL_ASSERT(r == V_EQ);
  return assign<To_Policy, From_Policy>(to, tmp, dir);
}
template<typename To_Policy , typename From_Policy >
Result Parma_Polyhedra_Library::Checked::assign_mpz_mpq ( mpz_class &  to,
const mpq_class &  from,
Rounding_Dir  dir 
)
inline

Definition at line 318 of file checked_mpz.inlines.hh.

References PPL_ASSERT, Parma_Polyhedra_Library::round_down(), Parma_Polyhedra_Library::round_ignore(), Parma_Polyhedra_Library::round_not_needed(), Parma_Polyhedra_Library::round_strict_relation(), Parma_Polyhedra_Library::round_up(), Parma_Polyhedra_Library::V_EQ, Parma_Polyhedra_Library::V_GE, Parma_Polyhedra_Library::V_GT, Parma_Polyhedra_Library::V_LE, Parma_Polyhedra_Library::V_LGE, and Parma_Polyhedra_Library::V_LT.

                                                                       {
  if (round_not_needed(dir)) {
    to = from.get_num();
    return V_LGE;
  }
  if (round_ignore(dir)) {
    to = from;
    return V_LGE;
  }
  mpz_srcptr n = from.get_num().get_mpz_t();
  mpz_srcptr d = from.get_den().get_mpz_t();
  if (round_down(dir)) {
    mpz_fdiv_q(to.get_mpz_t(), n, d);
    if (round_strict_relation(dir))
      return (mpz_divisible_p(n, d) != 0) ? V_EQ : V_GT;
    return V_GE;
  }
  else {
    PPL_ASSERT(round_up(dir));
    mpz_cdiv_q(to.get_mpz_t(), n, d);
    if (round_strict_relation(dir))
      return (mpz_divisible_p(n, d) != 0) ? V_EQ : V_LT;
    return V_LE;
  }
}
template<typename To_Policy , typename From_Policy , typename From >
Result Parma_Polyhedra_Library::Checked::assign_mpz_signed_int ( mpz_class &  to,
const From  from,
Rounding_Dir   
)
inline

Definition at line 231 of file checked_mpz.inlines.hh.

References From, and Parma_Polyhedra_Library::V_EQ.

                                                                    {
  if (sizeof(From) <= sizeof(signed long))
    to = static_cast<signed long>(from);
  else {
    mpz_ptr m = to.get_mpz_t();
    if (from >= 0)
      mpz_import(m, 1, 1, sizeof(From), 0, 0, &from);
    else {
      From n = -from;
      mpz_import(m, 1, 1, sizeof(From), 0, 0, &n);
      mpz_neg(m, m);
    }
  }
  return V_EQ;
}
template<typename To_Policy , typename From_Policy , typename From >
Result Parma_Polyhedra_Library::Checked::assign_mpz_unsigned_int ( mpz_class &  to,
const From  from,
Rounding_Dir   
)
inline

Definition at line 251 of file checked_mpz.inlines.hh.

References From, and Parma_Polyhedra_Library::V_EQ.

                                                                      {
  if (sizeof(From) <= sizeof(unsigned long))
    to = static_cast<unsigned long>(from);
  else
    mpz_import(to.get_mpz_t(), 1, 1, sizeof(From), 0, 0, &from);
  return V_EQ;
}
template<typename Policy , typename Type >
Result Parma_Polyhedra_Library::Checked::assign_nan ( Type &  to,
Result  r 
)
inline

Definition at line 630 of file checked.inlines.hh.

                               {
  assign_special<Policy>(to, VC_NAN, ROUND_IGNORE);
  return r;
}
template<typename To_Policy , typename From_Policy , typename To >
Result Parma_Polyhedra_Library::Checked::assign_signed_int_mpz ( To &  to,
const mpz_class &  from,
Rounding_Dir  dir 
)
inline

Definition at line 614 of file checked_int.inlines.hh.

References PPL_GT_SILENT, PPL_LT_SILENT, Parma_Polyhedra_Library::Boundary_NS::sgn(), To, and Parma_Polyhedra_Library::V_EQ.

                                                                       {
  if (sizeof(To) <= sizeof(signed long)) {
    if (!To_Policy::check_overflow) {
      to = from.get_si();
      return V_EQ;
    }
    if (from.fits_slong_p()) {
      signed long v = from.get_si();
      if (PPL_LT_SILENT(v, (Extended_Int<To_Policy, To>::min)))
        return set_neg_overflow_int<To_Policy>(to, dir);
      if (PPL_GT_SILENT(v, (Extended_Int<To_Policy, To>::max)))
        return set_pos_overflow_int<To_Policy>(to, dir);
      to = v;
      return V_EQ;
    }
  }
  else {
    mpz_srcptr m = from.get_mpz_t();
    size_t sz = mpz_size(m);
    if (sz <= sizeof(To) / sizeof(mp_limb_t)) {
      if (sz == 0) {
        to = 0;
        return V_EQ;
      }
      To v;
      mpz_export(&v, 0, -1, sizeof(To), 0, 0, m);
      if (v >= 0) {
        if (::sgn(from) < 0)
          return neg<To_Policy, To_Policy>(to, v, dir);
        to = v;
        return V_EQ;
      }
    }
  }
  return (::sgn(from) < 0)
    ? set_neg_overflow_int<To_Policy>(to, dir)
    : set_pos_overflow_int<To_Policy>(to, dir);
}
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result Parma_Polyhedra_Library::Checked::assign_signed_int_signed_int ( To &  to,
const From  from,
Rounding_Dir  dir 
)
inline

Definition at line 357 of file checked_int.inlines.hh.

References CHECK_P, From, PPL_GT_SILENT, PPL_LT_SILENT, and Parma_Polyhedra_Library::V_EQ.

                                                                        {
  if (sizeof(To) < sizeof(From)
      || (sizeof(To) == sizeof(From)
          && (Extended_Int<To_Policy, To>::min > Extended_Int<From_Policy, From>::min
              || Extended_Int<To_Policy, To>::max < Extended_Int<From_Policy, From>::max))) {
    if (CHECK_P(To_Policy::check_overflow,
                PPL_LT_SILENT(from,
                              static_cast<From>(Extended_Int<To_Policy, To>::min))))
      return set_neg_overflow_int<To_Policy>(to, dir);
    if (CHECK_P(To_Policy::check_overflow,
                PPL_GT_SILENT(from,
                              static_cast<From>(Extended_Int<To_Policy, To>::max))))
      return set_pos_overflow_int<To_Policy>(to, dir);
  }
  to = static_cast<To>(from);
  return V_EQ;
}
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result Parma_Polyhedra_Library::Checked::assign_signed_int_unsigned_int ( To &  to,
const From  from,
Rounding_Dir  dir 
)
inline

Definition at line 377 of file checked_int.inlines.hh.

References CHECK_P, From, To, and Parma_Polyhedra_Library::V_EQ.

                                                                          {
  if (sizeof(To) <= sizeof(From)) {
    if (CHECK_P(To_Policy::check_overflow,
                from > static_cast<From>(Extended_Int<To_Policy, To>::max)))
      return set_pos_overflow_int<To_Policy>(to, dir);
  }
  to = static_cast<To>(from);
  return V_EQ;
}
template<typename Policy >
Result Parma_Polyhedra_Library::Checked::assign_special_mpq ( mpq_class &  v,
Result_Class  c,
Rounding_Dir   
)
inline

Definition at line 103 of file checked_mpq.inlines.hh.

References PPL_UNREACHABLE, Parma_Polyhedra_Library::V_EQ_MINUS_INFINITY, Parma_Polyhedra_Library::V_EQ_PLUS_INFINITY, Parma_Polyhedra_Library::V_NAN, Parma_Polyhedra_Library::V_UNREPRESENTABLE, Parma_Polyhedra_Library::VC_MINUS_INFINITY, Parma_Polyhedra_Library::VC_NAN, and Parma_Polyhedra_Library::VC_PLUS_INFINITY.

                                                               {
  switch (c) {
  case VC_NAN:
    if (Policy::has_nan) {
      v.get_num() = 0;
      v.get_den() = 0;
      return V_NAN | V_UNREPRESENTABLE;
    }
    return V_NAN;
  case VC_MINUS_INFINITY:
    if (Policy::has_infinity) {
      v.get_num() = -1;
      v.get_den() = 0;
      return V_EQ_MINUS_INFINITY;
    }
    return V_EQ_MINUS_INFINITY | V_UNREPRESENTABLE;
  case VC_PLUS_INFINITY:
    if (Policy::has_infinity) {
      v.get_num() = 1;
      v.get_den() = 0;
      return V_EQ_PLUS_INFINITY;
    }
    return V_EQ_PLUS_INFINITY | V_UNREPRESENTABLE;
  default:
    PPL_UNREACHABLE;
    return V_NAN | V_UNREPRESENTABLE;
  }
}
template<typename Policy >
Result Parma_Polyhedra_Library::Checked::assign_special_mpz ( mpz_class &  v,
Result_Class  c,
Rounding_Dir   
)
inline

Definition at line 133 of file checked_mpz.inlines.hh.

References PPL_UNREACHABLE, set_mp_size(), Parma_Polyhedra_Library::V_EQ_MINUS_INFINITY, Parma_Polyhedra_Library::V_EQ_PLUS_INFINITY, Parma_Polyhedra_Library::V_NAN, Parma_Polyhedra_Library::V_UNREPRESENTABLE, Parma_Polyhedra_Library::VC_MINUS_INFINITY, Parma_Polyhedra_Library::VC_NAN, and Parma_Polyhedra_Library::VC_PLUS_INFINITY.

                                                               {
  switch (c) {
  case VC_NAN:
    if (Policy::has_nan)
      set_mp_size(v, C_Integer<mp_size_field_t>::min + 1);
    return V_NAN;
  case VC_MINUS_INFINITY:
    if (Policy::has_infinity) {
      set_mp_size(v, C_Integer<mp_size_field_t>::min);
      return V_EQ_MINUS_INFINITY;
    }
    return V_EQ_MINUS_INFINITY | V_UNREPRESENTABLE;
  case VC_PLUS_INFINITY:
    if (Policy::has_infinity) {
      set_mp_size(v, C_Integer<mp_size_field_t>::max);
      return V_EQ_PLUS_INFINITY;
    }
    return V_EQ_PLUS_INFINITY | V_UNREPRESENTABLE;
  default:
    PPL_UNREACHABLE;
    return V_NAN;
  }
}
template<typename To_Policy , typename From_Policy , typename To >
Result Parma_Polyhedra_Library::Checked::assign_unsigned_int_mpz ( To &  to,
const mpz_class &  from,
Rounding_Dir  dir 
)
inline

Definition at line 664 of file checked_int.inlines.hh.

References CHECK_P, PPL_GT_SILENT, Parma_Polyhedra_Library::Boundary_NS::sgn(), To, and Parma_Polyhedra_Library::V_EQ.

                                                                         {
  if (CHECK_P(To_Policy::check_overflow, ::sgn(from) < 0))
    return set_neg_overflow_int<To_Policy>(to, dir);
  if (sizeof(To) <= sizeof(unsigned long)) {
    if (!To_Policy::check_overflow) {
      to = static_cast<To>(from.get_ui());
      return V_EQ;
    }
    if (from.fits_ulong_p()) {
      unsigned long v = from.get_ui();
      if (PPL_GT_SILENT(v, (Extended_Int<To_Policy, To>::max)))
        return set_pos_overflow_int<To_Policy>(to, dir);
      to = static_cast<To>(v);
      return V_EQ;
    }
  }
  else {
    mpz_srcptr m = from.get_mpz_t();
    size_t sz = mpz_size(m);
    if (sz <= sizeof(To) / sizeof(mp_limb_t)) {
      if (sz == 0)
        to = 0;
      else
        mpz_export(&to, 0, -1, sizeof(To), 0, 0, m);
      return V_EQ;
    }
  }
  return set_pos_overflow_int<To_Policy>(to, dir);
}
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result Parma_Polyhedra_Library::Checked::assign_unsigned_int_signed_int ( To &  to,
const From  from,
Rounding_Dir  dir 
)
inline

Definition at line 389 of file checked_int.inlines.hh.

References CHECK_P, From, To, and Parma_Polyhedra_Library::V_EQ.

                                                                          {
  if (CHECK_P(To_Policy::check_overflow, from < 0))
    return set_neg_overflow_int<To_Policy>(to, dir);
  if (sizeof(To) < sizeof(From)) {
    if (CHECK_P(To_Policy::check_overflow,
                from > static_cast<From>(Extended_Int<To_Policy, To>::max)))
      return set_pos_overflow_int<To_Policy>(to, dir);
  }
  to = static_cast<To>(from);
  return V_EQ;
}
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result Parma_Polyhedra_Library::Checked::assign_unsigned_int_unsigned_int ( To &  to,
const From  from,
Rounding_Dir  dir 
)
inline

Definition at line 403 of file checked_int.inlines.hh.

References CHECK_P, From, PPL_GT_SILENT, To, and Parma_Polyhedra_Library::V_EQ.

                                                                            {
  if (sizeof(To) < sizeof(From)
      || (sizeof(To) == sizeof(From)
          && Extended_Int<To_Policy, To>::max < Extended_Int<From_Policy, From>::max)) {
    if (CHECK_P(To_Policy::check_overflow,
                PPL_GT_SILENT(from,
                              static_cast<From>(Extended_Int<To_Policy, To>::max))))
      return set_pos_overflow_int<To_Policy>(to, dir);
  }
  to = static_cast<To>(from);
  return V_EQ;
}
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result Parma_Polyhedra_Library::Checked::ceil_ext ( To &  to,
const From &  x,
Rounding_Dir  dir 
)
inline

Definition at line 141 of file checked_ext.inlines.hh.

References Parma_Polyhedra_Library::ROUND_IGNORE, Parma_Polyhedra_Library::VC_MINUS_INFINITY, Parma_Polyhedra_Library::VC_NAN, and Parma_Polyhedra_Library::VC_PLUS_INFINITY.

                                                  {
  if (!ext_to_handle<From_Policy>(x))
    goto native;
  if (is_nan<From_Policy>(x))
    return assign_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
  else if (is_minf<From_Policy>(x))
    return assign_special<To_Policy>(to, VC_MINUS_INFINITY, dir);
  else if (is_pinf<From_Policy>(x))
    return assign_special<To_Policy>(to, VC_PLUS_INFINITY, dir);
  else {
  native:
    return ceil<To_Policy, From_Policy>(to, x, dir);
  }
}
template<typename To_Policy , typename From_Policy >
Result Parma_Polyhedra_Library::Checked::ceil_mpq ( mpq_class &  to,
const mpq_class &  from,
Rounding_Dir   
)
inline

Definition at line 246 of file checked_mpq.inlines.hh.

References Parma_Polyhedra_Library::V_EQ.

                                                             {
  mpz_cdiv_q(to.get_num().get_mpz_t(),
             from.get_num().get_mpz_t(), from.get_den().get_mpz_t());
  to.get_den() = 1;
  return V_EQ;
}
template<typename Policy , typename T >
Result Parma_Polyhedra_Library::Checked::classify_float ( const T  v,
bool  nan,
bool  inf,
bool  sign 
)
inline

Definition at line 151 of file checked_float.inlines.hh.

References CHECK_P, PPL_ASSERT, Parma_Polyhedra_Library::V_EQ, Parma_Polyhedra_Library::V_EQ_MINUS_INFINITY, Parma_Polyhedra_Library::V_EQ_PLUS_INFINITY, Parma_Polyhedra_Library::V_GT, Parma_Polyhedra_Library::V_LGE, Parma_Polyhedra_Library::V_LT, and Parma_Polyhedra_Library::V_NAN.

                                                         {
  Float<T> f(v);
  if ((nan || sign) && CHECK_P(Policy::has_nan, f.u.binary.is_nan()))
    return V_NAN;
  if (inf) {
    if (Policy::has_infinity) {
      int sign_inf = f.u.binary.inf_sign();
      if (sign_inf < 0)
        return V_EQ_MINUS_INFINITY;
      if (sign_inf > 0)
        return V_EQ_PLUS_INFINITY;
    }
    else
      PPL_ASSERT(f.u.binary.inf_sign() == 0);
  }
  if (sign) {
    if (v < 0)
      return V_LT;
    if (v > 0)
      return V_GT;
    return V_EQ;
  }
  return V_LGE;
}
template<typename Policy , typename Type >
Result Parma_Polyhedra_Library::Checked::classify_int ( const Type  v,
bool  nan,
bool  inf,
bool  sign 
)
inline

Definition at line 197 of file checked_int.inlines.hh.

References Parma_Polyhedra_Library::V_EQ, Parma_Polyhedra_Library::V_EQ_MINUS_INFINITY, Parma_Polyhedra_Library::V_EQ_PLUS_INFINITY, Parma_Polyhedra_Library::V_GT, Parma_Polyhedra_Library::V_LGE, Parma_Polyhedra_Library::V_LT, and Parma_Polyhedra_Library::V_NAN.

                                                          {
  if (Policy::has_nan
      && (nan || sign)
      && v == Extended_Int<Policy, Type>::not_a_number)
    return V_NAN;
  if (!inf && !sign)
    return V_LGE;
  if (Policy::has_infinity) {
    if (v == Extended_Int<Policy, Type>::minus_infinity)
      return inf ? V_EQ_MINUS_INFINITY : V_LT;
    if (v == Extended_Int<Policy, Type>::plus_infinity)
      return inf ? V_EQ_PLUS_INFINITY : V_GT;
  }
  if (sign) {
    if (v < 0)
      return V_LT;
    if (v > 0)
      return V_GT;
    return V_EQ;
  }
  return V_LGE;
}
template<typename Policy >
Result Parma_Polyhedra_Library::Checked::classify_mpq ( const mpq_class &  v,
bool  nan,
bool  inf,
bool  sign 
)
inline

Definition at line 37 of file checked_mpq.inlines.hh.

References Parma_Polyhedra_Library::Boundary_NS::sgn(), Parma_Polyhedra_Library::V_EQ_MINUS_INFINITY, Parma_Polyhedra_Library::V_EQ_PLUS_INFINITY, Parma_Polyhedra_Library::V_GT, Parma_Polyhedra_Library::V_LGE, Parma_Polyhedra_Library::V_LT, and Parma_Polyhedra_Library::V_NAN.

                                                                {
  if ((Policy::has_nan || Policy::has_infinity)
      && ::sgn(v.get_den()) == 0) {
    int s = ::sgn(v.get_num());
    if (Policy::has_nan && (nan || sign) && s == 0)
      return V_NAN;
    if (!inf && !sign)
      return V_LGE;
    if (Policy::has_infinity) {
      if (s < 0)
        return inf ? V_EQ_MINUS_INFINITY : V_LT;
      if (s > 0)
        return inf ? V_EQ_PLUS_INFINITY : V_GT;
    }
  }
  if (sign)
    return static_cast<Result>(sgn<Policy>(v));
  return V_LGE;
}
template<typename Policy >
Result Parma_Polyhedra_Library::Checked::classify_mpz ( const mpz_class &  v,
bool  nan,
bool  inf,
bool  sign 
)
inline

Definition at line 73 of file checked_mpz.inlines.hh.

References get_mp_size(), Parma_Polyhedra_Library::V_EQ_MINUS_INFINITY, Parma_Polyhedra_Library::V_EQ_PLUS_INFINITY, Parma_Polyhedra_Library::V_GT, Parma_Polyhedra_Library::V_LGE, Parma_Polyhedra_Library::V_LT, and Parma_Polyhedra_Library::V_NAN.

                                                                {
  if (Policy::has_nan || Policy::has_infinity) {
    mp_size_field_t s = get_mp_size(v);
    if (Policy::has_nan
        && (nan || sign)
        && s == C_Integer<mp_size_field_t>::min + 1)
      return V_NAN;
    if (!inf && !sign)
      return V_LGE;
    if (Policy::has_infinity) {
      if (s == C_Integer<mp_size_field_t>::min)
        return inf ? V_EQ_MINUS_INFINITY : V_LT;
      if (s == C_Integer<mp_size_field_t>::max)
        return inf ? V_EQ_PLUS_INFINITY : V_GT;
    }
  }
  if (sign)
    return static_cast<Result>(sgn<Policy>(v));
  return V_LGE;
}
template<typename Policy1 , typename Policy2 , typename Type1 , typename Type2 >
Result_Relation Parma_Polyhedra_Library::Checked::cmp_ext ( const Type1 &  x,
const Type2 &  y 
)
inline

Definition at line 801 of file checked_ext.inlines.hh.

References Parma_Polyhedra_Library::VR_EMPTY, Parma_Polyhedra_Library::VR_EQ, Parma_Polyhedra_Library::VR_GT, and Parma_Polyhedra_Library::VR_LT.

                                        {
  if (!ext_to_handle<Policy1>(x) && !ext_to_handle<Policy2>(y))
    goto native;
  if (is_nan<Policy1>(x) || is_nan<Policy2>(y))
    return VR_EMPTY;
  else if (is_minf<Policy1>(x))
    return is_minf<Policy2>(y) ? VR_EQ : VR_LT;
  else if (is_pinf<Policy1>(x))
    return is_pinf<Policy2>(y) ? VR_EQ : VR_GT;
  else {
    if (is_minf<Policy2>(y))
      return VR_GT;
    if (is_pinf<Policy2>(y))
      return VR_LT;
  native:
    return cmp<Policy1, Policy2>(x, y);
  }
}
template<typename Policy1 , typename Policy2 , typename Type >
Result_Relation Parma_Polyhedra_Library::Checked::cmp_float ( const Type  x,
const Type  y 
)
inline

Definition at line 739 of file checked_float.inlines.hh.

References Parma_Polyhedra_Library::VR_EMPTY, Parma_Polyhedra_Library::VR_EQ, Parma_Polyhedra_Library::VR_GT, and Parma_Polyhedra_Library::VR_LT.

                                      {
  if (x > y)
    return VR_GT;
  if (x < y)
    return VR_LT;
  if (x == y)
    return VR_EQ;
  return VR_EMPTY;
}
template<typename Policy1 , typename Policy2 , typename Type1 , typename Type2 >
Result_Relation Parma_Polyhedra_Library::Checked::cmp_generic ( const Type1 &  x,
const Type2 &  y 
)
inline

Definition at line 620 of file checked.inlines.hh.

                                            {
  if (lt(y, x))
    return VR_GT;
  if (lt(x, y))
    return VR_LT;
  return VR_EQ;
}
template<typename Policy1 , typename Policy2 , typename Type >
Result_Relation Parma_Polyhedra_Library::Checked::cmp_mp ( const Type &  x,
const Type &  y 
)
inline

Definition at line 622 of file checked_mpz.inlines.hh.

References Parma_Polyhedra_Library::cmp(), Parma_Polyhedra_Library::VR_EQ, Parma_Polyhedra_Library::VR_GT, and Parma_Polyhedra_Library::VR_LT.

                                     {
  int i = ::cmp(x, y);
  return (i > 0) ? VR_GT : ((i < 0) ? VR_LT : VR_EQ);
}
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result Parma_Polyhedra_Library::Checked::construct_ext ( To &  to,
const From &  x,
Rounding_Dir  dir 
)
inline

Definition at line 69 of file checked_ext.inlines.hh.

References Parma_Polyhedra_Library::ROUND_IGNORE, Parma_Polyhedra_Library::VC_MINUS_INFINITY, Parma_Polyhedra_Library::VC_NAN, and Parma_Polyhedra_Library::VC_PLUS_INFINITY.

                                                       {
  if (!ext_to_handle<From_Policy>(x))
    goto native;
  if (is_nan<From_Policy>(x))
    return construct_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
  else if (is_minf<From_Policy>(x))
    return construct_special<To_Policy>(to, VC_MINUS_INFINITY, dir);
  else if (is_pinf<From_Policy>(x))
    return construct_special<To_Policy>(to, VC_PLUS_INFINITY, dir);
  else {
  native:
    return construct<To_Policy, From_Policy>(to, x, dir);
  }
}
template<typename To_Policy , typename From_Policy , typename From >
Result Parma_Polyhedra_Library::Checked::construct_mpq_base ( mpq_class &  to,
const From &  from,
Rounding_Dir   
)
inline

Definition at line 138 of file checked_mpq.inlines.hh.

References Parma_Polyhedra_Library::V_EQ.

                                                                  {
  new (&to) mpq_class(from);
  return V_EQ;
}
template<typename To_Policy , typename From_Policy , typename From >
Result Parma_Polyhedra_Library::Checked::construct_mpq_float ( mpq_class &  to,
const From &  from,
Rounding_Dir  dir 
)
inline

Definition at line 156 of file checked_mpq.inlines.hh.

References Parma_Polyhedra_Library::ROUND_IGNORE, Parma_Polyhedra_Library::V_EQ, Parma_Polyhedra_Library::VC_MINUS_INFINITY, Parma_Polyhedra_Library::VC_NAN, and Parma_Polyhedra_Library::VC_PLUS_INFINITY.

                                                                       {
  if (is_nan<From_Policy>(from))
    return construct_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
  else if (is_minf<From_Policy>(from))
    return construct_special<To_Policy>(to, VC_MINUS_INFINITY, dir);
  else if (is_pinf<From_Policy>(from))
    return construct_special<To_Policy>(to, VC_PLUS_INFINITY, dir);
  new (&to) mpq_class(from);
  return V_EQ;
}
template<typename To_Policy , typename From_Policy , typename From >
Result Parma_Polyhedra_Library::Checked::construct_mpz_base ( mpz_class &  to,
const From  from,
Rounding_Dir   
)
inline

Definition at line 177 of file checked_mpz.inlines.hh.

References Parma_Polyhedra_Library::V_EQ.

                                                                 {
    new (&to) mpz_class(from);
    return V_EQ;
}
template<typename To_Policy , typename From_Policy , typename From >
Result Parma_Polyhedra_Library::Checked::construct_mpz_float ( mpz_class &  to,
const From &  from,
Rounding_Dir  dir 
)
inline

Definition at line 194 of file checked_mpz.inlines.hh.

References From, Parma_Polyhedra_Library::ROUND_IGNORE, Parma_Polyhedra_Library::round_not_requested(), Parma_Polyhedra_Library::V_EQ, Parma_Polyhedra_Library::V_LGE, Parma_Polyhedra_Library::VC_MINUS_INFINITY, Parma_Polyhedra_Library::VC_NAN, and Parma_Polyhedra_Library::VC_PLUS_INFINITY.

                                                                       {
  if (is_nan<From_Policy>(from))
    return construct_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
  else if (is_minf<From_Policy>(from))
    return construct_special<To_Policy>(to, VC_MINUS_INFINITY, dir);
  else if (is_pinf<From_Policy>(from))
    return construct_special<To_Policy>(to, VC_PLUS_INFINITY, dir);
  if (round_not_requested(dir)) {
    new (&to) mpz_class(from);
    return V_LGE;
  }
  From n = rint(from);
  new (&to) mpz_class(n);
  if (from == n)
    return V_EQ;
  if (from < 0)
    return round_lt_mpz<To_Policy>(to, dir);
  else
    return round_gt_mpz<To_Policy>(to, dir);
}
template<typename To_Policy , typename From_Policy , typename Type >
Enable_If<Is_Same<To_Policy, From_Policy>::value, void>::type Parma_Polyhedra_Library::Checked::copy_generic ( Type &  to,
const Type &  from 
)
inline

Definition at line 282 of file checked.inlines.hh.

                                         {
  to = from;
}
template<typename To_Policy , typename From_Policy >
void Parma_Polyhedra_Library::Checked::copy_mpz ( mpz_class &  to,
const mpz_class &  from 
)
inline

Definition at line 161 of file checked_mpz.inlines.hh.

References get_mp_size(), PPL_ASSERT, and set_mp_size().

                                               {
  if (is_nan_mpz<From_Policy>(from))
    PPL_ASSERT(To_Policy::has_nan);
  else if (is_minf_mpz<From_Policy>(from) || is_pinf_mpz<From_Policy>(from))
    PPL_ASSERT(To_Policy::has_infinity);
  else {
    to = from;
    return;
  }
  set_mp_size(to, get_mp_size(from));
}
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result Parma_Polyhedra_Library::Checked::div_2exp_ext ( To &  to,
const From &  x,
unsigned int  exp,
Rounding_Dir  dir 
)
inline

Definition at line 678 of file checked_ext.inlines.hh.

References Parma_Polyhedra_Library::ROUND_IGNORE, Parma_Polyhedra_Library::VC_MINUS_INFINITY, Parma_Polyhedra_Library::VC_NAN, and Parma_Polyhedra_Library::VC_PLUS_INFINITY.

                                                                        {
  if (!ext_to_handle<From_Policy>(x))
    goto native;
  if (is_nan<From_Policy>(x))
    return assign_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
  else if (is_minf<From_Policy>(x))
    return assign_special<To_Policy>(to, VC_MINUS_INFINITY, dir);
  else if (is_pinf<From_Policy>(x))
    return assign_special<To_Policy>(to, VC_PLUS_INFINITY, dir);
  else {
  native:
    return div_2exp<To_Policy, From_Policy>(to, x, exp, dir);
  }
}
template<typename To_Policy , typename From_Policy , typename Type >
Result Parma_Polyhedra_Library::Checked::div_2exp_float ( Type &  to,
const Type  x,
unsigned int  exp,
Rounding_Dir  dir 
)
inline

Definition at line 648 of file checked_float.inlines.hh.

References PPL_ASSERT, Parma_Polyhedra_Library::ROUND_IGNORE, sizeof_to_bits, Type, and Parma_Polyhedra_Library::VC_NAN.

                                                                           {
  if (To_Policy::fpu_check_nan_result && is_nan<From_Policy>(x))
    return assign_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
  PPL_ASSERT(exp < sizeof_to_bits(sizeof(unsigned long long)));
  return
    div<To_Policy, From_Policy, Float_2exp>(to,
                                            x,
                                            Type(1ULL << exp),
                                            dir);
}
template<typename To_Policy , typename From_Policy >
Result Parma_Polyhedra_Library::Checked::div_2exp_mpq ( mpq_class &  to,
const mpq_class &  x,
unsigned int  exp,
Rounding_Dir   
)
inline

Definition at line 381 of file checked_mpq.inlines.hh.

References Parma_Polyhedra_Library::V_EQ.

                           {
  to.get_num() = x.get_num();
  mpz_mul_2exp(to.get_den().get_mpz_t(), x.get_den().get_mpz_t(), exp);
  to.canonicalize();
  return V_EQ;
}
template<typename To_Policy , typename From_Policy >
Result Parma_Polyhedra_Library::Checked::div_2exp_mpz ( mpz_class &  to,
const mpz_class &  x,
unsigned int  exp,
Rounding_Dir  dir 
)
inline

Definition at line 485 of file checked_mpz.inlines.hh.

References PPL_ASSERT, Parma_Polyhedra_Library::round_down(), Parma_Polyhedra_Library::round_not_requested(), Parma_Polyhedra_Library::round_strict_relation(), Parma_Polyhedra_Library::round_up(), Parma_Polyhedra_Library::V_EQ, Parma_Polyhedra_Library::V_GE, Parma_Polyhedra_Library::V_GT, Parma_Polyhedra_Library::V_LE, Parma_Polyhedra_Library::V_LGE, and Parma_Polyhedra_Library::V_LT.

                               {
  mpz_srcptr n = x.get_mpz_t();
  if (round_not_requested(dir)) {
    mpz_tdiv_q_2exp(to.get_mpz_t(), x.get_mpz_t(), exp);
    return V_LGE;
  }
  if (round_down(dir)) {
    mpz_fdiv_q_2exp(to.get_mpz_t(), n, exp);
    if (round_strict_relation(dir))
      return (mpz_divisible_2exp_p(n, exp) != 0) ? V_EQ : V_GT;
    return V_GE;
  }
  else {
    PPL_ASSERT(round_up(dir));
    mpz_cdiv_q_2exp(to.get_mpz_t(), n, exp);
    if (round_strict_relation(dir))
      return (mpz_divisible_2exp_p(n, exp) != 0) ? V_EQ : V_LT;
    return V_LE;
  }
}
template<typename To_Policy , typename From_Policy , typename Type >
Result Parma_Polyhedra_Library::Checked::div_2exp_signed_int ( Type &  to,
const Type  x,
unsigned int  exp,
Rounding_Dir  dir 
)
inline

Definition at line 1214 of file checked_int.inlines.hh.

References Parma_Polyhedra_Library::round_not_requested(), sizeof_to_bits, Type, Parma_Polyhedra_Library::V_EQ, Parma_Polyhedra_Library::V_GE, and Parma_Polyhedra_Library::V_LGE.

                                      {
  if (exp > sizeof_to_bits(sizeof(Type)) - 1) {
  zero:
    to = 0;
    if (round_not_requested(dir))
      return V_LGE;
    if (x < 0)
      return round_lt_int_no_overflow<To_Policy>(to, dir);
    else if (x > 0)
      return round_gt_int_no_overflow<To_Policy>(to, dir);
    else
      return V_EQ;
  }
  if (exp == sizeof_to_bits(sizeof(Type)) - 1) {
    if (x == C_Integer<Type>::min) {
      to = -1;
      return V_EQ;
    }
    goto zero;
  }
#if 0
  to = x / (Type(1) << exp);
  if (round_not_requested(dir))
    return V_GE;
  Type r = x % (Type(1) << exp);
  if (r < 0)
    return round_lt_int_no_overflow<To_Policy>(to, dir);
  else if (r > 0)
    return round_gt_int_no_overflow<To_Policy>(to, dir);
  else
    return V_EQ;
#else
  // Faster but compiler implementation dependent (see C++98 5.8.3)
  to = x >> exp;
  if (round_not_requested(dir))
    return V_GE;
  if (x & ((Type(1) << exp) - 1))
    return round_gt_int_no_overflow<To_Policy>(to, dir);
  return V_EQ;
#endif
}
template<typename To_Policy , typename From_Policy , typename Type >
Result Parma_Polyhedra_Library::Checked::div_2exp_unsigned_int ( Type &  to,
const Type  x,
unsigned int  exp,
Rounding_Dir  dir 
)
inline

Definition at line 1193 of file checked_int.inlines.hh.

References Parma_Polyhedra_Library::round_not_requested(), sizeof_to_bits, Type, Parma_Polyhedra_Library::V_EQ, and Parma_Polyhedra_Library::V_GE.

                                        {
  if (exp >= sizeof_to_bits(sizeof(Type))) {
    to = 0;
    if (round_not_requested(dir))
      return V_GE;
    if (x == 0)
      return V_EQ;
    return round_gt_int_no_overflow<To_Policy>(to, dir);
  }
  to = x >> exp;
  if (round_not_requested(dir))
    return V_GE;
  if (x & ((Type(1) << exp) - 1))
    return round_gt_int_no_overflow<To_Policy>(to, dir);
  else
    return V_EQ;
}
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename To , typename From1 , typename From2 >
Result Parma_Polyhedra_Library::Checked::div_ext ( To &  to,
const From1 &  x,
const From2 &  y,
Rounding_Dir  dir 
)
inline

Definition at line 486 of file checked_ext.inlines.hh.

References CHECK_P, PPL_ASSERT, Parma_Polyhedra_Library::ROUND_IGNORE, Parma_Polyhedra_Library::V_DIV_ZERO, Parma_Polyhedra_Library::V_EQ, Parma_Polyhedra_Library::V_INF_DIV_INF, Parma_Polyhedra_Library::VC_MINUS_INFINITY, Parma_Polyhedra_Library::VC_NAN, Parma_Polyhedra_Library::VC_PLUS_INFINITY, Parma_Polyhedra_Library::VR_GT, and Parma_Polyhedra_Library::VR_LT.

                                                                  {
  if (!ext_to_handle<From1_Policy>(x) && !ext_to_handle<From2_Policy>(y))
    goto native;
  if (is_nan<From1_Policy>(x) || is_nan<From2_Policy>(y))
    return assign_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
  if (is_minf<From1_Policy>(x)) {
    if (CHECK_P(To_Policy::check_inf_div_inf, is_minf<From2_Policy>(y)
                || is_pinf<From2_Policy>(y)))
      goto inf_div_inf;
    else {
      switch (sgn<From2_Policy>(y)) {
      case VR_LT:
        goto pinf;
      case VR_GT:
        goto minf;
      default:
        goto div_zero;
      }
    }
  }
  else if (is_pinf<From1_Policy>(x)) {
    if (CHECK_P(To_Policy::check_inf_div_inf, is_minf<From2_Policy>(y)
                || is_pinf<From2_Policy>(y))) {
    inf_div_inf:
      return assign_nan<To_Policy>(to, V_INF_DIV_INF);
    }
    else {
      switch (sgn<From2_Policy>(y)) {
      case VR_LT:
      minf:
        return assign_special<To_Policy>(to, VC_MINUS_INFINITY, dir);
      case VR_GT:
      pinf:
        return assign_special<To_Policy>(to, VC_PLUS_INFINITY, dir);
      default:
      div_zero:
        PPL_ASSERT(To_Policy::check_div_zero);
        return assign_nan<To_Policy>(to, V_DIV_ZERO);
      }
    }
  }
  else {
    if (is_minf<From2_Policy>(y) || is_pinf<From2_Policy>(y)) {
      to = 0;
      return V_EQ;
    }
    else {
    native:
      return div<To_Policy, From1_Policy, From2_Policy>(to, x, y, dir);
    }
  }
}
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename Type >
Result Parma_Polyhedra_Library::Checked::div_float ( Type &  to,
const Type  x,
const Type  y,
Rounding_Dir  dir 
)
inline

Definition at line 536 of file checked_float.inlines.hh.

References fpu_direct_rounding(), fpu_inverse_rounding(), Parma_Polyhedra_Library::fpu_restore_rounding_direction(), Parma_Polyhedra_Library::fpu_save_rounding_direction(), limit_precision(), Parma_Polyhedra_Library::round_fpu_dir(), Parma_Polyhedra_Library::V_DIV_ZERO, Parma_Polyhedra_Library::V_INF_DIV_INF, and Parma_Polyhedra_Library::V_NAN.

                                                                  {
  if (To_Policy::check_inf_div_inf
      && is_inf_float<From1_Policy>(x) && is_inf_float<From2_Policy>(y)) {
    return assign_nan<To_Policy>(to, V_INF_DIV_INF);
  }
  if (To_Policy::check_div_zero && y == 0) {
    return assign_nan<To_Policy>(to, V_DIV_ZERO);
  }
  prepare_inexact<To_Policy>(dir);
  if (fpu_direct_rounding(dir))
    to = x / y;
  else if (fpu_inverse_rounding(dir)) {
    to = x / -y;
    limit_precision(to);
    to = -to;
  }
  else {
    fpu_rounding_control_word_type old
      = fpu_save_rounding_direction(round_fpu_dir(dir));
    limit_precision(x);
    limit_precision(y);
    to = x / y;
    limit_precision(to);
    fpu_restore_rounding_direction(old);
  }
  if (To_Policy::fpu_check_nan_result && is_nan<To_Policy>(to))
    return V_NAN;
  return result_relation<To_Policy>(dir);
}
template<typename To_Policy , typename From1_Policy , typename From2_Policy >
Result Parma_Polyhedra_Library::Checked::div_mpq ( mpq_class &  to,
const mpq_class &  x,
const mpq_class &  y,
Rounding_Dir   
)
inline

Definition at line 304 of file checked_mpq.inlines.hh.

References CHECK_P, Parma_Polyhedra_Library::Boundary_NS::sgn(), Parma_Polyhedra_Library::V_DIV_ZERO, and Parma_Polyhedra_Library::V_EQ.

                                                                             {
  if (CHECK_P(To_Policy::check_div_zero, sgn(y) == 0)) {
    return assign_nan<To_Policy>(to, V_DIV_ZERO);
  }
  to = x / y;
  return V_EQ;
}
template<typename To_Policy , typename From1_Policy , typename From2_Policy >
Result Parma_Polyhedra_Library::Checked::div_mpz ( mpz_class &  to,
const mpz_class &  x,
const mpz_class &  y,
Rounding_Dir  dir 
)
inline

Definition at line 388 of file checked_mpz.inlines.hh.

References CHECK_P, PPL_ASSERT, Parma_Polyhedra_Library::round_down(), Parma_Polyhedra_Library::round_ignore(), Parma_Polyhedra_Library::round_not_needed(), Parma_Polyhedra_Library::round_strict_relation(), Parma_Polyhedra_Library::round_up(), Parma_Polyhedra_Library::Boundary_NS::sgn(), Parma_Polyhedra_Library::V_DIV_ZERO, Parma_Polyhedra_Library::V_EQ, Parma_Polyhedra_Library::V_GE, Parma_Polyhedra_Library::V_GT, Parma_Polyhedra_Library::V_LE, Parma_Polyhedra_Library::V_LGE, and Parma_Polyhedra_Library::V_LT.

                          {
  if (CHECK_P(To_Policy::check_div_zero, ::sgn(y) == 0)) {
    return assign_nan<To_Policy>(to, V_DIV_ZERO);
  }
  mpz_srcptr n = x.get_mpz_t();
  mpz_srcptr d = y.get_mpz_t();
  if (round_not_needed(dir)) {
    mpz_divexact(to.get_mpz_t(), n, d);
    return V_LGE;
  }
  if (round_ignore(dir)) {
    mpz_cdiv_q(to.get_mpz_t(), n, d);
    return V_LE;
  }
  if (round_down(dir)) {
    mpz_fdiv_q(to.get_mpz_t(), n, d);
    if (round_strict_relation(dir))
      return (mpz_divisible_p(n, d) != 0) ? V_EQ : V_GT;
    return V_GE;
  }
  else {
    PPL_ASSERT(round_up(dir));
    mpz_cdiv_q(to.get_mpz_t(), n, d);
    if (round_strict_relation(dir))
      return (mpz_divisible_p(n, d) != 0) ? V_EQ : V_LT;
    return V_LE;
  }
}
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename Type >
Result Parma_Polyhedra_Library::Checked::div_signed_int ( Type &  to,
const Type  x,
const Type  y,
Rounding_Dir  dir 
)
inline

Definition at line 1109 of file checked_int.inlines.hh.

References CHECK_P, Parma_Polyhedra_Library::round_not_requested(), Type, Parma_Polyhedra_Library::V_DIV_ZERO, Parma_Polyhedra_Library::V_EQ, and Parma_Polyhedra_Library::V_LGE.

                                                                       {
  if (CHECK_P(To_Policy::check_div_zero, y == 0)) {
    return assign_nan<To_Policy>(to, V_DIV_ZERO);
  }
  if (To_Policy::check_overflow && y == -1)
    return neg_signed_int<To_Policy, From1_Policy>(to, x, dir);
  to = x / y;
  if (round_not_requested(dir))
    return V_LGE;
  if (y == -1)
    return V_EQ;
  Type m = x % y;
  if (m < 0)
    return round_lt_int_no_overflow<To_Policy>(to, dir);
  else if (m > 0)
    return round_gt_int_no_overflow<To_Policy>(to, dir);
  else
    return V_EQ;
}
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename Type >
Result Parma_Polyhedra_Library::Checked::div_unsigned_int ( Type &  to,
const Type  x,
const Type  y,
Rounding_Dir  dir 
)
inline

Definition at line 1132 of file checked_int.inlines.hh.

References CHECK_P, Parma_Polyhedra_Library::round_not_requested(), Type, Parma_Polyhedra_Library::V_DIV_ZERO, Parma_Polyhedra_Library::V_EQ, and Parma_Polyhedra_Library::V_GE.

                                                                         {
  if (CHECK_P(To_Policy::check_div_zero, y == 0)) {
    return assign_nan<To_Policy>(to, V_DIV_ZERO);
  }
  to = x / y;
  if (round_not_requested(dir))
    return V_GE;
  Type m = x % y;
  if (m == 0)
    return V_EQ;
  return round_gt_int<To_Policy>(to, dir);
}
template<typename T1 , typename T2 >
Enable_If<(Safe_Int_Comparison<T1, T2>::value || Safe_Conversion<T1, T2>::value || Safe_Conversion<T2, T1>::value), bool>::type Parma_Polyhedra_Library::Checked::eq ( const T1 &  x,
const T2 &  y 
)
inline

Definition at line 479 of file checked.inlines.hh.

                             {
  return x == y;
}
template<typename Policy1 , typename Policy2 , typename Type1 , typename Type2 >
bool Parma_Polyhedra_Library::Checked::eq_ext ( const Type1 &  x,
const Type2 &  y 
)
inline

Definition at line 869 of file checked_ext.inlines.hh.

                                       {
  if (!ext_to_handle<Policy1>(x) && !ext_to_handle<Policy2>(y))
    goto native;
  if (is_nan<Policy1>(x) || is_nan<Policy2>(y))
    return false;
  if (is_minf<Policy1>(x))
    return is_minf<Policy2>(y);
  if (is_pinf<Policy1>(x))
    return is_pinf<Policy2>(y);
  else if (is_minf<Policy2>(y) || is_pinf<Policy2>(y))
    return false;
 native:
  return eq_p<Policy1, Policy2>(x, y);
}
template<typename Policy1 , typename Policy2 , typename Type1 , typename Type2 >
bool Parma_Polyhedra_Library::Checked::eq_p ( const Type1 &  x,
const Type2 &  y 
)
inline

Definition at line 613 of file checked.inlines.hh.

                                     {
  return eq(x, y);
}
template<typename Policy , typename Type >
bool Parma_Polyhedra_Library::Checked::ext_to_handle ( const Type &  x)
inline

Definition at line 44 of file checked_ext.inlines.hh.

References handle_ext_natively().

                             {
  return !handle_ext_natively(x)
    && (Policy::has_infinity || Policy::has_nan);
}
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result Parma_Polyhedra_Library::Checked::floor_ext ( To &  to,
const From &  x,
Rounding_Dir  dir 
)
inline

Definition at line 123 of file checked_ext.inlines.hh.

References Parma_Polyhedra_Library::ROUND_IGNORE, Parma_Polyhedra_Library::VC_MINUS_INFINITY, Parma_Polyhedra_Library::VC_NAN, and Parma_Polyhedra_Library::VC_PLUS_INFINITY.

                                                   {
  if (!ext_to_handle<From_Policy>(x))
    goto native;
  if (is_nan<From_Policy>(x))
    return assign_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
  else if (is_minf<From_Policy>(x))
    return assign_special<To_Policy>(to, VC_MINUS_INFINITY, dir);
  else if (is_pinf<From_Policy>(x))
    return assign_special<To_Policy>(to, VC_PLUS_INFINITY, dir);
  else {
  native:
    return floor<To_Policy, From_Policy>(to, x, dir);
  }
}
template<typename To_Policy , typename From_Policy >
Result Parma_Polyhedra_Library::Checked::floor_mpq ( mpq_class &  to,
const mpq_class &  from,
Rounding_Dir   
)
inline

Definition at line 235 of file checked_mpq.inlines.hh.

References Parma_Polyhedra_Library::V_EQ.

                                                              {
  mpz_fdiv_q(to.get_num().get_mpz_t(),
             from.get_num().get_mpz_t(), from.get_den().get_mpz_t());
  to.get_den() = 1;
  return V_EQ;
}
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename To , typename From1 , typename From2 >
Result Parma_Polyhedra_Library::Checked::gcd_exact ( To &  to,
const From1 &  x,
const From2 &  y,
Rounding_Dir  dir 
)
inline

Definition at line 317 of file checked.inlines.hh.

                                                                    {
  gcd_exact_no_abs<To_Policy, From1_Policy, From2_Policy>(to, x, y);
  return abs<To_Policy, To_Policy>(to, to, dir);
}
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename To , typename From >
void Parma_Polyhedra_Library::Checked::gcd_exact_no_abs ( To &  to,
const From &  x,
const From &  y 
)
inline

Definition at line 298 of file checked.inlines.hh.

References Parma_Polyhedra_Library::ROUND_NOT_NEEDED, and To.

                                                       {
  To w_x = x;
  To w_y = y;
  To remainder;
  while (w_y != 0) {
    // The following is derived from the assumption that w_x % w_y
    // is always representable. This is true for both native integers
    // and IEC 559 floating point numbers.
    rem<To_Policy, From1_Policy, From2_Policy>(remainder, w_x, w_y,
                                               ROUND_NOT_NEEDED);
    w_x = w_y;
    w_y = remainder;
  }
  to = w_x;
}
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename To , typename From1 , typename From2 >
Result Parma_Polyhedra_Library::Checked::gcd_ext ( To &  to,
const From1 &  x,
const From2 &  y,
Rounding_Dir  dir 
)
inline

Definition at line 751 of file checked_ext.inlines.hh.

References Parma_Polyhedra_Library::ROUND_IGNORE, and Parma_Polyhedra_Library::VC_NAN.

                                                                  {
  if (is_nan<From1_Policy>(x) || is_nan<From2_Policy>(y))
    return assign_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
  else if (is_minf<From1_Policy>(x) || is_pinf<From1_Policy>(x))
    return abs_ext<To_Policy, From2_Policy>(to, y, dir);
  else if (is_minf<From2_Policy>(y) || is_pinf<From2_Policy>(y))
    return abs_ext<To_Policy, From1_Policy>(to, x, dir);
  else
    return gcd<To_Policy, From1_Policy, From2_Policy>(to, x, y, dir);
}
template<typename To_Policy , typename From1_Policy , typename From2_Policy >
Result Parma_Polyhedra_Library::Checked::gcd_mpz ( mpz_class &  to,
const mpz_class &  x,
const mpz_class &  y,
Rounding_Dir   
)
inline

Definition at line 563 of file checked_mpz.inlines.hh.

References Parma_Polyhedra_Library::V_EQ.

                                                                             {
  mpz_gcd(to.get_mpz_t(), x.get_mpz_t(), y.get_mpz_t());
  return V_EQ;
}
template<typename To1_Policy , typename To2_Policy , typename To3_Policy , typename From1_Policy , typename From2_Policy , typename To1 , typename To2 , typename To3 , typename From1 , typename From2 >
Result Parma_Polyhedra_Library::Checked::gcdext_exact ( To1 &  to,
To2 &  s,
To3 &  t,
const From1 &  x,
const From2 &  y,
Rounding_Dir  dir 
)
inline

Definition at line 327 of file checked.inlines.hh.

References From2, To1, To2, To3, and Parma_Polyhedra_Library::V_EQ.

                               {
  // In case this becomes a bottleneck, we may consider using the
  // Stehle'-Zimmermann algorithm (see R. Crandall and C. Pomerance,
  // Prime Numbers - A Computational Perspective, Second Edition,
  // Springer, 2005).
  if (y == 0) {
    if (x == 0) {
      s = 0;
      t = 1;
      return V_EQ;
    }
    else {
      if (x < 0)
        s = -1;
      else
        s = 1;
      t = 0;
      return abs<To1_Policy, From1_Policy>(to, x, dir);
    }
  }

  s = 1;
  t = 0;
  bool negative_x = x < 0;
  bool negative_y = y < 0;

  Result r;
  r = abs<To1_Policy, From1_Policy>(to, x, dir);
  if (r != V_EQ)
    return r;

  From2 a_y;
  r = abs<To1_Policy, From2_Policy>(a_y, y, dir);
  if (r != V_EQ)
    return r;

  // If PPL_MATCH_GMP_GCDEXT is defined then s is favored when the absolute
  // values of the given numbers are equal.  For instance if x and y
  // are both 5 then s will be 1 and t will be 0, instead of the other
  // way round.  This is to match the behavior of GMP.
#define PPL_MATCH_GMP_GCDEXT 1
#ifdef PPL_MATCH_GMP_GCDEXT
  if (to == a_y)
    goto sign_check;
#endif

  {
    To2 v1 = 0;
    To3 v2 = 1;
    To1 v3 = static_cast<To1>(a_y);
    while (true) {
      To1 q = to / v3;
      // Remainder, next candidate GCD.
      To1 t3 = to - q*v3;
      To2 t1 = s - static_cast<To2>(q)*v1;
      To3 t2 = t - static_cast<To3>(q)*v2;
      s = v1;
      t = v2;
      to = v3;
      if (t3 == 0)
        break;
      v1 = t1;
      v2 = t2;
      v3 = t3;
    }
  }

#ifdef PPL_MATCH_GMP_GCDEXT
 sign_check:
#endif
  if (negative_x) {
    r = neg<To2_Policy, To2_Policy>(s, s, dir);
    if (r != V_EQ)
      return r;
  }
  if (negative_y)
    return neg<To3_Policy, To3_Policy>(t, t, dir);
  return V_EQ;
#undef PPL_MATCH_GMP_GCDEXT
}
template<typename To1_Policy , typename To2_Policy , typename To3_Policy , typename From1_Policy , typename From2_Policy , typename To1 , typename To2 , typename To3 , typename From1 , typename From2 >
Result Parma_Polyhedra_Library::Checked::gcdext_ext ( To1 &  to,
To2 &  s,
To3 &  t,
const From1 &  x,
const From2 &  y,
Rounding_Dir  dir 
)
inline

Definition at line 767 of file checked_ext.inlines.hh.

References Parma_Polyhedra_Library::ROUND_IGNORE, and Parma_Polyhedra_Library::VC_NAN.

                             {
  if (is_nan<From1_Policy>(x) || is_nan<From2_Policy>(y))
    return assign_special<To1_Policy>(to, VC_NAN, ROUND_IGNORE);
  else if (is_minf<From1_Policy>(x) || is_pinf<From1_Policy>(x)) {
    s = 0;
    t = y > 0 ? -1 : 1;
    return abs_ext<To1_Policy, From2_Policy>(to, y, dir);
  }
  else if (is_minf<From2_Policy>(y) || is_pinf<From2_Policy>(y)) {
    s = x > 0 ? -1 : 1;
    t = 0;
    return abs_ext<To1_Policy, From1_Policy>(to, x, dir);
  }
  else
    return gcdext<To1_Policy, To2_Policy, To3_Policy, From1_Policy, From2_Policy>(to, s, t, x, y, dir);
}
template<typename To_Policy , typename From1_Policy , typename From2_Policy >
Result Parma_Polyhedra_Library::Checked::gcdext_mpz ( mpz_class &  to,
mpz_class &  s,
mpz_class &  t,
const mpz_class &  x,
const mpz_class &  y,
Rounding_Dir   
)
inline

Definition at line 572 of file checked_mpz.inlines.hh.

References Parma_Polyhedra_Library::V_EQ.

                         {
  mpz_gcdext(to.get_mpz_t(), s.get_mpz_t(), t.get_mpz_t(),
             x.get_mpz_t(), y.get_mpz_t());
  return V_EQ;
}
template<typename Policy1 , typename Policy2 , typename Type1 , typename Type2 >
bool Parma_Polyhedra_Library::Checked::ge_ext ( const Type1 &  x,
const Type2 &  y 
)
inline

Definition at line 862 of file checked_ext.inlines.hh.

                                       {
  return le_ext<Policy1, Policy2>(y, x);
}
int Parma_Polyhedra_Library::Checked::get_digit ( char  c,
unsigned int  base = 10 
)
inline

Returns the integer value associated with the ASCII code c, in the base base positional number system, if there is such an association; returns $-1$ otherwise.

Definition at line 54 of file checked.cc.

Referenced by parse_number_part().

                                          {
  unsigned int n;
  switch (c) {
  case '0': n = 0; break;
  case '1': n = 1; break;
  case '2': n = 2; break;
  case '3': n = 3; break;
  case '4': n = 4; break;
  case '5': n = 5; break;
  case '6': n = 6; break;
  case '7': n = 7; break;
  case '8': n = 8; break;
  case '9': n = 9; break;
  case 'a': case 'A': n = 10; break;
  case 'b': case 'B': n = 11; break;
  case 'c': case 'C': n = 12; break;
  case 'd': case 'D': n = 13; break;
  case 'e': case 'E': n = 14; break;
  case 'f': case 'F': n = 15; break;
  case 'g': case 'G': n = 16; break;
  case 'h': case 'H': n = 17; break;
  case 'i': case 'I': n = 18; break;
  case 'j': case 'J': n = 19; break;
  case 'k': case 'K': n = 20; break;
  case 'l': case 'L': n = 21; break;
  case 'm': case 'M': n = 22; break;
  case 'n': case 'N': n = 23; break;
  case 'o': case 'O': n = 24; break;
  case 'p': case 'P': n = 25; break;
  case 'q': case 'Q': n = 26; break;
  case 'r': case 'R': n = 27; break;
  case 's': case 'S': n = 28; break;
  case 't': case 'T': n = 29; break;
  case 'u': case 'U': n = 30; break;
  case 'v': case 'V': n = 31; break;
  case 'w': case 'W': n = 32; break;
  case 'x': case 'X': n = 33; break;
  case 'y': case 'Y': n = 34; break;
  case 'z': case 'Z': n = 35; break;
  default:
    return -1;
  }
  if (n >= base)
    return -1;
  return static_cast<int>(n);
}

Definition at line 62 of file checked_mpz.inlines.hh.

Referenced by classify_mpz(), copy_mpz(), is_minf_mpz(), is_nan_mpz(), and is_pinf_mpz().

                                {
  return v.get_mpz_t()->_mp_size;
}
template<typename Policy1 , typename Policy2 , typename Type1 , typename Type2 >
bool Parma_Polyhedra_Library::Checked::gt_ext ( const Type1 &  x,
const Type2 &  y 
)
inline

Definition at line 839 of file checked_ext.inlines.hh.

                                       {
  return lt_ext<Policy1, Policy2>(y, x);
}
template<typename T >
bool Parma_Polyhedra_Library::Checked::handle_ext_natively ( const T &  )
inline

Definition at line 38 of file checked_ext.inlines.hh.

Referenced by ext_to_handle().

                              {
  return FPU_Related<T>::value;
}
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename To , typename From1 , typename From2 >
Result Parma_Polyhedra_Library::Checked::idiv_ext ( To &  to,
const From1 &  x,
const From2 &  y,
Rounding_Dir  dir 
)
inline

Definition at line 543 of file checked_ext.inlines.hh.

References CHECK_P, PPL_ASSERT, Parma_Polyhedra_Library::ROUND_IGNORE, Parma_Polyhedra_Library::V_DIV_ZERO, Parma_Polyhedra_Library::V_EQ, Parma_Polyhedra_Library::V_INF_DIV_INF, Parma_Polyhedra_Library::VC_MINUS_INFINITY, Parma_Polyhedra_Library::VC_NAN, Parma_Polyhedra_Library::VC_PLUS_INFINITY, Parma_Polyhedra_Library::VR_GT, and Parma_Polyhedra_Library::VR_LT.

                                                                   {
  if (!ext_to_handle<From1_Policy>(x) && !ext_to_handle<From2_Policy>(y))
    goto native;
  if (is_nan<From1_Policy>(x) || is_nan<From2_Policy>(y))
    return assign_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
  if (is_minf<From1_Policy>(x)) {
    if (CHECK_P(To_Policy::check_inf_div_inf, is_minf<From2_Policy>(y)
                || is_pinf<From2_Policy>(y)))
      goto inf_div_inf;
    else {
      switch (sgn<From2_Policy>(y)) {
      case VR_LT:
        goto pinf;
      case VR_GT:
        goto minf;
      default:
        goto div_zero;
      }
    }
  }
  else if (is_pinf<From1_Policy>(x)) {
    if (CHECK_P(To_Policy::check_inf_div_inf, is_minf<From2_Policy>(y)
                || is_pinf<From2_Policy>(y))) {
    inf_div_inf:
      return assign_nan<To_Policy>(to, V_INF_DIV_INF);
    }
    else {
      switch (sgn<From2_Policy>(y)) {
      case VR_LT:
      minf:
        return assign_special<To_Policy>(to, VC_MINUS_INFINITY, dir);
      case VR_GT:
      pinf:
        return assign_special<To_Policy>(to, VC_PLUS_INFINITY, dir);
      default:
      div_zero:
        PPL_ASSERT(To_Policy::check_div_zero);
        return assign_nan<To_Policy>(to, V_DIV_ZERO);
      }
    }
  }
  else {
    if (is_minf<From2_Policy>(y) || is_pinf<From2_Policy>(y)) {
      to = 0;
      return V_EQ;
    }
    else {
    native:
      return idiv<To_Policy, From1_Policy, From2_Policy>(to, x, y, dir);
    }
  }
}
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename Type >
Result Parma_Polyhedra_Library::Checked::idiv_float ( Type &  to,
const Type  x,
const Type  y,
Rounding_Dir  dir 
)
inline

Definition at line 569 of file checked_float.inlines.hh.

References PPL_ASSERT, Parma_Polyhedra_Library::result_class(), Parma_Polyhedra_Library::round_dir(), Parma_Polyhedra_Library::ROUND_NOT_NEEDED, Parma_Polyhedra_Library::ROUND_UP, Type, Parma_Polyhedra_Library::V_EQ, Parma_Polyhedra_Library::V_GE, Parma_Polyhedra_Library::V_LE, and Parma_Polyhedra_Library::VC_NORMAL.

                                                                   {
  Type temp;
  // The inexact check is useless
  dir = round_dir(dir);
  Result r = div<To_Policy, From1_Policy, From2_Policy>(temp, x, y, dir);
  if (result_class(r) != VC_NORMAL) {
    to = temp;
    return r;
  }
  Result r1 = trunc<To_Policy, To_Policy>(to, temp, ROUND_NOT_NEEDED);
  PPL_ASSERT(r1 == V_EQ);
  if (r == V_EQ || to != temp)
    return r1;
  // FIXME: Prove that it is impossible to return a strict relation
  return (dir == ROUND_UP) ? V_LE : V_GE;
}
template<typename To_Policy , typename From1_Policy , typename From2_Policy >
Result Parma_Polyhedra_Library::Checked::idiv_mpq ( mpq_class &  to,
const mpq_class &  x,
const mpq_class &  y,
Rounding_Dir  dir 
)
inline

Definition at line 316 of file checked_mpq.inlines.hh.

References CHECK_P, Parma_Polyhedra_Library::Boundary_NS::sgn(), and Parma_Polyhedra_Library::V_DIV_ZERO.

                                                                                  {
  if (CHECK_P(To_Policy::check_div_zero, sgn(y) == 0)) {
    return assign_nan<To_Policy>(to, V_DIV_ZERO);
  }
  to = x / y;
  return trunc<To_Policy, To_Policy>(to, to, dir);
}
template<typename To_Policy , typename From1_Policy , typename From2_Policy >
Result Parma_Polyhedra_Library::Checked::idiv_mpz ( mpz_class &  to,
const mpz_class &  x,
const mpz_class &  y,
Rounding_Dir   
)
inline

Definition at line 422 of file checked_mpz.inlines.hh.

References CHECK_P, Parma_Polyhedra_Library::Boundary_NS::sgn(), Parma_Polyhedra_Library::V_DIV_ZERO, and Parma_Polyhedra_Library::V_EQ.

                      {
  if (CHECK_P(To_Policy::check_div_zero, ::sgn(y) == 0)) {
    return assign_nan<To_Policy>(to, V_DIV_ZERO);
  }
  mpz_srcptr n = x.get_mpz_t();
  mpz_srcptr d = y.get_mpz_t();
  mpz_tdiv_q(to.get_mpz_t(), n, d);
  return V_EQ;
}
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename Type >
Result Parma_Polyhedra_Library::Checked::idiv_signed_int ( Type &  to,
const Type  x,
const Type  y,
Rounding_Dir  dir 
)
inline

Definition at line 1148 of file checked_int.inlines.hh.

References CHECK_P, Parma_Polyhedra_Library::V_DIV_ZERO, and Parma_Polyhedra_Library::V_EQ.

                                                                        {
  if (CHECK_P(To_Policy::check_div_zero, y == 0)) {
    return assign_nan<To_Policy>(to, V_DIV_ZERO);
  }
  if (To_Policy::check_overflow && y == -1)
    return neg_signed_int<To_Policy, From1_Policy>(to, x, dir);
  to = x / y;
  return V_EQ;
}
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename Type >
Result Parma_Polyhedra_Library::Checked::idiv_unsigned_int ( Type &  to,
const Type  x,
const Type  y,
Rounding_Dir   
)
inline

Definition at line 1161 of file checked_int.inlines.hh.

References CHECK_P, Parma_Polyhedra_Library::V_DIV_ZERO, and Parma_Polyhedra_Library::V_EQ.

                                                                      {
  if (CHECK_P(To_Policy::check_div_zero, y == 0)) {
    return assign_nan<To_Policy>(to, V_DIV_ZERO);
  }
  to = x / y;
  return V_EQ;
}
template<typename Policy , typename Type >
Result Parma_Polyhedra_Library::Checked::input_ext ( Type &  x,
std::istream &  is,
Rounding_Dir  dir 
)
template<typename To_Policy , typename To >
Result Parma_Polyhedra_Library::Checked::input_ext ( To &  to,
std::istream &  is,
Rounding_Dir  dir 
)
inline

Definition at line 915 of file checked_ext.inlines.hh.

                                                    {
  return input<To_Policy>(to, is, dir);
}
template<typename Policy , typename Type >
Result Parma_Polyhedra_Library::Checked::input_generic ( Type &  to,
std::istream &  is,
Rounding_Dir  dir 
)
inline

Definition at line 637 of file checked.inlines.hh.

                                                          {
  PPL_DIRTY_TEMP(mpq_class, q);
  Result r = input_mpq(q, is);
  Result_Class c = result_class(r);
  switch (c) {
  case VC_MINUS_INFINITY:
  case VC_PLUS_INFINITY:
    return assign_special<Policy>(to, c, dir);
  case VC_NAN:
    return assign_nan<Policy>(to, r);
  default:
    break;
  }
  PPL_ASSERT(r == V_EQ);
  return assign<Policy, void>(to, q, dir);
}
Result Parma_Polyhedra_Library::Checked::input_mpq ( mpq_class &  to,
std::istream &  is 
)

Definition at line 389 of file checked.cc.

References Parma_Polyhedra_Library::Checked::number_struct::base, Parma_Polyhedra_Library::Checked::number_struct::base_for_exponent, Parma_Polyhedra_Library::Checked::number_struct::exponent, Parma_Polyhedra_Library::Checked::number_struct::mantissa, Parma_Polyhedra_Library::Checked::number_struct::neg_exponent, Parma_Polyhedra_Library::Checked::number_struct::neg_mantissa, parse_number(), Parma_Polyhedra_Library::V_CVT_STR_UNK, Parma_Polyhedra_Library::V_EQ, and Parma_Polyhedra_Library::V_NAN.

Referenced by assign_mpq_long_double(), assign_mpz_long_double(), and input_mpq().

                                         {
  number_struct numer_struct;
  number_struct denom_struct;
  Result r = parse_number(is, numer_struct, denom_struct);
  if (r == V_CVT_STR_UNK) {
    is.setstate(is.failbit);
    return r;
  }
  is.clear(is.rdstate() & ~is.failbit);
  if (r != V_EQ)
    return r;
  if (denom_struct.base != 0 && denom_struct.mantissa.empty())
      return V_NAN;
  if (numer_struct.mantissa.empty()) {
    to = 0;
    return V_EQ;
  }
  mpz_ptr numer = to.get_num().get_mpz_t();
  mpz_ptr denom = to.get_den().get_mpz_t();
  mpz_set_str(numer, numer_struct.mantissa.c_str(),
              static_cast<int>(numer_struct.base));
  if (denom_struct.base != 0) {
    if (numer_struct.neg_mantissa != denom_struct.neg_mantissa)
      mpz_neg(numer, numer);
    mpz_set_str(denom, denom_struct.mantissa.c_str(),
                static_cast<int>(denom_struct.base));
    if (numer_struct.exponent != 0 || denom_struct.exponent != 0) {
      // Multiply the exponents into the numerator and denominator.
      mpz_t z;
      mpz_init(z);
      if (numer_struct.exponent != 0) {
        mpz_ui_pow_ui(z,
                      numer_struct.base_for_exponent, numer_struct.exponent);
        if (numer_struct.neg_exponent)
          mpz_mul(denom, denom, z);
        else
          mpz_mul(numer, numer, z);
      }
      if (denom_struct.exponent != 0) {
        mpz_ui_pow_ui(z,
                      denom_struct.base_for_exponent, denom_struct.exponent);
        if (denom_struct.neg_exponent)
          mpz_mul(numer, numer, z);
        else
          mpz_mul(denom, denom, z);
      }
      mpz_clear(z);
    }
  }
  else {
    if (numer_struct.neg_mantissa)
      mpz_neg(numer, numer);
    if (numer_struct.exponent != 0) {
      if (numer_struct.neg_exponent) {
        // Add the negative exponent as a denominator.
        mpz_ui_pow_ui(denom,
                      numer_struct.base_for_exponent, numer_struct.exponent);
        goto end;
      }
      // Multiply the exponent into the numerator.
      mpz_t z;
      mpz_init(z);
      mpz_ui_pow_ui(z,
                    numer_struct.base_for_exponent, numer_struct.exponent);
      mpz_mul(numer, numer, z);
      mpz_clear(z);
    }
    mpz_set_ui(denom, 1);
    return V_EQ;
  }
 end:
  // GMP operators require rationals in canonical form.
  to.canonicalize();
  return V_EQ;
}
template<typename Policy >
Result Parma_Polyhedra_Library::Checked::input_mpq ( mpq_class &  to,
std::istream &  is,
Rounding_Dir  dir 
)
inline

Definition at line 485 of file checked_mpq.inlines.hh.

References c, input_mpq(), Parma_Polyhedra_Library::result_class(), Parma_Polyhedra_Library::VC_MINUS_INFINITY, Parma_Polyhedra_Library::VC_NAN, and Parma_Polyhedra_Library::VC_PLUS_INFINITY.

                                                           {
  Result r = input_mpq(to, is);
  Result_Class c = result_class(r);
  switch (c) {
  case VC_MINUS_INFINITY:
  case VC_PLUS_INFINITY:
    return assign_special<Policy>(to, c, dir);
  case VC_NAN:
    return assign_nan<Policy>(to, r);
  default:
    return r;
  }
}
template<typename Policy , typename T >
bool Parma_Polyhedra_Library::Checked::is_inf_float ( const T  v)
inline

Definition at line 185 of file checked_float.inlines.hh.

References CHECK_P.

                        {
  Float<T> f(v);
  return CHECK_P(Policy::has_infinity, (f.u.binary.inf_sign() != 0));
}
template<typename Policy , typename T >
bool Parma_Polyhedra_Library::Checked::is_int_float ( const T  v)
inline

Definition at line 206 of file checked_float.inlines.hh.

References round_to_integer().

                        {
  return round_to_integer(v) == v;
}
template<typename Policy , typename Type >
bool Parma_Polyhedra_Library::Checked::is_int_int ( const Type  v)
inline

Definition at line 290 of file checked_int.inlines.hh.

                         {
  return !is_nan<Policy>(v);
}
template<typename Policy >
bool Parma_Polyhedra_Library::Checked::is_int_mpq ( const mpq_class &  v)
inline

Definition at line 91 of file checked_mpq.inlines.hh.

References Parma_Polyhedra_Library::Boundary_NS::sgn().

                               {
  if ((Policy::has_infinity || Policy::has_nan)
      && ::sgn(v.get_den()) == 0)
    return !(Policy::has_nan && ::sgn(v.get_num()) == 0);
  else
    return v.get_den() == 1;
}
template<typename Policy >
bool Parma_Polyhedra_Library::Checked::is_int_mpz ( const mpz_class &  v)
inline

Definition at line 125 of file checked_mpz.inlines.hh.

                               {
  return !is_nan<Policy>(v);
}
template<typename Policy , typename T >
bool Parma_Polyhedra_Library::Checked::is_minf_float ( const T  v)
inline

Definition at line 191 of file checked_float.inlines.hh.

References CHECK_P.

                         {
  Float<T> f(v);
  return CHECK_P(Policy::has_infinity, (f.u.binary.inf_sign() < 0));
}
template<typename Policy , typename Type >
bool Parma_Polyhedra_Library::Checked::is_minf_int ( const Type  v)
inline

Definition at line 252 of file checked_int.inlines.hh.

                          {
  return Policy::has_infinity
    && v == Extended_Int<Policy, Type>::minus_infinity;
}
template<typename Policy >
bool Parma_Polyhedra_Library::Checked::is_minf_mpq ( const mpq_class &  v)
inline

Definition at line 71 of file checked_mpq.inlines.hh.

References Parma_Polyhedra_Library::Boundary_NS::sgn().

                                {
  return Policy::has_infinity
    && ::sgn(v.get_den()) == 0
    && ::sgn(v.get_num()) < 0;
}
template<typename Policy >
bool Parma_Polyhedra_Library::Checked::is_minf_mpz ( const mpz_class &  v)
inline

Definition at line 107 of file checked_mpz.inlines.hh.

References get_mp_size().

                                {
  return Policy::has_infinity
    && get_mp_size(v) == C_Integer<mp_size_field_t>::min;
}
template<typename Policy , typename T >
bool Parma_Polyhedra_Library::Checked::is_nan_float ( const T  v)
inline

Definition at line 178 of file checked_float.inlines.hh.

References CHECK_P.

                        {
  Float<T> f(v);
  return CHECK_P(Policy::has_nan, f.u.binary.is_nan());
}
template<typename Policy , typename Type >
bool Parma_Polyhedra_Library::Checked::is_nan_int ( const Type  v)
inline

Definition at line 234 of file checked_int.inlines.hh.

                         {
  return Policy::has_nan && v == Extended_Int<Policy, Type>::not_a_number;
}
template<typename Policy >
bool Parma_Polyhedra_Library::Checked::is_nan_mpq ( const mpq_class &  v)
inline

Definition at line 61 of file checked_mpq.inlines.hh.

References Parma_Polyhedra_Library::Boundary_NS::sgn().

                               {
  return Policy::has_nan
    && ::sgn(v.get_den()) == 0
    && ::sgn(v.get_num()) == 0;
}
template<typename Policy >
bool Parma_Polyhedra_Library::Checked::is_nan_mpz ( const mpz_class &  v)
inline

Definition at line 98 of file checked_mpz.inlines.hh.

References get_mp_size().

                               {
  return Policy::has_nan
    && get_mp_size(v) == C_Integer<mp_size_field_t>::min + 1;
}
template<typename Policy , typename T >
bool Parma_Polyhedra_Library::Checked::is_pinf_float ( const T  v)
inline

Definition at line 198 of file checked_float.inlines.hh.

References CHECK_P.

                         {
  Float<T> f(v);
  return CHECK_P(Policy::has_infinity, (f.u.binary.inf_sign() > 0));
}
template<typename Policy , typename Type >
bool Parma_Polyhedra_Library::Checked::is_pinf_int ( const Type  v)
inline

Definition at line 271 of file checked_int.inlines.hh.

                          {
  return Policy::has_infinity
    && v == Extended_Int<Policy, Type>::plus_infinity;
}
template<typename Policy >
bool Parma_Polyhedra_Library::Checked::is_pinf_mpq ( const mpq_class &  v)
inline

Definition at line 81 of file checked_mpq.inlines.hh.

References Parma_Polyhedra_Library::Boundary_NS::sgn().

                                {
  return Policy::has_infinity
    && ::sgn(v.get_den()) == 0
    && ::sgn(v.get_num()) > 0;
}
template<typename Policy >
bool Parma_Polyhedra_Library::Checked::is_pinf_mpz ( const mpz_class &  v)
inline

Definition at line 116 of file checked_mpz.inlines.hh.

References get_mp_size().

                                {
  return Policy::has_infinity
    && get_mp_size(v) == C_Integer<mp_size_field_t>::max;
}
template<typename Type >
void Parma_Polyhedra_Library::Checked::isqrt_rem ( Type &  q,
Type &  r,
const Type  from 
)
inline

Definition at line 1443 of file checked_int.inlines.hh.

References sizeof_to_bits, and Type.

Referenced by sqrt_unsigned_int().

                                             {
  q = 0;
  r = from;
  Type t(1);
  for (t <<= sizeof_to_bits(sizeof(Type)) - 2; t != 0; t >>= 2) {
    Type s = q + t;
    if (s <= r) {
      r -= s;
      q = s + t;
    }
    q >>= 1;
  }
}
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename To , typename From1 , typename From2 >
Result Parma_Polyhedra_Library::Checked::lcm_ext ( To &  to,
const From1 &  x,
const From2 &  y,
Rounding_Dir  dir 
)
inline

Definition at line 788 of file checked_ext.inlines.hh.

References Parma_Polyhedra_Library::ROUND_IGNORE, Parma_Polyhedra_Library::VC_NAN, and Parma_Polyhedra_Library::VC_PLUS_INFINITY.

                                                                  {
  if (is_nan<From1_Policy>(x) || is_nan<From2_Policy>(y))
    return assign_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
  else if (is_minf<From1_Policy>(x) || is_pinf<From1_Policy>(x)
           || is_minf<From2_Policy>(y) || is_pinf<From2_Policy>(y))
    return assign_special<To_Policy>(to, VC_PLUS_INFINITY, dir);
  else
    return lcm<To_Policy, From1_Policy, From2_Policy>(to, x, y, dir);
}
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename To , typename From1 , typename From2 >
Result Parma_Polyhedra_Library::Checked::lcm_gcd_exact ( To &  to,
const From1 &  x,
const From2 &  y,
Rounding_Dir  dir 
)
inline

Definition at line 412 of file checked.inlines.hh.

References Parma_Polyhedra_Library::ROUND_NOT_NEEDED, To, and Parma_Polyhedra_Library::V_EQ.

                                                                        {
  if (x == 0 || y == 0) {
    to = 0;
    return V_EQ;
  }
  To a_x;
  To a_y;
  Result r;
  r = abs<From1_Policy, From1_Policy>(a_x, x, dir);
  if (r != V_EQ)
    return r;
  r = abs<From2_Policy, From2_Policy>(a_y, y, dir);
  if (r != V_EQ)
    return r;
  To gcd;
  gcd_exact_no_abs<To_Policy, From1_Policy, From2_Policy>(gcd, a_x, a_y);
  // The following is derived from the assumption that a_x / gcd(a_x, a_y)
  // is always representable. This is true for both native integers
  // and IEC 559 floating point numbers.
  div<To_Policy, From1_Policy, To_Policy>(to, a_x, gcd, ROUND_NOT_NEEDED);
  return mul<To_Policy, To_Policy, From2_Policy>(to, to, a_y, dir);
}
template<typename To_Policy , typename From1_Policy , typename From2_Policy >
Result Parma_Polyhedra_Library::Checked::lcm_mpz ( mpz_class &  to,
const mpz_class &  x,
const mpz_class &  y,
Rounding_Dir   
)
inline

Definition at line 584 of file checked_mpz.inlines.hh.

References Parma_Polyhedra_Library::V_EQ.

                                                                             {
  mpz_lcm(to.get_mpz_t(), x.get_mpz_t(), y.get_mpz_t());
  return V_EQ;
}
template<typename T1 , typename T2 >
Enable_If<(Safe_Int_Comparison<T1, T2>::value || Safe_Conversion<T1, T2>::value || Safe_Conversion<T2, T1>::value), bool>::type Parma_Polyhedra_Library::Checked::le ( const T1 &  x,
const T2 &  y 
)
inline

Definition at line 472 of file checked.inlines.hh.

                             {
  return x <= y;
}
template<typename Policy1 , typename Policy2 , typename Type1 , typename Type2 >
bool Parma_Polyhedra_Library::Checked::le_ext ( const Type1 &  x,
const Type2 &  y 
)
inline

Definition at line 846 of file checked_ext.inlines.hh.

                                       {
  if (!ext_to_handle<Policy1>(x) && !ext_to_handle<Policy2>(y))
    goto native;
  if (is_nan<Policy1>(x) || is_nan<Policy2>(y))
    return false;
  if (is_minf<Policy1>(x) || is_pinf<Policy2>(y))
    return true;
  if (is_pinf<Policy1>(x) || is_minf<Policy2>(y))
    return false;
 native:
  return le_p<Policy1, Policy2>(x, y);
}
template<typename Policy1 , typename Policy2 , typename Type1 , typename Type2 >
bool Parma_Polyhedra_Library::Checked::le_p ( const Type1 &  x,
const Type2 &  y 
)
inline

Definition at line 606 of file checked.inlines.hh.

                                     {
  return le(x, y);
}
void Parma_Polyhedra_Library::Checked::limit_precision ( const double &  v)
inline

Definition at line 141 of file checked_float.inlines.hh.

References Parma_Polyhedra_Library::PPL_CC_FLUSH().

                                 {
  PPL_CC_FLUSH(v);
}
void Parma_Polyhedra_Library::Checked::limit_precision ( const long double &  )
inline

Definition at line 146 of file checked_float.inlines.hh.

                                    {
}
template<typename T1 , typename T2 >
Enable_If<(Safe_Int_Comparison<T1, T2>::value || Safe_Conversion<T1, T2>::value || Safe_Conversion<T2, T1>::value), bool>::type Parma_Polyhedra_Library::Checked::lt ( const T1 &  x,
const T2 &  y 
)
inline

Definition at line 465 of file checked.inlines.hh.

                             {
  return x < y;
}
template<typename Policy1 , typename Policy2 , typename Type1 , typename Type2 >
bool Parma_Polyhedra_Library::Checked::lt_ext ( const Type1 &  x,
const Type2 &  y 
)
inline

Definition at line 823 of file checked_ext.inlines.hh.

                                       {
  if (!ext_to_handle<Policy1>(x) && !ext_to_handle<Policy2>(y))
    goto native;
  if (is_nan<Policy1>(x) || is_nan<Policy2>(y))
    return false;
  if (is_pinf<Policy1>(x) || is_minf<Policy2>(y))
    return false;
  if (is_minf<Policy1>(x) || is_pinf<Policy2>(y))
    return true;
 native:
  return lt_p<Policy1, Policy2>(x, y);
}
template<typename Policy1 , typename Policy2 , typename Type1 , typename Type2 >
bool Parma_Polyhedra_Library::Checked::lt_p ( const Type1 &  x,
const Type2 &  y 
)
inline

Definition at line 599 of file checked.inlines.hh.

                                     {
  return lt(x, y);
}
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result Parma_Polyhedra_Library::Checked::mul_2exp_ext ( To &  to,
const From &  x,
unsigned int  exp,
Rounding_Dir  dir 
)
inline

Definition at line 660 of file checked_ext.inlines.hh.

References Parma_Polyhedra_Library::ROUND_IGNORE, Parma_Polyhedra_Library::VC_MINUS_INFINITY, Parma_Polyhedra_Library::VC_NAN, and Parma_Polyhedra_Library::VC_PLUS_INFINITY.

                                                                        {
  if (!ext_to_handle<From_Policy>(x))
    goto native;
  if (is_nan<From_Policy>(x))
    return assign_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
  else if (is_minf<From_Policy>(x))
    return assign_special<To_Policy>(to, VC_MINUS_INFINITY, dir);
  else if (is_pinf<From_Policy>(x))
    return assign_special<To_Policy>(to, VC_PLUS_INFINITY, dir);
  else {
  native:
    return mul_2exp<To_Policy, From_Policy>(to, x, exp, dir);
  }
}
template<typename To_Policy , typename From_Policy , typename Type >
Result Parma_Polyhedra_Library::Checked::mul_2exp_float ( Type &  to,
const Type  x,
unsigned int  exp,
Rounding_Dir  dir 
)
inline

Definition at line 635 of file checked_float.inlines.hh.

References PPL_ASSERT, Parma_Polyhedra_Library::ROUND_IGNORE, sizeof_to_bits, Type, and Parma_Polyhedra_Library::VC_NAN.

                                                                           {
  if (To_Policy::fpu_check_nan_result && is_nan<From_Policy>(x))
    return assign_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
  PPL_ASSERT(exp < sizeof_to_bits(sizeof(unsigned long long)));
  return
    mul<To_Policy, From_Policy, Float_2exp>(to,
                                            x,
                                            Type(1ULL << exp),
                                            dir);
}
template<typename To_Policy , typename From_Policy >
Result Parma_Polyhedra_Library::Checked::mul_2exp_mpq ( mpq_class &  to,
const mpq_class &  x,
unsigned int  exp,
Rounding_Dir   
)
inline

Definition at line 369 of file checked_mpq.inlines.hh.

References Parma_Polyhedra_Library::V_EQ.

                           {
  mpz_mul_2exp(to.get_num().get_mpz_t(), x.get_num().get_mpz_t(), exp);
  to.get_den() = x.get_den();
  to.canonicalize();
  return V_EQ;
}
template<typename To_Policy , typename From_Policy >
Result Parma_Polyhedra_Library::Checked::mul_2exp_mpz ( mpz_class &  to,
const mpz_class &  x,
unsigned int  exp,
Rounding_Dir   
)
inline

Definition at line 475 of file checked_mpz.inlines.hh.

References Parma_Polyhedra_Library::V_EQ.

                           {
  mpz_mul_2exp(to.get_mpz_t(), x.get_mpz_t(), exp);
  return V_EQ;
}
template<typename To_Policy , typename From_Policy , typename Type >
Result Parma_Polyhedra_Library::Checked::mul_2exp_signed_int ( Type &  to,
const Type  x,
unsigned int  exp,
Rounding_Dir  dir 
)
inline

Definition at line 1351 of file checked_int.inlines.hh.

References PPL_GT_SILENT, PPL_LT_SILENT, sizeof_to_bits, Type, and Parma_Polyhedra_Library::V_EQ.

                                      {
  if (!To_Policy::check_overflow) {
    to = x << exp;
    return V_EQ;
  }
  if (exp >= sizeof_to_bits(sizeof(Type)) - 1) {
    if (x < 0)
      return set_neg_overflow_int<To_Policy>(to, dir);
    else if (x > 0)
      return set_pos_overflow_int<To_Policy>(to, dir);
    else {
      to = 0;
      return V_EQ;
    }
  }
  Type mask = ((Type(1) << exp) - 1) << ((sizeof_to_bits(sizeof(Type)) - 1) - exp);
  Type n;
  if (x < 0) {
    if ((x & mask) != mask)
      return set_neg_overflow_int<To_Policy>(to, dir);
    n = x << exp;
    if (PPL_LT_SILENT(n, (Extended_Int<To_Policy, Type>::min)))
      return set_neg_overflow_int<To_Policy>(to, dir);
  }
  else {
    if (x & mask)
      return set_pos_overflow_int<To_Policy>(to, dir);
    n = x << exp;
    if (PPL_GT_SILENT(n, (Extended_Int<To_Policy, Type>::max)))
      return set_pos_overflow_int<To_Policy>(to, dir);
  }
  to = n;
  return V_EQ;
}
template<typename To_Policy , typename From_Policy , typename Type >
Result Parma_Polyhedra_Library::Checked::mul_2exp_unsigned_int ( Type &  to,
const Type  x,
unsigned int  exp,
Rounding_Dir  dir 
)
inline

Definition at line 1327 of file checked_int.inlines.hh.

References PPL_GT_SILENT, sizeof_to_bits, Type, and Parma_Polyhedra_Library::V_EQ.

                                        {
  if (!To_Policy::check_overflow) {
    to = x << exp;
    return V_EQ;
  }
  if (exp >= sizeof_to_bits(sizeof(Type))) {
    if (x == 0) {
      to = 0;
      return V_EQ;
    }
    return set_pos_overflow_int<To_Policy>(to, dir);
  }
  if (x & (((Type(1) << exp) - 1) << (sizeof_to_bits(sizeof(Type)) - exp)))
    return set_pos_overflow_int<To_Policy>(to, dir);
  Type n = x << exp;
  if (PPL_GT_SILENT(n, (Extended_Int<To_Policy, Type>::max)))
    return set_pos_overflow_int<To_Policy>(to, dir);
  to = n;
  return V_EQ;
}
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename To , typename From1 , typename From2 >
Result Parma_Polyhedra_Library::Checked::mul_ext ( To &  to,
const From1 &  x,
const From2 &  y,
Rounding_Dir  dir 
)
inline

Definition at line 269 of file checked_ext.inlines.hh.

References PPL_ASSERT, Parma_Polyhedra_Library::ROUND_IGNORE, Parma_Polyhedra_Library::V_INF_MUL_ZERO, Parma_Polyhedra_Library::VC_MINUS_INFINITY, Parma_Polyhedra_Library::VC_NAN, Parma_Polyhedra_Library::VC_PLUS_INFINITY, Parma_Polyhedra_Library::VR_GT, and Parma_Polyhedra_Library::VR_LT.

                                                                  {
  if (!ext_to_handle<From1_Policy>(x) && !ext_to_handle<From2_Policy>(y))
    goto native;
  if (is_nan<From1_Policy>(x) || is_nan<From2_Policy>(y))
    return assign_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
  if (is_minf<From1_Policy>(x)) {
    switch (sgn_ext<From2_Policy>(y)) {
    case VR_LT:
      goto pinf;
    case VR_GT:
      goto minf;
    default:
      goto inf_mul_zero;
    }
  }
  else if (is_pinf<From1_Policy>(x)) {
    switch (sgn_ext<From2_Policy>(y)) {
    case VR_LT:
      goto minf;
    case VR_GT:
      goto pinf;
    default:
      goto inf_mul_zero;
    }
  }
  else {
    if (is_minf<From2_Policy>(y)) {
      switch (sgn<From1_Policy>(x)) {
      case VR_LT:
        goto pinf;
      case VR_GT:
        goto minf;
      default:
        goto inf_mul_zero;
      }
    }
    else if (is_pinf<From2_Policy>(y)) {
      switch (sgn<From1_Policy>(x)) {
      case VR_LT:
      minf:
        return assign_special<To_Policy>(to, VC_MINUS_INFINITY, dir);
      case VR_GT:
      pinf:
        return assign_special<To_Policy>(to, VC_PLUS_INFINITY, dir);
      default:
      inf_mul_zero:
        PPL_ASSERT(To_Policy::check_inf_mul_zero);
        return assign_nan<To_Policy>(to, V_INF_MUL_ZERO);
      }
    }
    else {
    native:
      return mul<To_Policy, From1_Policy, From2_Policy>(to, x, y, dir);
    }
  }
}
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename Type >
Result Parma_Polyhedra_Library::Checked::mul_float ( Type &  to,
const Type  x,
const Type  y,
Rounding_Dir  dir 
)
inline

Definition at line 504 of file checked_float.inlines.hh.

References fpu_direct_rounding(), fpu_inverse_rounding(), Parma_Polyhedra_Library::fpu_restore_rounding_direction(), Parma_Polyhedra_Library::fpu_save_rounding_direction(), limit_precision(), Parma_Polyhedra_Library::round_fpu_dir(), Parma_Polyhedra_Library::V_INF_MUL_ZERO, and Parma_Polyhedra_Library::V_NAN.

                                                                  {
  if (To_Policy::check_inf_mul_zero
      && ((x == 0 && is_inf_float<From2_Policy>(y))
          ||
          (y == 0 && is_inf_float<From1_Policy>(x)))) {
    return assign_nan<To_Policy>(to, V_INF_MUL_ZERO);
  }
  prepare_inexact<To_Policy>(dir);
  if (fpu_direct_rounding(dir))
    to = x * y;
  else if (fpu_inverse_rounding(dir)) {
    to = x * -y;
    limit_precision(to);
    to = -to;
  }
  else {
    fpu_rounding_control_word_type old
      = fpu_save_rounding_direction(round_fpu_dir(dir));
    limit_precision(x);
    limit_precision(y);
    to = x * y;
    limit_precision(to);
    fpu_restore_rounding_direction(old);
  }
  if (To_Policy::fpu_check_nan_result && is_nan<To_Policy>(to))
    return V_NAN;
  return result_relation<To_Policy>(dir);
}
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename Type >
Result Parma_Polyhedra_Library::Checked::mul_int_larger ( Type &  to,
const Type  x,
const Type  y,
Rounding_Dir  dir 
)
inline

Definition at line 955 of file checked_int.inlines.hh.

                                                                       {
  typename Larger<Type>::type_for_mul l = x;
  l *= y;
  return assign<To_Policy, To_Policy>(to, l, dir);
}
template<typename To_Policy , typename From1_Policy , typename From2_Policy >
Result Parma_Polyhedra_Library::Checked::mul_mpq ( mpq_class &  to,
const mpq_class &  x,
const mpq_class &  y,
Rounding_Dir   
)
inline

Definition at line 295 of file checked_mpq.inlines.hh.

References Parma_Polyhedra_Library::V_EQ.

                                                                             {
  to = x * y;
  return V_EQ;
}
template<typename To_Policy , typename From1_Policy , typename From2_Policy >
Result Parma_Polyhedra_Library::Checked::mul_mpz ( mpz_class &  to,
const mpz_class &  x,
const mpz_class &  y,
Rounding_Dir   
)
inline

Definition at line 379 of file checked_mpz.inlines.hh.

References Parma_Polyhedra_Library::V_EQ.

                                                                             {
  to = x * y;
  return V_EQ;
}
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename Type >
Result Parma_Polyhedra_Library::Checked::mul_signed_int ( Type &  to,
const Type  x,
const Type  y,
Rounding_Dir  dir 
)
inline

Definition at line 1049 of file checked_int.inlines.hh.

References Parma_Polyhedra_Library::V_EQ.

                                                                       {
  if (To_Policy::check_overflow && Larger<Type>::use_for_mul)
    return mul_int_larger<To_Policy, From1_Policy, From2_Policy>(to, x, y, dir);
  if (!To_Policy::check_overflow) {
    to = x * y;
    return V_EQ;
  }
  if (y == 0) {
    to = 0;
    return V_EQ;
  }
  if (y == -1)
    return neg_signed_int<To_Policy, From1_Policy>(to, x, dir);
  if (x >= 0) {
    if (y > 0) {
      if (x > Extended_Int<To_Policy, Type>::max / y)
        return set_pos_overflow_int<To_Policy>(to, dir);
    }
    else {
      if (x > Extended_Int<To_Policy, Type>::min / y)
        return set_neg_overflow_int<To_Policy>(to, dir);
    }
  }
  else {
    if (y < 0) {
      if (x < Extended_Int<To_Policy, Type>::max / y)
        return set_pos_overflow_int<To_Policy>(to, dir);
    }
    else {
      if (x < Extended_Int<To_Policy, Type>::min / y)
        return set_neg_overflow_int<To_Policy>(to, dir);
    }
  }
  to = x * y;
  return V_EQ;
}
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename Type >
Result Parma_Polyhedra_Library::Checked::mul_unsigned_int ( Type &  to,
const Type  x,
const Type  y,
Rounding_Dir  dir 
)
inline

Definition at line 1089 of file checked_int.inlines.hh.

References Parma_Polyhedra_Library::V_EQ.

                                                                         {
  if (To_Policy::check_overflow && Larger<Type>::use_for_mul)
    return mul_int_larger<To_Policy, From1_Policy, From2_Policy>(to, x, y, dir);
  if (!To_Policy::check_overflow) {
    to = x * y;
    return V_EQ;
  }
  if (y == 0) {
    to = 0;
    return V_EQ;
  }
  if (x > Extended_Int<To_Policy, Type>::max / y)
    return set_pos_overflow_int<To_Policy>(to, dir);
  to = x * y;
  return V_EQ;
}
float Parma_Polyhedra_Library::Checked::multiply_add ( float  x,
float  y,
float  z 
)
inline

Definition at line 37 of file checked_float.inlines.hh.

Referenced by add_mul_float(), and sub_mul_float().

                                        {
#if PPL_HAVE_DECL_FMAF && defined(FP_FAST_FMAF) \
  && !defined(__alpha) && !defined(__FreeBSD__)
  return fmaf(x, y, z);
#else
  return x*y + z;
#endif
}
double Parma_Polyhedra_Library::Checked::multiply_add ( double  x,
double  y,
double  z 
)
inline

Definition at line 47 of file checked_float.inlines.hh.

                                           {
#if PPL_HAVE_DECL_FMA && defined(FP_FAST_FMA) \
  && !defined(__alpha) && !defined(__FreeBSD__)
  return fma(x, y, z);
#else
  return x*y + z;
#endif
}
long double Parma_Polyhedra_Library::Checked::multiply_add ( long double  x,
long double  y,
long double  z 
)
inline

Definition at line 57 of file checked_float.inlines.hh.

                                                          {
#if PPL_HAVE_DECL_FMAL && defined(FP_FAST_FMAL) \
  && !defined(__alpha) && !defined(__FreeBSD__)
  return fmal(x, y, z);
#else
  return x*y + z;
#endif
}
template<typename Policy1 , typename Policy2 , typename Type1 , typename Type2 >
bool Parma_Polyhedra_Library::Checked::ne_ext ( const Type1 &  x,
const Type2 &  y 
)
inline

Definition at line 887 of file checked_ext.inlines.hh.

                                       {
  return !eq_ext<Policy1, Policy2>(x, y);
}
template<typename To_Policy , typename From_Policy , typename To , typename From >
Result Parma_Polyhedra_Library::Checked::neg_ext ( To &  to,
const From &  x,
Rounding_Dir  dir 
)
inline

Definition at line 105 of file checked_ext.inlines.hh.

References Parma_Polyhedra_Library::ROUND_IGNORE, Parma_Polyhedra_Library::VC_MINUS_INFINITY, Parma_Polyhedra_Library::VC_NAN, and Parma_Polyhedra_Library::VC_PLUS_INFINITY.

                                                 {
  if (!ext_to_handle<From_Policy>(x))
    goto native;
  if (is_nan<From_Policy>(x))
    return assign_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
  else if (is_minf<From_Policy>(x))
    return assign_special<To_Policy>(to, VC_PLUS_INFINITY, dir);
  else if (is_pinf<From_Policy>(x))
    return assign_special<To_Policy>(to, VC_MINUS_INFINITY, dir);
  else {
  native:
    return neg<To_Policy, From_Policy>(to, x, dir);
  }
}
template<typename To_Policy , typename From_Policy , typename Type >
Result Parma_Polyhedra_Library::Checked::neg_float ( Type &  to,
const Type  from,
Rounding_Dir   
)
inline

Definition at line 434 of file checked_float.inlines.hh.

References Parma_Polyhedra_Library::ROUND_IGNORE, Parma_Polyhedra_Library::V_EQ, and Parma_Polyhedra_Library::VC_NAN.

                                                   {
  if (To_Policy::fpu_check_nan_result && is_nan<From_Policy>(from))
    return assign_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
  to = -from;
  return V_EQ;
}
template<typename To_Policy , typename From_Policy , typename Type >
Result Parma_Polyhedra_Library::Checked::neg_int_larger ( Type &  to,
const Type  x,
Rounding_Dir  dir 
)
inline

Definition at line 928 of file checked_int.inlines.hh.

                                                         {
  typename Larger<Type>::type_for_neg l = x;
  l = -l;
  return assign<To_Policy, To_Policy>(to, l, dir);
}
template<typename To_Policy , typename From_Policy >
Result Parma_Polyhedra_Library::Checked::neg_mpq ( mpq_class &  to,
const mpq_class &  from,
Rounding_Dir   
)
inline

Definition at line 268 of file checked_mpq.inlines.hh.

References Parma_Polyhedra_Library::V_EQ.

                                                            {
  mpq_neg(to.get_mpq_t(), from.get_mpq_t());
  return V_EQ;
}
template<typename To_Policy , typename From_Policy >
Result Parma_Polyhedra_Library::Checked::neg_mpz ( mpz_class &  to,
const mpz_class &  from,
Rounding_Dir   
)
inline

Definition at line 352 of file checked_mpz.inlines.hh.

References Parma_Polyhedra_Library::V_EQ.

                                                            {
  mpz_neg(to.get_mpz_t(), from.get_mpz_t());
  return V_EQ;
}
template<typename To_Policy , typename From_Policy , typename Type >
Result Parma_Polyhedra_Library::Checked::neg_signed_int ( Type &  to,
const Type  from,
Rounding_Dir  dir 
)
inline

Definition at line 963 of file checked_int.inlines.hh.

References CHECK_P, and Parma_Polyhedra_Library::V_EQ.

                                                            {
  if (To_Policy::check_overflow && Larger<Type>::use_for_neg)
    return neg_int_larger<To_Policy, From_Policy>(to, from, dir);
  if (CHECK_P(To_Policy::check_overflow,
              (from < -Extended_Int<To_Policy, Type>::max)))
    return set_pos_overflow_int<To_Policy>(to, dir);
  to = -from;
  return V_EQ;
}
template<typename To_Policy , typename From_Policy , typename Type >
Result Parma_Polyhedra_Library::Checked::neg_unsigned_int ( Type &  to,
const Type  from,
Rounding_Dir  dir 
)
inline

Definition at line 975 of file checked_int.inlines.hh.

References CHECK_P, and Parma_Polyhedra_Library::V_EQ.

                                                              {
  if (To_Policy::check_overflow && Larger<Type>::use_for_neg)
    return neg_int_larger<To_Policy, From_Policy>(to, from, dir);
  if (CHECK_P(To_Policy::check_overflow, from != 0))
    return set_neg_overflow_int<To_Policy>(to, dir);
  to = from;
  return V_EQ;
}
template<typename Policy , typename Type >
Result Parma_Polyhedra_Library::Checked::output_char ( std::ostream &  os,
Type &  from,
const Numeric_Format &  ,
Rounding_Dir   
)
inline

Definition at line 1526 of file checked_int.inlines.hh.

References int, and Parma_Polyhedra_Library::V_EQ.

                                                 {
  os << int(from);
  return V_EQ;
}
template<typename Policy , typename Type >
Result Parma_Polyhedra_Library::Checked::output_ext ( std::ostream &  os,
const Type &  x,
const Numeric_Format &  format,
Rounding_Dir  dir 
)
inline

Definition at line 893 of file checked_ext.inlines.hh.

References Parma_Polyhedra_Library::V_EQ, and Parma_Polyhedra_Library::V_NAN.

Referenced by Parma_Polyhedra_Library::Checked_Number< T, Policy >::output().

                                                           {
  if (!ext_to_handle<Policy>(x))
    goto native;
  if (is_nan<Policy>(x)) {
    os << "nan";
    return V_NAN;
  }
  if (is_minf<Policy>(x)) {
    os << "-inf";
    return V_EQ;
  }
  if (is_pinf<Policy>(x)) {
    os << "+inf";
    return V_EQ;
  }
 native:
  return output<Policy>(os, x, format, dir);
}
template<typename Policy , typename Type >
Result Parma_Polyhedra_Library::Checked::output_float ( std::ostream &  os,
const Type  from,
const Numeric_Format &  ,
Rounding_Dir   
)
inline

Definition at line 999 of file checked_float.inlines.hh.

References Parma_Polyhedra_Library::V_EQ.

                           {
  if (from == 0)
    os << "0";
  else if (is_minf<Policy>(from))
    os << "-inf";
  else if (is_pinf<Policy>(from))
    os << "+inf";
  else if (is_nan<Policy>(from))
    os << "nan";
  else {
    std::streamsize old_precision = os.precision(10000);
    // FIXME: here correctness depends on the behavior of the standard
    // output operator which, in turn, may depend on the behavior
    // of printf().  The C99 standard, 7.19.16.1#13, does not give
    // enough guarantees.  We could not find something similar
    // in the C++ standard, so there is a concrete danger here.
    os << from;
    os.precision(old_precision);
  }
  return V_EQ;
}
template<typename Policy , typename Type >
Result Parma_Polyhedra_Library::Checked::output_int ( std::ostream &  os,
Type &  from,
const Numeric_Format &  ,
Rounding_Dir   
)
inline

Definition at line 1534 of file checked_int.inlines.hh.

References Parma_Polyhedra_Library::V_EQ.

                                                                            {
  os << from;
  return V_EQ;
}
template<typename Policy >
Result Parma_Polyhedra_Library::Checked::output_mpq ( std::ostream &  os,
const mpq_class &  from,
const Numeric_Format &  ,
Rounding_Dir   
)
inline

Definition at line 503 of file checked_mpq.inlines.hh.

References Parma_Polyhedra_Library::V_EQ.

                         {
  os << from;
  return V_EQ;
}
template<typename Policy >
Result Parma_Polyhedra_Library::Checked::output_mpz ( std::ostream &  os,
const mpz_class &  from,
const Numeric_Format &  ,
Rounding_Dir   
)
inline

Definition at line 632 of file checked_mpz.inlines.hh.

References Parma_Polyhedra_Library::V_EQ.

                         {
  os << from;
  return V_EQ;
}
Result Parma_Polyhedra_Library::Checked::parse_number ( std::istream &  is,
number_struct &  numer,
number_struct &  denom 
)

Definition at line 349 of file checked.cc.

References Parma_Polyhedra_Library::Checked::number_struct::base, Parma_Polyhedra_Library::Checked::number_struct::base_for_exponent, c, Parma_Polyhedra_Library::Checked::number_struct::exponent, Parma_Polyhedra_Library::Checked::number_struct::neg_exponent, parse_number_part(), sum_sign(), Parma_Polyhedra_Library::V_CVT_STR_UNK, and Parma_Polyhedra_Library::V_EQ.

Referenced by input_mpq().

                                                                         {
  // Read the numerator.
  Result r = parse_number_part(is, numer);
  if (r != V_EQ)
    return r;
  char c;
  is.get(c);
  if (is.bad())
    return V_CVT_STR_UNK;
  if (!is) {
    denom.base = 0;
    return r;
  }
  if (c != '/') {
    is.unget();
    denom.base = 0;
    return r;
  }
  // Read the denominator.
  r = parse_number_part(is, denom);
  if (r != V_EQ)
    return V_CVT_STR_UNK;
  if (numer.base == denom.base
      && numer.base_for_exponent == denom.base_for_exponent) {
    if (sum_sign(numer.neg_exponent, numer.exponent,
                 !denom.neg_exponent, denom.exponent)) {
      if (numer.neg_exponent) {
        denom.neg_exponent = false;
        denom.exponent = numer.exponent;
        numer.exponent = 0;
      }
      else
        denom.exponent = 0;
    }
  }
  return V_EQ;
}
Result Parma_Polyhedra_Library::Checked::parse_number_part ( std::istream &  is,
number_struct &  numer 
)

Helper function for parse_number(): reads the numerator or denominator part of a number from is into numer, returning the appropriate Result value.

Definition at line 132 of file checked.cc.

References Parma_Polyhedra_Library::Checked::number_struct::base, Parma_Polyhedra_Library::Checked::number_struct::base_for_exponent, c, Parma_Polyhedra_Library::Checked::number_struct::exponent, get_digit(), Parma_Polyhedra_Library::is_space(), Parma_Polyhedra_Library::Checked::number_struct::mantissa, Parma_Polyhedra_Library::Checked::number_struct::neg_exponent, Parma_Polyhedra_Library::Checked::number_struct::neg_mantissa, PPL_ASSERT, PPL_UNINITIALIZED, sum_sign(), Parma_Polyhedra_Library::V_CVT_STR_UNK, Parma_Polyhedra_Library::V_EQ, Parma_Polyhedra_Library::V_EQ_MINUS_INFINITY, Parma_Polyhedra_Library::V_EQ_PLUS_INFINITY, and Parma_Polyhedra_Library::V_NAN.

Referenced by parse_number().

                                                        {
  enum anonymous_enum { BASE, INTEGER, FRACTIONAL, EXPONENT } state = BASE;
  PPL_UNINITIALIZED(unsigned long, max_exp_div);
  PPL_UNINITIALIZED(int, max_exp_rem);
  bool empty_exponent = true;
  bool empty_mantissa = true;
  long exponent_offset = 0;
  unsigned exponent_offset_scale = 1;
  numer.base = 10;
  numer.base_for_exponent = 10;
  numer.neg_mantissa = false;
  numer.neg_exponent = false;
  numer.mantissa.erase();
  numer.exponent = 0;
  char c;
  do {
    if (!is.get(c))
      return V_CVT_STR_UNK;
  } while (is_space(c));
  switch (c) {
  case '-':
    numer.neg_mantissa = true;
    // Fall through.
  case '+':
    if (!is.get(c))
      return V_CVT_STR_UNK;
    if (c == 'i' || c == 'I')
      goto inf;
    if (c != '.')
      break;
    // Fall through.
  case '.':
    state = FRACTIONAL;
    if (!is.get(c))
      return V_CVT_STR_UNK;
    break;
  case 'n':
  case 'N':
    if (!is.get(c))
      return V_CVT_STR_UNK;
    if (c != 'a' && c != 'A')
      goto unexpected;
    if (!is.get(c))
      return V_CVT_STR_UNK;
    if (c != 'n' && c != 'N')
      goto unexpected;
    return V_NAN;
  inf:
  case 'i':
  case 'I':
    if (!is.get(c))
      return V_CVT_STR_UNK;
    if (c != 'n' && c != 'n')
      goto unexpected;
    if (!is.get(c))
      return V_CVT_STR_UNK;
    if (c != 'f' && c != 'F')
      goto unexpected;
    return numer.neg_mantissa ? V_EQ_MINUS_INFINITY : V_EQ_PLUS_INFINITY;
  }
  if (state != FRACTIONAL) {
    if (get_digit(c, 10) < 0)
      goto unexpected;
    char d;
    if (c == '0' && !is.get(d).fail()) {
      if (d == 'x' || d == 'X') {
        numer.base = 16;
        numer.base_for_exponent = 16;
        state = INTEGER;
        if (!is.get(c))
          return V_CVT_STR_UNK;
      }
      else
        is.unget();
    }
  }
  do {
    switch (state) {
    case BASE:
      if (get_digit(c, 10) >= 0) {
        if (c != '0' || !numer.mantissa.empty())
          numer.mantissa += c;
        empty_mantissa = false;
        break;
      }
      if (c == '^') {
        if (!is.get(c))
          return V_CVT_STR_UNK;
        if (c != '^')
          goto unexpected;
        numer.base = 0;
        for (std::string::const_iterator i = numer.mantissa.begin();
             i != numer.mantissa.end();
             i++) {
          numer.base = numer.base * 10 + static_cast<unsigned>(get_digit(*i, 10));
          if (numer.base > 36)
            goto unexpected;
        }
        if (numer.base < 2)
          goto unexpected;
        numer.base_for_exponent = numer.base;
        numer.mantissa.erase();
        empty_mantissa = true;
        state = INTEGER;
        break;
      }
      goto integer;
    case INTEGER:
      if (get_digit(c, numer.base) >= 0) {
        if (c != '0' || !numer.mantissa.empty())
          numer.mantissa += c;
        empty_mantissa = false;
        break;
      }
    integer:
      if (c == '.') {
        state = FRACTIONAL;
        break;
      }
      goto fractional;
    case FRACTIONAL:
      if (get_digit(c, numer.base) >= 0) {
        --exponent_offset;
        if (c != '0' || !numer.mantissa.empty())
          numer.mantissa += c;
        empty_mantissa = false;
        break;
      }
    fractional:
      if (empty_mantissa)
        goto unexpected;
      if (c == 'e' || c == 'E')
        goto exp;
      if (c == 'p' || c == 'P') {
        if (numer.base == 16) {
          numer.base_for_exponent = 2;
          exponent_offset_scale = 4;
          goto exp;
        }
        else
          goto unexpected;
      }
      if (c == '*') {
        if (!is.get(c))
          return V_CVT_STR_UNK;
        if (c != '^')
          goto unexpected;
      exp:
        state = EXPONENT;
        PPL_ASSERT(numer.base >= 2);
        const long l_max = C_Integer<long>::max;
        max_exp_div = static_cast<unsigned long>(l_max) / numer.base;
        max_exp_rem = static_cast<int>(l_max % static_cast<long>(numer.base));
        if (!is.get(c))
          return V_CVT_STR_UNK;
        if (c == '-') {
          numer.neg_exponent = true;
          break;
        }
        if (c == '+')
          break;
        continue;
      }
      is.unget();
      goto ok;
    case EXPONENT:
      int d = get_digit(c, 10);
      if (d >= 0) {
        empty_exponent = false;
        if (numer.exponent > max_exp_div
            || (numer.exponent == max_exp_div && d > max_exp_rem))
          return V_CVT_STR_UNK;
        numer.exponent = 10 * numer.exponent + static_cast<unsigned long>(d);
        break;
      }
      if (empty_exponent)
        goto unexpected;
      is.unget();
      goto ok;
    }
    is.get(c);
  } while (!is.fail());

  if (empty_mantissa || is.bad())
    return V_CVT_STR_UNK;

 ok:
  {
    std::string::size_type n = numer.mantissa.size();
    while (n > 0 && numer.mantissa[n - 1] == '0') {
      --n;
      ++exponent_offset;
    }
    numer.mantissa.erase(n);
    bool neg;
    if (exponent_offset < 0) {
      neg = true;
      exponent_offset = -exponent_offset;
    }
    else
      neg = false;
    sum_sign(numer.neg_exponent, numer.exponent,
             neg, static_cast<unsigned long>(exponent_offset) * exponent_offset_scale);
    return V_EQ;
  }

 unexpected:
  is.unget();
  return V_CVT_STR_UNK;
}
From bool Parma_Polyhedra_Library::Checked::PPL_DECLARE_FUN1_0_0 ( is_nan  ,
bool  ,
const  ,
Type   
)
From bool Type Parma_Polyhedra_Library::Checked::PPL_DECLARE_FUN1_0_0 ( is_pinf  ,
bool  ,
const  ,
Type   
)
From bool Type Type Parma_Polyhedra_Library::Checked::PPL_DECLARE_FUN1_0_2 ( assign_special  ,
Result  ,
nonconst  ,
Type  ,
Result_Class  ,
Rounding_Dir   
)
From bool Type Type Rounding_Dir Rounding_Dir Rounding_Dir Rounding_Dir Rounding_Dir Rounding_Dir Rounding_Dir Rounding_Dir unsigned Rounding_Dir unsigned Rounding_Dir unsigned Rounding_Dir Rounding_Dir Rounding_Dir std::istream Rounding_Dir Parma_Polyhedra_Library::Checked::PPL_DECLARE_FUN1_1_2 ( output  ,
Result  ,
std::ostream &  ,
const  ,
Type  ,
const Numeric_Format &  ,
Rounding_Dir   
)
Parma_Polyhedra_Library::Checked::PPL_DECLARE_FUN2_0_0 ( copy  ,
void  ,
nonconst  ,
Type1  ,
const  ,
Type2   
)
From Parma_Polyhedra_Library::Checked::PPL_DECLARE_FUN2_0_0 ( cmp  ,
Result_Relation  ,
const  ,
Type1  ,
const  ,
Type2   
)
From bool Type Type Rounding_Dir Parma_Polyhedra_Library::Checked::PPL_DECLARE_FUN2_0_1 ( construct  ,
Result  ,
nonconst  ,
To  ,
const  ,
From  ,
Rounding_Dir   
)
From bool Type Type Rounding_Dir Rounding_Dir Parma_Polyhedra_Library::Checked::PPL_DECLARE_FUN2_0_1 ( floor  ,
Result  ,
nonconst  ,
To  ,
const  ,
From  ,
Rounding_Dir   
)
From bool Type Type Rounding_Dir Rounding_Dir Rounding_Dir Parma_Polyhedra_Library::Checked::PPL_DECLARE_FUN2_0_1 ( trunc  ,
Result  ,
nonconst  ,
To  ,
const  ,
From  ,
Rounding_Dir   
)
From bool Type Type Rounding_Dir Rounding_Dir Rounding_Dir Rounding_Dir Rounding_Dir Parma_Polyhedra_Library::Checked::PPL_DECLARE_FUN3_0_1 ( add  ,
Result  ,
nonconst  ,
To  ,
const  ,
From1  ,
const  ,
From2  ,
Rounding_Dir   
)
From bool Type Type Rounding_Dir Rounding_Dir Rounding_Dir Rounding_Dir Rounding_Dir Rounding_Dir Parma_Polyhedra_Library::Checked::PPL_DECLARE_FUN3_0_1 ( mul  ,
Result  ,
nonconst  ,
To  ,
const  ,
From1  ,
const  ,
From2  ,
Rounding_Dir   
)
From bool Type Type Rounding_Dir Rounding_Dir Rounding_Dir Rounding_Dir Rounding_Dir Rounding_Dir Rounding_Dir Rounding_Dir unsigned Rounding_Dir unsigned Rounding_Dir unsigned Rounding_Dir Parma_Polyhedra_Library::Checked::PPL_DECLARE_FUN3_0_1 ( add_mul  ,
Result  ,
nonconst  ,
To  ,
const  ,
From1  ,
const  ,
From2  ,
Rounding_Dir   
)
template<typename Policy , typename Type >
struct Parma_Polyhedra_Library::Checked::PPL_FUNCTION_CLASS ( construct  )
read
template<typename To_Policy , typename From_Policy , typename To , typename From >
struct Parma_Polyhedra_Library::Checked::PPL_FUNCTION_CLASS ( construct  )
read

Definition at line 258 of file checked.inlines.hh.

References From, and To.

                                     {
  static inline Result function(To& to, const From& from, Rounding_Dir dir) {
    new (&to) To();
    return assign<To_Policy, From_Policy>(to, from, dir);
  }
};
template<typename To_Policy , typename To >
struct Parma_Polyhedra_Library::Checked::PPL_FUNCTION_CLASS ( construct_special  )
read

Definition at line 266 of file checked.inlines.hh.

References To.

                                             {
  static inline Result function(To& to, Result_Class r, Rounding_Dir dir) {
    new (&to) To();
    return assign_special<To_Policy>(to, r, dir);
  }
};
Parma_Polyhedra_Library::Checked::PPL_SAFE_CONVERSION ( signed  short,
signed  char 
)
Parma_Polyhedra_Library::Checked::PPL_SAFE_CONVERSION ( signed long  long,
signed  char 
)
Parma_Polyhedra_Library::Checked::PPL_SAFE_CONVERSION ( signed long  long,
signed  short 
)
Parma_Polyhedra_Library::Checked::PPL_SAFE_CONVERSION ( unsigned  short,
unsigned  char 
)
Parma_Polyhedra_Library::Checked::PPL_SAFE_CONVERSION ( unsigned  long,
unsigned  char 
)
Parma_Polyhedra_Library::Checked::PPL_SAFE_CONVERSION ( unsigned long  long,
char   
)
Parma_Polyhedra_Library::Checked::PPL_SAFE_CONVERSION ( unsigned long  long,
unsigned  char 
)
Parma_Polyhedra_Library::Checked::PPL_SAFE_CONVERSION ( mpz_class  ,
signed  char 
)
Parma_Polyhedra_Library::Checked::PPL_SAFE_CONVERSION ( mpz_class  ,
unsigned  char 
)
Parma_Polyhedra_Library::Checked::PPL_SAFE_CONVERSION ( mpq_class  ,
signed  char 
)
Parma_Polyhedra_Library::Checked::PPL_SAFE_CONVERSION ( mpq_class  ,
unsigned  char 
)
template<typename T >
void Parma_Polyhedra_Library::Checked::pred_float ( T &  v)
inline

Definition at line 232 of file checked_float.inlines.hh.

References PPL_ASSERT, and Parma_Polyhedra_Library::Bool< false >::value.

Referenced by round_lt_float().

                 {
  Float<T> f(v);
  PPL_ASSERT(!f.u.binary.is_nan());
  PPL_ASSERT(f.u.binary.inf_sign() >= 0);
  if (f.u.binary.zero_sign() > 0) {
    f.u.binary.negate();
    f.u.binary.inc();
  }
  else if (f.u.binary.sign_bit()) {
    f.u.binary.inc();
  }
  else {
    f.u.binary.dec();
  }
  v = f.value();
}
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename To , typename From1 , typename From2 >
Result Parma_Polyhedra_Library::Checked::rem_ext ( To &  to,
const From1 &  x,
const From2 &  y,
Rounding_Dir  dir 
)
inline

Definition at line 600 of file checked_ext.inlines.hh.

References CHECK_P, Parma_Polyhedra_Library::ROUND_IGNORE, Parma_Polyhedra_Library::V_EQ, Parma_Polyhedra_Library::V_INF_MOD, and Parma_Polyhedra_Library::VC_NAN.

                                                                  {
  if (!ext_to_handle<From1_Policy>(x) && !ext_to_handle<From2_Policy>(y))
    goto native;
  if (is_nan<From1_Policy>(x) || is_nan<From2_Policy>(y))
    return assign_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
  else if (CHECK_P(To_Policy::check_inf_mod, is_minf<From1_Policy>(x)
                   || is_pinf<From1_Policy>(x))) {
    return assign_nan<To_Policy>(to, V_INF_MOD);
  }
  else {
    if (is_minf<From1_Policy>(y) || is_pinf<From2_Policy>(y)) {
      to = x;
      return V_EQ;
    }
    else {
    native:
      return rem<To_Policy, From1_Policy, From2_Policy>(to, x, y, dir);
    }
  }
}
template<typename To_Policy , typename From1_Policy , typename From2_Policy , typename Type >
Result Parma_Polyhedra_Library::Checked::rem_float ( Type &  to,
const Type  x,
const Type  y,
Rounding_Dir   
)
inline

Definition at line 58