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
-
Constructor Summary
Constructors Constructor Description Utils()
-
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 -
-
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 searchtarget
- 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 matrixexact
- 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 matrixexact
- 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
-
-
-
-