pm::Integer Class Reference

Wrapper class for GMP's mpz_t type. More...

Inherited by pm::GMP::Proxy< kind, _canonicalize >.

List of all members.


Public Member Functions

 Integer ()
 Initialize to 0.
 Integer (long i)
 conversion
 Integer (int i)
 conversion
 Integer (double d)
 conversion
 Integer (const char *s)
 Recognizes automatically number base 10, 8, or 16.
 Integer (GMP::TempInteger &tmp)
 take over the GMP structure without copying
 Integer (const Rational &b)
 Performs division with rounding via truncation.
Integer & operator= (const Rational &b)
 Performs division with rounding via truncation.
Integer & operator= (const Integer &b)
 Assignment.
Integer & operator= (long b)
 Assignment with conversion.
Integer & operator= (int b)
 Assignment with conversion.
Integer & operator= (double d)
 Assignment with conversion.
Integer & set (const char *s)
 Recognizes automatically number base 10, 8, or 16.
Integer & set (mpz_srcptr src)
 for the rare case of unwrapped GMP objects coexisting with us
 operator double () const
 Cast.
 operator long () const
 Cast.
 operator int () const
 Cast.
std::string to_string (int base=10) const
 Converts integer to string.
void swap (Integer &b)
 Efficiently swapping two Integer objects.
Integer & operator++ ()
 Increment.
Integer & operator-- ()
 Decrement.
Integer & negate ()
 In-place negation.
Integer & operator+= (const Integer &b)
 Addition.
Integer & operator+= (long b)
 Addition.
Integer & operator-= (const Integer &b)
 Subtraction.
Integer & operator-= (long b)
 Subtraction.
Integer & operator*= (const Integer &b)
 Multiplication.
Integer & operator*= (long b)
 Multiplication.
Integer & operator/= (const Integer &b)
 Division with rounding via truncation.
Integer & operator/= (long b)
 Division with rounding via truncation.
Integer & div_exact (const Integer &b)
 b != infinity; but 0/0 allowed
Integer & div_exact (long b)
 0/0 allowed
Integer & operator%= (const Integer &b)
 Remainder of division.
Integer & operator%= (long b)
 Remainder of division.
Integer & operator<<= (unsigned long k)
 Multiply with 2**k.
Integer & operator>>= (unsigned long k)
 Divide through 2**k, truncate to zero.
bool bit (unsigned long i) const
 Test for bits.
bool odd () const
 Parity.
bool even () const
 Parity.
bool operator! () const
 Compares with 0.
 operator bool () const
 Compares with 0.
int compare (const Integer &b) const
 Comparison. The magnitude of the return value is arbitrary, only its sign is relevant.
int compare (long b) const
 Comparision.
int compare (int b) const
 Comparision.
int compare (double b) const
 Comparision.
void read (std::istream &is, bool allow_sign=true)
size_t strsize (std::ios::fmtflags flags) const
 Calculates the size of the buffer needed to store an ASCII representation of an Integer.
void putstr (std::ios::fmtflags flags, char *buf) const

Static Public Member Functions

static Integer fac (long k)
 Factorial.
static Integer pow (const Integer &a, unsigned long k)
 Power.
static Integer pow (unsigned long a, unsigned long k)
 Power.
static Integer binom (const Integer &n, long k)
 Binomial coefficient.
static Integer binom (long n, long k)
 Binomial coefficient.

Protected Attributes

mpz_t rep
 GMP's representation.

Friends

int isfinite (const Integer &a)
 Returns a positive number if not equal to infinity, otherwise zero.
int isinf (const Integer &a)
 Returns the sign if equal to +/-infinity, otherwise zero.
void relocate (Integer *from, Integer *to)
Integer operator+ (const Integer &a, const Integer &b)
 Addition.
Integer operator+ (const Integer &a, long b)
 Addition.
Integer operator- (const Integer &a, const Integer &b)
 Subtraction.
Integer operator- (const Integer &a, long b)
 Subtraction.
Integer operator- (long a, const Integer &b)
 Subtraction.
Integer operator- (const Integer &a)
 Subtraction.
Integer operator* (const Integer &a, const Integer &b)
 Multiplication.
Integer operator* (const Integer &a, long b)
 Multiplication.
Integer operator/ (const Integer &a, const Integer &b)
 Division with rounding via truncation.
Integer operator/ (const Integer &a, long b)
 Division.
int operator/ (int a, const Integer &b)
 Division.
long operator/ (long a, const Integer &b)
 Division.
Integer operator% (const Integer &a, const Integer &b)
 Remainder of division.
long operator% (const Integer &a, long b)
 Remainder of division.
Integer operator% (int a, const Integer &b)
 Remainder of division.
Integer operator% (long a, const Integer &b)
 Remainder of division.
Integer operator<< (const Integer &a, unsigned long k)
 Multiply with 2**k.
Integer operator>> (const Integer &a, unsigned long k)
 Divide through 2**k, truncate to 0.
bool operator== (const Integer &a, long b)
 Equality.
bool operator< (const Integer &a, long b)
 Less than.
bool operator> (const Integer &a, long b)
 Greater than.
bool abs_equal (const Integer &a, const Integer &b)
 Equality of absolute values.
bool abs_equal (const Integer &a, long b)
 Equality of absolute values.
bool abs_equal (const Integer &a, double b)
 Equality of absolute values.
Integer sqrt (const Integer &a)
 Square Root.
Integer abs (const Integer &a)
 Absolute value.
Integer gcd (const Integer &a, const Integer &b)
 Greatest common divisor.
Integer gcd (const Integer &a, long b)
 Greatest common divisor.
Integer gcd (long a, const Integer &b)
 Greatest common divisor.
Integer lcm (const Integer &a, const Integer &b)
 Least common multiple.
void gcd_ext (const Integer &a, const Integer &b, Integer &g, Integer &p, Integer &q)
 Extended gcd algorithm: g=a*p+b*q.
Integer div_exact (const Integer &a, const Integer &b)
 Division.
Integer div_exact (const Integer &a, long b)
 Division.
int log2_floor (const Integer &a)
 Logarithm (rounded down).
int log2_ceil (const Integer &a)
 Logarithm (rounded up).
std::ostream & operator<< (std::ostream &os, const Integer &a)
 Output to stream.
std::istream & operator>> (std::istream &is, Integer &a)
 Input from stream.

Classes

struct  div_t
 Analogous to div_t. More...

Detailed Description

Wrapper class for GMP's mpz_t type.

Member Function Documentation

void pm::Integer::read ( std::istream &  is,
bool  allow_sign = true 
)

Parameters:
allow_sign whether leading whitespaces and sign are expected

void pm::Integer::putstr ( std::ios::fmtflags  flags,
char *  buf 
) const

Produces a printable representation of an Integer.

Parameters:
buf buffer of size not less than the return value of strsize().


Friends And Related Function Documentation

void relocate ( Integer *  from,
Integer *  to 
) [friend]

Accelerated combination of copy constructor and destructor. Aimed to be used in container classes only!


The documentation for this class was generated from the following files:
Generated on Wed Mar 30 23:31:46 2011 for Polymake Template Library (PTL) by doxygen 1.5.6