[alexandria-devel] COUNT-PERMUTATIONS and SUBFACTORIAL patch

Mason Smith masonium at gmail.com
Tue May 18 05:31:16 UTC 2010


The attached patch addresses two issues:

1. COUNT-PERMUTATIONS now has type-checking and uses %MULTIPLY-RANGE, as was
suggested in the comments.

2. SUBFACTORIAL now produces correct values. Previously, the values returned
were incorrect starting with N = 12 or so. This was because the approximate
value of e, produced by (exp 1), had insufficient precision be used in the [
n! / e ] formula for the subfactorial !n. Changing (exp 1) to (exp1.0d0)
adds precision to e, but the problem still remained for N >= 14 or so. I
reimplemented SUBFACTORIAL using the !n = n! * \sum_{k=0}^k{ \frac{ (-1)^k
}{ k! } } formula to give exact results.

I also added tests for both of these functions.

In the near future, I'd like to open up a review of these functions (as well
as the other combinatorics functions). Nikodemus suggested a couple of
months ago that this should be done, but I wasn't sure if this was limited
to Alexandria's main developers or open to everyone.

Mason
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/alexandria-devel/attachments/20100517/9db514cd/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: combinatorics.patch
Type: application/octet-stream
Size: 2904 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/alexandria-devel/attachments/20100517/9db514cd/attachment.obj>


More information about the alexandria-devel mailing list