Class FactorialDouble
- java.lang.Object
-
- org.apache.commons.numbers.combinatorics.FactorialDouble
-
public final class FactorialDouble extends Object
Class for computing the natural logarithm of the factorial of a number. It allows to allocate a cache of precomputed values.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static FactorialDoublecreate()Creates an instance with no precomputed values.doublevalue(int n)Computes the factorial ofn.FactorialDoublewithCache(int cacheSize)Creates an instance with the specified cache size.
-
-
-
Method Detail
-
create
public static FactorialDouble create()
Creates an instance with no precomputed values.- Returns:
- instance with no precomputed values
-
withCache
public FactorialDouble withCache(int cacheSize)
Creates an instance with the specified cache size.- Parameters:
cacheSize- Number of precomputed values of the function.- Returns:
- a new instance where
cacheSizevalues have been precomputed. - Throws:
IllegalArgumentException- ifcacheSize < 0.
-
value
public double value(int n)
Computes the factorial ofn. The result should be small enough to fit into adouble: The largestnfor whichn!does not exceedDouble.MAX_VALUEis 170.Double.POSITIVE_INFINITYis returned forn > 170.- Parameters:
n- Argument.- Returns:
n!- Throws:
IllegalArgumentException- ifn < 0.
-
-