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
This commit is contained in:
Luc Maisonobe 2013-03-11 08:37:12 +00:00
parent 9d5715114c
commit 3ad5595706
5 changed files with 36 additions and 16 deletions

View File

@ -205,10 +205,12 @@ public interface RealFieldElement<T> extends FieldElement<T> {
*/ */
T log1p(); T log1p();
/** Base 10 logarithm. // TODO: add this method in 4.0, as it is not possible to do it in 3.2
* @return base 10 logarithm of the instance // due to incompatibility of the return type in the Dfp class
*/ // /** Base 10 logarithm.
T log10(); // * @return base 10 logarithm of the instance
// */
// T log10();
/** Cosine operation. /** Cosine operation.
* @return cos(this) * @return cos(this)

View File

@ -621,7 +621,9 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
return result; return result;
} }
/** {@inheritDoc} */ /** Base 10 logarithm.
* @return base 10 logarithm of the instance
*/
public DerivativeStructure log10() { public DerivativeStructure log10() {
final DerivativeStructure result = new DerivativeStructure(compiler); final DerivativeStructure result = new DerivativeStructure(compiler);
compiler.log10(data, 0, result.data, 0); compiler.log10(data, 0, result.data, 0);

View File

@ -2665,13 +2665,25 @@ public class Dfp implements RealFieldElement<Dfp> {
return DfpMath.log(this.add(getOne())); return DfpMath.log(this.add(getOne()));
} }
/** {@inheritDoc} // TODO: deactivate this implementation (and return type) in 4.0
* @since 3.2 /** 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() { @Deprecated
return DfpMath.log(this).divide(DfpMath.log(newInstance(10))); 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} /** {@inheritDoc}
* @since 3.2 * @since 3.2
*/ */

View File

@ -442,7 +442,9 @@ public class Decimal64 extends Number
return new Decimal64(FastMath.log1p(value)); return new Decimal64(FastMath.log1p(value));
} }
/** {@inheritDoc} */ /** Base 10 logarithm.
* @return base 10 logarithm of the instance
*/
public Decimal64 log10() { public Decimal64 log10() {
return new Decimal64(FastMath.log10(value)); return new Decimal64(FastMath.log10(value));
} }

View File

@ -312,12 +312,14 @@ public abstract class ExtendedFieldElementAbstractTest<T extends RealFieldElemen
} }
} }
@Test // TODO: add this test in 4.0, as it is not possible to do it in 3.2
public void testLog10() { // due to incompatibility of the return type in the Dfp class
for (double x = -0.9; x < 0.9; x += 0.05) { // @Test
checkRelative(FastMath.log10(x), build(x).log10()); // public void testLog10() {
} // for (double x = -0.9; x < 0.9; x += 0.05) {
} // checkRelative(FastMath.log10(x), build(x).log10());
// }
// }
@Test @Test
public void testAbs() { public void testAbs() {