public class NumberUtil
extends java.lang.Object
| Constructor and Description |
|---|
NumberUtil() |
| Modifier and Type | Method and Description |
|---|---|
static double |
Bound(double dblX,
double dblFloor,
double dblCeiling)
Bound the input to within (floor, Ceiling), i.e., compute Min (Max (floor, X), Ceiling)
|
static int |
Factorial(int n)
This function implements Factorial N.
|
static boolean |
IsValid(double dbl)
Checks if the input double is Infinite or NaN
|
static boolean |
IsValid(double[] adbl)
Checks if the input double array contains an Infinite or an NaN
|
static double |
Maximum(double[] adbl)
Retrieve the Maximum Element in the specified Array
|
static double |
Minimum(double[] adbl)
Retrieve the Minimum Element in the specified Array
|
static int |
NCK(int n,
int k)
This function implements N choose K.
|
static int |
NPK(int n,
int k)
This function implements N Permute K.
|
static boolean |
Print1DArray(java.lang.String strName,
double[] adblA,
boolean bBailOnNaN)
Print the contents of the 1D array
|
static boolean |
Print1DArray(java.lang.String strName,
double[] adblA,
int iNumDecimal,
boolean bBailOnNaN)
Print the contents of the 1D array to the Specified Decimal Location
|
static boolean |
Print2DArray(java.lang.String strName,
double[][] aadblA,
boolean bBailOnNaN)
Print the contents of the 2D array
|
static boolean |
Print2DArrayPair(java.lang.String strLeftLabel,
java.lang.String strRightLabel,
double[][] aadblLeft,
double[][] aadblRight,
boolean bBailOnNaN)
Print the Contents of the 2D Array Pair
|
static boolean |
Print2DArrayTriplet(java.lang.String strLeftLabel,
java.lang.String strMiddleLabel,
java.lang.String strRightLabel,
double[][] aadblLeft,
double[][] aadblMiddle,
double[][] aadblRight,
boolean bBailOnNaN)
Print the Contents of the 2D Array Triplet
|
static boolean |
PrintMatrix(java.lang.String strName,
double[][] aadblA) |
static boolean |
SameSign(double[] adbl)
Check if the specified array contains elements all of the same sign
|
static boolean |
WithinTolerance(double dbl1,
double dbl2)
Compare and checks if the two input numbers fall within a specified tolerance
|
static boolean |
WithinTolerance(double dbl1,
double dbl2,
double dblAbsoluteTolerance,
double dblRelativeTolerance)
Compare and checks if the two input numbers fall within a specified tolerance
|
public static final boolean IsValid(double dbl)
dbl - Input doublepublic static final boolean IsValid(double[] adbl)
adbl - Input double arraypublic static final boolean WithinTolerance(double dbl1,
double dbl2,
double dblAbsoluteTolerance,
double dblRelativeTolerance)
dbl1 - Number #1dbl2 - Number #2dblAbsoluteTolerance - Absolute TolerancedblRelativeTolerance - Relative Tolerancepublic static final boolean WithinTolerance(double dbl1,
double dbl2)
dbl1 - Number #1dbl2 - Number #2public static final int Factorial(int n)
n - Npublic static final int NPK(int n,
int k)
n - Nk - Kpublic static final int NCK(int n,
int k)
n - Nk - Kpublic static final double Bound(double dblX,
double dblFloor,
double dblCeiling)
throws java.lang.Exception
dblX - Input NumberdblFloor - FloordblCeiling - Ceilingjava.lang.Exception - Thrown if the inputs are invalidpublic static final double Minimum(double[] adbl)
throws java.lang.Exception
adbl - Array of elementsjava.lang.Exception - Thrown if the Inputs are invalidpublic static final double Maximum(double[] adbl)
throws java.lang.Exception
adbl - Array of elementsjava.lang.Exception - Thrown if the Inputs are invalidpublic static final boolean SameSign(double[] adbl)
throws java.lang.Exception
adbl - Array of elementsjava.lang.Exception - Thrown if the Inputs are invalidpublic static final boolean Print1DArray(java.lang.String strName,
double[] adblA,
boolean bBailOnNaN)
strName - Label NameadblA - The 1D arraybBailOnNaN - Bail on encountering an NaNpublic static final boolean Print1DArray(java.lang.String strName,
double[] adblA,
int iNumDecimal,
boolean bBailOnNaN)
strName - Label NameadblA - The 1D arrayiNumDecimal - Number of Decimal Places to DisplaybBailOnNaN - Bail on encountering an NaNpublic static final boolean Print2DArray(java.lang.String strName,
double[][] aadblA,
boolean bBailOnNaN)
strName - Label NameaadblA - The 2D arraybBailOnNaN - Bail on encountering an NaNpublic static final boolean Print2DArrayPair(java.lang.String strLeftLabel,
java.lang.String strRightLabel,
double[][] aadblLeft,
double[][] aadblRight,
boolean bBailOnNaN)
strLeftLabel - Left LabelstrRightLabel - Right LabelaadblLeft - The Left 2D arrayaadblRight - The Right 2D arraybBailOnNaN - Bail on encountering an NaNpublic static final boolean Print2DArrayTriplet(java.lang.String strLeftLabel,
java.lang.String strMiddleLabel,
java.lang.String strRightLabel,
double[][] aadblLeft,
double[][] aadblMiddle,
double[][] aadblRight,
boolean bBailOnNaN)
strLeftLabel - Left LabelstrMiddleLabel - Middle LabelstrRightLabel - Right LabelaadblLeft - The Left 2D arrayaadblMiddle - The Middle 2D arrayaadblRight - The Right 2D arraybBailOnNaN - Bail on encountering an NaNpublic static final boolean PrintMatrix(java.lang.String strName,
double[][] aadblA)