|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.math.BitSieve
A simple bit sieve used for finding prime number candidates. Allows setting and clearing of bits in a storage array. The size of the sieve is assumed to be constant to reduce overhead. All the bits of a new bitSieve are zero, and bits are removed from it by setting them. To reduce storage space and increase efficiency, no even numbers are represented in the sieve (each bit in the sieve represents an odd number). The relationship between the index of a bit and the number it represents is given by N = offset + (2*index + 1); Where N is the integer represented by a bit in the sieve, offset is some even integer offset indicating where the sieve begins, and index is the index of a bit in the sieve array.
BigInteger
Field Summary | |
private long[] |
bits
Stores the bits in this bitSieve. |
private int |
length
Length is how many bits this sieve holds. |
private static BitSieve |
smallSieve
A small sieve used to filter out multiples of small primes in a search sieve. |
Constructor Summary | |
private |
BitSieve()
Construct a "small sieve" with a base of 0. |
(package private) |
BitSieve(BigInteger base,
int searchLen)
Construct a bit sieve of searchLen bits used for finding prime number candidates. |
Method Summary | |
private static long |
bit(int bitIndex)
Return a unit that masks the specified bit in its unit. |
private boolean |
get(int bitIndex)
Get the value of the bit at the specified index. |
(package private) BigInteger |
retrieve(BigInteger initValue,
int certainty)
Test probable primes in the sieve and return successful candidates. |
private void |
set(int bitIndex)
Set the bit at the specified index. |
private int |
sieveSearch(int limit,
int start)
This method returns the index of the first clear bit in the search array that occurs at or after start. |
private void |
sieveSingle(int limit,
int start,
int step)
Sieve a single set of multiples out of the sieve. |
private static int |
unitIndex(int bitIndex)
Given a bit index return unit index containing it. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private long[] bits
private int length
private static BitSieve smallSieve
Constructor Detail |
private BitSieve()
BitSieve(BigInteger base, int searchLen)
Method Detail |
private static int unitIndex(int bitIndex)
private static long bit(int bitIndex)
private boolean get(int bitIndex)
private void set(int bitIndex)
private int sieveSearch(int limit, int start)
private void sieveSingle(int limit, int start, int step)
BigInteger retrieve(BigInteger initValue, int certainty)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |