Parma_Polyhedra_Library::Checked Namespace Reference
[C++ Language Interface]

Types and functions implementing checked numbers. More...


Classes

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< 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 >
struct  number_struct

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

template<typename Policy, typename To>
Result round (To &to, Result r, Rounding_Dir dir)
Result input_mpq (mpq_class &to, std::istream &is)
 safe_conversion (signed short, signed char)
 safe_conversion (signed long long, signed char)
 safe_conversion (signed long long, signed short)
 safe_conversion (unsigned short, unsigned char)
 safe_conversion (unsigned long, unsigned char)
 safe_conversion (unsigned long long, unsigned char)
 safe_conversion (double, float)
 safe_conversion (long double, float)
 safe_conversion (long double, double)
 safe_conversion (mpz_class, signed char)
 safe_conversion (mpz_class, unsigned char)
 safe_conversion (mpq_class, signed char)
 safe_conversion (mpq_class, unsigned char)
 safe_conversion (mpq_class, float)
 safe_conversion (mpq_class, double)
template<typename Policy, typename Type>
struct FUNCTION_CLASS (construct)< Policy
template<typename To_Policy, typename To>
struct 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)
Result neg (Result r)
Result add (Result r1, Result r2)
Result sub (Result r1, Result r2)
template<typename To_Policy, typename From1_Policy, typename From2_Policy, typename To, typename From>
void gcd_exact_noabs (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 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 S, typename U>
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)
template<typename U, typename S>
Enable_If
<(!Safe_Int_Comparison< S, U >
::value &&C_Integer< U >
::value &&C_Integer< S >
::is_signed), bool >::type 
lt (const U &x, const S &y)
template<typename S, typename U>
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)
template<typename U, typename S>
Enable_If
<(!Safe_Int_Comparison< S, U >
::value &&C_Integer< U >
::value &&C_Integer< S >
::is_signed), bool >::type 
le (const U &x, const S &y)
template<typename S, typename U>
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)
template<typename U, typename S>
Enable_If
<(!Safe_Int_Comparison< S, U >
::value &&C_Integer< U >
::value &&C_Integer< S >
::is_signed), bool >::type 
eq (const U &x, const S &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 cmp_generic (const Type1 &x, const Type2 &y)
template<typename Policy, typename Type>
Result input_generic (Type &to, std::istream &is, Rounding_Dir dir)
float fma (float x, float y, float z)
double fma (double x, double y, double z)
long double fma (long double x, long double y, long double z)
double rint (double x)
long double rint (long double x)
bool fpu_direct_rounding (Rounding_Dir dir)
bool fpu_inverse_rounding (Rounding_Dir dir)
float limit_precision (float v)
double limit_precision (double v)
long double limit_precision (long double v)
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>
int 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 r, 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 mul2exp_float (Type &to, const Type x, int exp, Rounding_Dir dir)
template<typename To_Policy, typename From_Policy, typename Type>
Result div2exp_float (Type &to, const Type x, 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 sgn_float (const Type x)
template<typename Policy1, typename Policy2, typename Type>
Result 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 r, 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 div2exp_unsigned_int (Type &to, const Type x, int exp, Rounding_Dir dir)
template<typename To_Policy, typename From_Policy, typename Type>
Result div2exp_signed_int (Type &to, const Type x, int exp, Rounding_Dir dir)
template<typename To_Policy, typename From_Policy, typename Type>
Result mul2exp_unsigned_int (Type &to, const Type x, int exp, Rounding_Dir dir)
template<typename To_Policy, typename From_Policy, typename Type>
Result mul2exp_signed_int (Type &to, const Type x, int exp, Rounding_Dir dir)
template<typename Type>
void isqrtrem (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 r, 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 mul2exp_mpq (mpq_class &to, const mpq_class &x, int exp, Rounding_Dir dir)
template<typename To_Policy, typename From_Policy>
Result div2exp_mpq (mpq_class &to, const mpq_class &x, int exp, Rounding_Dir 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)
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 r, 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 mul2exp_mpz (mpz_class &to, const mpz_class &x, int exp, Rounding_Dir dir)
template<typename To_Policy, typename From_Policy>
Result div2exp_mpz (mpz_class &to, const mpz_class &x, int exp, Rounding_Dir 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 sgn_mp (const Type &x)
template<typename Policy1, typename Policy2, typename Type>
Result 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)
int get_digit (int c, 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 &num)
 Helper function for parse_number(): reads the numerator or denominator part of a number from is into num, returning the appropriate Result value.
Result parse_number (std::istream &is, number_struct &num, number_struct &den)

Variables

unsigned long rational_sqrt_precision_parameter
 Holds the precision parameter used for rational sqrt calculations.


Detailed Description

Types and functions implementing checked numbers.


Typedef Documentation

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

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

Definition at line 55 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 57 of file checked_mpz.inlines.hh.

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

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

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


Function Documentation

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 585 of file checked_float.inlines.hh.

00585                                                    {
00586   if (To_Policy::check_nan_result && is_nan<From_Policy>(from))
00587     return assign_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
00588   to = std::abs(from);
00589   return V_EQ;
00590 }

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 231 of file checked.inlines.hh.

00231                                                         {
00232   if (from < 0)
00233     return neg<To_Policy, From_Policy>(to, from, dir);
00234   else
00235     return assign<To_Policy, From_Policy>(to, from, dir);
00236 }

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 355 of file checked_mpq.inlines.hh.

00355                                                             {
00356   to = abs(from);
00357   return V_EQ;
00358 }

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 451 of file checked_mpz.inlines.hh.

00451                                                             {
00452   to = abs(from);
00453   return V_EQ;
00454 }

Result Parma_Polyhedra_Library::Checked::add ( Result  r1,
Result  r2 
) [inline]

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

00250                           {
00251   assert(!is_special(r1));
00252   assert(!is_special(r2));
00253   if (r1 == V_EQ)
00254     return r2;
00255   if (r2 == V_EQ)
00256     return r1;
00257   if (((r1 & V_LT) && (r2 & V_GT))
00258       || ((r1 & V_GT) && (r2 & V_LT)))
00259     return V_LGE;
00260   return static_cast<Result>((((r1 & r2) & V_EQ) ? V_EQ : 0) |
00261                                (r1 & (V_LT | V_GT)));
00262 }

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 422 of file checked_float.inlines.hh.

References fpu_direct_rounding(), fpu_inverse_rounding(), and limit_precision().

00422                                                                   {
00423   if (To_Policy::check_inf_add_inf
00424       && is_inf_float<From1_Policy>(x) && x == -y)
00425     return assign_special<To_Policy>(to, V_INF_ADD_INF, ROUND_IGNORE);
00426   prepare_inexact<To_Policy>(dir);
00427   if (fpu_direct_rounding(dir))
00428     to = x + y;
00429   else if (fpu_inverse_rounding(dir))
00430     to = -limit_precision(-x - y);
00431   else {
00432     fpu_rounding_control_word_type old = fpu_save_rounding_direction(round_fpu_dir(dir));
00433     avoid_cse(x);
00434     avoid_cse(y);
00435     to = x + y;
00436     avoid_cse(to);
00437     fpu_restore_rounding_direction(old);
00438   }
00439   if (To_Policy::check_nan_result && is_nan<To_Policy>(to))
00440     return VC_NAN;
00441   return result_relation<To_Policy>(dir);
00442 }

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 842 of file checked_int.inlines.hh.

00842                                                                        {
00843   typename Larger<Type>::type_for_add l = x;
00844   l += y;
00845   return assign<To_Policy, To_Policy>(to, l, dir);
00846 }

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 268 of file checked_mpq.inlines.hh.

00268                                                                              {
00269   to = x + y;
00270   return V_EQ;
00271 }

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 339 of file checked_mpz.inlines.hh.

00339                                                                              {
00340   to = x + y;
00341   return V_EQ;
00342 }

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 802 of file checked_float.inlines.hh.

References fma(), fpu_direct_rounding(), fpu_inverse_rounding(), and limit_precision().

00802                                                                       {
00803   if (To_Policy::check_inf_mul_zero
00804       && ((x == 0 && is_inf_float<From2_Policy>(y)) ||
00805           (y == 0 && is_inf_float<From1_Policy>(x))))
00806     return assign_special<To_Policy>(to, V_INF_MUL_ZERO, ROUND_IGNORE);
00807   // FIXME: missing check_inf_add_inf
00808   prepare_inexact<To_Policy>(dir);
00809   if (fpu_direct_rounding(dir))
00810     to = fma(x, y, to);
00811   else if (fpu_inverse_rounding(dir))
00812     to = -limit_precision(fma(-x, y, -to));
00813   else {
00814     fpu_rounding_control_word_type old = fpu_save_rounding_direction(round_fpu_dir(dir));
00815     avoid_cse(x);
00816     avoid_cse(y);
00817     to = fma(x, y, to);
00818     avoid_cse(to);
00819     fpu_restore_rounding_direction(old);
00820   }
00821   if (To_Policy::check_nan_result && is_nan<To_Policy>(to))
00822     return VC_NAN;
00823   return result_relation<To_Policy>(dir);
00824 }

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 1245 of file checked_int.inlines.hh.

01245                                                                     {
01246   Type z;
01247   Result r = mul<To_Policy, From1_Policy, From2_Policy>(z, x, y, dir);
01248   switch (r) {
01249   case V_NEG_OVERFLOW:
01250   case V_LT:
01251     if (to <= 0) {
01252       to = z;
01253       return r;
01254     }
01255     return assign_special<To_Policy>(to, V_UNKNOWN_NEG_OVERFLOW, ROUND_IGNORE);
01256   case V_POS_OVERFLOW:
01257   case V_GT:
01258     if (to >= 0) {
01259       to = z;
01260       return r;
01261     }
01262     return assign_special<To_Policy>(to, V_UNKNOWN_POS_OVERFLOW, ROUND_IGNORE);
01263   default:
01264     return add<To_Policy, To_Policy, To_Policy>(to, to, z, dir);
01265   }
01266 }

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 364 of file checked_mpq.inlines.hh.

00365                           {
00366   to += x * y;
00367   return V_EQ;
00368 }

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 460 of file checked_mpz.inlines.hh.

00461                           {
00462   mpz_addmul(to.get_mpz_t(), x.get_mpz_t(), y.get_mpz_t());
00463   return V_EQ;
00464 }

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 889 of file checked_int.inlines.hh.

00889                                                                        {
00890   if (To_Policy::check_overflow && Larger<Type>::use_for_add)
00891     return add_int_larger<To_Policy, From1_Policy, From2_Policy>(to, x, y, dir);
00892   if (To_Policy::check_overflow) {
00893     if (y >= 0) {
00894       if (x > Extended_Int<To_Policy, Type>::max - y)
00895         return set_pos_overflow_int<To_Policy>(to, dir);
00896     }
00897     else if (x < Extended_Int<To_Policy, Type>::min - y)
00898         return set_neg_overflow_int<To_Policy>(to, dir);
00899   }
00900   to = x + y;
00901   return V_EQ;
00902 }

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 906 of file checked_int.inlines.hh.

References CHECK_P.

00906                                                                          {
00907   if (To_Policy::check_overflow && Larger<Type>::use_for_add)
00908     return add_int_larger<To_Policy, From1_Policy, From2_Policy>(to, x, y, dir);
00909   if (CHECK_P(To_Policy::check_overflow,
00910               (x > Extended_Int<To_Policy, Type>::max - y)))
00911     return set_pos_overflow_int<To_Policy>(to, dir);
00912   to = x + y;
00913   return V_EQ;
00914 }

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 218 of file checked.inlines.hh.

00218                                                      {
00219   to = from;
00220   return V_EQ;
00221 }

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 354 of file checked_float.inlines.hh.

00354                                                               {
00355   if (sizeof(From) > sizeof(To))
00356     return assign_float_float_inexact<To_Policy, From_Policy>(to, from, dir);
00357   else
00358     return assign_float_float_exact<To_Policy, From_Policy>(to, from, dir);
00359 }

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 325 of file checked_float.inlines.hh.

00325                                                                 {
00326   if (To_Policy::check_nan_result && is_nan<From_Policy>(from))
00327     return assign_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
00328   to = from;
00329   return V_EQ;
00330 }

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 334 of file checked_float.inlines.hh.

References fpu_direct_rounding(), and fpu_inverse_rounding().

00334                                                                       {
00335   if (To_Policy::check_nan_result && is_nan<From_Policy>(from))
00336     return assign_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
00337   prepare_inexact<To_Policy>(dir);
00338   if (fpu_direct_rounding(dir))
00339     to = from;
00340   else if (fpu_inverse_rounding(dir))
00341     to = -static_cast<To>(-from);
00342   else {
00343     fpu_rounding_control_word_type old = fpu_save_rounding_direction(round_fpu_dir(dir));
00344     avoid_cse(from);
00345     to = from;
00346     avoid_cse(to);
00347     fpu_restore_rounding_direction(old);
00348   }
00349   return result_relation<To_Policy>(dir);
00350 }

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 648 of file checked_float.inlines.hh.

00648                                                             {
00649   if (sizeof(From) * 8 > Float<To>::Binary::MANTISSA_BITS)
00650     return assign_float_int_inexact<To_Policy, From_Policy>(to, from, dir);
00651   else
00652     return assign_exact<To_Policy, From_Policy>(to, from, dir);
00653 }

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]

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

References fpu_direct_rounding().

00632                                                                     {
00633   prepare_inexact<To_Policy>(dir);
00634   if (fpu_direct_rounding(dir))
00635     to = from;
00636   else {
00637     fpu_rounding_control_word_type old = fpu_save_rounding_direction(round_fpu_dir(dir));
00638     avoid_cse(from);
00639     to = from;
00640     avoid_cse(to);
00641     fpu_restore_rounding_direction(old);
00642   }
00643   return result_relation<To_Policy>(dir);
00644 }

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 731 of file checked_float.inlines.hh.

References Parma_Polyhedra_Library::Bool< false >::value.

00732 {
00733   const mpz_class& _num = from.get_num();
00734   const mpz_class& _den = from.get_den();
00735   if (_den == 1)
00736     return assign_float_mpz<To_Policy, From_Policy>(to, _num, dir);
00737   mpz_srcptr num = _num.get_mpz_t();
00738   mpz_srcptr den = _den.get_mpz_t();
00739   int sign = mpz_sgn(num);
00740   signed long exponent = mpz_sizeinbase(num, 2) - mpz_sizeinbase(den, 2);
00741   if (exponent < Float<T>::Binary::EXPONENT_MIN_DENORM) {
00742     to = 0;
00743   inexact:
00744     if (sign < 0)
00745       return round_lt_float<To_Policy>(to, dir);
00746     else
00747       return round_gt_float<To_Policy>(to, dir);
00748   }
00749   if (exponent > static_cast<signed int>(Float<T>::Binary::EXPONENT_MAX + 1)) {
00750   overflow:
00751     if (sign < 0)
00752       return set_neg_overflow_float<To_Policy>(to, dir);
00753     else
00754       return set_pos_overflow_float<To_Policy>(to, dir);
00755   }
00756   unsigned int needed_bits = Float<T>::Binary::MANTISSA_BITS + 1;
00757   if (exponent < Float<T>::Binary::EXPONENT_MIN)
00758     needed_bits -= Float<T>::Binary::EXPONENT_MIN - exponent;
00759   mpz_t mantissa;
00760   mpz_init(mantissa);
00761   signed long shift = needed_bits - exponent;
00762   if (shift > 0) {
00763     mpz_mul_2exp(mantissa, num, shift);
00764     num = mantissa;
00765   }
00766   else if (shift < 0) {
00767     mpz_mul_2exp(mantissa, den, -shift);
00768     den = mantissa;
00769   }
00770   mpz_t r;
00771   mpz_init(r);
00772   mpz_tdiv_qr(mantissa, r, num, den);
00773   size_t bits = mpz_sizeinbase(mantissa, 2);
00774   bool inexact = (mpz_sgn(r) != 0);
00775   mpz_clear(r);
00776   if (bits == needed_bits + 1) {
00777     inexact = (inexact || mpz_odd_p(mantissa));
00778     mpz_div_2exp(mantissa, mantissa, 1);
00779   }
00780   else
00781     --exponent;
00782   if (exponent > static_cast<signed int>(Float<T>::Binary::EXPONENT_MAX)) {
00783     mpz_clear(mantissa);
00784     goto overflow;
00785   }
00786   else if (exponent < Float<T>::Binary::EXPONENT_MIN - 1) {
00787     // Denormalized.
00788     exponent = Float<T>::Binary::EXPONENT_MIN - 1;
00789   }
00790   Float<T> f(to);
00791   f.u.binary.build(sign < 0, mantissa, exponent);
00792   mpz_clear(mantissa);
00793   to = f.value();
00794   if (inexact)
00795     goto inexact;
00796   return V_EQ;
00797 }

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 691 of file checked_float.inlines.hh.

References Parma_Polyhedra_Library::Bool< false >::value.

00692 {
00693   mpz_srcptr from = _from.get_mpz_t();
00694   int sign = mpz_sgn(from);
00695   if (sign == 0) {
00696     to = 0;
00697     return V_EQ;
00698   }
00699   size_t exponent = mpz_sizeinbase(from, 2) - 1;
00700   if (exponent > static_cast<size_t>(Float<T>::Binary::EXPONENT_MAX)) {
00701     if (sign < 0)
00702       return set_neg_overflow_float<To_Policy>(to, dir);
00703     else
00704       return set_pos_overflow_float<To_Policy>(to, dir);
00705   }
00706   unsigned long zeroes = mpn_scan1(from->_mp_d, 0);
00707   size_t meaningful_bits = exponent - zeroes;
00708   mpz_t mantissa;
00709   mpz_init(mantissa);
00710   if (exponent > Float<T>::Binary::MANTISSA_BITS)
00711     mpz_tdiv_q_2exp(mantissa,
00712                     from,
00713                     exponent - Float<T>::Binary::MANTISSA_BITS);
00714   else
00715     mpz_mul_2exp(mantissa, from, Float<T>::Binary::MANTISSA_BITS - exponent);
00716   Float<T> f(to);
00717   f.u.binary.build(sign < 0, mantissa, exponent);
00718   mpz_clear(mantissa);
00719   to = f.value();
00720   if (meaningful_bits > Float<T>::Binary::MANTISSA_BITS) {
00721     if (sign < 0)
00722       return round_lt_float<To_Policy>(to, dir);
00723     else
00724       return round_gt_float<To_Policy>(to, dir);
00725   }
00726   return V_EQ;
00727 }

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 481 of file checked_int.inlines.hh.

References CHECK_P.

00481                                                             {
00482   if (is_nan<From_Policy>(from))
00483     return assign_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
00484   else if (is_minf<From_Policy>(from))
00485     return assign_special<To_Policy>(to, VC_MINUS_INFINITY, dir);
00486   else if (is_pinf<From_Policy>(from))
00487     return assign_special<To_Policy>(to, VC_PLUS_INFINITY, dir);
00488   if (CHECK_P(To_Policy::check_overflow, (from < Extended_Int<To_Policy, To>::min)))
00489     return set_neg_overflow_int<To_Policy>(to, dir);
00490   if (CHECK_P(To_Policy::check_overflow, (from > Extended_Int<To_Policy, To>::max)))
00491     return set_pos_overflow_int<To_Policy>(to, dir);
00492   to = static_cast<To>(from);
00493   if (round_ignore(dir))
00494     return V_LGE;
00495   if (from < to)
00496     return round_lt_int<To_Policy>(to, dir);
00497   else if (from > to)
00498     return round_gt_int<To_Policy>(to, dir);
00499   else
00500     return V_EQ;
00501 }

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 628 of file checked_int.inlines.hh.

00628                                                                 {
00629   mpz_srcptr n = from.get_num().get_mpz_t();
00630   mpz_srcptr d = from.get_den().get_mpz_t();
00631   DIRTY_TEMP0(mpz_class, q);
00632   mpz_ptr _q = q.get_mpz_t();
00633   if (round_ignore(dir)) {
00634     mpz_tdiv_q(_q, n, d);
00635     Result r = assign<To_Policy, void>(to, q, dir);
00636     if (r != V_EQ)
00637       return r;
00638     return V_LGE;
00639   }
00640   mpz_t rem;
00641   int sign;
00642   mpz_init(rem);
00643   mpz_tdiv_qr(_q, rem, n, d);
00644   sign = mpz_sgn(rem);
00645   mpz_clear(rem);
00646   Result r = assign<To_Policy, void>(to, q, dir);
00647   if (r != V_EQ)
00648     return r;
00649   switch (sign) {
00650   case -1:
00651     return round_lt_int<To_Policy>(to, dir);
00652   case 1:
00653     return round_gt_int<To_Policy>(to, dir);
00654   default:
00655     return V_EQ;
00656   }
00657 }

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 175 of file checked_mpq.inlines.hh.

00175                                                                     {
00176   if (is_nan<From_Policy>(from))
00177     return assign_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
00178   else if (is_minf<From_Policy>(from))
00179     return assign_special<To_Policy>(to, VC_MINUS_INFINITY, dir);
00180   else if (is_pinf<From_Policy>(from))
00181     return assign_special<To_Policy>(to, VC_PLUS_INFINITY, dir);
00182   to = from;
00183   return V_EQ;
00184 }

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 435 of file checked_mpq.inlines.hh.

References input_mpq().

00435                                                                           {
00436   if (is_nan<From_Policy>(from))
00437     return assign_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
00438   else if (is_minf<From_Policy>(from))
00439     return assign_special<To_Policy>(to, VC_MINUS_INFINITY, dir);
00440   else if (is_pinf<From_Policy>(from))
00441     return assign_special<To_Policy>(to, VC_PLUS_INFINITY, dir);
00442   // FIXME: this is an incredibly inefficient implementation!
00443   std::stringstream ss;
00444   output<From_Policy>(ss, from, Numeric_Format(), dir);
00445   return input_mpq(to, ss);
00446 }

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 191 of file checked_mpq.inlines.hh.

00191                                                                     {
00192   if (sizeof(From) <= sizeof(signed long))
00193     to = static_cast<signed long>(from);
00194   else {
00195     mpz_ptr m = to.get_num().get_mpz_t();
00196     if (from >= 0)
00197       mpz_import(m, 1, 1, sizeof(From), 0, 0, &from);
00198     else {
00199       From n = -from;
00200       mpz_import(m, 1, 1, sizeof(From), 0, 0, &n);
00201       mpz_neg(m, m);
00202     }
00203     to.get_den() = 1;
00204   }
00205   return V_EQ;
00206 }

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 212 of file checked_mpq.inlines.hh.

00212                                                                       {
00213   if (sizeof(From) <= sizeof(unsigned long))
00214     to = static_cast<unsigned long>(from);
00215   else {
00216     mpz_import(to.get_num().get_mpz_t(), 1, 1, sizeof(From), 0, 0, &from);
00217     to.get_den() = 1;
00218   }
00219   return V_EQ;
00220 }

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 255 of file checked_mpz.inlines.hh.

References rint().

00255                                                                    {
00256   if (is_nan<From_Policy>(from))
00257     return assign_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
00258   else if (is_minf<From_Policy>(from))
00259     return assign_special<To_Policy>(to, VC_MINUS_INFINITY, dir);
00260   else if (is_pinf<From_Policy>(from))
00261     return assign_special<To_Policy>(to, VC_PLUS_INFINITY, dir);
00262   if (round_ignore(dir)) {
00263     to = from;
00264     return V_LGE;
00265   }
00266   From n = rint(from);
00267   to = n;
00268   if (from < n)
00269     return round_lt_mpz<To_Policy>(to, dir);
00270   else if (from > n)
00271     return round_gt_mpz<To_Policy>(to, dir);
00272   else
00273     return V_EQ;
00274 }

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 281 of file checked_mpz.inlines.hh.

References input_mpq().

00281                                                                           {
00282   if (is_nan<From_Policy>(from))
00283     return assign_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
00284   else if (is_minf<From_Policy>(from))
00285     return assign_special<To_Policy>(to, VC_MINUS_INFINITY, dir);
00286   else if (is_pinf<From_Policy>(from))
00287     return assign_special<To_Policy>(to, VC_PLUS_INFINITY, dir);
00288   // FIXME: this is an incredibly inefficient implementation!
00289   std::stringstream ss;
00290   output<From_Policy>(ss, from, Numeric_Format(), dir);
00291   DIRTY_TEMP0(mpq_class, tmp);
00292 #ifndef NDEBUG
00293   Result r =
00294 #endif
00295     input_mpq(tmp, ss);
00296   assert(r == V_EQ);
00297   return assign<To_Policy, From_Policy>(to, tmp, dir);
00298 }

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 304 of file checked_mpz.inlines.hh.

00304                                                                        {
00305   if (round_ignore(dir)) {
00306     to = from;
00307     return V_LGE;
00308   }
00309   mpz_srcptr n = from.get_num().get_mpz_t();
00310   mpz_srcptr d = from.get_den().get_mpz_t();
00311   if (round_down(dir)) {
00312     mpz_fdiv_q(to.get_mpz_t(), n, d);
00313     return mpz_divisible_p(n, d) ? V_EQ : V_GT;
00314   }
00315   else {
00316     assert(round_up(dir));
00317     mpz_cdiv_q(to.get_mpz_t(), n, d);
00318     return mpz_divisible_p(n, d) ? V_EQ : V_LT;
00319   }
00320 }

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 223 of file checked_mpz.inlines.hh.

00223                                                                     {
00224   if (sizeof(From) <= sizeof(signed long))
00225     to = static_cast<signed long>(from);
00226   else {
00227     mpz_ptr m = to.get_mpz_t();
00228     if (from >= 0)
00229       mpz_import(m, 1, 1, sizeof(From), 0, 0, &from);
00230     else {
00231       From n = -from;
00232       mpz_import(m, 1, 1, sizeof(From), 0, 0, &n);
00233       mpz_neg(m, m);
00234     }
00235   }
00236   return V_EQ;
00237 }

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 243 of file checked_mpz.inlines.hh.

00243                                                                       {
00244   if (sizeof(From) <= sizeof(unsigned long))
00245     to = static_cast<unsigned long>(from);
00246   else
00247     mpz_import(to.get_mpz_t(), 1, 1, sizeof(From), 0, 0, &from);
00248   return V_EQ;
00249 }

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 543 of file checked_int.inlines.hh.

00543                                                                        {
00544   if (sizeof(To) <= sizeof(signed long)) {
00545     if (!To_Policy::check_overflow) {
00546       to = from.get_si();
00547       return V_EQ;
00548     }
00549     if (from.fits_slong_p()) {
00550       signed long v = from.get_si();
00551       if (v < C_Integer<To>::min)
00552         return set_neg_overflow_int<To_Policy>(to, dir);
00553       if (v > C_Integer<To>::max)
00554         return set_pos_overflow_int<To_Policy>(to, dir);
00555       to = v;
00556       return V_EQ;
00557     }
00558   }
00559   else {
00560     mpz_srcptr m = from.get_mpz_t();
00561     size_t sz = mpz_size(m);
00562     if (sz <= sizeof(To) / sizeof(mp_limb_t)) {
00563       if (sz == 0) {
00564         to = 0;
00565         return V_EQ;
00566       }
00567       To v;
00568       mpz_export(&v, 0, -1, sizeof(To), 0, 0, m);
00569       if (v >= 0) {
00570         if (::sgn(from) < 0)
00571           return neg<To_Policy, To_Policy>(to, v, dir);
00572         to = v;
00573         return V_EQ;
00574       }
00575     }
00576   }
00577   return ::sgn(from) < 0
00578     ? set_neg_overflow_int<To_Policy>(to, dir)
00579     : set_pos_overflow_int<To_Policy>(to, dir);
00580 }

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 344 of file checked_int.inlines.hh.

References CHECK_P.

00344                                                                         {
00345   if (sizeof(To) < sizeof(From)
00346       || (sizeof(To) == sizeof(From)
00347           && (Extended_Int<To_Policy, To>::min > Extended_Int<From_Policy, From>::min
00348               || Extended_Int<To_Policy, To>::max < Extended_Int<From_Policy, From>::max))) {
00349     if (CHECK_P(To_Policy::check_overflow,
00350                 from < static_cast<From>(Extended_Int<To_Policy, To>::min)))
00351       return set_neg_overflow_int<To_Policy>(to, dir);
00352     if (CHECK_P(To_Policy::check_overflow,
00353                 from > static_cast<From>(Extended_Int<To_Policy, To>::max)))
00354       return set_pos_overflow_int<To_Policy>(to, dir);
00355   }
00356   to = To(from);
00357   return V_EQ;
00358 }

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 362 of file checked_int.inlines.hh.

References CHECK_P.

00362                                                                           {
00363   if (sizeof(To) <= sizeof(From)) {
00364     if (CHECK_P(To_Policy::check_overflow,
00365                 from > static_cast<From>(Extended_Int<To_Policy, To>::max)))
00366       return set_pos_overflow_int<To_Policy>(to, dir);
00367   }
00368   to = To(from);
00369   return V_EQ;
00370 }

template<typename Policy, typename T>
Result Parma_Polyhedra_Library::Checked::assign_special_float ( T &  v,
Result  r,
Rounding_Dir   
) [inline]

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

References NAN.

00206                                                    {
00207   switch (classify(r)) {
00208   case VC_MINUS_INFINITY:
00209     v = -HUGE_VAL;
00210     break;
00211   case VC_PLUS_INFINITY:
00212     v = HUGE_VAL;
00213     break;
00214   case VC_NAN:
00215     v = NAN;
00216     return r;
00217   default:
00218     break;
00219   }
00220   return V_EQ;
00221 }

template<typename Policy, typename Type>
Result Parma_Polyhedra_Library::Checked::assign_special_int ( Type &  v,
Result  r,
Rounding_Dir  dir 
) [inline]

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

00297                                                         {
00298   Result t = classify(r);
00299   switch (t) {
00300   case VC_NAN:
00301     if (Policy::has_nan)
00302       v = Extended_Int<Policy, Type>::not_a_number;
00303     break;
00304   case VC_MINUS_INFINITY:
00305     if (Policy::has_infinity) {
00306       v = Extended_Int<Policy, Type>::minus_infinity;
00307       return V_EQ;
00308     }
00309     if (round_up(dir)) {
00310       v = Extended_Int<Policy, Type>::min;
00311       return V_LT;
00312     }
00313     break;
00314   case VC_PLUS_INFINITY:
00315     if (Policy::has_infinity) {
00316       v = Extended_Int<Policy, Type>::plus_infinity;
00317       return V_EQ;
00318     }
00319     if (round_down(dir)) {
00320       v = Extended_Int<Policy, Type>::max;
00321       return V_GT;
00322     }
00323     break;
00324   default:
00325     assert(0);
00326     break;
00327   }
00328   return r;
00329 }

template<typename Policy>
Result Parma_Polyhedra_Library::Checked::assign_special_mpq ( mpq_class &  v,
Result  r,
Rounding_Dir   
) [inline]

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

00102                                                          {
00103   Result c = classify(r);
00104   if (Policy::has_nan && c == VC_NAN) {
00105     v.get_num() = 0;
00106     v.get_den() = 0;
00107   }
00108   else if (Policy::has_infinity) {
00109     switch (c) {
00110     case VC_MINUS_INFINITY:
00111       v.get_num() = -1;
00112       v.get_den() = 0;
00113       return V_EQ;
00114     case VC_PLUS_INFINITY:
00115       v.get_num() = 1;
00116       v.get_den() = 0;
00117       return V_EQ;
00118     default:
00119       break;
00120     }
00121   }
00122   return r;
00123 }

template<typename Policy>
Result Parma_Polyhedra_Library::Checked::assign_special_mpz ( mpz_class &  v,
Result  r,
Rounding_Dir   
) [inline]

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

References set_mp_size().

00132                                                          {
00133   Result c = classify(r);
00134   if (Policy::has_nan && c == VC_NAN)
00135     set_mp_size(v, C_Integer<mp_size_field_t>::min + 1);
00136   else if (Policy::has_infinity) {
00137     switch (c) {
00138     case VC_MINUS_INFINITY:
00139       set_mp_size(v, C_Integer<mp_size_field_t>::min);
00140       return V_EQ;
00141     case VC_PLUS_INFINITY:
00142       set_mp_size(v, C_Integer<mp_size_field_t>::max);
00143       return V_EQ;
00144     default:
00145       break;
00146     }
00147   }
00148   return r;
00149 }

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 590 of file checked_int.inlines.hh.

References CHECK_P.

00590                                                                          {
00591   if (CHECK_P(To_Policy::check_overflow, ::sgn(from) < 0))
00592     return set_neg_overflow_int<To_Policy>(to, dir);
00593   if (sizeof(To) <= sizeof(unsigned long)) {
00594     if (!To_Policy::check_overflow) {
00595       to = from.get_ui();
00596       return V_EQ;
00597     }
00598     if (from.fits_ulong_p()) {
00599       unsigned long v = from.get_ui();
00600       if (v > C_Integer<To>::max)
00601         return set_pos_overflow_int<To_Policy>(to, dir);
00602       to = v;
00603       return V_EQ;
00604     }
00605   }
00606   else {
00607     mpz_srcptr m = from.get_mpz_t();
00608     size_t sz = mpz_size(m);
00609     if (sz <= sizeof(To) / sizeof(mp_limb_t)) {
00610       if (sz == 0)
00611         to = 0;
00612       else
00613         mpz_export(&to, 0, -1, sizeof(To), 0, 0, m);
00614       return V_EQ;
00615     }
00616   }
00617   return set_pos_overflow_int<To_Policy>(to, dir);
00618 }

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 374 of file checked_int.inlines.hh.

References CHECK_P.

00374                                                                           {
00375   if (CHECK_P(To_Policy::check_overflow, from < 0))
00376     return set_neg_overflow_int<To_Policy>(to, dir);
00377   if (sizeof(To) < sizeof(From)) {
00378     if (CHECK_P(To_Policy::check_overflow,
00379                 from > static_cast<From>(Extended_Int<To_Policy, To>::max)))
00380       return set_pos_overflow_int<To_Policy>(to, dir);
00381   }
00382   to = To(from);
00383   return V_EQ;
00384 }

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 388 of file checked_int.inlines.hh.

References CHECK_P.

00388                                                                             {
00389   if (sizeof(To) < sizeof(From)
00390       || (sizeof(To) == sizeof(From)
00391           && Extended_Int<To_Policy, To>::max < Extended_Int<From_Policy, From>::max)) {
00392     if (CHECK_P(To_Policy::check_overflow,
00393                 from > static_cast<From>(Extended_Int<To_Policy, To>::max)))
00394       return set_pos_overflow_int<To_Policy>(to, dir);
00395   }
00396   to = To(from);
00397   return V_EQ;
00398 }

template<typename To_Policy, typename From_Policy, typename Type>
Result Parma_Polyhedra_Library::Checked::ceil_float ( Type &  to,
const Type  from,
Rounding_Dir   
) [inline]

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

References fpu_direct_rounding(), fpu_inverse_rounding(), limit_precision(), and rint().

00382                                                     {
00383   if (To_Policy::check_nan_result && is_nan<From_Policy>(from))
00384     return assign_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
00385   if (fpu_direct_rounding(ROUND_UP))
00386     to = rint(from);
00387   else if (fpu_inverse_rounding(ROUND_UP))
00388     to = -limit_precision(rint(-from));
00389   else {
00390     fpu_rounding_control_word_type old = fpu_save_rounding_direction(round_fpu_dir(ROUND_UP));
00391     avoid_cse(from);
00392     to = rint(from);
00393     avoid_cse(to);
00394     fpu_restore_rounding_direction(old);
00395   }
00396   return V_EQ;
00397 }

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 237 of file checked_mpq.inlines.hh.

00237                                                              {
00238   mpz_cdiv_q(to.get_num().get_mpz_t(),
00239              from.get_num().get_mpz_t(), from.get_den().get_mpz_t());
00240   to.get_den() = 1;
00241   return V_EQ;
00242 }

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.

00151                                                          {
00152   Float<T> f(v);
00153   if ((nan || sign) && CHECK_P(Policy::has_nan, f.u.binary.is_nan()))
00154     return VC_NAN;
00155   if (inf) {
00156     int i = CHECK_P(Policy::has_infinity, f.u.binary.is_inf());
00157     if (i < 0)
00158       return VC_MINUS_INFINITY;
00159     if (i > 0)
00160       return VC_PLUS_INFINITY;
00161   }
00162   if (sign) {
00163     if (v < 0)
00164       return V_LT;
00165     if (v > 0)
00166       return V_GT;
00167     return V_EQ;
00168   }
00169   return VC_NORMAL;
00170 }

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 191 of file checked_int.inlines.hh.

00191                                                           {
00192   if (Policy::has_nan
00193       && (nan || sign)
00194       && v == Extended_Int<Policy, Type>::not_a_number)
00195     return VC_NAN;
00196   if (!inf & !sign)
00197     return VC_NORMAL;
00198   if (Policy::has_infinity) {
00199     if (v == Extended_Int<Policy, Type>::minus_infinity)
00200       return inf ? VC_MINUS_INFINITY : V_LT;
00201     if (v == Extended_Int<Policy, Type>::plus_infinity)
00202       return inf ? VC_PLUS_INFINITY : V_GT;
00203   }
00204   if (sign) {
00205     if (v < 0)
00206       return V_LT;
00207     if (v > 0)
00208       return V_GT;
00209     return V_EQ;
00210   }
00211   return VC_NORMAL;
00212 }

template<typename Policy>
Result Parma_Polyhedra_Library::Checked::classify_mpq ( const mpq_class &  v,
bool  nan,
bool  inf,
bool  sign 
) [inline]

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

00036                                                                 {
00037   if ((Policy::has_nan || Policy::has_infinity)
00038       && ::sgn(v.get_den()) == 0) {
00039     int s = ::sgn(v.get_num());
00040     if (Policy::has_nan && (nan || sign) && s == 0)
00041       return VC_NAN;
00042     if (!inf && !sign)
00043       return VC_NORMAL;
00044     if (Policy::has_infinity) {
00045       if (s < 0)
00046         return inf ? VC_MINUS_INFINITY : V_LT;
00047       if (s > 0)
00048         return inf ? VC_PLUS_INFINITY : V_GT;
00049     }
00050   }
00051   if (sign)
00052     return sgn<Policy>(v);
00053   return VC_NORMAL;
00054 }

template<typename Policy>
Result Parma_Polyhedra_Library::Checked::classify_mpz ( const mpz_class &  v,
bool  nan,
bool  inf,
bool  sign 
) [inline]

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

References get_mp_size().

00072                                                                 {
00073   if (Policy::has_nan || Policy::has_infinity) {
00074     mp_size_field_t s = get_mp_size(v);
00075     if (Policy::has_nan
00076         && (nan || sign)
00077         && s == C_Integer<mp_size_field_t>::min + 1)
00078       return VC_NAN;
00079     if (!inf && !sign)
00080       return VC_NORMAL;
00081     if (Policy::has_infinity) {
00082       if (s == C_Integer<mp_size_field_t>::min)
00083         return inf ? VC_MINUS_INFINITY : V_LT;
00084       if (s == C_Integer<mp_size_field_t>::max)
00085         return inf ? VC_PLUS_INFINITY : V_GT;
00086     }
00087   }
00088   if (sign)
00089     return sgn<Policy>(v);
00090   return VC_NORMAL;
00091 }

template<typename Policy1, typename Policy2, typename Type>
Result Parma_Polyhedra_Library::Checked::cmp_float ( const Type  x,
const Type  y 
) [inline]

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

00620                                       {
00621   if (x > y)
00622     return V_GT;
00623   if (x < y)
00624     return V_LT;
00625   if (x == y)
00626     return V_EQ;
00627   return V_UNORD_COMP;
00628 }

template<typename Policy1, typename Policy2, typename Type1, typename Type2>
Result Parma_Polyhedra_Library::Checked::cmp_generic ( const Type1 &  x,
const Type2 &  y 
) [inline]

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

00576                                             {
00577   if (lt(y, x))
00578     return V_GT;
00579   if (lt(x, y))
00580     return V_LT;
00581   return V_EQ;
00582 }

template<typename Policy1, typename Policy2, typename Type>
Result Parma_Polyhedra_Library::Checked::cmp_mp ( const Type &  x,
const Type &  y 
) [inline]

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

References Parma_Polyhedra_Library::cmp().

00538                                      {
00539   int i = ::cmp(x, y);
00540   return i > 0 ? V_GT : i == 0 ? V_EQ : V_LT;
00541 }

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 131 of file checked_mpq.inlines.hh.

00131                                                                   {
00132   new (&to) mpq_class(from);
00133   return V_EQ;
00134 }

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 148 of file checked_mpq.inlines.hh.

00148                                                                        {
00149   if (is_nan<From_Policy>(from))
00150     return construct_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
00151   else if (is_minf<From_Policy>(from))
00152     return construct_special<To_Policy>(to, VC_MINUS_INFINITY, dir);
00153   else if (is_pinf<From_Policy>(from))
00154     return construct_special<To_Policy>(to, VC_PLUS_INFINITY, dir);
00155   new (&to) mpq_class(from);
00156   return V_EQ;
00157 }

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 171 of file checked_mpz.inlines.hh.

00171                                                                  {
00172     new (&to) mpz_class(from);
00173     return V_EQ;
00174 }

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 187 of file checked_mpz.inlines.hh.

References rint().

00187                                                                        {
00188   if (is_nan<From_Policy>(from))
00189     return construct_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
00190   else if (is_minf<From_Policy>(from))
00191     return construct_special<To_Policy>(to, VC_MINUS_INFINITY, dir);
00192   else if (is_pinf<From_Policy>(from))
00193     return construct_special<To_Policy>(to, VC_PLUS_INFINITY, dir);
00194   if (round_ignore(dir)) {
00195     new (&to) mpz_class(from);
00196     return V_LGE;
00197   }
00198   From n = rint(from);
00199   new (&to) mpz_class(n);
00200   if (from < n)
00201     return round_lt_mpz<To_Policy>(to, dir);
00202   else if (from > n)
00203     return round_gt_mpz<To_Policy>(to, dir);
00204   else
00205     return V_EQ;
00206 }

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 225 of file checked.inlines.hh.

00225                                          {
00226   to = from;
00227 }

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 155 of file checked_mpz.inlines.hh.

References get_mp_size(), and set_mp_size().

00155                                                {
00156   if (is_nan_mpz<From_Policy>(from))
00157     assert(To_Policy::has_nan);
00158   else if (is_minf_mpz<From_Policy>(from) || is_pinf_mpz<From_Policy>(from))
00159     assert(To_Policy::has_infinity);
00160   else {
00161     to = from;
00162     return;
00163   }
00164   set_mp_size(to, get_mp_size(from));
00165 }

template<typename To_Policy, typename From_Policy, typename Type>
Result Parma_Polyhedra_Library::Checked::div2exp_float ( Type &  to,
const Type  x,
int  exp,
Rounding_Dir  dir 
) [inline]

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

00574                                                                  {
00575   if (To_Policy::check_nan_result && is_nan<From_Policy>(x))
00576     return assign_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
00577   if (exp < 0)
00578     return mul2exp<To_Policy, From_Policy>(to, x, -exp, dir);
00579   assert(static_cast<unsigned int>(exp) < sizeof(unsigned long long) * 8);
00580   return div<To_Policy, From_Policy, Float_2exp>(to, x, static_cast<Type>(1ULL << exp), dir);
00581 }

template<typename To_Policy, typename From_Policy>
Result Parma_Polyhedra_Library::Checked::div2exp_mpq ( mpq_class &  to,
const mpq_class &  x,
int  exp,
Rounding_Dir  dir 
) [inline]

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

00342                                                                           {
00343   if (exp < 0)
00344     return mul2exp<To_Policy, From_Policy>(to, x, -exp, dir);
00345   to.get_num() = x.get_num();
00346   mpz_mul_2exp(to.get_den().get_mpz_t(), x.get_den().get_mpz_t(), exp);
00347   to.canonicalize();
00348   return V_EQ;
00349 }

template<typename To_Policy, typename From_Policy>
Result Parma_Polyhedra_Library::Checked::div2exp_mpz ( mpz_class &  to,
const mpz_class &  x,
int  exp,
Rounding_Dir  dir 
) [inline]

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

00428                                                                           {
00429   if (exp < 0)
00430     return mul2exp<To_Policy, From_Policy>(to, x, -exp, dir);
00431   mpz_srcptr n = x.get_mpz_t();
00432   if (round_ignore(dir)) {
00433     mpz_tdiv_q_2exp(to.get_mpz_t(), x.get_mpz_t(), exp);
00434     return V_LGE;
00435   }
00436   if (round_down(dir)) {
00437     mpz_fdiv_q_2exp(to.get_mpz_t(), n, exp);
00438     return mpz_divisible_2exp_p(n, exp) ? V_EQ : V_GT;
00439   }
00440   else {
00441     assert(round_up(dir));
00442     mpz_cdiv_q_2exp(to.get_mpz_t(), n, exp);
00443     return mpz_divisible_2exp_p(n, exp) ? V_EQ : V_LT;
00444   }
00445 }

template<typename To_Policy, typename From_Policy, typename Type>
Result Parma_Polyhedra_Library::Checked::div2exp_signed_int ( Type &  to,
const Type  x,
int  exp,
Rounding_Dir  dir 
) [inline]

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

01098                                                                       {
01099   if (exp < 0)
01100     return mul2exp<To_Policy, From_Policy>(to, x, -exp, dir);
01101   if (static_cast<unsigned int>(exp) >= sizeof(Type) * 8) {
01102   zero:
01103     to = 0;
01104     if (round_ignore(dir))
01105       return V_LGE;
01106     if (x < 0)
01107       return round_lt_int_no_overflow<To_Policy>(to, dir);
01108     else if (x > 0)
01109       return round_gt_int_no_overflow<To_Policy>(to, dir);
01110     else
01111       return V_EQ;
01112   }
01113   if (static_cast<unsigned int>(exp) >= sizeof(Type) * 8 - 1) {
01114     if (x == C_Integer<Type>::min) {
01115       to = -1;
01116       return V_EQ;
01117     }
01118     goto zero;
01119   }
01120 #if 0
01121   to = x / (static_cast<Type>(1) << exp);
01122   if (round_ignore(dir))
01123     return V_GE;
01124   Type r = x % (static_cast<Type>(1) << exp);
01125   if (r < 0)
01126     return round_lt_int_no_overflow<To_Policy>(to, dir);
01127   else if (r > 0)
01128     return round_gt_int_no_overflow<To_Policy>(to, dir);
01129   else
01130     return V_EQ;
01131 #else
01132   // Faster but compiler implementation dependent (see C++98 5.8.3)
01133   to = x >> exp;
01134   if (round_ignore(dir))
01135     return V_GE;
01136   if (x & ((static_cast<Type>(1) << exp) - 1))
01137     return round_gt_int_no_overflow<To_Policy>(to, dir);
01138   return V_EQ;
01139 #endif
01140 }

template<typename To_Policy, typename From_Policy, typename Type>
Result Parma_Polyhedra_Library::Checked::div2exp_unsigned_int ( Type &  to,
const Type  x,
int  exp,
Rounding_Dir  dir 
) [inline]

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

01076                                                                         {
01077   if (exp < 0)
01078     return mul2exp<To_Policy, From_Policy>(to, x, -exp, dir);
01079   if (static_cast<unsigned int>(exp) >= sizeof(Type) * 8) {
01080     to = 0;
01081     if (round_ignore(dir))
01082       return V_GE;
01083     if (x == 0)
01084       return V_EQ;
01085     return round_gt_int_no_overflow<To_Policy>(to, dir);
01086   }
01087   to = x >> exp;
01088   if (round_ignore(dir))
01089     return V_GE;
01090   if (x & ((static_cast<Type>(1) << exp) - 1))
01091     return round_gt_int_no_overflow<To_Policy>(to, dir);
01092   else
01093     return V_EQ;
01094 }

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 498 of file checked_float.inlines.hh.

References fpu_direct_rounding(), fpu_inverse_rounding(), and limit_precision().

00498                                                                   {
00499   if (To_Policy::check_inf_div_inf
00500       && is_inf_float<From1_Policy>(x) && is_inf_float<From2_Policy>(y))
00501     return assign_special<To_Policy>(to, V_INF_DIV_INF, ROUND_IGNORE);
00502   if (To_Policy::check_div_zero && y == 0)
00503     return assign_special<To_Policy>(to, V_DIV_ZERO, ROUND_IGNORE);
00504   prepare_inexact<To_Policy>(dir);
00505   if (fpu_direct_rounding(dir))
00506     to = x / y;
00507   else if (fpu_inverse_rounding(dir))
00508     to = -limit_precision(x / -y);
00509   else {
00510     fpu_rounding_control_word_type old = fpu_save_rounding_direction(round_fpu_dir(dir));
00511     avoid_cse(x);
00512     avoid_cse(y);
00513     to = x / y;
00514     avoid_cse(to);
00515     fpu_restore_rounding_direction(old);
00516   }
00517   if (To_Policy::check_nan_result && is_nan<To_Policy>(to))
00518     return VC_NAN;
00519   return result_relation<To_Policy>(dir);
00520 }

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 295 of file checked_mpq.inlines.hh.

References CHECK_P.

00295                                                                              {
00296   if (CHECK_P(To_Policy::check_div_zero, sgn(y) == 0))
00297     return assign_special<To_Policy>(to, V_DIV_ZERO, ROUND_IGNORE);
00298   to = x / y;
00299   return V_EQ;
00300 }

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 366 of file checked_mpz.inlines.hh.

References CHECK_P.

00367                           {
00368   if (CHECK_P(To_Policy::check_div_zero, ::sgn(y) == 0))
00369     return assign_special<To_Policy>(to, V_DIV_ZERO, ROUND_IGNORE);
00370   mpz_srcptr n = x.get_mpz_t();
00371   mpz_srcptr d = y.get_mpz_t();
00372   if (round_ignore(dir)) {
00373     // FIXME: is this correct?
00374     mpz_divexact(to.get_mpz_t(), n, d);
00375     return V_LGE;
00376   }
00377   if (round_down(dir)) {
00378     mpz_fdiv_q(to.get_mpz_t(), n, d);
00379     return mpz_divisible_p(n, d) ? V_EQ : V_GT;
00380   }
00381   else {
00382     assert(round_up(dir));
00383     mpz_cdiv_q(to.get_mpz_t(), n, d);
00384     return mpz_divisible_p(n, d) ? V_EQ : V_LT;
00385   }
00386 }

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 1005 of file checked_int.inlines.hh.

References CHECK_P.

01005                                                                        {
01006   if (CHECK_P(To_Policy::check_div_zero, y == 0))
01007     return assign_special<To_Policy>(to, V_DIV_ZERO, ROUND_IGNORE);
01008   if (To_Policy::check_overflow && y == -1)
01009     return neg_signed_int<To_Policy, From1_Policy>(to, x, dir);
01010   to = x / y;
01011   if (round_ignore(dir))
01012     return V_LGE;
01013   Type m = x % y;
01014   if (m < 0)
01015     return round_lt_int_no_overflow<To_Policy>(to, dir);
01016   else if (m > 0)
01017     return round_gt_int_no_overflow<To_Policy>(to, dir);
01018   else
01019     return V_EQ;
01020 }

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 1024 of file checked_int.inlines.hh.

References CHECK_P.

01024                                                                          {
01025   if (CHECK_P(To_Policy::check_div_zero, y == 0))
01026     return assign_special<To_Policy>(to, V_DIV_ZERO, ROUND_IGNORE);
01027   to = x / y;
01028   if (round_ignore(dir))
01029     return V_GE;
01030   Type m = x % y;
01031   if (m == 0)
01032     return V_EQ;
01033   return round_gt_int<To_Policy>(to, dir);
01034 }

template<typename U, typename S>
Enable_If<(!Safe_Int_Comparison<S, U>::value && C_Integer<U>::value && C_Integer<S>::is_signed), bool>::type Parma_Polyhedra_Library::Checked::eq ( const U &  x,
const S &  y 
) [inline]

template<typename S, typename U>
Enable_If<(!Safe_Int_Comparison<S, U>::value && C_Integer<U>::value && C_Integer<S>::is_signed), bool>::type Parma_Polyhedra_Library::Checked::eq ( const S &  x,
const U &  y 
) [inline]

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

00490                            {
00491   return x >= 0 && x == y;
00492 }

template<typename T1, typename T2>
Enable_If<(!Safe_Conversion< T1, T2 >::value &&!Safe_Conversion< T2, T1 >::value &&(!C_Integer< T1 >::value||!C_Integer< T2 >::value)), bool >::type Parma_Polyhedra_Library::Checked::eq ( const T1 &  x,
const T2 &  y 
) [inline]

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

00450                              {
00451   return x == y;
00452 }

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 569 of file checked.inlines.hh.

00569                                      {
00570   return eq(x, y);
00571 }

template<typename To_Policy, typename From_Policy, typename Type>
Result Parma_Polyhedra_Library::Checked::floor_float ( Type &  to,
const Type  from,
Rounding_Dir   
) [inline]

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

References fpu_direct_rounding(), fpu_inverse_rounding(), limit_precision(), and rint().

00363                                                      {
00364   if (To_Policy::check_nan_result && is_nan<From_Policy>(from))
00365     return assign_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
00366   if (fpu_direct_rounding(ROUND_DOWN))
00367     to = rint(from);
00368   else if (fpu_inverse_rounding(ROUND_DOWN))
00369     to = -limit_precision(rint(-from));
00370   else {
00371     fpu_rounding_control_word_type old = fpu_save_rounding_direction(round_fpu_dir(ROUND_DOWN));
00372     avoid_cse(from);
00373     to = rint(from);
00374     avoid_cse(to);
00375     fpu_restore_rounding_direction(old);
00376   }
00377   return V_EQ;
00378 }

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 226 of file checked_mpq.inlines.hh.

00226                                                               {
00227   mpz_fdiv_q(to.get_num().get_mpz_t(),
00228              from.get_num().get_mpz_t(), from.get_den().get_mpz_t());
00229   to.get_den() = 1;
00230   return V_EQ;
00231 }

long double Parma_Polyhedra_Library::Checked::fma ( long double  x,
long double  y,
long double  z 
) [inline]

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

Referenced by fma().

00053                                                  {
00054 #if PPL_HAVE_DECL_FMAL && !defined(__alpha)
00055   return ::fmal(x, y, z);
00056 #else
00057   return x*y + z;
00058 #endif
00059 }

double Parma_Polyhedra_Library::Checked::fma ( double  x,
double  y,
double  z 
) [inline]

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

References fma().

00044                                   {
00045 #if PPL_HAVE_DECL_FMA && !defined(__alpha)
00046   return ::fma(x, y, z);
00047 #else
00048   return x*y + z;
00049 #endif
00050 }

float Parma_Polyhedra_Library::Checked::fma ( float  x,
float  y,
float  z 
) [inline]

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

Referenced by add_mul_float(), and sub_mul_float().

00035                                {
00036 #if PPL_HAVE_DECL_FMAF && !defined(__alpha)
00037   return ::fmaf(x, y, z);
00038 #else
00039   return x*y + z;
00040 #endif
00041 }

bool Parma_Polyhedra_Library::Checked::fpu_direct_rounding ( Rounding_Dir  dir  )  [inline]

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

Referenced by add_float(), add_mul_float(), assign_float_float_inexact(), assign_float_int_inexact(), ceil_float(), div_float(), floor_float(), mul_float(), sqrt_float(), sub_float(), and sub_mul_float().

00097                                       {
00098   return round_direct(dir) || round_ignore(dir);
00099 }

bool Parma_Polyhedra_Library::Checked::fpu_inverse_rounding ( Rounding_Dir  dir  )  [inline]

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

Referenced by add_float(), add_mul_float(), assign_float_float_inexact(), ceil_float(), div_float(), floor_float(), mul_float(), sub_float(), and sub_mul_float().

00102                                        {
00103   return round_inverse(dir);
00104 }

template<typename To_Policy, typename To>
struct Parma_Polyhedra_Library::Checked::FUNCTION_CLASS ( construct_special   )  [read]

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

00209                                          {
00210   static inline Result function(To& to, Result r, Rounding_Dir dir) {
00211     new (&to) To();
00212     return assign_special<To_Policy>(to, r, dir);
00213   }
00214 };

template<typename Policy, typename Type>
struct Parma_Polyhedra_Library::Checked::FUNCTION_CLASS ( construct   )  [read]

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

00201                                  {
00202   static inline Result function(To& to, const From& from, Rounding_Dir dir) {
00203     new (&to) To();
00204     return assign<To_Policy, From_Policy>(to, from, dir);
00205   }
00206 };

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 290 of file checked.inlines.hh.

00290                                                                     {
00291   gcd_exact_noabs<To_Policy, From1_Policy, From2_Policy>(to, x, y);
00292   return abs<To_Policy, To_Policy>(to, to, dir);
00293 }

template<typename To_Policy, typename From1_Policy, typename From2_Policy, typename To, typename From>
void Parma_Polyhedra_Library::Checked::gcd_exact_noabs ( To &  to,
const From &  x,
const From &  y 
) [inline]

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

00272                                                       {
00273   To nx = x;
00274   To ny = y;
00275   To rm;
00276   while (ny != 0) {
00277     // The following is derived from the assumption that x % y
00278     // is always representable. This is true for both native integers
00279     // and IEC 559 floating point numbers.
00280     rem<To_Policy, From1_Policy, From2_Policy>(rm, nx, ny, ROUND_NOT_NEEDED);
00281     nx = ny;
00282     ny = rm;
00283   }
00284   to = nx;
00285 }

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 480 of file checked_mpz.inlines.hh.

00480                                                                              {
00481   mpz_gcd(to.get_mpz_t(), x.get_mpz_t(), y.get_mpz_t());
00482   return V_EQ;
00483 }

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 300 of file checked.inlines.hh.

00301                                {
00302   // In case this becomes a bottleneck, we may consider using the
00303   // Stehle'-Zimmermann algorithm (see R. Crandall and C. Pomerance,
00304   // Prime Numbers - A Computational Perspective, Second Edition,
00305   // Springer, 2005).
00306   if (y == 0) {
00307     if (x == 0) {
00308       s = 0;
00309       t = 1;
00310       return V_EQ;
00311     }
00312     else {
00313       if (x < 0)
00314         s = -1;
00315       else
00316         s = 1;
00317       t = 0;
00318       return abs<To1_Policy, From1_Policy>(to, x, dir);
00319     }
00320   }
00321 
00322   s = 1;
00323   t = 0;
00324   bool negative_x = x < 0;
00325   bool negative_y = y < 0;
00326 
00327   Result r;
00328   r = abs<To1_Policy, From1_Policy>(to, x, dir);
00329   if (r != V_EQ)
00330     return r;
00331 
00332   From2 ay;
00333   r = abs<To1_Policy, From2_Policy>(ay, y, dir);
00334   if (r != V_EQ)
00335     return r;
00336 
00337   // If COPY_GMP is defined then s is favored when the absolute
00338   // values of the given numbers are equal.  For instance if x and y
00339   // are both 5 then s will be 1 and t will be 0, instead of the other
00340   // way round.  This is to match the behavior of GMP.
00341 #define COPY_GMP
00342 #ifdef COPY_GMP
00343   if (to == ay)
00344     goto sign_check;
00345 #endif
00346 
00347   {
00348     To2 v1 = 0;
00349     To3 v2 = 1;
00350     To1 v3 = static_cast<To1>(ay);
00351     while (true) {
00352       To1 q = to / v3;
00353       // Remainder, next candidate GCD.
00354       To1 t3 = to - q*v3;
00355       To2 t1 = s - static_cast<To2>(q)*v1;
00356       To3 t2 = t - static_cast<To3>(q)*v2;
00357       s = v1;
00358       t = v2;
00359       to = v3;
00360       if (t3 == 0)
00361         break;
00362       v1 = t1;
00363       v2 = t2;
00364       v3 = t3;
00365     }
00366   }
00367 
00368 #ifdef COPY_GMP
00369  sign_check:
00370 #endif
00371   if (negative_x) {
00372     r = neg<To2_Policy, To2_Policy>(s, s, dir);
00373     if (r != V_EQ)
00374       return r;
00375   }
00376   if (negative_y)
00377     return neg<To3_Policy, To3_Policy>(t, t, dir);
00378   return V_EQ;
00379 }

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 489 of file checked_mpz.inlines.hh.

00491                          {
00492   mpz_gcdext(to.get_mpz_t(), s.get_mpz_t(), t.get_mpz_t(),
00493              x.get_mpz_t(), y.get_mpz_t());
00494   return V_EQ;
00495 }

int Parma_Polyhedra_Library::Checked::get_digit ( int  c,
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 48 of file checked.cc.

Referenced by parse_number_part().

00048                                 {
00049   if (c >= '0' && c < '0' + (base > 10 ? 10 : base))
00050     return c - '0';
00051   if (base > 10) {
00052     base -= 10;
00053     if (c >= 'A' && c < 'A' + base)
00054       return c - 'A' + 10;
00055     if (c >= 'a' && c < 'a' + base)
00056       return c - 'a' + 10;
00057   }
00058   return -1;
00059 }

mp_size_field_t Parma_Polyhedra_Library::Checked::get_mp_size ( const mpz_class &  v  )  [inline]

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

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

00061                                 {
00062   return v.get_mpz_t()->_mp_size;
00063 }

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 525 of file checked_float.inlines.hh.

00525                                                                    {
00526   Type temp;
00527   // The inexact check is useless
00528   dir = round_dir(dir);
00529   Result r = div<To_Policy, From1_Policy, From2_Policy>(temp, x, y, dir);
00530   if (is_special(r)) {
00531     to = temp;
00532     return r;
00533   }
00534   Result r1 = trunc<To_Policy, To_Policy>(to, temp, ROUND_NOT_NEEDED);
00535   assert(r1 == V_EQ);
00536   if (r == V_EQ || to != temp)
00537     return r1;
00538   // FIXME: Prove that it's impossibile to return a strict relation
00539   return dir == ROUND_UP ? V_LE : V_GE;
00540 }

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 306 of file checked_mpq.inlines.hh.

References CHECK_P.

00306                                                                                   {
00307   if (CHECK_P(To_Policy::check_div_zero, sgn(y) == 0))
00308     return assign_special<To_Policy>(to, V_DIV_ZERO, ROUND_IGNORE);
00309   to = x / y;
00310   return trunc<To_Policy, To_Policy>(to, to, dir);
00311 }

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 392 of file checked_mpz.inlines.hh.

References CHECK_P.

00393                       {
00394   if (CHECK_P(To_Policy::check_div_zero, ::sgn(y) == 0))
00395     return assign_special<To_Policy>(to, V_DIV_ZERO, ROUND_IGNORE);
00396   mpz_srcptr n = x.get_mpz_t();
00397   mpz_srcptr d = y.get_mpz_t();
00398   mpz_tdiv_q(to.get_mpz_t(), n, d);
00399   return V_EQ;
00400 }

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 1038 of file checked_int.inlines.hh.

References CHECK_P.

01038                                                                         {
01039   if (CHECK_P(To_Policy::check_div_zero, y == 0))
01040     return assign_special<To_Policy>(to, V_DIV_ZERO, ROUND_IGNORE);
01041   if (To_Policy::check_overflow && y == -1)
01042     return neg_signed_int<To_Policy, From1_Policy>(to, x, dir);
01043   to = x / y;
01044   return V_EQ;
01045 }

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 1049 of file checked_int.inlines.hh.

References CHECK_P.

01049                                                                       {
01050   if (CHECK_P(To_Policy::check_div_zero, y == 0))
01051     return assign_special<To_Policy>(to, V_DIV_ZERO, ROUND_IGNORE);
01052   to = x / y;
01053   return V_EQ;
01054 }

template<typename Policy, typename Type>
Result Parma_Polyhedra_Library::Checked::input_generic ( Type &  to,
std::istream &  is,
Rounding_Dir  dir 
) [inline]

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

00586                                                           {
00587   DIRTY_TEMP0(mpq_class, q);
00588   Result r = input_mpq(q, is);
00589   if (is_special(r))
00590     return assign_special<Policy>(to, r, dir);
00591   if (r == V_EQ)
00592     return assign<Policy, void>(to, q, dir);
00593   assert(0);
00594   return VC_NAN;
00595 }

template<typename Policy>
Result Parma_Polyhedra_Library::Checked::input_mpq ( mpq_class &  to,
std::istream &  is,
Rounding_Dir   
) [inline]

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

References input_mpq().

00407                                                        {
00408   Result r = input_mpq(to, is);
00409   switch (classify(r)) {
00410   case VC_MINUS_INFINITY:
00411   case VC_PLUS_INFINITY:
00412   case VC_NAN:
00413     return assign_special<Policy>(to, r, ROUND_IGNORE);
00414   default:
00415     return r;
00416   }
00417 }

Result Parma_Polyhedra_Library::Checked::input_mpq ( mpq_class &  to,
std::istream &  is 
)

Definition at line 308 of file checked.cc.

References Parma_Polyhedra_Library::Checked::number_struct::base, 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, and parse_number().

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

00308                                          {
00309   number_struct num_struct;
00310   number_struct den_struct;
00311   Result r = parse_number(is, num_struct, den_struct);
00312   if (r != V_EQ)
00313     return r;
00314   if (den_struct.base && den_struct.mantissa.empty())
00315       return VC_NAN;
00316   if (num_struct.mantissa.empty()) {
00317     to = 0;
00318     return V_EQ;
00319   }
00320   mpz_ptr num = to.get_num().get_mpz_t();
00321   mpz_ptr den = to.get_den().get_mpz_t();
00322   mpz_set_str(num, num_struct.mantissa.c_str(), num_struct.base);
00323   if (den_struct.base) {
00324     if (num_struct.neg_mantissa ^ den_struct.neg_mantissa)
00325       mpz_neg(num, num);
00326     mpz_set_str(den, den_struct.mantissa.c_str(), den_struct.base);
00327     if (num_struct.exponent || den_struct.exponent) {
00328       // Multiply the exponents into the numerator and denominator.
00329       mpz_t z;
00330       mpz_init(z);
00331       if (num_struct.exponent) {
00332         mpz_ui_pow_ui(z, num_struct.base, num_struct.exponent);
00333         if (num_struct.neg_exponent)
00334           mpz_mul(den, den, z);
00335         else
00336           mpz_mul(num, num, z);
00337       }
00338       if (den_struct.exponent) {
00339         mpz_ui_pow_ui(z, den_struct.base, den_struct.exponent);
00340         if (den_struct.neg_exponent)
00341           mpz_mul(num, num, z);
00342         else
00343           mpz_mul(den, den, z);
00344       }
00345       mpz_clear(z);
00346     }
00347   }
00348   else {
00349     if (num_struct.neg_mantissa)
00350       mpz_neg(num, num);
00351     if (num_struct.exponent) {
00352       if (num_struct.neg_exponent) {
00353         // Add the negative exponent as a denominator.
00354         mpz_ui_pow_ui(den, num_struct.base, num_struct.exponent);
00355         goto end;
00356       }
00357       // Multiply the exponent into the numerator.
00358       mpz_t z;
00359       mpz_init(z);
00360       mpz_ui_pow_ui(z, num_struct.base, num_struct.exponent);
00361       mpz_mul(num, num, z);
00362       mpz_clear(z);
00363     }
00364     mpz_set_ui(den, 1);
00365     return V_EQ;
00366   }
00367  end:
00368   // GMP operators require rationals in canonical form.
00369   to.canonicalize();
00370   return V_EQ;
00371 }

template<typename Policy, typename T>
int Parma_Polyhedra_Library::Checked::is_inf_float ( const T  v  )  [inline]

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

References CHECK_P.

00181                         {
00182   Float<T> f(v);
00183   return CHECK_P(Policy::has_infinity, f.u.binary.is_inf());
00184 }

template<typename Policy, typename T>
bool Parma_Polyhedra_Library::Checked::is_int_float ( const T  v  )  [inline]

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

References rint().

00200                         {
00201   return rint(v) == v;
00202 }

template<typename Policy, typename Type>
bool Parma_Polyhedra_Library::Checked::is_int_int ( const Type  v  )  [inline]

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

00280                          {
00281   return !is_nan<Policy>(v);
00282 }

template<typename Policy>
bool Parma_Polyhedra_Library::Checked::is_int_mpq ( const mpq_class &  v  )  [inline]

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

00090                                {
00091   if ((Policy::has_infinity || Policy::has_nan)
00092       && ::sgn(v.get_den()) == 0)
00093     return !(Policy::has_nan && ::sgn(v.get_num()) == 0);
00094   else
00095     return v.get_den() == 1;
00096 }

template<typename Policy>
bool Parma_Polyhedra_Library::Checked::is_int_mpz ( const mpz_class &  v  )  [inline]

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

00124                                {
00125   return !is_nan<Policy>(v);
00126 }

template<typename Policy, typename T>
bool Parma_Polyhedra_Library::Checked::is_minf_float ( const T  v  )  [inline]

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

00187                          {
00188   return is_inf_float<Policy>(v) < 0;
00189 }

template<typename Policy, typename Type>
bool Parma_Polyhedra_Library::Checked::is_minf_int ( const Type  v  )  [inline]

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

00244                           {
00245   return Policy::has_infinity
00246     && v == Extended_Int<Policy, Type>::minus_infinity;
00247 }

template<typename Policy>
bool Parma_Polyhedra_Library::Checked::is_minf_mpq ( const mpq_class &  v  )  [inline]

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

00070                                 {
00071   return Policy::has_infinity
00072     && ::sgn(v.get_den()) == 0
00073     && ::sgn(v.get_num()) < 0;
00074 }

template<typename Policy>
bool Parma_Polyhedra_Library::Checked::is_minf_mpz ( const mpz_class &  v  )  [inline]

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

References get_mp_size().

00106                                 {
00107   return Policy::has_infinity
00108     && get_mp_size(v) == C_Integer<mp_size_field_t>::min;
00109 }

template<typename Policy, typename T>
bool Parma_Polyhedra_Library::Checked::is_nan_float ( const T  v  )  [inline]

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

References CHECK_P.

00174                         {
00175   Float<T> f(v);
00176   return CHECK_P(Policy::has_nan, f.u.binary.is_nan());
00177 }

template<typename Policy, typename Type>
bool Parma_Polyhedra_Library::Checked::is_nan_int ( const Type  v  )  [inline]

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

00227                          {
00228   return Policy::has_nan && v == Extended_Int<Policy, Type>::not_a_number;
00229 }

template<typename Policy>
bool Parma_Polyhedra_Library::Checked::is_nan_mpq ( const mpq_class &  v  )  [inline]

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

00060                                {
00061   return Policy::has_nan
00062     && ::sgn(v.get_den()) == 0
00063     && ::sgn(v.get_num()) == 0;
00064 }

template<typename Policy>
bool Parma_Polyhedra_Library::Checked::is_nan_mpz ( const mpz_class &  v  )  [inline]

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

References get_mp_size().

00097                                {
00098   return Policy::has_nan
00099     && get_mp_size(v) == C_Integer<mp_size_field_t>::min + 1;
00100 }

template<typename Policy, typename T>
bool Parma_Polyhedra_Library::Checked::is_pinf_float ( const T  v  )  [inline]

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

00193                          {
00194   return is_inf_float<Policy>(v) > 0;
00195 }

template<typename Policy, typename Type>
bool Parma_Polyhedra_Library::Checked::is_pinf_int ( const Type  v  )  [inline]

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

00262                           {
00263   return Policy::has_infinity
00264     && v == Extended_Int<Policy, Type>::plus_infinity;
00265 }

template<typename Policy>
bool Parma_Polyhedra_Library::Checked::is_pinf_mpq ( const mpq_class &  v  )  [inline]

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

00080                                 {
00081   return Policy::has_infinity
00082     && ::sgn(v.get_den()) == 0
00083     && ::sgn(v.get_num()) > 0;
00084 }

template<typename Policy>
bool Parma_Polyhedra_Library::Checked::is_pinf_mpz ( const mpz_class &  v  )  [inline]

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

References get_mp_size().

00115                                 {
00116   return Policy::has_infinity
00117     && get_mp_size(v) == C_Integer<mp_size_field_t>::max;
00118 }

template<typename Type>
void Parma_Polyhedra_Library::Checked::isqrtrem ( Type &  q,
Type &  r,
const Type  from 
) [inline]

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

Referenced by sqrt_unsigned_int().

01209                                             {
01210   q = 0;
01211   r = from;
01212   Type t(1);
01213   for (t <<= 8 * sizeof(Type) - 2; t != 0; t >>= 2) {
01214     Type s = q + t;
01215     if (s <= r) {
01216       r -= s;
01217       q = s + t;
01218     }
01219     q >>= 1;
01220   }
01221 }

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 384 of file checked.inlines.hh.

00384                                                                         {
00385   if (x == 0 || y == 0) {
00386     to = 0;
00387     return V_EQ;
00388   }
00389   To nx, ny;
00390   Result r;
00391   r = abs<From1_Policy, From1_Policy>(nx, x, dir);
00392   if (r != V_EQ)
00393     return r;
00394   r = abs<From2_Policy, From2_Policy>(ny, y, dir);
00395   if (r != V_EQ)
00396     return r;
00397   To gcd;
00398   gcd_exact_noabs<To_Policy, From1_Policy, From2_Policy>(gcd, nx, ny);
00399   // The following is derived from the assumption that x / gcd(x, y)
00400   // is always representable. This is true for both native integers
00401   // and IEC 559 floating point numbers.
00402   div<To_Policy, From1_Policy, To_Policy>(to, nx, gcd, ROUND_NOT_NEEDED);
00403   return mul<To_Policy, To_Policy, From2_Policy>(to, to, ny, dir);
00404 }

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 501 of file checked_mpz.inlines.hh.

00501                                                                              {
00502   mpz_lcm(to.get_mpz_t(), x.get_mpz_t(), y.get_mpz_t());
00503   return V_EQ;
00504 }

template<typename U, typename S>
Enable_If<(!Safe_Int_Comparison<S, U>::value && C_Integer<U>::value && C_Integer<S>::is_signed), bool>::type Parma_Polyhedra_Library::Checked::le ( const U &  x,
const S &  y 
) [inline]

template<typename S, typename U>
Enable_If<(!Safe_Int_Comparison<S, U>::value && C_Integer<U>::value && C_Integer<S>::is_signed), bool>::type Parma_Polyhedra_Library::Checked::le ( const S &  x,
const U &  y 
) [inline]

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

00474                            {
00475   return x < 0 || x <= y;
00476 }

template<typename T1, typename T2>
Enable_If<(!Safe_Conversion< T1, T2 >::value &&!Safe_Conversion< T2, T1 >::value &&(!C_Integer< T1 >::value||!C_Integer< T2 >::value)), bool >::type Parma_Polyhedra_Library::Checked::le ( const T1 &  x,
const T2 &  y 
) [inline]

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

00443                              {
00444   return x <= y;
00445 }

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 562 of file checked.inlines.hh.

00562                                      {
00563   return le(x, y);
00564 }

long double Parma_Polyhedra_Library::Checked::limit_precision ( long double  v  )  [inline]

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

00145                                {
00146   return v;
00147 }

double Parma_Polyhedra_Library::Checked::limit_precision ( double  v  )  [inline]

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

00138                           {
00139   double x = v;
00140   avoid_cse(x);
00141   return x;
00142 }

float Parma_Polyhedra_Library::Checked::limit_precision ( float  v  )  [inline]

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

Referenced by add_float(), add_mul_float(), ceil_float(), div_float(), floor_float(), mul_float(), sub_float(), and sub_mul_float().

00131                          {
00132   float x = v;
00133   avoid_cse(x);
00134   return x;
00135 }

template<typename U, typename S>
Enable_If<(!Safe_Int_Comparison<S, U>::value && C_Integer<U>::value && C_Integer<S>::is_signed), bool>::type Parma_Polyhedra_Library::Checked::lt ( const U &  x,
const S &  y 
) [inline]

template<typename S, typename U>
Enable_If<(!Safe_Int_Comparison<S, U>::value && C_Integer<U>::value && C_Integer<S>::is_signed), bool>::type Parma_Polyhedra_Library::Checked::lt ( const S &  x,
const U &  y 
) [inline]

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

00458                            {
00459   return x < 0 || x < y;
00460 }

template<typename T1, typename T2>
Enable_If<(!Safe_Conversion< T1, T2 >::value &&!Safe_Conversion< T2, T1 >::value &&(!C_Integer< T1 >::value||!C_Integer< T2 >::value)), bool >::type Parma_Polyhedra_Library::Checked::lt ( const T1 &  x,
const T2 &  y 
) [inline]

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

00436                              {
00437   return x < y;
00438 }

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 555 of file checked.inlines.hh.

00555                                      {
00556   return lt(x, y);
00557 }

template<typename To_Policy, typename From_Policy, typename Type>
Result Parma_Polyhedra_Library::Checked::mul2exp_float ( Type &  to,
const Type  x,
int  exp,
Rounding_Dir  dir 
) [inline]

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

00563                                                                  {
00564   if (To_Policy::check_nan_result && is_nan<From_Policy>(x))
00565     return assign_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
00566   if (exp < 0)
00567     return div2exp<To_Policy, From_Policy>(to, x, -exp, dir);
00568   assert(static_cast<unsigned int>(exp) < sizeof(unsigned long long) * 8);
00569   return mul<To_Policy, From_Policy, Float_2exp>(to, x, static_cast<Type>(1ULL << exp), dir);
00570 }

template<typename To_Policy, typename From_Policy>
Result Parma_Polyhedra_Library::Checked::mul2exp_mpq ( mpq_class &  to,
const mpq_class &  x,
int  exp,
Rounding_Dir  dir 
) [inline]

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

00329                                                                           {
00330   if (exp < 0)
00331     return div2exp<To_Policy, From_Policy>(to, x, -exp, dir);
00332   mpz_mul_2exp(to.get_num().get_mpz_t(), x.get_num().get_mpz_t(), exp);
00333   to.get_den() = x.get_den();
00334   to.canonicalize();
00335   return V_EQ;
00336 }

template<typename To_Policy, typename From_Policy>
Result Parma_Polyhedra_Library::Checked::mul2exp_mpz ( mpz_class &  to,
const mpz_class &  x,
int  exp,
Rounding_Dir  dir 
) [inline]

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

00417                                                                           {
00418   if (exp < 0)
00419     return div2exp<To_Policy, From_Policy>(to, x, -exp, dir);
00420   mpz_mul_2exp(to.get_mpz_t(), x.get_mpz_t(), exp);
00421   return V_EQ;
00422 }

template<typename To_Policy, typename From_Policy, typename Type>
Result Parma_Polyhedra_Library::Checked::mul2exp_signed_int ( Type &  to,
const Type  x,
int  exp,
Rounding_Dir  dir 
) [inline]

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

01169                                                                       {
01170   if (exp < 0)
01171     return div2exp<To_Policy, From_Policy>(to, x, -exp, dir);
01172   if (!To_Policy::check_overflow) {
01173     to = x << exp;
01174     return V_EQ;
01175   }
01176   if (static_cast<unsigned int>(exp) >= sizeof(Type) * 8 - 1) {
01177     if (x < 0)
01178       return set_neg_overflow_int<To_Policy>(to, dir);
01179     else if (x > 0)
01180       return set_pos_overflow_int<To_Policy>(to, dir);
01181     else {
01182       to = 0;
01183       return V_EQ;
01184     }
01185   }
01186   Type mask = ((static_cast<Type>(1) << exp) - 1)
01187     << (sizeof(Type) * 8 - 1 - exp);
01188   Type n;
01189   if (x < 0) {
01190     if ((x & mask) != mask)
01191       return set_neg_overflow_int<To_Policy>(to, dir);
01192     n = x << exp;
01193     if (n < Extended_Int<To_Policy, Type>::min)
01194       return set_neg_overflow_int<To_Policy>(to, dir);
01195   }
01196   else {
01197     if (x & mask)
01198       return set_pos_overflow_int<To_Policy>(to, dir);
01199     n = x << exp;
01200     if (n > Extended_Int<To_Policy, Type>::max)
01201       return set_pos_overflow_int<To_Policy>(to, dir);
01202   }
01203   to = n;
01204   return V_EQ;
01205 }

template<typename To_Policy, typename From_Policy, typename Type>
Result Parma_Polyhedra_Library::Checked::mul2exp_unsigned_int ( Type &  to,
const Type  x,
int  exp,
Rounding_Dir  dir 
) [inline]

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

01144                                                                         {
01145   if (exp < 0)
01146     return div2exp<To_Policy, From_Policy>(to, x, -exp, dir);
01147   if (!To_Policy::check_overflow) {
01148     to = x << exp;
01149     return V_EQ;
01150   }
01151   if (static_cast<unsigned int>(exp) >= sizeof(Type) * 8) {
01152     if (x == 0) {
01153       to = 0;
01154       return V_EQ;
01155     }
01156     return set_pos_overflow_int<To_Policy>(to, dir);
01157   }
01158   if (x & (((static_cast<Type>(1) << exp) - 1) << (sizeof(Type) * 8 - exp)))
01159     return set_pos_overflow_int<To_Policy>(to, dir);
01160   Type n = x << exp;
01161   if (n > Extended_Int<To_Policy, Type>::max)
01162     return set_pos_overflow_int<To_Policy>(to, dir);
01163   to = n;
01164   return V_EQ;
01165 }

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 472 of file checked_float.inlines.hh.

References fpu_direct_rounding(), fpu_inverse_rounding(), and limit_precision().

00472                                                                   {
00473   if (To_Policy::check_inf_mul_zero
00474       && ((x == 0 && is_inf_float<From2_Policy>(y)) ||
00475           (y == 0 && is_inf_float<From1_Policy>(x))))
00476     return assign_special<To_Policy>(to, V_INF_MUL_ZERO, ROUND_IGNORE);
00477   prepare_inexact<To_Policy>(dir);
00478   if (fpu_direct_rounding(dir))
00479     to = x * y;
00480   else if (fpu_inverse_rounding(dir))
00481     to = -limit_precision(x * -y);
00482   else {
00483     fpu_rounding_control_word_type old = fpu_save_rounding_direction(round_fpu_dir(dir));
00484     avoid_cse(x);
00485     avoid_cse(y);
00486     to = x * y;
00487     avoid_cse(to);
00488     fpu_restore_rounding_direction(old);
00489   }
00490   if (To_Policy::check_nan_result && is_nan<To_Policy>(to))
00491     return VC_NAN;
00492   return result_relation<To_Policy>(dir);
00493 }

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 858 of file checked_int.inlines.hh.

00858                                                                        {
00859   typename Larger<Type>::type_for_mul l = x;
00860   l *= y;
00861   return assign<To_Policy, To_Policy>(to, l, dir);
00862 }

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 286 of file checked_mpq.inlines.hh.

00286                                                                              {
00287   to = x * y;
00288   return V_EQ;
00289 }

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 357 of file checked_mpz.inlines.hh.

00357                                                                              {
00358   to = x * y;
00359   return V_EQ;
00360 }

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 947 of file checked_int.inlines.hh.

00947                                                                        {
00948   if (To_Policy::check_overflow && Larger<Type>::use_for_mul)
00949     return mul_int_larger<To_Policy, From1_Policy, From2_Policy>(to, x, y, dir);
00950   if (!To_Policy::check_overflow) {
00951     to = x * y;
00952     return V_EQ;
00953   }
00954   if (y == 0) {
00955     to = 0;
00956     return V_EQ;
00957   }
00958   if (y == -1)
00959     return neg_signed_int<To_Policy, From1_Policy>(to, x, dir);
00960   if (x >= 0) {
00961     if (y > 0) {
00962       if (x > Extended_Int<To_Policy, Type>::max / y)
00963         return set_pos_overflow_int<To_Policy>(to, dir);
00964     }
00965     else {
00966       if (x > Extended_Int<To_Policy, Type>::min / y)
00967         return set_neg_overflow_int<To_Policy>(to, dir);
00968     }
00969   }
00970   else {
00971     if (y < 0) {
00972       if (x < Extended_Int<To_Policy, Type>::max / y)
00973         return set_pos_overflow_int<To_Policy>(to, dir);
00974     }
00975     else {
00976       if (x < Extended_Int<To_Policy, Type>::min / y)
00977         return set_neg_overflow_int<To_Policy>(to, dir);
00978     }
00979   }
00980   to = x * y;
00981   return V_EQ;
00982 }

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 986 of file checked_int.inlines.hh.

00986                                                                          {
00987   if (To_Policy::check_overflow && Larger<Type>::use_for_mul)
00988     return mul_int_larger<To_Policy, From1_Policy, From2_Policy>(to, x, y, dir);
00989   if (!To_Policy::check_overflow) {
00990     to = x * y;
00991     return V_EQ;
00992   }
00993   if (y == 0) {
00994     to = 0;
00995     return V_EQ;
00996   }
00997   if (x > Extended_Int<To_Policy, Type>::max / y)
00998     return set_pos_overflow_int<To_Policy>(to, dir);
00999   to = x * y;
01000   return V_EQ;
01001 }

Result Parma_Polyhedra_Library::Checked::neg ( Result  r  )  [inline]

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

Referenced by parse_number_part(), and sub().

00239               {
00240   assert(!is_special(r));
00241   Result ret = static_cast<Result>(r & V_EQ);
00242   if (r & V_LT)
00243     ret = static_cast<Result>(ret | V_GT);
00244   if (r & V_GT)
00245     ret = static_cast<Result>(ret | V_LT);
00246   return ret;
00247 }

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 412 of file checked_float.inlines.hh.

00412                                                    {
00413   if (To_Policy::check_nan_result && is_nan<From_Policy>(from))
00414     return assign_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
00415   to = -from;
00416   return V_EQ;
00417 }

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 834 of file checked_int.inlines.hh.

00834                                                          {
00835   typename Larger<Type>::type_for_neg l = x;
00836   l = -l;
00837   return assign<To_Policy, To_Policy>(to, l, dir);
00838 }

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 259 of file checked_mpq.inlines.hh.

00259                                                             {
00260   mpq_neg(to.get_mpq_t(), from.get_mpq_t());
00261   return V_EQ;
00262 }

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 330 of file checked_mpz.inlines.hh.

00330                                                             {
00331   mpz_neg(to.get_mpz_t(), from.get_mpz_t());
00332   return V_EQ;
00333 }

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 866 of file checked_int.inlines.hh.

References CHECK_P.

00866                                                             {
00867   if (To_Policy::check_overflow && Larger<Type>::use_for_neg)
00868     return neg_int_larger<To_Policy, From_Policy>(to, from, dir);
00869   if (CHECK_P(To_Policy::check_overflow,
00870               (from < -Extended_Int<To_Policy, Type>::max)))
00871     return set_pos_overflow_int<To_Policy>(to, dir);
00872   to = -from;
00873   return V_EQ;
00874 }

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 878 of file checked_int.inlines.hh.

References CHECK_P.

00878                                                               {
00879   if (To_Policy::check_overflow && Larger<Type>::use_for_neg)
00880     return neg_int_larger<To_Policy, From_Policy>(to, from, dir);
00881   if (CHECK_P(To_Policy::check_overflow, from != 0))
00882     return set_neg_overflow_int<To_Policy>(to, dir);
00883   to = from;
00884   return V_EQ;
00885 }

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 1291 of file checked_int.inlines.hh.

01292                                                  {
01293   os << static_cast<int>(from);
01294   return V_EQ;
01295 }

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 854 of file checked_float.inlines.hh.

00855                            {
00856   if (from == 0)
00857     os << "0";
00858   else if (is_minf<Policy>(from))
00859     os << "-inf";
00860   else if (is_pinf<Policy>(from))
00861     os << "+inf";
00862   else if (is_nan<Policy>(from))
00863     os << "nan";
00864   else {
00865     int old_precision = os.precision(10000);
00866     // FIXME: here correctness depends on the behavior of the standard
00867     // output operator which, in turn, may depend on the behavior
00868     // of printf().  The C99 standard, 7.19.16.1#13, does not give
00869     // enough guarantees.  We could not find something similar
00870     // in the C++ standard, so there is a concrete danger here.
00871     os << from;
00872     os.precision(old_precision);
00873   }
00874   return V_EQ;
00875 }

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 1299 of file checked_int.inlines.hh.

01299                                                                             {
01300   os << from;
01301   return V_EQ;
01302 }

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 423 of file checked_mpq.inlines.hh.

00426                          {
00427   os << from;
00428   return V_EQ;
00429 }

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 548 of file checked_mpz.inlines.hh.

00549                          {
00550   os << from;
00551   return V_EQ;
00552 }

Result Parma_Polyhedra_Library::Checked::parse_number ( std::istream &  is,
number_struct &  num,
number_struct &  den 
)

Definition at line 277 of file checked.cc.

References Parma_Polyhedra_Library::Checked::number_struct::base, Parma_Polyhedra_Library::Checked::number_struct::exponent, Parma_Polyhedra_Library::Checked::number_struct::neg_exponent, parse_number_part(), and sum_sign().

Referenced by input_mpq().

00277                                                                      {
00278   // Read the numerator.
00279   Result r = parse_number_part(is, num);
00280   if (r != V_EQ)
00281     return r;
00282   if (is.get() != '/') {
00283     is.unget();
00284     den.base = 0;
00285     return r;
00286   }
00287   // Read the denominator.
00288   r = parse_number_part(is, den);
00289   if (r != V_EQ)
00290     return V_CVT_STR_UNK;
00291   if (num.base == den.base) {
00292     if (sum_sign(num.neg_exponent, num.exponent,
00293                  !den.neg_exponent, den.exponent)) {
00294       if (num.neg_exponent) {
00295         den.neg_exponent = false;
00296         den.exponent = num.exponent;
00297         num.exponent = 0;
00298       }
00299       else
00300         den.exponent = 0;
00301     }
00302   }
00303   return V_EQ;
00304 }

Result Parma_Polyhedra_Library::Checked::parse_number_part ( std::istream &  is,
number_struct &  num 
)

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

Definition at line 92 of file checked.cc.

References Parma_Polyhedra_Library::Checked::number_struct::base, Parma_Polyhedra_Library::Checked::number_struct::exponent, get_digit(), Parma_Polyhedra_Library::Checked::number_struct::mantissa, neg(), Parma_Polyhedra_Library::Checked::number_struct::neg_exponent, Parma_Polyhedra_Library::Checked::number_struct::neg_mantissa, and sum_sign().

Referenced by parse_number().

00092                                                       {
00093   enum { BASE, INTEGER, FRACTIONAL, EXPONENT } state = BASE;
00094   PPL_UNINITIALIZED(unsigned long, max_exp_div);
00095   PPL_UNINITIALIZED(int, max_exp_rem);
00096   bool empty_exponent = true;
00097   bool empty_mantissa = true;
00098   long exponent_offset = 0;
00099   num.base = 10;
00100   num.neg_mantissa = false;
00101   num.neg_exponent = false;
00102   num.mantissa.erase();
00103   num.exponent = 0;
00104   int c;
00105   do {
00106     c = is.get();
00107   } while (isspace(c));
00108   switch (c) {
00109   case '-':
00110     num.neg_mantissa = true;
00111     // Fall through.
00112   case '+':
00113     c = is.get();
00114     if (c == 'i' || c == 'I')
00115       goto inf;
00116     break;
00117   case 'n':
00118   case 'N':
00119     c = is.get();
00120     if (c != 'a' && c != 'A')
00121       goto error;
00122     c = is.get();
00123     if (c != 'n' && c != 'N')
00124       goto error;
00125     return VC_NAN;
00126   inf:
00127   case 'i':
00128   case 'I':
00129     c = is.get();
00130     if (c != 'n' && c != 'n')
00131       goto error;
00132     c = is.get();
00133     if (c != 'f' && c != 'F')
00134       goto error;
00135     return num.neg_mantissa ? VC_MINUS_INFINITY : VC_PLUS_INFINITY;
00136   }
00137   if (get_digit(c, 10) < 0)
00138     goto error;
00139   if (c == '0') {
00140     int d = is.get();
00141     if (d == 'x' || d == 'X') {
00142       num.base = 16;
00143       state = INTEGER;
00144       c = is.get();
00145     }
00146     else {
00147       c = d;
00148       empty_mantissa = false;
00149     }
00150   }
00151   else {
00152     num.mantissa += (char) c;
00153     empty_mantissa = false;
00154     c = is.get();
00155   }
00156   while (true) {
00157     switch (state) {
00158     case BASE:
00159       if (get_digit(c, 10) >= 0) {
00160         if (c != '0' || !num.mantissa.empty())
00161           num.mantissa += (char) c;
00162         empty_mantissa = false;
00163         break;
00164       }
00165       if (c == '^') {
00166         c = is.get();
00167         if (c != '^')
00168           goto error;
00169         std::string::const_iterator i;
00170         num.base = 0;
00171         for (i = num.mantissa.begin(); i != num.mantissa.end(); i++) {
00172           num.base = num.base * 10 + (*i - '0');
00173           if (num.base > 36)
00174             goto error;
00175         }
00176         if (num.base < 2)
00177           goto error;
00178         num.mantissa.erase();
00179         empty_mantissa = true;
00180         state = INTEGER;
00181         break;
00182       }
00183       goto integer;
00184     case INTEGER:
00185       if (get_digit(c, num.base) >= 0) {
00186         if (c != '0' || !num.mantissa.empty())
00187           num.mantissa += (char) c;
00188         empty_mantissa = false;
00189         break;
00190       }
00191     integer:
00192       if (c == '.') {
00193         state = FRACTIONAL;
00194         break;
00195       }
00196       goto fractional;
00197     case FRACTIONAL:
00198       if (get_digit(c, num.base) >= 0) {
00199         --exponent_offset;
00200         if (c != '0' || !num.mantissa.empty())
00201           num.mantissa += (char) c;
00202         empty_mantissa = false;
00203         break;
00204       }
00205     fractional:
00206       if (empty_mantissa)
00207         goto error;
00208       if (c == 'e' || c == 'E')
00209         goto exp;
00210       if (c == '*') {
00211         c = is.get();
00212         if (c != '^')
00213           goto error;
00214       exp:
00215         state = EXPONENT;
00216         max_exp_div = LONG_MAX / num.base;
00217         max_exp_rem = LONG_MAX % num.base;
00218         c = is.get();
00219         if (c == '-') {
00220           num.neg_exponent = true;
00221           break;
00222         }
00223         if (c == '+')
00224           break;
00225         continue;
00226       }
00227       goto ok;
00228     case EXPONENT:
00229       int d = get_digit(c, 10);
00230       if (d >= 0) {
00231         empty_exponent = false;
00232         if (num.exponent > max_exp_div
00233             || (num.exponent == max_exp_div && d > max_exp_rem))
00234           return V_CVT_STR_UNK;
00235         num.exponent = num.exponent * 10 + d;
00236         break;
00237       }
00238       if (empty_exponent)
00239         goto error;
00240       goto ok;
00241     }
00242     c = is.get();
00243   }
00244 
00245   {
00246   ok:
00247     is.unget();
00248     unsigned int n = num.mantissa.size();
00249     while (n > 0 && num.mantissa[n - 1] == '0') {
00250       --n;
00251       ++exponent_offset;
00252     }
00253     num.mantissa.erase(n);
00254     bool neg;
00255     if (exponent_offset < 0) {
00256       neg = true;
00257       exponent_offset = -exponent_offset;
00258     }
00259     else
00260       neg = false;
00261     sum_sign(num.neg_exponent, num.exponent,
00262              neg, exponent_offset);
00263     return V_EQ;
00264   }
00265 
00266  error:
00267   is.unget();
00268   return V_CVT_STR_UNK;
00269 }

template<typename T>
void Parma_Polyhedra_Library::Checked::pred_float ( T &  v  )  [inline]

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

References Parma_Polyhedra_Library::Bool< false >::value.

Referenced by round_lt_float().

00225                  {
00226   Float<T> f(v);
00227   assert(!f.u.binary.is_nan());
00228   assert(f.u.binary.is_inf() >= 0);
00229   if (f.u.binary.is_zero() > 0) {
00230     f.u.binary.negate();
00231     f.u.binary.inc();
00232   }
00233   else if (f.u.binary.sign_bit()) {
00234     f.u.binary.inc();
00235   }
00236   else {
00237     f.u.binary.dec();
00238   }
00239   v = f.value();
00240 }

template<typename Policy>
void Parma_Polyhedra_Library::Checked::prepare_inexact ( Rounding_Dir  dir  )  [inline]

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

00284                                   {
00285   if (Policy::fpu_check_inexact && round_fpu_check_inexact(dir))
00286     fpu_reset_inexact();
00287 }

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 545 of file checked_float.inlines.hh.

00545                                                               {
00546   if (To_Policy::check_inf_mod && is_inf_float<From1_Policy>(x))
00547     return assign_special<To_Policy>(to, V_INF_MOD, ROUND_IGNORE);
00548   if (To_Policy::check_div_zero && y == 0)
00549     return assign_special<To_Policy>(to, V_MOD_ZERO, ROUND_IGNORE);
00550   to = std::fmod(x, y);
00551   if (To_Policy::check_nan_result && is_nan<To_Policy>(to))
00552     return VC_NAN;
00553   return V_EQ;
00554 }

template<typename To_Policy, typename From1_Policy, typename From2_Policy>
Result Parma_Polyhedra_Library::Checked::rem_mpq ( mpq_class &  to,
const mpq_class &  x,
const mpq_class &  y,
Rounding_Dir   
) [inline]

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

References CHECK_P.

00317                                                                              {
00318   if (CHECK_P(To_Policy::check_div_zero, sgn(y) == 0))
00319     return assign_special<To_Policy>(to, V_MOD_ZERO, ROUND_IGNORE);
00320   to = x / y;
00321   to.get_num() %= to.get_den();
00322   return V_EQ;
00323 }

template<typename To_Policy, typename From1_Policy, typename From2_Policy>
Result Parma_Polyhedra_Library::Checked::rem_mpz ( mpz_class &  to,
const mpz_class &  x,
const mpz_class &  y,
Rounding_Dir   
) [inline]

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

References CHECK_P.

00406                                                                              {
00407   if (CHECK_P(To_Policy::check_div_zero, ::sgn(y) == 0))
00408     return assign_special<To_Policy>(to, V_MOD_ZERO, ROUND_IGNORE);
00409   to = x % y;
00410   return V_EQ;
00411 }

template<typename To_Policy, typename From1_Policy, typename From2_Policy, typename Type>
Result Parma_Polyhedra_Library::Checked::rem_signed_int ( Type &  to,
const Type  x,
const Type  y,
Rounding_Dir   
) [inline]

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

References CHECK_P.

01058                                                                    {
01059   if (CHECK_P(To_Policy::check_div_zero, y == 0))
01060     return assign_special<To_Policy>(to, V_MOD_ZERO, ROUND_IGNORE);
01061   to = x % y;
01062   return V_EQ;
01063 }

template<typename To_Policy, typename From1_Policy, typename From2_Policy, typename Type>
Result Parma_Polyhedra_Library::Checked::rem_unsigned_int ( Type &  to,
const Type  x,
const Type  y,
Rounding_Dir   
) [inline]

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

References CHECK_P.

01067                                                                      {
01068   if (CHECK_P(To_Policy::check_div_zero, y == 0))
01069     return assign_special<To_Policy>(to, V_MOD_ZERO, ROUND_IGNORE);
01070   to = x % y;
01071   return V_EQ;
01072 }

template<typename Policy>
Result Parma_Polyhedra_Library::Checked::result_relation ( Rounding_Dir  dir  )  [inline]

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

00291                                   {
00292   if (Policy::fpu_check_inexact && round_fpu_check_inexact(dir)) {
00293     switch (fpu_check_inexact()) {
00294     case 0:
00295       return V_EQ;
00296     case -1:
00297       goto unknown;
00298     case 1:
00299       break;
00300     }
00301     switch (round_dir(dir)) {
00302     case ROUND_DOWN:
00303       return V_GT;
00304     case ROUND_UP:
00305       return V_LT;
00306     default:
00307       return V_NE;
00308     }
00309   }
00310   else {
00311   unknown:
00312     switch (round_dir(dir)) {
00313     case ROUND_DOWN:
00314       return V_GE;
00315     case ROUND_UP:
00316       return V_LE;
00317     default:
00318       return V_LGE;
00319     }
00320   }
00321 }

long double Parma_Polyhedra_Library::Checked::rint ( long double  x  )  [inline]

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

Referenced by rint().

00082                     {
00083   return ::rint(x);
00084 }

double Parma_Polyhedra_Library::Checked::rint ( double  x  )  [inline]

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

References rint().

Referenced by assign_mpz_float(), ceil_float(), construct_mpz_float(), floor_float(), and is_int_float().

00069                {
00070   return ::rint(x);
00071 }

template<typename Policy, typename To>
Result Parma_Polyhedra_Library::Checked::round ( To &  to,
Result  r,
Rounding_Dir  dir 
) [inline]

template<typename Policy, typename To>
Result Parma_Polyhedra_Library::Checked::round_gt_float ( To &  to,
Rounding_Dir  dir 
) [inline]

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

References succ_float().

00273                                          {
00274   if (round_up(dir)) {
00275     succ_float(to);
00276     return V_LT;
00277   }
00278   return V_GT;
00279 }

template<typename Policy, typename To>
Result Parma_Polyhedra_Library::Checked::round_gt_int ( To &  to,
Rounding_Dir  dir 
) [inline]

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

00161                                        {
00162   if (round_up(dir)) {
00163     if (to == Extended_Int<Policy, To>::max) {
00164       if (Policy::has_infinity) {
00165         to = Extended_Int<Policy, To>::plus_infinity;
00166         return V_LT;
00167       }
00168       return V_POS_OVERFLOW;
00169     }
00170     else {
00171       ++to;
00172       return V_LT;
00173     }
00174   }
00175   return V_GT;
00176 }

template<typename Policy, typename To>
Result Parma_Polyhedra_Library::Checked::round_gt_int_no_overflow ( To &  to,
Rounding_Dir  dir 
) [inline]

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

00132                                                    {
00133   if (round_up(dir)) {
00134     ++to;
00135     return V_LT;
00136   }
00137   return V_GT;
00138 }

template<typename Policy>
Result Parma_Polyhedra_Library::Checked::round_gt_mpz ( mpz_class &  to,
Rounding_Dir  dir 
) [inline]

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

00044                                               {
00045   if (round_up(dir)) {
00046     ++to;
00047     return V_LT;
00048   }
00049   return V_GT;
00050 }

template<typename Policy, typename To>
Result Parma_Polyhedra_Library::Checked::round_lt_float ( To &  to,
Rounding_Dir  dir 
) [inline]

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

References pred_float().

00263                                          {
00264   if (round_down(dir)) {
00265     pred_float(to);
00266     return V_GT;
00267   }
00268   return V_LT;
00269 }

template<typename Policy, typename To>
Result Parma_Polyhedra_Library::Checked::round_lt_int ( To &  to,
Rounding_Dir  dir 
) [inline]

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

00142                                        {
00143   if (round_down(dir)) {
00144     if (to == Extended_Int<Policy, To>::min) {
00145       if (Policy::has_infinity) {
00146         to = Extended_Int<Policy, To>::minus_infinity;
00147         return V_GT;
00148       }
00149       return V_NEG_OVERFLOW;
00150     }
00151     else {
00152       --to;
00153       return V_GT;
00154     }
00155   }
00156   return V_LT;
00157 }

template<typename Policy, typename To>
Result Parma_Polyhedra_Library::Checked::round_lt_int_no_overflow ( To &  to,
Rounding_Dir  dir 
) [inline]

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

00122                                                    {
00123   if (round_down(dir)) {
00124     --to;
00125     return V_GT;
00126   }
00127   return V_LT;
00128 }

template<typename Policy>
Result Parma_Polyhedra_Library::Checked::round_lt_mpz ( mpz_class &  to,
Rounding_Dir  dir 
) [inline]

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

00034                                               {
00035   if (round_down(dir)) {
00036     --to;
00037     return V_GT;
00038   }
00039   return V_LT;
00040 }

Parma_Polyhedra_Library::Checked::safe_conversion ( mpq_class  ,
double   
)

Parma_Polyhedra_Library::Checked::safe_conversion ( mpq_class  ,
float   
)

Parma_Polyhedra_Library::Checked::safe_conversion ( mpq_class  ,
unsigned  char 
)

Parma_Polyhedra_Library::Checked::safe_conversion ( mpq_class  ,
signed  char 
)

Parma_Polyhedra_Library::Checked::safe_conversion ( mpz_class  ,
unsigned  char 
)

Parma_Polyhedra_Library::Checked::safe_conversion ( mpz_class  ,
signed  char 
)

Parma_Polyhedra_Library::Checked::safe_conversion ( long  double,
double   
)

Parma_Polyhedra_Library::Checked::safe_conversion ( long  double,
float   
)

Parma_Polyhedra_Library::Checked::safe_conversion ( double  ,
float   
)

Parma_Polyhedra_Library::Checked::safe_conversion ( unsigned long  long,
unsigned  char 
)

Parma_Polyhedra_Library::Checked::safe_conversion ( unsigned  long,
unsigned  char 
)

Parma_Polyhedra_Library::Checked::safe_conversion ( unsigned  short,
unsigned  char 
)

Parma_Polyhedra_Library::Checked::safe_conversion ( signed long  long,
signed  short 
)

Parma_Polyhedra_Library::Checked::safe_conversion ( signed long  long,
signed  char 
)

Parma_Polyhedra_Library::Checked::safe_conversion ( signed  short,
signed  char 
)

void Parma_Polyhedra_Library::Checked::set_mp_size ( mpz_class &  v,
mp_size_field_t  size 
) [inline]

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

Referenced by assign_special_mpz(), and copy_mpz().

00066                                                 {
00067   v.get_mpz_t()->_mp_size = size;
00068 }

template<typename Policy, typename T>
Result Parma_Polyhedra_Library::Checked::set_neg_overflow_float ( T &  to,
Rounding_Dir  dir 
) [inline]

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

References Parma_Polyhedra_Library::Bool< false >::value.

00657                                                 {
00658   switch (round_dir(dir)) {
00659   case ROUND_UP:
00660     {
00661       Float<T> f;
00662       f.u.binary.set_max(true);
00663       to = f.value();
00664       return V_LT;
00665     }
00666   default:
00667     to = -HUGE_VAL;
00668     return V_GT;
00669   }
00670 }

template<typename Policy, typename To>
Result Parma_Polyhedra_Library::Checked::set_neg_overflow_int ( To &  to,
Rounding_Dir  dir 
) [inline]

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

00090                                                {
00091   if (round_up(dir)) {
00092     to = Extended_Int<Policy, To>::min;
00093     return V_LT;
00094   }
00095   else {
00096     if (Policy::has_infinity) {
00097       to = Extended_Int<Policy, To>::minus_infinity;
00098       return V_GT;
00099     }
00100     return V_NEG_OVERFLOW;
00101   }
00102 }

template<typename Policy, typename T>
Result Parma_Polyhedra_Library::Checked::set_pos_overflow_float ( T &  to,
Rounding_Dir  dir 
) [inline]

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

References Parma_Polyhedra_Library::Bool< false >::value.

00674                                                 {
00675   switch (round_dir(dir)) {
00676   case ROUND_DOWN:
00677     {
00678       Float<T> f;
00679       f.u.binary.set_max(false);
00680       to = f.value();
00681       return V_GT;
00682     }
00683   default:
00684     to = HUGE_VAL;
00685     return V_LT;
00686   }
00687 }

template<typename Policy, typename To>
Result Parma_Polyhedra_Library::Checked::set_pos_overflow_int ( To &  to,
Rounding_Dir  dir 
) [inline]

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

00106                                                {
00107   if (round_down(dir)) {
00108     to = Extended_Int<Policy, To>::max;
00109     return V_GT;
00110   }
00111   else {
00112     if (Policy::has_infinity) {
00113       to = Extended_Int<Policy, To>::plus_infinity;
00114       return V_LT;
00115     }
00116     return V_POS_OVERFLOW;
00117   }
00118 }

template<typename Policy, typename Type>
Result Parma_Polyhedra_Library::Checked::sgn_float ( const Type  x  )  [inline]

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

00614                         {
00615   return classify<Policy>(x, false, false, true);
00616 }

template<typename Policy, typename Type>
Result Parma_Polyhedra_Library::Checked::sgn_generic ( const Type &  x  )  [inline]

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

00408                            {
00409   if (x > 0)
00410     return V_GT;
00411   if (x == 0)
00412     return V_EQ;
00413   return V_LT;
00414 }

template<typename Policy, typename Type>
Result Parma_Polyhedra_Library::Checked::sgn_mp ( const Type &  x  )  [inline]

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

00528                       {
00529   int i = ::sgn(x);
00530   return i > 0 ? V_GT : i == 0 ? V_EQ : V_LT;
00531 }

template<typename To_Policy, typename From_Policy, typename Type>
Result Parma_Polyhedra_Library::Checked::sqrt_float ( Type &  to,
const Type  from,
Rounding_Dir  dir 
) [inline]

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

References fpu_direct_rounding().

00594                                                         {
00595   if (To_Policy::check_nan_result && is_nan<From_Policy>(from))
00596     return assign_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
00597   if (To_Policy::check_sqrt_neg && from < 0)
00598     return assign_special<To_Policy>(to, V_SQRT_NEG, ROUND_IGNORE);
00599   prepare_inexact<To_Policy>(dir);
00600   if (fpu_direct_rounding(dir))
00601     to = std::sqrt(from);
00602   else {
00603     fpu_rounding_control_word_type old = fpu_save_rounding_direction(round_fpu_dir(dir));
00604     avoid_cse(from);
00605     to = std::sqrt(from);
00606     avoid_cse(to);
00607     fpu_restore_rounding_direction(old);
00608   }
00609   return result_relation<To_Policy>(dir);
00610 }

template<typename To_Policy, typename From_Policy>
Result Parma_Polyhedra_Library::Checked::sqrt_mpq ( mpq_class &  to,
const mpq_class &  from,
Rounding_Dir  dir 
) [inline]

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

References CHECK_P.

00386                                                                  {
00387   if (CHECK_P(To_Policy::check_sqrt_neg, from < 0))
00388     return assign_special<To_Policy>(to, V_SQRT_NEG, ROUND_IGNORE);
00389   const unsigned long k = rational_sqrt_precision_parameter;
00390   mpz_class& to_num = to.get_num();
00391   mul2exp<To_Policy, From_Policy>(to_num, from.get_num(), 2*k, dir);
00392   Result rdiv
00393     = div<To_Policy, To_Policy, To_Policy>(to_num,
00394                                            to_num, from.get_den(), dir);
00395   Result rsqrt = sqrt<To_Policy, To_Policy>(to_num, to_num, dir);
00396   mpz_class& to_den = to.get_den();
00397   to_den = 1;
00398   mul2exp<To_Policy, To_Policy>(to_den, to_den, k, dir);
00399   to.canonicalize();
00400   return rdiv != V_EQ ? rdiv : rsqrt;
00401 }

template<typename To_Policy, typename From_Policy>
Result Parma_Polyhedra_Library::Checked::sqrt_mpz ( mpz_class &  to,
const mpz_class &  from,
Rounding_Dir  dir 
) [inline]

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

References CHECK_P.

00510                                                                  {
00511   if (CHECK_P(To_Policy::check_sqrt_neg, from < 0))
00512     return assign_special<To_Policy>(to, V_SQRT_NEG, ROUND_IGNORE);
00513   if (round_ignore(dir)) {
00514     to = sqrt(from);
00515     return V_GE;
00516   }
00517   DIRTY_TEMP0(mpz_class, r);
00518   mpz_sqrtrem(to.get_mpz_t(), r.get_mpz_t(), from.get_mpz_t());
00519   if (r == 0)
00520     return V_EQ;
00521   return round_gt_mpz<To_Policy>(to, dir);
00522 }

template<typename To_Policy, typename From_Policy, typename Type>
Result Parma_Polyhedra_Library::Checked::sqrt_signed_int ( Type &  to,
const Type  from,
Rounding_Dir  dir 
) [inline]

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

References CHECK_P.

01237                                                              {
01238   if (CHECK_P(To_Policy::check_sqrt_neg, from < 0))
01239     return assign_special<To_Policy>(to, V_SQRT_NEG, ROUND_IGNORE);
01240   return sqrt_unsigned_int<To_Policy, From_Policy>(to, from, dir);
01241 }

template<typename To_Policy, typename From_Policy, typename Type>
Result Parma_Polyhedra_Library::Checked::sqrt_unsigned_int ( Type &  to,
const Type  from,
Rounding_Dir  dir 
) [inline]

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

References isqrtrem().

01225                                                                {
01226   Type rem;
01227   isqrtrem(to, rem, from);
01228   if (round_ignore(dir))
01229     return V_GE;
01230   if (rem == 0)
01231     return V_EQ;
01232   return round_gt_int<To_Policy>(to, dir);
01233 }

Result Parma_Polyhedra_Library::Checked::sub ( Result  r1,
Result  r2 
) [inline]

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

References neg().

00265                           {
00266   return add(r1, neg(r2));
00267 }

template<typename To_Policy, typename From1_Policy, typename From2_Policy, typename Type>
Result Parma_Polyhedra_Library::Checked::sub_float ( Type &  to,
const Type  x,
const Type  y,
Rounding_Dir  dir 
) [inline]

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

References fpu_direct_rounding(), fpu_inverse_rounding(), and limit_precision().

00447                                                                   {
00448   if (To_Policy::check_inf_sub_inf
00449       && is_inf_float<From1_Policy>(x) && x == y)
00450     return assign_special<To_Policy>(to, V_INF_SUB_INF, ROUND_IGNORE);
00451   prepare_inexact<To_Policy>(dir);
00452   if (fpu_direct_rounding(dir))
00453     to = x - y;
00454   else if (fpu_inverse_rounding(dir))
00455     to = -limit_precision(y - x);
00456   else {
00457     fpu_rounding_control_word_type old = fpu_save_rounding_direction(round_fpu_dir(dir));
00458     avoid_cse(x);
00459     avoid_cse(y);
00460     to = x - y;
00461     avoid_cse(to);
00462     fpu_restore_rounding_direction(old);
00463   }
00464   if (To_Policy::check_nan_result && is_nan<To_Policy>(to))
00465     return VC_NAN;
00466   return result_relation<To_Policy>(dir);
00467 }

template<typename To_Policy, typename From1_Policy, typename From2_Policy, typename Type>
Result Parma_Polyhedra_Library::Checked::sub_int_larger ( Type &  to,
const Type  x,
const Type  y,
Rounding_Dir  dir 
) [inline]

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

00850                                                                        {
00851   typename Larger<Type>::type_for_sub l = x;
00852   l -= y;
00853   return assign<To_Policy, To_Policy>(to, l, dir);
00854 }

template<typename To_Policy, typename From1_Policy, typename From2_Policy>
Result Parma_Polyhedra_Library::Checked::sub_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.

00277                                                                              {
00278   to = x - y;
00279   return V_EQ;
00280 }

template<typename To_Policy, typename From1_Policy, typename From2_Policy>
Result Parma_Polyhedra_Library::Checked::sub_mpz ( mpz_class &  to,
const mpz_class &  x,
const mpz_class &  y,
Rounding_Dir   
) [inline]

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

00348                                                                              {
00349   to = x - y;
00350   return V_EQ;
00351 }

template<typename To_Policy, typename From1_Policy, typename From2_Policy, typename Type>
Result Parma_Polyhedra_Library::Checked::sub_mul_float ( Type &  to,
const Type  x,
const Type  y,
Rounding_Dir  dir 
) [inline]

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

References fma(), fpu_direct_rounding(), fpu_inverse_rounding(), and limit_precision().

00828                                                                       {
00829   if (To_Policy::check_inf_mul_zero
00830       && ((x == 0 && is_inf_float<From2_Policy>(y)) ||
00831           (y == 0 && is_inf_float<From1_Policy>(x))))
00832     return assign_special<To_Policy>(to, V_INF_MUL_ZERO, ROUND_IGNORE);
00833   // FIXME: missing check_inf_add_inf
00834   prepare_inexact<To_Policy>(dir);
00835   if (fpu_direct_rounding(dir))
00836     to = fma(x, -y, to);
00837   else if (fpu_inverse_rounding(dir))
00838     to = -limit_precision(fma(x, y, -to));
00839   else {
00840     fpu_rounding_control_word_type old = fpu_save_rounding_direction(round_fpu_dir(dir));
00841     avoid_cse(x);
00842     avoid_cse(y);
00843     to = fma(x, -y, to);
00844     avoid_cse(to);
00845     fpu_restore_rounding_direction(old);
00846   }
00847   if (To_Policy::check_nan_result && is_nan<To_Policy>(to))
00848     return VC_NAN;
00849   return result_relation<To_Policy>(dir);
00850 }

template<typename To_Policy, typename From1_Policy, typename From2_Policy, typename Type>
Result Parma_Polyhedra_Library::Checked::sub_mul_int ( Type &  to,
const Type  x,
const Type  y,
Rounding_Dir  dir 
) [inline]

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

01270                                                                     {
01271   Type z;
01272   Result r = mul<To_Policy, From1_Policy, From2_Policy>(z, x, y, dir);
01273   switch (r) {
01274   case V_NEG_OVERFLOW:
01275   case V_LT:
01276     if (to >= 0)
01277       return set_pos_overflow_int<To_Policy>(to, dir);
01278     return V_UNKNOWN_NEG_OVERFLOW;
01279   case V_POS_OVERFLOW:
01280   case V_GT:
01281     if (to <= 0)
01282       return set_neg_overflow_int<To_Policy>(to, dir);
01283     return V_UNKNOWN_POS_OVERFLOW;
01284   default:
01285     return sub<To_Policy, To_Policy, To_Policy>(to, to, z, dir);
01286   }
01287 }

template<typename To_Policy, typename From1_Policy, typename From2_Policy>
Result Parma_Polyhedra_Library::Checked::sub_mul_mpq ( mpq_class &  to,
const mpq_class &  x,
const mpq_class &  y,
Rounding_Dir   
) [inline]

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

00375                           {
00376   to -= x * y;
00377   return V_EQ;
00378 }

template<typename To_Policy, typename From1_Policy, typename From2_Policy>
Result Parma_Polyhedra_Library::Checked::sub_mul_mpz ( mpz_class &  to,
const mpz_class &  x,
const mpz_class &  y,
Rounding_Dir   
) [inline]

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

00471                           {
00472   mpz_submul(to.get_mpz_t(), x.get_mpz_t(), y.get_mpz_t());
00473   return V_EQ;
00474 }

template<typename To_Policy, typename From1_Policy, typename From2_Policy, typename Type>
Result Parma_Polyhedra_Library::Checked::sub_signed_int ( Type &  to,
const Type  x,
const Type  y,
Rounding_Dir  dir 
) [inline]

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

00918                                                                        {
00919   if (To_Policy::check_overflow && Larger<Type>::use_for_sub)
00920     return sub_int_larger<To_Policy, From1_Policy, From2_Policy>(to, x, y, dir);
00921   if (To_Policy::check_overflow) {
00922     if (y >= 0) {
00923       if (x < Extended_Int<To_Policy, Type>::min + y)
00924         return set_neg_overflow_int<To_Policy>(to, dir);
00925     }
00926     else if (x > Extended_Int<To_Policy, Type>::max + y)
00927         return set_pos_overflow_int<To_Policy>(to, dir);
00928   }
00929   to = x - y;
00930   return V_EQ;
00931 }

template<typename To_Policy, typename From1_Policy, typename From2_Policy, typename Type>
Result Parma_Polyhedra_Library::Checked::sub_unsigned_int ( Type &  to,
const Type  x,
const Type  y,
Rounding_Dir  dir 
) [inline]

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

References CHECK_P.

00935                                                                          {
00936   if (To_Policy::check_overflow && Larger<Type>::use_for_sub)
00937     return sub_int_larger<To_Policy, From1_Policy, From2_Policy>(to, x, y, dir);
00938   if (CHECK_P(To_Policy::check_overflow,
00939               (x < Extended_Int<To_Policy, Type>::min + y)))
00940     return set_neg_overflow_int<To_Policy>(to, dir);
00941   to = x - y;
00942   return V_EQ;
00943 }

template<typename T>
void Parma_Polyhedra_Library::Checked::succ_float ( T &  v  )  [inline]

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

References Parma_Polyhedra_Library::Bool< false >::value.

Referenced by round_gt_float().

00244                  {
00245   Float<T> f(v);
00246   assert(!f.u.binary.is_nan());
00247   assert(f.u.binary.is_inf() <= 0);
00248   if (f.u.binary.is_zero() < 0) {
00249     f.u.binary.negate();
00250     f.u.binary.inc();
00251   }
00252   else if (!f.u.binary.sign_bit()) {
00253     f.u.binary.inc();
00254   }
00255   else {
00256     f.u.binary.dec();
00257   }
00258   v = f.value();
00259 }

bool Parma_Polyhedra_Library::Checked::sum_sign ( bool &  a_neg,
unsigned long &  a_mod,
bool  b_neg,
unsigned long  b_mod 
) [inline]

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.

Definition at line 69 of file checked.cc.

Referenced by parse_number(), and parse_number_part().

00070                                           {
00071   if (a_neg == b_neg) {
00072     if (a_mod > ULONG_MAX - b_mod)
00073       return false;
00074     a_mod += b_mod;
00075   }
00076   else if (a_mod >= b_mod)
00077     a_mod -= b_mod;
00078   else {
00079     a_neg = !a_neg;
00080     a_mod = b_mod - a_mod;
00081   }
00082   return true;
00083 }

template<typename To_Policy, typename From_Policy, typename Type>
Result Parma_Polyhedra_Library::Checked::trunc_float ( Type &  to,
const Type  from,
Rounding_Dir  dir 
) [inline]

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

00401                                                          {
00402   if (To_Policy::check_nan_result && is_nan<From_Policy>(from))
00403     return assign_special<To_Policy>(to, VC_NAN, ROUND_IGNORE);
00404   if (from >= 0)
00405     return floor<To_Policy, From_Policy>(to, from, dir);
00406   else
00407     return ceil<To_Policy, From_Policy>(to, from, dir);
00408 }

template<typename To_Policy, typename From_Policy>
Result Parma_Polyhedra_Library::Checked::trunc_mpq ( mpq_class &  to,
const mpq_class &  from,
Rounding_Dir   
) [inline]

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

00248                                                               {
00249   mpz_tdiv_q(to.get_num().get_mpz_t(),
00250              from.get_num().get_mpz_t(), from.get_den().get_mpz_t());
00251   to.get_den() = 1;
00252   return V_EQ;
00253 }


Variable Documentation

Holds the precision parameter used for rational sqrt calculations.

Definition at line 32 of file checked.cc.

Referenced by Parma_Polyhedra_Library::rational_sqrt_precision_parameter(), and Parma_Polyhedra_Library::set_rational_sqrt_precision_parameter().


Generated on Sat Oct 11 10:41:18 2008 for PPL by  doxygen 1.5.6