/** * Finds max value for an array of doubles (NaNs are ignored). If all values in the array * are NaNs, NaN is returned. * * @param values Array of double values * @return max value in the array (NaNs are ignored) */ public static double max(double[] values) { double max = Double.NaN; for (double value : values) { max = Util.max(max, value); } return max; }
/** * Finds max value for an array of doubles (NaNs are ignored). If all values in the array * are NaNs, NaN is returned. * * @param values Array of double values * @return max value in the array (NaNs are ignored) */ public static double max(double[] values) { double max = Double.NaN; for (double value : values) { max = Util.max(max, value); } return max; }
double getMaxValue() { return Util.max(values); } }
double getMaxValue() { return Util.max(values); } }
Aggregates getAggregates(long tStart, long tEnd) { Aggregates agg = new Aggregates(); long totalSeconds = 0; boolean firstFound = false; for (int i = 0; i < timestamps.length; i++) { long left = Math.max(timestamps[i] - step, tStart); long right = Math.min(timestamps[i], tEnd); long delta = right - left; // delta is only > 0 when the timestamp for a given buck is within the range of tStart and tEnd if (delta > 0) { double value = values[i]; agg.min = Util.min(agg.min, value); agg.max = Util.max(agg.max, value); if (!firstFound) { agg.first = value; firstFound = true; agg.last = value; } else if (delta >= step) { // an entire bucket is included in this range agg.last = value; } if (!Double.isNaN(value)) { agg.total = Util.sum(agg.total, delta * value); totalSeconds += delta; } } } agg.average = totalSeconds > 0 ? (agg.total / totalSeconds) : Double.NaN; return agg; }
if (pe instanceof SourcedPlotElement) { minval = Util.min(((SourcedPlotElement) pe).getMinValue(), minval); maxval = Util.max(((SourcedPlotElement) pe).getMaxValue(), maxval);
if (pe instanceof SourcedPlotElement) { minval = Util.min(((SourcedPlotElement) pe).getMinValue(), minval); maxval = Util.max(((SourcedPlotElement) pe).getMaxValue(), maxval);
private void accumulate(ArcState state, double value) throws IOException { if (Double.isNaN(value)) { state.setNanSteps(state.getNanSteps() + 1); } else { switch (consolFun.get()) { case MIN: state.setAccumValue(Util.min(state.getAccumValue(), value)); break; case MAX: state.setAccumValue(Util.max(state.getAccumValue(), value)); break; case FIRST: if (Double.isNaN(state.getAccumValue())) { state.setAccumValue(value); } break; case LAST: state.setAccumValue(value); break; case AVERAGE: case TOTAL: state.setAccumValue(Util.sum(state.getAccumValue(), value)); break; } } }
private void accumulate(ArcState state, double value) throws IOException { if (Double.isNaN(value)) { state.setNanSteps(state.getNanSteps() + 1); } else { switch (ConsolFun.valueOf(consolFun.get())) { case MIN: state.setAccumValue(Util.min(state.getAccumValue(), value)); break; case MAX: state.setAccumValue(Util.max(state.getAccumValue(), value)); break; case LAST: state.setAccumValue(value); break; case AVERAGE: case TOTAL: state.setAccumValue(Util.sum(state.getAccumValue(), value)); break; } } }