plll  1.0
plll::arithmetic::NInt< Type > Class Template Reference

Represents a native integer. More...

#include <arithmetic-nint.hpp>

Public Types

typedef NIntContext< Type > Context
 The context type.
 

Public Member Functions

 NInt () PLLL_INTERNAL_NOTHROW_POSTFIX_INLINE
 Creates a new integer. Default value is zero.
 
 NInt (const NIntContext< Type > &c) PLLL_INTERNAL_NOTHROW_POSTFIX_INLINE
 Creates a new integer. Default value is zero. More...
 
 NInt (const NInt &i) PLLL_INTERNAL_NOTHROW_POSTFIX_INLINE
 Creates a copy of the given integer. More...
 
template<typename T >
 NInt (const NInt< T > &i) PLLL_INTERNAL_NOTHROW_POSTFIX_INLINE
 Creates a copy of the given integer (of another native type). More...
 
 NInt (const NInt &i, const NIntContext< Type > &ic) PLLL_INTERNAL_NOTHROW_POSTFIX_INLINE
 Creates a copy of the given integer. More...
 
template<typename T >
 NInt (const NInt< T > &i, const NIntContext< Type > &ic) PLLL_INTERNAL_NOTHROW_POSTFIX_INLINE
 Creates a copy of the given integer (of another native type). More...
 
 NInt (double d) PLLL_INTERNAL_NOTHROW_POSTFIX_INLINE
 Creates a native CPU integer from the given native floating point number. More...
 
 NInt (long double d) PLLL_INTERNAL_NOTHROW_POSTFIX_INLINE
 Creates a native CPU integer from the given native floating point number. More...
 
 NInt (long i) PLLL_INTERNAL_NOTHROW_POSTFIX_INLINE
 Creates a native CPU integer from the given native integer. More...
 
 NInt (unsigned long i) PLLL_INTERNAL_NOTHROW_POSTFIX_INLINE
 Creates a native CPU integer from the given native integer. More...
 
 NInt (const Integer &i)
 Creates a native CPU integer from the given arbitrary precision integer. More...
 
NIntoperator= (const NInt &r) PLLL_INTERNAL_NOTHROW_POSTFIX_INLINE
 Copies the given integer into this one. More...
 

Static Public Member Functions

static void setContext (const NIntContext< Type > &c) PLLL_INTERNAL_NOTHROW_POSTFIX_INLINE
 Sets the integer context c. More...
 

Friends

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

Detailed Description

template<typename Type>
class plll::arithmetic::NInt< Type >

Represents a native integer.

Template Parameters
TypeA native signed integer type, such as int, long int and long long.

Definition at line 48 of file arithmetic-nint.hpp.

Constructor & Destructor Documentation

template<typename Type>
plll::arithmetic::NInt< Type >::NInt ( const NIntContext< Type > &  c)
inline

Creates a new integer. Default value is zero.

Parameters
cA native CPU integer context.

Definition at line 1168 of file arithmetic-nint.hpp.

template<typename Type>
plll::arithmetic::NInt< Type >::NInt ( const NInt< Type > &  i)
inline

Creates a copy of the given integer.

Parameters
iThe integer to be copied.

Definition at line 1178 of file arithmetic-nint.hpp.

template<typename Type>
template<typename T >
plll::arithmetic::NInt< Type >::NInt ( const NInt< T > &  i)
inline

Creates a copy of the given integer (of another native type).

Parameters
iThe integer to be copied.

Definition at line 1189 of file arithmetic-nint.hpp.

template<typename Type>
plll::arithmetic::NInt< Type >::NInt ( const NInt< Type > &  i,
const NIntContext< Type > &  ic 
)
inline

Creates a copy of the given integer.

Parameters
iThe integer to be copied.
icAn integer context.

Definition at line 1200 of file arithmetic-nint.hpp.

template<typename Type>
template<typename T >
plll::arithmetic::NInt< Type >::NInt ( const NInt< T > &  i,
const NIntContext< Type > &  ic 
)
inline

Creates a copy of the given integer (of another native type).

Parameters
iThe integer to be copied.
icAn integer context.

Definition at line 1212 of file arithmetic-nint.hpp.

template<typename Type>
plll::arithmetic::NInt< Type >::NInt ( double  d)
inlineexplicit

Creates a native CPU integer from the given native floating point number.

Parameters
dThe native floating point number.

Definition at line 1231 of file arithmetic-nint.hpp.

template<typename Type>
plll::arithmetic::NInt< Type >::NInt ( long double  d)
inlineexplicit

Creates a native CPU integer from the given native floating point number.

Parameters
dThe native floating point number.

Definition at line 1241 of file arithmetic-nint.hpp.

template<typename Type>
plll::arithmetic::NInt< Type >::NInt ( long  i)
inlineexplicit

Creates a native CPU integer from the given native integer.

Parameters
iThe native integer.

Definition at line 1251 of file arithmetic-nint.hpp.

template<typename Type>
plll::arithmetic::NInt< Type >::NInt ( unsigned long  i)
inlineexplicit

Creates a native CPU integer from the given native integer.

Parameters
iThe native integer.

Definition at line 1261 of file arithmetic-nint.hpp.

template<typename Type>
plll::arithmetic::NInt< Type >::NInt ( const Integer i)
inlineexplicit

Creates a native CPU integer from the given arbitrary precision integer.

Parameters
iThe native integer.

Definition at line 1271 of file arithmetic-nint.hpp.

Member Function Documentation

template<typename Type>
NInt& plll::arithmetic::NInt< Type >::operator= ( const NInt< Type > &  r)
inline

Copies the given integer into this one.

Parameters
rA integer to be moved into this one.

Definition at line 1281 of file arithmetic-nint.hpp.

template<typename Type>
static void plll::arithmetic::NInt< Type >::setContext ( const NIntContext< Type > &  c)
inlinestatic

Sets the integer context c.

Parameters
cThe integer context.

Definition at line 1222 of file arithmetic-nint.hpp.

Friends And Related Function Documentation

template<typename Type>
void abs ( NInt< Type > &  r,
const NInt< Type > &  a 
)
friend

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

Parameters
rThe result.
aThe operand.

Definition at line 1752 of file arithmetic-nint.hpp.

template<typename Type>
NInt<Type> abs ( const NInt< Type > &  i)
friend

Computes and returns the absolute value of i.

Parameters
iThe operand.
Returns
The result.

Definition at line 1758 of file arithmetic-nint.hpp.

template<typename Type>
void add ( NInt< Type > &  r,
const NInt< Type > &  a,
const NInt< Type > &  b 
)
friend

Adds a and b and stores the result in r.

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

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

template<typename Type>
long approxLog2 ( const NInt< Type > &  x)
friend

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

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

Definition at line 2161 of file arithmetic-nint.hpp.

template<typename Type>
int bit ( const NInt< Type > &  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 1846 of file arithmetic-nint.hpp.

template<typename Type>
long bitLength ( const NInt< Type > &  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 2168 of file arithmetic-nint.hpp.

template<typename Type>
void ceilDiv ( NInt< Type > &  r,
const NInt< Type > &  a,
const NInt< Type > &  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 2196 of file arithmetic-nint.hpp.

template<typename Type>
NInt<Type> ceilDiv ( const NInt< Type > &  a,
const NInt< Type > &  b 
)
friend

Computes and returns $\lceil \tfrac{a}{b} \rceil$.

Returns
The result.
Parameters
aThe divident.
bThe divisor.
See also
Integer Functions

Definition at line 2209 of file arithmetic-nint.hpp.

template<typename Type>
long ceilOfLog2 ( const NInt< Type > &  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 1965 of file arithmetic-nint.hpp.

template<typename Type>
int compare ( const NInt< Type > &  a,
const NInt< Type > &  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 1799 of file arithmetic-nint.hpp.

template<typename Type>
int compareAbsValues ( const NInt< Type > &  a,
const NInt< Type > &  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 1806 of file arithmetic-nint.hpp.

template<typename Type>
void decrement ( NInt< Type > &  r,
const NInt< Type > &  a 
)
friend

Decrements a by one and stores the result in r.

Parameters
rThe result.
aThe operand.

Definition at line 1740 of file arithmetic-nint.hpp.

template<typename Type>
void div ( NInt< Type > &  r,
const NInt< Type > &  a,
const NInt< Type > &  b 
)
friend

Divides a by b and stores the result in r.

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

Definition at line 1661 of file arithmetic-nint.hpp.

template<typename Type>
void euclideanDivision ( NInt< Type > &  q,
NInt< Type > &  r,
const NInt< Type > &  a,
const NInt< Type > &  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 2238 of file arithmetic-nint.hpp.

template<typename Type>
void euclideanDivisionPos ( NInt< Type > &  q,
NInt< Type > &  r,
const NInt< Type > &  a,
const NInt< Type > &  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 2246 of file arithmetic-nint.hpp.

template<typename Type>
void floorDiv ( NInt< Type > &  r,
const NInt< Type > &  a,
const NInt< Type > &  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 2175 of file arithmetic-nint.hpp.

template<typename Type>
NInt<Type> floorDiv ( const NInt< Type > &  a,
const NInt< Type > &  b 
)
friend

Computes and returns $\lfloor \tfrac{a}{b} \rfloor$.

Returns
The result.
Parameters
aThe divident.
bThe divisor.
See also
Integer Functions

Definition at line 2188 of file arithmetic-nint.hpp.

template<typename Type>
long floorOfLog2 ( const NInt< Type > &  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 1982 of file arithmetic-nint.hpp.

template<typename Type>
void GCD ( NInt< Type > &  r,
const NInt< Type > &  x,
const NInt< Type > &  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 2260 of file arithmetic-nint.hpp.

template<typename Type>
NInt<Type> GCD ( const NInt< Type > &  x,
const NInt< Type > &  y 
)
friend

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

Returns
The GCD of x and y.
Parameters
xThe first operand.
yThe first operand.
See also
Integer Functions

Definition at line 2278 of file arithmetic-nint.hpp.

template<typename Type>
void increment ( NInt< Type > &  r,
const NInt< Type > &  a 
)
friend

Increments a by one and stores the result in r.

Parameters
rThe result.
aThe operand.
See also
Integer Functions

Definition at line 1734 of file arithmetic-nint.hpp.

template<typename Type>
bool isNegative ( const NInt< Type > &  r)
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 1617 of file arithmetic-nint.hpp.

template<typename Type>
bool isNonNegative ( const NInt< Type > &  r)
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 1610 of file arithmetic-nint.hpp.

template<typename Type>
bool isNonPositive ( const NInt< Type > &  r)
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 1624 of file arithmetic-nint.hpp.

template<typename Type>
bool isOne ( const NInt< Type > &  r)
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 1582 of file arithmetic-nint.hpp.

template<typename Type>
bool isPMOne ( const NInt< Type > &  r)
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 1589 of file arithmetic-nint.hpp.

template<typename Type>
bool isPMTwo ( const NInt< Type > &  r)
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 1596 of file arithmetic-nint.hpp.

template<typename Type>
bool isPositive ( const NInt< Type > &  r)
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 1603 of file arithmetic-nint.hpp.

template<typename Type>
bool isZero ( const NInt< Type > &  r)
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 1575 of file arithmetic-nint.hpp.

template<typename Type>
void LCM ( NInt< Type > &  r,
const NInt< Type > &  x,
const NInt< Type > &  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 2330 of file arithmetic-nint.hpp.

template<typename Type>
NInt<Type> LCM ( const NInt< Type > &  x,
const NInt< Type > &  y 
)
friend

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

Returns
The LCM of x and y.
Parameters
xThe first operand.
yThe first operand.
See also
Integer Functions

Definition at line 2337 of file arithmetic-nint.hpp.

template<typename Type>
void makeAbs ( NInt< Type > &  a)
friend

Makes the operand non-negative.

Parameters
aThe operand.

Definition at line 1764 of file arithmetic-nint.hpp.

template<typename Type>
void mod ( NInt< Type > &  r,
const NInt< Type > &  a,
const NInt< Type > &  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 1667 of file arithmetic-nint.hpp.

template<typename Type>
void mul ( NInt< Type > &  r,
const NInt< Type > &  a,
const NInt< Type > &  b 
)
friend

Multiplies a with b and stores the result in r.

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

Definition at line 1655 of file arithmetic-nint.hpp.

template<typename Type>
void neg ( NInt< Type > &  r,
const NInt< Type > &  a 
)
friend

Negates a and stores the result in r.

Parameters
rThe result.
aThe operand.

Definition at line 1746 of file arithmetic-nint.hpp.

template<typename Type>
bool operator!= ( const NInt< Type > &  a,
const NInt< Type > &  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 1545 of file arithmetic-nint.hpp.

template<typename Type>
NInt<Type> operator% ( const NInt< Type > &  a,
const NInt< Type > &  b 
)
friend

Divides the first by the second integer and returns the remainder.

Parameters
aThe first operand.
bThe second operand.
Returns
The result.

Definition at line 1412 of file arithmetic-nint.hpp.

template<typename Type>
NInt<Type>& operator%= ( NInt< Type > &  cur,
const NInt< Type > &  i 
)
friend

Divides cur by the given integer i and stores the remainder in cur.

Parameters
curThe integer to operate on.
iThe integer to divide by.
Returns
A reference to cur containing the result.

Definition at line 1446 of file arithmetic-nint.hpp.

template<typename Type>
NInt<Type> operator* ( const NInt< Type > &  a,
const NInt< Type > &  b 
)
friend

Multiplies the two integers and returns the result.

Parameters
aThe first operand.
bThe second operand.
Returns
The result.

Definition at line 1400 of file arithmetic-nint.hpp.

template<typename Type>
NInt<Type>& operator*= ( NInt< Type > &  cur,
const NInt< Type > &  i 
)
friend

Multiplies the given integer i with cur.

Parameters
curThe integer to operate on.
iThe integer to multiply to cur.
Returns
A reference to cur containing the result.

Definition at line 1432 of file arithmetic-nint.hpp.

template<typename Type>
NInt<Type> operator+ ( const NInt< Type > &  a,
const NInt< Type > &  b 
)
friend

Adds the two integers and returns the result.

Parameters
aThe first operand.
bThe second operand.
Returns
The result.

Definition at line 1388 of file arithmetic-nint.hpp.

template<typename Type>
NInt<Type> operator++ ( NInt< Type > &  cur,
int   
)
friend

Increments the integer by one and returns the previous value.

Parameters
curThe integer to work on.
Returns
The previous value.

Definition at line 1481 of file arithmetic-nint.hpp.

template<typename Type>
NInt<Type>& operator++ ( NInt< Type > &  cur)
friend

Increments the integer by one and returns the new value.

Parameters
curThe integer to work on.
Returns
The new value (a reference to cur).

Definition at line 1493 of file arithmetic-nint.hpp.

template<typename Type>
NInt<Type>& operator+= ( NInt< Type > &  cur,
const NInt< Type > &  i 
)
friend

Adds the integer i to cur.

Parameters
curThe integer to operate on.
iThe integer to add to cur.
Returns
A reference to cur containing the result.

Definition at line 1425 of file arithmetic-nint.hpp.

template<typename Type>
NInt<Type> operator- ( const NInt< Type > &  a)
friend

Negates the integer.

Parameters
aThe integer.
Returns
The result.

Definition at line 1382 of file arithmetic-nint.hpp.

template<typename Type>
NInt<Type> operator- ( const NInt< Type > &  a,
const NInt< Type > &  b 
)
friend

Subtracts the second from the first integer and returns the result.

Parameters
aThe first operand.
bThe second operand.
Returns
The result.

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

template<typename Type>
NInt<Type> operator-- ( NInt< Type > &  cur,
int   
)
friend

Decrements the integer by one and returns the previous value.

Parameters
curThe integer to work on.
Returns
The previous value.

Definition at line 1487 of file arithmetic-nint.hpp.

template<typename Type>
NInt<Type>& operator-- ( NInt< Type > &  cur)
friend

Decreases the integer by one and returns the new value.

Parameters
curThe integer to work on.
Returns
The new value (a reference to cur).

Definition at line 1500 of file arithmetic-nint.hpp.

template<typename Type>
NInt<Type>& operator-= ( NInt< Type > &  cur,
const NInt< Type > &  i 
)
friend

Subtracts the integer i from cur.

Parameters
curThe integer to operate on.
iThe integer to subtract from cur.
Returns
A reference to cur containing the result.

Definition at line 1418 of file arithmetic-nint.hpp.

template<typename Type>
NInt<Type> operator/ ( const NInt< Type > &  a,
const NInt< Type > &  b 
)
friend

Divides the first by the second integer and returns the result.

Parameters
aThe first operand.
bThe second operand.
Returns
The result.

Definition at line 1406 of file arithmetic-nint.hpp.

template<typename Type>
NInt<Type>& operator/= ( NInt< Type > &  cur,
const NInt< Type > &  i 
)
friend

Divides cur by the given integer i.

Parameters
curThe integer to operate on.
iThe integer to divide by.
Returns
A reference to cur containing the result.

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

template<typename Type>
bool operator< ( const NInt< Type > &  a,
const NInt< Type > &  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 1563 of file arithmetic-nint.hpp.

template<typename Type>
NInt<Type> operator<< ( const NInt< Type > &  a,
long  b 
)
friend

Computes the bitwise left shift of the first integer by the number of bits given by the second integer, and returns the result.

This effectively multiplies the first integer by 2 to the power of the second integer.

Parameters
aThe first operand.
bThe second operand.
Returns
The result.

Definition at line 1507 of file arithmetic-nint.hpp.

template<typename Type>
NInt<Type> operator<< ( const NInt< Type > &  a,
const NInt< Type > &  b 
)
friend

Computes the bitwise left shift of the first integer by the number of bits given by the second integer, and returns the result.

This effectively multiplies the first integer by 2 to the power of the second integer.

Parameters
aThe first operand.
bThe second operand.
Returns
The result.

Definition at line 1523 of file arithmetic-nint.hpp.

template<typename Type>
bool operator<= ( const NInt< Type > &  a,
const NInt< Type > &  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 1551 of file arithmetic-nint.hpp.

template<typename Type>
bool operator== ( const NInt< Type > &  a,
const NInt< Type > &  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 1539 of file arithmetic-nint.hpp.

template<typename Type>
bool operator> ( const NInt< Type > &  a,
const NInt< Type > &  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 1569 of file arithmetic-nint.hpp.

template<typename Type>
bool operator>= ( const NInt< Type > &  a,
const NInt< Type > &  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 1557 of file arithmetic-nint.hpp.

template<typename Type>
NInt<Type> operator>> ( const NInt< Type > &  a,
long  b 
)
friend

Computes the bitwise right shift of the first integer by the number of bits given by the second integer, and returns the result.

This effectively divides the first integer by 2 to the power of the second integer, and rounds towards zero.

Parameters
aThe first operand.
bThe second operand.
Returns
The result.

Definition at line 1515 of file arithmetic-nint.hpp.

template<typename Type>
NInt<Type> operator>> ( const NInt< Type > &  a,
const NInt< Type > &  b 
)
friend

Computes the bitwise right shift of the first integer by the number of bits given by the second integer, and returns the result.

This effectively divides the first integer by 2 to the power of the second integer, and rounds towards zero.

Parameters
aThe first operand.
bThe second operand.
Returns
The result.

Definition at line 1531 of file arithmetic-nint.hpp.

template<typename Type>
NInt<Type> power ( const NInt< Type > &  a,
long  b 
)
friend

Computes and returns a raised to the power of b.

Parameters
aThe first operand.
bThe second operand.
Returns
The result.

Definition at line 1899 of file arithmetic-nint.hpp.

template<typename Type>
void power ( NInt< Type > &  r,
const NInt< Type > &  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 1893 of file arithmetic-nint.hpp.

template<typename Type>
NInt<Type> power ( const NInt< Type > &  a,
const NInt< Type > &  b 
)
friend

Computes and returns a raised to the power of b.

Parameters
aThe first operand.
bThe second operand.
Returns
The result.

Definition at line 1911 of file arithmetic-nint.hpp.

template<typename Type>
void power ( NInt< Type > &  r,
const NInt< Type > &  a,
const NInt< Type > &  b 
)
friend

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

Parameters
rThe result.
aThe base.
bThe exponent.

Definition at line 1905 of file arithmetic-nint.hpp.

template<typename Type>
void roundDiv ( NInt< Type > &  r,
const NInt< Type > &  a,
const NInt< Type > &  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 2217 of file arithmetic-nint.hpp.

template<typename Type>
NInt<Type> roundDiv ( const NInt< Type > &  a,
const NInt< Type > &  b 
)
friend

Computes and returns $\lfloor \tfrac{a}{b} \rceil$ (rounding to the next integer).

Returns
The result.
Parameters
aThe divident.
bThe divisor.
See also
Integer Functions

Definition at line 2230 of file arithmetic-nint.hpp.

template<typename Type>
void shl ( NInt< Type > &  r,
const NInt< Type > &  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 1681 of file arithmetic-nint.hpp.

template<typename Type>
void shl ( NInt< Type > &  r,
const NInt< Type > &  a,
const NInt< Type > &  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 1719 of file arithmetic-nint.hpp.

template<typename Type>
void shr ( NInt< Type > &  r,
const NInt< Type > &  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 1700 of file arithmetic-nint.hpp.

template<typename Type>
void shr ( NInt< Type > &  r,
const NInt< Type > &  a,
const NInt< Type > &  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 1725 of file arithmetic-nint.hpp.

template<typename Type>
int sign ( const NInt< Type > &  r)
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 1815 of file arithmetic-nint.hpp.

template<typename Type>
void sqrtCeil ( NInt< Type > &  r,
const NInt< Type > &  a 
)
friend

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

Parameters
rThe result.
aThe operand.

Definition at line 1917 of file arithmetic-nint.hpp.

template<typename Type>
void sqrtFloor ( NInt< Type > &  r,
const NInt< Type > &  a 
)
friend

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

Parameters
rThe result.
aThe operand.

Definition at line 1941 of file arithmetic-nint.hpp.

template<typename Type>
NInt<Type> square ( const NInt< Type > &  i)
friend

Computes and returns the square of i.

Parameters
iThe operand.
Returns
The result.

Definition at line 1865 of file arithmetic-nint.hpp.

template<typename Type>
void square ( NInt< Type > &  r,
const NInt< Type > &  a 
)
friend

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

Parameters
rThe result.
aThe operand.

Definition at line 1871 of file arithmetic-nint.hpp.

template<typename Type>
void sub ( NInt< Type > &  r,
const NInt< Type > &  a,
const NInt< Type > &  b 
)
friend

Subtracts b from a and stores the result in r.

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

Definition at line 1637 of file arithmetic-nint.hpp.

template<typename Type>
void XGCD ( NInt< Type > &  r,
NInt< Type > &  a,
NInt< Type > &  b,
const NInt< Type > &  x,
const NInt< Type > &  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 2286 of file arithmetic-nint.hpp.


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