plll  1.0
plll::arithmetic::Integer Class Reference

Represents an arbitrary precision integer. More...

#include <arithmetic-gmp.hpp>

Public Types

typedef IntegerContext Context
 The context type.
 

Public Member Functions

 Integer ()
 Creates a new integer. Default value is zero.
 
 Integer (const IntegerContext &c)
 Creates a new integer. Default value is zero. More...
 
 Integer (const Integer &i)
 Creates a copy of the given integer. More...
 
 Integer (const Integer &i, const IntegerContext &ic)
 Creates a copy of the given integer. More...
 
 Integer (signed int i)
 Creates a arbitrary precision integer from the given native integer. More...
 
 Integer (unsigned int i)
 Creates a arbitrary precision integer from the given native integer. More...
 
 Integer (signed long i)
 Creates a arbitrary precision integer from the given native integer. More...
 
 Integer (unsigned long i)
 Creates a arbitrary precision integer from the given native integer. More...
 
 Integer (long long i)
 Creates a arbitrary precision integer from the given native integer. More...
 
 Integer (double d)
 Creates a arbitrary precision integer from the given native floating point number. More...
 
 Integer (long double d)
 Creates a arbitrary precision integer from the given native floating point number. More...
 
template<class A , template< typename, typename > class O>
 Integer (const expressions::Expression< IntegerContext, A, O > &E)
 Creates an integer from the given integer expression. More...
 
template<class A , template< typename, typename > class O>
 Integer (const expressions::Expression< IntegerContext, A, O > &E, const IntegerContext &ic)
 Creates an integer from the given integer expression. More...
 
 Integer (const Real &r)
 Creates an integer from the given arbitrary precision floating point number. More...
 
Integeroperator= (const Integer &i)
 Assigns the integer i to the current integer.
 
 ~Integer () PLLL_INTERNAL_NOTHROW_POSTFIX_INLINE
 Releases the memory used by the arbitrary precision integer.
 

Static Public Member Functions

static void setContext (const IntegerContext &c)
 Sets the integer context c. More...
 

Friends

void abs (Integer &r, const Integer &a)
 Takes the absolute value of a and stores the result in r. More...
 
void add (Integer &r, const Integer &a, const Integer &b)
 Adds a and b and stores the result in r. More...
 
void addmul (Integer &r, const Integer &a, const Integer &b)
 Multiplies a and b and adds the result to r. More...
 
long approxLog2 (const Integer &x) PLLL_INTERNAL_NOTHROW_POSTFIX_INLINE
 Quickly approximates $\log_2 |x|$ and returns the approximation. More...
 
void band (Integer &r, const Integer &a, const Integer &b)
 Computes the bitwise and of a and b and stores the result in r. More...
 
int bit (const Integer &x, long n) PLLL_INTERNAL_NOTHROW_POSTFIX_INLINE
 Returns the n bit of $|x|$ in the usual binary representation. More...
 
long bitLength (const Integer &x) PLLL_INTERNAL_NOTHROW_POSTFIX_INLINE
 Computes and returns n such that $2^{n-1} \le |x| < 2^n$. More...
 
void bneg (Integer &r, const Integer &a)
 Takes the bitwise complement of a and stores the result in r. More...
 
void bor (Integer &r, const Integer &a, const Integer &b)
 Computes the bitwise or of a and b and stores the result in r. More...
 
void bxor (Integer &r, const Integer &a, const Integer &b)
 Computes the bitwise exclusive or of a and b and stores the result in r. More...
 
void ceilDiv (Integer &r, const Integer &a, const Integer &b)
 Computes $\lceil \tfrac{a}{b} \rceil$ and stores the result in r. More...
 
long ceilOfLog2 (const Integer &x) PLLL_INTERNAL_NOTHROW_POSTFIX_INLINE
 Computes and returns $\lceil \log_2 |x| \rceil$. More...
 
int compare (const Integer &a, const Integer &b)
 Compares the two integers. More...
 
int compareAbsValues (const Integer &a, const Integer &b)
 Compares the two integers in absolute value. More...
 
void decrement (Integer &r, const Integer &a)
 Decrements a by one and stores the result in r. More...
 
void div (Integer &r, const Integer &a, const Integer &b)
 Divides a by b and stores the result in r. More...
 
void divmod (Integer &q, Integer &r, const Integer &a, const Integer &b)
 Stores quotient and remainder of the division of a by b in q respectively r. More...
 
void euclideanDivision (Integer &q, Integer &r, const Integer &a, const Integer &b)
 Computes an Euclidean Division of a by b. More...
 
void euclideanDivisionPos (Integer &q, Integer &r, const Integer &a, const Integer &b)
 Computes an Euclidean Division of a by b. More...
 
void floorDiv (Integer &r, const Integer &a, const Integer &b)
 Computes $\lfloor \tfrac{a}{b} \rfloor$ and stores the result in r. More...
 
long floorOfLog2 (const Integer &x) PLLL_INTERNAL_NOTHROW_POSTFIX_INLINE
 Computes and returns $\lfloor \log_2 |x| \rfloor$. More...
 
void GCD (Integer &r, const Integer &x, const Integer &y)
 Computes the non-negative Greatest Common Divisior r of x and y. More...
 
void increment (Integer &r, const Integer &a)
 Increments a by one and stores the result in r. More...
 
bool isNegative (const Integer &i) PLLL_INTERNAL_NOTHROW_POSTFIX_INLINE
 Tests the given plll::arithmetic::Integer object for being strictly negative. More...
 
bool isNonNegative (const Integer &i) PLLL_INTERNAL_NOTHROW_POSTFIX_INLINE
 Tests the given plll::arithmetic::Integer object for being positive or zero. More...
 
bool isNonPositive (const Integer &i) PLLL_INTERNAL_NOTHROW_POSTFIX_INLINE
 Tests the given plll::arithmetic::Integer object for being negative or zero. More...
 
bool isOne (const Integer &i) PLLL_INTERNAL_NOTHROW_POSTFIX_INLINE
 Tests the given plll::arithmetic::Integer object for being one. More...
 
bool isPMOne (const Integer &i) PLLL_INTERNAL_NOTHROW_POSTFIX_INLINE
 Tests the given plll::arithmetic::Integer object for being one or minus one. More...
 
bool isPMTwo (const Integer &i) PLLL_INTERNAL_NOTHROW_POSTFIX_INLINE
 Tests the given plll::arithmetic::Integer object for being two or minus two. More...
 
bool isPositive (const Integer &i) PLLL_INTERNAL_NOTHROW_POSTFIX_INLINE
 Tests the given plll::arithmetic::Integer object for being strictly positive. More...
 
bool isZero (const Integer &i) PLLL_INTERNAL_NOTHROW_POSTFIX_INLINE
 Tests the given plll::arithmetic::Integer object for being zero. More...
 
void LCM (Integer &r, const Integer &x, const Integer &y)
 Computes the non-negative Least Common Multiple r of x and y. More...
 
void makeAbs (Integer &a) PLLL_INTERNAL_NOTHROW_POSTFIX_INLINE
 Makes the operand non-negative. More...
 
void mod (Integer &r, const Integer &a, const Integer &b)
 Takes the remainder of the division of a by b and stores it in r. More...
 
void mul (Integer &r, const Integer &a, const Integer &b)
 Multiplies a with b and stores the result in r. More...
 
void neg (Integer &r, const Integer &a)
 Negates a and stores the result in r. More...
 
bool operator!= (const Integer &a, const Integer &b)
 Compares the current integer with the given one for inequality. More...
 
bool operator< (const Integer &a, const Integer &b)
 Compares the current integer with the given one. More...
 
std::ostream & operator<< (std::ostream &s, const Integer &i)
 Outputs the integer on the given output stream.
 
bool operator<= (const Integer &a, const Integer &b)
 Compares the current integer with the given one. More...
 
bool operator== (const Integer &a, const Integer &b)
 Compares the current integer with the given one for equality. More...
 
bool operator> (const Integer &a, const Integer &b)
 Compares the current integer with the given one. More...
 
bool operator>= (const Integer &a, const Integer &b)
 Compares the current integer with the given one. More...
 
std::istream & operator>> (std::istream &s, Integer &i)
 Reads the integer from the given input stream.
 
void power (Integer &r, const Integer &a, long b)
 Raises a to the power b and stores the result in r. More...
 
void power (Integer &r, const Integer &a, const Integer &b)
 Raises a to the power b and stores the result in r. More...
 
void power (Real &res, const Real &a, const Integer &b)
 Raises a to the power b and stores the result in res. More...
 
void roundDiv (Integer &r, const Integer &a, const Integer &b)
 Computes $\lfloor \tfrac{a}{b} \rceil$ (rounding to the next integer) and stores the result in r. More...
 
void setbit (Integer &x, long n, bool value)
 Sets the n-th bit of $|x|$ to value. More...
 
void setOne (Integer &i)
 Sets the given integer to one.
 
void setZero (Integer &i)
 Sets the given integer to zero.
 
void shl (Integer &r, const Integer &a, long b)
 Shifts a by b bits to the left and stores the result in r. More...
 
void shl (Integer &r, const Integer &a, const Integer &b)
 Shifts a by b bits to the right and stores the result in r. More...
 
void shr (Integer &r, const Integer &a, long b)
 Shifts a by b bits to the left and stores the result in r. More...
 
void shr (Integer &r, const Integer &a, const Integer &b)
 Shifts a by b bits to the right and stores the result in r. More...
 
int sign (const Integer &i) PLLL_INTERNAL_NOTHROW_POSTFIX_INLINE
 Returns the sign of the given integer. More...
 
void sqrtCeil (Integer &r, const Integer &a)
 Computes $\lceil\sqrt{a}\rceil$ and stores the result in r. More...
 
void sqrtFloor (Integer &r, const Integer &a)
 Computes $\lfloor\sqrt{a}\rfloor$ and stores the result in r. More...
 
void square (Integer &r, const Integer &a)
 Computes the square of a and stores the result in r. More...
 
void sub (Integer &r, const Integer &a, const Integer &b)
 Subtracts b from a and stores the result in r. More...
 
void submul (Integer &r, const Integer &a, const Integer &b)
 Multiplies a and b and subtracts the result from r. More...
 
void XGCD (Integer &r, Integer &a, Integer &b, const Integer &x, const Integer &y)
 Computes the non-negative extended Greatest Common Divisior r of x and y. More...
 

Detailed Description

Represents an arbitrary precision integer.

Definition at line 1071 of file arithmetic-gmp.hpp.

Constructor & Destructor Documentation

plll::arithmetic::Integer::Integer ( const IntegerContext c)
inlineexplicit

Creates a new integer. Default value is zero.

Parameters
cAn integer context.

Definition at line 1115 of file arithmetic-gmp.hpp.

plll::arithmetic::Integer::Integer ( const Integer i)
inline

Creates a copy of the given integer.

Parameters
iThe integer to be copied.

Definition at line 1125 of file arithmetic-gmp.hpp.

plll::arithmetic::Integer::Integer ( const Integer i,
const IntegerContext ic 
)
inline

Creates a copy of the given integer.

Parameters
iThe integer to be copied.
icAn integer context.

Definition at line 1136 of file arithmetic-gmp.hpp.

plll::arithmetic::Integer::Integer ( signed int  i)
inlineexplicit

Creates a arbitrary precision integer from the given native integer.

Parameters
iThe native integer.

Definition at line 1146 of file arithmetic-gmp.hpp.

plll::arithmetic::Integer::Integer ( unsigned int  i)
inlineexplicit

Creates a arbitrary precision integer from the given native integer.

Parameters
iThe native integer.

Definition at line 1156 of file arithmetic-gmp.hpp.

plll::arithmetic::Integer::Integer ( signed long  i)
inlineexplicit

Creates a arbitrary precision integer from the given native integer.

Parameters
iThe native integer.

Definition at line 1166 of file arithmetic-gmp.hpp.

plll::arithmetic::Integer::Integer ( unsigned long  i)
inlineexplicit

Creates a arbitrary precision integer from the given native integer.

Parameters
iThe native integer.

Definition at line 1176 of file arithmetic-gmp.hpp.

plll::arithmetic::Integer::Integer ( long long  i)
inlineexplicit

Creates a arbitrary precision integer from the given native integer.

Parameters
iThe native integer.

Definition at line 1186 of file arithmetic-gmp.hpp.

plll::arithmetic::Integer::Integer ( double  d)
inlineexplicit

Creates a arbitrary precision integer from the given native floating point number.

Parameters
dThe native floating point number.

Definition at line 1198 of file arithmetic-gmp.hpp.

plll::arithmetic::Integer::Integer ( long double  d)
inlineexplicit

Creates a arbitrary precision integer from the given native floating point number.

Parameters
dThe native floating point number.

Definition at line 1209 of file arithmetic-gmp.hpp.

template<class A , template< typename, typename > class O>
plll::arithmetic::Integer::Integer ( const expressions::Expression< IntegerContext, A, O > &  E)
inline

Creates an integer from the given integer expression.

Parameters
EAn integer expression.

Definition at line 1220 of file arithmetic-gmp.hpp.

template<class A , template< typename, typename > class O>
plll::arithmetic::Integer::Integer ( const expressions::Expression< IntegerContext, A, O > &  E,
const IntegerContext ic 
)
inline

Creates an integer from the given integer expression.

Parameters
EAn integer expression.
icAn integer context.

Definition at line 1233 of file arithmetic-gmp.hpp.

plll::arithmetic::Integer::Integer ( const Real r)
explicit

Creates an integer from the given arbitrary precision floating point number.

Parameters
rAn arbitrary precision floating point number.

Member Function Documentation

static void plll::arithmetic::Integer::setContext ( const IntegerContext c)
inlinestatic

Sets the integer context c.

Parameters
cThe integer context.

Definition at line 1288 of file arithmetic-gmp.hpp.

Friends And Related Function Documentation

void abs ( Integer r,
const Integer a 
)
friend

Takes the absolute value of a and stores the result in r.

Parameters
rThe result.
aThe operand.

Definition at line 1458 of file arithmetic-gmp.hpp.

void add ( Integer r,
const Integer a,
const Integer b 
)
friend

Adds a and b and stores the result in r.

Parameters
rThe result.
aThe first operand.
bThe second operand.

Definition at line 1319 of file arithmetic-gmp.hpp.

void addmul ( Integer r,
const Integer a,
const Integer b 
)
friend

Multiplies a and b and adds the result to r.

Parameters
rThe accumulator.
aThe first operand.
bThe second operand.

Definition at line 1463 of file arithmetic-gmp.hpp.

long approxLog2 ( const Integer x)
friend

Quickly approximates $\log_2 |x|$ and returns the approximation.

Parameters
xA non-zero integer.
Returns
$\approx \log_2 |x|$.

Definition at line 1793 of file arithmetic-gmp.hpp.

void band ( Integer r,
const Integer a,
const Integer b 
)
friend

Computes the bitwise and of a and b and stores the result in r.

Parameters
rThe result.
aThe first operand.
bThe second operand.

Definition at line 1555 of file arithmetic-gmp.hpp.

int bit ( const Integer x,
long  n 
)
friend

Returns the n bit of $|x|$ in the usual binary representation.

Parameters
xThe integer whose bit to query.
nThe index of the bit to query.

Definition at line 1773 of file arithmetic-gmp.hpp.

long bitLength ( const Integer x)
friend

Computes and returns n such that $2^{n-1} \le |x| < 2^n$.

Parameters
xA non-zero integer.
Returns
$n \in \mathbb{N}$ such that ` $2^{n-1} \le |x| < 2^n$.
See also
Integer Functions

Definition at line 1810 of file arithmetic-gmp.hpp.

void bneg ( Integer r,
const Integer a 
)
friend

Takes the bitwise complement of a and stores the result in r.

Parameters
rThe result.
aThe operand.

Definition at line 1570 of file arithmetic-gmp.hpp.

void bor ( Integer r,
const Integer a,
const Integer b 
)
friend

Computes the bitwise or of a and b and stores the result in r.

Parameters
rThe result.
aThe first operand.
bThe second operand.

Definition at line 1560 of file arithmetic-gmp.hpp.

void bxor ( Integer r,
const Integer a,
const Integer b 
)
friend

Computes the bitwise exclusive or of a and b and stores the result in r.

Parameters
rThe result.
aThe first operand.
bThe second operand.

Definition at line 1565 of file arithmetic-gmp.hpp.

void ceilDiv ( Integer r,
const Integer a,
const Integer b 
)
friend

Computes $\lceil \tfrac{a}{b} \rceil$ and stores the result in r.

Parameters
rThe result.
aThe divident.
bThe divisor.
See also
Integer Functions

Definition at line 1524 of file arithmetic-gmp.hpp.

long ceilOfLog2 ( const Integer x)
friend

Computes and returns $\lceil \log_2 |x| \rceil$.

Parameters
xA non-zero integer.
Returns
$n \in \mathbb{N}$ such that ` $2^{n-1} < |x| \le 2^n$.
See also
Integer Functions

Definition at line 1798 of file arithmetic-gmp.hpp.

int compare ( const Integer a,
const Integer b 
)
friend

Compares the two integers.

Parameters
aThe first operand.
bThe second operand.
Returns
Returns a negative number if $a < b$, zero if $a = b$ and a positive number if $a > b$.

Definition at line 1718 of file arithmetic-gmp.hpp.

int compareAbsValues ( const Integer a,
const Integer b 
)
friend

Compares the two integers in absolute value.

Parameters
aThe first operand.
bThe second operand.
Returns
Returns a negative number if $|a| < |b|$, zero if $|a| = |b|$ and a positive number if $|a| > |b|$.

Definition at line 1742 of file arithmetic-gmp.hpp.

void decrement ( Integer r,
const Integer a 
)
friend

Decrements a by one and stores the result in r.

Parameters
rThe result.
aThe operand.

Definition at line 1314 of file arithmetic-gmp.hpp.

void div ( Integer r,
const Integer a,
const Integer b 
)
friend

Divides a by b and stores the result in r.

Parameters
rThe result.
aThe first operand.
bThe second operand.

Definition at line 1399 of file arithmetic-gmp.hpp.

void divmod ( Integer q,
Integer r,
const Integer a,
const Integer b 
)
friend

Stores quotient and remainder of the division of a by b in q respectively r.

Parameters
qThe quotient.
rThe remainder.
aThe first operand.
bThe second operand.

Definition at line 1439 of file arithmetic-gmp.hpp.

void euclideanDivision ( Integer q,
Integer r,
const Integer a,
const Integer b 
)
friend

Computes an Euclidean Division of a by b.

Parameters
qThe quotient of a divided by b.
rThe remainder of a divided by b, i.e. a modulo b.
aThe first operand.
bThe second operand. Must be non-zero.

Computes q and r such that a == q * b + r and that $0 \le |r| \le |b|$ and $b \cdot r \ge 0$.

Definition at line 1646 of file arithmetic-gmp.hpp.

void euclideanDivisionPos ( Integer q,
Integer r,
const Integer a,
const Integer b 
)
friend

Computes an Euclidean Division of a by b.

Parameters
qThe quotient of a divided by b.
rThe remainder of a divided by b, i.e. a modulo b.
aThe first operand.
bThe second operand. Must be non-zero.

Computes q and r such that a == q * b + r and that $0 \le r \le |b|$.

Definition at line 1652 of file arithmetic-gmp.hpp.

void floorDiv ( Integer r,
const Integer a,
const Integer b 
)
friend

Computes $\lfloor \tfrac{a}{b} \rfloor$ and stores the result in r.

Parameters
rThe result.
aThe divident.
bThe divisor.
See also
Integer Functions

Definition at line 1519 of file arithmetic-gmp.hpp.

long floorOfLog2 ( const Integer x)
friend

Computes and returns $\lfloor \log_2 |x| \rfloor$.

Parameters
xA non-zero integer.
Returns
$n \in \mathbb{N}$ such that ` $2^n \le |x| < 2^{n+1}$.
See also
Integer Functions

Definition at line 1805 of file arithmetic-gmp.hpp.

void GCD ( Integer r,
const Integer x,
const Integer y 
)
friend

Computes the non-negative Greatest Common Divisior r of x and y.

Parameters
rThe result is stored in here.
xThe first operand.
yThe first operand.
See also
Integer Functions

Definition at line 1658 of file arithmetic-gmp.hpp.

void increment ( Integer r,
const Integer a 
)
friend

Increments a by one and stores the result in r.

Parameters
rThe result.
aThe operand.
See also
Integer Functions

Definition at line 1309 of file arithmetic-gmp.hpp.

bool isNegative ( const Integer i)
friend

Tests the given plll::arithmetic::Integer object for being strictly negative.

Returns
Returns true if and only if the argument is strictly negative.
See also
Predicates

Definition at line 1631 of file arithmetic-gmp.hpp.

bool isNonNegative ( const Integer i)
friend

Tests the given plll::arithmetic::Integer object for being positive or zero.

Returns
Returns true if and only if the argument is positive or zero.
See also
Predicates

Definition at line 1626 of file arithmetic-gmp.hpp.

bool isNonPositive ( const Integer i)
friend

Tests the given plll::arithmetic::Integer object for being negative or zero.

Returns
Returns true if and only if the argument is negative or zero.
See also
Predicates

Definition at line 1636 of file arithmetic-gmp.hpp.

bool isOne ( const Integer i)
friend

Tests the given plll::arithmetic::Integer object for being one.

Returns
Returns true if and only if the argument is one.
See also
Predicates

Definition at line 1606 of file arithmetic-gmp.hpp.

bool isPMOne ( const Integer i)
friend

Tests the given plll::arithmetic::Integer object for being one or minus one.

Returns
Returns true if and only if the argument is $\pm 1$.
See also
Predicates

Definition at line 1611 of file arithmetic-gmp.hpp.

bool isPMTwo ( const Integer i)
friend

Tests the given plll::arithmetic::Integer object for being two or minus two.

Returns
Returns true if and only if the argument is $\pm 2$.
See also
Predicates

Definition at line 1616 of file arithmetic-gmp.hpp.

bool isPositive ( const Integer i)
friend

Tests the given plll::arithmetic::Integer object for being strictly positive.

Returns
Returns true if and only if the argument is strictly positive.
See also
Predicates

Definition at line 1621 of file arithmetic-gmp.hpp.

bool isZero ( const Integer i)
friend

Tests the given plll::arithmetic::Integer object for being zero.

Returns
Returns true if and only if the argument is zero.
See also
Predicates

Definition at line 1601 of file arithmetic-gmp.hpp.

void LCM ( Integer r,
const Integer x,
const Integer y 
)
friend

Computes the non-negative Least Common Multiple r of x and y.

Parameters
rThe result is stored in here.
xThe first operand.
yThe first operand.
See also
Integer Functions

Definition at line 1682 of file arithmetic-gmp.hpp.

void makeAbs ( Integer a)
friend

Makes the operand non-negative.

Parameters
aThe operand.

Definition at line 1641 of file arithmetic-gmp.hpp.

void mod ( Integer r,
const Integer a,
const Integer b 
)
friend

Takes the remainder of the division of a by b and stores it in r.

Parameters
rThe result.
aThe first operand.
bThe second operand.

Definition at line 1422 of file arithmetic-gmp.hpp.

void mul ( Integer r,
const Integer a,
const Integer b 
)
friend

Multiplies a with b and stores the result in r.

Parameters
rThe result.
aThe first operand.
bThe second operand.

Definition at line 1377 of file arithmetic-gmp.hpp.

void neg ( Integer r,
const Integer a 
)
friend

Negates a and stores the result in r.

Parameters
rThe result.
aThe operand.

Definition at line 1394 of file arithmetic-gmp.hpp.

bool operator!= ( const Integer a,
const Integer b 
)
friend

Compares the current integer with the given one for inequality.

Parameters
aThe first operand.
bThe second operand.
Returns
true if a does not equal b.

Definition at line 1155 of file arithmetic-gmp-iops.hpp.

bool operator< ( const Integer a,
const Integer b 
)
friend

Compares the current integer with the given one.

Parameters
aThe first operand.
bThe second operand.
Returns
true if a is less than b.

Definition at line 1188 of file arithmetic-gmp-iops.hpp.

bool operator<= ( const Integer a,
const Integer b 
)
friend

Compares the current integer with the given one.

Parameters
aThe first operand.
bThe second operand.
Returns
true if a is less than or equal to b.

Definition at line 1166 of file arithmetic-gmp-iops.hpp.

bool operator== ( const Integer a,
const Integer b 
)
friend

Compares the current integer with the given one for equality.

Parameters
aThe first operand.
bThe second operand.
Returns
true if a equals b.

Definition at line 1144 of file arithmetic-gmp-iops.hpp.

bool operator> ( const Integer a,
const Integer b 
)
friend

Compares the current integer with the given one.

Parameters
aThe first operand.
bThe second operand.
Returns
true if a is greater than b.

Definition at line 1199 of file arithmetic-gmp-iops.hpp.

bool operator>= ( const Integer a,
const Integer b 
)
friend

Compares the current integer with the given one.

Parameters
aThe first operand.
bThe second operand.
Returns
true if a is greater than or equal to b.

Definition at line 1177 of file arithmetic-gmp-iops.hpp.

void power ( Integer r,
const Integer a,
long  b 
)
friend

Raises a to the power b and stores the result in r.

Parameters
rThe result.
aThe base.
bThe exponent.

Definition at line 1503 of file arithmetic-gmp.hpp.

void power ( Integer r,
const Integer a,
const Integer b 
)
friend

Raises a to the power b and stores the result in r.

Parameters
rThe result.
aThe base.
bThe exponent.

Definition at line 1511 of file arithmetic-gmp.hpp.

void power ( Real res,
const Real a,
const Integer b 
)
friend

Raises a to the power b and stores the result in res.

Parameters
resThe result.
aThe base.
bThe exponent.
void roundDiv ( Integer r,
const Integer a,
const Integer b 
)
friend

Computes $\lfloor \tfrac{a}{b} \rceil$ (rounding to the next integer) and stores the result in r.

Parameters
rThe result.
aThe divident.
bThe divisor.
See also
Integer Functions

Definition at line 1529 of file arithmetic-gmp.hpp.

void setbit ( Integer x,
long  n,
bool  value 
)
friend

Sets the n-th bit of $|x|$ to value.

Parameters
xThe integer whose bits to modify.
nThe index of the bit to set or clear.
valueThe new value of the n-th bit. The default value is true.
See also
Integer Functions

Definition at line 1779 of file arithmetic-gmp.hpp.

void shl ( Integer r,
const Integer a,
long  b 
)
friend

Shifts a by b bits to the left and stores the result in r.

Parameters
rThe result.
aThe first operand.
bThe second operand.

Definition at line 1575 of file arithmetic-gmp.hpp.

void shl ( Integer r,
const Integer a,
const Integer b 
)
friend

Shifts a by b bits to the right and stores the result in r.

Parameters
rThe result.
aThe first operand.
bThe second operand.

Definition at line 1583 of file arithmetic-gmp.hpp.

void shr ( Integer r,
const Integer a,
long  b 
)
friend

Shifts a by b bits to the left and stores the result in r.

Parameters
rThe result.
aThe first operand.
bThe second operand.

Definition at line 1588 of file arithmetic-gmp.hpp.

void shr ( Integer r,
const Integer a,
const Integer b 
)
friend

Shifts a by b bits to the right and stores the result in r.

Parameters
rThe result.
aThe first operand.
bThe second operand.

Definition at line 1596 of file arithmetic-gmp.hpp.

int sign ( const Integer i)
friend

Returns the sign of the given integer.

Returns
Returns a negative value if the value is negative, 0 if it is zero, and a positive value if it is positive.

Definition at line 1767 of file arithmetic-gmp.hpp.

void sqrtCeil ( Integer r,
const Integer a 
)
friend

Computes $\lceil\sqrt{a}\rceil$ and stores the result in r.

Parameters
rThe result.
aThe operand.

Definition at line 1540 of file arithmetic-gmp.hpp.

void sqrtFloor ( Integer r,
const Integer a 
)
friend

Computes $\lfloor\sqrt{a}\rfloor$ and stores the result in r.

Parameters
rThe result.
aThe operand.

Definition at line 1550 of file arithmetic-gmp.hpp.

void square ( Integer r,
const Integer a 
)
friend

Computes the square of a and stores the result in r.

Parameters
rThe result.
aThe operand.

Definition at line 1788 of file arithmetic-gmp.hpp.

void sub ( Integer r,
const Integer a,
const Integer b 
)
friend

Subtracts b from a and stores the result in r.

Parameters
rThe result.
aThe first operand.
bThe second operand.

Definition at line 1339 of file arithmetic-gmp.hpp.

void submul ( Integer r,
const Integer a,
const Integer b 
)
friend

Multiplies a and b and subtracts the result from r.

Parameters
rThe accumulator.
aThe first operand.
bThe second operand.

Definition at line 1483 of file arithmetic-gmp.hpp.

void XGCD ( Integer r,
Integer a,
Integer b,
const Integer x,
const Integer y 
)
friend

Computes the non-negative extended Greatest Common Divisior r of x and y.

Parameters
rThe result is stored in here.
aThe Bezout coefficient of x.
bThe Bezout coefficient of y.
xThe first operand.
yThe first operand.

Afterwards, the variables r, a and b satisfy r == a * x + b * y.

See also
Integer Functions

Definition at line 1676 of file arithmetic-gmp.hpp.


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