java.lang.Object
org.jgrapht.util.MathUtil
Math Utilities.
- Author:
- Assaf Lehr
-
Method Summary
Modifier and TypeMethodDescriptionstatic longfactorial(int n) Calculate the factorial of $n$.static intlog2(int n) Calculate the floor of the binary logarithm of $n$.static booleanvectorDominates(double[] a, double[] b) Return whether a vector dominates another, i.e. whether it is less than or equal to the other vector in all components and strictly less in at least one component.static double[]vectorSum(double[] a, double[] b) Compute the element-wise sum of two vectors.
-
Method Details
-
factorial
public static long factorial(int n) Calculate the factorial of $n$.- Parameters:
n- the input number- Returns:
- the factorial
-
vectorSum
public static double[] vectorSum(double[] a, double[] b) Compute the element-wise sum of two vectors. The two vectors must have the same length.- Parameters:
a- the first vectorb- the second vector- Returns:
- the sum of the two vectors
-
vectorDominates
public static boolean vectorDominates(double[] a, double[] b) Return whether a vector dominates another, i.e. whether it is less than or equal to the other vector in all components and strictly less in at least one component. The two vectors must have the same length.- Parameters:
a- the first vectorb- the second vector- Returns:
- true if the first vector dominates the second
-
log2
public static int log2(int n) Calculate the floor of the binary logarithm of $n$.- Parameters:
n- the input number- Returns:
- the binary logarithm
-