plll
1.0
|
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... | |
Integer & | operator= (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 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 in the usual binary representation. More... | |
long | bitLength (const Integer &x) PLLL_INTERNAL_NOTHROW_POSTFIX_INLINE |
Computes and returns n such that . 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 and stores the result in r . More... | |
long | ceilOfLog2 (const Integer &x) PLLL_INTERNAL_NOTHROW_POSTFIX_INLINE |
Computes and returns . 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 and stores the result in r . More... | |
long | floorOfLog2 (const Integer &x) PLLL_INTERNAL_NOTHROW_POSTFIX_INLINE |
Computes and returns . 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 (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 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 and stores the result in r . More... | |
void | sqrtFloor (Integer &r, const Integer &a) |
Computes 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... | |
Represents an arbitrary precision integer.
Definition at line 1071 of file arithmetic-gmp.hpp.
|
inlineexplicit |
Creates a new integer. Default value is zero.
c | An integer context. |
Definition at line 1115 of file arithmetic-gmp.hpp.
|
inline |
Creates a copy of the given integer.
i | The integer to be copied. |
Definition at line 1125 of file arithmetic-gmp.hpp.
|
inline |
Creates a copy of the given integer.
i | The integer to be copied. |
ic | An integer context. |
Definition at line 1136 of file arithmetic-gmp.hpp.
|
inlineexplicit |
Creates a arbitrary precision integer from the given native integer.
i | The native integer. |
Definition at line 1146 of file arithmetic-gmp.hpp.
|
inlineexplicit |
Creates a arbitrary precision integer from the given native integer.
i | The native integer. |
Definition at line 1156 of file arithmetic-gmp.hpp.
|
inlineexplicit |
Creates a arbitrary precision integer from the given native integer.
i | The native integer. |
Definition at line 1166 of file arithmetic-gmp.hpp.
|
inlineexplicit |
Creates a arbitrary precision integer from the given native integer.
i | The native integer. |
Definition at line 1176 of file arithmetic-gmp.hpp.
|
inlineexplicit |
Creates a arbitrary precision integer from the given native integer.
i | The native integer. |
Definition at line 1186 of file arithmetic-gmp.hpp.
|
inlineexplicit |
Creates a arbitrary precision integer from the given native floating point number.
d | The native floating point number. |
Definition at line 1198 of file arithmetic-gmp.hpp.
|
inlineexplicit |
Creates a arbitrary precision integer from the given native floating point number.
d | The native floating point number. |
Definition at line 1209 of file arithmetic-gmp.hpp.
|
inline |
Creates an integer from the given integer expression.
E | An integer expression. |
Definition at line 1220 of file arithmetic-gmp.hpp.
|
inline |
Creates an integer from the given integer expression.
E | An integer expression. |
ic | An integer context. |
Definition at line 1233 of file arithmetic-gmp.hpp.
|
explicit |
Creates an integer from the given arbitrary precision floating point number.
r | An arbitrary precision floating point number. |
|
inlinestatic |
Sets the integer context c
.
c | The integer context. |
Definition at line 1288 of file arithmetic-gmp.hpp.
Takes the absolute value of a
and stores the result in r
.
r | The result. |
a | The operand. |
Definition at line 1458 of file arithmetic-gmp.hpp.
Adds a
and b
and stores the result in r
.
r | The result. |
a | The first operand. |
b | The second operand. |
Definition at line 1319 of file arithmetic-gmp.hpp.
Multiplies a
and b
and adds the result to r
.
r | The accumulator. |
a | The first operand. |
b | The second operand. |
Definition at line 1463 of file arithmetic-gmp.hpp.
|
friend |
Quickly approximates and returns the approximation.
x | A non-zero integer. |
Definition at line 1793 of file arithmetic-gmp.hpp.
Computes the bitwise and of a
and b
and stores the result in r
.
r | The result. |
a | The first operand. |
b | The second operand. |
Definition at line 1555 of file arithmetic-gmp.hpp.
|
friend |
Returns the n
bit of in the usual binary representation.
x | The integer whose bit to query. |
n | The index of the bit to query. |
Definition at line 1773 of file arithmetic-gmp.hpp.
|
friend |
Computes and returns n
such that .
x | A non-zero integer. |
Definition at line 1810 of file arithmetic-gmp.hpp.
Takes the bitwise complement of a
and stores the result in r
.
r | The result. |
a | The operand. |
Definition at line 1570 of file arithmetic-gmp.hpp.
Computes the bitwise or of a
and b
and stores the result in r
.
r | The result. |
a | The first operand. |
b | The second operand. |
Definition at line 1560 of file arithmetic-gmp.hpp.
Computes the bitwise exclusive or of a
and b
and stores the result in r
.
r | The result. |
a | The first operand. |
b | The second operand. |
Definition at line 1565 of file arithmetic-gmp.hpp.
Computes and stores the result in r
.
r | The result. |
a | The divident. |
b | The divisor. |
Definition at line 1524 of file arithmetic-gmp.hpp.
|
friend |
Computes and returns .
x | A non-zero integer. |
Definition at line 1798 of file arithmetic-gmp.hpp.
Compares the two integers.
a | The first operand. |
b | The second operand. |
Definition at line 1718 of file arithmetic-gmp.hpp.
Compares the two integers in absolute value.
a | The first operand. |
b | The second operand. |
Definition at line 1742 of file arithmetic-gmp.hpp.
Decrements a
by one and stores the result in r
.
r | The result. |
a | The operand. |
Definition at line 1314 of file arithmetic-gmp.hpp.
Divides a
by b
and stores the result in r
.
r | The result. |
a | The first operand. |
b | The second operand. |
Definition at line 1399 of file arithmetic-gmp.hpp.
Stores quotient and remainder of the division of a
by b
in q
respectively r
.
q | The quotient. |
r | The remainder. |
a | The first operand. |
b | The second operand. |
Definition at line 1439 of file arithmetic-gmp.hpp.
Computes an Euclidean Division of a
by b
.
q | The quotient of a divided by b . |
r | The remainder of a divided by b , i.e. a modulo b . |
a | The first operand. |
b | The second operand. Must be non-zero. |
Computes q
and r
such that a == q * b + r
and that and .
Definition at line 1646 of file arithmetic-gmp.hpp.
Computes an Euclidean Division of a
by b
.
q | The quotient of a divided by b . |
r | The remainder of a divided by b , i.e. a modulo b . |
a | The first operand. |
b | The second operand. Must be non-zero. |
Computes q
and r
such that a == q * b + r
and that .
Definition at line 1652 of file arithmetic-gmp.hpp.
Computes and stores the result in r
.
r | The result. |
a | The divident. |
b | The divisor. |
Definition at line 1519 of file arithmetic-gmp.hpp.
|
friend |
Computes and returns .
x | A non-zero integer. |
Definition at line 1805 of file arithmetic-gmp.hpp.
Computes the non-negative Greatest Common Divisior r
of x
and y
.
r | The result is stored in here. |
x | The first operand. |
y | The first operand. |
Definition at line 1658 of file arithmetic-gmp.hpp.
Increments a
by one and stores the result in r
.
r | The result. |
a | The operand. |
Definition at line 1309 of file arithmetic-gmp.hpp.
|
friend |
Tests the given plll::arithmetic::Integer
object for being strictly negative.
true
if and only if the argument is strictly negative. Definition at line 1631 of file arithmetic-gmp.hpp.
|
friend |
Tests the given plll::arithmetic::Integer
object for being positive or zero.
true
if and only if the argument is positive or zero. Definition at line 1626 of file arithmetic-gmp.hpp.
|
friend |
Tests the given plll::arithmetic::Integer
object for being negative or zero.
true
if and only if the argument is negative or zero. Definition at line 1636 of file arithmetic-gmp.hpp.
|
friend |
Tests the given plll::arithmetic::Integer
object for being one.
true
if and only if the argument is one. Definition at line 1606 of file arithmetic-gmp.hpp.
|
friend |
Tests the given plll::arithmetic::Integer
object for being one or minus one.
true
if and only if the argument is . Definition at line 1611 of file arithmetic-gmp.hpp.
|
friend |
Tests the given plll::arithmetic::Integer
object for being two or minus two.
true
if and only if the argument is . Definition at line 1616 of file arithmetic-gmp.hpp.
|
friend |
Tests the given plll::arithmetic::Integer
object for being strictly positive.
true
if and only if the argument is strictly positive. Definition at line 1621 of file arithmetic-gmp.hpp.
|
friend |
Tests the given plll::arithmetic::Integer
object for being zero.
true
if and only if the argument is zero. Definition at line 1601 of file arithmetic-gmp.hpp.
Computes the non-negative Least Common Multiple r
of x
and y
.
r | The result is stored in here. |
x | The first operand. |
y | The first operand. |
Definition at line 1682 of file arithmetic-gmp.hpp.
|
friend |
Makes the operand non-negative.
a | The operand. |
Definition at line 1641 of file arithmetic-gmp.hpp.
Takes the remainder of the division of a
by b
and stores it in r
.
r | The result. |
a | The first operand. |
b | The second operand. |
Definition at line 1422 of file arithmetic-gmp.hpp.
Multiplies a
with b
and stores the result in r
.
r | The result. |
a | The first operand. |
b | The second operand. |
Definition at line 1377 of file arithmetic-gmp.hpp.
Negates a
and stores the result in r
.
r | The result. |
a | The operand. |
Definition at line 1394 of file arithmetic-gmp.hpp.
Compares the current integer with the given one for inequality.
a | The first operand. |
b | The second operand. |
true
if a
does not equal b
. Definition at line 1155 of file arithmetic-gmp-iops.hpp.
Compares the current integer with the given one.
a | The first operand. |
b | The second operand. |
true
if a
is less than b
. Definition at line 1188 of file arithmetic-gmp-iops.hpp.
Compares the current integer with the given one.
a | The first operand. |
b | The second operand. |
true
if a
is less than or equal to b
. Definition at line 1166 of file arithmetic-gmp-iops.hpp.
Compares the current integer with the given one for equality.
a | The first operand. |
b | The second operand. |
true
if a
equals b
. Definition at line 1144 of file arithmetic-gmp-iops.hpp.
Compares the current integer with the given one.
a | The first operand. |
b | The second operand. |
true
if a
is greater than b
. Definition at line 1199 of file arithmetic-gmp-iops.hpp.
Compares the current integer with the given one.
a | The first operand. |
b | The second operand. |
true
if a
is greater than or equal to b
. Definition at line 1177 of file arithmetic-gmp-iops.hpp.
Raises a
to the power b
and stores the result in r
.
r | The result. |
a | The base. |
b | The exponent. |
Definition at line 1503 of file arithmetic-gmp.hpp.
Raises a
to the power b
and stores the result in r
.
r | The result. |
a | The base. |
b | The exponent. |
Definition at line 1511 of file arithmetic-gmp.hpp.
Raises a
to the power b
and stores the result in res
.
res | The result. |
a | The base. |
b | The exponent. |
Computes (rounding to the next integer) and stores the result in r
.
r | The result. |
a | The divident. |
b | The divisor. |
Definition at line 1529 of file arithmetic-gmp.hpp.
|
friend |
Sets the n
-th bit of to value
.
x | The integer whose bits to modify. |
n | The index of the bit to set or clear. |
value | The new value of the n -th bit. The default value is true . |
Definition at line 1779 of file arithmetic-gmp.hpp.
Shifts a
by b
bits to the left and stores the result in r
.
r | The result. |
a | The first operand. |
b | The second operand. |
Definition at line 1575 of file arithmetic-gmp.hpp.
Shifts a
by b
bits to the right and stores the result in r
.
r | The result. |
a | The first operand. |
b | The second operand. |
Definition at line 1583 of file arithmetic-gmp.hpp.
Shifts a
by b
bits to the left and stores the result in r
.
r | The result. |
a | The first operand. |
b | The second operand. |
Definition at line 1588 of file arithmetic-gmp.hpp.
Shifts a
by b
bits to the right and stores the result in r
.
r | The result. |
a | The first operand. |
b | The second operand. |
Definition at line 1596 of file arithmetic-gmp.hpp.
|
friend |
Returns the sign of the given integer.
Definition at line 1767 of file arithmetic-gmp.hpp.
Computes and stores the result in r
.
r | The result. |
a | The operand. |
Definition at line 1540 of file arithmetic-gmp.hpp.
Computes and stores the result in r
.
r | The result. |
a | The operand. |
Definition at line 1550 of file arithmetic-gmp.hpp.
Computes the square of a
and stores the result in r
.
r | The result. |
a | The operand. |
Definition at line 1788 of file arithmetic-gmp.hpp.
Subtracts b
from a
and stores the result in r
.
r | The result. |
a | The first operand. |
b | The second operand. |
Definition at line 1339 of file arithmetic-gmp.hpp.
Multiplies a
and b
and subtracts the result from r
.
r | The accumulator. |
a | The first operand. |
b | The second operand. |
Definition at line 1483 of file arithmetic-gmp.hpp.
Computes the non-negative extended Greatest Common Divisior r
of x
and y
.
r | The result is stored in here. |
a | The Bezout coefficient of x . |
b | The Bezout coefficient of y . |
x | The first operand. |
y | The first operand. |
Afterwards, the variables r
, a
and b
satisfy r == a * x + b * y
.
Definition at line 1676 of file arithmetic-gmp.hpp.