#3309: massively optimize the binomial function when an input is real or complex
floating point
------------------------------+---------------------------------------------
Reporter: was | Owner: somebody
Type: enhancement | Status: new
Priority: major | Milestone: sage-3.4.2
Component: basic arithmetic | Keywords:
------------------------------+---------------------------------------------
Comment(by ddrake):
I'm attaching a patch which uses gamma() when appropriate. We can use this
until we get the fast Pari stuff in. Here are some timings:
{{{
BEFORE
sage: x, y = 1140000.78, 420000
sage: %timeit binomial(x, y)
10 loops, best of 3: 1.03 s per loop
sage: x, y = RR(pi^5), 10
sage: %timeit binomial(x, y)
10000 loops, best of 3: 28.8 µs per loop
sage: x, y = RR(pi^15), 500
sage: %timeit binomial(x, y)
1000 loops, best of 3: 864 µs per loop
sage: x, y = RealField(500)(1729000*sqrt(2)), 17000
sage: %timeit binomial(x, y)
10 loops, best of 3: 35.8 ms per loop
}}}
With the patch:
{{{
AFTER
sage: x, y = 1140000.78, 420000
sage: %timeit binomial(x, y)
1000 loops, best of 3: 302 µs per loop
sage: x, y = RR(pi^5), 10
sage: %timeit binomial(x, y)
10000 loops, best of 3: 188 µs per loop
sage: x, y = RR(pi^15), 500
sage: %timeit binomial(x, y)
1000 loops, best of 3: 362 µs per loop
sage: x, y = RealField(500)(1729000*sqrt(2)), 17000
sage: %timeit binomial(x, y)
1000 loops, best of 3: 743 µs per loop
}}}
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/3309#comment:3>
Sage <http://sagemath.org/>
Sage - Open Source Mathematical Software: Building the Car Instead of
Reinventing the Wheel
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---