Ticket #9451 (new enhancement)

Opened 3 years ago

Last modified 3 years ago

[with patch, needs work] sieve of atkin

Reported by: rohana Owned by: was
Priority: major Milestone: sage-5.10
Component: number theory Keywords: prime, sieve, range
Cc: was, kevin.stueve, robertwb Work issues:
Report Upstream: N/A Reviewers:
Authors: Merged in:
Dependencies: Stopgaps:

Description (last modified by rohana) (diff)

The goal of this ticket is to efficiently implement the sieve of atkin. This first version is a step in that direction.

Paper on the sieve can be found at  http://bit.ly/sieveatkin

The implementation is written to be run in parallel, however I am unaware of any good method of making it parallel within cython (it would be nice to get openmp in there sometime).

Due to the length of the implementation, I moved prime_range from fast_arith into a new module.

The current implementation uses 64-bit ints and hits that barrier at input around 2**56, so I've capped it at 2**52 (in the future I plan to remove this limitation).

I've changed the default algorithm to atkins, since it is nearly as fast as the pari table, but doesn't use as much storage so it is more viable for large input.

Docstrings are incomplete.

Attachments

sieve_of_atkin.patch Download (38.2 KB) - added by rohana 3 years ago.
based on 4.4.4

Change History

comment:1 Changed 3 years ago by rohana

  • Description modified (diff)

Changed 3 years ago by rohana

based on 4.4.4

comment:2 Changed 3 years ago by mhansen

A couple quick things without really looking at the content of the patch:

1) You should probably import prime_range into fast_arith for backward compatibility.

2) You don't need backslashes to continue lines when they're in brackets.

3) You should make the default algorithm None and choose it inside of the function. That way it can choose a different algorithm if the input is outside of the range of atkins.

Note: See TracTickets for help on using tickets.