Class MathUtil

java.lang.Object
org.jgrapht.util.MathUtil

public class MathUtil extends Object
Math Utilities.
Author:
Assaf Lehr
  • Method Summary

    Modifier and Type
    Method
    Description
    static long
    factorial(int n)
    Calculate the factorial of $n$.
    static int
    log2(int n)
    Calculate the floor of the binary logarithm of $n$.
    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.
    static double[]
    vectorSum(double[] a, double[] b)
    Compute the element-wise sum of two vectors.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 vector
      b - 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 vector
      b - 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