#6870: [with second patch, needs work] Bug in binomial
------------------------------+---------------------------------------------
Reporter: hgranath | Owner: somebody
Type: defect | Status: new
Priority: minor | Milestone: sage-4.1.2
Component: basic arithmetic | Keywords: binomial
Reviewer: | Author:
Merged: |
------------------------------+---------------------------------------------
Comment(by kcrisman):
No, we should be able to compute the second type too, so don't jettison
that. But can't you combine the two? Checking type is not so bad to do,
and then you can still always try to coerce later. After all, at the
bottom there is a special case check for reals and floats. So maybe you
could do something like
{{{
if isinstance(m or x-m,whatever.rational):
convert to integer if possible
}}}
I did check, and the slowdown for symbolic ones is because of that check.
Checking for an instance takes about 1/10 the time.
{{{
sage: def f():
....: try:
....: m=ZZ(a)
....: except:
....: pass
....:
sage: timeit('f()')
625 loops, best of 3: 34.4 µs per loop
sage: def g():
....: isinstance(a,(int,long,Integer))
....:
sage: timeit('g()')
625 loops, best of 3: 2.57 µs per loop
}}}
where a = n+1
I guess the point is that we should definitely have as many correct
answers as possible, but that the slowdown should be on these admittedly
unusual cases with rationals, which are less likely to come up than the
usual cases.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/6870#comment:3>
Sage <http://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
-~----------~----~----~----~------~----~------~--~---