Class DoubleFactorialEstimator

java.lang.Object
com.irurueta.numerical.DoubleFactorialEstimator

public class DoubleFactorialEstimator extends Object
Estimates factorial values as double precision floating point values.
  • Field Details

    • CACHE_SIZE

      public static final int CACHE_SIZE
      Cache size for factorial values that can be represented without overflowing with double precision. Values up to 170! are representable, 171! overflows.
      See Also:
    • cache

      private final double[] cache
      Cache of values.
  • Constructor Details

    • DoubleFactorialEstimator

      public DoubleFactorialEstimator()
      Constructor with default cache size.
    • DoubleFactorialEstimator

      public DoubleFactorialEstimator(int cacheSize)
      Constructor.
      Parameters:
      cacheSize - size of cache.
      Throws:
      IllegalArgumentException - if provided value is less than 1 or exceeds 171.
  • Method Details

    • getCacheSize

      public int getCacheSize()
      Gets current cache size.
      Returns:
      cache size.
    • factorial

      public double factorial(int value)
      Gets factorial of provided value represented with double precision.
      Parameters:
      value - value to compute factorial for.
      Returns:
      computed factorial value.
      Throws:
      IllegalArgumentException - if provided value exceeds cache size.