org.apache.commons.math3.util.Precision.equalsIncludingNaN()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(13.7k)|赞(0)|评价(0)|浏览(91)

本文整理了Java中org.apache.commons.math3.util.Precision.equalsIncludingNaN()方法的一些代码示例,展示了Precision.equalsIncludingNaN()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Precision.equalsIncludingNaN()方法的具体详情如下:
包路径:org.apache.commons.math3.util.Precision
类名称:Precision
方法名:equalsIncludingNaN

Precision.equalsIncludingNaN介绍

[英]Returns true if the arguments are both NaN or they are equal as defined by #equals(double,double).
[中]如果参数均为NaN或由#equals(double,double)定义为相等,则返回true。

代码示例

代码示例来源:origin: org.apache.commons/commons-math3

/**
 * 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
 * @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;
}

代码示例来源:origin: org.apache.commons/commons-math3

/**
 * 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.
 * @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;
}

代码示例来源:origin: org.apache.commons/commons-math3

/**
 * Returns true if the arguments are both NaN, are equal or are within the range
 * of allowed error (inclusive).
 *
 * @param x first value
 * @param y second value
 * @param eps the amount of absolute error to allow.
 * @return {@code true} if the values are equal or within range of each other,
 * or both are NaN.
 * @since 2.2
 */
public static boolean equalsIncludingNaN(double x, double y, double eps) {
  return equalsIncludingNaN(x, y) || (FastMath.abs(y - x) <= eps);
}

代码示例来源:origin: org.apache.commons/commons-math3

/**
 * Returns true if the arguments are both NaN, are equal, or are within the range
 * of allowed error (inclusive).
 *
 * @param x first value
 * @param y second value
 * @param eps the amount of absolute error to allow.
 * @return {@code true} if the values are equal or within range of each other,
 * or both are NaN.
 * @since 2.2
 */
public static boolean equalsIncludingNaN(float x, float y, float eps) {
  return equalsIncludingNaN(x, y) || (FastMath.abs(y - x) <= eps);
}

代码示例来源:origin: org.apache.commons/commons-math3

/**
 * Replace every occurrence of a given value with a replacement value in a
 * copied slice of array defined by array part from [begin, begin+length).
 * @param values the input array
 * @param begin start index of the array to include
 * @param length number of elements to include from begin
 * @param original the value to be replaced with
 * @param replacement the value to be used for replacement
 * @return the copy of sliced array with replaced values
 */
private static double[] replaceAndSlice(final double[] values,
                    final int begin, final int length,
                    final double original,
                    final double replacement) {
  final double[] temp = copyOf(values, begin, length);
  for(int i = 0; i < length; i++) {
    temp[i] = Precision.equalsIncludingNaN(original, temp[i]) ?
         replacement : temp[i];
  }
  return temp;
}

代码示例来源:origin: org.apache.commons/commons-math3

if (Precision.equalsIncludingNaN(removedValue, values[i])) {
  bits.set(i - begin);

代码示例来源:origin: org.apache.commons/commons-math3

/**
 * Returns true iff <code>object</code> is an
 * <code>AbstractStorelessUnivariateStatistic</code> returning the same
 * values as this for <code>getResult()</code> and <code>getN()</code>
 * @param object object to test equality against.
 * @return true if object returns the same value as this
 */
@Override
public boolean equals(Object object) {
  if (object == this ) {
    return true;
  }
  if (object instanceof AbstractStorelessUnivariateStatistic == false) {
    return false;
  }
  AbstractStorelessUnivariateStatistic stat = (AbstractStorelessUnivariateStatistic) object;
  return Precision.equalsIncludingNaN(stat.getResult(), this.getResult()) &&
      Precision.equalsIncludingNaN(stat.getN(), this.getN());
}

代码示例来源:origin: org.apache.commons/commons-math3

/**
 * Returns true iff <code>object</code> is a
 * <code>SummaryStatistics</code> instance and all statistics have the
 * same values as this.
 * @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());
}

代码示例来源:origin: org.apache.commons/commons-math3

/**
 * Returns true iff <code>object</code> is a
 * <code>StatisticalSummaryValues</code> instance and all statistics have
 *  the same values as this.
 *
 * @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 StatisticalSummaryValues == false) {
    return false;
  }
  StatisticalSummaryValues stat = (StatisticalSummaryValues) object;
  return 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.getVariance(), getVariance());
}

代码示例来源:origin: org.apache.commons/commons-math3

/**
 * Returns true iff <code>object</code> is a <code>MultivariateSummaryStatistics</code>
 * instance and all statistics have the same values as this.
 * @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 MultivariateSummaryStatistics == false) {
    return false;
  }
  MultivariateSummaryStatistics stat = (MultivariateSummaryStatistics) object;
  return MathArrays.equalsIncludingNaN(stat.getGeometricMean(), getGeometricMean()) &&
      MathArrays.equalsIncludingNaN(stat.getMax(),           getMax())           &&
      MathArrays.equalsIncludingNaN(stat.getMean(),          getMean())          &&
      MathArrays.equalsIncludingNaN(stat.getMin(),           getMin())           &&
      Precision.equalsIncludingNaN(stat.getN(),             getN())             &&
      MathArrays.equalsIncludingNaN(stat.getSum(),           getSum())           &&
      MathArrays.equalsIncludingNaN(stat.getSumSq(),         getSumSq())         &&
      MathArrays.equalsIncludingNaN(stat.getSumLog(),        getSumLog())        &&
      stat.getCovariance().equals( getCovariance());
}

代码示例来源:origin: geogebra/geogebra

/**
 * Returns true if the arguments are both NaN, are equal or are within the range
 * of allowed error (inclusive).
 *
 * @param x first value
 * @param y second value
 * @param eps the amount of absolute error to allow.
 * @return {@code true} if the values are equal or within range of each other,
 * or both are NaN.
 * @since 2.2
 */
public static boolean equalsIncludingNaN(double x, double y, double eps) {
  return equalsIncludingNaN(x, y) || (Math.abs(y - x) <= eps);
}

代码示例来源:origin: io.virtdata/virtdata-lib-realer

/**
 * Returns true if the arguments are both NaN, are equal or are within the range
 * of allowed error (inclusive).
 *
 * @param x first value
 * @param y second value
 * @param eps the amount of absolute error to allow.
 * @return {@code true} if the values are equal or within range of each other,
 * or both are NaN.
 * @since 2.2
 */
public static boolean equalsIncludingNaN(double x, double y, double eps) {
  return equalsIncludingNaN(x, y) || (FastMath.abs(y - x) <= eps);
}

代码示例来源:origin: io.virtdata/virtdata-lib-realer

/**
 * Returns true if the arguments are both NaN, are equal, or are within the range
 * of allowed error (inclusive).
 *
 * @param x first value
 * @param y second value
 * @param eps the amount of absolute error to allow.
 * @return {@code true} if the values are equal or within range of each other,
 * or both are NaN.
 * @since 2.2
 */
public static boolean equalsIncludingNaN(float x, float y, float eps) {
  return equalsIncludingNaN(x, y) || (FastMath.abs(y - x) <= eps);
}

代码示例来源:origin: geogebra/geogebra

/**
 * Replace every occurrence of a given value with a replacement value in a
 * copied slice of array defined by array part from [begin, begin+length).
 * @param values the input array
 * @param begin start index of the array to include
 * @param length number of elements to include from begin
 * @param original the value to be replaced with
 * @param replacement the value to be used for replacement
 * @return the copy of sliced array with replaced values
 */
private static double[] replaceAndSlice(final double[] values,
                    final int begin, final int length,
                    final double original,
                    final double replacement) {
  final double[] temp = copyOf(values, begin, length);
  for(int i = 0; i < length; i++) {
    temp[i] = Precision.equalsIncludingNaN(original, temp[i]) ?
         replacement : temp[i];
  }
  return temp;
}

代码示例来源:origin: io.virtdata/virtdata-lib-realer

/**
 * Replace every occurrence of a given value with a replacement value in a
 * copied slice of array defined by array part from [begin, begin+length).
 * @param values the input array
 * @param begin start index of the array to include
 * @param length number of elements to include from begin
 * @param original the value to be replaced with
 * @param replacement the value to be used for replacement
 * @return the copy of sliced array with replaced values
 */
private static double[] replaceAndSlice(final double[] values,
                    final int begin, final int length,
                    final double original,
                    final double replacement) {
  final double[] temp = copyOf(values, begin, length);
  for(int i = 0; i < length; i++) {
    temp[i] = Precision.equalsIncludingNaN(original, temp[i]) ?
         replacement : temp[i];
  }
  return temp;
}

代码示例来源:origin: geogebra/geogebra

/**
 * Returns true iff <code>object</code> is an
 * <code>AbstractStorelessUnivariateStatistic</code> returning the same
 * values as this for <code>getResult()</code> and <code>getN()</code>
 * @param object object to test equality against.
 * @return true if object returns the same value as this
 */
@Override
public boolean equals(Object object) {
  if (object == this ) {
    return true;
  }
  if (object instanceof AbstractStorelessUnivariateStatistic == false) {
    return false;
  }
  AbstractStorelessUnivariateStatistic stat = (AbstractStorelessUnivariateStatistic) object;
  return Precision.equalsIncludingNaN(stat.getResult(), this.getResult()) &&
      Precision.equalsIncludingNaN(stat.getN(), this.getN());
}

代码示例来源:origin: io.virtdata/virtdata-lib-realer

/**
 * Returns true iff <code>object</code> is an
 * <code>AbstractStorelessUnivariateStatistic</code> returning the same
 * values as this for <code>getResult()</code> and <code>getN()</code>
 * @param object object to test equality against.
 * @return true if object returns the same value as this
 */
@Override
public boolean equals(Object object) {
  if (object == this ) {
    return true;
  }
  if (object instanceof AbstractStorelessUnivariateStatistic == false) {
    return false;
  }
  AbstractStorelessUnivariateStatistic stat = (AbstractStorelessUnivariateStatistic) object;
  return Precision.equalsIncludingNaN(stat.getResult(), this.getResult()) &&
      Precision.equalsIncludingNaN(stat.getN(), this.getN());
}

代码示例来源:origin: geogebra/geogebra

/**
 * Returns true iff <code>object</code> is a
 * <code>StatisticalSummaryValues</code> instance and all statistics have
 *  the same values as this.
 *
 * @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 StatisticalSummaryValues == false) {
    return false;
  }
  StatisticalSummaryValues stat = (StatisticalSummaryValues) object;
  return 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.getVariance(), getVariance());
}

代码示例来源:origin: io.virtdata/virtdata-lib-realer

/**
 * Returns true iff <code>object</code> is a
 * <code>StatisticalSummaryValues</code> instance and all statistics have
 *  the same values as this.
 *
 * @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 StatisticalSummaryValues == false) {
    return false;
  }
  StatisticalSummaryValues stat = (StatisticalSummaryValues) object;
  return 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.getVariance(), getVariance());
}

代码示例来源:origin: geogebra/geogebra

/**
 * Returns true iff <code>object</code> is a
 * <code>SummaryStatistics</code> instance and all statistics have the
 * same values as this.
 * @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());
}

相关文章