本文整理汇总了Java中org.apache.commons.math3.util.Precision.equalsIncludingNaN方法的典型用法代码示例。如果您正苦于以下问题:Java Precision.equalsIncludingNaN方法的具体用法?Java Precision.equalsIncludingNaN怎么用?Java Precision.equalsIncludingNaN使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.math3.util.Precision
的用法示例。
在下文中一共展示了Precision.equalsIncludingNaN方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: equals
import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
/**
* 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());
}
示例2: equals
import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
/**
* 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());
}
示例3: equals
import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
/**
* 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());
}
示例4: replaceAndSlice
import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
/**
* 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;
}
示例5: removeAndSlice
import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
/**
* Remove the occurrence of a given value in a copied slice of array
* defined by the 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 removedValue the value to be removed from the sliced array
* @return the copy of the sliced array after removing the removedValue
*/
private static double[] removeAndSlice(final double[] values,
final int begin, final int length,
final double removedValue) {
MathArrays.verifyValues(values, begin, length);
final double[] temp;
//BitSet(length) to indicate where the removedValue is located
final BitSet bits = new BitSet(length);
for (int i = begin; i < begin+length; i++) {
if (Precision.equalsIncludingNaN(removedValue, values[i])) {
bits.set(i - begin);
}
}
//Check if empty then create a new copy
if (bits.isEmpty()) {
temp = copyOf(values, begin, length); // Nothing removed, just copy
} else if(bits.cardinality() == length){
temp = new double[0]; // All removed, just empty
}else { // Some removable, so new
temp = new double[length - bits.cardinality()];
int start = begin; //start index from source array (i.e values)
int dest = 0; //dest index in destination array(i.e temp)
int nextOne = -1; //nextOne is the index of bit set of next one
int bitSetPtr = 0; //bitSetPtr is start index pointer of bitset
while ((nextOne = bits.nextSetBit(bitSetPtr)) != -1) {
final int lengthToCopy = nextOne - bitSetPtr;
System.arraycopy(values, start, temp, dest, lengthToCopy);
dest += lengthToCopy;
start = begin + (bitSetPtr = bits.nextClearBit(nextOne));
}
//Copy any residue past start index till begin+length
if (start < begin + length) {
System.arraycopy(values,start,temp,dest,begin + length - start);
}
}
return temp;
}
示例6: equals
import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
/**
* 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());
}
示例7: assertEquals
import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
/** verifies that two arrays are close (sup norm) */
public static void assertEquals(String msg, double[] expected, double[] observed, double tolerance) {
StringBuilder out = new StringBuilder(msg);
if (expected.length != observed.length) {
out.append("\n Arrays not same length. \n");
out.append("expected has length ");
out.append(expected.length);
out.append(" observed length = ");
out.append(observed.length);
Assert.fail(out.toString());
}
boolean failure = false;
for (int i=0; i < expected.length; i++) {
if (!Precision.equalsIncludingNaN(expected[i], observed[i], tolerance)) {
failure = true;
out.append("\n Elements at index ");
out.append(i);
out.append(" differ. ");
out.append(" expected = ");
out.append(expected[i]);
out.append(" observed = ");
out.append(observed[i]);
}
}
if (failure) {
Assert.fail(out.toString());
}
}
示例8: notifyGradebook
import org.apache.commons.math3.util.Precision; //导入方法依赖的package包/类
public void notifyGradebook(AssessmentGradingData data, PublishedAssessmentIfc pub) throws GradebookServiceException {
// If the assessment is published to the gradebook, make sure to update the scores in the gradebook
String toGradebook = pub.getEvaluationModel().getToGradeBook();
GradebookExternalAssessmentService g = null;
boolean integrated = IntegrationContextFactory.getInstance().isIntegrated();
if (integrated)
{
g = (GradebookExternalAssessmentService) SpringBeanLocator.getInstance().
getBean("org.sakaiproject.service.gradebook.GradebookExternalAssessmentService");
}
GradebookServiceHelper gbsHelper =
IntegrationContextFactory.getInstance().getGradebookServiceHelper();
PublishedAssessmentService publishedAssessmentService = new PublishedAssessmentService();
String currentSiteId = publishedAssessmentService.getPublishedAssessmentSiteId(pub.getPublishedAssessmentId().toString());
if (gbsHelper.gradebookExists(GradebookFacade.getGradebookUId(currentSiteId), g)
&& toGradebook.equals(EvaluationModelIfc.TO_DEFAULT_GRADEBOOK.toString())){
if(log.isDebugEnabled()) log.debug("Attempting to update a score in the gradebook");
// add retry logic to resolve deadlock problem while sending grades to gradebook
Double originalFinalScore = data.getFinalScore();
int retryCount = PersistenceService.getInstance().getPersistenceHelper().getRetryCount();
while (retryCount > 0){
try {
// Send the average score if average was selected for multiple submissions
Integer scoringType = pub.getEvaluationModel().getScoringType();
if (scoringType.equals(EvaluationModelIfc.AVERAGE_SCORE)) {
// status = 5: there is no submission but grader update something in the score page
if(data.getStatus() ==5) {
data.setFinalScore(data.getFinalScore());
} else {
Double averageScore = PersistenceService.getInstance().getAssessmentGradingFacadeQueries().
getAverageSubmittedAssessmentGrading(pub.getPublishedAssessmentId(), data.getAgentId());
data.setFinalScore(averageScore);
}
}
gbsHelper.updateExternalAssessmentScore(data, g);
retryCount = 0;
}
catch (org.sakaiproject.service.gradebook.shared.AssessmentNotFoundException ante) {
log.warn("problem sending grades to gradebook: {}", ante.getMessage());
if (AssessmentIfc.RETRACT_FOR_EDIT_STATUS.equals(pub.getStatus())) {
retryCount = retry(retryCount, ante, pub, true);
}
else {
// Otherwise, do the same exeption handling as others
retryCount = retry(retryCount, ante, pub, false);
}
}
catch (Exception e) {
retryCount = retry(retryCount, e, pub, false);
}
}
// change the final score back to the original score since it may set to average score.
// if we're deleting the last submission, the score might be null bugid 5440
if(originalFinalScore != null && data.getFinalScore() != null && !(Precision.equalsIncludingNaN(data.getFinalScore(), originalFinalScore, 0.0001))) {
data.setFinalScore(originalFinalScore);
}
try {
Long publishedAssessmentId = data.getPublishedAssessmentId();
String agent = data.getAgentId();
String comment = data.getComments();
gbsHelper.updateExternalAssessmentComment(publishedAssessmentId, agent, comment, g);
}
catch (Exception ex) {
log.warn("Error sending comments to gradebook: {}", ex.getMessage());
}
} else {
log.debug("Not updating the gradebook. toGradebook = {}", toGradebook);
}
}