SieveSegment

This respresents a single sieve segment.

The 'start' field says what this segment's first number is. 'primes' is a bitset of possible primes in this segment. 'cutoff' specifies the largest prime factor we're interested in. This means that cutoff**2-1 is the largest number we could reliably identify as prime.

We are using a mod30 wheel, which means that we don't need to manually factor using 2, 3, or 5 (30 is the lcm of 2, 3, and 5). Since each wheel turn is 30-bits, and our bitset groups elements into 32-bit groups (integers), we have a 480-bit (15 integer) period between the wheel and the bitset. This requires our segment length to be divisible by 480.

When building a sieve, we will first initialize using the mod30 wheel. Then, if we are on the first segment, we'll do a traditional sieve. We'll save any primes greater than 5 we find as factors, either fast factors (if they will show up frequently in each segment) or slow factors otherwise. If a factor is larger than cutoff we don't save it. After that we'll be done with the first segment.

For later segments, we will use our fast and slow factors to block out composites as we find them. Like in the first segment, we'll save factors we find (although any new factors we find now will always be slow). And of course we won't save any factors above our cutoff.

Once the sieve is initialized it doesn't do anything else interesting, besides report prime numbers. Currently its internals are made available to the Siever.

Companion:
class
trait Product
trait Mirror
class Object
trait Matchable
class Any

Type members

Inherited types

type MirroredElemLabels <: Tuple

The names of the product elements

The names of the product elements

Inherited from:
Mirror

The name of the type

The name of the type

Inherited from:
Mirror

Value members

Concrete fields