#19826: Remove default random_element from Groups
-------------------------------------+-------------------------------------
Reporter: tscrim | Owner: tscrim
Type: defect | Status: positive_review
Priority: major | Milestone: sage-7.0
Component: group theory | Resolution:
Keywords: | Merged in:
Authors: Travis Scrimshaw | Reviewers: Vincent Delecroix
Report Upstream: N/A | Work issues:
Branch: | Commit:
public/groups/remove_default_random_element-19826|
bc05028b165c8b9e0251170f16a4a8890e425f1c
Dependencies: | Stopgaps:
-------------------------------------+-------------------------------------
Changes (by vdelecroix):
* status: needs_review => positive_review
* reviewer: => Vincent Delecroix
Comment:
I would not claim that the `random_element` from category is much
better... it calls `unrank` which in the case of `CoxeterGroup` is just
the default one
{{{
def urank(self, r):
counter = 0
for u in self:
if counter == r:
return u
counter += 1
raise ValueError
}}}
But there is a trick! If you call `W.list()` it magically switches to
`_unrank_from_list`. See the difference
{{{
sage: W = CoxeterGroup(['D',4])
sage: %timeit W.random_element()
1 loops, best of 3: 403 ms per loop
sage: l = W.list()
sage: %timeit W.random_element()
100000 loops, best of 3: 5.28 µs per loop
}}}
--
Ticket URL: <http://trac.sagemath.org/ticket/19826#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 https://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.