#10255: improve karatsuba multiplication of univariate polynomials
--------------------------------+-------------------------------------------
   Reporter:  lftabera          |       Owner:  AlexGhitza                      
     
       Type:  enhancement       |      Status:  new                             
     
   Priority:  major             |   Milestone:  sage-4.6.1                      
     
  Component:  basic arithmetic  |    Keywords:  karatsuba, multiplication, 
polynomial
     Author:                    |    Upstream:  N/A                             
     
   Reviewer:                    |      Merged:                                  
     
Work_issues:                    |  
--------------------------------+-------------------------------------------

Comment(by jdemeyer):

 One can actually a speedup of more than a factor 10 by using PARI:

 The following function converts a polynomial over a number field to a PARI
 object:
 {{{
 def nfpol_to_pari(f):
     return pari([c._pari_('a') for c in f.list()]).Polrev()
 }}}

 Now let's try your example:
 {{{
 sage: K=QQ[I][x]
 sage: f=K.random_element(1500)
 sage: g=K.random_element(1500)
 sage: %time _ = f._mul_generic(g)
 CPU times: user 3.57 s, sys: 0.00 s, total: 3.57 s
 Wall time: 3.59 s
 sage: %time _ = f._mul_karatsuba(g)
 CPU times: user 5.06 s, sys: 0.05 s, total: 5.11 s
 Wall time: 5.12 s
 sage: fpari = nfpol_to_pari(f)
 sage: gpari = nfpol_to_pari(g)
 sage: %time _ = fpari*gpari
 CPU times: user 0.26 s, sys: 0.00 s, total: 0.26 s
 Wall time: 0.26 s
 }}}

 Since PARI is written completely in C, it's obvious why one could expect
 such a speedup.  Obviously, writing specialized code to deal with number
 field polynomials would even be better.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/10255#comment:8>
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