Merge branch 'master' of https://gitbox.apache.org/repos/asf/commons-math
diff --git a/.gitignore b/.gitignore
index b628f80..c930041 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,7 +6,7 @@
target
/build
/lib
-/site-content
+site-content
.ekstazi
*.class
*.iml
diff --git a/commons-math-legacy-core/src/main/java/org/apache/commons/math4/legacy/core/MathArrays.java b/commons-math-legacy-core/src/main/java/org/apache/commons/math4/legacy/core/MathArrays.java
index 0c77bf2..ba72623 100644
--- a/commons-math-legacy-core/src/main/java/org/apache/commons/math4/legacy/core/MathArrays.java
+++ b/commons-math-legacy-core/src/main/java/org/apache/commons/math4/legacy/core/MathArrays.java
@@ -617,7 +617,7 @@
*/
public static boolean equals(float[] x, float[] y) {
if (x == null || y == null) {
- return !((x == null) ^ (y == null));
+ return (x == null) == (y == null);
}
if (x.length != y.length) {
return false;
@@ -643,7 +643,7 @@
*/
public static boolean equalsIncludingNaN(float[] x, float[] y) {
if (x == null || y == null) {
- return !((x == null) ^ (y == null));
+ return (x == null) == (y == null);
}
if (x.length != y.length) {
return false;
@@ -668,7 +668,7 @@
*/
public static boolean equals(double[] x, double[] y) {
if (x == null || y == null) {
- return !((x == null) ^ (y == null));
+ return (x == null) == (y == null);
}
if (x.length != y.length) {
return false;
@@ -694,7 +694,7 @@
*/
public static boolean equalsIncludingNaN(double[] x, double[] y) {
if (x == null || y == null) {
- return !((x == null) ^ (y == null));
+ return (x == null) == (y == null);
}
if (x.length != y.length) {
return false;
diff --git a/commons-math-legacy-core/src/main/java/org/apache/commons/math4/legacy/core/dfp/Dfp.java b/commons-math-legacy-core/src/main/java/org/apache/commons/math4/legacy/core/dfp/Dfp.java
index ceffa21..41f15c9 100644
--- a/commons-math-legacy-core/src/main/java/org/apache/commons/math4/legacy/core/dfp/Dfp.java
+++ b/commons-math-legacy-core/src/main/java/org/apache/commons/math4/legacy/core/dfp/Dfp.java
@@ -2351,10 +2351,7 @@
}
// if this is greater than x
- boolean up = false;
- if (this.lessThan(x)) {
- up = true;
- }
+ boolean up = this.lessThan(x);
if (compare(this, x) == 0) {
return newInstance(x);
diff --git a/commons-math-legacy-core/src/main/java/org/apache/commons/math4/legacy/core/dfp/DfpMath.java b/commons-math-legacy-core/src/main/java/org/apache/commons/math4/legacy/core/dfp/DfpMath.java
index f831603..4503fb0 100644
--- a/commons-math-legacy-core/src/main/java/org/apache/commons/math4/legacy/core/dfp/DfpMath.java
+++ b/commons-math-legacy-core/src/main/java/org/apache/commons/math4/legacy/core/dfp/DfpMath.java
@@ -941,11 +941,7 @@
*/
public static Dfp acos(Dfp a) {
Dfp result;
- boolean negative = false;
-
- if (a.lessThan(a.getZero())) {
- negative = true;
- }
+ boolean negative = a.lessThan(a.getZero());
a = Dfp.copySign(a, a.getOne()); // absolute value
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/analysis/polynomials/PolynomialFunction.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/analysis/polynomials/PolynomialFunction.java
index dd382dd..d9884c8 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/analysis/polynomials/PolynomialFunction.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/analysis/polynomials/PolynomialFunction.java
@@ -371,10 +371,7 @@
return false;
}
PolynomialFunction other = (PolynomialFunction) obj;
- if (!Arrays.equals(coefficients, other.coefficients)) {
- return false;
- }
- return true;
+ return Arrays.equals(coefficients, other.coefficients);
}
/**
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/fitting/SimpleCurveFitter.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/fitting/SimpleCurveFitter.java
index 671150d..012c913 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/fitting/SimpleCurveFitter.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/fitting/SimpleCurveFitter.java
@@ -186,11 +186,7 @@
if (comp != 0) {
return comp;
}
- comp = Double.compare(p1.getWeight(), p2.getWeight());
- if (comp != 0) {
- return comp;
- }
- return 0;
+ return Double.compare(p1.getWeight(), p2.getWeight());
}
};
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/ode/events/EventState.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/ode/events/EventState.java
index 832067a..eeec951 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/ode/events/EventState.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/ode/events/EventState.java
@@ -365,7 +365,7 @@
// force the sign to its value "just after the event"
previousEventTime = t;
g0Positive = increasing;
- nextAction = handler.eventOccurred(t, y, !(increasing ^ forward));
+ nextAction = handler.eventOccurred(t, y, increasing == forward);
} else {
g0Positive = g0 >= 0;
nextAction = EventHandler.Action.CONTINUE;
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/ode/events/FieldEventState.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/ode/events/FieldEventState.java
index 3bf39e7..e91bacc 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/ode/events/FieldEventState.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/ode/events/FieldEventState.java
@@ -301,7 +301,7 @@
// force the sign to its value "just after the event"
previousEventTime = state.getTime();
g0Positive = increasing;
- nextAction = handler.eventOccurred(state, !(increasing ^ forward));
+ nextAction = handler.eventOccurred(state, increasing == forward);
} else {
g0Positive = g0.getReal() >= 0;
nextAction = Action.CONTINUE;
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/optim/linear/SolutionCallback.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/optim/linear/SolutionCallback.java
index 4d2b542..cdccdbd 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/optim/linear/SolutionCallback.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/optim/linear/SolutionCallback.java
@@ -57,6 +57,6 @@
* @return {@code true} if the solution is optimal, {@code false} otherwise
*/
public boolean isSolutionOptimal() {
- return tableau != null ? tableau.isOptimal() : false;
+ return tableau != null && tableau.isOptimal();
}
}
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/CMAESOptimizer.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/CMAESOptimizer.java
index 38f7919..cfee773 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/CMAESOptimizer.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/CMAESOptimizer.java
@@ -896,7 +896,7 @@
@Override
public int hashCode() {
long bits = Double.doubleToLongBits(value);
- return (int) ((1438542 ^ (bits >>> 32) ^ bits) & 0xffffffff);
+ return (int) ((1438542 ^ (bits >>> 32) ^ bits));
}
}
/**
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/Frequency.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/Frequency.java
index 5b9f510..e79858b 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/Frequency.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/Frequency.java
@@ -376,14 +376,7 @@
return false;
}
Frequency<?> other = (Frequency<?>) obj;
- if (freqTable == null) {
- if (other.freqTable != null) {
- return false;
- }
- } else if (!freqTable.equals(other.freqTable)) {
- return false;
- }
- return true;
+ return freqTable.equals(other.freqTable);
}
}
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/moment/VectorialCovariance.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/moment/VectorialCovariance.java
index dfa0d71..c8b5b5a 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/moment/VectorialCovariance.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/moment/VectorialCovariance.java
@@ -148,10 +148,7 @@
if (!Arrays.equals(productsSums, other.productsSums)) {
return false;
}
- if (!Arrays.equals(sums, other.sums)) {
- return false;
- }
- return true;
+ return Arrays.equals(sums, other.sums);
}
}
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/moment/VectorialMean.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/moment/VectorialMean.java
index d00b49a..ade4be4 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/moment/VectorialMean.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/moment/VectorialMean.java
@@ -96,10 +96,7 @@
return false;
}
VectorialMean other = (VectorialMean) obj;
- if (!Arrays.equals(means, other.means)) {
- return false;
- }
- return true;
+ return Arrays.equals(means, other.means);
}
}
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/rank/PSquarePercentile.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/rank/PSquarePercentile.java
index 603da76..ed064a9 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/rank/PSquarePercentile.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/rank/PSquarePercentile.java
@@ -908,7 +908,7 @@
*/
@Override
public boolean add(final E e) {
- return size() < capacity ? super.add(e) : false;
+ return size() < capacity && super.add(e);
}
/**
@@ -924,7 +924,7 @@
boolean isCollectionLess =
collection != null &&
collection.size() + size() <= capacity;
- return isCollectionLess ? super.addAll(collection) : false;
+ return isCollectionLess && super.addAll(collection);
}
}
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/inference/KolmogorovSmirnovTest.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/inference/KolmogorovSmirnovTest.java
index 14ccc1a..44cb2c6 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/inference/KolmogorovSmirnovTest.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/inference/KolmogorovSmirnovTest.java
@@ -1132,11 +1132,7 @@
throw new InsufficientDataException();
}
- if (values.length == x.length + y.length) {
- return false; // There are no ties.
- }
-
- return true;
+ return values.length != x.length + y.length; // There are no ties.
}
/**
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 2821512..0471499 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -45,7 +45,9 @@
If the output is not quite correct, check for invisible trailing spaces!
-->
-<document>
+<document xmlns="http://maven.apache.org/changes/1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/changes/1.0.0 http://maven.apache.org/xsd/changes-1.0.0.xsd">
<properties>
<title>Apache Commons Math Release Notes</title>
</properties>
@@ -95,6 +97,9 @@
nightmare was one of the main reasons for creating more focused
components.]
">
+ <action dev="aherbert" due-to="Arturo Bernal" type="update" issue="MATH-1572">
+ Simplify conditional expressions.
+ </action>
<action dev="erans" type="update" issue="MATH-1616">
Refactor "EmpiricalDistribution" class (in package "o.a.c.m.legacy.distribution").
</action>