#9054: create a class for basic function_field arithmetic for Sage
---------------------------------------------------------------------------------+
Reporter: was
| Owner: was
Type: enhancement
| Status: new
Priority: major
| Milestone: sage-wishlist
Component: algebra
| Resolution:
Keywords:
| Work_issues:
Upstream: N/A
| Reviewer:
Author: William Stein, Robert Bradshaw, Maarten Derickx, Moritz Minzlaff
| Merged:
Dependencies: #9094, #11034
|
---------------------------------------------------------------------------------+
Comment(by SimonKing):
Time for a little advertisement: I obtain a much improved performance with
#10667 (introducing the class of objects and morphisms of a category,
written in Cython). Perhaps it is useful for you?
'''__Testing commutative rings__'''
The function `is_CommutativeRing` does nothing but testing the class. But
it is a Python function. Let us compare its speed with the speed of a
Cython container, testing category containment.
`is_CommutativeRing`:
{{{
sage: from sage.rings.commutative_ring import is_CommutativeRing
sage: is_CommutativeRing??
...
Source:
def is_CommutativeRing(R):
return isinstance(R, CommutativeRing)
sage: is_CommutativeRing(QQ)
True
sage: s = SymmetricGroup(4)
sage: is_CommutativeRing(s)
False
sage: %timeit is_CommutativeRing(QQ)
625 loops, best of 3: 1.09 µs per loop
sage: %timeit is_CommutativeRing(s)
625 loops, best of 3: 3.51 µs per loop
}}}
Cython container:
{{{
sage: O = CommutativeRings().objects()
sage: QQ in O
True
sage: s in O
False
sage: %timeit QQ in O
625 loops, best of 3: 1.5 µs per loop
sage: %timeit s in O
625 loops, best of 3: 1.46 µs per loop
}}}
Hence, when applied to a symmetric group, the container performs a
category containment test (with negative result, of course) that is
''faster'' than a Python class check!
'''__Testing rings__'''
As you have observed, the current `is_Ring` function is suboptimal. I
rewrote it in #10667.
Without #10667 (but with #11115 for a fast cache):
{{{
sage: from sage.rings.ring import is_Ring
sage: MS = MatrixSpace(QQ,2)
sage: %timeit is_Ring(QQ)
625 loops, best of 3: 5.1 µs per loop
sage: is_Ring(MS)
True
sage: %timeit is_Ring(MS)
625 loops, best of 3: 17.3 µs per loop
sage: C = Rings()
sage: %timeit QQ in C
625 loops, best of 3: 4.18 µs per loop
sage: %timeit MS in C
625 loops, best of 3: 4.31 µs per loop
}}}
With #10667 in addition:
{{{
sage: from sage.rings.ring import is_Ring
sage: MS = MatrixSpace(QQ,2)
sage: %timeit is_Ring(QQ)
625 loops, best of 3: 259 ns per loop
sage: %timeit is_Ring(MS)
625 loops, best of 3: 17.5 µs per loop
sage: C = Rings().objects()
sage: %timeit QQ in C
625 loops, best of 3: 1.49 µs per loop
sage: %timeit MS in C
625 loops, best of 3: 1.57 µs per loop
}}}
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/9054#comment:47>
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.