List of usage examples for org.apache.commons.math3.util Precision equalsIncludingNaN
public static boolean equalsIncludingNaN(double x, double y)
From source file:org.apereo.portal.events.aggr.stat.JpaStatisticalSummary.java
/** * Returns true iff <code>object</code> is a * <code>SummaryStatistics</code> instance and all statistics have the * same values as this./* www .j a v a 2s . c o m*/ * @param object the object to test equality against. * @return true if object equals this */ @Override public boolean equals(Object object) { if (object == this) { return true; } if (object instanceof SummaryStatistics == false) { return false; } SummaryStatistics stat = (SummaryStatistics) object; return Precision.equalsIncludingNaN(stat.getGeometricMean(), getGeometricMean()) && Precision.equalsIncludingNaN(stat.getMax(), getMax()) && Precision.equalsIncludingNaN(stat.getMean(), getMean()) && Precision.equalsIncludingNaN(stat.getMin(), getMin()) && Precision.equalsIncludingNaN(stat.getN(), getN()) && Precision.equalsIncludingNaN(stat.getSum(), getSum()) && Precision.equalsIncludingNaN(stat.getSumsq(), getSumsq()) && Precision.equalsIncludingNaN(stat.getVariance(), getVariance()); }
From source file:org.briljantframework.array.AbstractDoubleArray.java
@Override public boolean equals(Object obj) { if (this == obj) { return true; }//from ww w.j av a 2 s.com if (obj instanceof DoubleArray) { DoubleArray mat = (DoubleArray) obj; if (!Arrays.equals(shape, mat.getShape())) { return false; } for (int i = 0; i < size(); i++) { if (!Precision.equalsIncludingNaN(get(i), mat.get(i))) { return false; } } return true; } else { return false; } }
From source file:org.gitools.analysis.groupcomparison.format.math33Preview.MathArrays.java
/** * Returns true iff both arguments are null or have same dimensions and all * their elements are equal as defined by * {@link Precision#equalsIncludingNaN(double, double) this method}. * * @param x first array/* w ww .jav a 2s . c o m*/ * @param y second array * @return true if the values are both null or have same dimension and * equal elements * @since 2.2 */ public static boolean equalsIncludingNaN(float[] x, float[] y) { if ((x == null) || (y == null)) { return !((x == null) ^ (y == null)); } if (x.length != y.length) { return false; } for (int i = 0; i < x.length; ++i) { if (!Precision.equalsIncludingNaN(x[i], y[i])) { return false; } } return true; }
From source file:org.gitools.analysis.groupcomparison.format.math33Preview.MathArrays.java
/** * Returns {@code true} iff both arguments are {@code null} or have same * dimensions and all their elements are equal as defined by * {@link Precision#equalsIncludingNaN(double, double) this method}. * * @param x First array./*from www .j a v a2s . co m*/ * @param y Second array. * @return {@code true} if the values are both {@code null} or have same * dimension and equal elements. * @since 2.2 */ public static boolean equalsIncludingNaN(double[] x, double[] y) { if ((x == null) || (y == null)) { return !((x == null) ^ (y == null)); } if (x.length != y.length) { return false; } for (int i = 0; i < x.length; ++i) { if (!Precision.equalsIncludingNaN(x[i], y[i])) { return false; } } return true; }