Package jline.util

Class Utils

  • All Implemented Interfaces:

    
    public class Utils
    
                        

    Miscellaneous utilities

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      public class Utils.MapeResult

      Container class for MAPE calculation results

    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      Utils()
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      static int findString(Map<Integer, String> map, String target) Finds the key corresponding to a target string value in a map.
      static boolean isInf(double val) Checks if a value represents infinity.
      static double mape(Matrix approx, Matrix exact) Return mean absolute percentage error of approx with respect to exact
      static Utils.MapeResult mapeWithNanMean(Matrix approx, Matrix exact) Polymorphic version that returns both MAPE and nanMean.
      static <T extends Object> List<T> unique(List<T> list)
      static String doubleArrayToString(Array<double> array) Convert double array to string representation
      static Array<int> parseIntArray(String str) Parse integer array from string representation
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Utils

        Utils()
    • Method Detail

      • findString

         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

         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

         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

         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

      • doubleArrayToString

         static String doubleArrayToString(Array<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

         static Array<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