Removed Java6 @Override annotations.

@Override is needed in Java6 when implementing an interface, but is
allowed only when overriding a previous implementation in Java5. Apache
Commons Math currently targets Java5, so these annotations were
spurious.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1536082 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Luc Maisonobe 2013-10-27 10:10:16 +00:00
parent c528afa780
commit 4b6b25d558
1 changed files with 4 additions and 52 deletions

View File

@ -34,7 +34,7 @@ import org.apache.commons.math3.util.Precision;
* First derivative computation with large number of variables. * First derivative computation with large number of variables.
* <p> * <p>
* This class plays a similar role to {@link DerivativeStructure}, with * This class plays a similar role to {@link DerivativeStructure}, with
* a focus on efficiency when dealing with large numer of independent variables * a focus on efficiency when dealing with large number of independent variables
* and most computation depend only on a few of them, and when only first derivative * and most computation depend only on a few of them, and when only first derivative
* is desired. When these conditions are met, this class should be much faster than * is desired. When these conditions are met, this class should be much faster than
* {@link DerivativeStructure} and use less memory. * {@link DerivativeStructure} and use less memory.
@ -70,7 +70,7 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
/** Internal constructor. /** Internal constructor.
* @param value value of the function * @param value value of the function
* @param scale scaling factor to apply to all deerivatives * @param scale scaling factor to apply to all derivatives
* @param derivatives derivatives map, a deep copy will be performed, * @param derivatives derivatives map, a deep copy will be performed,
* so the map given here will remain safe from changes in the new instance, * so the map given here will remain safe from changes in the new instance,
* may be null to create an empty derivatives map, i.e. a constant value * may be null to create an empty derivatives map, i.e. a constant value
@ -131,7 +131,6 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public double getReal() { public double getReal() {
return value; return value;
} }
@ -259,7 +258,6 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SparseGradient multiply(final int n) { public SparseGradient multiply(final int n) {
return new SparseGradient(value * n, n, derivatives); return new SparseGradient(value * n, n, derivatives);
} }
@ -290,13 +288,11 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SparseGradient negate() { public SparseGradient negate() {
return new SparseGradient(-value, -1.0, derivatives); return new SparseGradient(-value, -1.0, derivatives);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public Field<SparseGradient> getField() { public Field<SparseGradient> getField() {
return new Field<SparseGradient>() { return new Field<SparseGradient>() {
@ -319,13 +315,11 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SparseGradient remainder(final double a) { public SparseGradient remainder(final double a) {
return new SparseGradient(FastMath.IEEEremainder(value, a), derivatives); return new SparseGradient(FastMath.IEEEremainder(value, a), derivatives);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SparseGradient remainder(final SparseGradient a) { public SparseGradient remainder(final SparseGradient a) {
// compute k such that lhs % rhs = lhs - k rhs // compute k such that lhs % rhs = lhs - k rhs
@ -337,7 +331,6 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SparseGradient abs() { public SparseGradient abs() {
if (Double.doubleToLongBits(value) < 0) { if (Double.doubleToLongBits(value) < 0) {
// we use the bits representation to also handle -0.0 // we use the bits representation to also handle -0.0
@ -348,37 +341,31 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SparseGradient ceil() { public SparseGradient ceil() {
return createConstant(FastMath.ceil(value)); return createConstant(FastMath.ceil(value));
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SparseGradient floor() { public SparseGradient floor() {
return createConstant(FastMath.floor(value)); return createConstant(FastMath.floor(value));
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SparseGradient rint() { public SparseGradient rint() {
return createConstant(FastMath.rint(value)); return createConstant(FastMath.rint(value));
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public long round() { public long round() {
return FastMath.round(value); return FastMath.round(value);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SparseGradient signum() { public SparseGradient signum() {
return createConstant(FastMath.signum(value)); return createConstant(FastMath.signum(value));
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SparseGradient copySign(final SparseGradient sign) { public SparseGradient copySign(final SparseGradient sign) {
final long m = Double.doubleToLongBits(value); final long m = Double.doubleToLongBits(value);
final long s = Double.doubleToLongBits(sign.value); final long s = Double.doubleToLongBits(sign.value);
@ -389,7 +376,6 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SparseGradient copySign(final double sign) { public SparseGradient copySign(final double sign) {
final long m = Double.doubleToLongBits(value); final long m = Double.doubleToLongBits(value);
final long s = Double.doubleToLongBits(sign); final long s = Double.doubleToLongBits(sign);
@ -400,7 +386,6 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SparseGradient scalb(final int n) { public SparseGradient scalb(final int n) {
final SparseGradient out = new SparseGradient(FastMath.scalb(value, n), Collections.<Integer, Double> emptyMap()); final SparseGradient out = new SparseGradient(FastMath.scalb(value, n), Collections.<Integer, Double> emptyMap());
for (Map.Entry<Integer, Double> entry : derivatives.entrySet()) { for (Map.Entry<Integer, Double> entry : derivatives.entrySet()) {
@ -410,7 +395,6 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SparseGradient hypot(final SparseGradient y) { public SparseGradient hypot(final SparseGradient y) {
if (Double.isInfinite(value) || Double.isInfinite(y.value)) { if (Double.isInfinite(value) || Double.isInfinite(y.value)) {
return createConstant(Double.POSITIVE_INFINITY); return createConstant(Double.POSITIVE_INFINITY);
@ -421,10 +405,10 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
final int expX = FastMath.getExponent(value); final int expX = FastMath.getExponent(value);
final int expY = FastMath.getExponent(y.value); final int expY = FastMath.getExponent(y.value);
if (expX > expY + 27) { if (expX > expY + 27) {
// y is neglectible with respect to x // y is negligible with respect to x
return abs(); return abs();
} else if (expY > expX + 27) { } else if (expY > expX + 27) {
// x is neglectible with respect to y // x is negligible with respect to y
return y.abs(); return y.abs();
} else { } else {
@ -466,27 +450,23 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SparseGradient reciprocal() { public SparseGradient reciprocal() {
return new SparseGradient(1.0 / value, -1.0 / (value * value), derivatives); return new SparseGradient(1.0 / value, -1.0 / (value * value), derivatives);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SparseGradient sqrt() { public SparseGradient sqrt() {
final double sqrt = FastMath.sqrt(value); final double sqrt = FastMath.sqrt(value);
return new SparseGradient(sqrt, 0.5 / sqrt, derivatives); return new SparseGradient(sqrt, 0.5 / sqrt, derivatives);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SparseGradient cbrt() { public SparseGradient cbrt() {
final double cbrt = FastMath.cbrt(value); final double cbrt = FastMath.cbrt(value);
return new SparseGradient(cbrt, 1.0 / (3 * cbrt * cbrt), derivatives); return new SparseGradient(cbrt, 1.0 / (3 * cbrt * cbrt), derivatives);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SparseGradient rootN(final int n) { public SparseGradient rootN(final int n) {
if (n == 2) { if (n == 2) {
return sqrt(); return sqrt();
@ -499,13 +479,11 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SparseGradient pow(final double p) { public SparseGradient pow(final double p) {
return new SparseGradient(FastMath.pow(value, p), p * FastMath.pow(value, p - 1), derivatives); return new SparseGradient(FastMath.pow(value, p), p * FastMath.pow(value, p - 1), derivatives);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SparseGradient pow(final int n) { public SparseGradient pow(final int n) {
if (n == 0) { if (n == 0) {
return getField().getOne(); return getField().getOne();
@ -516,7 +494,6 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SparseGradient pow(final SparseGradient e) { public SparseGradient pow(final SparseGradient e) {
return log().multiply(e).exp(); return log().multiply(e).exp();
} }
@ -542,20 +519,17 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SparseGradient exp() { public SparseGradient exp() {
final double e = FastMath.exp(value); final double e = FastMath.exp(value);
return new SparseGradient(e, e, derivatives); return new SparseGradient(e, e, derivatives);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SparseGradient expm1() { public SparseGradient expm1() {
return new SparseGradient(FastMath.expm1(value), FastMath.exp(value), derivatives); return new SparseGradient(FastMath.expm1(value), FastMath.exp(value), derivatives);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SparseGradient log() { public SparseGradient log() {
return new SparseGradient(FastMath.log(value), 1.0 / value, derivatives); return new SparseGradient(FastMath.log(value), 1.0 / value, derivatives);
} }
@ -568,50 +542,42 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SparseGradient log1p() { public SparseGradient log1p() {
return new SparseGradient(FastMath.log1p(value), 1.0 / (1.0 + value), derivatives); return new SparseGradient(FastMath.log1p(value), 1.0 / (1.0 + value), derivatives);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SparseGradient cos() { public SparseGradient cos() {
return new SparseGradient(FastMath.cos(value), -FastMath.sin(value), derivatives); return new SparseGradient(FastMath.cos(value), -FastMath.sin(value), derivatives);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SparseGradient sin() { public SparseGradient sin() {
return new SparseGradient(FastMath.sin(value), FastMath.cos(value), derivatives); return new SparseGradient(FastMath.sin(value), FastMath.cos(value), derivatives);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SparseGradient tan() { public SparseGradient tan() {
final double t = FastMath.tan(value); final double t = FastMath.tan(value);
return new SparseGradient(t, 1 + t * t, derivatives); return new SparseGradient(t, 1 + t * t, derivatives);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SparseGradient acos() { public SparseGradient acos() {
return new SparseGradient(FastMath.acos(value), -1.0 / FastMath.sqrt(1 - value * value), derivatives); return new SparseGradient(FastMath.acos(value), -1.0 / FastMath.sqrt(1 - value * value), derivatives);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SparseGradient asin() { public SparseGradient asin() {
return new SparseGradient(FastMath.asin(value), 1.0 / FastMath.sqrt(1 - value * value), derivatives); return new SparseGradient(FastMath.asin(value), 1.0 / FastMath.sqrt(1 - value * value), derivatives);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SparseGradient atan() { public SparseGradient atan() {
return new SparseGradient(FastMath.atan(value), 1.0 / (1 + value * value), derivatives); return new SparseGradient(FastMath.atan(value), 1.0 / (1 + value * value), derivatives);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SparseGradient atan2(final SparseGradient x) { public SparseGradient atan2(final SparseGradient x) {
// compute r = sqrt(x^2+y^2) // compute r = sqrt(x^2+y^2)
@ -648,38 +614,32 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SparseGradient cosh() { public SparseGradient cosh() {
return new SparseGradient(FastMath.cosh(value), FastMath.sinh(value), derivatives); return new SparseGradient(FastMath.cosh(value), FastMath.sinh(value), derivatives);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SparseGradient sinh() { public SparseGradient sinh() {
return new SparseGradient(FastMath.sinh(value), FastMath.cosh(value), derivatives); return new SparseGradient(FastMath.sinh(value), FastMath.cosh(value), derivatives);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SparseGradient tanh() { public SparseGradient tanh() {
final double t = FastMath.tanh(value); final double t = FastMath.tanh(value);
return new SparseGradient(t, 1 - t * t, derivatives); return new SparseGradient(t, 1 - t * t, derivatives);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SparseGradient acosh() { public SparseGradient acosh() {
return new SparseGradient(FastMath.acosh(value), 1.0 / FastMath.sqrt(value * value - 1.0), derivatives); return new SparseGradient(FastMath.acosh(value), 1.0 / FastMath.sqrt(value * value - 1.0), derivatives);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SparseGradient asinh() { public SparseGradient asinh() {
return new SparseGradient(FastMath.asinh(value), 1.0 / FastMath.sqrt(value * value + 1.0), derivatives); return new SparseGradient(FastMath.asinh(value), 1.0 / FastMath.sqrt(value * value + 1.0), derivatives);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SparseGradient atanh() { public SparseGradient atanh() {
return new SparseGradient(FastMath.atanh(value), 1.0 / (1.0 - value * value), derivatives); return new SparseGradient(FastMath.atanh(value), 1.0 / (1.0 - value * value), derivatives);
} }
@ -721,7 +681,6 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SparseGradient linearCombination(final SparseGradient[] a, public SparseGradient linearCombination(final SparseGradient[] a,
final SparseGradient[] b) final SparseGradient[] b)
throws DimensionMismatchException { throws DimensionMismatchException {
@ -748,7 +707,6 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SparseGradient linearCombination(final double[] a, final SparseGradient[] b) { public SparseGradient linearCombination(final double[] a, final SparseGradient[] b) {
// compute a simple value, with all partial derivatives // compute a simple value, with all partial derivatives
@ -769,7 +727,6 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SparseGradient linearCombination(final SparseGradient a1, final SparseGradient b1, public SparseGradient linearCombination(final SparseGradient a1, final SparseGradient b1,
final SparseGradient a2, final SparseGradient b2) { final SparseGradient a2, final SparseGradient b2) {
@ -784,7 +741,6 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SparseGradient linearCombination(final double a1, final SparseGradient b1, public SparseGradient linearCombination(final double a1, final SparseGradient b1,
final double a2, final SparseGradient b2) { final double a2, final SparseGradient b2) {
@ -799,7 +755,6 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SparseGradient linearCombination(final SparseGradient a1, final SparseGradient b1, public SparseGradient linearCombination(final SparseGradient a1, final SparseGradient b1,
final SparseGradient a2, final SparseGradient b2, final SparseGradient a2, final SparseGradient b2,
final SparseGradient a3, final SparseGradient b3) { final SparseGradient a3, final SparseGradient b3) {
@ -817,7 +772,6 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SparseGradient linearCombination(final double a1, final SparseGradient b1, public SparseGradient linearCombination(final double a1, final SparseGradient b1,
final double a2, final SparseGradient b2, final double a2, final SparseGradient b2,
final double a3, final SparseGradient b3) { final double a3, final SparseGradient b3) {
@ -835,7 +789,6 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SparseGradient linearCombination(final SparseGradient a1, final SparseGradient b1, public SparseGradient linearCombination(final SparseGradient a1, final SparseGradient b1,
final SparseGradient a2, final SparseGradient b2, final SparseGradient a2, final SparseGradient b2,
final SparseGradient a3, final SparseGradient b3, final SparseGradient a3, final SparseGradient b3,
@ -855,7 +808,6 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SparseGradient linearCombination(final double a1, final SparseGradient b1, public SparseGradient linearCombination(final double a1, final SparseGradient b1,
final double a2, final SparseGradient b2, final double a2, final SparseGradient b2,
final double a3, final SparseGradient b3, final double a3, final SparseGradient b3,