Class LogFactorial
java.lang.Object
org.apache.commons.numbers.combinatorics.LogFactorial
public class LogFactorial
extends java.lang.Object
Class for computing the natural logarithm of the factorial of a number.
It allows to allocate a cache of precomputed values.
In case of cache miss, computation is performed by a call to
LogGamma.value(double).-
Method Summary
Modifier and Type Method Description static LogFactorialcreate()Creates an instance with no precomputed values.doublevalue(int n)Computes \( log_e(n!) \).LogFactorialwithCache(int cacheSize)Creates an instance with the specified cache size.
-
Method Details
-
create
Creates an instance with no precomputed values.- Returns:
- instance with no precomputed values
-
withCache
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:
java.lang.IllegalArgumentException- ifcacheSize < 0.
-
value
public double value(int n)Computes \( log_e(n!) \).- Parameters:
n- Argument.- Returns:
log(n!).- Throws:
java.lang.IllegalArgumentException- ifn < 0.
-