|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
ObjectNumThy
This class provides static methods from elementary number theory,
strictly limited to the int data type. The engine
for prime factorization is trial division.
Throughout this page of documentation, "Cohen" means Henri Cohen, A Course in Computational Number Theory, first edition, Graduate Texts in Mathematics 138, Springer-Verlag, Berlin, 1993.
| Field Summary | |
static double |
ARTIN_CONSTANT
Artin's constant: the product over all primes p of 1 - 1/(p(p-1)). |
| Constructor Summary | |
NumThy()
|
|
| Method Summary | |
static int[] |
extGcd(int a,
int b)
Given non-negative integers a and b, returns [u,v,d] such that the gcd of a and b is d and au + bv = d. |
static int[][] |
factor(int n)
Returns the prime factorization of n as an array of two-element int arrays. |
static int |
gcd(int a,
int b)
Returns the greatest common divisor as a non-negative int. |
static int |
getPrime(int n)
Returns the nth prime, for 0 ≤ n < 4792. |
static int |
invModN(int a,
int n)
Given a ≥ 0 and n ≥ 1, returns the multiplicative inverse of a modulo n. |
static boolean |
isPrime(int n)
Whether n is prime. |
static int |
lcm(int a,
int b)
Returns the least common multiple as a non-negative int. |
static void |
main(String[] args)
Tests the order of GL(n,q) and friends. |
static int |
nextPrime(int n)
Returns the smallest positive prime > n. |
static BigInteger |
orderGL(int n,
int q)
Returns the order of GL(n) over the finite field of q elements. |
static BigInteger |
orderPGL(int n,
int q)
Returns the order of PGL(n) over the finite field of q elements. |
static BigInteger |
orderPSL(int n,
int q)
Returns the order of PSL(n) over the finite field of q elements. |
static BigInteger |
orderSL(int n,
int q)
Returns the order of SL(n) over the finite field of q elements. |
static String |
pairsToString(int[][] x)
E.g., converts [[2,3],[3,1]] to2^3 * 3. |
static int |
power(int a,
int i,
int n)
Finds ai modulo n using a binary powering algorithm (O(log i)). |
static int |
primitiveRoot(int p)
Returns the smallest positive primitive root modulo the prime p. |
static int |
quadRes(int a,
int b)
Returns the value of the quadratic residue symbol (a|b). |
static int |
totient(int n)
Returns the Euler φ-function, the totient, of n. |
static int |
totient(int[][] fac)
Returns the Euler φ-function, the totient, of the positive integer whose factorization, as produced by factor(int), is
fac. |
| Methods inherited from class Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final double ARTIN_CONSTANT
1 - 1/(p(p-1)).Assuming the extended Riemann hypothesis, Hooley proved this is the density of p such that 2 is a primitive root mod p.
To get the density of p such that a given a > 1 is a primitive root, we adjust this value by a finite number of factors depending on a.
References:
| Constructor Detail |
public NumThy()
| Method Detail |
public static int getPrime(int n)
Integer.MAX_VALUE. Use nextPrime(int) for primes up to Integer.MAX_VALUE.
ArrayIndexOutOfBoundsException - If n is out of
bounds.public static boolean isPrime(int n)
public static int[][] factor(int n)
int arrays. Example: [[2,3], [3,2],
[11,1]] is the factorization of 792. The primes will occur in
increasing order. If n is negative, it is replaced with
its absolute value. The factorization of 1 is an array of
length 0.
For pretty-printing, see pairsToString(int[][]).
IllegalArgumentException - If n = 0.public static int nextPrime(int n)
IllegalArgumentException - If the return value would
be negative in the int datatype.public static int totient(int n)
IllegalArgumentException - If n < 1.public static int totient(int[][] fac)
factor(int), is
fac.
public static int[] extGcd(int a,
int b)
public static int gcd(int a,
int b)
int.
public static int lcm(int a,
int b)
int.
public static int invModN(int a,
int n)
int
datatype.
ArithmeticException - If a is not invertible
modulo n.
public static int power(int a,
int i,
int n)
IllegalArgumentException - If n is 0.public static int primitiveRoot(int p)
IllegalArgumentException - If p is not prime.
public static int quadRes(int a,
int b)
IllegalArgumentException - If b is even, or (in
particular) 0.
public static BigInteger orderGL(int n,
int q)
public static BigInteger orderSL(int n,
int q)
public static BigInteger orderPGL(int n,
int q)
public static BigInteger orderPSL(int n,
int q)
public static void main(String[] args)
public static String pairsToString(int[][] x)
[[2,3],[3,1]] to2^3 * 3.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||