|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectNumThy
This class provides static methods giving functions from
elementary number theory. It is strictly limited to the
int data type. The engine for prime factorization is
just trial division.
"Cohen" means Henri Cohen, A Course in Computational Number Theory, Graduate Texts in Mathematics 138, Springer.
| 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 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 n greater than or equal to 0 (the 0th prime is 2) and less than 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 > the argument. |
static BigInteger |
orderGL(int n,
int q)
Returns the order of GL(n) over the finite field of q elements, as a BigInteger. |
static BigInteger |
orderPGL(int n,
int q)
Returns the order of PGL(n) over the finite field of q elements, as a BigInteger. |
static BigInteger |
orderPSL(int n,
int q)
Returns the order of PSL(n) over the finite field of q elements, as a BigInteger. |
static BigInteger |
orderSL(int n,
int q)
Returns the order of SL(n) over the finite field of q elements, as a BigInteger. |
static int |
power(int a,
int i,
int n)
Returns a^i modulo n. |
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 phi-function, the totient, of n. |
static int |
totient(int[][] fac)
Returns the Euler phi-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. It is related to the density of p such that a given a greater than 1 is a primitive root, but we must first adjust 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.
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, and the exponents will be positive. If
n is negative, it is silently replaced with its absolute
value. The factorization of 1 is an array of length 0.
IllegalArgumentException - If n is 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 is less than 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)
Uses a binary powering algorithm (O(log i)).
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)
BigInteger. n must be
greater than or equal to 1, and q must be a prime
power.
public static BigInteger orderSL(int n,
int q)
BigInteger. n must be
greater than or equal to 1, and q must be a prime
power.
public static BigInteger orderPGL(int n,
int q)
BigInteger. n must be
greater than or equal to 1, and q must be a prime
power.
public static BigInteger orderPSL(int n,
int q)
BigInteger. n must be
greater than or equal to 1, and q must be a prime
power.
public static void main(String[] args)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||