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.

@see BigInteger @author Michael McCloskey

Constructors

this
this(BigInteger base, int searchLen)

Construct a bit sieve of searchLen bits used for finding prime number candidates. The new sieve begins at the specified base, which must be even.

Members

Functions

retrieve
BigInteger retrieve(BigInteger initValue, int certainty, Random* random)

Test probable primes in the sieve and return successful candidates.

Meta