From cc610e98c9736a6ada9adad2467e41bc6b02048b Mon Sep 17 00:00:00 2001 From: Luc Maisonobe Date: Thu, 21 Mar 2024 09:45:03 +0100 Subject: [PATCH 1/2] Allow variable arguments for building PolynomialFunction. Fixes #322 --- hipparchus-core/src/changes/changes.xml | 3 +++ .../hipparchus/analysis/polynomials/PolynomialFunction.java | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/hipparchus-core/src/changes/changes.xml b/hipparchus-core/src/changes/changes.xml index 4f85634ff..efe7374e4 100644 --- a/hipparchus-core/src/changes/changes.xml +++ b/hipparchus-core/src/changes/changes.xml @@ -50,6 +50,9 @@ If the output is not quite correct, check for invisible trailing spaces! + + Allow variable arguments for building PolynomialFunction. + Extracted class JacobiKey from PolynomialsUtils. diff --git a/hipparchus-core/src/main/java/org/hipparchus/analysis/polynomials/PolynomialFunction.java b/hipparchus-core/src/main/java/org/hipparchus/analysis/polynomials/PolynomialFunction.java index ebd63b823..d092a4bc0 100644 --- a/hipparchus-core/src/main/java/org/hipparchus/analysis/polynomials/PolynomialFunction.java +++ b/hipparchus-core/src/main/java/org/hipparchus/analysis/polynomials/PolynomialFunction.java @@ -68,7 +68,7 @@ public class PolynomialFunction implements UnivariateDifferentiableFunction, Fie * @throws NullArgumentException if {@code c} is {@code null}. * @throws MathIllegalArgumentException if {@code c} is empty. */ - public PolynomialFunction(double[] c) + public PolynomialFunction(double... c) throws MathIllegalArgumentException, NullArgumentException { super(); MathUtils.checkNotNull(c); From 3ad4c50316d33ed0529ca2393c65fa7999db2d26 Mon Sep 17 00:00:00 2001 From: Luc Maisonobe Date: Thu, 21 Mar 2024 09:47:18 +0100 Subject: [PATCH 2/2] Fixed warnings identified by IntelliJ code analysis. --- .../analysis/polynomials/PolynomialFunction.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/hipparchus-core/src/main/java/org/hipparchus/analysis/polynomials/PolynomialFunction.java b/hipparchus-core/src/main/java/org/hipparchus/analysis/polynomials/PolynomialFunction.java index d092a4bc0..36e56a817 100644 --- a/hipparchus-core/src/main/java/org/hipparchus/analysis/polynomials/PolynomialFunction.java +++ b/hipparchus-core/src/main/java/org/hipparchus/analysis/polynomials/PolynomialFunction.java @@ -392,7 +392,7 @@ public String toString() { s.append('x'); if (i > 1) { s.append('^'); - s.append(Integer.toString(i)); + s.append(i); } } } @@ -434,10 +434,7 @@ public boolean equals(Object obj) { return false; } PolynomialFunction other = (PolynomialFunction) obj; - if (!Arrays.equals(coefficients, other.coefficients)) { - return false; - } - return true; + return Arrays.equals(coefficients, other.coefficients); } /**