public class Mpz extends java.lang.Object implements java.io.Serializable, java.lang.Comparable<Mpz>, java.lang.Cloneable
This class wraps mpz_t
GMP objects.
Modifier and Type | Field and Description |
---|---|
static int |
infinite
This value can be returned by bit-searching or bit-counting operations.
|
Constructor and Description |
---|
Mpz()
Constructs an uninitialized number.
|
Mpz(java.math.BigInteger b)
Constructs a number initialized from a Java big integer.
|
Mpz(double d)
Constructs a number initialized with a double.
|
Mpz(int i)
Constructs a number initialized with an integer.
|
Mpz(int sign,
byte[] mag)
Constructs a number from a unsigned stored in a big-endian byte array
and a sign.
|
Mpz(Mpz v)
Constructs a copy of its argument.
|
Mpz(java.lang.String s)
Constructs a number initialized from a string representation.
|
Mpz(java.lang.String s,
int b)
Constructs a number initialized from a string representation in base b.
|
Modifier and Type | Method and Description |
---|---|
void |
abs()
Replaces this with |this|.
|
void |
abs(Mpz arg)
Stores |arg| into this.
|
void |
add(int arg)
Adds arg to this.
|
void |
add(Mpz arg)
Adds arg to this.
|
void |
add(Mpz arg1,
int arg2)
Stores arg1+arg2 into this.
|
void |
add(Mpz arg1,
Mpz arg2)
Stores arg1+arg2 into this.
|
void |
addMul(Mpz arg1,
int arg2)
Stores this+arg1*arg2 into this.
|
void |
addMul(Mpz arg1,
Mpz arg2)
Stores this+arg1*arg2 into this.
|
void |
and(Mpz op)
Stores the bitwise and of this and op into this.
|
void |
and(Mpz op1,
Mpz op2)
Stores the bitwise and of op1 and op2 into this.
|
java.math.BigInteger |
bigIntegerValue()
Returns this as a Java big integer.
|
void |
bin(int n,
int k)
Stores into this the binomial coefficient (n k).
|
void |
bin(Mpz n,
int k)
Stores into this the binomial coefficient (n k).
|
byte[] |
byteArrayValue()
Returns the magnitude of this.
|
int |
cdivQ(int d)
Divides this by d, rounds towards +oo, and returns the remainder.
|
void |
cdivQ(Mpz d)
Divides this by d and rounds towards +oo.
|
int |
cdivQ(Mpz n,
int d)
Stores the quotient of n/d rounded towards +oo into this,
and returns the remainder.
|
void |
cdivQ(Mpz n,
Mpz d)
Stores the quotient of n/d rounded towards +oo into this.
|
void |
cdivQ2exp(Mpz n,
int d)
Stores the quotient of n/(2^d) rounded towards +oo into this.
|
int |
cdivQR(Mpz r,
Mpz n,
int d)
Stores the quotient of n/d rounded towards +oo into this, the
remainder into r, and returns the remainder.
|
void |
cdivQR(Mpz r,
Mpz n,
Mpz d)
Stores the quotient of n/d rounded towards +oo into this and the
remainder into r.
|
int |
cdivR(int d)
Returns the remainder of of this/d rounded towards +oo.
|
int |
cdivR(Mpz n,
int d)
Stores the remainder of n/d rounded towards +oo into this,
and returns the remainder.
|
void |
cdivR(Mpz n,
Mpz d)
Stores the remainder of n/d rounded towards +oo into this.
|
void |
cdivR2exp(Mpz n,
int d)
Stores the remainder of n/(2^d) rounded towards +oo into this.
|
Mpz |
clone()
Creates a new Mpz initialized with the value of this.
|
void |
clrBit(int pos)
Sets the pos-th bit to 0 in this.
|
int |
cmp(double op)
Returns a positive, null, or negative number when this is respectively
strictly greater, equal, or strictly smaller than op.
|
int |
cmp(int op)
Returns a positive, null, or negative number when this is respectively
strictly greater, equal, or strictly smaller than op.
|
int |
cmp(Mpz op)
Returns a positive, null, or negative number when this is respectively
strictly greater, equal, or strictly smaller than op.
|
int |
cmpAbs(double op)
Returns a positive, null, or negative number when |this| is respectively
strictly greater, equal, or strictly smaller than |op|.
|
int |
cmpAbs(int op)
Returns a positive, null, or negative number when |this| is respectively
strictly greater, equal, or strictly smaller than |op|.
|
int |
cmpAbs(Mpz op)
Returns a positive, null, or negative number when |this| is respectively
strictly greater, equal, or strictly smaller than |op|.
|
int |
compareTo(Mpz x)
Compare the value of this and x.
|
void |
divExact(int d)
Divides this by d, assuming that d divides this. d must be positive.
|
void |
divExact(Mpz d)
Divides this by d, assuming that d divides this.
|
void |
divExact(Mpz n,
int d)
Stores n/d into this, assuming that d divides n. d must be positive.
|
void |
divExact(Mpz n,
Mpz d)
Stores n/d into this, assuming that d divides n.
|
double |
doubleExponentValue(int[] r)
Converts the integer to a mantissa and exponent.
|
double |
doubleValue()
Returns this as a double.
|
boolean |
equals(java.lang.Object x)
Whether x is a Mpz and has the same value as this.
|
void |
fac(int op)
Stores op!
|
int |
fdivQ(int d)
Divides this by d, rounds towards -oo, and returns the remainder.
|
void |
fdivQ(Mpz d)
Divides this by d and rounds towards -oo.
|
int |
fdivQ(Mpz n,
int d)
Stores the quotient of n/d rounded towards -oo into this,
and returns the remainder.
|
void |
fdivQ(Mpz n,
Mpz d)
Stores the quotient of n/d rounded towards -oo into this.
|
void |
fdivQ2exp(Mpz n,
int d)
Stores the quotient of n/(2^d) rounded towards -oo into this.
|
int |
fdivQR(Mpz r,
Mpz n,
int d)
Stores the quotient of n/d rounded towards -oo into this, the
remainder into r, and returns the remainder.
|
void |
fdivQR(Mpz r,
Mpz n,
Mpz d)
Stores the quotient of n/d rounded towards -oo into this and the
remainder into r.
|
int |
fdivR(int d)
Returns the remainder of of this/d rounded towards -oo.
|
int |
fdivR(Mpz n,
int d)
Stores the remainder of n/d rounded towards -oo into this,
and returns the remainder.
|
void |
fdivR(Mpz n,
Mpz d)
Stores the remainder of n/d rounded towards -oo into this.
|
void |
fdivR2exp(Mpz n,
int d)
Stores the remainder of n/(2^d) rounded towards -oo into this.
|
void |
fib(int n)
Stores into this the n-th Fibonacci number.
|
void |
fib(Mpz r,
int n)
Stores into this the n-th Fibonacci number, and into r the n-1-th
Fibonacci number.
|
protected void |
finalize()
Deallocates the underlying mpz_t GMP object.
|
boolean |
fitsInt()
Whether this can fit in an int.
|
int |
gcd(Mpz op1,
int op2)
Returns the greatest common divisor of op1 and op2.
|
void |
gcd(Mpz op1,
Mpz op2)
Stores into this the greatest common divisor of op1 and op2.
|
void |
gcd(Mpz s,
Mpz t,
Mpz op1,
Mpz op2)
Stores the greatest common divisor of op1 and op2 into this.
|
int |
hamDist(Mpz op)
Returns the Hamming distance between this and op.
|
int |
hashCode()
Returns a hash of the value of this.
|
int |
intValue()
Returns this as an integer.
|
boolean |
invert(Mpz op1,
Mpz op2)
Stores the inverse of op1 modulo op2 into this.
|
boolean |
isCongruent(int c,
int d)
Returns true if this equals c modulo d.
|
boolean |
isCongruent(Mpz c,
Mpz d)
Returns true if this equals c modulo d.
|
boolean |
isCongruent2exp(Mpz c,
int d)
Returns true if this equals c modulo 2^d.
|
boolean |
isDivisible(int d)
Returns true if d divides this.
|
boolean |
isDivisible(Mpz d)
Returns true if d divides this.
|
boolean |
isDivisible2exp(int d)
Returns true if 2^d divides this.
|
boolean |
isEqual(Mpz x)
Whether this and x have the same value.
|
boolean |
isEven()
Whether this is even.
|
boolean |
isOdd()
Whether this is odd.
|
boolean |
isPerfectPower()
Returns true if this has the form a^b for some a and b > 1.
|
boolean |
isPerfectSquare()
Returns true if this has the form a^2 for some a.
|
boolean |
isPhysicalEqual(Mpz x)
Whether this and x have the same address in memory.
|
int |
isProbabPrime(int r)
Returns 2 if this is definitely prime, 1 if it is probably prime,
and 0 if it is definitely composite.
|
static int |
jacobi(Mpz b,
Mpz p)
Returns the Jacobi symbol of a and b.
|
static int |
kronecker(int a,
Mpz b)
Returns the Jacobi symbol with the Kronecker extension.
|
static int |
kronecker(Mpz a,
int b)
Returns the Jacobi symbol with the Kronecker extension.
|
static int |
kronecker(Mpz a,
Mpz b)
Returns the Jacobi symbol with the Kronecker extension.
|
void |
lcm(Mpz op1,
int op2)
Stores into this the least common multiple of op1 and op2.
|
void |
lcm(Mpz op1,
Mpz op2)
Stores into this the least common multiple of op1 and op2.
|
static int |
legendre(Mpz a,
Mpz p)
Returns the Legendre symbol.
|
void |
lucnum(int n)
Stores into this the n-th Lucas number.
|
void |
lucnum(Mpz r,
int n)
Stores into this the n-th Lucas number, and into r the n-1-th
Lucas number.
|
int |
mod(int d)
Replaces this with this mod |d|.
|
void |
mod(Mpz d)
Replaces this with this mod |d|.
|
int |
mod(Mpz n,
int d)
Stores n mod |d| into this and returns it.
|
void |
mod(Mpz n,
Mpz d)
Stores n mod |d| into this.
|
void |
mul(int arg)
Multiplies this by arg.
|
void |
mul(Mpz arg)
Multiplies this by arg.
|
void |
mul(Mpz arg1,
int arg2)
Stores arg1*arg2 into this.
|
void |
mul(Mpz arg1,
Mpz arg2)
Stores arg1*arg2 into this.
|
void |
mul2exp(int arg)
Multiplies this by 2^arg.
|
void |
mul2exp(Mpz arg1,
int arg2)
Stores arg1*2^arg2 into this.
|
void |
neg()
Replaces this with -this.
|
void |
neg(Mpz arg)
Stores -arg into this.
|
void |
nextPrime(Mpz op)
Stores into this the next prime greater than op.
|
void |
not()
Stores the bitwise complement of this into this.
|
void |
not(Mpz op)
Stores the bitwise complement of op into this.
|
void |
notBit(int pos)
Inverts the pos-th bit in this.
|
void |
or(Mpz op)
Stores the bitwise or of this and op into this.
|
void |
or(Mpz op1,
Mpz op2)
Stores the bitwise or of op1 and op2 into this.
|
int |
popCount()
Returns the number of bits set to 1 in this.
|
void |
pow(int e)
Takes the e-th power of this.
|
void |
pow(int b,
int e)
Stores b^e into this.
|
void |
pow(Mpz b,
int e)
Stores b^e into this.
|
void |
pow(Mpz b,
int e,
Mpz m)
Stores b^e mod m into this.
|
void |
pow(Mpz b,
Mpz e,
Mpz m)
Stores b^e mod m into this.
|
void |
random(RandState r,
Mpz n)
Stores into this a uniformly distributed random number in 0..n-1.
|
void |
randomBits(RandState r,
int n)
Stores into this a uniformly distributed random number with n bits
(i.e., in 0..2^n-1).
|
int |
remove(Mpz f)
Removes from this all occurrences of factor f.
|
int |
remove(Mpz op,
Mpz f)
Stores into this op with all occurrences of factor f removed.
|
boolean |
root(int n)
Takes the n-th root of this, truncated.
|
boolean |
root(Mpz op,
int n)
Stores the n-th root of op into this, truncated.
|
void |
root(Mpz r,
Mpz op,
int n)
Stores the n-th root of op into this, truncated, and the remainder
op-this^n into r.
|
void |
rRandomBits(RandState r,
int n)
Stores into this a random number with n bits, and long strings of
zeros and ones in its binary representation.
|
int |
scan0(int pos)
Returns the position of the first bit set to 0 at or after position
pos.
|
int |
scan1(int pos)
Returns the position of the first bit set to 1
at or after position pos.
|
void |
set(java.math.BigInteger b)
Sets this to a Java big integer.
|
void |
set(double d)
Sets this to a double.
|
void |
set(int i)
Sets this to an integer.
|
void |
set(int sign,
byte[] mag)
Sets the value of this given a magnitude and a sign.
|
void |
set(Mpz v)
Copies the argument into this.
|
void |
set(java.lang.String s)
Sets this to the String s.
|
void |
set(java.lang.String s,
int b)
Sets this to the String s expressed in base b.
|
void |
setBit(int pos)
Sets the pos-th bit to 1 in this.
|
int |
sgn()
Returns +1, 0, or -1 when this is respectively strictly positive, null,
or strictly negative.
|
int |
size()
Returns the size (in GMP limbs) of the internal representation of
this.
|
int |
sizeInBase(int b)
Returns the number of digits necessary to represent |this| in base b.
|
void |
sqrt()
Takes the truncated square root of this.
|
void |
sqrt(Mpz op)
Stores the truncated square root of op into this.
|
void |
sqrt(Mpz r,
Mpz op)
Stores the square root of op into this, truncated, and the remainder
op-this^2 into r.
|
void |
sub(int arg)
Subtracts arg from this.
|
void |
sub(int arg1,
Mpz arg2)
Stores arg1-arg2 into this.
|
void |
sub(Mpz arg)
Subtracts arg from this.
|
void |
sub(Mpz arg1,
int arg2)
Stores arg1-arg2 into this.
|
void |
sub(Mpz arg1,
Mpz arg2)
Stores arg1-arg2 into this.
|
void |
subMul(Mpz arg1,
int arg2)
Stores this-arg1*arg2 into this.
|
void |
subMul(Mpz arg1,
Mpz arg2)
Stores this-arg1*arg2 into this.
|
void |
subRev(int arg)
Replaces this with arg-this.
|
int |
tdivQ(int d)
Divides this by d, rounds towards 0, and returns the remainder.
|
void |
tdivQ(Mpz d)
Divides this by d and rounds towards 0.
|
int |
tdivQ(Mpz n,
int d)
Stores the quotient of n/d rounded towards 0 into this,
and returns the remainder.
|
void |
tdivQ(Mpz n,
Mpz d)
Stores the quotient of n/d rounded towards 0 into this.
|
void |
tdivQ2exp(Mpz n,
int d)
Stores the quotient of n/(2^d) rounded towards 0 into this.
|
int |
tdivQR(Mpz r,
Mpz n,
int d)
Stores the quotient of n/d rounded towards 0 into this, the
remainder into r, and returns the remainder.
|
void |
tdivQR(Mpz r,
Mpz n,
Mpz d)
Stores the quotient of n/d rounded towards 0 into this and the
remainder into r.
|
int |
tdivR(int d)
Returns the remainder of of this/d rounded towards 0.
|
int |
tdivR(Mpz n,
int d)
Stores the remainder of n/d rounded towards 0 into this,
and returns the remainder.
|
void |
tdivR(Mpz n,
Mpz d)
Stores the remainder of n/d rounded towards 0 into this.
|
void |
tdivR2exp(Mpz n,
int d)
Stores the remainder of n/(2^d) rounded towards 0 into this.
|
java.lang.String |
toString()
Returns a String representation this in base 10.
|
java.lang.String |
toString(int b)
Returns a String representation of this in base b.
|
boolean |
tstBit(int pos)
Returns true if the pos-th bit in this is 1.
|
void |
xor(Mpz op)
Stores the bitwise xor of this and op into this.
|
void |
xor(Mpz op1,
Mpz op2)
Stores the bitwise xor of op1 and op2 into this.
|
public static final int infinite
public Mpz()
public Mpz(Mpz v)
public Mpz(int i)
public Mpz(double d)
The value is truncated to an integer.
public Mpz(java.math.BigInteger b)
public Mpz(java.lang.String s, int b)
b
- must be either 0, or between 2 and 62.
When b is 0, the leading characters are used to determine the base
(0x and 0X for hexadecimal, 0b and 0B for binary, 0 for octal,
decimal otherwise).public Mpz(java.lang.String s)
The leading characters are used to determine whether base: 0x and 0X for hexadecimal, 0b and 0B for binary, 0 for octal, and decimal otherwise.
public Mpz(int sign, byte[] mag)
public void set(int sign, byte[] mag)
Used during deserialization.
mag is the absolute value encoded in a byte array in big endian order.
public byte[] byteArrayValue()
User during serialization.
The magnitude is the absolute value, and it is returned as a byte array stored in big-endian order.
protected void finalize()
finalize
in class java.lang.Object
public Mpz clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
public void set(Mpz v)
public void set(int i)
public void set(double d)
The value is truncated.
public void set(java.math.BigInteger b)
public void set(java.lang.String s, int b)
Mpz(String,int)
public void set(java.lang.String s)
Mpz(String)
public int intValue()
The result is truncated if it does not fit in an integer.
fitsInt()
public double doubleValue()
If this cannot be represented as a double, the result is truncated.
Overflows cause infinities to be returned.
public double doubleExponentValue(int[] r)
The mantissa m returned is such that 0.5 <= |m| < 1, truncated to fit double.
The exponent is stored into r[0].
public java.math.BigInteger bigIntegerValue()
public java.lang.String toString(int b)
b
- must be between 2 and 62.public java.lang.String toString()
toString
in class java.lang.Object
public void add(Mpz arg1, int arg2)
public void add(Mpz arg)
public void add(int arg)
public void sub(Mpz arg1, int arg2)
public void sub(int arg1, Mpz arg2)
public void sub(Mpz arg)
public void sub(int arg)
public void subRev(int arg)
public void mul(Mpz arg1, int arg2)
public void mul(Mpz arg)
public void mul(int arg)
public void addMul(Mpz arg1, int arg2)
public void subMul(Mpz arg1, int arg2)
public void mul2exp(Mpz arg1, int arg2)
arg2 must be positive.
public void mul2exp(int arg)
arg must be positive.
public void neg(Mpz arg)
public void neg()
public void abs(Mpz arg)
public void abs()
public void cdivQ(Mpz n, Mpz d) throws java.lang.ArithmeticException
java.lang.ArithmeticException
public void cdivQ(Mpz d) throws java.lang.ArithmeticException
java.lang.ArithmeticException
public void cdivR(Mpz n, Mpz d) throws java.lang.ArithmeticException
java.lang.ArithmeticException
public void cdivQR(Mpz r, Mpz n, Mpz d) throws java.lang.ArithmeticException
java.lang.ArithmeticException
public int cdivQ(Mpz n, int d) throws java.lang.ArithmeticException
d must be positive.
java.lang.ArithmeticException
public int cdivQ(int d) throws java.lang.ArithmeticException
d must be positive.
java.lang.ArithmeticException
public int cdivR(Mpz n, int d) throws java.lang.ArithmeticException
d must be positive.
java.lang.ArithmeticException
public int cdivQR(Mpz r, Mpz n, int d) throws java.lang.ArithmeticException
d must be positive.
java.lang.ArithmeticException
public int cdivR(int d) throws java.lang.ArithmeticException
this is unchanged.
d must be positive.
java.lang.ArithmeticException
public void cdivQ2exp(Mpz n, int d) throws java.lang.ArithmeticException
d must be positive.
java.lang.ArithmeticException
public void cdivR2exp(Mpz n, int d) throws java.lang.ArithmeticException
d must be positive.
java.lang.ArithmeticException
public void fdivQ(Mpz n, Mpz d) throws java.lang.ArithmeticException
java.lang.ArithmeticException
public void fdivQ(Mpz d) throws java.lang.ArithmeticException
java.lang.ArithmeticException
public void fdivR(Mpz n, Mpz d) throws java.lang.ArithmeticException
java.lang.ArithmeticException
public void fdivQR(Mpz r, Mpz n, Mpz d) throws java.lang.ArithmeticException
java.lang.ArithmeticException
public int fdivQ(Mpz n, int d) throws java.lang.ArithmeticException
d must be positive.
java.lang.ArithmeticException
public int fdivQ(int d) throws java.lang.ArithmeticException
d must be positive.
java.lang.ArithmeticException
public int fdivR(Mpz n, int d) throws java.lang.ArithmeticException
d must be positive.
java.lang.ArithmeticException
public int fdivQR(Mpz r, Mpz n, int d) throws java.lang.ArithmeticException
d must be positive.
java.lang.ArithmeticException
public int fdivR(int d) throws java.lang.ArithmeticException
this is unchanged.
d must be positive.
java.lang.ArithmeticException
public void fdivQ2exp(Mpz n, int d) throws java.lang.ArithmeticException
java.lang.ArithmeticException
public void fdivR2exp(Mpz n, int d) throws java.lang.ArithmeticException
d must be positive.
java.lang.ArithmeticException
public void tdivQ(Mpz n, Mpz d) throws java.lang.ArithmeticException
java.lang.ArithmeticException
public void tdivQ(Mpz d) throws java.lang.ArithmeticException
java.lang.ArithmeticException
public void tdivR(Mpz n, Mpz d) throws java.lang.ArithmeticException
java.lang.ArithmeticException
public void tdivQR(Mpz r, Mpz n, Mpz d) throws java.lang.ArithmeticException
java.lang.ArithmeticException
public int tdivQ(Mpz n, int d) throws java.lang.ArithmeticException
d must be positive.
java.lang.ArithmeticException
public int tdivQ(int d) throws java.lang.ArithmeticException
d must be positive.
java.lang.ArithmeticException
public int tdivR(Mpz n, int d) throws java.lang.ArithmeticException
d must be positive.
java.lang.ArithmeticException
public int tdivQR(Mpz r, Mpz n, int d) throws java.lang.ArithmeticException
d must be positive.
java.lang.ArithmeticException
public int tdivR(int d) throws java.lang.ArithmeticException
this is unchanged.
d must be positive.
java.lang.ArithmeticException
public void tdivQ2exp(Mpz n, int d) throws java.lang.ArithmeticException
d must be positive.
java.lang.ArithmeticException
public void tdivR2exp(Mpz n, int d) throws java.lang.ArithmeticException
d must be positive.
java.lang.ArithmeticException
public void mod(Mpz n, Mpz d) throws java.lang.ArithmeticException
java.lang.ArithmeticException
public void mod(Mpz d) throws java.lang.ArithmeticException
java.lang.ArithmeticException
public int mod(Mpz n, int d) throws java.lang.ArithmeticException
java.lang.ArithmeticException
public int mod(int d) throws java.lang.ArithmeticException
java.lang.ArithmeticException
public void divExact(Mpz n, Mpz d) throws java.lang.ArithmeticException
java.lang.ArithmeticException
public void divExact(Mpz d) throws java.lang.ArithmeticException
java.lang.ArithmeticException
public void divExact(Mpz n, int d) throws java.lang.ArithmeticException
java.lang.ArithmeticException
public void divExact(int d) throws java.lang.ArithmeticException
java.lang.ArithmeticException
public boolean isDivisible(Mpz d)
Only 0 is divisible by 0.
public boolean isDivisible(int d)
d must be positive.
Only 0 is divisible by 0.
public boolean isDivisible2exp(int d)
d must be positive.
public boolean isCongruent(Mpz c, Mpz d)
When d=0, returns true if this equals c.
public boolean isCongruent(int c, int d)
d must be positive.
When d=0, returns true if this equals c.
public boolean isCongruent2exp(Mpz c, int d)
d must be positive.
public void pow(Mpz b, Mpz e, Mpz m) throws java.lang.ArithmeticException
Throws an ArithmeticException if e < 0 and b has no inverse modulo m.
java.lang.ArithmeticException
public void pow(Mpz b, int e, Mpz m) throws java.lang.ArithmeticException
e must be positive.
java.lang.ArithmeticException
public void pow(Mpz b, int e)
e must be positive.
0^0 is 1.
public void pow(int e)
e must be positive.
0^0 is 1.
public void pow(int b, int e)
b and e must be positive.
0^0 is 1.
public boolean root(Mpz op, int n)
Returns true if the computation was exact.
n must be positive.
public boolean root(int n)
Returns true if the computation was exact.
n must be positive.
public void root(Mpz r, Mpz op, int n)
n must be positive.
public void sqrt(Mpz op)
public void sqrt()
public void sqrt(Mpz r, Mpz op)
public boolean isPerfectPower()
0 and 1 are perfect powers.
public boolean isPerfectSquare()
0 and 1 are perfect squares.
public int isProbabPrime(int r)
r is the number of tests; high numbers increasing the certainty. A value between 5 and 10 is reasonable.
public void nextPrime(Mpz op)
This uses a probabilistic algorithm so that the chance of getting a composite are non-null but extremely small.
public void gcd(Mpz op1, Mpz op2)
The result is always positive, even for negative inputs.
public int gcd(Mpz op1, int op2)
this is unchanged.
op2 must be strictly positive.
public void gcd(Mpz s, Mpz t, Mpz op1, Mpz op2)
Sets s and t to values such that s*op1+t*op2 = gcd and |s| <= |op2|, |t| <= |op1|.
public void lcm(Mpz op1, int op2)
op2 must be positive.
public boolean invert(Mpz op1, Mpz op2)
Returns true if this inverse exists. Otherwise, returns false; this is undefined.
public static int legendre(Mpz a, Mpz p)
p must be an odd positive prime.
public static int kronecker(Mpz a, Mpz b)
public static int kronecker(Mpz a, int b)
public static int kronecker(int a, Mpz b)
public int remove(Mpz op, Mpz f)
Returns the number of removed factors.
public int remove(Mpz f)
Returns the number of removed factors.
public void fac(int op)
op must be positive.
public void bin(Mpz n, int k)
k must be positive.
public void bin(int n, int k)
n and k must be positive.
public void fib(int n)
n must be positive.
public void fib(Mpz r, int n)
n must be positive.
public void lucnum(int n)
n must be positive.
public void lucnum(Mpz r, int n)
n must be positive.
public int cmp(Mpz op)
public int cmp(int op)
public int cmp(double op)
public int cmpAbs(Mpz op)
public int cmpAbs(int op)
public int cmpAbs(double op)
public int sgn()
public boolean isEqual(Mpz x)
public boolean equals(java.lang.Object x)
equals
in class java.lang.Object
public int compareTo(Mpz x)
compareTo
in interface java.lang.Comparable<Mpz>
public int hashCode()
hashCode
in class java.lang.Object
public boolean isPhysicalEqual(Mpz x)
public void and(Mpz op)
public void or(Mpz op)
public void xor(Mpz op)
public void not(Mpz op)
public void not()
public int popCount()
Returns infinite
if this is negative.
public int hamDist(Mpz op)
Returns infinite
if this and op have different signs.
public int scan0(int pos)
pos must be positive.
May return infinite
, if this is negative.
public int scan1(int pos)
pos must be positive.
May return infinite
, if this is positive.
public void setBit(int pos)
pos must be positive.
public void clrBit(int pos)
pos must be positive.
public void notBit(int pos)
pos must be positive.
public boolean tstBit(int pos)
pos must be positive.
public boolean fitsInt()
public boolean isOdd()
public boolean isEven()
public int sizeInBase(int b)
public int size()
public void randomBits(RandState r, int n)
n must be positive.
public void random(RandState r, Mpz n)
public void rRandomBits(RandState r, int n)
Useful to trigger corner-case bugs when testing.