D.10 Miscellaneous Utilities
The KSL also provides a number of other useful class within the utilities package. The KSLMath
class provides for working with finer levels of numerical precision and has some useful functions for computing factorials and binomial coefficients. In addition, there are functions for converting doubles to other numeric values.
double getDefaultNumericalPrecision()
- returns the default numerical precision that can be expected on the machineboolean equal(double a, double b)
- returns true if the two doubles are equal with respect to the default numerical precisionboolean equal(double a, double b, double precision)
- returns true if the two doubles are equal with respect to the specified precisionboolean within(double a, double b, double precision)
- returns true if the absolute difference between the double is within the specified precisiondouble factorial(int n)
- returns a numerically stable computed value of the factorialdouble binomialCoefficient(int n, int k)
- returns a numerically stable computed value of the binomial coefficientdouble logFactorial(int n)
- returns the natural logarithm of the factorial
The following list may be of interest and lead the reader to further exploration of the details.
GetValueIfc
defines a general function and property to return a valueIdentityIfc
a general interface to ensure that an implementer have an identity and a name.Interval
is useful to representing an inclusive real-valued interval such as a confidence interval.PreviousValueIfc
allows an implementer to remember and return the previous value.KSLMaps
hold utility functions for making maps from arrays, flattening maps of maps, unflattening maps, and converting maps to JSON.utilities.rootfinding
This package has an implementation for finding the root of a function via binary searchutilities.observers
has base classes for implementing and using components that implement the observer pattern.