#19824: Faster comparison code in (real embedded) number fields
-----------------------------+-------------------------------------
Reporter: vdelecroix | Owner:
Type: PLEASE CHANGE | Status: new
Priority: major | Milestone: sage-7.0
Component: number fields | Keywords:
Merged in: | Authors: Vincent Delecroix
Reviewers: | Report Upstream: N/A
Work issues: | Branch:
Commit: | Dependencies: #19822
Stopgaps: |
-----------------------------+-------------------------------------
Using #19822 we provide a faster comparison code for number field elements
when real embedding is defined (see #17830). We obtain `x10` speed up. The
new code is also `x50` faster than comparisons in `QQbar` (with a fixed
number field element!!). For the benchmarks, we used the following
comparison function
{{{
def test(a,n):
cf = continued_fraction(a)
cv1 = a.parent()(cf.convergent(2*n+1))
cv2 = a.parent()(cf.convergent(2*n+2))
for _ in range(200):
assert cv1 > a > cv2
}}}
Before
{{{
sage: x = polygen(ZZ)
sage: K.<a> = NumberField(x^3 - 2, embedding=1.26)
sage: sage: %timeit test(a,10)
10 loops, best of 3: 51.1 ms per loop
sage: sage: %timeit test(a,20)
10 loops, best of 3: 67 ms per loop
sage: sage: %timeit test(a,100)
10 loops, best of 3: 108 ms per loop
sage: sage: %timeit test(a,200)
1 loops, best of 3: 154 ms per loop
}}}
after
{{{
sage: x = polygen(ZZ)
sage: K.<a> = NumberField(x^3 - 2, embedding=1.26)
sage: sage: sage: %timeit test(a,10)
100 loops, best of 3: 5.84 ms per loop
sage: sage: sage: %timeit test(a,20)
100 loops, best of 3: 10.2 ms per loop
sage: sage: sage: %timeit test(a,100)
10 loops, best of 3: 33.5 ms per loop
sage: sage: sage: %timeit test(a,200)
10 loops, best of 3: 64.8 ms per loop
}}}
To be compared with
{{{
sage: a = AA(2)**(1/3)
sage: a.exactify()
sage: sage: %timeit test(a,10)
10 loops, best of 3: 97.7 ms per loop
sage: sage: %timeit test(a,20)
10 loops, best of 3: 133 ms per loop
sage: sage: %timeit test(a,100)
1 loops, best of 3: 224 ms per loop
sage: sage: %timeit test(a,200)
1 loops, best of 3: 305 ms per loop
}}}
--
Ticket URL: <http://trac.sagemath.org/ticket/19824>
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.