PPL  1.2
Parma_Polyhedra_Library::Checked_Number< T, Policy > Class Template Reference

A wrapper for numeric types implementing a given policy. More...

#include <ppl.hh>

Public Member Functions

bool OK () const
 Checks if all the invariants are satisfied.
 
Result classify (bool nan=true, bool inf=true, bool sign=true) const
 Classifies *this. More...
 
Constructors
 Checked_Number ()
 Default constructor.
 
 Checked_Number (const Checked_Number &y)
 Copy constructor.
 
template<typename From , typename From_Policy >
 Checked_Number (const Checked_Number< From, From_Policy > &y, Rounding_Dir dir)
 Direct initialization from a Checked_Number and rounding mode.
 
 Checked_Number (char y, Rounding_Dir dir)
 Direct initialization from a plain char and rounding mode.
 
 Checked_Number (signed char y, Rounding_Dir dir)
 Direct initialization from a signed char and rounding mode.
 
 Checked_Number (signed short y, Rounding_Dir dir)
 Direct initialization from a signed short and rounding mode.
 
 Checked_Number (signed int y, Rounding_Dir dir)
 Direct initialization from a signed int and rounding mode.
 
 Checked_Number (signed long y, Rounding_Dir dir)
 Direct initialization from a signed long and rounding mode.
 
 Checked_Number (signed long long y, Rounding_Dir dir)
 Direct initialization from a signed long long and rounding mode.
 
 Checked_Number (unsigned char y, Rounding_Dir dir)
 Direct initialization from an unsigned char and rounding mode.
 
 Checked_Number (unsigned short y, Rounding_Dir dir)
 Direct initialization from an unsigned short and rounding mode.
 
 Checked_Number (unsigned int y, Rounding_Dir dir)
 Direct initialization from an unsigned int and rounding mode.
 
 Checked_Number (unsigned long y, Rounding_Dir dir)
 Direct initialization from an unsigned long and rounding mode.
 
 Checked_Number (unsigned long long y, Rounding_Dir dir)
 Direct initialization from an unsigned long long and rounding mode.
 
 Checked_Number (float y, Rounding_Dir dir)
 Direct initialization from a float and rounding mode.
 
 Checked_Number (double y, Rounding_Dir dir)
 Direct initialization from a double and rounding mode.
 
 Checked_Number (long double y, Rounding_Dir dir)
 Direct initialization from a long double and rounding mode.
 
 Checked_Number (const mpq_class &y, Rounding_Dir dir)
 Direct initialization from a rational and rounding mode.
 
 Checked_Number (const mpz_class &y, Rounding_Dir dir)
 Direct initialization from an unbounded integer and rounding mode.
 
 Checked_Number (const char *y, Rounding_Dir dir)
 Direct initialization from a C string and rounding mode.
 
template<typename From >
 Checked_Number (const From &, Rounding_Dir dir, typename Enable_If< Is_Special< From >::value, bool >::type ignored=false)
 Direct initialization from special and rounding mode.
 
template<typename From , typename From_Policy >
 Checked_Number (const Checked_Number< From, From_Policy > &y)
 Direct initialization from a Checked_Number, default rounding mode.
 
 Checked_Number (char y)
 Direct initialization from a plain char, default rounding mode.
 
 Checked_Number (signed char y)
 Direct initialization from a signed char, default rounding mode.
 
 Checked_Number (signed short y)
 Direct initialization from a signed short, default rounding mode.
 
 Checked_Number (signed int y)
 Direct initialization from a signed int, default rounding mode.
 
 Checked_Number (signed long y)
 Direct initialization from a signed long, default rounding mode.
 
 Checked_Number (signed long long y)
 Direct initialization from a signed long long, default rounding mode.
 
 Checked_Number (unsigned char y)
 Direct initialization from an unsigned char, default rounding mode.
 
 Checked_Number (unsigned short y)
 Direct initialization from an unsigned short, default rounding mode.
 
 Checked_Number (unsigned int y)
 Direct initialization from an unsigned int, default rounding mode.
 
 Checked_Number (unsigned long y)
 Direct initialization from an unsigned long, default rounding mode.
 
 Checked_Number (unsigned long long y)
 Direct initialization from an unsigned long long, default rounding mode.
 
 Checked_Number (float y)
 Direct initialization from a float, default rounding mode.
 
 Checked_Number (double y)
 Direct initialization from a double, default rounding mode.
 
 Checked_Number (long double y)
 Direct initialization from a long double, default rounding mode.
 
 Checked_Number (const mpq_class &y)
 Direct initialization from a rational, default rounding mode.
 
 Checked_Number (const mpz_class &y)
 Direct initialization from an unbounded integer, default rounding mode.
 
 Checked_Number (const char *y)
 Direct initialization from a C string, default rounding mode.
 
template<typename From >
 Checked_Number (const From &, typename Enable_If< Is_Special< From >::value, bool >::type ignored=false)
 Direct initialization from special, default rounding mode.
 
Accessors and Conversions
 operator T () const
 Conversion operator: returns a copy of the underlying numeric value.
 
T & raw_value ()
 Returns a reference to the underlying numeric value.
 
const T & raw_value () const
 Returns a const reference to the underlying numeric value.
 
Assignment Operators
Checked_Numberoperator= (const Checked_Number &y)
 Assignment operator.
 
template<typename From >
Checked_Numberoperator= (const From &y)
 Assignment operator.
 
template<typename From_Policy >
Checked_Numberoperator+= (const Checked_Number< T, From_Policy > &y)
 Add and assign operator.
 
Checked_Numberoperator+= (const T &y)
 Add and assign operator.
 
template<typename From >
Enable_If< Is_Native_Or_Checked< From >::value, Checked_Number< T, Policy > & >::type operator+= (const From &y)
 Add and assign operator.
 
template<typename From_Policy >
Checked_Numberoperator-= (const Checked_Number< T, From_Policy > &y)
 Subtract and assign operator.
 
Checked_Numberoperator-= (const T &y)
 Subtract and assign operator.
 
template<typename From >
Enable_If< Is_Native_Or_Checked< From >::value, Checked_Number< T, Policy > & >::type operator-= (const From &y)
 Subtract and assign operator.
 
template<typename From_Policy >
Checked_Numberoperator*= (const Checked_Number< T, From_Policy > &y)
 Multiply and assign operator.
 
Checked_Numberoperator*= (const T &y)
 Multiply and assign operator.
 
template<typename From >
Enable_If< Is_Native_Or_Checked< From >::value, Checked_Number< T, Policy > & >::type operator*= (const From &y)
 Multiply and assign operator.
 
template<typename From_Policy >
Checked_Numberoperator/= (const Checked_Number< T, From_Policy > &y)
 Divide and assign operator.
 
Checked_Numberoperator/= (const T &y)
 Divide and assign operator.
 
template<typename From >
Enable_If< Is_Native_Or_Checked< From >::value, Checked_Number< T, Policy > & >::type operator/= (const From &y)
 Divide and assign operator.
 
template<typename From_Policy >
Checked_Numberoperator%= (const Checked_Number< T, From_Policy > &y)
 Compute remainder and assign operator.
 
Checked_Numberoperator%= (const T &y)
 Compute remainder and assign operator.
 
template<typename From >
Enable_If< Is_Native_Or_Checked< From >::value, Checked_Number< T, Policy > & >::type operator%= (const From &y)
 Compute remainder and assign operator.
 
Increment and Decrement Operators
Checked_Numberoperator++ ()
 Pre-increment operator.
 
Checked_Number operator++ (int)
 Post-increment operator.
 
Checked_Numberoperator-- ()
 Pre-decrement operator.
 
Checked_Number operator-- (int)
 Post-decrement operator.
 

Related Functions

(Note that these are not member functions.)

template<typename T >
Enable_If< Is_Native_Or_Checked< T >::value, bool >::type is_not_a_number (const T &x)
 
template<typename T >
Enable_If< Is_Native_Or_Checked< T >::value, bool >::type is_minus_infinity (const T &x)
 
template<typename T >
Enable_If< Is_Native_Or_Checked< T >::value, bool >::type is_plus_infinity (const T &x)
 
template<typename T >
Enable_If< Is_Native_Or_Checked< T >::value, int >::type infinity_sign (const T &x)
 
template<typename T >
Enable_If< Is_Native_Or_Checked< T >::value, bool >::type is_integer (const T &x)
 
template<typename To , typename From >
Enable_If< Is_Native_Or_Checked< To >::value &&Is_Special< From >::value, Result >::type construct (To &to, const From &x, Rounding_Dir dir)
 
template<typename To , typename From >
Enable_If< Is_Native_Or_Checked< To >::value &&Is_Special< From >::value, Result >::type assign_r (To &to, const From &x, Rounding_Dir dir)
 
template<typename To >
Enable_If< Is_Native_Or_Checked< To >::value, Result >::type assign_r (To &to, const char *x, Rounding_Dir dir)
 
template<typename To , typename To_Policy >
Enable_If< Is_Native_Or_Checked< To >::value, Result >::type assign_r (To &to, char *x, Rounding_Dir dir)
 
template<typename T , typename Policy >
void swap (Checked_Number< T, Policy > &x, Checked_Number< T, Policy > &y)
 Swaps x with y. More...
 
template<typename T , typename Policy >
const T & raw_value (const Checked_Number< T, Policy > &x)
 
template<typename T , typename Policy >
T & raw_value (Checked_Number< T, Policy > &x)
 
template<typename T , typename Policy >
memory_size_type total_memory_in_bytes (const Checked_Number< T, Policy > &x)
 
template<typename T , typename Policy >
memory_size_type external_memory_in_bytes (const Checked_Number< T, Policy > &x)
 
template<typename To >
Enable_If< Is_Native_Or_Checked< To >::value, Result >::type assign_r (To &to, const char *x, Rounding_Dir dir)
 
template<typename T , typename Policy >
Checked_Number< T, Policy > operator+ (const Checked_Number< T, Policy > &x)
 
template<typename T , typename Policy >
Checked_Number< T, Policy > operator- (const Checked_Number< T, Policy > &x)
 
template<typename From >
Enable_If< Is_Native_Or_Checked< From >::value, int >::type sgn (const From &x)
 
template<typename From1 , typename From2 >
Enable_If< Is_Native_Or_Checked< From1 >::value &&Is_Native_Or_Checked< From2 >::value, int >::type cmp (const From1 &x, const From2 &y)
 
template<typename T >
Enable_If< Is_Native_Or_Checked< T >::value, Result >::type output (std::ostream &os, const T &x, const Numeric_Format &format, Rounding_Dir dir)
 
template<typename T , typename Policy >
std::ostream & operator<< (std::ostream &os, const Checked_Number< T, Policy > &x)
 
template<typename T >
Enable_If< Is_Native_Or_Checked< T >::value, Result >::type input (T &x, std::istream &is, Rounding_Dir dir)
 
template<typename T , typename Policy >
std::istream & operator>> (std::istream &is, Checked_Number< T, Policy > &x)
 
template<typename T , typename Policy >
void swap (Checked_Number< T, Policy > &x, Checked_Number< T, Policy > &y)
 
Memory Size Inspection Functions
template<typename T , typename Policy >
memory_size_type total_memory_in_bytes (const Checked_Number< T, Policy > &x)
 Returns the total size in bytes of the memory occupied by x. More...
 
template<typename T , typename Policy >
memory_size_type external_memory_in_bytes (const Checked_Number< T, Policy > &x)
 Returns the size in bytes of the memory managed by x. More...
 
Arithmetic Operators
template<typename T , typename Policy >
Checked_Number< T, Policy > operator+ (const Checked_Number< T, Policy > &x)
 Unary plus operator. More...
 
template<typename T , typename Policy >
Checked_Number< T, Policy > operator- (const Checked_Number< T, Policy > &x)
 Unary minus operator. More...
 
template<typename T , typename Policy >
void floor_assign (Checked_Number< T, Policy > &x)
 Assigns to x largest integral value not greater than x. More...
 
template<typename T , typename Policy >
void floor_assign (Checked_Number< T, Policy > &x, const Checked_Number< T, Policy > &y)
 Assigns to x largest integral value not greater than y. More...
 
template<typename T , typename Policy >
void ceil_assign (Checked_Number< T, Policy > &x)
 Assigns to x smallest integral value not less than x. More...
 
template<typename T , typename Policy >
void ceil_assign (Checked_Number< T, Policy > &x, const Checked_Number< T, Policy > &y)
 Assigns to x smallest integral value not less than y. More...
 
template<typename T , typename Policy >
void trunc_assign (Checked_Number< T, Policy > &x)
 Round x to the nearest integer not larger in absolute value. More...
 
template<typename T , typename Policy >
void trunc_assign (Checked_Number< T, Policy > &x, const Checked_Number< T, Policy > &y)
 Assigns to x the value of y rounded to the nearest integer not larger in absolute value. More...
 
template<typename T , typename Policy >
void neg_assign (Checked_Number< T, Policy > &x)
 Assigns to x its negation. More...
 
template<typename T , typename Policy >
void neg_assign (Checked_Number< T, Policy > &x, const Checked_Number< T, Policy > &y)
 Assigns to x the negation of y. More...
 
template<typename T , typename Policy >
void abs_assign (Checked_Number< T, Policy > &x)
 Assigns to x its absolute value. More...
 
template<typename T , typename Policy >
void abs_assign (Checked_Number< T, Policy > &x, const Checked_Number< T, Policy > &y)
 Assigns to x the absolute value of y. More...
 
template<typename T , typename Policy >
void add_mul_assign (Checked_Number< T, Policy > &x, const Checked_Number< T, Policy > &y, const Checked_Number< T, Policy > &z)
 Assigns to x the value x + y * z. More...
 
template<typename T , typename Policy >
void sub_mul_assign (Checked_Number< T, Policy > &x, const Checked_Number< T, Policy > &y, const Checked_Number< T, Policy > &z)
 Assigns to x the value x - y * z. More...
 
template<typename T , typename Policy >
void gcd_assign (Checked_Number< T, Policy > &x, const Checked_Number< T, Policy > &y, const Checked_Number< T, Policy > &z)
 Assigns to x the greatest common divisor of y and z. More...
 
template<typename T , typename Policy >
void gcdext_assign (Checked_Number< T, Policy > &x, Checked_Number< T, Policy > &s, Checked_Number< T, Policy > &t, const Checked_Number< T, Policy > &y, const Checked_Number< T, Policy > &z)
 Assigns to x the greatest common divisor of y and z, setting s and t such that s*y + t*z = x = gcd(y, z). More...
 
template<typename T , typename Policy >
void lcm_assign (Checked_Number< T, Policy > &x, const Checked_Number< T, Policy > &y, const Checked_Number< T, Policy > &z)
 Assigns to x the least common multiple of y and z. More...
 
template<typename T , typename Policy >
void mul_2exp_assign (Checked_Number< T, Policy > &x, const Checked_Number< T, Policy > &y, unsigned int exp)
 Assigns to x the value $ y \cdot 2^\mathtt{exp} $. More...
 
template<typename T , typename Policy >
void div_2exp_assign (Checked_Number< T, Policy > &x, const Checked_Number< T, Policy > &y, unsigned int exp)
 Assigns to x the value $ y / 2^\mathtt{exp} $. More...
 
template<typename T , typename Policy >
void exact_div_assign (Checked_Number< T, Policy > &x, const Checked_Number< T, Policy > &y, const Checked_Number< T, Policy > &z)
 If z divides y, assigns to x the quotient of the integer division of y and z. More...
 
template<typename T , typename Policy >
void sqrt_assign (Checked_Number< T, Policy > &x, const Checked_Number< T, Policy > &y)
 Assigns to x the integer square root of y. More...
 
Relational Operators and Comparison Functions
template<typename T1 , typename T2 >
Enable_If< Is_Native_Or_Checked< T1 >::value &&Is_Native_Or_Checked< T2 >::value &&(Is_Checked< T1 >::value||Is_Checked< T2 >::value), bool >::type operator== (const T1 &x, const T2 &y)
 Equality operator. More...
 
template<typename T1 , typename T2 >
Enable_If< Is_Native_Or_Checked< T1 >::value &&Is_Native_Or_Checked< T2 >::value, bool >::type equal (const T1 &x, const T2 &y)
 
template<typename T1 , typename T2 >
Enable_If< Is_Native_Or_Checked< T1 >::value &&Is_Native_Or_Checked< T2 >::value &&(Is_Checked< T1 >::value||Is_Checked< T2 >::value), bool >::type operator!= (const T1 &x, const T2 &y)
 Disequality operator. More...
 
template<typename T1 , typename T2 >
Enable_If< Is_Native_Or_Checked< T1 >::value &&Is_Native_Or_Checked< T2 >::value, bool >::type not_equal (const T1 &x, const T2 &y)
 
template<typename T1 , typename T2 >
Enable_If< Is_Native_Or_Checked< T1 >::value &&Is_Native_Or_Checked< T2 >::value &&(Is_Checked< T1 >::value||Is_Checked< T2 >::value), bool >::type operator>= (const T1 &x, const T2 &y)
 Greater than or equal to operator. More...
 
template<typename T1 , typename T2 >
Enable_If< Is_Native_Or_Checked< T1 >::value &&Is_Native_Or_Checked< T2 >::value, bool >::type greater_or_equal (const T1 &x, const T2 &y)
 
template<typename T1 , typename T2 >
Enable_If< Is_Native_Or_Checked< T1 >::value &&Is_Native_Or_Checked< T2 >::value &&(Is_Checked< T1 >::value||Is_Checked< T2 >::value), bool >::type operator> (const T1 &x, const T2 &y)
 Greater than operator. More...
 
template<typename T1 , typename T2 >
Enable_If< Is_Native_Or_Checked< T1 >::value &&Is_Native_Or_Checked< T2 >::value, bool >::type greater_than (const T1 &x, const T2 &y)
 
template<typename T1 , typename T2 >
Enable_If< Is_Native_Or_Checked< T1 >::value &&Is_Native_Or_Checked< T2 >::value &&(Is_Checked< T1 >::value||Is_Checked< T2 >::value), bool >::type operator<= (const T1 &x, const T2 &y)
 Less than or equal to operator. More...
 
template<typename T1 , typename T2 >
Enable_If< Is_Native_Or_Checked< T1 >::value &&Is_Native_Or_Checked< T2 >::value, bool >::type less_or_equal (const T1 &x, const T2 &y)
 
template<typename T1 , typename T2 >
Enable_If< Is_Native_Or_Checked< T1 >::value &&Is_Native_Or_Checked< T2 >::value &&(Is_Checked< T1 >::value||Is_Checked< T2 >::value), bool >::type operator< (const T1 &x, const T2 &y)
 Less than operator. More...
 
template<typename T1 , typename T2 >
Enable_If< Is_Native_Or_Checked< T1 >::value &&Is_Native_Or_Checked< T2 >::value, bool >::type less_than (const T1 &x, const T2 &y)
 
template<typename From >
Enable_If< Is_Native_Or_Checked< From >::value, int >::type sgn (const From &x)
 Returns $-1$, $0$ or $1$ depending on whether the value of x is negative, zero or positive, respectively.
 
template<typename From1 , typename From2 >
Enable_If< Is_Native_Or_Checked< From1 >::value &&Is_Native_Or_Checked< From2 >::value, int >::type cmp (const From1 &x, const From2 &y)
 Returns a negative, zero or positive value depending on whether x is lower than, equal to or greater than y, respectively.
 
Input-Output Operators
template<typename T >
Enable_If< Is_Native_Or_Checked< T >::value, Result >::type output (std::ostream &os, const T &x, const Numeric_Format &format, Rounding_Dir dir)
 
template<typename T , typename Policy >
std::ostream & operator<< (std::ostream &os, const Checked_Number< T, Policy > &x)
 Output operator. More...
 
template<typename T >
Enable_If< Is_Native_Or_Checked< T >::value, void >::type ascii_dump (std::ostream &s, const T &t)
 Ascii dump for native or checked. More...
 
template<typename T >
Enable_If< Is_Native_Or_Checked< T >::value, Result >::type input (T &x, std::istream &is, Rounding_Dir dir)
 Input function. More...
 
template<typename T , typename Policy >
std::istream & operator>> (std::istream &is, Checked_Number< T, Policy > &x)
 Input operator. More...
 
template<typename T >
Enable_If< Is_Native_Or_Checked< T >::value, bool >::type ascii_load (std::ostream &s, T &t)
 Ascii load for native or checked. More...
 

Detailed Description

template<typename T, typename Policy>
class Parma_Polyhedra_Library::Checked_Number< T, Policy >

A wrapper for numeric types implementing a given policy.

The wrapper and related functions implement an interface which is common to all kinds of coefficient types, therefore allowing for a uniform coding style. This class also implements the policy encoded by the second template parameter. The default policy is to perform the detection of overflow errors.

Member Function Documentation

template<typename T , typename Policy >
Result Parma_Polyhedra_Library::Checked_Number< T, Policy >::classify ( bool  nan = true,
bool  inf = true,
bool  sign = true 
) const
inline

Classifies *this.

Returns the appropriate Result characterizing:

  • whether *this is NaN, if nan is true;
  • whether *this is a (positive or negative) infinity, if inf is true;
  • the sign of *this, if sign is true.

Friends And Related Function Documentation

template<typename T >
Enable_If< Is_Native_Or_Checked< T >::value, bool >::type is_not_a_number ( const T &  x)
related
template<typename T >
Enable_If< Is_Native_Or_Checked< T >::value, bool >::type is_minus_infinity ( const T &  x)
related
template<typename T >
Enable_If< Is_Native_Or_Checked< T >::value, bool >::type is_plus_infinity ( const T &  x)
related
template<typename T >
Enable_If< Is_Native_Or_Checked< T >::value, int >::type infinity_sign ( const T &  x)
related
template<typename T >
Enable_If< Is_Native_Or_Checked< T >::value, bool >::type is_integer ( const T &  x)
related
template<typename To , typename From >
Enable_If< Is_Native_Or_Checked< To >::value &&Is_Special< From >::value, Result >::type construct ( To &  to,
const From &  x,
Rounding_Dir  dir 
)
related
template<typename To , typename From >
Enable_If< Is_Native_Or_Checked< To >::value &&Is_Special< From >::value, Result >::type assign_r ( To &  to,
const From &  x,
Rounding_Dir  dir 
)
related
template<typename To >
Enable_If< Is_Native_Or_Checked< To >::value, Result >::type assign_r ( To &  to,
const char *  x,
Rounding_Dir  dir 
)
related
template<typename To , typename To_Policy >
Enable_If< Is_Native_Or_Checked< To >::value, Result >::type assign_r ( To &  to,
char *  x,
Rounding_Dir  dir 
)
related
template<typename T , typename Policy >
memory_size_type total_memory_in_bytes ( const Checked_Number< T, Policy > &  x)
related

Returns the total size in bytes of the memory occupied by x.

template<typename T , typename Policy >
memory_size_type external_memory_in_bytes ( const Checked_Number< T, Policy > &  x)
related

Returns the size in bytes of the memory managed by x.

template<typename T , typename Policy >
Checked_Number< T, Policy > operator+ ( const Checked_Number< T, Policy > &  x)
related

Unary plus operator.

template<typename T , typename Policy >
Checked_Number< T, Policy > operator- ( const Checked_Number< T, Policy > &  x)
related

Unary minus operator.

template<typename T , typename Policy >
void floor_assign ( Checked_Number< T, Policy > &  x)
related

Assigns to x largest integral value not greater than x.

template<typename T , typename Policy >
void floor_assign ( Checked_Number< T, Policy > &  x,
const Checked_Number< T, Policy > &  y 
)
related

Assigns to x largest integral value not greater than y.

template<typename T , typename Policy >
void ceil_assign ( Checked_Number< T, Policy > &  x)
related

Assigns to x smallest integral value not less than x.

template<typename T , typename Policy >
void ceil_assign ( Checked_Number< T, Policy > &  x,
const Checked_Number< T, Policy > &  y 
)
related

Assigns to x smallest integral value not less than y.

template<typename T , typename Policy >
void trunc_assign ( Checked_Number< T, Policy > &  x)
related

Round x to the nearest integer not larger in absolute value.

template<typename T , typename Policy >
void trunc_assign ( Checked_Number< T, Policy > &  x,
const Checked_Number< T, Policy > &  y 
)
related

Assigns to x the value of y rounded to the nearest integer not larger in absolute value.

template<typename T , typename Policy >
void neg_assign ( Checked_Number< T, Policy > &  x)
related

Assigns to x its negation.

template<typename T , typename Policy >
void neg_assign ( Checked_Number< T, Policy > &  x,
const Checked_Number< T, Policy > &  y 
)
related

Assigns to x the negation of y.

template<typename T , typename Policy >
void abs_assign ( Checked_Number< T, Policy > &  x)
related

Assigns to x its absolute value.

template<typename T , typename Policy >
void abs_assign ( Checked_Number< T, Policy > &  x,
const Checked_Number< T, Policy > &  y 
)
related

Assigns to x the absolute value of y.

template<typename T , typename Policy >
void add_mul_assign ( Checked_Number< T, Policy > &  x,
const Checked_Number< T, Policy > &  y,
const Checked_Number< T, Policy > &  z 
)
related

Assigns to x the value x + y * z.

template<typename T , typename Policy >
void sub_mul_assign ( Checked_Number< T, Policy > &  x,
const Checked_Number< T, Policy > &  y,
const Checked_Number< T, Policy > &  z 
)
related

Assigns to x the value x - y * z.

template<typename T , typename Policy >
void gcd_assign ( Checked_Number< T, Policy > &  x,
const Checked_Number< T, Policy > &  y,
const Checked_Number< T, Policy > &  z 
)
related

Assigns to x the greatest common divisor of y and z.

template<typename T , typename Policy >
void gcdext_assign ( Checked_Number< T, Policy > &  x,
Checked_Number< T, Policy > &  s,
Checked_Number< T, Policy > &  t,
const Checked_Number< T, Policy > &  y,
const Checked_Number< T, Policy > &  z 
)
related

Assigns to x the greatest common divisor of y and z, setting s and t such that s*y + t*z = x = gcd(y, z).

template<typename T , typename Policy >
void lcm_assign ( Checked_Number< T, Policy > &  x,
const Checked_Number< T, Policy > &  y,
const Checked_Number< T, Policy > &  z 
)
related

Assigns to x the least common multiple of y and z.

template<typename T , typename Policy >
void mul_2exp_assign ( Checked_Number< T, Policy > &  x,
const Checked_Number< T, Policy > &  y,
unsigned int  exp 
)
related

Assigns to x the value $ y \cdot 2^\mathtt{exp} $.

template<typename T , typename Policy >
void div_2exp_assign ( Checked_Number< T, Policy > &  x,
const Checked_Number< T, Policy > &  y,
unsigned int  exp 
)
related

Assigns to x the value $ y / 2^\mathtt{exp} $.

template<typename T , typename Policy >
void exact_div_assign ( Checked_Number< T, Policy > &  x,
const Checked_Number< T, Policy > &  y,
const Checked_Number< T, Policy > &  z 
)
related

If z divides y, assigns to x the quotient of the integer division of y and z.

The behavior is undefined if z does not divide y.

template<typename T , typename Policy >
void sqrt_assign ( Checked_Number< T, Policy > &  x,
const Checked_Number< T, Policy > &  y 
)
related

Assigns to x the integer square root of y.

template<typename T1 , typename T2 >
Enable_If< Is_Native_Or_Checked< T1 >::value &&Is_Native_Or_Checked< T2 >::value &&(Is_Checked< T1 >::value||Is_Checked< T2 >::value), bool >::type operator== ( const T1 &  x,
const T2 &  y 
)
related

Equality operator.

template<typename T1 , typename T2 >
Enable_If< Is_Native_Or_Checked< T1 >::value &&Is_Native_Or_Checked< T2 >::value, bool >::type equal ( const T1 &  x,
const T2 &  y 
)
related
template<typename T1 , typename T2 >
Enable_If< Is_Native_Or_Checked< T1 >::value &&Is_Native_Or_Checked< T2 >::value &&(Is_Checked< T1 >::value||Is_Checked< T2 >::value), bool >::type operator!= ( const T1 &  x,
const T2 &  y 
)
related

Disequality operator.

template<typename T1 , typename T2 >
Enable_If< Is_Native_Or_Checked< T1 >::value &&Is_Native_Or_Checked< T2 >::value, bool >::type not_equal ( const T1 &  x,
const T2 &  y 
)
related
template<typename T1 , typename T2 >
Enable_If< Is_Native_Or_Checked< T1 >::value &&Is_Native_Or_Checked< T2 >::value &&(Is_Checked< T1 >::value||Is_Checked< T2 >::value), bool >::type operator>= ( const T1 &  x,
const T2 &  y 
)
related

Greater than or equal to operator.

template<typename T1 , typename T2 >
Enable_If< Is_Native_Or_Checked< T1 >::value &&Is_Native_Or_Checked< T2 >::value, bool >::type greater_or_equal ( const T1 &  x,
const T2 &  y 
)
related
template<typename T1 , typename T2 >
Enable_If< Is_Native_Or_Checked< T1 >::value &&Is_Native_Or_Checked< T2 >::value &&(Is_Checked< T1 >::value||Is_Checked< T2 >::value), bool >::type operator> ( const T1 &  x,
const T2 &  y 
)
related

Greater than operator.

template<typename T1 , typename T2 >
Enable_If< Is_Native_Or_Checked< T1 >::value &&Is_Native_Or_Checked< T2 >::value, bool >::type greater_than ( const T1 &  x,
const T2 &  y 
)
related
template<typename T1 , typename T2 >
Enable_If< Is_Native_Or_Checked< T1 >::value &&Is_Native_Or_Checked< T2 >::value &&(Is_Checked< T1 >::value||Is_Checked< T2 >::value), bool >::type operator<= ( const T1 &  x,
const T2 &  y 
)
related

Less than or equal to operator.

template<typename T1 , typename T2 >
Enable_If< Is_Native_Or_Checked< T1 >::value &&Is_Native_Or_Checked< T2 >::value, bool >::type less_or_equal ( const T1 &  x,
const T2 &  y 
)
related
template<typename T1 , typename T2 >
Enable_If< Is_Native_Or_Checked< T1 >::value &&Is_Native_Or_Checked< T2 >::value &&(Is_Checked< T1 >::value||Is_Checked< T2 >::value), bool >::type operator< ( const T1 &  x,
const T2 &  y 
)
related

Less than operator.

template<typename T1 , typename T2 >
Enable_If< Is_Native_Or_Checked< T1 >::value &&Is_Native_Or_Checked< T2 >::value, bool >::type less_than ( const T1 &  x,
const T2 &  y 
)
related
template<typename T >
Enable_If< Is_Native_Or_Checked< T >::value, Result >::type output ( std::ostream &  os,
const T &  x,
const Numeric_Format &  format,
Rounding_Dir  dir 
)
related
template<typename T , typename Policy >
std::ostream & operator<< ( std::ostream &  os,
const Checked_Number< T, Policy > &  x 
)
related

Output operator.

template<typename T >
Enable_If< Is_Native_Or_Checked< T >::value, void >::type ascii_dump ( std::ostream &  s,
const T &  t 
)
related

Ascii dump for native or checked.

template<typename T >
Enable_If< Is_Native_Or_Checked< T >::value, Result >::type input ( T &  x,
std::istream &  is,
Rounding_Dir  dir 
)
related

Input function.

Parameters
isInput stream to read from;
xNumber (possibly extended) to assign to in case of successful reading;
dirRounding mode to be applied.
Returns
Result of the input operation. Success, success with imprecision, overflow, parsing error: all possibilities are taken into account, checked for, and properly reported.

This function attempts reading a (possibly extended) number from the given stream is, possibly rounding as specified by dir, assigning the result to x upon success, and returning the appropriate Result.

The input syntax allows the specification of:

  • plain base-10 integer numbers as 34976098, -77 and +13;
  • base-10 integer numbers in scientific notation as 15e2 and 15*^2 (both meaning $15 \cdot 10^2 = 1500$), 9200e-2 and -18*^+11111111111111111;
  • base-10 rational numbers in fraction notation as 15/3 and 15/-3;
  • base-10 rational numbers in fraction/scientific notation as 15/30e-1 (meaning $5$) and 15*^-3/29e2 (meaning $3/580000$);
  • base-10 rational numbers in floating point notation as 71.3 (meaning $713/10$) and -0.123456 (meaning $-1929/15625$);
  • base-10 rational numbers in floating point scientific notation as 2.2e-1 (meaning $11/50$) and -2.20001*^+3 (meaning $-220001/100$);
  • integers and rationals (in fractional, floating point and scientific notations) specified by using Mathematica-style bases, in the range from 2 to 36, as 2^^11 (meaning $3$), 36^^z (meaning $35$), 36^^xyz (meaning $44027$), 2^^11.1 (meaning $7/2$), 10^^2e3 (meaning $2000$), 8^^2e3 (meaning $1024$), 8^^2.1e3 (meaning $1088$), 8^^20402543.120347e7 (meaning $9073863231288$), 8^^2.1 (meaning $17/8$); note that the base and the exponent are always written as plain base-10 integer numbers; also, when an ambiguity may arise, the character e is interpreted as a digit, so that 16^^1e2 (meaning $482$) is different from 16^^1*^2 (meaning $256$);
  • the C-style hexadecimal prefix 0x is interpreted as the Mathematica-style prefix 16^^;
  • the C-style binary exponent indicator p can only be used when base 16 has been specified; if used, the exponent will be applied to base 2 (instead of base 16, as is the case when the indicator e is used);
  • special values like inf and +inf (meaning $+\infty$), -inf (meaning $-\infty$), and nan (meaning "not a number").

The rationale behind the accepted syntax can be summarized as follows:

  • if the syntax is accepted by Mathematica, then this function accepts it with the same semantics;
  • if the syntax is acceptable as standard C++ integer or floating point literal (except for octal notation and type suffixes, which are not supported), then this function accepts it with the same semantics;
  • natural extensions of the above are accepted with the natural extensions of the semantics;
  • special values are accepted.

Valid syntax is more formally and completely specified by the following grammar, with the additional provisos that everything is case insensitive, that the syntactic category BDIGIT is further restricted by the current base and that for all bases above 14, any e is always interpreted as a digit and never as a delimiter for the exponent part (if such a delimiter is desired, it has to be written as *^).

number : NAN INF : 'inf'
| SIGN INF ;
| INF
| num NAN : 'nan'
| num DIV num ;
;
SIGN : '-'
num : u_num | '+'
| SIGN u_num ;
u_num : u_num1 EXP : 'e'
| HEX u_num1 | 'p'
| base BASE u_num1 | '*^'
; ;
POINT : '.'
u_num1 : mantissa ;
| mantissa EXP exponent
; DIV : '/'
;
mantissa: bdigits
| POINT bdigits MINUS : '-'
| bdigits POINT ;
| bdigits POINT bdigits
; PLUS : '+'
;
exponent: SIGN digits
| digits HEX : '0x'
; ;
bdigits : BDIGIT BASE : '^^'
| bdigits BDIGIT ;
;
DIGIT : '0' .. '9'
digits : DIGIT ;
| digits DIGIT
; BDIGIT : '0' .. '9'
| 'a' .. 'z'
;
template<typename T , typename Policy >
std::istream & operator>> ( std::istream &  is,
Checked_Number< T, Policy > &  x 
)
related

Input operator.

template<typename T >
Enable_If< Is_Native_Or_Checked< T >::value, bool >::type ascii_load ( std::ostream &  s,
T &  t 
)
related

Ascii load for native or checked.

template<typename T , typename Policy >
void swap ( Checked_Number< T, Policy > &  x,
Checked_Number< T, Policy > &  y 
)
related

Swaps x with y.

template<typename T , typename Policy >
const T & raw_value ( const Checked_Number< T, Policy > &  x)
related
template<typename T , typename Policy >
T & raw_value ( Checked_Number< T, Policy > &  x)
related
template<typename T , typename Policy >
memory_size_type total_memory_in_bytes ( const Checked_Number< T, Policy > &  x)
related
template<typename T , typename Policy >
memory_size_type external_memory_in_bytes ( const Checked_Number< T, Policy > &  x)
related
template<typename To >
Enable_If< Is_Native_Or_Checked< To >::value, Result >::type assign_r ( To &  to,
const char *  x,
Rounding_Dir  dir 
)
related
template<typename T , typename Policy >
Checked_Number< T, Policy > operator+ ( const Checked_Number< T, Policy > &  x)
related
template<typename T , typename Policy >
Checked_Number< T, Policy > operator- ( const Checked_Number< T, Policy > &  x)
related
template<typename From >
Enable_If< Is_Native_Or_Checked< From >::value, int >::type sgn ( const From &  x)
related
template<typename From1 , typename From2 >
Enable_If< Is_Native_Or_Checked< From1 >::value &&Is_Native_Or_Checked< From2 >::value, int >::type cmp ( const From1 &  x,
const From2 &  y 
)
related
template<typename T >
Enable_If< Is_Native_Or_Checked< T >::value, Result >::type output ( std::ostream &  os,
const T &  x,
const Numeric_Format &  format,
Rounding_Dir  dir 
)
related
template<typename T , typename Policy >
std::ostream & operator<< ( std::ostream &  os,
const Checked_Number< T, Policy > &  x 
)
related
template<typename T >
Enable_If< Is_Native_Or_Checked< T >::value, Result >::type input ( T &  x,
std::istream &  is,
Rounding_Dir  dir 
)
related
template<typename T , typename Policy >
std::istream & operator>> ( std::istream &  is,
Checked_Number< T, Policy > &  x 
)
related
template<typename T , typename Policy >
void swap ( Checked_Number< T, Policy > &  x,
Checked_Number< T, Policy > &  y 
)
related

The documentation for this class was generated from the following file: