This is an automated email from the ASF dual-hosted git repository.

aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-rng.git

commit 30342e9d596fa3d46545f8a511fe32189285a948
Author: Alex Herbert <[email protected]>
AuthorDate: Tue Apr 14 16:01:44 2026 +0100

    Remove unused logFactorial method
---
 .../rng/sampling/distribution/InternalUtils.java    | 16 +---------------
 .../sampling/distribution/InternalUtilsTest.java    | 21 +++++----------------
 2 files changed, 6 insertions(+), 31 deletions(-)

diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InternalUtils.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InternalUtils.java
index 471c6ad5..8e150d09 100644
--- 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InternalUtils.java
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InternalUtils.java
@@ -27,11 +27,7 @@ import org.apache.commons.rng.sampling.SharedStateSampler;
  */
 final class InternalUtils {
     /** All long-representable factorials, precomputed as the natural
-     * logarithm using Matlab R2023a VPA: log(vpa(x)).
-     *
-     * <p>Note: This table could be any length. Previously this stored
-     * the long value of n!, not log(n!). Using the previous length
-     * maintains behaviour. */
+     * logarithm using Matlab R2023a VPA: log(vpa(x)). */
     private static final double[] LOG_FACTORIALS = {
         0,
         0,
@@ -68,16 +64,6 @@ final class InternalUtils {
     /** Utility class. */
     private InternalUtils() {}
 
-    /**
-     * @param n Argument.
-     * @return {@code n!}
-     * @throws IndexOutOfBoundsException if the result is too large to be 
represented
-     * by a {@code long} (i.e. if {@code n > 20}), or {@code n} is negative.
-     */
-    static double logFactorial(int n)  {
-        return LOG_FACTORIALS[n];
-    }
-
     /**
      * Validate the probabilities sum to a finite positive number.
      *
diff --git 
a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/InternalUtilsTest.java
 
b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/InternalUtilsTest.java
index 512468dd..a389ba04 100644
--- 
a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/InternalUtilsTest.java
+++ 
b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/InternalUtilsTest.java
@@ -31,34 +31,23 @@ class InternalUtilsTest {
     private static final int MAX_REPRESENTABLE = 20;
 
     @Test
-    void testFactorial() {
-        Assertions.assertEquals(0L, InternalUtils.logFactorial(0));
+    void testFactorialLogNoCache() {
+        FactorialLog factorialLog = FactorialLog.create();
+        Assertions.assertEquals(0, factorialLog.value(0));
         long result = 1;
         for (int n = 1; n <= MAX_REPRESENTABLE; n++) {
             result *= n;
             final double expected = Math.log(result);
-            Assertions.assertEquals(expected, InternalUtils.logFactorial(n), 
Math.ulp(expected));
+            Assertions.assertEquals(expected, factorialLog.value(n), 
Math.ulp(expected));
         }
     }
 
-    @Test
-    void testFactorialThrowsWhenNegative() {
-        Assertions.assertThrows(IndexOutOfBoundsException.class,
-            () -> InternalUtils.logFactorial(-1));
-    }
-
-    @Test
-    void testFactorialThrowsWhenNotRepresentableAsLong() {
-        Assertions.assertThrows(IndexOutOfBoundsException.class,
-            () -> InternalUtils.logFactorial(MAX_REPRESENTABLE + 1));
-    }
-
     @Test
     void testFactorialLog() {
         // Cache size allows some of the factorials to be cached and some
         // to be under the precomputed factorials.
         FactorialLog factorialLog = 
FactorialLog.create().withCache(MAX_REPRESENTABLE / 2);
-        Assertions.assertEquals(0, factorialLog.value(0), 1e-10);
+        Assertions.assertEquals(0, factorialLog.value(0));
         for (int n = 1; n <= MAX_REPRESENTABLE + 5; n++) {
             // Use Commons math to compute logGamma(1 + n);
             final double expected = Gamma.logGamma(1 + n);

Reply via email to