@Override public String toString() { return "{"+Misc.showInts(vals)+"}"; }
private int findIndex(int runIdx, double want) { for (int j = 0; j < noffsets; j++) if (Misc.nearlyEquals(timeOffset[runIdx * noffsets + j], want)) return j; return -1; }
@Override public int compareTo(Tracker o) { return Misc.compare(hit+miss, o.hit+o.miss); } }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; if (!super.equals(o)) return false; Mercator that = (Mercator) o; if (!Misc.nearlyEqualsAbs(la1, that.la1, maxReletiveErrorPos * dY)) return false; // allow some slop, reletive to grid size if (!Misc.nearlyEqualsAbs(lo1, that.lo1, maxReletiveErrorPos * dX)) return false; if (!Misc.nearlyEquals(latin, that.latin)) return false; if (!Misc.nearlyEquals(dY, that.dY)) return false; if (!Misc.nearlyEquals(dX, that.dX)) return false; return true; }
private String createNumericDataDiffMessage(DataType dt, String name, Number v1, Number v2, IndexIterator iter) { return String.format(" DIFF %s %s: %s != %s; count = %s, absDiff = %s, relDiff = %s %n", dt, name, v1, v2, iter, Misc.absoluteDifference(v1.doubleValue(), v2.doubleValue()), Misc.relativeDifference(v1.doubleValue(), v2.doubleValue())); }
Record6() throws IOException { creationOrder = raf.readLong(); raf.read(heapId); if (debugBtree2) debugOut.println(" record6 creationOrder=" + creationOrder + " heapId=" + Misc.showBytes(heapId)); } }
/** * return true if val equals a missing_value (low level) */ public boolean isMissingValue(double val) { if (!hasMissingValue) return false; for (int i = 0; i < missingValue.length; i++) if (ucar.nc2.util.Misc.closeEnough(val, missingValue[i])) return true; return false; }
/** * Check if two numbers are nearly equal with given absolute tolerance. * * @param a first number. * @param b second number. * @param maxAbsDiff the maximum {@link #absoluteDifference absolute difference} the two numbers may have. * @return true if within tolerance. */ public static boolean nearlyEqualsAbs(float a, float b, float maxAbsDiff) { return absoluteDifference(a, b) <= Math.abs(maxAbsDiff); }
Record5() throws IOException { nameHash = raf.readInt(); raf.readFully(heapId); if (debugBtree2) debugOut.println(" record5 nameHash=" + nameHash + " heapId=" + Misc.showBytes(heapId)); } }
public boolean equals(Object oo) { if (this == oo) return true; if ( !(oo instanceof LevelCoord)) return false; LevelCoord other = (LevelCoord) oo; return (ucar.nc2.util.Misc.closeEnough(value1, other.value1) && ucar.nc2.util.Misc.closeEnough(value2, other.value2)); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; if (!super.equals(o)) return false; LatLon other = (LatLon) o; if (!Misc.nearlyEqualsAbs(la1, other.la1, maxReletiveErrorPos * deltaLat)) return false; // allow some slop, reletive to grid size if (!Misc.nearlyEqualsAbs(lo1, other.lo1, maxReletiveErrorPos * deltaLon)) return false; if (!Misc.nearlyEquals(deltaLat, other.deltaLat)) return false; if (!Misc.nearlyEquals(deltaLon, other.deltaLon)) return false; return true; }
/** Same as {@link #nearlyEqualsAbs(float, float, float)}, but with doubles. */ public static boolean nearlyEqualsAbs(double a, double b, double maxAbsDiff) { return absoluteDifference(a, b) <= Math.abs(maxAbsDiff); }
public void show(Formatter f) { if (isConstant) f.format("isConstant="+start); else if (isOrdered) f.format("isOrdered start="+start); else Misc.showInts(raw, f); }
Record6() throws IOException { creationOrder = raf.readLong(); raf.readFully(heapId); if (debugBtree2) debugOut.println(" record6 creationOrder=" + creationOrder + " heapId=" + Misc.showBytes(heapId)); } }
@Override public boolean isMissingValue(double val) { if (!hasMissingValue) { return false; } for (double aMissingValue : missingValue) { if (Misc.nearlyEquals(val, aMissingValue, Misc.defaultMaxRelativeDiffFloat)) { return true; } } return false; }
public boolean equals(Object oo) { if (this == oo) return true; if (!(oo instanceof LevelCoord)) return false; LevelCoord other = (LevelCoord) oo; return (ucar.nc2.util.Misc.closeEnough(value1, other.value1) && ucar.nc2.util.Misc.closeEnough(value2, other.value2)); }
/** Same as {@link #relativeDifference(float, float)}, but for doubles. */ public static double relativeDifference(double a, double b) { double absDiff = absoluteDifference(a, b); if (Double.compare(a, b) == 0) { // Shortcut: handles infinities and NaNs. return 0; } else if (a == 0 || b == 0 || absDiff < Double.MIN_NORMAL) { return absDiff / Double.MIN_NORMAL; } else { double maxAbsValue = Math.max(Math.abs(a), Math.abs(b)); return absDiff / maxAbsValue; } }
public void show(Formatter f) { if (isConstant) f.format("isConstant=%d",start); else if (isSequential) f.format("isSequential start=%d",start); else { f.format("isSorted=%s ", isSorted); Misc.showInts(raw, f); } }
Record5() throws IOException { nameHash = raf.readInt(); raf.read(heapId); if (debugBtree2) debugOut.println(" record5 nameHash=" + nameHash + " heapId=" + Misc.showBytes(heapId)); } }