octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #61300] integer range might exceed upper limit


From: Arun Giridhar
Subject: [Octave-bug-tracker] [bug #61300] integer range might exceed upper limit
Date: Tue, 30 Nov 2021 17:20:30 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0

Follow-up Comment #42, bug #61300 (project octave):

I think the problems are local to nchoosek and not to Range, becuase
nchoosek's heavy use of ranges was done with floating point and not integers,
which round differently.

It's not a regression as such. It's more that the fix to Range in this report
exposes a previously hidden bug in nchoosek.


    119     ## For a ~25% performance boost, multiply values pairwise so
there
    120     ## are fewer elements in do/until loop which is the slow part.
    121     ## Since Odd*Even is guaranteed to be Even, also take out a
factor
    122     ## of 2 from numerator and denominator.
    123     if (rem (k, 2))  # k is odd
    124       numer = [(v-k+1:v-(k+1)/2) .* (v-1:-1:v-(k-1)/2) / 2, v];
    125       denom = [(1:k/2) .* (k-1:-1:(k+1)/2) / 2, k];
    126     else             # k is even
    127       numer = (v-k+1:v-k/2) .* (v:-1:v-k/2+1) / 2;
    128       denom = (1:k/2) .* (k:-1:k/2+1) / 2;
    129     endif



    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?61300>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

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