Returns a positive, zero, or negative integer if
Returns a
Returns a
Returns a
Sets
Note:
This function will probably
be named "EuclideanDivision" in later release of this library, and the
order of the first two arguments may be changed.
Returns a
Returns a
Sets #include "lmath.hxx"
Public Methods
CompareMagnitudes
static inline int LMath::CompareMagnitudes(const LInteger& a, const LInteger& b)
a is
greater than, equal to, or less than b, respectively.
Negative
static inline LInteger LMath::Negative(const LInteger& a)
LInteger equal to the product of -1 and
a.
AbsoluteValue
static inline LInteger LMath::AbsoluteValue(const LInteger& a)
LInteger equal to the absolute value of
a.
TwoToThe
static LInteger LMath::TwoToThe(const int power)
LInteger equal to 2 raised to the power of
power. power must be non-negative.
LongDivide
static void LMath::LongDivide(const LInteger& divisor, const LInteger& dividend,
LInteger& Quotient, LInteger& Remainder)
Quotient and Remainder such that
dividend=Quotient*divisor+Remainder, with
0<=Remainder<|divisor|.
ModExp
static LInteger LMath::ModExp(const LInteger& g, const LInteger& x, const LInteger& n)
LInteger representing the integer between 0 and
|n|-1 which is congruent, mod n, to
g raised to the the xth power.
SpecialModExp
static LInteger LMath::SpecialModExp(const LInteger& g, const LInteger& x, const LInteger& n)
LInteger representing the integer between 0 and
n-1 which is congruent, mod n, to
g raised to the the xth power. This method
only works for certain g, x, and n:
g must be non-negative; x must be positive;
n must be odd and greater than 1. This method is
faster than ModExp for large values of
x. (The turn over pointed has not been determined, yet,
but it is certainly faster for 512+ bit g,
x, and n on my i486 DX/2.)
ExtendedEuclid
static LInteger LMath::ExtendedEuclid(const LInteger& a, const LInteger& b,
LInteger& u, LInteger& v)
u and v to values such that
a*u+b*v is equal to the greatest common divisor
of a and b, and returns a LInteger
representing this greatest common divisor.
Next
Previous
Table of Contents