Renamed ExtendedFieldElement into RealFieldElement.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1454903 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Luc Maisonobe 2013-03-10 19:44:31 +00:00
parent a51119c013
commit dc8b1f4ac5
8 changed files with 52 additions and 52 deletions

View File

@ -81,10 +81,10 @@ This is a minor release: It combines bug fixes and new features.
behave across events in ODE events detection.
</action>
<action dev="luc" type="add" >
Added Hermite interpolator for ExtendFieldElement instances.
Added Hermite interpolator for RealFieldElement instances.
</action>
<action dev="luc" type="add" >
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.
</action>
<action dev="luc" type="add" >

View File

@ -29,7 +29,7 @@ import org.apache.commons.math3.exception.DimensionMismatchException;
* @version $Id$
* @since 3.2
*/
public interface ExtendedFieldElement<T> extends FieldElement<T> {
public interface RealFieldElement<T> extends FieldElement<T> {
/** Get the real value of the number.
* @return real value

View File

@ -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<DerivativeStructure>, Serializable {
public class DerivativeStructure implements RealFieldElement<DerivativeStructure>, Serializable {
/** Serializable UID. */
private static final long serialVersionUID = 20120730L;

View File

@ -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<Dfp> {
public class Dfp implements RealFieldElement<Dfp> {
/** The radix, or base of this system. Set to 10000 */
public static final int RADIX = 10000;

View File

@ -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}.
* <p>Instance of this class are guaranteed to be immutable.</p>
*
* @param <T> the type of the field elements
@ -38,7 +38,7 @@ import org.apache.commons.math3.util.MathArrays;
* @since 3.2
*/
public class FieldRotation<T extends ExtendedFieldElement<T>> implements Serializable {
public class FieldRotation<T extends RealFieldElement<T>> implements Serializable {
/** Serializable version identifier */
private static final long serialVersionUID = 20130224l;
@ -425,7 +425,7 @@ public class FieldRotation<T extends ExtendedFieldElement<T>> 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<T> getAxis() {
final T squaredSine = q1.multiply(q1).add(q2.multiply(q2)).add(q3.multiply(q3));
@ -442,7 +442,7 @@ public class FieldRotation<T extends ExtendedFieldElement<T>> implements Seriali
/** Get the angle of the rotation.
* @return angle of the rotation (between 0 and &pi;)
* @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<T extends ExtendedFieldElement<T>> implements Seriali
* @param <T> the type of the field elements
* @return a new vector which is the image of u by the rotation
*/
public static <T extends ExtendedFieldElement<T>> FieldVector3D<T> applyTo(final Rotation r, final FieldVector3D<T> u) {
public static <T extends RealFieldElement<T>> FieldVector3D<T> applyTo(final Rotation r, final FieldVector3D<T> u) {
final T x = u.getX();
final T y = u.getY();
@ -931,7 +931,7 @@ public class FieldRotation<T extends ExtendedFieldElement<T>> implements Seriali
* @param <T> the type of the field elements
* @return a new vector which such that u is its image by the rotation
*/
public static <T extends ExtendedFieldElement<T>> FieldVector3D<T> applyInverseTo(final Rotation r, final FieldVector3D<T> u) {
public static <T extends RealFieldElement<T>> FieldVector3D<T> applyInverseTo(final Rotation r, final FieldVector3D<T> u) {
final T x = u.getX();
final T y = u.getY();
@ -991,7 +991,7 @@ public class FieldRotation<T extends ExtendedFieldElement<T>> implements Seriali
* @param <T> the type of the field elements
* @return a new rotation which is the composition of r by the instance
*/
public static <T extends ExtendedFieldElement<T>> FieldRotation<T> applyTo(final Rotation r1, final FieldRotation<T> rInner) {
public static <T extends RealFieldElement<T>> FieldRotation<T> applyTo(final Rotation r1, final FieldRotation<T> rInner) {
return new FieldRotation<T>(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<T extends ExtendedFieldElement<T>> implements Seriali
* @return a new rotation which is the composition of r by the inverse
* of the instance
*/
public static <T extends ExtendedFieldElement<T>> FieldRotation<T> applyInverseTo(final Rotation rOuter, final FieldRotation<T> rInner) {
public static <T extends RealFieldElement<T>> FieldRotation<T> applyInverseTo(final Rotation rOuter, final FieldRotation<T> rInner) {
return new FieldRotation<T>(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<T extends ExtendedFieldElement<T>> implements Seriali
* @param <T> the type of the field elements
* @return <i>distance</i> between r1 and r2
*/
public static <T extends ExtendedFieldElement<T>> T distance(final FieldRotation<T> r1, final FieldRotation<T> r2) {
public static <T extends RealFieldElement<T>> T distance(final FieldRotation<T> r1, final FieldRotation<T> r2) {
return r1.applyInverseTo(r2).getAngle();
}

View File

@ -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}.
* <p>Instance of this class are guaranteed to be immutable.</p>
* @param <T> the type of the field elements
* @version $Id$
* @since 3.2
*/
public class FieldVector3D<T extends ExtendedFieldElement<T>> implements Serializable {
public class FieldVector3D<T extends RealFieldElement<T>> implements Serializable {
/** Serializable version identifier. */
private static final long serialVersionUID = 20130224L;
@ -302,7 +302,7 @@ public class FieldVector3D<T extends ExtendedFieldElement<T>> 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<T extends ExtendedFieldElement<T>> 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<T extends ExtendedFieldElement<T>> 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<T extends ExtendedFieldElement<T>> 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<T extends ExtendedFieldElement<T>> implements Seriali
/** Get the azimuth of the vector.
* @return azimuth (&alpha;) of the vector, between -&pi; and +&pi;
* @see #FieldVector3D(ExtendedFieldElement, ExtendedFieldElement)
* @see #FieldVector3D(RealFieldElement, RealFieldElement)
*/
public T getAlpha() {
return y.atan2(x);
@ -398,7 +398,7 @@ public class FieldVector3D<T extends ExtendedFieldElement<T>> implements Seriali
/** Get the elevation of the vector.
* @return elevation (&delta;) of the vector, between -&pi;/2 and +&pi;/2
* @see #FieldVector3D(ExtendedFieldElement, ExtendedFieldElement)
* @see #FieldVector3D(RealFieldElement, RealFieldElement)
*/
public T getDelta() {
return z.divide(getNorm()).asin();
@ -575,7 +575,7 @@ public class FieldVector3D<T extends ExtendedFieldElement<T>> implements Seriali
* @return angular separation between v1 and v2
* @exception MathArithmeticException if either vector has a null norm
*/
public static <T extends ExtendedFieldElement<T>> T angle(final FieldVector3D<T> v1, final FieldVector3D<T> v2)
public static <T extends RealFieldElement<T>> T angle(final FieldVector3D<T> v1, final FieldVector3D<T> v2)
throws MathArithmeticException {
final T normProduct = v1.getNorm().multiply(v2.getNorm());
@ -611,7 +611,7 @@ public class FieldVector3D<T extends ExtendedFieldElement<T>> implements Seriali
* @return angular separation between v1 and v2
* @exception MathArithmeticException if either vector has a null norm
*/
public static <T extends ExtendedFieldElement<T>> T angle(final FieldVector3D<T> v1, final Vector3D v2)
public static <T extends RealFieldElement<T>> T angle(final FieldVector3D<T> v1, final Vector3D v2)
throws MathArithmeticException {
final T normProduct = v1.getNorm().multiply(v2.getNorm());
@ -647,7 +647,7 @@ public class FieldVector3D<T extends ExtendedFieldElement<T>> implements Seriali
* @return angular separation between v1 and v2
* @exception MathArithmeticException if either vector has a null norm
*/
public static <T extends ExtendedFieldElement<T>> T angle(final Vector3D v1, final FieldVector3D<T> v2)
public static <T extends RealFieldElement<T>> T angle(final Vector3D v1, final FieldVector3D<T> v2)
throws MathArithmeticException {
return angle(v2, v1);
}
@ -697,7 +697,7 @@ public class FieldVector3D<T extends ExtendedFieldElement<T>> implements Seriali
* Test for the equality of two 3D vectors.
* <p>
* If all coordinates of two 3D vectors are exactly the same, and none of their
* {@link ExtendedFieldElement#getReal() real part} are <code>NaN</code>, the
* {@link RealFieldElement#getReal() real part} are <code>NaN</code>, the
* two 3D vectors are considered to be equal.
* </p>
* <p>
@ -937,7 +937,7 @@ public class FieldVector3D<T extends ExtendedFieldElement<T>> implements Seriali
* @param <T> the type of the field elements
* @return the dot product v1.v2
*/
public static <T extends ExtendedFieldElement<T>> T dotProduct(final FieldVector3D<T> v1,
public static <T extends RealFieldElement<T>> T dotProduct(final FieldVector3D<T> v1,
final FieldVector3D<T> v2) {
return v1.dotProduct(v2);
}
@ -948,7 +948,7 @@ public class FieldVector3D<T extends ExtendedFieldElement<T>> implements Seriali
* @param <T> the type of the field elements
* @return the dot product v1.v2
*/
public static <T extends ExtendedFieldElement<T>> T dotProduct(final FieldVector3D<T> v1,
public static <T extends RealFieldElement<T>> T dotProduct(final FieldVector3D<T> v1,
final Vector3D v2) {
return v1.dotProduct(v2);
}
@ -959,7 +959,7 @@ public class FieldVector3D<T extends ExtendedFieldElement<T>> implements Seriali
* @param <T> the type of the field elements
* @return the dot product v1.v2
*/
public static <T extends ExtendedFieldElement<T>> T dotProduct(final Vector3D v1,
public static <T extends RealFieldElement<T>> T dotProduct(final Vector3D v1,
final FieldVector3D<T> v2) {
return v2.dotProduct(v1);
}
@ -970,7 +970,7 @@ public class FieldVector3D<T extends ExtendedFieldElement<T>> implements Seriali
* @param <T> the type of the field elements
* @return the cross product v1 ^ v2 as a new Vector
*/
public static <T extends ExtendedFieldElement<T>> FieldVector3D<T> crossProduct(final FieldVector3D<T> v1,
public static <T extends RealFieldElement<T>> FieldVector3D<T> crossProduct(final FieldVector3D<T> v1,
final FieldVector3D<T> v2) {
return v1.crossProduct(v2);
}
@ -981,7 +981,7 @@ public class FieldVector3D<T extends ExtendedFieldElement<T>> implements Seriali
* @param <T> the type of the field elements
* @return the cross product v1 ^ v2 as a new Vector
*/
public static <T extends ExtendedFieldElement<T>> FieldVector3D<T> crossProduct(final FieldVector3D<T> v1,
public static <T extends RealFieldElement<T>> FieldVector3D<T> crossProduct(final FieldVector3D<T> v1,
final Vector3D v2) {
return v1.crossProduct(v2);
}
@ -992,7 +992,7 @@ public class FieldVector3D<T extends ExtendedFieldElement<T>> implements Seriali
* @param <T> the type of the field elements
* @return the cross product v1 ^ v2 as a new Vector
*/
public static <T extends ExtendedFieldElement<T>> FieldVector3D<T> crossProduct(final Vector3D v1,
public static <T extends RealFieldElement<T>> FieldVector3D<T> crossProduct(final Vector3D v1,
final FieldVector3D<T> v2) {
return new FieldVector3D<T>(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<T extends ExtendedFieldElement<T>> implements Seriali
* @param <T> the type of the field elements
* @return the distance between v1 and v2 according to the L<sub>1</sub> norm
*/
public static <T extends ExtendedFieldElement<T>> T distance1(final FieldVector3D<T> v1,
public static <T extends RealFieldElement<T>> T distance1(final FieldVector3D<T> v1,
final FieldVector3D<T> v2) {
return v1.distance1(v2);
}
@ -1022,7 +1022,7 @@ public class FieldVector3D<T extends ExtendedFieldElement<T>> implements Seriali
* @param <T> the type of the field elements
* @return the distance between v1 and v2 according to the L<sub>1</sub> norm
*/
public static <T extends ExtendedFieldElement<T>> T distance1(final FieldVector3D<T> v1,
public static <T extends RealFieldElement<T>> T distance1(final FieldVector3D<T> v1,
final Vector3D v2) {
return v1.distance1(v2);
}
@ -1036,7 +1036,7 @@ public class FieldVector3D<T extends ExtendedFieldElement<T>> implements Seriali
* @param <T> the type of the field elements
* @return the distance between v1 and v2 according to the L<sub>1</sub> norm
*/
public static <T extends ExtendedFieldElement<T>> T distance1(final Vector3D v1,
public static <T extends RealFieldElement<T>> T distance1(final Vector3D v1,
final FieldVector3D<T> v2) {
return v2.distance1(v1);
}
@ -1050,7 +1050,7 @@ public class FieldVector3D<T extends ExtendedFieldElement<T>> implements Seriali
* @param <T> the type of the field elements
* @return the distance between v1 and v2 according to the L<sub>2</sub> norm
*/
public static <T extends ExtendedFieldElement<T>> T distance(final FieldVector3D<T> v1,
public static <T extends RealFieldElement<T>> T distance(final FieldVector3D<T> v1,
final FieldVector3D<T> v2) {
return v1.distance(v2);
}
@ -1064,7 +1064,7 @@ public class FieldVector3D<T extends ExtendedFieldElement<T>> implements Seriali
* @param <T> the type of the field elements
* @return the distance between v1 and v2 according to the L<sub>2</sub> norm
*/
public static <T extends ExtendedFieldElement<T>> T distance(final FieldVector3D<T> v1,
public static <T extends RealFieldElement<T>> T distance(final FieldVector3D<T> v1,
final Vector3D v2) {
return v1.distance(v2);
}
@ -1078,7 +1078,7 @@ public class FieldVector3D<T extends ExtendedFieldElement<T>> implements Seriali
* @param <T> the type of the field elements
* @return the distance between v1 and v2 according to the L<sub>2</sub> norm
*/
public static <T extends ExtendedFieldElement<T>> T distance(final Vector3D v1,
public static <T extends RealFieldElement<T>> T distance(final Vector3D v1,
final FieldVector3D<T> v2) {
return v2.distance(v1);
}
@ -1092,7 +1092,7 @@ public class FieldVector3D<T extends ExtendedFieldElement<T>> implements Seriali
* @param <T> the type of the field elements
* @return the distance between v1 and v2 according to the L<sub>&infin;</sub> norm
*/
public static <T extends ExtendedFieldElement<T>> T distanceInf(final FieldVector3D<T> v1,
public static <T extends RealFieldElement<T>> T distanceInf(final FieldVector3D<T> v1,
final FieldVector3D<T> v2) {
return v1.distanceInf(v2);
}
@ -1106,7 +1106,7 @@ public class FieldVector3D<T extends ExtendedFieldElement<T>> implements Seriali
* @param <T> the type of the field elements
* @return the distance between v1 and v2 according to the L<sub>&infin;</sub> norm
*/
public static <T extends ExtendedFieldElement<T>> T distanceInf(final FieldVector3D<T> v1,
public static <T extends RealFieldElement<T>> T distanceInf(final FieldVector3D<T> v1,
final Vector3D v2) {
return v1.distanceInf(v2);
}
@ -1120,7 +1120,7 @@ public class FieldVector3D<T extends ExtendedFieldElement<T>> implements Seriali
* @param <T> the type of the field elements
* @return the distance between v1 and v2 according to the L<sub>&infin;</sub> norm
*/
public static <T extends ExtendedFieldElement<T>> T distanceInf(final Vector3D v1,
public static <T extends RealFieldElement<T>> T distanceInf(final Vector3D v1,
final FieldVector3D<T> v2) {
return v2.distanceInf(v1);
}
@ -1134,7 +1134,7 @@ public class FieldVector3D<T extends ExtendedFieldElement<T>> implements Seriali
* @param <T> the type of the field elements
* @return the square of the distance between v1 and v2
*/
public static <T extends ExtendedFieldElement<T>> T distanceSq(final FieldVector3D<T> v1,
public static <T extends RealFieldElement<T>> T distanceSq(final FieldVector3D<T> v1,
final FieldVector3D<T> v2) {
return v1.distanceSq(v2);
}
@ -1148,7 +1148,7 @@ public class FieldVector3D<T extends ExtendedFieldElement<T>> implements Seriali
* @param <T> the type of the field elements
* @return the square of the distance between v1 and v2
*/
public static <T extends ExtendedFieldElement<T>> T distanceSq(final FieldVector3D<T> v1,
public static <T extends RealFieldElement<T>> T distanceSq(final FieldVector3D<T> v1,
final Vector3D v2) {
return v1.distanceSq(v2);
}
@ -1162,7 +1162,7 @@ public class FieldVector3D<T extends ExtendedFieldElement<T>> implements Seriali
* @param <T> the type of the field elements
* @return the square of the distance between v1 and v2
*/
public static <T extends ExtendedFieldElement<T>> T distanceSq(final Vector3D v1,
public static <T extends RealFieldElement<T>> T distanceSq(final Vector3D v1,
final FieldVector3D<T> v2) {
return v2.distanceSq(v1);
}

View File

@ -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<Decimal64>, Comparable<Decimal64> {
implements RealFieldElement<Decimal64>, Comparable<Decimal64> {
/** The constant value of {@code 0d} as a {@code Decimal64}. */
public static final Decimal64 ZERO;

View File

@ -23,7 +23,7 @@ import org.apache.commons.math3.util.MathArrays;
import org.junit.Assert;
import org.junit.Test;
public abstract class ExtendedFieldElementAbstractTest<T extends ExtendedFieldElement<T>> {
public abstract class ExtendedFieldElementAbstractTest<T extends RealFieldElement<T>> {
protected abstract T build(double x);