diff --git a/src/changes/changes.xml b/src/changes/changes.xml index e9772f92f..b838e53cd 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -81,10 +81,10 @@ This is a minor release: It combines bug fixes and new features. behave across events in ODE events detection. - Added Hermite interpolator for ExtendFieldElement instances. + Added Hermite interpolator for RealFieldElement instances. - Added ExtendFieldElement interface to represent anything that is + Added RealFieldElement interface to represent anything that is real number like, implemented by both Decimal64, Dfp and DerivativeStructure. diff --git a/src/main/java/org/apache/commons/math3/ExtendedFieldElement.java b/src/main/java/org/apache/commons/math3/RealFieldElement.java similarity index 99% rename from src/main/java/org/apache/commons/math3/ExtendedFieldElement.java rename to src/main/java/org/apache/commons/math3/RealFieldElement.java index 272c117cb..e704f756f 100644 --- a/src/main/java/org/apache/commons/math3/ExtendedFieldElement.java +++ b/src/main/java/org/apache/commons/math3/RealFieldElement.java @@ -29,7 +29,7 @@ import org.apache.commons.math3.exception.DimensionMismatchException; * @version $Id$ * @since 3.2 */ -public interface ExtendedFieldElement extends FieldElement { +public interface RealFieldElement extends FieldElement { /** Get the real value of the number. * @return real value diff --git a/src/main/java/org/apache/commons/math3/analysis/differentiation/DerivativeStructure.java b/src/main/java/org/apache/commons/math3/analysis/differentiation/DerivativeStructure.java index 06d4a2015..fef9a42b0 100644 --- a/src/main/java/org/apache/commons/math3/analysis/differentiation/DerivativeStructure.java +++ b/src/main/java/org/apache/commons/math3/analysis/differentiation/DerivativeStructure.java @@ -18,7 +18,7 @@ package org.apache.commons.math3.analysis.differentiation; import java.io.Serializable; -import org.apache.commons.math3.ExtendedFieldElement; +import org.apache.commons.math3.RealFieldElement; import org.apache.commons.math3.Field; import org.apache.commons.math3.FieldElement; import org.apache.commons.math3.exception.DimensionMismatchException; @@ -58,7 +58,7 @@ import org.apache.commons.math3.util.MathUtils; * @version $Id$ * @since 3.1 */ -public class DerivativeStructure implements ExtendedFieldElement, Serializable { +public class DerivativeStructure implements RealFieldElement, Serializable { /** Serializable UID. */ private static final long serialVersionUID = 20120730L; diff --git a/src/main/java/org/apache/commons/math3/dfp/Dfp.java b/src/main/java/org/apache/commons/math3/dfp/Dfp.java index 7db33cdef..0787c0f1b 100644 --- a/src/main/java/org/apache/commons/math3/dfp/Dfp.java +++ b/src/main/java/org/apache/commons/math3/dfp/Dfp.java @@ -19,7 +19,7 @@ package org.apache.commons.math3.dfp; import java.util.Arrays; -import org.apache.commons.math3.ExtendedFieldElement; +import org.apache.commons.math3.RealFieldElement; import org.apache.commons.math3.exception.DimensionMismatchException; import org.apache.commons.math3.util.FastMath; @@ -95,7 +95,7 @@ import org.apache.commons.math3.util.FastMath; * @version $Id$ * @since 2.2 */ -public class Dfp implements ExtendedFieldElement { +public class Dfp implements RealFieldElement { /** The radix, or base of this system. Set to 10000 */ public static final int RADIX = 10000; diff --git a/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/FieldRotation.java b/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/FieldRotation.java index 964347483..c5c8ecf42 100644 --- a/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/FieldRotation.java +++ b/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/FieldRotation.java @@ -19,7 +19,7 @@ package org.apache.commons.math3.geometry.euclidean.threed; import java.io.Serializable; -import org.apache.commons.math3.ExtendedFieldElement; +import org.apache.commons.math3.RealFieldElement; import org.apache.commons.math3.Field; import org.apache.commons.math3.exception.MathArithmeticException; import org.apache.commons.math3.exception.MathIllegalArgumentException; @@ -28,7 +28,7 @@ import org.apache.commons.math3.util.FastMath; import org.apache.commons.math3.util.MathArrays; /** - * This class is a re-implementation of {@link Rotation} using {@link ExtendedFieldElement}. + * This class is a re-implementation of {@link Rotation} using {@link RealFieldElement}. *

Instance of this class are guaranteed to be immutable.

* * @param the type of the field elements @@ -38,7 +38,7 @@ import org.apache.commons.math3.util.MathArrays; * @since 3.2 */ -public class FieldRotation> implements Serializable { +public class FieldRotation> implements Serializable { /** Serializable version identifier */ private static final long serialVersionUID = 20130224l; @@ -425,7 +425,7 @@ public class FieldRotation> implements Seriali /** Get the normalized axis of the rotation. * @return normalized axis of the rotation - * @see #FieldRotation(FieldVector3D, ExtendedFieldElement) + * @see #FieldRotation(FieldVector3D, RealFieldElement) */ public FieldVector3D getAxis() { final T squaredSine = q1.multiply(q1).add(q2.multiply(q2)).add(q3.multiply(q3)); @@ -442,7 +442,7 @@ public class FieldRotation> implements Seriali /** Get the angle of the rotation. * @return angle of the rotation (between 0 and π) - * @see #FieldRotation(FieldVector3D, ExtendedFieldElement) + * @see #FieldRotation(FieldVector3D, RealFieldElement) */ public T getAngle() { if ((q0.getReal() < -0.1) || (q0.getReal() > 0.1)) { @@ -834,7 +834,7 @@ public class FieldRotation> implements Seriali * @param the type of the field elements * @return a new vector which is the image of u by the rotation */ - public static > FieldVector3D applyTo(final Rotation r, final FieldVector3D u) { + public static > FieldVector3D applyTo(final Rotation r, final FieldVector3D u) { final T x = u.getX(); final T y = u.getY(); @@ -931,7 +931,7 @@ public class FieldRotation> implements Seriali * @param the type of the field elements * @return a new vector which such that u is its image by the rotation */ - public static > FieldVector3D applyInverseTo(final Rotation r, final FieldVector3D u) { + public static > FieldVector3D applyInverseTo(final Rotation r, final FieldVector3D u) { final T x = u.getX(); final T y = u.getY(); @@ -991,7 +991,7 @@ public class FieldRotation> implements Seriali * @param the type of the field elements * @return a new rotation which is the composition of r by the instance */ - public static > FieldRotation applyTo(final Rotation r1, final FieldRotation rInner) { + public static > FieldRotation applyTo(final Rotation r1, final FieldRotation rInner) { return new FieldRotation(rInner.q0.multiply(r1.getQ0()).subtract(rInner.q1.multiply(r1.getQ1()).add(rInner.q2.multiply(r1.getQ2())).add(rInner.q3.multiply(r1.getQ3()))), rInner.q1.multiply(r1.getQ0()).add(rInner.q0.multiply(r1.getQ1())).add(rInner.q2.multiply(r1.getQ3()).subtract(rInner.q3.multiply(r1.getQ2()))), rInner.q2.multiply(r1.getQ0()).add(rInner.q0.multiply(r1.getQ2())).add(rInner.q3.multiply(r1.getQ1()).subtract(rInner.q1.multiply(r1.getQ3()))), @@ -1050,7 +1050,7 @@ public class FieldRotation> implements Seriali * @return a new rotation which is the composition of r by the inverse * of the instance */ - public static > FieldRotation applyInverseTo(final Rotation rOuter, final FieldRotation rInner) { + public static > FieldRotation applyInverseTo(final Rotation rOuter, final FieldRotation rInner) { return new FieldRotation(rInner.q0.multiply(rOuter.getQ0()).add(rInner.q1.multiply(rOuter.getQ1()).add(rInner.q2.multiply(rOuter.getQ2())).add(rInner.q3.multiply(rOuter.getQ3()))).negate(), rInner.q0.multiply(rOuter.getQ1()).add(rInner.q2.multiply(rOuter.getQ3()).subtract(rInner.q3.multiply(rOuter.getQ2()))).subtract(rInner.q1.multiply(rOuter.getQ0())), rInner.q0.multiply(rOuter.getQ2()).add(rInner.q3.multiply(rOuter.getQ1()).subtract(rInner.q1.multiply(rOuter.getQ3()))).subtract(rInner.q2.multiply(rOuter.getQ0())), @@ -1177,7 +1177,7 @@ public class FieldRotation> implements Seriali * @param the type of the field elements * @return distance between r1 and r2 */ - public static > T distance(final FieldRotation r1, final FieldRotation r2) { + public static > T distance(final FieldRotation r1, final FieldRotation r2) { return r1.applyInverseTo(r2).getAngle(); } diff --git a/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/FieldVector3D.java b/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/FieldVector3D.java index 13d65fa85..5371054ac 100644 --- a/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/FieldVector3D.java +++ b/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/FieldVector3D.java @@ -20,7 +20,7 @@ package org.apache.commons.math3.geometry.euclidean.threed; import java.io.Serializable; import java.text.NumberFormat; -import org.apache.commons.math3.ExtendedFieldElement; +import org.apache.commons.math3.RealFieldElement; import org.apache.commons.math3.exception.DimensionMismatchException; import org.apache.commons.math3.exception.MathArithmeticException; import org.apache.commons.math3.exception.util.LocalizedFormats; @@ -28,13 +28,13 @@ import org.apache.commons.math3.util.FastMath; import org.apache.commons.math3.util.MathArrays; /** - * This class is a re-implementation of {@link Vector3D} using {@link ExtendedFieldElement}. + * This class is a re-implementation of {@link Vector3D} using {@link RealFieldElement}. *

Instance of this class are guaranteed to be immutable.

* @param the type of the field elements * @version $Id$ * @since 3.2 */ -public class FieldVector3D> implements Serializable { +public class FieldVector3D> implements Serializable { /** Serializable version identifier. */ private static final long serialVersionUID = 20130224L; @@ -302,7 +302,7 @@ public class FieldVector3D> implements Seriali /** Get the abscissa of the vector. * @return abscissa of the vector - * @see #FieldVector3D(ExtendedFieldElement, ExtendedFieldElement, ExtendedFieldElement) + * @see #FieldVector3D(RealFieldElement, RealFieldElement, RealFieldElement) */ public T getX() { return x; @@ -310,7 +310,7 @@ public class FieldVector3D> implements Seriali /** Get the ordinate of the vector. * @return ordinate of the vector - * @see #FieldVector3D(ExtendedFieldElement, ExtendedFieldElement, ExtendedFieldElement) + * @see #FieldVector3D(RealFieldElement, RealFieldElement, RealFieldElement) */ public T getY() { return y; @@ -318,7 +318,7 @@ public class FieldVector3D> implements Seriali /** Get the height of the vector. * @return height of the vector - * @see #FieldVector3D(ExtendedFieldElement, ExtendedFieldElement, ExtendedFieldElement) + * @see #FieldVector3D(RealFieldElement, RealFieldElement, RealFieldElement) */ public T getZ() { return z; @@ -326,7 +326,7 @@ public class FieldVector3D> implements Seriali /** Get the vector coordinates as a dimension 3 array. * @return vector coordinates - * @see #FieldVector3D(ExtendedFieldElement[]) + * @see #FieldVector3D(RealFieldElement[]) */ public T[] toArray() { final T[] array = MathArrays.buildArray(x.getField(), 3); @@ -390,7 +390,7 @@ public class FieldVector3D> implements Seriali /** Get the azimuth of the vector. * @return azimuth (α) of the vector, between -π and +π - * @see #FieldVector3D(ExtendedFieldElement, ExtendedFieldElement) + * @see #FieldVector3D(RealFieldElement, RealFieldElement) */ public T getAlpha() { return y.atan2(x); @@ -398,7 +398,7 @@ public class FieldVector3D> implements Seriali /** Get the elevation of the vector. * @return elevation (δ) of the vector, between -π/2 and +π/2 - * @see #FieldVector3D(ExtendedFieldElement, ExtendedFieldElement) + * @see #FieldVector3D(RealFieldElement, RealFieldElement) */ public T getDelta() { return z.divide(getNorm()).asin(); @@ -575,7 +575,7 @@ public class FieldVector3D> implements Seriali * @return angular separation between v1 and v2 * @exception MathArithmeticException if either vector has a null norm */ - public static > T angle(final FieldVector3D v1, final FieldVector3D v2) + public static > T angle(final FieldVector3D v1, final FieldVector3D v2) throws MathArithmeticException { final T normProduct = v1.getNorm().multiply(v2.getNorm()); @@ -611,7 +611,7 @@ public class FieldVector3D> implements Seriali * @return angular separation between v1 and v2 * @exception MathArithmeticException if either vector has a null norm */ - public static > T angle(final FieldVector3D v1, final Vector3D v2) + public static > T angle(final FieldVector3D v1, final Vector3D v2) throws MathArithmeticException { final T normProduct = v1.getNorm().multiply(v2.getNorm()); @@ -647,7 +647,7 @@ public class FieldVector3D> implements Seriali * @return angular separation between v1 and v2 * @exception MathArithmeticException if either vector has a null norm */ - public static > T angle(final Vector3D v1, final FieldVector3D v2) + public static > T angle(final Vector3D v1, final FieldVector3D v2) throws MathArithmeticException { return angle(v2, v1); } @@ -697,7 +697,7 @@ public class FieldVector3D> implements Seriali * Test for the equality of two 3D vectors. *

* If all coordinates of two 3D vectors are exactly the same, and none of their - * {@link ExtendedFieldElement#getReal() real part} are NaN, the + * {@link RealFieldElement#getReal() real part} are NaN, the * two 3D vectors are considered to be equal. *

*

@@ -937,7 +937,7 @@ public class FieldVector3D> implements Seriali * @param the type of the field elements * @return the dot product v1.v2 */ - public static > T dotProduct(final FieldVector3D v1, + public static > T dotProduct(final FieldVector3D v1, final FieldVector3D v2) { return v1.dotProduct(v2); } @@ -948,7 +948,7 @@ public class FieldVector3D> implements Seriali * @param the type of the field elements * @return the dot product v1.v2 */ - public static > T dotProduct(final FieldVector3D v1, + public static > T dotProduct(final FieldVector3D v1, final Vector3D v2) { return v1.dotProduct(v2); } @@ -959,7 +959,7 @@ public class FieldVector3D> implements Seriali * @param the type of the field elements * @return the dot product v1.v2 */ - public static > T dotProduct(final Vector3D v1, + public static > T dotProduct(final Vector3D v1, final FieldVector3D v2) { return v2.dotProduct(v1); } @@ -970,7 +970,7 @@ public class FieldVector3D> implements Seriali * @param the type of the field elements * @return the cross product v1 ^ v2 as a new Vector */ - public static > FieldVector3D crossProduct(final FieldVector3D v1, + public static > FieldVector3D crossProduct(final FieldVector3D v1, final FieldVector3D v2) { return v1.crossProduct(v2); } @@ -981,7 +981,7 @@ public class FieldVector3D> implements Seriali * @param the type of the field elements * @return the cross product v1 ^ v2 as a new Vector */ - public static > FieldVector3D crossProduct(final FieldVector3D v1, + public static > FieldVector3D crossProduct(final FieldVector3D v1, final Vector3D v2) { return v1.crossProduct(v2); } @@ -992,7 +992,7 @@ public class FieldVector3D> implements Seriali * @param the type of the field elements * @return the cross product v1 ^ v2 as a new Vector */ - public static > FieldVector3D crossProduct(final Vector3D v1, + public static > FieldVector3D crossProduct(final Vector3D v1, final FieldVector3D v2) { return new FieldVector3D(v2.x.linearCombination(v1.getY(), v2.z, -v1.getZ(), v2.y), v2.y.linearCombination(v1.getZ(), v2.x, -v1.getX(), v2.z), @@ -1008,7 +1008,7 @@ public class FieldVector3D> implements Seriali * @param the type of the field elements * @return the distance between v1 and v2 according to the L1 norm */ - public static > T distance1(final FieldVector3D v1, + public static > T distance1(final FieldVector3D v1, final FieldVector3D v2) { return v1.distance1(v2); } @@ -1022,7 +1022,7 @@ public class FieldVector3D> implements Seriali * @param the type of the field elements * @return the distance between v1 and v2 according to the L1 norm */ - public static > T distance1(final FieldVector3D v1, + public static > T distance1(final FieldVector3D v1, final Vector3D v2) { return v1.distance1(v2); } @@ -1036,7 +1036,7 @@ public class FieldVector3D> implements Seriali * @param the type of the field elements * @return the distance between v1 and v2 according to the L1 norm */ - public static > T distance1(final Vector3D v1, + public static > T distance1(final Vector3D v1, final FieldVector3D v2) { return v2.distance1(v1); } @@ -1050,7 +1050,7 @@ public class FieldVector3D> implements Seriali * @param the type of the field elements * @return the distance between v1 and v2 according to the L2 norm */ - public static > T distance(final FieldVector3D v1, + public static > T distance(final FieldVector3D v1, final FieldVector3D v2) { return v1.distance(v2); } @@ -1064,7 +1064,7 @@ public class FieldVector3D> implements Seriali * @param the type of the field elements * @return the distance between v1 and v2 according to the L2 norm */ - public static > T distance(final FieldVector3D v1, + public static > T distance(final FieldVector3D v1, final Vector3D v2) { return v1.distance(v2); } @@ -1078,7 +1078,7 @@ public class FieldVector3D> implements Seriali * @param the type of the field elements * @return the distance between v1 and v2 according to the L2 norm */ - public static > T distance(final Vector3D v1, + public static > T distance(final Vector3D v1, final FieldVector3D v2) { return v2.distance(v1); } @@ -1092,7 +1092,7 @@ public class FieldVector3D> implements Seriali * @param the type of the field elements * @return the distance between v1 and v2 according to the L norm */ - public static > T distanceInf(final FieldVector3D v1, + public static > T distanceInf(final FieldVector3D v1, final FieldVector3D v2) { return v1.distanceInf(v2); } @@ -1106,7 +1106,7 @@ public class FieldVector3D> implements Seriali * @param the type of the field elements * @return the distance between v1 and v2 according to the L norm */ - public static > T distanceInf(final FieldVector3D v1, + public static > T distanceInf(final FieldVector3D v1, final Vector3D v2) { return v1.distanceInf(v2); } @@ -1120,7 +1120,7 @@ public class FieldVector3D> implements Seriali * @param the type of the field elements * @return the distance between v1 and v2 according to the L norm */ - public static > T distanceInf(final Vector3D v1, + public static > T distanceInf(final Vector3D v1, final FieldVector3D v2) { return v2.distanceInf(v1); } @@ -1134,7 +1134,7 @@ public class FieldVector3D> implements Seriali * @param the type of the field elements * @return the square of the distance between v1 and v2 */ - public static > T distanceSq(final FieldVector3D v1, + public static > T distanceSq(final FieldVector3D v1, final FieldVector3D v2) { return v1.distanceSq(v2); } @@ -1148,7 +1148,7 @@ public class FieldVector3D> implements Seriali * @param the type of the field elements * @return the square of the distance between v1 and v2 */ - public static > T distanceSq(final FieldVector3D v1, + public static > T distanceSq(final FieldVector3D v1, final Vector3D v2) { return v1.distanceSq(v2); } @@ -1162,7 +1162,7 @@ public class FieldVector3D> implements Seriali * @param the type of the field elements * @return the square of the distance between v1 and v2 */ - public static > T distanceSq(final Vector3D v1, + public static > T distanceSq(final Vector3D v1, final FieldVector3D v2) { return v2.distanceSq(v1); } diff --git a/src/main/java/org/apache/commons/math3/util/Decimal64.java b/src/main/java/org/apache/commons/math3/util/Decimal64.java index 19aa7a1e3..f3cc616da 100644 --- a/src/main/java/org/apache/commons/math3/util/Decimal64.java +++ b/src/main/java/org/apache/commons/math3/util/Decimal64.java @@ -16,20 +16,20 @@ */ package org.apache.commons.math3.util; -import org.apache.commons.math3.ExtendedFieldElement; +import org.apache.commons.math3.RealFieldElement; import org.apache.commons.math3.Field; import org.apache.commons.math3.exception.DimensionMismatchException; /** * This class wraps a {@code double} value in an object. It is similar to the * standard class {@link Double}, while also implementing the - * {@link ExtendedFieldElement} interface. + * {@link RealFieldElement} interface. * * @since 3.1 * @version $Id$ */ public class Decimal64 extends Number - implements ExtendedFieldElement, Comparable { + implements RealFieldElement, Comparable { /** The constant value of {@code 0d} as a {@code Decimal64}. */ public static final Decimal64 ZERO; diff --git a/src/test/java/org/apache/commons/math3/ExtendedFieldElementAbstractTest.java b/src/test/java/org/apache/commons/math3/ExtendedFieldElementAbstractTest.java index 2475a180c..fab4618b9 100644 --- a/src/test/java/org/apache/commons/math3/ExtendedFieldElementAbstractTest.java +++ b/src/test/java/org/apache/commons/math3/ExtendedFieldElementAbstractTest.java @@ -23,7 +23,7 @@ import org.apache.commons.math3.util.MathArrays; import org.junit.Assert; import org.junit.Test; -public abstract class ExtendedFieldElementAbstractTest> { +public abstract class ExtendedFieldElementAbstractTest> { protected abstract T build(double x);