#7013: [with patch, needs work] prime_pi and nth_prime
----------------------------------------+-----------------------------------
   Reporter:  kevin.stueve              |       Owner:  kevin.stueve            
       Type:  enhancement               |      Status:  needs_work              
   Priority:  major                     |   Milestone:  sage-4.4                
  Component:  number theory             |    Keywords:  primes, sieve, table,LMO
     Author:  Kevin Stueve              |    Upstream:  N/A                     
   Reviewer:  was,robertwb,GeorgSWeber  |      Merged:                          
Work_issues:                            |  
----------------------------------------+-----------------------------------

Comment(by kevin.stueve):

 Andrew Ohana Cythonized my last prime counting code post.  I triple quoted
 the message he sent me on Mar 23

 """Hey,

 So I've attached a code, how to get it working (in sage), the
 prime_sieve.c has the main method separated from the sieve so that we can
 get an unsigned 64-bit int straight out of it and into cython (huge
 speedup that bests the multiprocessed python code with a single thread on
 my machine):

 0) I will refer to the sage directory (where the sage command lies) as
 SAGE_ROOT (as per the sage api)

 1) make sure you clone sage and exit, you can do this from within sage by
 running hg_sage.clone(clone_name), eg

 sage: hg_sage.clone('PrimePi')
 <clone output>
 sage: exit

 2) copy your tables (with the same file names) into
 SAGE_ROOT/data/prime_pi_tables/

 3) copy the two files I've attached to
 SAGE_ROOT/devel/sage/sage/functions/

 4) edit SAGE_ROOT/devel/sage/sage/functions/all.py and add the following
 line after the prime_pi line

 from cython_table_based_prime_pi import cython_table_based_prime_pi

 we will remove this when the old prime_pi method is removed

 5) edit SAGE_ROOT/devel/sage/module_list.py and add the following lines in
 the sage.functions section

 Extension('sage.functions.cython_table_based_prime_pi',
     sources = ['sage/functions/cython_table_based_prime_pi.pyx']),

 again we will remove this later on (after testing).

 6) run the sage command with the argument -br e.g.

 SAGE_ROOT/sage -br

 7) you should now be able to use the cython_table_based_prime_pi function
 from within sage whenever you are in the PrimePi branch (you can switch
 branches with the hg_sage.switch command).

 Hopefully this illustrates how to add code to sage in general, the
 module_list is not needed for python modules, only for cython modules and
 multiple cython sources can be used for a single module.

 -- Andrew"""

 I think that we are ready to make an optional package and installing it in
 the online version of Sage.  Andrew Ohana's instructions should allow
 anyone to add the table-based prime counting algorithm along with the
 densest data available to their copy of Sage.

 Kevin Stueve

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/7013#comment:52>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to