D.9 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.
GetValueIfcdefines a general function and property to return a valueIdentityIfca general interface to ensure that an implementer have an identity and a name.Intervalis useful to representing an inclusive real-valued interval such as a confidence interval.PreviousValueIfcallows an implementer to remember and return the previous value.KSLMapshold utility functions for making maps from arrays, flattening maps of maps, unflattening maps, and converting maps to JSON.utilities.rootfindingThis package has an implementation for finding the root of a function via binary searchutilities.observershas base classes for implementing and using components that implement the observer pattern.