Package jline.util

Class Utils

java.lang.Object
jline.util.Utils

public class Utils extends Object
Miscellaneous utilities
  • Constructor Details

    • Utils

      public Utils()
  • Method Details

    • findString

      public static int findString(Map<Integer,String> map, String target)
      Finds the key corresponding to a target string value in a map.
      Parameters:
      map - the map to search
      target - the string value to find
      Returns:
      the key associated with the target value, or 0 if not found
    • isInf

      public static boolean isInf(double val)
      Checks if a value represents infinity. Considers Double infinity and integer limit values as infinite.
      Parameters:
      val - the value to check
      Returns:
      true if the value represents infinity, false otherwise
    • mape

      public static double mape(Matrix approx, Matrix exact)
      Return mean absolute percentage error of approx with respect to exact
      Parameters:
      approx - The approximate values matrix
      exact - The exact values matrix
      Returns:
      The mean absolute percentage error as a percentage
    • mapeWithNanMean

      public static Utils.MapeResult mapeWithNanMean(Matrix approx, Matrix exact)
      Polymorphic version that returns both MAPE and nanMean. Calculates mean absolute percentage error and handles NaN/zero values appropriately.
      Parameters:
      approx - The approximate values matrix
      exact - The exact values matrix
      Returns:
      MapeResult containing MAPE, nanMean, and count of valid comparisons
    • unique

      public static <T> List<T> unique(List<T> list)
    • doubleArrayToString

      public static String doubleArrayToString(double[] array)
      Convert double array to string representation
      Parameters:
      array - The double array to convert
      Returns:
      String representation in format [1.0,2.0,3.0]
    • parseIntArray

      public static int[] parseIntArray(String str)
      Parse integer array from string representation
      Parameters:
      str - String representation in format [1,2,3] or 1,2,3
      Returns:
      Parsed integer array