#16880: previous_prime, previous_prime_power, next_prime_power
-------------------------------------+-------------------------------------
       Reporter:  vdelecroix         |        Owner:
           Type:  enhancement        |       Status:  needs_review
       Priority:  major              |    Milestone:  sage-6.7
      Component:  number theory      |   Resolution:
       Keywords:                     |    Merged in:
        Authors:  Vincent Delecroix  |    Reviewers:
Report Upstream:  N/A                |  Work issues:
         Branch:                     |       Commit:
  u/vdelecroix/16880                 |  db1e869640dbb20d39e565970aaa8c5d58fa8953
   Dependencies:                     |     Stopgaps:
-------------------------------------+-------------------------------------

Comment (by jdemeyer):

 1. I don't know if `lesser or equal than` is proper English. How about
 `less than or equal to`?

 2. `PARI` instead of `Pari`.

 3. In `next_prime_power` and `previous_prime_power`, a small optimization
 is possible: you can replace
 {{{
 mpz_set(n.value, self.value)
 mpz_add_ui(n.value, n.value, 1)
 }}}
 by
 {{{
 mpz_add_ui(n.value, self.value, 1)
 }}}

 and in `next_prime_power`, replace
 {{{
 if mpz_cmp_ui(n.value, 2) < 0:
     mpz_set_ui(n.value, 2)
     return n
 }}}
 by
 {{{
 if mpz_cmp_ui(self.value, 2) < 0:
     return smallInteger(2)
 }}}

 4. Another algorithmic comment for `next_prime_power` (an analogous
 comment holds for `previous_prime_power`): instead of computing the next
 power of 2 and doing
 {{{
 while mpz_cmp(m.value, n.value) == 1:
 }}}
 I would instead check if `mpz_sizeinbase(n.value, 2)` increases during the
 loop. In that case, we know that we skipped a power of 2.

--
Ticket URL: <http://trac.sagemath.org/ticket/16880#comment:20>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to