#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):
The following implementation of `R.random_element()` is 30-40% faster than
the existing one (and correctly uses the uniform distribution, according
to the docstring of `ZZ.random_element()`):
{{{
def random_element(self, bound=None):
if bound is None:
return self(ZZ.random_element(0, self.__order-1))
else:
return commutative_ring.CommutativeRing.random_element(self,
bound)
}}}
6.2.beta4:
{{{
sage: %timeit R.random_element()
100000 loops, best of 3: 5.67 µs per loop
}}}
With patch:
{{{
sage: %timeit R.random_element()
100000 loops, best of 3: 3.53 µs per loop
}}}
But I don't understand where the time goes:
{{{
sage: foo = None
sage: %timeit if foo is None: ZZ.random_element(0, R.order()-1)
1000000 loops, best of 3: 809 ns per loop
}}}
--
Ticket URL: <http://trac.sagemath.org/ticket/9882#comment:2>
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.