sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.31k stars 450 forks source link

prime_range should allow a step #29760

Open kedlaya opened 4 years ago

kedlaya commented 4 years ago

Is there any reason not to implement the following?

sage: prime_range(11, 100, 10)
[11, 31, 61, 71]

For this ticket, I have in mind the easy fix of running the same internal algorithm and retaining only the answers in the desired congruence class; that is, prime_range(x, y, z) would be equivalent to

[p for p in prime_range(x, y) if (p-x)%z == 0]

A more advanced (and more efficient) version would be to change the underlying algorithm.

Depends on #31548

CC: @DaveWitteMorris

Component: number theory

Author: David Roe

Branch/Commit: u/roed/prime_range @ 7f0a385

Issue created by migration from https://trac.sagemath.org/ticket/29760

kedlaya commented 3 years ago

Description changed:

--- 
+++ 
@@ -7,6 +7,6 @@
 For this ticket, I have in mind the easy fix of running the same internal algorithm and retaining only the answers in the desired congruence class; that is, `prime_range(x, y, z)` would be equivalent to

-p for p in prime_range(x, y) if (p-x)%z == 0 +[p for p in prime_range(x, y) if (p-x)%z == 0]

 A more advanced (and more efficient) version would be to change the underlying algorithm.
kedlaya commented 3 years ago
comment:1

Upon further reflection, maybe I should also be asking for this in the primes iterator.

mkoeppe commented 3 years ago
comment:2

Setting new milestone based on a cursory review of ticket status, priority, and last modification date.

roed314 commented 3 years ago

Branch: u/roed/prime_range

roed314 commented 3 years ago
comment:4

Dependence on #31548 is in order to have FLINT's ulong_extras.


Last 10 new commits:

1a7bb38Fixing some bugs
6f41da9Fixing doctest problems from switching default implementation to flint for small matrices
cd1b853Merge branch 'u/roed/nmod_mat' of trac.sagemath.org:sage into t/31548/nmod_mat
d0507c4Working on fixing reduction matrix bug
9748ffcAdd deprecation warning to _reduction_matrix
6e2b75aMerge branch 'u/roed/nmod_mat' of trac.sagemath.org:sage into t/31548/nmod_mat
ee10b06Working on documentation and fixing tests
465f51dWorking on documentation
760e0c9Small fixes
726b135Add step to prime_range and primes
roed314 commented 3 years ago

Author: David Roe

roed314 commented 3 years ago

Commit: 726b135

roed314 commented 3 years ago

Dependencies: #31548

roed314 commented 3 years ago
comment:5

The changes in this ticket are all in sage/rings/fast_arith.p* and sage/arith/misc.py.

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from 726b135 to 7f0a385

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

7f0a385Fix fast_arith.pxd
kedlaya commented 3 years ago
comment:7

Looks fine modulo the dependence on #31548.

mkoeppe commented 3 years ago
comment:8

Setting a new milestone for this ticket based on a cursory review.

mezzarobba commented 2 years ago
comment:9

needs rebase, dependency too