object SieveSegment extends Serializable
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.
- Alphabetic
- By Inheritance
- SieveSegment
- Serializable
- Serializable
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
- val wheel30: Array[Int]