guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

logcount bignum negatives optimization


From: Kevin Ryde
Subject: logcount bignum negatives optimization
Date: Thu, 22 May 2003 10:39:55 +1000
User-agent: Gnus/5.090019 (Oort Gnus v0.19) Emacs/21.2 (gnu/linux)

The zeros count for logcount on negatives can be done with mpz_hamdist
by passing -1 for the second operand.  This saves initializing and
clearing a temporary mpz_t.

        * numbers.c (z_negative_one): New variable.
        (scm_init_numbers): Initialize it.
        (scm_logcount): Use it and mpz_hamdist to count zeros for negatives.

        * tests/numbers.test (logcount): More tests.

I haven't changed the positive case, except to put it first and to
share the scm_remember_upto, but a few tests of that won't go astray.

Attachment: numbers.c.logcount.diff
Description: Text document

Attachment: numbers.test.logcount.diff
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]