wangtongada / gmpy

Automatically exported from code.google.com/p/gmpy
GNU Lesser General Public License v3.0
0 stars 0 forks source link

patch: mpz_bitcount, faster mpmath_normalize #21

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
In the attached patch there is mpz_bitcount, which is an optimized version 
of bit_length which accepts only mpz; in mpmath bitcount has almost always
mpz as argument, so this provides some speedup. Another speedup
comes optimizing input processing in mpmath_normalize.
In issue 94 in http://groups.google.com/group/mpmath-issues
there is a patch to libmpf.py to be used with this patch.
The speedup in runtests is 5% on my Athlon XP 2600.

Original issue reported on code.google.com by mario.pe...@gmail.com on 13 Jan 2009 at 12:14

Attachments:

GoogleCodeExporter commented 8 years ago
Added exception handling when mpmath_normalize has wrong number of arguments.
Now mpmath is predisposed for using bitcount1 = gmpy.mpz_bitcount

Original comment by mario.pe...@gmail.com on 13 Jan 2009 at 5:36

Attachments:

GoogleCodeExporter commented 8 years ago
Thanks for patches. I did change the name to _mpmath_bitcount. You had that 
name in
the doc string, too. I didn't want to cause any confusion with bit_length. I 
should
have the patches committed later this evening.

We would like to release gmpy 1.04 within a few days. Are you working on other 
patches?

Original comment by casevh on 14 Jan 2009 at 6:13

GoogleCodeExporter commented 8 years ago
Sorry I didn't answer before; I didn't see the last line of your message.
I am translating the basic arithmetic operations in libmpf.

Original comment by mario.pe...@gmail.com on 22 Jan 2009 at 5:13

GoogleCodeExporter commented 8 years ago
In this patch there is a bug fix for _mpmath_bitcount for the case of n=0, 
see issue 94 in mpmath.

Original comment by mario.pe...@gmail.com on 23 Jan 2009 at 7:44

Attachments:

GoogleCodeExporter commented 8 years ago
In issue 94 of mpmath Fredrik suggested to drop _mpmath_bitcount, optimizing
instead bit_length. Indeed it can be optimized; I put there a version of
bit_length which is only 4% slower than _mpmath_bitcount; I would like to work
on this a bit before submitting it here, but anyway, I am in favour of dropping
_mpmath_bitcount.

Original comment by mario.pe...@gmail.com on 25 Jan 2009 at 10:01