[PATCH] Remove unnecessary factorial array
Andreas Jaeger
aj@suse.com
Wed Feb 13 11:39:00 GMT 2013
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
More information about the Libc-alpha
mailing list