diff options
author | Tim Peters <tim.peters@gmail.com> | 2002-08-12 06:17:58 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2002-08-12 06:17:58 (GMT) |
commit | 44121a6bc9828c993932b87e442440dc4f260f3c (patch) | |
tree | 9d8be85c1b84bbf7104fb9e0df6cbf2f347725a5 /Include/cellobject.h | |
parent | 877a2126786bd2a8e5086fbddb05a593c40cbc51 (diff) | |
download | cpython-44121a6bc9828c993932b87e442440dc4f260f3c.zip cpython-44121a6bc9828c993932b87e442440dc4f260f3c.tar.gz cpython-44121a6bc9828c993932b87e442440dc4f260f3c.tar.bz2 |
x_mul(): This failed to normalize its result.
k_mul(): This didn't allocate enough result space when one input had
more than twice as many bits as the other. This was partly hidden by
that x_mul() didn't normalize its result.
The Karatsuba recurrence is pretty much hosed if the inputs aren't
roughly the same size. If one has at least twice as many bits as the
other, we get a degenerate case where the "high half" of the smaller
input is 0. Added a special case for that, for speed, but despite that
it helped, this can still be much slower than the "grade school" method.
It seems to take a really wild imbalance to trigger that; e.g., a
2**22-bit input times a 1000-bit input on my box runs about twice as slow
under k_mul than under x_mul. This still needs to be addressed.
I'm also not sure that allocating a->ob_size + b->ob_size digits is
enough, given that this is computing k = (ah+al)*(bh+bl) instead of
k = (ah-al)*(bl-bh); i.e., it's certainly enough for the final result,
but it's vaguely possible that adding in the "artificially" large k may
overflow that temporarily. If so, an assert will trigger in the debug
build, but we'll probably compute the right result anyway(!).
Diffstat (limited to 'Include/cellobject.h')
0 files changed, 0 insertions, 0 deletions