#9882: slow random_element() for integer mod ring
-------------------------------+-------------------
       Reporter:  dmharvey     |        Owner:  tbd
           Type:  defect       |       Status:  new
       Priority:  major        |    Milestone:
      Component:  performance  |   Resolution:
       Keywords:               |    Merged in:
        Authors:               |    Reviewers:
Report Upstream:  N/A          |  Work issues:
         Branch:               |       Commit:
   Dependencies:               |     Stopgaps:
-------------------------------+-------------------

Comment (by mmezzarobba):

 Replying to [comment:3 ppurka]:
 > Replying to [comment:2 mmezzarobba]:
 > > But I don't understand where the time goes:
 >
 > All of the time goes in returning an element of the integer mod ring.

 Thanks for your reply, and... sorry for being thick, but I still don't
 understand! I get:
 {{{
 sage: %timeit ZZ.random_element(0, R.order()-1)
 1000000 loops, best of 3: 650 ns per loop
 sage: a = (R.order()-1)
 sage: %timeit R(a)
 1000000 loops, best of 3: 325 ns per loop
 sage: a = (R.order()-1)//2
 sage: %timeit R(a)
 1000000 loops, best of 3: 324 ns per loop
 }}}
 so I would hope for a total running time of the order of 1 µs + some
 overhead for my function, but I get:
 {{{
 sage: %timeit R.random_element()
 100000 loops, best of 3: 3.45 µs per loop
 }}}

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