This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Remove unnecessary factorial array
- From: Andreas Jaeger <aj at suse dot com>
- To: libc-alpha at sourceware dot org
- Cc: Siddhesh Poyarekar <siddhesh at redhat dot com>
- Date: Wed, 13 Feb 2013 12:38:56 +0100
- Subject: Re: [PATCH] Remove unnecessary factorial array
- References: <20130213111349.GS15748@spoyarek.pnq.redhat.com>
On Wednesday, February 13, 2013 16:43:49 Siddhesh Poyarekar wrote:
> Hi,
>
> I just realized that in the mpexp fix I just committed, the nfa array
> I had created to store factorials of values in the np1 array is
> unnecessary. After computation of the following polynomial loop:
>
> double kf = 1.0;
>
> /* Evaluate the rest. The result will be in mpt2. */
> for (k = n - 1; k > 0; k--)
> {
> /* n! / k! = n * (n - 1) ... * (n - k + 1) */
> kf *= k + 1;
>
> __dbl_mp (kf, &mpk, p);
> __add (&mpt2, &mpk, &mpt1, p);
> __mul (&mps, &mpt1, &mpt2, p);
> }
>
> kf is in fact n!. Attached patch removes the static variable and uses
> kf instead. No regressions observed in the testsuite due to this.
> OK to commit?
Yes, this is fine - but please change the comment "n! is pre-computed",
it's wrong now,
Andreas
--
Andreas Jaeger aj@{suse.com,opensuse.org} Twitter/Identica: jaegerandi
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn,Jennifer Guild,Felix Imendörffer,HRB16746 (AG Nürnberg)
GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126