Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#10784 closed enhancement (fixed)

primes can have better functionality.

Reported by: mderickx Owned by: was
Priority: major Milestone: sage-4.7
Component: number theory Keywords: prime, iterator, beginner
Cc: niles Merged in: sage-4.7.alpha2
Authors: Douglas McNeil Reviewers: Karl-Dieter Crisman
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by jdemeyer)

In this topic: http://groups.google.com/group/sage-devel/browse_thread/thread/cd05585cf395b3a0/c7c82fbb725dee50

D.S. McNeil posted several ideas for enhancing sage. This ticket is for the enhancements proposed for the primes function.

(3) primes(10, infinity) should work. 
Since we're just calling next_prime, there's no reason to require the 
upper limit to be an integer. 
Wouldn't mind a proof=False option which calls next_probable_prime 
instead, either. 

Apply trac_10784_primes_enhancements.patch and trac_10784-reviewer.patch

Attachments (2)

trac_10784_primes_enhancements.patch (3.7 KB) - added by dsm 10 years ago.
allow +infinity, proof
trac_10784-reviewer.patch (2.8 KB) - added by kcrisman 10 years ago.
Apply after initial patch

Download all attachments as: .zip

Change History (11)

comment:1 Changed 10 years ago by mderickx

  • Component changed from PLEASE CHANGE to number theory
  • Milestone set to sage-4.7
  • Owner changed from tbd to was
  • Type changed from PLEASE CHANGE to enhancement

Changed 10 years ago by dsm

allow +infinity, proof

comment:2 Changed 10 years ago by dsm

Patch attached to allow support for infinity as upper bound and proof option (with same semantics as next_prime's proof option: it's simply passed through to next_prime).

First idea was to avoid casting to ZZ entirely, which would allow primes(2, 100/3), but that can lead to some mysterious error messages. Current approach simply special-cases infinity as an upper bound -- allowing -infinity as a lower bound isn't that useful, because unlike the case of an infinite upper bound, that can be easily worked around from outside the function, and so problems with the bounds are caught at first iteration, which seems better.

comment:3 Changed 10 years ago by dsm

  • Summary changed from primes can have better functionallity. to primes can have better functionality.

comment:4 Changed 10 years ago by niles

  • Authors set to D. S. McNeil
  • Cc niles added
  • Description modified (diff)
  • Keywords prime iterator beginner added
  • Status changed from new to needs_review

Looks really good -- I've marked it as 'beginner', meaning that this is a patch which someone who is just beginning could review. If no one beats me to it, I'll go ahead and review it :)

comment:5 Changed 10 years ago by kcrisman

  • Description modified (diff)
  • Reviewers set to Karl-Dieter Crisman
  • Status changed from needs_review to positive_review

This is a great patch, nicely tested. I've made some minor tweaks in the documentation to remove some errors in the docbuild and a few other things like indentation, and added one doctest. Positive review.

Changed 10 years ago by kcrisman

Apply after initial patch

comment:7 Changed 10 years ago by jdemeyer

  • Description modified (diff)

comment:8 Changed 10 years ago by jdemeyer

  • Merged in set to sage-4.7.alpha2
  • Resolution set to fixed
  • Status changed from positive_review to closed

comment:9 Changed 10 years ago by jdemeyer

  • Authors changed from D. S. McNeil to Douglas McNeil
Note: See TracTickets for help on using tickets.