This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Remove unnecessary factorial array


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]