Package com.irurueta.numerical
Class DoubleFactorialEstimator
java.lang.Object
com.irurueta.numerical.DoubleFactorialEstimator
Estimates factorial values as double precision floating point values.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final double[]
Cache of values.static final int
Cache size for factorial values that can be represented without overflowing with double precision. -
Constructor Summary
ConstructorsConstructorDescriptionConstructor with default cache size.DoubleFactorialEstimator
(int cacheSize) Constructor. -
Method Summary
Modifier and TypeMethodDescriptiondouble
factorial
(int value) Gets factorial of provided value represented with double precision.int
Gets current cache size.
-
Field Details
-
CACHE_SIZE
public static final int CACHE_SIZECache 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[] cacheCache 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.
-