#3436: random_matrix() with prescribed density buggy
------------------------------+---------------------------------------------
Reporter: rpw | Owner: was
Type: defect | Status: needs_work
Priority: major | Milestone: sage-4.3.1
Component: linear algebra | Keywords:
Work_issues: | Author: spancratz
Upstream: N/A | Reviewer:
Merged: |
------------------------------+---------------------------------------------
Comment(by spancratz):
I've now finished the implementation, but I still need to re-base it.
Here are some timings. First, the old implementation:
{{{
sage: MS = MatrixSpace(CyclotomicField(10), 100, 100)
sage: timeit('A = MS.random_element()')
25 loops, best of 3: 17.5 ms per loop
sage: timeit('A = MS.random_element(density=0.1)')
25 loops, best of 3: 8.89 ms per loop
sage: A = MS.random_element(density=0.1)
sage: n(len(A.nonzero_positions())/10000)
0.231700000000000
}}}
Second, the new implementation:
{{{
sage: MS = MatrixSpace(CyclotomicField(10), 100, 100)
sage: timeit('A = MS.random_element()')
25 loops, best of 3: 22 ms per loop
sage: timeit('A = MS.random_element(density=0.1)')
25 loops, best of 3: 9.36 ms per loop
sage: timeit('A = MS.random_element(density=0.1, nonzero=True)')
25 loops, best of 3: 9.35 ms per loop
sage: timeit('A = MS.random_element(density=0.1, nonzero=False)')
25 loops, best of 3: 9.37 ms per loop
sage: A = MS.random_element(density=0.1, nonzero=True)
sage: n(len(A.nonzero_positions())/10000)
0.0963000000000000
}}}
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/3436#comment:17>
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.