#13196: GL(n, GF(q)).random_element() is way too slow for what it does
--------------------------------------------------------------+-------------
Reporter: Bouillaguet | Owner:
joyner
Type: enhancement | Status:
needs_review
Priority: trivial | Milestone:
sage-5.2
Component: group theory | Resolution:
Keywords: matrix group, finite field, random element | Work issues:
Report Upstream: N/A | Reviewers:
Authors: Charles Bouillaguet | Merged in:
Dependencies: | Stopgaps:
--------------------------------------------------------------+-------------
Changes (by Bouillaguet):
* status: needs_work => needs_review
Old description:
> GL(32, GF(2)).random_element() takes more than 10s, which is ridiculous.
>
> Proposed solution : use simple rejection sampling (i.e. generate a random
> matrix, check if it invertible, if not try again). The result is
> uniformly distributed amongst invertible matrices.
>
> Before patch:
> {{{
> sage: %time GL(64, GF(2)).random_element()
> 5 loops, best of 3: 15.5 s per loop
> }}}
>
> After patch :
> {{{
> sage: %timeit GL(64, GF(2)).random_element()
> 625 loops, best of 3: 929 µs per loop
> }}}
New description:
GL(32, GF(2)).random_element() takes more than 10s, which is ridiculous.
Proposed solution : use simple rejection sampling (i.e. generate a random
matrix, check if it invertible, if not try again). The result is uniformly
distributed amongst invertible matrices.
Before patch:
{{{
sage: %time GL(64, GF(2)).random_element()
5 loops, best of 3: 15.5 s per loop
}}}
After patch :
{{{
sage: %timeit GL(64, GF(2)).random_element()
625 loops, best of 3: 2ms per loop
}}}
--
Comment:
Patch updated. The bug was that my function returned a matrix, instead of
returning an element of the group (basically, it returned g.matrix()
instead of returning g). Fix: coerce the result into the group again. It
takes a bit of time, and there is likely a workaround, but this is better
than nothing.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13196#comment:11>
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.