diff --git a/src/main/java/org/apache/commons/math/linear/AbstractRealVector.java b/src/main/java/org/apache/commons/math/linear/AbstractRealVector.java index 1efc7562c..0b6f0e641 100644 --- a/src/main/java/org/apache/commons/math/linear/AbstractRealVector.java +++ b/src/main/java/org/apache/commons/math/linear/AbstractRealVector.java @@ -23,7 +23,11 @@ import java.util.NoSuchElementException; import org.apache.commons.math.exception.MathUnsupportedOperationException; import org.apache.commons.math.exception.DimensionMismatchException; import org.apache.commons.math.exception.OutOfRangeException; -import org.apache.commons.math.analysis.BinaryFunction; +import org.apache.commons.math.analysis.FunctionUtils; +import org.apache.commons.math.analysis.function.Add; +import org.apache.commons.math.analysis.function.Multiply; +import org.apache.commons.math.analysis.function.Divide; +import org.apache.commons.math.analysis.function.Power; import org.apache.commons.math.analysis.UnivariateRealFunction; import org.apache.commons.math.exception.util.LocalizedFormats; import org.apache.commons.math.util.FastMath; @@ -154,7 +158,7 @@ public abstract class AbstractRealVector implements RealVector { /** {@inheritDoc} */ public RealVector mapAddToSelf(double d) { if (d != 0) { - return mapToSelf(BinaryFunction.ADD.fix1stArgument(d)); + return mapToSelf(FunctionUtils.fix2ndArgument(new Add(), d)); } return this; } @@ -349,7 +353,7 @@ public abstract class AbstractRealVector implements RealVector { /** {@inheritDoc} */ public RealVector mapMultiplyToSelf(double d){ - return mapToSelf(BinaryFunction.MULTIPLY.fix1stArgument(d)); + return mapToSelf(FunctionUtils.fix2ndArgument(new Multiply(), d)); } /** {@inheritDoc} */ @@ -369,7 +373,7 @@ public abstract class AbstractRealVector implements RealVector { /** {@inheritDoc} */ public RealVector mapDivideToSelf(double d){ - return mapToSelf(BinaryFunction.DIVIDE.fix2ndArgument(d)); + return mapToSelf(FunctionUtils.fix2ndArgument(new Divide(), d)); } /** {@inheritDoc} */ @@ -379,7 +383,7 @@ public abstract class AbstractRealVector implements RealVector { /** {@inheritDoc} */ public RealVector mapPowToSelf(double d){ - return mapToSelf(BinaryFunction.POW.fix2ndArgument(d)); + return mapToSelf(new Power(d)); } /** {@inheritDoc} */ diff --git a/src/main/java/org/apache/commons/math/linear/RealVector.java b/src/main/java/org/apache/commons/math/linear/RealVector.java index 27b933947..0ec55cd7a 100644 --- a/src/main/java/org/apache/commons/math/linear/RealVector.java +++ b/src/main/java/org/apache/commons/math/linear/RealVector.java @@ -19,7 +19,6 @@ package org.apache.commons.math.linear; import java.util.Iterator; import org.apache.commons.math.analysis.UnivariateRealFunction; -import org.apache.commons.math.exception.MathUserException; /** @@ -57,9 +56,10 @@ public interface RealVector { * * @param function Function to apply to each entry. * @return this vector. - * @throws MathUserException if the function throws it. + * @throws org.apache.commons.math.exception.MathUserException + * if the function throws it. */ - RealVector mapToSelf(UnivariateRealFunction function) throws MathUserException; + RealVector mapToSelf(UnivariateRealFunction function); /** * Acts as if implemented as: @@ -67,11 +67,12 @@ public interface RealVector { * return copy().map(function); * * - * @param function Functin to apply to each entry. + * @param function Function to apply to each entry. * @return a new vector. - * @throws MathUserException if the function throws it. + * @throws org.apache.commons.math.exception.MathUserException + * if the function throws it. */ - RealVector map(UnivariateRealFunction function) throws MathUserException; + RealVector map(UnivariateRealFunction function); /** Class representing a modifiable entry in the vector. */ public abstract class Entry {