From 3ad5595706a90adc920105b5c486e4fc0db6d497 Mon Sep 17 00:00:00 2001 From: Luc Maisonobe Date: Mon, 11 Mar 2013 08:37:12 +0000 Subject: [PATCH] Removed the log10 declaration in RealFieldElement interface. This method introduced a binary incompatibility as one implementing class (Dfp) did not have the proper return type and had to be changed. The method will be added back in the interface for 4.0, when it will be allowed to change the return type for Dfp. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1455053 13f79535-47bb-0310-9956-ffa450edef68 --- .../commons/math3/RealFieldElement.java | 10 ++++++---- .../differentiation/DerivativeStructure.java | 4 +++- .../org/apache/commons/math3/dfp/Dfp.java | 20 +++++++++++++++---- .../apache/commons/math3/util/Decimal64.java | 4 +++- .../ExtendedFieldElementAbstractTest.java | 14 +++++++------ 5 files changed, 36 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/apache/commons/math3/RealFieldElement.java b/src/main/java/org/apache/commons/math3/RealFieldElement.java index e9d041f53..420eca40f 100644 --- a/src/main/java/org/apache/commons/math3/RealFieldElement.java +++ b/src/main/java/org/apache/commons/math3/RealFieldElement.java @@ -205,10 +205,12 @@ public interface RealFieldElement extends FieldElement { */ T log1p(); - /** Base 10 logarithm. - * @return base 10 logarithm of the instance - */ - T log10(); +// TODO: add this method in 4.0, as it is not possible to do it in 3.2 +// due to incompatibility of the return type in the Dfp class +// /** Base 10 logarithm. +// * @return base 10 logarithm of the instance +// */ +// T log10(); /** Cosine operation. * @return cos(this) 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 fef9a42b0..dd7f98e42 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 @@ -621,7 +621,9 @@ public class DerivativeStructure implements RealFieldElement { return DfpMath.log(this.add(getOne())); } - /** {@inheritDoc} - * @since 3.2 +// TODO: deactivate this implementation (and return type) in 4.0 + /** Get the exponent of the greatest power of 10 that is less than or equal to abs(this). + * @return integer base 10 logarithm + * @deprecated as of 3.2, replaced by {@link #intLog10()}, in 4.0 the return type + * will be changed to Dfp */ - public Dfp log10() { - return DfpMath.log(this).divide(DfpMath.log(newInstance(10))); + @Deprecated + public int log10() { + return intLog10(); } +// TODO: activate this implementation (and return type) in 4.0 +// /** {@inheritDoc} +// * @since 3.2 +// */ +// public Dfp log10() { +// return DfpMath.log(this).divide(DfpMath.log(newInstance(10))); +// } + /** {@inheritDoc} * @since 3.2 */ 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 f3cc616da..1e3e12fe1 100644 --- a/src/main/java/org/apache/commons/math3/util/Decimal64.java +++ b/src/main/java/org/apache/commons/math3/util/Decimal64.java @@ -442,7 +442,9 @@ public class Decimal64 extends Number return new Decimal64(FastMath.log1p(value)); } - /** {@inheritDoc} */ + /** Base 10 logarithm. + * @return base 10 logarithm of the instance + */ public Decimal64 log10() { return new Decimal64(FastMath.log10(value)); } diff --git a/src/test/java/org/apache/commons/math3/ExtendedFieldElementAbstractTest.java b/src/test/java/org/apache/commons/math3/ExtendedFieldElementAbstractTest.java index fab4618b9..76e9cd548 100644 --- a/src/test/java/org/apache/commons/math3/ExtendedFieldElementAbstractTest.java +++ b/src/test/java/org/apache/commons/math3/ExtendedFieldElementAbstractTest.java @@ -312,12 +312,14 @@ public abstract class ExtendedFieldElementAbstractTest