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

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

[Octave-bug-tracker] [bug #65495] nchoosek error "gcd: all values must b


From: Markus Mützel
Subject: [Octave-bug-tracker] [bug #65495] nchoosek error "gcd: all values must be integers"
Date: Wed, 20 Mar 2024 13:35:47 -0400 (EDT)

Follow-up Comment #12, bug #65495 (group octave):

Re-ordering the multiplications and division like this, leads to the same
result for `nchoosek (1024, 512)` like in Octave 9:

diff -r a79e07f980ff scripts/specfun/nchoosek.m
--- a/scripts/specfun/nchoosek.m        Fri Mar 15 07:24:58 2024 -0400
+++ b/scripts/specfun/nchoosek.m        Wed Mar 20 18:34:14 2024 +0100
@@ -140,11 +140,11 @@
         g1 = gcd (C, i);
         g2 = gcd (v - k + i, i/g1);
         C /= g1;
+        C /= i/(g1 * g2);
         C *= (v - k + i)/g2;
         if (is_int && (C == imax))
           break;  # Stop here; saturation reached.
         endif
-        C /= i/(g1 * g2);
       else
         C *= (v - k + i);
         C /= i;


But that might un-do the precision improvements of Hendrik's change. (I
haven't checked though.)



    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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