diff --git a/prism/src/prism/PrismUtils.java b/prism/src/prism/PrismUtils.java index 53a5533f..94bb51e5 100644 --- a/prism/src/prism/PrismUtils.java +++ b/prism/src/prism/PrismUtils.java @@ -213,6 +213,24 @@ public class PrismUtils return doublesAreCloseAbs(d1, d2, epsilonDouble); } + /** + * Return the maximum finite value in a double array, looking at + * those entries with indices given bit the integer iterator. + */ + public static double findMaxFinite(double[] soln, PrimitiveIterator.OfInt indices) + { + double max_v = Double.NEGATIVE_INFINITY; + while (indices.hasNext()) { + int i = indices.nextInt(); + + double v = soln[i]; + if (v < Double.POSITIVE_INFINITY) { + max_v = Double.max(v, max_v); + } + } + return max_v; + } + /** * Format a large integer, represented by a double, as a string. */