spire.math.prime

SieveSegment

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.

Linear Supertypes
Serializable, Serializable, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. SieveSegment
  2. Serializable
  3. Serializable
  4. AnyRef
  5. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  5. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  9. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  10. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  11. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  12. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  13. final def notify(): Unit

    Definition Classes
    AnyRef
  14. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  15. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  16. def toString(): String

    Definition Classes
    AnyRef → Any
  17. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  18. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  19. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  20. val wheel30: Array[Int]

Inherited from Serializable

Inherited from Serializable

Inherited from AnyRef

Inherited from Any

Ungrouped