kcl.waterloo.math
Class Precise
- java.lang.Object
-
- kcl.waterloo.math.Precise
-
public class Precise extends java.lang.Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static java.math.BigDecimal[]cumprod(double[] in)Returns the cumulative sum for a double[] as aBigDecimalstatic java.math.BigDecimal[]cumsum(double[] in)Returns the cumulative sum for a double[] as aBigDecimalstatic java.math.BigDecimaldot(double[] in1, double[] in2)static java.math.BigDecimalfactorial(java.math.BigDecimal n)Returns the factorial as a BigDecimal.static java.math.BigDecimalfactorial(long n)Returns the factorial as a BigDecimal.static java.util.LinkedHashMapgetFactorialTable()static java.math.BigDecimalmean(double[] in)Returns the sumsq for a double[].static java.math.BigDecimalnCk(java.math.BigDecimal n, java.math.BigDecimal k)Accurately returns the binomial (N choose K) as a BigDecimalstatic java.math.BigDecimalnCk(int n, int k)Accurately returns the binomial (N choose K) as a BigDecimalstatic java.math.BigDecimalnCk(long n, long k)Accurately returns the binomial (N choose K) as a BigDecimalstatic voidreset()Resets the internal hashmaps - thus freeing memorystatic java.math.BigDecimalsum(double[] in)Returns the sum for a double[].static java.math.BigDecimalsumsq(double[] in)Returns the sum of squares for a double[] accumulated as aBigDecimal
-
-
-
Method Detail
-
sum
public static java.math.BigDecimal sum(double[] in)
Returns the sum for a double[]. The sum is accumulated as aBigDecimal- Parameters:
in-- Returns:
- a BigDecimal
-
cumsum
public static java.math.BigDecimal[] cumsum(double[] in)
Returns the cumulative sum for a double[] as aBigDecimal- Parameters:
in-- Returns:
- BigDecimal
-
cumprod
public static java.math.BigDecimal[] cumprod(double[] in)
Returns the cumulative sum for a double[] as aBigDecimal- Parameters:
in-- Returns:
- a BigDecimal
-
sumsq
public static java.math.BigDecimal sumsq(double[] in)
Returns the sum of squares for a double[] accumulated as aBigDecimal- Parameters:
in- BigDecimal- Returns:
- `
-
dot
public static java.math.BigDecimal dot(double[] in1, double[] in2)
-
mean
public static java.math.BigDecimal mean(double[] in)
Returns the sumsq for a double[]. The mean is calculated as aBigDecimalbut returned as double- Parameters:
in-- Returns:
- a BigDecimal
-
reset
public static void reset()
Resets the internal hashmaps - thus freeing memory
-
getFactorialTable
public static java.util.LinkedHashMap getFactorialTable()
-
factorial
public static java.math.BigDecimal factorial(long n)
Returns the factorial as a BigDecimal. Forn less than 0returns null. Forn=0,1returns 1. Otherwise returns n!. Once calculated, values of n and n! are stored in a HashMap. Subsequent calls with input n will return the stored value of n!.- Parameters:
n- - type long- Returns:
- n! - type BigDecimal
-
factorial
public static java.math.BigDecimal factorial(java.math.BigDecimal n)
Returns the factorial as a BigDecimal. Forn less than 0returns null. Forn=0,1returns 1. Otherwise returns n! Once calculated, values of n and n! are stored in a HashMap. Subsequent calls with input n will return the stored value of n!.- Parameters:
n- - type BigDecimal- Returns:
- n! - type BigDecimal
-
nCk
public static java.math.BigDecimal nCk(int n, int k)Accurately returns the binomial (N choose K) as a BigDecimal
For k< 0, return ZERO
For k==0 or k ==n return ONE
For k==1 return n
Otherwise returns
n!/((n*k)! k!)
- Parameters:
n- - intk- - int- Returns:
n!/((n*k)! k!)
as a BigDecimal
-
nCk
public static java.math.BigDecimal nCk(long n, long k)Accurately returns the binomial (N choose K) as a BigDecimal
For k< 0, return ZERO
For k==0 or k ==n return ONE
For k==1 return n
Otherwise returns
n!/((n*k)! k!)
- Parameters:
n- - longk- - long- Returns:
n!/((n*k)! k!)
as a BigDecimal
-
nCk
public static java.math.BigDecimal nCk(java.math.BigDecimal n, java.math.BigDecimal k)Accurately returns the binomial (N choose K) as a BigDecimal
For k< 0, return ZERO
For k==0 or k ==n return ONE
For k==1 return n
Otherwise returns
n!/((n*k)! k!)
- Parameters:
n- - BigDecimalk- - BigDecimal- Returns:
n!/((n*k)! k!)
as a BigDecimal
-
-
DMelt 3.0 © DataMelt by jWork.ORG